summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1994-09-17 00:02:50 +0000
committerKarl Heuer <kwzh@gnu.org>1994-09-17 00:02:50 +0000
commit4afa4ba8cd21167398b6b50800e32144bf318097 (patch)
tree845a959042a57a67a4db9421821ce94493a43219 /lib-src
parentf7e3b494fc660c065af16da3749aa36a541bd861 (diff)
downloademacs-4afa4ba8cd21167398b6b50800e32144bf318097.tar.gz
(FD_*) [HAVE_SOCKETS & !HAVE_SYSVIPC]: If not already defined, use simple
32-bit versions of these macros. (main) [HAVE_SOCKETS & !HAVE_SYSVIPC]: Use these macros.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsserver.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/lib-src/emacsserver.c b/lib-src/emacsserver.c
index ed3493b76ce..b6d3abbd032 100644
--- a/lib-src/emacsserver.c
+++ b/lib-src/emacsserver.c
@@ -58,6 +58,28 @@ main ()
extern int errno;
+/* Copied from src/process.c */
+#ifdef FD_SET
+/* We could get this from param.h, but better not to depend on finding that.
+ And better not to risk that it might define other symbols used in this
+ file. */
+#ifdef FD_SETSIZE
+#define MAXDESC FD_SETSIZE
+#else
+#define MAXDESC 64
+#endif
+#define SELECT_TYPE fd_set
+#else /* no FD_SET */
+#define MAXDESC 32
+#define SELECT_TYPE int
+
+/* Define the macros to access a single-int bitmap of descriptors. */
+#define FD_SET(n, p) (*(p) |= (1 << (n)))
+#define FD_CLR(n, p) (*(p) &= ~(1 << (n)))
+#define FD_ISSET(n, p) (*(p) & (1 << (n)))
+#define FD_ZERO(p) (*(p) = 0)
+#endif /* no FD_SET */
+
main ()
{
char system_name[32];
@@ -129,15 +151,17 @@ main ()
signal (SIGPIPE, SIG_IGN);
for (;;)
{
- int rmask = (1 << s) + 1;
- if (select (s + 1, (fd_set *)&rmask, 0, 0, 0) < 0)
+ SELECT_TYPE rmask;
+ FD_ZERO (rmask);
+ FD_SET (rmask, 0);
+ FD_SET (rmask, s);
+ if (select (s + 1, &rmask, 0, 0, 0) < 0)
perror ("select");
- if (rmask & (1 << s)) /* client sends list of filenames */
+ if (FD_ISSET (rmask, s)) /* client sends list of filenames */
{
fromlen = sizeof (fromunix);
fromunix.sun_family = AF_UNIX;
- infd = accept (s, (struct sockaddr *) &fromunix,
- (size_t *) &fromlen);
+ infd = accept (s, (struct sockaddr *) &fromunix, &fromlen);
if (infd < 0)
{
if (errno == EMFILE || errno == ENFILE)
@@ -186,7 +210,7 @@ main ()
fflush (infile);
continue;
}
- else if (rmask & 1) /* emacs sends codeword, fd, and string message */
+ else if (FD_ISSET (rmask, 0)) /* emacs sends codeword, fd, and string message */
{
/* Read command codeword and fd */
clearerr (stdin);