Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[std] Add sys_cpu_arch function #275

Merged
merged 3 commits into from
Mar 27, 2023
Merged
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
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2021-10-27 : 2.3.1
????-??-?? : 2.4.0
all : deprecated neko (see README)
std : fixed put_env when null is passed in (#229 https://github.com/HaxeFoundation/haxe/issues/10395)
std : added sys_cpu_arch (#275)
std : fix sys_is64 returning false on 64 bit Windows (#276)
cmake : updated apr version for Mac
all : fixed various build issues on macOS Catalina
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
endif()

set(NEKO_VERSION_MAJOR 2)
set(NEKO_VERSION_MINOR 3)
set(NEKO_VERSION_PATCH 1)
set(NEKO_VERSION_MINOR 4)
set(NEKO_VERSION_PATCH 0)

# NEKO_VERSION is cached such that we can query it by `cmake -L -N -B . | grep NEKO_VERSION`
set(NEKO_VERSION ${NEKO_VERSION_MAJOR}.${NEKO_VERSION_MINOR}.${NEKO_VERSION_PATCH} CACHE STRING INTERNAL)
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ variables:
- name: AZURE_PIPELINES_BRANCH
value: $(Build.SourceBranchName)
- name: NEKO_VERSION
value: "2.3.1"
value: "2.4.0"

trigger:
branches:
Expand Down
27 changes: 27 additions & 0 deletions libs/std/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,32 @@ static value sys_is64() {
#endif
}

/**
sys_cpu_arch : void -> string
<doc>
Returns the cpu architecture. Current possible values:
<ul>
<li>[x86_64]</li>
<li>[x86]</li>
<li>[arm64]</li>
<li>[arm]</li>
</ul>
</doc>
**/
static value sys_cpu_arch() {
#if defined(__x86_64__) || defined(_M_AMD64)
return alloc_string("x86_64");
#elif defined(__i386__) || defined(_M_IX86)
return alloc_string("x86");
#elif defined(__aarch64__) || defined(_M_ARM64)
return alloc_string("arm64");
#elif defined(__arm__) || defined(_M_ARM)
return alloc_string("arm");
#else
#error Unknown CPU architecture
#endif
}

/**
sys_command : string -> int
<doc>Run the shell command and return exit code</doc>
Expand Down Expand Up @@ -703,6 +729,7 @@ DEFINE_PRIM(sys_command,1);
DEFINE_PRIM(sys_exit,1);
DEFINE_PRIM(sys_string,0);
DEFINE_PRIM(sys_is64,0);
DEFINE_PRIM(sys_cpu_arch,0);
DEFINE_PRIM(sys_stat,1);
DEFINE_PRIM(sys_time,0);
DEFINE_PRIM(sys_cpu_time,0);
Expand Down