10#ifndef KMP_SAFE_C_API_H
11#define KMP_SAFE_C_API_H
21#if KMP_OS_WINDOWS && KMP_MSVC_COMPAT
23#define RSIZE_MAX_STR (4UL << 10)
26#define KMP_ALLOCA _alloca
28#define KMP_MEMCPY_S memcpy_s
29#define KMP_SNPRINTF sprintf_s
30#define KMP_SSCANF sscanf_s
31#define KMP_STRCPY_S strcpy_s
32#define KMP_STRNCPY_S strncpy_s
33#define KMP_STRNCAT_S strncat_s
36#define KMP_MEMCPY(dst, src, cnt) memcpy_s(dst, cnt, src, cnt)
38template <typename T, bool B = std::is_array<T>::value>
39struct kmp_get_rmax_t {};
40template <
typename T>
struct kmp_get_rmax_t<T, false> {
41 static const size_t value = RSIZE_MAX_STR;
43template <
typename T>
struct kmp_get_rmax_t<T, true> {
44 static const size_t value =
sizeof(T);
46#define KMP_STRLEN(str) strnlen_s(str, kmp_get_rmax_t<decltype(str)>::value)
49#define KMP_STRNCPY(dst, src, cnt) strncpy_s(dst, cnt, src, cnt)
52#define KMP_VSNPRINTF(dst, cnt, fmt, arg) \
53 vsnprintf_s(dst, cnt, _TRUNCATE, fmt, arg)
60#define KMP_ALLOCA __builtin_alloca
62#define KMP_ALLOCA alloca
64#define KMP_MEMCPY_S(dst, bsz, src, cnt) memcpy(dst, src, cnt)
65#define KMP_SNPRINTF snprintf
66#define KMP_SSCANF sscanf
67#define KMP_STRCPY_S(dst, bsz, src) strcpy(dst, src)
68#define KMP_STRNCPY_S(dst, bsz, src, cnt) strncpy(dst, src, cnt)
69#define KMP_STRNCAT_S(dst, bsz, src, cnt) strncat(dst, src, cnt)
70#define KMP_VSNPRINTF vsnprintf
71#define KMP_STRNCPY strncpy
72#define KMP_STRLEN strlen
73#define KMP_MEMCPY memcpy
79 char const *src,
size_t src_size) {
80 if (src_size >= buf_size) {
81 src_size = buf_size - 1;
84 buffer[src_size] =
'\0';
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
#define KMP_STRNCPY_S(dst, bsz, src, cnt)
static void __kmp_strncpy_truncate(char *buffer, size_t buf_size, char const *src, size_t src_size)