Index: trunk/config.auto.h.in =================================================================== --- trunk/config.auto.h.in (revision 2429) +++ trunk/config.auto.h.in (revision 2430) @@ -290,6 +290,9 @@ #include #endif +typedef @/local/pcb/coord_type@ Coord; +#define COORD_MAX @/local/pcb/coord_max@ +#define coord_abs @/local/pcb/coord_abs@ @] Index: trunk/scconfig/hooks.c =================================================================== --- trunk/scconfig/hooks.c (revision 2429) +++ trunk/scconfig/hooks.c (revision 2430) @@ -43,6 +43,7 @@ printf("options are:\n"); printf(" --prefix=path change installation prefix from /usr to path\n"); printf(" --debug configure for building a debug version (-g -O0)\n"); + printf(" --coord=32|64 set coordinate integer type's width in bits\n"); } static void help2(void) @@ -65,6 +66,15 @@ put("/local/pcb/debug", strue); 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); + return 1; + } if ((strcmp(key, "with-intl") == 0) || (strcmp(key, "enable-intl") == 0)) { want_intl = 1; return 1; @@ -102,6 +112,7 @@ #include "plugins.h" put("/local/pcb/debug", sfalse); + put("/local/pcb/coord_bits", "32"); return 0; } @@ -267,6 +278,7 @@ /* options for config.h */ require("sys/path_sep", 0, 1); + require("sys/types/size/*", 0, 1); require("cc/alloca/presents", 0, 0); require("cc/rdynamic", 0, 0); require("libs/env/putenv/presents", 0, 0); @@ -321,6 +333,29 @@ } } + /* figure coordinate bits */ + { + int want_c_bits = atoi(get("/local/pcb/coord_bits")); + int int_bits = atoi(get("sys/types/size/signed_int")) * 8; + int long_bits = atoi(get("sys/types/size/signed_long_int")) * 8; + int long_long_bits = atoi(get("sys/types/size/signed_long_long_int")) * 8; + const char *chosen, *abs_name, *postfix; + char tmp[64]; + + if (want_c_bits == int_bits) { postfix="U"; chosen = "int"; abs_name="abs"; } + else if (want_c_bits == long_bits) { postfix="UL"; chosen = "long int"; abs_name="labs"; } + else if (want_c_bits == long_long_bits) { postfix="ULL"; chosen = "long long int"; abs_name="llabs"; } + else { + report("ERROR: can't find a suitable integer type for coord to be %d bits wide\n", want_c_bits); + exit(1); + } + + sprintf(tmp, "((1%s<<%d)-1)", postfix, want_c_bits - 1); + put("/local/pcb/coord_type", chosen); + put("/local/pcb/coord_max", tmp); + put("/local/pcb/coord_abs", abs_name); + } + return 0; } @@ -387,6 +422,12 @@ printf("%-55s %s\n", desc, res); } +static void print_sum_cfg_val(const char *node, const char *desc) +{ + const char *state = get(node); + printf("%-55s %s\n", desc, state); +} + /* Runs after detection hooks, should generate the output (Makefiles, etc.) */ int hook_generate() { @@ -430,6 +471,7 @@ print_sum_setting("/local/pcb/want_parsgen", "Regenerating languages with bison & flex"); print_sum_setting("/local/pcb/want_nls", "Internationalization with gettext"); print_sum_setting("/local/pcb/debug", "Compilation for debugging"); + print_sum_cfg_val("/local/pcb/coord_bits", "Coordinate type bits"); #undef plugin_def #undef plugin_header @@ -446,7 +488,6 @@ else fprintf(stderr, "Error generating some of the files\n"); - return 0; } Index: trunk/src/global.h =================================================================== --- trunk/src/global.h (revision 2429) +++ trunk/src/global.h (revision 2430) @@ -558,12 +558,4 @@ #define AUSAGE(x) Message ("Usage:\n%s\n", (x##_syntax)) #define AFAIL(x) { Message ("Syntax error. Usage:\n%s\n", (x##_syntax)); return 1; } -#if COORD_MAX == LONG_MAX -#define coord_abs labs -#elif COORD_MAX == INT_MAX -#define coord_abs abs -#else -#error Can not find abs() for coord type. -#endif - #endif /* PCB_GLOBAL_H */ Index: trunk/src/unit.h =================================================================== --- trunk/src/unit.h (revision 2429) +++ trunk/src/unit.h (revision 2430) @@ -30,7 +30,7 @@ #include "config.h" -typedef COORD_TYPE Coord; /* pcb base unit */ +/* typedef ... Coord; pcb base unit, typedef'd in config.auto.h */ typedef double Angle; /* degrees */ enum e_allow {