88 lines
2.8 KiB
Diff
88 lines
2.8 KiB
Diff
From 7ea7fe229ea6195938d9eadbe783cb1aa74380ba Mon Sep 17 00:00:00 2001
|
|
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
|
Date: Sun, 26 Apr 2020 15:33:39 +0200
|
|
Subject: [PATCH] Use LONG_BIT to define RADIX_BITS
|
|
|
|
This allows to avoid having to support each CPU architecture
|
|
individually.
|
|
|
|
Also, add the necessary defines in the makefile to expose
|
|
LONG_BIT. Adding those defines end up requiring using <sys/select.h>
|
|
as we're now using >= POSIX.1-2001 definitions of fd_set and friends.
|
|
|
|
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
|
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
|
|
[Bernd: rebased for git rev 5452af422edeff70fcae8ea99dd28a0922051d7b]
|
|
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
|
|
[Fabrice: rebase for rev183-2024-03-27]
|
|
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
|
---
|
|
src/LibSupport.h | 21 +++------------------
|
|
src/TcpServerPosix.c | 1 +
|
|
src/makefile | 2 ++
|
|
3 files changed, 6 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/src/tpm_radix.h b/src/tpm_radix.h
|
|
index 5055560..48b1e16 100644
|
|
--- a/src/tpm_radix.h
|
|
+++ b/src/tpm_radix.h
|
|
@@ -61,27 +61,9 @@
|
|
//** Introduction
|
|
// Common defines for supporting large numbers and cryptographic buffer sizing.
|
|
//*********************
|
|
-#ifndef RADIX_BITS
|
|
-# if defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
|
|
- || defined(__amd64) || defined(_WIN64) || defined(_M_X64) || defined(_M_ARM64) \
|
|
- || defined(__aarch64__) || defined(__PPC64__) || defined(__s390x__) \
|
|
- || defined(__powerpc64__) || defined(__ppc64__)
|
|
-# define RADIX_BITS 64
|
|
-# elif defined(__i386__) || defined(__i386) || defined(i386) || defined(_WIN32) \
|
|
- || defined(_M_IX86)
|
|
-# define RADIX_BITS 32
|
|
-# elif defined(_M_ARM) || defined(__arm__) || defined(__thumb__)
|
|
-# define RADIX_BITS 32
|
|
-# elif defined(__riscv)
|
|
-// __riscv and __riscv_xlen are standardized by the RISC-V community and should be available
|
|
-// on any compliant compiler.
|
|
-//
|
|
-// https://github.com/riscv-non-isa/riscv-toolchain-conventions
|
|
-# define RADIX_BITS __riscv_xlen
|
|
-# else
|
|
-# error Unable to determine RADIX_BITS from compiler environment
|
|
-# endif
|
|
-#endif // RADIX_BITS
|
|
+#include <limits.h>
|
|
+
|
|
+#define RADIX_BITS LONG_BIT
|
|
|
|
#if RADIX_BITS == 64
|
|
# define RADIX_BYTES 8
|
|
diff --git a/src/TcpServerPosix.c b/src/TcpServerPosix.c
|
|
index cad0402..6293cdd 100644
|
|
--- a/src/TcpServerPosix.c
|
|
+++ b/src/TcpServerPosix.c
|
|
@@ -66,6 +66,7 @@
|
|
|
|
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
+#include <sys/select.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
diff --git a/src/makefile b/src/makefile
|
|
index f124e78..6ee128e 100644
|
|
--- a/src/makefile
|
|
+++ b/src/makefile
|
|
@@ -47,6 +47,8 @@ CCFLAGS = -Wall \
|
|
-c -ggdb -O0 \
|
|
-DTPM_POSIX \
|
|
-D_POSIX_ \
|
|
+ -D_DEFAULT_SOURCE \
|
|
+ -D_XOPEN_SOURCE=500 \
|
|
-DTPM_NUVOTON
|
|
|
|
# add this line for big endian platforms
|
|
--
|
|
2.17.1
|
|
|