diff options
| author | Paul Eggert | 2014-09-29 19:43:23 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-09-29 19:43:23 -0700 |
| commit | dc4525691c2c236abdb6c074438223413f80091c (patch) | |
| tree | 86305e7415bcf1b5cc6ddad6879e922f9e5e163c /src/xterm.c | |
| parent | a19f0977a96ee74b96410b41a8ea793c86f64b58 (diff) | |
| download | emacs-dc4525691c2c236abdb6c074438223413f80091c.tar.gz emacs-dc4525691c2c236abdb6c074438223413f80091c.zip | |
Simplify stack-allocated Lisp objects, and make them more portable.
The build_local_string macro was used in two ways: (1) string
literals for which scoped allocation suffices, and (2) file name
components, where it's not safe in general to assume bounded-size
ASCII data. Simplify by defining a new macro SCOPED_STRING that
allocates a block-scope string, and by using SCOPED_STRING for (1)
and build_string for (2). Furthermore, actually use stack
allocation only for objects known to have sufficient alignment.
This simpler implementation means Emacs can make
USE_STACK_LISP_OBJECTS the default unless GC_MARK_STACK !=
GC_MAKE_GCPROS_NOOPS.
* lisp.h (GCALIGNED): Align even if !USE_STACK_LISP_OBJECTS,
for fewer differences among implementations.
(struct Lisp_String): Now GCALIGNED.
(USE_STACK_LISP_OBJECTS): Default to true, since the
implementation no longer insists on a nonempty GCALIGNED.
But make it false if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS.
(SCOPED_CONS_INITIALIZER): Remove, since it's no longer needed
separately. Move definiens to scoped_cons. The old definition
was incorrect when GCALIGNED was defined to be empty.
(union Aligned_String): New type.
(USE_STACK_CONS, USE_STACK_STRING): New constants, so that the
implementation ports to compilers that don't align strictly enough.
Don't worry about the union sizes; it's not worth bothering about.
(scoped_cons, scoped_list1, scoped_list3, scoped_list4):
Rewrite using USE_STACK_CONS.
(scoped_cons): Assume the use of union Aligned_Cons.
(lisp_string_size, make_local_string, build_local_string): Remove.
Unless otherwise specified, all callers of build_local_string
changed to use SCOPED_STRING.
(SCOPED_STRING): New macro.
* data.c (wrong_choice):
* menu.c (single_menu_item):
* process.c (Fformat_network_address):
Hoist use of SCOPED_STRING out of a scope, so that its returned
object lives long enough.
* fileio.c (Fexpand_file_name): Use build_string, not SCOPED_STRING,
as the string might be long or might not be ASCII.
Diffstat (limited to 'src/xterm.c')
| -rw-r--r-- | src/xterm.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/xterm.c b/src/xterm.c index 8d52b2a2815..8a0e28a2e1a 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -10937,8 +10937,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10937 | { | 10937 | { |
| 10938 | Lisp_Object value; | 10938 | Lisp_Object value; |
| 10939 | value = display_x_get_resource | 10939 | value = display_x_get_resource |
| 10940 | (dpyinfo, build_local_string ("privateColormap"), | 10940 | (dpyinfo, SCOPED_STRING ("privateColormap"), |
| 10941 | build_local_string ("PrivateColormap"), Qnil, Qnil); | 10941 | SCOPED_STRING ("PrivateColormap"), Qnil, Qnil); |
| 10942 | if (STRINGP (value) | 10942 | if (STRINGP (value) |
| 10943 | && (!strcmp (SSDATA (value), "true") | 10943 | && (!strcmp (SSDATA (value), "true") |
| 10944 | || !strcmp (SSDATA (value), "on"))) | 10944 | || !strcmp (SSDATA (value), "on"))) |
| @@ -11146,8 +11146,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 11146 | for debugging X code. */ | 11146 | for debugging X code. */ |
| 11147 | { | 11147 | { |
| 11148 | Lisp_Object value = display_x_get_resource | 11148 | Lisp_Object value = display_x_get_resource |
| 11149 | (dpyinfo, build_local_string ("synchronous"), | 11149 | (dpyinfo, SCOPED_STRING ("synchronous"), |
| 11150 | build_local_string ("Synchronous"), Qnil, Qnil); | 11150 | SCOPED_STRING ("Synchronous"), Qnil, Qnil); |
| 11151 | if (STRINGP (value) | 11151 | if (STRINGP (value) |
| 11152 | && (!strcmp (SSDATA (value), "true") | 11152 | && (!strcmp (SSDATA (value), "true") |
| 11153 | || !strcmp (SSDATA (value), "on"))) | 11153 | || !strcmp (SSDATA (value), "on"))) |
| @@ -11156,8 +11156,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 11156 | 11156 | ||
| 11157 | { | 11157 | { |
| 11158 | Lisp_Object value = display_x_get_resource | 11158 | Lisp_Object value = display_x_get_resource |
| 11159 | (dpyinfo, build_local_string ("useXIM"), | 11159 | (dpyinfo, SCOPED_STRING ("useXIM"), |
| 11160 | build_local_string ("UseXIM"), Qnil, Qnil); | 11160 | SCOPED_STRING ("UseXIM"), Qnil, Qnil); |
| 11161 | #ifdef USE_XIM | 11161 | #ifdef USE_XIM |
| 11162 | if (STRINGP (value) | 11162 | if (STRINGP (value) |
| 11163 | && (!strcmp (SSDATA (value), "false") | 11163 | && (!strcmp (SSDATA (value), "false") |