summaryrefslogtreecommitdiff
path: root/rgo/include/rgo.h
blob: 276c8dca45500b8a6cad9186710950ec6a3c2a6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
	Copyright 2022 Gabriel Jensen

	This file is part of rgo.

	rgo is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

	rgo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License along with rgo. If not, see <https://www.gnu.org/licenses/>. 
*/

#if !defined(__i386__) && !defined(__x86_64__)
#error Unsupported machine architecture! Support: AMD64, IA-32.
#endif

#if !defined(rgo_ver)
#if defined(__ASSEMBLER__)
#define rgo_ver $0x2
#else
#define rgo_ver (0x2)
#endif

#if defined(__ASSEMBLER__)
.extern rgo_fndbyte
.extern rgo_fndchr
.extern rgo_memcpy
.extern rgo_memeq
.extern rgo_memfill
.extern rgo_strcpy
.extern rgo_streq
.extern rgo_strfill
.extern rgo_strlen
#else
#include <stddef.h>
#include <stdint.h>

#if defined(__cplusplus)
#define rgo_priv_externc extern "C"
#else
#define rgo_priv_externc
#endif

rgo_priv_externc __attribute__((alloc_size(0x2),hot,malloc,nothrow)) void *  __rgo_memdup(void const * __restrict__ ptr, size_t                    num);
rgo_priv_externc __attribute__((hot,nothrow))                        size_t  rgo_fndbyte( void const * __restrict__ ptr, size_t                    num,uint8_t                   byte);
rgo_priv_externc __attribute__((hot,nothrow))                        size_t  rgo_fndchr(  char const * __restrict__ str, char                      chr);
rgo_priv_externc __attribute__((hot,nothrow))                        void    rgo_memcpy(  void const * __restrict__ in,  size_t                    num,void *       __restrict__ out);
rgo_priv_externc __attribute__((hot,nothrow))                        uint8_t rgo_memeq(   void const * __restrict__ lptr,size_t                    num,void const * __restrict__ rptr);
rgo_priv_externc __attribute__((hot,nothrow))                        void    rgo_memfill( void const * __restrict__ ptr, size_t                    num,uint8_t                   val);
rgo_priv_externc __attribute__((hot,nothrow))                        size_t  rgo_strcpy(  char const * __restrict__ lstr,char const * __restrict__ rstr);
rgo_priv_externc __attribute__((hot,malloc,nothrow))                 char *  rgo_strdup(  char const * __restrict__ str);
rgo_priv_externc __attribute__((hot,nothrow))                        uint8_t rgo_streq(   char const * __restrict__ lstr,char const * __restrict__ rstr);
rgo_priv_externc __attribute__((hot,nothrow))                        void    rgo_strfill( char const * __restrict__ lstr,char                      chr);
rgo_priv_externc __attribute__((hot,nothrow))                        size_t  rgo_strlen(  char const * __restrict__ str);

#if defined(__cplusplus)
template<typename T> [[gnu::alloc_size(0x2),gnu::hot,gnu::malloc]] auto rgo_memdup(T const * __restrict__ const _ptr,::size_t const _num) noexcept -> T * {return static_cast<T *>(::__rgo_memdup(_ptr,_num));}
#else
#define rgo_memdup __rgo_memdup
#endif
#endif

#endif