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--- 16 src/LibSupport.h | 21 +++------------------ 17 src/TcpServerPosix.c | 1 + 18 src/makefile | 2 ++ 19 3 files changed, 6 insertions(+), 18 deletions(-) 20 21diff --git a/src/LibSupport.h b/src/LibSupport.h 22index 5055560..48b1e16 100644 23--- a/src/LibSupport.h 24+++ b/src/LibSupport.h 25@@ -64,24 +64,9 @@ 26 #ifndef _LIB_SUPPORT_H_ 27 #define _LIB_SUPPORT_H_ 28 29-/* kgold added power and s390 */ 30-#ifndef RADIX_BITS 31-# if defined(__x86_64__) || defined(__x86_64) \ 32- || defined(__amd64__) || defined(__amd64) \ 33- || defined(_WIN64) || defined(_M_X64) \ 34- || defined(_M_ARM64) || defined(__aarch64__) \ 35- || defined(__powerpc64__) || defined(__PPC64__) || defined(__ppc64__) \ 36- || defined(__s390x__) 37-# define RADIX_BITS 64 38-# elif defined(__i386__) || defined(__i386) || defined(i386) \ 39- || defined(_WIN32) || defined(_M_IX86) \ 40- || defined(_M_ARM) || defined(__arm__) || defined(__thumb__) \ 41- || defined(__powerpc__) || defined(__PPC__) 42-# define RADIX_BITS 32 43-# else 44-# error Unable to determine RADIX_BITS from compiler environment 45-# endif 46-#endif // RADIX_BITS 47+#include <limits.h> 48+ 49+#define RADIX_BITS LONG_BIT 50 51 // These macros use the selected libraries to the proper include files. 52 #define LIB_QUOTE(_STRING_) #_STRING_ 53diff --git a/src/TcpServerPosix.c b/src/TcpServerPosix.c 54index cad0402..6293cdd 100644 55--- a/src/TcpServerPosix.c 56+++ b/src/TcpServerPosix.c 57@@ -66,6 +66,7 @@ 58 59 #include <stdio.h> 60 #include <stdbool.h> 61+#include <sys/select.h> 62 #include <unistd.h> 63 #include <sys/types.h> 64 #include <sys/socket.h> 65diff --git a/src/makefile b/src/makefile 66index f124e78..6ee128e 100644 67--- a/src/makefile 68+++ b/src/makefile 69@@ -46,6 +46,8 @@ CCFLAGS = -Wall \ 70 -c -ggdb -O0 \ 71 -DTPM_POSIX \ 72 -D_POSIX_ \ 73+ -D_DEFAULT_SOURCE \ 74+ -D_XOPEN_SOURCE=500 \ 75 -DTPM_NUVOTON 76 77 # add this line for big endian platforms 78-- 792.17.1 80 81