CFLAGS += -Wall -g -DNMRPFLASH_VERSION=\"$(VERSION)\"
LDFLAGS += $(LIBS)
-.PHONY: clean install release release/osx release/linux release/win32
-
-nmrpflash: nmrp.o tftp.o ethsock.o main.o
- $(CC) $(CFLAGS) -o nmrpflash nmrp.o tftp.o ethsock.o main.o $(LDFLAGS)
+nmrpflash_OBJ = nmrp.o tftp.o ethsock.o main.o util.o
-nmrp.o: nmrp.c nmrpd.h
- $(CC) $(CFLAGS) -c -o nmrp.o nmrp.c
-
-tftp.o: tftp.c nmrpd.h
- $(CC) $(CFLAGS) -c -o tftp.o tftp.c
+.PHONY: clean install release release/osx release/linux release/win32
-ethsock.o: ethsock.c nmrpd.h
- $(CC) $(CFLAGS) -c -o ethsock.o ethsock.c
+nmrpflash: $(nmrpflash_OBJ)
+ $(CC) $(CFLAGS) -o nmrpflash $(nmrpflash_OBJ) $(LDFLAGS)
-main.o: main.c nmrpd.h
- $(CC) $(CFLAGS) -c -o main.o main.c
+%.o: %.c nmrpd.h
+ $(CC) -c $(CFLAGS) $< -o $@
fuzz: clean
CC=afl-gcc CFLAGS=-DNMRPFLASH_FUZZ make nmrpflash
}
set_addr(&sin, ipaddr);
- clock_t now = clock();
+ time_t beg = time_monotonic();
/* Wait until the new IP has actually been added */
while (bind(fd, (struct sockaddr*)&sin, sizeof(sin)) != 0) {
- if (((clock() - now) / CLOCKS_PER_SEC) >= 5) {
+ if ((time_monotonic() - beg) >= 5) {
fprintf(stderr, "Failed to bind after 5 seconds: ");
sock_perror("bind");
DeleteIPAddress((*undo)->context);
i = 0;
upload_ok = 0;
- beg = time(NULL);
+ beg = time_monotonic();
while (1) {
printf("\rAdvertising NMRP server on %s ... %c",
} else if (status == 1) {
goto out;
} else {
- if ((time(NULL) - beg) >= 60) {
+ if ((time_monotonic() - beg) >= 60) {
printf("\nNo response after 60 seconds. Bailing out.\n");
goto out;
}
int ethsock_ip_add(struct ethsock *sock, uint32_t ipaddr, uint32_t ipmask, struct ethsock_ip_undo **undo);
int ethsock_ip_del(struct ethsock *sock, struct ethsock_ip_undo **undo);
+
+time_t time_monotonic();
#endif
SupportXPThemes=0\r
CompilerSet=3\r
CompilerSettings=0000000100000000000001000\r
-UnitCount=5\r
+UnitCount=6\r
\r
[VersionInfo]\r
Major=1\r
OverrideBuildCmd=0\r
BuildCmd=\r
\r
+[Unit6]\r
+FileName=util.c\r
+CompileCpp=0\r
+Folder=\r
+Compile=1\r
+Link=1\r
+Priority=1000\r
+OverrideBuildCmd=0\r
+BuildCmd=\r
+\r
#include <time.h>
+#include <math.h>
+#include "nmrpd.h"
#ifdef NMRPFLASH_OSX
#include <mach/mach_time.h>
#ifndef NMRPFLASH_OSX
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts.ts_sec;
+ return ts.tv_sec;
#else
static double factor = 0.0;
mach_timebase_info_data_t timebase;
return round(GetTickCount() / 1000.0);
#endif
}
-
-int main()
-{
- time_t beg = time_monotonic();
- printf("now: %ld\n", beg);
- sleep(2);
- printf("+2s: %ld\n", time_monotonic());
- return 0;
-}