bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] implement full-blown select(2) for winsock


From: Bruno Haible
Subject: Re: [PATCH] implement full-blown select(2) for winsock
Date: Sat, 4 Oct 2008 18:20:02 +0200
User-agent: KMail/1.5.4

Hi Paolo, Simon,

You discussed on 2008-09-23. As far as I understood, basically, Simon wants
a module 'select' separate from 'sys_select' because
  - it's cleaner,
  - the guy who needs <sys/select.h> just for 'struct timeval' does not
    need the select() function.

Paolo wants sys_select to provide 'select' automatically because
  "without these fixes, winsock is simply just too crippled for the
   casual Unix programmer.  Providing sys/socket.h and sys/select.h
   without anything like these wrappers was just giving a false sense
   of portability."

Here is a proposal that should acknowledge both of your arguments:
Provide separate modules 'select' separate from 'sys_select', like we do
in the rest of gnulib, but if 'sys_select' is used without 'select', then
  #define select select_used_without_requesting_gnulib_module_select
so that the developer gets an explicit error message, rather than falling
into a pitfall.

Is this acceptable to both of you?

Here's the patch for sys_select. I would also apply the same technique to
the sys_socket module. (For example, many programs only use only connect()
but not listen() and bind().)


2008-10-04  Bruno Haible  <address@hidden>

        * lib/sys_select.in.h (select): If GNULIB_SELECT is not set, define it
        to an undefined symbol, for an error message.
        * m4/sys_select_h.m4 (gl_SYS_SELECT_MODULE_INDICATOR): New macro.
        (gl_SYS_SELECT_H_DEFAULTS): New macro.
        (gl_HEADER_SYS_SELECT): Require it. Don't require compilation of
        winsock-select.c here.
        * modules/sys_select (Files): Remove lib/winsock-select.c.
        (Depends-on): Remove alloca.
        (Makefile.am): Substitute GNULIB_SELECT.
        * modules/select: New file.

*** lib/sys_select.in.h.orig    2008-10-04 18:04:40.000000000 +0200
--- lib/sys_select.in.h 2008-10-04 17:59:48.000000000 +0200
***************
*** 49,57 ****
  extern "C" {
  #  endif
  
! #  undef select
! #  define select              rpl_select
  extern int rpl_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
  
  #  ifdef __cplusplus
  }
--- 49,62 ----
  extern "C" {
  #  endif
  
! #  if @GNULIB_SELECT@
! #   undef select
! #   define select rpl_select
  extern int rpl_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
+ #  else
+ #   undef select
+ #   define select select_used_without_requesting_gnulib_module_select
+ #  endif
  
  #  ifdef __cplusplus
  }
*** m4/sys_select_h.m4.orig     2008-10-04 18:04:40.000000000 +0200
--- m4/sys_select_h.m4  2008-10-04 18:02:42.000000000 +0200
***************
*** 1,4 ****
! # sys_select_h.m4 serial 5
  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,
--- 1,4 ----
! # sys_select_h.m4 serial 6
  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,
***************
*** 7,12 ****
--- 7,13 ----
  AC_DEFUN([gl_HEADER_SYS_SELECT],
  [
    AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+   AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
    AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
      [gl_cv_header_sys_select_h_selfcontained],
      [
***************
*** 29,35 ****
      gl_PREREQ_SYS_H_WINSOCK2
    fi
    AC_SUBST([SYS_SELECT_H])
!   if test x$ac_cv_header_winsock2_h = xyes; then
!     AC_LIBOBJ(winsock-select)
!   fi
  ])
--- 30,45 ----
      gl_PREREQ_SYS_H_WINSOCK2
    fi
    AC_SUBST([SYS_SELECT_H])
! ])
! 
! AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
! [
!   dnl Use AC_REQUIRE here, so that the default settings are expanded once 
only.
!   AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
!   
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
! ])
! 
! AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
! [
!   GNULIB_SELECT=0; AC_SUBST([GNULIB_SELECT])
  ])
*** modules/sys_select.orig     2008-10-04 18:04:40.000000000 +0200
--- modules/sys_select  2008-10-04 18:00:15.000000000 +0200
***************
*** 3,13 ****
  
  Files:
  lib/sys_select.in.h
- lib/winsock-select.c
  m4/sys_select_h.m4
  
  Depends-on:
- alloca
  include_next
  sys_socket
  sys_time
--- 3,11 ----
***************
*** 29,34 ****
--- 27,33 ----
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''NEXT_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \
              -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \
+             -e 's|@''GNULIB_SELECT''@|$(GNULIB_SELECT)|g' \
              -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
              < $(srcdir)/sys_select.in.h; \
        } > address@hidden
Changing permissions from . to 100644
*** modules/select.orig 2003-09-23 19:59:22.000000000 +0200
--- modules/select      2008-10-04 18:03:06.000000000 +0200
***************
*** 0 ****
--- 1,27 ----
+ Description:
+ select() function: synchronous I/O multiplexing.
+ 
+ Files:
+ lib/winsock-select.c
+ 
+ Depends-on:
+ alloca
+ sys_select
+ 
+ configure.ac:
+ AC_REQUIRE([gl_HEADER_SYS_SELECT])
+ if test "$ac_cv_header_winsock2_h" = yes; then
+   AC_LIBOBJ([winsock-select])
+ fi
+ gl_SYS_SELECT_MODULE_INDICATOR([select])
+ 
+ Makefile.am:
+ 
+ Include:
+ #include <sys/select.h>
+ 
+ License:
+ LGPLv2+
+ 
+ Maintainer:
+ Simon Josefsson





reply via email to

[Prev in Thread] Current Thread [Next in Thread]