Author: yoann
Date: 2008-11-12 10:36:48 +0100 (Wed, 12 Nov 2008)
New Revision: 11085
Added:
libprelude/trunk/libmissing/connect.c
libprelude/trunk/libmissing/getsockname.c
libprelude/trunk/libmissing/setsockopt.c
libprelude/trunk/libmissing/socket.c
libprelude/trunk/libmissing/tests/accept.c
libprelude/trunk/libmissing/tests/bind.c
libprelude/trunk/libmissing/tests/ioctl.c
libprelude/trunk/libmissing/tests/listen.c
libprelude/trunk/libmissing/tests/sys_ioctl.in.h
libprelude/trunk/libmissing/tests/w32sock.h
libprelude/trunk/libmissing/w32sock.h
Removed:
libprelude/trunk/libmissing/m4/memchr.m4
libprelude/trunk/libmissing/m4/memcmp.m4
libprelude/trunk/libmissing/m4/strpbrk.m4
libprelude/trunk/libmissing/memchr.c
libprelude/trunk/libmissing/memcmp.c
libprelude/trunk/libmissing/raise.c
libprelude/trunk/libmissing/strpbrk.c
libprelude/trunk/libmissing/tests/test-memchr.c
libprelude/trunk/libmissing/tests/test-memcmp.c
libprelude/trunk/libmissing/tests/winsock.c
libprelude/trunk/libmissing/winsock.c
Modified:
libprelude/trunk/libmissing/Makefile.am
libprelude/trunk/libmissing/glthread/thread.c
libprelude/trunk/libmissing/m4/gnulib-comp.m4
libprelude/trunk/libmissing/m4/include_next.m4
libprelude/trunk/libmissing/m4/netdb_h.m4
libprelude/trunk/libmissing/m4/stdlib_h.m4
libprelude/trunk/libmissing/m4/sys_socket_h.m4
libprelude/trunk/libmissing/m4/unistd_h.m4
libprelude/trunk/libmissing/netdb.in.h
libprelude/trunk/libmissing/signal.in.h
libprelude/trunk/libmissing/stdlib.in.h
libprelude/trunk/libmissing/sys_socket.in.h
libprelude/trunk/libmissing/sys_stat.in.h
libprelude/trunk/libmissing/tests/Makefile.am
libprelude/trunk/libmissing/tests/close.c
libprelude/trunk/libmissing/unistd.in.h
Log:
Update GnuLib code.
Modified: libprelude/trunk/libmissing/Makefile.am
===================================================================
--- libprelude/trunk/libmissing/Makefile.am 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/Makefile.am 2008-11-12 09:36:48 UTC (rev 11085)
@@ -166,9 +166,9 @@
## begin gnulib module connect
-EXTRA_DIST += winsock.c
+EXTRA_DIST += connect.c w32sock.h
-EXTRA_libmissing_la_SOURCES += winsock.c
+EXTRA_libmissing_la_SOURCES += connect.c
## end gnulib module connect
@@ -296,9 +296,9 @@
## begin gnulib module getsockname
-EXTRA_DIST += winsock.c
+EXTRA_DIST += getsockname.c w32sock.h
-EXTRA_libmissing_la_SOURCES += winsock.c
+EXTRA_libmissing_la_SOURCES += getsockname.c
## end gnulib module getsockname
@@ -448,24 +448,6 @@
## end gnulib module malloc-posix
-## begin gnulib module memchr
-
-
-EXTRA_DIST += memchr.c
-
-EXTRA_libmissing_la_SOURCES += memchr.c
-
-## end gnulib module memchr
-
-## begin gnulib module memcmp
-
-
-EXTRA_DIST += memcmp.c
-
-EXTRA_libmissing_la_SOURCES += memcmp.c
-
-## end gnulib module memcmp
-
## begin gnulib module memmem-simple
@@ -572,15 +554,6 @@
## end gnulib module poll
-## begin gnulib module raise
-
-
-EXTRA_DIST += raise.c
-
-EXTRA_libmissing_la_SOURCES += raise.c
-
-## end gnulib module raise
-
## begin gnulib module realloc-posix
@@ -621,9 +594,9 @@
## begin gnulib module setsockopt
-EXTRA_DIST += winsock.c
+EXTRA_DIST += setsockopt.c w32sock.h
-EXTRA_libmissing_la_SOURCES += winsock.c
+EXTRA_libmissing_la_SOURCES += setsockopt.c
## end gnulib module setsockopt
@@ -693,9 +666,9 @@
## begin gnulib module socket
-EXTRA_DIST += winsock.c
+EXTRA_DIST += socket.c w32sock.h
-EXTRA_libmissing_la_SOURCES += winsock.c
+EXTRA_libmissing_la_SOURCES += socket.c
## end gnulib module socket
@@ -863,6 +836,7 @@
-e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
-e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
-e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
+ -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
-e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
-e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
-e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
@@ -875,11 +849,13 @@
-e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
-e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
-e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
+ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
-e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
-e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
-e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
-e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
-e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
+ -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
-e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
-e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
-e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
@@ -1062,15 +1038,6 @@
## end gnulib module strnlen
-## begin gnulib module strpbrk
-
-
-EXTRA_DIST += strpbrk.c
-
-EXTRA_libmissing_la_SOURCES += strpbrk.c
-
-## end gnulib module strpbrk
-
## begin gnulib module strptime
@@ -1139,7 +1106,7 @@
-e 's|@''GNULIB_GETSOCKOPT''@|$(GNULIB_GETSOCKOPT)|g' \
-e 's|@''GNULIB_LISTEN''@|$(GNULIB_LISTEN)|g' \
-e 's|@''GNULIB_RECV''@|$(GNULIB_RECV)|g' \
- -e 's|@''GNULIB_SEND''@|$()GNULIB_SEND|g' \
+ -e 's|@''GNULIB_SEND''@|$(GNULIB_SEND)|g' \
-e 's|@''GNULIB_RECVFROM''@|$(GNULIB_RECVFROM)|g' \
-e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \
-e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \
@@ -1153,10 +1120,8 @@
MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
MOSTLYCLEANDIRS += sys
-EXTRA_DIST += sys_socket.in.h winsock.c
+EXTRA_DIST += sys_socket.in.h
-EXTRA_libmissing_la_SOURCES += winsock.c
-
## end gnulib module sys_socket
## begin gnulib module sys_stat
@@ -1311,6 +1276,7 @@
-e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
-e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \
-e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
+ -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
-e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
-e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
-e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
@@ -1326,6 +1292,7 @@
-e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
-e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
-e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
+ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
-e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
-e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
-e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
Copied: libprelude/trunk/libmissing/connect.c (from rev 11082, libprelude/trunk/libmissing/raise.c)
===================================================================
--- libprelude/trunk/libmissing/connect.c (rev 0)
+++ libprelude/trunk/libmissing/connect.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,47 @@
+/* connect.c --- wrappers for Windows connect function
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef connect
+
+int
+rpl_connect (int fd, struct sockaddr *sockaddr, int len)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ int r = connect (sock, sockaddr, len);
+ if (r < 0)
+ {
+ /* EINPROGRESS is not returned by WinSock 2.0; for backwards
+ compatibility, connect(2) uses EWOULDBLOCK. */
+ if (WSAGetLastError () == WSAEWOULDBLOCK)
+ WSASetLastError (WSAEINPROGRESS);
+
+ set_winsock_errno ();
+ }
+
+ return r;
+}
Copied: libprelude/trunk/libmissing/getsockname.c (from rev 11082, libprelude/trunk/libmissing/raise.c)
===================================================================
--- libprelude/trunk/libmissing/getsockname.c (rev 0)
+++ libprelude/trunk/libmissing/getsockname.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,40 @@
+/* getsockname.c --- wrappers for Windows getsockname function
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef getsockname
+
+int
+rpl_getsockname (int fd, struct sockaddr *addr, int *addrlen)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ int r = getsockname (sock, addr, addrlen);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+}
Modified: libprelude/trunk/libmissing/glthread/thread.c
===================================================================
--- libprelude/trunk/libmissing/glthread/thread.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/glthread/thread.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -210,6 +210,7 @@
gl_thread_t thread = gl_thread_self ();
thread->result = retval;
_endthreadex (0); /* calls ExitThread (0) */
+ abort ();
}
#endif
Modified: libprelude/trunk/libmissing/m4/gnulib-comp.m4
===================================================================
--- libprelude/trunk/libmissing/m4/gnulib-comp.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/gnulib-comp.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -55,7 +55,7 @@
gl_COND
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
- AC_LIBOBJ([winsock])
+ AC_LIBOBJ([connect])
fi
gl_SYS_SOCKET_MODULE_INDICATOR([connect])
gl_FUNC_DUP2
@@ -76,7 +76,7 @@
gl_FUNC_GETPASS
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
- AC_LIBOBJ([winsock])
+ AC_LIBOBJ([getsockname])
fi
gl_SYS_SOCKET_MODULE_INDICATOR([getsockname])
AC_SUBST([LIBINTL])
@@ -96,8 +96,6 @@
AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.])
gl_FUNC_MALLOC_POSIX
gl_STDLIB_MODULE_INDICATOR([malloc-posix])
- gl_FUNC_MEMCHR
- gl_FUNC_MEMCMP
gl_FUNC_MEMMEM
gl_FUNC_MEMMEM_SIMPLE
gl_STRING_MODULE_INDICATOR([memmem])
@@ -110,7 +108,6 @@
gl_FUNC_PERROR
gl_STRING_MODULE_INDICATOR([perror])
gl_FUNC_POLL
- AC_REPLACE_FUNCS(raise)
gl_FUNC_REALLOC_POSIX
gl_STDLIB_MODULE_INDICATOR([realloc-posix])
gl_REGEX
@@ -122,7 +119,7 @@
gl_SYS_SELECT_MODULE_INDICATOR([select])
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
- AC_LIBOBJ([winsock])
+ AC_LIBOBJ([setsockopt])
fi
gl_SYS_SOCKET_MODULE_INDICATOR([setsockopt])
gl_SIGNAL_H
@@ -135,7 +132,7 @@
gl_STDIO_MODULE_INDICATOR([snprintf])
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
- AC_LIBOBJ([winsock])
+ AC_LIBOBJ([socket])
fi
gl_SYS_SOCKET_MODULE_INDICATOR([socket])
gl_TYPE_SOCKLEN_T
@@ -160,8 +157,6 @@
gl_STRING_MODULE_INDICATOR([strndup])
gl_FUNC_STRNLEN
gl_STRING_MODULE_INDICATOR([strnlen])
- gl_FUNC_STRPBRK
- gl_STRING_MODULE_INDICATOR([strpbrk])
gl_FUNC_STRPTIME
gl_FUNC_STRSEP
gl_STRING_MODULE_INDICATOR([strsep])
@@ -231,12 +226,12 @@
gl_source_base='libmissing/tests'
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
- AC_LIBOBJ([winsock])
+ AC_LIBOBJ([accept])
fi
gl_SYS_SOCKET_MODULE_INDICATOR([accept])
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
- AC_LIBOBJ([winsock])
+ AC_LIBOBJ([bind])
fi
gl_SYS_SOCKET_MODULE_INDICATOR([bind])
gl_FUNC_CLOSE
@@ -245,8 +240,15 @@
gl_STDIO_MODULE_INDICATOR([fclose])
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
- AC_LIBOBJ([winsock])
+ AC_LIBOBJ([ioctl])
+ gl_REPLACE_SYS_IOCTL_H
fi
+ gl_SYS_IOCTL_MODULE_INDICATOR([ioctl])
+ gl_MODULE_INDICATOR([ioctl])
+ AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+ if test "$ac_cv_header_winsock2_h" = yes; then
+ AC_LIBOBJ([listen])
+ fi
gl_SYS_SOCKET_MODULE_INDICATOR([listen])
AC_CHECK_DECLS_ONCE([alarm])
AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
@@ -254,6 +256,8 @@
gt_TYPE_WCHAR_T
gt_TYPE_WINT_T
AC_CHECK_DECLS_ONCE([alarm])
+ gl_SYS_IOCTL_H
+ AC_PROG_MKDIR_P
AC_CHECK_FUNCS([shutdown])
gl_YIELD
m4_ifval(gltests_LIBSOURCES_LIST, [
@@ -357,6 +361,7 @@
lib/c-ctype.c
lib/c-ctype.h
lib/config.charset
+ lib/connect.c
lib/dup2.c
lib/errno.in.h
lib/float+.h
@@ -371,6 +376,7 @@
lib/getline.c
lib/getpass.c
lib/getpass.h
+ lib/getsockname.c
lib/gettext.h
lib/gettimeofday.c
lib/glthread/cond.c
@@ -389,8 +395,6 @@
lib/localcharset.h
lib/lseek.c
lib/malloc.c
- lib/memchr.c
- lib/memcmp.c
lib/memmem.c
lib/minmax.h
lib/mktime.c
@@ -404,7 +408,6 @@
lib/printf-args.h
lib/printf-parse.c
lib/printf-parse.h
- lib/raise.c
lib/realloc.c
lib/ref-add.sin
lib/ref-del.sin
@@ -416,11 +419,13 @@
lib/regexec.c
lib/relocatable.c
lib/relocatable.h
+ lib/setsockopt.c
lib/signal.in.h
lib/sigprocmask.c
lib/size_max.h
lib/sleep.c
lib/snprintf.c
+ lib/socket.c
lib/stdbool.in.h
lib/stdint.in.h
lib/stdio-impl.h
@@ -437,7 +442,6 @@
lib/strncasecmp.c
lib/strndup.c
lib/strnlen.c
- lib/strpbrk.c
lib/strptime.c
lib/strsep.c
lib/sys_select.in.h
@@ -453,10 +457,10 @@
lib/vasnprintf.c
lib/vasnprintf.h
lib/vsnprintf.c
+ lib/w32sock.h
lib/wchar.in.h
lib/wctype.in.h
lib/winsock-select.c
- lib/winsock.c
lib/write.c
lib/xsize.h
m4/alloca.m4
@@ -493,8 +497,6 @@
m4/lseek.m4
m4/malloc.m4
m4/mbstate_t.m4
- m4/memchr.m4
- m4/memcmp.m4
m4/memmem.m4
m4/minmax.m4
m4/mktime.m4
@@ -530,7 +532,6 @@
m4/strings_h.m4
m4/strndup.m4
m4/strnlen.m4
- m4/strpbrk.m4
m4/strptime.m4
m4/strsep.m4
m4/sys_ioctl_h.m4
@@ -571,8 +572,6 @@
tests/test-lock.c
tests/test-lseek.c
tests/test-lseek.sh
- tests/test-memchr.c
- tests/test-memcmp.c
tests/test-memmem.c
tests/test-netdb.c
tests/test-netinet_in.c
@@ -602,11 +601,16 @@
tests/test-vsnprintf.c
tests/test-wchar.c
tests/test-wctype.c
+ tests=lib/accept.c
+ tests=lib/bind.c
tests=lib/close.c
tests=lib/fclose.c
tests=lib/glthread/yield.h
+ tests=lib/ioctl.c
+ tests=lib/listen.c
tests=lib/sockets.c
tests=lib/sockets.h
+ tests=lib/sys_ioctl.in.h
tests=lib/verify.h
- tests=lib/winsock.c
+ tests=lib/w32sock.h
])
Modified: libprelude/trunk/libmissing/m4/include_next.m4
===================================================================
--- libprelude/trunk/libmissing/m4/include_next.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/include_next.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,4 +1,4 @@
-# include_next.m4 serial 8
+# include_next.m4 serial 9
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -87,6 +87,7 @@
AC_DEFUN([gl_CHECK_NEXT_HEADERS],
[
AC_REQUIRE([gl_INCLUDE_NEXT])
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_CHECK_HEADERS_ONCE([$1])
m4_foreach_w([gl_HEADER_NAME], [$1],
@@ -105,11 +106,22 @@
[AC_LANG_SOURCE(
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
)])
- dnl eval is necessary to expand ac_cpp.
+ dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
+ dnl that contain only a #include of other header files and no
+ dnl non-comment tokens of their own. This leads to a failure to
+ dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
+ dnl and others. The workaround is to force preservation of comments
+ dnl through option -C. This ensures all necessary #line directives
+ dnl are present. GCC supports option -C as well.
+ case "$host_os" in
+ aix*) gl_absname_cpp="$ac_cpp -C" ;;
+ *) gl_absname_cpp="$ac_cpp" ;;
+ esac
+ dnl eval is necessary to expand gl_absname_cpp.
dnl Ultrix and Pyramid sh refuse to redirect output of eval,
dnl so use subshell.
AS_VAR_SET([gl_next_header],
- ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
+ ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
s#^/[^/]#//&#
Deleted: libprelude/trunk/libmissing/m4/memchr.m4
===================================================================
--- libprelude/trunk/libmissing/m4/memchr.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/memchr.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,18 +0,0 @@
-# memchr.m4 serial 4
-dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_FUNC_MEMCHR],
-[
- AC_REPLACE_FUNCS(memchr)
- if test $ac_cv_func_memchr = no; then
- gl_PREREQ_MEMCHR
- fi
-])
-
-# Prerequisites of lib/memchr.c.
-AC_DEFUN([gl_PREREQ_MEMCHR], [
- AC_CHECK_HEADERS(bp-sym.h)
-])
Deleted: libprelude/trunk/libmissing/m4/memcmp.m4
===================================================================
--- libprelude/trunk/libmissing/m4/memcmp.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/memcmp.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,31 +0,0 @@
-# memcmp.m4 serial 13
-dnl Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_FUNC_MEMCMP],
-[
- if test $cross_compiling != no; then
- # AC_FUNC_MEMCMP as of 2.62 defaults to 'no' when cross compiling.
- # We default to yes if memcmp appears to exist, which works
- # better for MinGW.
- AC_CACHE_CHECK([whether cross-compiling target has memcmp],
- [ac_cv_func_memcmp_working],
- [AC_LINK_IFELSE([
- AC_LANG_PROGRAM([[#include <string.h>
- ]], [[int ret = memcmp ("foo", "bar", 0);]])],
- [ac_cv_func_memcmp_working=yes],
- [ac_cv_func_memcmp_working=no])])
- fi
- AC_FUNC_MEMCMP
- dnl Note: AC_FUNC_MEMCMP does AC_LIBOBJ(memcmp).
- if test $ac_cv_func_memcmp_working = no; then
- AC_DEFINE(memcmp, rpl_memcmp,
- [Define to rpl_memcmp if the replacement function should be used.])
- gl_PREREQ_MEMCMP
- fi
-])
-
-# Prerequisites of lib/memcmp.c.
-AC_DEFUN([gl_PREREQ_MEMCMP], [:])
Modified: libprelude/trunk/libmissing/m4/netdb_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/netdb_h.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/netdb_h.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,4 +1,4 @@
-# netdb_h.m4 serial 2
+# netdb_h.m4 serial 3
dnl Copyright (C) 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,8 @@
AC_REQUIRE([gl_NETDB_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([netdb.h])
if test $ac_cv_header_netdb_h = yes; then
- NETDB_H=''
+ AC_CHECK_TYPES([struct addrinfo], [NETDB_H=''], [NETDB_H='netdb.h'],
+ [[#include <netdb.h>]])
HAVE_NETDB_H=1
else
NETDB_H='netdb.h'
Modified: libprelude/trunk/libmissing/m4/stdlib_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/stdlib_h.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/stdlib_h.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 10
+# stdlib_h.m4 serial 13
dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,9 @@
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([stdlib.h])
+ AC_CHECK_TYPES([struct random_data],
+ [], [HAVE_STRUCT_RANDOM_DATA=0],
+ [[#include <stdlib.h>]])
])
AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
@@ -28,6 +31,7 @@
GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
+ GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
@@ -35,22 +39,24 @@
GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
dnl Assume proper GNU behavior unless another module says otherwise.
- HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
- HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX])
- HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
- HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX])
- HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
- HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX])
- HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
- HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
- HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
- HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
- HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
- HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
- HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV])
- HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
- REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
- REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
- REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
- VOID_UNSETENV=0; AC_SUBST([VOID_UNSETENV])
+ HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
+ HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX])
+ HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
+ HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX])
+ HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
+ HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX])
+ HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
+ HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
+ HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
+ HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
+ HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
+ HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
+ HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
+ HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
+ HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV])
+ HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
+ REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
+ REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
+ REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
+ VOID_UNSETENV=0; AC_SUBST([VOID_UNSETENV])
])
Deleted: libprelude/trunk/libmissing/m4/strpbrk.m4
===================================================================
--- libprelude/trunk/libmissing/m4/strpbrk.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/strpbrk.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,18 +0,0 @@
-# strpbrk.m4 serial 4
-dnl Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_FUNC_STRPBRK],
-[
- AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- AC_REPLACE_FUNCS(strpbrk)
- if test $ac_cv_func_strpbrk = no; then
- HAVE_STRPBRK=0
- gl_PREREQ_STRPBRK
- fi
-])
-
-# Prerequisites of lib/strpbrk.c.
-AC_DEFUN([gl_PREREQ_STRPBRK], [:])
Modified: libprelude/trunk/libmissing/m4/sys_socket_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/sys_socket_h.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/sys_socket_h.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 11
+# sys_socket_h.m4 serial 12
dnl Copyright (C) 2005-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -71,8 +71,8 @@
# Sets and substitutes HAVE_WINSOCK2_H.
AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
[
- AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
- AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
+ m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])])
+ m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])])
AC_CHECK_HEADERS_ONCE([sys/socket.h])
if test $ac_cv_header_sys_socket_h != yes; then
dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
@@ -96,12 +96,10 @@
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
- gl_MODULE_INDICATOR([$1])
])
AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
[
- AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for GNULIB_CLOSE
GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET])
GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT])
GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT])
Modified: libprelude/trunk/libmissing/m4/unistd_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/unistd_h.m4 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/m4/unistd_h.m4 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 15
+# unistd_h.m4 serial 16
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -43,6 +43,7 @@
GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
+ GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
@@ -59,6 +60,7 @@
HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
HAVE_GETDOMAINNAME=1; AC_SUBST([HAVE_GETDOMAINNAME])
HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
+ HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
HAVE_GETUSERSHELL=1; AC_SUBST([HAVE_GETUSERSHELL])
HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
Deleted: libprelude/trunk/libmissing/memchr.c
===================================================================
--- libprelude/trunk/libmissing/memchr.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/memchr.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,172 +0,0 @@
-/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, 2008
- Free Software Foundation, Inc.
-
- Based on strlen implementation by Torbjorn Granlund ([email protected]),
- with help from Dan Sahlin ([email protected]) and
- commentary by Jim Blandy ([email protected]);
- adaptation to memchr suggested by Dick Karpinski ([email protected]),
- and implemented by Roland McGrath ([email protected]).
-
-NOTE: The canonical source of this file is maintained with the GNU C Library.
-Bugs can be reported to [email protected].
-
-This program 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 3 of the License, or any
-later version.
-
-This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef _LIBC
-# include <config.h>
-#endif
-
-#include <string.h>
-
-#include <stddef.h>
-
-#if defined _LIBC
-# include <memcopy.h>
-#else
-# define reg_char char
-#endif
-
-#include <limits.h>
-
-#if HAVE_BP_SYM_H || defined _LIBC
-# include <bp-sym.h>
-#else
-# define BP_SYM(sym) sym
-#endif
-
-#undef __memchr
-#ifdef _LIBC
-# undef memchr
-#endif
-
-#ifndef weak_alias
-# define __memchr memchr
-#endif
-
-/* Search no more than N bytes of S for C. */
-void *
-__memchr (void const *s, int c_in, size_t n)
-{
- /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
- long instead of a 64-bit uintmax_t tends to give better
- performance. On 64-bit hardware, unsigned long is generally 64
- bits already. Change this typedef to experiment with
- performance. */
- typedef unsigned long int longword;
-
- const unsigned char *char_ptr;
- const longword *longword_ptr;
- longword repeated_one;
- longword repeated_c;
- unsigned reg_char c;
-
- c = (unsigned char) c_in;
-
- /* Handle the first few bytes by reading one byte at a time.
- Do this until CHAR_PTR is aligned on a longword boundary. */
- for (char_ptr = (const unsigned char *) s;
- n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
- --n, ++char_ptr)
- if (*char_ptr == c)
- return (void *) char_ptr;
-
- longword_ptr = (const longword *) char_ptr;
-
- /* All these elucidatory comments refer to 4-byte longwords,
- but the theory applies equally well to any size longwords. */
-
- /* Compute auxiliary longword values:
- repeated_one is a value which has a 1 in every byte.
- repeated_c has c in every byte. */
- repeated_one = 0x01010101;
- repeated_c = c | (c << 8);
- repeated_c |= repeated_c << 16;
- if (0xffffffffU < (longword) -1)
- {
- repeated_one |= repeated_one << 31 << 1;
- repeated_c |= repeated_c << 31 << 1;
- if (8 < sizeof (longword))
- {
- size_t i;
-
- for (i = 64; i < sizeof (longword) * 8; i *= 2)
- {
- repeated_one |= repeated_one << i;
- repeated_c |= repeated_c << i;
- }
- }
- }
-
- /* Instead of the traditional loop which tests each byte, we will test a
- longword at a time. The tricky part is testing if *any of the four*
- bytes in the longword in question are equal to c. We first use an xor
- with repeated_c. This reduces the task to testing whether *any of the
- four* bytes in longword1 is zero.
-
- We compute tmp =
- ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
- That is, we perform the following operations:
- 1. Subtract repeated_one.
- 2. & ~longword1.
- 3. & a mask consisting of 0x80 in every byte.
- Consider what happens in each byte:
- - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
- and step 3 transforms it into 0x80. A carry can also be propagated
- to more significant bytes.
- - If a byte of longword1 is nonzero, let its lowest 1 bit be at
- position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
- the byte ends in a single bit of value 0 and k bits of value 1.
- After step 2, the result is just k bits of value 1: 2^k - 1. After
- step 3, the result is 0. And no carry is produced.
- So, if longword1 has only non-zero bytes, tmp is zero.
- Whereas if longword1 has a zero byte, call j the position of the least
- significant zero byte. Then the result has a zero at positions 0, ...,
- j-1 and a 0x80 at position j. We cannot predict the result at the more
- significant bytes (positions j+1..3), but it does not matter since we
- already have a non-zero bit at position 8*j+7.
-
- So, the test whether any byte in longword1 is zero is equivalent to
- testing whether tmp is nonzero. */
-
- while (n >= sizeof (longword))
- {
- longword longword1 = *longword_ptr ^ repeated_c;
-
- if ((((longword1 - repeated_one) & ~longword1)
- & (repeated_one << 7)) != 0)
- break;
- longword_ptr++;
- n -= sizeof (longword);
- }
-
- char_ptr = (const unsigned char *) longword_ptr;
-
- /* At this point, we know that either n < sizeof (longword), or one of the
- sizeof (longword) bytes starting at char_ptr is == c. On little-endian
- machines, we could determine the first such byte without any further
- memory accesses, just by looking at the tmp result from the last loop
- iteration. But this does not work on big-endian machines. Choose code
- that works in both cases. */
-
- for (; n > 0; --n, ++char_ptr)
- {
- if (*char_ptr == c)
- return (void *) char_ptr;
- }
-
- return NULL;
-}
-#ifdef weak_alias
-weak_alias (__memchr, BP_SYM (memchr))
-#endif
Deleted: libprelude/trunk/libmissing/memcmp.c
===================================================================
--- libprelude/trunk/libmissing/memcmp.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/memcmp.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,361 +0,0 @@
-/* Copyright (C) 1991, 1993, 1995, 1997, 1998, 2003, 2006 Free Software
- Foundation, Inc.
-
- Contributed by Torbjorn Granlund ([email protected]).
-
- NOTE: The canonical source of this file is maintained with the GNU C Library.
- Bugs can be reported to [email protected].
-
- This program 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 3 of the License, or any
- later version.
-
- This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef _LIBC
-# include <config.h>
-#endif
-
-#include <string.h>
-
-#undef memcmp
-
-#ifdef _LIBC
-
-# include <memcopy.h>
-# include <endian.h>
-
-# if __BYTE_ORDER == __BIG_ENDIAN
-# define WORDS_BIGENDIAN
-# endif
-
-#else /* Not in the GNU C library. */
-
-# include <sys/types.h>
-
-/* Type to use for aligned memory operations.
- This should normally be the biggest type supported by a single load
- and store. Must be an unsigned type. */
-# define op_t unsigned long int
-# define OPSIZ (sizeof(op_t))
-
-/* Threshold value for when to enter the unrolled loops. */
-# define OP_T_THRES 16
-
-/* Type to use for unaligned operations. */
-typedef unsigned char byte;
-
-# ifndef WORDS_BIGENDIAN
-# define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
-# else
-# define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
-# endif
-
-#endif /* In the GNU C library. */
-
-#ifdef WORDS_BIGENDIAN
-# define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1)
-#else
-# define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b))
-#endif
-
-/* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */
-
-/* The strategy of this memcmp is:
-
- 1. Compare bytes until one of the block pointers is aligned.
-
- 2. Compare using memcmp_common_alignment or
- memcmp_not_common_alignment, regarding the alignment of the other
- block after the initial byte operations. The maximum number of
- full words (of type op_t) are compared in this way.
-
- 3. Compare the few remaining bytes. */
-
-#ifndef WORDS_BIGENDIAN
-/* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine.
- A and B are known to be different.
- This is needed only on little-endian machines. */
-
-# ifdef __GNUC__
-__inline
-# endif
-static int
-memcmp_bytes (long unsigned int a, long unsigned int b)
-{
- long int srcp1 = (long int) &a;
- long int srcp2 = (long int) &b;
- op_t a0, b0;
-
- do
- {
- a0 = ((byte *) srcp1)[0];
- b0 = ((byte *) srcp2)[0];
- srcp1 += 1;
- srcp2 += 1;
- }
- while (a0 == b0);
- return a0 - b0;
-}
-#endif
-
-/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
- objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
- memory operations on `op_t's. */
-#ifdef __GNUC__
-__inline
-#endif
-static int
-memcmp_common_alignment (long int srcp1, long int srcp2, size_t len)
-{
- op_t a0, a1;
- op_t b0, b1;
-
- switch (len % 4)
- {
- default: /* Avoid warning about uninitialized local variables. */
- case 2:
- a0 = ((op_t *) srcp1)[0];
- b0 = ((op_t *) srcp2)[0];
- srcp1 -= 2 * OPSIZ;
- srcp2 -= 2 * OPSIZ;
- len += 2;
- goto do1;
- case 3:
- a1 = ((op_t *) srcp1)[0];
- b1 = ((op_t *) srcp2)[0];
- srcp1 -= OPSIZ;
- srcp2 -= OPSIZ;
- len += 1;
- goto do2;
- case 0:
- if (OP_T_THRES <= 3 * OPSIZ && len == 0)
- return 0;
- a0 = ((op_t *) srcp1)[0];
- b0 = ((op_t *) srcp2)[0];
- goto do3;
- case 1:
- a1 = ((op_t *) srcp1)[0];
- b1 = ((op_t *) srcp2)[0];
- srcp1 += OPSIZ;
- srcp2 += OPSIZ;
- len -= 1;
- if (OP_T_THRES <= 3 * OPSIZ && len == 0)
- goto do0;
- /* Fall through. */
- }
-
- do
- {
- a0 = ((op_t *) srcp1)[0];
- b0 = ((op_t *) srcp2)[0];
- if (a1 != b1)
- return CMP_LT_OR_GT (a1, b1);
-
- do3:
- a1 = ((op_t *) srcp1)[1];
- b1 = ((op_t *) srcp2)[1];
- if (a0 != b0)
- return CMP_LT_OR_GT (a0, b0);
-
- do2:
- a0 = ((op_t *) srcp1)[2];
- b0 = ((op_t *) srcp2)[2];
- if (a1 != b1)
- return CMP_LT_OR_GT (a1, b1);
-
- do1:
- a1 = ((op_t *) srcp1)[3];
- b1 = ((op_t *) srcp2)[3];
- if (a0 != b0)
- return CMP_LT_OR_GT (a0, b0);
-
- srcp1 += 4 * OPSIZ;
- srcp2 += 4 * OPSIZ;
- len -= 4;
- }
- while (len != 0);
-
- /* This is the right position for do0. Please don't move
- it into the loop. */
- do0:
- if (a1 != b1)
- return CMP_LT_OR_GT (a1, b1);
- return 0;
-}
-
-/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
- `op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
- operations on `op_t', but SRCP1 *should be unaligned*. */
-#ifdef __GNUC__
-__inline
-#endif
-static int
-memcmp_not_common_alignment (long int srcp1, long int srcp2, size_t len)
-{
- op_t a0, a1, a2, a3;
- op_t b0, b1, b2, b3;
- op_t x;
- int shl, shr;
-
- /* Calculate how to shift a word read at the memory operation
- aligned srcp1 to make it aligned for comparison. */
-
- shl = 8 * (srcp1 % OPSIZ);
- shr = 8 * OPSIZ - shl;
-
- /* Make SRCP1 aligned by rounding it down to the beginning of the `op_t'
- it points in the middle of. */
- srcp1 &= -OPSIZ;
-
- switch (len % 4)
- {
- default: /* Avoid warning about uninitialized local variables. */
- case 2:
- a1 = ((op_t *) srcp1)[0];
- a2 = ((op_t *) srcp1)[1];
- b2 = ((op_t *) srcp2)[0];
- srcp1 -= 1 * OPSIZ;
- srcp2 -= 2 * OPSIZ;
- len += 2;
- goto do1;
- case 3:
- a0 = ((op_t *) srcp1)[0];
- a1 = ((op_t *) srcp1)[1];
- b1 = ((op_t *) srcp2)[0];
- srcp2 -= 1 * OPSIZ;
- len += 1;
- goto do2;
- case 0:
- if (OP_T_THRES <= 3 * OPSIZ && len == 0)
- return 0;
- a3 = ((op_t *) srcp1)[0];
- a0 = ((op_t *) srcp1)[1];
- b0 = ((op_t *) srcp2)[0];
- srcp1 += 1 * OPSIZ;
- goto do3;
- case 1:
- a2 = ((op_t *) srcp1)[0];
- a3 = ((op_t *) srcp1)[1];
- b3 = ((op_t *) srcp2)[0];
- srcp1 += 2 * OPSIZ;
- srcp2 += 1 * OPSIZ;
- len -= 1;
- if (OP_T_THRES <= 3 * OPSIZ && len == 0)
- goto do0;
- /* Fall through. */
- }
-
- do
- {
- a0 = ((op_t *) srcp1)[0];
- b0 = ((op_t *) srcp2)[0];
- x = MERGE(a2, shl, a3, shr);
- if (x != b3)
- return CMP_LT_OR_GT (x, b3);
-
- do3:
- a1 = ((op_t *) srcp1)[1];
- b1 = ((op_t *) srcp2)[1];
- x = MERGE(a3, shl, a0, shr);
- if (x != b0)
- return CMP_LT_OR_GT (x, b0);
-
- do2:
- a2 = ((op_t *) srcp1)[2];
- b2 = ((op_t *) srcp2)[2];
- x = MERGE(a0, shl, a1, shr);
- if (x != b1)
- return CMP_LT_OR_GT (x, b1);
-
- do1:
- a3 = ((op_t *) srcp1)[3];
- b3 = ((op_t *) srcp2)[3];
- x = MERGE(a1, shl, a2, shr);
- if (x != b2)
- return CMP_LT_OR_GT (x, b2);
-
- srcp1 += 4 * OPSIZ;
- srcp2 += 4 * OPSIZ;
- len -= 4;
- }
- while (len != 0);
-
- /* This is the right position for do0. Please don't move
- it into the loop. */
- do0:
- x = MERGE(a2, shl, a3, shr);
- if (x != b3)
- return CMP_LT_OR_GT (x, b3);
- return 0;
-}
-
-int
-rpl_memcmp (const void *s1, const void *s2, size_t len)
-{
- op_t a0;
- op_t b0;
- long int srcp1 = (long int) s1;
- long int srcp2 = (long int) s2;
- op_t res;
-
- if (len >= OP_T_THRES)
- {
- /* There are at least some bytes to compare. No need to test
- for LEN == 0 in this alignment loop. */
- while (srcp2 % OPSIZ != 0)
- {
- a0 = ((byte *) srcp1)[0];
- b0 = ((byte *) srcp2)[0];
- srcp1 += 1;
- srcp2 += 1;
- res = a0 - b0;
- if (res != 0)
- return res;
- len -= 1;
- }
-
- /* SRCP2 is now aligned for memory operations on `op_t'.
- SRCP1 alignment determines if we can do a simple,
- aligned compare or need to shuffle bits. */
-
- if (srcp1 % OPSIZ == 0)
- res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ);
- else
- res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ);
- if (res != 0)
- return res;
-
- /* Number of bytes remaining in the interval [0..OPSIZ-1]. */
- srcp1 += len & -OPSIZ;
- srcp2 += len & -OPSIZ;
- len %= OPSIZ;
- }
-
- /* There are just a few bytes to compare. Use byte memory operations. */
- while (len != 0)
- {
- a0 = ((byte *) srcp1)[0];
- b0 = ((byte *) srcp2)[0];
- srcp1 += 1;
- srcp2 += 1;
- res = a0 - b0;
- if (res != 0)
- return res;
- len -= 1;
- }
-
- return 0;
-}
-
-#ifdef weak_alias
-# undef bcmp
-weak_alias (memcmp, bcmp)
-#endif
Modified: libprelude/trunk/libmissing/netdb.in.h
===================================================================
--- libprelude/trunk/libmissing/netdb.in.h 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/netdb.in.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -36,7 +36,7 @@
#ifndef _GL_NETDB_H
#define _GL_NETDB_H
-#if @HAVE_NETDB_H@
+#if @HAVE_NETDB_H@ && HAVE_STRUCT_ADDRINFO
/* Declarations for a platform that has <netdb.h>. */
@@ -45,7 +45,8 @@
/* Get netdb.h definitions such as struct hostent for MinGW. */
#include <sys/socket.h>
-/* Declarations for a platform that lacks <netdb.h>. */
+/* Declarations for a platform that lacks <netdb.h>, or where it is
+ incomplete. */
#if @GNULIB_GETADDRINFO@
Deleted: libprelude/trunk/libmissing/raise.c
===================================================================
--- libprelude/trunk/libmissing/raise.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/raise.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,30 +0,0 @@
-/* Provide a non-threads replacement for the POSIX raise function.
-
- Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
-
- This program 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 3 of the License, or
- (at your option) any later version.
-
- This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <signal.h>
-#include <unistd.h>
-
-int
-raise (int sig)
-{
- return kill (getpid (), sig);
-}
Copied: libprelude/trunk/libmissing/setsockopt.c (from rev 11082, libprelude/trunk/libmissing/raise.c)
===================================================================
--- libprelude/trunk/libmissing/setsockopt.c (rev 0)
+++ libprelude/trunk/libmissing/setsockopt.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,40 @@
+/* setsockopt.c --- wrappers for Windows setsockopt function
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef setsockopt
+
+int
+rpl_setsockopt (int fd, int level, int optname, const void *optval, int optlen)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ int r = setsockopt (sock, level, optname, optval, optlen);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+}
Modified: libprelude/trunk/libmissing/signal.in.h
===================================================================
--- libprelude/trunk/libmissing/signal.in.h 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/signal.in.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -178,6 +178,12 @@
#endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */
+/* Some systems don't have SA_NODEFER. */
+#ifndef SA_NODEFER
+# define SA_NODEFER 0
+#endif
+
+
#ifdef __cplusplus
}
#endif
Copied: libprelude/trunk/libmissing/socket.c (from rev 11082, libprelude/trunk/libmissing/raise.c)
===================================================================
--- libprelude/trunk/libmissing/socket.c (rev 0)
+++ libprelude/trunk/libmissing/socket.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,43 @@
+/* socket.c --- wrappers for Windows socket function
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+int
+rpl_socket (int domain, int type, int protocol)
+{
+ /* We have to use WSASocket() to create non-overlapped IO sockets.
+ Overlapped IO sockets cannot be used with read/write. */
+ SOCKET fh = WSASocket (domain, type, protocol, NULL, 0, 0);
+
+ if (fh == INVALID_SOCKET)
+ {
+ set_winsock_errno ();
+ return -1;
+ }
+ else
+ return SOCKET_TO_FD (fh);
+}
Modified: libprelude/trunk/libmissing/stdlib.in.h
===================================================================
--- libprelude/trunk/libmissing/stdlib.in.h 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/stdlib.in.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -41,6 +41,23 @@
# include <sys/loadavg.h>
#endif
+#if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@
+# include <stdint.h>
+#endif
+
+#if !@HAVE_STRUCT_RANDOM_DATA@
+struct random_data
+{
+ int32_t *fptr; /* Front pointer. */
+ int32_t *rptr; /* Rear pointer. */
+ int32_t *state; /* Array of state values. */
+ int rand_type; /* Type of random number generator. */
+ int rand_deg; /* Degree of random number generator. */
+ int rand_sep; /* Distance between front and rear. */
+ int32_t *end_ptr; /* Pointer behind state table. */
+};
+#endif
+
/* The definition of GL_LINK_WARNING is copied here. */
@@ -217,6 +234,43 @@
#endif
+#if @GNULIB_RANDOM_R@
+# if !@HAVE_RANDOM_R@
+
+# ifndef RAND_MAX
+# define RAND_MAX 2147483647
+# endif
+
+int srandom_r (unsigned int seed, struct random_data *rand_state);
+int initstate_r (unsigned int seed, char *buf, size_t buf_size,
+ struct random_data *rand_state);
+int setstate_r (char *arg_state, struct random_data *rand_state);
+int random_r (struct random_data *buf, int32_t *result);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef random_r
+# define random_r(b,r) \
+ (GL_LINK_WARNING ("random_r is unportable - " \
+ "use gnulib module random_r for portability"), \
+ random_r (b,r))
+# undef initstate_r
+# define initstate_r(s,b,sz,r) \
+ (GL_LINK_WARNING ("initstate_r is unportable - " \
+ "use gnulib module random_r for portability"), \
+ initstate_r (s,b,sz,r))
+# undef srandom_r
+# define srandom_r(s,r) \
+ (GL_LINK_WARNING ("srandom_r is unportable - " \
+ "use gnulib module random_r for portability"), \
+ srandom_r (s,r))
+# undef setstate_r
+# define setstate_r(a,r) \
+ (GL_LINK_WARNING ("setstate_r is unportable - " \
+ "use gnulib module random_r for portability"), \
+ setstate_r (a,r))
+#endif
+
+
#if @GNULIB_RPMATCH@
# if !@HAVE_RPMATCH@
/* Test a user response to a question.
Deleted: libprelude/trunk/libmissing/strpbrk.c
===================================================================
--- libprelude/trunk/libmissing/strpbrk.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/strpbrk.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,42 +0,0 @@
-/* Copyright (C) 1991, 1994, 2000, 2002-2003, 2006 Free Software
- Foundation, Inc.
-
- NOTE: The canonical source of this file is maintained with the GNU C Library.
- Bugs can be reported to [email protected].
-
- This program 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, or (at your option) any
- later version.
-
- This program 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 this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include <config.h>
-
-#include <stddef.h>
-#include <string.h>
-
-#undef strpbrk
-
-/* Find the first occurrence in S of any character in ACCEPT. */
-char *
-strpbrk (const char *s, const char *accept)
-{
- while (*s != '\0')
- {
- const char *a = accept;
- while (*a != '\0')
- if (*a++ == *s)
- return (char *) s;
- ++s;
- }
-
- return NULL;
-}
Modified: libprelude/trunk/libmissing/sys_socket.in.h
===================================================================
--- libprelude/trunk/libmissing/sys_socket.in.h 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/sys_socket.in.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -120,9 +120,9 @@
/* Re-define FD_ISSET to avoid a WSA call while we are not using
network sockets. */
static inline int
-rpl_fd_isset (int fd, fd_set * set)
+rpl_fd_isset (SOCKET fd, fd_set * set)
{
- int i;
+ u_int i;
if (set == NULL)
return 0;
@@ -145,6 +145,11 @@
# define close close_used_without_including_unistd_h
# endif
+# if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
+# undef gethostname
+# define gethostname gethostname_used_without_including_unistd_h
+# endif
+
# if @GNULIB_SOCKET@
# if @HAVE_WINSOCK2_H@
# undef socket
@@ -388,12 +393,6 @@
# define select select_used_without_including_sys_select_h
# endif
-# if @GNULIB_CLOSE@ && @HAVE_WINSOCK2_H@
-/* gnulib internal function. */
-# define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
-extern int _gl_close_fd_maybe_socket (int fd);
-# endif
-
# ifdef __cplusplus
}
# endif
Modified: libprelude/trunk/libmissing/sys_stat.in.h
===================================================================
--- libprelude/trunk/libmissing/sys_stat.in.h 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/sys_stat.in.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -275,15 +275,22 @@
# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
#endif
+#if @GNULIB_LSTAT@
+# if ! @HAVE_LSTAT@
/* mingw does not support symlinks, therefore it does not have lstat. But
without links, stat does just fine. */
-#if ! @HAVE_LSTAT@
-# define lstat stat
-#endif
-#if @GNULIB_LSTAT@ && @REPLACE_LSTAT@
+# define lstat stat
+# elif @REPLACE_LSTAT@
+# undef lstat
+# define lstat rpl_lstat
+extern int rpl_lstat (const char *name, struct stat *buf);
+# endif
+#elif defined GNULIB_POSIXCHECK
# undef lstat
-# define lstat rpl_lstat
-extern int rpl_lstat (const char *name, struct stat *buf);
+# define lstat(p,b) \
+ (GL_LINK_WARNING ("lstat is unportable - " \
+ "use gnulib module lstat for portability"), \
+ lstat (p, b))
#endif
Modified: libprelude/trunk/libmissing/tests/Makefile.am
===================================================================
--- libprelude/trunk/libmissing/tests/Makefile.am 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/tests/Makefile.am 2008-11-12 09:36:48 UTC (rev 11085)
@@ -45,9 +45,9 @@
## begin gnulib module accept
-EXTRA_DIST += winsock.c
+EXTRA_DIST += accept.c w32sock.h
-EXTRA_libtests_a_SOURCES += winsock.c
+EXTRA_libtests_a_SOURCES += accept.c
## end gnulib module accept
@@ -72,9 +72,9 @@
## begin gnulib module bind
-EXTRA_DIST += winsock.c
+EXTRA_DIST += bind.c w32sock.h
-EXTRA_libtests_a_SOURCES += winsock.c
+EXTRA_libtests_a_SOURCES += bind.c
## end gnulib module bind
@@ -178,12 +178,21 @@
## end gnulib module gettimeofday-tests
+## begin gnulib module ioctl
+
+
+EXTRA_DIST += ioctl.c w32sock.h
+
+EXTRA_libtests_a_SOURCES += ioctl.c
+
+## end gnulib module ioctl
+
## begin gnulib module listen
-EXTRA_DIST += winsock.c
+EXTRA_DIST += listen.c w32sock.h
-EXTRA_libtests_a_SOURCES += winsock.c
+EXTRA_libtests_a_SOURCES += listen.c
## end gnulib module listen
@@ -205,22 +214,6 @@
## end gnulib module lseek-tests
-## begin gnulib module memchr-tests
-
-TESTS += test-memchr
-check_PROGRAMS += test-memchr
-EXTRA_DIST += test-memchr.c
-
-## end gnulib module memchr-tests
-
-## begin gnulib module memcmp-tests
-
-TESTS += test-memcmp
-check_PROGRAMS += test-memcmp
-EXTRA_DIST += test-memcmp.c
-
-## end gnulib module memcmp-tests
-
## begin gnulib module memmem-tests
TESTS += test-memmem
@@ -380,6 +373,33 @@
## end gnulib module strings-tests
+## begin gnulib module sys_ioctl
+
+BUILT_SOURCES += $(SYS_IOCTL_H)
+
+# We need the following in order to create <sys/ioctl.h> when the system
+# does not have a complete one.
+sys/ioctl.h: sys_ioctl.in.h
+ @MKDIR_P@ sys
+ rm -f $@-t $@
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''HAVE_SYS_IOCTL_H''@|$(HAVE_SYS_IOCTL_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \
+ -e 's|@''GNULIB_IOCTL''@|$(GNULIB_IOCTL)|g' \
+ -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \
+ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ < $(srcdir)/sys_ioctl.in.h; \
+ } > $@-t
+ mv $@-t $@
+MOSTLYCLEANFILES += sys/ioctl.h sys/ioctl.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_ioctl.in.h
+
+## end gnulib module sys_ioctl
+
## begin gnulib module sys_select-tests
TESTS += test-sys_select
Copied: libprelude/trunk/libmissing/tests/accept.c (from rev 11082, libprelude/trunk/libmissing/tests/close.c)
===================================================================
--- libprelude/trunk/libmissing/tests/accept.c (rev 0)
+++ libprelude/trunk/libmissing/tests/accept.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,42 @@
+/* accept.c --- wrappers for Windows accept function
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef accept
+
+int
+rpl_accept (int fd, struct sockaddr *addr, int *addrlen)
+{
+ SOCKET fh = accept (FD_TO_SOCKET (fd), addr, addrlen);
+ if (fh == INVALID_SOCKET)
+ {
+ set_winsock_errno ();
+ return -1;
+ }
+ else
+ return SOCKET_TO_FD (fh);
+}
Copied: libprelude/trunk/libmissing/tests/bind.c (from rev 11082, libprelude/trunk/libmissing/tests/close.c)
===================================================================
--- libprelude/trunk/libmissing/tests/bind.c (rev 0)
+++ libprelude/trunk/libmissing/tests/bind.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,40 @@
+/* bind.c --- wrappers for Windows bind function
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef bind
+
+int
+rpl_bind (int fd, struct sockaddr *sockaddr, int len)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ int r = bind (sock, sockaddr, len);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+}
Modified: libprelude/trunk/libmissing/tests/close.c
===================================================================
--- libprelude/trunk/libmissing/tests/close.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/tests/close.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -20,10 +20,47 @@
#include <unistd.h>
#if GNULIB_SYS_SOCKET
+# define WIN32_LEAN_AND_MEAN
# include <sys/socket.h>
#endif
+#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+static int
+_gl_close_fd_maybe_socket (int fd)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ WSANETWORKEVENTS ev;
+
+ ev.lNetworkEvents = 0xDEADBEEF;
+ WSAEnumNetworkEvents (sock, NULL, &ev);
+ if (ev.lNetworkEvents != 0xDEADBEEF)
+ {
+ /* FIXME: other applications, like squid, use an undocumented
+ _free_osfhnd free function. But this is not enough: The 'osfile'
+ flags for fd also needs to be cleared, but it is hard to access it.
+ Instead, here we just close twice the file descriptor. */
+ if (closesocket (sock))
+ {
+ set_winsock_errno ();
+ return -1;
+ }
+ else
+ {
+ /* This call frees the file descriptor and does a
+ CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
+ _close (fd);
+ return 0;
+ }
+ }
+ else
+ return _close (fd);
+}
+#endif
+
/* Override close() to call into other gnulib modules. */
int
Copied: libprelude/trunk/libmissing/tests/ioctl.c (from rev 11082, libprelude/trunk/libmissing/tests/close.c)
===================================================================
--- libprelude/trunk/libmissing/tests/ioctl.c (rev 0)
+++ libprelude/trunk/libmissing/tests/ioctl.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,49 @@
+/* ioctl.c --- wrappers for Windows ioctl function
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <config.h>
+
+#include <stdarg.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+int
+rpl_ioctl (int fd, int req, ...)
+{
+ void *buf;
+ va_list args;
+ SOCKET sock;
+ int r;
+
+ va_start (args, req);
+ buf = va_arg (args, void *);
+ va_end (args);
+
+ sock = FD_TO_SOCKET (fd);
+ r = ioctlsocket (sock, req, buf);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+}
Copied: libprelude/trunk/libmissing/tests/listen.c (from rev 11082, libprelude/trunk/libmissing/tests/close.c)
===================================================================
--- libprelude/trunk/libmissing/tests/listen.c (rev 0)
+++ libprelude/trunk/libmissing/tests/listen.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,40 @@
+/* listen.c --- wrappers for Windows listen function
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef listen
+
+int
+rpl_listen (int fd, int backlog)
+{
+ SOCKET sock = FD_TO_SOCKET (fd);
+ int r = listen (sock, backlog);
+ if (r < 0)
+ set_winsock_errno ();
+
+ return r;
+}
Added: libprelude/trunk/libmissing/tests/sys_ioctl.in.h
===================================================================
--- libprelude/trunk/libmissing/tests/sys_ioctl.in.h (rev 0)
+++ libprelude/trunk/libmissing/tests/sys_ioctl.in.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,70 @@
+/* Substitute for and wrapper around <sys/ioctl.h>.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _GL_SYS_IOCTL_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_SYS_IOCTL_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_IOCTL_H@
+#endif
+
+#ifndef _GL_SYS_IOCTL_H
+#define _GL_SYS_IOCTL_H
+
+/* AIX 5.1 and Solaris 10 declare ioctl() in <unistd.h> and in <stropts.h>,
+ but not in <sys/ioctl.h>. */
+#include <unistd.h>
+
+/* The definition of GL_LINK_WARNING is copied here. */
+
+
+/* Declare overridden functions. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if @GNULIB_IOCTL@
+# if @SYS_IOCTL_H_HAVE_WINSOCK2_H@
+# undef ioctl
+# define ioctl rpl_ioctl
+extern int ioctl (int fd, int request, ... /* {void *,char *} arg */);
+# endif
+#elif @SYS_IOCTL_H_HAVE_WINSOCK2_H@
+# undef ioctl
+# define ioctl ioctl_used_without_requesting_gnulib_module_ioctl
+#elif defined GNULIB_POSIXCHECK
+# undef ioctl
+# define ioctl(f,c,a) \
+ (GL_LINK_WARNING ("ioctl does not portably work on sockets - " \
+ "use gnulib module ioctl for portability"), \
+ ioctl (f, c, a))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _GL_SYS_IOCTL_H */
+#endif /* _GL_SYS_IOCTL_H */
Deleted: libprelude/trunk/libmissing/tests/test-memchr.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-memchr.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/tests/test-memchr.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2008 Free Software Foundation
- * Written by Eric Blake and Bruno Haible
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
-
-/* Calculating void * + int is not portable, so this wrapper converts
- to char * to make the tests easier to write. */
-#define MEMCHR (char *) memchr
-
-int
-main ()
-{
- void *nil = NULL; /* Use to avoid gcc attribute((nonnull)) warnings. */
-
- size_t n = 0x100000;
- char *input = malloc (n);
- ASSERT (input);
-
- input[0] = 'a';
- input[1] = 'b';
- memset (input + 2, 'c', 1024);
- memset (input + 1026, 'd', n - 1028);
- input[n - 2] = 'e';
- input[n - 1] = 'a';
-
- /* Basic behavior tests. */
- ASSERT (MEMCHR (input, 'a', n) == input);
-
- ASSERT (MEMCHR (input, 'a', 0) == NULL);
- ASSERT (MEMCHR (nil, 'a', 0) == NULL);
-
- ASSERT (MEMCHR (input, 'b', n) == input + 1);
- ASSERT (MEMCHR (input, 'c', n) == input + 2);
- ASSERT (MEMCHR (input, 'd', n) == input + 1026);
-
- ASSERT (MEMCHR (input + 1, 'a', n - 1) == input + n - 1);
- ASSERT (MEMCHR (input + 1, 'e', n - 1) == input + n - 2);
-
- ASSERT (MEMCHR (input, 'f', n) == NULL);
- ASSERT (MEMCHR (input, '\0', n) == NULL);
-
- /* Check that a very long haystack is handled quickly if the byte is
- found near the beginning. */
- {
- size_t repeat = 10000;
- for (; repeat > 0; repeat--)
- {
- ASSERT (MEMCHR (input, 'c', n) == input + 2);
- }
- }
-
- /* Alignment tests. */
- {
- int i, j;
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 256; j++)
- input[i + j] = j;
- for (j = 0; j < 256; j++)
- {
- ASSERT (MEMCHR (input + i, j, 256) == input + i + j);
- }
- }
- }
-
- free (input);
-
- return 0;
-}
Deleted: libprelude/trunk/libmissing/tests/test-memcmp.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-memcmp.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/tests/test-memcmp.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2008 Free Software Foundation
- * Written by Simon Josefsson
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
-
-int
-main (void)
-{
- void *nil = NULL; /* Use to avoid gcc attribute((nonnull)) warnings. */
-
- /* Test equal / not equal distinction. */
- ASSERT (memcmp (nil, nil, 0) == 0);
- ASSERT (memcmp ("foo", "foobar", 2) == 0);
- ASSERT (memcmp ("foo", "foobar", 3) == 0);
- ASSERT (memcmp ("foo", "foobar", 4) != 0);
- ASSERT (memcmp ("foo", "bar", 1) != 0);
- ASSERT (memcmp ("foo", "bar", 3) != 0);
-
- /* Test less / equal / greater distinction. */
- ASSERT (memcmp ("foo", "moo", 4) < 0);
- ASSERT (memcmp ("moo", "foo", 4) > 0);
- ASSERT (memcmp ("oomph", "oops", 3) < 0);
- ASSERT (memcmp ("oops", "oomph", 3) > 0);
- ASSERT (memcmp ("foo", "foobar", 4) < 0);
- ASSERT (memcmp ("foobar", "foo", 4) > 0);
-
- /* Some old versions of memcmp were not 8-bit clean. */
- ASSERT (memcmp ("\100", "\201", 1) < 0);
- ASSERT (memcmp ("\201", "\100", 1) > 0);
- ASSERT (memcmp ("\200", "\201", 1) < 0);
- ASSERT (memcmp ("\201", "\200", 1) > 0);
-
- /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
- or more and with at least one buffer not starting on a 4-byte boundary.
- William Lewis provided this test program. */
- {
- char foo[21];
- char bar[21];
- int i;
- for (i = 0; i < 4; i++)
- {
- char *a = foo + i;
- char *b = bar + i;
- strcpy (a, "--------01111111");
- strcpy (b, "--------10000000");
- ASSERT (memcmp (a, b, 16) < 0);
- }
- }
-
- return 0;
-}
Added: libprelude/trunk/libmissing/tests/w32sock.h
===================================================================
--- libprelude/trunk/libmissing/tests/w32sock.h (rev 0)
+++ libprelude/trunk/libmissing/tests/w32sock.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,62 @@
+/* w32sock.h --- internal auxilliary functions for Windows socket functions
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <errno.h>
+
+/* Get O_RDWR and O_BINARY. */
+#include <fcntl.h>
+
+/* Get _get_osfhandle() and _open_osfhandle(). */
+#include <io.h>
+
+#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
+#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
+
+static inline void
+set_winsock_errno (void)
+{
+ int err = WSAGetLastError ();
+ WSASetLastError (0);
+
+ /* Map some WSAE* errors to the runtime library's error codes. */
+ switch (err)
+ {
+ case WSA_INVALID_HANDLE:
+ errno = EBADF;
+ break;
+ case WSA_NOT_ENOUGH_MEMORY:
+ errno = ENOMEM;
+ break;
+ case WSA_INVALID_PARAMETER:
+ errno = EINVAL;
+ break;
+ case WSAEWOULDBLOCK:
+ errno = EWOULDBLOCK;
+ break;
+ case WSAENAMETOOLONG:
+ errno = ENAMETOOLONG;
+ break;
+ case WSAENOTEMPTY:
+ errno = ENOTEMPTY;
+ break;
+ default:
+ errno = (err > 10000 && err < 10025) ? err - 10000 : err;
+ break;
+ }
+}
Deleted: libprelude/trunk/libmissing/tests/winsock.c
===================================================================
--- libprelude/trunk/libmissing/tests/winsock.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/tests/winsock.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,348 +0,0 @@
-/* winsock.c --- wrappers for Windows socket functions
-
- Copyright (C) 2008 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Paolo Bonzini */
-
-#include <config.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <io.h>
-#include <sys/socket.h>
-#if GNULIB_IOCTL
-#include <sys/ioctl.h>
-#endif
-
-#undef socket
-#undef connect
-#undef accept
-#undef bind
-#undef getpeername
-#undef getsockname
-#undef getsockopt
-#undef listen
-#undef recv
-#undef send
-#undef recvfrom
-#undef sendto
-#undef setsockopt
-#undef shutdown
-
-#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
-#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
-
-
-static inline void
-set_winsock_errno (void)
-{
- int err = WSAGetLastError ();
- WSASetLastError (0);
-
- /* Map some WSAE* errors to the runtime library's error codes. */
- switch (err)
- {
- case WSA_INVALID_HANDLE:
- errno = EBADF;
- break;
- case WSA_NOT_ENOUGH_MEMORY:
- errno = ENOMEM;
- break;
- case WSA_INVALID_PARAMETER:
- errno = EINVAL;
- break;
- case WSAEWOULDBLOCK:
- errno = EWOULDBLOCK;
- break;
- case WSAENAMETOOLONG:
- errno = ENAMETOOLONG;
- break;
- case WSAENOTEMPTY:
- errno = ENOTEMPTY;
- break;
- default:
- errno = (err > 10000 && err < 10025) ? err - 10000 : err;
- break;
- }
-}
-
-
-/* Hook for gnulib module close. */
-
-#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
-int
-_gl_close_fd_maybe_socket (int fd)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- WSANETWORKEVENTS ev;
-
- ev.lNetworkEvents = 0xDEADBEEF;
- WSAEnumNetworkEvents (sock, NULL, &ev);
- if (ev.lNetworkEvents != 0xDEADBEEF)
- {
- /* FIXME: other applications, like squid, use an undocumented
- _free_osfhnd free function. But this is not enough: The 'osfile'
- flags for fd also needs to be cleared, but it is hard to access it.
- Instead, here we just close twice the file descriptor. */
- if (closesocket (sock))
- {
- set_winsock_errno ();
- return -1;
- }
- else
- {
- /* This call frees the file descriptor and does a
- CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
- _close (fd);
- return 0;
- }
- }
- else
- return _close (fd);
-}
-#endif
-
-
-/* Wrappers for WinSock functions. */
-
-#if GNULIB_SOCKET
-int
-rpl_socket (int domain, int type, int protocol)
-{
- /* We have to use WSASocket() to create non-overlapped IO sockets.
- Overlapped IO sockets cannot be used with read/write. */
- SOCKET fh = WSASocket (domain, type, protocol, NULL, 0, 0);
-
- if (fh == INVALID_SOCKET)
- {
- set_winsock_errno ();
- return -1;
- }
- else
- return SOCKET_TO_FD (fh);
-}
-#endif
-
-#if GNULIB_CONNECT
-int
-rpl_connect (int fd, struct sockaddr *sockaddr, int len)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = connect (sock, sockaddr, len);
- if (r < 0)
- {
- /* EINPROGRESS is not returned by WinSock 2.0; for backwards
- compatibility, connect(2) uses EWOULDBLOCK. */
- if (WSAGetLastError () == WSAEWOULDBLOCK)
- WSASetLastError (WSAEINPROGRESS);
-
- set_winsock_errno ();
- }
-
- return r;
-}
-#endif
-
-#if GNULIB_ACCEPT
-int
-rpl_accept (int fd, struct sockaddr *addr, int *addrlen)
-{
- SOCKET fh = accept (FD_TO_SOCKET (fd), addr, addrlen);
- if (fh == INVALID_SOCKET)
- {
- set_winsock_errno ();
- return -1;
- }
- else
- return SOCKET_TO_FD (fh);
-}
-#endif
-
-#if GNULIB_BIND
-int
-rpl_bind (int fd, struct sockaddr *sockaddr, int len)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = bind (sock, sockaddr, len);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_GETPEERNAME
-int
-rpl_getpeername (int fd, struct sockaddr *addr, int *addrlen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = getpeername (sock, addr, addrlen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_GETSOCKNAME
-int
-rpl_getsockname (int fd, struct sockaddr *addr, int *addrlen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = getsockname (sock, addr, addrlen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_GETSOCKOPT
-int
-rpl_getsockopt (int fd, int level, int optname, void *optval, int *optlen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = getsockopt (sock, level, optname, optval, optlen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_LISTEN
-int
-rpl_listen (int fd, int backlog)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = listen (sock, backlog);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_IOCTL
-int
-rpl_ioctl (int fd, int req, ...)
-{
- void *buf;
- va_list args;
- SOCKET sock;
- int r;
-
- va_start (args, req);
- buf = va_arg (args, void *);
- va_end (args);
-
- sock = FD_TO_SOCKET (fd);
- r = ioctlsocket (sock, req, buf);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_RECV
-int
-rpl_recv (int fd, void *buf, int len, int flags)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = recv (sock, buf, len, flags);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_SEND
-int
-rpl_send (int fd, const void *buf, int len, int flags)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = send (sock, buf, len, flags);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_RECVFROM
-int
-rpl_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from,
- int *fromlen)
-{
- int frombufsize = *fromlen;
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = recvfrom (sock, buf, len, flags, from, fromlen);
-
- if (r < 0)
- set_winsock_errno ();
-
- /* Winsock recvfrom() only returns a valid 'from' when the socket is
- connectionless. POSIX gives a valid 'from' for all types of sockets. */
- else if (*fromlen == frombufsize)
- rpl_getpeername (fd, from, fromlen);
-
- return r;
-}
-#endif
-
-#if GNULIB_SENDTO
-int
-rpl_sendto (int fd, const void *buf, int len, int flags,
- struct sockaddr *to, int tolen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = sendto (sock, buf, len, flags, to, tolen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_SETSOCKOPT
-int
-rpl_setsockopt (int fd, int level, int optname, const void *optval, int optlen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = setsockopt (sock, level, optname, optval, optlen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_SHUTDOWN
-int
-rpl_shutdown (int fd, int how)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = shutdown (sock, how);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
Modified: libprelude/trunk/libmissing/unistd.in.h
===================================================================
--- libprelude/trunk/libmissing/unistd.in.h 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/unistd.in.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -42,6 +42,47 @@
# include <sys/types.h>
#endif
+#if @GNULIB_GETHOSTNAME@
+/* Get all possible declarations of gethostname(). */
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+# include <winsock2.h>
+# if !defined _GL_SYS_SOCKET_H
+# undef socket
+# define socket socket_used_without_including_sys_socket_h
+# undef connect
+# define connect connect_used_without_including_sys_socket_h
+# undef accept
+# define accept accept_used_without_including_sys_socket_h
+# undef bind
+# define bind bind_used_without_including_sys_socket_h
+# undef getpeername
+# define getpeername getpeername_used_without_including_sys_socket_h
+# undef getsockname
+# define getsockname getsockname_used_without_including_sys_socket_h
+# undef getsockopt
+# define getsockopt getsockopt_used_without_including_sys_socket_h
+# undef listen
+# define listen listen_used_without_including_sys_socket_h
+# undef recv
+# define recv recv_used_without_including_sys_socket_h
+# undef send
+# define send send_used_without_including_sys_socket_h
+# undef recvfrom
+# define recvfrom recvfrom_used_without_including_sys_socket_h
+# undef sendto
+# define sendto sendto_used_without_including_sys_socket_h
+# undef setsockopt
+# define setsockopt setsockopt_used_without_including_sys_socket_h
+# undef shutdown
+# define shutdown shutdown_used_without_including_sys_socket_h
+# endif
+# if !defined _GL_SYS_SELECT_H
+# undef select
+# define select select_used_without_including_sys_select_h
+# endif
+# endif
+#endif
+
/* The definition of GL_LINK_WARNING is copied here. */
@@ -78,6 +119,10 @@
#if @GNULIB_CLOSE@
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+/* Need a gnulib internal function. */
+# define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
+# endif
# if @REPLACE_CLOSE@
/* Automatically included by modules that need a replacement for close. */
# undef close
@@ -272,6 +317,33 @@
#endif
+#if @GNULIB_GETHOSTNAME@
+/* Return the standard host name of the machine.
+ WARNING! The host name may or may not be fully qualified.
+
+ Put up to LEN bytes of the host name into NAME.
+ Null terminate it if the name is shorter than LEN.
+ If the host name is longer than LEN, set errno = EINVAL and return -1.
+ Return 0 if successful, otherwise set errno and return -1. */
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+# undef gethostname
+# define gethostname rpl_gethostname
+# endif
+# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
+extern int gethostname(char *name, size_t len);
+# endif
+#elif @UNISTD_H_HAVE_WINSOCK2_H@
+# undef gethostname
+# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
+#elif defined GNULIB_POSIXCHECK
+# undef gethostname
+# define gethostname(n,l) \
+ (GL_LINK_WARNING ("gethostname is unportable - " \
+ "use gnulib module gethostname for portability"), \
+ gethostname (n, l))
+#endif
+
+
#if @GNULIB_GETLOGIN_R@
/* Copies the user's login name to NAME.
The array pointed to by NAME has room for SIZE bytes.
Added: libprelude/trunk/libmissing/w32sock.h
===================================================================
--- libprelude/trunk/libmissing/w32sock.h (rev 0)
+++ libprelude/trunk/libmissing/w32sock.h 2008-11-12 09:36:48 UTC (rev 11085)
@@ -0,0 +1,62 @@
+/* w32sock.h --- internal auxilliary functions for Windows socket functions
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paolo Bonzini */
+
+#include <errno.h>
+
+/* Get O_RDWR and O_BINARY. */
+#include <fcntl.h>
+
+/* Get _get_osfhandle() and _open_osfhandle(). */
+#include <io.h>
+
+#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
+#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
+
+static inline void
+set_winsock_errno (void)
+{
+ int err = WSAGetLastError ();
+ WSASetLastError (0);
+
+ /* Map some WSAE* errors to the runtime library's error codes. */
+ switch (err)
+ {
+ case WSA_INVALID_HANDLE:
+ errno = EBADF;
+ break;
+ case WSA_NOT_ENOUGH_MEMORY:
+ errno = ENOMEM;
+ break;
+ case WSA_INVALID_PARAMETER:
+ errno = EINVAL;
+ break;
+ case WSAEWOULDBLOCK:
+ errno = EWOULDBLOCK;
+ break;
+ case WSAENAMETOOLONG:
+ errno = ENAMETOOLONG;
+ break;
+ case WSAENOTEMPTY:
+ errno = ENOTEMPTY;
+ break;
+ default:
+ errno = (err > 10000 && err < 10025) ? err - 10000 : err;
+ break;
+ }
+}
Deleted: libprelude/trunk/libmissing/winsock.c
===================================================================
--- libprelude/trunk/libmissing/winsock.c 2008-11-06 15:25:48 UTC (rev 11084)
+++ libprelude/trunk/libmissing/winsock.c 2008-11-12 09:36:48 UTC (rev 11085)
@@ -1,348 +0,0 @@
-/* winsock.c --- wrappers for Windows socket functions
-
- Copyright (C) 2008 Free Software Foundation, Inc.
-
- This program 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 3 of the License, or
- (at your option) any later version.
-
- This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Paolo Bonzini */
-
-#include <config.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <io.h>
-#include <sys/socket.h>
-#if GNULIB_IOCTL
-#include <sys/ioctl.h>
-#endif
-
-#undef socket
-#undef connect
-#undef accept
-#undef bind
-#undef getpeername
-#undef getsockname
-#undef getsockopt
-#undef listen
-#undef recv
-#undef send
-#undef recvfrom
-#undef sendto
-#undef setsockopt
-#undef shutdown
-
-#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
-#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
-
-
-static inline void
-set_winsock_errno (void)
-{
- int err = WSAGetLastError ();
- WSASetLastError (0);
-
- /* Map some WSAE* errors to the runtime library's error codes. */
- switch (err)
- {
- case WSA_INVALID_HANDLE:
- errno = EBADF;
- break;
- case WSA_NOT_ENOUGH_MEMORY:
- errno = ENOMEM;
- break;
- case WSA_INVALID_PARAMETER:
- errno = EINVAL;
- break;
- case WSAEWOULDBLOCK:
- errno = EWOULDBLOCK;
- break;
- case WSAENAMETOOLONG:
- errno = ENAMETOOLONG;
- break;
- case WSAENOTEMPTY:
- errno = ENOTEMPTY;
- break;
- default:
- errno = (err > 10000 && err < 10025) ? err - 10000 : err;
- break;
- }
-}
-
-
-/* Hook for gnulib module close. */
-
-#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
-int
-_gl_close_fd_maybe_socket (int fd)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- WSANETWORKEVENTS ev;
-
- ev.lNetworkEvents = 0xDEADBEEF;
- WSAEnumNetworkEvents (sock, NULL, &ev);
- if (ev.lNetworkEvents != 0xDEADBEEF)
- {
- /* FIXME: other applications, like squid, use an undocumented
- _free_osfhnd free function. But this is not enough: The 'osfile'
- flags for fd also needs to be cleared, but it is hard to access it.
- Instead, here we just close twice the file descriptor. */
- if (closesocket (sock))
- {
- set_winsock_errno ();
- return -1;
- }
- else
- {
- /* This call frees the file descriptor and does a
- CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
- _close (fd);
- return 0;
- }
- }
- else
- return _close (fd);
-}
-#endif
-
-
-/* Wrappers for WinSock functions. */
-
-#if GNULIB_SOCKET
-int
-rpl_socket (int domain, int type, int protocol)
-{
- /* We have to use WSASocket() to create non-overlapped IO sockets.
- Overlapped IO sockets cannot be used with read/write. */
- SOCKET fh = WSASocket (domain, type, protocol, NULL, 0, 0);
-
- if (fh == INVALID_SOCKET)
- {
- set_winsock_errno ();
- return -1;
- }
- else
- return SOCKET_TO_FD (fh);
-}
-#endif
-
-#if GNULIB_CONNECT
-int
-rpl_connect (int fd, struct sockaddr *sockaddr, int len)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = connect (sock, sockaddr, len);
- if (r < 0)
- {
- /* EINPROGRESS is not returned by WinSock 2.0; for backwards
- compatibility, connect(2) uses EWOULDBLOCK. */
- if (WSAGetLastError () == WSAEWOULDBLOCK)
- WSASetLastError (WSAEINPROGRESS);
-
- set_winsock_errno ();
- }
-
- return r;
-}
-#endif
-
-#if GNULIB_ACCEPT
-int
-rpl_accept (int fd, struct sockaddr *addr, int *addrlen)
-{
- SOCKET fh = accept (FD_TO_SOCKET (fd), addr, addrlen);
- if (fh == INVALID_SOCKET)
- {
- set_winsock_errno ();
- return -1;
- }
- else
- return SOCKET_TO_FD (fh);
-}
-#endif
-
-#if GNULIB_BIND
-int
-rpl_bind (int fd, struct sockaddr *sockaddr, int len)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = bind (sock, sockaddr, len);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_GETPEERNAME
-int
-rpl_getpeername (int fd, struct sockaddr *addr, int *addrlen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = getpeername (sock, addr, addrlen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_GETSOCKNAME
-int
-rpl_getsockname (int fd, struct sockaddr *addr, int *addrlen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = getsockname (sock, addr, addrlen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_GETSOCKOPT
-int
-rpl_getsockopt (int fd, int level, int optname, void *optval, int *optlen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = getsockopt (sock, level, optname, optval, optlen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_LISTEN
-int
-rpl_listen (int fd, int backlog)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = listen (sock, backlog);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_IOCTL
-int
-rpl_ioctl (int fd, int req, ...)
-{
- void *buf;
- va_list args;
- SOCKET sock;
- int r;
-
- va_start (args, req);
- buf = va_arg (args, void *);
- va_end (args);
-
- sock = FD_TO_SOCKET (fd);
- r = ioctlsocket (sock, req, buf);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_RECV
-int
-rpl_recv (int fd, void *buf, int len, int flags)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = recv (sock, buf, len, flags);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_SEND
-int
-rpl_send (int fd, const void *buf, int len, int flags)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = send (sock, buf, len, flags);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_RECVFROM
-int
-rpl_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from,
- int *fromlen)
-{
- int frombufsize = *fromlen;
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = recvfrom (sock, buf, len, flags, from, fromlen);
-
- if (r < 0)
- set_winsock_errno ();
-
- /* Winsock recvfrom() only returns a valid 'from' when the socket is
- connectionless. POSIX gives a valid 'from' for all types of sockets. */
- else if (*fromlen == frombufsize)
- rpl_getpeername (fd, from, fromlen);
-
- return r;
-}
-#endif
-
-#if GNULIB_SENDTO
-int
-rpl_sendto (int fd, const void *buf, int len, int flags,
- struct sockaddr *to, int tolen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = sendto (sock, buf, len, flags, to, tolen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_SETSOCKOPT
-int
-rpl_setsockopt (int fd, int level, int optname, const void *optval, int optlen)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = setsockopt (sock, level, optname, optval, optlen);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
-
-#if GNULIB_SHUTDOWN
-int
-rpl_shutdown (int fd, int how)
-{
- SOCKET sock = FD_TO_SOCKET (fd);
- int r = shutdown (sock, how);
- if (r < 0)
- set_winsock_errno ();
-
- return r;
-}
-#endif
_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.