[amdgcn] Remove dependency on stdint.h in libgcc

Message ID a6fcbe4c-7b21-3d2e-45da-5e608c35bcc9@codesourcery.com
State New
Headers show
Series
  • [amdgcn] Remove dependency on stdint.h in libgcc
Related show

Commit Message

Kwok Cheung Yeung Jan. 10, 2020, 2:21 p.m.
The patch for sub-word atomics support added an include of stdint.h for the 
definition of uintptr_h, but this can result in GCC compilation failing if the 
stdint.h header has not been installed (from newlib in the case of AMD GCN).

I have fixed this by removing the stdint.h include and replacing uintptr_t with 
__UINTPTR_TYPE__, which is a predefined macro in the C preprocessor.

Okay for trunk?

Kwok

2020-01-10  Kwok Cheung Yeung  <kcy@codesourcery.com>

	libgcc/
	* config/gcn/atomic.c: Remove include of stdint.h.
	(__sync_val_compare_and_swap_##SIZE): Replace uintptr_t with
	__UINTPTR_TYPE__.
---
  libgcc/config/gcn/atomic.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

-- 
2.8.1

Comments

Andrew Stubbs Jan. 10, 2020, 2:43 p.m. | #1
On 10/01/2020 14:21, Kwok Cheung Yeung wrote:
> The patch for sub-word atomics support added an include of stdint.h for 

> the definition of uintptr_h, but this can result in GCC compilation 

> failing if the stdint.h header has not been installed (from newlib in 

> the case of AMD GCN).

> 

> I have fixed this by removing the stdint.h include and replacing 

> uintptr_t with __UINTPTR_TYPE__, which is a predefined macro in the C 

> preprocessor.

> 

> Okay for trunk?

> 

> Kwok

> 

> 2020-01-10  Kwok Cheung Yeung  <kcy@codesourcery.com>

> 

>      libgcc/

>      * config/gcn/atomic.c: Remove include of stdint.h.

>      (__sync_val_compare_and_swap_##SIZE): Replace uintptr_t with

>      __UINTPTR_TYPE__.

> ---

>   libgcc/config/gcn/atomic.c | 5 ++---

>   1 file changed, 2 insertions(+), 3 deletions(-)

> 

> diff --git a/libgcc/config/gcn/atomic.c b/libgcc/config/gcn/atomic.c

> index 214c9a5..adceb02 100644

> --- a/libgcc/config/gcn/atomic.c

> +++ b/libgcc/config/gcn/atomic.c

> @@ -22,15 +22,14 @@

>      <http://www.gnu.org/licenses/>.  */

> 

>   #include <stdbool.h>

> -#include <stdint.h>

> 

>   #define __SYNC_SUBWORD_COMPARE_AND_SWAP(TYPE, SIZE)                 \

>                                            \

>   TYPE                                         \

>   __sync_val_compare_and_swap_##SIZE (TYPE *ptr, TYPE oldval, TYPE 

> newval)     \

>   {                                         \

> -  unsigned int *wordptr = (unsigned int *)((uintptr_t) ptr & 

> ~3UL);         \

> -  int shift = ((uintptr_t) ptr & 3UL) * 8;                     \

> +  unsigned int *wordptr = (unsigned int *)((__UINTPTR_TYPE__ ) ptr & 

> ~3UL);  \

> +  int shift = ((__UINTPTR_TYPE__ ) ptr & 3UL) * 8;                 \

>     unsigned int valmask = (1 << (SIZE * 8)) - 1;                    \

>     unsigned int wordmask = ~(valmask << shift);                     \

>     unsigned int oldword = *wordptr;                         \


OK, thanks.

Andrew

Patch

diff --git a/libgcc/config/gcn/atomic.c b/libgcc/config/gcn/atomic.c
index 214c9a5..adceb02 100644
--- a/libgcc/config/gcn/atomic.c
+++ b/libgcc/config/gcn/atomic.c
@@ -22,15 +22,14 @@ 
     <http://www.gnu.org/licenses/>.  */

  #include <stdbool.h>
-#include <stdint.h>

  #define __SYNC_SUBWORD_COMPARE_AND_SWAP(TYPE, SIZE)			     \
  									     \
  TYPE									     \
  __sync_val_compare_and_swap_##SIZE (TYPE *ptr, TYPE oldval, TYPE newval)     \
  {									     \
-  unsigned int *wordptr = (unsigned int *)((uintptr_t) ptr & ~3UL);	     \
-  int shift = ((uintptr_t) ptr & 3UL) * 8;				     \
+  unsigned int *wordptr = (unsigned int *)((__UINTPTR_TYPE__ ) ptr & ~3UL);  \
+  int shift = ((__UINTPTR_TYPE__ ) ptr & 3UL) * 8;			     \
    unsigned int valmask = (1 << (SIZE * 8)) - 1;				    \
    unsigned int wordmask = ~(valmask << shift);				     \
    unsigned int oldword = *wordptr;					     \