• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #include "hi_osal.h"
20 #include <linux/kernel.h>
21 #include <linux/string.h>
22 #include <linux/random.h>
23 
osal_memncmp(const void * buf1,unsigned long size1,const void * buf2,unsigned long size2)24 int osal_memncmp(const void *buf1, unsigned long size1,
25     const void *buf2, unsigned long size2)
26 {
27     if (size1 != size2) {
28         return -1;
29     }
30 
31     return memcmp(buf1, buf2, size1);
32 }
33 EXPORT_SYMBOL(osal_memncmp);
34 
osal_strncmp(const char * str1,unsigned long size1,const char * str2,unsigned long size2)35 int osal_strncmp(const char *str1, unsigned long size1,
36     const char *str2, unsigned long size2)
37 {
38     if (size1 != size2) {
39         return -1;
40     }
41 
42     return strncmp(str1, str2, size1);
43 }
44 EXPORT_SYMBOL(osal_strncmp);
45 
osal_strncasecmp(const char * str1,unsigned long size1,const char * str2,unsigned long size2)46 int osal_strncasecmp(const char *str1, unsigned long size1,
47     const char *str2, unsigned long size2)
48 {
49     if (size1 != size2) {
50         return -1;
51     }
52 
53     return strncasecmp(str1, str2, size1);
54 }
55 EXPORT_SYMBOL(osal_strncasecmp);
56 
osal_strtol(const char * str,char ** end,unsigned int base)57 long osal_strtol(const char *str, char **end, unsigned int base)
58 {
59     return simple_strtol(str, end, base);
60 }
61 EXPORT_SYMBOL(osal_strtol);
62 
osal_strtoul(const char * str,char ** end,unsigned int base)63 unsigned long  osal_strtoul(const char *str, char **end, unsigned int base)
64 {
65     return simple_strtoul(str, end, base);
66 }
67 EXPORT_SYMBOL(osal_strtoul);
68 
osal_get_random_bytes(void * buf,int nbytes)69 void osal_get_random_bytes(void *buf, int nbytes)
70 {
71     get_random_bytes(buf, nbytes);
72 }
73 EXPORT_SYMBOL(osal_get_random_bytes);
74