aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2016-02-23 09:42:05 -0800
committerPaul Eggert2016-02-23 09:42:28 -0800
commit82848cf689c24a8bc635449846250ea6edb757c4 (patch)
tree4263b19e46cf62711d40ec14ccd3173225d48f2a /src
parentf4152efd2f7db87134e5e1c50e312a431e81db23 (diff)
downloademacs-82848cf689c24a8bc635449846250ea6edb757c4.tar.gz
emacs-82848cf689c24a8bc635449846250ea6edb757c4.zip
Minor cleanups for async DNS etc.
* src/frame.h (FRAME_WINDOW_CONFIGURATION_CHANGED): Omit unnecessary parens. * src/gnutls.c (gnutls_try_handshake, emacs_gnutls_deinit) (gnutls_verify_boot): Use bool for boolean. (ATTRIBUTE_FORMAT_PRINTF): Add printf attribute. * src/process.c (free_dns_request, Fmake_network_process): Allocate and free async request control block all in one go. (set_network_socket_coding_system, finish_after_tls_connection) (connect_network_socket): Now static. (conv_numerical_to_lisp): 2nd arg is now int, not unsigned. (Fmake_network_process): Use list1 for brevity. (wait_for_socket_fds): 2nd arg is now const ptr. * src/process.h (struct Lisp_Process.dns_request): Now struct gaicb *, not struct gaicb **, since there was always exactly one. All uses changed. * src/window.c, src/window.h (run_window_configuration_change_hook): Now static.
Diffstat (limited to 'src')
-rw-r--r--src/frame.h2
-rw-r--r--src/gnutls.c55
-rw-r--r--src/process.c233
-rw-r--r--src/process.h2
-rw-r--r--src/window.c13
-rw-r--r--src/window.h1
6 files changed, 146 insertions, 160 deletions
diff --git a/src/frame.h b/src/frame.h
index d9424ab5965..b83820a2084 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -832,7 +832,7 @@ default_pixels_per_inch_y (void)
832/* True if the frame's window configuration has changed since last call 832/* True if the frame's window configuration has changed since last call
833 of run_window_size_change_functions. */ 833 of run_window_size_change_functions. */
834#define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \ 834#define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
835 ((f)->window_configuration_changed) 835 (f)->window_configuration_changed
836 836
837/* The minibuffer window of frame F, if it has one; otherwise nil. */ 837/* The minibuffer window of frame F, if it has one; otherwise nil. */
838#define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window 838#define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
diff --git a/src/gnutls.c b/src/gnutls.c
index ce4fbf9b7ef..d1b34c5bf7f 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -409,13 +409,13 @@ gnutls_try_handshake (struct Lisp_Process *proc)
409 emacs_gnutls_handle_error (state, ret); 409 emacs_gnutls_handle_error (state, ret);
410 QUIT; 410 QUIT;
411 } 411 }
412 while (ret < 0 && gnutls_error_is_fatal (ret) == 0 && 412 while (ret < 0 && gnutls_error_is_fatal (ret) == 0
413 ! proc->is_non_blocking_client); 413 && ! proc->is_non_blocking_client);
414 414
415 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; 415 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
416 416
417 if (proc->is_non_blocking_client) 417 if (proc->is_non_blocking_client)
418 proc->gnutls_p = 1; 418 proc->gnutls_p = true;
419 419
420 if (ret == GNUTLS_E_SUCCESS) 420 if (ret == GNUTLS_E_SUCCESS)
421 { 421 {
@@ -424,7 +424,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
424 } 424 }
425 else 425 else
426 { 426 {
427 //check_memory_full (gnutls_alert_send_appropriate (state, ret)); 427 /* check_memory_full (gnutls_alert_send_appropriate (state, ret)); */
428 } 428 }
429 return ret; 429 return ret;
430} 430}
@@ -650,7 +650,7 @@ emacs_gnutls_deinit (Lisp_Object proc)
650 650
651 CHECK_PROCESS (proc); 651 CHECK_PROCESS (proc);
652 652
653 if (XPROCESS (proc)->gnutls_p == 0) 653 if (! XPROCESS (proc)->gnutls_p)
654 return Qnil; 654 return Qnil;
655 655
656 log_level = XPROCESS (proc)->gnutls_log_level; 656 log_level = XPROCESS (proc)->gnutls_log_level;
@@ -677,7 +677,7 @@ emacs_gnutls_deinit (Lisp_Object proc)
677 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1; 677 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1;
678 } 678 }
679 679
680 XPROCESS (proc)->gnutls_p = 0; 680 XPROCESS (proc)->gnutls_p = false;
681 return Qt; 681 return Qt;
682} 682}
683 683
@@ -1162,8 +1162,7 @@ emacs_gnutls_global_deinit (void)
1162} 1162}
1163#endif 1163#endif
1164 1164
1165/* VARARGS 1 */ 1165static void ATTRIBUTE_FORMAT_PRINTF (2, 3)
1166static void
1167boot_error (struct Lisp_Process *p, const char *m, ...) 1166boot_error (struct Lisp_Process *p, const char *m, ...)
1168{ 1167{
1169 va_list ap; 1168 va_list ap;
@@ -1184,7 +1183,7 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
1184 Lisp_Object warnings; 1183 Lisp_Object warnings;
1185 int max_log_level = p->gnutls_log_level; 1184 int max_log_level = p->gnutls_log_level;
1186 Lisp_Object hostname, verify_error; 1185 Lisp_Object hostname, verify_error;
1187 bool verify_error_all = 0; 1186 bool verify_error_all = false;
1188 char *c_hostname; 1187 char *c_hostname;
1189 1188
1190 if (NILP (proplist)) 1189 if (NILP (proplist))
@@ -1194,12 +1193,11 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
1194 hostname = Fplist_get (proplist, QCgnutls_bootprop_hostname); 1193 hostname = Fplist_get (proplist, QCgnutls_bootprop_hostname);
1195 1194
1196 if (EQ (verify_error, Qt)) 1195 if (EQ (verify_error, Qt))
1197 { 1196 verify_error_all = true;
1198 verify_error_all = 1;
1199 }
1200 else if (NILP (Flistp (verify_error))) 1197 else if (NILP (Flistp (verify_error)))
1201 { 1198 {
1202 boot_error (p, "gnutls-boot: invalid :verify_error parameter (not a list)"); 1199 boot_error (p,
1200 "gnutls-boot: invalid :verify_error parameter (not a list)");
1203 return Qnil; 1201 return Qnil;
1204 } 1202 }
1205 1203
@@ -1225,8 +1223,7 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
1225 warnings = Fplist_get (Fgnutls_peer_status (proc), intern (":warnings")); 1223 warnings = Fplist_get (Fgnutls_peer_status (proc), intern (":warnings"));
1226 if (!NILP (warnings)) 1224 if (!NILP (warnings))
1227 { 1225 {
1228 Lisp_Object tail; 1226 for (Lisp_Object tail = warnings; CONSP (tail); tail = XCDR (tail))
1229 for (tail = warnings; CONSP (tail); tail = XCDR (tail))
1230 { 1227 {
1231 Lisp_Object warning = XCAR (tail); 1228 Lisp_Object warning = XCAR (tail);
1232 Lisp_Object message = Fgnutls_peer_status_warning_describe (warning); 1229 Lisp_Object message = Fgnutls_peer_status_warning_describe (warning);
@@ -1241,7 +1238,8 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
1241 || !NILP (Fmember (QCgnutls_bootprop_trustfiles, verify_error))) 1238 || !NILP (Fmember (QCgnutls_bootprop_trustfiles, verify_error)))
1242 { 1239 {
1243 emacs_gnutls_deinit (proc); 1240 emacs_gnutls_deinit (proc);
1244 boot_error (p, "Certificate validation failed %s, verification code %x", 1241 boot_error (p,
1242 "Certificate validation failed %s, verification code %x",
1245 c_hostname, peer_verification); 1243 c_hostname, peer_verification);
1246 return Qnil; 1244 return Qnil;
1247 } 1245 }
@@ -1265,8 +1263,8 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
1265 if (ret < GNUTLS_E_SUCCESS) 1263 if (ret < GNUTLS_E_SUCCESS)
1266 return gnutls_make_error (ret); 1264 return gnutls_make_error (ret);
1267 1265
1268 gnutls_verify_cert_list = 1266 gnutls_verify_cert_list
1269 gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); 1267 = gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size);
1270 1268
1271 if (gnutls_verify_cert_list == NULL) 1269 if (gnutls_verify_cert_list == NULL)
1272 { 1270 {
@@ -1276,10 +1274,10 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
1276 return Qnil; 1274 return Qnil;
1277 } 1275 }
1278 1276
1279 /* We only check the first certificate in the given chain. */ 1277 /* Check only the first certificate in the given chain. */
1280 ret = gnutls_x509_crt_import (gnutls_verify_cert, 1278 ret = gnutls_x509_crt_import (gnutls_verify_cert,
1281 &gnutls_verify_cert_list[0], 1279 &gnutls_verify_cert_list[0],
1282 GNUTLS_X509_FMT_DER); 1280 GNUTLS_X509_FMT_DER);
1283 1281
1284 if (ret < GNUTLS_E_SUCCESS) 1282 if (ret < GNUTLS_E_SUCCESS)
1285 { 1283 {
@@ -1294,26 +1292,25 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
1294 check_memory_full (err); 1292 check_memory_full (err);
1295 if (!err) 1293 if (!err)
1296 { 1294 {
1297 XPROCESS (proc)->gnutls_extra_peer_verification |= 1295 XPROCESS (proc)->gnutls_extra_peer_verification
1298 CERTIFICATE_NOT_MATCHING; 1296 |= CERTIFICATE_NOT_MATCHING;
1299 if (verify_error_all 1297 if (verify_error_all
1300 || !NILP (Fmember (QCgnutls_bootprop_hostname, verify_error))) 1298 || !NILP (Fmember (QCgnutls_bootprop_hostname, verify_error)))
1301 { 1299 {
1302 gnutls_x509_crt_deinit (gnutls_verify_cert); 1300 gnutls_x509_crt_deinit (gnutls_verify_cert);
1303 emacs_gnutls_deinit (proc); 1301 emacs_gnutls_deinit (proc);
1304 boot_error (p, "The x509 certificate does not match \"%s\"", c_hostname); 1302 boot_error (p, "The x509 certificate does not match \"%s\"",
1303 c_hostname);
1305 return Qnil; 1304 return Qnil;
1306 } 1305 }
1307 else 1306 else
1308 { 1307 GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:",
1309 GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:", 1308 c_hostname);
1310 c_hostname);
1311 }
1312 } 1309 }
1313 } 1310 }
1314 1311
1315 /* Set this flag only if the whole initialization succeeded. */ 1312 /* Set this flag only if the whole initialization succeeded. */
1316 XPROCESS (proc)->gnutls_p = 1; 1313 XPROCESS (proc)->gnutls_p = true;
1317 1314
1318 return gnutls_make_error (ret); 1315 return gnutls_make_error (ret);
1319} 1316}
diff --git a/src/process.c b/src/process.c
index 5172518ac6b..41e821e145d 100644
--- a/src/process.c
+++ b/src/process.c
@@ -281,7 +281,7 @@ static int max_input_desc;
281 281
282/* Indexed by descriptor, gives the process (if any) for that descriptor. */ 282/* Indexed by descriptor, gives the process (if any) for that descriptor. */
283static Lisp_Object chan_process[FD_SETSIZE]; 283static Lisp_Object chan_process[FD_SETSIZE];
284static void wait_for_socket_fds (Lisp_Object process, char *name); 284static void wait_for_socket_fds (Lisp_Object, char const *);
285 285
286/* Alist of elements (NAME . PROCESS). */ 286/* Alist of elements (NAME . PROCESS). */
287static Lisp_Object Vprocess_alist; 287static Lisp_Object Vprocess_alist;
@@ -745,14 +745,10 @@ free_dns_request (Lisp_Object proc)
745{ 745{
746 struct Lisp_Process *p = XPROCESS (proc); 746 struct Lisp_Process *p = XPROCESS (proc);
747 747
748 if (p->dns_requests[0]->ar_result) 748 if (p->dns_request->ar_result)
749 freeaddrinfo (p->dns_requests[0]->ar_result); 749 freeaddrinfo (p->dns_request->ar_result);
750 xfree ((void *)p->dns_requests[0]->ar_request); 750 xfree (p->dns_request);
751 xfree ((void *)p->dns_requests[0]->ar_name); 751 p->dns_request = NULL;
752 xfree ((void *)p->dns_requests[0]->ar_service);
753 xfree (p->dns_requests[0]);
754 xfree (p->dns_requests);
755 p->dns_requests = NULL;
756} 752}
757#endif 753#endif
758 754
@@ -847,9 +843,9 @@ nil, indicating the current buffer's process. */)
847 p = XPROCESS (process); 843 p = XPROCESS (process);
848 844
849#ifdef HAVE_GETADDRINFO_A 845#ifdef HAVE_GETADDRINFO_A
850 if (p->dns_requests) 846 if (p->dns_request)
851 { 847 {
852 gai_cancel (p->dns_requests[0]); 848 gai_cancel (p->dns_request);
853 free_dns_request (process); 849 free_dns_request (process);
854 } 850 }
855#endif 851#endif
@@ -1063,13 +1059,10 @@ The string argument is normally a multibyte string, except:
1063- if `default-enable-multibyte-characters' is nil, it is a unibyte 1059- if `default-enable-multibyte-characters' is nil, it is a unibyte
1064 string (the result of converting the decoded input multibyte 1060 string (the result of converting the decoded input multibyte
1065 string to unibyte with `string-make-unibyte'). */) 1061 string to unibyte with `string-make-unibyte'). */)
1066 (register Lisp_Object process, Lisp_Object filter) 1062 (Lisp_Object process, Lisp_Object filter)
1067{ 1063{
1068 struct Lisp_Process *p;
1069
1070 CHECK_PROCESS (process); 1064 CHECK_PROCESS (process);
1071 1065 struct Lisp_Process *p = XPROCESS (process);
1072 p = XPROCESS (process);
1073 1066
1074 /* Don't signal an error if the process's input file descriptor 1067 /* Don't signal an error if the process's input file descriptor
1075 is closed. This could make debugging Lisp more difficult, 1068 is closed. This could make debugging Lisp more difficult,
@@ -1217,7 +1210,7 @@ returned. See `make-network-process' or `make-serial-process' for a
1217list of keywords. 1210list of keywords.
1218If PROCESS is a non-blocking network process that hasn't been fully 1211If PROCESS is a non-blocking network process that hasn't been fully
1219set up yet, this function will block until socket setup has completed. */) 1212set up yet, this function will block until socket setup has completed. */)
1220 (register Lisp_Object process, Lisp_Object key) 1213 (Lisp_Object process, Lisp_Object key)
1221{ 1214{
1222 Lisp_Object contact; 1215 Lisp_Object contact;
1223 1216
@@ -1263,8 +1256,8 @@ DEFUN ("process-plist", Fprocess_plist, Sprocess_plist,
1263 1256
1264DEFUN ("set-process-plist", Fset_process_plist, Sset_process_plist, 1257DEFUN ("set-process-plist", Fset_process_plist, Sset_process_plist,
1265 2, 2, 0, 1258 2, 2, 0,
1266 doc: /* Replace the plist of PROCESS with PLIST. Returns PLIST. */) 1259 doc: /* Replace the plist of PROCESS with PLIST. Return PLIST. */)
1267 (register Lisp_Object process, Lisp_Object plist) 1260 (Lisp_Object process, Lisp_Object plist)
1268{ 1261{
1269 CHECK_PROCESS (process); 1262 CHECK_PROCESS (process);
1270 CHECK_LIST (plist); 1263 CHECK_LIST (plist);
@@ -1304,7 +1297,7 @@ A 4 or 5 element vector represents an IPv4 address (with port number).
1304An 8 or 9 element vector represents an IPv6 address (with port number). 1297An 8 or 9 element vector represents an IPv6 address (with port number).
1305If optional second argument OMIT-PORT is non-nil, don't include a port 1298If optional second argument OMIT-PORT is non-nil, don't include a port
1306number in the string, even when present in ADDRESS. 1299number in the string, even when present in ADDRESS.
1307Returns nil if format of ADDRESS is invalid. */) 1300Return nil if format of ADDRESS is invalid. */)
1308 (Lisp_Object address, Lisp_Object omit_port) 1301 (Lisp_Object address, Lisp_Object omit_port)
1309{ 1302{
1310 if (NILP (address)) 1303 if (NILP (address))
@@ -2474,7 +2467,7 @@ set up yet, this function will block until socket setup has completed. */)
2474DEFUN ("set-process-datagram-address", Fset_process_datagram_address, Sset_process_datagram_address, 2467DEFUN ("set-process-datagram-address", Fset_process_datagram_address, Sset_process_datagram_address,
2475 2, 2, 0, 2468 2, 2, 0,
2476 doc: /* Set the datagram address for PROCESS to ADDRESS. 2469 doc: /* Set the datagram address for PROCESS to ADDRESS.
2477Returns nil upon error setting address, ADDRESS otherwise. 2470Return nil upon error setting address, ADDRESS otherwise.
2478 2471
2479If PROCESS is a non-blocking network process that hasn't been fully 2472If PROCESS is a non-blocking network process that hasn't been fully
2480set up yet, this function will block until socket setup has completed. */) 2473set up yet, this function will block until socket setup has completed. */)
@@ -2543,7 +2536,7 @@ static const struct socket_options {
2543 2536
2544/* Set option OPT to value VAL on socket S. 2537/* Set option OPT to value VAL on socket S.
2545 2538
2546 Returns (1<<socket_options[OPT].optbit) if option is known, 0 otherwise. 2539 Return (1<<socket_options[OPT].optbit) if option is known, 0 otherwise.
2547 Signals an error if setting a known option fails. 2540 Signals an error if setting a known option fails.
2548*/ 2541*/
2549 2542
@@ -2955,10 +2948,9 @@ usage: (make-serial-process &rest ARGS) */)
2955 return proc; 2948 return proc;
2956} 2949}
2957 2950
2958void set_network_socket_coding_system (Lisp_Object proc, 2951static void
2959 Lisp_Object host, 2952set_network_socket_coding_system (Lisp_Object proc, Lisp_Object host,
2960 Lisp_Object service, 2953 Lisp_Object service, Lisp_Object name)
2961 Lisp_Object name)
2962{ 2954{
2963 Lisp_Object tem; 2955 Lisp_Object tem;
2964 struct Lisp_Process *p = XPROCESS (proc); 2956 struct Lisp_Process *p = XPROCESS (proc);
@@ -2981,9 +2973,10 @@ void set_network_socket_coding_system (Lisp_Object proc,
2981 } 2973 }
2982 else if (!NILP (Vcoding_system_for_read)) 2974 else if (!NILP (Vcoding_system_for_read))
2983 val = Vcoding_system_for_read; 2975 val = Vcoding_system_for_read;
2984 else if ((!NILP (p->buffer) && 2976 else if ((!NILP (p->buffer)
2985 NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters))) 2977 && NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters)))
2986 || (NILP (p->buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))) 2978 || (NILP (p->buffer)
2979 && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
2987 /* We dare not decode end-of-line format by setting VAL to 2980 /* We dare not decode end-of-line format by setting VAL to
2988 Qraw_text, because the existing Emacs Lisp libraries 2981 Qraw_text, because the existing Emacs Lisp libraries
2989 assume that they receive bare code including a sequence of 2982 assume that they receive bare code including a sequence of
@@ -3045,7 +3038,7 @@ void set_network_socket_coding_system (Lisp_Object proc,
3045} 3038}
3046 3039
3047#ifdef HAVE_GNUTLS 3040#ifdef HAVE_GNUTLS
3048void 3041static void
3049finish_after_tls_connection (Lisp_Object proc) 3042finish_after_tls_connection (Lisp_Object proc)
3050{ 3043{
3051 struct Lisp_Process *p = XPROCESS (proc); 3044 struct Lisp_Process *p = XPROCESS (proc);
@@ -3081,7 +3074,7 @@ finish_after_tls_connection (Lisp_Object proc)
3081} 3074}
3082#endif 3075#endif
3083 3076
3084void 3077static void
3085connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses) 3078connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
3086{ 3079{
3087 ptrdiff_t count = SPECPDL_INDEX (); 3080 ptrdiff_t count = SPECPDL_INDEX ();
@@ -3190,8 +3183,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
3190 Lisp_Object service; 3183 Lisp_Object service;
3191 service = make_number (ntohs (sa1.sin_port)); 3184 service = make_number (ntohs (sa1.sin_port));
3192 contact = Fplist_put (contact, QCservice, service); 3185 contact = Fplist_put (contact, QCservice, service);
3193 // Save the port number so that we can stash it in 3186 /* Save the port number so that we can stash it in
3194 // the process object later. 3187 the process object later. */
3195 ((struct sockaddr_in *)sa)->sin_port = sa1.sin_port; 3188 ((struct sockaddr_in *)sa)->sin_port = sa1.sin_port;
3196 } 3189 }
3197 } 3190 }
@@ -3422,15 +3415,14 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
3422 3415
3423#ifndef HAVE_GETADDRINFO 3416#ifndef HAVE_GETADDRINFO
3424static Lisp_Object 3417static Lisp_Object
3425conv_numerical_to_lisp (unsigned char *number, unsigned int length, int port) 3418conv_numerical_to_lisp (unsigned char *number, int length, int port)
3426{ 3419{
3427 Lisp_Object address = Fmake_vector (make_number (length + 1), Qnil); 3420 Lisp_Object address = Fmake_vector (make_number (length + 1), Qnil);
3428 register struct Lisp_Vector *p = XVECTOR (address); 3421 struct Lisp_Vector *p = XVECTOR (address);
3429 int i;
3430 3422
3431 p->contents[length] = make_number (port); 3423 p->contents[length] = make_number (port);
3432 for (i = 0; i < length; i++) 3424 for (int i = 0; i < length; i++)
3433 p->contents[i] = make_number (*(number + i)); 3425 p->contents[i] = make_number (number[i]);
3434 3426
3435 return address; 3427 return address;
3436} 3428}
@@ -3606,9 +3598,9 @@ usage: (make-network-process &rest ARGS) */)
3606 Lisp_Object proc; 3598 Lisp_Object proc;
3607 Lisp_Object contact; 3599 Lisp_Object contact;
3608 struct Lisp_Process *p; 3600 struct Lisp_Process *p;
3609#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETADDRINFO_A) 3601#if defined HAVE_GETADDRINFO || defined HAVE_GETADDRINFO_A
3610 struct addrinfo *hints;
3611 const char *portstring; 3602 const char *portstring;
3603 ptrdiff_t portstringlen;
3612 char portbuf[128]; 3604 char portbuf[128];
3613#endif 3605#endif
3614#ifdef HAVE_LOCAL_SOCKETS 3606#ifdef HAVE_LOCAL_SOCKETS
@@ -3623,7 +3615,7 @@ usage: (make-network-process &rest ARGS) */)
3623 int family = -1; 3615 int family = -1;
3624 int ai_protocol = 0; 3616 int ai_protocol = 0;
3625#ifdef HAVE_GETADDRINFO_A 3617#ifdef HAVE_GETADDRINFO_A
3626 struct gaicb **dns_requests = NULL; 3618 struct gaicb *dns_request = NULL;
3627#endif 3619#endif
3628 ptrdiff_t count = SPECPDL_INDEX (); 3620 ptrdiff_t count = SPECPDL_INDEX ();
3629 3621
@@ -3673,7 +3665,7 @@ usage: (make-network-process &rest ARGS) */)
3673 if (!get_lisp_to_sockaddr_size (address, &family)) 3665 if (!get_lisp_to_sockaddr_size (address, &family))
3674 error ("Malformed :address"); 3666 error ("Malformed :address");
3675 3667
3676 ip_addresses = Fcons (address, Qnil); 3668 ip_addresses = list1 (address);
3677 goto open_socket; 3669 goto open_socket;
3678 } 3670 }
3679 3671
@@ -3737,7 +3729,7 @@ usage: (make-network-process &rest ARGS) */)
3737 CHECK_STRING (service); 3729 CHECK_STRING (service);
3738 if (sizeof address_un.sun_path <= SBYTES (service)) 3730 if (sizeof address_un.sun_path <= SBYTES (service))
3739 error ("Service name too long"); 3731 error ("Service name too long");
3740 ip_addresses = Fcons (service, Qnil); 3732 ip_addresses = list1 (service);
3741 goto open_socket; 3733 goto open_socket;
3742 } 3734 }
3743#endif 3735#endif
@@ -3753,48 +3745,53 @@ usage: (make-network-process &rest ARGS) */)
3753 } 3745 }
3754#endif 3746#endif
3755 3747
3756#if defined (HAVE_GETADDRINFO) || defined (HAVE_GETADDRINFO_A) 3748#if defined HAVE_GETADDRINFO || defined HAVE_GETADDRINFO_A
3757 if (!NILP (host)) 3749 if (!NILP (host))
3758 { 3750 {
3759
3760 /* SERVICE can either be a string or int. 3751 /* SERVICE can either be a string or int.
3761 Convert to a C string for later use by getaddrinfo. */ 3752 Convert to a C string for later use by getaddrinfo. */
3762 if (EQ (service, Qt)) 3753 if (EQ (service, Qt))
3763 portstring = "0"; 3754 {
3755 portstring = "0";
3756 portstringlen = 1;
3757 }
3764 else if (INTEGERP (service)) 3758 else if (INTEGERP (service))
3765 { 3759 {
3766 sprintf (portbuf, "%"pI"d", XINT (service));
3767 portstring = portbuf; 3760 portstring = portbuf;
3761 portstringlen = sprintf (portbuf, "%"pI"d", XINT (service));
3768 } 3762 }
3769 else 3763 else
3770 { 3764 {
3771 CHECK_STRING (service); 3765 CHECK_STRING (service);
3772 portstring = SSDATA (service); 3766 portstring = SSDATA (service);
3767 portstringlen = SBYTES (service);
3773 } 3768 }
3774
3775 hints = xzalloc (sizeof (struct addrinfo));
3776 hints->ai_flags = 0;
3777 hints->ai_family = family;
3778 hints->ai_socktype = socktype;
3779 hints->ai_protocol = 0;
3780 } 3769 }
3781
3782#endif 3770#endif
3783 3771
3784#ifdef HAVE_GETADDRINFO_A 3772#ifdef HAVE_GETADDRINFO_A
3785 if (!NILP (Fplist_get (contact, QCnowait)) && 3773 if (!NILP (Fplist_get (contact, QCnowait)) && !NILP (host))
3786 !NILP (host))
3787 { 3774 {
3788 int ret; 3775 ptrdiff_t hostlen = SBYTES (host);
3789 3776 struct req
3790 dns_requests = xmalloc (sizeof (struct gaicb*)); 3777 {
3791 dns_requests[0] = xmalloc (sizeof (struct gaicb)); 3778 struct gaicb gaicb;
3792 dns_requests[0]->ar_name = strdup (SSDATA (host)); 3779 struct addrinfo hints;
3793 dns_requests[0]->ar_service = strdup (portstring); 3780 char str[FLEXIBLE_ARRAY_MEMBER];
3794 dns_requests[0]->ar_request = hints; 3781 } *req = xmalloc (offsetof (struct req, str)
3795 dns_requests[0]->ar_result = NULL; 3782 + hostlen + 1 + portstringlen + 1);
3796 3783 dns_request = &req->gaicb;
3797 ret = getaddrinfo_a (GAI_NOWAIT, dns_requests, 1, NULL); 3784 dns_request->ar_name = req->str;
3785 dns_request->ar_service = req->str + hostlen + 1;
3786 dns_request->ar_request = &req->hints;
3787 dns_request->ar_result = NULL;
3788 memset (&req->hints, 0, sizeof req->hints);
3789 req->hints.ai_family = family;
3790 req->hints.ai_socktype = socktype;
3791 strcpy (req->str, SSDATA (host));
3792 strcpy (req->str + hostlen + 1, portstring);
3793
3794 int ret = getaddrinfo_a (GAI_NOWAIT, &dns_request, 1, NULL);
3798 if (ret) 3795 if (ret)
3799 error ("%s/%s getaddrinfo_a error %d", SSDATA (host), portstring, ret); 3796 error ("%s/%s getaddrinfo_a error %d", SSDATA (host), portstring, ret);
3800 3797
@@ -3818,7 +3815,12 @@ usage: (make-network-process &rest ARGS) */)
3818 res_init (); 3815 res_init ();
3819#endif 3816#endif
3820 3817
3821 ret = getaddrinfo (SSDATA (host), portstring, hints, &res); 3818 struct addrinfo hints;
3819 memset (&hints, 0, sizeof hints);
3820 hints.ai_family = family;
3821 hints.ai_socktype = socktype;
3822
3823 ret = getaddrinfo (SSDATA (host), portstring, &hints, &res);
3822 if (ret) 3824 if (ret)
3823#ifdef HAVE_GAI_STRERROR 3825#ifdef HAVE_GAI_STRERROR
3824 error ("%s/%s %s", SSDATA (host), portstring, gai_strerror (ret)); 3826 error ("%s/%s %s", SSDATA (host), portstring, gai_strerror (ret));
@@ -3838,7 +3840,6 @@ usage: (make-network-process &rest ARGS) */)
3838 ip_addresses = Fnreverse (ip_addresses); 3840 ip_addresses = Fnreverse (ip_addresses);
3839 3841
3840 freeaddrinfo (res); 3842 freeaddrinfo (res);
3841 xfree (hints);
3842 3843
3843 goto open_socket; 3844 goto open_socket;
3844 } 3845 }
@@ -3866,6 +3867,8 @@ usage: (make-network-process &rest ARGS) */)
3866 if (!NILP (host)) 3867 if (!NILP (host))
3867 { 3868 {
3868 struct hostent *host_info_ptr; 3869 struct hostent *host_info_ptr;
3870 unsigned char *addr;
3871 int addrlen;
3869 3872
3870 /* gethostbyname may fail with TRY_AGAIN, but we don't honor that, 3873 /* gethostbyname may fail with TRY_AGAIN, but we don't honor that,
3871 as it may `hang' Emacs for a very long time. */ 3874 as it may `hang' Emacs for a very long time. */
@@ -3881,11 +3884,8 @@ usage: (make-network-process &rest ARGS) */)
3881 3884
3882 if (host_info_ptr) 3885 if (host_info_ptr)
3883 { 3886 {
3884 ip_addresses = Fcons (conv_numerical_to_lisp 3887 addr = (unsigned char *) host_info_ptr->h_addr;
3885 ((unsigned char *) host_info_ptr->h_addr, 3888 addrlen = host_info_ptr->h_length;
3886 host_info_ptr->h_length,
3887 port),
3888 Qnil);
3889 } 3889 }
3890 else 3890 else
3891 /* Attempt to interpret host as numeric inet address. This 3891 /* Attempt to interpret host as numeric inet address. This
@@ -3896,11 +3896,11 @@ usage: (make-network-process &rest ARGS) */)
3896 if (numeric_addr == -1) 3896 if (numeric_addr == -1)
3897 error ("Unknown host \"%s\"", SDATA (host)); 3897 error ("Unknown host \"%s\"", SDATA (host));
3898 3898
3899 ip_addresses = Fcons (conv_numerical_to_lisp 3899 addr = (unsigned char *) &numeric_addr;
3900 ((unsigned char *) &numeric_addr, 4, port), 3900 addrlen = 4;
3901 Qnil);
3902 } 3901 }
3903 3902
3903 ip_addresses = list1 (conv_numerical_to_lisp (addr, addrlen, port));
3904 } 3904 }
3905#endif /* not HAVE_GETADDRINFO */ 3905#endif /* not HAVE_GETADDRINFO */
3906 3906
@@ -3930,7 +3930,7 @@ usage: (make-network-process &rest ARGS) */)
3930 p->socktype = socktype; 3930 p->socktype = socktype;
3931 p->ai_protocol = ai_protocol; 3931 p->ai_protocol = ai_protocol;
3932#ifdef HAVE_GETADDRINFO_A 3932#ifdef HAVE_GETADDRINFO_A
3933 p->dns_requests = NULL; 3933 p->dns_request = NULL;
3934#endif 3934#endif
3935#ifdef HAVE_GNUTLS 3935#ifdef HAVE_GNUTLS
3936 tem = Fplist_get (contact, QCtls_parameters); 3936 tem = Fplist_get (contact, QCtls_parameters);
@@ -3969,7 +3969,7 @@ usage: (make-network-process &rest ARGS) */)
3969 here will be nil, so we postpone connecting to the server. */ 3969 here will be nil, so we postpone connecting to the server. */
3970 if (!p->is_server && NILP (ip_addresses)) 3970 if (!p->is_server && NILP (ip_addresses))
3971 { 3971 {
3972 p->dns_requests = dns_requests; 3972 p->dns_request = dns_request;
3973 p->status = Qconnect; 3973 p->status = Qconnect;
3974 } 3974 }
3975 else 3975 else
@@ -4693,10 +4693,10 @@ check_for_dns (Lisp_Object proc)
4693 int ret = 0; 4693 int ret = 0;
4694 4694
4695 /* Sanity check. */ 4695 /* Sanity check. */
4696 if (! p->dns_requests) 4696 if (! p->dns_request)
4697 return Qnil; 4697 return Qnil;
4698 4698
4699 ret = gai_error (p->dns_requests[0]); 4699 ret = gai_error (p->dns_request);
4700 if (ret == EAI_INPROGRESS) 4700 if (ret == EAI_INPROGRESS)
4701 return Qt; 4701 return Qt;
4702 4702
@@ -4705,7 +4705,7 @@ check_for_dns (Lisp_Object proc)
4705 { 4705 {
4706 struct addrinfo *res; 4706 struct addrinfo *res;
4707 4707
4708 for (res = p->dns_requests[0]->ar_result; res; res = res->ai_next) 4708 for (res = p->dns_request->ar_result; res; res = res->ai_next)
4709 { 4709 {
4710 ip_addresses = Fcons (conv_sockaddr_to_lisp 4710 ip_addresses = Fcons (conv_sockaddr_to_lisp
4711 (res->ai_addr, res->ai_addrlen), 4711 (res->ai_addr, res->ai_addrlen),
@@ -4721,7 +4721,7 @@ check_for_dns (Lisp_Object proc)
4721 pset_status (p, (list2 4721 pset_status (p, (list2
4722 (Qfailed, 4722 (Qfailed,
4723 concat3 (build_string ("Name lookup of "), 4723 concat3 (build_string ("Name lookup of "),
4724 build_string (p->dns_requests[0]->ar_name), 4724 build_string (p->dns_request->ar_name),
4725 build_string (" failed"))))); 4725 build_string (" failed")))));
4726 } 4726 }
4727 4727
@@ -4737,10 +4737,10 @@ check_for_dns (Lisp_Object proc)
4737#endif /* HAVE_GETADDRINFO_A */ 4737#endif /* HAVE_GETADDRINFO_A */
4738 4738
4739static void 4739static void
4740wait_for_socket_fds (Lisp_Object process, char *name) 4740wait_for_socket_fds (Lisp_Object process, char const *name)
4741{ 4741{
4742 while (XPROCESS (process)->infd < 0 && 4742 while (XPROCESS (process)->infd < 0
4743 EQ (XPROCESS (process)->status, Qconnect)) 4743 && EQ (XPROCESS (process)->status, Qconnect))
4744 { 4744 {
4745 add_to_log ("Waiting for socket from %s...", build_string (name)); 4745 add_to_log ("Waiting for socket from %s...", build_string (name));
4746 wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0); 4746 wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0);
@@ -4761,8 +4761,8 @@ static void
4761wait_for_tls_negotiation (Lisp_Object process) 4761wait_for_tls_negotiation (Lisp_Object process)
4762{ 4762{
4763#ifdef HAVE_GNUTLS 4763#ifdef HAVE_GNUTLS
4764 while (XPROCESS (process)->gnutls_p && 4764 while (XPROCESS (process)->gnutls_p
4765 XPROCESS (process)->gnutls_initstage != GNUTLS_STAGE_READY) 4765 && XPROCESS (process)->gnutls_initstage != GNUTLS_STAGE_READY)
4766 { 4766 {
4767 add_to_log ("Waiting for TLS..."); 4767 add_to_log ("Waiting for TLS...");
4768 wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0); 4768 wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0);
@@ -4895,7 +4895,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4895 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 4895 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4896 break; 4896 break;
4897 4897
4898#if defined (HAVE_GETADDRINFO_A) || defined (HAVE_GNUTLS) 4898#if defined HAVE_GETADDRINFO_A || defined HAVE_GNUTLS
4899 { 4899 {
4900 Lisp_Object ip_addresses; 4900 Lisp_Object ip_addresses;
4901 Lisp_Object process_list_head, aproc; 4901 Lisp_Object process_list_head, aproc;
@@ -4909,18 +4909,17 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4909 { 4909 {
4910#ifdef HAVE_GETADDRINFO_A 4910#ifdef HAVE_GETADDRINFO_A
4911 /* Check for pending DNS requests. */ 4911 /* Check for pending DNS requests. */
4912 if (p->dns_requests) 4912 if (p->dns_request)
4913 { 4913 {
4914 ip_addresses = check_for_dns (aproc); 4914 ip_addresses = check_for_dns (aproc);
4915 if (!NILP (ip_addresses) && 4915 if (!NILP (ip_addresses) && !EQ (ip_addresses, Qt))
4916 !EQ (ip_addresses, Qt))
4917 connect_network_socket (aproc, ip_addresses); 4916 connect_network_socket (aproc, ip_addresses);
4918 } 4917 }
4919#endif 4918#endif
4920#ifdef HAVE_GNUTLS 4919#ifdef HAVE_GNUTLS
4921 /* Continue TLS negotiation. */ 4920 /* Continue TLS negotiation. */
4922 if (p->gnutls_initstage == GNUTLS_STAGE_HANDSHAKE_TRIED && 4921 if (p->gnutls_initstage == GNUTLS_STAGE_HANDSHAKE_TRIED
4923 p->is_non_blocking_client) 4922 && p->is_non_blocking_client)
4924 { 4923 {
4925 gnutls_try_handshake (p); 4924 gnutls_try_handshake (p);
4926 p->gnutls_handshakes_tried++; 4925 p->gnutls_handshakes_tried++;
@@ -4930,8 +4929,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4930 gnutls_verify_boot (aproc, Qnil); 4929 gnutls_verify_boot (aproc, Qnil);
4931 finish_after_tls_connection (aproc); 4930 finish_after_tls_connection (aproc);
4932 } 4931 }
4933 else if (p->gnutls_handshakes_tried > 4932 else if (p->gnutls_handshakes_tried
4934 GNUTLS_EMACS_HANDSHAKES_LIMIT) 4933 > GNUTLS_EMACS_HANDSHAKES_LIMIT)
4935 { 4934 {
4936 deactivate_process (aproc); 4935 deactivate_process (aproc);
4937 pset_status (p, list2 (Qfailed, 4936 pset_status (p, list2 (Qfailed,
@@ -5567,8 +5566,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5567 /* If we have an incompletely set up TLS connection, 5566 /* If we have an incompletely set up TLS connection,
5568 then defer the sentinel signalling until 5567 then defer the sentinel signalling until
5569 later. */ 5568 later. */
5570 if (NILP (p->gnutls_boot_parameters) && 5569 if (NILP (p->gnutls_boot_parameters)
5571 !p->gnutls_p) 5570 && !p->gnutls_p)
5572#endif 5571#endif
5573 { 5572 {
5574 pset_status (p, Qrun); 5573 pset_status (p, Qrun);
@@ -6034,10 +6033,11 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
6034 ssize_t rv; 6033 ssize_t rv;
6035 struct coding_system *coding; 6034 struct coding_system *coding;
6036 6035
6037 if (NETCONN_P (proc)) { 6036 if (NETCONN_P (proc))
6038 wait_while_connecting (proc); 6037 {
6039 wait_for_tls_negotiation (proc); 6038 wait_while_connecting (proc);
6040 } 6039 wait_for_tls_negotiation (proc);
6040 }
6041 6041
6042 if (p->raw_status_new) 6042 if (p->raw_status_new)
6043 update_status (p); 6043 update_status (p);
@@ -6295,10 +6295,8 @@ If PROCESS is a non-blocking network process that hasn't been fully
6295set up yet, this function will block until socket setup has completed. */) 6295set up yet, this function will block until socket setup has completed. */)
6296 (Lisp_Object process, Lisp_Object string) 6296 (Lisp_Object process, Lisp_Object string)
6297{ 6297{
6298 Lisp_Object proc;
6299 CHECK_STRING (string); 6298 CHECK_STRING (string);
6300 proc = get_process (process); 6299 Lisp_Object proc = get_process (process);
6301
6302 send_process (proc, SSDATA (string), 6300 send_process (proc, SSDATA (string),
6303 SBYTES (string), string); 6301 SBYTES (string), string);
6304 return Qnil; 6302 return Qnil;
@@ -6340,12 +6338,8 @@ process group. */)
6340{ 6338{
6341 /* Initialize in case ioctl doesn't exist or gives an error, 6339 /* Initialize in case ioctl doesn't exist or gives an error,
6342 in a way that will cause returning t. */ 6340 in a way that will cause returning t. */
6343 pid_t gid; 6341 Lisp_Object proc = get_process (process);
6344 Lisp_Object proc; 6342 struct Lisp_Process *p = XPROCESS (proc);
6345 struct Lisp_Process *p;
6346
6347 proc = get_process (process);
6348 p = XPROCESS (proc);
6349 6343
6350 if (!EQ (p->type, Qreal)) 6344 if (!EQ (p->type, Qreal))
6351 error ("Process %s is not a subprocess", 6345 error ("Process %s is not a subprocess",
@@ -6354,7 +6348,7 @@ process group. */)
6354 error ("Process %s is not active", 6348 error ("Process %s is not active",
6355 SDATA (p->name)); 6349 SDATA (p->name));
6356 6350
6357 gid = emacs_get_tty_pgrp (p); 6351 pid_t gid = emacs_get_tty_pgrp (p);
6358 6352
6359 if (gid == p->pid) 6353 if (gid == p->pid)
6360 return Qnil; 6354 return Qnil;
@@ -7170,16 +7164,14 @@ encode subprocess input.
7170 7164
7171If PROCESS is a non-blocking network process that hasn't been fully 7165If PROCESS is a non-blocking network process that hasn't been fully
7172set up yet, this function will block until socket setup has completed. */) 7166set up yet, this function will block until socket setup has completed. */)
7173 (register Lisp_Object process, Lisp_Object decoding, Lisp_Object encoding) 7167 (Lisp_Object process, Lisp_Object decoding, Lisp_Object encoding)
7174{ 7168{
7175 register struct Lisp_Process *p;
7176
7177 CHECK_PROCESS (process); 7169 CHECK_PROCESS (process);
7178 7170
7179 if (NETCONN_P (process)) 7171 if (NETCONN_P (process))
7180 wait_for_socket_fds (process, "set-process-coding-system"); 7172 wait_for_socket_fds (process, "set-process-coding-system");
7181 7173
7182 p = XPROCESS (process); 7174 struct Lisp_Process *p = XPROCESS (process);
7183 7175
7184 if (p->infd < 0) 7176 if (p->infd < 0)
7185 error ("Input file descriptor of %s closed", SDATA (p->name)); 7177 error ("Input file descriptor of %s closed", SDATA (p->name));
@@ -7214,14 +7206,12 @@ all character code conversion except for end-of-line conversion is
7214suppressed. */) 7206suppressed. */)
7215 (Lisp_Object process, Lisp_Object flag) 7207 (Lisp_Object process, Lisp_Object flag)
7216{ 7208{
7217 register struct Lisp_Process *p;
7218
7219 CHECK_PROCESS (process); 7209 CHECK_PROCESS (process);
7220 7210
7221 if (NETCONN_P (process)) 7211 if (NETCONN_P (process))
7222 wait_for_socket_fds (process, "set-process-filter-multibyte"); 7212 wait_for_socket_fds (process, "set-process-filter-multibyte");
7223 7213
7224 p = XPROCESS (process); 7214 struct Lisp_Process *p = XPROCESS (process);
7225 if (NILP (flag)) 7215 if (NILP (flag))
7226 pset_decode_coding_system 7216 pset_decode_coding_system
7227 (p, raw_text_coding_system (p->decode_coding_system)); 7217 (p, raw_text_coding_system (p->decode_coding_system));
@@ -7235,14 +7225,11 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
7235 doc: /* Return t if a multibyte string is given to PROCESS's filter.*/) 7225 doc: /* Return t if a multibyte string is given to PROCESS's filter.*/)
7236 (Lisp_Object process) 7226 (Lisp_Object process)
7237{ 7227{
7238 register struct Lisp_Process *p;
7239 struct coding_system *coding;
7240
7241 CHECK_PROCESS (process); 7228 CHECK_PROCESS (process);
7242 p = XPROCESS (process); 7229 struct Lisp_Process *p = XPROCESS (process);
7243 if (p->infd < 0) 7230 if (p->infd < 0)
7244 return Qnil; 7231 return Qnil;
7245 coding = proc_decode_coding_system[p->infd]; 7232 struct coding_system *coding = proc_decode_coding_system[p->infd];
7246 return (CODING_FOR_UNIBYTE (coding) ? Qnil : Qt); 7233 return (CODING_FOR_UNIBYTE (coding) ? Qnil : Qt);
7247} 7234}
7248 7235
diff --git a/src/process.h b/src/process.h
index c7531576915..884c3041f67 100644
--- a/src/process.h
+++ b/src/process.h
@@ -179,7 +179,7 @@ struct Lisp_Process
179#ifdef HAVE_GETADDRINFO_A 179#ifdef HAVE_GETADDRINFO_A
180 /* Whether the socket is waiting for response from an asynchronous 180 /* Whether the socket is waiting for response from an asynchronous
181 DNS call. */ 181 DNS call. */
182 struct gaicb **dns_requests; 182 struct gaicb *dns_request;
183#endif 183#endif
184 184
185#ifdef HAVE_GNUTLS 185#ifdef HAVE_GNUTLS
diff --git a/src/window.c b/src/window.c
index 29c35875039..be34c49135e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -57,6 +57,7 @@ static bool foreach_window_1 (struct window *,
57static bool window_resize_check (struct window *, bool); 57static bool window_resize_check (struct window *, bool);
58static void window_resize_apply (struct window *, bool); 58static void window_resize_apply (struct window *, bool);
59static void select_window_1 (Lisp_Object, bool); 59static void select_window_1 (Lisp_Object, bool);
60static void run_window_configuration_change_hook (struct frame *);
60 61
61static struct window *set_window_fringes (struct window *, Lisp_Object, 62static struct window *set_window_fringes (struct window *, Lisp_Object,
62 Lisp_Object, Lisp_Object); 63 Lisp_Object, Lisp_Object);
@@ -720,7 +721,8 @@ the height of the screen areas spanned by its children. */)
720 return make_number (decode_valid_window (window)->pixel_height); 721 return make_number (decode_valid_window (window)->pixel_height);
721} 722}
722 723
723DEFUN ("window-pixel-width-before-size-change", Fwindow_pixel_width_before_size_change, 724DEFUN ("window-pixel-width-before-size-change",
725 Fwindow_pixel_width_before_size_change,
724 Swindow_pixel_width_before_size_change, 0, 1, 0, 726 Swindow_pixel_width_before_size_change, 0, 1, 0,
725 doc: /* Return pixel width of window WINDOW before last size changes. 727 doc: /* Return pixel width of window WINDOW before last size changes.
726WINDOW must be a valid window and defaults to the selected one. 728WINDOW must be a valid window and defaults to the selected one.
@@ -734,7 +736,8 @@ after that. */)
734 (decode_valid_window (window)->pixel_width_before_size_change)); 736 (decode_valid_window (window)->pixel_width_before_size_change));
735} 737}
736 738
737DEFUN ("window-pixel-height-before-size-change", Fwindow_pixel_height_before_size_change, 739DEFUN ("window-pixel-height-before-size-change",
740 Fwindow_pixel_height_before_size_change,
738 Swindow_pixel_height_before_size_change, 0, 1, 0, 741 Swindow_pixel_height_before_size_change, 0, 1, 0,
739 doc: /* Return pixel height of window WINDOW before last size changes. 742 doc: /* Return pixel height of window WINDOW before last size changes.
740WINDOW must be a valid window and defaults to the selected one. 743WINDOW must be a valid window and defaults to the selected one.
@@ -3184,7 +3187,7 @@ select_frame_norecord (Lisp_Object frame)
3184 Fselect_frame (frame, Qt); 3187 Fselect_frame (frame, Qt);
3185} 3188}
3186 3189
3187void 3190static void
3188run_window_configuration_change_hook (struct frame *f) 3191run_window_configuration_change_hook (struct frame *f)
3189{ 3192{
3190 ptrdiff_t count = SPECPDL_INDEX (); 3193 ptrdiff_t count = SPECPDL_INDEX ();
@@ -3310,8 +3313,8 @@ run_window_size_change_functions (Lisp_Object frame)
3310 struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f)); 3313 struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
3311 Lisp_Object functions = Vwindow_size_change_functions; 3314 Lisp_Object functions = Vwindow_size_change_functions;
3312 3315
3313 if (FRAME_WINDOW_CONFIGURATION_CHANGED (f) || 3316 if (FRAME_WINDOW_CONFIGURATION_CHANGED (f)
3314 window_size_changed (r)) 3317 || window_size_changed (r))
3315 { 3318 {
3316 while (CONSP (functions)) 3319 while (CONSP (functions))
3317 { 3320 {
diff --git a/src/window.h b/src/window.h
index a4d4dfe3ff4..2c030335792 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1020,7 +1020,6 @@ extern void grow_mini_window (struct window *, int, bool);
1020extern void shrink_mini_window (struct window *, bool); 1020extern void shrink_mini_window (struct window *, bool);
1021extern int window_relative_x_coord (struct window *, enum window_part, int); 1021extern int window_relative_x_coord (struct window *, enum window_part, int);
1022 1022
1023void run_window_configuration_change_hook (struct frame *f);
1024void run_window_size_change_functions (Lisp_Object); 1023void run_window_size_change_functions (Lisp_Object);
1025 1024
1026/* Make WINDOW display BUFFER. RUN_HOOKS_P means it's allowed 1025/* Make WINDOW display BUFFER. RUN_HOOKS_P means it's allowed