Tom Rini | 421a5d0 | 2018-06-19 11:21:44 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: MIT |
Igor Opaniuk | 8b23ae2 | 2018-06-03 21:56:36 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 The Android Open Source Project |
Igor Opaniuk | 8b23ae2 | 2018-06-03 21:56:36 +0300 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 6 | #include <hang.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 7 | #include <malloc.h> |
Igor Opaniuk | 8b23ae2 | 2018-06-03 21:56:36 +0300 | [diff] [blame] | 8 | #include <stdarg.h> |
| 9 | #include <stdlib.h> |
| 10 | |
| 11 | #include "avb_sysdeps.h" |
| 12 | |
| 13 | int avb_memcmp(const void* src1, const void* src2, size_t n) { |
| 14 | return memcmp(src1, src2, n); |
| 15 | } |
| 16 | |
| 17 | void* avb_memcpy(void* dest, const void* src, size_t n) { |
| 18 | return memcpy(dest, src, n); |
| 19 | } |
| 20 | |
| 21 | void* avb_memset(void* dest, const int c, size_t n) { |
| 22 | return memset(dest, c, n); |
| 23 | } |
| 24 | |
| 25 | int avb_strcmp(const char* s1, const char* s2) { |
| 26 | return strcmp(s1, s2); |
| 27 | } |
| 28 | |
Sam Protsenko | 6a71702 | 2019-08-15 23:04:02 +0300 | [diff] [blame] | 29 | int avb_strncmp(const char* s1, const char* s2, size_t n) { |
| 30 | return strncmp(s1, s2, n); |
Igor Opaniuk | 8b23ae2 | 2018-06-03 21:56:36 +0300 | [diff] [blame] | 31 | } |
| 32 | |
Sam Protsenko | 6a71702 | 2019-08-15 23:04:02 +0300 | [diff] [blame] | 33 | size_t avb_strlen(const char* str) { |
| 34 | return strlen(str); |
Igor Opaniuk | 8b23ae2 | 2018-06-03 21:56:36 +0300 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | void avb_abort(void) { |
| 38 | hang(); |
| 39 | } |
| 40 | |
| 41 | void avb_print(const char* message) { |
| 42 | printf("%s", message); |
| 43 | } |
| 44 | |
| 45 | void avb_printv(const char* message, ...) { |
| 46 | va_list ap; |
| 47 | const char* m; |
| 48 | |
| 49 | va_start(ap, message); |
| 50 | for (m = message; m != NULL; m = va_arg(ap, const char*)) { |
| 51 | printf("%s", m); |
| 52 | } |
| 53 | va_end(ap); |
| 54 | } |
| 55 | |
| 56 | void* avb_malloc_(size_t size) { |
| 57 | return malloc(size); |
| 58 | } |
| 59 | |
| 60 | void avb_free(void* ptr) { |
| 61 | free(ptr); |
| 62 | } |
Sam Protsenko | 6a71702 | 2019-08-15 23:04:02 +0300 | [diff] [blame] | 63 | |
| 64 | uint32_t avb_div_by_10(uint64_t* dividend) { |
| 65 | uint32_t rem = (uint32_t)(*dividend % 10); |
| 66 | *dividend /= 10; |
| 67 | return rem; |
| 68 | } |