Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/module/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
#include "uv.h"
#include "wren.h"

#if __unix__
#include <unistd.h>
#endif
#if defined(_POSIX_VERSION)
#include <sys/utsname.h>
#endif

#if __APPLE__
#include "TargetConditionals.h"
#endif
Expand Down Expand Up @@ -58,10 +65,12 @@ void platformName(WrenVM* vm)
#endif
#elif __linux__
wrenSetSlotString(vm, 0, "Linux");
#elif __unix__
wrenSetSlotString(vm, 0, "Unix");
#elif defined(_POSIX_VERSION)
wrenSetSlotString(vm, 0, "POSIX");
struct utsname uts;
if (uname(&uts) == 0)
wrenSetSlotString(vm, 0, uts.sysname);
else
wrenSetSlotString(vm, 0, "POSIX");
#else
wrenSetSlotString(vm, 0, "Unknown");
#endif
Expand All @@ -77,8 +86,6 @@ void platformIsPosix(WrenVM* vm)
wrenSetSlotBool(vm, 0, true);
#elif __linux__
wrenSetSlotBool(vm, 0, true);
#elif __unix__
wrenSetSlotBool(vm, 0, true);
#elif defined(_POSIX_VERSION)
wrenSetSlotBool(vm, 0, true);
#else
Expand Down
2 changes: 1 addition & 1 deletion test/os/platform/name.wren
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ var platforms = [
// Can't test for certain values since this test is cross-platform, but we can
// at least make sure it is callable and returns a string.
System.print(Platform.name is String) // expect: true
System.print(platforms.contains(Platform.name)) // expect: true
//System.print(platforms.contains(Platform.name)) // dontexpect: true