Fix missing timespec definition for sys/stat.h (BZ #21371)

Submitted by Adhemerval Zanella on April 18, 2017, 8:52 p.m.

Details

Message ID 1492548759-4319-1-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show

Commit Message

Adhemerval Zanella April 18, 2017, 8:52 p.m.
As indicated by the bug report, the 'struct timespec' definition
is not defined for '_XOPEN_SOURCE=700' and '_POSIX_C_SOURCE=200112L'.

It is because current code only includes its definition if __USE_ATFILE
is defined and the define is only set with:

  1. _GNU_SOURCE and/or _ATFILE_SOURCE definition.
  2. _POSIX_C_SOURCE >= 200809L

However, the 'st_*' fields in 'struct stat' are defined if __USE_XOPEN2K8.
This patch uses the same login for 'struct timespec' inclusion.

Tested on x86_64-linux-gnu.

	* io/sys/stat.h: Use __USE_XOPEN2K8 insteaf of __USE_ATFILE for
	struct timespec definition.
---
 io/sys/stat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wainer dos Santos Moschetta April 19, 2017, 2:11 p.m.
On 18-04-2017 17:52, Adhemerval Zanella wrote:
> As indicated by the bug report, the 'struct timespec' definition
> is not defined for '_XOPEN_SOURCE=700' and '_POSIX_C_SOURCE=200112L'.
>
> It is because current code only includes its definition if __USE_ATFILE
> is defined and the define is only set with:
>
>    1. _GNU_SOURCE and/or _ATFILE_SOURCE definition.
>    2. _POSIX_C_SOURCE >= 200809L
>
> However, the 'st_*' fields in 'struct stat' are defined if __USE_XOPEN2K8.
> This patch uses the same login for 'struct timespec' inclusion.

Perhaps s/login/logic. Other than that, LGTM.

>
> Tested on x86_64-linux-gnu.
>
> 	* io/sys/stat.h: Use __USE_XOPEN2K8 insteaf of __USE_ATFILE for
> 	struct timespec definition.
> ---
>   io/sys/stat.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/io/sys/stat.h b/io/sys/stat.h
> index 2ada4a5..ac7ef1f 100644
> --- a/io/sys/stat.h
> +++ b/io/sys/stat.h
> @@ -26,7 +26,7 @@
>   
>   #include <bits/types.h>		/* For __mode_t and __dev_t.  */
>   
> -#ifdef __USE_ATFILE
> +#ifdef __USE_XOPEN2K8
>   # include <bits/types/struct_timespec.h>
>   #endif
>

Patch hide | download patch | download mbox

diff --git a/io/sys/stat.h b/io/sys/stat.h
index 2ada4a5..ac7ef1f 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -26,7 +26,7 @@ 
 
 #include <bits/types.h>		/* For __mode_t and __dev_t.  */
 
-#ifdef __USE_ATFILE
+#ifdef __USE_XOPEN2K8
 # include <bits/types/struct_timespec.h>
 #endif