Mercurial > gnulib
annotate m4/pwrite.m4 @ 17363:5a51fb7777a9
sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin
Problem reported by Marco Atzeri in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>.
* lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]:
Simply delegate to the system <sys/select.h> in this case too.
Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only
if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to
be needed on Solaris either.
* lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]:
Simply delgate to the system <sys/time.h> in this case.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 19 Mar 2013 09:08:47 -0700 |
parents | e542fd46ad6f |
children | 344018b6e5d7 |
rev | line source |
---|---|
16798
c8c585f9c2c7
pwrite: Don't replace on all platforms.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
1 # pwrite.m4 serial 5 |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16798
diff
changeset
|
2 dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. |
13314 | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | |
5 dnl with or without modifications, as long as this notice is preserved. | |
6 | |
7 AC_DEFUN([gl_FUNC_PWRITE], | |
8 [ | |
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) | |
14069
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
13314 | 11 |
12 dnl Persuade glibc <unistd.h> to declare pwrite(). | |
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | |
14 | |
15 AC_CHECK_FUNCS_ONCE([pwrite]) | |
14069
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
16 if test $ac_cv_func_pwrite = yes; then |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
17 dnl On HP-UX 11.11 with _FILE_OFFSET_BITS=64, pwrite() on a file does not |
14086
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
18 dnl fail when an invalid (negative) offset is passed and uses an arbitrary |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
19 dnl offset instead of the argument. |
14069
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
20 AC_CACHE_CHECK([whether pwrite works], |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
21 [gl_cv_func_pwrite_works], |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
22 [ |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
23 dnl Initial guess, used when cross-compiling. |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
24 changequote(,)dnl |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
25 case "$host_os" in |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
26 # Guess no on HP-UX. |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
27 hpux*) gl_cv_func_pwrite_works="guessing no" ;; |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
28 # Guess yes otherwise. |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
29 *) gl_cv_func_pwrite_works="guessing yes" ;; |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
30 esac |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
31 changequote([,])dnl |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
32 gl_save_CPPFLAGS="$CPPFLAGS" |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
33 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64" |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
34 rm -f conftest.out |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
35 AC_RUN_IFELSE( |
14086
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
36 [AC_LANG_PROGRAM([[ |
14069
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
37 #include <sys/types.h> |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
38 #include <unistd.h> |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
39 #include <fcntl.h> |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
40 ]], |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
41 [[ |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
42 { |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
43 /* This test fails on HP-UX 11.00..11.11. */ |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
44 { |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
45 int fd = open ("conftest.out", O_RDWR | O_CREAT | O_TRUNC, 0600); |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
46 if (fd < 0) |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
47 return 1; |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
48 if (pwrite (fd, "b", 1, (off_t) -1) >= 0) |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
49 return 2; |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
50 } |
14086
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
51 /* This test fails on HP-UX 11.00..11.11. */ |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
52 { |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
53 int fd; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
54 char buf[] = "01"; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
55 |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
56 fd = open ("conftest.out", O_WRONLY | O_CREAT | O_TRUNC, 0600); |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
57 if (fd < 0) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
58 return 3; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
59 if (write (fd, buf, 2) < 2) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
60 return 4; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
61 if (close (fd) < 0) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
62 return 5; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
63 |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
64 fd = open ("conftest.out", O_WRONLY, 0600); |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
65 if (fd < 0) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
66 return 6; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
67 if (pwrite (fd, "W", 1, (off_t) 0) != 1) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
68 return 7; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
69 if (close (fd) < 0) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
70 return 8; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
71 |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
72 fd = open ("conftest.out", O_RDONLY); |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
73 if (fd < 0) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
74 return 9; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
75 if (read (fd, buf, 2) < 2) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
76 return 10; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
77 if (close (fd) < 0) |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
78 return 11; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
79 if (buf[0] != 'W') |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
80 return 12; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
81 if (buf[1] != '1') |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
82 return 13; |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
83 } |
b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
84 return 0; |
14069
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
85 }]])], |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
86 [gl_cv_func_pwrite_works=yes], |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
87 [gl_cv_func_pwrite_works=no], |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
88 [:]) |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
89 rm -f conftest.out |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
90 CPPFLAGS="$gl_save_CPPFLAGS" |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
91 ]) |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
92 case "$gl_cv_func_pwrite_works" in |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
93 *yes) ;; |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
94 *) REPLACE_PWRITE=1 ;; |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
95 esac |
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
96 else |
13314 | 97 HAVE_PWRITE=0 |
14069
081ce9a593c4
pwrite: Work around HP-UX 11.11 bug.
Bruno Haible <bruno@clisp.org>
parents:
13314
diff
changeset
|
98 fi |
13314 | 99 ]) |