[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/lisp.h [emacs-unicode-2]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/src/lisp.h [emacs-unicode-2] |
Date: |
Tue, 29 Jun 2004 13:08:09 -0400 |
Index: emacs/src/lisp.h
diff -c emacs/src/lisp.h:1.465.2.7 emacs/src/lisp.h:1.465.2.8
*** emacs/src/lisp.h:1.465.2.7 Mon Jun 28 07:29:21 2004
--- emacs/src/lisp.h Tue Jun 29 16:46:03 2004
***************
*** 1203,1209 ****
{
int type : 16; /* = Lisp_Misc_Save_Value */
unsigned gcmarkbit : 1;
! int spacer : 15;
void *pointer;
int integer;
};
--- 1203,1212 ----
{
int type : 16; /* = Lisp_Misc_Save_Value */
unsigned gcmarkbit : 1;
! int spacer : 14;
! /* If DOGC is set, POINTER is the address of a memory
! area containing INTEGER potential Lisp_Objects. */
! unsigned int dogc : 1;
void *pointer;
int integer;
};
***************
*** 2498,2503 ****
--- 2501,2507 ----
extern void display_malloc_warning P_ ((void));
extern int inhibit_garbage_collection P_ ((void));
extern Lisp_Object make_save_value P_ ((void *, int));
+ extern void free_misc P_ ((Lisp_Object));
extern void free_marker P_ ((Lisp_Object));
extern void free_cons P_ ((struct Lisp_Cons *));
extern void init_alloc_once P_ ((void));
***************
*** 3290,3295 ****
--- 3294,3357 ----
: Fcons ((el), (check)))))
+ /* SAFE_ALLOCA normally allocates memory on the stack, but if size is
+ larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */
+
+ #define MAX_ALLOCA 16*1024
+
+ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
+
+ #define USE_SAFE_ALLOCA \
+ int sa_count = SPECPDL_INDEX ()
+
+ /* SAFE_ALLOCA allocates a simple buffer. */
+
+ #define SAFE_ALLOCA(buf, type, size) \
+ do { \
+ if ((size) < MAX_ALLOCA) \
+ buf = (type) alloca (size); \
+ else \
+ { \
+ buf = (type) xmalloc (size); \
+ record_unwind_protect (safe_alloca_unwind, \
+ make_save_value (buf, 0)); \
+ } \
+ } while (0)
+
+ /* SAFE_FREE frees xmalloced memory and enables GC as needed. */
+
+ #define SAFE_FREE(size) \
+ do { \
+ if ((size) >= MAX_ALLOCA) \
+ unbind_to (sa_count, Qnil); \
+ } while (0)
+
+
+ /* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */
+
+ #define SAFE_ALLOCA_LISP(buf, nelt) \
+ do { \
+ int size_ = (nelt) * sizeof (Lisp_Object); \
+ if (size_ < MAX_ALLOCA) \
+ buf = (Lisp_Object *) alloca (size_); \
+ else \
+ { \
+ Lisp_Object arg_; \
+ buf = (Lisp_Object *) xmalloc (size_); \
+ arg_ = make_save_value (buf, nelt); \
+ XSAVE_VALUE (arg_)->dogc = 1; \
+ record_unwind_protect (safe_alloca_unwind, arg_); \
+ } \
+ } while (0)
+
+ #define SAFE_FREE_LISP(nelt) \
+ do { \
+ if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \
+ unbind_to (sa_count, Qnil); \
+ } while (0)
+
+
+
#endif /* EMACS_LISP_H */
/* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e