Used platform-independent aint printf patterns

This commit is contained in:
Roman Venediktov 2024-07-01 09:31:26 +02:00
parent 6a474f80f7
commit 468caac0f2
2 changed files with 11 additions and 17 deletions

View file

@ -618,7 +618,7 @@ aint inner_hash (aint depth, auint acc, void *p) {
extern void *LstringInt (char *b) {
aint n;
sscanf(b, "%lld", &n);
sscanf(b, "%" SCNdAI, &n);
return (void *)BOX(n);
}
@ -1274,7 +1274,7 @@ extern aint Lread () {
printf("> ");
fflush(stdout);
scanf("%lli", &result);
scanf("%" SCNdAI, &result);
return BOX(result);
}
@ -1291,7 +1291,7 @@ extern int Lbinoperror2 (void) {
/* Lwrite is an implementation of the "write" construct */
extern aint Lwrite (aint n) {
printf("%lld\n", UNBOX(n));
printf("%" PRIdAI "\n", UNBOX(n));
fflush(stdout);
return 0;

View file

@ -10,27 +10,21 @@
#if defined(__x86_64__) || defined(__ppc64__)
#define X86_64
#else
#endif
typedef size_t ptrt; // pointer type, because can hold a pointer on a corresponding platform
typedef
#ifdef X86_64
int64_t
typedef int64_t aint; // adaptive int
typedef uint64_t auint; // adaptive unsigned int
#define PRIdAI PRId64
#define SCNdAI SCNd64
#else
int32_t
typedef int32_t aint; // adaptive int
typedef uint32_t auint; // adaptive unsigned int
#define PRIdAI PRId32
#define SCNdAI SCNd32
#endif
aint; // adaptive int
typedef
#ifdef X86_64
uint64_t
#else
uint32_t
#endif
auint; // adaptive unsigned int
#define STRING_TAG 0x00000001
#define ARRAY_TAG 0x00000003