On Tue, 23. May 2006, 00:25:11 -0700, Paul Eggert wrote: > In that case, it may be best for gnulib to generate a substitute > <sys/select.h> file that does the right thing under Microsoft Windows > (or indeed, any platform that lacks <sys/select.h>). That way, gnulib > modules like nanosleep can simply "#include <sys/select.h>" > unconditionally and use 'select'. > > Is that something you could write?
No, but the existing sys_socket module from Simon does almost the same. I adapted it. Martin diff -uNr gnulib/lib/select_.h gnulib-sys_select_h/lib/select_.h --- gnulib/lib/select_.h 1970-01-01 01:00:00.000000000 +0100 +++ gnulib-sys_select_h/lib/select_.h 2006-05-23 21:49:37.000000000 +0200 @@ -0,0 +1,33 @@ +/* Provide a sys/select header file for systems lacking it (read: mingw32). + Copyright (C) 2006 Free Software Foundation, Inc. + Adapted from socket_.h, 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 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 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 _SYS_SELECT_H +#define _SYS_SELECT_H + +/* This file is supposed to be used on platforms that lack + sys/select.h. It is intended to provide definitions and prototypes + needed by an application. + + Currently only mingw32 is supported, which has the header file + winsock2.h that declares select(). */ + +#if HAVE_WINSOCK2_H +# include <winsock2.h> +#endif + +#endif /* _SYS_SELECT_H */ diff -uNr gnulib/m4/sys_select_h.m4 gnulib-sys_select_h/m4/sys_select_h.m4 --- gnulib/m4/sys_select_h.m4 1970-01-01 01:00:00.000000000 +0100 +++ gnulib-sys_select_h/m4/sys_select_h.m4 2006-05-23 21:52:42.000000000 +0200 @@ -0,0 +1,24 @@ +# sys_select_h.m4 serial 1 +dnl Copyright (C) 2006 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. + +dnl Adapted from sys_socket_h.m4, written by Simon Josefsson. + +AC_DEFUN([gl_HEADER_SYS_SELECT], +[ + AC_CHECK_HEADERS_ONCE([sys/select.h]) + if test $ac_cv_header_sys_select_h = yes; then + SYS_SELECT_H='' + else + dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make + dnl the check for this header unconditional; yet cygwin reports + dnl that the header is present but cannot be compiled (since on + dnl cygwin, all socket information should come from the standard header + dnl files). + AC_CHECK_HEADERS([winsock2.h]) + SYS_SELECT_H='sys/select.h' + fi + AC_SUBST(SYS_SELECT_H) +]) diff -uNr gnulib/modules/sys_select gnulib-sys_select_h/modules/sys_select --- gnulib/modules/sys_select 1970-01-01 01:00:00.000000000 +0100 +++ gnulib-sys_select_h/modules/sys_select 2006-05-23 21:46:24.000000000 +0200 @@ -0,0 +1,35 @@ +Description: +A <sys/select.h> for systems lacking it. + +Files: +lib/select_.h +m4/sys_select_h.m4 + +Depends-on: + +configure.ac: +gl_HEADER_SYS_SELECT + +Makefile.am: +BUILT_SOURCES += $(SYS_SELECT_H) +EXTRA_DIST += select_.h + +# We need the following in order to create <sys/select.h> when the system +# doesn't have one that works with the given compiler. +sys/select.h: select_.h + test -d sys || mkdir sys + cp $(srcdir)/select_.h [EMAIL PROTECTED] + mv [EMAIL PROTECTED] $@ +MOSTLYCLEANFILES += sys/select.h sys/select.h-t + +mostlyclean-local: + -rmdir sys 2>/dev/null + +Include: +#include <sys/select.h> + +License: +LGPL + +Maintainer: +?