Patches to improve Hurd parts: generic verify.h and Hurd-specific fcntl-internal.h
Thomas Schwinge
tschwinge@gnu.org
Thu Dec 18 15:00:00 GMT 2008
Hello!
So, here is what I propose instead of changing include/sys/socket.h:
Add the gnulib verify.h (see my other email) to either a Hurd-specific
place or (preferably) a general place (and then avoid the duplication of
the verify macro in time/mktime.c, as well as using it in
iconvdata/cp1255.c, iconvdata/cp1258.c, and iconvdata/tcvn5712-1.c) and
add a Hurd-specific fcntl-internal.h (as follows). I renamed the file to
emphasize the fcntl part (O_* flags), as more such conversions to and
from O_* flags may needed in the future.
Further trivial changes to my posted patches are needed, I can also
re-post them if desired.
socket.c: #include <fcntl-internal.h>
socketpair.c: #include <fcntl-internal.h>
accept4.c: #include <fcntl-internal.h>
pipe2.c:
#include <fcntl.h>
#include <fcntl-internal.h>
#include <hurd.h>
fcntl-intern.h follows.
/* Copyright (C) 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <fcntl.h>
#include <sys/socket.h>
#include <verify.h>
/* Do some compile-time checks for the SOCK_* constants, which we rely on. */
verify (SOCK_CLOEXEC == O_CLOEXEC);
verify ((SOCK_MAX | SOCK_TYPE_MASK) == SOCK_TYPE_MASK);
verify ((SOCK_CLOEXEC & SOCK_TYPE_MASK) == 0);
verify ((SOCK_NONBLOCK & SOCK_TYPE_MASK) == 0);
/* Helper functions for translating between O_* and SOCK_* flags. */
__extern_always_inline
int
sock_to_o_flags (int in)
{
int out = 0;
if (in & SOCK_NONBLOCK)
out |= O_NONBLOCK;
/* Others are passed through unfiltered. */
out |= in & ~(SOCK_NONBLOCK);
return out;
}
__extern_always_inline
int
o_to_sock_flags (int in)
{
int out = 0;
if (in & O_NONBLOCK)
out |= SOCK_NONBLOCK;
/* Others are passed through unfiltered. */
out |= in & ~(O_NONBLOCK);
return out;
}
Regards,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20081218/57efb899/attachment.sig>
More information about the Libc-alpha
mailing list