~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to m4/select.m4

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# select.m4 serial 5
2
 
dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
 
1
# select.m4 serial 7
 
2
dnl Copyright (C) 2009-2012 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
5
5
dnl with or without modifications, as long as this notice is preserved.
46
46
      *yes) ;;
47
47
      *) REPLACE_SELECT=1 ;;
48
48
    esac
49
 
  fi
 
49
 
 
50
    dnl On FreeBSD 8.2, select() doesn't always reject bad fds.
 
51
    AC_CACHE_CHECK([whether select detects invalid fds],
 
52
      [gl_cv_func_select_detects_ebadf],
 
53
      [
 
54
        AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
55
#include <sys/types.h>
 
56
#include <sys/time.h>
 
57
#if HAVE_SYS_SELECT_H
 
58
# include <sys/select.h>
 
59
#endif
 
60
#include <unistd.h>
 
61
#include <errno.h>
 
62
]],[[
 
63
  fd_set set;
 
64
  dup2(0, 16);
 
65
  FD_ZERO(&set);
 
66
  FD_SET(16, &set);
 
67
  close(16);
 
68
  struct timeval timeout;
 
69
  timeout.tv_sec = 0;
 
70
  timeout.tv_usec = 5;
 
71
  return select (17, &set, NULL, NULL, &timeout) != -1 || errno != EBADF;
 
72
]])], [gl_cv_func_select_detects_ebadf=yes],
 
73
      [gl_cv_func_select_detects_ebadf=no],
 
74
          [
 
75
           case "$host_os" in
 
76
                    # Guess yes on glibc systems.
 
77
            *-gnu*) gl_cv_func_select_detects_ebadf="guessing yes" ;;
 
78
                    # If we don't know, assume the worst.
 
79
            *)      gl_cv_func_select_detects_ebadf="guessing no" ;;
 
80
           esac
 
81
          ])
 
82
      ])
 
83
    case $gl_cv_func_select_detects_ebadf in
 
84
      *yes) ;;
 
85
      *) REPLACE_SELECT=1 ;;
 
86
    esac
 
87
  fi
 
88
 
 
89
  dnl Determine the needed libraries.
 
90
  LIB_SELECT="$LIBSOCKET"
 
91
  if test $REPLACE_SELECT = 1; then
 
92
    case "$host_os" in
 
93
      mingw*)
 
94
        dnl On the MSVC platform, the function MsgWaitForMultipleObjects
 
95
        dnl (used in lib/select.c) requires linking with -luser32. On mingw,
 
96
        dnl it is implicit.
 
97
        AC_LINK_IFELSE(
 
98
          [AC_LANG_SOURCE([[
 
99
#define WIN32_LEAN_AND_MEAN
 
100
#include <windows.h>
 
101
int
 
102
main ()
 
103
{
 
104
  MsgWaitForMultipleObjects (0, NULL, 0, 0, 0);
 
105
  return 0;
 
106
}]])],
 
107
          [],
 
108
          [LIB_SELECT="$LIB_SELECT -luser32"])
 
109
        ;;
 
110
    esac
 
111
  fi
 
112
  AC_SUBST([LIB_SELECT])
50
113
])