From 7b11a95b82052299c2844578034b6336c051593a Mon Sep 17 00:00:00 2001 From: Trent Huber Date: Wed, 23 Jul 2025 03:59:03 -0400 Subject: [PATCH] Changes for Linux compatibility --- cbs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cbs.c b/cbs.c index fa4b22e..798b53c 100644 --- a/cbs.c +++ b/cbs.c @@ -10,8 +10,10 @@ #ifdef __APPLE__ #define DYEXT ".dylib" +#define TIME st_mtimespec #else #define DYEXT ".so" +#define TIME st_mtim #endif #define NONE (char *[]){NULL} @@ -150,8 +152,8 @@ void load(char type, char *target, char **objs) { int after(struct stat astat, struct stat bstat) { struct timespec a, b; - a = astat.st_mtimespec; - b = bstat.st_mtimespec; + a = astat.TIME; + b = bstat.TIME; return a.tv_sec == b.tv_sec ? a.tv_nsec > b.tv_nsec : a.tv_sec > b.tv_sec; } @@ -167,11 +169,10 @@ void build(char *path) { if (!(current = getcwd(NULL, 0))) err(EXIT_FAILURE, "Unable to check current directory"); - exists = stat("build", &exe) != -1; if ((self = strcmp(absolute, current) == 0)) { if (stat("build.c", &src) == -1) err(EXIT_FAILURE, "Unable to stat `build.c'"); - if ((leave = exists && after(exe, src)) + if ((leave = (exists = stat("build", &exe) == 0) && after(exe, src)) && utimensat(AT_FDCWD, "build.c", NULL, 0) == -1) err(EXIT_FAILURE, "Unable to update `build.c' modification time"); } else { @@ -183,6 +184,7 @@ void build(char *path) { if (chdir(path) == -1) err(EXIT_FAILURE, "Unable to change directory to `%s'", path); + exists = stat("build", &exe) == 0; leave = cpid; } -- 2.51.0