xref: /xnu-11215/osfmk/machine/string.h (revision 94d3b452)
1 /*
2  * Copyright (c) 2022 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 
29 #ifndef _MACHINE_STRING_H_
30 #define _MACHINE_STRING_H_
31 
32 #include <sys/cdefs.h>
33 
34 /*
35  * Below are prototypes that call into a precise symbol,
36  * and prevent the compiler from using a builtin.
37  */
38 
39 /*
40  * Memory functions
41  */
42 extern int bcmp_impl(const void *, const void *, size_t) asm("_bcmp");
43 extern int memcmp_impl(const void *, const void *, size_t) asm("_memcmp");
44 
45 extern unsigned long memcmp_zero_ptr_aligned_impl(const void *addr, size_t size) asm("_memcmp_zero_ptr_aligned");
46 
47 extern void *bzero_impl(void *, const void *, size_t) asm("_bzero");
48 extern void *memset_impl(void *, int c, size_t) asm("_memset");
49 
50 extern void *memcpy_impl(void *, const void *, size_t) asm("_memcpy");
51 extern void *memmove_impl(void *, const void *, size_t) asm("_memmove");
52 extern void bcopy_impl(const void *, void *, size_t) asm("_bcopy");
53 
54 /*
55  * String functions
56  */
57 extern size_t strlen_impl(const char *) asm("_strlen");
58 extern size_t strnlen_impl(const char *s, size_t) asm("_strnlen");
59 
60 extern int strprefix_impl(const char *, const char *) asm("_strprefix");
61 
62 extern int strcmp_impl(const char *, const char *) asm("_strcmp");
63 extern int strncmp_impl(const char *, const char *, size_t) asm("_strncmp");
64 extern int strlcmp_impl(const char *, const char *, size_t) asm("_strlcmp");
65 extern int strbufcmp_impl(const char *, size_t, const char *, size_t) asm("_strbufcmp");
66 extern int strcasecmp_impl(const char *, const char *) asm("_strcasecmp");
67 extern int strncasecmp_impl(const char *, const char *, size_t) asm("_strncasecmp");
68 extern int strlcasecmp_impl(const char *, const char *, size_t) asm("_strlcasecmp");
69 extern int strbufcasecmp_impl(const char *, size_t, const char *, size_t) asm("_strbufcasecmp");
70 
71 extern char *strchr_impl(const char *, int) asm("_strchr");
72 extern char *strrchr_impl(const char *, int) asm("_strrchr");
73 extern char *strnstr_impl(const char *s, const char *, size_t) asm("_strnstr");
74 
75 extern size_t strlcat_impl(char *, const char *, size_t) asm("_strlcat");
76 extern const char *strbufcat_impl(char *, size_t, const char *, size_t) asm("_strbufcat");
77 extern size_t strlcpy_impl(char *, const char *, size_t) asm("_strlcpy");
78 extern const char *strbufcpy_impl(char *, size_t, const char *, size_t) asm("_strbufcpy");
79 
80 /*
81  * Deprecated functions
82  */
83 extern char *strncpy_impl(char *, const char *, size_t) asm("_strncpy");
84 extern char *strncat_impl(char *, const char *, size_t) asm("_strncat");
85 
86 #if CONFIG_VSPRINTF
87 extern char *strcpy_impl(char *, const char *) asm("_strcpy");
88 extern char *strcat_impl(char *, const char *) asm("_strcat");
89 #endif
90 
91 #endif /* _MACHINE_STRING_H_ */
92