Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
LibC.h
1// Copyright (c) Stefano Cristiano
2// SPDX-License-Identifier: MIT
3#pragma once
4#include "../Foundation/PrimitiveTypes.h"
5#if SC_COMPILER_ENABLE_STD_CPP || SC_LANGUAGE_EXCEPTIONS
6#include <memory.h>
7#include <string.h>
8#else
9#if SC_PLATFORM_WINDOWS
10extern "C"
11{
12 void* __cdecl memmove(void* dst, const void* src, size_t n);
13 void* __cdecl memcpy(void* dst, const void* src, size_t n);
14 int __cdecl memcmp(const void* s1, const void* s2, size_t n);
15 void* __cdecl memset(void* dst, SC::int32_t c, size_t len);
16 [[nodiscard]] void const* __cdecl memchr(const void* ptr, SC::int32_t c, size_t count);
17
18 SC::size_t strlen(const char* s);
19 size_t __cdecl wcslen(wchar_t const*);
20}
21#elif SC_PLATFORM_APPLE
22extern "C"
23{
24 void* memmove(void* dst, const void* src, SC::size_t n);
25 void* memcpy(void* dst, const void* src, SC::size_t n);
26 int memcmp(const void* s1, const void* s2, SC::size_t n);
27 void* memset(void* dst, SC::int32_t c, SC::size_t len);
28 void* memchr(const void* ptr, SC::int32_t c, SC::size_t count);
29
30 SC::size_t strlen(const char* s);
31}
32#elif SC_PLATFORM_LINUX
33extern "C"
34{
35 void* memmove(void* dst, const void* src, SC::size_t n);
36 void* memcpy(void* dst, const void* src, SC::size_t n);
37 int memcmp(const void* s1, const void* s2, SC::size_t n);
38 void* memset(void* dst, SC::int32_t c, SC::size_t len);
39
40 SC::size_t strlen(const char* s);
41}
42extern "C++"
43{
44 extern const void* memchr(const void* __s, int __c, SC::size_t __n) __asm("memchr");
45}
46#elif SC_PLATFORM_EMSCRIPTEN
47#else
48#error "Unsupported platform"
49#endif
50#endif // SC_SAFE_INCLUDES
unsigned long size_t
Platform independent unsigned size type.
Definition PrimitiveTypes.h:56
int int32_t
Platform independent (4) bytes signed int.
Definition PrimitiveTypes.h:46