• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "hvb_sysdeps.h"
16 #include <string.h>
17 
18 #ifdef LOG_TAG
19 #undef LOG_TAG
20 #endif
21 
22 #define LOG_TAG "libhvb"
23 
hvb_memcmp(const void * src1,const void * src2,size_t n)24 int hvb_memcmp(const void *src1, const void *src2, size_t n)
25 {
26     return memcmp(src1, src2, n);
27 }
28 
hvb_memcpy(void * dest,const void * src,size_t n)29 void *hvb_memcpy(void *dest, const void *src, size_t n)
30 {
31     return memcpy(dest, src, n);
32 }
33 
hvb_memset(void * dest,const int c,size_t n)34 void *hvb_memset(void *dest, const int c, size_t n)
35 {
36     return memset(dest, c, n);
37 }
38 
hvb_strcmp(const char * s1,const char * s2)39 int hvb_strcmp(const char *s1, const char *s2)
40 {
41     return strcmp(s1, s2);
42 }
43 
hvb_strncmp(const char * s1,const char * s2,size_t n)44 int hvb_strncmp(const char *s1, const char *s2, size_t n)
45 {
46     return strncmp(s1, s2, n);
47 }
48 
hvb_strlen(const char * str)49 size_t hvb_strlen(const char *str)
50 {
51     return (size_t)strlen(str);
52 }
53 
hvb_abort(void)54 void hvb_abort(void)
55 {
56     printf("ERROR, an error happened\n");
57 }
58 
hvb_print(const char * message)59 void hvb_print(const char *message)
60 {
61     printf("%s\n", message);
62 }
63 
hvb_printv(const char * message,...)64 void hvb_printv(const char *message, ...)
65 {
66     va_list ap;
67     const char *msg;
68 
69     va_start(ap, message);
70     for (msg = message; msg != NULL; msg = va_arg(ap, const char*)) {
71         printf("%s", msg);
72     }
73     va_end(ap);
74 }
75 
hvb_malloc_(size_t size)76 void *hvb_malloc_(size_t size)
77 {
78     return malloc(size);
79 }
80 
hvb_free(void * ptr)81 void hvb_free(void *ptr)
82 {
83     free(ptr);
84 }
85 
hvb_div_by_10(uint64_t * dividend)86 uint32_t hvb_div_by_10(uint64_t *dividend)
87 {
88     uint32_t rem = (uint32_t)(*dividend % 10);
89     *dividend /= 10;
90     return rem;
91 }
92