OSDN Git Service

(__va_copy): New definition.
[pf3gnuchains/gcc-fork.git] / gcc / alloca.c
index 16f19a2..8f98b73 100644 (file)
    your main control loop, etc. to force garbage collection.  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-/* If compiling with GCC, this file's not needed.  */
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef emacs
+#include "blockinput.h"
+#endif
+
+/* 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.  */
 #ifndef alloca
 
 #ifdef emacs
@@ -58,7 +73,9 @@ typedef void *pointer;
 typedef char *pointer;
 #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
@@ -163,11 +180,15 @@ alloca (size)
 #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))
@@ -182,6 +203,10 @@ alloca (size)
        break;                  /* Rest are not deeper.  */
 
     last_alloca_header = hp;   /* -> last valid storage.  */
+
+#ifdef emacs
+    UNBLOCK_INPUT;
+#endif
   }
 
   if (size == 0)
@@ -193,6 +218,9 @@ alloca (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;
 
@@ -322,7 +350,7 @@ struct stk_trailer
 
 #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)
@@ -473,3 +501,4 @@ i00afunc (long address)
 #endif /* CRAY */
 
 #endif /* no alloca */
+#endif /* not GCC version 2 */