Index: trunk/scconfig/hooks.c =================================================================== --- trunk/scconfig/hooks.c (revision 30881) +++ trunk/scconfig/hooks.c (revision 30882) @@ -18,10 +18,8 @@ #include "librnd/scconfig/plugin_3state.h" #include "librnd/scconfig/hooks_common.h" #include "librnd/scconfig/hooks_gui.c" +#include "librnd/scconfig/rnd_hook_detect.h" - -int want_coord_bits; - const arg_auto_set_t disable_libs[] = { /* list of --disable-LIBs and the subtree they affect */ {"disable-xrender", "libs/gui/xrender", arg_lib_nodes, "$do not use xrender for lesstif"}, {"disable-xinerama", "libs/gui/xinerama", arg_lib_nodes, "$do not use xinerama for lesstif"}, @@ -62,17 +60,6 @@ { rnd_hook_custom_arg(key, value); - if (strcmp(key, "coord") == 0) { - int v = atoi(value); - if ((v != 32) && (v != 64)) { - report("ERROR: --coord needs to be 32 or 64.\n"); - exit(1); - } - put("/local/pcb/coord_bits", value); - want_coord_bits = v; - return 1; - } - if (strcmp(key, "dot_pcb_rnd") == 0) { put("/local/pcb/dot_pcb_rnd", value); return 1; @@ -103,8 +90,6 @@ put("/local/pcb/want_bison", sfalse); put("/local/pcb/want_byaccic", sfalse); - put("/local/pcb/coord_bits", "32"); - want_coord_bits = 32; put("/local/pcb/dot_pcb_rnd", ".pcb-rnd"); return 0; @@ -530,48 +515,8 @@ /* plugin dependencies */ plugin_deps(1); - /* figure coordinate bits */ - { - int int_bits = safe_atoi(get("sys/types/size/signed_int")) * 8; - int long_bits = safe_atoi(get("sys/types/size/signed_long_int")) * 8; - int long_long_bits = safe_atoi(get("sys/types/size/signed_long_long_int")) * 8; - int int64_bits = safe_atoi(get("sys/types/size/uint64_t")) * 8; - const char *chosen, *postfix; - char tmp[64]; - int need_stdint = 0; + rnd_hook_detect_coord_bits(); /* remove this after the librnd split */ - if (want_coord_bits == int_bits) { postfix="U"; chosen = "int"; } - else if (want_coord_bits == long_bits) { postfix="UL"; chosen = "long int"; } - else if (want_coord_bits == int64_bits) { postfix="ULL"; chosen = "int64_t"; need_stdint = 1; } - else if (want_coord_bits == long_long_bits) { postfix="ULL"; chosen = "long long int"; } - else { - report("ERROR: can't find a suitable integer type for coord to be %d bits wide\n", want_coord_bits); - exit(1); - } - - sprintf(tmp, "((1%s<<%d)-1)", postfix, want_coord_bits - 1); - put("/local/pcb/coord_type", chosen); - put("/local/pcb/coord_max", tmp); - - chosen = NULL; - if (istrue(get("/local/pcb/debug"))) { /* debug: c89 */ - if (int64_bits >= 64) { - /* to suppress warnings on systems that support c99 but are forced to compile in c89 mode */ - chosen = "int64_t"; - need_stdint = 1; - } - } - - if (chosen == NULL) { /* non-debug, thus non-c89 */ - if (long_long_bits >= 64) chosen = "long long int"; - else if (long_bits >= 64) chosen = "long int"; - else chosen = "double"; - } - put("/local/pcb/long64", chosen); - if (need_stdint) - put("/local/pcb/include_stdint", "#include "); - } - /* set cflags for C89 */ put("/local/pcb/c89flags", ""); if (istrue(get("/local/pcb/debug"))) { Index: trunk/scconfig/librnd/scconfig/hooks_common.h =================================================================== --- trunk/scconfig/librnd/scconfig/hooks_common.h (revision 30881) +++ trunk/scconfig/librnd/scconfig/hooks_common.h (revision 30882) @@ -3,9 +3,9 @@ const arg_auto_set_t disable_libs[]; int hook_custom_arg(const char *key, const char *value); +/*** implementation ***/ +int want_coord_bits; - -/*** implementation ***/ static void all_plugin_select(const char *state, int force); static void rnd_help1(const char *progname) @@ -112,6 +112,16 @@ report("ERROR: --with-intl is no longer supported, please do not use it\n"); return 1; } + if (strcmp(key, "coord") == 0) { + int v = atoi(value); + if ((v != 32) && (v != 64)) { + report("ERROR: --coord needs to be 32 or 64.\n"); + exit(1); + } + put("/local/pcb/coord_bits", value); + want_coord_bits = v; + return 1; + } return 0; } @@ -248,6 +258,8 @@ #define plugin_dep(plg, on, hidlib) #include "plugins.h" + put("/local/pcb/coord_bits", "32"); + want_coord_bits = 32; } Index: trunk/scconfig/librnd/scconfig/rnd_hook_detect.h =================================================================== --- trunk/scconfig/librnd/scconfig/rnd_hook_detect.h (nonexistent) +++ trunk/scconfig/librnd/scconfig/rnd_hook_detect.h (revision 30882) @@ -0,0 +1,44 @@ +extern int want_coord_bits; + + /* figure coordinate bits */ +static void rnd_hook_detect_coord_bits(void) +{ + int int_bits = safe_atoi(get("sys/types/size/signed_int")) * 8; + int long_bits = safe_atoi(get("sys/types/size/signed_long_int")) * 8; + int long_long_bits = safe_atoi(get("sys/types/size/signed_long_long_int")) * 8; + int int64_bits = safe_atoi(get("sys/types/size/uint64_t")) * 8; + const char *chosen, *postfix; + char tmp[64]; + int need_stdint = 0; + + if (want_coord_bits == int_bits) { postfix="U"; chosen = "int"; } + else if (want_coord_bits == long_bits) { postfix="UL"; chosen = "long int"; } + else if (want_coord_bits == int64_bits) { postfix="ULL"; chosen = "int64_t"; need_stdint = 1; } + else if (want_coord_bits == long_long_bits) { postfix="ULL"; chosen = "long long int"; } + else { + report("ERROR: can't find a suitable integer type for coord to be %d bits wide\n", want_coord_bits); + exit(1); + } + + sprintf(tmp, "((1%s<<%d)-1)", postfix, want_coord_bits - 1); + put("/local/pcb/coord_type", chosen); + put("/local/pcb/coord_max", tmp); + + chosen = NULL; + if (istrue(get("/local/pcb/debug"))) { /* debug: c89 */ + if (int64_bits >= 64) { + /* to suppress warnings on systems that support c99 but are forced to compile in c89 mode */ + chosen = "int64_t"; + need_stdint = 1; + } + } + + if (chosen == NULL) { /* non-debug, thus non-c89 */ + if (long_long_bits >= 64) chosen = "long long int"; + else if (long_bits >= 64) chosen = "long int"; + else chosen = "double"; + } + put("/local/pcb/long64", chosen); + if (need_stdint) + put("/local/pcb/include_stdint", "#include "); +}