Index: trunk/config.auto.h.in =================================================================== --- trunk/config.auto.h.in (revision 2454) +++ trunk/config.auto.h.in (revision 2455) @@ -55,12 +55,6 @@ /* Define to 1 if you have the header file. */ #define HAVE_PWD_H 1 -/* Define to 1 if you have the `rand' function. */ -#define HAVE_RAND 1 - -/* Define to 1 if you have the `random' function. */ -#define HAVE_RANDOM 1 - /* Define to 1 if you have the `realpath' function. */ #define HAVE_REALPATH 1 Index: trunk/src/compat_misc.c =================================================================== --- trunk/src/compat_misc.c (revision 2454) +++ trunk/src/compat_misc.c (revision 2455) @@ -48,9 +48,18 @@ } #endif -#ifndef HAVE_RANDOM -long random(void) +/* On some old systems random() works better than rand(). Unfrtunately +random() is less portable than rand(), which is C89. By default, just +use rand(). Later on: scconfig should detect and enable random() if +we find a system where it really breaks. */ +#ifdef HAVE_RANDOM +long pcb_rand(void) { + return (long) random(); +} +#else +long pcb_rand(void) +{ return (long) rand(); } #endif Index: trunk/src/compat_misc.h =================================================================== --- trunk/src/compat_misc.h (revision 2454) +++ trunk/src/compat_misc.h (revision 2455) @@ -35,9 +35,7 @@ float logf(float); #endif -#ifndef HAVE_RANDOM -long random(void); -#endif +long pcb_random(void); const char *get_user_name(void); Index: trunk/src/object_act.c =================================================================== --- trunk/src/object_act.c (revision 2454) +++ trunk/src/object_act.c (revision 2455) @@ -568,8 +568,8 @@ d = parse_layout_attribute_units("import::disperse", d); if (d > 0) { - nx += rand() % (d * 2) - d; - ny += rand() % (d * 2) - d; + nx += pcb_rand() % (d * 2) - d; + ny += pcb_rand() % (d * 2) - d; } if (nx < 0) Index: trunk/src_plugins/autoroute/autoroute.c =================================================================== --- trunk/src_plugins/autoroute/autoroute.c (revision 2454) +++ trunk/src_plugins/autoroute/autoroute.c (revision 2455) @@ -4266,7 +4266,7 @@ * end at bigger ones. also prefer to start at planes, then pads */ heap_insert(net_heap, (float) (b.X2 - b.X1) * #if defined(ROUTE_RANDOMIZED) - (0.3 + rand() / (RAND_MAX + 1.0)) * + (0.3 + pcb_rand() / (RAND_MAX + 1.0)) * #endif (b.Y2 - b.Y1) * (p->type == PLANE ? -1 : (p->type == PAD ? 1 : 10)), p); } Index: trunk/src_plugins/export_png/png.c =================================================================== --- trunk/src_plugins/export_png/png.c (revision 2454) +++ trunk/src_plugins/export_png/png.c (revision 2455) @@ -834,7 +834,7 @@ else { rgb(&cop, 140, 150, 160); - r = (rand() % 5 - 2) * 2; + r = (pcb_rand() % 5 - 2) * 2; cop.r += r; cop.g += r; cop.b += r; Index: trunk/src_plugins/mincut/pcb-mincut/solve.c =================================================================== --- trunk/src_plugins/mincut/pcb-mincut/solve.c (revision 2454) +++ trunk/src_plugins/mincut/pcb-mincut/solve.c (revision 2455) @@ -42,7 +42,7 @@ static int pick_del(sstate_t *st) { int idx, ret, size; - idx = rand() % st->num_avail; + idx = pcb_rand() % st->num_avail; ret = st->avail[idx]; size = (st->num_avail-idx-1) * sizeof(int); if (size > 0) @@ -62,7 +62,7 @@ num_neigh++; } } - return st->neigh[rand() % num_neigh]; + return st->neigh[pcb_rand() % num_neigh]; } static void retag(sstate_t *st, int from, int to)