summaryrefslogtreecommitdiff
path: root/zap/include
diff options
context:
space:
mode:
Diffstat (limited to 'zap/include')
-rw-r--r--zap/include/zap/base.h25
-rw-r--r--zap/include/zap/bs.h43
-rw-r--r--zap/include/zap/math.h94
-rw-r--r--zap/include/zap/mem.h61
4 files changed, 65 insertions, 158 deletions
diff --git a/zap/include/zap/base.h b/zap/include/zap/base.h
deleted file mode 100644
index a52414b..0000000
--- a/zap/include/zap/base.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- 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 <stdbool.h>
-#include <susinfo.h>
-
-#if !defined(zap_priv_hdr_base)
-#define zap_priv_hdr_base
-
-#define zap_ver (0xFu)
-
-#if defined(sus_lang_cxx)
-extern "C" {
-#endif
-
-extern bool const zap_fastimpl;
-
-#if defined(sus_lang_cxx)
-}
-#endif
-
-#endif
diff --git a/zap/include/zap/bs.h b/zap/include/zap/bs.h
new file mode 100644
index 0000000..930b1a8
--- /dev/null
+++ b/zap/include/zap/bs.h
@@ -0,0 +1,43 @@
+/*
+ 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/.
+*/
+
+#if !defined(zap_priv_hdr_bs)
+#define zap_priv_hdr_bs
+
+#if defined(sus_lang_cxx)
+extern "C" {
+#endif
+
+typedef unsigned char zap_bool;
+#define zap_false ((zap_bool)+0x0u)
+#define zap_true ((zap_bool)+0xFFu)
+
+typedef unsigned short zap_chr10;
+typedef unsigned int zap_chr20;
+typedef unsigned char zap_chr8;
+
+typedef signed char zap_cmp;
+#define zap_eq ((zap_cmp)+0x0)
+#define zap_gt ((zap_cmp)+0x7F)
+#define zap_lt ((zap_cmp)-0x80)
+
+#define zap_nopos (~((zap_sz)+0u))
+
+#if defined(__cplusplus)
+#define zap_nullptr ((unsigned long)0x0u)
+#else
+#define zap_nullptr ((void *)0x0u)
+#endif
+
+typedef unsigned long zap_sz;
+
+#define zap_ver ((unsigned long)+0x10u)
+
+#if defined(sus_lang_cxx)
+}
+#endif
+
+#endif
diff --git a/zap/include/zap/math.h b/zap/include/zap/math.h
deleted file mode 100644
index 97afb66..0000000
--- a/zap/include/zap/math.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- 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
index 20d7326..0580019 100644
--- a/zap/include/zap/mem.h
+++ b/zap/include/zap/mem.h
@@ -4,54 +4,37 @@
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
+#include <zap/bs.h>
#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);
+__attribute__ ((hot,nothrow,warn_unused_result)) zap_sz zap_fndbyte( void const * ptr, zap_sz num, unsigned char byte);
+__attribute__ ((hot,nothrow,warn_unused_result)) zap_sz zap_fndchr( char const * str, char chr);
+__attribute__ ((hot)) void zap_foreach( void * ptr, zap_sz sz, zap_sz num, void (* fn)(void *));
+__attribute__ ((hot,nothrow)) void zap_memcat( void const * lptr, zap_sz llen,void const * rptr, zap_sz rlen, void * buf);
+__attribute__ ((hot,nothrow,warn_unused_result)) zap_cmp zap_memcmp( void const * lstr, zap_sz num, void const * rstr);
+__attribute__ ((hot,nothrow)) void zap_memcp( void const * in, zap_sz num, void * out);
+__attribute__ ((hot,nothrow,warn_unused_result)) zap_bool zap_memeq( void const * lptr, zap_sz num, void const * rptr);
+__attribute__ ((hot,nothrow)) void zap_memfill( void * ptr, zap_sz num, unsigned char val);
+__attribute__ ((hot)) void zap_memgen( void * ptr, zap_sz sz, zap_sz num, void (* fn)(zap_sz,void *));
+__attribute__ ((hot,nothrow)) void zap_strcat( char const * lstr, char const * rstr,char * buf);
+__attribute__ ((hot,nothrow,warn_unused_result)) zap_cmp zap_strcmp( char const * lstr, char const * rstr);
+__attribute__ ((hot,nothrow)) zap_sz zap_strcp( char const * in, char * out);
+__attribute__ ((hot,nothrow,warn_unused_result)) zap_bool zap_streq( char const * lstr, char const * rstr);
+__attribute__ ((hot,nothrow)) zap_sz zap_strfill( char * lstr, char chr);
+__attribute__ ((hot,nothrow,warn_unused_result)) zap_sz zap_strlen( char const * str);
+__attribute__ ((hot,nothrow)) void zap_utf8dec( zap_chr8 const * in, zap_chr20 * out);
+__attribute__ ((hot,nothrow)) zap_sz zap_utf8declen(zap_chr8 const * utf8);
+__attribute__ ((hot,nothrow)) void zap_utf8enc( zap_chr20 const * in, zap_chr8 * out);
+__attribute__ ((hot,nothrow)) zap_sz zap_utf8enclen(zap_chr20 const * utf20);
+__attribute__ ((hot,nothrow)) void zap_win1252dec(zap_chr8 const * in, zap_chr20 * out);
+__attribute__ ((hot,nothrow)) void zap_win1252enc(zap_chr20 const * in, zap_chr8 * out);
-#endif
#if defined(sus_lang_cxx)
}
#endif