From: Marco Schlumpp Date: Tue, 24 May 2022 18:17:14 +0000 (+0200) Subject: lib/nolibc: Define u_(long|int|short_char) for _DEFAULT_SOURCE files X-Git-Tag: RELEASE-0.13.0~78 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=6d07539298dae30eb07f078942563af2be60acd9;p=unikraft%2Funikraft.git lib/nolibc: Define u_(long|int|short_char) for _DEFAULT_SOURCE files These typedefs are commonly used in BSD code. Most libc libraries define them by default or for _DEFAULT_SOURCE files. Because unikraft is usually closer to Linux, this adopts the later approach. Signed-off-by: Marco Schlumpp Reviewed-by: Razvan Deaconescu Reviewed-by: Marc Rittinghaus Approved-by: Marc Rittinghaus Tested-by: Unikraft CI GitHub-Closes: #627 --- diff --git a/lib/nolibc/include/nolibc-internal/shareddefs.h b/lib/nolibc/include/nolibc-internal/shareddefs.h index 15eb4771d..1c5542eee 100644 --- a/lib/nolibc/include/nolibc-internal/shareddefs.h +++ b/lib/nolibc/include/nolibc-internal/shareddefs.h @@ -212,3 +212,11 @@ typedef unsigned short __sa_family_t; typedef __sa_family_t sa_family_t; #define __DEFINED_sa_family_t #endif + +#if defined(__NEED_BSD_TYPES) && !defined(__DEFINED_BSD_TYPES) +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +#define __DEFINED_BSD_TYPES +#endif diff --git a/lib/nolibc/include/sys/types.h b/lib/nolibc/include/sys/types.h index fc42ee310..880cc3909 100644 --- a/lib/nolibc/include/sys/types.h +++ b/lib/nolibc/include/sys/types.h @@ -41,6 +41,9 @@ extern "C" { #endif +#ifdef _DEFAULT_SOURCE +#define __NEED_BSD_TYPES +#endif #define __NEED_size_t #define __NEED_ssize_t #define __NEED_off_t