klibc-bot for H. Peter Anvin
2014-Apr-09 23:03 UTC
[klibc] [klibc:master] Move architecture-specific initialization to arch/
Commit-ID: aed6821b52456a4c538c9097999adba451e49248 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=aed6821b52456a4c538c9097999adba451e49248 Author: H. Peter Anvin <hpa at linux.intel.com> AuthorDate: Wed, 9 Apr 2014 16:00:01 -0700 Committer: H. Peter Anvin <hpa at linux.intel.com> CommitDate: Wed, 9 Apr 2014 16:00:01 -0700 [klibc] Move architecture-specific initialization to arch/ Move out architecture-specific initialization code (currently only for i386) into the arch/ directory and define a configuration variable _KLIBC_HAS_ARCHINIT to indicate its presence. For consistency, change __init_stdio() to __libc_init_stdio(). Signed-off-by: H. Peter Anvin <hpa at linux.intel.com> --- usr/include/arch/i386/klibc/archconfig.h | 3 +++ usr/include/klibc/sysconfig.h | 9 +++++++++ usr/klibc/arch/i386/Kbuild | 2 +- usr/klibc/arch/i386/archinit.c | 18 ++++++++++++++++++ usr/klibc/libc_init.c | 21 +++++++++------------ usr/klibc/stdio/fdopen.c | 2 +- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/usr/include/arch/i386/klibc/archconfig.h b/usr/include/arch/i386/klibc/archconfig.h index b409a21..d8db763 100644 --- a/usr/include/arch/i386/klibc/archconfig.h +++ b/usr/include/arch/i386/klibc/archconfig.h @@ -12,4 +12,7 @@ /* The i386 <asm/signal.h> is still not clean enough for this... */ #define _KLIBC_USE_RT_SIG 0 +/* We have __libc_arch_init() */ +#define _KLIBC_HAS_ARCHINIT 1 + #endif /* _KLIBC_ARCHCONFIG_H */ diff --git a/usr/include/klibc/sysconfig.h b/usr/include/klibc/sysconfig.h index 5fa9b60..ab947c0 100644 --- a/usr/include/klibc/sysconfig.h +++ b/usr/include/klibc/sysconfig.h @@ -216,4 +216,13 @@ # define _KLIBC_ARM_USE_BX 0 #endif +/* + * _KLIBC_HAS_ARCHINIT + * + * This architecture uses __libc_archinit() + */ +#ifndef _KLIBC_HAS_ARCHINIT +# define _KLIBC_HAS_ARCHINIT 0 +#endif + #endif /* _KLIBC_SYSCONFIG_H */ diff --git a/usr/klibc/arch/i386/Kbuild b/usr/klibc/arch/i386/Kbuild index edc7b3c..1642374 100644 --- a/usr/klibc/arch/i386/Kbuild +++ b/usr/klibc/arch/i386/Kbuild @@ -2,7 +2,7 @@ # klibc .o files for i386 # -klib-y := socketcall.o setjmp.o syscall.o varsyscall.o +klib-y := archinit.o socketcall.o setjmp.o syscall.o varsyscall.o klib-y += open.o openat.o vfork.o klib-y += libgcc/__ashldi3.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o klib-y += libgcc/__muldi3.o libgcc/__negdi2.o diff --git a/usr/klibc/arch/i386/archinit.c b/usr/klibc/arch/i386/archinit.c new file mode 100644 index 0000000..111d130 --- /dev/null +++ b/usr/klibc/arch/i386/archinit.c @@ -0,0 +1,18 @@ +/* + * arch/i386/archinit.c + * + * Architecture-specific libc initialization + */ + +#include <stdint.h> +#include <klibc/compiler.h> +#include <elf.h> +#include <sys/auxv.h> + +extern void (*__syscall_entry)(int, ...); + +void __libc_archinit(void) +{ + if (__auxval[AT_SYSINFO]) + __syscall_entry = (void (*)(int, ...)) __auxval[AT_SYSINFO]; +} diff --git a/usr/klibc/libc_init.c b/usr/klibc/libc_init.c index 1c6180b..c54d022 100644 --- a/usr/klibc/libc_init.c +++ b/usr/klibc/libc_init.c @@ -25,6 +25,7 @@ #include <klibc/compiler.h> #include <elf.h> #include <sys/auxv.h> +#include <klibc/sysconfig.h> #include "atexit.h" /* This file is included from __static_init.c or __shared_init.c */ @@ -40,7 +41,8 @@ struct auxentry { unsigned long v; }; -extern void __init_stdio(void); +extern void __libc_init_stdio(void); +extern void __libc_archinit(void); unsigned long __auxval[_AUXVAL_MAX]; @@ -90,20 +92,11 @@ __noreturn __libc_init(uintptr_t * elfdata, void (*onexit) (void)) __page_size = page_size = __auxval[AT_PAGESZ]; -#ifdef __i386__ - { - extern void (*__syscall_entry)(int, ...); - if (__auxval[AT_SYSINFO]) - __syscall_entry = (void (*)(int, ...)) - __auxval[AT_SYSINFO]; - } -#endif - #if __GNUC__ >= 4 /* unsigned int is 32 bits on all our architectures */ page_shift = __builtin_clz(page_size) ^ 31; #elif defined(__i386__) || defined(__x86_64__) - asm("bsrl %1,%0": "=r"(page_shift):"r"(page_size)); + asm("bsrl %1,%0" : "=r" (page_shift) : "r" (page_size)); #else while (page_size > 1) { page_shift++; @@ -112,7 +105,11 @@ __noreturn __libc_init(uintptr_t * elfdata, void (*onexit) (void)) #endif __page_shift = page_shift; - __init_stdio(); +#if _KLIBC_HAS_ARCHINIT + __libc_archinit(); +#endif + + __libc_init_stdio(); environ = envp; exit(MAIN(argc, argv, envp)); diff --git a/usr/klibc/stdio/fdopen.c b/usr/klibc/stdio/fdopen.c index 51285ba..cdc35cc 100644 --- a/usr/klibc/stdio/fdopen.c +++ b/usr/klibc/stdio/fdopen.c @@ -48,7 +48,7 @@ err: return NULL; } -void __init_stdio(void) +void __libc_init_stdio(void) { stdin = fdopen(0, NULL); stdout = fdopen(1, NULL);
Apparently Analagous Threads
- [klibc:master] Inline __arch_libcinit()
- [klibc:master] i386: use the vdso for system calls on i386
- [klibc:master] auxv: convert auxiliary vector into an array; define getauxval()
- [klibc:master] i386: remove special handling of socketcall
- [klibc 24/43] i386 support for klibc