You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2012/11/18 19:46:19 UTC
[lucy-commits] [16/23] git commit: refs/heads/c99-types - Remove old integer
typedefs and macros
Remove old integer typedefs and macros
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/8d1efb04
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/8d1efb04
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/8d1efb04
Branch: refs/heads/c99-types
Commit: 8d1efb04635fc317900544e8220901e649e659e7
Parents: 13b4b04
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Nov 17 23:19:27 2012 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sun Nov 18 16:36:32 2012 +0100
----------------------------------------------------------------------
charmonizer/src/Charmonizer/Probe/Integers.c | 86 ++++--------------
charmonizer/src/Charmonizer/Probe/Integers.h | 52 ++---------
charmonizer/src/Charmonizer/Test/TestIntegers.c | 8 +-
3 files changed, 29 insertions(+), 117 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/8d1efb04/charmonizer/src/Charmonizer/Probe/Integers.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/Integers.c b/charmonizer/src/Charmonizer/Probe/Integers.c
index f3f5dce..37a6090 100644
--- a/charmonizer/src/Charmonizer/Probe/Integers.c
+++ b/charmonizer/src/Charmonizer/Probe/Integers.c
@@ -254,7 +254,21 @@ chaz_Integers_run(void) {
chaz_ConfWriter_add_def("SIZEOF___INT64", scratch);
}
- /* Write affirmations, typedefs and maximums/minimums. */
+ /* Write affirmations. */
+ if (has_8) {
+ chaz_ConfWriter_add_def("HAS_INT8_T", NULL);
+ }
+ if (has_16) {
+ chaz_ConfWriter_add_def("HAS_INT16_T", NULL);
+ }
+ if (has_32) {
+ chaz_ConfWriter_add_def("HAS_INT32_T", NULL);
+ }
+ if (has_64) {
+ chaz_ConfWriter_add_def("HAS_INT64_T", NULL);
+ }
+
+ /* Write typedefs, maximums/minimums and literals macros. */
chaz_ConfWriter_add_typedef("int", "bool_t");
if (has_stdint) {
chaz_ConfWriter_add_sys_include("stdint.h");
@@ -334,51 +348,6 @@ chaz_Integers_run(void) {
}
chaz_ConfWriter_add_global_def("SIZE_MAX", "((size_t)-1)");
}
- if (has_8) {
- chaz_ConfWriter_add_def("HAS_I8_T", NULL);
- chaz_ConfWriter_add_typedef("signed char", "i8_t");
- chaz_ConfWriter_add_typedef("unsigned char", "u8_t");
- /* FIXME: use integer literals. */
- chaz_ConfWriter_add_def("I8_MAX", "0x7F");
- chaz_ConfWriter_add_def("I8_MIN", "(-I8_MAX - 1)");
- chaz_ConfWriter_add_def("U8_MAX", "(I8_MAX * 2 + 1)");
- }
- if (has_16) {
- chaz_ConfWriter_add_def("HAS_I16_T", NULL);
- chaz_ConfWriter_add_typedef("short", "i16_t");
- chaz_ConfWriter_add_typedef("unsigned short", "u16_t");
- /* FIXME: use integer literals. */
- chaz_ConfWriter_add_def("I16_MAX", "0x7FFF");
- chaz_ConfWriter_add_def("I16_MIN", "(-I16_MAX - 1)");
- chaz_ConfWriter_add_def("U16_MAX", "(I16_MAX * 2 + 1)");
- }
- if (has_32) {
- chaz_ConfWriter_add_def("HAS_I32_T", NULL);
- chaz_ConfWriter_add_typedef(i32_t_type, "i32_t");
- sprintf(scratch, "unsigned %s", i32_t_type);
- chaz_ConfWriter_add_typedef(scratch, "u32_t");
- /* FIXME: use integer literals. */
- sprintf(scratch, "0x7FFFFFFF%s", i32_t_postfix);
- chaz_ConfWriter_add_def("I32_MAX", scratch);
- chaz_ConfWriter_add_def("I32_MIN", "(-I32_MAX - 1)");
- sprintf(scratch, "(I32_MAX * 2%s + 1%s)", u32_t_postfix,
- u32_t_postfix);
- chaz_ConfWriter_add_def("U32_MAX", scratch);
- }
- if (has_64) {
- chaz_ConfWriter_add_def("HAS_I64_T", NULL);
- chaz_ConfWriter_add_typedef(i64_t_type, "i64_t");
- sprintf(scratch, "unsigned %s", i64_t_type);
- chaz_ConfWriter_add_typedef(scratch, "u64_t");
- /* FIXME: use integer literals. */
- sprintf(scratch, "0x7FFFFFFFFFFFFFFF%s", i64_t_postfix);
- chaz_ConfWriter_add_def("I64_MAX", scratch);
- sprintf(scratch, "(-I64_MAX - 1%s)", i64_t_postfix);
- chaz_ConfWriter_add_def("I64_MIN", scratch);
- sprintf(scratch, "(I64_MAX * 2%s + 1%s)", u64_t_postfix,
- u64_t_postfix);
- chaz_ConfWriter_add_def("U64_MAX", scratch);
- }
/* Create the I64P and U64P printf macros. */
if (has_64) {
@@ -419,36 +388,15 @@ chaz_Integers_run(void) {
}
- /* Write out the 32-bit and 64-bit literal macros. */
- if (has_32) {
- if (strcmp(i32_t_postfix, "") == 0) {
- chaz_ConfWriter_add_def("I32_C(n)", "n");
- sprintf(scratch, "n##%s", u32_t_postfix);
- chaz_ConfWriter_add_def("U32_C(n)", scratch);
- }
- else {
- sprintf(scratch, "n##%s", i32_t_postfix);
- chaz_ConfWriter_add_def("I32_C(n)", scratch);
- sprintf(scratch, "n##%s", u32_t_postfix);
- chaz_ConfWriter_add_def("U32_C(n)", scratch);
- }
- }
- if (has_64) {
- sprintf(scratch, "n##%s", i64_t_postfix);
- chaz_ConfWriter_add_def("I64_C(n)", scratch);
- sprintf(scratch, "n##%s", u64_t_postfix);
- chaz_ConfWriter_add_def("U64_C(n)", scratch);
- }
-
/* Create macro for promoting pointers to integers. */
if (has_64) {
if (sizeof_ptr == 8) {
chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
- "((chy_i64_t)(chy_u64_t)(ptr))");
+ "((int64_t)(uint64_t)(ptr))");
}
else {
chaz_ConfWriter_add_def("PTR_TO_I64(ptr)",
- "((chy_i64_t)(chy_u32_t)(ptr))");
+ "((int64_t)(uint32_t)(ptr))");
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/8d1efb04/charmonizer/src/Charmonizer/Probe/Integers.h
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/Integers.h b/charmonizer/src/Charmonizer/Probe/Integers.h
index 22766fe..edc2fa2 100644
--- a/charmonizer/src/Charmonizer/Probe/Integers.h
+++ b/charmonizer/src/Charmonizer/Probe/Integers.h
@@ -76,44 +76,16 @@
* UINT32_C
* UINT64_C
*
- * The following typedefs will be created if a suitable integer type exists,
- * as will most often be the case. However, if for example a char is 64 bits
- * (as on certain Crays), no 8-bit types will be defined, or if no 64-bit
- * integer type is available, no 64-bit types will be defined, etc.
+ * The following typedefs will be created:
*
* bool_t
- * i8_t
- * u8_t
- * i16_t
- * u16_t
- * i32_t
- * u32_t
- * i64_t
- * u64_t
- *
- * Availability of the preceding integer typedefs is indicated by which of
- * these are defined:
- *
- * HAS_I8_T
- * HAS_I16_T
- * HAS_I32_T
- * HAS_I64_T
- *
- * Maximums will be defined for all available integer types (save bool_t), and
- * minimums for all available signed types.
- *
- * I8_MAX
- * U8_MAX
- * I16_MAX
- * U16_MAX
- * I32_MAX
- * U32_MAX
- * I64_MAX
- * U64_MAX
- * I8_MIN
- * I16_MIN
- * I32_MIN
- * I64_MIN
+ *
+ * Availability of integer types is indicated by which of these are defined:
+ *
+ * HAS_INT8_T
+ * HAS_INT16_T
+ * HAS_INT32_T
+ * HAS_INT64_T
*
* If 64-bit integers are available, this macro will promote pointers to i64_t
* safely.
@@ -127,14 +99,6 @@
* I64P
* U64P
*
- * 32-bit and 64-bit literals can be spec'd via these macros, which append the
- * appropriate postfix:
- *
- * I32_C(n)
- * U32_C(n)
- * I64_C(n)
- * U64_C(n)
- *
* These symbols will be defined if they are not already:
*
* true
http://git-wip-us.apache.org/repos/asf/lucy/blob/8d1efb04/charmonizer/src/Charmonizer/Test/TestIntegers.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Test/TestIntegers.c b/charmonizer/src/Charmonizer/Test/TestIntegers.c
index 7f5d549..ffef508 100644
--- a/charmonizer/src/Charmonizer/Test/TestIntegers.c
+++ b/charmonizer/src/Charmonizer/Test/TestIntegers.c
@@ -55,7 +55,7 @@ S_run_tests(TestBatch *batch) {
OK(the_truth, "bool_t true");
OK(!false, "false is false");
}
-#ifdef HAS_I8_T
+#ifdef HAS_INT8_T
{
int8_t foo = -100;
uint8_t bar = 200;
@@ -68,7 +68,7 @@ S_run_tests(TestBatch *batch) {
LONG_EQ(UINT8_MAX, 255, "UINT8_MAX");
}
#endif
-#ifdef HAS_I16_T
+#ifdef HAS_INT16_T
{
int16_t foo = -100;
uint16_t bar = 30000;
@@ -81,7 +81,7 @@ S_run_tests(TestBatch *batch) {
LONG_EQ(UINT16_MAX, 65535, "UINT16_MAX");
}
#endif
-#ifdef HAS_I32_T
+#ifdef HAS_INT32_T
{
int32_t foo = -100;
uint32_t bar = 4000000000UL;
@@ -95,7 +95,7 @@ S_run_tests(TestBatch *batch) {
OK((UINT32_MAX == UINT32_C(4294967295)), "UINT32_MAX");
}
#endif
-#ifdef HAS_I64_T
+#ifdef HAS_INT64_T
{
char buf[100];
int64_t foo = -100;