diff options
Diffstat (limited to 'newlib/libc/sys/linux/machine')
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/Makefile.am | 3 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/Makefile.in | 8 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/crt0.c | 7 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/i386mach.h | 83 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/include/setjmp.h | 6 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/setjmp.S | 91 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/socketcall.h | 31 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/syscall.h | 47 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/syscalls.c | 11 | ||||
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/weakalias.h | 4 |
10 files changed, 263 insertions, 28 deletions
diff --git a/newlib/libc/sys/linux/machine/i386/Makefile.am b/newlib/libc/sys/linux/machine/i386/Makefile.am index 791c2e851..330a414c0 100644 --- a/newlib/libc/sys/linux/machine/i386/Makefile.am +++ b/newlib/libc/sys/linux/machine/i386/Makefile.am @@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -LIB_SOURCES = sigset.c +LIB_SOURCES = setjmp.S sigset.c syscalls.c liblinuxi386_la_LDFLAGS = -Xcompiler -nostdlib @@ -22,5 +22,6 @@ include $(srcdir)/../../../../../Makefile.shared all: crt0.o +AM_CFLAGS = -I$(srcdir)/../.. ACLOCAL_AMFLAGS = -I ../../../../.. CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host diff --git a/newlib/libc/sys/linux/machine/i386/Makefile.in b/newlib/libc/sys/linux/machine/i386/Makefile.in index d2c07bec6..c84ef686c 100644 --- a/newlib/libc/sys/linux/machine/i386/Makefile.in +++ b/newlib/libc/sys/linux/machine/i386/Makefile.in @@ -92,7 +92,7 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -LIB_SOURCES = sigset.c +LIB_SOURCES = setjmp.S sigset.c syscalls.c liblinuxi386_la_LDFLAGS = -Xcompiler -nostdlib @@ -103,6 +103,7 @@ liblinuxi386_la_LDFLAGS = -Xcompiler -nostdlib @USE_LIBTOOL_FALSE@noinst_LIBRARIES = @USE_LIBTOOL_FALSE@lib.a @USE_LIBTOOL_FALSE@lib_a_SOURCES = @USE_LIBTOOL_FALSE@$(LIB_SOURCES) +AM_CFLAGS = -I$(srcdir)/../.. ACLOCAL_AMFLAGS = -I ../../../../.. CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -115,11 +116,12 @@ DEFS = @DEFS@ -I. -I$(srcdir) CPPFLAGS = @CPPFLAGS@ LIBS = @LIBS@ lib_a_LIBADD = -@USE_LIBTOOL_FALSE@lib_a_OBJECTS = sigset.o +@USE_LIBTOOL_FALSE@lib_a_OBJECTS = setjmp.o sigset.o syscalls.o LTLIBRARIES = $(noinst_LTLIBRARIES) liblinuxi386_la_LIBADD = -@USE_LIBTOOL_TRUE@liblinuxi386_la_OBJECTS = sigset.lo +@USE_LIBTOOL_TRUE@liblinuxi386_la_OBJECTS = setjmp.lo sigset.lo \ +@USE_LIBTOOL_TRUE@syscalls.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) diff --git a/newlib/libc/sys/linux/machine/i386/crt0.c b/newlib/libc/sys/linux/machine/i386/crt0.c index 01ae7a397..cc9cb9249 100644 --- a/newlib/libc/sys/linux/machine/i386/crt0.c +++ b/newlib/libc/sys/linux/machine/i386/crt0.c @@ -9,12 +9,15 @@ #include <stdlib.h> #include <time.h> +#include <string.h> extern char **environ; extern int main(int argc,char **argv,char **envp); +extern void *_end; +extern void *__bss_start; void _start(int args) { @@ -29,6 +32,10 @@ void _start(int args) char **argv = (char **) (params+1); environ = argv+argc+1; + + /* clear bss */ + memset(__bss_start,0,((char *)_end - (char *)__bss_start)); + tzset(); /* initialize timezone info */ exit(main(argc,argv,environ)); } diff --git a/newlib/libc/sys/linux/machine/i386/i386mach.h b/newlib/libc/sys/linux/machine/i386/i386mach.h new file mode 100644 index 000000000..23c32190d --- /dev/null +++ b/newlib/libc/sys/linux/machine/i386/i386mach.h @@ -0,0 +1,83 @@ +/* This file was based on the modified setjmp.S performed by + * Joel Sherill (joel@OARcorp.com) which specified the use + * of the __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ macros. + ** + ** This file is distributed WITHOUT ANY WARRANTY; without even the implied + ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* These are predefined by new versions of GNU cpp. */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#define __REG_PREFIX__ % + +/* ANSI concatenation macros. */ + +#define CONCAT1(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a##b + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1(__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1(__REG_PREFIX__, x) + +#define eax REG(eax) +#define ebx REG(ebx) +#define ecx REG(ecx) +#define edx REG(edx) +#define esi REG(esi) +#define edi REG(edi) +#define ebp REG(ebp) +#define esp REG(esp) + +#define st0 REG(st) +#define st1 REG(st(1)) +#define st2 REG(st(2)) +#define st3 REG(st(3)) +#define st4 REG(st(4)) +#define st5 REG(st(5)) +#define st6 REG(st(6)) +#define st7 REG(st(7)) + +#define ax REG(ax) +#define bx REG(bx) +#define cx REG(cx) +#define dx REG(dx) + +#define ah REG(ah) +#define bh REG(bh) +#define ch REG(ch) +#define dh REG(dh) + +#define al REG(al) +#define bl REG(bl) +#define cl REG(cl) +#define dl REG(dl) + +#define mm1 REG(mm1) +#define mm2 REG(mm2) +#define mm3 REG(mm3) +#define mm4 REG(mm4) +#define mm5 REG(mm5) +#define mm6 REG(mm6) +#define mm7 REG(mm7) + +#ifdef _I386MACH_NEED_SOTYPE_FUNCTION +#define SOTYPE_FUNCTION(sym) .type SYM(sym),@function +#else +#define SOTYPE_FUNCTION(sym) +#endif + +#ifdef _I386MACH_ALLOW_HW_INTERRUPTS +#define __CLI +#define __STI +#else +#define __CLI cli +#define __STI sti +#endif diff --git a/newlib/libc/sys/linux/machine/i386/include/setjmp.h b/newlib/libc/sys/linux/machine/i386/include/setjmp.h new file mode 100644 index 000000000..f080c3d9f --- /dev/null +++ b/newlib/libc/sys/linux/machine/i386/include/setjmp.h @@ -0,0 +1,6 @@ +#define _JBLEN 9 +typedef long __jmp_buf[_JBLEN]; + +#define SP_INDEX 7 +#define _JMPBUF_UNWINDS(buf, address) \ + ((void *)(address) < (void *)(buf)[SP_INDEX]) diff --git a/newlib/libc/sys/linux/machine/i386/setjmp.S b/newlib/libc/sys/linux/machine/i386/setjmp.S new file mode 100644 index 000000000..d276f55fb --- /dev/null +++ b/newlib/libc/sys/linux/machine/i386/setjmp.S @@ -0,0 +1,91 @@ +/* This is file is a merger of SETJMP.S and LONGJMP.S */ +/* + * This file was modified to use the __USER_LABEL_PREFIX__ and + * __REGISTER_PREFIX__ macros defined by later versions of GNU cpp by + * Joel Sherrill (joel@OARcorp.com) + * Slight change: now includes i386mach.h for this (Werner Almesberger) + * + * Copyright (C) 1991 DJ Delorie + * All rights reserved. + * + * Redistribution and use in source and binary forms is permitted + * provided that the above copyright notice and following paragraph are + * duplicated in all such forms. + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + + /* + ** jmp_buf: + ** eax ebx ecx edx esi edi ebp esp eip + ** 0 4 8 12 16 20 24 28 32 + */ + + #include "i386mach.h" + + .global SYM (setjmp) + .global SYM (__libc_longjmp) + .weak SYM (longjmp) + SOTYPE_FUNCTION(setjmp) + SOTYPE_FUNCTION(longjmp) + SOTYPE_FUNCTION(__libc_longjmp) + +SYM (setjmp): + + pushl ebp + movl esp,ebp + + pushl edi + movl 8 (ebp),edi + + movl eax,0 (edi) + movl ebx,4 (edi) + movl ecx,8 (edi) + movl edx,12 (edi) + movl esi,16 (edi) + + movl -4 (ebp),eax + movl eax,20 (edi) + + movl 0 (ebp),eax + movl eax,24 (edi) + + movl esp,eax + addl $12,eax + movl eax,28 (edi) + + movl 4 (ebp),eax + movl eax,32 (edi) + + popl edi + movl $0,eax + leave + ret + +SYM (__libc_longjmp): +SYM (longjmp): + .weak longjmp + pushl ebp + movl esp,ebp + + movl 8(ebp),edi /* get jmp_buf */ + movl 12(ebp),eax /* store retval in j->eax */ + movl eax,0(edi) + + movl 24(edi),ebp + + __CLI + movl 28(edi),esp + + pushl 32(edi) + + movl 0(edi),eax + movl 4(edi),ebx + movl 8(edi),ecx + movl 12(edi),edx + movl 16(edi),esi + movl 20(edi),edi + __STI + + ret diff --git a/newlib/libc/sys/linux/machine/i386/socketcall.h b/newlib/libc/sys/linux/machine/i386/socketcall.h index 7c1973962..bd83d5175 100644 --- a/newlib/libc/sys/linux/machine/i386/socketcall.h +++ b/newlib/libc/sys/linux/machine/i386/socketcall.h @@ -6,6 +6,7 @@ #define _SOCKETCALL_H +#include <machine/weakalias.h> #include <sys/errno.h> #include <asm/unistd.h> #include "sockops.h" @@ -25,32 +26,38 @@ __syscall_return(type,__res); \ #undef _sockcall1 #define _sockcall1(type,name,type1,arg1) \ -type name(type1 arg1) \ -__sockcall_base(type,name) +type __libc_##name(type1 arg1) \ +__sockcall_base(type,name) \ +weak_alias(__libc_##name,name) #undef _sockcall2 #define _sockcall2(type,name,type1,arg1,type2,arg2) \ -type name(type1 arg1, type2 arg2) \ -__sockcall_base(type,name) +type __libc_##name(type1 arg1, type2 arg2) \ +__sockcall_base(type,name) \ +weak_alias(__libc_##name,name) #undef _sockcall3 #define _sockcall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ -type name(type1 arg1, type2 arg2, type3 arg3) \ -__sockcall_base(type,name) +type __libc_##name(type1 arg1, type2 arg2, type3 arg3) \ +__sockcall_base(type,name) \ +weak_alias(__libc_##name,name) #undef _sockcall4 #define _sockcall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ -__sockcall_base(type,name) +type __libc_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +__sockcall_base(type,name) \ +weak_alias(__libc_##name,name) #undef _sockcall5 #define _sockcall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ -__sockcall_base(type,name) +type __libc_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ +__sockcall_base(type,name) \ +weak_alias(__libc_##name,name) #undef _sockcall6 #define _sockcall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \ -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \ -__sockcall_base(type,name) +type __libc_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \ +__sockcall_base(type,name) \ +weak_alias(__libc_##name,name) #endif /* _SOCKETCALL_H */ diff --git a/newlib/libc/sys/linux/machine/i386/syscall.h b/newlib/libc/sys/linux/machine/i386/syscall.h index c8f265f68..b165f0442 100644 --- a/newlib/libc/sys/linux/machine/i386/syscall.h +++ b/newlib/libc/sys/linux/machine/i386/syscall.h @@ -5,6 +5,7 @@ #ifndef SYSCALL_H +#include <machine/weakalias.h> #include <sys/errno.h> #include <asm/unistd.h> @@ -22,6 +23,12 @@ * PIC uses %ebx, so we need to save it during system calls */ +#undef __inline_syscall0 +#define __inline_syscall0(name,ret) \ +__asm__ volatile ("int $0x80" \ + : "=a" (ret) \ + : "0" (__NR_##name)); + #undef __inline_syscall1 #define __inline_syscall1(name,ret,arg1) \ __asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \ @@ -61,61 +68,77 @@ __asm__ volatile ("push %%ebx; lea 8(%%ebp),%%ebx; int $0x80; pop %%ebx" \ : "=a" (ret) \ : "0" (__NR_##name)); +#undef _syscall0 +#define _syscall0(type,name) \ +type __libc_##name (void) \ +{ \ +long __res; \ +__inline_syscall0(name,__res) \ +__syscall_return(type,__res); \ +} \ +weak_alias(__libc_##name,name); + #undef _syscall1 #define _syscall1(type,name,type1,arg1) \ -type name(type1 arg1) \ +type __libc_##name (type1 arg1) \ { \ long __res; \ __inline_syscall1(name,__res,arg1) \ __syscall_return(type,__res); \ -} +} \ +weak_alias(__libc_##name,name); #undef _syscall2 #define _syscall2(type,name,type1,arg1,type2,arg2) \ -type name(type1 arg1,type2 arg2) \ +type __libc_##name (type1 arg1,type2 arg2) \ { \ long __res; \ __inline_syscall2(name,__res,arg1,arg2) \ __syscall_return(type,__res); \ -} +} \ +weak_alias(__libc_##name,name); #undef _syscall3 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ -type name(type1 arg1,type2 arg2,type3 arg3) \ +type __libc_##name (type1 arg1,type2 arg2,type3 arg3) \ { \ long __res; \ __inline_syscall3(name,__res,arg1,arg2,arg3) \ __syscall_return(type,__res); \ -} +} \ +weak_alias(__libc_##name,name); #undef _syscall4 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +type __libc_##name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ { \ long __res; \ __inline_syscall4(name,__res,arg1,arg2,arg3,arg4) \ __syscall_return(type,__res); \ -} +} \ +weak_alias(__libc_##name,name); #undef _syscall5 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ type5,arg5) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ +type __libc_##name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ { \ long __res; \ __inline_syscall5(name,__res,arg1,arg2,arg3,arg4,arg5) \ __syscall_return(type,__res); \ -} +} \ +weak_alias(__libc_##name,name); #undef _syscall6 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ type5,arg5,type6,arg6) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ +type __libc_##name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ { \ long __res; \ __inline_syscall6(name,__res,arg1,arg2,arg3,arg4,arg5,arg6) \ __syscall_return(type,__res); \ -} +} \ +weak_alias(__libc_##name,name); #endif /* __PIC__ && __i386__ */ diff --git a/newlib/libc/sys/linux/machine/i386/syscalls.c b/newlib/libc/sys/linux/machine/i386/syscalls.c new file mode 100644 index 000000000..838dd73b3 --- /dev/null +++ b/newlib/libc/sys/linux/machine/i386/syscalls.c @@ -0,0 +1,11 @@ +/* miscellaneous i386-specific linux syscalls */ + +/* Copyright 2002, Red Hat Inc. */ + +#include <sys/resource.h> +#include <machine/syscall.h> +#include <errno.h> + +_syscall2(int,getrlimit,int,resource,struct rlimit *,rlp); +_syscall2(int,setrlimit,int,resource,const struct rlimit *,rlp); + diff --git a/newlib/libc/sys/linux/machine/i386/weakalias.h b/newlib/libc/sys/linux/machine/i386/weakalias.h new file mode 100644 index 000000000..539ee4ae4 --- /dev/null +++ b/newlib/libc/sys/linux/machine/i386/weakalias.h @@ -0,0 +1,4 @@ +#define weak_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); + + |