From 849369abb5c282665dc8116e024f1610008ad5e9 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Wed, 19 Aug 2026 12:36:53 +0100 Subject: [PATCH] Removed C90 limitations and NO_LONG_LONG related stuff as even MinGW on Windows 2000 works --- Makefile.unix | 2 +- lib.c | 2 +- lib.h | 2 +- ranlib.c | 23 +---------------------- stdint.h | 49 ------------------------------------------------- 5 files changed, 4 insertions(+), 74 deletions(-) delete mode 100644 stdint.h diff --git a/Makefile.unix b/Makefile.unix index 46f6d67..b1cc3f0 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -5,7 +5,7 @@ SRCDIR ?= $(CURDIR) VPATH := $(SRCDIR) CC := gcc -CFLAGS := -D_FILE_OFFSET_BITS=64 -O2 -Wall -Werror -Wextra -ansi -pedantic -std=c90 +CFLAGS := -D_FILE_OFFSET_BITS=64 -O2 -Wall -Werror -Wextra CSRC := append.c ar.c conv.c delete.c display.c extract.c hashtab.c lib.c ranlib.c replace.c report.c diff --git a/lib.c b/lib.c index 2eea95d..b89ad7c 100644 --- a/lib.c +++ b/lib.c @@ -8,6 +8,7 @@ #endif #include +#include #include #include #include @@ -15,7 +16,6 @@ #include "ar.h" #include "lib.h" #include "report.h" -#include "stdint.h" static void print_usage (void) { diff --git a/lib.h b/lib.h index d9f51ca..097465d 100644 --- a/lib.h +++ b/lib.h @@ -4,7 +4,7 @@ #ifndef _LIB_H #define _LIB_H -#include "stdint.h" +#include char *xstrdup (const char *__p); char *xstrndup (const char *__p, unsigned long __size); diff --git a/ranlib.c b/ranlib.c index 9cd53f8..79b1376 100644 --- a/ranlib.c +++ b/ranlib.c @@ -3,6 +3,7 @@ *****************************************************************************/ #include #include +#include #include #include #include @@ -15,7 +16,6 @@ #include "lib.h" #include "macho.h" #include "report.h" -#include "stdint.h" struct strtab { @@ -284,12 +284,7 @@ static void elf64_get_symbols (void *object, int64_t offset, int endianess) { uint16_t e_shnum = array_to_integer (hdr->e_shnum, 2, endianess); uint16_t e_shentsize = array_to_integer (hdr->e_shentsize, 2, endianess); - -#if defined (NO_LONG_LONG) - uint64_t e_shoff = array_to_integer (hdr->e_shoff, 4, endianess); -#else uint64_t e_shoff = array_to_integer (hdr->e_shoff, 8, endianess); -#endif uint64_t sh_link, sh_offset, sh_entsize, sh_size; uint64_t sym_strtab_size, i, j, st_name; @@ -310,12 +305,7 @@ static void elf64_get_symbols (void *object, int64_t offset, int endianess) { } sh_link = array_to_integer (shdr.sh_link, 4, endianess); - -#if defined (NO_LONG_LONG) - sh_offset = array_to_integer (shdr.sh_offset, 4, endianess); -#else sh_offset = array_to_integer (shdr.sh_offset, 8, endianess); -#endif if (sh_link == 0 || sh_link >= e_shnum) { continue; @@ -327,16 +317,6 @@ static void elf64_get_symbols (void *object, int64_t offset, int endianess) { continue; } -#if defined (NO_LONG_LONG) - sym_strtab_size = array_to_integer (strtabhdr.sh_size, 4, endianess); - sym_strtab = (char *) object + array_to_integer (strtabhdr.sh_offset, 4, endianess); - - if ((sh_entsize = array_to_integer (shdr.sh_entsize, 4, endianess)) < sizeof (elf_symbol)) { - continue; - } - - sh_size = array_to_integer (shdr.sh_size, 4, endianess); -#else sym_strtab_size = array_to_integer (strtabhdr.sh_size, 8, endianess); sym_strtab = (char *) object + array_to_integer (strtabhdr.sh_offset, 8, endianess); @@ -345,7 +325,6 @@ static void elf64_get_symbols (void *object, int64_t offset, int endianess) { } sh_size = array_to_integer (shdr.sh_size, 8, endianess); -#endif for (j = 1; j < sh_size / sh_entsize; j++) { diff --git a/stdint.h b/stdint.h deleted file mode 100644 index 1b97ab8..0000000 --- a/stdint.h +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * @file stdint.h - *****************************************************************************/ -#ifndef _STDINT_H_INCLUDED -#ifndef _STDINT_H -#ifndef _STDINT_H_ - -#define _STDINT_H_INCLUDED -#define _STDINT_H -#define _STDINT_H_ - -#include - -/* Add all data types (even though we don't use them) as the project seems to fail to build on some systems. */ -typedef signed char int8_t; -typedef unsigned char uint8_t; - -typedef signed short int16_t; -typedef unsigned short uint16_t; - -#if INT_MAX > 32767 -typedef signed int int32_t; -typedef unsigned int uint32_t; -#else -typedef signed long int32_t; -typedef unsigned long uint32_t; -#endif - -#ifndef _INT64_T -#define _INT64_T -#if defined (NO_LONG_LONG) || ((ULONG_MAX >> 16) >> 16) == 0xffffffff -typedef signed long int64_t; -#else -typedef signed long long int64_t; -#endif -#endif /* _INT64_T */ - -#ifndef _UINT64_T -#define _UINT64_T -#if defined (NO_LONG_LONG) || ((ULONG_MAX >> 16) >> 16) == 0xffffffff -typedef unsigned long uint64_t; -#else -typedef unsigned long long uint64_t; -#endif -#endif /* _UINT64_T */ - -#endif /* _STDINT_H_ */ -#endif /* _STDINT_H */ -#endif /* _STDINT_H_INCLUDED */ -- 2.34.1