Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/55075 )
Change subject: include: always unsigned long for size_t ......................................................................
include: always unsigned long for size_t
Using the definition that GCC provides, size_t is an 'unsigned int' on 32-bit platforms and 'unsigned long' on 64-bit platforms. This is a constant source of compatibility problems, since code is often written for one integer type and then fails to compile for the other (e.g. printf format specifiers). 'unsigned long' always matches the platform size (see uintptr_t in <stdint.h>), so use it for size_t everywhere. This also removes a weird macro hack for defining ssize_t.
Change-Id: I8a8fa97c6961991dd8e291d2dc7d8762f83cad6d Signed-off-by: Jacob Garber jgarber1@ualberta.ca --- M src/include/stddef.h 1 file changed, 3 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/55075/1
diff --git a/src/include/stddef.h b/src/include/stddef.h index b668b1a..3e973e6 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -4,17 +4,9 @@ #include <commonlib/helpers.h>
typedef long ptrdiff_t; -#ifndef __SIZE_TYPE__ -#define __SIZE_TYPE__ unsigned long -#endif -typedef __SIZE_TYPE__ size_t; -/* There is a GCC macro for a size_t type, but not - * for a ssize_t type. Below construct tricks GCC - * into making __SIZE_TYPE__ signed. - */ -#define unsigned signed -typedef __SIZE_TYPE__ ssize_t; -#undef unsigned + +typedef unsigned long size_t; +typedef signed long ssize_t;
typedef int wchar_t; typedef unsigned int wint_t;