Show
Ignore:
Timestamp:
11/21/04 09:53:25 (4 years ago)
Author:
miyoshi
Message:

* abbrev.c: Sync up with Emacs CVS HEAD.

* acldef.h: Ditto.

* alloca.c: Ditto.

* atimer.c: Ditto.

* atimer.h: Ditto.

* blockinput.h: Ditto.

* buffer.c: Ditto.

* buffer.h: Ditto.

* bytecode.c: Ditto.

* editfns.c: Ditto.

* fileio.c: Ditto.

* lisp.h: Update declarations.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.2/src/alloca.c

    r3104 r3553  
    11/* alloca.c -- allocate automatically reclaimed memory 
    22   (Mostly) portable public-domain implementation -- D A Gwyn 
     3 
     4   NOTE: The canonical source of this file is maintained with gnulib. 
     5   Bugs can be reported to bug-gnulib@gnu.org. 
    36 
    47   This implementation of the PWB library alloca function, 
     
    2326 
    2427#ifdef HAVE_CONFIG_H 
    25 #include <config.h> 
     28# include <config.h> 
    2629#endif 
    2730 
    2831#ifdef HAVE_STRING_H 
    29 #include <string.h> 
     32# include <string.h> 
    3033#endif 
    3134#ifdef HAVE_STDLIB_H 
    32 #include <stdlib.h> 
     35# include <stdlib.h> 
    3336#endif 
    3437 
    35 #ifdef emacs 
    36 #include "lisp.h" 
    37 #include "blockinput.h" 
     38#ifdef DO_BLOCK_INPUT 
     39# include "blockinput.h" 
    3840#endif 
    3941 
     
    4345/* If someone has defined alloca as a macro, 
    4446   there must be some other way alloca is supposed to work.  */ 
    45 #ifndef alloca 
    46  
    47 #ifdef emacs 
    48 #ifdef static 
     47# ifndef alloca 
     48 
     49#  ifdef emacs 
     50#   ifdef static 
    4951/* actually, only want this if static is defined as "" 
    5052   -- this is for usg, in which emacs must undefine static 
    5153   in order to make unexec workable 
    5254   */ 
    53 #ifndef STACK_DIRECTION 
    54   #error "Must know STACK_DIRECTION at compile-time" 
    55 #endif /* STACK_DIRECTION undefined */ 
    56 #endif /* static */ 
    57 #endif /* emacs */ 
     55#    ifndef STACK_DIRECTION 
     56you 
     57lose 
     58-- must know STACK_DIRECTION at compile-time 
     59/* Using #error here is not wise since this file should work for 
     60   old and obscure compilers.   
     61 
     62   As far as I know, using it is OK if it's indented -- at least for 
     63   pcc-based processors.  -- fx */ 
     64#    endif /* STACK_DIRECTION undefined */ 
     65#   endif /* static */ 
     66#  endif /* emacs */ 
    5867 
    5968/* If your stack is a linked list of frames, you have to 
    6069   provide an "address metric" ADDRESS_FUNCTION macro.  */ 
    6170 
    62 #if defined (CRAY) && defined (CRAY_STACKSEG_END) 
     71#  if defined (CRAY) && defined (CRAY_STACKSEG_END) 
    6372long i00afunc (); 
    64 #define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) 
    65 #else 
    66 #define ADDRESS_FUNCTION(arg) &(arg) 
    67 #endif 
    68  
    69 #ifdef POINTER_TYPE 
     73#   define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) 
     74#  else 
     75#   define ADDRESS_FUNCTION(arg) &(arg) 
     76#  endif 
     77 
     78#  ifndef POINTER_TYPE 
     79#   ifdef __STDC__ 
     80#    define POINTER_TYPE void 
     81#   else 
     82#    define POINTER_TYPE char 
     83#   endif 
     84#  endif 
    7085typedef POINTER_TYPE *pointer; 
    71 #else 
    72 #if __STDC__ 
    73 typedef void *pointer; 
    74 #else 
    75 typedef char *pointer; 
    76 #endif /*__STDC__*/ 
    77 #endif /*POINTER_TYPE*/ 
    78  
    79  
    80 #ifndef NULL 
    81 #define NULL    0 
    82 #endif 
    83  
    84 /* Different portions of Emacs need to call different versions of 
    85    malloc.  The Emacs executable needs alloca to call xmalloc, because 
    86    ordinary malloc isn't protected from input signals.  On the other 
    87    hand, the utilities in lib-src need alloca to call malloc; some of 
    88    them are very simple, and don't have an xmalloc routine. 
    89  
    90    Non-Emacs programs expect this to call use xmalloc. 
     86 
     87#  ifndef NULL 
     88#   define NULL 0 
     89#  endif 
     90 
     91/* The Emacs executable needs alloca to call xmalloc, because ordinary 
     92   malloc isn't protected from input signals.  xmalloc also checks for 
     93   out-of-memory errors, so we should use it generally. 
    9194 
    9295   Callers below should use malloc.  */ 
    9396 
    94 #ifdef emacs 
    95 #define malloc xmalloc 
    96 #ifdef EMACS_FREE 
    97 #define free EMACS_FREE 
    98 #endif 
    99 #endif 
    100 extern pointer malloc (); 
     97#  undef malloc 
     98#  define malloc xmalloc 
     99#  undef free 
     100#  define free xfree 
     101 
     102void *xmalloc _P ((size_t)); 
     103void xfree _P ((void *)); 
    101104 
    102105/* Define STACK_DIRECTION if you know the direction of stack 
     
    108111   STACK_DIRECTION = 0 => direction of growth unknown  */ 
    109112 
    110 #ifndef STACK_DIRECTION 
    111 #define        STACK_DIRECTION        0       /* Direction unknown.  */ 
    112 #endif 
    113  
    114 #if STACK_DIRECTION != 0 
    115  
    116 #define        STACK_DIR      STACK_DIRECTION /* Known at compile-time.  */ 
    117  
    118 #else /* STACK_DIRECTION == 0; need run-time code.  */ 
     113#  ifndef STACK_DIRECTION 
     114#   define STACK_DIRECTION    0       /* Direction unknown.  */ 
     115#  endif 
     116 
     117#  if STACK_DIRECTION != 0 
     118 
     119#   define STACK_DIR  STACK_DIRECTION /* Known at compile-time.  */ 
     120 
     121#  else /* STACK_DIRECTION == 0; need run-time code.  */ 
    119122 
    120123static int stack_dir;           /* 1 or -1 once known.  */ 
    121 #define        STACK_DIR      stack_dir 
     124#   define STACK_DIR  stack_dir 
    122125 
    123126static void 
     
    143146} 
    144147 
    145 #endif /* STACK_DIRECTION == 0 */ 
     148#  endif /* STACK_DIRECTION == 0 */ 
    146149 
    147150/* An "alloca header" is used to: 
     
    152155   alignment chunk size.  The following default should work okay.  */ 
    153156 
    154 #ifndef       ALIGN_SIZE 
    155 #define        ALIGN_SIZE     sizeof(double) 
    156 #endif 
     157#  ifndef     ALIGN_SIZE 
     158#   define ALIGN_SIZE sizeof(double) 
     159#  endif 
    157160 
    158161typedef union hdr 
     
    177180pointer 
    178181alloca (size) 
    179      unsigned size; 
     182     size_t size; 
    180183{ 
    181184  auto char probe;              /* Probes stack depth: */ 
    182185  register char *depth = ADDRESS_FUNCTION (probe); 
    183186 
    184 #if STACK_DIRECTION == 0 
     187#  if STACK_DIRECTION == 0 
    185188  if (STACK_DIR == 0)           /* Unknown growth direction.  */ 
    186189    find_stack_direction (); 
    187 #endif 
     190#  endif 
    188191 
    189192  /* Reclaim garbage, defined as all alloca'd storage that 
     
    193196    register header *hp;        /* Traverses linked list.  */ 
    194197 
    195 #ifdef emacs 
     198#  ifdef DO_BLOCK_INPUT 
    196199    BLOCK_INPUT; 
    197 #endif 
     200#  endif 
    198201 
    199202    for (hp = last_alloca_header; hp != NULL;) 
     
    212215    last_alloca_header = hp;    /* -> last valid storage.  */ 
    213216 
    214 #ifdef emacs 
     217#  ifdef DO_BLOCK_INPUT 
    215218    UNBLOCK_INPUT; 
    216 #endif 
     219#  endif 
    217220  } 
    218221 
     
    223226 
    224227  { 
     228    /* Address of header.  */ 
    225229    register pointer new = malloc (sizeof (header) + size); 
    226     /* Address of header.  */ 
    227230 
    228231    if (new == 0) 
     
    240243} 
    241244 
    242 #if defined (CRAY) && defined (CRAY_STACKSEG_END) 
    243  
    244 #ifdef DEBUG_I00AFUNC 
    245 #include <stdio.h> 
    246 #endif 
    247  
    248 #ifndef CRAY_STACK 
    249 #define CRAY_STACK 
    250 #ifndef CRAY2 
     245#  if defined (CRAY) && defined (CRAY_STACKSEG_END) 
     246 
     247#   ifdef DEBUG_I00AFUNC 
     248#    include <stdio.h> 
     249#   endif 
     250 
     251#   ifndef CRAY_STACK 
     252#    define CRAY_STACK 
     253#    ifndef CRAY2 
    251254/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ 
    252255struct stack_control_header 
     
    300303  }; 
    301304 
    302 #else /* CRAY2 */ 
     305#    else /* CRAY2 */ 
    303306/* The following structure defines the vector of words 
    304307   returned by the STKSTAT library routine.  */ 
     
    353356  }; 
    354357 
    355 #endif /* CRAY2 */ 
    356 #endif /* not CRAY_STACK */ 
    357  
    358 #ifdef CRAY2 
     358#    endif /* CRAY2 */ 
     359#   endif /* not CRAY_STACK */ 
     360 
     361#   ifdef CRAY2 
    359362/* Determine a "stack measure" for an arbitrary ADDRESS. 
    360363   I doubt that "lint" will like this much.  */ 
     
    427430} 
    428431 
    429 #else /* not CRAY2 */ 
     432#   else /* not CRAY2 */ 
    430433/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. 
    431434   Determine the number of the cell within the stack, 
     
    472475  while (!(this_segment <= address && address <= stkl)) 
    473476    { 
    474 #ifdef DEBUG_I00AFUNC 
     477#    ifdef DEBUG_I00AFUNC 
    475478      fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); 
    476 #endif 
     479#    endif 
    477480      if (pseg == 0) 
    478481        break; 
     
    493496  while (pseg != 0) 
    494497    { 
    495 #ifdef DEBUG_I00AFUNC 
     498#    ifdef DEBUG_I00AFUNC 
    496499      fprintf (stderr, "%011o %011o\n", pseg, size); 
    497 #endif 
     500#    endif 
    498501      stkl = stkl - pseg; 
    499502      ssptr = (struct stack_segment_linkage *) stkl; 
     
    505508} 
    506509 
    507 #endif /* not CRAY2 */ 
    508 #endif /* CRAY */ 
    509  
    510 #endif /* no alloca */ 
     510#   endif /* not CRAY2 */ 
     511#  endif /* CRAY */ 
     512 
     513# endif /* no alloca */ 
    511514#endif /* not GCC version 2 */ 
     515 
     516/* arch-tag: 5c9901c8-3cd4-453e-bd66-d9035a175ee3 
     517   (do not change this comment) */