diff mbox

[PATCH/AARCH64,1/6] Fix size and pointer different types for ILP32.

Message ID 1386105892-2379-2-git-send-email-apinski@cavium.com
State New
Headers show

Commit Message

Andrew Pinski Dec. 3, 2013, 9:24 p.m. UTC
While compiling some programs, GCC and glibc (and newlib)'s definitions of size_t
were not agreeing and causing format warnings to happen.  The simple testcase for this is:
#include <stdio.h>
#include <stdint.h>

int main(void)
{
  ssize_t t = 0x1;
  printf("%zd\n", t);
  return 0;
}
----- CUT -----

OK?  Built and tested for aarch64-elf without any regressions.

Thanks,
Andrew Pinski



	* config/aarch64/aarch64.h (SIZE_TYPE):  Set to unsigned int for ILP32.
        (PTRDIFF_TYPE): Set to int for ILP32.
---
 gcc/ChangeLog                |    5 +++++
 gcc/config/aarch64/aarch64.h |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

iff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index cead022..65d226d 100644

Comments

Marcus Shawcroft Dec. 10, 2013, 11:23 a.m. UTC | #1
On 3 December 2013 21:24, Andrew Pinski <pinskia@gmail.com> wrote:
>
> While compiling some programs, GCC and glibc (and newlib)'s definitions of size_t
> were not agreeing and causing format warnings to happen.  The simple testcase for this is:
> #include <stdio.h>
> #include <stdint.h>
>
> int main(void)
> {
>   ssize_t t = 0x1;
>   printf("%zd\n", t);
>   return 0;
> }

Hi Andrew,

The PCS IHI0056C defines SIZE_TYPE as 'unsigned long' for both ILP32
and LP64 and PTRDIFF_TYPE as "signed long" for both ILP32 and LP64.
This seems like a sane choice to me.

Trying to recreate the failure with the test fragment above doesn't
given a warning:

$ aarch64-none-elf-gcc -Wall -mabi=ilp32 test-size_t.c -specs=rdimon.specs
$ aarch64-none-linux-gnu-gcc -Wall -mabi=ilp32 test-size_t.c -c
$

..what am I doing differently to your test run?

Cheers
/Marcus
Andrew Pinski Feb. 25, 2014, 1:28 a.m. UTC | #2
On Tue, Dec 10, 2013 at 3:23 AM, Marcus Shawcroft
<marcus.shawcroft@gmail.com> wrote:
> On 3 December 2013 21:24, Andrew Pinski <pinskia@gmail.com> wrote:
>>
>> While compiling some programs, GCC and glibc (and newlib)'s definitions of size_t
>> were not agreeing and causing format warnings to happen.  The simple testcase for this is:
>> #include <stdio.h>
>> #include <stdint.h>
>>
>> int main(void)
>> {
>>   ssize_t t = 0x1;
>>   printf("%zd\n", t);
>>   return 0;
>> }
>
> Hi Andrew,
>
> The PCS IHI0056C defines SIZE_TYPE as 'unsigned long' for both ILP32
> and LP64 and PTRDIFF_TYPE as "signed long" for both ILP32 and LP64.
> This seems like a sane choice to me.
>
> Trying to recreate the failure with the test fragment above doesn't
> given a warning:
>
> $ aarch64-none-elf-gcc -Wall -mabi=ilp32 test-size_t.c -specs=rdimon.specs
> $ aarch64-none-linux-gnu-gcc -Wall -mabi=ilp32 test-size_t.c -c
> $
>
> ..what am I doing differently to your test run?

I found out it was a bug in glibc where it defines __SSIZE_T_TYPE to
__SWORD_TYPE (int for ilp32 and long for lp64) rather than
__SLONGWORD_TYPE (long always).
I have fix for when I submit the glibc patches.

Thanks,
Andrew Pinski

>
> Cheers
> /Marcus
diff mbox

Patch

--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -144,9 +144,9 @@ 
 /* Using long long breaks -ansi and -std=c90, so these will need to be
    made conditional for an LLP64 ABI.  */
 
-#define SIZE_TYPE	"long unsigned int"
+#define SIZE_TYPE	(TARGET_ILP32 ? "unsigned int" : "long unsigned int")
 
-#define PTRDIFF_TYPE	"long int"
+#define PTRDIFF_TYPE	(TARGET_ILP32 ? "int" : "long int")
 
 #define PCC_BITFIELD_TYPE_MATTERS	1