Skip to content

Commit

Permalink
fix: various cleanups and refining of POSIX platform definition
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Jan 3, 2025
1 parent 1762846 commit 9137af4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
7 changes: 0 additions & 7 deletions src/cjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ extern bool extract_assets(CJITState *CJIT);
/////////////
// from file.c
extern char* file_load(const char *filename, unsigned int *len);
extern char *load_stdin();
extern char* dir_load(const char *path);
extern bool write_to_file(const char *path, const char *filename,
const char *buf, unsigned int len);

// terminal printing functions
extern void _out(const char *fmt, ...);
Expand All @@ -103,8 +99,5 @@ extern void _err(const char *fmt, ...);
/////////////
// from repl.c
extern int cjit_cli_tty(CJITState *cjit);
#ifdef KILO_SUPPORTED
extern int cjit_cli_kilo(CJITState *cjit);
#endif

#endif
5 changes: 5 additions & 0 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ bool write_to_file(const char *path, const char *filename, const char *buf, unsi
return true;
}

#if 0 // unused for now, dangerous to have if unnecessary
static int rm_ftw(const char *pathname,
const struct stat *sbuf,
int type, struct FTW *ftwb) {
Expand Down Expand Up @@ -205,7 +206,10 @@ bool rm_recursive(char *path) {
}
return true;
}
#endif


#if 0
#if !defined(WINDOWS)

static char *full_content = NULL;
Expand Down Expand Up @@ -273,3 +277,4 @@ char *dir_load(const char *path)


#endif
#endif // 0
12 changes: 7 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <muntar.h>
#include <assets.h>

extern char *load_stdin();

#define MAX_ARG_STRING 1024
static int parse_value(char *str) {
int i = 0;
Expand Down Expand Up @@ -141,19 +143,19 @@ int main(int argc, char **argv) {
strcpy(CJIT->output_filename,opt.arg);
cjit_set_output(CJIT, EXE);
} else if (c == 'L') { // library path
if(!CJIT->quiet)_err("lib path: %s",opt.arg);
if(CJIT->verbose)_err("arg lib path: %s",opt.arg);
cjit_add_library_path(CJIT, opt.arg);
} else if (c == 'l') { // library link
if(!CJIT->quiet)_err("lib: %s",opt.arg);
if(CJIT->verbose)_err("arg lib: %s",opt.arg);
cjit_add_library(CJIT, opt.arg);
} else if (c == 'C') { // cflags compiler options
if(!CJIT->quiet)_err("cflags: %s",opt.arg);
if(CJIT->verbose)_err("arg cflags: %s",opt.arg);
cjit_set_tcc_options(CJIT->TCC, opt.arg);
} else if (c == 'I') { // include paths in cflags
if(!CJIT->quiet)_err("inc: %s",opt.arg);
if(CJIT->verbose)_err("arg inc: %s",opt.arg);
cjit_add_include_path(CJIT, opt.arg);
} else if (c == 'e') { // entry point (default main)
if(!CJIT->quiet)_err("entry: %s",opt.arg);
if(!CJIT->quiet)_err("entry function: %s",opt.arg);
if(CJIT->entry) free(CJIT->entry);
CJIT->entry = malloc(strlen(opt.arg)+1);
strcpy(CJIT->entry,opt.arg);
Expand Down
8 changes: 8 additions & 0 deletions src/platforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@
#endif
#if defined(__linux__)
#define LINUX
#define POSIX
#define UNIX
#define PLATFORM "GNU/Linux"
#endif
#if defined(__APPLE__)
#define APPLE
#define POSIX
#define PLATFORM "Apple/OSX"
#endif
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define BSD
#define POSIX
#define UNIX
#define PLATFORM "BSD"
#endif
#if defined(__ANDROID__)
#define ANDROID
#define POSIX
#define PLATFORM "Android"
#endif
#if defined(__EMSCRIPTEN__)
Expand All @@ -39,10 +45,12 @@
#endif
#if defined(__BEOS__) || defined(__HAIKU__)
#define BEOS
#define POSIX
#define PLATFORM "BEOS"
#endif
#if defined(__HAIKU__)
#define HAIKU
#define POSIX
#define PLATFORM "Haiku"
#endif
#endif
Expand Down

0 comments on commit 9137af4

Please sign in to comment.