xref: /aosp_15_r20/system/libufdt/sysdeps/include/libufdt_sysdeps.h (revision 13e8728f0cffde9369df671f7b293a048a99c7ed)
1*13e8728fSAndroid Build Coastguard Worker /*
2*13e8728fSAndroid Build Coastguard Worker  * Copyright (C) 2016 The Android Open Source Project
3*13e8728fSAndroid Build Coastguard Worker  *
4*13e8728fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*13e8728fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*13e8728fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*13e8728fSAndroid Build Coastguard Worker  *
8*13e8728fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*13e8728fSAndroid Build Coastguard Worker  *
10*13e8728fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*13e8728fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*13e8728fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*13e8728fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*13e8728fSAndroid Build Coastguard Worker  * limitations under the License.
15*13e8728fSAndroid Build Coastguard Worker  */
16*13e8728fSAndroid Build Coastguard Worker 
17*13e8728fSAndroid Build Coastguard Worker #ifndef LIBDTOVERLAY_SYSDEPS_H
18*13e8728fSAndroid Build Coastguard Worker #define LIBDTOVERLAY_SYSDEPS_H
19*13e8728fSAndroid Build Coastguard Worker 
20*13e8728fSAndroid Build Coastguard Worker /* Change these includes to match your platform to bring in the
21*13e8728fSAndroid Build Coastguard Worker  * equivalent types available in a normal C runtime. At least things
22*13e8728fSAndroid Build Coastguard Worker  * like uint8_t, uint64_t, and bool (with |false|, |true| keywords)
23*13e8728fSAndroid Build Coastguard Worker  * must be present.
24*13e8728fSAndroid Build Coastguard Worker  */
25*13e8728fSAndroid Build Coastguard Worker #include <inttypes.h>
26*13e8728fSAndroid Build Coastguard Worker #include <stdbool.h>
27*13e8728fSAndroid Build Coastguard Worker #include <stddef.h>
28*13e8728fSAndroid Build Coastguard Worker #include <stdint.h>
29*13e8728fSAndroid Build Coastguard Worker 
30*13e8728fSAndroid Build Coastguard Worker #ifdef DTO_ENABLE_DEBUG
31*13e8728fSAndroid Build Coastguard Worker /* Print functions, used for diagnostics.
32*13e8728fSAndroid Build Coastguard Worker  *
33*13e8728fSAndroid Build Coastguard Worker  * These have no effect unless FDT_ENABLE_DEBUG is defined.
34*13e8728fSAndroid Build Coastguard Worker  */
35*13e8728fSAndroid Build Coastguard Worker #define dto_debug(...)                   \
36*13e8728fSAndroid Build Coastguard Worker   do {                                   \
37*13e8728fSAndroid Build Coastguard Worker     dto_print("DEBUG: %s():", __func__); \
38*13e8728fSAndroid Build Coastguard Worker     dto_print(__VA_ARGS__);              \
39*13e8728fSAndroid Build Coastguard Worker   } while (0)
40*13e8728fSAndroid Build Coastguard Worker #else
41*13e8728fSAndroid Build Coastguard Worker #define dto_debug(...) \
42*13e8728fSAndroid Build Coastguard Worker   do {                 \
43*13e8728fSAndroid Build Coastguard Worker   } while (0)
44*13e8728fSAndroid Build Coastguard Worker #endif
45*13e8728fSAndroid Build Coastguard Worker 
46*13e8728fSAndroid Build Coastguard Worker #ifndef DTO_DISABLE_ERROR_MSG
47*13e8728fSAndroid Build Coastguard Worker #define dto_error(...)                   \
48*13e8728fSAndroid Build Coastguard Worker   do {                                   \
49*13e8728fSAndroid Build Coastguard Worker     dto_print("ERROR: %s():", __func__); \
50*13e8728fSAndroid Build Coastguard Worker     dto_print(__VA_ARGS__);              \
51*13e8728fSAndroid Build Coastguard Worker   } while (0)
52*13e8728fSAndroid Build Coastguard Worker #else
53*13e8728fSAndroid Build Coastguard Worker #define dto_error(...) \
54*13e8728fSAndroid Build Coastguard Worker   do {                 \
55*13e8728fSAndroid Build Coastguard Worker   } while (0)
56*13e8728fSAndroid Build Coastguard Worker #endif
57*13e8728fSAndroid Build Coastguard Worker 
58*13e8728fSAndroid Build Coastguard Worker int dto_print(const char *fmt, ...);
59*13e8728fSAndroid Build Coastguard Worker 
60*13e8728fSAndroid Build Coastguard Worker void dto_qsort(void *base, size_t nmemb, size_t size,
61*13e8728fSAndroid Build Coastguard Worker                int (*compar)(const void *, const void *));
62*13e8728fSAndroid Build Coastguard Worker 
63*13e8728fSAndroid Build Coastguard Worker void *dto_malloc(size_t size);
64*13e8728fSAndroid Build Coastguard Worker 
65*13e8728fSAndroid Build Coastguard Worker void dto_free(void *ptr);
66*13e8728fSAndroid Build Coastguard Worker 
67*13e8728fSAndroid Build Coastguard Worker char *dto_strchr(const char *s, int c);
68*13e8728fSAndroid Build Coastguard Worker 
69*13e8728fSAndroid Build Coastguard Worker unsigned long int dto_strtoul(const char *nptr, char **endptr, int base);
70*13e8728fSAndroid Build Coastguard Worker 
71*13e8728fSAndroid Build Coastguard Worker size_t dto_strlen(const char *s);
72*13e8728fSAndroid Build Coastguard Worker 
73*13e8728fSAndroid Build Coastguard Worker int dto_memcmp(const void *lhs, const void *rhs, size_t n);
74*13e8728fSAndroid Build Coastguard Worker 
75*13e8728fSAndroid Build Coastguard Worker void *dto_memcpy(void *dest, const void *src, size_t n);
76*13e8728fSAndroid Build Coastguard Worker 
77*13e8728fSAndroid Build Coastguard Worker int dto_strcmp(const char *s1, const char *s2);
78*13e8728fSAndroid Build Coastguard Worker 
79*13e8728fSAndroid Build Coastguard Worker int dto_strncmp(const char *s1, const char *s2, size_t n);
80*13e8728fSAndroid Build Coastguard Worker 
81*13e8728fSAndroid Build Coastguard Worker void *dto_memchr(const void *s, int c, size_t n);
82*13e8728fSAndroid Build Coastguard Worker 
83*13e8728fSAndroid Build Coastguard Worker void *dto_memset(void *s, int c, size_t n);
84*13e8728fSAndroid Build Coastguard Worker 
85*13e8728fSAndroid Build Coastguard Worker #endif /* LIBDTOVERLAY_SYSDEPS_H */
86