1 /*
2 * Copyright (C) 2018-2022 Intel Corporation.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #ifndef RTL_H
8 #define RTL_H
9
10 #include <types.h>
11
12 union u_qword {
13 struct {
14 uint32_t low;
15 uint32_t high;
16 } dwords;
17
18 uint64_t qword;
19
20 };
21
22 /* MACRO related to string */
23 #define ULONG_MAX ((uint64_t)(~0UL)) /* 0xFFFFFFFF */
24 #define LONG_MAX (ULONG_MAX >> 1U) /* 0x7FFFFFFF */
25 #define LONG_MIN (~LONG_MAX) /* 0x80000000 */
26
is_space(char c)27 static inline bool is_space(char c)
28 {
29 return ((c == ' ') || (c == '\t'));
30 }
31
is_eol(char c)32 static inline bool is_eol(char c)
33 {
34 return ((c == 0x0d) || (c == 0x0a) || (c == '\0'));
35 }
36
37 /* Function prototypes */
38 int32_t strcmp(const char *s1_arg, const char *s2_arg);
39 int32_t strncmp(const char *s1_arg, const char *s2_arg, size_t n_arg);
40 int32_t strncpy_s(char *d, size_t dmax, const char *s, size_t slen);
41 char *strchr(char *s_arg, char ch);
42 size_t strnlen_s(const char *str_arg, size_t maxlen_arg);
43 void *memset(void *base, uint8_t v, size_t n);
44 int32_t memcpy_s(void *d, size_t dmax, const void *s, size_t slen);
45 void memcpy_erms(void *d, const void *s, size_t slen);
46 void memcpy_erms_backwards(void *d, const void *s, size_t slen);
47 int64_t strtol_deci(const char *nptr);
48 uint64_t strtoul_hex(const char *nptr);
49 char *strstr_s(const char *str1, size_t maxlen1, const char *str2, size_t maxlen2);
50 int32_t strncat_s(char *dest, size_t dmax, const char *src, size_t slen);
51
52 #endif /* RTL_H */
53