Patchwork [1/6] Fix incorrect check for fdatasync() in configure

login
register
mail settings
Submitter Alexandre Raymond
Date May 27, 2011, 5:22 p.m.
Message ID <1306516951-31105-2-git-send-email-cerbere@gmail.com>
Download mbox | patch
Permalink /patch/97722/
State New
Headers show

Comments

Alexandre Raymond - May 27, 2011, 5:22 p.m.
For some reason, darwin provides a symbol for fdatasync(), but
doesn't officially support it.

The manpage for fdatasync on Linux states the following:

"On POSIX  systems  on  which fdatasync() is available,
_POSIX_SYNCHRONIZED_IO is defined in <unistd.h> to a value greater than 0."

In fact, unistd.h defines this value to "-1", at least on OSX 10.6.7.

Add this check to the configure file.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
---
 configure |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
Andreas Färber - May 29, 2011, 2:50 p.m.
Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:

> For some reason, darwin provides a symbol for fdatasync(), but
> doesn't officially support it.
>
> The manpage for fdatasync on Linux states the following:
>
> "On POSIX  systems  on  which fdatasync() is available,
> _POSIX_SYNCHRONIZED_IO is defined in <unistd.h> to a value greater  
> than 0."

The Open Group Base Specification Issue 7 says this on fdatasync():

"The functionality shall be equivalent to fsync() with the symbol  
_POSIX_SYNCHRONIZED_IO defined, with the exception that all I/O  
operations shall be completed as defined for synchronized I/O data  
integrity completion."

On unistd.h it goes on to say:

"_POSIX_SYNCHRONIZED_IO
[SIO]
The implementation supports the Synchronized Input and Output option.  
If this symbol is defined in <unistd.h>, it shall be defined to be -1,  
0, or 200809L."

The change history has nothing on that define and its value -1, so I'm  
not convinced that this really is The Right Way to check.

> In fact, unistd.h defines this value to "-1", at least on OSX 10.6.7.
>
> Add this check to the configure file.
>
> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>

Andreas

> ---
> configure |    8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index a318d37..b21ef75 100755
> --- a/configure
> +++ b/configure
> @@ -2477,7 +2477,13 @@ fi
> fdatasync=no
> cat > $TMPC << EOF
> #include <unistd.h>
> -int main(void) { return fdatasync(0); }
> +int main(void) {
> +#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
> +return fdatasync(0);
> +#else
> +#abort Not supported
> +#endif
> +}
> EOF
> if compile_prog "" "" ; then
>     fdatasync=yes
> -- 
> 1.7.5
Alexandre Raymond - May 29, 2011, 3:46 p.m.
Hi Andreas,

According to this excerpt from The Open Group Base Specifications
Issue 6 (http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html),
'>0' indeed means that the functionality is implemented and can be
used.
----8<----
The following symbolic constants, if defined in <unistd.h>, shall have
a value of -1, 0, or greater, unless otherwise specified below. If
these are undefined, the fpathconf(), pathconf(), or sysconf()
functions can be used to determine whether the option is provided for
a particular invocation of the application.

If a symbolic constant is defined with the value -1, the option is not
supported. Headers, data types, and function interfaces required only
for the option need not be supplied. An application that attempts to
use anything associated only with the option is considered to be
requiring an extension.

If a symbolic constant is defined with a value greater than zero, the
option shall always be supported when the application is executed. All
headers, data types, and functions shall be present and shall operate
as specified.

If a symbolic constant is defined with the value zero, all headers,
data types, and functions shall be present. The application can check
at runtime to see whether the option is supported by calling
fpathconf(), pathconf(), or sysconf() with the indicated name
parameter.
----8<----

Alexandre

On Sun, May 29, 2011 at 10:50 AM, Andreas Färber <andreas.faerber@web.de> wrote:
> Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:
>
>> For some reason, darwin provides a symbol for fdatasync(), but
>> doesn't officially support it.
>>
>> The manpage for fdatasync on Linux states the following:
>>
>> "On POSIX  systems  on  which fdatasync() is available,
>> _POSIX_SYNCHRONIZED_IO is defined in <unistd.h> to a value greater than
>> 0."
>
> The Open Group Base Specification Issue 7 says this on fdatasync():
>
> "The functionality shall be equivalent to fsync() with the symbol
> _POSIX_SYNCHRONIZED_IO defined, with the exception that all I/O operations
> shall be completed as defined for synchronized I/O data integrity
> completion."
>
> On unistd.h it goes on to say:
>
> "_POSIX_SYNCHRONIZED_IO
> [SIO]
> The implementation supports the Synchronized Input and Output option. If
> this symbol is defined in <unistd.h>, it shall be defined to be -1, 0, or
> 200809L."
>
> The change history has nothing on that define and its value -1, so I'm not
> convinced that this really is The Right Way to check.
>
>> In fact, unistd.h defines this value to "-1", at least on OSX 10.6.7.
>>
>> Add this check to the configure file.
>>
>> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
>
> Andreas
>
>> ---
>> configure |    8 +++++++-
>> 1 files changed, 7 insertions(+), 1 deletions(-)
>>
>> diff --git a/configure b/configure
>> index a318d37..b21ef75 100755
>> --- a/configure
>> +++ b/configure
>> @@ -2477,7 +2477,13 @@ fi
>> fdatasync=no
>> cat > $TMPC << EOF
>> #include <unistd.h>
>> -int main(void) { return fdatasync(0); }
>> +int main(void) {
>> +#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
>> +return fdatasync(0);
>> +#else
>> +#abort Not supported
>> +#endif
>> +}
>> EOF
>> if compile_prog "" "" ; then
>>    fdatasync=yes
>> --
>> 1.7.5
>
>
Andreas Färber - May 29, 2011, 5:05 p.m.
Hi Alexandre,

Am 29.05.2011 um 17:46 schrieb Alexandre Raymond:

> According to this excerpt from The Open Group Base Specifications
> Issue 6 (http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html 
> ),
> '>0' indeed means that the functionality is implemented and can be
> used.
> ----8<----
> The following symbolic constants, if defined in <unistd.h>, shall have
> a value of -1, 0, or greater, unless otherwise specified below. If
> these are undefined, the fpathconf(), pathconf(), or sysconf()
> functions can be used to determine whether the option is provided for
> a particular invocation of the application.
>
> If a symbolic constant is defined with the value -1, the option is not
> supported. Headers, data types, and function interfaces required only
> for the option need not be supplied. An application that attempts to
> use anything associated only with the option is considered to be
> requiring an extension.
>
> If a symbolic constant is defined with a value greater than zero, the
> option shall always be supported when the application is executed. All
> headers, data types, and functions shall be present and shall operate
> as specified.
>
> If a symbolic constant is defined with the value zero, all headers,
> data types, and functions shall be present. The application can check
> at runtime to see whether the option is supported by calling
> fpathconf(), pathconf(), or sysconf() with the indicated name
> parameter.
> ----8<----

Indeed, confirmed in Issue 7, thanks a lot. Could you please provide  
me with an updated commit message saying so? Then I'll apply it.

Andreas

Patch

diff --git a/configure b/configure
index a318d37..b21ef75 100755
--- a/configure
+++ b/configure
@@ -2477,7 +2477,13 @@  fi
 fdatasync=no
 cat > $TMPC << EOF
 #include <unistd.h>
-int main(void) { return fdatasync(0); }
+int main(void) {
+#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
+return fdatasync(0);
+#else
+#abort Not supported
+#endif
+}
 EOF
 if compile_prog "" "" ; then
     fdatasync=yes