Update res.exp and opt.exp: Take variadic parameters; Add inheritable error type (that may be used for exceptions): err; Implement trp in inline assembly; Raise SIGTRAP on some hosted environments in trp; Fix error in ARM64 syscal comment; Add (C++98 compatible) metaprogramming class for special values: val; Rework arrays; Add function for moving memory sequences: mov;
This commit is contained in:
parent
3d285c927d
commit
18e345cb48
15 changed files with 562 additions and 358 deletions
|
@ -12,6 +12,15 @@
|
|||
* Rename remqual to remcv;
|
||||
* Fix nan and inf for qualified types;
|
||||
|
||||
* Update res.exp and opt.exp: Take variadic parameters;
|
||||
* Add inheritable error type (that may be used for exceptions): err;
|
||||
* Implement trp in inline assembly;
|
||||
* Raise SIGTRAP on some hosted environments in trp;
|
||||
* Fix error in ARM64 syscal comment;
|
||||
* Add (C++98 compatible) metaprogramming class for special values: val;
|
||||
* Rework arrays;
|
||||
* Add function for moving memory sequences: mov;
|
||||
|
||||
# 1.1.1
|
||||
|
||||
* Fix res dtor calls;
|
||||
|
|
61
test.cc
61
test.cc
|
@ -91,12 +91,11 @@ static_assert(::zp::typequ<::zp::nulptrtyp,::std::nullptr_t>::val == true);
|
|||
static_assert(::zp::bytelen == CHAR_BIT);
|
||||
|
||||
template<typename typtyp> constexpr static auto chktyp() noexcept -> bool {
|
||||
using ::zp::inf;
|
||||
using ::zp::nan;
|
||||
using ::zp::nulptr;
|
||||
using ::zp::typequ;
|
||||
|
||||
using typ = ::zp::typ<typtyp>;
|
||||
using val = ::zp::val<typtyp>;
|
||||
using numlim = ::std::numeric_limits<typtyp>;
|
||||
|
||||
if constexpr (!typequ<typename ::zp::remcv<typtyp>::typ,bool>::val && !typ::ischr) {static_assert(typ::isint == ::std::is_integral_v<typtyp>);}
|
||||
|
@ -107,11 +106,11 @@ template<typename typtyp> constexpr static auto chktyp() noexcept -> bool {
|
|||
|
||||
static_assert(typ::hassgn == numlim::is_signed);
|
||||
|
||||
static_assert(typ::min == numlim::lowest());
|
||||
static_assert(typ::max == numlim::max());
|
||||
static_assert(val::min() == numlim::lowest());
|
||||
static_assert(val::max() == numlim::max());
|
||||
|
||||
if constexpr (typ::isflt) {
|
||||
static_assert(inf<typtyp>::val == numlim::infinity());
|
||||
static_assert(val::inf() == numlim::infinity());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -307,17 +306,17 @@ int main() {
|
|||
chkeq(sizeof (f02),0x4u);
|
||||
chkeq(sizeof (f04),0x8u);
|
||||
|
||||
f02 = ::zp::nan<::zp::f02>::val;
|
||||
f04 = ::zp::nan<::zp::f04>::val;
|
||||
f02 = ::zp::val<::zp::f02>::nan();
|
||||
f04 = ::zp::val<::zp::f04>::nan();
|
||||
|
||||
chkeq(::zp::isnan(f02),true);
|
||||
chkeq(::zp::isnan(f04),true);
|
||||
|
||||
f02 = ::zp::inf<::zp::f02>::val;
|
||||
f04 = ::zp::inf<::zp::f04>::val;
|
||||
f02 = ::zp::val<::zp::f02>::inf();
|
||||
f04 = ::zp::val<::zp::f04>::inf();
|
||||
|
||||
chkgt(f02,::zp::typ<::zp::f02>::max);
|
||||
chkgt(f04,::zp::typ<::zp::f04>::max);
|
||||
chkgt(f02,::zp::val<::zp::f02>::max());
|
||||
chkgt(f04,::zp::val<::zp::f04>::max());
|
||||
}();
|
||||
|
||||
[&] {
|
||||
|
@ -483,45 +482,31 @@ int main() {
|
|||
delete[] buf02;
|
||||
}();
|
||||
|
||||
#if false
|
||||
[&] {
|
||||
tst("boxes");
|
||||
|
||||
::zp::box<::zp::i8s,::std::allocator<::zp::i8s>> box0 = 0x4;
|
||||
|
||||
chkeq(*box0,0x4);
|
||||
|
||||
::zp::box<::zp::i8s,::std::allocator<::zp::i8s>> const box1 = 0x0-box1;
|
||||
|
||||
chkeq(*box1,-0x4);
|
||||
}();
|
||||
#endif
|
||||
|
||||
[&] {
|
||||
tst("arrays");
|
||||
|
||||
::zp::arr<::zp::i8,::std::allocator<::zp::i8>> arr(0x8u);
|
||||
auto arr0 = ::zp::arr<::zp::i8,::std::allocator<::zp::i8>>::alc(0x8u);
|
||||
|
||||
chkeq(arr.len(),0x8u);
|
||||
chkeq(arr0.len(),0x8u);
|
||||
|
||||
arr[0x0] = 0x7Fu;
|
||||
arr[0x1] = 0x3Fu;
|
||||
arr[0x2] = 0x1Fu;
|
||||
arr[0x3] = 0x0Fu;
|
||||
arr[0x4] = 0x07u;
|
||||
arr[0x5] = 0x03u;
|
||||
arr[0x6] = 0x01u;
|
||||
arr[0x7] = 0x00u;
|
||||
arr0[0x0] = 0x7Fu;
|
||||
arr0[0x1] = 0x3Fu;
|
||||
arr0[0x2] = 0x1Fu;
|
||||
arr0[0x3] = 0x0Fu;
|
||||
arr0[0x4] = 0x07u;
|
||||
arr0[0x5] = 0x03u;
|
||||
arr0[0x6] = 0x01u;
|
||||
arr0[0x7] = 0x00u;
|
||||
|
||||
::zp::i8 prv = 0xFFu;
|
||||
for (::zp::i8 const val : arr) {
|
||||
for (::zp::i8 const val : arr0) {
|
||||
chkeq(val,static_cast<::zp::i8>(prv>>0x1u));
|
||||
prv = val;
|
||||
}
|
||||
|
||||
arr.fil(0xFFu);
|
||||
arr0.fil(0xFFu);
|
||||
|
||||
for (::zp::i8 const val : arr) {
|
||||
for (::zp::i8 const val : arr0) {
|
||||
chkeq(val,0xFFu);
|
||||
}
|
||||
}();
|
||||
|
|
|
@ -23,8 +23,6 @@ ifeq "$(stdcxx)" ""
|
|||
stdcxx := c++98
|
||||
endif
|
||||
|
||||
OBJ_ZP_TRP := source/any/zp/trp.o
|
||||
|
||||
OBJ_MEM_MEMCPY := source/any/mem/memcpy.o
|
||||
OBJ_MEM_MEMEQU := source/any/mem/memequ.o
|
||||
OBJ_MEM_MEMFIL := source/any/mem/memfil.o
|
||||
|
@ -65,11 +63,11 @@ OBJ_STR_WSTRLEN := source/any/str/wstrlen.o
|
|||
OBJ_STR_WSTRSRH := source/any/str/wstrsrh.o
|
||||
|
||||
OBJ_ZP_SYSCAL := source/any/zp/syscal.o
|
||||
OBJ_ZP_TRP := source/any/zp/trp.o
|
||||
|
||||
ifeq "$(tar)" "amd64"
|
||||
|
||||
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
|
||||
|
@ -146,51 +144,56 @@ LIB := libzp.a
|
|||
endif
|
||||
|
||||
HDRS := \
|
||||
include/zp/mem \
|
||||
include/zp/mem.h \
|
||||
include/zp/mth \
|
||||
include/zp/mth.h \
|
||||
include/zp/str \
|
||||
include/zp/str.h \
|
||||
include/zp/zp \
|
||||
include/zp/zp.h \
|
||||
include/zp/det/mem.ii \
|
||||
include/zp/det/mth.ii \
|
||||
include/zp/det/str.ii \
|
||||
include/zp/det/zp.ii \
|
||||
include/zp/prv/arc.h \
|
||||
include/zp/prv/chr.h \
|
||||
include/zp/prv/flt.h \
|
||||
include/zp/prv/imp.h \
|
||||
include/zp/prv/int.h \
|
||||
include/zp/prv/std.h \
|
||||
include/zp/prv/sys.h \
|
||||
include-private/zp/prv/fmt \
|
||||
include/zp/mem \
|
||||
include/zp/mem.h \
|
||||
include/zp/mth \
|
||||
include/zp/mth.h \
|
||||
include/zp/str \
|
||||
include/zp/str.h \
|
||||
include/zp/zp \
|
||||
include/zp/zp.h \
|
||||
include/zp/det/mem.ii \
|
||||
include/zp/det/mth.ii \
|
||||
include/zp/det/str.ii \
|
||||
include/zp/det/zp.ii \
|
||||
include/zp/det/mem.d/arr.ii \
|
||||
include/zp/prv/arc.h \
|
||||
include/zp/prv/chr.h \
|
||||
include/zp/prv/flt.h \
|
||||
include/zp/prv/imp.h \
|
||||
include/zp/prv/int.h \
|
||||
include/zp/prv/std.h \
|
||||
include/zp/prv/sys.h \
|
||||
include-private/zp/prv/fmt \
|
||||
include-private/zp/prv/str
|
||||
|
||||
CFLAGS := \
|
||||
-Iinclude \
|
||||
-Iinclude-private \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wpedantic \
|
||||
-ffreestanding \
|
||||
-fshort-enums \
|
||||
-nostdlib \
|
||||
-pipe \
|
||||
-Iinclude \
|
||||
-Iinclude-private \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wpedantic \
|
||||
-ffreestanding \
|
||||
-fno-strict-aliasing \
|
||||
-fno-strict-overflow \
|
||||
-fshort-enums \
|
||||
-nostdlib \
|
||||
-pipe \
|
||||
-std=$(stdc)
|
||||
|
||||
CXXFLAGS := \
|
||||
-Iinclude \
|
||||
-Iinclude-private \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wpedantic \
|
||||
-ffreestanding \
|
||||
-fno-exceptions \
|
||||
-fshort-enums \
|
||||
-nostdlib \
|
||||
-pipe \
|
||||
-Iinclude \
|
||||
-Iinclude-private \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wpedantic \
|
||||
-ffreestanding \
|
||||
-fno-exceptions \
|
||||
-fno-strict-aliasing \
|
||||
-fno-strict-overflow \
|
||||
-fshort-enums \
|
||||
-nostdlib \
|
||||
-pipe \
|
||||
-std=$(stdcxx)
|
||||
|
||||
ifeq "$(shrlib)" "true"
|
||||
|
|
48
zp/include/zp/det/mem.d/arr.ii
Normal file
48
zp/include/zp/det/mem.d/arr.ii
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
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>.
|
||||
*/
|
||||
|
||||
template<typename typ,typename alctyp> ::zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> const& oth) : _alc(alctyp {}),_len(oth._len) {
|
||||
this->_buf = this->_alc.allocate(this->_len);
|
||||
::zp::cpy(this->_buf,oth._buf,oth._len);
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> ::zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> && oth) : _alc(oth._alc),_buf(oth._buf),_len(oth._len) {oth._buf = ::zp::nulptr<typ>();}
|
||||
|
||||
template<typename typ,typename alctyp> ::zp::arr<typ,alctyp>::~arr() noexcept(false) {
|
||||
zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return;}
|
||||
|
||||
for (typ * elm = this->begin();elm != this->end();++elm) {elm->~typ();} // Destroy the elements.
|
||||
|
||||
this->_alc.deallocate(this->_buf,this->_len);
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> template<typename... argtyp> auto ::zp::arr<typ,alctyp>::alc(::zp::siz const len,argtyp const&... arg) -> ::zp::arr<typ,alctyp> {
|
||||
::zp::arr<typ,alctyp> arr;
|
||||
|
||||
arr._len = len;
|
||||
arr._buf = arr._alc.allocate(len);
|
||||
zp_unlik (arr._buf == ::zp::nulptr<typ>()) {::zp::trp();} // If the allocator does NOT throw exceptions.
|
||||
|
||||
for (typ * elm = arr.begin();elm != arr.end();++elm) {*elm = typ {arg...};} // Construct the elements.
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::oky() const noexcept -> bool {return this->_buf == ::zp::nulptr<typ>();}
|
||||
|
||||
template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::len() const noexcept -> ::zp::siz {return this->_len;}
|
||||
|
||||
template<typename typ,typename alctyp> template<typename valtyp> ::zp::siz ::zp::arr<typ,alctyp>::fil(valtyp const& val) {return static_cast<::zp::siz>(::zp::fil(this->_buf,val,this->_len)-this->_buf);}
|
||||
|
||||
template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::begin() noexcept -> typ * {return this->_buf;}
|
||||
template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::begin() const noexcept -> typ const* {return this->_buf;}
|
||||
template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::end() noexcept -> typ * {return this->_buf+this->_len;}
|
||||
template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::end() const noexcept -> typ const* {return this->_buf+this->_len;}
|
||||
|
||||
template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::operator [](::zp::ptrdif const off) noexcept -> typ & {zp_unlik (off < 0x0) {::zp::trp();} return this->_buf[off];}
|
||||
template<typename typ,typename alctyp> auto ::zp::arr<typ,alctyp>::operator [](::zp::ptrdif const off) const noexcept -> typ const& {zp_unlik (off < 0x0) {::zp::trp();} return this->_buf[off];}
|
||||
|
||||
template<typename typ,typename alctyp> ::zp::arr<typ,alctyp>::arr() : _alc(alctyp {}) {}
|
|
@ -4,82 +4,8 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
#if zp_std_cxx11 && false
|
||||
template<typename typ,typename alctyp> ::zp::box<typ,alctyp>::box(typ const& val) : _alc(alctyp {}) {
|
||||
this->_obj.buf = this->_alc(0x1);
|
||||
*this->_obj.buf = val;
|
||||
this->_obj.cnt = 0x0u;
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> ::zp::box<typ,alctyp>::box(typ && val) : _alc(alctyp {}) {
|
||||
this->_obj.buf = this->_alc.allocate(0x1u);
|
||||
*this->_obj.buf = val;
|
||||
*this->_obj.cnt = 0x0u;
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> ::zp::box<typ,alctyp>::~box() noexcept(false) {
|
||||
this->_buf->~typ();
|
||||
this->_alc.deallocate(this->_buf,0x1u);
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator =(typ const& val) -> ::zp::box<typ,alctyp> & {*this->_obj.buf = val;return *this;}
|
||||
template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator =(typ && val) -> ::zp::box<typ,alctyp> & {*this->_obj.buf = val;return *this;}
|
||||
|
||||
template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator *() noexcept -> typ & {return *this->_buf;}
|
||||
template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator *() const noexcept -> typ const& {return *this->_buf;}
|
||||
template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator &() noexcept -> typ * {return this->_buf;}
|
||||
template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator &() const noexcept -> typ const* {return this->_buf;}
|
||||
template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator ->() noexcept -> typ * {return *this->_buf;}
|
||||
template<typename typ,typename alctyp> auto ::zp::box<typ,alctyp>::operator ->() const noexcept -> typ const* {return *this->_buf;}
|
||||
|
||||
template<typename typ,typename alctyp> ::zp::box<typ,alctyp>::operator typ() const noexcept {return *this->_buf;}
|
||||
#endif
|
||||
|
||||
#if zp_std_cxx11
|
||||
template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr() : _alc(alctyp()) {}
|
||||
|
||||
/*template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> & oth) : _alc(alctyp()),_buf(this->_alc.allocate(len)),_len(oth._len) {
|
||||
|
||||
zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return;} // Allocation failed.
|
||||
|
||||
::zp::cpy(this->_buf,oth._buf,oth._len);
|
||||
}*/
|
||||
|
||||
template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::siz const len) : _alc(alctyp {}) {
|
||||
this->_buf = this->_alc.allocate(len);
|
||||
this->_len = len;
|
||||
}
|
||||
|
||||
#if zp_std_cxx11
|
||||
template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> && oth) : _alc(oth._alc),_buf(oth._buf),_len(oth._len) {oth._buf = ::zp::nulptr<typ>();}
|
||||
#endif
|
||||
|
||||
template<typename typ,typename alctyp> zp_nothw zp::arr<typ,alctyp>::~arr() {
|
||||
zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return;}
|
||||
this->_alc.deallocate(this->_buf,this->_len);
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> zp_nothw bool zp::arr<typ,alctyp>::oky() const {return this->_buf == ::zp::nulptr<typ>();}
|
||||
|
||||
template<typename typ,typename alctyp> zp_nothw ::zp::siz zp::arr<typ,alctyp>::len() const {return this->_len;}
|
||||
|
||||
template<typename typ,typename alctyp> bool zp::arr<typ,alctyp>::alc(::zp::siz const len) {
|
||||
this->_len = len;
|
||||
this->_buf = this->_alc(len);
|
||||
|
||||
zp_unlik (this->_buf == ::zp::nulptr<typ>()) {return true;} // If the allocator does NOT throw exceptions.
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> template<typename valtyp> ::zp::siz zp::arr<typ,alctyp>::fil(valtyp const& val) {return static_cast<::zp::siz>(::zp::fil(this->_buf,val,this->_len)-this->_buf);}
|
||||
|
||||
template<typename typ,typename alctyp> typ * zp::arr<typ,alctyp>::begin() {return this->_buf;}
|
||||
template<typename typ,typename alctyp> typ const* zp::arr<typ,alctyp>::begin() const {return this->_buf;}
|
||||
template<typename typ,typename alctyp> typ * zp::arr<typ,alctyp>::end() {return this->_buf+this->_len;}
|
||||
template<typename typ,typename alctyp> typ const* zp::arr<typ,alctyp>::end() const {return this->_buf+this->_len;}
|
||||
|
||||
template<typename typ,typename alctyp> typ & zp::arr<typ,alctyp>::operator [](::zp::ptrdif const off) {return this->_buf[off];}
|
||||
template<typename typ,typename alctyp> typ const& zp::arr<typ,alctyp>::operator [](::zp::ptrdif const off) const {return this->_buf[off];}
|
||||
#include <zp/det/mem.d/arr.ii>
|
||||
#endif
|
||||
|
||||
template<typename dsttyp,typename srctyp> zp_nothw inline ::zp::cpyres<dsttyp,srctyp> zp::memcpy(dsttyp * dst,srctyp const* src,::zp::siz const num) {
|
||||
|
@ -94,7 +20,7 @@ template<typename dsttyp,typename srctyp> zp_nothw inline ::zp::cpyres<dsttyp,sr
|
|||
}
|
||||
|
||||
template<typename ltyp,typename rtyp> ::zp::cpyres<ltyp,rtyp> zp::cpy(ltyp * dst,rtyp * src,::zp::siz const num) {
|
||||
ltyp * const stp = dst+num;
|
||||
ltyp * const stp = dst+num;
|
||||
while (dst != stp) {*dst++ = *src++;}
|
||||
|
||||
::zp::cpyres<ltyp,rtyp> res;
|
||||
|
@ -131,3 +57,12 @@ template<typename buftyp,typename valtyp> buftyp * zp::srh(buftyp * buf,valtyp &
|
|||
|
||||
return ::zp::nulptr<buftyp>();
|
||||
}
|
||||
|
||||
#if zp_std_cxx11
|
||||
template<typename ltyp,typename rtyp> ::zp::cpyres<ltyp,rtyp> zp::mov(ltyp * dst,rtyp * src,::zp::siz const num) {
|
||||
ltyp * const stp = dst+num;
|
||||
while (dst != stp) {*dst++ = ::zp::fwd(*src++);}
|
||||
|
||||
return ::zp::cpyres<ltyp,rtyp> {dst,src};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -36,9 +36,9 @@ template<typename typ> auto ::zp::opt<typ>::chk() const noexcept -> bool {return
|
|||
|
||||
template<typename typ> auto ::zp::opt<typ>::val() const noexcept -> typ const& {return this->_val;}
|
||||
|
||||
template<typename typ> template<typename funtyp,typename msgtyp> auto ::zp::opt<typ>::exp(funtyp const& fun,msgtyp const& msg) const noexcept -> typ const& {
|
||||
template<typename typ> template<typename funtyp,typename... argtyp> auto ::zp::opt<typ>::exp(funtyp const& fun,argtyp const&... arg) const noexcept -> typ const& {
|
||||
zp_unlik (!this->_hasval) {
|
||||
fun(msg);
|
||||
fun(arg...);
|
||||
::zp::unrch();
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ template<typename okytyp,typename errtyp> auto ::zp::res<okytyp,errtyp>::getoky(
|
|||
|
||||
template<typename okytyp,typename errtyp> auto ::zp::res<okytyp,errtyp>::geterr() const noexcept -> errtyp const& {return this->_errval;}
|
||||
|
||||
template<typename okytyp,typename errtyp> template<typename funtyp,typename msgtyp> auto ::zp::res<okytyp,errtyp>::exp(funtyp const& fun,msgtyp const& msg) const noexcept -> okytyp const& {
|
||||
template<typename okytyp,typename errtyp> template<typename funtyp,typename... argtyp> auto ::zp::res<okytyp,errtyp>::exp(funtyp const& fun,argtyp const&... arg) const noexcept -> okytyp const& {
|
||||
zp_unlik (!this->_hasoky) {
|
||||
fun(msg);
|
||||
fun(arg...);
|
||||
::zp::unrch();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,82 +11,46 @@
|
|||
#include <zp/mem.h>
|
||||
|
||||
namespace zp {
|
||||
struct alcerr : public err {};
|
||||
|
||||
template<typename dsttyp,typename srctyp> struct cpyres {
|
||||
dsttyp * dst;
|
||||
srctyp * src;
|
||||
};
|
||||
|
||||
#if zp_std_cxx11 && false
|
||||
namespace det {
|
||||
template<typename typ,typename alctyp> struct boxobj {
|
||||
alctyp alc
|
||||
::zp::i02 cnt;
|
||||
typ * buf;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename typ,typename alctyp> class box {
|
||||
public:
|
||||
box() = delete;
|
||||
box(box<typ,alctyp> const& oth);
|
||||
box(box<typ,alctyp> && oth);
|
||||
box(typ const& val);
|
||||
box(typ && val);
|
||||
|
||||
~box() noexcept(false);
|
||||
|
||||
auto operator =(typ const& val) -> ::zp::box<typ,alctyp> &;
|
||||
auto operator =(typ && val) -> ::zp::box<typ,alctyp> &;
|
||||
|
||||
auto operator *() noexcept -> typ &;
|
||||
auto operator *() const noexcept -> typ const&;
|
||||
auto operator &() noexcept -> typ *;
|
||||
auto operator &() const noexcept -> typ const*;
|
||||
auto operator ->() noexcept -> typ *;
|
||||
auto operator ->() const noexcept -> typ const*;
|
||||
|
||||
operator typ() const noexcept;
|
||||
|
||||
private:
|
||||
alctyp _alc;
|
||||
boxobj<typ,alctyp> _obj;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if zp_std_cxx11
|
||||
template<typename typ,typename alctyp> class arr {
|
||||
public:
|
||||
zp_nothw arr();
|
||||
arr(::zp::arr<typ,alctyp> & oth);
|
||||
explicit arr(::zp::siz len);
|
||||
#if zp_std_cxx11
|
||||
zp_nothw arr(::zp::arr<typ,alctyp> && oth);
|
||||
#endif
|
||||
arr(::zp::arr<typ,alctyp> const& oth);
|
||||
arr(::zp::arr<typ,alctyp> && oth);
|
||||
|
||||
zp_nothw ~arr();
|
||||
~arr() noexcept(false);
|
||||
|
||||
zp_nothw bool oky() const;
|
||||
template<typename... argtyp> static auto alc(::zp::siz len,argtyp const&... arg) -> ::zp::arr<typ,alctyp>;
|
||||
|
||||
zp_nothw typ * ptr();
|
||||
zp_nothw typ const* ptr() const;
|
||||
zp_nothw ::zp::siz len() const;
|
||||
auto oky() const noexcept -> bool;
|
||||
|
||||
bool alc(::zp::siz len);
|
||||
auto ptr() noexcept -> typ *;
|
||||
auto ptr() const noexcept -> typ const*;
|
||||
auto len() const noexcept -> ::zp::siz;
|
||||
|
||||
template<typename valtyp> ::zp::siz fil(valtyp const& val);
|
||||
template<typename othval,typename othalc> auto cpy(::zp::arr<othval,othalc> const& oth) -> ::zp::siz;
|
||||
template<typename valtyp> auto fil(valtyp const& val) -> ::zp::siz;
|
||||
|
||||
zp_nothw typ * begin();
|
||||
zp_nothw typ const* begin() const;
|
||||
zp_nothw typ * end();
|
||||
zp_nothw typ const* end() const;
|
||||
auto begin() noexcept -> typ *;
|
||||
auto begin() const noexcept -> typ const*;
|
||||
auto end() noexcept -> typ *;
|
||||
auto end() const noexcept -> typ const*;
|
||||
|
||||
zp_nothw typ & operator [](::zp::ptrdif off);
|
||||
zp_nothw typ const& operator [](::zp::ptrdif off) const;
|
||||
auto operator [](::zp::ptrdif off) noexcept -> typ &; // Always UB if (off<0).
|
||||
auto operator [](::zp::ptrdif off) const noexcept -> typ const&;
|
||||
|
||||
private:
|
||||
alctyp _alc;
|
||||
typ * _buf;
|
||||
::zp::siz _len;
|
||||
|
||||
arr();
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -96,12 +60,12 @@ namespace zp {
|
|||
template<typename typ> zp_useres zp_nothw zp_iln inline typ * memsrh(typ * zp_prv_rsr buf, char unsigned val, ::zp::siz const num) {return static_cast<typ *>(::zp_memsrh(buf,val,num));}
|
||||
template<typename typ> zp_useres zp_nothw zp_iln inline typ const* memsrh(typ const* zp_prv_rsr buf, char unsigned val, ::zp::siz const num) {return const_cast<typ const*>(static_cast<typ *>(::zp_memsrh(buf,val,num)));}
|
||||
|
||||
template<typename ltyp, typename rtyp> zp_nothw ::zp::cpyres<ltyp,rtyp> cpy(ltyp * dst, rtyp * src, ::zp::siz num);
|
||||
template<typename ltyp, typename rtyp> zp_nothw bool equ(ltyp * lbuf,rtyp * rbuf,::zp::siz num);
|
||||
template<typename buftyp,typename valtyp> zp_nothw buftyp * fil(buftyp * buf, valtyp & val, ::zp::siz num);
|
||||
template<typename buftyp,typename valtyp> zp_nothw buftyp * srh(buftyp * buf, valtyp & val, ::zp::siz num);
|
||||
template<typename ltyp, typename rtyp> ::zp::cpyres<ltyp,rtyp> cpy(ltyp * dst, rtyp * src, ::zp::siz num);
|
||||
template<typename ltyp, typename rtyp> bool equ(ltyp * lbuf,rtyp * rbuf,::zp::siz num);
|
||||
template<typename buftyp,typename valtyp> buftyp * fil(buftyp * buf, valtyp & val, ::zp::siz num);
|
||||
template<typename buftyp,typename valtyp> buftyp * srh(buftyp * buf, valtyp & val, ::zp::siz num);
|
||||
#if zp_std_cxx11
|
||||
template<typename ltyp, typename rtyp> zp_nothw ::zp::cpyres<ltyp,rtyp> cpy(ltyp * dst, rtyp * src, ::zp::siz num); // Identical to cpy except that all values are passed to fwd firstly.
|
||||
template<typename ltyp, typename rtyp> ::zp::cpyres<ltyp,rtyp> mov(ltyp * dst, rtyp * src, ::zp::siz num); // Identical to cpy except that all values are passed to fwd firstly.
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ typedef struct {
|
|||
void * src;
|
||||
} zp_cpyres;
|
||||
|
||||
zp_nothw zp_i02 zp_prv_inc02(zp_i02 * ptr);
|
||||
zp_nothw zp_i02 zp_prv_dec02(zp_i02 * ptr);
|
||||
|
||||
zp_nothw zp_cpyres zp_memcpy(void * zp_prv_rsr dst, void const* zp_prv_rsr src, zp_siz num);
|
||||
zp_nothw zp_useres bool zp_memequ(void const* zp_prv_rsr lbuf,void const* zp_prv_rsr rbuf,zp_siz num);
|
||||
zp_nothw void * zp_memfil(void * zp_prv_rsr dst, char unsigned val, zp_siz num);
|
||||
|
|
|
@ -76,14 +76,6 @@
|
|||
|
||||
#endif
|
||||
|
||||
#define zp_minvalf02 zp_minvalf
|
||||
#define zp_maxvalf02 zp_maxvalf
|
||||
typedef float zp_f02;
|
||||
|
||||
#define zp_minvalf04 zp_minvald
|
||||
#define zp_maxvalf04 zp_maxvald
|
||||
typedef double zp_f04;
|
||||
|
||||
#if zp_prv_hasbltin(__builtin_nan)
|
||||
#define zp_nand (__builtin_nan(""))
|
||||
#else
|
||||
|
@ -116,8 +108,14 @@ typedef double zp_f04;
|
|||
#define zp_inff (zp_maxvalf)
|
||||
#endif
|
||||
|
||||
#define zp_minvalf02 zp_minvalf
|
||||
#define zp_maxvalf02 zp_maxvalf
|
||||
typedef float zp_f02;
|
||||
#define zp_nanf02 (zp_nanf)
|
||||
#define zp_nanf04 (zp_nand)
|
||||
|
||||
#define zp_inff02 (zp_inff)
|
||||
|
||||
#define zp_minvalf04 zp_minvald
|
||||
#define zp_maxvalf04 zp_maxvald
|
||||
typedef double zp_f04;
|
||||
#define zp_nanf04 (zp_nand)
|
||||
#define zp_inff04 (zp_infd)
|
||||
|
|
464
zp/include/zp/zp
464
zp/include/zp/zp
File diff suppressed because one or more lines are too long
|
@ -4,9 +4,11 @@
|
|||
If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
|
||||
*/
|
||||
|
||||
/* All identifiers in the "priv" namespaces are, */
|
||||
/* well, private, and may not be used by any */
|
||||
/* program (causes UB or something). */
|
||||
/*
|
||||
All identifiers in the "prv" and "det"
|
||||
namespaces are, well, private, and may not be
|
||||
used by any program (causes UB or something).
|
||||
*/
|
||||
|
||||
/*
|
||||
Greater Header Dependencies:
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
; 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>.
|
||||
|
||||
global zp_trp
|
||||
|
||||
zp_trp:
|
||||
ud2
|
|
@ -9,7 +9,7 @@
|
|||
zp_nothw zp_cpyres zp_memcpy(void * const dstptr,void const* const srcptr,zp_siz const num) {
|
||||
zp_cpyres res;
|
||||
|
||||
char unsigned * dst = dstptr;
|
||||
char unsigned * dst = dstptr;
|
||||
char unsigned const* src = srcptr;
|
||||
|
||||
char unsigned * const stp = dst+num;
|
||||
|
|
|
@ -6,9 +6,32 @@
|
|||
|
||||
#include <zp/zp.h>
|
||||
|
||||
void zp_trp(void) {
|
||||
#if zp_prv_hasbltin(__builtin_trap)
|
||||
__builtin_trap();
|
||||
#if zp_sys_lnx
|
||||
#include <linux/unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
void zp_trp(void) {
|
||||
#if zp_sys_lnx
|
||||
|
||||
zp_syscal(__NR_kill,(pid_t)zp_syscal(__NR_getpid),SIGTRAP);
|
||||
|
||||
#elif zp_imp_gcc
|
||||
#if zp_arc_amd64
|
||||
|
||||
__asm__ (
|
||||
"ud2\n"
|
||||
);
|
||||
|
||||
#endif
|
||||
#elif zp_imp_msc
|
||||
#if zp_arc_amd64
|
||||
|
||||
__asm ud2;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for (;;) {}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
zp_syscal:
|
||||
/* System calls on ARM64 use the following registers: */
|
||||
/* x0 : System call identifier */
|
||||
/* x8 : System call identifier */
|
||||
/* x1 : First parameter */
|
||||
/* x2 : Second parameter */
|
||||
/* x3 : Third parameter */
|
||||
|
|
Reference in a new issue