aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <[email protected]>2013-10-16 23:42:21 -0700
committerPaul Eggert <[email protected]>2013-10-16 23:42:21 -0700
commit3d798ba7dbad4bac02226959cfd82099bf11fd9f (patch)
treea498f5f85e4b65a4e6b20b470834a304ee127d9e /src
parent921c1d62980fe93d4c26d6aeae0ef2a81a752b11 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog30
-rw-r--r--src/dispextern.h4
-rw-r--r--src/fileio.c103
-rw-r--r--src/gnutls.c4
-rw-r--r--src/gnutls.h2
-rw-r--r--src/keyboard.c3
-rw-r--r--src/keyboard.h2
-rw-r--r--src/lisp.h1
-rw-r--r--src/process.c81
-rw-r--r--src/process.h5
-rw-r--r--src/term.c6
-rw-r--r--src/termhooks.h2
-rw-r--r--src/w32.c5
-rw-r--r--src/xdisp.c6
-rw-r--r--src/xfaces.c3
15 files changed, 163 insertions, 94 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f95ee3384b..a0df442584 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,35 @@
2013-10-17 Paul Eggert <[email protected]>
+ 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.
diff --git a/src/dispextern.h b/src/dispextern.h
index 2d09fe7c5f..681eba25cb 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -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 *);
diff --git a/src/fileio.c b/src/fileio.c
index a80145ae42..a1dcb72b4e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -161,6 +161,56 @@ static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
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 @@ 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;
}
-/* 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,
diff --git a/src/gnutls.c b/src/gnutls.c
index 2157d55505..f9e86d1a69 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -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)
diff --git a/src/gnutls.h b/src/gnutls.h
index 86dcab77b6..0f648dbd81 100644
--- a/src/gnutls.h
+++ b/src/gnutls.h
@@ -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);
diff --git a/src/keyboard.c b/src/keyboard.c
index bb8fefa704..a776720b80 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2097,6 +2097,9 @@ bind_polling_period (int n)
/* Apply the control modifier to CHARACTER. */
+#ifndef WINDOWSNT
+static
+#endif
int
make_ctrl_char (int c)
{
diff --git a/src/keyboard.h b/src/keyboard.h
index b9bb006b4e..b8aad959dd 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -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);
diff --git a/src/lisp.h b/src/lisp.h
index 4e141c7131..e1a6fc7c91 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -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);
diff --git a/src/process.c b/src/process.c
index cf9d5e265e..91bc090e76 100644
--- a/src/process.c
+++ b/src/process.c
@@ -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) */)
}
-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
diff --git a/src/process.h b/src/process.h
index fc69e2761a..37d220e987 100644
--- a/src/process.h
+++ b/src/process.h
@@ -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
diff --git a/src/term.c b/src/term.c
index ee81c59dcd..b4c2e2560c 100644
--- a/src/term.c
+++ b/src/term.c
@@ -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;
diff --git a/src/termhooks.h b/src/termhooks.h
index a3977f5336..31825a4c95 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -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);
diff --git a/src/w32.c b/src/w32.c
index e26c6f4643..2c157d1176 100644
--- 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;
diff --git a/src/xdisp.c b/src/xdisp.c
index 033d3b4714..395a74e412 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -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)
{
diff --git a/src/xfaces.c b/src/xfaces.c
index 828788b4ab..363d3bb078 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -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)