]> code.delx.au - gnu-emacs/blobdiff - src/sysdep.c
Fix pr-interface-map initialization
[gnu-emacs] / src / sysdep.c
index 87998088753172da730815127af493bbf5dbe86a..d1f378a3f8744aa87a55ec64f40124549b11b9fa 100644 (file)
@@ -6,7 +6,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -46,7 +46,11 @@ extern void srandom P_ ((unsigned int));
 #endif
 #endif
 
+/* The w32 build defines select stuff in w32.h, which is included by
+   sys/select.h (included below).   */
+#ifndef WINDOWSNT
 #include "sysselect.h"
+#endif
 
 #include "blockinput.h"
 
@@ -1188,7 +1192,7 @@ int inherited_pgroup;
    redirect the tty device handle FD to point to our own process
    group.  We need to be in our own process group to receive SIGIO
    properly.  */
-void
+static void
 narrow_foreground_group (int fd)
 {
   int me = getpid ();
@@ -1206,7 +1210,7 @@ narrow_foreground_group (int fd)
 }
 
 /* Set the tty to our original foreground group.  */
-void
+static void
 widen_foreground_group (int fd)
 {
   if (inherited_pgroup != getpid ())
@@ -1747,6 +1751,15 @@ init_sys_modes (tty_out)
         fcntl (fileno (tty_out->input), F_GETOWN, 0);
       fcntl (fileno (tty_out->input), F_SETOWN, getpid ());
       init_sigio (fileno (tty_out->input));
+#ifdef HAVE_GPM
+      if (gpm_tty == tty_out)
+       {
+         /* Arrange for mouse events to give us SIGIO signals.  */
+         fcntl (gpm_fd, F_SETOWN, getpid ());
+         fcntl (gpm_fd, F_SETFL, fcntl (gpm_fd, F_GETFL, 0) | O_NONBLOCK);
+         init_sigio (gpm_fd);
+       }
+#endif /* HAVE_GPM */
     }
 #endif /* F_GETOWN */
 #endif /* F_SETOWN_BUG */
@@ -1769,7 +1782,8 @@ init_sys_modes (tty_out)
   setbuf (tty_out->output, (char *) _sobuf);
 #endif
 
-  tty_set_terminal_modes (tty_out->terminal);
+  if (tty_out->terminal->set_terminal_modes_hook)
+    tty_out->terminal->set_terminal_modes_hook (tty_out->terminal);
 
   if (!tty_out->term_initted)
     {
@@ -1981,7 +1995,8 @@ reset_sys_modes (tty_out)
   }
 #endif
 
-  tty_reset_terminal_modes (tty_out->terminal);
+  if (tty_out->terminal->reset_terminal_modes_hook)
+    tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
 
 #ifdef BSD_SYSTEM
 #ifndef BSD4_1
@@ -2503,10 +2518,50 @@ init_system_name ()
 #endif /* not CANNOT_DUMP */
     if (! index (hostname, '.'))
       {
-       struct hostent *hp;
        int count;
+#ifdef HAVE_GETADDRINFO
+        struct addrinfo *res;
+        struct addrinfo hints;
+        int ret;
+
+        memset (&hints, 0, sizeof(hints));
+        hints.ai_socktype = SOCK_STREAM;
+        hints.ai_flags = AI_CANONNAME;
+
+       for (count = 0;; count++)
+         {
+            if ((ret = getaddrinfo (hostname, NULL, &hints, &res)) == 0
+                || ret != EAI_AGAIN)
+              break;
+
+            if (count >= 5)
+             break;
+           Fsleep_for (make_number (1), Qnil);
+         }
+
+        if (ret == 0)
+          {
+            struct addrinfo *it = res;
+            while (it)
+              {
+                char *fqdn = it->ai_canonname;
+                if (fqdn && index (fqdn, '.')
+                    && strcmp (fqdn, "localhost.localdomain") != 0)
+                  break;
+                it = it->ai_next;
+              }
+            if (it)
+              {
+                hostname = alloca (strlen (it->ai_canonname) + 1);
+                strcpy (hostname, it->ai_canonname);
+              }
+            freeaddrinfo (res);
+          }
+#else /* !HAVE_GETADDRINFO */
+        struct hostent *hp;
        for (count = 0;; count++)
          {
+
 #ifdef TRY_AGAIN
            h_errno = 0;
 #endif
@@ -2514,11 +2569,14 @@ init_system_name ()
 #ifdef TRY_AGAIN
            if (! (hp == 0 && h_errno == TRY_AGAIN))
 #endif
+
              break;
+
            if (count >= 5)
              break;
            Fsleep_for (make_number (1), Qnil);
          }
+
        if (hp)
          {
            char *fqdn = (char *) hp->h_name;
@@ -2531,7 +2589,9 @@ init_system_name ()
                /* We still don't have a fully qualified domain name.
                   Try to find one in the list of alternate names */
                char **alias = hp->h_aliases;
-               while (*alias && !index (*alias, '.'))
+               while (*alias
+                      && (!index (*alias, '.')
+                          || !strcmp (*alias, "localhost.localdomain")))
                  alias++;
                if (*alias)
                  fqdn = *alias;
@@ -2550,6 +2610,7 @@ init_system_name ()
              }
 #endif
          }
+#endif /* !HAVE_GETADDRINFO */
       }
 #endif /* HAVE_SOCKETS */
   /* We used to try using getdomainname here,
@@ -2781,7 +2842,7 @@ sys_select (nfds, rfds, wfds, efds, timeout)
     }
   return ravail;
 }
-#endif not WINDOWSNT
+#endif /* not WINDOWSNT */
 
 /* Read keyboard input into the standard buffer,
    waiting for at least one character.  */
@@ -3425,6 +3486,15 @@ emacs_close (fd)
   int did_retry = 0;
   register int rtnval;
 
+#if defined (MAC_OSX) && defined (HAVE_CARBON)
+  {
+    extern int mac_try_close_socket P_ ((int));
+
+    if (mac_try_close_socket (fd))
+      return 0;
+  }
+#endif
+
   while ((rtnval = close (fd)) == -1
         && (errno == EINTR))
     did_retry = 1;