emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114696: Make some functions static in non-Microsoft


From: Paul Eggert
Subject: [Emacs-diffs] trunk r114696: Make some functions static in non-Microsoft builds.
Date: Thu, 17 Oct 2013 06:42:41 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114696
revision-id: address@hidden
parent: address@hidden
author: Paul Eggert  <address@hidden>
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Wed 2013-10-16 23:42:21 -0700
message:
  Make some functions static in non-Microsoft builds.
  
  On my platform (Fedora 19 x86-64), this shrinks the
  Emacs executable (text+data) by 0.25%.
  * dispextern.h (erase_phys_cursor) [!WINDOWSNT]:
  (load_color) [!MSDOS]:
  * gnutls.h (emacs_gnutls_transport_set_errno) [!WINDOWSNT]:
  * keyboard.h (make_ctrl_char) [!WINDOWSNT]:
  * lisp.h (check_existing):
  * process.h (conv_sockaddr_to_lisp, network_interface_list)
  (network_interface_info) [!WINDOWSNT]:
  * termhooks.h (encode_terminal_code) [!WINDOWSNT]:
  Remove extern decls.
  * fileio.c (check_existing):
  * keyboard.c (make_ctrl_char) [!WINDOWSNT]:
  * process.c (conv_sockaddr_to_lisp, network_interface_list)
  (network_interface_info) [!WINDOWSNT]:
  * term.c (encode_terminal_code) [!WINDOWSNT]:
  * xdisp.c (erase_phys_cursor) [!WINDOWSNT]:
  * xfaces.c (load_color) [!MSDOS]:
  Now static.
  * fileio.c (check_existing, check_executable, check_writable):
  * process.c (network_interface_list, network_interface_info):
  Move earlier, so that we don't need forward decls.
  * gnutls.c (fn_gnutls_transport_set_errno)
  (emacs_gnutls_transport_set_errno) [!WINDOWNT]:
  Remove; unused.
  * w32.c (init_environment): Use faccessat rather than
  check_existing, partly for consistency with the rest of the code
  in this file, partly so that check_existing can be static.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/dispextern.h               
dispextern.h-20091113204419-o5vbwnq5f7feedwu-218
  src/fileio.c                   fileio.c-20091113204419-o5vbwnq5f7feedwu-210
  src/gnutls.c                   gnutls.c-20100926054902-dzayyj6wycit6kzn-3
  src/gnutls.h                   gnutls.h-20100926054902-dzayyj6wycit6kzn-4
  src/keyboard.c                 keyboard.c-20091113204419-o5vbwnq5f7feedwu-449
  src/keyboard.h                 keyboard.h-20091113204419-o5vbwnq5f7feedwu-450
  src/lisp.h                     lisp.h-20091113204419-o5vbwnq5f7feedwu-253
  src/process.c                  process.c-20091113204419-o5vbwnq5f7feedwu-462
  src/process.h                  process.h-20091113204419-o5vbwnq5f7feedwu-272
  src/term.c                     term.c-20091113204419-o5vbwnq5f7feedwu-220
  src/termhooks.h                termhooks.h-20091113204419-o5vbwnq5f7feedwu-249
  src/w32.c                      w32.c-20091113204419-o5vbwnq5f7feedwu-808
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
  src/xfaces.c                   xfaces.c-20091113204419-o5vbwnq5f7feedwu-560
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-10-17 03:08:59 +0000
+++ b/src/ChangeLog     2013-10-17 06:42:21 +0000
@@ -1,5 +1,35 @@
 2013-10-17  Paul Eggert  <address@hidden>
 
