From 0bf4243ae0c8bfa68d62b67b32bacef3da486364 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Mon, 16 Mar 2020 12:46:31 +0200 Subject: [PATCH] Use intptr_t and uintptr_t Thanks @krytarowski --- tiny/lisp-nontail.c | 13 ++++--------- tiny/lisp.c | 13 ++++--------- tiny/lisp2.c | 13 ++++--------- tiny/lispf.c | 17 ++++------------- 4 files changed, 16 insertions(+), 40 deletions(-) diff --git a/tiny/lisp-nontail.c b/tiny/lisp-nontail.c index b8ff3a4..9f6a916 100644 --- a/tiny/lisp-nontail.c +++ b/tiny/lisp-nontail.c @@ -27,15 +27,10 @@ #include #include -#ifdef __LP64__ -#define NUM_FORMAT "%" PRId64 -typedef uint64_t value_t; -typedef int64_t number_t; -#else -#define NUM_FORMAT "%" PRId32 -typedef uint32_t value_t; -typedef int32_t number_t; -#endif +#define NUM_FORMAT "%" PRIdPTR + +typedef intptr_t number_t; +typedef uintptr_t value_t; typedef struct { value_t car; diff --git a/tiny/lisp.c b/tiny/lisp.c index 1e99ebc..061362f 100644 --- a/tiny/lisp.c +++ b/tiny/lisp.c @@ -27,15 +27,10 @@ #include #include -#ifdef __LP64__ -#define NUM_FORMAT "%" PRId64 -typedef uint64_t value_t; -typedef int64_t number_t; -#else -#define NUM_FORMAT "%" PRId32 -typedef uint32_t value_t; -typedef int32_t number_t; -#endif +#define NUM_FORMAT "%" PRIdPTR + +typedef intptr_t number_t; +typedef uintptr_t value_t; typedef struct { value_t car; diff --git a/tiny/lisp2.c b/tiny/lisp2.c index 69a1b5f..782a819 100644 --- a/tiny/lisp2.c +++ b/tiny/lisp2.c @@ -48,15 +48,10 @@ #include #include -#ifdef __LP64__ -#define NUM_FORMAT "%" PRId64 -typedef uint64_t value_t; -typedef int64_t number_t; -#else -#define NUM_FORMAT "%" PRId32 -typedef uint32_t value_t; -typedef int32_t number_t; -#endif +#define NUM_FORMAT "%" PRIdPTR + +typedef intptr_t number_t; +typedef uintptr_t value_t; typedef struct { value_t car; diff --git a/tiny/lispf.c b/tiny/lispf.c index 9b88b1f..e401335 100644 --- a/tiny/lispf.c +++ b/tiny/lispf.c @@ -33,25 +33,16 @@ #include #include -#ifdef __LP64__ -typedef uint64_t value_t; -#else -typedef uint32_t value_t; -#endif - #ifdef FLOAT #define NUM_FORMAT "%f" typedef float number_t; #else -#ifdef __LP64__ -#define NUM_FORMAT "%" PRId64 -typedef int64_t number_t; -#else -#define NUM_FORMAT "%" PRId32 -typedef int32_t number_t; -#endif +#define NUM_FORMAT "%" PRIdPTR +typedef intptr_t number_t; #endif +typedef uintptr_t value_t; + typedef struct { value_t car; value_t cdr;