summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-01-30 14:57:46 -0500
committerJakob Kaivo <jkk@ung.org>2024-01-30 14:57:46 -0500
commitcc6e7378d3f5473137e0c46d39173e6f60dcefda (patch)
tree4cd2883ad16fd594b7777b6f3821d5b9177af5c4
parent000a7c045c98c30aac86db93f8c9c978e5ca8c59 (diff)
update standards and safety checks
-rw-r--r--src/stdlib/_Exit.c7
-rw-r--r--src/stdlib/__constraint_info.h1
-rw-r--r--src/stdlib/__stdlib.c1
-rw-r--r--src/stdlib/_stdlib.h3
-rw-r--r--src/stdlib/a64l.c7
-rw-r--r--src/stdlib/abort.c4
-rw-r--r--src/stdlib/abort_handler_s.c9
-rw-r--r--src/stdlib/abs.c8
-rw-r--r--src/stdlib/aligned_alloc.c9
-rw-r--r--src/stdlib/at_quick_exit.c14
-rw-r--r--src/stdlib/atexit.c3
-rw-r--r--src/stdlib/atof.c7
-rw-r--r--src/stdlib/atoi.c7
-rw-r--r--src/stdlib/atol.c7
-rw-r--r--src/stdlib/atoll.c7
-rw-r--r--src/stdlib/bsearch.c8
-rw-r--r--src/stdlib/bsearch_s.c11
-rw-r--r--src/stdlib/calloc.c8
-rw-r--r--src/stdlib/div.c10
-rw-r--r--src/stdlib/drand48.c7
-rw-r--r--src/stdlib/ecvt.c7
-rw-r--r--src/stdlib/erand48.c7
-rw-r--r--src/stdlib/exit.c2
-rw-r--r--src/stdlib/fcvt.c7
-rw-r--r--src/stdlib/free.c8
-rw-r--r--src/stdlib/gcvt.c7
-rw-r--r--src/stdlib/getenv.c10
-rw-r--r--src/stdlib/getenv_s.c9
-rw-r--r--src/stdlib/getsubopt.c7
-rw-r--r--src/stdlib/grantpt.c7
-rw-r--r--src/stdlib/ignore_handler_s.c9
-rw-r--r--src/stdlib/initstate.c7
-rw-r--r--src/stdlib/jrand48.c7
-rw-r--r--src/stdlib/l64a.c7
-rw-r--r--src/stdlib/labs.c8
-rw-r--r--src/stdlib/lcong48.c7
-rw-r--r--src/stdlib/ldiv.c9
-rw-r--r--src/stdlib/llabs.c8
-rw-r--r--src/stdlib/lldiv.c8
-rw-r--r--src/stdlib/lrand48.c7
-rw-r--r--src/stdlib/malloc.c8
-rw-r--r--src/stdlib/mblen.c8
-rw-r--r--src/stdlib/mbstowcs.c8
-rw-r--r--src/stdlib/mbstowcs_s.c10
-rw-r--r--src/stdlib/mbtowc.c7
-rw-r--r--src/stdlib/mkstemp.c7
-rw-r--r--src/stdlib/mktemp.c7
-rw-r--r--src/stdlib/mrand48.c7
-rw-r--r--src/stdlib/nrand48.c7
-rw-r--r--src/stdlib/ptsname.c7
-rw-r--r--src/stdlib/putenv.c7
-rw-r--r--src/stdlib/qsort.c7
-rw-r--r--src/stdlib/qsort_s.c11
-rw-r--r--src/stdlib/quick_exit.c8
-rw-r--r--src/stdlib/rand.c8
-rw-r--r--src/stdlib/random.c8
-rw-r--r--src/stdlib/realloc.c20
-rw-r--r--src/stdlib/realpath.c7
-rw-r--r--src/stdlib/seed48.c8
-rw-r--r--src/stdlib/set_constraint_handler_s.c9
-rw-r--r--src/stdlib/setkey.c7
-rw-r--r--src/stdlib/setstate.c7
-rw-r--r--src/stdlib/srand.c7
-rw-r--r--src/stdlib/srand48.c7
-rw-r--r--src/stdlib/srandom.c7
-rw-r--r--src/stdlib/strtod.c8
-rw-r--r--src/stdlib/strtof.c8
-rw-r--r--src/stdlib/strtol.c8
-rw-r--r--src/stdlib/strtold.c8
-rw-r--r--src/stdlib/strtoll.c8
-rw-r--r--src/stdlib/strtoul.c8
-rw-r--r--src/stdlib/strtoull.c8
-rw-r--r--src/stdlib/system.c8
-rw-r--r--src/stdlib/ttyslot.c8
-rw-r--r--src/stdlib/unlockpt.c7
-rw-r--r--src/stdlib/valloc.c7
-rw-r--r--src/stdlib/wcstombs.c8
-rw-r--r--src/stdlib/wcstombs_s.c9
-rw-r--r--src/stdlib/wctomb.c8
-rw-r--r--src/stdlib/wctomb_s.c9
80 files changed, 221 insertions, 389 deletions
diff --git a/src/stdlib/_Exit.c b/src/stdlib/_Exit.c
index 59d045fe..93b855c8 100644
--- a/src/stdlib/_Exit.c
+++ b/src/stdlib/_Exit.c
@@ -1,7 +1,5 @@
-#if 0
-
#include <stdlib.h>
-#include "_safety.h"
+#include "_stdlib.h"
#include "_syscall.h"
/** cause normal program termination without handlers **/
@@ -35,6 +33,3 @@ No functions registered by fn(atexit) or fn(at_quick_exit) are called.
/*
STDC(199901)
*/
-
-
-#endif
diff --git a/src/stdlib/__constraint_info.h b/src/stdlib/__constraint_info.h
index 9e66db5b..0cdae024 100644
--- a/src/stdlib/__constraint_info.h
+++ b/src/stdlib/__constraint_info.h
@@ -1,4 +1,5 @@
struct __constraint_info {
const char *func;
int value;
+ int signal;
};
diff --git a/src/stdlib/__stdlib.c b/src/stdlib/__stdlib.c
index b6423713..a95b7ef7 100644
--- a/src/stdlib/__stdlib.c
+++ b/src/stdlib/__stdlib.c
@@ -6,4 +6,5 @@ struct __stdlib __stdlib = {
/*
STDC(0)
+SIGNAL_SAFE(0)
*/
diff --git a/src/stdlib/_stdlib.h b/src/stdlib/_stdlib.h
index 82b7943d..d8120e66 100644
--- a/src/stdlib/_stdlib.h
+++ b/src/stdlib/_stdlib.h
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <limits.h>
+#include "_safety.h"
#define _rand(_n) \
(((_n) = (_n) * 1103515245 + 12345) ? (_n) / UINT_MAX % RAND_MAX : 0)
@@ -18,7 +19,7 @@ struct __stdlib {
void (*fns[32])(void);
struct atexit *next;
struct atexit *prev;
- } atexit;
+ } atexit, at_quick_exit;
int exit_called;
int quick_exit_called;
unsigned int rand;
diff --git a/src/stdlib/a64l.c b/src/stdlib/a64l.c
index f579d5fa..287e76f8 100644
--- a/src/stdlib/a64l.c
+++ b/src/stdlib/a64l.c
@@ -1,9 +1,9 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
long a64l(const char *s)
{
+ SIGNAL_SAFE(0);
long l = 0;
int i = 0;
int n = 0;
@@ -21,6 +21,3 @@ long a64l(const char *s)
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/abort.c b/src/stdlib/abort.c
index cf968456..ed762be7 100644
--- a/src/stdlib/abort.c
+++ b/src/stdlib/abort.c
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <signal.h>
-#include "_safety.h"
+#include "_stdlib.h"
+
+#undef abort
/** cause abnormal program termination **/
diff --git a/src/stdlib/abort_handler_s.c b/src/stdlib/abort_handler_s.c
index 145c9e6d..4b1e3f03 100644
--- a/src/stdlib/abort_handler_s.c
+++ b/src/stdlib/abort_handler_s.c
@@ -4,15 +4,20 @@
//#include <errno.h>
#include "errno/errno_t.h"
#include "_stdlib.h"
-#include "_safety.h"
void abort_handler_s(const char * restrict msg, void * restrict ptr, errno_t error)
{
+ SIGNAL_SAFE(0);
+
struct __constraint_info *ci = ptr;
puts(msg);
if (ci) {
- printf("In call to %s()", ci->func);
+ if (ci->signal != 0) {
+ /* TODO: map numbers to names as well */
+ printf("While handling signal %d: ", ci->signal);
+ }
+ printf("Function %s()", ci->func);
if (__checked_call.file) {
printf(" (");
if (__checked_call.func) {
diff --git a/src/stdlib/abs.c b/src/stdlib/abs.c
index b043fd03..74455c59 100644
--- a/src/stdlib/abs.c
+++ b/src/stdlib/abs.c
@@ -1,12 +1,13 @@
-#if 0
-
#include <stdlib.h>
#include <limits.h>
+#include "_stdlib.h"
/** absolute value **/
int abs(int j)
{
+ SIGNAL_SAFE(0);
+
if (j == INT_MIN) {
/* undefined behavior */
}
@@ -23,6 +24,3 @@ UNDEFINED(ABS(ARGUMENT(j)) cannot be represented)
RETURN_SUCCESS(ABS(j));
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/aligned_alloc.c b/src/stdlib/aligned_alloc.c
index 36bae69d..983cb7de 100644
--- a/src/stdlib/aligned_alloc.c
+++ b/src/stdlib/aligned_alloc.c
@@ -1,9 +1,9 @@
-#if 0
-
-#include <stdli.h>
+#include <stdlib.h>
+#include "_stdlib.h"
void *aligned_alloc(size_t alignment, size_t size)
{
+ SIGNAL_SAFE(0);
/* all allocations are page aligned */
(void)alignment;
return malloc(size);
@@ -12,6 +12,3 @@ void *aligned_alloc(size_t alignment, size_t size)
/*
STDC(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/at_quick_exit.c b/src/stdlib/at_quick_exit.c
index f3659fd6..e3ae86cc 100644
--- a/src/stdlib/at_quick_exit.c
+++ b/src/stdlib/at_quick_exit.c
@@ -1,5 +1,3 @@
-#if 0
-
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
@@ -8,11 +6,11 @@
/** register a function to run at quick exit **/
int at_quick_exit(void (*func)(void))
{
- __C_MIN(201112L);
- if (__stdlib.nat_quick_exit >= ATEXIT_MAX) {
- return 1;
- }
+ SIGNAL_SAFE(0);
+ (void)func;
+
+ /*
if (__stdlib.at_quick_exit == NULL) {
__stdlib.at_quick_exit = calloc(1,
sizeof(*__stdlib.at_quick_exit));
@@ -35,6 +33,7 @@ int at_quick_exit(void (*func)(void))
__stdlib.at_quick_exit->next->prev = __stdlib.at_quick_exit;
__stdlib.at_quick_exit = __stdlib.at_quick_exit->next;
__stdlib.nat_quick_exit++;
+ */
return 0;
}
@@ -54,6 +53,3 @@ program exits via fn(quick_exit). The function must take no parameters.
/*
STDC(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/atexit.c b/src/stdlib/atexit.c
index 79b486d0..4e20f993 100644
--- a/src/stdlib/atexit.c
+++ b/src/stdlib/atexit.c
@@ -7,6 +7,9 @@
int atexit(void (*func)(void))
{
struct atexit *ae = &(__stdlib.atexit);
+
+ SIGNAL_SAFE(0);
+
while (ae->nfns == sizeof(ae->fns) / sizeof(ae->fns[0])) {
if (ae->next == NULL) {
ae->next = calloc(1, sizeof(*ae->next));
diff --git a/src/stdlib/atof.c b/src/stdlib/atof.c
index 1cb52620..f3d147f1 100644
--- a/src/stdlib/atof.c
+++ b/src/stdlib/atof.c
@@ -1,11 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert string to floating-point **/
double atof(const char * nptr)
{
+ SIGNAL_SAFE(0);
return strtod(nptr, (char**)NULL);
}
@@ -19,6 +19,3 @@ LC_CTYPE
RETURN_SUCCESS(the converted value)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/atoi.c b/src/stdlib/atoi.c
index 4ed20bc3..92ad6e8a 100644
--- a/src/stdlib/atoi.c
+++ b/src/stdlib/atoi.c
@@ -1,11 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert string to integer **/
int atoi(const char * nptr)
{
+ SIGNAL_SAFE(0);
return (int)strtol(nptr, (char**)NULL, 10);
}
@@ -19,6 +19,3 @@ LC_CTYPE
RETURN_SUCCESS(the converted value)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/atol.c b/src/stdlib/atol.c
index 0a1e35d5..c178584c 100644
--- a/src/stdlib/atol.c
+++ b/src/stdlib/atol.c
@@ -1,11 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert string to long integer **/
long int atol(const char * nptr)
{
+ SIGNAL_SAFE(0);
return strtol(nptr, (char**)NULL, 10);
}
@@ -19,6 +19,3 @@ LC_CTYPE
RETURN_SUCCESS(the converted value)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/atoll.c b/src/stdlib/atoll.c
index b9da2def..fe1569b9 100644
--- a/src/stdlib/atoll.c
+++ b/src/stdlib/atoll.c
@@ -1,11 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert string to long long integer **/
long long int atoll(const char *nptr)
{
+ SIGNAL_SAFE(0);
return strtoll(nptr, (char**)NULL, 10);
}
@@ -19,6 +19,3 @@ LC_CTYPE
RETURN_SUCCESS(the converted value)
STDC(199901)
*/
-
-
-#endif
diff --git a/src/stdlib/bsearch.c b/src/stdlib/bsearch.c
index 39bf7694..a7531672 100644
--- a/src/stdlib/bsearch.c
+++ b/src/stdlib/bsearch.c
@@ -1,6 +1,5 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** binary search **/
@@ -12,6 +11,8 @@ void * bsearch(const void * key, const void * base, size_t nmemb, size_t size, i
unsigned int trip = 1;
const char *addr = base;
+ SIGNAL_SAFE(0);
+
while (ret == NULL) {
int comp = compar(key, addr + (i * size));
if (comp == 0) {
@@ -44,6 +45,3 @@ RETURN_FAILURE(CONSTANT(NULL))
RETURN_SUCCESS(a pointer to the matching element)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/bsearch_s.c b/src/stdlib/bsearch_s.c
index dfa1a7ed..706aa399 100644
--- a/src/stdlib/bsearch_s.c
+++ b/src/stdlib/bsearch_s.c
@@ -1,18 +1,20 @@
-#if 0
-
#include <stddef.h>
+#include "_stdlib.h"
/** binary search **/
void *bsearch_s(const void * key, const void * base, rsize_t nmemb, rsize_t size, int (*compar)(const void *x, const void *y, void * context), void *context)
{
+ SIGNAL_SAFE(0);
+
/* TODO: testing */
+ (void)size;
void *ret = NULL;
size_t i = nmemb / 2;
unsigned int trip = 1;
while (ret == NULL) {
- int comp = compar(key, base+i);
+ int comp = compar(key, base+i, context);
if (comp == 0) {
return (void*)base+i;
} else if (comp > 0) {
@@ -47,6 +49,3 @@ element.
/*
CEXT1(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/calloc.c b/src/stdlib/calloc.c
index 609cd0d4..e5b5f38b 100644
--- a/src/stdlib/calloc.c
+++ b/src/stdlib/calloc.c
@@ -1,7 +1,6 @@
-#if 0
-
#include <stdlib.h>
#include <string.h>
+#include "_stdlib.h"
/** allocate and initialize memory **/
@@ -10,6 +9,8 @@ void * calloc(size_t nmemb, size_t size)
void *p = NULL;
size_t total = nmemb * size;
+ SIGNAL_SAFE(0);
+
if (total < nmemb || total < size) {
return NULL;
}
@@ -38,6 +39,3 @@ RETURN_FAILURE(CONSTANT(NULL))
RETURN_SUCCESS(a pointer to the newly allocated memory)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/div.c b/src/stdlib/div.c
index 89e6bf0e..8d515ec6 100644
--- a/src/stdlib/div.c
+++ b/src/stdlib/div.c
@@ -1,12 +1,15 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
+#undef div
/** calculate quotient and remainder **/
div_t div(int numer, int denom)
{
div_t d;
+
+ SIGNAL_SAFE(0);
+
d.quot = numer / denom;
d.rem = numer % denom;
return d;
@@ -22,6 +25,3 @@ UNDEFINED(The result cannot be represented)
RETURN_SUCCESS(a TYPEDEF(div_t) containing both the quotient and remainder)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/drand48.c b/src/stdlib/drand48.c
index 21a5b1d0..8f0e4a55 100644
--- a/src/stdlib/drand48.c
+++ b/src/stdlib/drand48.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
double drand48(void)
{
+ SIGNAL_SAFE(0);
return 0.0;
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/ecvt.c b/src/stdlib/ecvt.c
index 81756c48..fc2e6016 100644
--- a/src/stdlib/ecvt.c
+++ b/src/stdlib/ecvt.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char *ecvt(double value, int ndigit, int *decpt, int *sign)
{
+ SIGNAL_SAFE(0);
return 0;
}
/*
XOPEN(400,700)
*/
-
-
-#endif
diff --git a/src/stdlib/erand48.c b/src/stdlib/erand48.c
index 3b1506cf..e7fdeb4d 100644
--- a/src/stdlib/erand48.c
+++ b/src/stdlib/erand48.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
double erand48(unsigned short xsubi[3])
{
+ SIGNAL_SAFE(0);
return 0.0;
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/exit.c b/src/stdlib/exit.c
index 60a933b8..12876050 100644
--- a/src/stdlib/exit.c
+++ b/src/stdlib/exit.c
@@ -9,6 +9,8 @@ _Noreturn void exit(int status)
long scno = __syscall_lookup(exit);
struct atexit *ae = &(__stdlib.atexit);
+ SIGNAL_SAFE(0);
+
if (__stdlib.quick_exit_called) {
__stdlib.constraint_handler("Undefined behavior: exit() called after quick_exit()", NULL, 0);
}
diff --git a/src/stdlib/fcvt.c b/src/stdlib/fcvt.c
index cab92565..857a25d7 100644
--- a/src/stdlib/fcvt.c
+++ b/src/stdlib/fcvt.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char *fcvt(double value, int ndigit, int *decpt, int *sign)
{
+ SIGNAL_SAFE(0);
return 0;
}
/*
XOPEN(400,700)
*/
-
-
-#endif
diff --git a/src/stdlib/free.c b/src/stdlib/free.c
index 350c70cc..e0a1270a 100644
--- a/src/stdlib/free.c
+++ b/src/stdlib/free.c
@@ -1,11 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** deallocate memory **/
void free(void * ptr)
{
+ SIGNAL_SAFE(0);
+
if (ptr == NULL) {
return;
}
@@ -22,6 +23,3 @@ causes nothing to happen.
UNDEFINED(ARGUMENT(ptr) was not returned by a previous call to FUNCTION(calloc), FUNCTION(malloc), or FUNCTION(realloc))
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/gcvt.c b/src/stdlib/gcvt.c
index 67b6f730..61b40132 100644
--- a/src/stdlib/gcvt.c
+++ b/src/stdlib/gcvt.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char *gcvt(double value, int ndigit, char *buf)
{
+ SIGNAL_SAFE(0);
return 0;
}
/*
XOPEN(400,700)
*/
-
-
-#endif
diff --git a/src/stdlib/getenv.c b/src/stdlib/getenv.c
index 56ca970d..989a5f84 100644
--- a/src/stdlib/getenv.c
+++ b/src/stdlib/getenv.c
@@ -1,5 +1,3 @@
-#if 0
-
#include <stdlib.h>
#include <string.h>
#include "_stdlib.h"
@@ -8,9 +6,12 @@
char * getenv(const char * name)
{
- size_t len = strlen(name);
+ size_t len = 0;
size_t i = 0;
+ SIGNAL_SAFE(0);
+
+ len = strlen(name);
for (i = 0; environ[i] != NULL; i++) {
if (!strncmp(environ[i], name, len) && environ[i][len] == '=') {
return environ[i] + len + 1;
@@ -32,6 +33,3 @@ RETURN_FAILURE(CONSTANT(NULL))
RETURN_SUCCESS(a pointer to the environment string)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/getenv_s.c b/src/stdlib/getenv_s.c
index 32904779..73e6131c 100644
--- a/src/stdlib/getenv_s.c
+++ b/src/stdlib/getenv_s.c
@@ -1,12 +1,12 @@
-#if 0
-
#include <string.h>
#include <stdlib.h>
+#include "_stdlib.h"
/** get an environment variable **/
errno_t getenv_s(size_t * restrict len, char * restrict value, rsize_t maxsize, const char * restrict name)
{
- __C_EXT(1, 201112L);
+ SIGNAL_SAFE(0);
+ (void)len; (void)value; (void)maxsize; (void)name;
return 0;
}
@@ -27,6 +27,3 @@ environment.
/*
CEXT1(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/getsubopt.c b/src/stdlib/getsubopt.c
index 08f56e4f..93dd08c3 100644
--- a/src/stdlib/getsubopt.c
+++ b/src/stdlib/getsubopt.c
@@ -1,9 +1,9 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
int getsubopt(char ** optionp, char * const * keylistp, char ** valuep)
{
+ SIGNAL_SAFE(0);
return 0;
}
@@ -11,6 +11,3 @@ int getsubopt(char ** optionp, char * const * keylistp, char ** valuep)
XOPEN(400)
POSIX(200809)
*/
-
-
-#endif
diff --git a/src/stdlib/grantpt.c b/src/stdlib/grantpt.c
index beab15ae..49796817 100644
--- a/src/stdlib/grantpt.c
+++ b/src/stdlib/grantpt.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
int grantpt(int fildes)
{
+ SIGNAL_SAFE(0);
return fildes;
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/ignore_handler_s.c b/src/stdlib/ignore_handler_s.c
index 6ef026eb..78d92307 100644
--- a/src/stdlib/ignore_handler_s.c
+++ b/src/stdlib/ignore_handler_s.c
@@ -1,11 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** ignore constraint violations **/
void ignore_handler_s(const char * restrict msg, void * restrict ptr, errno_t error)
{
- __C_EXT(1, 201112L);
+ SIGNAL_SAFE(0);
+ (void)msg; (void)ptr; (void)error;
return;
}
@@ -24,6 +24,3 @@ It simply returns to its caller.
/*
CEXT1(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/initstate.c b/src/stdlib/initstate.c
index e10b78a7..fde257eb 100644
--- a/src/stdlib/initstate.c
+++ b/src/stdlib/initstate.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char * initstate(unsigned seed, char * state, size_t size)
{
+ SIGNAL_SAFE(0);
return state;
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/jrand48.c b/src/stdlib/jrand48.c
index 395b56c0..470dbce5 100644
--- a/src/stdlib/jrand48.c
+++ b/src/stdlib/jrand48.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
long jrand48(unsigned short xsub[3])
{
+ SIGNAL_SAFE(0);
return 0;
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/l64a.c b/src/stdlib/l64a.c
index 09b9ac95..67c0f9b9 100644
--- a/src/stdlib/l64a.c
+++ b/src/stdlib/l64a.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char * l64a(long value)
{
+ SIGNAL_SAFE(0);
return NULL;
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/labs.c b/src/stdlib/labs.c
index aa1aaecf..692fd8d0 100644
--- a/src/stdlib/labs.c
+++ b/src/stdlib/labs.c
@@ -1,12 +1,13 @@
-#if 0
-
#include <stdlib.h>
#include <limits.h>
+#include "_stdlib.h"
/** absolute value **/
long int labs(long int j)
{
+ SIGNAL_SAFE(0);
+
if (j == LONG_MIN) {
/* undefined */
return LONG_MIN;
@@ -24,6 +25,3 @@ UNDEFINED(ABS(ARGUMENT(j)) cannot be represented)
RETURN_SUCCESS(ABS(ARGUMENT(j)))
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/lcong48.c b/src/stdlib/lcong48.c
index b14824d8..ac43c301 100644
--- a/src/stdlib/lcong48.c
+++ b/src/stdlib/lcong48.c
@@ -1,14 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
void lcong48(unsigned short param[7])
{
+ SIGNAL_SAFE(0);
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/ldiv.c b/src/stdlib/ldiv.c
index 9345b8e0..dc236d10 100644
--- a/src/stdlib/ldiv.c
+++ b/src/stdlib/ldiv.c
@@ -1,12 +1,14 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** calculate quotient and remainder **/
ldiv_t ldiv(long int numer, long int denom)
{
ldiv_t d;
+
+ SIGNAL_SAFE(0);
+
d.quot = numer / denom;
d.rem = numer % denom;
return d;
@@ -22,6 +24,3 @@ UNDEFINED(The result cannot be represented)
RETURN_SUCCESS(a TYPEDEF(ldiv_t) containing both the quotient and remainder)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/llabs.c b/src/stdlib/llabs.c
index 9bf435bd..e60e34b5 100644
--- a/src/stdlib/llabs.c
+++ b/src/stdlib/llabs.c
@@ -1,12 +1,13 @@
-#if 0
-
#include <stdlib.h>
#include <limits.h>
+#include "_stdlib.h"
/** absolute value **/
long long int llabs(long long int j)
{
+ SIGNAL_SAFE(0);
+
if (j == LLONG_MIN) {
/* undefined */
return LLONG_MIN;
@@ -24,6 +25,3 @@ UNDEFINED(ABS(ARGUMENT(j)) cannot be represented
RETURN_SUCCESS(ABS(ARGUMENT(j))
STDC(199901)
*/
-
-
-#endif
diff --git a/src/stdlib/lldiv.c b/src/stdlib/lldiv.c
index 2472b9f7..6a8e6fd5 100644
--- a/src/stdlib/lldiv.c
+++ b/src/stdlib/lldiv.c
@@ -1,11 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** calculate quotient and remainder **/
lldiv_t lldiv(long long int numer, long long int denom)
{
+ SIGNAL_SAFE(0);
+
lldiv_t d;
d.quot = numer / denom;
d.rem = numer % denom;
@@ -22,6 +23,3 @@ UNDEFINED(The result cannot be represented)
RETURN_SUCCESS(a TYPEDEF(ldiv_t) containing both the quotient and remainder)
STDC(199901)
*/
-
-
-#endif
diff --git a/src/stdlib/lrand48.c b/src/stdlib/lrand48.c
index f8477e2e..f4bb3c70 100644
--- a/src/stdlib/lrand48.c
+++ b/src/stdlib/lrand48.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
long lrand48(void)
{
+ SIGNAL_SAFE(0);
return 0;
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/malloc.c b/src/stdlib/malloc.c
index 01924ee4..733d73b3 100644
--- a/src/stdlib/malloc.c
+++ b/src/stdlib/malloc.c
@@ -1,10 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** allocate memory **/
void * malloc(size_t size)
{
+ SIGNAL_SAFE(0);
+
if (size == 0) {
return NULL;
}
@@ -23,6 +24,3 @@ RETURN_FAILURE(CONSTANT(NULL))
RETURN_SUCCESS(a pointer to the allocated space)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/mblen.c b/src/stdlib/mblen.c
index 45b80ccb..42188418 100644
--- a/src/stdlib/mblen.c
+++ b/src/stdlib/mblen.c
@@ -1,11 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** count bytes in multibyte character **/
int mblen(const char * s, size_t n)
{
+ SIGNAL_SAFE(0);
+
/* FIXME: forward dependency on AMD1 */
#if 0
mbstate_t ps = 0;
@@ -34,6 +35,3 @@ RETURN(0, ARGUMENT(s) points to a null character);
RETURN(TYPE(int), the number of bytes in the multibyte character);
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/mbstowcs.c b/src/stdlib/mbstowcs.c
index 70daf2ca..c01f8201 100644
--- a/src/stdlib/mbstowcs.c
+++ b/src/stdlib/mbstowcs.c
@@ -1,11 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert multibyte string to wide character string **/
size_t mbstowcs(wchar_t * restrict pwcs, const char * restrict s, size_t n)
{
+ SIGNAL_SAFE(0);
+
/* FIXME: forward dependency on AMD1 */
#if 0
mbstate_t ps = 0;
@@ -30,6 +31,3 @@ RETURN_FAILURE(-1)
RETURN_SUCCESS(the number of wide characters converted, not counting any terminating zero)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/mbstowcs_s.c b/src/stdlib/mbstowcs_s.c
index 8abab6e8..23426796 100644
--- a/src/stdlib/mbstowcs_s.c
+++ b/src/stdlib/mbstowcs_s.c
@@ -1,11 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert multibyte string to wide character string **/
errno_t mbstowcs_s(size_t * restrict retval, wchar_t * restrict dst, rsize_t dstmax, const char * restrict src, rsize_t len)
{
- __C_EXT(1, 201112L);
+ SIGNAL_SAFE(0);
+ (void)retval; (void)dst; (void)dstmax; (void)src; (void)len;
+ return 0;
}
/***
@@ -26,6 +27,3 @@ be converted after a null character, which is converted.
/*
CEXT1(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/mbtowc.c b/src/stdlib/mbtowc.c
index 73c590af..015a4505 100644
--- a/src/stdlib/mbtowc.c
+++ b/src/stdlib/mbtowc.c
@@ -1,11 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert a multibyte character to a wide character **/
int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n)
{
+ SIGNAL_SAFE(0);
/* FIXME: forward dependency on AMD1 */
#if 0
static mbstate_t ps = 0;
@@ -37,6 +37,3 @@ RETURN(0, ARGUMENT(s) points to a null character)
RETURN(TYPE(int), the number of bytes in the converted multibyte character)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/mkstemp.c b/src/stdlib/mkstemp.c
index 6c97e468..7e721167 100644
--- a/src/stdlib/mkstemp.c
+++ b/src/stdlib/mkstemp.c
@@ -1,9 +1,9 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
int mkstemp(char * template)
{
+ SIGNAL_SAFE(0);
return 0;
}
@@ -11,6 +11,3 @@ int mkstemp(char * template)
XOPEN(400)
POSIX(200809)
*/
-
-
-#endif
diff --git a/src/stdlib/mktemp.c b/src/stdlib/mktemp.c
index b3656c4c..e1887653 100644
--- a/src/stdlib/mktemp.c
+++ b/src/stdlib/mktemp.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char *mktemp(char *template)
{
+ SIGNAL_SAFE(0);
return template;
}
/*
XOPEN(400,700)
*/
-
-
-#endif
diff --git a/src/stdlib/mrand48.c b/src/stdlib/mrand48.c
index 5f9a7f7d..3a1c78b7 100644
--- a/src/stdlib/mrand48.c
+++ b/src/stdlib/mrand48.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
long mrand48(void)
{
+ SIGNAL_SAFE(0);
return 0;
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/nrand48.c b/src/stdlib/nrand48.c
index 30ff633c..73ca509b 100644
--- a/src/stdlib/nrand48.c
+++ b/src/stdlib/nrand48.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
long nrand48(unsigned short xsubi[3])
{
+ SIGNAL_SAFE(0);
return 0;
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/ptsname.c b/src/stdlib/ptsname.c
index fc7cce1c..147aa934 100644
--- a/src/stdlib/ptsname.c
+++ b/src/stdlib/ptsname.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char * ptsname(int fildes)
{
+ SIGNAL_SAFE(0);
return NULL;
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/putenv.c b/src/stdlib/putenv.c
index 723ecb1f..0cfc1cb8 100644
--- a/src/stdlib/putenv.c
+++ b/src/stdlib/putenv.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
int putenv(char * string)
{
+ SIGNAL_SAFE(0);
return 0;
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/qsort.c b/src/stdlib/qsort.c
index 9fec5191..42764817 100644
--- a/src/stdlib/qsort.c
+++ b/src/stdlib/qsort.c
@@ -1,6 +1,5 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** sort an array **/
@@ -38,6 +37,7 @@ static void __qsort(char *base, size_t size, size_t lo, size_t hi, int (*compar)
void qsort(void * base, size_t nmemb, size_t size, int (*compar)(const void *, const void *))
{
+ SIGNAL_SAFE(0);
__qsort(base, size, 0, nmemb - 1, compar);
}
@@ -55,6 +55,3 @@ is greater than the second.
UNSPECIFIED(The order of equal elements)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/qsort_s.c b/src/stdlib/qsort_s.c
index 4510d36d..3586dad0 100644
--- a/src/stdlib/qsort_s.c
+++ b/src/stdlib/qsort_s.c
@@ -1,14 +1,14 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** sort an array **/
errno_t qsort_s(void *base, rsize_t nmemb, rsize_t size,
int (*compar)(const void * x, const void * y, void *context),
void * context)
{
- __C_EXT(1, 201112L);
- /* TODO */
+ SIGNAL_SAFE(0);
+ (void)base; (void)nmemb; (void)size; (void)compar; (void)context;
+ return 0;
}
/***
@@ -29,6 +29,3 @@ greater than the second.
/*
CEXT1(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/quick_exit.c b/src/stdlib/quick_exit.c
index e1f1213a..06c69da8 100644
--- a/src/stdlib/quick_exit.c
+++ b/src/stdlib/quick_exit.c
@@ -1,7 +1,4 @@
-#if 0
-
#include <stdlib.h>
-#include "_safety.h"
#include "_stdlib.h"
/** cause normal quick program termination **/
@@ -10,10 +7,12 @@ _Noreturn void quick_exit(int status)
SIGNAL_SAFE(1);
/* execute all at_quick_exit() registered functions in reverse order */
+ /*
while (__stdlib.at_quick_exit) {
__stdlib.at_quick_exit->fn();
__stdlib.at_quick_exit = __stdlib.at_quick_exit->prev;
}
+ */
fflush(NULL);
// fclose(all the things);
@@ -46,6 +45,3 @@ streams are closed. All temporary files created by fn(tmpfile) are removed.
/*
STDC(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/rand.c b/src/stdlib/rand.c
index f02adac0..588522a7 100644
--- a/src/stdlib/rand.c
+++ b/src/stdlib/rand.c
@@ -1,10 +1,11 @@
-#if 0
-
#include "_stdlib.h"
+#undef rand
/** get a pseudo-random number **/
int rand(void)
{
+ SIGNAL_SAFE(0);
+
return (int)_rand(__stdlib.rand);
}
@@ -16,6 +17,3 @@ computes a pseudo-random number in the range [0,CONSTANT(RAND_MAX)].
RETURN_SUCCESS(a pseudo-random integer)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/random.c b/src/stdlib/random.c
index 4cf34916..45f712a1 100644
--- a/src/stdlib/random.c
+++ b/src/stdlib/random.c
@@ -1,15 +1,13 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
long random(void)
{
+ SIGNAL_SAFE(0);
+
return 0;
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/realloc.c b/src/stdlib/realloc.c
index 98564654..982d01ac 100644
--- a/src/stdlib/realloc.c
+++ b/src/stdlib/realloc.c
@@ -1,5 +1,3 @@
-#if 0
-
#if ((!defined _POSIX_C_SOURCE) || (_POSIX_C_SOURCE < 199309L))
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L /* force mmap() constants */
@@ -7,9 +5,10 @@
#endif
#include <stdlib.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/mman.h>
+#include "_stdlib.h"
+//#include <sys/types.h>
+//#include <fcntl.h>
+//#include <sys/mman.h>
#ifdef POSIX_FORCED
#include "_syscall.h"
@@ -17,10 +16,18 @@
#define open(_p, _a, _m) __scall3(open, _p, _a, _m)
#endif
+#define O_RDWR 0
+#define PROT_READ 0
+#define PROT_WRITE 0
+#define MAP_PRIVATE 0
+#define MAP_FAILED 0
+
/** change the amount of memory allocated **/
void * realloc(void * ptr, size_t size)
{
+ SIGNAL_SAFE(0);
+
/* FIXME: forward dependency on POSIX.1b-1993, non-std /dev/zero */
static int backing = -1;
@@ -67,6 +74,3 @@ RETURN_FAILURE(CONSTANT(NULL))
RETURN_SUCCESS(a pointer to the reallocate space)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/realpath.c b/src/stdlib/realpath.c
index 07b946e2..db8b7cab 100644
--- a/src/stdlib/realpath.c
+++ b/src/stdlib/realpath.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char * realpath(const char * restrict file_name, char * restrict resolved_name)
{
+ SIGNAL_SAFE(0);
return resolved_name;
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/seed48.c b/src/stdlib/seed48.c
index 8a070709..42c194a4 100644
--- a/src/stdlib/seed48.c
+++ b/src/stdlib/seed48.c
@@ -1,15 +1,13 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
unsigned short * seed48(unsigned short seed16v[3])
{
+ SIGNAL_SAFE(0);
+
return seed16v;
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/set_constraint_handler_s.c b/src/stdlib/set_constraint_handler_s.c
index cecf3cbb..c042ec3b 100644
--- a/src/stdlib/set_constraint_handler_s.c
+++ b/src/stdlib/set_constraint_handler_s.c
@@ -1,16 +1,13 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
constraint_handler_t set_constraint_handler_s(constraint_handler_t handler)
{
- __C_EXT(1, 201112L);
+ SIGNAL_SAFE(0);
+
return handler;
}
/*
CEXT1(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/setkey.c b/src/stdlib/setkey.c
index 61386689..7659c223 100644
--- a/src/stdlib/setkey.c
+++ b/src/stdlib/setkey.c
@@ -1,14 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
void setkey(const char * key)
{
+ SIGNAL_SAFE(0);
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/setstate.c b/src/stdlib/setstate.c
index 9d7caa72..c58a0325 100644
--- a/src/stdlib/setstate.c
+++ b/src/stdlib/setstate.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
char * setstate(char * state)
{
+ SIGNAL_SAFE(0);
return state;
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/srand.c b/src/stdlib/srand.c
index ab364ad4..0870de9b 100644
--- a/src/stdlib/srand.c
+++ b/src/stdlib/srand.c
@@ -1,11 +1,11 @@
-#if 0
-
#include "_stdlib.h"
/** seed the pseudo-random number generator **/
void srand(unsigned int seed)
{
+ SIGNAL_SAFE(0);
+
__stdlib.rand = seed;
}
@@ -18,6 +18,3 @@ Program execution begins with a seed of 1.
/*
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/srand48.c b/src/stdlib/srand48.c
index fcd82d93..5c0768e9 100644
--- a/src/stdlib/srand48.c
+++ b/src/stdlib/srand48.c
@@ -1,14 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
void srand48(long seedval)
{
+ SIGNAL_SAFE(0);
}
/*
XOPEN(4)
*/
-
-
-#endif
diff --git a/src/stdlib/srandom.c b/src/stdlib/srandom.c
index b2822abd..07b93e3c 100644
--- a/src/stdlib/srandom.c
+++ b/src/stdlib/srandom.c
@@ -1,14 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
void srandom(unsigned seed)
{
+ SIGNAL_SAFE(0);
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/strtod.c b/src/stdlib/strtod.c
index 500c8e32..b259f05c 100644
--- a/src/stdlib/strtod.c
+++ b/src/stdlib/strtod.c
@@ -1,10 +1,9 @@
-#if 0
-
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
+#include "_stdlib.h"
#ifndef INFINITY
#include "math/INFINITY.h"
@@ -25,6 +24,8 @@ double strtod(const char * restrict nptr, char ** restrict endptr)
double nan = NAN;
double huge = HUGE_VAL;
+ SIGNAL_SAFE(0);
+
#include "_strtod.h"
return ret;
@@ -50,6 +51,3 @@ RETURN(CONSTANT(-HUGE_VAL), converted value too small)
RETURN(VAR(a TYPE(double)), the converted value)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/strtof.c b/src/stdlib/strtof.c
index 18c8b2ac..2dfb8183 100644
--- a/src/stdlib/strtof.c
+++ b/src/stdlib/strtof.c
@@ -1,10 +1,9 @@
-#if 0
-
#include <stdlib.h>
#include <float.h>
#include <errno.h>
#include <ctype.h>
#include <math.h>
+#include "_stdlib.h"
/** convert string to floating-point **/
@@ -17,6 +16,8 @@ float strtof(const char * restrict nptr, char ** restrict endptr)
float inf = INFINITY;
float nan = NAN;
+ SIGNAL_SAFE(0);
+
#include "_strtod.h"
return ret;
@@ -42,6 +43,3 @@ RETURN(CONSTANT(-HUGE_VALF), converted value too small)
RETURN(VAR(a TYPE(float)), the converted value)
STDC(199901)
*/
-
-
-#endif
diff --git a/src/stdlib/strtol.c b/src/stdlib/strtol.c
index 9b12b0e6..dc2b9d87 100644
--- a/src/stdlib/strtol.c
+++ b/src/stdlib/strtol.c
@@ -1,9 +1,8 @@
-#if 0
-
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
+#include "_stdlib.h"
/** convert string to long integer **/
@@ -13,6 +12,8 @@ long int strtol(const char * restrict nptr, char ** restrict endptr, int base)
long int max = LONG_MAX;
long int min = LONG_MIN;
+ SIGNAL_SAFE(0);
+
#include "_strtoi.h"
return ret;
@@ -47,6 +48,3 @@ RETURN(CONSTANT(LONG_MIN), converted value too small)
RETURN(a TYPE(long int) value, the converted value)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/strtold.c b/src/stdlib/strtold.c
index 5bb5bf63..43fc77bd 100644
--- a/src/stdlib/strtold.c
+++ b/src/stdlib/strtold.c
@@ -1,10 +1,9 @@
-#if 0
-
#include <stdlib.h>
#include <float.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
+#include "_stdlib.h"
/** convert string to floating-point **/
@@ -17,6 +16,8 @@ long double strtold(const char * restrict nptr, char ** restrict endptr)
long double inf = INFINITY;
long double nan = NAN;
+ SIGNAL_SAFE(0);
+
#include "_strtod.h"
return ret;
@@ -42,6 +43,3 @@ RETURN(CONSTANT(-HUGE_VALL), converted value too small)
RETURN(VAR(a TYPE(long double)), the converted value)
STDC(199901)
*/
-
-
-#endif
diff --git a/src/stdlib/strtoll.c b/src/stdlib/strtoll.c
index 5df50390..10f05209 100644
--- a/src/stdlib/strtoll.c
+++ b/src/stdlib/strtoll.c
@@ -1,9 +1,8 @@
-#if 0
-
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
+#include "_stdlib.h"
long long int strtoll(const char * restrict nptr, char ** restrict endptr, int base)
{
@@ -11,6 +10,8 @@ long long int strtoll(const char * restrict nptr, char ** restrict endptr, int b
long long int max = LLONG_MAX;
long long int min = LLONG_MIN;
+ SIGNAL_SAFE(0);
+
#include "_strtoi.h"
return ret;
@@ -19,6 +20,3 @@ long long int strtoll(const char * restrict nptr, char ** restrict endptr, int b
/*
STDC(199901)
*/
-
-
-#endif
diff --git a/src/stdlib/strtoul.c b/src/stdlib/strtoul.c
index aa952d0c..1270c92c 100644
--- a/src/stdlib/strtoul.c
+++ b/src/stdlib/strtoul.c
@@ -1,9 +1,8 @@
-#if 0
-
#include <errno.h>
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
+#include "_stdlib.h"
/** convert string to unsigned long integer **/
@@ -13,6 +12,8 @@ unsigned long int strtoul(const char * nptr, char ** endptr, int base)
unsigned long int max = ULONG_MAX;
unsigned long int min = 0;
+ SIGNAL_SAFE(0);
+
#include "_strtoi.h"
return ret;
@@ -46,6 +47,3 @@ RETURN(ULONG_MAX, converted value too large)
RETURN(an TYPE(unsigned long int) value, the converted value)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/strtoull.c b/src/stdlib/strtoull.c
index bf0eff9a..2a74df16 100644
--- a/src/stdlib/strtoull.c
+++ b/src/stdlib/strtoull.c
@@ -1,9 +1,8 @@
-#if 0
-
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
+#include "_stdlib.h"
unsigned long long int strtoull(const char * restrict nptr, char ** restrict endptr, int base)
{
@@ -11,6 +10,8 @@ unsigned long long int strtoull(const char * restrict nptr, char ** restrict end
unsigned long long int max = ULLONG_MAX;
unsigned long long int min = 0;
+ SIGNAL_SAFE(0);
+
#include "_strtoi.h"
return ret;
@@ -19,6 +20,3 @@ unsigned long long int strtoull(const char * restrict nptr, char ** restrict end
/*
STDC(199901)
*/
-
-
-#endif
diff --git a/src/stdlib/system.c b/src/stdlib/system.c
index dff181d9..863cfdca 100644
--- a/src/stdlib/system.c
+++ b/src/stdlib/system.c
@@ -1,6 +1,5 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
#ifdef _POSIX_SOURCE
# include <errno.h>
@@ -13,6 +12,8 @@
int system(const char * string)
{
+ SIGNAL_SAFE(0);
+
#ifdef _POSIX_SOURCE
pid_t pid;
int status;
@@ -69,6 +70,3 @@ RETURN(NONZERO, If ARGUMENT(string) is CONSTANT(NULL), a command processor is av
RETURN(0, If ARGUMENT(string) is CONSTANT(NULL), a command processor is not available)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/ttyslot.c b/src/stdlib/ttyslot.c
index 2fe95dc9..1d440739 100644
--- a/src/stdlib/ttyslot.c
+++ b/src/stdlib/ttyslot.c
@@ -1,15 +1,13 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
int ttyslot(void)
{
+ SIGNAL_SAFE(0);
+
return 0;
}
/*
XOPEN(400,600)
*/
-
-
-#endif
diff --git a/src/stdlib/unlockpt.c b/src/stdlib/unlockpt.c
index 45fcc941..69572138 100644
--- a/src/stdlib/unlockpt.c
+++ b/src/stdlib/unlockpt.c
@@ -1,15 +1,12 @@
-#if 0
-
#include <stdlib.h>
int unlockpt(int fildes)
{
+ SIGNAL_SAFE(0);
+
return fildes;
}
/*
XOPEN(400)
*/
-
-
-#endif
diff --git a/src/stdlib/valloc.c b/src/stdlib/valloc.c
index 647751be..c93b2c43 100644
--- a/src/stdlib/valloc.c
+++ b/src/stdlib/valloc.c
@@ -1,14 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
void *valloc(size_t size)
{
+ SIGNAL_SAFE(0);
}
/*
XOPEN(400,600)
*/
-
-
-#endif
diff --git a/src/stdlib/wcstombs.c b/src/stdlib/wcstombs.c
index a39cdc38..1d9dd4eb 100644
--- a/src/stdlib/wcstombs.c
+++ b/src/stdlib/wcstombs.c
@@ -1,11 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert wide character string to multibyte string **/
size_t wcstombs(char * restrict s, const wchar_t * restrict pwcs, size_t n)
{
+ SIGNAL_SAFE(0);
+
(void)s; (void)pwcs; (void)n;
/* TODO */
return 0;
@@ -25,6 +26,3 @@ RETURN_FAILURE(-1)
RETURN_SUCCESS(the number of bytes modified, not counting any terminating null)
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/wcstombs_s.c b/src/stdlib/wcstombs_s.c
index 180426a0..d5c830fa 100644
--- a/src/stdlib/wcstombs_s.c
+++ b/src/stdlib/wcstombs_s.c
@@ -1,11 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert wide character string to multibyte string **/
errno_t wcstombs_s(size_t * restrict retval, char * restrict dst, rsize_t dstmax, const wchar_t * restrict src, rsize_t len)
{
- __C_EXT(1, 201112L);
+ SIGNAL_SAFE(0);
+ (void)retval; (void)dst; (void)dstmax; (void)src; (void)len;
/* TODO */
return 0;
}
@@ -28,6 +28,3 @@ after reaching a null wide character, which is converted and stored.
/*
CEXT1(201112)
*/
-
-
-#endif
diff --git a/src/stdlib/wctomb.c b/src/stdlib/wctomb.c
index 3d834d3b..ce4c8e82 100644
--- a/src/stdlib/wctomb.c
+++ b/src/stdlib/wctomb.c
@@ -1,11 +1,12 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert wide character to multibyte character **/
int wctomb(char * s, wchar_t wchar)
{
+ SIGNAL_SAFE(0);
+
/* FIXME: forward dependency on AMD1 */
#if 0
static mbstate_t ps = 0;
@@ -33,6 +34,3 @@ RETURN(-1, The value of ARGUMENT(wchar) does not correspond to a valid multibyte
RETURN(TYPE(int), The number of bytes contained in the multibyte character corresponding to ARGUMENT(wchar))
STDC(1)
*/
-
-
-#endif
diff --git a/src/stdlib/wctomb_s.c b/src/stdlib/wctomb_s.c
index ea3e6865..8027c59d 100644
--- a/src/stdlib/wctomb_s.c
+++ b/src/stdlib/wctomb_s.c
@@ -1,11 +1,11 @@
-#if 0
-
#include <stdlib.h>
+#include "_stdlib.h"
/** convert wide character to multibyte character **/
errno_t wctomb_s(int * restrict status, char * restrict s, rsize_t smax, wchar_t wc)
{
- __C_EXT(1, 201112L);
+ SIGNAL_SAFE(0);
+ (void)status; (void)s; (void)smax; (void)wc;
/* TODO */
return 0;
}
@@ -32,6 +32,3 @@ state dependency.
/*
CEXT1(201112)
*/
-
-
-#endif