summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-12-16 09:11:32 -0700
committerEric Blake <ebb9@byu.net>2009-12-16 19:25:34 -0700
commit021c8619190757f535c72ad5cdb1d624e19620d6 (patch)
treed98db31ff71feefea79d98d8f2838893c5bc3b43 /m4
parentda91bb7df9bc25e3349b9f3172bfa9d9962f293e (diff)
downloadgnulib-021c8619190757f535c72ad5cdb1d624e19620d6.tar.gz
fcntl: port portions of fcntl to mingw
Borrow ideas from dup_cloexec and dup3 to implement F_DUPFD and F_DUPFD_CLOEXEC. Support querying the inheritance status via F_GETFD, but for now, no support for changing with F_SETFD. The remaining portions of fcntl fail with EINVAL. * m4/fcntl.m4 (gl_FUNC_FCNTL): Also build fcntl.c on mingw. * lib/fcntl.c (fcntl) <F_DUPFD, F_DUPFD_CLOEXEC, F_GETFD>: Provide replacement for mingw. * modules/fcntl (Description): Update. (Depends-on): Add dup2. * m4/fcntl_h.m4 (gl_FCNTL_H_DEFAULTS): Add witness. * modules/fcntl-h (Makefile.am): Substitute it. * lib/fcntl.in.h (fcntl): Update declaration. (F_DUPFD, F_GETFD): New macros, when needed. * doc/posix-headers/fcntl.texi (fcntl.h): Update documentation. * doc/posix-functions/fcntl.texi (fcntl): Likewise. * tests/test-fcntl.c (check_flags, main): Enhance test for items we now guarantee. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'm4')
-rw-r--r--m4/fcntl.m414
-rw-r--r--m4/fcntl_h.m43
2 files changed, 10 insertions, 7 deletions
diff --git a/m4/fcntl.m4 b/m4/fcntl.m4
index b2a7e6bc21..4fc5f6bfad 100644
--- a/m4/fcntl.m4
+++ b/m4/fcntl.m4
@@ -1,4 +1,4 @@
-# fcntl.m4 serial 2
+# fcntl.m4 serial 3
dnl Copyright (C) 2009 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,9 +7,9 @@ dnl with or without modifications, as long as this notice is preserved.
# For now, this module ensures that fcntl()
# - supports F_DUPFD correctly
# - supports or emulates F_DUPFD_CLOEXEC
+# - supports F_GETFD
# Still to be ported to mingw:
-# - F_GETFD, F_SETFD, F_DUPFD
-# - F_DUPFD_CLOEXEC
+# - F_SETFD
# - F_GETFL, F_SETFL
# - F_GETOWN, F_SETOWN
# - F_GETLK, F_SETLK, F_SETLKW
@@ -21,7 +21,7 @@ AC_DEFUN([gl_FUNC_FCNTL],
AC_REQUIRE([AC_CANONICAL_HOST])
AC_CHECK_FUNCS_ONCE([fcntl])
if test $ac_cv_func_fcntl = no; then
- HAVE_FCNTL=0
+ gl_REPLACE_FCNTL
else
dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
@@ -74,8 +74,10 @@ AC_DEFUN([gl_REPLACE_FCNTL],
[
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
AC_CHECK_FUNCS_ONCE([fcntl])
- if test $ac_cv_func_fcntl = yes; then
+ if test $ac_cv_func_fcntl = no; then
+ HAVE_FCNTL=0
+ else
REPLACE_FCNTL=1
- AC_LIBOBJ([fcntl])
fi
+ AC_LIBOBJ([fcntl])
])
diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4
index 3825adf971..12e435e1a6 100644
--- a/m4/fcntl_h.m4
+++ b/m4/fcntl_h.m4
@@ -1,4 +1,4 @@
-# serial 7
+# serial 8
# Configure fcntl.h.
dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
@@ -101,6 +101,7 @@ AC_DEFUN([gl_FCNTL_H_DEFAULTS],
GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT])
dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL])
HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])