From 5de3b07e2b54fcf3be089e0cf064265abcb13e63 Mon Sep 17 00:00:00 2001 From: Zachary Pierson Date: Mon, 2 Jul 2018 02:50:08 -0500 Subject: [PATCH 1/4] Made `os_osx.odin` use the new-style `runtime.args__` and added `read_directory` for macOS --- core/os/os_osx.odin | 5 +++-- src/common.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/os/os_osx.odin b/core/os/os_osx.odin index befd97257..411107706 100644 --- a/core/os/os_osx.odin +++ b/core/os/os_osx.odin @@ -3,6 +3,7 @@ package os foreign import dl "system:dl" foreign import libc "system:c" +import "core:runtime" import "core:strings" OS :: "osx"; @@ -287,8 +288,8 @@ dlerror :: proc() -> string { _alloc_command_line_arguments :: proc() -> []string { - args := make([]string, len(__args__)); - for arg, i in __args__ { + args := make([]string, len(runtime.args__)); + for arg, i in runtime.args__ { args[i] = string(arg); } return args; diff --git a/src/common.cpp b/src/common.cpp index ec6ec7798..adeebc410 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -822,7 +822,7 @@ ReadDirectoryError read_directory(String path, Array *fi) { return ReadDirectory_None; } -#elif defined(GB_SYSTEM_LINUX) +#elif defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_OSX) #include From 3b2c8678179a64c2e53e22a1dae50487fb8873e7 Mon Sep 17 00:00:00 2001 From: Morten Vassvik Date: Wed, 4 Jul 2018 21:04:48 +0200 Subject: [PATCH 2/4] Replaced CLOCK_PROCESS_CPUTIME_ID with CLOCK_MONOTONIC in calls to clock_gettime and clock_getres to make timings on calling external executables accurate instead of showing them taking negligible time on linux. --- src/timings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/timings.cpp b/src/timings.cpp index 89280b779..3aea7a0fa 100644 --- a/src/timings.cpp +++ b/src/timings.cpp @@ -51,7 +51,7 @@ u64 osx_time_stamp__freq(void) { u64 unix_time_stamp_time_now(void) { struct timespec ts; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); return (ts.tv_sec * 1000000000) + ts.tv_nsec; } @@ -61,7 +61,7 @@ u64 unix_time_stamp__freq(void) { if (freq == 0) { struct timespec ts; - clock_getres(CLOCK_PROCESS_CPUTIME_ID, &ts); + clock_getres(CLOCK_MONOTONIC, &ts); freq = cast(u64) ((1.0 / ts.tv_nsec) * 1000000000.0); } From ea055f14654e3fe4580a71ce7490adb11ce0809d Mon Sep 17 00:00:00 2001 From: Morten Vassvik Date: Thu, 5 Jul 2018 15:46:11 +0200 Subject: [PATCH 3/4] Surrounded explicit link paths (.a and .so) and the exe path for 'odin run' in quotes, so that it works in paths containing characters that must be escaped (like spaces) --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9559a3dc6..25ebc9dea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -992,12 +992,12 @@ int main(int arg_count, char **arg_ptr) { // the system library paths for the library file). if (string_ends_with(lib, str_lit(".a"))) { // static libs, absolute full path relative to the file in which the lib was imported from - lib_str = gb_string_append_fmt(lib_str, " -l:%.*s ", LIT(lib)); + lib_str = gb_string_append_fmt(lib_str, " -l:\"%.*s\" ", LIT(lib)); } else if (string_ends_with(lib, str_lit(".so"))) { // dynamic lib, relative path to executable // NOTE(vassvik): it is the user's responsibility to make sure the shared library files are visible // at runtimeto the executable - lib_str = gb_string_append_fmt(lib_str, " -l:%s/%.*s ", cwd, LIT(lib)); + lib_str = gb_string_append_fmt(lib_str, " -l:\"%s/%.*s\" ", cwd, LIT(lib)); } else { // dynamic or static system lib, just link regularly searching system library paths lib_str = gb_string_append_fmt(lib_str, " -l%.*s ", LIT(lib)); @@ -1085,7 +1085,7 @@ int main(int arg_count, char **arg_ptr) { remove_temp_files(output_base); if (run_output) { - system_exec_command_line_app("odin run", false, "%.*s", LIT(output_base)); + system_exec_command_line_app("odin run", false, "\"%.*s\"", LIT(output_base)); } #endif #endif From e04ba7530d7439cb97f4f061f68d4e8149f0735e Mon Sep 17 00:00:00 2001 From: Morten Vassvik Date: Thu, 5 Jul 2018 15:48:55 +0200 Subject: [PATCH 4/4] Updated makefile to run demo package instead of demo.odin --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c4e1fab92..8f8fe0d75 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ endif all: debug demo demo: - ./odin run examples/demo.odin + ./odin run examples/demo debug: $(CC) src/main.cpp $(DISABLED_WARNINGS) $(CFLAGS) -g $(LDFLAGS) -o odin