aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2005-05-13 22:59:23 +0000
committerKaroly Lorentey2005-05-13 22:59:23 +0000
commit892f9671ada52150f280915fb34970b7acb0312a (patch)
tree24e447c3c289704486aaf0c761a4b31360f7ddf8 /src
parentd585a729699a4a5d55ece3f773d1ae497067085a (diff)
parent5063dbbf5a6145d5feb0c951d153d376bebb668f (diff)
downloademacs-892f9671ada52150f280915fb34970b7acb0312a.tar.gz
emacs-892f9671ada52150f280915fb34970b7acb0312a.zip
Merged from miles@gnu.org--gnu-2005 (patch 296-306)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-296 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-297 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-298 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-300 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-301 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-302 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-303 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-304 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-305 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-306 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-344
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog51
-rw-r--r--src/emacs.c3
-rw-r--r--src/image.c1
-rw-r--r--src/keyboard.c37
-rw-r--r--src/mac.c299
-rw-r--r--src/macfns.c1
-rw-r--r--src/macmenu.c1
-rw-r--r--src/macselect.c4
-rw-r--r--src/macterm.c85
-rw-r--r--src/unexmacosx.c96
-rw-r--r--src/xfns.c1
-rw-r--r--src/xmenu.c2
-rw-r--r--src/xterm.c6
13 files changed, 385 insertions, 202 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a8e248a1718..a86f78e5b96 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,54 @@
12005-05-13 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * emacs.c (main) [MAC_OS8]: Call init_atimer before mac_term_init.
4
5 * keyboard.c (readable_events) [USE_TOOLKIT_SCROLL_BARS]: Regard
6 toolkit scroll bar thumb drag events as squeezable and prevent
7 redisplay from being paused by them.
8
9 * mac.c [!MAC_OSX]: Include keyboard.h and syssignal.h.
10 [!MAC_OSX] (target_ticks): Remove variable.
11 [!MAC_OSX] (check_alarm, pause, index): Remove functions.
12 [!MAC_OSX && __MRC__] (sys_strftime): Likewise.
13 [!MAC_OSX] (select): If fd 0 is not set in rfds and some input
14 event occurs before timeout, behave as if the function were
15 interrupted.
16 [!MAC_OSX] (sigblock, sigsetmask, alarm): Simulate SIGALRM
17 handling using Time Manager routines.
18 [!MAC_OSX] (mac_atimer_task, mac_atimer_qlink, signal_mask): New
19 variables.
20 [!MAC_OSX] (mac_atimer_handler, set_mac_atimer, remove_mac_atimer)
21 (setitimer): New functions.
22
23 * macfns.c, macmenu.c: Don't include signal.h.
24
25 * macterm.c [USE_TOOLKIT_SCROLL_BARS] (get_control_part_bounds):
26 Rename from get_control_part_bound. All callers changed.
27 (x_scroll_bar_clear): New function.
28 (x_clear_frame): Use it.
29 (XTset_vertical_scroll_bar): Don't call Draw1Control.
30 (x_scroll_bar_handle_click): Change type of second argument from
31 int to ControlPartCode.
32 (check_alarm): Remove declaration.
33 (XTread_Socket) [!TARGET_API_MAC_CARBON]: Don't call it.
34 (XTread_Socket): Use ControlPartCode instead of SInt16.
35
362005-05-13 Nozomu Ando <nand@mac.com>
37
38 * unexmacosx.c: Include assert.h.
39 (MACOSX_MALLOC_MULT16): New define.
40 [MACOSX_MALLOC_MULT16] (ptr_in_unexec_regions): Determine whether
41 ptr is in unexec regions by checking it is multiple of 16.
42 (unexec_malloc_header_t): New typedef.
43 (unexec_malloc, unexec_realloc, unexec_free): Store and use
44 allocated size information in unexec_malloc_header.
45
462005-05-10 Richard M. Stallman <rms@gnu.org>
47
48 * xterm.c (noinclude): Add #undef.
49
50 * image.c, xfns.c, xmenu.c: Don't include signal.h.
51
12005-05-09 Juanma Barranquero <lekktu@gmail.com> 522005-05-09 Juanma Barranquero <lekktu@gmail.com>
2 53
3 * fileio.c (Fexpand_file_name, Frename_file, Fadd_name_to_file) 54 * fileio.c (Fexpand_file_name, Frename_file, Fadd_name_to_file)
diff --git a/src/emacs.c b/src/emacs.c
index 67cf1eb03be..a1805c6497a 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1326,6 +1326,7 @@ main (argc, argv
1326 syms_of_search (); 1326 syms_of_search ();
1327 syms_of_frame (); 1327 syms_of_frame ();
1328 1328
1329 init_atimer ();
1329 mac_term_init (build_string ("Mac"), NULL, NULL); 1330 mac_term_init (build_string ("Mac"), NULL, NULL);
1330 init_keyboard (); 1331 init_keyboard ();
1331#endif 1332#endif
@@ -1351,7 +1352,9 @@ main (argc, argv
1351#ifdef CLASH_DETECTION 1352#ifdef CLASH_DETECTION
1352 init_filelock (); 1353 init_filelock ();
1353#endif 1354#endif
1355#ifndef MAC_OS8
1354 init_atimer (); 1356 init_atimer ();
1357#endif
1355 running_asynch_code = 0; 1358 running_asynch_code = 0;
1356 1359
1357 /* Handle --unibyte and the EMACS_UNIBYTE envvar, 1360 /* Handle --unibyte and the EMACS_UNIBYTE envvar,
diff --git a/src/image.c b/src/image.c
index 6a1fc7aa795..f03adfdc48f 100644
--- a/src/image.c
+++ b/src/image.c
@@ -20,7 +20,6 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */ 20Boston, MA 02111-1307, USA. */
21 21
22#include <config.h> 22#include <config.h>
23#include <signal.h>
24#include <stdio.h> 23#include <stdio.h>
25#include <math.h> 24#include <math.h>
26#include <ctype.h> 25#include <ctype.h>
diff --git a/src/keyboard.c b/src/keyboard.c
index e78b51d247b..596df7aed79 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3525,9 +3525,11 @@ readable_events (flags)
3525 READABLE_EVENTS_FILTER_EVENTS is set, report it as empty. */ 3525 READABLE_EVENTS_FILTER_EVENTS is set, report it as empty. */
3526 if (kbd_fetch_ptr != kbd_store_ptr) 3526 if (kbd_fetch_ptr != kbd_store_ptr)
3527 { 3527 {
3528 int have_live_event = 1; 3528 if (flags & (READABLE_EVENTS_FILTER_EVENTS
3529 3529#ifdef USE_TOOLKIT_SCROLL_BARS
3530 if (flags & READABLE_EVENTS_FILTER_EVENTS) 3530 | READABLE_EVENTS_IGNORE_SQUEEZABLES
3531#endif
3532 ))
3531 { 3533 {
3532 struct input_event *event; 3534 struct input_event *event;
3533 3535
@@ -3535,16 +3537,29 @@ readable_events (flags)
3535 ? kbd_fetch_ptr 3537 ? kbd_fetch_ptr
3536 : kbd_buffer); 3538 : kbd_buffer);
3537 3539
3538 while (have_live_event && event->kind == FOCUS_IN_EVENT) 3540 do
3539 { 3541 {
3540 event++; 3542 if (!(
3543#ifdef USE_TOOLKIT_SCROLL_BARS
3544 (flags & READABLE_EVENTS_FILTER_EVENTS) &&
3545#endif
3546 event->kind == FOCUS_IN_EVENT)
3547#ifdef USE_TOOLKIT_SCROLL_BARS
3548 && !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
3549 && event->kind == SCROLL_BAR_CLICK_EVENT
3550 && event->part == scroll_bar_handle
3551 && event->modifiers == 0)
3552#endif
3553 )
3554 return 1;
3555 event++;
3541 if (event == kbd_buffer + KBD_BUFFER_SIZE) 3556 if (event == kbd_buffer + KBD_BUFFER_SIZE)
3542 event = kbd_buffer; 3557 event = kbd_buffer;
3543 if (event == kbd_store_ptr) 3558 }
3544 have_live_event = 0; 3559 while (event != kbd_store_ptr);
3545 }
3546 } 3560 }
3547 if (have_live_event) return 1; 3561 else
3562 return 1;
3548 } 3563 }
3549 3564
3550#ifdef HAVE_MOUSE 3565#ifdef HAVE_MOUSE
@@ -6543,7 +6558,7 @@ lucid_event_type_list_p (object)
6543 If READABLE_EVENTS_FILTER_EVENTS is set in FLAGS, ignore internal 6558 If READABLE_EVENTS_FILTER_EVENTS is set in FLAGS, ignore internal
6544 events (FOCUS_IN_EVENT). 6559 events (FOCUS_IN_EVENT).
6545 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse 6560 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse
6546 movements. */ 6561 movements and toolkit scroll bar thumb drags. */
6547 6562
6548static void 6563static void
6549get_input_pending (addr, flags) 6564get_input_pending (addr, flags)
diff --git a/src/mac.c b/src/mac.c
index 14257fdee94..eaf4f029cf1 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -1672,37 +1672,7 @@ sys_fopen (const char *name, const char *mode)
1672} 1672}
1673 1673
1674 1674
1675long target_ticks = 0; 1675#include "keyboard.h"
1676
1677#ifdef __MRC__
1678__sigfun alarm_signal_func = (__sigfun) 0;
1679#elif __MWERKS__
1680__signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0;
1681#else /* not __MRC__ and not __MWERKS__ */
1682You lose!!!
1683#endif /* not __MRC__ and not __MWERKS__ */
1684
1685
1686/* These functions simulate SIG_ALRM. The stub for function signal
1687 stores the signal handler function in alarm_signal_func if a
1688 SIG_ALRM is encountered. check_alarm is called in XTread_socket,
1689 which emacs calls periodically. A pending alarm is represented by
1690 a non-zero target_ticks value. check_alarm calls the handler
1691 function pointed to by alarm_signal_func if one has been set up and
1692 an alarm is pending. */
1693
1694void
1695check_alarm ()
1696{
1697 if (target_ticks && TickCount () > target_ticks)
1698 {
1699 target_ticks = 0;
1700 if (alarm_signal_func)
1701 (*alarm_signal_func)(SIGALRM);
1702 }
1703}
1704
1705
1706extern Boolean mac_wait_next_event (EventRecord *, UInt32, Boolean); 1676extern Boolean mac_wait_next_event (EventRecord *, UInt32, Boolean);
1707 1677
1708int 1678int
@@ -1713,25 +1683,17 @@ select (n, rfds, wfds, efds, timeout)
1713 SELECT_TYPE *efds; 1683 SELECT_TYPE *efds;
1714 struct timeval *timeout; 1684 struct timeval *timeout;
1715{ 1685{
1716#if TARGET_API_MAC_CARBON
1717 OSErr err; 1686 OSErr err;
1687#if TARGET_API_MAC_CARBON
1718 EventTimeout timeout_sec = 1688 EventTimeout timeout_sec =
1719 (timeout 1689 (timeout
1720 ? (EMACS_SECS (*timeout) * kEventDurationSecond 1690 ? (EMACS_SECS (*timeout) * kEventDurationSecond
1721 + EMACS_USECS (*timeout) * kEventDurationMicrosecond) 1691 + EMACS_USECS (*timeout) * kEventDurationMicrosecond)
1722 : kEventDurationForever); 1692 : kEventDurationForever);
1723 1693
1724 if (FD_ISSET (0, rfds)) 1694 BLOCK_INPUT;
1725 { 1695 err = ReceiveNextEvent (0, NULL, timeout_sec, kEventLeaveInQueue, NULL);
1726 BLOCK_INPUT; 1696 UNBLOCK_INPUT;
1727 err = ReceiveNextEvent (0, NULL, timeout_sec, kEventLeaveInQueue, NULL);
1728 UNBLOCK_INPUT;
1729 if (err == noErr)
1730 return 1;
1731 else
1732 FD_ZERO (rfds);
1733 }
1734 return 0;
1735#else /* not TARGET_API_MAC_CARBON */ 1697#else /* not TARGET_API_MAC_CARBON */
1736 EventRecord e; 1698 EventRecord e;
1737 UInt32 sleep_time = EMACS_SECS (*timeout) * 60 + 1699 UInt32 sleep_time = EMACS_SECS (*timeout) * 60 +
@@ -1746,47 +1708,62 @@ select (n, rfds, wfds, efds, timeout)
1746 read_avail_input which in turn calls XTread_socket to poll for 1708 read_avail_input which in turn calls XTread_socket to poll for
1747 these events. Otherwise these never get processed except but a 1709 these events. Otherwise these never get processed except but a
1748 very slow poll timer. */ 1710 very slow poll timer. */
1749 if (FD_ISSET (0, rfds) && mac_wait_next_event (&e, sleep_time, false)) 1711 if (mac_wait_next_event (&e, sleep_time, false))
1750 return 1; 1712 err = noErr;
1751 1713 else
1752 return 0; 1714 err = -9875; /* eventLoopTimedOutErr */
1753#endif /* not TARGET_API_MAC_CARBON */ 1715#endif /* not TARGET_API_MAC_CARBON */
1754}
1755
1756
1757/* Called in sys_select to wait for an alarm signal to arrive. */
1758
1759int
1760pause ()
1761{
1762 EventRecord e;
1763 unsigned long tick;
1764
1765 if (!target_ticks) /* no alarm pending */
1766 return -1;
1767 1716
1768 if ((tick = TickCount ()) < target_ticks) 1717 if (FD_ISSET (0, rfds))
1769 WaitNextEvent (0, &e, target_ticks - tick, NULL); /* Accept no event; 1718 if (err == noErr)
1770 just wait. by T.I. */ 1719 return 1;
1720 else
1721 {
1722 FD_ZERO (rfds);
1723 return 0;
1724 }
1725 else
1726 if (err == noErr)
1727 {
1728 if (input_polling_used ())
1729 {
1730 /* It could be confusing if a real alarm arrives while
1731 processing the fake one. Turn it off and let the
1732 handler reset it. */
1733 extern void poll_for_input_1 P_ ((void));
1734 int old_poll_suppress_count = poll_suppress_count;
1735 poll_suppress_count = 1;
1736 poll_for_input_1 ();
1737 poll_suppress_count = old_poll_suppress_count;
1738 }
1739 errno = EINTR;
1740 return -1;
1741 }
1742 else
1743 return 0;
1744}
1771 1745
1772 target_ticks = 0;
1773 if (alarm_signal_func)
1774 (*alarm_signal_func)(SIGALRM);
1775 1746
1776 return 0; 1747/* Simulation of SIGALRM. The stub for function signal stores the
1777} 1748 signal handler function in alarm_signal_func if a SIGALRM is
1749 encountered. */
1778 1750
1751#include <signal.h>
1752#include "syssignal.h"
1779 1753
1780int 1754static TMTask mac_atimer_task;
1781alarm (int seconds)
1782{
1783 long remaining = target_ticks ? (TickCount () - target_ticks) / 60 : 0;
1784 1755
1785 target_ticks = seconds ? TickCount () + 60 * seconds : 0; 1756static QElemPtr mac_atimer_qlink = (QElemPtr) &mac_atimer_task;
1786 1757
1787 return (remaining < 0) ? 0 : (unsigned int) remaining; 1758static int signal_mask = 0;
1788}
1789 1759
1760#ifdef __MRC__
1761__sigfun alarm_signal_func = (__sigfun) 0;
1762#elif __MWERKS__
1763__signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0;
1764#else /* not __MRC__ and not __MWERKS__ */
1765You lose!!!
1766#endif /* not __MRC__ and not __MWERKS__ */
1790 1767
1791#undef signal 1768#undef signal
1792#ifdef __MRC__ 1769#ifdef __MRC__
@@ -1819,6 +1796,128 @@ sys_signal (int signal_num, __signal_func_ptr signal_func)
1819} 1796}
1820 1797
1821 1798
1799static pascal void
1800mac_atimer_handler (qlink)
1801 TMTaskPtr qlink;
1802{
1803 if (alarm_signal_func)
1804 (alarm_signal_func) (SIGALRM);
1805}
1806
1807
1808static void
1809set_mac_atimer (count)
1810 long count;
1811{
1812 static TimerUPP mac_atimer_handlerUPP = NULL;
1813
1814 if (mac_atimer_handlerUPP == NULL)
1815 mac_atimer_handlerUPP = NewTimerUPP (mac_atimer_handler);
1816 mac_atimer_task.tmCount = 0;
1817 mac_atimer_task.tmAddr = mac_atimer_handlerUPP;
1818 mac_atimer_qlink = (QElemPtr) &mac_atimer_task;
1819 InsTime (mac_atimer_qlink);
1820 if (count)
1821 PrimeTime (mac_atimer_qlink, count);
1822}
1823
1824
1825int
1826remove_mac_atimer (remaining_count)
1827 long *remaining_count;
1828{
1829 if (mac_atimer_qlink)
1830 {
1831 RmvTime (mac_atimer_qlink);
1832 if (remaining_count)
1833 *remaining_count = mac_atimer_task.tmCount;
1834 mac_atimer_qlink = NULL;
1835
1836 return 0;
1837 }
1838 else
1839 return -1;
1840}
1841
1842
1843int
1844sigblock (int mask)
1845{
1846 int old_mask = signal_mask;
1847
1848 signal_mask |= mask;
1849
1850 if ((old_mask ^ signal_mask) & sigmask (SIGALRM))
1851 remove_mac_atimer (NULL);
1852
1853 return old_mask;
1854}
1855
1856
1857int
1858sigsetmask (int mask)
1859{
1860 int old_mask = signal_mask;
1861
1862 signal_mask = mask;
1863
1864 if ((old_mask ^ signal_mask) & sigmask (SIGALRM))
1865 if (signal_mask & sigmask (SIGALRM))
1866 remove_mac_atimer (NULL);
1867 else
1868 set_mac_atimer (mac_atimer_task.tmCount);
1869
1870 return old_mask;
1871}
1872
1873
1874int
1875alarm (int seconds)
1876{
1877 long remaining_count;
1878
1879 if (remove_mac_atimer (&remaining_count) == 0)
1880 {
1881 set_mac_atimer (seconds * 1000);
1882
1883 return remaining_count / 1000;
1884 }
1885 else
1886 {
1887 mac_atimer_task.tmCount = seconds * 1000;
1888
1889 return 0;
1890 }
1891}
1892
1893
1894int
1895setitimer (which, value, ovalue)
1896 int which;
1897 const struct itimerval *value;
1898 struct itimerval *ovalue;
1899{
1900 long remaining_count;
1901 long count = (EMACS_SECS (value->it_value) * 1000
1902 + (EMACS_USECS (value->it_value) + 999) / 1000);
1903
1904 if (remove_mac_atimer (&remaining_count) == 0)
1905 {
1906 if (ovalue)
1907 {
1908 bzero (ovalue, sizeof (*ovalue));
1909 EMACS_SET_SECS_USECS (ovalue->it_value, remaining_count / 1000,
1910 (remaining_count % 1000) * 1000);
1911 }
1912 set_mac_atimer (count);
1913 }
1914 else
1915 mac_atimer_task.tmCount = count;
1916
1917 return 0;
1918}
1919
1920
1822/* gettimeofday should return the amount of time (in a timeval 1921/* gettimeofday should return the amount of time (in a timeval
1823 structure) since midnight today. The toolbox function Microseconds 1922 structure) since midnight today. The toolbox function Microseconds
1824 returns the number of microseconds (in a UnsignedWide value) since 1923 returns the number of microseconds (in a UnsignedWide value) since
@@ -1946,35 +2045,6 @@ sys_time (time_t *timer)
1946} 2045}
1947 2046
1948 2047
1949/* MPW strftime broken for "%p" format */
1950#ifdef __MRC__
1951#undef strftime
1952#include <time.h>
1953size_t
1954sys_strftime (char * s, size_t maxsize, const char * format,
1955 const struct tm * timeptr)
1956{
1957 if (strcmp (format, "%p") == 0)
1958 {
1959 if (maxsize < 3)
1960 return 0;
1961 if (timeptr->tm_hour < 12)
1962 {
1963 strcpy (s, "AM");
1964 return 2;
1965 }
1966 else
1967 {
1968 strcpy (s, "PM");
1969 return 2;
1970 }
1971 }
1972 else
1973 return strftime (s, maxsize, format, timeptr);
1974}
1975#endif /* __MRC__ */
1976
1977
1978/* no subprocesses, empty wait */ 2048/* no subprocesses, empty wait */
1979 2049
1980int 2050int
@@ -1993,13 +2063,6 @@ croak (char *badfunc)
1993 2063
1994 2064
1995char * 2065char *
1996index (const char * str, int chr)
1997{
1998 return strchr (str, chr);
1999}
2000
2001
2002char *
2003mktemp (char *template) 2066mktemp (char *template)
2004{ 2067{
2005 int len, k; 2068 int len, k;
@@ -2187,20 +2250,6 @@ sys_subshell ()
2187} 2250}
2188 2251
2189 2252
2190int
2191sigsetmask (int x)
2192{
2193 return 0;
2194}
2195
2196
2197int
2198sigblock (int mask)
2199{
2200 return 0;
2201}
2202
2203
2204void 2253void
2205request_sigio (void) 2254request_sigio (void)
2206{ 2255{
diff --git a/src/macfns.c b/src/macfns.c
index a8b685582d5..d0dd9b9c072 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -22,7 +22,6 @@ Boston, MA 02111-1307, USA. */
22 22
23#include <config.h> 23#include <config.h>
24 24
25#include <signal.h>
26#include <stdio.h> 25#include <stdio.h>
27#include <math.h> 26#include <math.h>
28#include <limits.h> 27#include <limits.h>
diff --git a/src/macmenu.c b/src/macmenu.c
index 35615cc3796..eb870176f12 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -21,7 +21,6 @@ Boston, MA 02111-1307, USA. */
21/* Contributed by Andrew Choi (akochoi@mac.com). */ 21/* Contributed by Andrew Choi (akochoi@mac.com). */
22 22
23#include <config.h> 23#include <config.h>
24#include <signal.h>
25 24
26#include <stdio.h> 25#include <stdio.h>
27#include "lisp.h" 26#include "lisp.h"
diff --git a/src/macselect.c b/src/macselect.c
index a115c9b3229..890bb62d1d4 100644
--- a/src/macselect.c
+++ b/src/macselect.c
@@ -1104,9 +1104,11 @@ next communication only. After the communication, this variable is
1104set to nil. */); 1104set to nil. */);
1105 Vnext_selection_coding_system = Qnil; 1105 Vnext_selection_coding_system = Qnil;
1106 1106
1107#ifdef MAC_OSX
1107 DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection, 1108 DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection,
1108 doc: /* Selection name for communication via Services menu. */); 1109 doc: /* Selection name for communication via Services menu. */);
1109 Vmac_services_selection = intern ("CLIPBOARD"); 1110 Vmac_services_selection = intern ("PRIMARY");
1111#endif
1110 1112
1111 QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY); 1113 QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY);
1112 QSECONDARY = intern ("SECONDARY"); staticpro (&QSECONDARY); 1114 QSECONDARY = intern ("SECONDARY"); staticpro (&QSECONDARY);
diff --git a/src/macterm.c b/src/macterm.c
index 1e8aba4e178..47c77e6dd56 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -3271,11 +3271,9 @@ x_clear_frame ()
3271 BLOCK_INPUT; 3271 BLOCK_INPUT;
3272 XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f)); 3272 XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f));
3273 3273
3274#if 0 /* Clearing frame on Mac OS clears scroll bars. */
3275 /* We have to clear the scroll bars, too. If we have changed 3274 /* We have to clear the scroll bars, too. If we have changed
3276 colors or something like that, then they should be notified. */ 3275 colors or something like that, then they should be notified. */
3277 x_scroll_bar_clear (f); 3276 x_scroll_bar_clear (f);
3278#endif
3279 3277
3280 XFlush (FRAME_MAC_DISPLAY (f)); 3278 XFlush (FRAME_MAC_DISPLAY (f));
3281 UNBLOCK_INPUT; 3279 UNBLOCK_INPUT;
@@ -4135,12 +4133,12 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
4135static pascal void scroll_bar_timer_callback P_ ((EventLoopTimerRef, void *)); 4133static pascal void scroll_bar_timer_callback P_ ((EventLoopTimerRef, void *));
4136static OSStatus install_scroll_bar_timer P_ ((void)); 4134static OSStatus install_scroll_bar_timer P_ ((void));
4137static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval)); 4135static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval));
4138static int control_part_code_to_scroll_bar_part P_((ControlPartCode)); 4136static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode));
4139static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, 4137static void construct_scroll_bar_click P_ ((struct scroll_bar *, int,
4140 unsigned long, 4138 unsigned long,
4141 struct input_event *)); 4139 struct input_event *));
4142static OSErr get_control_part_bound P_((ControlHandle, ControlPartCode, 4140static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode,
4143 Rect *)); 4141 Rect *));
4144static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, 4142static void x_scroll_bar_handle_press P_ ((struct scroll_bar *,
4145 ControlPartCode, 4143 ControlPartCode,
4146 unsigned long, 4144 unsigned long,
@@ -4267,7 +4265,7 @@ construct_scroll_bar_click (bar, part, timestamp, bufp)
4267} 4265}
4268 4266
4269static OSErr 4267static OSErr
4270get_control_part_bound (ch, part_code, rect) 4268get_control_part_bounds (ch, part_code, rect)
4271 ControlHandle ch; 4269 ControlHandle ch;
4272 ControlPartCode part_code; 4270 ControlPartCode part_code;
4273 Rect *rect; 4271 Rect *rect;
@@ -4340,8 +4338,8 @@ x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp)
4340 int top, top_range; 4338 int top, top_range;
4341 Rect r; 4339 Rect r;
4342 4340
4343 get_control_part_bound (SCROLL_BAR_CONTROL_HANDLE (bar), 4341 get_control_part_bounds (SCROLL_BAR_CONTROL_HANDLE (bar),
4344 kControlIndicatorPart, &r); 4342 kControlIndicatorPart, &r);
4345 4343
4346 if (GC_NILP (bar->dragging)) 4344 if (GC_NILP (bar->dragging))
4347 XSETINT (bar->dragging, mouse_pos.v - r.top); 4345 XSETINT (bar->dragging, mouse_pos.v - r.top);
@@ -4669,13 +4667,11 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4669 BLOCK_INPUT; 4667 BLOCK_INPUT;
4670 4668
4671 /* If already correctly positioned, do nothing. */ 4669 /* If already correctly positioned, do nothing. */
4672 if (XINT (bar->left) == sb_left 4670 if (!(XINT (bar->left) == sb_left
4673 && XINT (bar->top) == top 4671 && XINT (bar->top) == top
4674 && XINT (bar->width) == sb_width 4672 && XINT (bar->width) == sb_width
4675 && XINT (bar->height) == height) 4673 && XINT (bar->height) == height))
4676 Draw1Control (ch); 4674 {
4677 else
4678 {
4679 /* Clear areas not covered by the scroll bar because it's not as 4675 /* Clear areas not covered by the scroll bar because it's not as
4680 wide as the area reserved for it . This makes sure a 4676 wide as the area reserved for it . This makes sure a
4681 previous mode line display is cleared after C-x 2 C-x 1, for 4677 previous mode line display is cleared after C-x 2 C-x 1, for
@@ -4724,11 +4720,11 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4724 4720
4725 /* Move the scroll bar thumb to the top. */ 4721 /* Move the scroll bar thumb to the top. */
4726 SetControl32BitValue (ch, 0); 4722 SetControl32BitValue (ch, 0);
4727 get_control_part_bound (ch, kControlIndicatorPart, &r0); 4723 get_control_part_bounds (ch, kControlIndicatorPart, &r0);
4728 4724
4729 /* Move the scroll bar thumb to the bottom. */ 4725 /* Move the scroll bar thumb to the bottom. */
4730 SetControl32BitValue (ch, 1); 4726 SetControl32BitValue (ch, 1);
4731 get_control_part_bound (ch, kControlIndicatorPart, &r1); 4727 get_control_part_bounds (ch, kControlIndicatorPart, &r1);
4732 4728
4733 UnionRect (&r0, &r1, &r0); 4729 UnionRect (&r0, &r1, &r0);
4734 XSETINT (bar->track_top, r0.top); 4730 XSETINT (bar->track_top, r0.top);
@@ -4876,7 +4872,7 @@ XTjudge_scroll_bars (f)
4876static void 4872static void
4877x_scroll_bar_handle_click (bar, part_code, er, bufp) 4873x_scroll_bar_handle_click (bar, part_code, er, bufp)
4878 struct scroll_bar *bar; 4874 struct scroll_bar *bar;
4879 int part_code; 4875 ControlPartCode part_code;
4880 EventRecord *er; 4876 EventRecord *er;
4881 struct input_event *bufp; 4877 struct input_event *bufp;
4882{ 4878{
@@ -5034,6 +5030,21 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
5034 5030
5035 *time = last_mouse_movement_time; 5031 *time = last_mouse_movement_time;
5036} 5032}
5033
5034
5035/* The screen has been cleared so we may have changed foreground or
5036 background colors, and the scroll bars may need to be redrawn.
5037 Clear out the scroll bars, and ask for expose events, so we can
5038 redraw them. */
5039
5040void
5041x_scroll_bar_clear (f)
5042 FRAME_PTR f;
5043{
5044 XTcondemn_scroll_bars (f);
5045 XTjudge_scroll_bars (f);
5046}
5047
5037 5048
5038/*********************************************************************** 5049/***********************************************************************
5039 Text Cursor 5050 Text Cursor
@@ -7498,7 +7509,6 @@ OSErr install_window_handler (WindowPtr);
7498 7509
7499extern void init_emacs_passwd_dir (); 7510extern void init_emacs_passwd_dir ();
7500extern int emacs_main (int, char **, char **); 7511extern int emacs_main (int, char **, char **);
7501extern void check_alarm ();
7502 7512
7503extern void initialize_applescript(); 7513extern void initialize_applescript();
7504extern void terminate_applescript(); 7514extern void terminate_applescript();
@@ -8650,23 +8660,18 @@ profiler_exit_proc ()
8650#endif 8660#endif
8651 8661
8652/* These few functions implement Emacs as a normal Mac application 8662/* These few functions implement Emacs as a normal Mac application
8653 (almost): set up the heap and the Toolbox, handle necessary 8663 (almost): set up the heap and the Toolbox, handle necessary system
8654 system events plus a few simple menu events. They also set up 8664 events plus a few simple menu events. They also set up Emacs's
8655 Emacs's access to functions defined in the rest of this file. 8665 access to functions defined in the rest of this file. Emacs uses
8656 Emacs uses function hooks to perform all its terminal I/O. A 8666 function hooks to perform all its terminal I/O. A complete list of
8657 complete list of these functions appear in termhooks.h. For what 8667 these functions appear in termhooks.h. For what they do, read the
8658 they do, read the comments there and see also w32term.c and 8668 comments there and see also w32term.c and xterm.c. What's
8659 xterm.c. What's noticeably missing here is the event loop, which 8669 noticeably missing here is the event loop, which is normally
8660 is normally present in most Mac application. After performing the 8670 present in most Mac application. After performing the necessary
8661 necessary Mac initializations, main passes off control to 8671 Mac initializations, main passes off control to emacs_main
8662 emacs_main (corresponding to main in emacs.c). Emacs_main calls 8672 (corresponding to main in emacs.c). Emacs_main calls XTread_socket
8663 mac_read_socket (defined further below) to read input. This is 8673 (defined further below) to read input. This is where
8664 where WaitNextEvent is called to process Mac events. This is also 8674 WaitNextEvent/ReceiveNextEvent is called to process Mac events. */
8665 where check_alarm in sysdep.c is called to simulate alarm signals.
8666 This makes the cursor jump back to its correct position after
8667 briefly jumping to that of the matching parenthesis, print useful
8668 hints and prompts in the minibuffer after the user stops typing for
8669 a wait, etc. */
8670 8675
8671#ifdef MAC_OS8 8676#ifdef MAC_OS8
8672#undef main 8677#undef main
@@ -8929,7 +8934,7 @@ XTread_socket (sd, expected, hold_quit)
8929 case mouseUp: 8934 case mouseUp:
8930 { 8935 {
8931 WindowPtr window_ptr; 8936 WindowPtr window_ptr;
8932 SInt16 part_code; 8937 ControlPartCode part_code;
8933 int tool_bar_p = 0; 8938 int tool_bar_p = 0;
8934 8939
8935#if USE_CARBON_EVENTS 8940#if USE_CARBON_EVENTS
@@ -8973,7 +8978,7 @@ XTread_socket (sd, expected, hold_quit)
8973 SelectWindow (window_ptr); 8978 SelectWindow (window_ptr);
8974 else 8979 else
8975 { 8980 {
8976 SInt16 control_part_code; 8981 ControlPartCode control_part_code;
8977 ControlHandle ch; 8982 ControlHandle ch;
8978 Point mouse_loc = er.where; 8983 Point mouse_loc = er.where;
8979#ifdef MAC_OSX 8984#ifdef MAC_OSX
@@ -9548,10 +9553,6 @@ XTread_socket (sd, expected, hold_quit)
9548 pending_autoraise_frame = 0; 9553 pending_autoraise_frame = 0;
9549 } 9554 }
9550 9555
9551#if !TARGET_API_MAC_CARBON
9552 check_alarm (); /* simulate the handling of a SIGALRM */
9553#endif
9554
9555 UNBLOCK_INPUT; 9556 UNBLOCK_INPUT;
9556 return count; 9557 return count;
9557} 9558}
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index 1f2b4c96620..fc369eab7cd 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -105,6 +105,8 @@ Boston, MA 02111-1307, USA. */
105#include <objc/malloc.h> 105#include <objc/malloc.h>
106#endif 106#endif
107 107
108#include <assert.h>
109
108 110
109#define VERBOSE 1 111#define VERBOSE 1
110 112
@@ -998,6 +1000,23 @@ unexec_init_emacs_zone ()
998 malloc_set_zone_name (emacs_zone, "EmacsZone"); 1000 malloc_set_zone_name (emacs_zone, "EmacsZone");
999} 1001}
1000 1002
1003#ifndef MACOSX_MALLOC_MULT16
1004#define MACOSX_MALLOC_MULT16 1
1005#endif
1006
1007typedef struct unexec_malloc_header {
1008 union {
1009 char c[8];
1010 size_t size;
1011 } u;
1012} unexec_malloc_header_t;
1013
1014#if MACOSX_MALLOC_MULT16
1015
1016#define ptr_in_unexec_regions(p) ((((vm_address_t) (p)) & 8) != 0)
1017
1018#else
1019
1001int 1020int
1002ptr_in_unexec_regions (void *ptr) 1021ptr_in_unexec_regions (void *ptr)
1003{ 1022{
@@ -1011,36 +1030,75 @@ ptr_in_unexec_regions (void *ptr)
1011 return 0; 1030 return 0;
1012} 1031}
1013 1032
1033#endif
1034
1014void * 1035void *
1015unexec_malloc (size_t size) 1036unexec_malloc (size_t size)
1016{ 1037{
1017 if (in_dumped_exec) 1038 if (in_dumped_exec)
1018 return malloc (size); 1039 {
1040 void *p;
1041
1042 p = malloc (size);
1043#if MACOSX_MALLOC_MULT16
1044 assert (((vm_address_t) p % 16) == 0);
1045#endif
1046 return p;
1047 }
1019 else 1048 else
1020 return malloc_zone_malloc (emacs_zone, size); 1049 {
1050 unexec_malloc_header_t *ptr;
1051
1052 ptr = (unexec_malloc_header_t *)
1053 malloc_zone_malloc (emacs_zone, size + sizeof (unexec_malloc_header_t));
1054 ptr->u.size = size;
1055 ptr++;
1056#if MACOSX_MALLOC_MULT16
1057 assert (((vm_address_t) ptr % 16) == 8);
1058#endif
1059 return (void *) ptr;
1060 }
1021} 1061}
1022 1062
1023void * 1063void *
1024unexec_realloc (void *old_ptr, size_t new_size) 1064unexec_realloc (void *old_ptr, size_t new_size)
1025{ 1065{
1026 if (in_dumped_exec) 1066 if (in_dumped_exec)
1027 if (ptr_in_unexec_regions (old_ptr)) 1067 {
1028 { 1068 void *p;
1029 char *p = malloc (new_size); 1069
1030 /* 2002-04-15 T. Ikegami <ikegami@adam.uprr.pr>. The original 1070 if (ptr_in_unexec_regions (old_ptr))
1031 code to get size failed to reallocate read_buffer 1071 {
1032 (lread.c). */ 1072 p = (size_t *) malloc (new_size);
1033 int old_size = malloc_default_zone()->size (emacs_zone, old_ptr); 1073 size_t old_size = ((unexec_malloc_header_t *) old_ptr)[-1].u.size;
1034 int size = new_size > old_size ? old_size : new_size; 1074 size_t size = new_size > old_size ? old_size : new_size;
1035 1075
1036 if (size) 1076 if (size)
1037 memcpy (p, old_ptr, size); 1077 memcpy (p, old_ptr, size);
1038 return p; 1078 }
1039 } 1079 else
1040 else 1080 {
1041 return realloc (old_ptr, new_size); 1081 p = realloc (old_ptr, new_size);
1082 }
1083#if MACOSX_MALLOC_MULT16
1084 assert (((vm_address_t) p % 16) == 0);
1085#endif
1086 return p;
1087 }
1042 else 1088 else
1043 return malloc_zone_realloc (emacs_zone, old_ptr, new_size); 1089 {
1090 unexec_malloc_header_t *ptr;
1091
1092 ptr = (unexec_malloc_header_t *)
1093 malloc_zone_realloc (emacs_zone, (unexec_malloc_header_t *) old_ptr - 1,
1094 new_size + sizeof (unexec_malloc_header_t));
1095 ptr->u.size = new_size;
1096 ptr++;
1097#if MACOSX_MALLOC_MULT16
1098 assert (((vm_address_t) ptr % 16) == 8);
1099#endif
1100 return (void *) ptr;
1101 }
1044} 1102}
1045 1103
1046void 1104void
@@ -1052,7 +1110,7 @@ unexec_free (void *ptr)
1052 free (ptr); 1110 free (ptr);
1053 } 1111 }
1054 else 1112 else
1055 malloc_zone_free (emacs_zone, ptr); 1113 malloc_zone_free (emacs_zone, (unexec_malloc_header_t *) ptr - 1);
1056} 1114}
1057 1115
1058/* arch-tag: 1a784f7b-a184-4c4f-9544-da8619593d72 1116/* arch-tag: 1a784f7b-a184-4c4f-9544-da8619593d72
diff --git a/src/xfns.c b/src/xfns.c
index 666acfec773..44e1dbae0c2 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -20,7 +20,6 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */ 20Boston, MA 02111-1307, USA. */
21 21
22#include <config.h> 22#include <config.h>
23#include <signal.h>
24#include <stdio.h> 23#include <stdio.h>
25#include <math.h> 24#include <math.h>
26 25
diff --git a/src/xmenu.c b/src/xmenu.c
index 1a2386fe916..931d2a87904 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -33,8 +33,10 @@ Boston, MA 02111-1307, USA. */
33 33
34#include <config.h> 34#include <config.h>
35 35
36#if 0 /* Why was this included? And without syssignal.h? */
36/* On 4.3 this loses if it comes after xterm.h. */ 37/* On 4.3 this loses if it comes after xterm.h. */
37#include <signal.h> 38#include <signal.h>
39#endif
38 40
39#include <stdio.h> 41#include <stdio.h>
40 42
diff --git a/src/xterm.c b/src/xterm.c
index ebd0954edb7..aa5f9829105 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7794,6 +7794,12 @@ x_error_handler (display, error)
7794#define NO_INLINE 7794#define NO_INLINE
7795#endif 7795#endif
7796 7796
7797/* Some versions of GNU/Linux define noinline in their headers. */
7798
7799#ifdef noinline
7800#undef noinline
7801#endif
7802
7797/* On older GCC versions, just putting x_error_quitter 7803/* On older GCC versions, just putting x_error_quitter
7798 after x_error_handler prevents inlining into the former. */ 7804 after x_error_handler prevents inlining into the former. */
7799 7805