ref: 737c3edeba2c7615e08d9263e9eb010bbfd1e42b
parent: cd9da74cbc2ff04de2179565bf31d8536eb9bd6b
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jul 12 22:36:48 EDT 2015
ape: add stdint.h, fix SSIZE_MAX and add SIZE_MAX to limits.h
--- a/amd64/include/ape/inttypes.h
+++ /dev/null
@@ -1,21 +1,0 @@
-#ifndef _SUSV2_SOURCE
-#error "inttypes.h is SUSV2"
-#endif
-
-#ifndef _INTTYPES_H_
-#define _INTTYPES_H_ 1
-
-
-typedef char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-typedef long long int64_t;
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long uint64_t;
-
-typedef long long intptr_t;
-typedef unsigned long long uintptr_t;
-
-#endif
--- /dev/null
+++ b/amd64/include/ape/stdint.h
@@ -1,0 +1,31 @@
+#ifndef _STDINT_H_
+#define _STDINT_H_ 1
+
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef long long intptr_t;
+typedef unsigned long long uintptr_t;
+
+#define INT8_MIN 0x80
+#define INT16_MIN 0x8000
+#define INT32_MIN 0x80000000
+#define INT64_MIN 0x8000000000000000LL
+
+#define INT8_MAX 0x7f
+#define INT16_MAX 0x7fff
+#define INT32_MAX 0x7fffffff
+#define INT64_MAX 0x7fffffffffffffffULL
+
+#define UINT8_MAX 0xff
+#define UINT16_MAX 0xffff
+#define UINT32_MAX 0xffffffffL
+#define UINT64_MAX 0xffffffffffffffffULL
+
+#endif
--- a/sys/include/ape/inttypes.h
+++ b/sys/include/ape/inttypes.h
@@ -5,19 +5,26 @@
#ifndef _INTTYPES_H_
#define _INTTYPES_H_ 1
-typedef int _intptr_t;
-typedef unsigned int _uintptr_t;
+#include <stdint.h>
+#define PRId8 "d"
+#define PRId16 "d"
+#define PRId32 "d"
+#define PRId64 "lld"
-typedef char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-typedef long long int64_t;
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long uint64_t;
-typedef _intptr_t intptr_t;
-typedef _uintptr_t uintptr_t;
+#define PRIo8 "o"
+#define PRIo16 "o"
+#define PRIo32 "o"
+#define PRIo64 "llo"
+
+#define PRIx8 "x"
+#define PRIx16 "x"
+#define PRIx32 "x"
+#define PRIx64 "llx"
+
+#define PRIu8 "u"
+#define PRIu16 "u"
+#define PRIu32 "u"
+#define PRIu64 "llu"
#endif
--- a/sys/include/ape/limits.h
+++ b/sys/include/ape/limits.h
@@ -47,7 +47,7 @@
#define _POSIX_SEM_NSEMS_MAX 256
#define _POSIX_SEM_VALUE_MAX 32767
#define _POSIX_SIGQUEUE_MAX 32
-#define _POSIX_SSIZE_MAX 32767
+#define _POSIX_SSIZE_MAX SSIZE_MAX
#define _POSIX_STREAM_MAX 8
#define _POSIX_TIMER_MAX 32
#define _POSIX_TZNAME_MAX 3
@@ -76,6 +76,7 @@
/*#define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX */
/*#define SIGQUEUE_MAX _POSIX_SIGQUEUE_MAX */
#define SSIZE_MAX LONG_MAX
+#define SIZE_MAX ULONG_MAX
/*#define STREAM_MAX _POSIX_STREAM_MAX */
/*#define TIMER_MAX _POSIX_TIMER_MAX */
#define TZNAME_MAX _POSIX_TZNAME_MAX
--- /dev/null
+++ b/sys/include/ape/stdint.h
@@ -1,0 +1,33 @@
+#ifndef _STDINT_H_
+#define _STDINT_H_ 1
+
+typedef int _intptr_t;
+typedef unsigned int _uintptr_t;
+
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+typedef _intptr_t intptr_t;
+typedef _uintptr_t uintptr_t;
+
+#define INT8_MIN 0x80
+#define INT16_MIN 0x8000
+#define INT32_MIN 0x80000000
+#define INT64_MIN 0x8000000000000000LL
+
+#define INT8_MAX 0x7f
+#define INT16_MAX 0x7fff
+#define INT32_MAX 0x7fffffff
+#define INT64_MAX 0x7fffffffffffffffULL
+
+#define UINT8_MAX 0xff
+#define UINT16_MAX 0xffff
+#define UINT32_MAX 0xffffffffL
+#define UINT64_MAX 0xffffffffffffffffULL
+
+#endif