1 /*
2 * Copyright (C) 2021 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/module.h>
21 #include <linux/kernel.h>
22 #include <linux/printk.h>
23 #include <linux/string.h>
24 #include <linux/version.h>
25
osal_strcmp(const char * cs,const char * ct)26 int osal_strcmp(const char *cs, const char *ct)
27 {
28 return strcmp(cs, ct);
29 }
30 EXPORT_SYMBOL(osal_strcmp);
osal_strncmp(const char * cs,const char * ct,int count)31 int osal_strncmp(const char *cs, const char *ct, int count)
32 {
33 return strncmp(cs, ct, count);
34 }
35 EXPORT_SYMBOL(osal_strncmp);
osal_strnicmp(const char * s1,const char * s2,int len)36 int osal_strnicmp(const char *s1, const char *s2, int len)
37 {
38 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
39 return strnicmp(s1, s2, len);
40 #else
41 osal_unused(s1);
42 osal_unused(s2);
43 osal_unused(len);
44 #endif
45 return 0;
46 }
47 EXPORT_SYMBOL(osal_strnicmp);
osal_strcasecmp(const char * s1,const char * s2)48 int osal_strcasecmp(const char *s1, const char *s2)
49 {
50 return strcasecmp(s1, s2);
51 }
52 EXPORT_SYMBOL(osal_strcasecmp);
osal_strncasecmp(const char * s1,const char * s2,int n)53 int osal_strncasecmp(const char *s1, const char *s2, int n)
54 {
55 return strncasecmp(s1, s2, n);
56 }
57 EXPORT_SYMBOL(osal_strncasecmp);
osal_strchr(const char * s,int c)58 char *osal_strchr(const char *s, int c)
59 {
60 return strchr(s, c);
61 }
62 EXPORT_SYMBOL(osal_strchr);
osal_strnchr(const char * s,int count,int c)63 char *osal_strnchr(const char *s, int count, int c)
64 {
65 return strnchr(s, count, c);
66 }
67 EXPORT_SYMBOL(osal_strnchr);
osal_strrchr(const char * s,int c)68 char *osal_strrchr(const char *s, int c)
69 {
70 return strrchr(s, c);
71 }
72 EXPORT_SYMBOL(osal_strrchr);
osal_strstr(const char * s1,const char * s2)73 char *osal_strstr(const char *s1, const char *s2)
74 {
75 return strstr(s1, s2);
76 }
77 EXPORT_SYMBOL(osal_strstr);
osal_strnstr(const char * s1,const char * s2,int len)78 char *osal_strnstr(const char *s1, const char *s2, int len)
79 {
80 return strnstr(s1, s2, len);
81 }
82 EXPORT_SYMBOL(osal_strnstr);
osal_strlen(const char * s)83 int osal_strlen(const char *s)
84 {
85 return strlen(s);
86 }
87 EXPORT_SYMBOL(osal_strlen);
osal_strnlen(const char * s,int count)88 int osal_strnlen(const char *s, int count)
89 {
90 return strnlen(s, count);
91 }
92 EXPORT_SYMBOL(osal_strnlen);
osal_strpbrk(const char * cs,const char * ct)93 char *osal_strpbrk(const char *cs, const char *ct)
94 {
95 return strpbrk(cs, ct);
96 }
97 EXPORT_SYMBOL(osal_strpbrk);
osal_strsep(char ** s,const char * ct)98 char *osal_strsep(char **s, const char *ct)
99 {
100 return strsep(s, ct);
101 }
102 EXPORT_SYMBOL(osal_strsep);
osal_strspn(const char * s,const char * accept)103 int osal_strspn(const char *s, const char *accept)
104 {
105 return strspn(s, accept);
106 }
107 EXPORT_SYMBOL(osal_strspn);
osal_strcspn(const char * s,const char * reject)108 int osal_strcspn(const char *s, const char *reject)
109 {
110 return strcspn(s, reject);
111 }
112 EXPORT_SYMBOL(osal_strcspn);
osal_memscan(void * addr,int c,int size)113 void *osal_memscan(void *addr, int c, int size)
114 {
115 return memscan(addr, c, size);
116 }
117 EXPORT_SYMBOL(osal_memscan);
osal_memcmp(const void * cs,const void * ct,int count)118 int osal_memcmp(const void *cs, const void *ct, int count)
119 {
120 return memcmp(cs, ct, count);
121 }
122 EXPORT_SYMBOL(osal_memcmp);
osal_memchr(const void * s,int c,int n)123 void *osal_memchr(const void *s, int c, int n)
124 {
125 return memchr(s, c, n);
126 }
127 EXPORT_SYMBOL(osal_memchr);
osal_memchr_inv(const void * start,int c,int bytes)128 void *osal_memchr_inv(const void *start, int c, int bytes)
129 {
130 return memchr_inv(start, c, bytes);
131 }
132 EXPORT_SYMBOL(osal_memchr_inv);
osal_strtoull(const char * cp,char ** endp,unsigned int base)133 unsigned long long osal_strtoull(const char *cp, char **endp, unsigned int base)
134 {
135 return simple_strtoull(cp, endp, base);
136 }
137 EXPORT_SYMBOL(osal_strtoull);
osal_strtoul(const char * cp,char ** endp,unsigned int base)138 unsigned long osal_strtoul(const char *cp, char **endp, unsigned int base)
139 {
140 return simple_strtoul(cp, endp, base);
141 }
142 EXPORT_SYMBOL(osal_strtoul);
osal_strtol(const char * cp,char ** endp,unsigned int base)143 long osal_strtol(const char *cp, char **endp, unsigned int base)
144 {
145 return simple_strtol(cp, endp, base);
146 }
147 EXPORT_SYMBOL(osal_strtol);
osal_strtoll(const char * cp,char ** endp,unsigned int base)148 long long osal_strtoll(const char *cp, char **endp, unsigned int base)
149 {
150 return simple_strtoll(cp, endp, base);
151 }
152 EXPORT_SYMBOL(osal_strtoll);
153
154