diff options
38 files changed, 765 insertions, 378 deletions
diff --git a/ChangeLog b/ChangeLog index 19d6230b9f..1d3fe31fc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,91 @@ +Sat Dec 21 04:14:16 1996 Ulrich Drepper <drepper@cygnus.com> + + * sysdeps/unix/common/pause.c: Add missing second argument in + call to __sigpause. + Reported by a sun <asun@zoology.washington.edu>. + + * locale/weight.h: Correct handling of collation elements. + Reported by Keld Simonsen <keld@dkuug.dk>. + + * manual/time.texi: Document ^ flag and %P format. + + * new-malloc/malloc.c: Update from Wolfram Gloger. + + * nss/nss.h: Reformat copyright. + * posix/sched.h: Likewise. + * sysdeps/i386/fpu_control.h: Likewise. + * sysdeps/unix/sysv/linux/fcntlbits.h: Likewise. + * sysdeps/unix/sysv/linux/ioctls.h: Likewise. + * sysdeps/unix/sysv/linux/sigcontext.h: Likewise. + * sysdeps/unix/sysv/linux/utsnamelen.h: Likewise. + * sysdeps/unix/sysv/linux/sys/acct.h: Likewise. + * sysvips/sys/msg.h: Likewise. + + * stdio-common/Makefile (routines): Remove fcloseall. + * stdio-common/fcloseall.c: Removed. + + * stdlib/Makefile (distribute): Add abort-instr.h. + * sysdeps/generic/abort-instr.h: New file. + * sysdeps/i386/abort-instr.h: New file. + * sysdeps/generic/abort.c: Use lock and stage counter to prevent + any form of loop. + + * sysdeps/unix/sysv/linux/timebits.h: Define CLK_TCK as 100. + * sysdeps/unix/sysv/linux/alpha/timebits.h: Define CLOCKS_PER_SEC + as 1000000. Define CLK_TCK as 1024. + * time/time.c (CLK_TCK): Define only if not already set. + + * time/strftime.c: Don't use `isdigit' when computing field width + from string since the locale might have more than one digit + block. + +Fri Dec 20 12:38:14 1996 Darrel Hankerson <hankedr@mail.auburn.edu> + + * posix/getopt.c (in -W option handling): Return when optind == argc. + +Thu Dec 19 14:24:50 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * nis/nss_nis/nis-alias.c (_nss_nis_parse_aliasent): Add const to + type of KEY. + + * nis/nss_compat/compat-grp.c: Include the declaration of the file + parser. + * nis/nss_compat/compat-pwd.c: Likewise. + * nis/nss_compat/compat-spwd.c: Likewise. + * nis/nss_nis/nis-ethers.c: Likewise. + * nis/nss_nis/nis-grp.c: Likewise. + * nis/nss_nis/nis-network.c: Likewise. + * nis/nss_nis/nis-proto.c: Likewise. + * nis/nss_nis/nis-pwd.c: Likewise. + * nis/nss_nis/nis-rpc.c: Likewise. + * nis/nss_nis/nis-spwd.c: Likewise. + + * nis/nss_compat/compat-grp.c (getgrent_next_nis, + getgrent_next_file): Pass the correct type for the buffer to the + parser function. + * nis/nss_compat/compat-pwd.c (getpwent_next_netgr, + getpwent_next_nis, getpwent_next_file): Likewise. + * nis/nss_compat/compat-spwd.c (getspent_next_netgr, + getspent_next_nis, getspent_next_file): Likewise. + * nis/nss_nis/nis-ethers.c (internal_nis_getetherent_r, + _nss_nis_getethernam_r, _nss_nis_getetherbyaddr_r): Likewise. + * nis/nss_nis/nis-grp.c (internal_nis_getgrent_r, + _nss_nis_getgrnam_r, _nss_nis_getgrgid_r): Likewise. + * nis/nss_nis/nis-network.c (internal_nis_getnetent_r, + _nss_nis_getnetbyname_r, _nss_nis_getnetbyaddr_r): Likewise. + * nis/nss_nis/nis-proto.c (internal_nis_getprotoent_r, + _nss_nis_getprotobyname_r, _nss_nis_getprotobynumber_r): Likewise. + * nis/nss_nis/nis-pwd.c (internal_nis_getpwent_r, + _nss_nis_getpwnam_r, _nss_nis_getpwuid_r): Likewise. + * nis/nss_nis/nis-rpc.c (internal_nis_getrpcent_r, + _nss_nis_getrpcbynumber_r): Likewise. + * nis/nss_nis/nis-spwd.c (internal_nis_getspent_r, + _nss_nis_getspnam_r): Likewise. + +Thu Dec 19 13:37:16 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * sysdeps/unix/sysv/linux/m68k/setjmp.c: New file. + Thu Dec 19 23:28:33 1996 Ulrich Drepper <drepper@cygnus.com> * resolv/resolv.h: Update from BIND 4.9.5-P1. diff --git a/interp.c b/interp.c index e08cf22d21..540a303620 100644 --- a/interp.c +++ b/interp.c @@ -1,4 +1,4 @@ -/* interp - add information about dynamic loader to shared library obejcts. +/* interp - add information about dynamic loader to shared library objects. Copyright (C) 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/locale/weight.h b/locale/weight.h index 1b7b6eae81..0d6ef51722 100644 --- a/locale/weight.h +++ b/locale/weight.h @@ -118,7 +118,7 @@ get_weight (const STRING_TYPE **str, weight_t *result) /* This is a comparison between a u_int32_t array (aka wchar_t) and an 8-bit string. */ for (idx = 0; __collate_extra[slot + 2 + idx] != 0; ++idx) - if (__collate_extra[slot + 2 + idx] != (u_int32_t) str[idx]) + if (__collate_extra[slot + 2 + idx] != (u_int32_t) (*str)[idx]) break; /* When the loop finished with all character of the collation @@ -127,6 +127,7 @@ get_weight (const STRING_TYPE **str, weight_t *result) { size_t cnt; + *str += idx; idx += slot + 3; for (cnt = 0; cnt < collate_nrules; ++cnt) { diff --git a/malloc/malloc.c b/malloc/malloc.c index 840655f4db..7e71e9777a 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -179,7 +179,7 @@ Define to enable debugging. Adds fairly extensive assertion-based checking to help track down memory errors, but noticeably slows down execution. - MALLOC_HOOKS (default: NOT defined) + MALLOC_HOOKS (default: NOT defined) Define to enable support run-time replacement of the allocation functions through user-defined `hooks'. REALLOC_ZERO_BYTES_FREES (default: NOT defined) @@ -298,7 +298,7 @@ #if __STD_C # include <stddef.h> /* for size_t */ # if defined(_LIBC) || defined(MALLOC_HOOKS) -# include <stdlib.h> /* for getenv() */ +# include <stdlib.h> /* for getenv(), abort() */ # endif #else # include <sys/types.h> @@ -315,13 +315,6 @@ extern "C" { #include <stdio.h> /* needed for malloc_stats */ -/* We must not pollute the name space in the GNU libc. */ -#ifdef _LIBC -#define malloc_stats __malloc_stats -#define malloc_usable_size __malloc_usable_size -#define malloc_trim __malloc_trim -#endif - /* Compile-time options @@ -878,6 +871,9 @@ extern Void_t* sbrk(); #define pvALLOc __libc_pvalloc #define mALLINFo __libc_mallinfo #define mALLOPt __libc_mallopt +#define mALLOC_STATs __malloc_stats +#define mALLOC_USABLE_SIZe __malloc_usable_size +#define mALLOC_TRIm __malloc_trim #else @@ -890,6 +886,9 @@ extern Void_t* sbrk(); #define pvALLOc pvalloc #define mALLINFo mallinfo #define mALLOPt mallopt +#define mALLOC_STATs malloc_stats +#define mALLOC_USABLE_SIZe malloc_usable_size +#define mALLOC_TRIm malloc_trim #endif @@ -908,12 +907,9 @@ Void_t* vALLOc(size_t); Void_t* pvALLOc(size_t); Void_t* cALLOc(size_t, size_t); void cfree(Void_t*); -int __malloc_trim(size_t); -int malloc_trim(size_t); -size_t __malloc_usable_size(Void_t*); -size_t malloc_usable_size(Void_t*); -void __malloc_stats(void); -void malloc_stats(void); +int mALLOC_TRIm(size_t); +size_t mALLOC_USABLE_SIZe(Void_t*); +void mALLOC_STATs(void); int mALLOPt(int, int); struct mallinfo mALLINFo(void); #else @@ -928,12 +924,9 @@ Void_t* vALLOc(); Void_t* pvALLOc(); Void_t* cALLOc(); void cfree(); -int __malloc_trim(); -int malloc_trim(); -size_t _malloc_usable_size(); -size_t malloc_usable_size(); -void __malloc_stats(); -void malloc_stats(); +int mALLOC_TRIm(); +size_t mALLOC_USABLE_SIZe(); +void mALLOC_STATs(); int mALLOPt(); struct mallinfo mALLINFo(); #endif @@ -1166,9 +1159,9 @@ typedef struct _heap_info { static void chunk_free(arena *ar_ptr, mchunkptr p); static mchunkptr chunk_alloc(arena *ar_ptr, INTERNAL_SIZE_T size); static mchunkptr chunk_realloc(arena *ar_ptr, mchunkptr oldp, - INTERNAL_SIZE_T oldsize, INTERNAL_SIZE_T nb); + INTERNAL_SIZE_T oldsize, INTERNAL_SIZE_T nb); static mchunkptr chunk_align(arena *ar_ptr, INTERNAL_SIZE_T nb, - size_t alignment); + size_t alignment); static int main_trim(size_t pad); #ifndef NO_THREADS static int heap_trim(heap_info *heap, size_t pad); @@ -1178,6 +1171,8 @@ static Void_t* malloc_check(size_t sz); static void free_check(Void_t* mem); static Void_t* realloc_check(Void_t* oldmem, size_t bytes); static Void_t* memalign_check(size_t alignment, size_t bytes); +static Void_t* malloc_starter(size_t sz); +static void free_starter(Void_t* mem); #endif #else @@ -1195,6 +1190,8 @@ static Void_t* malloc_check(); static void free_check(); static Void_t* realloc_check(); static Void_t* memalign_check(); +static Void_t* malloc_starter(); +static void free_starter(); #endif #endif @@ -1434,7 +1431,7 @@ static arena main_arena = { IAV(112), IAV(113), IAV(114), IAV(115), IAV(116), IAV(117), IAV(118), IAV(119), IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127) }, - NULL, /* next */ + &main_arena, /* next */ 0, /* size */ #if THREAD_STATS 0, 0, 0, /* stat_lock_direct, stat_lock_loop, stat_lock_wait */ @@ -1489,8 +1486,9 @@ static unsigned long max_mmapped_mem = 0; -/* Already initialized? */ -int __malloc_initialized; + +/* Already initialized? */ +int __malloc_initialized = 0; /* Initialization routine. */ @@ -1507,11 +1505,22 @@ ptmalloc_init __MALLOC_P((void)) #endif { #if defined(_LIBC) || defined(MALLOC_HOOKS) + __malloc_ptr_t (*save_malloc_hook) __MALLOC_P ((size_t __size)); + void (*save_free_hook) __MALLOC_P ((__malloc_ptr_t __ptr)); const char* s; #endif if(__malloc_initialized) return; __malloc_initialized = 1; +#if defined(_LIBC) || defined(MALLOC_HOOKS) + /* With some threads implementations, creating thread-specific data + or initializing a mutex may call malloc() itself. Provide a + simple starter version (realloc() won't work). */ + save_malloc_hook = __malloc_hook; + save_free_hook = __free_hook; + __malloc_hook = malloc_starter; + __free_hook = free_starter; +#endif #if defined(_LIBC) /* Initialize the pthreads interface. */ if (__pthread_initialize != NULL) @@ -1525,6 +1534,8 @@ ptmalloc_init __MALLOC_P((void)) #endif #if defined(_LIBC) || defined(MALLOC_HOOKS) s = getenv("MALLOC_CHECK_"); + __malloc_hook = save_malloc_hook; + __free_hook = save_free_hook; if(s) { if(s[0]) mallopt(M_CHECK_ACTION, (int)(s[0] - '0')); malloc_check_init(); @@ -1598,7 +1609,8 @@ malloc_check_init() __free_hook = free_check; __realloc_hook = realloc_check; __memalign_hook = memalign_check; - fprintf(stderr, "Using debugging hooks\n"); + if(check_action == 1) + fprintf(stderr, "malloc: using debugging hooks\n"); } #endif @@ -1821,17 +1833,16 @@ grow_heap(h, diff) heap_info *h; long diff; /* arena_get() acquires an arena and locks the corresponding mutex. First, try the one last locked successfully by this thread. (This is the common case and handled with a macro for speed.) Then, loop - over the singly linked list of arenas. If no arena is readily - available, create a new one. */ + once over the circularly linked list of arenas. If no arena is + readily available, create a new one. */ #define arena_get(ptr, size) do { \ Void_t *vptr = NULL; \ ptr = (arena *)tsd_getspecific(arena_key, vptr); \ if(ptr && !mutex_trylock(&ptr->mutex)) { \ THREAD_STAT(++(ptr->stat_lock_direct)); \ - } else { \ + } else \ ptr = arena_get2(ptr, (size)); \ - } \ } while(0) static arena * @@ -1847,17 +1858,27 @@ arena_get2(a_tsd, size) arena *a_tsd; size_t size; int i; unsigned long misalign; - /* Check the singly-linked list for unlocked arenas. */ - if(a_tsd) { - for(a = a_tsd->next; a; a = a->next) { - if(!mutex_trylock(&a->mutex)) - goto done; + if(!a_tsd) + a = a_tsd = &main_arena; + else { + a = a_tsd->next; + if(!a) { + /* This can only happen while initializing the new arena. */ + (void)mutex_lock(&main_arena.mutex); + THREAD_STAT(++(main_arena.stat_lock_wait)); + return &main_arena; } } - for(a = &main_arena; a != a_tsd; a = a->next) { - if(!mutex_trylock(&a->mutex)) - goto done; - } + + /* Check the global, circularly linked list for available arenas. */ + do { + if(!mutex_trylock(&a->mutex)) { + THREAD_STAT(++(a->stat_lock_loop)); + tsd_setspecific(arena_key, (Void_t *)a); + return a; + } + a = a->next; + } while(a != a_tsd); /* Nothing immediately available, so generate a new arena. */ h = new_heap(size + (sizeof(*h) + sizeof(*a) + MALLOC_ALIGNMENT)); @@ -1866,7 +1887,9 @@ arena_get2(a_tsd, size) arena *a_tsd; size_t size; a = h->ar_ptr = (arena *)(h+1); for(i=0; i<NAV; i++) init_bin(a, i); + a->next = NULL; a->size = h->size; + tsd_setspecific(arena_key, (Void_t *)a); mutex_init(&a->mutex); i = mutex_lock(&a->mutex); /* remember result */ @@ -1887,9 +1910,7 @@ arena_get2(a_tsd, size) arena *a_tsd; size_t size; if(i) /* locking failed; keep arena for further attempts later */ return 0; -done: THREAD_STAT(++(a->stat_lock_loop)); - tsd_setspecific(arena_key, (Void_t *)a); return a; } @@ -2890,7 +2911,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes; static mchunkptr #if __STD_C chunk_realloc(arena* ar_ptr, mchunkptr oldp, INTERNAL_SIZE_T oldsize, - INTERNAL_SIZE_T nb) + INTERNAL_SIZE_T nb) #else chunk_realloc(ar_ptr, oldp, oldsize, nb) arena* ar_ptr; mchunkptr oldp; INTERNAL_SIZE_T oldsize, nb; @@ -3339,9 +3360,9 @@ void cfree(mem) Void_t *mem; */ #if __STD_C -int malloc_trim(size_t pad) +int mALLOC_TRIm(size_t pad) #else -int malloc_trim(pad) size_t pad; +int mALLOC_TRIm(pad) size_t pad; #endif { int res; @@ -3475,9 +3496,9 @@ heap_trim(heap, pad) heap_info *heap; size_t pad; */ #if __STD_C -size_t malloc_usable_size(Void_t* mem) +size_t mALLOC_USABLE_SIZe(Void_t* mem) #else -size_t malloc_usable_size(mem) Void_t* mem; +size_t mALLOC_USABLE_SIZe(mem) Void_t* mem; #endif { mchunkptr p; @@ -3603,7 +3624,7 @@ dump_heap(heap) heap_info *heap; */ -void malloc_stats() +void mALLOC_STATs() { int i; arena *ar_ptr; @@ -3613,7 +3634,7 @@ void malloc_stats() long stat_lock_direct = 0, stat_lock_loop = 0, stat_lock_wait = 0; #endif - for(i=0, ar_ptr = &main_arena; ar_ptr; ar_ptr = ar_ptr->next, i++) { + for(i=0, ar_ptr = &main_arena;; i++) { malloc_update_mallinfo(ar_ptr, &mi); fprintf(stderr, "Arena %d:\n", i); fprintf(stderr, "system bytes = %10u\n", (unsigned int)mi.arena); @@ -3627,10 +3648,14 @@ void malloc_stats() #endif #if !defined(NO_THREADS) && MALLOC_DEBUG > 1 if(ar_ptr != &main_arena) { + (void)mutex_lock(&ar_ptr->mutex); heap_info *heap = heap_for_ptr(top(ar_ptr)); while(heap) { dump_heap(heap); heap = heap->prev; } + (void)mutex_unlock(&ar_ptr->mutex); } #endif + ar_ptr = ar_ptr->next; + if(ar_ptr == &main_arena) break; } fprintf(stderr, "Total (incl. mmap):\n"); fprintf(stderr, "system bytes = %10u\n", system_b); @@ -3713,26 +3738,7 @@ int mALLOPt(param_number, value) int param_number; int value; return 0; } } - -#ifdef _LIBC -weak_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc) -weak_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree) -weak_alias (__libc_free, __free) weak_alias (__libc_free, free) -weak_alias (__libc_malloc, __malloc) weak_alias (__libc_malloc, malloc) -weak_alias (__libc_memalign, __memalign) weak_alias (__libc_memalign, memalign) -weak_alias (__libc_realloc, __realloc) weak_alias (__libc_realloc, realloc) -weak_alias (__libc_valloc, __valloc) weak_alias (__libc_valloc, valloc) -weak_alias (__libc_pvalloc, __pvalloc) weak_alias (__libc_pvalloc, pvalloc) -weak_alias (__libc_mallinfo, __mallinfo) weak_alias (__libc_mallinfo, mallinfo) -weak_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt) -#undef malloc_stats -weak_alias (__malloc_stats, malloc_stats) -#undef malloc_usable_size -weak_alias (__malloc_usable_size, malloc_usable_size) -#undef malloc_trim -weak_alias (__malloc_trim, malloc_trim) -#endif #if defined(_LIBC) || defined(MALLOC_HOOKS) @@ -3741,7 +3747,7 @@ weak_alias (__malloc_trim, malloc_trim) byte per chunk; still this will catch most cases of double frees or overruns. */ -#define MAGICBYTE ((char)0xd7) +#define MAGICBYTE(p) ( ( ((unsigned)p >> 3) ^ ((unsigned)p >> 11)) & 0xFF ) /* Convert a pointer to be free()d or realloc()ed to a valid chunk pointer. If the provided pointer is not valid, return NULL. The @@ -3760,29 +3766,35 @@ mem2chunk_check(mem) Void_t* mem; p = mem2chunk(mem); if(!aligned_OK(p)) return NULL; if( (char*)p>=sbrk_base && (char*)p<(sbrk_base+sbrked_mem) ) { - /* Must be a chunk in conventional memory. */ + /* Must be a chunk in conventional heap memory. */ if(chunk_is_mmapped(p) || ( (sz = chunksize(p)), ((char*)p + sz)>=(sbrk_base+sbrked_mem) ) || - sz<MINSIZE || sz&MALLOC_ALIGN_MASK || !inuse(p) ) return NULL; - if(*((char*)p + sz + (SIZE_SZ-1)) != MAGICBYTE) return NULL; - *((char*)p + sz + (SIZE_SZ-1)) = 0; + sz<MINSIZE || sz&MALLOC_ALIGN_MASK || !inuse(p) || + ( !prev_inuse(p) && (p->prev_size&MALLOC_ALIGN_MASK || + (long)prev_chunk(p)<(long)sbrk_base || + next_chunk(prev_chunk(p))!=p) )) + return NULL; + if(*((unsigned char*)p + sz + (SIZE_SZ-1)) != MAGICBYTE(p)) + return NULL; + *((unsigned char*)p + sz + (SIZE_SZ-1)) ^= 0xFF; } else { unsigned long offset, page_mask = malloc_getpagesize-1; - /* mmap()ed chunks have MALLOC_ALIGNMENT or higher power-of two + /* mmap()ed chunks have MALLOC_ALIGNMENT or higher power-of-two alignment relative to the beginning of a page. Check this first. */ offset = (unsigned long)mem & page_mask; if((offset!=MALLOC_ALIGNMENT && offset!=0 && offset!=0x10 && - offset!=0x20 && offset!=0x40 && offset!=0x80 && offset!=0x100 && - offset!=0x200 && offset!=0x400 && offset!=0x800 && offset!=0x1000 && - offset<0x2000) || + offset!=0x20 && offset!=0x40 && offset!=0x80 && offset!=0x100 && + offset!=0x200 && offset!=0x400 && offset!=0x800 && offset!=0x1000 && + offset<0x2000) || !chunk_is_mmapped(p) || (p->size & PREV_INUSE) || ( (((unsigned long)p - p->prev_size) & page_mask) != 0 ) || ( (sz = chunksize(p)), ((p->prev_size + sz) & page_mask) != 0 ) ) return NULL; - if(*((char*)p + sz - 1) != MAGICBYTE) return NULL; - *((char*)p + sz - 1) = 0; + if(*((unsigned char*)p + sz - 1) != MAGICBYTE(p)) + return NULL; + *((unsigned char*)p + sz - 1) ^= 0xFF; } return p; } @@ -3806,7 +3818,7 @@ malloc_check(sz) size_t sz; --nb; else nb += SIZE_SZ - 1; - *((char*)victim + nb) = MAGICBYTE; + *((unsigned char*)victim + nb) = MAGICBYTE(victim); return chunk2mem(victim); } @@ -3820,8 +3832,10 @@ free_check(mem) Void_t* mem; mchunkptr p; if(!mem) return; + (void)mutex_lock(&main_arena.mutex); p = mem2chunk_check(mem); if(!p) { + (void)mutex_unlock(&main_arena.mutex); switch(check_action) { case 1: fprintf(stderr, "free(): invalid pointer %lx!\n", (long)(mem)); @@ -3833,11 +3847,14 @@ free_check(mem) Void_t* mem; } #if HAVE_MMAP if (chunk_is_mmapped(p)) { + (void)mutex_unlock(&main_arena.mutex); munmap_chunk(p); return; } #endif - (void)mutex_lock(&main_arena.mutex); +#if 0 /* Erase freed memory. */ + memset(mem, 0, chunksize(p) - (SIZE_SZ+1)); +#endif chunk_free(&main_arena, p); (void)mutex_unlock(&main_arena.mutex); } @@ -3853,8 +3870,10 @@ realloc_check(oldmem, bytes) Void_t* oldmem; size_t bytes; INTERNAL_SIZE_T nb, oldsize; if (oldmem == 0) return malloc_check(bytes); + (void)mutex_lock(&main_arena.mutex); oldp = mem2chunk_check(oldmem); if(!oldp) { + (void)mutex_unlock(&main_arena.mutex); switch(check_action) { case 1: fprintf(stderr, "realloc(): invalid pointer %lx!\n", (long)(oldmem)); @@ -3868,7 +3887,6 @@ realloc_check(oldmem, bytes) Void_t* oldmem; size_t bytes; nb = request2size(bytes+1); - (void)mutex_lock(&main_arena.mutex); #if HAVE_MMAP if (chunk_is_mmapped(oldp)) { #if HAVE_MREMAP @@ -3878,19 +3896,31 @@ realloc_check(oldmem, bytes) Void_t* oldmem; size_t bytes; /* Note the extra SIZE_SZ overhead. */ if(oldsize - SIZE_SZ >= nb) newp = oldp; /* do nothing */ else { - /* Must alloc, copy, free. */ - newp = chunk_alloc(&main_arena, nb); - if (newp) { - MALLOC_COPY(chunk2mem(newp), oldmem, oldsize - 2*SIZE_SZ); - munmap_chunk(oldp); - } + /* Must alloc, copy, free. */ + newp = chunk_alloc(&main_arena, nb); + if (newp) { + MALLOC_COPY(chunk2mem(newp), oldmem, oldsize - 2*SIZE_SZ); + munmap_chunk(oldp); + } } #if HAVE_MREMAP } #endif - } else + } else { #endif /* HAVE_MMAP */ newp = chunk_realloc(&main_arena, oldp, oldsize, nb); +#if 0 /* Erase freed memory. */ + nb = chunksize(newp); + if(oldp<newp || oldp>=chunk_at_offset(newp, nb)) { + memset((char*)oldmem + 2*sizeof(mbinptr), 0, + oldsize - (2*sizeof(mbinptr)+2*SIZE_SZ+1)); + } else if(nb > oldsize+SIZE_SZ) { + memset((char*)chunk2mem(newp) + oldsize, 0, nb - (oldsize+SIZE_SZ)); + } +#endif +#if HAVE_MMAP + } +#endif (void)mutex_unlock(&main_arena.mutex); if(!newp) return NULL; @@ -3899,7 +3929,7 @@ realloc_check(oldmem, bytes) Void_t* oldmem; size_t bytes; --nb; else nb += SIZE_SZ - 1; - *((char*)newp + nb) = MAGICBYTE; + *((unsigned char*)newp + nb) = MAGICBYTE(newp); return chunk2mem(newp); } @@ -3926,12 +3956,66 @@ memalign_check(alignment, bytes) size_t alignment; size_t bytes; --nb; else nb += SIZE_SZ - 1; - *((char*)p + nb) = MAGICBYTE; + *((unsigned char*)p + nb) = MAGICBYTE(p); return chunk2mem(p); } +/* The following hooks are used when the global initialization in + ptmalloc_init() hasn't completed yet. */ + +static Void_t* +#if __STD_C +malloc_starter(size_t sz) +#else +malloc_starter(sz) size_t sz; +#endif +{ + mchunkptr victim = chunk_alloc(&main_arena, request2size(sz)); + + return victim ? chunk2mem(victim) : 0; +} + +static void +#if __STD_C +free_starter(Void_t* mem) +#else +free_starter(mem) Void_t* mem; +#endif +{ + mchunkptr p; + + if(!mem) return; + p = mem2chunk(mem); +#if HAVE_MMAP + if (chunk_is_mmapped(p)) { + munmap_chunk(p); + return; + } +#endif + chunk_free(&main_arena, p); +} + #endif /* defined(_LIBC) || defined(MALLOC_HOOKS) */ + + +#ifdef _LIBC +weak_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc) +weak_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree) +weak_alias (__libc_free, __free) weak_alias (__libc_free, free) +weak_alias (__libc_malloc, __malloc) weak_alias (__libc_malloc, malloc) +weak_alias (__libc_memalign, __memalign) weak_alias (__libc_memalign, memalign) +weak_alias (__libc_realloc, __realloc) weak_alias (__libc_realloc, realloc) +weak_alias (__libc_valloc, __valloc) weak_alias (__libc_valloc, valloc) +weak_alias (__libc_pvalloc, __pvalloc) weak_alias (__libc_pvalloc, pvalloc) +weak_alias (__libc_mallinfo, __mallinfo) weak_alias (__libc_mallinfo, mallinfo) +weak_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt) + +weak_alias (__malloc_stats, malloc_stats) +weak_alias (__malloc_usable_size, malloc_usable_size) +weak_alias (__malloc_trim, malloc_trim) +#endif + /* History: diff --git a/manual/time.texi b/manual/time.texi index 26c3c5928a..1214be23d4 100644 --- a/manual/time.texi +++ b/manual/time.texi @@ -640,8 +640,12 @@ The number is padded with spaces. The number is not padded at all. @item 0 -The number is padded with zeros even if the format spefies padding +The number is padded with zeros even if the format specifies padding with spaces. + +@item ^ +The output uses uppercase characters, but only if this is possible +(@pxref{Case Conversion}). @end table The default action is to pad the number with zeros to keep it a constant @@ -774,6 +778,17 @@ Either @samp{AM} or @samp{PM}, according to the given time value; or the corresponding strings for the current locale. Noon is treated as @samp{PM} and midnight as @samp{AM}. +@ignore +We currently have a problem with makeinfo. Write @samp{AM} and @samp{am} +both results in `am'. I.e., the difference in case is not visible anymore. +@end ignore +@item %P +Either @samp{am} or @samp{pm}, according to the given time value; or the +corresponding strings for the current locale, printed in lowercase +characters. Noon is treated as @samp{pm} and midnight as @samp{am}. + +This format is a GNU extension. + @item %r The complete time using the AM/PM format of the current locale. diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c index 0b4ed40e59..de96dbbeb6 100644 --- a/nis/nss_compat/compat-grp.c +++ b/nis/nss_compat/compat-grp.c @@ -26,6 +26,12 @@ #include <rpcsvc/yp.h> #include <rpcsvc/ypclnt.h> +/* Get the declaration of the parser function. */ +#define ENTNAME grent +#define STRUCTURE group +#define EXTERN_PARSER +#include "../../nss/nss_files/files-parse.c" + /* Structure for remembering -@netgroup and -user members ... */ #define BLACKLIST_INITIAL_SIZE 512 #define BLACKLIST_INCREMENT 256 @@ -146,6 +152,7 @@ static enum nss_status getgrent_next_nis (struct group *result, ent_t *ent, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *domain; char *outkey, *outval; int outkeylen, outvallen; @@ -196,7 +203,7 @@ getgrent_next_nis (struct group *result, ent_t *ent, char *buffer, while (isspace (*p)) ++p; } - while (!_nss_files_parse_grent (p, result, buffer, buflen)); + while (!_nss_files_parse_grent (p, result, data, buflen)); if (!in_blacklist (result->gr_name, strlen (result->gr_name), ent)) return NSS_STATUS_SUCCESS; @@ -209,6 +216,7 @@ static enum nss_status getgrent_next_file (struct group *result, ent_t *ent, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; while (1) { char *p; @@ -230,7 +238,7 @@ getgrent_next_file (struct group *result, ent_t *ent, while (*p == '\0' || *p == '#' || /* Parse the line. If it is invalid, loop to get the next line of the file to parse. */ - !_nss_files_parse_grent (p, result, buffer, buflen)); + !_nss_files_parse_grent (p, result, data, buflen)); if (result->gr_name[0] != '+' && result->gr_name[0] != '-') /* This is a real entry. */ @@ -266,7 +274,7 @@ getgrent_next_file (struct group *result, ent_t *ent, while (isspace (*p)) p++; free (outval); - if (_nss_files_parse_grent (p, result, buffer, buflen)) + if (_nss_files_parse_grent (p, result, data, buflen)) /* We found the entry. */ break; } diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c index 39ee2c5901..56659e9ed5 100644 --- a/nis/nss_compat/compat-pwd.c +++ b/nis/nss_compat/compat-pwd.c @@ -29,6 +29,12 @@ #include "netgroup.h" +/* Get the declaration of the parser function. */ +#define ENTNAME pwent +#define STRUCTURE passwd +#define EXTERN_PARSER +#include "../../nss/nss_files/files-parse.c" + /* Structure for remembering -@netgroup and -user members ... */ #define BLACKLIST_INITIAL_SIZE 512 #define BLACKLIST_INCREMENT 256 @@ -269,6 +275,7 @@ static enum nss_status getpwent_next_netgr (struct passwd *result, ent_t *ent, char *group, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *ypdomain, *host, *user, *domain, *outval, *p, *p2; int status, outvallen; size_t p2len; @@ -290,8 +297,8 @@ getpwent_next_netgr (struct passwd *result, ent_t *ent, char *group, while (1) { - status = __internal_getnetgrent (&host, &user, &domain, &ent->netgrdata, - buffer, buflen); + status = __internal_getnetgrent_r (&host, &user, &domain, + &ent->netgrdata, buffer, buflen); if (status != 1) { __internal_endnetgrent (&ent->netgrdata); @@ -323,7 +330,7 @@ getpwent_next_netgr (struct passwd *result, ent_t *ent, char *group, while (isspace (*p)) p++; free (outval); - if (_nss_files_parse_pwent (p, result, buffer, buflen)) + if (_nss_files_parse_pwent (p, result, data, buflen)) { copy_pwd_changes (result, &ent->pwd, p2, p2len); break; @@ -337,6 +344,7 @@ static enum nss_status getpwent_next_nis (struct passwd *result, ent_t *ent, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *domain, *outkey, *outval, *p, *p2; int outkeylen, outvallen; size_t p2len; @@ -397,7 +405,7 @@ getpwent_next_nis (struct passwd *result, ent_t *ent, char *buffer, while (isspace (*p)) ++p; } - while (!_nss_files_parse_pwent (p, result, buffer, buflen)); + while (!_nss_files_parse_pwent (p, result, data, buflen)); copy_pwd_changes (result, &ent->pwd, p2, p2len); @@ -412,6 +420,7 @@ static enum nss_status getpwent_next_file (struct passwd *result, ent_t *ent, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; while (1) { char *p, *p2; @@ -433,7 +442,7 @@ getpwent_next_file (struct passwd *result, ent_t *ent, while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ /* Parse the line. If it is invalid, loop to get the next line of the file to parse. */ - !_nss_files_parse_pwent (p, result, buffer, buflen)); + !_nss_files_parse_pwent (p, result, data, buflen)); if (result->pw_name[0] != '+' && result->pw_name[0] != '-') /* This is a real entry. */ @@ -516,7 +525,7 @@ getpwent_next_file (struct passwd *result, ent_t *ent, while (isspace (*p)) p++; free (outval); - if (_nss_files_parse_pwent (p, result, buffer, buflen)) + if (_nss_files_parse_pwent (p, result, data, buflen)) { copy_pwd_changes (result, &pwd, p2, p2len); give_pwd_free (&pwd); diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c index ba73b1846f..47dd22970a 100644 --- a/nis/nss_compat/compat-spwd.c +++ b/nis/nss_compat/compat-spwd.c @@ -27,6 +27,12 @@ #include <rpcsvc/yp.h> #include <rpcsvc/ypclnt.h> +/* Get the declaration of the parser function. */ +#define ENTNAME spent +#define STRUCTURE spwd +#define EXTERN_PARSER +#include "../../nss/nss_files/files-parse.c" + /* Structure for remembering -@netgroup and -user members ... */ #define BLACKLIST_INITIAL_SIZE 512 #define BLACKLIST_INCREMENT 256 @@ -212,6 +218,7 @@ static enum nss_status getspent_next_netgr (struct spwd *result, ent_t *ent, char *group, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *ypdomain, *host, *user, *domain, *outval, *p, *p2; int status, outvallen; size_t p2len; @@ -263,7 +270,7 @@ getspent_next_netgr (struct spwd *result, ent_t *ent, char *group, while (isspace (*p)) p++; free (outval); - if (_nss_files_parse_spent (p, result, buffer, buflen)) + if (_nss_files_parse_spent (p, result, data, buflen)) { copy_spwd_changes (result, &ent->pwd, p2, p2len); break; @@ -277,6 +284,7 @@ static enum nss_status getspent_next_nis (struct spwd *result, ent_t *ent, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *domain, *outkey, *outval, *p, *p2; int outkeylen, outvallen; size_t p2len; @@ -337,7 +345,7 @@ getspent_next_nis (struct spwd *result, ent_t *ent, while (isspace (*p)) ++p; } - while (!_nss_files_parse_spent (p, result, buffer, buflen)); + while (!_nss_files_parse_spent (p, result, data, buflen)); copy_spwd_changes (result, &ent->pwd, p2, p2len); @@ -352,6 +360,7 @@ static enum nss_status getspent_next_file (struct spwd *result, ent_t *ent, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; while (1) { char *p, *p2; @@ -373,7 +382,7 @@ getspent_next_file (struct spwd *result, ent_t *ent, while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ /* Parse the line. If it is invalid, loop to get the next line of the file to parse. */ - !_nss_files_parse_spent (p, result, buffer, buflen)); + !_nss_files_parse_spent (p, result, data, buflen)); if (result->sp_namp[0] != '+' && result->sp_namp[0] != '-') /* This is a real entry. */ @@ -456,7 +465,7 @@ getspent_next_file (struct spwd *result, ent_t *ent, while (isspace (*p)) p++; free (outval); - if (_nss_files_parse_spent (p, result, buffer, buflen)) + if (_nss_files_parse_spent (p, result, data, buflen)) { copy_spwd_changes (result, &pwd, p2, p2len); give_spwd_free (&pwd); diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c index df884d6faa..733e1508c5 100644 --- a/nis/nss_nis/nis-alias.c +++ b/nis/nss_nis/nis-alias.c @@ -35,7 +35,7 @@ static char *oldkey = NULL; static int oldkeylen = 0; static int -_nss_nis_parse_aliasent (char *key, char *alias, struct aliasent *result, +_nss_nis_parse_aliasent (const char *key, char *alias, struct aliasent *result, char *buffer, size_t buflen) { char *first_unused = buffer + strlen (alias) + 1; diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c index ae3ba76adf..25f77f5f82 100644 --- a/nis/nss_nis/nis-ethers.c +++ b/nis/nss_nis/nis-ethers.c @@ -33,10 +33,16 @@ __libc_lock_define_initialized (static, lock) struct ether { - char *e_name; + const char *e_name; struct ether_addr e_addr; }; +/* Get the declaration of the parser function. */ +#define ENTNAME etherent +#define STRUCTURE ether +#define EXTERN_PARSER +#include "../nss/nss_files/files-parse.c" + static bool_t new_start = 1; static char *oldkey = NULL; static int oldkeylen = 0; @@ -80,6 +86,7 @@ _nss_nis_endetherent (void) static enum nss_status internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; int len, keylen, parse_res; @@ -120,7 +127,7 @@ internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen) ++p; free (result); - parse_res = _nss_files_parse_etherent (p, eth, buffer, buflen); + parse_res = _nss_files_parse_etherent (p, eth, data, buflen); if (!parse_res && errno == ERANGE) return NSS_STATUS_TRYAGAIN; @@ -152,6 +159,7 @@ enum nss_status _nss_nis_getethernam_r (const char *name, struct ether *eth, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, parse_res; @@ -188,7 +196,7 @@ _nss_nis_getethernam_r (const char *name, struct ether *eth, ++p; free (result); - parse_res = _nss_files_parse_etherent (p, eth, buffer, buflen); + parse_res = _nss_files_parse_etherent (p, eth, data, buflen); if (!parse_res) { @@ -205,6 +213,7 @@ enum nss_status _nss_nis_getetherbyaddr_r (struct ether_addr *addr, struct ether *eth, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, nlen, parse_res; @@ -250,7 +259,7 @@ _nss_nis_getetherbyaddr_r (struct ether_addr *addr, struct ether *eth, ++p; free (result); - parse_res = _nss_files_parse_etherent (p, eth, buffer, buflen); + parse_res = _nss_files_parse_etherent (p, eth, data, buflen); if (!parse_res) { diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c index 72de8b3c83..d727202513 100644 --- a/nis/nss_nis/nis-grp.c +++ b/nis/nss_nis/nis-grp.c @@ -28,6 +28,12 @@ #include "nss-nis.h" +/* Get the declaration of the parser function. */ +#define ENTNAME grent +#define STRUCTURE group +#define EXTERN_PARSER +#include "../nss/nss_files/files-parse.c" + /* Protect global state against multiple changers */ __libc_lock_define_initialized (static, lock) @@ -74,6 +80,7 @@ _nss_nis_endgrent (void) static enum nss_status internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; int len, keylen, parse_res; @@ -114,7 +121,7 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen) ++p; free (result); - parse_res = _nss_files_parse_grent (p, grp, buffer, buflen); + parse_res = _nss_files_parse_grent (p, grp, data, buflen); if (!parse_res && errno == ERANGE) return NSS_STATUS_TRYAGAIN; @@ -146,6 +153,7 @@ enum nss_status _nss_nis_getgrnam_r (const char *name, struct group *grp, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, parse_res; @@ -182,7 +190,7 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, ++p; free (result); - parse_res = _nss_files_parse_grent (p, grp, buffer, buflen); + parse_res = _nss_files_parse_grent (p, grp, data, buflen); if (!parse_res) { @@ -199,6 +207,7 @@ enum nss_status _nss_nis_getgrgid_r (gid_t gid, struct group *grp, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, nlen, parse_res; @@ -232,7 +241,7 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp, ++p; free (result); - parse_res = _nss_files_parse_grent (p, grp, buffer, buflen); + parse_res = _nss_files_parse_grent (p, grp, data, buflen); if (!parse_res) { diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c index e82b40143e..391f4c5895 100644 --- a/nis/nss_nis/nis-network.c +++ b/nis/nss_nis/nis-network.c @@ -30,6 +30,11 @@ #include "nss-nis.h" +/* Get the declaration of the parser function. */ +#define ENTNAME netent +#define EXTERN_PARSER +#include "../nss/nss_files/files-parse.c" + __libc_lock_define_initialized (static, lock) static bool_t new_start = 1; @@ -76,6 +81,7 @@ static enum nss_status internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, int *herrnop) { + struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; int len, keylen, parse_res; @@ -120,7 +126,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen, ++p; free (result); - parse_res = _nss_files_parse_netent (p, net, buffer, buflen); + parse_res = _nss_files_parse_netent (p, net, data, buflen); if (!parse_res && errno == ERANGE) { *herrnop = NETDB_INTERNAL; @@ -157,6 +163,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer, size_t buflen, int *herrnop) { enum nss_status retval; + struct parser_data *data = (void *) buffer; char *domain, *result, *p; int len, parse_res; @@ -197,7 +204,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, ++p; free (result); - parse_res = _nss_files_parse_netent (p, net, buffer, buflen); + parse_res = _nss_files_parse_netent (p, net, data, buflen); if (!parse_res) { @@ -215,6 +222,7 @@ enum nss_status _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net, char *buffer, size_t buflen, int *herrnop) { + struct parser_data *data = (void *) buffer; char *domain; char *result; int len; @@ -275,7 +283,7 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net, ++p; free (result); - parse_res = _nss_files_parse_netent (p, net, buffer, buflen); + parse_res = _nss_files_parse_netent (p, net, data, buflen); if (!parse_res) diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c index 6feae63258..ccb95c3c41 100644 --- a/nis/nss_nis/nis-proto.c +++ b/nis/nss_nis/nis-proto.c @@ -28,6 +28,11 @@ #include "nss-nis.h" +/* Get the declaration of the parser function. */ +#define ENTNAME protoent +#define EXTERN_PARSER +#include "../nss/nss_files/files-parse.c" + __libc_lock_define_initialized (static, lock) static bool_t new_start = 1; @@ -74,6 +79,7 @@ static enum nss_status internal_nis_getprotoent_r (struct protoent *proto, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; int len, keylen, parse_res; @@ -114,7 +120,7 @@ internal_nis_getprotoent_r (struct protoent *proto, ++p; free (result); - parse_res = _nss_files_parse_protoent (p, proto, buffer, buflen); + parse_res = _nss_files_parse_protoent (p, proto, data, buflen); if (!parse_res && errno == ERANGE) return NSS_STATUS_TRYAGAIN; @@ -146,6 +152,7 @@ enum nss_status _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, parse_res; @@ -182,7 +189,7 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto, ++p; free (result); - parse_res = _nss_files_parse_protoent (p, proto, buffer, buflen); + parse_res = _nss_files_parse_protoent (p, proto, data, buflen); if (!parse_res) { @@ -199,6 +206,7 @@ enum nss_status _nss_nis_getprotobynumber_r (int number, struct protoent *proto, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, nlen, parse_res; @@ -232,7 +240,7 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto, ++p; free (result); - parse_res = _nss_files_parse_protoent (p, proto, buffer, buflen); + parse_res = _nss_files_parse_protoent (p, proto, data, buflen); if (!parse_res) { diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c index 752f7032a6..60a59fe4a8 100644 --- a/nis/nss_nis/nis-pwd.c +++ b/nis/nss_nis/nis-pwd.c @@ -28,6 +28,12 @@ #include "nss-nis.h" +/* Get the declaration of the parser function. */ +#define ENTNAME pwent +#define STRUCTURE passwd +#define EXTERN_PARSER +#include "../nss/nss_files/files-parse.c" + /* Protect global state against multiple changers */ __libc_lock_define_initialized (static, lock) @@ -74,6 +80,7 @@ _nss_nis_endpwent (void) static enum nss_status internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; int len, keylen, parse_res; @@ -114,7 +121,7 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen) ++p; free (result); - parse_res = _nss_files_parse_pwent (p, pwd, buffer, buflen); + parse_res = _nss_files_parse_pwent (p, pwd, data, buflen); if (!parse_res && errno == ERANGE) return NSS_STATUS_TRYAGAIN; @@ -146,6 +153,7 @@ enum nss_status _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, parse_res; @@ -182,7 +190,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, ++p; free (result); - parse_res = _nss_files_parse_pwent (p, pwd, buffer, buflen); + parse_res = _nss_files_parse_pwent (p, pwd, data, buflen); if (!parse_res) { @@ -199,6 +207,7 @@ enum nss_status _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, nlen, parse_res; @@ -232,7 +241,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, ++p; free (result); - parse_res = _nss_files_parse_pwent (p, pwd, buffer, buflen); + parse_res = _nss_files_parse_pwent (p, pwd, data, buflen); if (!parse_res) { diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c index a549076537..2dae9ea8fa 100644 --- a/nis/nss_nis/nis-rpc.c +++ b/nis/nss_nis/nis-rpc.c @@ -28,6 +28,11 @@ #include "nss-nis.h" +/* Get the declaration of the parser function. */ +#define ENTNAME rpcent +#define EXTERN_PARSER +#include "../nss/nss_files/files-parse.c" + __libc_lock_define_initialized (static, lock) struct intern_t @@ -98,6 +103,7 @@ static enum nss_status internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, intern_t *data) { + struct parser_data *pdata = (void *) buffer; char *domain; char *result; int len, parse_res; @@ -141,7 +147,7 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen, ++p; free (result); - parse_res = _nss_files_parse_rpcent (p, rpc, buffer, buflen); + parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen); if (!parse_res && errno == ERANGE) return NSS_STATUS_TRYAGAIN; @@ -223,6 +229,7 @@ enum nss_status _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, nlen, parse_res; @@ -256,7 +263,7 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc, ++p; free (result); - parse_res = _nss_files_parse_rpcent (p, rpc, buffer, buflen); + parse_res = _nss_files_parse_rpcent (p, rpc, data, buflen); if (!parse_res) { diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c index b5f8c3afd2..193cd7190c 100644 --- a/nis/nss_nis/nis-spwd.c +++ b/nis/nss_nis/nis-spwd.c @@ -28,6 +28,12 @@ #include "nss-nis.h" +/* Get the declaration of the parser function. */ +#define ENTNAME spent +#define STRUCTURE spwd +#define EXTERN_PARSER +#include "../nss/nss_files/files-parse.c" + /* Protect global state against multiple changers */ __libc_lock_define_initialized (static, lock) @@ -74,6 +80,7 @@ _nss_nis_endspent (void) static enum nss_status internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; char *domain, *result, *outkey; int len, keylen, parse_res; @@ -114,7 +121,7 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen) ++p; free (result); - parse_res = _nss_files_parse_spent (p, sp, buffer, buflen); + parse_res = _nss_files_parse_spent (p, sp, data, buflen); if (!parse_res && errno == ERANGE) return NSS_STATUS_TRYAGAIN; @@ -146,6 +153,7 @@ enum nss_status _nss_nis_getspnam_r (const char *name, struct spwd *sp, char *buffer, size_t buflen) { + struct parser_data *data = (void *) buffer; enum nss_status retval; char *domain, *result, *p; int len, parse_res; @@ -182,7 +190,7 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp, ++p; free (result); - parse_res = _nss_files_parse_spent (p, sp, buffer, buflen); + parse_res = _nss_files_parse_spent (p, sp, data, buflen); if (!parse_res) { diff --git a/nss/nss.h b/nss/nss.h index 8246719054..1ba7bc8b63 100644 --- a/nss/nss.h +++ b/nss/nss.h @@ -1,20 +1,20 @@ /* Copyright (C) 1996 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 Library General Public License as -published by the Free Software Foundation; either version 2 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library 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. */ + 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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. */ /* Define interface to NSS. This is meant for the interface functions and for implementors of new services. */ diff --git a/posix/getopt.c b/posix/getopt.c index f4507d42d6..01adee0fe5 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -6,23 +6,23 @@ Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. Its master source is NOT part of -the C library, however. The master source lives in /gd/gnu/lib. - -The GNU C Library 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. - -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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in /gd/gnu/lib. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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. */ /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. Ditto for AIX 3.2 and <stdlib.h>. */ @@ -726,6 +726,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) c = ':'; else c = '?'; + return c; } else /* We already incremented `optind' once; diff --git a/posix/sched.h b/posix/sched.h index 026a5e2f20..277f93eb52 100644 --- a/posix/sched.h +++ b/posix/sched.h @@ -1,21 +1,21 @@ /* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. -Copyright (C) 1996 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 Library General Public License as -published by the Free Software Foundation; either version 2 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library 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. */ + Copyright (C) 1996 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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 _SCHED_H #define _SCHED_H 1 diff --git a/stdio-common/Makefile b/stdio-common/Makefile index 4f4d45e998..ec7429c36e 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -33,7 +33,7 @@ routines := \ tmpfile tmpnam tmpnam_r tempnam tempname \ getline getw putw \ remove rename \ - lockfile fcloseall + lockfile aux := errlist siglist distribute := _itoa.h printf-parse.h diff --git a/stdio-common/fcloseall.c b/stdio-common/fcloseall.c deleted file mode 100644 index 0b1702e112..0000000000 --- a/stdio-common/fcloseall.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Close all streams but make sure this isn't done more than once. - This function is called in abort(). - Copyright (C) 1996 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. - - The GNU C Library 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. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library 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. */ - -#include <libc-lock.h> -#include <stdio.h> - -static int already_called; - -__libc_lock_define_initialized (static, lock); - -void -__close_all_streams (void) -{ - /* We must be prepared for multi-threading on multiple calls. */ - if (! __libc_lock_trylock (lock) && ! already_called) - { - /* Signal that we already did this. */ - already_called = 1; - - /* Do the real work. */ - fclose (NULL); - - /* We don't release the lock so that the `trylock' immediately - fails. */ - } -} diff --git a/stdlib/Makefile b/stdlib/Makefile index eadcd40cee..6e7b753180 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -44,7 +44,7 @@ routines := \ a64l l64a \ rpmatch strfmon getsubopt -distribute := exit.h grouping.h +distribute := exit.h grouping.h abort-instr.h tests := tst-strtol tst-strtod testmb testrand testsort testdiv \ test-canon diff --git a/sysdeps/generic/abort-instr.h b/sysdeps/generic/abort-instr.h new file mode 100644 index 0000000000..106a330b2b --- /dev/null +++ b/sysdeps/generic/abort-instr.h @@ -0,0 +1,2 @@ +/* We cannot give any generic instruction to crash the program. + abort() will have to make sure it never returns. */ diff --git a/sysdeps/generic/abort.c b/sysdeps/generic/abort.c index 61b99377b9..604eadc4f5 100644 --- a/sysdeps/generic/abort.c +++ b/sysdeps/generic/abort.c @@ -16,16 +16,26 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <libc-lock.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <signal.h> +/* Try to get a machine dependent instruction which will make the + program crash. This is used in case everything else fails. */ +#include "abort-instr.h" +#ifndef ABORT_INSTRUCTION +/* No such instruction is available. */ +# define ABORT_INSTRUCTION +#endif + +/* We must avoid to run in circles. Therefore we remember how far we + already got. */ +static int stage; -/* Function to close all streams and also make sure we don't loop by - calling abort while closing the streams. */ -extern void __close_all_streams (void); +/* We should be prepared for multiple threads trying to run abort. */ +__libc_lock_define_initialized_recursive (static, lock); /* Cause an abnormal program termination with core-dump. */ @@ -35,41 +45,78 @@ abort (void) struct sigaction act; sigset_t sigs; - if (__sigemptyset (&sigs) == 0 && - __sigaddset (&sigs, SIGABRT) == 0) - __sigprocmask (SIG_UNBLOCK, &sigs, (sigset_t *) NULL); + /* First acquire the lock. */ + __libc_lock_lock (lock); + + /* Now it's for sure we are alone. But recursive calls are possible. */ - /* If there is a user handler installed use it. We don't close or - flush streams. */ - if (__sigaction (SIGABRT, NULL, &act) >= 0 - && act.sa_handler != SIG_DFL) + /* Unlock SIGABRT. */ + if (stage == 0) { - /* Send signal to call user handler. */ - raise (SIGABRT); + ++stage; + if (__sigemptyset (&sigs) == 0 && + __sigaddset (&sigs, SIGABRT) == 0) + __sigprocmask (SIG_UNBLOCK, &sigs, (sigset_t *) NULL); + } + + /* Flush all streams. We cannot close them now because the user + might have registered a handler for SIGABRT. */ + if (stage == 1) + { + ++stage; + fflush (NULL); + } - /* It returns, so we are responsible for closing the streams. */ - __close_all_streams (); + /* Send signal which possibly calls a user handler. */ + if (stage == 2) + { + ++stage; + raise (SIGABRT); + } - /* There was a handler installed. Now remove it. */ + /* There was a handler installed. Now remove it. */ + if (stage == 3) + { + ++stage; memset (&act, '\0', sizeof (struct sigaction)); act.sa_handler = SIG_DFL; __sigfillset (&act.sa_mask); act.sa_flags = 0; __sigaction (SIGABRT, &act, NULL); } - else - /* No handler installed so the next `raise' will hopefully - terminate the process. Therefore we must close the streams. */ - __close_all_streams (); + + /* Now close the streams which also flushes the output the user + defined handler might has produced. */ + if (stage == 4) + { + ++stage; + fclose (NULL); + } /* Try again. */ - raise (SIGABRT); + if (stage == 5) + { + ++stage; + raise (SIGABRT); + } - /* If we can't signal ourselves, exit. */ - _exit (127); + /* Now try to abort using the system specific command. */ + if (stage == 6) + { + ++stage; + ABORT_INSTRUCTION; + } + + /* If we can't signal ourselves and the abort instruction failed, exit. */ + if (stage == 7) + { + ++stage; + _exit (127); + } - /* If even this fails make sure we never return. */ + /* If even this fails try to use the provided instruction to crash + or otherwise make sure we never return. */ while (1) - /* For ever and ever. */ - ; + /* Try for ever and ever. */ + ABORT_INSTRUCTION; } diff --git a/sysdeps/i386/abort-instr.h b/sysdeps/i386/abort-instr.h new file mode 100644 index 0000000000..810f10379b --- /dev/null +++ b/sysdeps/i386/abort-instr.h @@ -0,0 +1,2 @@ +/* An instruction which should crash any program is `hlt'. */ +#define ABORT_INSTRUCTION asm ("hlt") diff --git a/sysdeps/i386/fpu_control.h b/sysdeps/i386/fpu_control.h index 7944b1a5ee..4677f13518 100644 --- a/sysdeps/i386/fpu_control.h +++ b/sysdeps/i386/fpu_control.h @@ -1,22 +1,22 @@ /* FPU control word bits. i387 version. -Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. -Contributed by Olaf Flebbe. - -The GNU C Library 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. - -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 -Library General Public License for more details. - -You should have received a copy of the GNU Library 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. */ + Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Olaf Flebbe. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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 _FPU_CONTROL_H #define _FPU_CONTROL_H 1 diff --git a/sysdeps/unix/common/pause.c b/sysdeps/unix/common/pause.c index a073dd2b3a..1580a0baef 100644 --- a/sysdeps/unix/common/pause.c +++ b/sysdeps/unix/common/pause.c @@ -1,20 +1,20 @@ /* Copyright (C) 1991, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. + 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 Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library 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. -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 -Library General Public License for more details. + 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 + Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU Library 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. */ #include <signal.h> #include <unistd.h> @@ -26,6 +26,6 @@ Cambridge, MA 02139, USA. */ int __libc_pause (void) { - return __sigpause (__sigblock (0)); + return __sigpause (__sigblock (0), 0); } weak_alias (__libc_pause, pause) diff --git a/sysdeps/unix/sysv/linux/alpha/timebits.h b/sysdeps/unix/sysv/linux/alpha/timebits.h index f777dc2aa8..1ad0df8c5b 100644 --- a/sysdeps/unix/sysv/linux/alpha/timebits.h +++ b/sysdeps/unix/sysv/linux/alpha/timebits.h @@ -33,9 +33,18 @@ struct timeval #ifndef _TIMEBITS_H -#define _TIMEBITS_H 1 - -#include <asm/param.h> -#define CLOCKS_PER_SEC HZ /* XXX names not kosher */ +# define _TIMEBITS_H 1 + +/* ISO/IEC 9899:1990 7.12.1: <time.h> + The macro `CLOCKS_PER_SEC' is the number per second of the value + returned by the `clock' function. */ +/* CAE XSH, Issue 4, Version 2: <time.h> + The value of CLOCKS_PER_SEC is required to be 1 million on all + XSI-conformant systems. */ +# define CLOCKS_PER_SEC 1000000 + +/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK + presents the real value for clock ticks per second for the system. */ +# define CLK_TCK 1024 #endif /* timebits.h */ diff --git a/sysdeps/unix/sysv/linux/fcntlbits.h b/sysdeps/unix/sysv/linux/fcntlbits.h index 9088e6df57..43954df6ec 100644 --- a/sysdeps/unix/sysv/linux/fcntlbits.h +++ b/sysdeps/unix/sysv/linux/fcntlbits.h @@ -1,21 +1,21 @@ /* O_*, F_*, FD_* bit values for Linux. -Copyright (C) 1995, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. + Copyright (C) 1995, 1996 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 Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library 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. -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 -Library General Public License for more details. + 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 + Library General Public License for more details. -You should have received a copy of the GNU Library 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. */ + You should have received a copy of the GNU Library 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 _FCNTLBITS_H #define _FCNTLBITS_H 1 diff --git a/sysdeps/unix/sysv/linux/ioctls.h b/sysdeps/unix/sysv/linux/ioctls.h index f7a3467ca6..8b5326998a 100644 --- a/sysdeps/unix/sysv/linux/ioctls.h +++ b/sysdeps/unix/sysv/linux/ioctls.h @@ -1,20 +1,20 @@ /* Copyright (C) 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. + 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 Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library 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. -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 -Library General Public License for more details. + 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 + Library General Public License for more details. -You should have received a copy of the GNU Library 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. */ + You should have received a copy of the GNU Library 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 _IOCTLS_H #define _IOCTLS_H 1 diff --git a/sysdeps/unix/sysv/linux/m68k/setjmp.c b/sysdeps/unix/sysv/linux/m68k/setjmp.c new file mode 100644 index 0000000000..ef609cc7ab --- /dev/null +++ b/sysdeps/unix/sysv/linux/m68k/setjmp.c @@ -0,0 +1,83 @@ +/* Copyright (C) 1991, 1992, 1994, 1996 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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. */ + +#include <setjmp.h> + +/* Save the current program position in ENV and return 0. */ +int +__sigsetjmp (jmp_buf env, int savemask) +{ + /* Save data registers D1 through D7. */ + asm volatile ("movem%.l %/d1-%/d7, %0" + : : "m" (env[0].__jmpbuf[0].__dregs[0])); + + /* Save return address in place of register A0. */ + env[0].__jmpbuf[0].__aregs[0] = ((void **) &env)[-1]; + + /* Save address registers A1 through A5. */ + asm volatile ("movem%.l %/a1-%/a5, %0" + : : "m" (env[0].__jmpbuf[0].__aregs[1])); + + /* Save caller's FP, not our own. */ + env[0].__jmpbuf[0].__fp = ((void **) &env)[-2]; + + /* Save caller's SP, not our own. */ + env[0].__jmpbuf[0].__sp = (void *) &env; + +#if defined (__HAVE_68881__) || defined (__HAVE_FPU__) + /* Save floating-point (68881) registers FP0 through FP7. */ + asm volatile ("fmovem%.x %/fp0-%/fp7, %0" + : : "m" (env[0].__jmpbuf[0].__fpregs[0])); +#endif + + /* Save the signal mask if requested. */ + return __sigjmp_save (env, savemask); +} + +/* Binary compatibility entry point. */ +int +__setjmp (jmp_buf env) +{ + /* Save data registers D1 through D7. */ + asm volatile ("movem%.l %/d1-%/d7, %0" + : : "m" (env[0].__jmpbuf[0].__dregs[0])); + + /* Save return address in place of register A0. */ + env[0].__jmpbuf[0].__aregs[0] = ((void **) &env)[-1]; + + /* Save address registers A1 through A5. */ + asm volatile ("movem%.l %/a1-%/a5, %0" + : : "m" (env[0].__jmpbuf[0].__aregs[1])); + + /* Save caller's FP, not our own. */ + env[0].__jmpbuf[0].__fp = ((void **) &env)[-2]; + + /* Save caller's SP, not our own. */ + env[0].__jmpbuf[0].__sp = (void *) &env; + +#if defined (__HAVE_68881__) || defined (__HAVE_FPU__) + /* Save floating-point (68881) registers FP0 through FP7. */ + asm volatile ("fmovem%.x %/fp0-%/fp7, %0" + : : "m" (env[0].__jmpbuf[0].__fpregs[0])); +#endif + + /* Don't save the signal mask. */ + env[0].__mask_was_saved = 0; + + return 0; +} diff --git a/sysdeps/unix/sysv/linux/sigcontext.h b/sysdeps/unix/sysv/linux/sigcontext.h index 92733ab447..71afc76c71 100644 --- a/sysdeps/unix/sysv/linux/sigcontext.h +++ b/sysdeps/unix/sysv/linux/sigcontext.h @@ -1,20 +1,20 @@ /* Copyright (C) 1996 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 Library General Public License as -published by the Free Software Foundation; either version 2 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library 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. */ + 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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 _SIGCONTEXT_H #define _SIGCONTEXT_H 1 diff --git a/sysdeps/unix/sysv/linux/sys/acct.h b/sysdeps/unix/sysv/linux/sys/acct.h index da039307d1..4267ef405e 100644 --- a/sysdeps/unix/sysv/linux/sys/acct.h +++ b/sysdeps/unix/sysv/linux/sys/acct.h @@ -1,20 +1,20 @@ /* Copyright (C) 1996 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 Library General Public License as -published by the Free Software Foundation; either version 2 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library 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. */ + 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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 _SYS_ACCT_H diff --git a/sysdeps/unix/sysv/linux/timebits.h b/sysdeps/unix/sysv/linux/timebits.h index 52f666faf5..f2f73a48d4 100644 --- a/sysdeps/unix/sysv/linux/timebits.h +++ b/sysdeps/unix/sysv/linux/timebits.h @@ -43,4 +43,8 @@ struct timeval XSI-conformant systems. */ # define CLOCKS_PER_SEC 1000000 +/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK + presents the real value for clock ticks per second for the system. */ +# define CLK_TCK 100 + #endif /* timebits.h */ diff --git a/sysdeps/unix/sysv/linux/utsnamelen.h b/sysdeps/unix/sysv/linux/utsnamelen.h index c16c3852fb..64e2ab5bbc 100644 --- a/sysdeps/unix/sysv/linux/utsnamelen.h +++ b/sysdeps/unix/sysv/linux/utsnamelen.h @@ -1,19 +1,20 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 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 Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library 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. -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 -Library General Public License for more details. + 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 + Library General Public License for more details. -You should have received a copy of the GNU Library 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. */ + You should have received a copy of the GNU Library 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. */ /* Length of the entries in `struct utsname' is 65. */ #define _UTSNAME_LENGTH 65 diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h index 22df1eca95..b90f05165b 100644 --- a/sysvipc/sys/msg.h +++ b/sysvipc/sys/msg.h @@ -1,21 +1,21 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. -This file is part of the GNU C Library. -Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. -The GNU C Library 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. + The GNU C Library 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. -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 -Library General Public License for more details. + 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 + Library General Public License for more details. -You should have received a copy of the GNU Library 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. */ + You should have received a copy of the GNU Library 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 _SYS_MSG_H #define _SYS_MSG_H @@ -37,7 +37,7 @@ __BEGIN_DECLS /* Template for struct to be used as argument for `msgsnd' and `msgrcv'. */ struct msgbuf { - long mtype; /* type of received/sent message */ + long int mtype; /* type of received/sent message */ char mtext[1]; /* text of the message */ }; @@ -50,7 +50,7 @@ extern int msgget __P ((key_t __key, int __msgflg)); /* Receive message from message queue. */ extern int msgrcv __P ((int __msqid, void *__msgp, size_t __msgsz, - long __msgtyp, int __msgflg)); + long int __msgtyp, int __msgflg)); /* Send message to message queue. */ extern int msgsnd __P ((int __msqid, void *__msgp, size_t __msgsz, diff --git a/time/strftime.c b/time/strftime.c index 963e9e4e4d..4afcdd20fb 100644 --- a/time/strftime.c +++ b/time/strftime.c @@ -229,6 +229,11 @@ static const char spaces[16] = " "; # define TOUPPER(Ch) (islower (Ch) ? toupper (Ch) : (Ch)) # define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) #endif +/* We don't use `isdigit' here since the locale dependent + interpretation is not what we want here. We only need to accept + the arabic digits in the ASCII range. One day there is perhaps a + more reliable way to accept other sets of digits. */ +#define ISDIGIT(Ch) ((unsigned int) (Ch) - '0' <= 9) static char *memcpy_lowcase __P ((char *dest, const char *src, size_t len)); @@ -487,17 +492,19 @@ strftime (s, maxsize, format, tp) #endif /* ! DO_MULTIBYTE */ - /* Check for flags that can modify a number format. */ + /* Check for flags that can modify a format. */ while (1) { switch (*++f) { + /* This influences the number formats. */ case '_': case '-': case '0': pad = *f; continue; + /* This changes textual output. */ case '^': to_uppcase = 1; continue; @@ -510,15 +517,16 @@ strftime (s, maxsize, format, tp) } /* As a GNU extension we allow to specify the field width. */ - if (isdigit (*f)) + if (ISDIGIT (*f)) { width = 0; do { width *= 10; width += *f - '0'; + ++f; } - while (isdigit (*++f)); + while (ISDIGIT (*f)); } /* Check for modifiers. */ diff --git a/time/time.h b/time/time.h index e824e64b9d..d12236fdf2 100644 --- a/time/time.h +++ b/time/time.h @@ -48,8 +48,10 @@ __BEGIN_DECLS /* This is the obsolete POSIX.1-1988 name for the same constant. */ #ifdef __USE_POSIX +#ifndef CLK_TCK #define CLK_TCK CLOCKS_PER_SEC #endif +#endif #endif /* <time.h> included. */ |