Skip to content

Commit

Permalink
[std] Add sys_cpu_arch function (#275)
Browse files Browse the repository at this point in the history
* Add sys_cpu_arch function

* Bump version to 2.4.0

---------

Co-authored-by: Simon Krajewski <[email protected]>
  • Loading branch information
tobil4sk and Simn authored Mar 27, 2023
1 parent 4e207e8 commit b99abf6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
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

0 comments on commit b99abf6

Please sign in to comment.