summaryrefslogtreecommitdiff
path: root/zap/include
diff options
context:
space:
mode:
Diffstat (limited to 'zap/include')
-rw-r--r--zap/include/zap/base.h42
-rw-r--r--zap/include/zap/math.h94
-rw-r--r--zap/include/zap/mem.h59
3 files changed, 156 insertions, 39 deletions
diff --git a/zap/include/zap/base.h b/zap/include/zap/base.h
index 4866051..a52414b 100644
--- a/zap/include/zap/base.h
+++ b/zap/include/zap/base.h
@@ -5,31 +5,12 @@
*/
#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
#include <susinfo.h>
-#if !defined(zap_hdr_base)
-#define zap_hdr_base
+#if !defined(zap_priv_hdr_base)
+#define zap_priv_hdr_base
-#define zap_ver ((uint_Least64_t)0xEu)
-
-#if defined(sus_lang_asm)
-
-.extern zap_fndbyte
-.extern zap_fndchr
-.extern zap_foreach
-.extern zap_memcmp
-.extern zap_memcpy
-.extern zap_memeq
-.extern zap_memfill
-.extern zap_strcmp
-.extern zap_strcpy
-.extern zap_streq
-.extern zap_strfill
-.extern zap_strlen
-
-#else
+#define zap_ver (0xFu)
#if defined(sus_lang_cxx)
extern "C" {
@@ -37,23 +18,6 @@ extern "C" {
extern bool const zap_fastimpl;
-/* Memory sequence functions: */
-sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_fndbyte( void const * ptr, size_t num, unsigned char byte);
-sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_fndchr( char const * str, char chr);
-sus_attr_hot sus_attr_nothrw void zap_foreach( void * ptr, size_t sz, size_t num, void (* fn)(void *));
-sus_attr_hot sus_attr_nothrw sus_attr_useret int_least8_t zap_memcmp( void const * lstr,size_t num, void const * rstr);
-sus_attr_hot sus_attr_nothrw void zap_memcpy( void const * in, size_t num, void * out);
-sus_attr_alloc sus_attr_allocsz(0x2) sus_attr_hot sus_attr_nothrw sus_attr_useret void * zap_memdup( void const * ptr, size_t num);
-sus_attr_hot sus_attr_nothrw sus_attr_useret bool zap_memeq( void const * lptr,size_t num, void const * rptr);
-sus_attr_hot sus_attr_nothrw void zap_memfill( void * ptr, size_t num, unsigned char val);
-sus_attr_hot sus_attr_nothrw sus_attr_useret int_least8_t zap_strcmp( char const * lstr,char const * rstr);
-sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_strcpy( char const * in, char * out);
-sus_attr_alloc sus_attr_hot sus_attr_nothrw sus_attr_useret char * zap_strdup( char const * str);
-sus_attr_hot sus_attr_nothrw sus_attr_useret bool zap_streq( char const * lstr,char const * rstr);
-sus_attr_hot sus_attr_nothrw void zap_strfill( char * lstr,char chr);
-sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_strlen( char const * str);
-
-#endif
#if defined(sus_lang_cxx)
}
#endif
diff --git a/zap/include/zap/math.h b/zap/include/zap/math.h
new file mode 100644
index 0000000..97afb66
--- /dev/null
+++ b/zap/include/zap/math.h
@@ -0,0 +1,94 @@
+/*
+ Copyright 2022 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 <zap/base.h>
+
+#include <susinfo.h>
+
+#if !defined(zap_priv_hdr_math)
+#define zap_priv_hdr_math
+
+#if !defined(sus_langfeat_c_llng) && !defined(sus_langfeat_cxx_llng)
+#error The (long long) type is required but unsupported by the implementation !
+#endif
+
+#if defined(sus_lang_cxx)
+extern "C" {
+#endif
+
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret signed char zap_abs_c( signed char val);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret int zap_abs_i( int val);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret long zap_abs_l( long val);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret long long zap_abs_ll( long long val);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret short zap_abs_s( short val);
+
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret signed char zap_fma_c( signed char a,signed char b,signed char c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret int zap_fma_i( int a,int b,int c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret long zap_fma_l( long a,long b,long c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret long long zap_fma_ll( long long a,long long b,long long c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret short zap_fma_s( short a,short b,short c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret unsigned char zap_fma_uc( unsigned char a,unsigned char b,unsigned char c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret unsigned int zap_fma_ui( unsigned int a,unsigned int b,unsigned int c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret unsigned long zap_fma_ul( unsigned long a,unsigned long b,unsigned long c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret unsigned long long zap_fma_ull(unsigned long long a,unsigned long long b,unsigned long long c);
+sus_attr_const sus_attr_hot sus_attr_nothrw sus_attr_useret unsigned short zap_fma_us( unsigned short a,unsigned short b,unsigned short c);
+
+#if defined(sus_langfeat_c_generic)
+
+#define zap_abs_tg(_val) \
+ (_Generic((_val), \
+ signed char:zap_abs_c, \
+ int: zap_abs_i, \
+ long: zap_abs_l, \
+ long long: zap_abs_ll,\
+ short: zap_abs_s, \
+ )((_val)))
+
+#define zap_fma_tg(_a,_b,_c) \
+ (_Generic((_a), \
+ signed char: zap_fma_c, \
+ int: zap_fma_i, \
+ long: zap_fma_l, \
+ long long: zap_fma_ll, \
+ short: zap_fma_s, \
+ unsigned char: zap_fma_uc, \
+ unsigned int: zap_fma_ui, \
+ unsigned long: zap_fma_ul, \
+ unsigned long long:zap_fma_ull,\
+ unsigned short: zap_fma_us, \
+ )((_a),(_b),(_c)))
+
+#elif defined(sus_lang_cxx)
+
+extern "C++" {
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline signed char zap_priv_cxxtg_abs(signed char const _val) {return ::zap_abs_c( _val);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline int zap_priv_cxxtg_abs(int const _val) {return ::zap_abs_i( _val);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline long zap_priv_cxxtg_abs(long const _val) {return ::zap_abs_l( _val);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline long long zap_priv_cxxtg_abs(long long const _val) {return ::zap_abs_ll(_val);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline short zap_priv_cxxtg_abs(short const _val) {return ::zap_abs_s( _val);};
+
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline signed char zap_priv_cxxtg_fma(signed char const _a,signed char const _b,signed char const _c) {return ::zap_fma_c( _a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline int zap_priv_cxxtg_fma(int const _a,int const _b,int const _c) {return ::zap_fma_i( _a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline long zap_priv_cxxtg_fma(long const _a,long const _b,long const _c) {return ::zap_fma_l( _a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline long long zap_priv_cxxtg_fma(long long const _a,long long const _b,long long const _c) {return ::zap_fma_ll( _a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline short zap_priv_cxxtg_fma(short const _a,short const _b,short const _c) {return ::zap_fma_s( _a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline unsigned char zap_priv_cxxtg_fma(unsigned char const _a,unsigned char const _b,unsigned char const _c) {return ::zap_fma_uc( _a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline unsigned int zap_priv_cxxtg_fma(unsigned int const _a,unsigned int const _b,unsigned int const _c) {return ::zap_fma_ui( _a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline unsigned long zap_priv_cxxtg_fma(unsigned long const _a,unsigned long const _b,unsigned long const _c) {return ::zap_fma_ul( _a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline unsigned long long zap_priv_cxxtg_fma(unsigned long long const _a,unsigned long long const _b,unsigned long long const _c) {return ::zap_fma_ull(_a,_b,_c);};
+ sus_attr_const sus_attr_inline sus_attr_useret sus_inline unsigned short zap_priv_cxxtg_fma(unsigned short const _a,unsigned short const _b,unsigned short const _c) {return ::zap_fma_us( _a,_b,_c);};
+}
+
+#define zap_abs_tg(_val) (::zap_priv_cxxtg_abs( _val))
+#define zap_fma_tg(_a, _b,_c) (::zap_priv_cxxtg_fma(_a, _b,_c))
+
+#endif
+
+#if defined(sus_lang_cxx)
+}
+#endif
+
+#endif
diff --git a/zap/include/zap/mem.h b/zap/include/zap/mem.h
new file mode 100644
index 0000000..20d7326
--- /dev/null
+++ b/zap/include/zap/mem.h
@@ -0,0 +1,59 @@
+/*
+ Copyright 2022 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 <zap/base.h>
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <susinfo.h>
+
+#if !defined(zap_priv_hdr_mem)
+#define zap_priv_hdr_mem
+
+#if defined(sus_lang_asm)
+
+.extern zap_fndbyte
+.extern zap_fndchr
+.extern zap_foreach
+.extern zap_memcmp
+.extern zap_memcpy
+.extern zap_memeq
+.extern zap_memfill
+.extern zap_memfill
+.extern zap_strcmp
+.extern zap_strcpy
+.extern zap_streq
+.extern zap_strfill
+.extern zap_strlen
+
+#else
+
+#if defined(sus_lang_cxx)
+extern "C" {
+#endif
+
+sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_fndbyte( void const * ptr, size_t num, unsigned char byte);
+sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_fndchr( char const * str, char chr);
+sus_attr_hot void zap_foreach( void * ptr, size_t sz, size_t num, void (* fn)(void *));
+sus_attr_hot sus_attr_nothrw sus_attr_useret int_least8_t zap_memcmp( void const * lstr,size_t num, void const * rstr);
+sus_attr_hot sus_attr_nothrw void zap_memcpy( void const * in, size_t num, void * out);
+sus_attr_alloc sus_attr_allocsz(0x2) sus_attr_hot sus_attr_nothrw sus_attr_useret void * zap_memdup( void const * ptr, size_t num);
+sus_attr_hot sus_attr_nothrw sus_attr_useret bool zap_memeq( void const * lptr,size_t num, void const * rptr);
+sus_attr_hot sus_attr_nothrw void zap_memfill( void * ptr, size_t num, unsigned char val);
+sus_attr_hot sus_attr_nothrw sus_attr_useret int_least8_t zap_strcmp( char const * lstr,char const * rstr);
+sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_strcpy( char const * in, char * out);
+sus_attr_alloc sus_attr_hot sus_attr_nothrw sus_attr_useret char * zap_strdup( char const * str);
+sus_attr_hot sus_attr_nothrw sus_attr_useret bool zap_streq( char const * lstr,char const * rstr);
+sus_attr_hot sus_attr_nothrw void zap_strfill( char * lstr,char chr);
+sus_attr_hot sus_attr_nothrw sus_attr_useret size_t zap_strlen( char const * str);
+
+#endif
+#if defined(sus_lang_cxx)
+}
+#endif
+
+#endif