+       Make some functions static in non-Microsoft builds.
+       On my platform (Fedora 19 x86-64), this shrinks the
+       Emacs executable (text+data) by 0.25%.
+       * dispextern.h (erase_phys_cursor) [!WINDOWSNT]:
+       (load_color) [!MSDOS]:
+       * gnutls.h (emacs_gnutls_transport_set_errno) [!WINDOWSNT]:
+       * keyboard.h (make_ctrl_char) [!WINDOWSNT]:
+       * lisp.h (check_existing):
+       * process.h (conv_sockaddr_to_lisp, network_interface_list)
+       (network_interface_info) [!WINDOWSNT]:
+       * termhooks.h (encode_terminal_code) [!WINDOWSNT]:
+       Remove extern decls.
+       * fileio.c (check_existing):
+       * keyboard.c (make_ctrl_char) [!WINDOWSNT]:
+       * process.c (conv_sockaddr_to_lisp, network_interface_list)
+       (network_interface_info) [!WINDOWSNT]:
+       * term.c (encode_terminal_code) [!WINDOWSNT]:
+       * xdisp.c (erase_phys_cursor) [!WINDOWSNT]:
+       * xfaces.c (load_color) [!MSDOS]:
+       Now static.
+       * fileio.c (check_existing, check_executable, check_writable):
+       * process.c (network_interface_list, network_interface_info):
+       Move earlier, so that we don't need forward decls.
+       * gnutls.c (fn_gnutls_transport_set_errno)
+       (emacs_gnutls_transport_set_errno) [!WINDOWNT]:
+       Remove; unused.
+       * w32.c (init_environment): Use faccessat rather than
+       check_existing, partly for consistency with the rest of the code
+       in this file, partly so that check_existing can be static.
+
        Make VALMASK visible to GDB even if clang is used (Bug#15574).
        * emacs.c (MAIN_PROGRAM): New macro.
        * lisp.h (DEFINE_GDB_SYMBOL_BEGIN, DEFINE_GDB_SYMBOL_END): New macros.

=== modified file 'src/dispextern.h'
--- a/src/dispextern.h  2013-10-11 15:42:06 +0000
+++ b/src/dispextern.h  2013-10-17 06:42:21 +0000
@@ -3229,7 +3229,9 @@
                                     enum draw_glyphs_face);
 extern void get_phys_cursor_geometry (struct window *, struct glyph_row *,
                                       struct glyph *, int *, int *, int *);
+#ifdef WINDOWSNT
 extern void erase_phys_cursor (struct window *);
+#endif
 extern void display_and_set_cursor (struct window *, bool, int, int, int, int);
 extern void x_update_cursor (struct frame *, bool);
 extern void x_clear_cursor (struct window *);
@@ -3343,8 +3345,10 @@
                                        Lisp_Object);
 Lisp_Object tty_color_name (struct frame *, int);
 void clear_face_cache (int);
+#ifdef MSDOS
 unsigned long load_color (struct frame *, struct face *, Lisp_Object,
                           enum lface_attribute_index);
+#endif
 void unload_color (struct frame *, unsigned long);
 char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object,
                         int *);

=== modified file 'src/fileio.c'
--- a/src/fileio.c      2013-10-10 21:42:38 +0000
+++ b/src/fileio.c      2013-10-17 06:42:21 +0000
@@ -161,6 +161,56 @@
                     struct coding_system *);
 
 
