From 519d8f07e636c3171ad8ce05e729abb0d5b3c4e1 Mon Sep 17 00:00:00 2001 From: "Jason S. Ninneman" Date: Mon, 29 May 2017 09:30:37 -0700 Subject: [PATCH] Really mean it about strict C99 compliance. --- Makefile | 7 ++++--- actions1.c | 2 +- main.c | 2 ++ misc.c | 7 +++++++ misc.h | 3 +-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7fae0ef..4faf82e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ # Makefile for the open-source release of adventure 2.5 +CCFLAGS=-std=c99 LIBS=-lrt UNAME_S := $(shell uname -s) GCCVERSIONGTEQ4 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 4) @@ -13,10 +14,10 @@ OBJS=main.o init.o actions1.o actions2.o score.o misc.o SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO adventure.text advent.text control misc.h main.h share.h funcs.h .c.o: - $(CC) -O $(DBX) -c $< + $(CC) $(CCFLAGS) -O $(DBX) -c $< advent: $(OBJS) database.o - $(CC) -Wall -std=c99 -O $(DBX) -o advent $(OBJS) database.o $(LIBS) + $(CC) $(CCFLAGS) -O $(DBX) -o advent $(OBJS) database.o $(LIBS) main.o: main.h misc.h funcs.h database.h @@ -32,7 +33,7 @@ misc.o: misc.h main.h database.h database.c database.h: compile ./compile - $(CC) $(OPTIONS) -O $(DBX) -c database.c + $(CC) $(CCFLAGS) -O $(DBX) -c database.c clean: rm -f *.o advent advent.html advent.6 database.[ch] compile diff --git a/actions1.c b/actions1.c index 0cf8e97..c82a7bc 100644 --- a/actions1.c +++ b/actions1.c @@ -523,7 +523,7 @@ L8300: SPK=201; /* This next part is shared with the "resume" code. The two cases are * distinguished by the value of kk (-1 for suspend, +1 for resume). */ -L8305: DATIME(I,K); +L8305: DATIME(&I,&K); K=I+650*K; SAVWRD(KK,K); K=VRSION; diff --git a/main.c b/main.c index e2c24e5..65726e1 100644 --- a/main.c +++ b/main.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "main.h" #include "database.h" #include "misc.h" @@ -920,4 +921,5 @@ L12400: LIMIT= -1; L18999: RSPEAK(SPK); L19000: RSPEAK(136); score(0); + return true; } diff --git a/misc.c b/misc.c index 111848e..1e72ba7 100644 --- a/misc.c +++ b/misc.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "main.h" #include "share.h" /* for SETUP */ #include "misc.h" @@ -1002,5 +1003,11 @@ L30: if(IN)IGNORE(fread(ARR,sizeof(long),250,F)); +void DATIME(long* D, long* T) { + struct timeval tv; + gettimeofday(&tv, NULL); + *D = (long) tv.tv_sec; + *T = (long) tv.tv_usec; +} long fIABS(N)long N; {return(N<0? -N : N);} long fMOD(N,M)long N, M; {return(N%M);} diff --git a/misc.h b/misc.h index a42a5a3..e16c308 100644 --- a/misc.h +++ b/misc.h @@ -1,4 +1,3 @@ -#include #include #include @@ -68,7 +67,7 @@ extern void fMPINIT(); #define MPINIT() fMPINIT() extern void fSAVEIO(long,long,long*); #define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR) -#define DATIME(D,T) do {struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); D=ts.tv_sec, T=ts.tv_nsec;} while (0) +extern void DATIME(long*, long*); extern long fIABS(long); #define IABS(N) fIABS(N) extern long fMOD(long,long); -- 2.31.1