Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc Add strerror_ss_r to be used by syslog_ss
details: https://anonhg.NetBSD.org/src/rev/1d12e2d50b0b
branches: trunk
changeset: 350451:1d12e2d50b0b
user: christos <christos%NetBSD.org@localhost>
date: Thu Jan 12 00:35:38 2017 +0000
description:
Add strerror_ss_r to be used by syslog_ss
diffstat:
lib/libc/include/extern.h | 4 +-
lib/libc/include/namespace.h | 3 +-
lib/libc/string/Makefile.inc | 4 +-
lib/libc/string/strerror_ss.c | 65 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 72 insertions(+), 4 deletions(-)
diffs (121 lines):
diff -r bde1c65459db -r 1d12e2d50b0b lib/libc/include/extern.h
--- a/lib/libc/include/extern.h Wed Jan 11 22:09:38 2017 +0000
+++ b/lib/libc/include/extern.h Thu Jan 12 00:35:38 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.23 2013/08/19 13:03:12 joerg Exp $ */
+/* $NetBSD: extern.h,v 1.24 2017/01/12 00:35:38 christos Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -72,4 +72,6 @@
int _sys_setcontext(const ucontext_t *);
+int strerror_r_ss(int, char *, size_t);
+
__END_DECLS
diff -r bde1c65459db -r 1d12e2d50b0b lib/libc/include/namespace.h
--- a/lib/libc/include/namespace.h Wed Jan 11 22:09:38 2017 +0000
+++ b/lib/libc/include/namespace.h Thu Jan 12 00:35:38 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.182 2016/09/24 21:31:25 christos Exp $ */
+/* $NetBSD: namespace.h,v 1.183 2017/01/12 00:35:38 christos Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -60,6 +60,7 @@
#define sbrk _sbrk
#define strerror_l _strerror_l
#define strerror_r _strerror_r
+#define strerror_r_ss _strerror_r_ss
#define strlcat _strlcat
#define strlcpy _strlcpy
#define strtod_l _strtod_l
diff -r bde1c65459db -r 1d12e2d50b0b lib/libc/string/Makefile.inc
--- a/lib/libc/string/Makefile.inc Wed Jan 11 22:09:38 2017 +0000
+++ b/lib/libc/string/Makefile.inc Thu Jan 12 00:35:38 2017 +0000
@@ -1,5 +1,5 @@
# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-# $NetBSD: Makefile.inc,v 1.82 2016/10/15 14:22:00 kamil Exp $
+# $NetBSD: Makefile.inc,v 1.83 2017/01/12 00:35:38 christos Exp $
# string sources
.PATH: ${ARCHDIR}/string ${.CURDIR}/string
@@ -10,7 +10,7 @@
SRCS+= bm.c stpcpy.c stpncpy.c \
strcasecmp.c strncasecmp.c strcasestr.c strcoll.c strdup.c \
- strerror.c strlcat.c strlcpy.c strnlen.c \
+ strerror.c strerror_ss.c strlcat.c strlcpy.c strnlen.c \
strmode.c strsignal.c strtok.c \
strtok_r.c strxfrm.c __strsignal.c strerror_r.c strndup.c \
stresep.c memrchr.c
diff -r bde1c65459db -r 1d12e2d50b0b lib/libc/string/strerror_ss.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/string/strerror_ss.c Thu Jan 12 00:35:38 2017 +0000
@@ -0,0 +1,65 @@
+/* $NetBSD: strerror_ss.c,v 1.1 2017/01/12 00:35:38 christos Exp $ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: strerror_ss.c,v 1.1 2017/01/12 00:35:38 christos Exp $");
+
+#include "namespace.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "extern.h"
+
+#ifdef __weak_alias
+__weak_alias(strerror_r_ss,_strerror_r_ss)
+#endif
+
+int
+strerror_r_ss(int num, char *buf, size_t len)
+{
+ if (num >= 0 || num < sys_nerr)
+ strlcpy(buf, sys_errlist[num], len);
+ else
+ snprintf_ss(buf, len, "Unknown error %d", num);
+ return 0;
+}
+
+#ifdef notyet
+__aconst char *
+strerror_ss(int num)
+{
+ static char buf[64];
+
+ strerror_r_ss(num, buf, sizeof(buf));
+ return buf;
+}
+#endif
Home |
Main Index |
Thread Index |
Old Index