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 #include "libufdt_sysdeps.h"
18
19 #include <stdarg.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23
24 #ifndef DTO_DISABLE_DEFAULT_POSIX_LIBC_PRINT
dto_print(const char * fmt,...)25 int dto_print(const char *fmt, ...) {
26 int err;
27
28 va_list ap;
29 va_start(ap, fmt);
30 err = vfprintf(stderr, fmt, ap);
31 va_end(ap);
32
33 return err;
34 }
35 #endif
36
dto_qsort(void * base,size_t nmemb,size_t size,int (* compar)(const void *,const void *))37 void dto_qsort(void *base, size_t nmemb, size_t size,
38 int (*compar)(const void *, const void *)) {
39 qsort(base, nmemb, size, compar);
40 }
41
42 #ifndef DTO_DISABLE_DEFAULT_POSIX_LIBC_ALLOCATION
dto_malloc(size_t size)43 void *dto_malloc(size_t size) { return malloc(size); }
44
dto_free(void * ptr)45 void dto_free(void *ptr) { free(ptr); }
46 #endif
47
dto_strchr(const char * s,int c)48 char *dto_strchr(const char *s, int c) { return strchr(s, c); }
49
dto_strtoul(const char * nptr,char ** endptr,int base)50 unsigned long int dto_strtoul(const char *nptr, char **endptr, int base) {
51 return strtoul(nptr, endptr, base);
52 }
53
dto_strlen(const char * s)54 size_t dto_strlen(const char *s) { return strlen(s); }
55
dto_memcmp(const void * lhs,const void * rhs,size_t n)56 int dto_memcmp(const void *lhs, const void *rhs, size_t n) {
57 return memcmp(lhs, rhs, n);
58 }
59
dto_memcpy(void * dest,const void * src,size_t n)60 void *dto_memcpy(void *dest, const void *src, size_t n) {
61 return memcpy(dest, src, n);
62 }
63
dto_strcmp(const char * s1,const char * s2)64 int dto_strcmp(const char *s1, const char *s2) { return strcmp(s1, s2); }
65
dto_strncmp(const char * s1,const char * s2,size_t n)66 int dto_strncmp(const char *s1, const char *s2, size_t n) {
67 return strncmp(s1, s2, n);
68 }
69
dto_memchr(const void * s,int c,size_t n)70 void *dto_memchr(const void *s, int c, size_t n) { return memchr(s, c, n); }
71
dto_memset(void * s,int c,size_t n)72 void *dto_memset(void *s, int c, size_t n) { return memset(s, c, n); }
73