Author: marvin
Date: Thu Jun 14 00:37:54 2012
New Revision: 1350067
URL: http://svn.apache.org/viewvc?rev=1350067&view=rev
Log:
Shorten symbols automatically.
Automatically generate a shortened version of every symbol added via
ConfWriter_add_def() amd ConfWriter_add_typedef(), removing the need for
individual Charmonizer modules to manage shortening manually.
Modified:
lucy/trunk/charmonizer/src/Charmonizer/Core/ConfWriter.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/AtomicOps.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/DirManip.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/Floats.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/Memory.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/SymbolVisibility.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.c
lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c
Modified: lucy/trunk/charmonizer/src/Charmonizer/Core/ConfWriter.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Core/ConfWriter.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Core/ConfWriter.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Core/ConfWriter.c Thu Jun 14
00:37:54 2012
@@ -222,8 +222,50 @@ ConfWriter_end_module(void) {
(int)defs[i].type);
}
}
- S_clear_def_list();
+
+ /* Write out short names. */
+ ConfWriter_append_conf(
+ "\n#if defined(CHY_USE_SHORT_NAMES) "
+ "|| defined(CHAZ_USE_SHORT_NAMES)\n"
+ );
+ for (i = 0; i < def_count; i++) {
+ switch (defs[i].type) {
+ case CONFELEM_DEF: {
+ const char *sym = defs[i].str1;
+ const char *value = defs[i].str2;
+ if (!value || strcmp(sym, value) != 0) {
+ const char *prefix = S_sym_is_uppercase(sym)
+ ? "CHY_" : "chy_";
+ ConfWriter_append_conf(" #define %s %s%s\n", sym,
+ prefix, sym);
+ }
+ }
+ break;
+ case CONFELEM_TYPEDEF: {
+ const char *sym = defs[i].str2;
+ const char *value = defs[i].str1;
+ if (strcmp(sym, value) != 0) {
+ const char *prefix = S_sym_is_uppercase(sym)
+ ? "CHY_" : "chy_";
+ ConfWriter_append_conf(" #define %s %s%s\n", sym,
+ prefix, sym);
+ }
+ }
+ break;
+ case CONFELEM_SYS_INCLUDE:
+ case CONFELEM_LOCAL_INCLUDE:
+ /* no-op */
+ break;
+ default:
+ Util_die("Internal error: bad element type %d",
+ (int)defs[i].type);
+ }
+ }
+
+ ConfWriter_append_conf("#endif /* USE_SHORT_NAMES */\n");
ConfWriter_append_conf("\n");
+
+ S_clear_def_list();
}
void
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/AtomicOps.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/AtomicOps.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/AtomicOps.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/AtomicOps.c Thu Jun 14
00:37:54 2012
@@ -68,22 +68,6 @@ AtomicOps_run(void) {
ConfWriter_add_def("HAS_INTRIN_H", NULL);
}
- /* Shorten */
- ConfWriter_start_short_names();
- if (has_libkern_osatomic_h) {
- ConfWriter_shorten_macro("HAS_LIBKERN_OSATOMIC_H");
- if (has_osatomic_cas_ptr) {
- ConfWriter_shorten_macro("HAS_OSATOMIC_CAS_PTR");
- }
- }
- if (has_sys_atomic_h) {
- ConfWriter_shorten_macro("HAS_SYS_ATOMIC_H");
- }
- if (has_intrin_h) {
- ConfWriter_shorten_macro("HAS_INTRIN_H");
- }
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/DirManip.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirManip.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/DirManip.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/DirManip.c Thu Jun 14 00:37:54
2012
@@ -200,14 +200,8 @@ DirManip_run(void) {
/* Shorten. */
ConfWriter_start_short_names();
ConfWriter_shorten_macro("DIR_SEP");
- if (has_dirent_h) { ConfWriter_shorten_macro("HAS_DIRENT_H"); }
- if (has_direct_h) { ConfWriter_shorten_macro("HAS_DIRECT_H"); }
- if (has_dirent_d_namlen) {
ConfWriter_shorten_macro("HAS_DIRENT_D_NAMLEN"); }
- if (has_dirent_d_type) { ConfWriter_shorten_macro("HAS_DIRENT_D_TYPE"); }
ConfWriter_shorten_function("makedir");
ConfWriter_shorten_macro("MAKEDIR_MODE_IGNORED");
- if (remove_zaps_dirs) { ConfWriter_shorten_macro("REMOVE_ZAPS_DIRS"); }
-
ConfWriter_end_short_names();
ConfWriter_end_module();
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/Floats.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/Floats.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/Floats.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/Floats.c Thu Jun 14 00:37:54
2012
@@ -45,16 +45,6 @@ Floats_run(void) {
ConfWriter_add_def("F64_NEGINF", "(chy_f64neginf.d)");
ConfWriter_add_def("F64_NAN", "(chy_f64nan.d)");
- /* Shorten. */
- ConfWriter_start_short_names();
- ConfWriter_shorten_macro("F32_INF");
- ConfWriter_shorten_macro("F32_NEGINF");
- ConfWriter_shorten_macro("F32_NAN");
- ConfWriter_shorten_macro("F64_INF");
- ConfWriter_shorten_macro("F64_NEGINF");
- ConfWriter_shorten_macro("F64_NAN");
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c Thu Jun 14
00:37:54 2012
@@ -129,21 +129,6 @@ FuncMacro_run(void) {
ConfWriter_add_def("INLINE", NULL);
}
- /* Shorten. */
- ConfWriter_start_short_names();
- if (has_iso_funcmac) {
- ConfWriter_shorten_macro("HAS_ISO_FUNC_MACRO");
- }
- if (has_gnuc_funcmac) {
- ConfWriter_shorten_macro("HAS_GNUC_FUNC_MACRO");
- }
- if (has_iso_funcmac || has_gnuc_funcmac) {
- ConfWriter_shorten_macro("HAS_FUNC_MACRO");
- ConfWriter_shorten_macro("FUNC_MACRO");
- }
- ConfWriter_shorten_macro("INLINE");
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.c Thu Jun 14 00:37:54
2012
@@ -168,21 +168,6 @@ Headers_run(void) {
ConfWriter_add_def(aff_buf, NULL);
}
- /* Shorten. */
- ConfWriter_start_short_names();
- if (has_posix) {
- ConfWriter_shorten_macro("HAS_POSIX");
- }
- if (has_c89) {
- ConfWriter_shorten_macro("HAS_C89");
- ConfWriter_shorten_macro("HAS_C90");
- }
- for (i = 0; keepers[i] != NULL; i++) {
- S_encode_affirmation(keepers[i]);
- ConfWriter_shorten_macro(aff_buf);
- }
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c Thu Jun 14 00:37:54
2012
@@ -401,72 +401,6 @@ Integers_run(void) {
"#endif\n"
);
- /* Shorten. */
- ConfWriter_start_short_names();
- if (S_machine_is_big_endian()) {
- ConfWriter_shorten_macro("BIG_END");
- }
- else {
- ConfWriter_shorten_macro("LITTLE_END");
- }
- ConfWriter_shorten_macro("SIZEOF_CHAR");
- ConfWriter_shorten_macro("SIZEOF_SHORT");
- ConfWriter_shorten_macro("SIZEOF_LONG");
- ConfWriter_shorten_macro("SIZEOF_INT");
- ConfWriter_shorten_macro("SIZEOF_PTR");
- if (has_long_long) {
- ConfWriter_shorten_macro("HAS_LONG_LONG");
- ConfWriter_shorten_macro("SIZEOF_LONG_LONG");
- }
- if (has___int64) {
- ConfWriter_shorten_macro("HAS___INT64");
- ConfWriter_shorten_macro("SIZEOF___INT64");
- }
- if (has_inttypes) {
- ConfWriter_shorten_macro("HAS_INTTYPES_H");
- }
- ConfWriter_shorten_typedef("bool_t");
- if (has_8) {
- ConfWriter_shorten_macro("HAS_I8_T");
- ConfWriter_shorten_typedef("i8_t");
- ConfWriter_shorten_typedef("u8_t");
- ConfWriter_shorten_macro("I8_MAX");
- ConfWriter_shorten_macro("I8_MIN");
- ConfWriter_shorten_macro("U8_MAX");
- }
- if (has_16) {
- ConfWriter_shorten_macro("HAS_I16_T");
- ConfWriter_shorten_typedef("i16_t");
- ConfWriter_shorten_typedef("u16_t");
- ConfWriter_shorten_macro("I16_MAX");
- ConfWriter_shorten_macro("I16_MIN");
- ConfWriter_shorten_macro("U16_MAX");
- }
- if (has_32) {
- ConfWriter_shorten_macro("HAS_I32_T");
- ConfWriter_shorten_typedef("i32_t");
- ConfWriter_shorten_typedef("u32_t");
- ConfWriter_shorten_macro("I32_MAX");
- ConfWriter_shorten_macro("I32_MIN");
- ConfWriter_shorten_macro("U32_MAX");
- ConfWriter_shorten_macro("I32_C");
- ConfWriter_shorten_macro("U32_C");
- }
- if (has_64) {
- ConfWriter_shorten_macro("HAS_I64_T");
- ConfWriter_shorten_typedef("i64_t");
- ConfWriter_shorten_typedef("u64_t");
- ConfWriter_shorten_macro("I64_MAX");
- ConfWriter_shorten_macro("I64_MIN");
- ConfWriter_shorten_macro("U64_MAX");
- ConfWriter_shorten_macro("I64P");
- ConfWriter_shorten_macro("U64P");
- ConfWriter_shorten_macro("I64_C");
- ConfWriter_shorten_macro("U64_C");
- ConfWriter_shorten_macro("PTR_TO_I64");
- }
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c Thu Jun 14
00:37:54 2012
@@ -168,40 +168,6 @@ LargeFiles_run(void) {
ConfWriter_append_conf("#define CHAZ_HAS_STAT_ST_BLOCKS\n");
}
- /* Short names. */
- ConfWriter_start_short_names();
- if (found_off64_t) {
- ConfWriter_shorten_macro("HAS_64BIT_OFFSET_TYPE");
- if (strcmp(off64_type, "off64_t") != 0) {
- ConfWriter_shorten_typedef("off64_t");
- }
- }
- if (found_stdio64) {
- ConfWriter_shorten_macro("HAS_64BIT_STDIO");
- if (strcmp(fopen_command, "fopen64") != 0) {
- ConfWriter_shorten_function("fopen64");
- }
- if (strcmp(fopen_command, "ftello64") != 0) {
- ConfWriter_shorten_function("ftello64");
- }
- if (strcmp(fopen_command, "fseeko64") != 0) {
- ConfWriter_shorten_function("fseeko64");
- }
- }
- if (found_lseek) {
- ConfWriter_shorten_macro("HAS_64BIT_LSEEK");
- if (strcmp(lseek_command, "lseek64") != 0) {
- ConfWriter_shorten_function("lseek64");
- }
- }
- if (found_pread64) {
- ConfWriter_shorten_macro("HAS_64BIT_PREAD");
- if (strcmp(pread64_command, "pread64") != 0) {
- ConfWriter_shorten_function("pread64");
- }
- }
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/Memory.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/Memory.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/Memory.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/Memory.c Thu Jun 14 00:37:54
2012
@@ -106,28 +106,6 @@ Memory_run(void) {
}
}
- /* Shorten */
- ConfWriter_start_short_names();
- if (has_sys_mman_h) {
- ConfWriter_shorten_macro("HAS_SYS_MMAN_H");
- }
- if (has_alloca_h) {
- ConfWriter_shorten_macro("HAS_ALLOCA_H");
- }
- if (has_malloc_h) {
- ConfWriter_shorten_macro("HAS_MALLOC_H");
- if (!has_alloca && has_underscore_alloca) {
- ConfWriter_shorten_function("alloca");
- }
- }
- if (need_stdlib_h) {
- ConfWriter_shorten_macro("ALLOCA_IN_STDLIB_H");
- }
- if (!has_alloca && has_builtin_alloca) {
- ConfWriter_shorten_function("alloca");
- }
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/SymbolVisibility.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/SymbolVisibility.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/SymbolVisibility.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/SymbolVisibility.c Thu Jun 14
00:37:54 2012
@@ -69,12 +69,6 @@ SymbolVisibility_run(void) {
ConfWriter_add_def("IMPORT", NULL);
}
- /* Shorten */
- ConfWriter_start_short_names();
- ConfWriter_shorten_macro("EXPORT");
- ConfWriter_shorten_macro("IMPORT");
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.c Thu Jun 14
00:37:54 2012
@@ -31,12 +31,6 @@ UnusedVars_run(void) {
ConfWriter_add_def("UNUSED_VAR(x)", "((void)x)");
ConfWriter_add_def("UNREACHABLE_RETURN(type)", "return (type)0");
- /* Shorten. */
- ConfWriter_start_short_names();
- ConfWriter_shorten_macro("UNUSED_VAR");
- ConfWriter_shorten_macro("UNREACHABLE_RETURN");
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}
Modified: lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c?rev=1350067&r1=1350066&r2=1350067&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c Thu Jun 14
00:37:54 2012
@@ -75,19 +75,6 @@ VariadicMacros_run(void) {
ConfWriter_add_def("HAS_GNUC_VARIADIC_MACROS", NULL);
}
- /* Shorten. */
- ConfWriter_start_short_names();
- if (has_varmacros) {
- ConfWriter_shorten_macro("HAS_VARIADIC_MACROS");
- }
- if (has_iso_varmacros) {
- ConfWriter_shorten_macro("HAS_ISO_VARIADIC_MACROS");
- }
- if (has_gnuc_varmacros) {
- ConfWriter_shorten_macro("HAS_GNUC_VARIADIC_MACROS");
- }
- ConfWriter_end_short_names();
-
ConfWriter_end_module();
}