forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jwasm-2.10-types-test.patch
60 lines (56 loc) · 1.92 KB
/
jwasm-2.10-types-test.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From b19339d4356efbd9b49f73e67ed7c09b9dad4b75 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <[email protected]>
Date: Thu, 16 May 2013 12:24:17 +0300
Subject: [PATCH 1/2] types: add sanity tests for used sizes
Signed-off-by: Sergei Trofimovich <[email protected]>
---
GccUnix.mak | 2 +-
checks.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
create mode 100644 checks.c
diff --git a/GccUnix.mak b/GccUnix.mak
index 567b842..bcb2fef 100644
--- a/GccUnix.mak
+++ b/GccUnix.mak
@@ -44,7 +44,7 @@ proj_obj = $(OUTD)/main.o $(OUTD)/assemble.o $(OUTD)/assume.o \
$(OUTD)/apiemu.o $(OUTD)/dbgcv.o $(OUTD)/end.o \
$(OUTD)/backptch.o $(OUTD)/msgtext.o $(OUTD)/tbyte.o \
$(OUTD)/cpumodel.o $(OUTD)/safeseh.o $(OUTD)/cmdline.o \
- $(OUTD)/fastpass.o
+ $(OUTD)/fastpass.o $(OUTD)/checks.o
######
#.c.o:
diff --git a/checks.c b/checks.c
new file mode 100644
index 0000000..af8630f
--- /dev/null
+++ b/checks.c
@@ -0,0 +1,26 @@
+/****************************************************************************
+*
+* This code is Public Domain.
+*
+* ========================================================================
+*
+* Description: make sure "inttype.h" filelds are of the desired size.
+*
+****************************************************************************/
+
+#include "inttype.h"
+
+/* fails to compile if type sizes are of unexpected size */
+static void validate_inttype_sizes()
+{
+/* try to create */
+#define T_IS_SIZE(__type, __expected_size, __test_name) \
+ char __test_name[2 * (sizeof (__type) == (__expected_size)) - 1];
+
+ T_IS_SIZE(uint_8, 1, size_of_uint_8_must_be_1_byte);
+ T_IS_SIZE(uint_16, 2, size_of_uint_16_must_be_2_bytes);
+ T_IS_SIZE(uint_32, 4, size_of_uint_32_must_be_4_bytes);
+ T_IS_SIZE(uint_64, 8, size_of_uint_64_must_be_8_bytes);
+
+#undef T_IS_SIZE
+}
--
1.8.2.1