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