diff options
author | Mike Frysinger <vapier@gentoo.org> | 2006-08-23 23:20:30 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2006-08-23 23:20:30 +0000 |
commit | 190da1cd0c221438c563b5b605ff811e9075e210 (patch) | |
tree | ca5177a27d154dfa08b85d678ce6e33ac0672522 | |
parent | e0605c73da33c6f06b13c4bdf5cb42db97cd4b30 (diff) |
sync with psm: update errno handling to be the same on all arches
21 files changed, 160 insertions, 113 deletions
diff --git a/include/errno.h b/include/errno.h index 9f3c6efcb..aef117e87 100644 --- a/include/errno.h +++ b/include/errno.h @@ -43,30 +43,32 @@ __BEGIN_DECLS variable. This redeclaration using the macro still works, but it will be a function declaration without a prototype and may trigger a -Wstrict-prototypes warning. */ -# ifndef __ASSEMBLER__ -# ifndef errno +#ifndef errno extern int errno; -# endif +#endif -# if defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__ +#if defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__ /* The full and simple forms of the name with which the program was invoked. These variables are set up automatically at startup based on the value of ARGV[0] (this works only if you use GNU ld). */ extern char *program_invocation_name, *program_invocation_short_name; -# endif /* __USE_GNU */ -# endif /* __ASSEMBLER__ */ +#endif /* __USE_GNU */ #endif /* _ERRNO_H */ __END_DECLS +#if defined _LIBC && ( defined IS_IN_libc || defined NOT_IN_libc ) +#include <bits/uClibc_errno.h> +#endif + #endif /* _ERRNO_H */ /* The Hurd <bits/errno.h> defines `error_t' as an enumerated type so that printing `error_t' values in the debugger shows the names. We might need this definition sometimes even if this file was included before. */ -#if ( defined __USE_GNU || defined __need_error_t ) && !defined __ASSEMBLER__ +#if defined __USE_GNU || defined __need_error_t # ifndef __error_t_defined typedef int error_t; # define __error_t_defined 1 diff --git a/libc/misc/internals/__errno_location.c b/libc/misc/internals/__errno_location.c index cd2a9c0eb..5a2af36fd 100644 --- a/libc/misc/internals/__errno_location.c +++ b/libc/misc/internals/__errno_location.c @@ -1,8 +1,16 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + #include <errno.h> #undef errno +extern int errno; libc_hidden_proto(errno) /* psm: moved to bits/errno.h: libc_hidden_proto(__errno_location) */ +libc_hidden_proto(__errno_location) int * weak_const_function __errno_location (void) { return &errno; diff --git a/libc/misc/internals/__h_errno_location.c b/libc/misc/internals/__h_errno_location.c index 96f51ae5c..10b7673e3 100644 --- a/libc/misc/internals/__h_errno_location.c +++ b/libc/misc/internals/__h_errno_location.c @@ -1,7 +1,14 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + #define __FORCE_GLIBC #include <features.h> #include <netdb.h> #undef h_errno +extern int h_errno; libc_hidden_proto(h_errno) diff --git a/libc/sysdeps/linux/alpha/bits/syscalls.h b/libc/sysdeps/linux/alpha/bits/syscalls.h index 3c227e643..561d4bf15 100644 --- a/libc/sysdeps/linux/alpha/bits/syscalls.h +++ b/libc/sysdeps/linux/alpha/bits/syscalls.h @@ -9,12 +9,12 @@ * programs. */ #include <bits/sysnum.h> -#ifndef __set_errno -# define __set_errno(val) (*__errno_location ()) = (val) -#endif - #ifndef __ASSEMBLER__ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + #define _syscall_return(type) \ return (_sc_err ? __set_errno(_sc_ret), _sc_ret = -1L : 0), (type) _sc_ret diff --git a/libc/sysdeps/linux/arm/bits/syscalls.h b/libc/sysdeps/linux/arm/bits/syscalls.h index d25d1824e..b6cfc1f9b 100644 --- a/libc/sysdeps/linux/arm/bits/syscalls.h +++ b/libc/sysdeps/linux/arm/bits/syscalls.h @@ -9,19 +9,17 @@ * programs. */ #include <bits/sysnum.h> -#ifndef __set_errno -# define __set_errno(val) (*__errno_location ()) = (val) -#endif -#ifndef SYS_ify -# define SYS_ify(syscall_name) (__NR_##syscall_name) -#endif - /* Some of the sneaky macros in the code were taken from glibc-2.3.2/sysdeps/unix/sysv/linux/arm/sysdep.h */ #ifdef __ASSEMBLER__ + +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + /* Call a given syscall, with arguments loaded. For EABI, we must save and restore r7 for the syscall number. Unlike the DO_CALL macro in glibc, this macro does not load syscall arguments. */ diff --git a/libc/sysdeps/linux/bfin/bits/syscalls.h b/libc/sysdeps/linux/bfin/bits/syscalls.h index 475d193ce..2309f7f6d 100644 --- a/libc/sysdeps/linux/bfin/bits/syscalls.h +++ b/libc/sysdeps/linux/bfin/bits/syscalls.h @@ -9,15 +9,11 @@ * programs. */ #include <bits/sysnum.h> -#ifndef __set_errno -# define __set_errno(val) ((*__errno_location ()) = (val)) -#endif +#ifndef __ASSEMBLER__ -#ifndef SYS_ify -# define SYS_ify(syscall_name) (__NR_##syscall_name) -#endif +#include <errno.h> -#ifndef __ASSEMBLER__ +#define SYS_ify(syscall_name) (__NR_##syscall_name) /* user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h> */ #if defined _LIBC && !defined __set_errno diff --git a/libc/sysdeps/linux/common/bits/errno.h b/libc/sysdeps/linux/common/bits/errno.h index 45a0ec0d1..78e8c6972 100644 --- a/libc/sysdeps/linux/common/bits/errno.h +++ b/libc/sysdeps/linux/common/bits/errno.h @@ -1,5 +1,5 @@ /* Error constants. Linux specific version. - Copyright (C) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,35 +19,41 @@ #ifdef _ERRNO_H -#include <bits/errno_values.h> +# undef EDOM +# undef EILSEQ +# undef ERANGE +# include <bits/errno_values.h> -#ifndef ENOTSUP +/* Linux has no ENOTSUP error code. */ # define ENOTSUP EOPNOTSUPP -#endif -#ifndef ECANCELED -# define ECANCELED 125 -#endif - -#ifndef __ASSEMBLER__ +/* Older Linux versions also had no ECANCELED error code. */ +# ifndef ECANCELED +# define ECANCELED 125 +# endif -/* We now need a declaration of the `errno' variable. */ -extern int errno; +/* Support for error codes to support robust mutexes was added later, too. */ +# ifndef EOWNERDEAD +# define EOWNERDEAD 130 +# define ENOTRECOVERABLE 131 +# endif +# ifndef __ASSEMBLER__ /* Function to get address of global `errno' variable. */ extern int *__errno_location (void) __THROW __attribute__ ((__const__)); -# if defined _LIBC && ( defined IS_IN_libc || defined NOT_IN_libc ) -libc_hidden_proto(__errno_location) -/* We wouldn't need a special macro anymore but it is history. */ -# define __set_errno(val) ((errno) = (val)) -# endif /* _LIBC */ - -# ifdef __UCLIBC_HAS_THREADS__ +# ifdef __UCLIBC_HAS_THREADS__ /* When using threads, errno is a per-thread value. */ -# define errno (*__errno_location ()) -# endif - -#endif /* !__ASSEMBLER__ */ - +# define errno (*__errno_location ()) +# endif +# endif /* !__ASSEMBLER__ */ #endif /* _ERRNO_H */ + +#if !defined _ERRNO_H && defined __need_Emath +/* This is ugly but the kernel header is not clean enough. We must + define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is + defined. */ +# define EDOM 33 /* Math argument out of domain of function. */ +# define EILSEQ 84 /* Illegal byte sequence. */ +# define ERANGE 34 /* Math result not representable. */ +#endif /* !_ERRNO_H && __need_Emath */ diff --git a/libc/sysdeps/linux/common/bits/syscalls.h b/libc/sysdeps/linux/common/bits/syscalls.h index e891af8e5..4895c4fa0 100644 --- a/libc/sysdeps/linux/common/bits/syscalls.h +++ b/libc/sysdeps/linux/common/bits/syscalls.h @@ -5,6 +5,4 @@ * forbidden. Don't do it. It is bad for you. */ - -#error You have not provided architecture specific _syscall[0-5] macros - +#error You have not provided architecture specific _syscall[0-6] macros diff --git a/libc/sysdeps/linux/common/bits/uClibc_errno.h b/libc/sysdeps/linux/common/bits/uClibc_errno.h new file mode 100644 index 000000000..9da9f8155 --- /dev/null +++ b/libc/sysdeps/linux/common/bits/uClibc_errno.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ +#ifndef _BITS_UCLIBC_ERRNO_H +#define _BITS_UCLIBC_ERRNO_H 1 + +#ifdef IS_IN_rtld +# undef errno +# define errno _dl_errno +extern int _dl_errno; // attribute_hidden; +#elif defined __UCLIBC_HAS_THREADS__ +# include <tls.h> +# if USE___THREAD +# undef errno +# ifndef NOT_IN_libc +# define errno __libc_errno +# else +# define errno errno +# endif +extern __thread int errno __attribute_tls_model_ie; +# endif /* USE___THREAD */ +#endif /* IS_IN_rtld */ + +#define __set_errno(val) (errno = (val)) + +#ifndef __ASSEMBLER__ +extern int *__errno_location (void) __THROW __attribute__ ((__const__)) +# ifdef IS_IN_rtld + attribute_hidden +# endif +; +#include <tls.h> +#if USE___THREAD +libc_hidden_proto(__errno_location) +#endif + +/* We now need a declaration of the `errno' variable. */ +# ifndef __UCLIBC_HAS_THREADS__ +/*extern int errno;*/ +libc_hidden_proto(errno) +# endif +#endif /* !__ASSEMBLER__ */ + +#endif diff --git a/libc/sysdeps/linux/cris/bits/syscalls.h b/libc/sysdeps/linux/cris/bits/syscalls.h index ce68c04d4..8b74518ce 100644 --- a/libc/sysdeps/linux/cris/bits/syscalls.h +++ b/libc/sysdeps/linux/cris/bits/syscalls.h @@ -8,16 +8,11 @@ /* Include the __NR_<name> definitions. */ #include <bits/sysnum.h> -#if 0 -#ifndef __set_errno -#define __set_errno(val) (*__errno_location()) = (val) -#endif -#endif +#ifndef __ASSEMBLER__ -#undef SYS_ify -#define SYS_ify(syscall_name) (__NR_##syscall_name) +#include <errno.h> -#ifndef __ASSEMBLER__ +#define SYS_ify(syscall_name) (__NR_##syscall_name) #undef _syscall0 #define _syscall0(type,name) \ diff --git a/libc/sysdeps/linux/frv/bits/syscalls.h b/libc/sysdeps/linux/frv/bits/syscalls.h index 23219d602..fae1079bd 100644 --- a/libc/sysdeps/linux/frv/bits/syscalls.h +++ b/libc/sysdeps/linux/frv/bits/syscalls.h @@ -9,12 +9,12 @@ * programs. */ #include <bits/sysnum.h> -#ifndef SYS_ify -# define SYS_ify(syscall_name) (__NR_##syscall_name) -#endif - #ifndef __ASSEMBLER__ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + /* 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) \ diff --git a/libc/sysdeps/linux/hppa/bits/syscalls.h b/libc/sysdeps/linux/hppa/bits/syscalls.h index cb80138f5..365f5b4b1 100644 --- a/libc/sysdeps/linux/hppa/bits/syscalls.h +++ b/libc/sysdeps/linux/hppa/bits/syscalls.h @@ -9,12 +9,10 @@ * programs. */ #include <bits/sysnum.h> -#ifndef __set_errno -# define __set_errno(val) (*__errno_location ()) = (val) -#endif - #ifndef __ASSEMBLER__ +#include <errno.h> + #define SYS_ify(syscall_name) __NR_##syscall_name /* Assume all syscalls are done from PIC code just to be diff --git a/libc/sysdeps/linux/i386/bits/syscalls.h b/libc/sysdeps/linux/i386/bits/syscalls.h index 58475e3af..73f858521 100644 --- a/libc/sysdeps/linux/i386/bits/syscalls.h +++ b/libc/sysdeps/linux/i386/bits/syscalls.h @@ -4,8 +4,6 @@ # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead." #endif -#include <errno.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. */ @@ -18,6 +16,10 @@ #ifndef __ASSEMBLER__ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + /* We need some help from the assembler to generate optimal code. We define some macros here which later will be used. */ diff --git a/libc/sysdeps/linux/ia64/bits/syscalls.h b/libc/sysdeps/linux/ia64/bits/syscalls.h index c5da7d91f..666468a7a 100644 --- a/libc/sysdeps/linux/ia64/bits/syscalls.h +++ b/libc/sysdeps/linux/ia64/bits/syscalls.h @@ -31,17 +31,14 @@ * programs. */ #include <bits/sysnum.h> -#ifndef __set_errno -# define __set_errno(val) (*__errno_location ()) = (val) -#endif +#ifndef __ASSEMBLER__ +#include <errno.h> -#ifndef __ASSEMBLER__ +#define SYS_ify(syscall_name) (__NR_##syscall_name) #undef IA64_USE_NEW_STUB -#define SYS_ify(syscall_name) __NR_##syscall_name - /* taken from asm-ia64/break.h */ #define __IA64_BREAK_SYSCALL 0x100000 #define ___IA64_BREAK_SYSCALL "0x100000" diff --git a/libc/sysdeps/linux/mips/bits/syscalls.h b/libc/sysdeps/linux/mips/bits/syscalls.h index 7133d83e3..1987bbfb2 100644 --- a/libc/sysdeps/linux/mips/bits/syscalls.h +++ b/libc/sysdeps/linux/mips/bits/syscalls.h @@ -9,15 +9,12 @@ * programs. */ #include <bits/sysnum.h> -#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__ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + #define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \ "$14", "$15", "$24", "$25", "memory" diff --git a/libc/sysdeps/linux/powerpc/bits/syscalls.h b/libc/sysdeps/linux/powerpc/bits/syscalls.h index e28c380ee..ae269b876 100644 --- a/libc/sysdeps/linux/powerpc/bits/syscalls.h +++ b/libc/sysdeps/linux/powerpc/bits/syscalls.h @@ -5,13 +5,13 @@ # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead." #endif -#include <errno.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> +#ifndef __ASSEMBLER__ + /* Define a macro which expands inline into the wrapper code for a system call. This use is for internal calls that do not need to handle errors normally. It will never touch errno. @@ -20,6 +20,10 @@ "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal an error return status). */ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + # undef INLINE_SYSCALL #if 1 # define INLINE_SYSCALL(name, nr, args...) \ @@ -164,5 +168,5 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6 return (type) INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); \ } +#endif /* __ASSEMBLER__ */ #endif /* _BITS_SYSCALLS_H */ - diff --git a/libc/sysdeps/linux/sh/bits/syscalls.h b/libc/sysdeps/linux/sh/bits/syscalls.h index 55b227f71..83b20f63e 100644 --- a/libc/sysdeps/linux/sh/bits/syscalls.h +++ b/libc/sysdeps/linux/sh/bits/syscalls.h @@ -9,15 +9,12 @@ * programs. */ #include <bits/sysnum.h> -#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__ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + /* user-visible error numbers are in the range -1 - -125: see <asm-sh/errno.h> */ #define __syscall_return(type, res) \ do { \ diff --git a/libc/sysdeps/linux/sh64/bits/syscalls.h b/libc/sysdeps/linux/sh64/bits/syscalls.h index e6190303a..9b4efc2e5 100644 --- a/libc/sysdeps/linux/sh64/bits/syscalls.h +++ b/libc/sysdeps/linux/sh64/bits/syscalls.h @@ -9,15 +9,12 @@ * programs. */ #include <bits/sysnum.h> -#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__ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + /* user-visible error numbers are in the range -1 - -125: see <asm-sh64/errno.h> */ #define __syscall_return(type, res) \ do { \ diff --git a/libc/sysdeps/linux/sparc/bits/syscalls.h b/libc/sysdeps/linux/sparc/bits/syscalls.h index b8865d453..b0f953972 100644 --- a/libc/sysdeps/linux/sparc/bits/syscalls.h +++ b/libc/sysdeps/linux/sparc/bits/syscalls.h @@ -11,12 +11,12 @@ * programs. */ #include <bits/sysnum.h> -#ifndef __set_errno -# define __set_errno(val) (*__errno_location ()) = (val) -#endif - #ifndef __ASSEMBLER__ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + #undef __SYSCALL_STRING #if __WORDSIZE == 32 # define __SYSCALL_STRING \ diff --git a/libc/sysdeps/linux/vax/bits/syscalls.h b/libc/sysdeps/linux/vax/bits/syscalls.h index caa62118d..f80b40539 100644 --- a/libc/sysdeps/linux/vax/bits/syscalls.h +++ b/libc/sysdeps/linux/vax/bits/syscalls.h @@ -9,13 +9,11 @@ * programs. */ #include <bits/sysnum.h> -#ifndef __set_errno -# define __set_errno(val) (*__errno_location())=(val) -#endif +#ifndef __ASSEMBLER__ -#ifndef SYS_ify -# define SYS_ify(syscall_name) (__NR_##syscall_name) -#endif +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) #undef _syscall_return #define _syscall_return(type) \ @@ -261,4 +259,5 @@ type name (type1 arg1, \ _syscall_return (type); \ } +#endif /* __ASSEMBLER__ */ #endif /* _BITS_SYSCALLS_H */ diff --git a/libc/sysdeps/linux/x86_64/bits/syscalls.h b/libc/sysdeps/linux/x86_64/bits/syscalls.h index d44f637ac..afd97c0b0 100644 --- a/libc/sysdeps/linux/x86_64/bits/syscalls.h +++ b/libc/sysdeps/linux/x86_64/bits/syscalls.h @@ -9,10 +9,6 @@ * programs. */ #include <bits/sysnum.h> -#ifndef __set_errno -# define __set_errno(val) (*__errno_location ()) = (val) -#endif - /* Some of the sneaky macros in the code were taken from glibc-2.2.5/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -20,6 +16,10 @@ #ifndef __ASSEMBLER__ +#include <errno.h> + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + #undef _syscall0 #define _syscall0(type,name) \ type name(void) \ |