comparison src/alloca.c @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents 375f2633d815
children
comparison
equal deleted inserted replaced
89908:ee1402f7b568 89909:68c22ea6027c
34 #ifdef HAVE_STDLIB_H 34 #ifdef HAVE_STDLIB_H
35 # include <stdlib.h> 35 # include <stdlib.h>
36 #endif 36 #endif
37 37
38 #ifdef DO_BLOCK_INPUT 38 #ifdef DO_BLOCK_INPUT
39 # include "lisp.h"
40 # include "blockinput.h" 39 # include "blockinput.h"
41 #endif 40 #endif
42 41
43 /* If compiling with GCC 2, this file's not needed. */ 42 /* If compiling with GCC 2, this file's not needed. */
44 #if !defined (__GNUC__) || __GNUC__ < 2 43 #if !defined (__GNUC__) || __GNUC__ < 2
56 # ifndef STACK_DIRECTION 55 # ifndef STACK_DIRECTION
57 you 56 you
58 lose 57 lose
59 -- must know STACK_DIRECTION at compile-time 58 -- must know STACK_DIRECTION at compile-time
60 /* Using #error here is not wise since this file should work for 59 /* Using #error here is not wise since this file should work for
61 old and obscure compilers. */ 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 */
62 # endif /* STACK_DIRECTION undefined */ 64 # endif /* STACK_DIRECTION undefined */
63 # endif /* static */ 65 # endif /* static */
64 # endif /* emacs */ 66 # endif /* emacs */
65 67
66 /* If your stack is a linked list of frames, you have to 68 /* If your stack is a linked list of frames, you have to
71 # define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) 73 # define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
72 # else 74 # else
73 # define ADDRESS_FUNCTION(arg) &(arg) 75 # define ADDRESS_FUNCTION(arg) &(arg)
74 # endif 76 # endif
75 77
76 # ifdef POINTER_TYPE 78 # ifndef POINTER_TYPE
79 # ifdef __STDC__
80 # define POINTER_TYPE void
81 # else
82 # define POINTER_TYPE char
83 # endif
84 # endif
77 typedef POINTER_TYPE *pointer; 85 typedef POINTER_TYPE *pointer;
78 # else /* not POINTER_TYPE */
79 # if __STDC__
80 typedef void *pointer;
81 # else /* not __STDC__ */
82 typedef char *pointer;
83 # endif /* not __STDC__ */
84 # endif /* not POINTER_TYPE */
85 86
86 # ifndef NULL 87 # ifndef NULL
87 # define NULL 0 88 # define NULL 0
88 # endif 89 # endif
89 90
90 /* Different portions of Emacs need to call different versions of 91 /* The Emacs executable needs alloca to call xmalloc, because ordinary
91 malloc. The Emacs executable needs alloca to call xmalloc, because 92 malloc isn't protected from input signals. xmalloc also checks for
92 ordinary malloc isn't protected from input signals. On the other 93 out-of-memory errors, so we should use it generally.
93 hand, the utilities in lib-src need alloca to call malloc; some of
94 them are very simple, and don't have an xmalloc routine.
95
96 Non-Emacs programs expect this to call xmalloc.
97 94
98 Callers below should use malloc. */ 95 Callers below should use malloc. */
99 96
100 # ifdef emacs 97 # undef malloc
101 # undef malloc 98 # define malloc xmalloc
102 # define malloc xmalloc 99 # undef free
103 # ifdef EMACS_FREE 100 # define free xfree
104 # define free EMACS_FREE 101
105 # endif 102 void *xmalloc _P ((size_t));
106 # endif 103 void xfree _P ((void *));
107 extern pointer malloc ();
108 104
109 /* Define STACK_DIRECTION if you know the direction of stack 105 /* Define STACK_DIRECTION if you know the direction of stack
110 growth for your system; otherwise it will be automatically 106 growth for your system; otherwise it will be automatically
111 deduced at run-time. 107 deduced at run-time.
112 108
227 return NULL; /* No allocation required. */ 223 return NULL; /* No allocation required. */
228 224
229 /* Allocate combined header + user data storage. */ 225 /* Allocate combined header + user data storage. */
230 226
231 { 227 {
228 /* Address of header. */
232 register pointer new = malloc (sizeof (header) + size); 229 register pointer new = malloc (sizeof (header) + size);
233 /* Address of header. */
234 230
235 if (new == 0) 231 if (new == 0)
236 abort(); 232 abort();
237 233
238 ((header *) new)->h.next = last_alloca_header; 234 ((header *) new)->h.next = last_alloca_header;
514 # endif /* not CRAY2 */ 510 # endif /* not CRAY2 */
515 # endif /* CRAY */ 511 # endif /* CRAY */
516 512
517 # endif /* no alloca */ 513 # endif /* no alloca */
518 #endif /* not GCC version 2 */ 514 #endif /* not GCC version 2 */
515
516 /* arch-tag: 5c9901c8-3cd4-453e-bd66-d9035a175ee3
517 (do not change this comment) */