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