+/* Return true if FILENAME exists.  */
+
+static bool
+check_existing (const char *filename)
+{
+  return faccessat (AT_FDCWD, filename, F_OK, AT_EACCESS) == 0;
+}
+
+/* Return true if file FILENAME exists and can be executed.  */
+
+static bool
+check_executable (char *filename)
+{
+  return faccessat (AT_FDCWD, filename, X_OK, AT_EACCESS) == 0;
+}
+
+/* Return true if file FILENAME exists and can be accessed
+   according to AMODE, which should include W_OK.
+   On failure, return false and set errno.  */
+
+static bool
+check_writable (const char *filename, int amode)
+{
+#ifdef MSDOS
+  /* FIXME: an faccessat implementation should be added to the
+     DOS/Windows ports and this #ifdef branch should be removed.  */
+  struct stat st;
+  if (stat (filename, &st) < 0)
+    return 0;
+  errno = EPERM;
+  return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode));
+#else /* not MSDOS */
+  bool res = faccessat (AT_FDCWD, filename, amode, AT_EACCESS) == 0;
+#ifdef CYGWIN
+  /* faccessat may have returned failure because Cygwin couldn't
+     determine the file's UID or GID; if so, we return success. */
+  if (!res)
+    {
+      int faccessat_errno = errno;
+      struct stat st;
+      if (stat (filename, &st) < 0)
+        return 0;
+      res = (st.st_uid == -1 || st.st_gid == -1);
+      errno = faccessat_errno;
+    }
+#endif /* CYGWIN */
+  return res;
+#endif /* not MSDOS */
+}
+
 /* Signal a file-access failure.  STRING describes the failure,
    NAME the file involved, and ERRORNO the errno value.
 
@@ -1733,7 +1783,7 @@
 
   xnm = SSDATA (filename);
   x = xnm + SBYTES (filename);
-  
+
   /* If /~ or // appears, discard everything through first slash.  */
   while ((p = search_embedded_absfilename (xnm, x)) != NULL)
     /* This time we do not start over because we've already expanded envvars
@@ -2440,55 +2490,6 @@
   return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil;
 }
 
-/* Return true if FILENAME exists.  */
-bool
-check_existing (const char *filename)
-{
-  return faccessat (AT_FDCWD, filename, F_OK, AT_EACCESS) == 0;
-}
-
-/* Return true if file FILENAME exists and can be executed.  */
-
-static bool
-check_executable (char *filename)
-{
-  return faccessat (AT_FDCWD, filename, X_OK, AT_EACCESS) == 0;
-}
-
-/* Return true if file FILENAME exists and can be accessed
-   according to AMODE, which should include W_OK.
-   On failure, return false and set errno.  */
-
-static bool
-check_writable (const char *filename, int amode)
-{
-#ifdef MSDOS
-  /* FIXME: an faccessat implementation should be added to the
-     DOS/Windows ports and this #ifdef branch should be removed.  */
-  struct stat st;
-  if (stat (filename, &st) < 0)
-    return 0;
-  errno = EPERM;
-  return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode));
-#else /* not MSDOS */
-  bool res = faccessat (AT_FDCWD, filename, amode, AT_EACCESS) == 0;
-#ifdef CYGWIN
-  /* faccessat may have returned failure because Cygwin couldn't
-     determine the file's UID or GID; if so, we return success. */
-  if (!res)
-    {
-      int faccessat_errno = errno;
-      struct stat st;
-      if (stat (filename, &st) < 0)
-        return 0;
-      res = (st.st_uid == -1 || st.st_gid == -1);
-      errno = faccessat_errno;
-    }
-#endif /* CYGWIN */
-  return res;
-#endif /* not MSDOS */
-}
-
 DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0,
        doc: /* Return t if file FILENAME exists (whether or not you can read 
it.)
 See also `file-readable-p' and `file-attributes'.
@@ -2514,7 +2515,7 @@
 
   absname = ENCODE_FILE (absname);
 
-  return (check_existing (SSDATA (absname))) ? Qt : Qnil;
+  return check_existing (SSDATA (absname)) ? Qt : Qnil;
 }
 
 DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0,

=== modified file 'src/gnutls.c'
--- a/src/gnutls.c      2013-10-11 13:47:35 +0000
+++ b/src/gnutls.c      2013-10-17 06:42:21 +0000
@@ -249,7 +249,9 @@
 #define fn_gnutls_record_recv                  gnutls_record_recv
 #define fn_gnutls_record_send                  gnutls_record_send
 #define fn_gnutls_strerror                     gnutls_strerror
+#ifdef WINDOWSNT
 #define fn_gnutls_transport_set_errno          gnutls_transport_set_errno
+#endif
 #define fn_gnutls_transport_set_ptr2           gnutls_transport_set_ptr2
 #define fn_gnutls_x509_crt_check_hostname      gnutls_x509_crt_check_hostname
 #define fn_gnutls_x509_crt_deinit              gnutls_x509_crt_deinit
@@ -364,11 +366,13 @@
   return fn_gnutls_record_check_pending (state);
 }
 
+#ifdef WINDOWSNT
 void
 emacs_gnutls_transport_set_errno (gnutls_session_t state, int err)
 {
   fn_gnutls_transport_set_errno (state, err);
 }
+#endif
 
 ptrdiff_t
 emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t 
nbyte)

=== modified file 'src/gnutls.h'
--- a/src/gnutls.h      2013-07-10 23:23:57 +0000
+++ b/src/gnutls.h      2013-10-17 06:42:21 +0000
@@ -64,7 +64,9 @@
 emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte);
 
 extern int emacs_gnutls_record_check_pending (gnutls_session_t state);
+#ifdef WINDOWSNT
 extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err);
+#endif
 extern Lisp_Object emacs_gnutls_deinit (Lisp_Object);
 
 extern void syms_of_gnutls (void);

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2013-10-15 13:57:37 +0000
+++ b/src/keyboard.c    2013-10-17 06:42:21 +0000
@@ -2097,6 +2097,9 @@
 
 /* Apply the control modifier to CHARACTER.  */
 
