SzuWei Lin | 6ad4caa | 2017-04-06 17:12:27 +0800 | [diff] [blame] | 1 | /* |
| 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 Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 17 | #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 | |
| 50 | int dto_print(const char *fmt, ...); |
| 51 | |
| 52 | void dto_qsort(void *base, size_t nmemb, size_t size, |
| 53 | int (*compar)(const void *, const void *)); |
| 54 | |
| 55 | void *dto_malloc(size_t size); |
| 56 | |
| 57 | void dto_free(void *ptr); |
| 58 | |
Li Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 59 | char *dto_strchr(const char *s, int c); |
| 60 | |
| 61 | unsigned long int dto_strtoul(const char *nptr, char **endptr, int base); |
| 62 | |
| 63 | size_t dto_strlen(const char *s); |
| 64 | |
SzuWei Lin | 3407a9c | 2017-03-28 17:14:56 +0800 | [diff] [blame] | 65 | int dto_memcmp(const void *lhs, const void *rhs, size_t n); |
| 66 | |
Li Chen | f6c209b | 2016-11-28 12:15:33 +0800 | [diff] [blame] | 67 | void *dto_memcpy(void *dest, const void *src, size_t n); |
| 68 | |
| 69 | int dto_strcmp(const char *s1, const char *s2); |
| 70 | |
| 71 | int dto_strncmp(const char *s1, const char *s2, size_t n); |
| 72 | |
| 73 | void *dto_memchr(const void *s, int c, size_t n); |
| 74 | |
| 75 | void *dto_memset(void *s, int c, size_t n); |
| 76 | |
| 77 | #endif /* LIBDTOVERLAY_SYSDEPS_H */ |