]> code.delx.au - gnu-emacs/commitdiff
Make some functions static in non-Microsoft builds.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 17 Oct 2013 06:42:21 +0000 (23:42 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 17 Oct 2013 06:42:21 +0000 (23:42 -0700)
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.

15 files changed:
src/ChangeLog
src/dispextern.h
src/fileio.c
src/gnutls.c
src/gnutls.h
src/keyboard.c
src/keyboard.h
src/lisp.h
src/process.c
src/process.h
src/term.c
src/termhooks.h
src/w32.c
src/xdisp.c
src/xfaces.c

index f95ee3384bf046abb25099af2425b8bda9aa0b9c..a0df4425844032d97c6a9dc54077ee07c185cf32 100644 (file)
@@ -1,5 +1,35 @@
 2013-10-17  Paul Eggert  <eggert@cs.ucla.edu>
 
+       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.
index 2d09fe7c5fe3ccdeb8ac5815dadaf873bbc48817..681eba25cb3d399e8ad18708ef28de5f34ad2b5f 100644 (file)
@@ -3229,7 +3229,9 @@ extern void draw_phys_cursor_glyph (struct window *,
                                     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 @@ void update_face_from_frame_parameter (struct frame *, Lisp_Object,
                                        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 *);
index a80145ae42c627565c75d267f60c706d6915943e..a1dcb72b4e41ec5f389209863377506f1cf67cb1 100644 (file)
@@ -160,6 +160,56 @@ static bool a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
 static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
                     struct coding_system *);
 
+\f
+/* 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 */
+}
 \f
 /* Signal a file-access failure.  STRING describes the failure,
    NAME the file involved, and ERRORNO the errno value.
@@ -1733,7 +1783,7 @@ those `/' is discarded.  */)
 
   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 @@ On Unix, this is a name starting with a `/' or a `~'.  */)
   return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil;
 }
 \f
-/* 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 @@ Use `file-symlink-p' to test for such links.  */)
 
   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,
index 2157d5550537a70e470c43a1138c000ee1e1fd9c..f9e86d1a6975a605cb5e4e08935b4baceab823db 100644 (file)
@@ -249,7 +249,9 @@ init_gnutls_functions (void)
 #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 @@ emacs_gnutls_record_check_pending (gnutls_session_t state)
   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)
index 86dcab77b62245ac00d61657d533d09ab859f033..0f648dbd81c37e05d616c94932258f1d1749944a 100644 (file)
@@ -64,7 +64,9 @@ extern ptrdiff_t
 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);
index bb8fefa7046c68cf5da1497d95d16e25e47cd60e..a776720b807b8e7583312fc40668a48bea4ca683 100644 (file)
@@ -2097,6 +2097,9 @@ bind_polling_period (int n)
 \f
 /* Apply the control modifier to CHARACTER.  */
 
+#ifndef WINDOWSNT
+static
+#endif
 int
 make_ctrl_char (int c)
 {
index b9bb006b4ed0d1ae3c3ef619cad8d699e9888f89..b8aad959dd9950bee340c5c41d5b5407c3587ab4 100644 (file)
@@ -517,7 +517,9 @@ extern bool input_polling_used (void);
 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);
index 4e141c71319a0a30ce5b9ee57d0ac096b6b178a9..e1a6fc7c91a01dd0bfcb51c260554ddb6471b9e2 100644 (file)
@@ -3873,7 +3873,6 @@ extern void init_fileio (void);
 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);
index cf9d5e265e1d22d63cc1c03cf4d57ded6e7cb9d5..91bc090e76ee491dea9a07888bbff945ead4c3f1 100644 (file)
@@ -1958,6 +1958,9 @@ create_pty (Lisp_Object process)
 /* 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 @@ usage: (make-network-process &rest ARGS)  */)
 }
 
 \f
-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 @@ static const struct ifflag_def ifflag_table[] = {
   { 0, 0 }
 };
 
-Lisp_Object
+static Lisp_Object
 network_interface_info (Lisp_Object ifname)
 {
   struct ifreq rq;
@@ -3829,6 +3799,45 @@ network_interface_info (Lisp_Object ifname)
 #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
index fc69e2761a5d2000ba48f050a424eb2f8c2a1da9..37d220e987c549268d8312ac55d8874a02de07f4 100644 (file)
@@ -227,7 +227,9 @@ extern Lisp_Object system_process_attributes (Lisp_Object);
 
 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 delete_write_fd (int fd);
 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
index ee81c59dcd41d266293a4bf0e99118d94f5e8520..b4c2e2560cc73f1a48493b446fa206d24e6f937c 100644 (file)
@@ -500,8 +500,12 @@ static ptrdiff_t encode_terminal_dst_size;
    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;
index a3977f5336e5028cc821c9d46dcfa742a79bc1e2..31825a4c95d6787d57b719aa19f7ba2ffe904034 100644 (file)
@@ -630,8 +630,10 @@ extern void delete_terminal (struct terminal *);
 /* 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);
index e26c6f464330cb23e4a5ddc7c39c2ffdba03f47e..2c157d117697625a032822833d642016109bea04 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -2088,7 +2088,7 @@ init_environment (char ** argv)
     /* 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 @@ init_environment (char ** argv)
                          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;
index 033d3b471479bb0d7f5810318950158f6d9af461..395a74e4122a52c4411ed82cfb000b1892396ba7 100644 (file)
@@ -26410,9 +26410,11 @@ draw_phys_cursor_glyph (struct window *w, struct glyph_row *row,
 }
 
 
-/* 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)
 {
index 828788b4abdb1eac0318d554eea5c1fb0092d64e..363d3bb0784e44dac19957c6fdbdc1f934430a9a 100644 (file)
@@ -1197,6 +1197,9 @@ COLOR must be a valid color name.  */)
    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)