1 #ifndef __STRING_H__
2 #define __STRING_H__
3 
4 #include <sys/compiler.h>
5 #include <sys/types.h>
6 
7 extern int __LIB__ bcmp(const void *b1,const void *b2,size_t len) __smallc;
8 #if !__GBZ80__ && !__8080__
9 extern int __LIB__ bcmp_callee(const void *b1,const void *b2,size_t len) __smallc __z88dk_callee;
10 #define bcmp(a,b,c) bcmp_callee(a,b,c)
11 #endif
12 
13 
14 extern void __LIB__ bcopy(const void *src,void *dst,size_t len) __smallc;
15 #if !__GBZ80__ && !__8080__
16 extern void __LIB__ bcopy_callee(const void *src,void *dst,size_t len) __smallc __z88dk_callee;
17 #define bcopy(a,b,c) bcopy_callee(a,b,c)
18 #endif
19 
20 
21 extern void __LIB__ bzero(void *mem,size_t n) __smallc;
22 extern void __LIB__ bzero_callee(void *mem,size_t n) __smallc __z88dk_callee;
23 #define bzero(a,b) bzero_callee(a,b)
24 
25 
26 extern char __LIB__ *index(const char *s,int c) __smallc;
27 extern char __LIB__ *index_callee(const char *s,int c) __smallc __z88dk_callee;
28 #define index(a,b) index_callee(a,b)
29 
30 
31 extern char __LIB__ *rindex(const char *s,int c) __smallc;
32 extern char __LIB__ *rindex_callee(const char *s,int c) __smallc __z88dk_callee;
33 #define rindex(a,b) rindex_callee(a,b)
34 
35 
36 extern char __LIB__ *strset(char *s,int c) __smallc;
37 extern char __LIB__ *strset_callee(char *s,int c) __smallc __z88dk_callee;
38 #define strset(a,b) strset_callee(a,b)
39 
40 
41 extern char __LIB__ *strnset(char *s,int c,size_t n) __smallc;
42 #if !__GBZ80__ && !__8080__
43 extern char __LIB__ *strnset_callee(char *s,int c,size_t n) __smallc __z88dk_callee;
44 #define strnset(a,b,c) strnset_callee(a,b,c)
45 #endif
46 
47 
48 extern void __LIB__ *rawmemchr(const void *mem,int c) __smallc;
49 extern void __LIB__ *rawmemchr_callee(const void *mem,int c) __smallc __z88dk_callee;
50 #define rawmemchr(a,b) rawmemchr_callee(a,b)
51 
52 
53 
54 extern char __LIB__ *_memlwr_(void *p,size_t n) __smallc;
55 extern char __LIB__ *_memlwr__callee(void *p,size_t n) __smallc __z88dk_callee;
56 #define _memlwr_(a,b) _memlwr__callee(a,b)
57 
58 
59 extern char __LIB__ *_memstrcpy_(void *p,const char *s,size_t n) __smallc;
60 #if !__GBZ80__ && !__8080__
61 extern char __LIB__ *_memstrcpy__callee(void *p,const char *s,size_t n) __smallc __z88dk_callee;
62 #define _memstrcpy_(a,b,c) _memstrcpy__callee(a,b,c)
63 #endif
64 
65 
66 extern char __LIB__ *_memupr_(void *p,size_t n) __smallc;
67 extern char __LIB__ *_memupr__callee(void *p,size_t n) __smallc __z88dk_callee;
68 #define _memupr_(a,b) _memupr__callee(a,b)
69 
70 
71 extern char __LIB__  *_strrstrip_(char *s) __smallc __z88dk_callee __z88dk_fastcall;
72 
73 
74 extern int __LIB__  ffs(int i) __smallc __z88dk_callee __z88dk_fastcall;
75 
76 
77 extern int __LIB__  ffsl(long i) __smallc __z88dk_callee __z88dk_fastcall;
78 
79 
80 extern void __LIB__ *memccpy(void *dst,const void *src,int c,size_t n) __smallc;
81 extern void __LIB__ *memccpy_callee(void *dst,const void *src,int c,size_t n) __smallc __z88dk_callee;
82 #define memccpy(a,b,c,d) memccpy_callee(a,b,c,d)
83 
84 
85 extern void __LIB__ *memchr(const void *s,int c,size_t n) __smallc;
86 #if !__GBZ80__ && !__8080__
87 extern void __LIB__ *memchr_callee(const void *s,int c,size_t n) __smallc __z88dk_callee;
88 #define memchr(a,b,c) memchr_callee(a,b,c)
89 #endif
90 
91 
92 extern int __LIB__ memcmp(const void *s1,const void *s2,size_t n) __smallc;
93 #if !__GBZ80__ && !__8080__
94 extern int __LIB__ memcmp_callee(const void *s1,const void *s2,size_t n) __smallc __z88dk_callee;
95 #define memcmp(a,b,c) memcmp_callee(a,b,c)
96 #endif
97 
98 
99 extern void __LIB__ *memcpy(void *dst,const void *src,size_t n) __smallc;
100 #if !__GBZ80__ && !__8080__
101 extern void __LIB__ *memcpy_callee(void *dst,const void *src,size_t n) __smallc __z88dk_callee;
102 #define memcpy(a,b,c) memcpy_callee(a,b,c)
103 #endif
104 
105 
106 extern void __LIB__ *memmem(const void *haystack,size_t haystack_len,const void *needle,size_t needle_len) __smallc;
107 extern void __LIB__ *memmem_callee(const void *haystack,size_t haystack_len,const void *needle,size_t needle_len) __smallc __z88dk_callee;
108 #define memmem(a,b,c,d) memmem_callee(a,b,c,d)
109 
110 
111 extern void __LIB__ *memmove(void *dst,const void *src,size_t n) __smallc;
112 #if !__GBZ80__ && !__8080__
113 extern void __LIB__ *memmove_callee(void *dst,const void *src,size_t n) __smallc __z88dk_callee;
114 #define memmove(a,b,c) memmove_callee(a,b,c)
115 #endif
116 
117 
118 extern void __LIB__ *memrchr(const void *s,int c,size_t n) __smallc;
119 #if !__GBZ80__ && !__8080__
120 extern void __LIB__ *memrchr_callee(const void *s,int c,size_t n) __smallc __z88dk_callee;
121 #define memrchr(a,b,c) memrchr_callee(a,b,c)
122 #endif
123 
124 
125 extern void __LIB__ *memset(void *s,int c,size_t n) __smallc;
126 extern void __LIB__ *memset_callee(void *s,int c,size_t n) __smallc __z88dk_callee;
127 #define memset(a,b,c) memset_callee(a,b,c)
128 
129 
130 extern void __LIB__ *memswap(void *s1,void *s2,size_t n) __smallc;
131 extern void __LIB__ *memswap_callee(void *s1,void *s2,size_t n) __smallc __z88dk_callee;
132 #define memswap(a,b,c) memswap_callee(a,b,c)
133 
134 
135 extern char __LIB__ *stpcpy(char *dst,const char *src) __smallc;
136 extern char __LIB__ *stpcpy_callee(char *dst,const char *src) __smallc __z88dk_callee;
137 #define stpcpy(a,b) stpcpy_callee(a,b)
138 
139 
140 extern char __LIB__ *stpncpy(char *dst,const char *src,size_t n) __smallc;
141 #if !__GBZ80__ && !__8080__
142 extern char __LIB__ *stpncpy_callee(char *dst,const char *src,size_t n) __smallc __z88dk_callee;
143 #define stpncpy(a,b,c) stpncpy_callee(a,b,c)
144 #endif
145 
146 
147 extern int __LIB__ strcasecmp(const char *s1,const char *s2) __smallc;
148 extern int __LIB__ strcasecmp_callee(const char *s1,const char *s2) __smallc __z88dk_callee;
149 #define strcasecmp(a,b) strcasecmp_callee(a,b)
150 
151 
152 extern char __LIB__ *strcat(char *dst,const char *src) __smallc;
153 extern char __LIB__ *strcat_callee(char *dst,const char *src) __smallc __z88dk_callee;
154 #define strcat(a,b) strcat_callee(a,b)
155 
156 
157 extern char __LIB__ *strchr(const char *s,int c) __smallc;
158 extern char __LIB__ *strchr_callee(const char *s,int c) __smallc __z88dk_callee;
159 #define strchr(a,b) strchr_callee(a,b)
160 
161 
162 extern char __LIB__ *strchrnul(const char *s,int c) __smallc;
163 extern char __LIB__ *strchrnul_callee(const char *s,int c) __smallc __z88dk_callee;
164 #define strchrnul(a,b) strchrnul_callee(a,b)
165 
166 
167 extern int __LIB__ strcmp(const char *s1,const char *s2) __smallc;
168 extern int __LIB__ strcmp_callee(const char *s1,const char *s2) __smallc __z88dk_callee;
169 #define strcmp(a,b) strcmp_callee(a,b)
170 
171 
172 extern int __LIB__ strcoll(const char *s1,const char *s2) __smallc;
173 extern int __LIB__ strcoll_callee(const char *s1,const char *s2) __smallc __z88dk_callee;
174 #define strcoll(a,b) strcoll_callee(a,b)
175 
176 
177 extern char __LIB__ *strcpy(char *dst,const char *src) __smallc;
178 extern char __LIB__ *strcpy_callee(char *dst,const char *src) __smallc __z88dk_callee;
179 #define strcpy(a,b) strcpy_callee(a,b)
180 
181 
182 extern size_t __LIB__ strcspn(const char *s,const char *nspn) __smallc;
183 extern size_t __LIB__ strcspn_callee(const char *s,const char *nspn) __smallc __z88dk_callee;
184 #define strcspn(a,b) strcspn_callee(a,b)
185 
186 
187 extern char __LIB__  *strdup(const char *s) __smallc __z88dk_fastcall;
188 
189 
190 extern char __LIB__  *strerror(int errnum) __smallc __z88dk_fastcall;
191 
192 
193 extern int __LIB__ stricmp(const char *s1,const char *s2) __smallc;
194 extern int __LIB__ stricmp_callee(const char *s1,const char *s2) __smallc __z88dk_callee;
195 #define stricmp(a,b) stricmp_callee(a,b)
196 
197 
198 extern size_t __LIB__ strlcat(char *dst,const char *src,size_t n) __smallc;
199 #if !__GBZ80__ && !__8080__
200 extern size_t __LIB__ strlcat_callee(char *dst,const char *src,size_t n) __smallc __z88dk_callee;
201 #define strlcat(a,b,c) strlcat_callee(a,b,c)
202 #endif
203 
204 
205 extern size_t __LIB__ strlcpy(char *dst,const char *src,size_t n) __smallc;
206 #if !__GBZ80__ && !__8080__
207 extern size_t __LIB__ strlcpy_callee(char *dst,const char *src,size_t n) __smallc __z88dk_callee;
208 #define strlcpy(a,b,c) strlcpy_callee(a,b,c)
209 #endif
210 
211 
212 extern size_t __LIB__  strlen(const char *s) __smallc __z88dk_fastcall;
213 
214 
215 extern char __LIB__  *strlwr(char *s) __smallc __z88dk_fastcall;
216 
217 
218 extern int __LIB__ strncasecmp(const char *s1,const char *s2,size_t n) __smallc;
219 #if !__GBZ80__ && !__8080__
220 extern int __LIB__ strncasecmp_callee(const char *s1,const char *s2,size_t n) __smallc __z88dk_callee;
221 #define strncasecmp(a,b,c) strncasecmp_callee(a,b,c)
222 #endif
223 
224 
225 extern char __LIB__ *strncat(char *dst,const char *src,size_t n) __smallc;
226 #if !__GBZ80__ && !__8080__
227 extern char __LIB__ *strncat_callee(char *dst,const char *src,size_t n) __smallc __z88dk_callee;
228 #define strncat(a,b,c) strncat_callee(a,b,c)
229 #endif
230 
231 
232 extern char __LIB__ *strnchr(const char *s,size_t n,int c) __smallc;
233 #if !__GBZ80__ && !__8080__
234 extern char __LIB__ *strnchr_callee(const char *s,size_t n,int c) __smallc __z88dk_callee;
235 #define strnchr(a,b,c) strnchr_callee(a,b,c)
236 #endif
237 
238 
239 extern int __LIB__ strncmp(const char *s1,const char *s2,size_t n) __smallc;
240 #if !__GBZ80__ && !__8080__
241 extern int __LIB__ strncmp_callee(const char *s1,const char *s2,size_t n) __smallc __z88dk_callee;
242 #define strncmp(a,b,c) strncmp_callee(a,b,c)
243 #endif
244 
245 
246 extern char __LIB__ *strncpy(char *dst,const char *src,size_t n) __smallc;
247 #if !__GBZ80__ && !__8080__
248 extern char __LIB__ *strncpy_callee(char *dst,const char *src,size_t n) __smallc __z88dk_callee;
249 #define strncpy(a,b,c) strncpy_callee(a,b,c)
250 #endif
251 
252 
253 extern char __LIB__ *strndup(const char *s,size_t n) __smallc;
254 extern char __LIB__ *strndup_callee(const char *s,size_t n) __smallc __z88dk_callee;
255 #define strndup(a,b) strndup_callee(a,b)
256 
257 
258 extern int __LIB__ strnicmp(const char *s1,const char *s2,size_t n) __smallc;
259 extern int __LIB__ strnicmp_callee(const char *s1,const char *s2,size_t n) __smallc __z88dk_callee;
260 #define strnicmp(a,b,c) strnicmp_callee(a,b,c)
261 
262 
263 extern size_t __LIB__ strnlen(const char *s,size_t max_len) __smallc;
264 extern size_t __LIB__ strnlen_callee(const char *s,size_t max_len) __smallc __z88dk_callee;
265 #define strnlen(a,b) strnlen_callee(a,b)
266 
267 
268 extern char __LIB__ *strpbrk(const char *s,const char *set) __smallc;
269 extern char __LIB__ *strpbrk_callee(const char *s,const char *set) __smallc __z88dk_callee;
270 #define strpbrk(a,b) strpbrk_callee(a,b)
271 
272 
273 extern char __LIB__ *strrchr(const char *s,int c) __smallc;
274 extern char __LIB__ *strrchr_callee(const char *s,int c) __smallc __z88dk_callee;
275 #define strrchr(a,b) strrchr_callee(a,b)
276 
277 
278 extern size_t __LIB__ strrcspn(const char *s,const char *set) __smallc;
279 extern size_t __LIB__ strrcspn_callee(const char *s,const char *set) __smallc __z88dk_callee;
280 #define strrcspn(a,b) strrcspn_callee(a,b)
281 
282 
283 extern char __LIB__  *strrev(char *s) __smallc __z88dk_fastcall;
284 
285 
286 extern size_t __LIB__ strrspn(const char *s,const char *set) __smallc;
287 extern size_t __LIB__ strrspn_callee(const char *s,const char *set) __smallc __z88dk_callee;
288 #define strrspn(a,b) strrspn_callee(a,b)
289 
290 
291 extern char __LIB__  *strrstrip(char *s) __smallc __z88dk_fastcall;
292 
293 
294 extern char __LIB__ *strsep(char **s,const char *delim) __smallc;
295 extern char __LIB__ *strsep_callee(char **s,const char *delim) __smallc __z88dk_callee;
296 #define strsep(a,b) strsep_callee(a,b)
297 
298 
299 extern size_t __LIB__ strspn(const char *s,const char *pfx) __smallc;
300 extern size_t __LIB__ strspn_callee(const char *s,const char *pfx) __smallc __z88dk_callee;
301 #define strspn(a,b) strspn_callee(a,b)
302 
303 
304 extern char __LIB__ *strstr(const char *s,const char *subs) __smallc;
305 extern char __LIB__ *strstr_callee(const char *s,const char *subs) __smallc __z88dk_callee;
306 #define strstr(a,b) strstr_callee(a,b)
307 
308 
309 extern char __LIB__  *strstrip(char *s) __smallc __z88dk_fastcall;
310 
311 
312 extern char __LIB__ *strtok(char *s,const char *delim) __smallc;
313 extern char __LIB__ *strtok_callee(char *s,const char *delim) __smallc __z88dk_callee;
314 #define strtok(a,b) strtok_callee(a,b)
315 
316 
317 extern char __LIB__ *strtok_r(char *s,const char *delim,char **last_s) __smallc;
318 #if !__GBZ80__ && !__8080__
319 extern char __LIB__ *strtok_r_callee(char *s,const char *delim,char **last_s) __smallc __z88dk_callee;
320 #define strtok_r(a,b,c) strtok_r_callee(a,b,c)
321 #endif
322 
323 
324 extern char __LIB__  *strupr(char *s) __smallc __z88dk_fastcall;
325 
326 
327 extern size_t __LIB__ strxfrm(char *dst,const char *src,size_t n) __smallc;
328 #if !__GBZ80__ && !__8080__
329 extern size_t __LIB__ strxfrm_callee(char *dst,const char *src,size_t n) __smallc __z88dk_callee;
330 #define strxfrm(a,b,c) strxfrm_callee(a,b,c)
331 #endif
332 
333 extern char __LIB__    *strrstr(const char *haystack, const char *needle) __smallc;
334 extern char __LIB__    *strrstr_callee(const char *haystack, const char *needle) __smallc __z88dk_callee;
335 #define strrstr(a,b)   strrstr_callee(a,b)
336 
337 
338 extern void __LIB__    *memopi(void *, void *, uint, uint) __smallc;
339 extern void __LIB__    *memopi_callee(void *, void *, uint, uint) __smallc __z88dk_callee;
340 #define memopi(a,b,c,d) memopi_callee(a,b,c,d)
341 
342 extern void __LIB__    *memopd(void *, void *, uint, uint) __smallc;
343 extern void __LIB__    *memopd_callee(void *, void *, uint, uint) __smallc __z88dk_callee;
344 #define memopd(a,b,c,d) memopd_callee(a,b,c,d)
345 
346 /*
347  * Now handle far stuff
348  */
349 
350 #ifdef FARDATA
351 
352 #define strlen(s) strlen_far(s)
353 extern int __LIB__ strlen_far(far char *);
354 
355 #undef strcat
356 #define strcat(s1,s2) strcat_far(s1,s2)
357 extern far char __LIB__ *strcat_far(far char *, far char *) __smallc;
358 
359 #undef strcpy
360 #define strcpy(s1,s2) strcpy_far(s1,s2)
361 extern far char __LIB__ *strcpy_far(far char *, far char *) __smallc;
362 
363 #undef strncat
364 #define strncat(s1,s2) strncat_far(s1,s2,n)
365 extern far char __LIB__ *strncat_far(far char *, far char *, int) __smallc;
366 
367 #undef strncpy
368 #define strncpy(s1,s2) strncpy_far(s1,s2,n)
369 extern far char __LIB__ *strncpy_far(far char *, far char *, int) __smallc;
370 
371 #define strlwr(s) strlwr_far(s)
372 extern far char __LIB__ *strlwr_far(far char *);
373 
374 #define strupr(s) strupr_far(s)
375 extern far char __LIB__ *strupr_far(far char *);
376 
377 #undef strchr
378 #define strchr(s,c) strchr_far(s1,c)
379 extern far char __LIB__ *strchr_far(far unsigned char *, unsigned char) __smallc;
380 
381 #undef strrchr
382 #define strrchr(s,c) strrchr_far(s1,c)
383 extern far char __LIB__ *strrchr_far(far unsigned char *, unsigned char) __smallc;
384 
385 #define strdup(s) strdup_far(s)
386 extern far char __LIB__ *strdup_far(far char *);
387 
388 #endif
389 
390 
391 
392 
393 #ifdef __SCCZ80
394 
395    #ifndef __DISABLE_BUILTIN
396 
397    #ifndef __DISABLE_BUILTIN_MEMSET
398    #undef  memset
399    #define memset(a,b,c)   __builtin_memset(a,b,c)
400    extern void __LIB__    *__builtin_memset(void *dst, int c, size_t n) __smallc;
401    #endif
402 
403    #ifndef __DISABLE_BUILTIN_MEMCPY
404    #undef  memcpy
405    #define memcpy(a,b,c)   __builtin_memcpy(a,b,c)
406    extern void __LIB__    *__builtin_memcpy(void *dst, void *src,size_t n) __smallc;
407    #endif
408 
409    #ifndef __DISABLE_BUILTIN_STRCPY
410    #undef  strcpy
411    #define strcpy(a,b)     __builtin_strcpy(a,b)
412    extern char __LIB__    *__builtin_strcpy(char *dst, const char *src) __smallc;
413    #endif
414 
415    #ifndef __DISABLE_BUILTIN_STRCHR
416    #undef  strchr
417    #define strchr(a,b)     __builtin_strchr(a,b)
418    extern char __LIB__    *__builtin_strchr(const char *haystack, int needle) __smallc;
419    #endif
420 
421    #endif
422 
423 #endif
424 
425 #ifdef __SDCC
426 
427    extern int ffsll(long long i) __preserves_regs(b,c);
428    extern int ffsll_callee(long long i) __preserves_regs(b,c) __z88dk_callee;
429    #define ffsll(a) ffsll_callee(a)
430    #define __DISABLE_BUILTIN
431 
432    #ifndef __DISABLE_BUILTIN
433 
434    #ifndef __DISABLE_BUILTIN_MEMCPY
435    #undef  memcpy
436    #define memcpy(dst, src, n)    __builtin_memcpy(dst, src, n)
437    #endif
438 
439    #ifndef __DISABLE_BUILTIN_STRCPY
440    #undef  strcpy
441    #define strcpy(dst, src)       __builtin_strcpy(dst, src)
442    #endif
443 
444    #ifndef __DISABLE_BUILTIN_STRNCPY
445    #undef  strncpy
446    #define strncpy(dst, src, n)   __builtin_strncpy(dst, src, n)
447    #endif
448 
449    #ifndef __DISABLE_BUILTIN_STRCHR
450    #undef  strchr
451    #define strchr(s, c)           __builtin_strchr(s, c)
452    #endif
453 
454    #ifndef __DISABLE_BUILTIN_MEMSET
455    #undef  memset
456    #define memset(dst, c, n)      __builtin_memset(dst, c, n)
457    #endif
458 
459    #endif
460 
461 #endif
462 
463 #endif
464