diff options
Diffstat (limited to 'libc/sysdeps')
| -rw-r--r-- | libc/sysdeps/linux/bfin/bits/syscalls.h | 266 | ||||
| -rw-r--r-- | libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h | 2 | ||||
| -rw-r--r-- | libc/sysdeps/linux/bfin/syscall.c | 64 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/getcwd.c | 4 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/mremap.c | 9 | ||||
| -rw-r--r-- | libc/sysdeps/linux/m68k/clone.S | 6 | ||||
| -rw-r--r-- | libc/sysdeps/linux/m68k/crt1.S | 15 | 
7 files changed, 207 insertions, 159 deletions
diff --git a/libc/sysdeps/linux/bfin/bits/syscalls.h b/libc/sysdeps/linux/bfin/bits/syscalls.h index d8d628cab..475d193ce 100644 --- a/libc/sysdeps/linux/bfin/bits/syscalls.h +++ b/libc/sysdeps/linux/bfin/bits/syscalls.h @@ -4,169 +4,177 @@  # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."  #endif -#include <features.h> -  /* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel   * header files.  It also defines the traditional `SYS_<name>' macros for older   * programs.  */  #include <bits/sysnum.h> -/* This code is mostly cut & paste from the uClinux bfin port */ +#ifndef __set_errno +# define __set_errno(val) ((*__errno_location ()) = (val)) +#endif + +#ifndef SYS_ify +# define SYS_ify(syscall_name)  (__NR_##syscall_name) +#endif  #ifndef __ASSEMBLER__ -#define __syscall_return(type, res)					\ -do {									\ -	if ((unsigned long)(res) >= (unsigned long)(-125)) 		\ -	{	__set_errno(-(res));					\ -		res = -1;						\ -	}								\ -	return (type) (res);						\ +/* user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h> */ +#if defined _LIBC && !defined __set_errno +# define __syscall_return(type, res) \ +do { \ +        unsigned long __sr2 = (res);		    			    \ +	if (__builtin_expect ((unsigned long)(__sr2)			    \ +			      >= (unsigned long)(-4095), 0)) {		    \ +		extern int __syscall_error (int);			    \ +		return (type) __syscall_error (__sr2);		    	    \ +	}								    \ +	return (type) (__sr2); 						    \  } while (0) +#else +# define __syscall_return(type, res) \ +do { \ +        unsigned long __sr2 = (res);		    			    \ +	if (__builtin_expect ((unsigned long)(__sr2)			    \ +			      >= (unsigned long)(-4095), 0)) {		    \ +		__set_errno (-__sr2);				    	    \ +		__sr2 = -1; 						    \ +	}								    \ +	return (type) (__sr2); 						    \ +} while (0) +#endif  #define _syscall0(type,name)						\  type name(void) {							\ -  long __res;								\ -  __asm__ __volatile__ (						\ -  "p0 = %1;\n\t"							\ -  "excpt 0;\n\t" 							\ -  "%0=r0;\n\t"								\ -  : "=da" (__res) 							\ -  : "i" (__NR_##name)							\ -  : "CC", "P0");							\ -__syscall_return(type,__res);						\ +	long __res;							\ +	__asm__ __volatile__ (						\ +		"p0 = %1;\n\t"						\ +		"excpt 0;\n\t"						\ +		"%0=r0;\n\t"						\ +		: "=da" (__res)						\ +		: "i" (__NR_##name)					\ +		: "memory","CC","R0","P0");				\ +	__syscall_return(type,__res);					\  }  #define _syscall1(type,name,type1,arg1)					\  type name(type1 arg1) {							\ -  long __res;								\ -  __asm__ __volatile__ (						\ -  "r0=%2;\n\t"								\ -  "p0=%1;\n\t"								\ -  "excpt 0;\n\t" 							\ -  "%0=r0;\n\t"								\ -        : "=da" (__res)							\ -        : "i" (__NR_##name),						\ -	  "a" ((long)(arg1))						\ -	: "CC", "R0", "P0");						\ -__syscall_return(type,__res);						\ +	long __res;							\ +	__asm__ __volatile__ (						\ +		"r0=%2;\n\t"						\ +		"p0=%1;\n\t"						\ +		"excpt 0;\n\t"						\ +		"%0=r0;\n\t"						\ +		: "=da" (__res)						\ +		: "i" (__NR_##name),					\ +		  "rm" ((long)(arg1))					\ +		: "memory","CC","R0","P0");				\ +	__syscall_return(type,__res);					\  }  #define _syscall2(type,name,type1,arg1,type2,arg2)			\  type name(type1 arg1,type2 arg2) {					\ -  long __res;								\ -  __asm__ __volatile__ (						\ -  "r1=%3;\n\t"								\ -  "r0=%2;\n\t"								\ -  "p0=%1;\n\t"								\ -  "excpt 0;\n\t" 							\ -  "%0=r0;\n\t"								\ -        : "=da" (__res)							\ -        : "i" (__NR_##name),						\ -	  "a" ((long)(arg1)),						\ -	  "a" ((long)(arg2))						\ -	: "CC", "R0","R1", "P0");					\ -__syscall_return(type,__res);						\ +	long __res;							\ +	__asm__ __volatile__ (						\ +		"r1=%3;\n\t"						\ +		"r0=%2;\n\t"						\ +		"p0=%1;\n\t"						\ +		"excpt 0;\n\t"						\ +		"%0=r0;\n\t"						\ +		: "=da" (__res)						\ +		: "i" (__NR_##name),					\ +		  "rm" ((long)(arg1)),					\ +		  "rm" ((long)(arg2))					\ +		: "memory","CC","R0","R1","P0");			\ +	__syscall_return(type,__res);					\  } -  #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)		\  type name(type1 arg1,type2 arg2,type3 arg3) {				\ -  long __res;								\ -  __asm__ __volatile__ (						\ -  "r2=%4;\n\t"								\ -  "r1=%3;\n\t"								\ -  "r0=%2;\n\t"								\ -  "p0=%1;\n\t"								\ -  "excpt 0;\n\t" 							\ -  "%0=r0;\n\t"								\ -        : "=da" (__res)							\ -        : "i"   (__NR_##name),						\ -	  "a"   ((long)(arg1)),						\ -	  "a"   ((long)(arg2)),						\ -	  "a"   ((long)(arg3))						\ -        : "CC", "R0","R1","R2", "P0");					\ -__syscall_return(type,__res);						\ +	long __res;							\ +	__asm__ __volatile__ (						\ +		"r2=%4;\n\t"						\ +		"r1=%3;\n\t"						\ +		"r0=%2;\n\t"						\ +		"p0=%1;\n\t"						\ +		"excpt 0;\n\t"						\ +		"%0=r0;\n\t"						\ +		: "=da" (__res)						\ +		: "i"   (__NR_##name),					\ +		  "rm"   ((long)(arg1)),				\ +		  "rm"   ((long)(arg2)),				\ +		  "rm"   ((long)(arg3))					\ +		: "memory","CC","R0","R1","R2","P0");			\ +	__syscall_return(type,__res);					\  }  #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\  type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) {		\ -  long __res;								\ -  __asm__ __volatile__ (						\ -  "[--sp] = r3;\n\t"							\ -  "r3=%5;\n\t"								\ -  "r2=%4;\n\t"								\ -  "r1=%3;\n\t"								\ -  "r0=%2;\n\t"								\ -  "p0=%1;\n\t"								\ -  "excpt 0;\n\t" 							\ -  "%0=r0;\n\t"								\ -  "r3 = [sp++];\n\t"							\ -  	: "=da" (__res)							\ -  	: "i"  (__NR_##name),						\ -	  "a"  ((long)(arg1)),						\ -	  "a"  ((long)(arg2)),						\ -	  "a"  ((long)(arg3)),						\ -	  "a"  ((long)(arg4))						\ -  	: "CC", "R0","R1","R2","R3", "P0");				\ -__syscall_return(type,__res);						\ +	long __res;							\ +	__asm__ __volatile__ (						\ +		"r3=%5;\n\t"						\ +		"r2=%4;\n\t"						\ +		"r1=%3;\n\t"						\ +		"r0=%2;\n\t"						\ +		"p0=%1;\n\t"						\ +		"excpt 0;\n\t"						\ +		"%0=r0;\n\t"						\ +		: "=da" (__res)						\ +		: "i"  (__NR_##name),					\ +		  "rm"  ((long)(arg1)),					\ +		  "rm"  ((long)(arg2)),					\ +		  "rm"  ((long)(arg3)),					\ +		  "rm"  ((long)(arg4))					\ +		: "memory","CC","R0","R1","R2","R3","P0");		\ +	__syscall_return(type,__res);					\  }  #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) {	\ -  long __res;								\ -  __asm__ __volatile__ (						\ -  "[--sp] = r4;\n\t"                                                    \ -  "[--sp] = r3;\n\t"                                                    \ -  "r4=%6;\n\t"								\ -  "r3=%5;\n\t"								\ -  "r2=%4;\n\t"								\ -  "r1=%3;\n\t"								\ -  "r0=%2;\n\t"								\ -  "P0=%1;\n\t"								\ -  "excpt 0;\n\t" 							\ -  "%0=r0;\n\t"								\ -  "r3 = [sp++];\n\t" 							\ -  "r4 = [sp++];\n\t"                                                    \ -  	: "=da" (__res)							\ -  	: "i"  (__NR_##name),						\ -	  "rm"  ((long)(arg1)),						\ -	  "rm"  ((long)(arg2)),						\ -	  "rm"  ((long)(arg3)),						\ -	  "rm"  ((long)(arg4)),						\ -	  "rm"  ((long)(arg5))						\ -	: "CC","R0","R1","R2","R3","R4","P0");				\ -__syscall_return(type,__res);						\ +	long __res;							\ +	__asm__ __volatile__ (						\ +		"r4=%6;\n\t"						\ +		"r3=%5;\n\t"						\ +		"r2=%4;\n\t"						\ +		"r1=%3;\n\t"						\ +		"r0=%2;\n\t"						\ +		"P0=%1;\n\t"						\ +		"excpt 0;\n\t"						\ +		"%0=r0;\n\t"						\ +		: "=da" (__res)						\ +		: "i"  (__NR_##name),					\ +		  "rm"  ((long)(arg1)),					\ +		  "rm"  ((long)(arg2)),					\ +		  "rm"  ((long)(arg3)),					\ +		  "rm"  ((long)(arg4)),					\ +		  "rm"  ((long)(arg5))					\ +		: "memory","CC","R0","R1","R2","R3","R4","P0");		\ +	__syscall_return(type,__res);					\  } -#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) {	\ -  long __res;								\ -  __asm__ __volatile__ (						\ -  "[--sp] = r5;\n\t"                                                    \ -  "[--sp] = r4;\n\t"                                                    \ -  "[--sp] = r3;\n\t"                                                    \ -  "r4=%6;\n\t"								\ -  "r3=%5;\n\t"								\ -  "r2=%4;\n\t"								\ -  "r1=%3;\n\t"								\ -  "r0=%2;\n\t"								\ -  "P0=%1;\n\t"								\ -  "excpt 0;\n\t" 							\ -  "%0=r0;\n\t"								\ -  "r3 = [sp++];\n\t" 							\ -  "r4 = [sp++];\n\t"                                                    \ -  "r5 = [sp++];\n\t"                                                    \ -  	: "=da" (__res)							\ -  	: "i"  (__NR_##name),						\ -	  "rm"  ((long)(arg1)),						\ -	  "rm"  ((long)(arg2)),						\ -	  "rm"  ((long)(arg3)),						\ -	  "rm"  ((long)(arg4)),						\ -	  "rm"  ((long)(arg5)),						\ -	  "rm"  ((long)(arg6))						\ -	: "CC","R0","R1","R2","R3","R4","R5","P0");				\ -__syscall_return(type,__res);						\ +#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) { \ +	long __res;							\ +	__asm__ __volatile__ (						\ +		"r5=%7;\n\t"						\ +		"r4=%6;\n\t"						\ +		"r3=%5;\n\t"						\ +		"r2=%4;\n\t"						\ +		"r1=%3;\n\t"						\ +		"r0=%2;\n\t"						\ +		"P0=%1;\n\t"						\ +		"excpt 0;\n\t"						\ +		"%0=r0;\n\t"						\ +		: "=da" (__res)						\ +		: "i"  (__NR_##name),					\ +		  "rm"  ((long)(arg1)),					\ +		  "rm"  ((long)(arg2)),					\ +		  "rm"  ((long)(arg3)),					\ +		  "rm"  ((long)(arg4)),					\ +		  "rm"  ((long)(arg5)),					\ +		  "rm"  ((long)(arg6))					\ +		: "memory","CC","R0","R1","R2","R3","R4","R5","P0");	\ +	__syscall_return(type,__res);					\  }  #endif /* __ASSEMBLER__ */ diff --git a/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h b/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h index 1b40e32a2..a9140ee7e 100644 --- a/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h @@ -10,7 +10,7 @@  #undef __UCLIBC_ABORT_INSTRUCTION__  /* can your target use syscall6() for mmap ? */ -#undef __UCLIBC_MMAP_HAS_6_ARGS__ +#define __UCLIBC_MMAP_HAS_6_ARGS__  /* does your target use syscall4() for truncate64 ? (32bit arches only) */  #undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ diff --git a/libc/sysdeps/linux/bfin/syscall.c b/libc/sysdeps/linux/bfin/syscall.c index c223f56a3..1db873874 100644 --- a/libc/sysdeps/linux/bfin/syscall.c +++ b/libc/sysdeps/linux/bfin/syscall.c @@ -1,10 +1,22 @@  /* vi: set sw=4 ts=4: */  /* syscall for blackfin/uClibc   * - * Copyright (C) 2004 by Analog Devices Inc. - * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> + * Copyright (C) 2004-2006 by Analog Devices Inc. + * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>   * - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License + * for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   */  #include <features.h> @@ -12,26 +24,34 @@  #include <sys/types.h>  #include <sys/syscall.h> -long syscall(long sysnum, long a, long b, long c, long d, long e) +long syscall(long sysnum, long a, long b, long c, long d, long e, long f)  {  	int _r0 = 0; -    asm volatile( -	    "p0 = %1;"		/*SysCall Number*/ -	    "r0 = %2;" -	    "r1 = %3;" -	    "r2 = %4;" -		"r3 = %6;" -		"r4 = %5;" -		"excpt 0;"		/*Call the System Call*/ -		"%0 = r0;"		/*Store the result of syscall*/ -	    : "=r"(_r0) -	    : "r"(sysnum), "r"(a), "r"(b), -	      "r"(c), "r"(d), "r"(e) -	    : "memory"); -    if(_r0 >=(unsigned long) -4095) { -	(*__errno_location())=(-_r0); -	_r0=(unsigned long) -1; -    } -    return (long) _r0; +	__asm__ __volatile__ ( +		"R5 = %7;" +		"R4 = %6;" +		"R3 = %5;" +		"R2 = %4;" +		"R1 = %3;" +		"R0 = %2;" +		"P0 = %1;" +		"excpt 0;" +		"%0 = R0;" +		: "=r" (_r0) +		: "rm" (sysnum), +		  "rm" (a), +		  "rm" (b), +		  "rm" (c), +		  "rm" (d), +		  "rm" (e), +		  "rm" (f) +		: "memory","CC","R0","R1","R2","R3","R4","R5","P0"); + +	if (_r0 >= (unsigned long) -4095) { +		(*__errno_location()) = (-_r0); +		_r0 = (unsigned long) -1; +	} + +	return (long)_r0;  } diff --git a/libc/sysdeps/linux/common/getcwd.c b/libc/sysdeps/linux/common/getcwd.c index a9042c76b..165ea317e 100644 --- a/libc/sysdeps/linux/common/getcwd.c +++ b/libc/sysdeps/linux/common/getcwd.c @@ -12,9 +12,11 @@  #include <dirent.h>  #include <string.h>  #include <unistd.h> +#include <sys/param.h>  #include <sys/syscall.h>  libc_hidden_proto(getcwd) +libc_hidden_proto(getpagesize)  libc_hidden_proto(strcat)  libc_hidden_proto(strcpy) @@ -182,7 +184,7 @@ char *getcwd(char *buf, size_t size)  	    __set_errno(EINVAL);  	    return NULL;  	} -	alloc_size = PATH_MAX; +	alloc_size = MAX (PATH_MAX, getpagesize ());      }      path=buf;      if (buf == NULL) { diff --git a/libc/sysdeps/linux/common/mremap.c b/libc/sysdeps/linux/common/mremap.c index 080d2c1c2..5499c0975 100644 --- a/libc/sysdeps/linux/common/mremap.c +++ b/libc/sysdeps/linux/common/mremap.c @@ -9,10 +9,13 @@  #include "syscalls.h"  #include <unistd.h> +#define mremap _hidemremap  #include <sys/mman.h> +#undef mremap -libc_hidden_proto(mremap) +void *mremap(void *, size_t, size_t, int, void *); -_syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t, -		  new_size, int, may_move); +libc_hidden_proto(mremap) +_syscall5(void *, mremap, void *, old_address, size_t, old_size, size_t, +		  new_size, int, may_move, void *, new_address);  libc_hidden_def(mremap) diff --git a/libc/sysdeps/linux/m68k/clone.S b/libc/sysdeps/linux/m68k/clone.S index 2735bcba0..8ef916e91 100644 --- a/libc/sysdeps/linux/m68k/clone.S +++ b/libc/sysdeps/linux/m68k/clone.S @@ -21,11 +21,11 @@ clone:  	movel   4(%sp), %d1             /* no NULL function pointers */  	movel	%d1, %a0  	tstl    %d1 -	beq.w   __syscall_error +	jbeq    __syscall_error  	movel   8(%sp), %d1             /* no NULL stack pointers */  	movel	%d1, %a1  	tstl    %d1 -	beq.w   __syscall_error +	jbeq    __syscall_error  	/* Allocate space and copy the argument onto the new stack.  */  	movel   16(%sp), -(%a1) @@ -50,7 +50,7 @@ clone:  #endif  	tstl    %d0 -	bmi.w   __syscall_error +	jbmi    __syscall_error  	beq.w   thread_start  	rts diff --git a/libc/sysdeps/linux/m68k/crt1.S b/libc/sysdeps/linux/m68k/crt1.S index ee25e48eb..9ce14e594 100644 --- a/libc/sysdeps/linux/m68k/crt1.S +++ b/libc/sysdeps/linux/m68k/crt1.S @@ -51,6 +51,13 @@  		(4*(argc+1))(%sp)	envp[0]  		...  					NULL + +   The uclinux conventions are different.  %a1 is not defined on entry +   and the stack is laid out as follows: + +		0(%sp)			argc +		4(%sp)			argv +		8(%sp)			envp  */  #include <features.h> @@ -73,15 +80,23 @@ _start:  	   arguments for `main': argc, argv.  envp will be determined  	   later in __libc_start_main.  */  	move.l (%sp)+, %d0	/* Pop the argument count.  */ +#ifndef __ARCH_USE_MMU__ +	move.l (%sp)+, %a0 +#else  	move.l %sp, %a0		/* The argument vector starts just at the  				   current stack top.  */ +#endif  	/* Provide the highest stack address to the user code (for stacks  	   which grow downward).  */  	pea (%sp) +#ifndef __ARCH_USE_MMU__ +	clr.l -(%sp) +#else  	pea (%a1)		/* Push address of the shared library  				   termination function.  */ +#endif  	/* Push the address of our own entry points to `.fini' and  	   `.init'.  */  | 
