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