libio: Replace __LP64__ with __WORDSIZE

Message ID 20250131150648.2272514-1-tuliom@ascii.art.br (mailing list archive)
State Committed
Commit cdb0800022110bc68a033944f09e501be5bd72d7
Headers
Series libio: Replace __LP64__ with __WORDSIZE |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed

Commit Message

Tulio Magno Quites Machado Filho Jan. 31, 2025, 3:06 p.m. UTC
  From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>

__LP64__ is a GCC extension and shouldn't be used in an installed
header.

Fixes: 596a61cf6b (libio: Start to return errors when flushing fwrite's buffer [BZ #29459], 2025-01-28)
Reported-by: Florian Weimer <fweimer@redhat.com>
---
 libio/bits/types/struct_FILE.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Arjun Shankar Feb. 5, 2025, 12:01 p.m. UTC | #1
Hi Tulio,

> From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
>
> __LP64__ is a GCC extension and shouldn't be used in an installed
> header.
>
> Fixes: 596a61cf6b (libio: Start to return errors when flushing fwrite's buffer [BZ #29459], 2025-01-28)
> Reported-by: Florian Weimer <fweimer@redhat.com>

This looks good to me.

Reviewed-by: Arjun Shankar <arjun@redhat.com>

> ---
>  libio/bits/types/struct_FILE.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libio/bits/types/struct_FILE.h b/libio/bits/types/struct_FILE.h
> index 2012d70681..ac99002ae7 100644
> --- a/libio/bits/types/struct_FILE.h
> +++ b/libio/bits/types/struct_FILE.h
> @@ -32,6 +32,7 @@
>  #endif
>
>  #include <bits/types.h>
> +#include <bits/wordsize.h>

OK. This contains __WORDSIZE.

>
>  struct _IO_FILE;
>  struct _IO_marker;
> @@ -97,11 +98,11 @@ struct _IO_FILE_complete
>    void *_freeres_buf;
>    struct _IO_FILE **_prevchain;
>    int _mode;
> -#ifdef __LP64__
> +#if __WORDSIZE == 64

GCC's note about __LP64__ and _LP64 says:
These macros are defined, with value 1, if (and only if) the
compilation is for a target where long int and pointer both use
64-bits and int uses 32-bit.

The replacement is therefore equivalent, but skips using the
predefined GCC macro.

OK.

>    int _unused3;
>  #endif
>    __uint64_t _total_written;
> -#ifndef __LP64__
> +#if __WORDSIZE == 32

Also OK.

>    int _unused3;
>  #endif
>    /* Make sure we don't get into trouble again.  */
> --
> 2.48.1
>
  
Tulio Magno Quites Machado Filho Feb. 5, 2025, 7:26 p.m. UTC | #2
Arjun Shankar <arjun@redhat.com> writes:

> This looks good to me.
>
> Reviewed-by: Arjun Shankar <arjun@redhat.com>

Pushed as cdb0800022110bc68a033944f09e501be5bd72d7.

Thank you!
  

Patch

diff --git a/libio/bits/types/struct_FILE.h b/libio/bits/types/struct_FILE.h
index 2012d70681..ac99002ae7 100644
--- a/libio/bits/types/struct_FILE.h
+++ b/libio/bits/types/struct_FILE.h
@@ -32,6 +32,7 @@ 
 #endif
 
 #include <bits/types.h>
+#include <bits/wordsize.h>
 
 struct _IO_FILE;
 struct _IO_marker;
@@ -97,11 +98,11 @@  struct _IO_FILE_complete
   void *_freeres_buf;
   struct _IO_FILE **_prevchain;
   int _mode;
-#ifdef __LP64__
+#if __WORDSIZE == 64
   int _unused3;
 #endif
   __uint64_t _total_written;
-#ifndef __LP64__
+#if __WORDSIZE == 32
   int _unused3;
 #endif
   /* Make sure we don't get into trouble again.  */