mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-02 00:24:12 +08:00
bd27fef329
When compile nolibc-test.c with 2.31 glibc, we got such error: In file included from /usr/riscv64-linux-gnu/include/sys/cdefs.h:452, from /usr/riscv64-linux-gnu/include/features.h:461, from /usr/riscv64-linux-gnu/include/bits/libc-header-start.h:33, from /usr/riscv64-linux-gnu/include/limits.h:26, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:194, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/syslimits.h:7, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:34, from /labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/nolibc-test.c:6: /usr/riscv64-linux-gnu/include/bits/wordsize.h:28:3: error: #error "rv32i-based targets are not supported" 28 | # error "rv32i-based targets are not supported" Glibc (>= 2.33) commit 5b6113d62efa ("RISC-V: Support the 32-bit ABI implementation") fixed up above error. As suggested by Thomas, defining INT_MIN/INT_MAX for nolibc can remove the including of limits.h, and therefore no above error. of course, the other libcs still require limits.h, move it to the right place. The LONG_MIN/LONG_MAX are also defined too. Suggested-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/linux-riscv/09d60dc2-e298-4c22-8e2f-8375861bd9be@t-8ch.de/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
114 lines
3.2 KiB
C
114 lines
3.2 KiB
C
/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
|
|
/*
|
|
* Standard definitions and types for NOLIBC
|
|
* Copyright (C) 2023 Vincent Dagonneau <v@vda.io>
|
|
*/
|
|
|
|
#ifndef _NOLIBC_STDINT_H
|
|
#define _NOLIBC_STDINT_H
|
|
|
|
typedef unsigned char uint8_t;
|
|
typedef signed char int8_t;
|
|
typedef unsigned short uint16_t;
|
|
typedef signed short int16_t;
|
|
typedef unsigned int uint32_t;
|
|
typedef signed int int32_t;
|
|
typedef unsigned long long uint64_t;
|
|
typedef signed long long int64_t;
|
|
typedef unsigned long size_t;
|
|
typedef signed long ssize_t;
|
|
typedef unsigned long uintptr_t;
|
|
typedef signed long intptr_t;
|
|
typedef signed long ptrdiff_t;
|
|
|
|
typedef int8_t int_least8_t;
|
|
typedef uint8_t uint_least8_t;
|
|
typedef int16_t int_least16_t;
|
|
typedef uint16_t uint_least16_t;
|
|
typedef int32_t int_least32_t;
|
|
typedef uint32_t uint_least32_t;
|
|
typedef int64_t int_least64_t;
|
|
typedef uint64_t uint_least64_t;
|
|
|
|
typedef int8_t int_fast8_t;
|
|
typedef uint8_t uint_fast8_t;
|
|
typedef ssize_t int_fast16_t;
|
|
typedef size_t uint_fast16_t;
|
|
typedef ssize_t int_fast32_t;
|
|
typedef size_t uint_fast32_t;
|
|
typedef int64_t int_fast64_t;
|
|
typedef uint64_t uint_fast64_t;
|
|
|
|
typedef int64_t intmax_t;
|
|
typedef uint64_t uintmax_t;
|
|
|
|
/* limits of integral types */
|
|
|
|
#define INT8_MIN (-128)
|
|
#define INT16_MIN (-32767-1)
|
|
#define INT32_MIN (-2147483647-1)
|
|
#define INT64_MIN (-9223372036854775807LL-1)
|
|
|
|
#define INT8_MAX (127)
|
|
#define INT16_MAX (32767)
|
|
#define INT32_MAX (2147483647)
|
|
#define INT64_MAX (9223372036854775807LL)
|
|
|
|
#define UINT8_MAX (255)
|
|
#define UINT16_MAX (65535)
|
|
#define UINT32_MAX (4294967295U)
|
|
#define UINT64_MAX (18446744073709551615ULL)
|
|
|
|
#define INT_LEAST8_MIN INT8_MIN
|
|
#define INT_LEAST16_MIN INT16_MIN
|
|
#define INT_LEAST32_MIN INT32_MIN
|
|
#define INT_LEAST64_MIN INT64_MIN
|
|
|
|
#define INT_LEAST8_MAX INT8_MAX
|
|
#define INT_LEAST16_MAX INT16_MAX
|
|
#define INT_LEAST32_MAX INT32_MAX
|
|
#define INT_LEAST64_MAX INT64_MAX
|
|
|
|
#define UINT_LEAST8_MAX UINT8_MAX
|
|
#define UINT_LEAST16_MAX UINT16_MAX
|
|
#define UINT_LEAST32_MAX UINT32_MAX
|
|
#define UINT_LEAST64_MAX UINT64_MAX
|
|
|
|
#define SIZE_MAX ((size_t)(__LONG_MAX__) * 2 + 1)
|
|
#define INTPTR_MIN (-__LONG_MAX__ - 1)
|
|
#define INTPTR_MAX __LONG_MAX__
|
|
#define PTRDIFF_MIN INTPTR_MIN
|
|
#define PTRDIFF_MAX INTPTR_MAX
|
|
#define UINTPTR_MAX SIZE_MAX
|
|
|
|
#define INT_FAST8_MIN INT8_MIN
|
|
#define INT_FAST16_MIN INTPTR_MIN
|
|
#define INT_FAST32_MIN INTPTR_MIN
|
|
#define INT_FAST64_MIN INT64_MIN
|
|
|
|
#define INT_FAST8_MAX INT8_MAX
|
|
#define INT_FAST16_MAX INTPTR_MAX
|
|
#define INT_FAST32_MAX INTPTR_MAX
|
|
#define INT_FAST64_MAX INT64_MAX
|
|
|
|
#define UINT_FAST8_MAX UINT8_MAX
|
|
#define UINT_FAST16_MAX SIZE_MAX
|
|
#define UINT_FAST32_MAX SIZE_MAX
|
|
#define UINT_FAST64_MAX UINT64_MAX
|
|
|
|
#ifndef INT_MIN
|
|
#define INT_MIN (-__INT_MAX__ - 1)
|
|
#endif
|
|
#ifndef INT_MAX
|
|
#define INT_MAX __INT_MAX__
|
|
#endif
|
|
|
|
#ifndef LONG_MIN
|
|
#define LONG_MIN (-__LONG_MAX__ - 1)
|
|
#endif
|
|
#ifndef LONG_MAX
|
|
#define LONG_MAX __LONG_MAX__
|
|
#endif
|
|
|
|
#endif /* _NOLIBC_STDINT_H */
|