comparison src/sysdep.c @ 109126:aec1143e8d85

Convert (most) functions in src to standard C. * src/alloc.c: Convert function definitions to standard C. * src/atimer.c: * src/bidi.c: * src/bytecode.c: * src/callint.c: * src/callproc.c: * src/casefiddle.c: * src/casetab.c: * src/category.c: * src/ccl.c: * src/character.c: * src/charset.c: * src/chartab.c: * src/cmds.c: * src/coding.c: * src/composite.c: * src/data.c: * src/dbusbind.c: * src/dired.c: * src/dispnew.c: * src/doc.c: * src/doprnt.c: * src/ecrt0.c: * src/editfns.c: * src/fileio.c: * src/filelock.c: * src/filemode.c: * src/fns.c: * src/font.c: * src/fontset.c: * src/frame.c: * src/fringe.c: * src/ftfont.c: * src/ftxfont.c: * src/gtkutil.c: * src/indent.c: * src/insdel.c: * src/intervals.c: * src/keymap.c: * src/lread.c: * src/macros.c: * src/marker.c: * src/md5.c: * src/menu.c: * src/minibuf.c: * src/prefix-args.c: * src/print.c: * src/ralloc.c: * src/regex.c: * src/region-cache.c: * src/scroll.c: * src/search.c: * src/sound.c: * src/strftime.c: * src/syntax.c: * src/sysdep.c: * src/termcap.c: * src/terminal.c: * src/terminfo.c: * src/textprop.c: * src/tparam.c: * src/undo.c: * src/unexelf.c: * src/window.c: * src/xfaces.c: * src/xfns.c: * src/xfont.c: * src/xftfont.c: * src/xgselect.c: * src/xmenu.c: * src/xrdb.c: * src/xselect.c: * src/xsettings.c: * src/xsmfns.c: * src/xterm.c: Likewise.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 04 Jul 2010 00:50:25 -0700
parents 2bc9a0c04c87
children cd13b432f239
comparison
equal deleted inserted replaced
109125:12b02558bf51 109126:aec1143e8d85
252 252
253 253
254 /* Discard pending input on all input descriptors. */ 254 /* Discard pending input on all input descriptors. */
255 255
256 void 256 void
257 discard_tty_input () 257 discard_tty_input (void)
258 { 258 {
259 #ifndef WINDOWSNT 259 #ifndef WINDOWSNT
260 struct emacs_tty buf; 260 struct emacs_tty buf;
261 261
262 if (noninteractive) 262 if (noninteractive)
351 } 351 }
352 352
353 353
354 /*ARGSUSED*/ 354 /*ARGSUSED*/
355 void 355 void
356 set_exclusive_use (fd) 356 set_exclusive_use (int fd)
357 int fd;
358 { 357 {
359 #ifdef FIOCLEX 358 #ifdef FIOCLEX
360 ioctl (fd, FIOCLEX, 0); 359 ioctl (fd, FIOCLEX, 0);
361 #endif 360 #endif
362 /* Ok to do nothing if this feature does not exist */ 361 /* Ok to do nothing if this feature does not exist */
374 373
375 int wait_debugging; /* Set nonzero to make following function work under dbx 374 int wait_debugging; /* Set nonzero to make following function work under dbx
376 (at least for bsd). */ 375 (at least for bsd). */
377 376
378 SIGTYPE 377 SIGTYPE
379 wait_for_termination_signal () 378 wait_for_termination_signal (void)
380 {} 379 {}
381 380
382 /* Wait for subprocess with process id `pid' to terminate and 381 /* Wait for subprocess with process id `pid' to terminate and
383 make sure it will get eliminated (not remain forever as a zombie) */ 382 make sure it will get eliminated (not remain forever as a zombie) */
384 383
385 void 384 void
386 wait_for_termination (pid) 385 wait_for_termination (int pid)
387 int pid;
388 { 386 {
389 while (1) 387 while (1)
390 { 388 {
391 #ifdef subprocesses 389 #ifdef subprocesses
392 #if defined (BSD_SYSTEM) || defined (HPUX) 390 #if defined (BSD_SYSTEM) || defined (HPUX)
436 * flush any pending output 434 * flush any pending output
437 * (may flush input as well; it does not matter the way we use it) 435 * (may flush input as well; it does not matter the way we use it)
438 */ 436 */
439 437
440 void 438 void
441 flush_pending_output (channel) 439 flush_pending_output (int channel)
442 int channel;
443 { 440 {
444 #ifdef HAVE_TERMIOS 441 #ifdef HAVE_TERMIOS
445 /* If we try this, we get hit with SIGTTIN, because 442 /* If we try this, we get hit with SIGTTIN, because
446 the child's tty belongs to the child's pgrp. */ 443 the child's tty belongs to the child's pgrp. */
447 #else 444 #else
463 we will be controlling an inferior through. 460 we will be controlling an inferior through.
464 It should not echo or do line-editing, since that is done 461 It should not echo or do line-editing, since that is done
465 in Emacs. No padding needed for insertion into an Emacs buffer. */ 462 in Emacs. No padding needed for insertion into an Emacs buffer. */
466 463
467 void 464 void
468 child_setup_tty (out) 465 child_setup_tty (int out)
469 int out;
470 { 466 {
471 #ifndef DOS_NT 467 #ifndef DOS_NT
472 struct emacs_tty s; 468 struct emacs_tty s;
473 469
474 EMACS_GET_TTY (out, &s); 470 EMACS_GET_TTY (out, &s);
568 static void restore_signal_handlers (struct save_signal *); 564 static void restore_signal_handlers (struct save_signal *);
569 565
570 /* Suspend the Emacs process; give terminal to its superior. */ 566 /* Suspend the Emacs process; give terminal to its superior. */
571 567
572 void 568 void
573 sys_suspend () 569 sys_suspend (void)
574 { 570 {
575 #if defined (SIGTSTP) && !defined (MSDOS) 571 #if defined (SIGTSTP) && !defined (MSDOS)
576 572
577 { 573 {
578 int pgrp = EMACS_GETPGRP (0); 574 int pgrp = EMACS_GETPGRP (0);
589 } 585 }
590 586
591 /* Fork a subshell. */ 587 /* Fork a subshell. */
592 588
593 void 589 void
594 sys_subshell () 590 sys_subshell (void)
595 { 591 {
596 #ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */ 592 #ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */
597 int st; 593 int st;
598 char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */ 594 char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */
599 #endif 595 #endif
717 restore_signal_handlers (saved_handlers); 713 restore_signal_handlers (saved_handlers);
718 synch_process_alive = 0; 714 synch_process_alive = 0;
719 } 715 }
720 716
721 static void 717 static void
722 save_signal_handlers (saved_handlers) 718 save_signal_handlers (struct save_signal *saved_handlers)
723 struct save_signal *saved_handlers;
724 { 719 {
725 while (saved_handlers->code) 720 while (saved_handlers->code)
726 { 721 {
727 saved_handlers->handler 722 saved_handlers->handler
728 = (SIGTYPE (*) (int)) signal (saved_handlers->code, SIG_IGN); 723 = (SIGTYPE (*) (int)) signal (saved_handlers->code, SIG_IGN);
729 saved_handlers++; 724 saved_handlers++;
730 } 725 }
731 } 726 }
732 727
733 static void 728 static void
734 restore_signal_handlers (saved_handlers) 729 restore_signal_handlers (struct save_signal *saved_handlers)
735 struct save_signal *saved_handlers;
736 { 730 {
737 while (saved_handlers->code) 731 while (saved_handlers->code)
738 { 732 {
739 signal (saved_handlers->code, saved_handlers->handler); 733 signal (saved_handlers->code, saved_handlers->handler);
740 saved_handlers++; 734 saved_handlers++;
767 #ifdef F_SETFL 761 #ifdef F_SETFL
768 762
769 int old_fcntl_flags[MAXDESC]; 763 int old_fcntl_flags[MAXDESC];
770 764
771 void 765 void
772 init_sigio (fd) 766 init_sigio (int fd)
773 int fd;
774 { 767 {
775 #ifdef FASYNC 768 #ifdef FASYNC
776 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; 769 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC;
777 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); 770 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC);
778 #endif 771 #endif
779 interrupts_deferred = 0; 772 interrupts_deferred = 0;
780 } 773 }
781 774
782 void 775 void
783 reset_sigio (fd) 776 reset_sigio (int fd)
784 int fd;
785 { 777 {
786 #ifdef FASYNC 778 #ifdef FASYNC
787 fcntl (fd, F_SETFL, old_fcntl_flags[fd]); 779 fcntl (fd, F_SETFL, old_fcntl_flags[fd]);
788 #endif 780 #endif
789 } 781 }
791 #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ 783 #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */
792 /* XXX Uhm, FASYNC is not used anymore here. */ 784 /* XXX Uhm, FASYNC is not used anymore here. */
793 /* XXX Yeah, but you need it for SIGIO, don't you? */ 785 /* XXX Yeah, but you need it for SIGIO, don't you? */
794 786
795 void 787 void
796 request_sigio () 788 request_sigio (void)
797 { 789 {
798 if (noninteractive) 790 if (noninteractive)
799 return; 791 return;
800 792
801 #ifdef SIGWINCH 793 #ifdef SIGWINCH
855 847
856 /* Set *TC to the parameters associated with the terminal FD. 848 /* Set *TC to the parameters associated with the terminal FD.
857 Return zero if all's well, or -1 if we ran into an error we 849 Return zero if all's well, or -1 if we ran into an error we
858 couldn't deal with. */ 850 couldn't deal with. */
859 int 851 int
860 emacs_get_tty (fd, settings) 852 emacs_get_tty (int fd, struct emacs_tty *settings)
861 int fd;
862 struct emacs_tty *settings;
863 { 853 {
864 /* Retrieve the primary parameters - baud rate, character size, etcetera. */ 854 /* Retrieve the primary parameters - baud rate, character size, etcetera. */
865 #ifdef HAVE_TCATTR 855 #ifdef HAVE_TCATTR
866 /* We have those nifty POSIX tcmumbleattr functions. */ 856 /* We have those nifty POSIX tcmumbleattr functions. */
867 bzero (&settings->main, sizeof (settings->main)); 857 bzero (&settings->main, sizeof (settings->main));
904 /* Set the parameters of the tty on FD according to the contents of 894 /* Set the parameters of the tty on FD according to the contents of
905 *SETTINGS. If FLUSHP is non-zero, we discard input. 895 *SETTINGS. If FLUSHP is non-zero, we discard input.
906 Return 0 if all went well, and -1 if anything failed. */ 896 Return 0 if all went well, and -1 if anything failed. */
907 897
908 int 898 int
909 emacs_set_tty (fd, settings, flushp) 899 emacs_set_tty (int fd, struct emacs_tty *settings, int flushp)
910 int fd;
911 struct emacs_tty *settings;
912 int flushp;
913 { 900 {
914 /* Set the primary parameters - baud rate, character size, etcetera. */ 901 /* Set the primary parameters - baud rate, character size, etcetera. */
915 #ifdef HAVE_TCATTR 902 #ifdef HAVE_TCATTR
916 int i; 903 int i;
917 /* We have those nifty POSIX tcmumbleattr functions. 904 /* We have those nifty POSIX tcmumbleattr functions.
1019 } 1006 }
1020 1007
1021 /* Initialize the terminal mode on the given tty device. */ 1008 /* Initialize the terminal mode on the given tty device. */
1022 1009
1023 void 1010 void
1024 init_sys_modes (tty_out) 1011 init_sys_modes (struct tty_display_info *tty_out)
1025 struct tty_display_info *tty_out;
1026 { 1012 {
1027 struct emacs_tty tty; 1013 struct emacs_tty tty;
1028 1014
1029 Vtty_erase_char = Qnil; 1015 Vtty_erase_char = Qnil;
1030 1016
1363 1349
1364 /* Set the logical window size associated with descriptor FD 1350 /* Set the logical window size associated with descriptor FD
1365 to HEIGHT and WIDTH. This is used mainly with ptys. */ 1351 to HEIGHT and WIDTH. This is used mainly with ptys. */
1366 1352
1367 int 1353 int
1368 set_window_size (fd, height, width) 1354 set_window_size (int fd, int height, int width)
1369 int fd, height, width;
1370 { 1355 {
1371 #ifdef TIOCSWINSZ 1356 #ifdef TIOCSWINSZ
1372 1357
1373 /* BSD-style. */ 1358 /* BSD-style. */
1374 struct winsize size; 1359 struct winsize size;
1412 1397
1413 /* Prepare the terminal for closing it; move the cursor to the 1398 /* Prepare the terminal for closing it; move the cursor to the
1414 bottom of the frame, turn off interrupt-driven I/O, etc. */ 1399 bottom of the frame, turn off interrupt-driven I/O, etc. */
1415 1400
1416 void 1401 void
1417 reset_sys_modes (tty_out) 1402 reset_sys_modes (struct tty_display_info *tty_out)
1418 struct tty_display_info *tty_out;
1419 { 1403 {
1420 if (noninteractive) 1404 if (noninteractive)
1421 { 1405 {
1422 fflush (stdout); 1406 fflush (stdout);
1423 return; 1407 return;
1488 #ifdef HAVE_PTYS 1472 #ifdef HAVE_PTYS
1489 1473
1490 /* Set up the proper status flags for use of a pty. */ 1474 /* Set up the proper status flags for use of a pty. */
1491 1475
1492 void 1476 void
1493 setup_pty (fd) 1477 setup_pty (int fd)
1494 int fd;
1495 { 1478 {
1496 /* I'm told that TOICREMOTE does not mean control chars 1479 /* I'm told that TOICREMOTE does not mean control chars
1497 "can't be sent" but rather that they don't have 1480 "can't be sent" but rather that they don't have
1498 input-editing or signaling effects. 1481 input-editing or signaling effects.
1499 That should be good, because we have other ways 1482 That should be good, because we have other ways
1538 */ 1521 */
1539 1522
1540 #if !(defined (__NetBSD__) && defined (__ELF__)) 1523 #if !(defined (__NetBSD__) && defined (__ELF__))
1541 #ifndef HAVE_TEXT_START 1524 #ifndef HAVE_TEXT_START
1542 char * 1525 char *
1543 start_of_text () 1526 start_of_text (void)
1544 { 1527 {
1545 #ifdef TEXT_START 1528 #ifdef TEXT_START
1546 return ((char *) TEXT_START); 1529 return ((char *) TEXT_START);
1547 #else 1530 #else
1548 extern int _start (); 1531 extern int _start ();
1578 * 1561 *
1579 */ 1562 */
1580 1563
1581 #ifndef start_of_data 1564 #ifndef start_of_data
1582 char * 1565 char *
1583 start_of_data () 1566 start_of_data (void)
1584 { 1567 {
1585 #ifdef DATA_START 1568 #ifdef DATA_START
1586 return ((char *) DATA_START); 1569 return ((char *) DATA_START);
1587 #else 1570 #else
1588 #ifdef ORDINARY_LINK 1571 #ifdef ORDINARY_LINK
1619 extern int h_errno; 1602 extern int h_errno;
1620 #endif 1603 #endif
1621 #endif /* TRY_AGAIN */ 1604 #endif /* TRY_AGAIN */
1622 1605
1623 void 1606 void
1624 init_system_name () 1607 init_system_name (void)
1625 { 1608 {
1626 #ifndef HAVE_GETHOSTNAME 1609 #ifndef HAVE_GETHOSTNAME
1627 struct utsname uts; 1610 struct utsname uts;
1628 uname (&uts); 1611 uname (&uts);
1629 Vsystem_name = build_string (uts.nodename); 1612 Vsystem_name = build_string (uts.nodename);
2075 # endif 2058 # endif
2076 # define sys_siglist my_sys_siglist 2059 # define sys_siglist my_sys_siglist
2077 #endif 2060 #endif
2078 2061
2079 void 2062 void
2080 init_signals () 2063 init_signals (void)
2081 { 2064 {
2082 sigemptyset (&empty_mask); 2065 sigemptyset (&empty_mask);
2083 sigfillset (&full_mask); 2066 sigfillset (&full_mask);
2084 2067
2085 #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 2068 #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
2281 # endif /* !HAVE_LRAND48 */ 2264 # endif /* !HAVE_LRAND48 */
2282 # endif /* !HAVE_RANDOM */ 2265 # endif /* !HAVE_RANDOM */
2283 #endif /* !RAND_BITS */ 2266 #endif /* !RAND_BITS */
2284 2267
2285 void 2268 void
2286 seed_random (arg) 2269 seed_random (long int arg)
2287 long arg;
2288 { 2270 {
2289 #ifdef HAVE_RANDOM 2271 #ifdef HAVE_RANDOM
2290 srandom ((unsigned int)arg); 2272 srandom ((unsigned int)arg);
2291 #else 2273 #else
2292 # ifdef HAVE_LRAND48 2274 # ifdef HAVE_LRAND48
2300 /* 2282 /*
2301 * Build a full Emacs-sized word out of whatever we've got. 2283 * Build a full Emacs-sized word out of whatever we've got.
2302 * This suffices even for a 64-bit architecture with a 15-bit rand. 2284 * This suffices even for a 64-bit architecture with a 15-bit rand.
2303 */ 2285 */
2304 long 2286 long
2305 get_random () 2287 get_random (void)
2306 { 2288 {
2307 long val = random (); 2289 long val = random ();
2308 #if VALBITS > RAND_BITS 2290 #if VALBITS > RAND_BITS
2309 val = (val << RAND_BITS) ^ random (); 2291 val = (val << RAND_BITS) ^ random ();
2310 #if VALBITS > 2*RAND_BITS 2292 #if VALBITS > 2*RAND_BITS
2335 } 2317 }
2336 #endif /* not WINDOWSNT */ 2318 #endif /* not WINDOWSNT */
2337 #endif /* ! HAVE_STRERROR */ 2319 #endif /* ! HAVE_STRERROR */
2338 2320
2339 int 2321 int
2340 emacs_open (path, oflag, mode) 2322 emacs_open (const char *path, int oflag, int mode)
2341 const char *path;
2342 int oflag, mode;
2343 { 2323 {
2344 register int rtnval; 2324 register int rtnval;
2345 2325
2346 while ((rtnval = open (path, oflag, mode)) == -1 2326 while ((rtnval = open (path, oflag, mode)) == -1
2347 && (errno == EINTR)) 2327 && (errno == EINTR))
2348 QUIT; 2328 QUIT;
2349 return (rtnval); 2329 return (rtnval);
2350 } 2330 }
2351 2331
2352 int 2332 int
2353 emacs_close (fd) 2333 emacs_close (int fd)
2354 int fd;
2355 { 2334 {
2356 int did_retry = 0; 2335 int did_retry = 0;
2357 register int rtnval; 2336 register int rtnval;
2358 2337
2359 while ((rtnval = close (fd)) == -1 2338 while ((rtnval = close (fd)) == -1
2368 2347
2369 return rtnval; 2348 return rtnval;
2370 } 2349 }
2371 2350
2372 int 2351 int
2373 emacs_read (fildes, buf, nbyte) 2352 emacs_read (int fildes, char *buf, unsigned int nbyte)
2374 int fildes;
2375 char *buf;
2376 unsigned int nbyte;
2377 { 2353 {
2378 register int rtnval; 2354 register int rtnval;
2379 2355
2380 while ((rtnval = read (fildes, buf, nbyte)) == -1 2356 while ((rtnval = read (fildes, buf, nbyte)) == -1
2381 && (errno == EINTR)) 2357 && (errno == EINTR))
2382 QUIT; 2358 QUIT;
2383 return (rtnval); 2359 return (rtnval);
2384 } 2360 }
2385 2361
2386 int 2362 int
2387 emacs_write (fildes, buf, nbyte) 2363 emacs_write (int fildes, const char *buf, unsigned int nbyte)
2388 int fildes;
2389 const char *buf;
2390 unsigned int nbyte;
2391 { 2364 {
2392 register int rtnval, bytes_written; 2365 register int rtnval, bytes_written;
2393 2366
2394 bytes_written = 0; 2367 bytes_written = 0;
2395 2368
2572 /* 2545 /*
2573 * This function will go away as soon as all the stubs fixed. (fnf) 2546 * This function will go away as soon as all the stubs fixed. (fnf)
2574 */ 2547 */
2575 2548
2576 void 2549 void
2577 croak (badfunc) 2550 croak (char *badfunc)
2578 char *badfunc;
2579 { 2551 {
2580 printf ("%s not yet implemented\r\n", badfunc); 2552 printf ("%s not yet implemented\r\n", badfunc);
2581 reset_all_sys_modes (); 2553 reset_all_sys_modes ();
2582 exit (1); 2554 exit (1);
2583 } 2555 }
2605 #endif /* not HAVE_CLOSEDIR */ 2577 #endif /* not HAVE_CLOSEDIR */
2606 #endif /* SYSV_SYSTEM_DIR */ 2578 #endif /* SYSV_SYSTEM_DIR */
2607 2579
2608 2580
2609 int 2581 int
2610 set_file_times (filename, atime, mtime) 2582 set_file_times (const char *filename, struct timeval atime, struct timeval mtime)
2611 const char *filename;
2612 EMACS_TIME atime, mtime;
2613 { 2583 {
2614 #ifdef HAVE_UTIMES 2584 #ifdef HAVE_UTIMES
2615 struct timeval tv[2]; 2585 struct timeval tv[2];
2616 tv[0] = atime; 2586 tv[0] = atime;
2617 tv[1] = mtime; 2587 tv[1] = mtime;
2991 #ifdef HAVE_PROCFS 2961 #ifdef HAVE_PROCFS
2992 2962
2993 /* Process enumeration and access via /proc. */ 2963 /* Process enumeration and access via /proc. */
2994 2964
2995 Lisp_Object 2965 Lisp_Object
2996 list_system_processes () 2966 list_system_processes (void)
2997 { 2967 {
2998 Lisp_Object procdir, match, proclist, next; 2968 Lisp_Object procdir, match, proclist, next;
2999 struct gcpro gcpro1, gcpro2; 2969 struct gcpro gcpro1, gcpro2;
3000 register Lisp_Object tail; 2970 register Lisp_Object tail;
3001 2971