summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-06-05 15:07:06 -0400
committerJakob Kaivo <jkk@ung.org>2024-06-05 15:07:06 -0400
commit1161633db54ce8fd1180649f52909390a2986213 (patch)
tree81eb6390d21e2ad435595f534664121b181a5bb5
parent66d9ce2cdab4e989e7b4fbab17ba7f4aa4a4af70 (diff)
rename all per-header internal structs to __<header>_h
-rw-r--r--mk/__fenv.d9
-rw-r--r--mk/__fenv_h.d9
-rw-r--r--mk/__stdio.d9
-rw-r--r--mk/__stdio_h.d9
-rw-r--r--mk/__stdlib.d9
-rw-r--r--mk/__stdlib_h.d9
-rw-r--r--mk/__time.d9
-rw-r--r--mk/__time_h.d9
-rw-r--r--mk/all.mk8
-rw-r--r--mk/deps.mk32
-rw-r--r--src/__main.c12
-rw-r--r--src/fenv/__fenv_h.c (renamed from src/fenv/__fenv.c)2
-rw-r--r--src/fenv/_fenv.h4
-rw-r--r--src/signal/__signal_h.c2
-rw-r--r--src/signal/__signal_handler.c2
-rw-r--r--src/signal/_signal.h2
-rw-r--r--src/signal/raise.c2
-rw-r--r--src/stdio/__printf.c2
-rw-r--r--src/stdio/__scanf.c2
-rw-r--r--src/stdio/__stdio_h.c (renamed from src/stdio/__stdio.c)2
-rw-r--r--src/stdio/_stdio.h6
-rw-r--r--src/stdio/fflush.c2
-rw-r--r--src/stdio/fopen.c4
-rw-r--r--src/stdlib/__stdlib_h.c (renamed from src/stdlib/__stdlib.c)2
-rw-r--r--src/stdlib/_stdlib.h6
-rw-r--r--src/stdlib/at_quick_exit.c2
-rw-r--r--src/stdlib/atexit.c2
-rw-r--r--src/stdlib/exit.c12
-rw-r--r--src/stdlib/getenv.c6
-rw-r--r--src/stdlib/quick_exit.c12
-rw-r--r--src/stdlib/rand.c2
-rw-r--r--src/stdlib/srand.c2
-rw-r--r--src/time/__time_h.c (renamed from src/time/__time.c)2
-rw-r--r--src/time/_time.h6
34 files changed, 102 insertions, 108 deletions
diff --git a/mk/__fenv.d b/mk/__fenv.d
deleted file mode 100644
index 00fd56f5..00000000
--- a/mk/__fenv.d
+++ /dev/null
@@ -1,9 +0,0 @@
-libc_C.-1: libc.a(__fenv.o)
-libc.a(__fenv.o): $(OBJDIR)/__fenv.o
- @$(AR) $(ARFLAGS) $@ $(OBJDIR)/$%
-
-$(OBJDIR)/__fenv.o: src/fenv/__fenv.c
-$(OBJDIR)/__fenv.o: src/fenv/_fenv.h
-$(OBJDIR)/__fenv.o:
- @mkdir -p $(@D)
- $(CC) -c -o $@ $(CFLAGS) src/fenv/__fenv.c
diff --git a/mk/__fenv_h.d b/mk/__fenv_h.d
new file mode 100644
index 00000000..749d3b9e
--- /dev/null
+++ b/mk/__fenv_h.d
@@ -0,0 +1,9 @@
+libc_C.-1: libc.a(__fenv_h.o)
+libc.a(__fenv_h.o): $(OBJDIR)/__fenv_h.o
+ @$(AR) $(ARFLAGS) $@ $(OBJDIR)/$%
+
+$(OBJDIR)/__fenv_h.o: src/fenv/__fenv_h.c
+$(OBJDIR)/__fenv_h.o: src/fenv/_fenv.h
+$(OBJDIR)/__fenv_h.o:
+ @mkdir -p $(@D)
+ $(CC) -c -o $@ $(CFLAGS) src/fenv/__fenv_h.c
diff --git a/mk/__stdio.d b/mk/__stdio.d
deleted file mode 100644
index c3b2d0b5..00000000
--- a/mk/__stdio.d
+++ /dev/null
@@ -1,9 +0,0 @@
-libc_C.0: libc.a(__stdio.o)
-libc.a(__stdio.o): $(OBJDIR)/__stdio.o
- @$(AR) $(ARFLAGS) $@ $(OBJDIR)/$%
-
-$(OBJDIR)/__stdio.o: src/stdio/__stdio.c
-$(OBJDIR)/__stdio.o: src/stdio/_stdio.h
-$(OBJDIR)/__stdio.o:
- @mkdir -p $(@D)
- $(CC) -c -o $@ $(CFLAGS) src/stdio/__stdio.c
diff --git a/mk/__stdio_h.d b/mk/__stdio_h.d
new file mode 100644
index 00000000..36cc4336
--- /dev/null
+++ b/mk/__stdio_h.d
@@ -0,0 +1,9 @@
+libc_C.0: libc.a(__stdio_h.o)
+libc.a(__stdio_h.o): $(OBJDIR)/__stdio_h.o
+ @$(AR) $(ARFLAGS) $@ $(OBJDIR)/$%
+
+$(OBJDIR)/__stdio_h.o: src/stdio/__stdio_h.c
+$(OBJDIR)/__stdio_h.o: src/stdio/_stdio.h
+$(OBJDIR)/__stdio_h.o:
+ @mkdir -p $(@D)
+ $(CC) -c -o $@ $(CFLAGS) src/stdio/__stdio_h.c
diff --git a/mk/__stdlib.d b/mk/__stdlib.d
deleted file mode 100644
index 8dfb2640..00000000
--- a/mk/__stdlib.d
+++ /dev/null
@@ -1,9 +0,0 @@
-libc_C.0: libc.a(__stdlib.o)
-libc.a(__stdlib.o): $(OBJDIR)/__stdlib.o
- @$(AR) $(ARFLAGS) $@ $(OBJDIR)/$%
-
-$(OBJDIR)/__stdlib.o: src/stdlib/__stdlib.c
-$(OBJDIR)/__stdlib.o: src/stdlib/_stdlib.h
-$(OBJDIR)/__stdlib.o:
- @mkdir -p $(@D)
- $(CC) -c -o $@ $(CFLAGS) src/stdlib/__stdlib.c
diff --git a/mk/__stdlib_h.d b/mk/__stdlib_h.d
new file mode 100644
index 00000000..5ca8d477
--- /dev/null
+++ b/mk/__stdlib_h.d
@@ -0,0 +1,9 @@
+libc_C.0: libc.a(__stdlib_h.o)
+libc.a(__stdlib_h.o): $(OBJDIR)/__stdlib_h.o
+ @$(AR) $(ARFLAGS) $@ $(OBJDIR)/$%
+
+$(OBJDIR)/__stdlib_h.o: src/stdlib/__stdlib_h.c
+$(OBJDIR)/__stdlib_h.o: src/stdlib/_stdlib.h
+$(OBJDIR)/__stdlib_h.o:
+ @mkdir -p $(@D)
+ $(CC) -c -o $@ $(CFLAGS) src/stdlib/__stdlib_h.c
diff --git a/mk/__time.d b/mk/__time.d
deleted file mode 100644
index f4be0c7a..00000000
--- a/mk/__time.d
+++ /dev/null
@@ -1,9 +0,0 @@
-libc_C.-1: libc.a(__time.o)
-libc.a(__time.o): $(OBJDIR)/__time.o
- @$(AR) $(ARFLAGS) $@ $(OBJDIR)/$%
-
-$(OBJDIR)/__time.o: src/time/__time.c
-$(OBJDIR)/__time.o: src/time/_time.h
-$(OBJDIR)/__time.o:
- @mkdir -p $(@D)
- $(CC) -c -o $@ $(CFLAGS) src/time/__time.c
diff --git a/mk/__time_h.d b/mk/__time_h.d
new file mode 100644
index 00000000..7aad4841
--- /dev/null
+++ b/mk/__time_h.d
@@ -0,0 +1,9 @@
+libc_C.-1: libc.a(__time_h.o)
+libc.a(__time_h.o): $(OBJDIR)/__time_h.o
+ @$(AR) $(ARFLAGS) $@ $(OBJDIR)/$%
+
+$(OBJDIR)/__time_h.o: src/time/__time_h.c
+$(OBJDIR)/__time_h.o: src/time/_time.h
+$(OBJDIR)/__time_h.o:
+ @mkdir -p $(@D)
+ $(CC) -c -o $@ $(CFLAGS) src/time/__time_h.c
diff --git a/mk/all.mk b/mk/all.mk
index 82a3ac40..a717f8f1 100644
--- a/mk/all.mk
+++ b/mk/all.mk
@@ -52,13 +52,13 @@ include mk/fesetexceptflag.d
include mk/fetestexcept.d
include mk/fegetexceptflag.d
include mk/fesetround.d
-include mk/__fenv.d
include mk/feupdateenv.d
include mk/feholdexcept.d
include mk/fesetenv.d
include mk/feclearexcept.d
include mk/fegetround.d
include mk/fegetenv.d
+include mk/__fenv_h.d
include mk/__dangerous.d
include mk/atomic_store.d
include mk/atomic_compare_exchange_weak.d
@@ -211,9 +211,9 @@ include mk/clock.d
include mk/gmtime_s.d
include mk/strftime.d
include mk/localtime.d
-include mk/__time.d
include mk/localtime_s.d
include mk/nanosleep.d
+include mk/__time_h.d
include mk/mktime.d
include mk/asctime.d
include mk/__readonly.d
@@ -259,7 +259,6 @@ include mk/fscanf_s.d
include mk/getchar_unlocked.d
include mk/tmpnam.d
include mk/fsetpos.d
-include mk/__stdio.d
include mk/scanf.d
include mk/gets_s.d
include mk/gets.d
@@ -280,6 +279,7 @@ include mk/snprintf.d
include mk/putchar_unlocked.d
include mk/flockfile.d
include mk/fprintf_s.d
+include mk/__stdio_h.d
include mk/freopen_s.d
include mk/sprintf.d
include mk/fscanf.d
@@ -450,6 +450,7 @@ include mk/qsort.d
include mk/strtold.d
include mk/free.d
include mk/strtoull.d
+include mk/__stdlib_h.d
include mk/mblen.d
include mk/abs.d
include mk/lldiv.d
@@ -476,7 +477,6 @@ include mk/wctomb_s.d
include mk/strtod.d
include mk/bsearch_s.d
include mk/realloc.d
-include mk/__stdlib.d
include mk/calloc.d
include mk/div.d
include mk/__sys.x86-64.s.d
diff --git a/mk/deps.mk b/mk/deps.mk
index c7865c33..a7de1837 100644
--- a/mk/deps.mk
+++ b/mk/deps.mk
@@ -218,10 +218,6 @@ all: mk/fesetround.d
mk/fesetround.d: src/fenv/fesetround.c
sh mk/deps.sh src/fenv/fesetround.c
-all: mk/__fenv.d
-mk/__fenv.d: src/fenv/__fenv.c
- sh mk/deps.sh src/fenv/__fenv.c
-
all: mk/feupdateenv.d
mk/feupdateenv.d: src/fenv/feupdateenv.c
sh mk/deps.sh src/fenv/feupdateenv.c
@@ -246,6 +242,10 @@ all: mk/fegetenv.d
mk/fegetenv.d: src/fenv/fegetenv.c
sh mk/deps.sh src/fenv/fegetenv.c
+all: mk/__fenv_h.d
+mk/__fenv_h.d: src/fenv/__fenv_h.c
+ sh mk/deps.sh src/fenv/__fenv_h.c
+
all: mk/__dangerous.d
mk/__dangerous.d: src/__dangerous.c
sh mk/deps.sh src/__dangerous.c
@@ -854,10 +854,6 @@ all: mk/localtime.d
mk/localtime.d: src/time/localtime.c
sh mk/deps.sh src/time/localtime.c
-all: mk/__time.d
-mk/__time.d: src/time/__time.c
- sh mk/deps.sh src/time/__time.c
-
all: mk/localtime_s.d
mk/localtime_s.d: src/time/localtime_s.c
sh mk/deps.sh src/time/localtime_s.c
@@ -866,6 +862,10 @@ all: mk/nanosleep.d
mk/nanosleep.d: src/time/nanosleep.c
sh mk/deps.sh src/time/nanosleep.c
+all: mk/__time_h.d
+mk/__time_h.d: src/time/__time_h.c
+ sh mk/deps.sh src/time/__time_h.c
+
all: mk/mktime.d
mk/mktime.d: src/time/mktime.c
sh mk/deps.sh src/time/mktime.c
@@ -1046,10 +1046,6 @@ all: mk/fsetpos.d
mk/fsetpos.d: src/stdio/fsetpos.c
sh mk/deps.sh src/stdio/fsetpos.c
-all: mk/__stdio.d
-mk/__stdio.d: src/stdio/__stdio.c
- sh mk/deps.sh src/stdio/__stdio.c
-
all: mk/scanf.d
mk/scanf.d: src/stdio/scanf.c
sh mk/deps.sh src/stdio/scanf.c
@@ -1130,6 +1126,10 @@ all: mk/fprintf_s.d
mk/fprintf_s.d: src/stdio/fprintf_s.c
sh mk/deps.sh src/stdio/fprintf_s.c
+all: mk/__stdio_h.d
+mk/__stdio_h.d: src/stdio/__stdio_h.c
+ sh mk/deps.sh src/stdio/__stdio_h.c
+
all: mk/freopen_s.d
mk/freopen_s.d: src/stdio/freopen_s.c
sh mk/deps.sh src/stdio/freopen_s.c
@@ -1810,6 +1810,10 @@ all: mk/strtoull.d
mk/strtoull.d: src/stdlib/strtoull.c
sh mk/deps.sh src/stdlib/strtoull.c
+all: mk/__stdlib_h.d
+mk/__stdlib_h.d: src/stdlib/__stdlib_h.c
+ sh mk/deps.sh src/stdlib/__stdlib_h.c
+
all: mk/mblen.d
mk/mblen.d: src/stdlib/mblen.c
sh mk/deps.sh src/stdlib/mblen.c
@@ -1914,10 +1918,6 @@ all: mk/realloc.d
mk/realloc.d: src/stdlib/realloc.c
sh mk/deps.sh src/stdlib/realloc.c
-all: mk/__stdlib.d
-mk/__stdlib.d: src/stdlib/__stdlib.c
- sh mk/deps.sh src/stdlib/__stdlib.c
-
all: mk/calloc.d
mk/calloc.d: src/stdlib/calloc.c
sh mk/deps.sh src/stdlib/calloc.c
diff --git a/src/__main.c b/src/__main.c
index 16fe3808..a24c24ef 100644
--- a/src/__main.c
+++ b/src/__main.c
@@ -22,30 +22,30 @@ void __init_libc(void)
}
init = 1;
- __stdin = /* stdin ? stdin : */ __stdio.FILES + 0;
+ __stdin = /* stdin ? stdin : */ __stdio_h.FILES + 0;
__stdin->fd = 0;
freopen(NULL, "r", __stdin);
- __stdout = /* stdout ? stdout : */ __stdio.FILES + 1;
+ __stdout = /* stdout ? stdout : */ __stdio_h.FILES + 1;
__stdout->fd = 1;
freopen(NULL, "w", __stdout);
- __stderr = /* stderr ? stderr : */ __stdio.FILES + 2;
+ __stderr = /* stderr ? stderr : */ __stdio_h.FILES + 2;
__stderr->fd = 2;
freopen(NULL, "w", __stderr);
setvbuf(__stderr, NULL, _IONBF, 0);
#if 0 && _POSIX_SOURCE
extern char **environ;
- __stdlib.environ = environ;
+ __stdlib_h.environ = environ;
#endif
}
void __main(int (*main)(int, char*[]), int argc, char **argv)
{
- __stdlib.environ = argv + argc + 1;
+ __stdlib_h.environ = argv + argc + 1;
#ifdef _POSIX_SOURCE
- environ = __stdlib.environ;
+ environ = __stdlib_h.environ;
#endif
__init_libc();
diff --git a/src/fenv/__fenv.c b/src/fenv/__fenv_h.c
index 09181539..0cebd658 100644
--- a/src/fenv/__fenv.c
+++ b/src/fenv/__fenv_h.c
@@ -1,6 +1,6 @@
#include "_fenv.h"
-struct __fenv __fenv = { 0 };
+struct __fenv __fenv_h = { 0 };
/*
STDC(-1)
diff --git a/src/fenv/_fenv.h b/src/fenv/_fenv.h
index 6daf2246..0455fef3 100644
--- a/src/fenv/_fenv.h
+++ b/src/fenv/_fenv.h
@@ -1,12 +1,12 @@
#include <fenv.h>
#include "_safety.h"
-extern struct __fenv {
+extern struct __fenv_h {
fexcept_t *valid_fexcept;
size_t nvalid_fexcept;
fenv_t *valid_fenv;
size_t nvalid_fenv;
-} __fenv;
+} __fenv_h;
#ifdef NDEBUG
#define ASSERT_VALID_EXCEPTION_MASK(_n) (void)(_n)
diff --git a/src/signal/__signal_h.c b/src/signal/__signal_h.c
index fde51b63..87ec8e28 100644
--- a/src/signal/__signal_h.c
+++ b/src/signal/__signal_h.c
@@ -1,6 +1,6 @@
#include "_signal.h"
-struct __signal __signal_h = { 0 };
+struct __signal_h __signal_h = { 0 };
/*
STDC(0)
diff --git a/src/signal/__signal_handler.c b/src/signal/__signal_handler.c
index 2e8afd1e..7bd6718a 100644
--- a/src/signal/__signal_handler.c
+++ b/src/signal/__signal_handler.c
@@ -5,7 +5,7 @@
void __signal_handler(int sig)
{
- if (__stdlib.exit_called == QUICK) {
+ if (__stdlib_h.exit_called == QUICK) {
UNDEFINED("signal %d occured during quick_exit", sig);
}
diff --git a/src/signal/_signal.h b/src/signal/_signal.h
index f450c053..1e484f83 100644
--- a/src/signal/_signal.h
+++ b/src/signal/_signal.h
@@ -7,7 +7,7 @@
typedef void (*handler)(int);
-extern struct __signal {
+extern struct __signal_h {
int current;
handler handlers[NSIGNALS];
} __signal_h;
diff --git a/src/signal/raise.c b/src/signal/raise.c
index 0547e4a1..7b3d876e 100644
--- a/src/signal/raise.c
+++ b/src/signal/raise.c
@@ -11,7 +11,7 @@
int raise(int sig)
{
SIGNAL_SAFE(0);
- if (__stdlib.exit_called == QUICK) {
+ if (__stdlib_h.exit_called == QUICK) {
UNDEFINED("raise() called during quick_exit()");
}
/*
diff --git a/src/stdio/__printf.c b/src/stdio/__printf.c
index 05c79747..807e0948 100644
--- a/src/stdio/__printf.c
+++ b/src/stdio/__printf.c
@@ -344,7 +344,7 @@ int (__printf)(struct io_options *opt, const char * format, va_list arg)
nout = __append(s, "0x", nout, n);
__itos(numbuf, (intptr_t)argptr, ZERO, sizeof(argptr) * 2, 16);
nout = __append(s, numbuf, nout, n);
- ADD_PREV_STRING(s_to_track, __stdio.formatted_pointers, __stdio.nformatted_pointers);
+ ADD_PREV_STRING(s_to_track, __stdio_h.formatted_pointers, __stdio_h.nformatted_pointers);
break;
case 'n': /* write-back */
diff --git a/src/stdio/__scanf.c b/src/stdio/__scanf.c
index 75e42942..9869fa37 100644
--- a/src/stdio/__scanf.c
+++ b/src/stdio/__scanf.c
@@ -253,7 +253,7 @@ int __scanf(struct io_options *opt, const char * format, va_list arg)
/* TODO: error checking */
str_ptr[i] = __get(opt);
}
- ASSERT_PREV_STRING(str_ptr, __stdio.formatted_pointers, __stdio.nformatted_pointers, "printf() or similar");
+ ASSERT_PREV_STRING(str_ptr, __stdio_h.formatted_pointers, __stdio_h.nformatted_pointers, "printf() or similar");
void **ptr = va_arg(arg, void **);
if (ptr == NULL) {
UNDEFINED("parameter is NULL");
diff --git a/src/stdio/__stdio.c b/src/stdio/__stdio_h.c
index d77e01dc..d553908f 100644
--- a/src/stdio/__stdio.c
+++ b/src/stdio/__stdio_h.c
@@ -1,6 +1,6 @@
#include "_stdio.h"
-struct __stdio __stdio = { 0 };
+struct __stdio_h __stdio_h = { 0 };
/*
STDC(0)
diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h
index 57d33e63..cdd8fb47 100644
--- a/src/stdio/_stdio.h
+++ b/src/stdio/_stdio.h
@@ -128,13 +128,11 @@ size_t __conv(const char *, struct io_conversion *);
int __printf(struct io_options * restrict, const char * restrict, va_list);
int __scanf(struct io_options * restrict, const char * restrict, va_list);
-struct __stdio {
+extern struct __stdio_h {
struct __FILE FILES[FOPEN_MAX];
char **formatted_pointers;
size_t nformatted_pointers;
-};
-
-extern struct __stdio __stdio;
+} __stdio_h;
/*
STDC(-1)
diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c
index a1e984f9..010e2e43 100644
--- a/src/stdio/fflush.c
+++ b/src/stdio/fflush.c
@@ -13,7 +13,7 @@ int fflush(FILE *stream)
if (stream == NULL) {
size_t i;
for (i = 0; i < FOPEN_MAX; i++) {
- stream = __stdio.FILES + i;
+ stream = __stdio_h.FILES + i;
if (stream->write && (stream->operation != OP_INPUT)) {
fflush(stream);
}
diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c
index dfb4f27c..824c8f30 100644
--- a/src/stdio/fopen.c
+++ b/src/stdio/fopen.c
@@ -15,8 +15,8 @@ FILE * fopen(const char * restrict filename, const char * restrict mode)
ASSERT_NOOVERLAP(filename, strlen(filename), mode, strlen(mode));
for (i = 0; i < FOPEN_MAX; i++) {
- if (__stdio.FILES[i].bmode == 0) {
- f = &(__stdio.FILES[i]);
+ if (__stdio_h.FILES[i].bmode == 0) {
+ f = &(__stdio_h.FILES[i]);
break;
}
}
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;
}
/***
diff --git a/src/time/__time.c b/src/time/__time_h.c
index de0c93fe..88312857 100644
--- a/src/time/__time.c
+++ b/src/time/__time_h.c
@@ -1,6 +1,6 @@
#include "_time.h"
-struct __time __time;
+struct __time_h __time_h = { 0 };
/*
STDC(-1)
diff --git a/src/time/_time.h b/src/time/_time.h
index b6d05212..76be4a7b 100644
--- a/src/time/_time.h
+++ b/src/time/_time.h
@@ -24,12 +24,10 @@
#define TZNAMELEN 64
-struct __time {
+extern struct __time_h {
char stdtz[TZNAMELEN];
char dsttz[TZNAMELEN];
-};
-
-extern struct __time __time;
+} __time_h;
/*
STDC(0)