aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-09-15 18:53:23 +0400
committerDmitry Antipov2014-09-15 18:53:23 +0400
commitedb0288b83b45d295df52ce7644e897613358971 (patch)
tree8f169c257e9752ca860764cc19ec232d287eb189 /src/process.c
parent497daa12743ed71a70e41f966631d1c8856248cc (diff)
downloademacs-edb0288b83b45d295df52ce7644e897613358971.tar.gz
emacs-edb0288b83b45d295df52ce7644e897613358971.zip
If USE_LOCAL_ALLOCATORS, allocate some Lisp objects on stack.
* lisp.h (local_cons, local_list1, local_list2, local_list3) [USE_LOCAL_ALLOCATORS]: New macros. [!USE_LOCAL_ALLOCATORS]: Fall back to regular functions. (build_local_string): Avoid argument name expansion clash with make_local_string. * alloc.c (toplevel) [USE_LOCAL_ALLOCATORS && GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS]: Preprocessor guard to avoid impossible configuration. * charset.c (Ffind_charset_region, Ffind_charset_string): Use make_local_vector. * lread.c (read1, substitute_object_recurse): Use scoped_cons. * textprop.c (Fput_text_property, Fadd_face_text_property): Use scoped_list2. (copy_text_properties): Use local_cons and local_list3. * chartab.c (uniprop_table): * data.c (wrong_choice, wrong_range): * doc.c (get_doc_string): * editfns.c (format2): * fileio.c (Fexpand_file_name, auto_save_error): * fns.c (Fyes_or_no_p): * font.c (font_parse_xlfd, font_parse_family_registry, font_add_log): * fontset.c (Fset_fontset_font): * keyboard.c (echo_add_key, echo_dash, parse_menu_item) (read_char_minibuf_menu_prompt): * keymap.c (silly_event_symbol_error, describe_vector): * menu.c (single_menu_item): * minibuf.c (Fread_buffer): * process.c (status_message, Fformat_network_address) (server_accept_connection): Use make_local_string and build_local_string. Prefer compound literals where appropriate.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c71
1 files changed, 30 insertions, 41 deletions
diff --git a/src/process.c b/src/process.c
index ef9f295fd89..41ca66671a9 100644
--- a/src/process.c
+++ b/src/process.c
@@ -620,7 +620,7 @@ status_message (struct Lisp_Process *p)
620 if (c1 != c2) 620 if (c1 != c2)
621 Faset (string, make_number (0), make_number (c2)); 621 Faset (string, make_number (0), make_number (c2));
622 } 622 }
623 string2 = build_string (coredump ? " (core dumped)\n" : "\n"); 623 string2 = build_local_string (coredump ? " (core dumped)\n" : "\n");
624 return concat2 (string, string2); 624 return concat2 (string, string2);
625 } 625 }
626 else if (EQ (symbol, Qexit)) 626 else if (EQ (symbol, Qexit))
@@ -630,14 +630,14 @@ status_message (struct Lisp_Process *p)
630 if (code == 0) 630 if (code == 0)
631 return build_string ("finished\n"); 631 return build_string ("finished\n");
632 string = Fnumber_to_string (make_number (code)); 632 string = Fnumber_to_string (make_number (code));
633 string2 = build_string (coredump ? " (core dumped)\n" : "\n"); 633 string2 = build_local_string (coredump ? " (core dumped)\n" : "\n");
634 return concat3 (build_string ("exited abnormally with code "), 634 return concat3 (build_local_string ("exited abnormally with code "),
635 string, string2); 635 string, string2);
636 } 636 }
637 else if (EQ (symbol, Qfailed)) 637 else if (EQ (symbol, Qfailed))
638 { 638 {
639 string = Fnumber_to_string (make_number (code)); 639 string = Fnumber_to_string (make_number (code));
640 string2 = build_string ("\n"); 640 string2 = build_local_string ("\n");
641 return concat3 (build_string ("failed with code "), 641 return concat3 (build_string ("failed with code "),
642 string, string2); 642 string, string2);
643 } 643 }
@@ -1305,22 +1305,22 @@ Returns nil if format of ADDRESS is invalid. */)
1305 1305
1306 if (size == 4 || (size == 5 && !NILP (omit_port))) 1306 if (size == 4 || (size == 5 && !NILP (omit_port)))
1307 { 1307 {
1308 args[0] = build_string ("%d.%d.%d.%d"); 1308 args[0] = build_local_string ("%d.%d.%d.%d");
1309 nargs = 4; 1309 nargs = 4;
1310 } 1310 }
1311 else if (size == 5) 1311 else if (size == 5)
1312 { 1312 {
1313 args[0] = build_string ("%d.%d.%d.%d:%d"); 1313 args[0] = build_local_string ("%d.%d.%d.%d:%d");
1314 nargs = 5; 1314 nargs = 5;
1315 } 1315 }
1316 else if (size == 8 || (size == 9 && !NILP (omit_port))) 1316 else if (size == 8 || (size == 9 && !NILP (omit_port)))
1317 { 1317 {
1318 args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x"); 1318 args[0] = build_local_string ("%x:%x:%x:%x:%x:%x:%x:%x");
1319 nargs = 8; 1319 nargs = 8;
1320 } 1320 }
1321 else if (size == 9) 1321 else if (size == 9)
1322 { 1322 {
1323 args[0] = build_string ("[%x:%x:%x:%x:%x:%x:%x:%x]:%d"); 1323 args[0] = build_local_string ("[%x:%x:%x:%x:%x:%x:%x:%x]:%d");
1324 nargs = 9; 1324 nargs = 9;
1325 } 1325 }
1326 else 1326 else
@@ -1339,16 +1339,12 @@ Returns nil if format of ADDRESS is invalid. */)
1339 args[i+1] = p->contents[i]; 1339 args[i+1] = p->contents[i];
1340 } 1340 }
1341 1341
1342 return Fformat (nargs+1, args); 1342 return Fformat (nargs + 1, args);
1343 } 1343 }
1344 1344
1345 if (CONSP (address)) 1345 if (CONSP (address))
1346 { 1346 return Fformat (2, ((Lisp_Object [])
1347 Lisp_Object args[2]; 1347 { build_local_string ("<Family %d>"), Fcar (address) }));
1348 args[0] = build_string ("<Family %d>");
1349 args[1] = Fcar (address);
1350 return Fformat (2, args);
1351 }
1352 1348
1353 return Qnil; 1349 return Qnil;
1354} 1350}
@@ -4061,20 +4057,14 @@ server_accept_connection (Lisp_Object server, int channel)
4061 { 4057 {
4062 case AF_INET: 4058 case AF_INET:
4063 { 4059 {
4064 Lisp_Object args[5];
4065 unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr; 4060 unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr;
4066 args[0] = build_string ("%d.%d.%d.%d");
4067 args[1] = make_number (*ip++);
4068 args[2] = make_number (*ip++);
4069 args[3] = make_number (*ip++);
4070 args[4] = make_number (*ip++);
4071 host = Fformat (5, args);
4072 service = make_number (ntohs (saddr.in.sin_port));
4073 4061
4074 args[0] = build_string (" <%s:%d>"); 4062 host = Fformat (5, ((Lisp_Object [])
4075 args[1] = host; 4063 { build_local_string ("%d.%d.%d.%d"), make_number (*ip++),
4076 args[2] = service; 4064 make_number (*ip++), make_number (*ip++), make_number (*ip++) }));
4077 caller = Fformat (3, args); 4065 service = make_number (ntohs (saddr.in.sin_port));
4066 caller = Fformat (3, ((Lisp_Object [])
4067 { build_local_string (" <%s:%d>"), host, service }));
4078 } 4068 }
4079 break; 4069 break;
4080 4070
@@ -4084,16 +4074,14 @@ server_accept_connection (Lisp_Object server, int channel)
4084 Lisp_Object args[9]; 4074 Lisp_Object args[9];
4085 uint16_t *ip6 = (uint16_t *)&saddr.in6.sin6_addr; 4075 uint16_t *ip6 = (uint16_t *)&saddr.in6.sin6_addr;
4086 int i; 4076 int i;
4087 args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x"); 4077
4078 args[0] = build_local_string ("%x:%x:%x:%x:%x:%x:%x:%x");
4088 for (i = 0; i < 8; i++) 4079 for (i = 0; i < 8; i++)
4089 args[i+1] = make_number (ntohs (ip6[i])); 4080 args[i + 1] = make_number (ntohs (ip6[i]));
4090 host = Fformat (9, args); 4081 host = Fformat (9, args);
4091 service = make_number (ntohs (saddr.in.sin_port)); 4082 service = make_number (ntohs (saddr.in.sin_port));
4092 4083 caller = Fformat (3, ((Lisp_Object [])
4093 args[0] = build_string (" <[%s]:%d>"); 4084 { build_local_string (" <[%s]:%d>"), host, service }));
4094 args[1] = host;
4095 args[2] = service;
4096 caller = Fformat (3, args);
4097 } 4085 }
4098 break; 4086 break;
4099#endif 4087#endif
@@ -4103,7 +4091,8 @@ server_accept_connection (Lisp_Object server, int channel)
4103#endif 4091#endif
4104 default: 4092 default:
4105 caller = Fnumber_to_string (make_number (connect_counter)); 4093 caller = Fnumber_to_string (make_number (connect_counter));
4106 caller = concat3 (build_string (" <"), caller, build_string (">")); 4094 caller = concat3
4095 (build_local_string (" <"), caller, build_local_string (">"));
4107 break; 4096 break;
4108 } 4097 }
4109 4098
@@ -4202,14 +4191,14 @@ server_accept_connection (Lisp_Object server, int channel)
4202 4191
4203 if (!NILP (ps->log)) 4192 if (!NILP (ps->log))
4204 call3 (ps->log, server, proc, 4193 call3 (ps->log, server, proc,
4205 concat3 (build_string ("accept from "), 4194 concat3 (build_local_string ("accept from "),
4206 (STRINGP (host) ? host : build_string ("-")), 4195 (STRINGP (host) ? host : build_local_string ("-")),
4207 build_string ("\n"))); 4196 build_local_string ("\n")));
4208 4197
4209 exec_sentinel (proc, 4198 exec_sentinel (proc,
4210 concat3 (build_string ("open from "), 4199 concat3 (build_local_string ("open from "),
4211 (STRINGP (host) ? host : build_string ("-")), 4200 (STRINGP (host) ? host : build_local_string ("-")),
4212 build_string ("\n"))); 4201 build_local_string ("\n")));
4213} 4202}
4214 4203
4215/* This variable is different from waiting_for_input in keyboard.c. 4204/* This variable is different from waiting_for_input in keyboard.c.