Sane C++ Libraries
C++ Platform Abstraction Libraries
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#else
8#if SC_PLATFORM_WINDOWS
9extern "C"
10{
11 void* __cdecl memmove(void* dst, const void* src, size_t n);
12 void* __cdecl memcpy(void* dst, const void* src, size_t n);
13 int __cdecl memcmp(const void* s1, const void* s2, size_t n);
14 void* __cdecl memset(void* dst, SC::int32_t c, size_t len);
15 [[nodiscard]] void const* __cdecl memchr(const void* ptr, SC::int32_t c, size_t count);
16}
17#elif SC_PLATFORM_APPLE
18extern "C"
19{
20 void* memmove(void* dst, const void* src, SC::size_t n);
21 void* memcpy(void* dst, const void* src, SC::size_t n);
22 int memcmp(const void* s1, const void* s2, SC::size_t n);
23 void* memset(void* dst, SC::int32_t c, SC::size_t len);
24 void* memchr(const void* ptr, SC::int32_t c, SC::size_t count);
25}
26#elif SC_PLATFORM_LINUX
27extern "C"
28{
29 void* memmove(void* dst, const void* src, SC::size_t n);
30 void* memcpy(void* dst, const void* src, SC::size_t n);
31 int memcmp(const void* s1, const void* s2, SC::size_t n);
32 void* memset(void* dst, SC::int32_t c, SC::size_t len);
33}
34extern "C++"
35{
36 extern const void* memchr(const void* __s, int __c, SC::size_t __n) __asm("memchr");
37}
38#elif SC_PLATFORM_EMSCRIPTEN
39#else
40#error "Unsupported platform"
41#endif
42#endif // SC_SAFE_INCLUDES
int int32_t
Platform independent (4) bytes signed int.
Definition: PrimitiveTypes.h:46
unsigned long size_t
Platform independent unsigned size type.
Definition: PrimitiveTypes.h:56