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 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 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 59char *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 65int dto_memcmp(const void *lhs, const void *rhs, size_t n); 66 67void *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 */ 78