diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 989355c3d..fcd764c25 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,39 @@ +2005-09-08 Jeff Johnston + + * Makefile.am: Add include files under bits sub-directory. + * Makefile.in: Regenerated. + * libc/sys/linux/argp/argp-fs-xinl.c: Set __OPTIMIZE__ to + actual value of 1 to be compatible with newer glibc headers. + * libc/sys/linux/sys/cdefs.h: Fix to be compatible with newer + glibc headers. + * libc/sys/linux/sys/dirent.h: Ditto. + * libc/sys/linux/argp/argp-xinl.c: Ditto. + * libc/sys/linux/dl/dl-runtime.c: Make sure fixup and + profile_fixup routines are marked used so they won't be + optimized away. + * libc/sys/linux/dl/dl-cache.c: Don't use weak_extern macro + to mark functions as weak. + * libc/sys/linux/dl/dl-open.c: Ditto. + * libc/sys/linux/iconv/gconv_open.c: Fix to obey new gcc4 + rules about lvalues. + * libc/sys/linux/iconv/gconv_simple.c: Ditto. + * libc/sys/linux/linuxthreads/bits/libc-lock.h: Don't use + weak_extern macro to mark functions as weak. Instead always + use #pragma weak. + * iconvdata/jis0208.h: Fix to work with gcc4. + * libc/sys/linux/dl/dl-load.c: Ditto. + * libc/sys/linux/dl/dl-reloc.c: Ditto. + * libc/sys/linux/dl/do-rel.h: Ditto. + * libc/sys/linux/dl/dynamic-link.h: Ditto. + * libc/sys/linux/include/ltdl.h: Ditto. + * libc/sys/linux/machine/i386/dl-machine.h: Ditto. + * libc/sys/linux/machine/i386/weakalias.h: Ditto. + * libc/sys/linux/net/ns_ntoa.c: Ditto. + * libc/sys/linux/bits/initspin.h: New file. + * libc/sys/linux/bits/libc-lock.h: Ditto. + * libc/sys/linux/bits/pthreadtypes.h: Ditto. + * libc/sys/linux/bits/typesizes.h: Ditto. + 2005-09-08 Eric Blake * libc/argz/argz_insert.c (argz_insert): Don't die with EINVAL when diff --git a/newlib/Makefile.am b/newlib/Makefile.am index cd8fa61c2..db574a2ab 100644 --- a/newlib/Makefile.am +++ b/newlib/Makefile.am @@ -281,6 +281,7 @@ endif $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/sys/`basename $$i`; \ else true; fi ; \ done ; \ + $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/bits; \ for i in $(srcdir)/libc/sys/$(sys_dir)/bits/*.h; do \ if [ -f $$i ]; then \ $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/bits/`basename $$i`; \ diff --git a/newlib/Makefile.in b/newlib/Makefile.in index 7ce0e6048..0e4e5a7c4 100644 --- a/newlib/Makefile.in +++ b/newlib/Makefile.in @@ -787,6 +787,7 @@ install-data-local: install-toollibLIBRARIES $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/sys/`basename $$i`; \ else true; fi ; \ done ; \ + $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/bits; \ for i in $(srcdir)/libc/sys/$(sys_dir)/bits/*.h; do \ if [ -f $$i ]; then \ $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/bits/`basename $$i`; \ diff --git a/newlib/iconvdata/jis0208.h b/newlib/iconvdata/jis0208.h index ef6b891eb..131a5c562 100644 --- a/newlib/iconvdata/jis0208.h +++ b/newlib/iconvdata/jis0208.h @@ -24,15 +24,6 @@ #include #include -/* Conversion table. */ -extern const uint16_t __jis0208_to_ucs[]; - -extern const char __jisx0208_from_ucs4_lat1[256][2]; -extern const char __jisx0208_from_ucs4_greek[0xc1][2]; -extern const struct jisx0208_ucs_idx __jisx0208_from_ucs_idx[]; -extern const char __jisx0208_from_ucs_tab[][2]; - - /* Struct for table with indeces in UCS mapping table. */ struct jisx0208_ucs_idx { @@ -41,6 +32,13 @@ struct jisx0208_ucs_idx uint16_t idx; }; +/* Conversion table. */ +extern const uint16_t __jis0208_to_ucs[]; + +extern const char __jisx0208_from_ucs4_lat1[256][2]; +extern const char __jisx0208_from_ucs4_greek[0xc1][2]; +extern const struct jisx0208_ucs_idx __jisx0208_from_ucs_idx[]; +extern const char __jisx0208_from_ucs_tab[][2]; static inline uint32_t jisx0208_to_ucs4 (const unsigned char **s, size_t avail, unsigned char offset) diff --git a/newlib/libc/sys/linux/argp/argp-fs-xinl.c b/newlib/libc/sys/linux/argp/argp-fs-xinl.c index b61a303e8..9b836d138 100644 --- a/newlib/libc/sys/linux/argp/argp-fs-xinl.c +++ b/newlib/libc/sys/linux/argp/argp-fs-xinl.c @@ -24,7 +24,7 @@ #define ARGP_FS_EI #undef __OPTIMIZE__ -#define __OPTIMIZE__ +#define __OPTIMIZE__ 1 #include "argp-fmtstream.h" /* Add weak aliases. */ diff --git a/newlib/libc/sys/linux/argp/argp-xinl.c b/newlib/libc/sys/linux/argp/argp-xinl.c index 0d64b1efb..644836d30 100644 --- a/newlib/libc/sys/linux/argp/argp-xinl.c +++ b/newlib/libc/sys/linux/argp/argp-xinl.c @@ -29,7 +29,7 @@ #endif #define ARGP_EI #undef __OPTIMIZE__ -#define __OPTIMIZE__ +#define __OPTIMIZE__ 1 #include /* Add weak aliases. */ diff --git a/newlib/libc/sys/linux/bits/initspin.h b/newlib/libc/sys/linux/bits/initspin.h new file mode 100644 index 000000000..a19ec077e --- /dev/null +++ b/newlib/libc/sys/linux/bits/initspin.h @@ -0,0 +1,28 @@ +/* Generic definitions for spinlock initializers. + Copyright (C) 2000, 2001 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 + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Initial value of a spinlock. Most platforms should use zero, + unless they only implement a "test and clear" operation instead of + the usual "test and set". */ +#define __LT_SPINLOCK_INIT 0 + +/* Macros for lock initializers, using the above definition. */ +#define __LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT } +#define __ALT_LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT } +#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_INIT } diff --git a/newlib/libc/sys/linux/bits/libc-lock.h b/newlib/libc/sys/linux/bits/libc-lock.h new file mode 100644 index 000000000..2b170444b --- /dev/null +++ b/newlib/libc/sys/linux/bits/libc-lock.h @@ -0,0 +1,380 @@ +/* libc-internal interface for mutex locks. LinuxThreads version. + Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003 + 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 + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_LIBC_LOCK_H +#define _BITS_LIBC_LOCK_H 1 + +#include + +#if defined _LIBC && !defined NOT_IN_libc +#include +#endif + +/* Mutex type. */ +#if defined(_LIBC) || defined(_IO_MTSAFE_IO) +typedef pthread_mutex_t __libc_lock_t; +typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t; +# ifdef __USE_UNIX98 +typedef pthread_rwlock_t __libc_rwlock_t; +# else +typedef struct __libc_rwlock_opaque__ __libc_rwlock_t; +# endif +typedef __libc_lock_recursive_t __rtld_lock_recursive_t; +#else +typedef struct __libc_lock_opaque__ __libc_lock_t; +typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t; +typedef struct __libc_rwlock_opaque__ __libc_rwlock_t; +#endif + +/* Type for key to thread-specific data. */ +typedef pthread_key_t __libc_key_t; + +/* Define a lock variable NAME with storage class CLASS. The lock must be + initialized with __libc_lock_init before it can be used (or define it + with __libc_lock_define_initialized, below). Use `extern' for CLASS to + declare a lock defined in another module. In public structure + definitions you must use a pointer to the lock structure (i.e., NAME + begins with a `*'), because its storage size will not be known outside + of libc. */ +#define __libc_lock_define(CLASS,NAME) \ + CLASS __libc_lock_t NAME; +#define __libc_rwlock_define(CLASS,NAME) \ + CLASS __libc_rwlock_t NAME; +#define __libc_lock_define_recursive(CLASS,NAME) \ + CLASS __libc_lock_recursive_t NAME; +#define __rtld_lock_define_recursive(CLASS,NAME) \ + CLASS __rtld_lock_recursive_t NAME; + +/* Define an initialized lock variable NAME with storage class CLASS. + + For the C library we take a deeper look at the initializer. For + this implementation all fields are initialized to zero. Therefore + we don't initialize the variable which allows putting it into the + BSS section. (Except on PA-RISC and other odd architectures, where + initialized locks must be set to one due to the lack of normal + atomic operations.) */ + +#if __LT_SPINLOCK_INIT == 0 +# define __libc_lock_define_initialized(CLASS,NAME) \ + CLASS __libc_lock_t NAME; +#else +# define __libc_lock_define_initialized(CLASS,NAME) \ + CLASS __libc_lock_t NAME = PTHREAD_MUTEX_INITIALIZER; +#endif + +#define __libc_rwlock_define_initialized(CLASS,NAME) \ + CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER; + +/* Define an initialized recursive lock variable NAME with storage + class CLASS. */ +#define __libc_lock_define_initialized_recursive(CLASS,NAME) \ + CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER; +#define _LIBC_LOCK_RECURSIVE_INITIALIZER \ + {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP} + +#define __rtld_lock_define_initialized_recursive(CLASS,NAME) \ + CLASS __rtld_lock_recursive_t NAME = _RTLD_LOCK_RECURSIVE_INITIALIZER; +#define _RTLD_LOCK_RECURSIVE_INITIALIZER \ + {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP} + +#if defined _LIBC && defined IS_IN_libpthread +# define __libc_maybe_call(FUNC, ARGS, ELSE) FUNC ARGS +#else +# if defined __PIC__ || (defined _LIBC && defined SHARED) +# define __libc_maybe_call(FUNC, ARGS, ELSE) \ + (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \ + _fn != NULL ? (*_fn) ARGS : ELSE; })) +# else +# define __libc_maybe_call(FUNC, ARGS, ELSE) \ + (FUNC != NULL ? FUNC ARGS : ELSE) +# endif +#endif +#if defined _LIBC && !defined NOT_IN_libc && defined SHARED +# define __libc_maybe_call2(FUNC, ARGS, ELSE) \ + ({__builtin_expect (__libc_pthread_functions.ptr_##FUNC != NULL, 0) \ + ? __libc_pthread_functions.ptr_##FUNC ARGS : ELSE; }) +#else +# define __libc_maybe_call2(FUNC, ARGS, ELSE) __libc_maybe_call (__##FUNC, ARGS, ELSE) +#endif + +/* Initialize the named lock variable, leaving it in a consistent, unlocked + state. */ +#if defined _LIBC && !defined NOT_IN_libc && defined SHARED +#define __libc_lock_init(NAME) \ + ({ \ + (NAME).__m_count = 0; \ + (NAME).__m_owner = NULL; \ + (NAME).__m_kind = PTHREAD_MUTEX_TIMED_NP; \ + (NAME).__m_lock.__status = 0; \ + (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \ + 0; }) +#else +#define __libc_lock_init(NAME) \ + (__libc_maybe_call2 (pthread_mutex_init, (&(NAME), NULL), 0)) +#endif +#define __libc_rwlock_init(NAME) \ + (__libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0)); + +/* Same as last but this time we initialize a recursive mutex. */ +#if defined _LIBC && !defined NOT_IN_libc && defined SHARED +#define __libc_lock_init_recursive(NAME) \ + ({ \ + (NAME).mutex.__m_count = 0; \ + (NAME).mutex.__m_owner = NULL; \ + (NAME).mutex.__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \ + (NAME).mutex.__m_lock.__status = 0; \ + (NAME).mutex.__m_lock.__spinlock = __LT_SPINLOCK_INIT; \ + 0; }) +#else +#define __libc_lock_init_recursive(NAME) \ + do { \ + if (__pthread_mutex_init != NULL) \ + { \ + pthread_mutexattr_t __attr; \ + __pthread_mutexattr_init (&__attr); \ + __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \ + __pthread_mutex_init (&(NAME).mutex, &__attr); \ + __pthread_mutexattr_destroy (&__attr); \ + } \ + } while (0); +#endif +#define __rtld_lock_init_recursive(NAME) \ + __libc_lock_init_recursive (NAME) + +/* Finalize the named lock variable, which must be locked. It cannot be + used again until __libc_lock_init is called again on it. This must be + called on a lock variable before the containing storage is reused. */ +#define __libc_lock_fini(NAME) \ + (__libc_maybe_call2 (pthread_mutex_destroy, (&(NAME)), 0)); +#define __libc_rwlock_fini(NAME) \ + (__libc_maybe_call (__pthread_rwlock_destroy, (&(NAME)), 0)); + +/* Finalize recursive named lock. */ +#define __libc_lock_fini_recursive(NAME) __libc_lock_fini ((NAME).mutex) +#define __rtld_lock_fini_recursive(NAME) __libc_lock_fini_recursive (NAME) + +/* Lock the named lock variable. */ +#define __libc_lock_lock(NAME) \ + (__libc_maybe_call2 (pthread_mutex_lock, (&(NAME)), 0)); +#define __libc_rwlock_rdlock(NAME) \ + (__libc_maybe_call (__pthread_rwlock_rdlock, (&(NAME)), 0)); +#define __libc_rwlock_wrlock(NAME) \ + (__libc_maybe_call (__pthread_rwlock_wrlock, (&(NAME)), 0)); + +/* Lock the recursive named lock variable. */ +#define __libc_lock_lock_recursive(NAME) __libc_lock_lock ((NAME).mutex) + +/* Try to lock the named lock variable. */ +#define __libc_lock_trylock(NAME) \ + (__libc_maybe_call2 (pthread_mutex_trylock, (&(NAME)), 0)) +#define __libc_rwlock_tryrdlock(NAME) \ + (__libc_maybe_call (__pthread_rwlock_tryrdlock, (&(NAME)), 0)) +#define __libc_rwlock_trywrlock(NAME) \ + (__libc_maybe_call (__pthread_rwlock_trywrlock, (&(NAME)), 0)) + +/* Try to lock the recursive named lock variable. */ +#define __libc_lock_trylock_recursive(NAME) __libc_lock_trylock ((NAME).mutex) +#define __rtld_lock_trylock_recursive(NAME) \ + __libc_lock_trylock_recursive (NAME) + +/* Unlock the named lock variable. */ +#define __libc_lock_unlock(NAME) \ + (__libc_maybe_call2 (pthread_mutex_unlock, (&(NAME)), 0)); +#define __libc_rwlock_unlock(NAME) \ + (__libc_maybe_call (__pthread_rwlock_unlock, (&(NAME)), 0)); + +/* Unlock the recursive named lock variable. */ +#define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock ((NAME).mutex) + +#if defined _LIBC && defined SHARED +# define __rtld_lock_default_lock_recursive(lock) \ + ++((pthread_mutex_t *)(lock))->__m_count; + +# define __rtld_lock_default_unlock_recursive(lock) \ + --((pthread_mutex_t *)(lock))->__m_count; + +# define __rtld_lock_lock_recursive(NAME) \ + GL(dl_rtld_lock_recursive) (&(NAME).mutex) + +# define __rtld_lock_unlock_recursive(NAME) \ + GL(dl_rtld_unlock_recursive) (&(NAME).mutex) +#else +#define __rtld_lock_lock_recursive(NAME) __libc_lock_lock_recursive (NAME) +#define __rtld_lock_unlock_recursive(NAME) __libc_lock_unlock_recursive (NAME) +#endif + +/* Define once control variable. */ +#if PTHREAD_ONCE_INIT == 0 +/* Special case for static variables where we can avoid the initialization + if it is zero. */ +# define __libc_once_define(CLASS, NAME) \ + CLASS pthread_once_t NAME +#else +# define __libc_once_define(CLASS, NAME) \ + CLASS pthread_once_t NAME = PTHREAD_ONCE_INIT +#endif + +/* Call handler iff the first call. */ +#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \ + do { \ + if (__pthread_once != NULL) \ + __pthread_once (&(ONCE_CONTROL), (INIT_FUNCTION)); \ + else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) { \ + INIT_FUNCTION (); \ + (ONCE_CONTROL) = 2; \ + } \ + } while (0) + + +/* Start critical region with cleanup. */ +#define __libc_cleanup_region_start(DOIT, FCT, ARG) \ + { struct _pthread_cleanup_buffer _buffer; \ + int _avail = (DOIT) && _pthread_cleanup_push_defer != NULL; \ + if (_avail) { \ + _pthread_cleanup_push_defer (&_buffer, (FCT), (ARG)); \ + } + +/* End critical region with cleanup. */ +#define __libc_cleanup_region_end(DOIT) \ + if (_avail) { \ + _pthread_cleanup_pop_restore (&_buffer, (DOIT)); \ + } \ + } + +/* Sometimes we have to exit the block in the middle. */ +#define __libc_cleanup_end(DOIT) \ + if (_avail) { \ + _pthread_cleanup_pop_restore (&_buffer, (DOIT)); \ + } + +#define __libc_cleanup_push(fct, arg) \ + { struct _pthread_cleanup_buffer _buffer; \ + __libc_maybe_call (_pthread_cleanup_push, (&_buffer, (fct), (arg)), 0) + +#define __libc_cleanup_pop(execute) \ + __libc_maybe_call (_pthread_cleanup_pop, (&_buffer, execute), 0); \ + } + +/* Create thread-specific key. */ +#define __libc_key_create(KEY, DESTRUCTOR) \ + (__libc_maybe_call (__pthread_key_create, (KEY, DESTRUCTOR), 1)) + +/* Get thread-specific data. */ +#define __libc_getspecific(KEY) \ + (__libc_maybe_call (__pthread_getspecific, (KEY), NULL)) + +/* Set thread-specific data. */ +#define __libc_setspecific(KEY, VALUE) \ + (__libc_maybe_call (__pthread_setspecific, (KEY, VALUE), 0)) + + +/* Register handlers to execute before and after `fork'. */ +#define __libc_atfork(PREPARE, PARENT, CHILD) \ + (__libc_maybe_call (__pthread_atfork, (PREPARE, PARENT, CHILD), 0)) + +/* Functions that are used by this file and are internal to the GNU C + library. */ + +extern int __pthread_mutex_init (pthread_mutex_t *__mutex, + __const pthread_mutexattr_t *__mutex_attr); + +extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex); + +extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex); + +extern int __pthread_mutex_lock (pthread_mutex_t *__mutex); + +extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex); + +extern int __pthread_mutexattr_init (pthread_mutexattr_t *__attr); + +extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr); + +extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr, + int __kind); + +#ifdef __USE_UNIX98 +extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock, + __const pthread_rwlockattr_t *__attr); + +extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock); + +extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock); + +extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock); + +extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock); + +extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock); + +extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock); +#endif + +extern int __pthread_key_create (pthread_key_t *__key, + void (*__destr_function) (void *)); + +extern int __pthread_setspecific (pthread_key_t __key, + __const void *__pointer); + +extern void *__pthread_getspecific (pthread_key_t __key); + +extern int __pthread_once (pthread_once_t *__once_control, + void (*__init_routine) (void)); + +extern int __pthread_atfork (void (*__prepare) (void), + void (*__parent) (void), + void (*__child) (void)); + + + +/* Make the pthread functions weak so that we can elide them from + single-threaded processes. */ +#ifndef __NO_WEAK_PTHREAD_ALIASES +# pragma weak __pthread_mutex_init +# pragma weak __pthread_mutex_destroy +# pragma weak __pthread_mutex_lock +# pragma weak __pthread_mutex_trylock +# pragma weak __pthread_mutex_unlock +# pragma weak __pthread_mutexattr_init +# pragma weak __pthread_mutexattr_destroy +# pragma weak __pthread_mutexattr_settype +# pragma weak __pthread_rwlock_destroy +# pragma weak __pthread_rwlock_rdlock +# pragma weak __pthread_rwlock_tryrdlock +# pragma weak __pthread_rwlock_wrlock +# pragma weak __pthread_rwlock_trywrlock +# pragma weak __pthread_rwlock_unlock +# pragma weak __pthread_key_create +# pragma weak __pthread_setspecific +# pragma weak __pthread_getspecific +# pragma weak __pthread_once +# pragma weak __pthread_initialize +# pragma weak __pthread_atfork +# pragma weak _pthread_cleanup_push_defer +# pragma weak _pthread_cleanup_pop_restore +# pragma weak _pthread_cleanup_push +# pragma weak _pthread_cleanup_pop +#endif + +/* We need portable names for some functions. E.g., when they are + used as argument to __libc_cleanup_region_start. */ +#define __libc_mutex_unlock __pthread_mutex_unlock + +#endif /* bits/libc-lock.h */ diff --git a/newlib/libc/sys/linux/bits/pthreadtypes.h b/newlib/libc/sys/linux/bits/pthreadtypes.h new file mode 100644 index 000000000..d1daef07a --- /dev/null +++ b/newlib/libc/sys/linux/bits/pthreadtypes.h @@ -0,0 +1,152 @@ +/* Linuxthreads - a simple clone()-based implementation of Posix */ +/* threads for Linux. */ +/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */ +/* */ +/* 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. */ + +#if !defined _BITS_TYPES_H && !defined _PTHREAD_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_PTHREADTYPES_H +#define _BITS_PTHREADTYPES_H 1 + +#define __need_schedparam +#include + +/* Fast locks (not abstract because mutexes and conditions aren't abstract). */ +struct _pthread_fastlock +{ + long int __status; /* "Free" or "taken" or head of waiting list */ + int __spinlock; /* Used by compare_and_swap emulation. Also, + adaptive SMP lock stores spin count here. */ +}; + +#ifndef _PTHREAD_DESCR_DEFINED +/* Thread descriptors */ +typedef struct _pthread_descr_struct *_pthread_descr; +# define _PTHREAD_DESCR_DEFINED +#endif + + +/* Attributes for threads. */ +typedef struct __pthread_attr_s +{ + int __detachstate; + int __schedpolicy; + struct __sched_param __schedparam; + int __inheritsched; + int __scope; + size_t __guardsize; + int __stackaddr_set; + void *__stackaddr; + size_t __stacksize; +} pthread_attr_t; + + +/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */ + +#ifdef __GLIBC_HAVE_LONG_LONG +__extension__ typedef long long __pthread_cond_align_t; +#else +typedef long __pthread_cond_align_t; +#endif + +typedef struct +{ + struct _pthread_fastlock __c_lock; /* Protect against concurrent access */ + _pthread_descr __c_waiting; /* Threads waiting on this condition */ + char __padding[48 - sizeof (struct _pthread_fastlock) + - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)]; + __pthread_cond_align_t __align; +} pthread_cond_t; + + +/* Attribute for conditionally variables. */ +typedef struct +{ + int __dummy; +} pthread_condattr_t; + +/* Keys for thread-specific data */ +typedef unsigned int pthread_key_t; + + +/* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */ +/* (The layout is unnatural to maintain binary compatibility + with earlier releases of LinuxThreads.) */ +typedef struct +{ + int __m_reserved; /* Reserved for future use */ + int __m_count; /* Depth of recursive locking */ + _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */ + int __m_kind; /* Mutex kind: fast, recursive or errcheck */ + struct _pthread_fastlock __m_lock; /* Underlying fast lock */ +} pthread_mutex_t; + + +/* Attribute for mutex. */ +typedef struct +{ + int __mutexkind; +} pthread_mutexattr_t; + + +/* Once-only execution */ +typedef int pthread_once_t; + + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +/* Read-write locks. */ +typedef struct _pthread_rwlock_t +{ + struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */ + int __rw_readers; /* Number of readers */ + _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */ + _pthread_descr __rw_read_waiting; /* Threads waiting for reading */ + _pthread_descr __rw_write_waiting; /* Threads waiting for writing */ + int __rw_kind; /* Reader/Writer preference selection */ + int __rw_pshared; /* Shared between processes or not */ +} pthread_rwlock_t; + + +/* Attribute for read-write locks. */ +typedef struct +{ + int __lockkind; + int __pshared; +} pthread_rwlockattr_t; +#endif + +#ifdef __USE_XOPEN2K +/* POSIX spinlock data type. */ +typedef volatile int pthread_spinlock_t; + +/* POSIX barrier. */ +typedef struct { + struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */ + int __ba_required; /* Threads needed for completion */ + int __ba_present; /* Threads waiting */ + _pthread_descr __ba_waiting; /* Queue of waiting threads */ +} pthread_barrier_t; + +/* barrier attribute */ +typedef struct { + int __pshared; +} pthread_barrierattr_t; + +#endif + + +/* Thread identifiers */ +typedef unsigned long int pthread_t; + +#endif /* bits/pthreadtypes.h */ diff --git a/newlib/libc/sys/linux/bits/typesizes.h b/newlib/libc/sys/linux/bits/typesizes.h new file mode 100644 index 000000000..45264ac9c --- /dev/null +++ b/newlib/libc/sys/linux/bits/typesizes.h @@ -0,0 +1,66 @@ +/* bits/typesizes.h -- underlying types for *_t. Generic version. + Copyright (C) 2002, 2003 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BITS_TYPES_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_TYPESIZES_H +#define _BITS_TYPESIZES_H 1 + +/* See for the meaning of these macros. This file exists so + that need not vary across different GNU platforms. */ + +#define __DEV_T_TYPE __UQUAD_TYPE +#define __UID_T_TYPE __U32_TYPE +#define __GID_T_TYPE __U32_TYPE +#define __INO_T_TYPE __ULONGWORD_TYPE +#define __INO64_T_TYPE __UQUAD_TYPE +#define __MODE_T_TYPE __U32_TYPE +#define __NLINK_T_TYPE __UWORD_TYPE +#define __OFF_T_TYPE __SLONGWORD_TYPE +#define __OFF64_T_TYPE __SQUAD_TYPE +#define __PID_T_TYPE __S32_TYPE +#define __RLIM_T_TYPE __ULONGWORD_TYPE +#define __RLIM64_T_TYPE __UQUAD_TYPE +#define __BLKCNT_T_TYPE __SLONGWORD_TYPE +#define __BLKCNT64_T_TYPE __SQUAD_TYPE +#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE +#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE +#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE +#define __FSFILCNT64_T_TYPE __UQUAD_TYPE +#define __ID_T_TYPE __U32_TYPE +#define __CLOCK_T_TYPE __SLONGWORD_TYPE +#define __TIME_T_TYPE __SLONGWORD_TYPE +#define __USECONDS_T_TYPE __U32_TYPE +#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __DADDR_T_TYPE __S32_TYPE +#define __SWBLK_T_TYPE __SLONGWORD_TYPE +#define __KEY_T_TYPE __S32_TYPE +#define __CLOCKID_T_TYPE __S32_TYPE +#define __TIMER_T_TYPE __S32_TYPE +#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE +#define __FSID_T_TYPE struct { int __val[2]; } +#define __SSIZE_T_TYPE __SWORD_TYPE + +/* Number of descriptors that can fit in an `fd_set'. */ +#define __FD_SETSIZE 1024 + + +#endif /* bits/typesizes.h */ diff --git a/newlib/libc/sys/linux/dl/dl-cache.c b/newlib/libc/sys/linux/dl/dl-cache.c index a71e5e876..9511da13f 100644 --- a/newlib/libc/sys/linux/dl/dl-cache.c +++ b/newlib/libc/sys/linux/dl/dl-cache.c @@ -208,7 +208,7 @@ _dl_load_cache_lookup (const char *name) /* This file ends in static libraries where we don't have a hwcap. */ unsigned long int *hwcap; uint64_t platform; - weak_extern (_dl_hwcap); + #pragma weak _dl_hwcap /* This is where the strings start. */ cache_data = (const char *) cache_new; diff --git a/newlib/libc/sys/linux/dl/dl-load.c b/newlib/libc/sys/linux/dl/dl-load.c index 65b72c729..4e32d604b 100644 --- a/newlib/libc/sys/linux/dl/dl-load.c +++ b/newlib/libc/sys/linux/dl/dl-load.c @@ -1095,7 +1095,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, } else /* Adjust the PT_PHDR value by the runtime load address. */ - (ElfW(Addr)) l->l_phdr += l->l_addr; + l->l_phdr = (ElfW(Addr)) l->l_phdr + l->l_addr; } /* We are done mapping in the file. We no longer need the descriptor. */ @@ -1115,7 +1115,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, } } else - (ElfW(Addr)) l->l_ld += l->l_addr; + l->l_ld = (ElfW(Addr)) l->l_ld + l->l_addr; l->l_entry += l->l_addr; diff --git a/newlib/libc/sys/linux/dl/dl-open.c b/newlib/libc/sys/linux/dl/dl-open.c index 195361427..4e068d435 100644 --- a/newlib/libc/sys/linux/dl/dl-open.c +++ b/newlib/libc/sys/linux/dl/dl-open.c @@ -36,8 +36,8 @@ extern ElfW(Addr) _dl_sysdep_start (void **start_argptr, void (*dl_main) (const ElfW(Phdr) *phdr, ElfW(Word) phnum, - ElfW(Addr) *user_entry)); -weak_extern (BP_SYM (_dl_sysdep_start)) + ElfW(Addr) *user_entry)) + weak_function; /* This function is used to unload the cache file if necessary. */ extern void _dl_unload_cache (void); diff --git a/newlib/libc/sys/linux/dl/dl-reloc.c b/newlib/libc/sys/linux/dl/dl-reloc.c index 94163143e..0bffa4e76 100644 --- a/newlib/libc/sys/linux/dl/dl-reloc.c +++ b/newlib/libc/sys/linux/dl/dl-reloc.c @@ -105,50 +105,47 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], { /* Do the actual relocation of the object's GOT and other data. */ - /* String table object symbols. */ - const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]); - /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */ -#define RESOLVE_MAP(ref, version, r_type) \ +#define RESOLVE_MAP(ref, version, r_type, scope) \ (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \ - ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0) \ - && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class) \ + ? ((__builtin_expect ((*ref) == map->l_lookup_cache.sym, 0) \ + && elf_machine_type_class (r_type) == map->l_lookup_cache.type_class)\ ? (++_dl_num_cache_relocations, \ - (*ref) = l->l_lookup_cache.ret, \ - l->l_lookup_cache.value) \ + (*ref) = map->l_lookup_cache.ret, \ + map->l_lookup_cache.value) \ : ({ lookup_t _lr; \ int _tc = elf_machine_type_class (r_type); \ - l->l_lookup_cache.type_class = _tc; \ - l->l_lookup_cache.sym = (*ref); \ + map->l_lookup_cache.type_class = _tc; \ + map->l_lookup_cache.sym = (*ref); \ _lr = ((version) != NULL && (version)->hash != 0 \ ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, \ - l, (ref), scope, \ + map, (ref), scope, \ (version), _tc, 0) \ - : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), \ + : _dl_lookup_symbol (strtab + (*ref)->st_name, map, (ref),\ scope, _tc, 0)); \ - l->l_lookup_cache.ret = (*ref); \ - l->l_lookup_cache.value = _lr; })) \ - : l) -#define RESOLVE(ref, version, r_type) \ + map->l_lookup_cache.ret = (*ref); \ + map->l_lookup_cache.value = _lr; })) \ + : map) +#define RESOLVE(ref, version, r_type, scope) \ (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \ - ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0) \ - && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class) \ + ? ((__builtin_expect ((*ref) == map->l_lookup_cache.sym, 0) \ + && elf_machine_type_class (r_type) == map->l_lookup_cache.type_class)\ ? (++_dl_num_cache_relocations, \ - (*ref) = l->l_lookup_cache.ret, \ - l->l_lookup_cache.value) \ + (*ref) = map->l_lookup_cache.ret, \ + map->l_lookup_cache.value) \ : ({ lookup_t _lr; \ int _tc = elf_machine_type_class (r_type); \ - l->l_lookup_cache.type_class = _tc; \ - l->l_lookup_cache.sym = (*ref); \ + map->l_lookup_cache.type_class = _tc; \ + map->l_lookup_cache.sym = (*ref); \ _lr = ((version) != NULL && (version)->hash != 0 \ ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, \ - l, (ref), scope, \ + map, (ref), scope, \ (version), _tc, 0) \ - : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), \ + : _dl_lookup_symbol (strtab + (*ref)->st_name, map, (ref),\ scope, _tc, 0)); \ - l->l_lookup_cache.ret = (*ref); \ - l->l_lookup_cache.value = _lr; })) \ - : l->l_addr) + map->l_lookup_cache.ret = (*ref); \ + map->l_lookup_cache.value = _lr; })) \ + : map->l_addr) #include "dynamic-link.h" @@ -197,6 +194,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], } } +#include void internal_function diff --git a/newlib/libc/sys/linux/dl/dl-runtime.c b/newlib/libc/sys/linux/dl/dl-runtime.c index 403091d2e..4fb81cfaf 100644 --- a/newlib/libc/sys/linux/dl/dl-runtime.c +++ b/newlib/libc/sys/linux/dl/dl-runtime.c @@ -46,7 +46,7 @@ function. */ #ifndef ELF_MACHINE_NO_PLT -static ElfW(Addr) __attribute__ ((regparm (2), unused)) +static ElfW(Addr) __attribute__ ((regparm (2), used)) fixup ( # ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS, @@ -130,7 +130,7 @@ fixup ( #if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__ -static ElfW(Addr) __attribute__ ((regparm (3), unused)) +static ElfW(Addr) __attribute__ ((regparm (3), used)) profile_fixup ( #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS, diff --git a/newlib/libc/sys/linux/dl/do-rel.h b/newlib/libc/sys/linux/dl/do-rel.h index 46202d704..03b9e807b 100644 --- a/newlib/libc/sys/linux/dl/do-rel.h +++ b/newlib/libc/sys/linux/dl/do-rel.h @@ -44,7 +44,8 @@ static inline void elf_dynamic_do_rel (struct link_map *map, ElfW(Addr) reladdr, ElfW(Addr) relsize, - int lazy) + int lazy, + struct r_scope_elem *scope[]) { const ElfW(Rel) *r = (const void *) reladdr; const ElfW(Rel) *end = (const void *) (reladdr + relsize); @@ -77,7 +78,7 @@ elf_dynamic_do_rel (struct link_map *map, RTLD_BOOTSTRAP) because rtld.c contains the common defn for _dl_rtld_map, which is incompatible with a weak decl in the same file. */ - weak_extern (_dl_rtld_map); + #pragma weak _dl_rtld_map if (map != &_dl_rtld_map) /* Already done in rtld itself. */ # ifndef DO_RELA /* Rela platforms get the offset from r_addend and this must @@ -101,13 +102,14 @@ elf_dynamic_do_rel (struct link_map *map, ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)]; elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], &map->l_versions[ndx], - (void *) (l_addr + r->r_offset)); + (void *) (l_addr + r->r_offset), + scope); } } else for (; r < end; ++r) elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL, - (void *) (l_addr + r->r_offset)); + (void *) (l_addr + r->r_offset), scope); } } diff --git a/newlib/libc/sys/linux/dl/dynamic-link.h b/newlib/libc/sys/linux/dl/dynamic-link.h index a63fded89..c1709f7c6 100644 --- a/newlib/libc/sys/linux/dl/dynamic-link.h +++ b/newlib/libc/sys/linux/dl/dynamic-link.h @@ -17,6 +17,9 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#ifndef __DYNAMIC_LINK_H__ +#define __DYNAMIC_LINK_H__ + #include #include #include @@ -33,7 +36,7 @@ extern int _dl_verbose __attribute__ ((unused)); /* Read the dynamic section at DYN and fill in INFO with indices DT_*. */ -static inline void __attribute__ ((unused)) +static void __attribute__ ((unused)) elf_get_dynamic_info (struct link_map *l) { ElfW(Dyn) *dyn = l->l_ld; @@ -121,6 +124,17 @@ elf_get_dynamic_info (struct link_map *l) info[DT_RPATH] = NULL; } +# if ! ELF_MACHINE_NO_REL +# include "do-rel.h" +# endif + +# if ! ELF_MACHINE_NO_RELA +# define DO_RELA +# include "do-rel.h" +# endif + +#endif /* __DYNAMIC_LINK_H__ */ + #ifdef RESOLVE /* Get the definitions of `elf_dynamic_do_rel' and `elf_dynamic_do_rela'. @@ -164,7 +178,8 @@ elf_get_dynamic_info (struct link_map *l) elf_dynamic_do_##reloc ((map), \ ranges[ranges_index].start, \ ranges[ranges_index].size, \ - ranges[ranges_index].lazy); \ + ranges[ranges_index].lazy, \ + scope); \ } while (0) # else # define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, test_rel) \ @@ -204,7 +219,8 @@ elf_get_dynamic_info (struct link_map *l) elf_dynamic_do_##reloc ((map), \ ranges[ranges_index].start, \ ranges[ranges_index].size, \ - ranges[ranges_index].lazy); \ + ranges[ranges_index].lazy, \ + scope); \ } while (0) # endif @@ -215,7 +231,6 @@ elf_get_dynamic_info (struct link_map *l) # endif # if ! ELF_MACHINE_NO_REL -# include "do-rel.h" # define ELF_DYNAMIC_DO_REL(map, lazy) \ _ELF_DYNAMIC_DO_RELOC (REL, rel, map, lazy, _ELF_CHECK_REL) # else @@ -223,8 +238,6 @@ elf_get_dynamic_info (struct link_map *l) # endif # if ! ELF_MACHINE_NO_RELA -# define DO_RELA -# include "do-rel.h" # define ELF_DYNAMIC_DO_RELA(map, lazy) \ _ELF_DYNAMIC_DO_RELOC (RELA, rela, map, lazy, _ELF_CHECK_REL) # else diff --git a/newlib/libc/sys/linux/iconv/gconv_open.c b/newlib/libc/sys/linux/iconv/gconv_open.c index 5c10d601e..1b2fbb51a 100644 --- a/newlib/libc/sys/linux/iconv/gconv_open.c +++ b/newlib/libc/sys/linux/iconv/gconv_open.c @@ -172,7 +172,10 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle, lastp = runp; else /* This means we haven't found the module. Remove it. */ - (lastp == NULL ? trans : lastp->next) = runp->next; + if (lastp == NULL) + trans = runp->next; + else + lastp->next = runp->next; } /* Allocate room for handle. */ diff --git a/newlib/libc/sys/linux/iconv/gconv_simple.c b/newlib/libc/sys/linux/iconv/gconv_simple.c index a4a99ea81..edc091f7c 100644 --- a/newlib/libc/sys/linux/iconv/gconv_simple.c +++ b/newlib/libc/sys/linux/iconv/gconv_simple.c @@ -75,7 +75,10 @@ internal_ucs4_loop (struct __gconv_step *step, size_t cnt; for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4) - *((uint32_t *) outptr)++ = bswap_32 (*(const uint32_t *) inptr); + { + *((uint32_t *) outptr) = bswap_32 (*(const uint32_t *) inptr); + outptr = (unsigned char *)((uint32_t *) outptr + 1); + } *inptrp = inptr; *outptrp = outptr; @@ -180,8 +183,13 @@ internal_ucs4_loop_single (struct __gconv_step *step, *outptrp += 4; #elif __BYTE_ORDER == __BIG_ENDIAN - /* XXX unaligned */ - *(*((uint32_t **) outptrp)++) = state->__value.__wch; + { + uint32_t **p = (uint32_t **)outptrp; + uint32_t *q = *p; + /* XXX unaligned */ + *q = state->__value.__wch; + outptrp = (unsigned char *)(p + 1); + } #else # error "This endianess is not supported." #endif @@ -244,7 +252,7 @@ ucs4_internal_loop (struct __gconv_step *step, if (flags & __GCONV_IGNORE_ERRORS) { /* Just ignore this character. */ - ++*irreversible; + *irreversible = *irreversible + 1; continue; } @@ -253,7 +261,8 @@ ucs4_internal_loop (struct __gconv_step *step, return __GCONV_ILLEGAL_INPUT; } - *((uint32_t *) outptr)++ = inval; + *((uint32_t *) outptr) = inval; + outptr = (unsigned char *) ((uint32_t *) outptr + 1); } *inptrp = inptr; @@ -301,7 +310,7 @@ ucs4_internal_loop_unaligned (struct __gconv_step *step, if (flags & __GCONV_IGNORE_ERRORS) { /* Just ignore this character. */ - ++*irreversible; + *irreversible = *irreversible + 1; continue; } @@ -536,8 +545,13 @@ internal_ucs4le_loop_single (struct __gconv_step *step, *outptrp += 4; #else + { /* XXX unaligned */ - *(*((uint32_t **) outptrp)++) = state->__value.__wch; + uint32_t **p = (uint32_t **)outptrp; + uint32_t *q = *p; + *q = state->__value.__wch; + outptrp = (unsigned char **)(p + 1); + } #endif /* Clear the state buffer. */ @@ -604,7 +618,8 @@ ucs4le_internal_loop (struct __gconv_step *step, return __GCONV_ILLEGAL_INPUT; } - *((uint32_t *) outptr)++ = inval; + *((uint32_t *) outptr) = inval; + outptr = (unsigned char *)((uint32_t *) outptr + 1); } *inptrp = inptr; @@ -781,12 +796,16 @@ ucs4le_internal_loop_single (struct __gconv_step *step, break; \ } \ \ - ++*irreversible; \ + *irreversible = *irreversible + 1; \ ++inptr; \ } \ else \ - /* It's an one byte sequence. */ \ - *((uint32_t *) outptr)++ = *inptr++; \ + { \ + /* It's an one byte sequence. */ \ + *((uint32_t *) outptr) = *inptr; \ + ++inptr; \ + outptr = (unsigned char *)((uint32_t *) outptr + 1); \ + } \ } #define LOOP_NEED_FLAGS #include @@ -815,8 +834,11 @@ ucs4le_internal_loop_single (struct __gconv_step *step, STANDARD_ERR_HANDLER (4); \ } \ else \ - /* It's an one byte sequence. */ \ - *outptr++ = *((const uint32_t *) inptr)++; \ + { \ + /* It's an one byte sequence. */ \ + *outptr++ = *((const uint32_t *) inptr); \ + inptr = ((const uint32_t *) inptr + 1); \ + } \ } #define LOOP_NEED_FLAGS #include @@ -993,7 +1015,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, { \ /* Ignore it. */ \ inptr += i; \ - ++*irreversible; \ + *irreversible = *irreversible + 1; \ continue; \ } \ \ @@ -1023,7 +1045,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, if (ignore_errors_p ()) \ { \ inptr += i; \ - ++*irreversible; \ + *irreversible = *irreversible + 1; \ continue; \ } \ \ @@ -1035,7 +1057,8 @@ ucs4le_internal_loop_single (struct __gconv_step *step, } \ \ /* Now adjust the pointers and store the result. */ \ - *((uint32_t *) outptr)++ = ch; \ + *((uint32_t *) outptr) = ch; \ + outptr = (unsigned char *)((uint32_t *) outptr + 1); \ } #define LOOP_NEED_FLAGS @@ -1174,11 +1197,12 @@ ucs4le_internal_loop_single (struct __gconv_step *step, break; \ } \ inptr += 2; \ - ++*irreversible; \ + *irreversible = *irreversible + 1; \ continue; \ } \ \ - *((uint32_t *) outptr)++ = u1; \ + *((uint32_t *) outptr) = u1; \ + outptr = (unsigned char *)((uint32_t *) outptr + 1); \ inptr += 2; \ } #define LOOP_NEED_FLAGS @@ -1223,12 +1247,13 @@ ucs4le_internal_loop_single (struct __gconv_step *step, break; \ } \ inptr += 4; \ - ++*irreversible; \ + *irreversible = *irreversible + 1; \ continue; \ } \ else \ { \ - *((uint16_t *) outptr)++ = val; \ + *((uint16_t *) outptr) = val; \ + outptr = (unsigned char *)((uint16_t *) outptr + 1); \ inptr += 4; \ } \ } @@ -1265,11 +1290,12 @@ ucs4le_internal_loop_single (struct __gconv_step *step, break; \ } \ inptr += 2; \ - ++*irreversible; \ + *irreversible = *irreversible + 1; \ continue; \ } \ \ - *((uint32_t *) outptr)++ = u1; \ + *((uint32_t *) outptr) = u1; \ + outptr = (unsigned char *)((uint32_t *) outptr + 1); \ inptr += 2; \ } #define LOOP_NEED_FLAGS @@ -1313,12 +1339,13 @@ ucs4le_internal_loop_single (struct __gconv_step *step, break; \ } \ inptr += 4; \ - ++*irreversible; \ + *irreversible = *irreversible + 1; \ continue; \ } \ else \ { \ - *((uint16_t *) outptr)++ = bswap_16 (val); \ + *((uint16_t *) outptr) = bswap_16 (val); \ + outptr = (unsigned char *)((uint16_t *) outptr + 1); \ inptr += 4; \ } \ } diff --git a/newlib/libc/sys/linux/include/ltdl.h b/newlib/libc/sys/linux/include/ltdl.h new file mode 100644 index 000000000..2bbfa302c --- /dev/null +++ b/newlib/libc/sys/linux/include/ltdl.h @@ -0,0 +1,361 @@ +/* ltdl.h -- generic dlopen functions + Copyright (C) 1998-2000 Free Software Foundation, Inc. + Originally by Thomas Tanner + This file is part of GNU Libtool. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +As a special exception to the GNU Lesser General Public License, +if you distribute this file as part of a program or library that +is built using GNU libtool, you may include it under the same +distribution terms that you use for the rest of that program. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA +*/ + +/* Only include this header file once. */ +#ifndef LTDL_H +#define LTDL_H 1 + +#include /* for size_t declaration */ + + +/* --- MACROS FOR PORTABILITY --- */ + + +/* Saves on those hard to debug '\0' typos.... */ +#define LT_EOS_CHAR '\0' + +/* LTDL_BEGIN_C_DECLS should be used at the beginning of your declarations, + so that C++ compilers don't mangle their names. Use LTDL_END_C_DECLS at + the end of C declarations. */ +#ifdef __cplusplus +# define LT_BEGIN_C_DECLS extern "C" { +# define LT_END_C_DECLS } +#else +# define LT_BEGIN_C_DECLS /* empty */ +# define LT_END_C_DECLS /* empty */ +#endif + +LT_BEGIN_C_DECLS + + +/* LT_PARAMS is a macro used to wrap function prototypes, so that compilers + that don't understand ANSI C prototypes still work, and ANSI C + compilers can issue warnings about type mismatches. */ +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) || defined(__cplusplus) +# define LT_PARAMS(protos) protos +# define lt_ptr void* +#else +# define LT_PARAMS(protos) () +# define lt_ptr char* +#endif + +/* LT_STMT_START/END are used to create macros which expand to a + a single compound statement in a portable way. */ +#if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus) +# define LT_STMT_START (void)( +# define LT_STMT_END ) +#else +# if (defined (sun) || defined (__sun__)) +# define LT_STMT_START if (1) +# define LT_STMT_END else (void)0 +# else +# define LT_STMT_START do +# define LT_STMT_END while (0) +# endif +#endif + +/* LT_CONC creates a new concatenated symbol for the compiler + in a portable way. */ +#if defined(__STDC__) || defined(__cplusplus) +# define LT_CONC(s,t) s##t +#else +# define LT_CONC(s,t) s/**/t +#endif + +/* LT_STRLEN can be used safely on NULL pointers. */ +#define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0) + + + +/* --- WINDOWS SUPPORT --- */ + + +/* Canonicalise Windows and Cygwin recognition macros. */ +#ifdef __CYGWIN32__ +# ifndef __CYGWIN__ +# define __CYGWIN__ __CYGWIN32__ +# endif +#endif +#if defined(_WIN32) || defined(WIN32) +# ifndef __WINDOWS__ +# ifdef _WIN32 +# define __WINDOWS__ _WIN32 +# else +# ifdef WIN32 +# define __WINDOWS__ WIN32 +# endif +# endif +# endif +#endif + +#ifdef __WINDOWS__ +# ifndef __CYGWIN__ +/* LT_DIRSEP_CHAR is accepted *in addition* to '/' as a directory + separator when it is set. */ +# define LT_DIRSEP_CHAR '\\' +# define LT_PATHSEP_CHAR ';' +# endif +#endif +#ifndef LT_PATHSEP_CHAR +# define LT_PATHSEP_CHAR ':' +#endif + +/* DLL building support on win32 hosts; mostly to workaround their + ridiculous implementation of data symbol exporting. */ +#ifndef LT_SCOPE +# ifdef __WINDOWS__ +# ifdef DLL_EXPORT /* defined by libtool (if required) */ +# define LT_SCOPE __declspec(dllexport) +# endif +# ifdef LIBLTDL_DLL_IMPORT /* define if linking with this dll */ +# define LT_SCOPE extern __declspec(dllimport) +# endif +# endif +# ifndef LT_SCOPE /* static linking or !__WINDOWS__ */ +# define LT_SCOPE extern +# endif +#endif + + + + +/* --- DYNAMIC MODULE LOADING API --- */ + + +typedef struct lt_dlhandle_struct *lt_dlhandle; /* A loaded module. */ + +/* Initialisation and finalisation functions for libltdl. */ +extern int lt_dlinit LT_PARAMS((void)); +extern int lt_dlexit LT_PARAMS((void)); + +/* Module search path manipulation. */ +extern int lt_dladdsearchdir LT_PARAMS((const char *search_dir)); +extern int lt_dlinsertsearchdir LT_PARAMS((const char *before, + const char *search_dir)); +extern int lt_dlsetsearchpath LT_PARAMS((const char *search_path)); +extern const char *lt_dlgetsearchpath LT_PARAMS((void)); +extern int lt_dlforeachfile LT_PARAMS(( + const char *search_path, + int (*func) (const char *filename, lt_ptr data), + lt_ptr data)); + +/* Portable libltdl versions of the system dlopen() API. */ +extern lt_dlhandle lt_dlopen LT_PARAMS((const char *filename)); +extern lt_dlhandle lt_dlopenext LT_PARAMS((const char *filename)); +extern lt_ptr lt_dlsym LT_PARAMS((lt_dlhandle handle, + const char *name)); +extern const char *lt_dlerror LT_PARAMS((void)); +extern int lt_dlclose LT_PARAMS((lt_dlhandle handle)); + +/* Module residency management. */ +extern int lt_dlmakeresident LT_PARAMS((lt_dlhandle handle)); +extern int lt_dlisresident LT_PARAMS((lt_dlhandle handle)); + + + + +/* --- MUTEX LOCKING --- */ + + +typedef void lt_dlmutex_lock LT_PARAMS((void)); +typedef void lt_dlmutex_unlock LT_PARAMS((void)); +typedef void lt_dlmutex_seterror LT_PARAMS((const char *errmsg)); +typedef const char *lt_dlmutex_geterror LT_PARAMS((void)); + +extern int lt_dlmutex_register LT_PARAMS((lt_dlmutex_lock *lock, + lt_dlmutex_unlock *unlock, + lt_dlmutex_seterror *seterror, + lt_dlmutex_geterror *geterror)); + + + + +/* --- MEMORY HANDLING --- */ + + +/* By default, the realloc function pointer is set to our internal + realloc implementation which iself uses lt_dlmalloc and lt_dlfree. + libltdl relies on a featureful realloc, but if you are sure yours + has the right semantics then you can assign it directly. Generally, + it is safe to assign just a malloc() and a free() function. */ +LT_SCOPE lt_ptr (*lt_dlmalloc) LT_PARAMS((size_t size)); +LT_SCOPE lt_ptr (*lt_dlrealloc) LT_PARAMS((lt_ptr ptr, size_t size)); +LT_SCOPE void (*lt_dlfree) LT_PARAMS((lt_ptr ptr)); + + + + +/* --- PRELOADED MODULE SUPPORT --- */ + + +/* A preopened symbol. Arrays of this type comprise the exported + symbols for a dlpreopened module. */ +typedef struct { + const char *name; + lt_ptr address; +} lt_dlsymlist; + +extern int lt_dlpreload LT_PARAMS((const lt_dlsymlist *preloaded)); +extern int lt_dlpreload_default + LT_PARAMS((const lt_dlsymlist *preloaded)); + +#define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \ + extern const lt_dlsymlist lt_preloaded_symbols[]; \ + lt_dlpreload_default(lt_preloaded_symbols); \ + }LT_STMT_END + + + + +/* --- MODULE INFORMATION --- */ + + +/* Read only information pertaining to a loaded module. */ +typedef struct { + char *filename; /* file name */ + char *name; /* module name */ + int ref_count; /* number of times lt_dlopened minus + number of times lt_dlclosed. */ +} lt_dlinfo; + +extern const lt_dlinfo *lt_dlgetinfo LT_PARAMS((lt_dlhandle handle)); +extern lt_dlhandle lt_dlhandle_next LT_PARAMS((lt_dlhandle place)); +extern int lt_dlforeach LT_PARAMS(( + int (*func) (lt_dlhandle handle, lt_ptr data), + lt_ptr data)); + +/* Associating user data with loaded modules. */ +typedef unsigned lt_dlcaller_id; + +extern lt_dlcaller_id lt_dlcaller_register LT_PARAMS((void)); +extern lt_ptr lt_dlcaller_set_data LT_PARAMS((lt_dlcaller_id key, + lt_dlhandle handle, + lt_ptr data)); +extern lt_ptr lt_dlcaller_get_data LT_PARAMS((lt_dlcaller_id key, + lt_dlhandle handle)); + + + +/* --- USER MODULE LOADER API --- */ + + +typedef struct lt_dlloader lt_dlloader; +typedef lt_ptr lt_user_data; +typedef lt_ptr lt_module; + +/* Function pointer types for creating user defined module loaders. */ +typedef lt_module lt_module_open LT_PARAMS((lt_user_data loader_data, + const char *filename)); +typedef int lt_module_close LT_PARAMS((lt_user_data loader_data, + lt_module handle)); +typedef lt_ptr lt_find_sym LT_PARAMS((lt_user_data loader_data, + lt_module handle, + const char *symbol)); +typedef int lt_dlloader_exit LT_PARAMS((lt_user_data loader_data)); + +struct lt_user_dlloader { + const char *sym_prefix; + lt_module_open *module_open; + lt_module_close *module_close; + lt_find_sym *find_sym; + lt_dlloader_exit *dlloader_exit; + lt_user_data dlloader_data; +}; + +extern lt_dlloader *lt_dlloader_next LT_PARAMS((lt_dlloader *place)); +extern lt_dlloader *lt_dlloader_find LT_PARAMS(( + const char *loader_name)); +extern const char *lt_dlloader_name LT_PARAMS((lt_dlloader *place)); +extern lt_user_data *lt_dlloader_data LT_PARAMS((lt_dlloader *place)); +extern int lt_dlloader_add LT_PARAMS((lt_dlloader *place, + const struct lt_user_dlloader *dlloader, + const char *loader_name)); +extern int lt_dlloader_remove LT_PARAMS(( + const char *loader_name)); + + + +/* --- ERROR MESSAGE HANDLING --- */ + + +/* Defining error strings alongside their symbolic names in a macro in + this way allows us to expand the macro in different contexts with + confidence that the enumeration of symbolic names will map correctly + onto the table of error strings. */ +#define lt_dlerror_table \ + LT_ERROR(UNKNOWN, "unknown error") \ + LT_ERROR(DLOPEN_NOT_SUPPORTED, "dlopen support not available") \ + LT_ERROR(INVALID_LOADER, "invalid loader") \ + LT_ERROR(INIT_LOADER, "loader initialization failed") \ + LT_ERROR(REMOVE_LOADER, "loader removal failed") \ + LT_ERROR(FILE_NOT_FOUND, "file not found") \ + LT_ERROR(DEPLIB_NOT_FOUND, "dependency library not found") \ + LT_ERROR(NO_SYMBOLS, "no symbols defined") \ + LT_ERROR(CANNOT_OPEN, "can't open the module") \ + LT_ERROR(CANNOT_CLOSE, "can't close the module") \ + LT_ERROR(SYMBOL_NOT_FOUND, "symbol not found") \ + LT_ERROR(NO_MEMORY, "not enough memory") \ + LT_ERROR(INVALID_HANDLE, "invalid module handle") \ + LT_ERROR(BUFFER_OVERFLOW, "internal buffer overflow") \ + LT_ERROR(INVALID_ERRORCODE, "invalid errorcode") \ + LT_ERROR(SHUTDOWN, "library already shutdown") \ + LT_ERROR(CLOSE_RESIDENT_MODULE, "can't close resident module") \ + LT_ERROR(INVALID_MUTEX_ARGS, "invalid mutex handler registration") \ + LT_ERROR(INVALID_POSITION, "invalid search path insert position") + +/* Enumerate the symbolic error names. */ +enum { +#define LT_ERROR(name, diagnostic) LT_CONC(LT_ERROR_, name), + lt_dlerror_table +#undef LT_ERROR + + LT_ERROR_MAX +}; + +/* These functions are only useful from inside custom module loaders. */ +extern int lt_dladderror LT_PARAMS((const char *diagnostic)); +extern int lt_dlseterror LT_PARAMS((int errorcode)); + + + + +/* --- SOURCE COMPATIBILITY WITH OLD LIBLTDL --- */ + + +#ifdef LT_NON_POSIX_NAMESPACE +# define lt_ptr_t lt_ptr +# define lt_module_t lt_module +# define lt_module_open_t lt_module_open +# define lt_module_close_t lt_module_close +# define lt_find_sym_t lt_find_sym +# define lt_dlloader_exit_t lt_dlloader_exit +# define lt_dlloader_t lt_dlloader +# define lt_dlloader_data_t lt_user_data +#endif + +LT_END_C_DECLS + +#endif /* !LTDL_H */ diff --git a/newlib/libc/sys/linux/linuxthreads/bits/libc-lock.h b/newlib/libc/sys/linux/linuxthreads/bits/libc-lock.h index 2c1d16277..125002255 100644 --- a/newlib/libc/sys/linux/linuxthreads/bits/libc-lock.h +++ b/newlib/libc/sys/linux/linuxthreads/bits/libc-lock.h @@ -265,36 +265,6 @@ extern int __pthread_atfork (void (*__prepare) (void), /* Make the pthread functions weak so that we can elide them from single-threaded processes. */ #ifndef __NO_WEAK_PTHREAD_ALIASES -# ifdef weak_extern -# if _LIBC -# include -# else -# define BP_SYM (sym) sym -# endif -weak_extern (BP_SYM (__pthread_mutex_init)) -weak_extern (BP_SYM (__pthread_mutex_destroy)) -weak_extern (BP_SYM (__pthread_mutex_lock)) -weak_extern (BP_SYM (__pthread_mutex_trylock)) -weak_extern (BP_SYM (__pthread_mutex_unlock)) -weak_extern (BP_SYM (__pthread_mutexattr_init)) -weak_extern (BP_SYM (__pthread_mutexattr_destroy)) -weak_extern (BP_SYM (__pthread_mutexattr_settype)) -weak_extern (BP_SYM (__pthread_rwlock_init)) -weak_extern (BP_SYM (__pthread_rwlock_destroy)) -weak_extern (BP_SYM (__pthread_rwlock_rdlock)) -weak_extern (BP_SYM (__pthread_rwlock_tryrdlock)) -weak_extern (BP_SYM (__pthread_rwlock_wrlock)) -weak_extern (BP_SYM (__pthread_rwlock_trywrlock)) -weak_extern (BP_SYM (__pthread_rwlock_unlock)) -weak_extern (BP_SYM (__pthread_key_create)) -weak_extern (BP_SYM (__pthread_setspecific)) -weak_extern (BP_SYM (__pthread_getspecific)) -weak_extern (BP_SYM (__pthread_once)) -weak_extern (__pthread_initialize) -weak_extern (__pthread_atfork) -weak_extern (BP_SYM (_pthread_cleanup_push_defer)) -weak_extern (BP_SYM (_pthread_cleanup_pop_restore)) -# else # pragma weak __pthread_mutex_init # pragma weak __pthread_mutex_destroy # pragma weak __pthread_mutex_lock diff --git a/newlib/libc/sys/linux/machine/i386/dl-machine.h b/newlib/libc/sys/linux/machine/i386/dl-machine.h index 032713e5b..80757e89a 100644 --- a/newlib/libc/sys/linux/machine/i386/dl-machine.h +++ b/newlib/libc/sys/linux/machine/i386/dl-machine.h @@ -292,6 +292,20 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc, return value; } +static inline void __attribute__ ((unused)) +elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, + const Elf32_Sym *sym, const struct r_found_version *version, + Elf32_Addr *const reloc_addr, + struct r_scope_elem *scope[]); + +static inline void __attribute__ ((unused)) +elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc, + Elf32_Addr *const reloc_addr); + +static inline void +elf_machine_lazy_rel (struct link_map *map, + Elf32_Addr l_addr, const Elf32_Rel *reloc); + #endif /* !dl_machine_h */ #ifdef RESOLVE @@ -299,10 +313,11 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc, /* Perform the relocation specified by RELOC and SYM (which is fully resolved). MAP is the object containing the reloc. */ -static inline void +static inline void __attribute__ ((unused)) elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, const Elf32_Sym *sym, const struct r_found_version *version, - Elf32_Addr *const reloc_addr) + Elf32_Addr *const reloc_addr, + struct r_scope_elem *scope[]) { const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); @@ -316,7 +331,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the common defn for _dl_rtld_map, which is incompatible with a weak decl in the same file. */ - weak_extern (_dl_rtld_map); + #pragma weak _dl_rtld_map if (map != &_dl_rtld_map) /* Already done in rtld itself. */ # endif *reloc_addr += map->l_addr; @@ -331,7 +346,9 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, #ifndef RTLD_BOOTSTRAP const Elf32_Sym *const refsym = sym; #endif - Elf32_Addr value = RESOLVE (&sym, version, r_type); + /* String table object symbols. */ + const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); + Elf32_Addr value = RESOLVE (&sym, version, r_type, scope); if (sym) value += sym->st_value; @@ -379,7 +396,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, } } -static inline void +static inline void __attribute__ ((unused)) elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc, Elf32_Addr *const reloc_addr) { diff --git a/newlib/libc/sys/linux/machine/i386/weakalias.h b/newlib/libc/sys/linux/machine/i386/weakalias.h index 7b0b18a48..2813bfe26 100644 --- a/newlib/libc/sys/linux/machine/i386/weakalias.h +++ b/newlib/libc/sys/linux/machine/i386/weakalias.h @@ -1,8 +1,10 @@ #define weak_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); +#if 0 #define weak_extern(symbol) _weak_extern (symbol) #define _weak_extern(symbol) asm (".weak " #symbol); +#endif #define weak_function __attribute__ ((weak)) diff --git a/newlib/libc/sys/linux/net/ns_ntoa.c b/newlib/libc/sys/linux/net/ns_ntoa.c index 018076064..b6a6c4c22 100644 --- a/newlib/libc/sys/linux/net/ns_ntoa.c +++ b/newlib/libc/sys/linux/net/ns_ntoa.c @@ -43,6 +43,8 @@ static char sccsid[] = "@(#)ns_ntoa.c 8.1 (Berkeley) 6/4/93"; #include #include +static char *spectHex(char *p0); + char * ns_ntoa(addr) struct ns_addr addr; @@ -54,7 +56,6 @@ ns_ntoa(addr) char *cp2; u_char *up = addr.x_host.c_host; u_char *uplim = up + 6; - static char *spectHex(); net.net_e = addr.x_net; sprintf(obuf, "%lx", (u_long)ntohl(net.long_e)); diff --git a/newlib/libc/sys/linux/sys/cdefs.h b/newlib/libc/sys/linux/sys/cdefs.h index 459785bcb..f6ea0c73e 100644 --- a/newlib/libc/sys/linux/sys/cdefs.h +++ b/newlib/libc/sys/linux/sys/cdefs.h @@ -227,4 +227,12 @@ # endif #endif +/* The nonull function attribute allows to mark pointer parameters which + must not be NULL. */ +#if __GNUC_PREREQ (3,3) +# define __nonnull(params) __attribute__ ((__nonnull__ params)) +#else +# define __nonnull(params) +#endif + #endif /* sys/cdefs.h */ diff --git a/newlib/libc/sys/linux/sys/dirent.h b/newlib/libc/sys/linux/sys/dirent.h index 083158eb3..4bbae4229 100644 --- a/newlib/libc/sys/linux/sys/dirent.h +++ b/newlib/libc/sys/linux/sys/dirent.h @@ -41,6 +41,7 @@ int closedir(DIR *); /* internal prototype */ void _seekdir(DIR *dir,off_t offset); +DIR *_opendir(const char *); #ifndef _POSIX_SOURCE long telldir (DIR *);