software/include/base: Fix size_t, ptrdiff_t, and (u)intptr_t

As per convention, the types of size_t, ptrdiff_t, intptr_t, and
uintptr_t should be based on "long" or "int" depending on the platform
(32-bit or 64-bit).

This fixes compiler warnings of the following type:

    litex/soc/software/liblitesdcard/sdcard.c: In function 'sdcard_read':
    litex/soc/software/liblitesdcard/sdcard.c:476:39: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
      sdblock2mem_dma_base_write((uint64_t)(uintptr_t) buf);
					  ^

Reported-by: Gabriel Somlo <gsomlo@gmail.com>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
This commit is contained in:
Geert Uytterhoeven 2021-01-19 14:45:53 +01:00
parent 1710c5f1ef
commit 91c9192626
2 changed files with 10 additions and 0 deletions

View file

@ -11,8 +11,13 @@ extern "C" {
#define NULL ((void *)0) #define NULL ((void *)0)
#endif #endif
#ifdef __LP64__
typedef unsigned long size_t; typedef unsigned long size_t;
typedef long ptrdiff_t; typedef long ptrdiff_t;
#else
typedef unsigned int size_t;
typedef int ptrdiff_t;
#endif
#define offsetof(type, member) __builtin_offsetof(type, member) #define offsetof(type, member) __builtin_offsetof(type, member)

View file

@ -5,8 +5,13 @@
extern "C" { extern "C" {
#endif #endif
#ifdef __LP64__
typedef long intptr_t;
typedef unsigned long uintptr_t;
#else
typedef int intptr_t; typedef int intptr_t;
typedef unsigned int uintptr_t; typedef unsigned int uintptr_t;
#endif
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;