1From 7ea7fe229ea6195938d9eadbe783cb1aa74380ba Mon Sep 17 00:00:00 2001 2From: Thomas Petazzoni <thomas.petazzoni@bootlin.com> 3Date: Sun, 26 Apr 2020 15:33:39 +0200 4Subject: [PATCH] Use LONG_BIT to define RADIX_BITS 5 6This allows to avoid having to support each CPU architecture 7individually. 8 9Also, add the necessary defines in the makefile to expose 10LONG_BIT. Adding those defines end up requiring using <sys/select.h> 11as we're now using >= POSIX.1-2001 definitions of fd_set and friends. 12 13Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> 14Signed-off-by: Vincent Fazio <vfazio@gmail.com> 15[Bernd: rebased for git rev 5452af422edeff70fcae8ea99dd28a0922051d7b] 16Signed-off-by: Bernd Kuhls <bernd@kuhls.net> 17--- 18 src/LibSupport.h | 21 +++------------------ 19 src/TcpServerPosix.c | 1 + 20 src/makefile | 2 ++ 21 3 files changed, 6 insertions(+), 18 deletions(-) 22 23diff --git a/src/LibSupport.h b/src/LibSupport.h 24index 5055560..48b1e16 100644 25--- a/src/LibSupport.h 26+++ b/src/LibSupport.h 27@@ -64,32 +64,9 @@ 28 #ifndef _LIB_SUPPORT_H_ 29 #define _LIB_SUPPORT_H_ 30 31-/* kgold added power and s390 */ 32-#ifndef RADIX_BITS 33-# if defined(__x86_64__) || defined(__x86_64) \ 34- || defined(__amd64__) || defined(__amd64) \ 35- || defined(_WIN64) || defined(_M_X64) \ 36- || defined(_M_ARM64) || defined(__aarch64__) \ 37- || defined(__powerpc64__) || defined(__PPC64__) || defined(__ppc64__) \ 38- || defined(__s390x__) 39-# define RADIX_BITS 64 40-# elif defined(__i386__) || defined(__i386) || defined(i386) \ 41- || defined(_WIN32) || defined(_M_IX86) \ 42- || defined(_M_ARM) || defined(__arm__) || defined(__thumb__) \ 43- || defined(__powerpc__) || defined(__PPC__) 44-# define RADIX_BITS 32 45-# elif defined(__riscv) || defined(__riscv__) 46-# if __riscv_xlen == 32 47-# define RADIX_BITS 32 48-# elif __riscv_xlen == 64 49-# define RADIX_BITS 64 50-# else 51-# error Unsupported __riscv_xlen value 52-# endif 53-# else 54-# error Unable to determine RADIX_BITS from compiler environment 55-# endif 56-#endif // RADIX_BITS 57+#include <limits.h> 58+ 59+#define RADIX_BITS LONG_BIT 60 61 // These macros use the selected libraries to the proper include files. 62 #define LIB_QUOTE(_STRING_) #_STRING_ 63diff --git a/src/TcpServerPosix.c b/src/TcpServerPosix.c 64index cad0402..6293cdd 100644 65--- a/src/TcpServerPosix.c 66+++ b/src/TcpServerPosix.c 67@@ -66,6 +66,7 @@ 68 69 #include <stdio.h> 70 #include <stdbool.h> 71+#include <sys/select.h> 72 #include <unistd.h> 73 #include <sys/types.h> 74 #include <sys/socket.h> 75diff --git a/src/makefile b/src/makefile 76index f124e78..6ee128e 100644 77--- a/src/makefile 78+++ b/src/makefile 79@@ -47,6 +47,8 @@ CCFLAGS = -Wall \ 80 -c -ggdb -O0 \ 81 -DTPM_POSIX \ 82 -D_POSIX_ \ 83+ -D_DEFAULT_SOURCE \ 84+ -D_XOPEN_SOURCE=500 \ 85 -DTPM_NUVOTON 86 87 # add this line for big endian platforms 88-- 892.17.1 90 91