diff options
Diffstat (limited to 'usr/src/man/man3c')
-rw-r--r-- | usr/src/man/man3c/Makefile | 9 | ||||
-rw-r--r-- | usr/src/man/man3c/memset_s.3c | 104 | ||||
-rw-r--r-- | usr/src/man/man3c/set_constraint_handler_s.3c | 133 |
3 files changed, 245 insertions, 1 deletions
diff --git a/usr/src/man/man3c/Makefile b/usr/src/man/man3c/Makefile index 295eb6ffa5..a64bda079a 100644 --- a/usr/src/man/man3c/Makefile +++ b/usr/src/man/man3c/Makefile @@ -244,6 +244,7 @@ MANFILES= __fbufsize.3c \ mbtowc.3c \ membar_ops.3c \ memory.3c \ + memset_s.3c \ mkfifo.3c \ mkstemp.3c \ mktemp.3c \ @@ -413,6 +414,7 @@ MANFILES= __fbufsize.3c \ sem_unlink.3c \ sem_wait.3c \ semaphore.3c \ + set_constraint_handler_s.3c \ setbuf.3c \ setbuffer.3c \ setcat.3c \ @@ -562,7 +564,7 @@ MANFILES= __fbufsize.3c \ wordexp.3c \ wsprintf.3c \ wsscanf.3c \ - wstring.3c \ + wstring.3c MANLINKS= FD_CLR.3c \ FD_ISSET.3c \ @@ -582,6 +584,7 @@ MANLINKS= FD_CLR.3c \ _exithandle.3c \ _flushlbf.3c \ _setjmp.3c \ + abort_handler_s.3c \ addrtosymstr.3c \ aiowrite.3c \ alloca.3c \ @@ -892,6 +895,7 @@ MANLINKS= FD_CLR.3c \ htonl.3c \ htonll.3c \ htons.3c \ + ignore_handler_s.3c \ inet6.3c \ inet_addr.3c \ inet_aton.3c \ @@ -2284,6 +2288,9 @@ sema_post.3c := LINKSRC = semaphore.3c sema_trywait.3c := LINKSRC = semaphore.3c sema_wait.3c := LINKSRC = semaphore.3c +abort_handler_s.3c := LINKSRC = set_constraint_handler_s.3c +ignore_handler_s.3c := LINKSRC = set_constraint_handler_s.3c + setvbuf.3c := LINKSRC = setbuf.3c setlinebuf.3c := LINKSRC = setbuffer.3c diff --git a/usr/src/man/man3c/memset_s.3c b/usr/src/man/man3c/memset_s.3c new file mode 100644 index 0000000000..9da92ff927 --- /dev/null +++ b/usr/src/man/man3c/memset_s.3c @@ -0,0 +1,104 @@ +.\" +.\" This file and its contents are supplied under the terms of the +.\" Common Development and Distribution License ("CDDL"), version 1.0. +.\" You may only use this file in accordance with the terms of version +.\" 1.0 of the CDDL. +.\" +.\" A full copy of the text of the CDDL should have accompanied this +.\" source. A copy of the CDDL is also available via the Internet at +.\" http://www.illumos.org/license/CDDL. +.\" +.\" +.\" Copyright 2018 Nexenta Systems, Inc. +.\" +.Dd August 12, 2017 +.Dt MEMSET_S 3C +.Os +.Sh NAME +.Nm memset_s +.Nd copy a value to all bytes of a memory buffer +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.Fd #define __STDC_WANT_LIB_EXT1__ 1 +.In string.h +.Ft errno_t +.Fo memset_s +.Fa "void *s" +.Fa "rsize_t smax" +.Fa "int c" +.Fa "rsize_t n" +.Fc +.Sh DESCRIPTION +The +.Fn memset_s +function copies the value of +.Fa c +.Po converted to an +.Vt unsigned char +.Pc +into each of the first +.Fa n +bytes of the memory buffer pointed to by +.Fa s . +.Pp +Unlike the +.Xr memset 3C , +.Fn memset_s +is guaranteed to never be optimized away by the compiler. +.Pp +The +.Fn memset_s +function detects the following runtime-constraint violations: +.Bl -enum +.It +.Fa s +is a +.Dv NULL +pointer. +.It +.Fa smax +or +.Fa n +is greater than +.Dv RSIZE_MAX . +.It +.Fa n +is greater than +.Fa smax +.Pq buffer overflow . +.El +.Pp +If runtime-constraint violation is detected, and if +.Fa s +and +.Fa smax +are valid, the +.Fn memset_s +function copies the value of +.Fa c +.Po converted to an +.Vt unsigned char +.Pc +into each of the first +.Fa smax +bytes of the memory buffer pointed to by +.Fa s +before calling the runtime-constraint handler. +.Sh RETURN VALUES +The +.Fn memset_s +function returns 0 if there was no runtime-constraint violation. +Otherwise, a non-zero value is returned. +.Sh INTERFACE STABILITY +.Sy Standard +.Sh MT-LEVEL +.Sy Safe +.Sh SEE ALSO +.Xr memset 3C , +.Xr set_constraint_handler 3C +.Sh STANDARDS +The +.Fn memset_s +function conforms to +.St -isoC-2011 . diff --git a/usr/src/man/man3c/set_constraint_handler_s.3c b/usr/src/man/man3c/set_constraint_handler_s.3c new file mode 100644 index 0000000000..0b2bd5a165 --- /dev/null +++ b/usr/src/man/man3c/set_constraint_handler_s.3c @@ -0,0 +1,133 @@ +.\" +.\" This file and its contents are supplied under the terms of the +.\" Common Development and Distribution License ("CDDL"), version 1.0. +.\" You may only use this file in accordance with the terms of version +.\" 1.0 of the CDDL. +.\" +.\" A full copy of the text of the CDDL should have accompanied this +.\" source. A copy of the CDDL is also available via the Internet at +.\" http://www.illumos.org/license/CDDL. +.\" +.\" +.\" Copyright 2018 Nexenta Systems, Inc. +.\" +.Dd August 12, 2017 +.Dt SET_CONSTRAINT_HANDLER_S 3C +.Os +.Sh NAME +.Nm set_constraint_handler_s , +.Nm abort_handler_s , +.Nm ignore_handler_s +.Nd runtime-constraint handling +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.Fd #define __STDC_WANT_LIB_EXT1__ 1 +.In stdlib.h +.Ft constraint_handler_t +.Fo set_constraint_handler_s +.Fa "constraint_handler_t handler" +.Fc +.Ft void +.Fo abort_handler_s +.Fa "const char *restrict msg" +.Fa "void *restrict ptr" +.Fa "errno_t error" +.Fc +.Ft void +.Fo ignore_handler_s +.Fa "const char *restrict msg" +.Fa "void *restrict ptr" +.Fa "errno_t error" +.Fc +.Sh DESCRIPTION +The +.Fn set_constraint_handler_s +function sets the runtime-constraint handler to be +.Fa handler . +.Pp +The runtime-constraint handler is the callback function invoked when a library +function detects a runtime-constraint violation, having the following prototype: +.Bd -literal -offset indent +void (*constraint_handler_t)(const char *restrict msg, + void *restrict ptr, errno_t error); +.Ed +.Pp +The arguments are as follows: +.Bl -tag -width "error" +.It Fa msg +A pointer to a character string describing the runtime-constraint violation. +.It Fa ptr +A +.Dv NULL +pointer. +.It Fa error +If the function calling the handler has a return type declared as +.Vt errno_t , +the return value of the function is passed. +Otherwise, a positive value of type +.Vt errno_t +is passed. +.El +.Pp +Only the most recent handler registered with +.Fn set_constraint_handler_s +is called when a runtime-constraint violation occurs. +.Pp +The implementation has a default constraint handler that is used if no calls to +the +.Fn set_constraint_handler_s +function have been made. +If the +.Fa handler +argument to +.Fn set_constraint_handler_s +is a +.Dv NULL +pointer, the default handler becomes the current constraint handler. +.Pp +The +.Fn abort_handler_s +and +.Fn ignore_handler_s +are the standard-defined runtime-constraint handlers provided by the C library. +.Pp +The +.Fn abort_handler_s +function writes the error message including the +.Fa msg +to +.Dv stderr +and calls the +.Xr abort 3C +function. +The +.Fn abort_handler_s +is currently the default runtime-constraint handler. +.Pp +The +.Fn ignore_handler_s +simply returns to its caller. +.Sh RETURN VALUES +The +.Fn set_constraint_handler_s +function returns a pointer to the previously registered handler, or +.Dv NULL +if none was previously registered. +.Pp +The +.Fn abort_handler_s +function does not return to its caller. +.Pp +The +.Fn ignore_handler_s +function returns no value. +.Sh INTERFACE STABILITY +.Sy Standard +.Sh MT-LEVEL +.Sy Safe +.Sh STANDARDS +The +.Fn set_constraint_handler_s +function conforms to +.St -isoC-2011 . |