summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
24 files changed, 46 insertions, 52 deletions
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)