summaryrefslogtreecommitdiff
path: root/src/sysdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c383
1 files changed, 147 insertions, 236 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index e311d181c9c..d720c7c5811 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -18,10 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
#include <ctype.h>
#include <signal.h>
#include <stdio.h>
@@ -79,9 +76,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "dosfns.h"
#include "msdos.h"
#include <sys/param.h>
-
-extern int etext;
-extern unsigned start __asm__ ("start");
#endif
#include <sys/file.h>
@@ -169,7 +163,7 @@ static const int baud_convert[] =
int emacs_ospeed;
-void croak P_ ((char *)) NO_RETURN;
+void croak (char *) NO_RETURN;
/* Temporary used by `sigblock' when defined in terms of signprocmask. */
@@ -182,7 +176,7 @@ SIGMASKTYPE sigprocmask_set;
Any other returned value must be freed with free. This is used
only when get_current_dir_name is not defined on the system. */
char*
-get_current_dir_name ()
+get_current_dir_name (void)
{
char *buf;
char *pwd;
@@ -254,7 +248,7 @@ get_current_dir_name ()
/* Discard pending input on all input descriptors. */
void
-discard_tty_input ()
+discard_tty_input (void)
{
#ifndef WINDOWSNT
struct emacs_tty buf;
@@ -353,8 +347,7 @@ init_baud_rate (int fd)
/*ARGSUSED*/
void
-set_exclusive_use (fd)
- int fd;
+set_exclusive_use (int fd)
{
#ifdef FIOCLEX
ioctl (fd, FIOCLEX, 0);
@@ -362,33 +355,23 @@ set_exclusive_use (fd)
/* Ok to do nothing if this feature does not exist */
}
-#ifndef subprocesses
-
-wait_without_blocking ()
-{
- croak ("wait_without_blocking");
- synch_process_alive = 0;
-}
-
-#endif /* not subprocesses */
int wait_debugging; /* Set nonzero to make following function work under dbx
(at least for bsd). */
SIGTYPE
-wait_for_termination_signal ()
+wait_for_termination_signal (void)
{}
+#ifndef MSDOS
/* Wait for subprocess with process id `pid' to terminate and
make sure it will get eliminated (not remain forever as a zombie) */
void
-wait_for_termination (pid)
- int pid;
+wait_for_termination (int pid)
{
while (1)
{
-#ifdef subprocesses
#if defined (BSD_SYSTEM) || defined (HPUX)
/* Note that kill returns -1 even if the process is just a zombie now.
But inevitably a SIGCHLD interrupt should be generated
@@ -424,22 +407,16 @@ wait_for_termination (pid)
sigsuspend (&empty_mask);
#endif /* not WINDOWSNT */
#endif /* not BSD_SYSTEM, and not HPUX version >= 6 */
-#else /* not subprocesses */
- break;
-#endif /* not subprocesses */
}
}
-#ifdef subprocesses
-
/*
* flush any pending output
* (may flush input as well; it does not matter the way we use it)
*/
void
-flush_pending_output (channel)
- int channel;
+flush_pending_output (int channel)
{
#ifdef HAVE_TERMIOS
/* If we try this, we get hit with SIGTTIN, because
@@ -465,10 +442,9 @@ flush_pending_output (channel)
in Emacs. No padding needed for insertion into an Emacs buffer. */
void
-child_setup_tty (out)
- int out;
+child_setup_tty (int out)
{
-#ifndef DOS_NT
+#ifndef WINDOWSNT
struct emacs_tty s;
EMACS_GET_TTY (out, &s);
@@ -552,25 +528,25 @@ child_setup_tty (out)
EMACS_SET_TTY (out, &s, 0);
-#endif /* not DOS_NT */
+#endif /* not WINDOWSNT */
}
+#endif /* MSDOS */
-#endif /* subprocesses */
/* Record a signal code and the handler for it. */
struct save_signal
{
int code;
- SIGTYPE (*handler) P_ ((int));
+ SIGTYPE (*handler) (int);
};
-static void save_signal_handlers P_ ((struct save_signal *));
-static void restore_signal_handlers P_ ((struct save_signal *));
+static void save_signal_handlers (struct save_signal *);
+static void restore_signal_handlers (struct save_signal *);
/* Suspend the Emacs process; give terminal to its superior. */
void
-sys_suspend ()
+sys_suspend (void)
{
#if defined (SIGTSTP) && !defined (MSDOS)
@@ -591,7 +567,7 @@ sys_suspend ()
/* Fork a subshell. */
void
-sys_subshell ()
+sys_subshell (void)
{
#ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */
int st;
@@ -626,7 +602,7 @@ sys_subshell ()
dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil);
str = (unsigned char *) alloca (SCHARS (dir) + 2);
len = SCHARS (dir);
- bcopy (SDATA (dir), str, len);
+ memcpy (str, SDATA (dir), len);
if (str[len - 1] != '/') str[len++] = '/';
str[len] = 0;
xyzzy:
@@ -659,9 +635,7 @@ sys_subshell ()
if (str)
chdir ((char *) str);
-#ifdef subprocesses
close_process_descs (); /* Close Emacs's pipes/ptys */
-#endif
#ifdef SET_EMACS_PRIORITY
{
@@ -719,20 +693,18 @@ sys_subshell ()
}
static void
-save_signal_handlers (saved_handlers)
- struct save_signal *saved_handlers;
+save_signal_handlers (struct save_signal *saved_handlers)
{
while (saved_handlers->code)
{
saved_handlers->handler
- = (SIGTYPE (*) P_ ((int))) signal (saved_handlers->code, SIG_IGN);
+ = (SIGTYPE (*) (int)) signal (saved_handlers->code, SIG_IGN);
saved_handlers++;
}
}
static void
-restore_signal_handlers (saved_handlers)
- struct save_signal *saved_handlers;
+restore_signal_handlers (struct save_signal *saved_handlers)
{
while (saved_handlers->code)
{
@@ -769,8 +741,7 @@ unrequest_sigio (void)
int old_fcntl_flags[MAXDESC];
void
-init_sigio (fd)
- int fd;
+init_sigio (int fd)
{
#ifdef FASYNC
old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC;
@@ -780,8 +751,7 @@ init_sigio (fd)
}
void
-reset_sigio (fd)
- int fd;
+reset_sigio (int fd)
{
#ifdef FASYNC
fcntl (fd, F_SETFL, old_fcntl_flags[fd]);
@@ -793,7 +763,7 @@ reset_sigio (fd)
/* XXX Yeah, but you need it for SIGIO, don't you? */
void
-request_sigio ()
+request_sigio (void)
{
if (noninteractive)
return;
@@ -808,7 +778,7 @@ request_sigio ()
void
unrequest_sigio (void)
-{
+{
if (noninteractive)
return;
@@ -828,7 +798,7 @@ unrequest_sigio (void)
#ifndef MSDOS
void
-request_sigio ()
+request_sigio (void)
{
if (noninteractive || read_socket_hook)
return;
@@ -837,7 +807,7 @@ request_sigio ()
}
void
-unrequest_sigio ()
+unrequest_sigio (void)
{
if (noninteractive || read_socket_hook)
return;
@@ -857,14 +827,12 @@ unrequest_sigio ()
Return zero if all's well, or -1 if we ran into an error we
couldn't deal with. */
int
-emacs_get_tty (fd, settings)
- int fd;
- struct emacs_tty *settings;
+emacs_get_tty (int fd, struct emacs_tty *settings)
{
/* Retrieve the primary parameters - baud rate, character size, etcetera. */
#ifdef HAVE_TCATTR
/* We have those nifty POSIX tcmumbleattr functions. */
- bzero (&settings->main, sizeof (settings->main));
+ memset (&settings->main, 0, sizeof (settings->main));
if (tcgetattr (fd, &settings->main) < 0)
return -1;
@@ -906,10 +874,7 @@ emacs_get_tty (fd, settings)
Return 0 if all went well, and -1 if anything failed. */
int
-emacs_set_tty (fd, settings, flushp)
- int fd;
- struct emacs_tty *settings;
- int flushp;
+emacs_set_tty (int fd, struct emacs_tty *settings, int flushp)
{
/* Set the primary parameters - baud rate, character size, etcetera. */
#ifdef HAVE_TCATTR
@@ -934,7 +899,7 @@ emacs_set_tty (fd, settings, flushp)
{
struct termios new;
- bzero (&new, sizeof (new));
+ memset (&new, 0, sizeof (new));
/* Get the current settings, and see if they're what we asked for. */
tcgetattr (fd, &new);
/* We cannot use memcmp on the whole structure here because under
@@ -1021,8 +986,7 @@ init_all_sys_modes (void)
/* Initialize the terminal mode on the given tty device. */
void
-init_sys_modes (tty_out)
- struct tty_display_info *tty_out;
+init_sys_modes (struct tty_display_info *tty_out)
{
struct emacs_tty tty;
@@ -1033,10 +997,10 @@ init_sys_modes (tty_out)
if (!tty_out->output)
return; /* The tty is suspended. */
-
+
if (! tty_out->old_tty)
tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
-
+
EMACS_GET_TTY (fileno (tty_out->input), tty_out->old_tty);
tty = *tty_out->old_tty;
@@ -1094,7 +1058,7 @@ init_sys_modes (tty_out)
means that the interrupt and quit feature must be
disabled on secondary ttys, or we would not even see the
keypress.
-
+
Note that even though emacsclient could have special code
to pass SIGINT to Emacs, we should _not_ enable
interrupt/quit keys for emacsclient frames. This means
@@ -1112,7 +1076,7 @@ init_sys_modes (tty_out)
tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use
of C-z */
#endif /* VSWTCH */
-
+
#if defined (__mips__) || defined (HAVE_TCATTR)
#ifdef VSUSP
tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */
@@ -1203,9 +1167,9 @@ init_sys_modes (tty_out)
tty.tchars.t_startc = '\021';
tty.tchars.t_stopc = '\023';
}
-
+
tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
-
+
#endif /* HAVE_TCHARS */
#endif /* not HAVE_TERMIO */
@@ -1365,8 +1329,7 @@ get_tty_size (int fd, int *widthp, int *heightp)
to HEIGHT and WIDTH. This is used mainly with ptys. */
int
-set_window_size (fd, height, width)
- int fd, height, width;
+set_window_size (int fd, int height, int width)
{
#ifdef TIOCSWINSZ
@@ -1414,8 +1377,7 @@ reset_all_sys_modes (void)
bottom of the frame, turn off interrupt-driven I/O, etc. */
void
-reset_sys_modes (tty_out)
- struct tty_display_info *tty_out;
+reset_sys_modes (struct tty_display_info *tty_out)
{
if (noninteractive)
{
@@ -1427,11 +1389,11 @@ reset_sys_modes (tty_out)
if (!tty_out->output)
return; /* The tty is suspended. */
-
+
/* Go to and clear the last line of the terminal. */
cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
-
+
/* Code adapted from tty_clear_end_of_line. */
if (tty_out->TS_clr_line)
{
@@ -1441,16 +1403,16 @@ reset_sys_modes (tty_out)
{ /* have to do it the hard way */
int i;
tty_turn_off_insert (tty_out);
-
+
for (i = curX (tty_out); i < FrameCols (tty_out) - 1; i++)
{
fputc (' ', tty_out->output);
}
}
-
+
cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
fflush (tty_out->output);
-
+
if (tty_out->terminal->reset_terminal_modes_hook)
tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
@@ -1490,8 +1452,7 @@ reset_sys_modes (tty_out)
/* Set up the proper status flags for use of a pty. */
void
-setup_pty (fd)
- int fd;
+setup_pty (int fd)
{
/* I'm told that TOICREMOTE does not mean control chars
"can't be sent" but rather that they don't have
@@ -1527,83 +1488,6 @@ setup_pty (fd)
}
#endif /* HAVE_PTYS */
-#if !defined(CANNOT_DUMP) || !defined(SYSTEM_MALLOC)
-/* Some systems that cannot dump also cannot implement these. */
-
-/*
- * Return the address of the start of the text segment prior to
- * doing an unexec. After unexec the return value is undefined.
- * See crt0.c for further explanation and _start.
- *
- */
-
-#if !(defined (__NetBSD__) && defined (__ELF__))
-#ifndef HAVE_TEXT_START
-char *
-start_of_text ()
-{
-#ifdef TEXT_START
- return ((char *) TEXT_START);
-#else
- extern int _start ();
- return ((char *) _start);
-#endif /* TEXT_START */
-}
-#endif /* not HAVE_TEXT_START */
-#endif
-
-/*
- * Return the address of the start of the data segment prior to
- * doing an unexec. After unexec the return value is undefined.
- * See crt0.c for further information and definition of data_start.
- *
- * Apparently, on BSD systems this is etext at startup. On
- * USG systems (swapping) this is highly mmu dependent and
- * is also dependent on whether or not the program is running
- * with shared text. Generally there is a (possibly large)
- * gap between end of text and start of data with shared text.
- *
- * On Uniplus+ systems with shared text, data starts at a
- * fixed address. Each port (from a given oem) is generally
- * different, and the specific value of the start of data can
- * be obtained via the UniPlus+ specific "uvar" system call,
- * however the method outlined in crt0.c seems to be more portable.
- *
- * Probably what will have to happen when a USG unexec is available,
- * at least on UniPlus, is temacs will have to be made unshared so
- * that text and data are contiguous. Then once loadup is complete,
- * unexec will produce a shared executable where the data can be
- * at the normal shared text boundary and the startofdata variable
- * will be patched by unexec to the correct value.
- *
- */
-
-#ifndef start_of_data
-char *
-start_of_data ()
-{
-#ifdef DATA_START
- return ((char *) DATA_START);
-#else
-#ifdef ORDINARY_LINK
- /*
- * This is a hack. Since we're not linking crt0.c or pre_crt0.c,
- * data_start isn't defined. We take the address of environ, which
- * is known to live at or near the start of the system crt0.c, and
- * we don't sweat the handful of bytes that might lose.
- */
- extern char **environ;
-
- return ((char *) &environ);
-#else
- extern int data_start;
- return ((char *) &data_start);
-#endif /* ORDINARY_LINK */
-#endif /* DATA_START */
-}
-#endif /* start_of_data */
-#endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */
-
/* init_system_name sets up the string for the Lisp function
system-name to return. */
@@ -1621,7 +1505,7 @@ extern int h_errno;
#endif /* TRY_AGAIN */
void
-init_system_name ()
+init_system_name (void)
{
#ifndef HAVE_GETHOSTNAME
struct utsname uts;
@@ -1654,7 +1538,7 @@ init_system_name ()
#ifndef CANNOT_DUMP
if (initialized)
#endif /* not CANNOT_DUMP */
- if (! index (hostname, '.'))
+ if (! strchr (hostname, '.'))
{
int count;
#ifdef HAVE_GETADDRINFO
@@ -1662,7 +1546,7 @@ init_system_name ()
struct addrinfo hints;
int ret;
- memset (&hints, 0, sizeof(hints));
+ memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
@@ -1683,7 +1567,7 @@ init_system_name ()
while (it)
{
char *fqdn = it->ai_canonname;
- if (fqdn && index (fqdn, '.')
+ if (fqdn && strchr (fqdn, '.')
&& strcmp (fqdn, "localhost.localdomain") != 0)
break;
it = it->ai_next;
@@ -1719,13 +1603,13 @@ init_system_name ()
{
char *fqdn = (char *) hp->h_name;
- if (!index (fqdn, '.'))
+ if (!strchr (fqdn, '.'))
{
/* 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, '.')
+ && (!strchr (*alias, '.')
|| !strcmp (*alias, "localhost.localdomain")))
alias++;
if (*alias)
@@ -1774,8 +1658,8 @@ jmp_buf read_alarm_throw;
int read_alarm_should_throw;
-SIGTYPE
-select_alarm ()
+void
+select_alarm (int ignore)
{
select_alarmed = 1;
signal (SIGALRM, SIG_IGN);
@@ -1787,23 +1671,18 @@ select_alarm ()
#ifndef WINDOWSNT
/* Only rfds are checked. */
int
-sys_select (nfds, rfds, wfds, efds, timeout)
- int nfds;
- SELECT_TYPE *rfds, *wfds, *efds;
- EMACS_TIME *timeout;
+sys_select (int nfds,
+ SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
+ EMACS_TIME *timeout)
{
/* XXX This needs to be updated for multi-tty support. Is there
- anybody who needs to emulate select these days? */
+ anybody who needs to emulate select these days? */
int ravail = 0;
SELECT_TYPE orfds;
int timeoutval;
int *local_timeout;
extern int proc_buffered_char[];
-#ifndef subprocesses
- int process_tick = 0, update_tick = 0;
-#else
extern int process_tick, update_tick;
-#endif
unsigned char buf;
#if defined (HAVE_SELECT) && defined (HAVE_X_WINDOWS)
@@ -1924,12 +1803,11 @@ sys_select (nfds, rfds, wfds, efds, timeout)
waiting for at least one character. */
void
-read_input_waiting ()
+read_input_waiting (void)
{
/* XXX This needs to be updated for multi-tty support. Is there
anybody who needs to emulate select these days? */
int nread, i;
- extern int quit_char;
if (read_socket_hook)
{
@@ -2077,7 +1955,7 @@ static char *my_sys_siglist[NSIG];
#endif
void
-init_signals ()
+init_signals (void)
{
sigemptyset (&empty_mask);
sigfillset (&full_mask);
@@ -2283,8 +2161,7 @@ init_signals ()
#endif /* !RAND_BITS */
void
-seed_random (arg)
- long arg;
+seed_random (long int arg)
{
#ifdef HAVE_RANDOM
srandom ((unsigned int)arg);
@@ -2302,7 +2179,7 @@ seed_random (arg)
* This suffices even for a 64-bit architecture with a 15-bit rand.
*/
long
-get_random ()
+get_random (void)
{
long val = random ();
#if VALBITS > RAND_BITS
@@ -2337,9 +2214,7 @@ strerror (errnum)
#endif /* ! HAVE_STRERROR */
int
-emacs_open (path, oflag, mode)
- const char *path;
- int oflag, mode;
+emacs_open (const char *path, int oflag, int mode)
{
register int rtnval;
@@ -2350,8 +2225,7 @@ emacs_open (path, oflag, mode)
}
int
-emacs_close (fd)
- int fd;
+emacs_close (int fd)
{
int did_retry = 0;
register int rtnval;
@@ -2370,10 +2244,7 @@ emacs_close (fd)
}
int
-emacs_read (fildes, buf, nbyte)
- int fildes;
- char *buf;
- unsigned int nbyte;
+emacs_read (int fildes, char *buf, unsigned int nbyte)
{
register int rtnval;
@@ -2384,10 +2255,7 @@ emacs_read (fildes, buf, nbyte)
}
int
-emacs_write (fildes, buf, nbyte)
- int fildes;
- const char *buf;
- unsigned int nbyte;
+emacs_write (int fildes, const char *buf, unsigned int nbyte)
{
register int rtnval, bytes_written;
@@ -2448,11 +2316,10 @@ emacs_write (fildes, buf, nbyte)
#ifndef HAVE_GETWD
char *
-getwd (pathname)
- char *pathname;
+getwd (char *pathname)
{
char *npath, *spath;
- extern char *getcwd ();
+ extern char *getcwd (char *, size_t);
BLOCK_INPUT; /* getcwd uses malloc */
spath = npath = getcwd ((char *) 0, MAXPATHLEN);
@@ -2481,9 +2348,8 @@ getwd (pathname)
#ifndef HAVE_RENAME
-rename (from, to)
- const char *from;
- const char *to;
+int
+rename (const char *from, const char *to)
{
if (access (from, 0) == 0)
{
@@ -2503,7 +2369,8 @@ rename (from, to)
/* HPUX curses library references perror, but as far as we know
it won't be called. Anyway this definition will do for now. */
-perror ()
+void
+perror (void)
{
}
#endif /* HPUX and not HAVE_PERROR */
@@ -2516,9 +2383,8 @@ perror ()
* until we are, then close the unsuccessful ones.
*/
-dup2 (oldd, newd)
- int oldd;
- int newd;
+int
+dup2 (int oldd, int newd)
{
register int fd, ret;
@@ -2546,17 +2412,14 @@ dup2 (oldd, newd)
* Only needed when subprocesses are defined.
*/
-#ifdef subprocesses
#ifndef HAVE_GETTIMEOFDAY
#ifdef HAVE_TIMEVAL
/* ARGSUSED */
int
-gettimeofday (tp, tzp)
- struct timeval *tp;
- struct timezone *tzp;
+gettimeofday (struct timeval *tp, struct timezone *tzp)
{
- extern long time ();
+ extern long time (long);
tp->tv_sec = time ((long *)0);
tp->tv_usec = 0;
@@ -2566,16 +2429,14 @@ gettimeofday (tp, tzp)
}
#endif
-#endif
-#endif /* subprocess && !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL */
+#endif /* !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL */
/*
* This function will go away as soon as all the stubs fixed. (fnf)
*/
void
-croak (badfunc)
- char *badfunc;
+croak (char *badfunc)
{
printf ("%s not yet implemented\r\n", badfunc);
reset_all_sys_modes ();
@@ -2607,9 +2468,7 @@ closedir (DIR *dirp /* stream from opendir */)
int
-set_file_times (filename, atime, mtime)
- const char *filename;
- EMACS_TIME atime, mtime;
+set_file_times (const char *filename, EMACS_TIME atime, EMACS_TIME mtime)
{
#ifdef HAVE_UTIMES
struct timeval tv[2];
@@ -2646,9 +2505,7 @@ set_file_times (filename, atime, mtime)
* Make a directory.
*/
int
-mkdir (dpath, dmode)
- char *dpath;
- int dmode;
+mkdir (char *dpath, int dmode)
{
int cpid, status, fd;
struct stat statbuf;
@@ -2706,8 +2563,7 @@ mkdir (dpath, dmode)
#ifndef HAVE_RMDIR
int
-rmdir (dpath)
- char *dpath;
+rmdir (char *dpath)
{
int cpid, status, fd;
struct stat statbuf;
@@ -2752,10 +2608,62 @@ rmdir (dpath)
#endif /* !HAVE_RMDIR */
+#ifndef HAVE_MEMSET
+void *
+memset (void *b, int n, size_t length)
+{
+ unsigned char *p = b;
+ while (length-- > 0)
+ *p++ = n;
+ return b;
+}
+#endif /* !HAVE_MEMSET */
+
+#ifndef HAVE_MEMCPY
+void *
+memcpy (void *b1, void *b2, size_t length)
+{
+ unsigned char *p1 = b1, *p2 = b2;
+ while (length-- > 0)
+ *p1++ = *p2++;
+ return b1;
+}
+#endif /* !HAVE_MEMCPY */
+
+#ifndef HAVE_MEMMOVE
+void *
+memmove (void *b1, void *b2, size_t length)
+{
+ unsigned char *p1 = b1, *p2 = b2;
+ if (p1 < p2 || p1 >= p2 + length)
+ while (length-- > 0)
+ *p1++ = *p2++;
+ else
+ {
+ p1 += length;
+ p2 += length;
+ while (length-- > 0)
+ *--p1 = *--p2;
+ }
+ return b1;
+}
+#endif /* !HAVE_MEMCPY */
+
+#ifndef HAVE_MEMCMP
+int
+memcmp (void *b1, void *b2, size_t length)
+{
+ unsigned char *p1 = b1, *p2 = b2;
+ while (length-- > 0)
+ if (*p1++ != *p2++)
+ return p1[-1] < p2[-1] ? -1 : 1;
+ return 0;
+}
+#endif /* !HAVE_MEMCMP */
+
#ifndef HAVE_STRSIGNAL
char *
-strsignal (code)
- int code;
+strsignal (int code)
{
char *signame = 0;
@@ -2771,7 +2679,8 @@ strsignal (code)
#ifdef HAVE_TERMIOS
/* For make-serial-process */
-int serial_open (char *port)
+int
+serial_open (char *port)
{
int fd = -1;
@@ -2804,7 +2713,8 @@ int serial_open (char *port)
#if !defined (HAVE_CFMAKERAW)
/* Workaround for targets which are missing cfmakeraw. */
/* Pasted from man page. */
-static void cfmakeraw (struct termios *termios_p)
+static void
+cfmakeraw (struct termios *termios_p)
{
termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
termios_p->c_oflag &= ~OPOST;
@@ -2816,7 +2726,8 @@ static void cfmakeraw (struct termios *termios_p)
#if !defined (HAVE_CFSETSPEED)
/* Workaround for targets which are missing cfsetspeed. */
-static int cfsetspeed (struct termios *termios_p, speed_t vitesse)
+static int
+cfsetspeed (struct termios *termios_p, speed_t vitesse)
{
return (cfsetispeed (termios_p, vitesse)
+ cfsetospeed (termios_p, vitesse));
@@ -2826,7 +2737,7 @@ static int cfsetspeed (struct termios *termios_p, speed_t vitesse)
/* For serial-process-configure */
void
serial_configure (struct Lisp_Process *p,
- Lisp_Object contact)
+ Lisp_Object contact)
{
Lisp_Object childp2 = Qnil;
Lisp_Object tem = Qnil;
@@ -2869,7 +2780,7 @@ serial_configure (struct Lisp_Process *p,
CHECK_NUMBER (tem);
if (XINT (tem) != 7 && XINT (tem) != 8)
error (":bytesize must be nil (8), 7, or 8");
- summary[0] = XINT(tem) + '0';
+ summary[0] = XINT (tem) + '0';
#if defined (CSIZE) && defined (CS7) && defined (CS8)
attr.c_cflag &= ~CSIZE;
attr.c_cflag |= ((XINT (tem) == 7) ? CS7 : CS8);
@@ -2993,7 +2904,7 @@ serial_configure (struct Lisp_Process *p,
/* Process enumeration and access via /proc. */
Lisp_Object
-list_system_processes ()
+list_system_processes (void)
{
Lisp_Object procdir, match, proclist, next;
struct gcpro gcpro1, gcpro2;
@@ -3027,7 +2938,7 @@ list_system_processes ()
#elif !defined (WINDOWSNT) && !defined (MSDOS)
Lisp_Object
-list_system_processes ()
+list_system_processes (void)
{
return Qnil;
}
@@ -3226,7 +3137,7 @@ system_process_attributes (Lisp_Object pid)
procfn_end = fn + strlen (fn);
strcpy (procfn_end, "/stat");
fd = emacs_open (fn, O_RDONLY, 0);
- if (fd >= 0 && (nread = emacs_read (fd, procbuf, sizeof(procbuf) - 1)) > 0)
+ if (fd >= 0 && (nread = emacs_read (fd, procbuf, sizeof (procbuf) - 1)) > 0)
{
procbuf[nread] = '\0';
p = procbuf;
@@ -3487,7 +3398,7 @@ system_process_attributes (Lisp_Object pid)
strcpy (procfn_end, "/psinfo");
fd = emacs_open (fn, O_RDONLY, 0);
if (fd >= 0
- && (nread = read (fd, (char*)&pinfo, sizeof(struct psinfo)) > 0))
+ && (nread = read (fd, (char*)&pinfo, sizeof (struct psinfo)) > 0))
{
attrs = Fcons (Fcons (Qppid, make_fixnum_or_float (pinfo.pr_ppid)), attrs);
attrs = Fcons (Fcons (Qpgrp, make_fixnum_or_float (pinfo.pr_pgid)), attrs);