diff --git a/gebs.h b/gebs.h index d88620b..cd856a3 100644 --- a/gebs.h +++ b/gebs.h @@ -73,19 +73,8 @@ int main(int argc, char ** argv) #ifndef GEBS_H_ #define GEBS_H_ - -// ---------------------------------------------------------------------------- -// Platform macros -// ---------------------------------------------------------------------------- - -#define GEBS_PLATFORM_POSIX 0 - -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) -# define GEBS_PLATFORM GEBS_PLATFORM_POSIX -#endif - -#ifndef GEBS_PLATFORM -# error "GEBS_PLATFORM is undefined!" +#if !(defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))) +# error "gebs works only on posix platforms" #endif // ---------------------------------------------------------------------------- @@ -100,15 +89,11 @@ int main(int argc, char ** argv) #include #include -#if GEBS_PLATFORM == GEBS_PLATFORM_POSIX -# include -# include -# include -# include -# include -#else -# error "Unknown GEBS_PLATFORM" -#endif +#include +#include +#include +#include +#include #define discard __attribute__((unused)) @@ -402,7 +387,6 @@ int gebs_cmd_run_sync_alloc(Gebs_Allocator *alloc, Gebs_Cmd *cmd) gebs_sb_finish_alloc(alloc, &sb); GEBS_LOGI("cmd `%s`\n", sb.items); -#if GEBS_PLATFORM == GEBS_PLATFORM_POSIX // Clone the list Gebs_Cmd new_cmd = {0}; defer { gebs_cmd_free_alloc(alloc, &new_cmd); } @@ -438,9 +422,6 @@ int gebs_cmd_run_sync_alloc(Gebs_Allocator *alloc, Gebs_Cmd *cmd) } while(!WIFEXITED(wstatus) && !WIFSIGNALED(wstatus)); } } -#else -# error "gebs_cmd_run_sync_alloc unknown command" -#endif } int gebs_cmd_run_sync_collect_alloc(Gebs_Allocator *alloc, Gebs_Cmd *cmd, Gebs_String_Builder *sb_out) @@ -450,7 +431,6 @@ int gebs_cmd_run_sync_collect_alloc(Gebs_Allocator *alloc, Gebs_Cmd *cmd, Gebs_S gebs_sb_finish_alloc(alloc, &sb); GEBS_LOGI("cmd `%s`\n", sb.items); -#if GEBS_PLATFORM == GEBS_PLATFORM_POSIX // Clone the list Gebs_Cmd new_cmd = {0}; defer { gebs_cmd_free_alloc(alloc, &new_cmd); } @@ -502,9 +482,6 @@ int gebs_cmd_run_sync_collect_alloc(Gebs_Allocator *alloc, Gebs_Cmd *cmd, Gebs_S } while(!WIFEXITED(wstatus) && !WIFSIGNALED(wstatus)); } } -#else -# error "gebs_cmd_run_sync_alloc unknown command" -#endif } // ---------------------------------------------------------------------------- @@ -667,41 +644,26 @@ void gebs_scratch_arena_reset(void) bool gebs_mkdir(const char *p) { -#if GEBS_PLATFORM == GEBS_PLATFORM_POSIX + GEBS_LOGO("mkdir %s\n", p); return mkdir(p, 0777) == 0; -#else -# error "gebs_mkdir unknown platform" -#endif } bool gebs_exists(const char *p) { -#if GEBS_PLATFORM == GEBS_PLATFORM_POSIX struct stat st; return stat(p, &st) == 0; -#else -# error "gebs_exists unknown platform" -#endif } bool gebs_rename(const char *a, const char *b) { GEBS_LOGO("rename %s -> %s\n", a, b); -#if GEBS_PLATFORM == GEBS_PLATFORM_POSIX return rename(a, b) == 0; -#else -# error "gebs_rename unknown platform" -#endif } bool gebs_remove(const char *p) { GEBS_LOGO("remove %s\n", p); -#if GEBS_PLATFORM == GEBS_PLATFORM_POSIX return remove(p) == 0; -#else -# error "gebs_remove unknown platform" -#endif } // ---------------------------------------------------------------------------- @@ -710,7 +672,6 @@ bool gebs_remove(const char *p) bool gebs_needs_rebuild(const char *out, const char *in) { -#if GEBS_PLATFORM == GEBS_PLATFORM_POSIX time_t out_mtime = 0; time_t in_mtime = 0; @@ -720,9 +681,6 @@ bool gebs_needs_rebuild(const char *out, const char *in) if (stat(in, &attr2) == 0) { in_mtime = attr2.st_mtime; } return in_mtime > out_mtime; -#else -# error "gebs_needs_rebuild unknown platform" -#endif } void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv,