libufdt_sysdeps_posix.c 1.8 KB

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