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 */
42extern int bcmp_impl(const void *, const void *, size_t) asm("_bcmp");
43extern int memcmp_impl(const void *, const void *, size_t) asm("_memcmp");
44
45extern unsigned long memcmp_zero_ptr_aligned_impl(const void *addr, size_t size) asm("_memcmp_zero_ptr_aligned");
46
47extern void *bzero_impl(void *, const void *, size_t) asm("_bzero");
48extern void *memset_impl(void *, int c, size_t) asm("_memset");
49
50extern void *memcpy_impl(void *, const void *, size_t) asm("_memcpy");
51extern void *memmove_impl(void *, const void *, size_t) asm("_memmove");
52extern void bcopy_impl(const void *, void *, size_t) asm("_bcopy");
53
54/*
55 * String functions
56 */
57extern size_t strlen_impl(const char *) asm("_strlen");
58extern size_t strnlen_impl(const char *s, size_t) asm("_strnlen");
59
60extern int strprefix_impl(const char *, const char *) asm("_strprefix");
61
62extern int strcmp_impl(const char *, const char *) asm("_strcmp");
63extern int strncmp_impl(const char *, const char *, size_t) asm("_strncmp");
64extern int strlcmp_impl(const char *, const char *, size_t) asm("_strlcmp");
65extern int strbufcmp_impl(const char *, size_t, const char *, size_t) asm("_strbufcmp");
66extern int strcasecmp_impl(const char *, const char *) asm("_strcasecmp");
67extern int strncasecmp_impl(const char *, const char *, size_t) asm("_strncasecmp");
68extern int strlcasecmp_impl(const char *, const char *, size_t) asm("_strlcasecmp");
69extern int strbufcasecmp_impl(const char *, size_t, const char *, size_t) asm("_strbufcasecmp");
70
71extern char *strchr_impl(const char *, int) asm("_strchr");
72extern char *strrchr_impl(const char *, int) asm("_strrchr");
73extern char *strnstr_impl(const char *s, const char *, size_t) asm("_strnstr");
74
75extern size_t strlcat_impl(char *, const char *, size_t) asm("_strlcat");
76extern const char *strbufcat_impl(char *, size_t, const char *, size_t) asm("_strbufcat");
77extern size_t strlcpy_impl(char *, const char *, size_t) asm("_strlcpy");
78extern const char *strbufcpy_impl(char *, size_t, const char *, size_t) asm("_strbufcpy");
79
80/*
81 * Deprecated functions
82 */
83extern char *strncpy_impl(char *, const char *, size_t) asm("_strncpy");
84extern char *strncat_impl(char *, const char *, size_t) asm("_strncat");
85
86#if CONFIG_VSPRINTF
87extern char *strcpy_impl(char *, const char *) asm("_strcpy");
88extern char *strcat_impl(char *, const char *) asm("_strcat");
89#endif
90
91#endif /* _MACHINE_STRING_H_ */
92