summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-09-21 13:59:38 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-09-21 13:59:38 +0200
commitac5d97ead2173f6ec6a8fc3f57b994c86c0afe27 (patch)
treedebba7630c16dc9580d294f355683ec42f398ffd
parent59f09db0b59c710e65aa075874f9d53f29ee18cf (diff)
Rename SOCK_* into PFLOCAL_SOCK_*
To avoid conflicting with glibc's SOCK_* * pflocal/io.c, pflocal/sock.c, pflocal/sock.h, pflocal/socket.c: Rename SOCK_CONNECTED into PFLOCAL_SOCK_CONNECTED, SOCK_NONBLOCK into PFLOCAL_SOCK_NONBLOCK, SOCK_SHUTDOWN_READ into PFLOCAL_SOCK_SHUTDOWN_READ, SOCK_SHUTDOWN_WRITE into PFLOCAL_SOCK_SHUTDOWN_WRITE.
-rw-r--r--pflocal/io.c18
-rw-r--r--pflocal/sock.c28
-rw-r--r--pflocal/sock.h10
-rw-r--r--pflocal/socket.c16
4 files changed, 36 insertions, 36 deletions
diff --git a/pflocal/io.c b/pflocal/io.c
index 67d0349e..00e859a4 100644
--- a/pflocal/io.c
+++ b/pflocal/io.c
@@ -63,7 +63,7 @@ S_io_read (struct sock_user *user,
else if (!err)
{
err =
- pipe_read (pipe, user->sock->flags & SOCK_NONBLOCK, NULL,
+ pipe_read (pipe, user->sock->flags & PFLOCAL_SOCK_NONBLOCK, NULL,
data, data_len, amount);
pipe_release_reader (pipe);
}
@@ -104,7 +104,7 @@ S_io_write (struct sock_user *user,
if (!err)
{
- err = pipe_write (pipe, user->sock->flags & SOCK_NONBLOCK,
+ err = pipe_write (pipe, user->sock->flags & PFLOCAL_SOCK_NONBLOCK,
source_addr, data, data_len, amount);
if (err && source_addr)
ports_port_deref (source_addr);
@@ -365,9 +365,9 @@ S_io_get_openmodes (struct sock_user *user, int *bits)
flags = user->sock->flags;
*bits =
O_APPEND /* pipes always append */
- | (flags & SOCK_NONBLOCK ? O_NONBLOCK : 0)
- | (flags & SOCK_SHUTDOWN_READ ? 0 : O_READ)
- | (flags & SOCK_SHUTDOWN_WRITE ? 0 : O_WRITE);
+ | (flags & PFLOCAL_SOCK_NONBLOCK ? O_NONBLOCK : 0)
+ | (flags & PFLOCAL_SOCK_SHUTDOWN_READ ? 0 : O_READ)
+ | (flags & PFLOCAL_SOCK_SHUTDOWN_WRITE ? 0 : O_WRITE);
return 0;
}
@@ -379,9 +379,9 @@ S_io_set_all_openmodes (struct sock_user *user, int bits)
pthread_mutex_lock (&user->sock->lock);
if (bits & O_NONBLOCK)
- user->sock->flags |= SOCK_NONBLOCK;
+ user->sock->flags |= PFLOCAL_SOCK_NONBLOCK;
else
- user->sock->flags &= ~SOCK_NONBLOCK;
+ user->sock->flags &= ~PFLOCAL_SOCK_NONBLOCK;
pthread_mutex_unlock (&user->sock->lock);
return 0;
@@ -395,7 +395,7 @@ S_io_set_some_openmodes (struct sock_user *user, int bits)
pthread_mutex_lock (&user->sock->lock);
if (bits & O_NONBLOCK)
- user->sock->flags |= SOCK_NONBLOCK;
+ user->sock->flags |= PFLOCAL_SOCK_NONBLOCK;
pthread_mutex_unlock (&user->sock->lock);
return 0;
@@ -409,7 +409,7 @@ S_io_clear_some_openmodes (struct sock_user *user, int bits)
pthread_mutex_lock (&user->sock->lock);
if (bits & O_NONBLOCK)
- user->sock->flags &= ~SOCK_NONBLOCK;
+ user->sock->flags &= ~PFLOCAL_SOCK_NONBLOCK;
pthread_mutex_unlock (&user->sock->lock);
return 0;
diff --git a/pflocal/sock.c b/pflocal/sock.c
index ac66eaca..442205ae 100644
--- a/pflocal/sock.c
+++ b/pflocal/sock.c
@@ -45,11 +45,11 @@ sock_acquire_read_pipe (struct sock *sock, struct pipe **pipe)
/* SOCK may have a read pipe even before it's connected, so make
sure it really is. */
if ( !(sock->pipe_class->flags & PIPE_CLASS_CONNECTIONLESS)
- && !(sock->flags & SOCK_CONNECTED))
+ && !(sock->flags & PFLOCAL_SOCK_CONNECTED))
err = ENOTCONN;
else
pipe_acquire_reader (*pipe);
- else if (sock->flags & SOCK_SHUTDOWN_READ)
+ else if (sock->flags & PFLOCAL_SOCK_SHUTDOWN_READ)
/* Reading on a socket with the read-half shutdown always acts as if the
pipe were at eof, even if the socket isn't connected yet [at least in
netbsd]. */
@@ -74,7 +74,7 @@ sock_acquire_write_pipe (struct sock *sock, struct pipe **pipe)
*pipe = sock->write_pipe;
if (*pipe != NULL)
pipe_acquire_writer (*pipe); /* Do this before unlocking the sock! */
- else if (sock->flags & SOCK_SHUTDOWN_WRITE)
+ else if (sock->flags & PFLOCAL_SOCK_SHUTDOWN_WRITE)
/* Writing on a socket with the write-half shutdown always acts as if the
pipe were broken, even if the socket isn't connected yet [at least in
netbsd]. */
@@ -133,7 +133,7 @@ sock_create (struct pipe_class *pipe_class, mode_t mode, struct sock **sock)
void
sock_free (struct sock *sock)
{
- sock_shutdown (sock, SOCK_SHUTDOWN_READ | SOCK_SHUTDOWN_WRITE);
+ sock_shutdown (sock, PFLOCAL_SOCK_SHUTDOWN_READ | PFLOCAL_SOCK_SHUTDOWN_WRITE);
if (sock->id != MACH_PORT_NULL)
mach_port_destroy (mach_task_self (), sock->id);
if (sock->listen_queue)
@@ -164,7 +164,7 @@ sock_clone (struct sock *template, struct sock **sock)
return err;
/* Copy some properties from TEMPLATE. */
- (*sock)->flags = template->flags & ~SOCK_CONNECTED;
+ (*sock)->flags = template->flags & ~PFLOCAL_SOCK_CONNECTED;
return 0;
}
@@ -382,11 +382,11 @@ sock_connect (struct sock *sock1, struct sock *sock2)
void connect (struct sock *wr, struct sock *rd)
{
- if (!( (wr->flags & SOCK_SHUTDOWN_WRITE)
- || (rd->flags & SOCK_SHUTDOWN_READ)))
+ if (!( (wr->flags & PFLOCAL_SOCK_SHUTDOWN_WRITE)
+ || (rd->flags & PFLOCAL_SOCK_SHUTDOWN_READ)))
{
struct pipe *pipe = rd->read_pipe;
- assert (pipe); /* Since SOCK_SHUTDOWN_READ isn't set. */
+ assert (pipe); /* Since PFLOCAL_SOCK_SHUTDOWN_READ isn't set. */
pipe_add_writer (pipe);
wr->write_pipe = pipe;
}
@@ -402,7 +402,7 @@ sock_connect (struct sock *sock1, struct sock *sock2)
/* If SOCK1 == SOCK2, then we get a fifo! */
pthread_mutex_lock (&sock2->lock);
- if ((sock1->flags & SOCK_CONNECTED) || (sock2->flags & SOCK_CONNECTED))
+ if ((sock1->flags & PFLOCAL_SOCK_CONNECTED) || (sock2->flags & SOCK_CONNECTED))
/* An already-connected socket. */
err = EISCONN;
else
@@ -416,11 +416,11 @@ sock_connect (struct sock *sock1, struct sock *sock2)
/* Only make the reverse for connection-oriented protocols. */
if (! (sock1->pipe_class->flags & PIPE_CLASS_CONNECTIONLESS))
{
- sock1->flags |= SOCK_CONNECTED;
+ sock1->flags |= PFLOCAL_SOCK_CONNECTED;
if (sock1 != sock2)
{
connect (sock2, sock1);
- sock2->flags |= SOCK_CONNECTED;
+ sock2->flags |= PFLOCAL_SOCK_CONNECTED;
}
}
}
@@ -442,7 +442,7 @@ sock_connect (struct sock *sock1, struct sock *sock2)
/* ---------------------------------------------------------------- */
/* Shutdown either the read or write halves of SOCK, depending on whether the
- SOCK_SHUTDOWN_READ or SOCK_SHUTDOWN_WRITE flags are set in FLAGS. */
+ PFLOCAL_SOCK_SHUTDOWN_READ or PFLOCAL_SOCK_SHUTDOWN_WRITE flags are set in FLAGS. */
void
sock_shutdown (struct sock *sock, unsigned flags)
{
@@ -455,13 +455,13 @@ sock_shutdown (struct sock *sock, unsigned flags)
old_flags = sock->flags;
sock->flags |= flags;
- if (flags & SOCK_SHUTDOWN_READ && !(old_flags & SOCK_SHUTDOWN_READ))
+ if (flags & PFLOCAL_SOCK_SHUTDOWN_READ && !(old_flags & SOCK_SHUTDOWN_READ))
{
/* Shutdown the read half. */
read_pipe = sock->read_pipe;
sock->read_pipe = NULL;
}
- if (flags & SOCK_SHUTDOWN_WRITE && !(old_flags & SOCK_SHUTDOWN_WRITE))
+ if (flags & PFLOCAL_SOCK_SHUTDOWN_WRITE && !(old_flags & SOCK_SHUTDOWN_WRITE))
{
/* Shutdown the write half. */
write_pipe = sock->write_pipe;
diff --git a/pflocal/sock.h b/pflocal/sock.h
index fb2db5a4..5800420c 100644
--- a/pflocal/sock.h
+++ b/pflocal/sock.h
@@ -85,10 +85,10 @@ struct sock
};
/* Socket flags */
-#define SOCK_CONNECTED 0x1 /* A connected connection-oriented sock. */
-#define SOCK_NONBLOCK 0x2 /* Don't block on I/O. */
-#define SOCK_SHUTDOWN_READ 0x4 /* The read-half has been shutdown. */
-#define SOCK_SHUTDOWN_WRITE 0x8 /* The write-half has been shutdown. */
+#define PFLOCAL_SOCK_CONNECTED 0x1 /* A connected connection-oriented sock. */
+#define PFLOCAL_SOCK_NONBLOCK 0x2 /* Don't block on I/O. */
+#define PFLOCAL_SOCK_SHUTDOWN_READ 0x4 /* The read-half has been shutdown. */
+#define PFLOCAL_SOCK_SHUTDOWN_WRITE 0x8 /* The write-half has been shutdown. */
/* Returns the pipe that SOCK is reading from in PIPE, locked and with an
additional reference, or an error saying why it's not possible. NULL may
@@ -143,7 +143,7 @@ error_t sock_get_addr (struct sock *sock, struct addr **addr);
error_t sock_get_write_addr_port (struct sock *sock, mach_port_t *addr_port);
/* Shutdown either the read or write halves of SOCK, depending on whether the
- SOCK_SHUTDOWN_READ or SOCK_SHUTDOWN_WRITE flags are set in FLAGS. */
+ PFLOCAL_SOCK_SHUTDOWN_READ or PFLOCAL_SOCK_SHUTDOWN_WRITE flags are set in FLAGS. */
void sock_shutdown (struct sock *sock, unsigned flags);
/* Return a new address, not connected to any socket yet, ADDR. */
diff --git a/pflocal/socket.c b/pflocal/socket.c
index ce1edd82..6723734c 100644
--- a/pflocal/socket.c
+++ b/pflocal/socket.c
@@ -109,8 +109,8 @@ S_socket_connect (struct sock_user *user, struct addr *addr)
if (sock->connect_queue)
/* SOCK is already doing a connect. */
err = EALREADY;
- else if (sock->flags & SOCK_CONNECTED)
- /* SOCK_CONNECTED is only set for connection-oriented sockets,
+ else if (sock->flags & PFLOCAL_SOCK_CONNECTED)
+ /* PFLOCAL_SOCK_CONNECTED is only set for connection-oriented sockets,
which can only ever connect once. [If we didn't do this test
here, it would eventually fail when the listening socket
tried to accept our connection request.] */
@@ -124,7 +124,7 @@ S_socket_connect (struct sock_user *user, struct addr *addr)
pthread_mutex_unlock (&sock->lock);
err = connq_connect (peer->listen_queue,
- sock->flags & SOCK_NONBLOCK);
+ sock->flags & PFLOCAL_SOCK_NONBLOCK);
if (!err)
{
struct sock *server;
@@ -182,7 +182,7 @@ S_socket_accept (struct sock_user *user,
struct sock *peer_sock;
err = connq_listen (sock->listen_queue,
- (sock->flags & SOCK_NONBLOCK) ? &noblock : NULL,
+ (sock->flags & PFLOCAL_SOCK_NONBLOCK) ? &noblock : NULL,
&peer_sock);
if (!err)
{
@@ -229,8 +229,8 @@ S_socket_shutdown (struct sock_user *user, int what)
if (! user)
return EOPNOTSUPP;
sock_shutdown (user->sock,
- (what != 1 ? SOCK_SHUTDOWN_READ : 0)
- | (what != 0 ? SOCK_SHUTDOWN_WRITE : 0));
+ (what != 1 ? PFLOCAL_SOCK_SHUTDOWN_READ : 0)
+ | (what != 0 ? PFLOCAL_SOCK_SHUTDOWN_WRITE : 0));
return 0;
}
@@ -325,7 +325,7 @@ S_socket_send (struct sock_user *user, struct addr *dest_addr, int flags,
if (!err)
{
- err = pipe_send (pipe, sock->flags & SOCK_NONBLOCK,
+ err = pipe_send (pipe, sock->flags & PFLOCAL_SOCK_NONBLOCK,
source_addr, data, data_len,
control, control_len, ports, num_ports,
amount);
@@ -391,7 +391,7 @@ S_socket_recv (struct sock_user *user,
else if (!err)
{
err =
- pipe_recv (pipe, user->sock->flags & SOCK_NONBLOCK, &flags,
+ pipe_recv (pipe, user->sock->flags & PFLOCAL_SOCK_NONBLOCK, &flags,
&source_addr, data, data_len, amount,
control, control_len, ports, num_ports);
pipe_release_reader (pipe);