Commit 3d798ba7 authored by Paul Eggert's avatar Paul Eggert

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.
parent 921c1d62
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.
......
......@@ -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 *);
......
......@@ -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 *);
/* 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,
......
......@@ -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)
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment