]> pd.if.org Git - pdclib/commitdiff
(merge)
authorOwen Shepherd <owen.shepherd@e43.eu>
Tue, 14 Aug 2012 14:54:36 +0000 (15:54 +0100)
committerOwen Shepherd <owen.shepherd@e43.eu>
Tue, 14 Aug 2012 14:54:36 +0000 (15:54 +0100)
man/abort.3 [new file with mode: 0644]
man/assert.3 [new file with mode: 0644]
man/assert.h.3 [new file with mode: 0644]
man/atexit.3 [new file with mode: 0644]
man/exit.3 [new file with mode: 0644]
man/pdclib.3 [new file with mode: 0644]
man/strdup.3 [new file with mode: 0644]

diff --git a/man/abort.3 b/man/abort.3
new file mode 100644 (file)
index 0000000..4062011
--- /dev/null
@@ -0,0 +1,52 @@
+.\" This file is part of the Public Domain C Library (PDCLib).\r
+.\" Permission is granted to use, modify, and / or redistribute at will.\r
+.\"\r
+.Dd\r
+.Dt abort 3\r
+.Os\r
+\r
+.Sh NAME\r
+.Nm abort\r
+.Nd abnormal process termination\r
+\r
+.Sh SYNOPSIS\r
+.In stdlib.h\r
+.Fn "noreturn void abort" "void"\r
+\r
+.Sh DESCRIPTION\r
+.Fn abort\r
+causes abnormal process termination to occur.\r
+\r
+.Pp\r
+First,\r
+.Dv SIGABRT\r
+will be raised, as if by\r
+.Fn raise SIGABRT .\r
+If the signal is not being caught, or the handler which catches the signal \r
+returns, \r
+.Fn abort\r
+will then proceed to cause the process to terminate with a failure exit status.\r
+It is implementation defined whether any open\r
+.Vt FILE\r
+streams are flushed before the process exits.\r
+\r
+.Sh IMPLEMENTATION NOTES\r
+PDCLib implements termination (in the case that the \r
+.Dv SIGABRT\r
+handler returns) by calling\r
+.Fn _Exit EXIT_FAILURE .\r
+Therefore, stream flushing rules for\r
+.Nm\r
+follow those defined for\r
+.Fn _Exit .\r
+\r
+.Sh SEE ALSO\r
+.Xr exit 3\r
+.Xr quick_exit 3\r
+.Xr _Exit 3\r
+.Xr raise 3\r
+\r
+.Sh STANDARDS\r
+.Fn abort\r
+is first defined in\r
+.St -isoC-90 .
\ No newline at end of file
diff --git a/man/assert.3 b/man/assert.3
new file mode 100644 (file)
index 0000000..d2874e3
--- /dev/null
@@ -0,0 +1,43 @@
+.\" This file is part of the Public Domain C Library (PDCLib).\r
+.\" Permission is granted to use, modify, and / or redistribute at will.\r
+.\"\r
+.Dd\r
+.Dt assert 3\r
+.Os\r
+\r
+.Sh NAME\r
+.Nm assert\r
+.Nd validate assertion\r
+\r
+.Sh SYNOPSIS\r
+.In assert.h\r
+.Fn "void assert" "<scalar expression>"\r
+\r
+.Sh DESCRIPTION\r
+If\r
+.Dv NDEBUG\r
+was defined when\r
+.In assert.h\r
+was last included, the macro\r
+.Nm\r
+results in no code being generated. Otherwise, if the expression evaluates to \r
+false, an error message is printed to \r
+.Va stderr\r
+and execution is terminated by invoking\r
+.Fn abort .\r
+.Sh IMPLEMENTATION NOTES\r
+The enclosing function of the call to\r
+.Nm\r
+will only be printed in the error message when compiling for C99, or a later\r
+revision of the C standard. \r
+\r
+.Sh SEE ALSO\r
+.Xr _Exit 3\r
+.Xr quick_exit 3\r
+.Xr exit 3\r
+.Xr abort 3\r
+\r
+.Sh STANDARDS\r
+Conforming to\r
+.St -isoC-90 ,\r
+.St -isoC-99 .
\ No newline at end of file
diff --git a/man/assert.h.3 b/man/assert.h.3
new file mode 100644 (file)
index 0000000..1a532fa
--- /dev/null
@@ -0,0 +1,39 @@
+.\" This file is part of the Public Domain C Library (PDCLib).\r
+.\" Permission is granted to use, modify, and / or redistribute at will.\r
+.\"\r
+.Dd\r
+.Dt ASSERT.H 3\r
+.Os\r
+.\"\r
+.Sh NAME\r
+.Nm assert.h\r
+.Nd verify program assertion\r
+.\"\r
+.Sh SYNOPSIS\r
+.In assert.h\r
+.\"\r
+.Sh DESCRIPTION\r
+The header\r
+.In assert.h\r
+shall define one macro:\r
+.Dv assert(<scalar expression>) .\r
+.Pp\r
+If\r
+.Dv NDEBUG\r
+was undefined at the most recent inclusion of this header, then it shall be\r
+defined as a macro which will evaluate the scalar expression and, if it is\r
+false, abort the program with a descriptive error message as defined in\r
+.Xr assert 3 .\r
+.\"\r
+.Pp\r
+If\r
+.Dv NDEBUG\r
+was defined at the most recent inclusion of this header, then it shall be\r
+defined as a macro which evaluates as a void expression and\r
+.Sy does not\r
+evaluate its parameter.\r
+.\"\r
+.Sh STANDARDS\r
+Conforming to\r
+.St -isoC-90 ,\r
+.St -isoC-99 .
\ No newline at end of file
diff --git a/man/atexit.3 b/man/atexit.3
new file mode 100644 (file)
index 0000000..a210266
--- /dev/null
@@ -0,0 +1,100 @@
+.\" This file is part of the Public Domain C Library (PDCLib).\r
+.\" Permission is granted to use, modify, and / or redistribute at will.\r
+.\"\r
+.Dd\r
+.Dt atexit 3\r
+.Os\r
+\r
+.Sh NAME\r
+.Nm atexit\r
+.Nd registration of functions to be invoked before process termination\r
+\r
+.Sh SYNOPSIS\r
+.In stdlib.h\r
+.Fn "int atexit" "void (*handler)(void)"\r
+.Fn "int at_quick_exit" "void (*handler)(void)" \r
+(C11, C++11)\r
+\r
+.Sh DESCRIPTION\r
+These functions register a function to be called when the corresponding process\r
+exit function is invoked. For\r
+.Fn atexit \r
+the function will be invoked when the process is terminated by calling\r
+.Fn exit ;\r
+for\r
+.Fn at_quick_exit\r
+the function will be invoked when the process is terminated by calling\r
+.Fn quick_exit .\r
+\r
+.Pp\r
+These functions are used in order to permit a program to perform actions before\r
+a process is terminated; for example, releasing an interprocess semaphore. \r
+Special care should be taken when writing \r
+.Fn at_quick_exit\r
+handlers; the purpose of \r
+.Fn quick_exit\r
+is to support the abandonning of a process when normal process termination might\r
+not be possible; at_quick_exit handlers should therefore be used sparingly and\r
+only when their use is essential.\r
+\r
+.Pp\r
+The standard guarantees that \r
+.Fn atexit\r
+and\r
+.Fn at_quick_exit\r
+may each be called at least 32 times successfully.\r
+\r
+.Pp\r
+.Fn atexit \r
+and\r
+.Fn at_quick_exit\r
+handlers are called in reverse order of the order they were registered in. For\r
+precise details of their ordering, see\r
+.Xr exit 3 .\r
+\r
+.Pp\r
+The result of exiting from a handler registered with\r
+.Fn atexit\r
+or\r
+.Fn at_quick_exit\r
+by use of \r
+.Fn longjmp\r
+is undefined. If any function or destructor invoked by\r
+.Fn exit\r
+or\r
+.Fn quick_exit\r
+should throw, \r
+.Fn std::terminate\r
+is invoked.\r
+\r
+.Pp\r
+Undefined behaviour results if an \r
+.Fn atexit\r
+or\r
+.Fn at_quick_exit\r
+handler calls\r
+.Fn exit\r
+or\r
+.Fn quick_exit . \r
+\r
+.Sh RETURN VALUES\r
+Returns 0 to indicate success; nonzero returns indicate failure.\r
+\r
+.Sh ERRORS\r
+No errors are defined\r
+\r
+.Sh SEE ALSO\r
+.Xr abort 3\r
+.Xr exit 3\r
+.Xr quick_exit 3\r
+.Xr _Exit 3\r
+\r
+.Sh STANDARDS\r
+.Fn atexit\r
+is first defined in\r
+.St -isoC-90 ;\r
+.Fn at_quick_exit\r
+was introduced in\r
+.St -isoC-2011 \r
+and\r
+ISO/IEC 14882:2011 "C++ 2011" .
\ No newline at end of file
diff --git a/man/exit.3 b/man/exit.3
new file mode 100644 (file)
index 0000000..ac8ae99
--- /dev/null
@@ -0,0 +1,119 @@
+.\" This file is part of the Public Domain C Library (PDCLib).\r
+.\" Permission is granted to use, modify, and / or redistribute at will.\r
+.\"\r
+.Dd\r
+.Dt exit 3\r
+.Os\r
+\r
+.Sh NAME\r
+.Nm exit\r
+.Nd terminates the process\r
+\r
+.Sh SYNOPSIS\r
+.In stdlib.h\r
+.Fn "noreturn void exit" "int status"\r
+.Fn "noreturn void quick_exit" "int status"\r
+.Fn "noreturn void _Exit" "int exitcode"\r
+\r
+.Sh DESCRIPTION\r
+Calling any of these three functions terminates the current process, returning \r
+the exit code passed as a parameter. The interpretation of the exit code is \r
+undefined, except that 0 or\r
+.Dv EXIT_SUCCESS\r
+shall indicate successful completion and\r
+.Dv EXIT_FAILURE\r
+shall indicate a non-successful completion.\r
+\r
+.Pp\r
+.Fn exit\r
+first destroys all objects with C++ thread local storage duration (the C \r
+standard leaves whether or not thread local objects are destroyed or not \r
+undefined). Next, the destructors of all C++ objects of static storage duration \r
+are invoked along with all functions passed to\r
+.Fn atexit \r
+in reverse order of registration (the time of registration for C++ objects of \r
+static storage duration is taken to be the time at which the constructor \r
+completes). It then flushes all open\r
+.Vt FILE\r
+streams with unwritten data and closes them. Finally, files created by\r
+.Fn tmpfile\r
+are removed, before handing control back to the host environment. Note in \r
+particular that functions registered with\r
+.Fn at_quick_exit\r
+are\r
+.Sy not\r
+called.\r
+\r
+.Pp\r
+.Fn quick_exit\r
+invokes any functions registered with\r
+.Fn at_quick_exit\r
+in reverse order of registration, then returns control to the host \r
+environment by calling\r
+.Fn _Exit .\r
+No signal handlers are called, nor are any functions registered with\r
+.Fn atexit .\r
+\r
+.Pp\r
+.Fn _Exit\r
+returns control to the controlling environment without invoking any functions\r
+registered by\r
+.Fn atexit ,\r
+.Fn at_quick_exit ,\r
+any signal handlers, or the destructors of any thread local objects or C++ \r
+objects of static storage duration. Whether or not any open \r
+.Vt FILE\r
+streams with unwritten data are flushed or not is undefined.\r
+\r
+.Pp\r
+The result of aborting a call to \r
+.Fn exit\r
+or\r
+.Fn quick_exit\r
+by use of \r
+.Fn longjmp\r
+is undefined. If any function or destructor invoked by\r
+.Fn exit\r
+or\r
+.Fn quick_exit\r
+should throw, \r
+.Fn std::terminate\r
+is invoked.\r
+\r
+.Pp\r
+Undefined behaviour results if, while a call to\r
+.Fn exit\r
+or\r
+.Fn quick_exit\r
+is in progress, a call to \r
+.Fn exit\r
+or\r
+.Fn quick_exit\r
+is made. \r
+\r
+.Sh IMPLEMENTATION NOTES\r
+PDCLib implements the process of flushing streams in\r
+.Fn _Exit ,\r
+and therefore\r
+.Fn exit\r
+calls it after all\r
+.Fn atexit\r
+handlers have been invoked.\r
+\r
+.Sh SEE ALSO\r
+.Xr abort 3\r
+.Xr atexit 3\r
+.Xr at_quick_exit 3\r
+\r
+.Sh STANDARDS\r
+.Fn exit\r
+is first defined in\r
+.St -isoC-90 ;\r
+.Fn _Exit\r
+was introduced in\r
+.St -isoC-99 .\r
+.Fn quick_exit\r
+was introduced in\r
+.St -isoC-11 \r
+and\r
+ISO/IEC 14882:2011 "C++ 2011" .
\ No newline at end of file
diff --git a/man/pdclib.3 b/man/pdclib.3
new file mode 100644 (file)
index 0000000..f0f90a4
--- /dev/null
@@ -0,0 +1,95 @@
+.\" This file is part of the Public Domain C Library (PDCLib).\r
+.\" Permission is granted to use, modify, and / or redistribute at will.\r
+.\"\r
+.Dd\r
+.Dt PDCLIB 3\r
+.Os\r
+\r
+.Sh NAME\r
+.Nm PDCLib\r
+.Nd Public domain, portable C library\r
+\r
+.Sh LIBRARY\r
+.Lb pdclib\r
+.Sh SYNOPSIS\r
+.In assert.h\r
+.In ctype.h\r
+.In errno.h\r
+.In inttypes.h\r
+.In iso646.h\r
+.In limits.h\r
+.In locale.h\r
+.In signal.h\r
+.In stdarg.h\r
+.In stdbool.h\r
+.In stddef.h\r
+.In stdint.h\r
+.In stdio.h\r
+.In stdlib.h\r
+.In stdnoreturn.h\r
+.In string.h\r
+.In threads.h\r
+.In time.h\r
+\r
+.Sh DESCRIPTION\r
+The\r
+.Nm\r
+library is a portable, public domain C library. It aims at full conformance with\r
+ISO C89, C95, C99 and C11 when used in combination with a conformant compiler. \r
+In addition, it aims at conformance with the portion of ISO C++97 and C++2011 \r
+which is derived from said standards.\r
+.Pp\r
+.Nm\r
+aims for strict conformance with the selected C/C++ standard. Therefore, unlike\r
+most C libraries, it does not by default expose any extensions. Some extensions\r
+(from POSIX or the Single Unix Specification) can be selected by defining the \r
+appropriate feature selection macro, such as \r
+.Dv _POSIX_C_SOURCE\r
+or\r
+.Dv _XOPEN_SOURCE\r
+to the appropriate value. For example, in the following definition:\r
+.Bd -offset indent\r
+.Sy #define _XOPEN_SOURCE || _POSIX_C_SOURCE >= 200809L\r
+.br\r
+.Sy #include\r
+.In string.h\r
+.br\r
+.Fn "char * strdup" "const char *"\r
+.Ed\r
+\r
+it is documented that defining either \r
+.Dv _XOPEN_SOURCE\r
+or\r
+.Dv _POSIX_C_SOURCE\r
+to have a value greater than\r
+.Li 200809L\r
+before the first inclusion of\r
+.In string.h\r
+will expose a definition of the function\r
+.Fn strdup\r
+\r
+.Sh SEE ALSO\r
+.Xr cc 1 ,\r
+.Xr c++ 7\r
+.Sh STANDARDS\r
+When compiled with a C compiler, conformant with \r
+.St -isoC-90 ,\r
+.St -isoC-amd1 ,\r
+.St -isoC-tcor1 ,\r
+.St -isoC-tcor2 ,\r
+.St -isoC-99 or\r
+.St -isoC-2011\r
+as dependent upon the version of C the compiler declares conformance with.\r
+.Pp\r
+When compiled with a C++ compiler, conformant with ISO/IEC 14882:1997 or ISO/IEC\r
+14882:2011 "The C++ Programming Language" as dependent upon the version of C++\r
+the compiler declares conformance with.\r
+.Sh AUTHORS\r
+The\r
+.Nm\r
+library is maintained by by\r
+.An Owen Shepherd ,\r
+.Mt pdclib@owenshepherd.net .\r
+Based upon work by\r
+.An Martin "Solar" Baute ,\r
+.Mt solar@rootdirectory.de .\r
diff --git a/man/strdup.3 b/man/strdup.3
new file mode 100644 (file)
index 0000000..8ac67e0
--- /dev/null
@@ -0,0 +1,59 @@
+.\" This file is part of the Public Domain C Library (PDCLib).\r
+.\" Permission is granted to use, modify, and / or redistribute at will.\r
+.\"\r
+.Dd\r
+.Dt strdup 3\r
+.Os\r
+\r
+.Sh NAME\r
+.Nm strdup\r
+.Nd string duplication\r
+\r
+.Sh SYNOPSIS\r
+.Sy #define _XOPEN_SOURCE || _POSIX_C_SOURCE >= 200809L\r
+.In string.h\r
+.Fn "char *strdup" "const char *str"\r
+.Pp\r
+.Sy #define _POSIX_C_SOURCE >= 200809L\r
+.In string.h\r
+.Fn "char *strndup" "const char *str" "size_t len"\r
+\r
+.Sh DESCRIPTION\r
+.Fn strdup\r
+allocates a new buffer of sufficient size as to be able to hold the entirety of\r
+.Va str ,\r
+including the terminating character, and copies the contents of\r
+.Va str\r
+into it.\r
+\r
+.Pp\r
+.Fn strndup\r
+allocates a buffer large enough to contain\r
+.Va len\r
+characters, plus a trailing null character, or sufficient to contain the \r
+entirety of\r
+.Va str\r
+including the trailing null character, whichever is smaller. The first \r
+.Va len\r
+characters of \r
+.Va str\r
+are then copied into it, and a null character appended.\r
+\r
+.Pp\r
+The buffers returned by these functions must be released by a call to\r
+.Fn free .\r
+\r
+.Sh SEE ALSO\r
+.Xr free 3\r
+.Xr malloc 3\r
+.Xr strcpy 3\r
+.Xr strncpy 3\r
+\r
+.Sh STANDARDS\r
+.Fn strdup\r
+first specified in \r
+.St -xpg3 .\r
+Moved into POSIX, and\r
+.Fn strndup\r
+added, with\r
+.St -p1003.1-2008 .
\ No newline at end of file