summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt5
-rw-r--r--test.cc35
-rw-r--r--zp/GNUmakefile44
-rw-r--r--zp/include/zp/mth6
-rw-r--r--zp/include/zp/mth.h8
-rw-r--r--zp/source/any/mth/isnan.cc12
6 files changed, 62 insertions, 48 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index c5d63ec..599bc90 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -188,6 +188,11 @@
* Add more math tests;
* Implement C++ isnan;
+* Don't implement isnan as a macro;
+* Fix syscal not being translated;
+* Rename targ variable to tar;
+* Don't use "fast" optimisation;
+
# 0.0.2
* Migrate to CMake;
diff --git a/test.cc b/test.cc
index b25ff2d..b008006 100644
--- a/test.cc
+++ b/test.cc
@@ -157,7 +157,7 @@ static_assert(::zp::maxval<long unsigned>::val == ::std::numeric_limits<lon
static_assert(::zp::maxval<long long unsigned>::val == ::std::numeric_limits<long long unsigned>::max());
static_assert(::zp::maxval<wchar_t>::val == ::std::numeric_limits<wchar_t>::max());
-template<typename ltyp,typename rtyp> static auto cmp(int unsigned & num,int unsigned & numerr,long const ln,ltyp const & lvalref,rtyp const & rvalref) noexcept {
+template<typename ltyp,typename rtyp> static auto cmp(int unsigned & numerr,long const ln,ltyp const & lvalref,rtyp const & rvalref) noexcept {
char const * const ltypnm = typeid (ltyp).name();
char const * const rtypnm = typeid (rtyp).name();
@@ -172,10 +172,10 @@ template<typename ltyp,typename rtyp> static auto cmp(int unsigned & num,int uns
auto const lval = getval(lvalref);
auto const rval = getval(rvalref);
- ::std::cout << " " << num++ << ". comparing " << ltypnm << " (" << lval << ") vs. " << rtypnm << " (" << rval << ")... ";
+ ::std::cout << " " << ln << ". comparing " << ltypnm << " (" << lval << ") vs. " << rtypnm << " (" << rval << ")... ";
if (lval != rval) {
- ::std::cout << "\x1B[38;5;161munequal\x1B[0m (at #" << ln << ")\n";
+ ::std::cout << "\x1B[38;5;161munequal\x1B[0m\n";
//throw ::std::exception {};
++numerr;
@@ -185,16 +185,13 @@ template<typename ltyp,typename rtyp> static auto cmp(int unsigned & num,int uns
::std::cout <<"\x1B[38;5;77mequal\x1B[0m\n";
}
-#define cmp(lval,rval) (::cmp(num,numerr,__LINE__,(lval),(rval)))
+#define cmp(lval,rval) (::cmp(numerr,__LINE__,(lval),(rval)))
int main() {
- int unsigned num;
int unsigned numerr = 0x0u;
- auto const tst = [&num](char const * const cmp_eq) noexcept {
- ::std::cout <<"\n\x1B[38;5;75mtesting\x1B[0m " <<cmp_eq <<"\n\n";
-
- num = 0x0;
+ auto const tst = [](char const * const tst) noexcept {
+ ::std::cout <<"\n\x1B[38;5;75mtesting\x1B[0m " << tst <<"\n\n";
};
::std::cout <<"zp " <<::zp::ver.api <<"." <<::zp::ver.ext <<", run-time test\n";
@@ -220,7 +217,7 @@ int main() {
}();
[&] {
- tst("mathematics");
+ tst("special numbers");
::zp::f02 f02;
::zp::f04 f04;
@@ -237,8 +234,12 @@ int main() {
f02 = ::zp::inf<::zp::f02>::val;
f04 = ::zp::inf<::zp::f04>::val;
- cmp(f02 >= ::zp::maxval<::zp::f02>::val,true);
- cmp(f04 >= ::zp::maxval<::zp::f04>::val,true);
+ cmp(f02 > ::zp::maxval<::zp::f02>::val,true);
+ cmp(f04 > ::zp::maxval<::zp::f04>::val,true);
+ }();
+
+ [&] {
+ tst("mathematics");
}();
/*[&] {
@@ -286,14 +287,6 @@ int main() {
cmp(avec2.y,-0x7);
cmp(svec2.x,-0x1);
cmp(svec2.y,+0x1);
- }();
-
- [&] {
- tst("special numbers");
-
- cmp(zp_isnanf( zp_nanf), true);
- cmp(zp_isnand( zp_nand), true);
- cmp(zp_isnandl(zp_nanld),true);
}();*/
[&] {
@@ -414,5 +407,5 @@ int main() {
::std::cout <<"\nDone \u2212 " <<numerr <<" error(s)\n";
- return EXIT_SUCCESS;
+ return numerr ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/zp/GNUmakefile b/zp/GNUmakefile
index e1f2d49..2e71b51 100644
--- a/zp/GNUmakefile
+++ b/zp/GNUmakefile
@@ -2,17 +2,19 @@
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-ifeq "$(targ)" ""
-targ := $(shell ../getTarget.sh)
-$(info Targeting $(targ)!)
+ifeq "$(tar)" ""
+tar := $(shell ../getTarget.sh)
+$(info Targeting $(tar)!)
endif
-ifeq "$(targ)" "amd64"
+ifeq "$(tar)" "amd64"
AS := nasm -felf64
-else ifeq "$(targ)" "ia32"
+else ifeq "$(tar)" "ia32"
AS := nasm -felf32
endif
+CXX := g++
+
ifeq "$(stdc)" ""
stdc := c90
endif
@@ -21,7 +23,7 @@ ifeq "$(stdcxx)" ""
stdcxx := c++98
endif
-OBJ_BAS_TRP := source/any/zp/trp.o
+OBJ_ZP_TRP := source/any/zp/trp.o
OBJ_MEM_MEMCPY := source/any/mem/memcpy.o
OBJ_MEM_MEMEQU := source/any/mem/memequ.o
@@ -31,6 +33,7 @@ OBJ_MEM_MEMSRH := source/any/mem/memsrh.o
#OBJ_MTH_ABS := source/any/mth/abs.o
#OBJ_MTH_DIVMOD := source/any/mth/divmod.o
#OBJ_MTH_DOT := source/any/mth/dot.o
+OBJ_MTH_ISNAN := source/any/mth/isnan.o
#OBJ_MTH_VADD := source/any/mth/vadd.o
#OBJ_MTH_VSUB := source/any/mth/vsub.o
@@ -62,34 +65,34 @@ OBJ_STR_WSTRFIL := source/any/str/wstrfil.o
OBJ_STR_WSTRLEN := source/any/str/wstrlen.o
OBJ_STR_WSTRSRH := source/any/str/wstrsrh.o
-OBJ_BAS_SYSCAL := source/any/zp/syscal.o
+OBJ_ZP_SYSCAL := source/any/zp/syscal.o
-ifeq "$(targ)" "amd64"
+ifeq "$(tar)" "amd64"
-OBJ_BAS_SYSCAL := source/amd64/zp/syscal.o
-OBJ_BAS_TRP := source/amd64/zp/trp.o
+OBJ_ZP_SYSCAL := source/amd64/zp/syscal.o
+OBJ_ZP_TRP := source/amd64/zp/trp.o
OBJ_MEM_MEMCPY := source/amd64/mem/memcpy.o
OBJ_MEM_MEMFIL := source/amd64/mem/memfil.o
-else ifeq "$(targ)" "arm"
+else ifeq "$(tar)" "arm"
-OBJ_BAS_SYSCAL := source/arm/zp/syscal.o
+OBJ_ZP_SYSCAL := source/arm/zp/syscal.o
OBJ_MEM_MEMCPY := source/arm/mem/memcpy.o
-else ifeq "$(targ)" "arm64"
+else ifeq "$(tar)" "arm64"
-OBJ_BAS_SYSCAL := source/arm64/zp/syscal.o
+OBJ_ZP_SYSCAL := source/arm64/zp/syscal.o
OBJ_MEM_MEMCPY := source/arm64/mem/memcpy.o
-else ifeq "$(targ)" "ia32"
+else ifeq "$(tar)" "ia32"
-OBJ_BAS_SYSCAL := source/ia32/zp/syscal.o
+OBJ_ZP_SYSCAL := source/ia32/zp/syscal.o
endif
OBJS := \
- $(OBJ_BAS_TRP) \
+ $(OBJ_ZP_TRP) \
\
$(OBJ_MEM_MEMCPY) \
$(OBJ_MEM_MEMEQU) \
@@ -99,6 +102,7 @@ OBJS := \
$(OBJ_MTH_ABS) \
$(OBJ_MTH_DIVMOD) \
$(OBJ_MTH_DOT) \
+ $(OBJ_MTH_ISNAN) \
$(OBJ_MTH_VADD) \
$(OBJ_MTH_VSUB) \
\
@@ -133,7 +137,7 @@ OBJS := \
ifneq "$(nosyscal)" "true"
OBJS := \
$(OBJS) \
- $(OBJ_BAS_SYSCL)
+ $(OBJ_ZP_SYSCAL)
endif
ifeq "$(shrlib)" "true"
@@ -192,13 +196,13 @@ CXXFLAGS := \
ifeq "$(shrlib)" "true"
CFLAGS := \
$(CFLAGS) \
- -Ofast \
+ -O3 \
-fpic \
-g
CXXFLAGS := \
$(CXXFLAGS) \
- -Ofast \
+ -O3 \
-fpic \
-g
diff --git a/zp/include/zp/mth b/zp/include/zp/mth
index 4887c67..4122a47 100644
--- a/zp/include/zp/mth
+++ b/zp/include/zp/mth
@@ -82,13 +82,13 @@ namespace zp {
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::divmodres<i02s> divmod(::zp::i02s num,::zp::i02s den);
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::divmodres<i04s> divmod(::zp::i04s num,::zp::i04s den);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot2(::zp::vec2< ::zp::f02> lvec,::zp::vec2< ::zp::f02> rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot2(::zp::vec2< ::zp::f02> lvec,::zp::vec2< ::zp::f02> rvec);
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot2(::zp::vec2< ::zp::f04> lvec,::zp::vec2< ::zp::f04> rvec);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot3(::zp::vec3< ::zp::f02> lvec,::zp::vec3< ::zp::f02> rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot3(::zp::vec3< ::zp::f02> lvec,::zp::vec3< ::zp::f02> rvec);
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot3(::zp::vec3< ::zp::f04> lvec,::zp::vec3< ::zp::f04> rvec);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot4(::zp::vec4< ::zp::f02> lvec,::zp::vec4< ::zp::f02> rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot4(::zp::vec4< ::zp::f02> lvec,::zp::vec4< ::zp::f02> rvec);
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot4(::zp::vec4< ::zp::f04> lvec,::zp::vec4< ::zp::f04> rvec);
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 exp(::zp::f02 val,::zp::f02 n);
diff --git a/zp/include/zp/mth.h b/zp/include/zp/mth.h
index 5166d10..dbfe695 100644
--- a/zp/include/zp/mth.h
+++ b/zp/include/zp/mth.h
@@ -61,10 +61,6 @@ typedef struct {
zp_f04 w;
} zp_vec4f04;
-/* is not-a-number */
-#define zp_isnanf02(val) ((bool)((val) != (val)))
-#define zp_isnanf04(val) ((bool)((val) != (val)))
-
/* absolute */
zp_nothw zp_unseq zp_useres zp_f02 zp_absf02(zp_f02 val);
zp_nothw zp_unseq zp_useres zp_f04 zp_absf04(zp_f04 val);
@@ -147,6 +143,10 @@ zp_nothw zp_unseq zp_useres zp_f04 zp_dot4f04(zp_vec4f04 lvec,zp_vec4f04 rvec);
zp_nothw zp_unseq zp_useres zp_f02 zp_expf02(zp_f02 val,zp_f02 n);
zp_nothw zp_unseq zp_useres zp_f04 zp_expf04(zp_f04 val,zp_f04 n);
+/* is a not-a-number */
+zp_nothw zp_unseq zp_useres bool zp_isnanf02(zp_f02 val);
+zp_nothw zp_unseq zp_useres bool zp_isnanf04(zp_f04 val);
+
/* binary logarithm */
zp_nothw zp_unseq zp_useres zp_f02 zp_lbf02(zp_f02 val);
zp_nothw zp_unseq zp_useres zp_f04 zp_lbf04(zp_f04 val);
diff --git a/zp/source/any/mth/isnan.cc b/zp/source/any/mth/isnan.cc
new file mode 100644
index 0000000..0efa156
--- /dev/null
+++ b/zp/source/any/mth/isnan.cc
@@ -0,0 +1,12 @@
+/*
+ Copyright 2022-2023 Gabriel Jensen.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
+*/
+
+#include <zp/mth.h>
+
+extern "C" {
+ zp_nothw bool zp_isnanf02(zp_f02 const val) {return val != val;}
+ zp_nothw bool zp_isnanf04(zp_f04 const val) {return val != val;}
+}