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