diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/misc/internals/Makefile | 7 | ||||
-rw-r--r-- | libc/stdlib/Makefile | 5 | ||||
-rw-r--r-- | libc/stdlib/atexit.c | 49 | ||||
-rw-r--r-- | libc/sysdeps/linux/arm/bits/confname.h | 5 | ||||
-rw-r--r-- | libc/sysdeps/linux/i386/bits/confname.h | 5 | ||||
-rw-r--r-- | libc/sysdeps/linux/m68k/bits/confname.h | 5 | ||||
-rw-r--r-- | libc/unistd/sysconf.c | 4 |
7 files changed, 40 insertions, 40 deletions
diff --git a/libc/misc/internals/Makefile b/libc/misc/internals/Makefile index da693ce51..863d32401 100644 --- a/libc/misc/internals/Makefile +++ b/libc/misc/internals/Makefile @@ -24,9 +24,12 @@ TOPDIR=../../ include $(TOPDIR)Rules.mak LIBC=$(TOPDIR)libc.a -CSRC=ultostr.c ltostr.c ulltostr.c lltostr.c zoicheck.c +CSRC=ultostr.c ltostr.c ifeq ($(HAS_FLOATS),true) - CSRC += dtostr.c + CSRC += dtostr.c zoicheck.c +endif +ifeq ($(HAS_LONG_LONG),true) + CSRC += ulltostr.c lltostr.c endif COBJS=$(patsubst %.c,%.o, $(CSRC)) diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile index 06d87c674..6ea292d5b 100644 --- a/libc/stdlib/Makefile +++ b/libc/stdlib/Makefile @@ -45,7 +45,10 @@ endif COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(MOBJ) $(MOBJ1) $(MOBJ2) $(COBJS) +OBJS=$(MOBJ) $(MOBJ2) $(COBJS) +ifeq ($(HAS_LONG_LONG),true) + OBJS += $(MOBJ1) +endif all: $(OBJS) $(LIBC) diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c index 5079692af..a7ec0fb1f 100644 --- a/libc/stdlib/atexit.c +++ b/libc/stdlib/atexit.c @@ -12,45 +12,17 @@ * Combined atexit and __do_exit into one object file. */ +#include <stdlib.h> #include <errno.h> -/* ATEXIT.H */ - -/* - * NOTE!!! The following should match the value returned by - * by sysconf(_SC_ATEXIT_MAX) in unistd/sysconf.c - */ -#define MAXATEXIT 20 /* AIUI Posix requires 10 */ - typedef void (*vfuncp) (void); - extern vfuncp __cleanup; -extern void __do_exit(); -extern void _exit __P((int __status)) __attribute__ ((__noreturn__)); - -extern vfuncp __atexit_table[MAXATEXIT]; -extern int __atexit_count; - -/* End ATEXIT.H */ #ifdef L_atexit -int atexit(vfuncp ptr) -{ - if ((__atexit_count < 0) || (__atexit_count >= MAXATEXIT)) { - errno = ENOMEM; - return -1; - } - if (ptr) { - __cleanup = __do_exit; - __atexit_table[__atexit_count++] = ptr; - } - return 0; -} +static vfuncp __atexit_table[__UCLIBC_MAX_ATEXIT]; +static int __atexit_count = 0; -vfuncp __atexit_table[MAXATEXIT]; -int __atexit_count = 0; - -void __do_exit(int rv) +static void __do_exit(void) { int count = __atexit_count - 1; @@ -62,6 +34,19 @@ void __do_exit(int rv) (*__atexit_table[count])(); } } + +int atexit(vfuncp ptr) +{ + if ((__atexit_count < 0) || (__atexit_count >= __UCLIBC_MAX_ATEXIT)) { + errno = ENOMEM; + return -1; + } + if (ptr) { + __cleanup = __do_exit; + __atexit_table[__atexit_count++] = ptr; + } + return 0; +} #endif #ifdef L_exit diff --git a/libc/sysdeps/linux/arm/bits/confname.h b/libc/sysdeps/linux/arm/bits/confname.h index 229088d67..a649e52f2 100644 --- a/libc/sysdeps/linux/arm/bits/confname.h +++ b/libc/sysdeps/linux/arm/bits/confname.h @@ -335,8 +335,11 @@ enum #define _SC_XOPEN_LEGACY _SC_XOPEN_LEGACY _SC_XOPEN_REALTIME, #define _SC_XOPEN_REALTIME _SC_XOPEN_REALTIME - _SC_XOPEN_REALTIME_THREADS + _SC_XOPEN_REALTIME_THREADS, #define _SC_XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS + + /* MUST BE LAST VALUE!!! */ + _UCLIBC_SYSCONF_NUM_VALID_ARGS }; #if (defined __USE_POSIX2 || defined __USE_UNIX98 \ diff --git a/libc/sysdeps/linux/i386/bits/confname.h b/libc/sysdeps/linux/i386/bits/confname.h index 229088d67..a649e52f2 100644 --- a/libc/sysdeps/linux/i386/bits/confname.h +++ b/libc/sysdeps/linux/i386/bits/confname.h @@ -335,8 +335,11 @@ enum #define _SC_XOPEN_LEGACY _SC_XOPEN_LEGACY _SC_XOPEN_REALTIME, #define _SC_XOPEN_REALTIME _SC_XOPEN_REALTIME - _SC_XOPEN_REALTIME_THREADS + _SC_XOPEN_REALTIME_THREADS, #define _SC_XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS + + /* MUST BE LAST VALUE!!! */ + _UCLIBC_SYSCONF_NUM_VALID_ARGS }; #if (defined __USE_POSIX2 || defined __USE_UNIX98 \ diff --git a/libc/sysdeps/linux/m68k/bits/confname.h b/libc/sysdeps/linux/m68k/bits/confname.h index 229088d67..a649e52f2 100644 --- a/libc/sysdeps/linux/m68k/bits/confname.h +++ b/libc/sysdeps/linux/m68k/bits/confname.h @@ -335,8 +335,11 @@ enum #define _SC_XOPEN_LEGACY _SC_XOPEN_LEGACY _SC_XOPEN_REALTIME, #define _SC_XOPEN_REALTIME _SC_XOPEN_REALTIME - _SC_XOPEN_REALTIME_THREADS + _SC_XOPEN_REALTIME_THREADS, #define _SC_XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS + + /* MUST BE LAST VALUE!!! */ + _UCLIBC_SYSCONF_NUM_VALID_ARGS }; #if (defined __USE_POSIX2 || defined __USE_UNIX98 \ diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c index d5c6f6b9d..032311378 100644 --- a/libc/unistd/sysconf.c +++ b/libc/unistd/sysconf.c @@ -22,6 +22,7 @@ #include <pwd.h> #include <stddef.h> #include <stdio.h> +#include <stdlib.h> #include <time.h> #include <unistd.h> #include <sys/sysinfo.h> @@ -658,8 +659,7 @@ long int sysconf(int name) #endif case _SC_ATEXIT_MAX: - /* See stdlib/atexit.c */ - return 20; + return __UCLIBC_MAX_ATEXIT; case _SC_PASS_MAX: /* We have no limit but since the return value might be used to |