summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-04-23 20:32:46 +0000
committerkib <kib@FreeBSD.org>2017-04-23 20:32:46 +0000
commitbc743032ad67f907e01ab07b89fa2c5417004333 (patch)
tree0d47e469cd483a5664a7e6aa1e11d412c4523637 /include
parent240392415ab16d458302b3fdfead83d6cfa884e1 (diff)
downloadFreeBSD-src-bc743032ad67f907e01ab07b89fa2c5417004333.zip
FreeBSD-src-bc743032ad67f907e01ab07b89fa2c5417004333.tar.gz
MFC r316213:
Implement the memset_s(3) function as specified by the C11 ISO/IEC 9899:2011 Appendix K 3.7.4.1. MFC r316258: Only activate __EXT1_VISIBLE block when using sys/errno.h in userspace.
Diffstat (limited to 'include')
-rw-r--r--include/stddef.h8
-rw-r--r--include/stdlib.h20
-rw-r--r--include/string.h16
3 files changed, 44 insertions, 0 deletions
diff --git a/include/stddef.h b/include/stddef.h
index fbcb3fb..90baf07 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -72,4 +72,12 @@ typedef __max_align_t max_align_t;
#define offsetof(type, member) __offsetof(type, member)
+#if __EXT1_VISIBLE
+/* ISO/IEC 9899:2011 K.3.3.2 */
+#ifndef _RSIZE_T_DEFINED
+#define _RSIZE_T_DEFINED
+typedef size_t rsize_t;
+#endif
+#endif /* __EXT1_VISIBLE */
+
#endif /* _STDDEF_H_ */
diff --git a/include/stdlib.h b/include/stdlib.h
index 26a2775..eb79404 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -327,6 +327,26 @@ __uint64_t
extern char *suboptarg; /* getsubopt(3) external variable */
#endif /* __BSD_VISIBLE */
+
+#if __EXT1_VISIBLE
+
+#ifndef _ERRNO_T_DEFINED
+#define _ERRNO_T_DEFINED
+typedef int errno_t;
+#endif
+
+/* K.3.6 */
+typedef void (*constraint_handler_t)(const char * __restrict,
+ void * __restrict, errno_t);
+/* K.3.6.1.1 */
+constraint_handler_t set_constraint_handler_s(constraint_handler_t handler);
+/* K.3.6.1.2 */
+_Noreturn void abort_handler_s(const char * __restrict, void * __restrict,
+ errno_t);
+/* K3.6.1.3 */
+void ignore_handler_s(const char * __restrict, void * __restrict, errno_t);
+#endif /* __EXT1_VISIBLE */
+
__END_DECLS
__NULLABILITY_PRAGMA_POP
diff --git a/include/string.h b/include/string.h
index af8b0d4..5ffaabb 100644
--- a/include/string.h
+++ b/include/string.h
@@ -139,6 +139,22 @@ void swab(const void * __restrict, void * __restrict, ssize_t);
#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
#include <xlocale/_string.h>
#endif
+
+#if __EXT1_VISIBLE
+
+#ifndef _RSIZE_T_DEFINED
+#define _RSIZE_T_DEFINED
+typedef size_t rsize_t;
+#endif
+
+#ifndef _ERRNO_T_DEFINED
+#define _ERRNO_T_DEFINED
+typedef int errno_t;
+#endif
+
+/* ISO/IEC 9899:2011 K.3.7.4.1.1 */
+errno_t memset_s(void *, rsize_t, int, rsize_t);
+#endif /* __EXT1_VISIBLE */
__END_DECLS
#endif /* _STRING_H_ */
OpenPOWER on IntegriCloud