aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-12-25 17:51:20 +0100
committerLoïc Hoguin <[email protected]>2017-12-25 17:51:20 +0100
commit1284144bc49474dc2377047cdd99502247dbded2 (patch)
tree92fe89a878e9021464c64d0603e41ff1efa2fd66
parent371bc5f677b3c763407fc79f01cb9d0c598199cc (diff)
downloadesdl2-1284144bc49474dc2377047cdd99502247dbded2.tar.gz
esdl2-1284144bc49474dc2377047cdd99502247dbded2.tar.bz2
esdl2-1284144bc49474dc2377047cdd99502247dbded2.zip
Add the new sdl_cpuinfo.h functions
-rw-r--r--README.asciidoc2
-rw-r--r--c_src/esdl2.h4
-rw-r--r--c_src/sdl_cpu_info.c26
-rw-r--r--src/esdl2.erl12
-rw-r--r--src/sdl_cpu_info.erl18
5 files changed, 51 insertions, 11 deletions
diff --git a/README.asciidoc b/README.asciidoc
index e5e47bc..1835fa5 100644
--- a/README.asciidoc
+++ b/README.asciidoc
@@ -10,6 +10,7 @@ corresponding to the public headers.
* 'SDL.h'
* 'SDL_blendmode.h'
+* 'SDL_cpuinfo.h'
* 'SDL_mouse.h'
* 'SDL_filesystem.h'
* 'SDL_power.h'
@@ -17,7 +18,6 @@ corresponding to the public headers.
== Partially implemented
* 'SDL_clipboard.h': We currently do not support UTF-8. We should probably switch to binaries as input/output to support it.
-* 'SDL_cpuinfo.h': `SDL_HasAVX2` and `SDL_HasNEON` must be implemented.
* 'SDL_events.h': Most of it is missing.
* 'SDL_hints.h': We only have a proof of concept callback system.
* 'SDL_keyboard.h': Most of it is missing.
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index 2993549..5a1ec99 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -186,9 +186,11 @@
F(get_cpu_count, 0) \
F(get_system_ram, 0) \
F(has_3dnow, 0) \
- F(has_avx, 0) \
F(has_altivec, 0) \
+ F(has_avx, 0) \
+ F(has_avx2, 0) \
F(has_mmx, 0) \
+ F(has_neon, 0) \
F(has_rdtsc, 0) \
F(has_sse, 0) \
F(has_sse2, 0) \
diff --git a/c_src/sdl_cpu_info.c b/c_src/sdl_cpu_info.c
index 6285cfe..c616891 100644
--- a/c_src/sdl_cpu_info.c
+++ b/c_src/sdl_cpu_info.c
@@ -45,6 +45,16 @@ NIF_FUNCTION(has_3dnow)
return atom_false;
}
+// has_altivec
+
+NIF_FUNCTION(has_altivec)
+{
+ if (SDL_HasAltiVec())
+ return atom_true;
+
+ return atom_false;
+}
+
// has_avx
NIF_FUNCTION(has_avx)
@@ -55,11 +65,11 @@ NIF_FUNCTION(has_avx)
return atom_false;
}
-// has_altivec
+// has_avx2
-NIF_FUNCTION(has_altivec)
+NIF_FUNCTION(has_avx2)
{
- if (SDL_HasAltiVec())
+ if (SDL_HasAVX2())
return atom_true;
return atom_false;
@@ -75,6 +85,16 @@ NIF_FUNCTION(has_mmx)
return atom_false;
}
+// has_neon
+
+NIF_FUNCTION(has_neon)
+{
+ if (SDL_HasNEON())
+ return atom_true;
+
+ return atom_false;
+}
+
// has_rdtsc
NIF_FUNCTION(has_rdtsc)
diff --git a/src/esdl2.erl b/src/esdl2.erl
index 815c12c..1020849 100644
--- a/src/esdl2.erl
+++ b/src/esdl2.erl
@@ -38,9 +38,11 @@
-export([get_cpu_count/0]).
-export([get_system_ram/0]).
-export([has_3dnow/0]).
--export([has_avx/0]).
-export([has_altivec/0]).
+-export([has_avx/0]).
+-export([has_avx2/0]).
-export([has_mmx/0]).
+-export([has_neon/0]).
-export([has_rdtsc/0]).
-export([has_sse/0]).
-export([has_sse2/0]).
@@ -233,15 +235,21 @@ get_system_ram() ->
has_3dnow() ->
erlang:nif_error({not_loaded, ?MODULE}).
+has_altivec() ->
+ erlang:nif_error({not_loaded, ?MODULE}).
+
has_avx() ->
erlang:nif_error({not_loaded, ?MODULE}).
-has_altivec() ->
+has_avx2() ->
erlang:nif_error({not_loaded, ?MODULE}).
has_mmx() ->
erlang:nif_error({not_loaded, ?MODULE}).
+has_neon() ->
+ erlang:nif_error({not_loaded, ?MODULE}).
+
has_rdtsc() ->
erlang:nif_error({not_loaded, ?MODULE}).
diff --git a/src/sdl_cpu_info.erl b/src/sdl_cpu_info.erl
index 3153e8a..e34f2bd 100644
--- a/src/sdl_cpu_info.erl
+++ b/src/sdl_cpu_info.erl
@@ -18,9 +18,11 @@
-export([get_cpu_count/0]).
-export([get_system_ram/0]).
-export([has_3dnow/0]).
--export([has_avx/0]).
-export([has_altivec/0]).
+-export([has_avx/0]).
+-export([has_avx2/0]).
-export([has_mmx/0]).
+-export([has_neon/0]).
-export([has_rdtsc/0]).
-export([has_sse/0]).
-export([has_sse2/0]).
@@ -44,18 +46,26 @@ get_system_ram() ->
has_3dnow() ->
esdl2:has_3dnow().
+-spec has_altivec() -> boolean().
+has_altivec() ->
+ esdl2:has_altivec().
+
-spec has_avx() -> boolean().
has_avx() ->
esdl2:has_avx().
--spec has_altivec() -> boolean().
-has_altivec() ->
- esdl2:has_altivec().
+-spec has_avx2() -> boolean().
+has_avx2() ->
+ esdl2:has_avx2().
-spec has_mmx() -> boolean().
has_mmx() ->
esdl2:has_mmx().
+-spec has_neon() -> boolean().
+has_neon() ->
+ esdl2:has_neon().
+
-spec has_rdtsc() -> boolean().
has_rdtsc() ->
esdl2:has_rdtsc().