From: Bruno Haible Date: Fri, 15 Nov 2002 17:23:30 +0000 (+0000) Subject: Update from gnulib. X-Git-Tag: v0.12~1209 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae921b51afb9e7aa84433e16fd0f96d8c74b4657;p=thirdparty%2Fgettext.git Update from gnulib. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 7960cce7a..d29b2b02a 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2002-11-15 Bruno Haible + + * alloca.c: Update from current gnulib version. + * memset.c: Update from current gnulib version. + 2002-11-13 Bruno Haible Assume ANSI C. diff --git a/lib/alloca.c b/lib/alloca.c index 1f6ebbdd4..6ad425a4c 100644 --- a/lib/alloca.c +++ b/lib/alloca.c @@ -21,74 +21,61 @@ allocating any. It is a good idea to use alloca(0) in your main control loop, etc. to force garbage collection. */ -/* Synched up with: FSF 19.30. */ - -/* Authorsip: +#ifdef HAVE_CONFIG_H +# include +#endif - FSF: A long time ago. - Very few changes for XEmacs. - */ +#if HAVE_STRING_H +# include +#endif +#if HAVE_STDLIB_H +# include +#endif -#ifdef HAVE_CONFIG_H -#include +#ifdef emacs +# include "blockinput.h" #endif -/* XEmacs: If compiling with GCC 2, this file is theoretically not needed. - However, alloca() is broken under GCC 2 on many machines: you - cannot put a call to alloca() as part of an argument to a function. - */ +/* If compiling with GCC 2, this file's not needed. */ +#if !defined (__GNUC__) || __GNUC__ < 2 + /* If someone has defined alloca as a macro, there must be some other way alloca is supposed to work. */ -/* XEmacs sometimes uses the C alloca even when a builtin alloca is available, - because it's safer. */ -#if defined (EMACS_WANTS_C_ALLOCA) || (!defined (alloca) && (!defined (__GNUC__) || __GNUC__ < 2)) +# ifndef alloca -#ifdef emacs -#ifdef static +# ifdef emacs +# ifdef static /* actually, only want this if static is defined as "" -- this is for usg, in which emacs must undefine static in order to make unexec workable */ -#ifndef STACK_DIRECTION +# ifndef STACK_DIRECTION you lose -- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ +# endif /* STACK_DIRECTION undefined */ +# endif /* static */ +# endif /* emacs */ /* If your stack is a linked list of frames, you have to provide an "address metric" ADDRESS_FUNCTION macro. */ -#if defined (CRAY) && defined (CRAY_STACKSEG_END) +# if defined (CRAY) && defined (CRAY_STACKSEG_END) long i00afunc (); -#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -#else -#define ADDRESS_FUNCTION(arg) &(arg) -#endif +# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) +# else +# define ADDRESS_FUNCTION(arg) &(arg) +# endif -#ifdef __STDC__ /* XEmacs change */ +# if __STDC__ typedef void *pointer; -#else +# else typedef char *pointer; -#endif - -/* XEmacs: With ERROR_CHECK_MALLOC defined, there is no xfree -- it's - a macro that does some stuff to try and trap invalid frees, - and then calls xfree_1 to actually do the work. */ - -#ifdef emacs -# ifdef ERROR_CHECK_MALLOC -void xfree_1 (pointer); -# define xfree xfree_1 -# else -void xfree (pointer); -# endif -#endif +# endif -#ifndef WINDOWSNT -#define NULL 0 -#endif +# ifndef NULL +# define NULL 0 +# endif /* Different portions of Emacs need to call different versions of malloc. The Emacs executable needs alloca to call xmalloc, because @@ -96,18 +83,15 @@ void xfree (pointer); hand, the utilities in lib-src need alloca to call malloc; some of them are very simple, and don't have an xmalloc routine. - Non-Emacs programs expect this to call use xmalloc. + Non-Emacs programs expect this to call xmalloc. Callers below should use malloc. */ -#ifndef emacs -#define malloc xmalloc -#endif -#ifndef WINDOWSNT +# ifndef emacs +# undef malloc +# define malloc xmalloc +# endif extern pointer malloc (); -#else -extern void *malloc(); -#endif /* Define STACK_DIRECTION if you know the direction of stack growth for your system; otherwise it will be automatically @@ -117,18 +101,18 @@ extern void *malloc(); STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* Direction unknown. */ -#endif +# ifndef STACK_DIRECTION +# define STACK_DIRECTION 0 /* Direction unknown. */ +# endif -#if STACK_DIRECTION != 0 +# if STACK_DIRECTION != 0 -#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ +# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ -#else /* STACK_DIRECTION == 0; need run-time code. */ +# else /* STACK_DIRECTION == 0; need run-time code. */ static int stack_dir; /* 1 or -1 once known. */ -#define STACK_DIR stack_dir +# define STACK_DIR stack_dir static void find_stack_direction () @@ -152,7 +136,7 @@ find_stack_direction () } } -#endif /* STACK_DIRECTION == 0 */ +# endif /* STACK_DIRECTION == 0 */ /* An "alloca header" is used to: (a) chain together all alloca'ed blocks; @@ -161,9 +145,9 @@ find_stack_direction () It is very important that sizeof(header) agree with malloc alignment chunk size. The following default should work okay. */ -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif +# ifndef ALIGN_SIZE +# define ALIGN_SIZE sizeof(double) +# endif typedef union hdr { @@ -185,26 +169,26 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */ implementations of C, for example under Gould's UTX/32. */ pointer -#ifdef EMACS_WANTS_C_ALLOCA -c_alloca (unsigned size) -#else -alloca (unsigned size) -#endif +alloca (size_t size) { auto char probe; /* Probes stack depth: */ register char *depth = ADDRESS_FUNCTION (probe); -#if STACK_DIRECTION == 0 +# if STACK_DIRECTION == 0 if (STACK_DIR == 0) /* Unknown growth direction. */ find_stack_direction (); -#endif +# endif /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ + was allocated from deeper in the stack than currently. */ { register header *hp; /* Traverses linked list. */ +# ifdef emacs + BLOCK_INPUT; +# endif + for (hp = last_alloca_header; hp != NULL;) if ((STACK_DIR > 0 && hp->h.deep > depth) || (STACK_DIR < 0 && hp->h.deep < depth)) @@ -219,6 +203,10 @@ alloca (unsigned size) break; /* Rest are not deeper. */ last_alloca_header = hp; /* -> last valid storage. */ + +# ifdef emacs + UNBLOCK_INPUT; +# endif } if (size == 0) @@ -230,6 +218,9 @@ alloca (unsigned size) register pointer new = malloc (sizeof (header) + size); /* Address of header. */ + if (new == 0) + abort(); + ((header *) new)->h.next = last_alloca_header; ((header *) new)->h.deep = depth; @@ -241,15 +232,15 @@ alloca (unsigned size) } } -#if defined (CRAY) && defined (CRAY_STACKSEG_END) +# if defined (CRAY) && defined (CRAY_STACKSEG_END) -#ifdef DEBUG_I00AFUNC -#include -#endif +# ifdef DEBUG_I00AFUNC +# include +# endif -#ifndef CRAY_STACK -#define CRAY_STACK -#ifndef CRAY2 +# ifndef CRAY_STACK +# define CRAY_STACK +# ifndef CRAY2 /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ struct stack_control_header { @@ -301,7 +292,7 @@ struct stack_segment_linkage long sss7; }; -#else /* CRAY2 */ +# else /* CRAY2 */ /* The following structure defines the vector of words returned by the STKSTAT library routine. */ struct stk_stat @@ -354,12 +345,12 @@ struct stk_trailer long unknown14; }; -#endif /* CRAY2 */ -#endif /* not CRAY_STACK */ +# endif /* CRAY2 */ +# endif /* not CRAY_STACK */ -#ifdef CRAY2 +# ifdef CRAY2 /* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ + I doubt that "lint" will like this much. */ static long i00afunc (long *address) @@ -428,7 +419,7 @@ i00afunc (long *address) return (result); } -#else /* not CRAY2 */ +# else /* not CRAY2 */ /* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. Determine the number of the cell within the stack, given the address of the cell. The purpose of this @@ -473,9 +464,9 @@ i00afunc (long address) while (!(this_segment <= address && address <= stkl)) { -#ifdef DEBUG_I00AFUNC +# ifdef DEBUG_I00AFUNC fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -#endif +# endif if (pseg == 0) break; stkl = stkl - pseg; @@ -494,9 +485,9 @@ i00afunc (long address) while (pseg != 0) { -#ifdef DEBUG_I00AFUNC +# ifdef DEBUG_I00AFUNC fprintf (stderr, "%011o %011o\n", pseg, size); -#endif +# endif stkl = stkl - pseg; ssptr = (struct stack_segment_linkage *) stkl; size = ssptr->sssize; @@ -506,7 +497,8 @@ i00afunc (long address) return (result); } -#endif /* not CRAY2 */ -#endif /* CRAY */ +# endif /* not CRAY2 */ +# endif /* CRAY */ -#endif /* complicated expression at top of file */ +# endif /* no alloca */ +#endif /* not GCC version 2 */ diff --git a/lib/memset.c b/lib/memset.c index 5e090b1ac..5744bcbf7 100644 --- a/lib/memset.c +++ b/lib/memset.c @@ -1,5 +1,5 @@ /* memset.c -- set an area of memory to a given value - Copyright (C) 1991, 2002 Free Software Foundation, Inc. + Copyright (C) 1991 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ char * -memset (char *str, int c, unsigned len) +memset (char *str, int c, unsigned int len) { register char *st = str;