diff --git a/include/limits.h b/include/limits.h index 056e2ada83..4d959d153f 100644 --- a/include/limits.h +++ b/include/limits.h @@ -123,11 +123,22 @@ #define _POSIX_OPEN_MAX CONFIG_NFILE_DESCRIPTORS #define _POSIX_PATH_MAX CONFIG_PATH_MAX #define _POSIX_PIPE_BUF 512 -#define _POSIX_SSIZE_MAX INT_MAX #define _POSIX_STREAM_MAX CONFIG_NFILE_STREAMS #define _POSIX_TZNAME_MAX 3 -/* Requred for sigqueue */ +#ifdef CONFIG_SMALL_MEMORY + +#define _POSIX_SSIZE_MAX 32767 /* See sys/types.h */ +#define _POSIX_SSIZE_MIN -32768 + +#else /* CONFIG_SMALL_MEMORY */ + +#define _POSIX_SSIZE_MAX 2147483647 /* See sys/types.h */ +#define _POSIX_SSIZE_MIN -2147483648 + +#endif /* CONFIG_SMALL_MEMORY */ + +/* Required for sigqueue */ #define _POSIX_RTSIG_MAX 31 #define _POSIX_SIGQUEUE_MAX 32 @@ -184,6 +195,7 @@ #define PATH_MAX _POSIX_PATH_MAX #define PIPE_BUF _POSIX_PIPE_BUF #define SSIZE_MAX _POSIX_SSIZE_MAX +#define SSIZE_MIN _POSIX_SSIZE_MIN #define STREAM_MAX _POSIX_STREAM_MAX #define TZNAME_MAX _POSIX_TZNAME_MAX diff --git a/include/stdint.h b/include/stdint.h index 4c14d935ea..49e852258d 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -185,10 +185,16 @@ #endif #ifdef CONFIG_SMALL_MEMORY -# define SIZE_MAX 0xffff -#else -# define SIZE_MAX 0xffffffff -#endif + +#define SIZE_MAX UINT16_MAX /* See sys/types.h */ +#define RSIZE_MAX UINT16_MAX + +#else /* CONFIG_SMALL_MEMORY */ + +#define SIZE_MAX UINT32_MAX /* See sys/types.h */ +#define RSIZE_MAX UINT32_MAX + +#endif /* CONFIG_SMALL_MEMORY */ #if 0 # define WCHAR_MIN diff --git a/include/sys/types.h b/include/sys/types.h index 7b579744ac..0fa01c1178 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -133,26 +133,14 @@ typedef unsigned int mode_t; #ifdef CONFIG_SMALL_MEMORY -#define SIZE_MAX UINT16_MAX typedef uint16_t size_t; - -#define SSIZE_MAX INT16_MAX -#define SSIZE_MIN INT16_MIN typedef int16_t ssize_t; - -#define RSIZE_MAX UINT16_MAX typedef uint16_t rsize_t; #else /* CONFIG_SMALL_MEMORY */ -#define SIZE_MAX UINT32_MAX typedef uint32_t size_t; - -#define SSIZE_MAX INT32_MAX -#define SSIZE_MIN INT32_MIN typedef int32_t ssize_t; - -#define RSIZE_MAX UINT32_MAX typedef uint32_t rsize_t; #endif /* CONFIG_SMALL_MEMORY */