diff --git a/Makefile b/Makefile index 9abcef499500fb50b5fb67317cdf5dd001df34a6..c42fa7105b433d37b0db906c1e87e65bb8e969a9 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,6 @@ UTILSOBJ = $(TARGET_DIR)/utils/sysdevs.o \ $(TARGET_DIR)/utils/strings.o \ $(TARGET_DIR)/utils/strlist.o \ $(TARGET_DIR)/utils/newasm.o \ - $(TARGET_DIR)/utils/rnd.o \ $(TARGET_DIR)/utils/regex.o \ $(TARGET_DIR)/utils/p2c.o \ diff --git a/include/log_action.h b/include/log_action.h index d497c141cd588020bf0ebfca5d3d5ca56579aea9..135a7cee1ba06b9336087801ee2e0fc0bd78f257 100644 --- a/include/log_action.h +++ b/include/log_action.h @@ -310,8 +310,6 @@ typedef struct log_action_t FILE **tracefile; - long rndseed; /** Seed for RAND funtion */ - char *homedirname; enum diff --git a/include/logsim.h b/include/logsim.h index 3abc8d2835895e9f8a5f0c43cb5d1ccb722a5e07..c66da0795fd5508b06fec0367e7fdfa26ba2c7ca 100644 --- a/include/logsim.h +++ b/include/logsim.h @@ -6,7 +6,6 @@ #include "logdig.h" #include "logsima.h" #include "logsimed.h" -#include <utils/rnd.h> #include <graphics/newkbd.h> #include <utils/newasm.h> #include <graphics/newci.h> diff --git a/include/utils/rnd.h b/include/utils/rnd.h deleted file mode 100644 index 65607ed070bafa1950f31c2605f8259b8f165a70..0000000000000000000000000000000000000000 --- a/include/utils/rnd.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef RND_H -#define RND_H - -#include <utils/p2c.h> - -/** - * Use the c library random methods - */ -void P_random() DEPRECATED; -long P_rand() DEPRECATED; - -#endif /* RND_H */ diff --git a/src/log.c b/src/log.c index 285f97bb501e20b86bd7396b0d99cd3b4922d102..11e9ee2e86f48803b0642f9e171ff186a853dc8c 100644 --- a/src/log.c +++ b/src/log.c @@ -34,6 +34,7 @@ #include <unistd.h> #include <time.h> +#include <stdlib.h> #include <string.h> @@ -42,7 +43,6 @@ #include "logdef.h" #include <utils/sysglobals.h> #include <utils/sysdevs.h> -#include <utils/rnd.h> /*homeless orphans*/ @@ -1316,7 +1316,7 @@ void tracemessage(char *msg) do { sprintf(tracefname, "/tmp/%.10s%03ld", - cuserid(NULL), P_rand(&gg.rndseed, 1000L)); + cuserid(NULL), rand() % 1000L); } while (access(tracefname, F_OK) == 0); } @@ -14112,7 +14112,6 @@ static void initialize() gg.host = log_host_log; gg.toolbase = NULL; inithooks(); - gg.rndseed = timers_sysclock(); gg.simstate = simst_null; gg.simstatetool = NULL; for (i = 0; i < maxgatesfiles; i++) @@ -14592,6 +14591,7 @@ int main(int argc, char * argv[]) nc_text_in_window = 1; PASCAL_MAIN(argc, argv); + srand(time(NULL)); tracefile = NULL; dumpfile = NULL; gg.initdone = false; diff --git a/src/logcom.c b/src/logcom.c index d59b627a9e883312275507394e1f7804dcf01b07..50bfa2155ad9ee15698f7550f8ea8f43fa100231 100644 --- a/src/logcom.c +++ b/src/logcom.c @@ -37,7 +37,6 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "logdef.h" #include <utils/sysglobals.h> #include <utils/sysdevs.h> -#include <utils/rnd.h> #include <utils/misc.h> #include <graphics/newci.h> #include <utils/filepack.h> diff --git a/src/loged.c b/src/loged.c index 4641d7cdd5999069029443411f41e581fa931857..d673e6d9a3baffefb83b5ba2e0b49ffca3ed2ddf 100644 --- a/src/loged.c +++ b/src/loged.c @@ -47,6 +47,8 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define SIM_KIND #include <unistd.h> #include <utils/p2c.h> +#include <time.h> +#include <stdlib.h> #include "logdef.h" @@ -5306,7 +5308,7 @@ static void dumpcmd() else { if (*argument == '\0') { do { - sprintf(argument, "/tmp/loged%ld.ps", P_rand()); + sprintf(argument, "/tmp/loged%ld.ps", rand()); spool = 1; } while (access(argument, F_OK) == 0); } else @@ -6486,7 +6488,7 @@ char *argument_; char argument[256], fn[256]; strcpy(argument, argument_); - sprintf(fn, "/tmp/loged%03ld.text", P_rand()); + sprintf(fn, "/tmp/loged%03ld.text", rand()); if (*argument == '\0' && curkind != NULL) strcpy(argument, kind.name); writefile(fn, argument); @@ -6721,6 +6723,7 @@ int main(int argc, char * argv[]) nc_text_in_window = 1; PASCAL_MAIN(argc, argv); + srand(time(NULL)); if (P_argc > 1 && !strcmp(P_argv[1], "-p")) { /* piped mode */ nc_text_in_window = 0; @@ -6744,7 +6747,6 @@ int main(int argc, char * argv[]) gg.resetflag = false; gg.pwrflag = false; gg.refrflag = false; - gg.rndseed = timers_sysclock(); *gg.func = '\0'; gg.time = 0.0; gg.simstate = simst_null; diff --git a/src/logsim.c b/src/logsim.c index 221bd9b2b7e5faefebfa5959822c76a5500a763f..e7f50db82093d0f6384804d597455215347d5dc1 100644 --- a/src/logsim.c +++ b/src/logsim.c @@ -39,6 +39,7 @@ #include <utils/p2c.h> +#include <stdlib.h> #include "logsim.h" #include "node.h" @@ -78,7 +79,7 @@ static const histcolortabletype histcolortable = { -static long rndseed, newsystime, oldsystime, stabtime, resetcounter; +static long newsystime, oldsystime, stabtime, resetcounter; static log_sigrec *vddsig, *gndsig, *resetsig; static int isstable, stabilizing, passready, maketimebid; static double nexttimebid; @@ -1214,7 +1215,7 @@ static void tstep_16(log_16_action *act) n = WITH->nbase; while (n != NULL) { - if (n->simtype == logsima_tool_16 && P_rand(&WITH->rndseed, 5L) == 0) + if (n->simtype == logsima_tool_16 && (rand() % 5L) == 0) { ni = (nodeinfo *)n->info; ni->v = ni->v00; @@ -1515,7 +1516,6 @@ void Log_16_proc(log_action_t *lact) if (*WITH->acttool->comment == '\0') strcpy(WITH->acttool->comment, "Digital simulator"); logsima_init(); - WITH->rndseed = timers_sysclock(); newsystime = 0; vddsig = NULL; gndsig = NULL; diff --git a/src/logsimh.c b/src/logsimh.c index cc89c0ce6cef6f338d64f24f7b553b81d3826896..a93efd6cb626e9b71da046dd1e36fb7e87cbbb85 100644 --- a/src/logsimh.c +++ b/src/logsimh.c @@ -4095,7 +4095,7 @@ static void dodump(struct LOC_compilepage *LINK) char STR2[256]; f = NULL; - sprintf(buf, "/spool/apple.text/dig%ld", P_rand()); + sprintf(buf, "/spool/apple.text/dig%ld", rand()); sprintf(STR2, "Writing to dump file %s", buf); (*logsima_action.lact->hook.vmessage)(STR2); if (f != NULL) diff --git a/src/screen.c b/src/screen.c index f718122cd75544b61ec89b5025b4a0224bf004c8..948f6984c22d188997321669ff7852cd18611cf9 100644 --- a/src/screen.c +++ b/src/screen.c @@ -466,14 +466,14 @@ void addrabbit() } if (j == -1) { - j = P_rand(&gg.rndseed, (long)rabtabsize) + 1; + j = (rand() % (long) rabtabsize) + 1; m_bunny((long)rabtable[j - 1].x, (long)rabtable[j - 1].y); rabtable[j - 1].next = 0; } do { - rx = P_rand(&gg.rndseed, across - 24L); - ry = P_rand(&gg.rndseed, baseline - 40L) + down - baseline + 30; + rx = rand() % (across - 24L); + ry = (rand() % (baseline - 40L)) + down - baseline + 30; nogood = false; for (i = 0; i < rabtabsize; i++) { diff --git a/src/utils/rnd.c b/src/utils/rnd.c deleted file mode 100644 index 47fb10652ecc252633a52f41b2d07f47299b9139..0000000000000000000000000000000000000000 --- a/src/utils/rnd.c +++ /dev/null @@ -1,25 +0,0 @@ -#include <stdlib.h> -#include <utils/rnd.h> - - -void P_random(long *seed) -{ - - srand48(*seed); - *seed = lrand48(); -} - - -long P_rand(long *seed, long limit) -{ - - srand48(*seed); - *seed = lrand48(); - if (limit != 0) - return(abs(*seed % limit)); /* I know, I know. This skews probabilities */ - /* slightly toward low numbers unless limit */ - /* is a divisor of 2^32. Tough. */ - else - return(0); -} -