+#ifndef WINDOWSNT
+static
+#endif
 int
 make_ctrl_char (int c)
 {

=== modified file 'src/keyboard.h'
--- a/src/keyboard.h    2013-10-15 13:57:37 +0000
+++ b/src/keyboard.h    2013-10-17 06:42:21 +0000
@@ -517,7 +517,9 @@
 extern void clear_input_pending (void);
 extern bool requeued_events_pending_p (void);
 extern void bind_polling_period (int);
+#ifdef WINDOWSNT
 extern int make_ctrl_char (int) ATTRIBUTE_CONST;
+#endif
 extern void stuff_buffered_input (Lisp_Object);
 extern void clear_waiting_for_input (void);
 extern void swallow_events (bool);

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2013-10-17 03:08:59 +0000
+++ b/src/lisp.h        2013-10-17 06:42:21 +0000
@@ -3873,7 +3873,6 @@
 extern void syms_of_fileio (void);
 extern Lisp_Object make_temp_name (Lisp_Object, bool);
 extern Lisp_Object Qdelete_file;
-extern bool check_existing (const char *);
 
 /* Defined in search.c.  */
 extern void shrink_regexp_cache (void);

=== modified file 'src/process.c'
--- a/src/process.c     2013-10-16 15:44:02 +0000
+++ b/src/process.c     2013-10-17 06:42:21 +0000
@@ -1958,6 +1958,9 @@
 /* Convert an internal struct sockaddr to a lisp object (vector or string).
    The address family of sa is not included in the result.  */
 
+#ifndef WINDOWSNT
+static
+#endif
 Lisp_Object
 conv_sockaddr_to_lisp (struct sockaddr *sa, int len)
 {
@@ -3504,43 +3507,10 @@
 }
 
 
-DEFUN ("network-interface-list", Fnetwork_interface_list, 
Snetwork_interface_list, 0, 0, 0,
-       doc: /* Return an alist of all network interfaces and their network 
address.
-Each element is a cons, the car of which is a string containing the
-interface name, and the cdr is the network address in internal
-format; see the description of ADDRESS in `make-network-process'.
-
-If the information is not available, return nil.  */)
-  (void)
-{
-#if (defined (HAVE_NET_IF_H) && defined (SIOCGIFCONF)) || defined (WINDOWSNT)
-  return network_interface_list ();
-#else
-  return Qnil;
-#endif
-}
-
-DEFUN ("network-interface-info", Fnetwork_interface_info, 
Snetwork_interface_info, 1, 1, 0,
-       doc: /* Return information about network interface named IFNAME.
-The return value is a list (ADDR BCAST NETMASK HWADDR FLAGS),
-where ADDR is the layer 3 address, BCAST is the layer 3 broadcast address,
-NETMASK is the layer 3 network mask, HWADDR is the layer 2 address, and
-FLAGS is the current flags of the interface.
-
-Data that is unavailable is returned as nil.  */)
-  (Lisp_Object ifname)
-{
-#if (defined (HAVE_NET_IF_H) && (defined (SIOCGIFADDR) || defined 
(SIOCGIFHWADDR) || defined (SIOCGIFFLAGS))) || defined (WINDOWSNT)
-  return network_interface_info (ifname);
-#else
-  return Qnil;
-#endif
-}
-
-#if defined (HAVE_NET_IF_H)
+#ifdef HAVE_NET_IF_H
 
 #ifdef SIOCGIFCONF
-Lisp_Object
+static Lisp_Object
 network_interface_list (void)
 {
   struct ifconf ifconf;
@@ -3683,7 +3653,7 @@
   { 0, 0 }
 };
 
-Lisp_Object
+static Lisp_Object
 network_interface_info (Lisp_Object ifname)
 {
   struct ifreq rq;
@@ -3829,6 +3799,45 @@
 #endif /* !SIOCGIFADDR && !SIOCGIFHWADDR && !SIOCGIFFLAGS */
 #endif /* defined (HAVE_NET_IF_H) */
 
+DEFUN ("network-interface-list", Fnetwork_interface_list,
+       Snetwork_interface_list, 0, 0, 0,
+       doc: /* Return an alist of all network interfaces and their network 
address.
+Each element is a cons, the car of which is a string containing the
+interface name, and the cdr is the network address in internal
+format; see the description of ADDRESS in `make-network-process'.
+
+If the information is not available, return nil.  */)
+  (void)
+{
+#if (defined HAVE_NET_IF_H && defined SIOCGIFCONF) || defined WINDOWSNT
+  return network_interface_list ();
+#else
+  return Qnil;
+#endif
+}
+
+DEFUN ("network-interface-info", Fnetwork_interface_info,
+       Snetwork_interface_info, 1, 1, 0,
+       doc: /* Return information about network interface named IFNAME.
+The return value is a list (ADDR BCAST NETMASK HWADDR FLAGS),
+where ADDR is the layer 3 address, BCAST is the layer 3 broadcast address,
+NETMASK is the layer 3 network mask, HWADDR is the layer 2 address, and
+FLAGS is the current flags of the interface.
+
+Data that is unavailable is returned as nil.  */)
+  (Lisp_Object ifname)
+{
+#if ((defined HAVE_NET_IF_H                           \
+      && (defined SIOCGIFADDR || defined SIOCGIFHWADDR \
+         || defined SIOCGIFFLAGS))                    \
+     || defined WINDOWSNT)
+  return network_interface_info (ifname);
+#else
+  return Qnil;
+#endif
+}
+
+
 /* Turn off input and output for process PROC.  */
 
 static void

