diff options
author | Jakob Kaivo <jkk@ung.org> | 2024-06-05 15:07:06 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2024-06-05 15:07:06 -0400 |
commit | 1161633db54ce8fd1180649f52909390a2986213 (patch) | |
tree | 81eb6390d21e2ad435595f534664121b181a5bb5 /src/stdlib | |
parent | 66d9ce2cdab4e989e7b4fbab17ba7f4aa4a4af70 (diff) |
rename all per-header internal structs to __<header>_h
Diffstat (limited to 'src/stdlib')
-rw-r--r-- | src/stdlib/__stdlib_h.c (renamed from src/stdlib/__stdlib.c) | 2 | ||||
-rw-r--r-- | src/stdlib/_stdlib.h | 6 | ||||
-rw-r--r-- | src/stdlib/at_quick_exit.c | 2 | ||||
-rw-r--r-- | src/stdlib/atexit.c | 2 | ||||
-rw-r--r-- | src/stdlib/exit.c | 12 | ||||
-rw-r--r-- | src/stdlib/getenv.c | 6 | ||||
-rw-r--r-- | src/stdlib/quick_exit.c | 12 | ||||
-rw-r--r-- | src/stdlib/rand.c | 2 | ||||
-rw-r--r-- | src/stdlib/srand.c | 2 |
9 files changed, 22 insertions, 24 deletions
diff --git a/src/stdlib/__stdlib.c b/src/stdlib/__stdlib_h.c index 10117f1e..dd277546 100644 --- a/src/stdlib/__stdlib.c +++ b/src/stdlib/__stdlib_h.c @@ -1,6 +1,6 @@ #include "_stdlib.h" -struct __stdlib __stdlib = { +struct __stdlib_h __stdlib_h = { #if __STDC_VERSION__ >= 201112 && defined __STDC_WANT_LIB_EXT1__ .constraint_handler = abort_handler_s, #endif diff --git a/src/stdlib/_stdlib.h b/src/stdlib/_stdlib.h index d5f89b09..64e64abd 100644 --- a/src/stdlib/_stdlib.h +++ b/src/stdlib/_stdlib.h @@ -53,7 +53,7 @@ static int __safe_compar(int (*compar)(const void *, const void *), const void * #include "__constraint_info.h" void abort_handler_s(const char * restrict msg, void * restrict ptr, errno_t error); -struct __stdlib { +extern struct __stdlib_h { struct atexit { int nfns; void (*fns[32])(void); @@ -64,9 +64,7 @@ struct __stdlib { unsigned int rand; constraint_handler_t constraint_handler; char **environ; -}; - -extern struct __stdlib __stdlib; +} __stdlib_h; #ifdef _POSIX_SOURCE extern char **environ; diff --git a/src/stdlib/at_quick_exit.c b/src/stdlib/at_quick_exit.c index 6a6db796..d23dfda8 100644 --- a/src/stdlib/at_quick_exit.c +++ b/src/stdlib/at_quick_exit.c @@ -8,7 +8,7 @@ int at_quick_exit(void (*func)(void)) { SIGNAL_SAFE(0); - struct atexit *ae = &(__stdlib.at_quick_exit); + struct atexit *ae = &(__stdlib_h.at_quick_exit); 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/atexit.c b/src/stdlib/atexit.c index d4b54c5f..e1d57df4 100644 --- a/src/stdlib/atexit.c +++ b/src/stdlib/atexit.c @@ -6,7 +6,7 @@ int atexit(void (*func)(void)) { - struct atexit *ae = &(__stdlib.atexit); + struct atexit *ae = &(__stdlib_h.atexit); SIGNAL_SAFE(0); diff --git a/src/stdlib/exit.c b/src/stdlib/exit.c index e6423891..928c4423 100644 --- a/src/stdlib/exit.c +++ b/src/stdlib/exit.c @@ -8,17 +8,17 @@ /** cause normal program termination **/ _Noreturn void exit(int status) { - struct atexit *ae = &(__stdlib.atexit); + struct atexit *ae = &(__stdlib_h.atexit); SIGNAL_SAFE(0); - if (__stdlib.exit_called == QUICK) { - __stdlib.constraint_handler("Undefined behavior: exit() called after quick_exit()", NULL, 0); + if (__stdlib_h.exit_called == QUICK) { + __stdlib_h.constraint_handler("Undefined behavior: exit() called after quick_exit()", NULL, 0); } - if (__stdlib.exit_called == REGULAR) { - __stdlib.constraint_handler("Undefined behavior: exit() called twice", NULL, 0); + if (__stdlib_h.exit_called == REGULAR) { + __stdlib_h.constraint_handler("Undefined behavior: exit() called twice", NULL, 0); } - __stdlib.exit_called = REGULAR; + __stdlib_h.exit_called = REGULAR; /* execute all atexit() registered functions in reverse order */ while (ae) { diff --git a/src/stdlib/getenv.c b/src/stdlib/getenv.c index 5ef8f6a9..a2747998 100644 --- a/src/stdlib/getenv.c +++ b/src/stdlib/getenv.c @@ -17,10 +17,10 @@ char * getenv(const char * name) } len = strlen(name); - for (i = 0; __stdlib.environ[i] != NULL; i++) { - if (!strncmp(__stdlib.environ[i], name, len) && __stdlib.environ[i][len] == '=') { + for (i = 0; __stdlib_h.environ[i] != NULL; i++) { + if (!strncmp(__stdlib_h.environ[i], name, len) && __stdlib_h.environ[i][len] == '=') { __readonly(RO_UNLOCK, variable); - strcpy(variable, __stdlib.environ[i] + len + 1); + strcpy(variable, __stdlib_h.environ[i] + len + 1); __readonly(RO_LOCK, variable); return variable; } diff --git a/src/stdlib/quick_exit.c b/src/stdlib/quick_exit.c index 9ad6780e..59039e7b 100644 --- a/src/stdlib/quick_exit.c +++ b/src/stdlib/quick_exit.c @@ -7,16 +7,16 @@ _Noreturn void quick_exit(int status) { SIGNAL_SAFE(1); - if (__stdlib.exit_called == QUICK) { - __stdlib.constraint_handler("Undefined behavior: quick_exit() called twice", NULL, 0); + if (__stdlib_h.exit_called == QUICK) { + __stdlib_h.constraint_handler("Undefined behavior: quick_exit() called twice", NULL, 0); } - if (__stdlib.exit_called) { - __stdlib.constraint_handler("Undefined behavior: quick_exit() called after exit", NULL, 0); + if (__stdlib_h.exit_called) { + __stdlib_h.constraint_handler("Undefined behavior: quick_exit() called after exit", NULL, 0); } - __stdlib.exit_called = QUICK; + __stdlib_h.exit_called = QUICK; /* execute all at_quick_exit() registered functions in reverse order */ - struct atexit *ae = &(__stdlib.at_quick_exit); + struct atexit *ae = &(__stdlib_h.at_quick_exit); while (ae) { int i = ae->nfns; while (i > 0) { diff --git a/src/stdlib/rand.c b/src/stdlib/rand.c index a68dc046..00670dd5 100644 --- a/src/stdlib/rand.c +++ b/src/stdlib/rand.c @@ -5,7 +5,7 @@ int rand(void) { SIGNAL_SAFE(0); - return (int)_rand(__stdlib.rand); + return (int)_rand(__stdlib_h.rand); } /*** diff --git a/src/stdlib/srand.c b/src/stdlib/srand.c index 0870de9b..31f37a48 100644 --- a/src/stdlib/srand.c +++ b/src/stdlib/srand.c @@ -6,7 +6,7 @@ void srand(unsigned int seed) { SIGNAL_SAFE(0); - __stdlib.rand = seed; + __stdlib_h.rand = seed; } /*** |