Use defined stdint.h
authorRobert Pengelly <robertapengelly@hotmail.com>
Tue, 19 Aug 2025 04:35:01 +0000 (05:35 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Tue, 19 Aug 2025 04:35:01 +0000 (05:35 +0100)
Makefile.unix
Makefile.w32
ranlib.c
stdint.h

index 02c268cfa858e39cf6e0cbe58a7bd3df69fcb61f..09ff4fc82c2ff750f36b5dc99d4fc3257a161feb 100644 (file)
@@ -7,10 +7,6 @@ VPATH               :=  $(SRCDIR)
 CC                  :=  gcc
 CFLAGS              :=  -D_FILE_OFFSET_BITS=64 -O2 -Wall -Werror -Wextra -ansi -pedantic -std=c90
 
-ifneq ($(shell uname -s),Darwin)
-CFLAGS += -m32
-endif
-
 CSRC                :=  append.c ar.c conv.c delete.c display.c extract.c lib.c ranlib.c replace.c report.c
 
 ifeq ($(OS), Windows_NT)
index 9a70e98eb5b1343bba6ec87fdb361b112b8a05f4..7749f25deb9a8884642cc5a7fcbed0e99d7dff1c 100644 (file)
@@ -5,7 +5,7 @@ SRCDIR              ?=  $(CURDIR)
 VPATH               :=  $(SRCDIR)
 
 CC                  :=  gcc
-CFLAGS              :=  -D_FILE_OFFSET_BITS=64 -O2 -Wall -Werror -Wextra -ansi -m32 -pedantic -std=c90
+CFLAGS              :=  -D_FILE_OFFSET_BITS=64 -O2 -Wall -Werror -Wextra -ansi -pedantic -std=c90
 
 CSRC                :=  append.c ar.c conv.c delete.c display.c extract.c lib.c ranlib.c replace.c report.c
 
index 3c5227d327f8b7783ca1744f236d77eb176c4b4e..a34cefbd824a09d2581cc2a1e2eef2396d678d95 100644 (file)
--- a/ranlib.c
+++ b/ranlib.c
@@ -1,7 +1,6 @@
 /******************************************************************************
  * @file            ranlib.c
  *****************************************************************************/
-#include    <inttypes.h>
 #include    <limits.h>
 #include    <stddef.h>
 #include    <stdio.h>
@@ -312,8 +311,8 @@ static void coff_get_symbols (void *object, long offset) {
     : ((uint32_t) arr[0] | (((uint32_t) arr[1]) << 8) | (((uint32_t) arr[2]) << 16) | (((uint32_t) arr[3]) << 24)))
 
 #define     GET_ELF_UINT64(arr)                                                                                                                                                                                                                 \
-    (endianess ? (((uint_fast64_t) arr[0]) << 56) | (((uint_fast64_t) arr[1]) << 48) | (((uint_fast64_t) arr[2]) << 40) | (((uint_fast64_t) arr[3]) >> 32) | (((uint_fast64_t) arr[4]) << 24) | (((uint_fast64_t) arr[5]) << 16) | (((uint_fast64_t) arr[6]) << 8) | (((uint_fast64_t) arr[7]))  \
-        : ((uint_fast64_t) arr[0]) | (((uint_fast64_t) arr[1]) << 8) | (((uint_fast64_t) arr[2]) << 16) | (((uint_fast64_t) arr[3]) << 24) | (((uint_fast64_t) arr[4]) << 32) | (((uint_fast64_t) arr[5]) << 40) | (((uint_fast64_t) arr[6]) << 48) | (((uint_fast64_t) arr[7]) << 56))
+    (endianess ? (((uint64_t) arr[0]) << 56) | (((uint64_t) arr[1]) << 48) | (((uint64_t) arr[2]) << 40) | (((uint64_t) arr[3]) >> 32) | (((uint64_t) arr[4]) << 24) | (((uint64_t) arr[5]) << 16) | (((uint64_t) arr[6]) << 8) | (((uint64_t) arr[7]))  \
+        : ((uint64_t) arr[0]) | (((uint64_t) arr[1]) << 8) | (((uint64_t) arr[2]) << 16) | (((uint64_t) arr[3]) << 24) | (((uint64_t) arr[4]) << 32) | (((uint64_t) arr[5]) << 40) | (((uint64_t) arr[6]) << 48) | (((uint64_t) arr[7]) << 56))
 
 static void elf32_get_symbols (void *object, long offset, int endianess) {
 
@@ -732,15 +731,21 @@ static void omf_get_symbols (void *object, char *filename, unsigned long bytes,
 void ranlib (void) {
 
     FILE *tfp = tmpfile ();
-    long offset = 0;
     
     struct ar_header header;
-    long bytes, i, j, len, read, val;
+    long i, j, len, read, val;
     
     unsigned char *object;
     void *contents;
     
     char temp[16];
+    long offset = 0;
+    
+#if     UINT_MAX == 65535
+    long bytes;
+#else
+    int bytes;
+#endif
     
     for (;;) {
     
@@ -910,9 +915,13 @@ void ranlib (void) {
     memcpy (header.group, temp, 6);
     memcpy (header.mode, temp, 8);
     
+#if     UINT_MAX == 65535
     len = sprintf (temp, "%ld", bytes + 4);
-    temp[len] = ' ';
+#else
+    len = sprintf (temp, "%d", bytes + 4);
+#endif
     
+    temp[len] = ' ';
     memcpy (header.size, temp, 10);
     
     header.endsig[0] = '`';
index f4b18c0646873c038a77b8777e6c9a7270486bca..5163ae36a3a85fc82fd1872dcab8ba87fff82bbb 100644 (file)
--- a/stdint.h
+++ b/stdint.h
@@ -20,4 +20,12 @@ typedef     signed int                  int32_t;
 typedef     unsigned int                uint32_t;
 #endif
 
+#if     ULONG_MAX == 4294967295 && !defined (NO_LONG_LONG)
+typedef     signed long long            int64_t;
+typedef     signed long long            uint64_t;
+#else
+typedef     signed long                 int64_t;
+typedef     unsigned long               uint64_t;
+#endif
+
 #endif      /* _STDINT_H */