comparison src/sysdep.c @ 110730:09a7eef06018

Remove unused code. * src/sysdep.c (select_alarm, sys_select, read_input_waiting): Remove select emulation, all systems support select. (set_exclusive_use): Remove, the only user is in an #if 0 block. * src/process.c (create_process): Remove #if 0 code.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 03 Oct 2010 07:16:48 -0700
parents 5f187a091415
children 54e610201634
comparison
equal deleted inserted replaced
110729:99084f50aa8e 110730:09a7eef06018
297 ? baud_convert[emacs_ospeed] : 9600); 297 ? baud_convert[emacs_ospeed] : 9600);
298 if (baud_rate == 0) 298 if (baud_rate == 0)
299 baud_rate = 1200; 299 baud_rate = 1200;
300 } 300 }
301 301
302
303 /*ARGSUSED*/
304 void
305 set_exclusive_use (int fd)
306 {
307 #ifdef FIOCLEX
308 ioctl (fd, FIOCLEX, 0);
309 #endif
310 /* Ok to do nothing if this feature does not exist */
311 }
312 302
313 303
314 int wait_debugging; /* Set nonzero to make following function work under dbx 304 int wait_debugging; /* Set nonzero to make following function work under dbx
315 (at least for bsd). */ 305 (at least for bsd). */
316 306
481 #endif 471 #endif
482 472
483 EMACS_SET_TTY (out, &s, 0); 473 EMACS_SET_TTY (out, &s, 0);
484 #endif /* not WINDOWSNT */ 474 #endif /* not WINDOWSNT */
485 } 475 }
486 #endif /* MSDOS */ 476 #endif /* not MSDOS */
487 477
488 478
489 /* Record a signal code and the handler for it. */ 479 /* Record a signal code and the handler for it. */
490 struct save_signal 480 struct save_signal
491 { 481 {
1484 if (*p == ' ' || *p == '\t') 1474 if (*p == ' ' || *p == '\t')
1485 *p = '-'; 1475 *p = '-';
1486 } 1476 }
1487 } 1477 }
1488 1478
1489 #ifndef MSDOS
1490 #if !defined (HAVE_SELECT)
1491
1492 #include "sysselect.h"
1493 #undef select
1494
1495 #if defined (HAVE_X_WINDOWS) && !defined (HAVE_SELECT)
1496 /* Cause explanatory error message at compile time,
1497 since the select emulation is not good enough for X. */
1498 int *x = &x_windows_lose_if_no_select_system_call;
1499 #endif
1500
1501 /* Emulate as much as select as is possible under 4.1 and needed by Gnu Emacs
1502 * Only checks read descriptors.
1503 */
1504 /* How long to wait between checking fds in select */
1505 #define SELECT_PAUSE 1
1506 int select_alarmed;
1507
1508 /* For longjmp'ing back to read_input_waiting. */
1509
1510 jmp_buf read_alarm_throw;
1511
1512 /* Nonzero if the alarm signal should throw back to read_input_waiting.
1513 The read_socket_hook function sets this to 1 while it is waiting. */
1514
1515 int read_alarm_should_throw;
1516
1517 void
1518 select_alarm (int ignore)
1519 {
1520 select_alarmed = 1;
1521 signal (SIGALRM, SIG_IGN);
1522 SIGNAL_THREAD_CHECK (SIGALRM);
1523 if (read_alarm_should_throw)
1524 longjmp (read_alarm_throw, 1);
1525 }
1526
1527 #ifndef WINDOWSNT
1528 /* Only rfds are checked. */
1529 int
1530 sys_select (int nfds,
1531 SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
1532 EMACS_TIME *timeout)
1533 {
1534 /* XXX This needs to be updated for multi-tty support. Is there
1535 anybody who needs to emulate select these days? */
1536 int ravail = 0;
1537 SELECT_TYPE orfds;
1538 int timeoutval;
1539 int *local_timeout;
1540 extern int proc_buffered_char[];
1541 extern int process_tick, update_tick;
1542 unsigned char buf;
1543
1544 #if defined (HAVE_SELECT) && defined (HAVE_X_WINDOWS)
1545 /* If we're using X, then the native select will work; we only need the
1546 emulation for non-X usage. */
1547 if (!NILP (Vinitial_window_system))
1548 return select (nfds, rfds, wfds, efds, timeout);
1549 #endif
1550 timeoutval = timeout ? EMACS_SECS (*timeout) : 100000;
1551 local_timeout = &timeoutval;
1552 FD_ZERO (&orfds);
1553 if (rfds)
1554 {
1555 orfds = *rfds;
1556 FD_ZERO (rfds);
1557 }
1558 if (wfds)
1559 FD_ZERO (wfds);
1560 if (efds)
1561 FD_ZERO (efds);
1562
1563 /* If we are looking only for the terminal, with no timeout,
1564 just read it and wait -- that's more efficient. */
1565 if (*local_timeout == 100000 && process_tick == update_tick
1566 && FD_ISSET (0, &orfds))
1567 {
1568 int fd;
1569 for (fd = 1; fd < nfds; ++fd)
1570 if (FD_ISSET (fd, &orfds))
1571 goto hardway;
1572 if (! detect_input_pending ())
1573 read_input_waiting ();
1574 FD_SET (0, rfds);
1575 return 1;
1576 }
1577
1578 hardway:
1579 /* Once a second, till the timer expires, check all the flagged read
1580 * descriptors to see if any input is available. If there is some then
1581 * set the corresponding bit in the return copy of rfds.
1582 */
1583 while (1)
1584 {
1585 register int to_check, fd;
1586
1587 if (rfds)
1588 {
1589 for (to_check = nfds, fd = 0; --to_check >= 0; fd++)
1590 {
1591 if (FD_ISSET (fd, &orfds))
1592 {
1593 int avail = 0, status = 0;
1594
1595 if (fd == 0)
1596 avail = detect_input_pending (); /* Special keyboard handler */
1597 else
1598 {
1599 #ifdef FIONREAD
1600 status = ioctl (fd, FIONREAD, &avail);
1601 #else /* no FIONREAD */
1602 /* Hoping it will return -1 if nothing available
1603 or 0 if all 0 chars requested are read. */
1604 if (proc_buffered_char[fd] >= 0)
1605 avail = 1;
1606 else
1607 {
1608 avail = read (fd, &buf, 1);
1609 if (avail > 0)
1610 proc_buffered_char[fd] = buf;
1611 }
1612 #endif /* no FIONREAD */
1613 }
1614 if (status >= 0 && avail > 0)
1615 {
1616 FD_SET (fd, rfds);
1617 ravail++;
1618 }
1619 }
1620 }
1621 }
1622 if (*local_timeout == 0 || ravail != 0 || process_tick != update_tick)
1623 break;
1624
1625 turn_on_atimers (0);
1626 signal (SIGALRM, select_alarm);
1627 select_alarmed = 0;
1628 alarm (SELECT_PAUSE);
1629
1630 /* Wait for a SIGALRM (or maybe a SIGTINT) */
1631 while (select_alarmed == 0 && *local_timeout != 0
1632 && process_tick == update_tick)
1633 {
1634 /* If we are interested in terminal input,
1635 wait by reading the terminal.
1636 That makes instant wakeup for terminal input at least. */
1637 if (FD_ISSET (0, &orfds))
1638 {
1639 read_input_waiting ();
1640 if (detect_input_pending ())
1641 select_alarmed = 1;
1642 }
1643 else
1644 pause ();
1645 }
1646 (*local_timeout) -= SELECT_PAUSE;
1647
1648 /* Reset the old alarm if there was one. */
1649 turn_on_atimers (1);
1650
1651 if (*local_timeout == 0) /* Stop on timer being cleared */
1652 break;
1653 }
1654 return ravail;
1655 }
1656 #endif /* not WINDOWSNT */
1657
1658 /* Read keyboard input into the standard buffer,
1659 waiting for at least one character. */
1660
1661 void
1662 read_input_waiting (void)
1663 {
1664 /* XXX This needs to be updated for multi-tty support. Is there
1665 anybody who needs to emulate select these days? */
1666 int nread, i;
1667
1668 if (read_socket_hook)
1669 {
1670 struct input_event hold_quit;
1671
1672 EVENT_INIT (hold_quit);
1673 hold_quit.kind = NO_EVENT;
1674
1675 read_alarm_should_throw = 0;
1676 if (! setjmp (read_alarm_throw))
1677 nread = (*read_socket_hook) (0, 1, &hold_quit);
1678 else
1679 nread = -1;
1680
1681 if (hold_quit.kind != NO_EVENT)
1682 kbd_buffer_store_event (&hold_quit);
1683 }
1684 else
1685 {
1686 struct input_event e;
1687 char buf[3];
1688 nread = read (fileno (stdin), buf, 1);
1689 EVENT_INIT (e);
1690
1691 /* Scan the chars for C-g and store them in kbd_buffer. */
1692 e.kind = ASCII_KEYSTROKE_EVENT;
1693 e.frame_or_window = selected_frame;
1694 e.modifiers = 0;
1695 for (i = 0; i < nread; i++)
1696 {
1697 /* Convert chars > 0177 to meta events if desired.
1698 We do this under the same conditions that read_avail_input does. */
1699 if (read_socket_hook == 0)
1700 {
1701 /* If the user says she has a meta key, then believe her. */
1702 if (meta_key == 1 && (buf[i] & 0x80))
1703 e.modifiers = meta_modifier;
1704 if (meta_key != 2)
1705 buf[i] &= ~0x80;
1706 }
1707
1708 XSETINT (e.code, buf[i]);
1709 kbd_buffer_store_event (&e);
1710 /* Don't look at input that follows a C-g too closely.
1711 This reduces lossage due to autorepeat on C-g. */
1712 if (buf[i] == quit_char)
1713 break;
1714 }
1715 }
1716 }
1717
1718 #if !defined (HAVE_SELECT)
1719 #define select sys_select
1720 #endif
1721
1722 #endif /* not HAVE_SELECT */
1723 #endif /* not MSDOS */
1724
1725 /* POSIX signals support - DJB */ 1479 /* POSIX signals support - DJB */
1726 /* Anyone with POSIX signals should have ANSI C declarations */ 1480 /* Anyone with POSIX signals should have ANSI C declarations */
1727 1481
1728 sigset_t empty_mask, full_mask; 1482 sigset_t empty_mask, full_mask;
1729 1483
2269 */ 2023 */
2270 2024
2271 #ifndef HAVE_GETTIMEOFDAY 2025 #ifndef HAVE_GETTIMEOFDAY
2272 #ifdef HAVE_TIMEVAL 2026 #ifdef HAVE_TIMEVAL
2273 2027
2274 /* ARGSUSED */
2275 int 2028 int
2276 gettimeofday (struct timeval *tp, struct timezone *tzp) 2029 gettimeofday (struct timeval *tp, struct timezone *tzp)
2277 { 2030 {
2278 extern long time (long); 2031 extern long time (long);
2279 2032