=== modified file 'src/process.h'
--- a/src/process.h     2013-10-16 17:36:04 +0000
+++ b/src/process.h     2013-10-17 06:42:21 +0000
@@ -227,7 +227,9 @@
 
 extern void record_deleted_pid (pid_t, Lisp_Object);
 struct sockaddr;
+#ifdef WINDOWSNT
 extern Lisp_Object conv_sockaddr_to_lisp (struct sockaddr *, int);
+#endif
 extern void hold_keyboard_input (void);
 extern void unhold_keyboard_input (void);
 extern bool kbd_on_hold_p (void);
@@ -242,8 +244,9 @@
 extern void catch_child_signal (void);
 #endif
 
+#ifdef WINDOWSNT
 extern Lisp_Object network_interface_list (void);
 extern Lisp_Object network_interface_info (Lisp_Object);
-
+#endif
 
 INLINE_HEADER_END

=== modified file 'src/term.c'
--- a/src/term.c        2013-10-14 15:37:12 +0000
+++ b/src/term.c        2013-10-17 06:42:21 +0000
@@ -500,8 +500,12 @@
    Set CODING->produced to the byte-length of the resulting byte
    sequence, and return a pointer to that byte sequence.  */
 
+#ifndef WINDOWSNT
+static
+#endif
 unsigned char *
-encode_terminal_code (struct glyph *src, int src_len, struct coding_system 
*coding)
+encode_terminal_code (struct glyph *src, int src_len,
+                     struct coding_system *coding)
 {
   struct glyph *src_end = src + src_len;
   unsigned char *buf;

=== modified file 'src/termhooks.h'
--- a/src/termhooks.h   2013-10-15 18:38:26 +0000
+++ b/src/termhooks.h   2013-10-17 06:42:21 +0000
@@ -630,8 +630,10 @@
 /* The initial terminal device, created by initial_term_init.  */
 extern struct terminal *initial_terminal;
 
+#ifdef WINDOWSNT
 extern unsigned char *encode_terminal_code (struct glyph *, int,
                                            struct coding_system *);
+#endif
 
 #ifdef HAVE_GPM
 extern void close_gpm (int gpm_fd);

=== modified file 'src/w32.c'
--- a/src/w32.c 2013-10-16 15:44:02 +0000
+++ b/src/w32.c 2013-10-17 06:42:21 +0000
@@ -2088,7 +2088,7 @@
     /* For backwards compatibility, check if a .emacs file exists in C:/
        If not, then we can try to default to the appdata directory under the
        user's profile, which is more likely to be writable.   */
-    if (!check_existing ("C:/.emacs"))
+    if (faccessat (AT_FDCWD, "C:/.emacs", F_OK, AT_EACCESS) != 0)
       {
        HRESULT profile_result;
        /* Dynamically load ShGetFolderPath, as it won't exist on versions
@@ -2226,7 +2226,8 @@
                          strcpy (&fname[pend - pstart + 1], "cmdproxy.exe");
                          ExpandEnvironmentStrings ((LPSTR) fname, bufc,
                                                    sizeof (bufc));
-                         if (check_existing (bufc))
+                         if (faccessat (AT_FDCWD, bufc, F_OK, AT_EACCESS)
+                             == 0)
                            {
                              lpval = bufc;
                              dwType = REG_SZ;

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-10-11 15:42:06 +0000
+++ b/src/xdisp.c       2013-10-17 06:42:21 +0000
@@ -26410,9 +26410,11 @@
 }
 
 
-/* EXPORT:
-   Erase the image of a cursor of window W from the screen.  */
+/* Erase the image of a cursor of window W from the screen.  */
 
+#ifndef WINDOWSNT
+static
+#endif
 void
 erase_phys_cursor (struct window *w)
 {

=== modified file 'src/xfaces.c'
--- a/src/xfaces.c      2013-10-14 10:55:24 +0000
+++ b/src/xfaces.c      2013-10-17 06:42:21 +0000
@@ -1197,6 +1197,9 @@
    record that fact in flags of the face so that we don't try to free
    these colors.  */
 
+#ifndef MSDOS
+static
+#endif
 unsigned long
 load_color (struct frame *f, struct face *face, Lisp_Object name,
            enum lface_attribute_index target_index)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]