]> pd.if.org Git - pdclib/blobdiff - internals/_PDCLIB_config.h
Added exit, _Exit, atexit.
[pdclib] / internals / _PDCLIB_config.h
index 74eb290286d8178ca66e6cbb5b0db8fc1af7e286..2fa66c79507dd347522b1bead42c55210300d1fe 100644 (file)
 /* The character (sequence) your platform uses as newline.                    */
 #define _PDCLIB_endl "\n"
 
+/* exit() can signal success to the host environment by the value of zero or  */
+/* the constant EXIT_SUCCESS. Failure is signaled by EXIT_FAILURE. Note that  */
+/* any other return value is "implementation-defined", i.e. your environment  */
+/* is not required to handle it gracefully. Set your definitions here.        */
+#define _PDCLIB_SUCCESS 0
+#define _PDCLIB_FAILURE -1
+
+/* qsort() in <stdlib.h> requires a function that swaps two memory areas.     */
+/* Below is a naive implementation that can be improved significantly for     */
+/* specific platforms, e.g. by swapping int instead of char.                  */
+#define _PDCLIB_memswp( i, j, size ) char tmp; do { tmp = *i; *i++ = *j; *j++ = tmp; } while ( --size );
+
 /* -------------------------------------------------------------------------- */
 /* Integers                                                                   */
 /* -------------------------------------------------------------------------- */
 #define _PDCLIB_LONG_BYTES  4
 #define _PDCLIB_LLONG_BYTES 8
 
+/* <stdlib.h> defines the div() function family that allows taking quotient   */
+/* and remainder of an integer division in one operation. Many platforms      */
+/* support this in hardware / opcode, and the standard permits ordering of    */
+/* the return structure in any way to fit the hardware. That is why those     */
+/* structs can be configured here.                                            */
+
+struct _PDCLIB_div_t
+{
+    int quot;
+    int rem;
+};
+
+struct _PDCLIB_ldiv_t
+{
+    long int quot;
+    long int rem;
+};
+
+struct _PDCLIB_lldiv_t
+{
+    long long int quot;
+    long long int rem;
+};
+
 /* -------------------------------------------------------------------------- */
 /* <stdint.h> defines a set of integer types that are of a minimum width, and */
 /* "usually fastest" on the system. (If, for example, accessing a single char */
 #define _PDCLIB_intptr int
 #define _PDCLIB_INTPTR INT
 
+/* Largest supported integer type. Implementation note: see _PDCLIB_atomax(). */
 #define _PDCLIB_intmax long long int
 #define _PDCLIB_INTMAX LLINT
 /* You are also required to state the literal suffix for the intmax type      */
@@ -162,3 +199,12 @@ typedef char * _PDCLIB_va_list;
 #define _PDCLIB_va_copy( dest, src ) ( (dest) = (src), (void)0 )
 #define _PDCLIB_va_end( ap ) ( (ap) = (void *)0, (void)0 )
 #define _PDCLIB_va_start( ap, parmN ) ( (ap) = (char *) &parmN + ( _PDCLIB_va_round(parmN) ), (void)0 )
+
+/* -------------------------------------------------------------------------- */
+/* OS "glue"                                                                  */
+/* This is where PDCLib interfaces with the operating system. The examples    */
+/* below are POSIX calls; provide your OS' equivalents.                       */
+/* -------------------------------------------------------------------------- */
+
+/* A system call that terminates the calling process */
+#define _PDCLIB_Exit( x ) _exit( x )