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