commit 9d237f29e03cd4ecb44b1760d5edc0f39bcb496d
parent dbe8221ce0b2c9672dc92ef833e240bc0b821d16
Author: bsandro <email@bsandro.tech>
Date: Fri, 26 Dec 2025 00:43:00 +0200
Makefile cleanup
Diffstat:
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,12 +1,12 @@
.SUFFIXES:
MAKEFLAGS+=-rR
-CFLAGS=-O3 -std=gnu99 -Werror -Wall -Wextra -ffast-math -I.
-ifeq ($(shell uname -m),riscv64)
-CFLAGS+=-mtune=sifive-u74
+CFLAGS=-std=c99 -Wpedantic -Wall -Wextra -ffast-math -I.
+ifeq (${DEBUG},1)
+CFLAGS+=-O0 -g
else
-CFLAGS+=-mtune=native -march=native
+CFLAGS+=-O3 -mtune=native -march=native
endif
-LDFLAGS=-lc -lm
+LDFLAGS=-lc -lm -flto
CC=clang
.PHONY: clean
diff --git a/cputime.h b/cputime.h
@@ -2,11 +2,11 @@
#include <time.h>
static volatile double time_started = 0;
-void __attribute((constructor)) begin() {
+void __attribute((constructor)) begin(void) {
time_started = clock();
}
-void __attribute((destructor)) end() {
+void __attribute((destructor)) end(void) {
double elapsed = clock() - time_started;
printf("Elapsed: %f s\n", elapsed/CLOCKS_PER_SEC);
}
diff --git a/day02.c b/day02.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
+#include "cputime.h"
#define MAX_LEN 256