shithub: femtolisp

Download patch

ref: 0bf4243ae0c8bfa68d62b67b32bacef3da486364
parent: 1006496256ea36d8b1ba22739db6a70987f1987e
author: Lassi Kortela <[email protected]>
date: Mon Mar 16 08:46:31 EDT 2020

Use intptr_t and uintptr_t

Thanks @krytarowski

--- a/tiny/lisp-nontail.c
+++ b/tiny/lisp-nontail.c
@@ -27,15 +27,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#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;
--- a/tiny/lisp.c
+++ b/tiny/lisp.c
@@ -27,15 +27,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#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;
--- a/tiny/lisp2.c
+++ b/tiny/lisp2.c
@@ -48,15 +48,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#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;
--- a/tiny/lispf.c
+++ b/tiny/lispf.c
@@ -33,24 +33,15 @@
 #include <stdlib.h>
 #include <string.h>
 
-#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;
+#define NUM_FORMAT "%" PRIdPTR
+typedef intptr_t number_t;
 #endif
-#endif
+
+typedef uintptr_t value_t;
 
 typedef struct {
     value_t car;