xref: /xnu-8796.141.3/libsyscall/wrappers/_libc_funcptr.c (revision 1b191cb58250d0705d8a51287127505aa4bc0789)
1*1b191cb5SApple OSS Distributions /*
2*1b191cb5SApple OSS Distributions  * Copyright (c) 2010-2014 Apple Inc. All rights reserved.
3*1b191cb5SApple OSS Distributions  *
4*1b191cb5SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*1b191cb5SApple OSS Distributions  *
6*1b191cb5SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*1b191cb5SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*1b191cb5SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*1b191cb5SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*1b191cb5SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*1b191cb5SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*1b191cb5SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*1b191cb5SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*1b191cb5SApple OSS Distributions  *
15*1b191cb5SApple OSS Distributions  * Please obtain a copy of the License at
16*1b191cb5SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*1b191cb5SApple OSS Distributions  *
18*1b191cb5SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*1b191cb5SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*1b191cb5SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*1b191cb5SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*1b191cb5SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*1b191cb5SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*1b191cb5SApple OSS Distributions  * limitations under the License.
25*1b191cb5SApple OSS Distributions  *
26*1b191cb5SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*1b191cb5SApple OSS Distributions  */
28*1b191cb5SApple OSS Distributions 
29*1b191cb5SApple OSS Distributions #include "_libkernel_init.h"
30*1b191cb5SApple OSS Distributions #include "strings.h"
31*1b191cb5SApple OSS Distributions 
32*1b191cb5SApple OSS Distributions extern _libkernel_functions_t _libkernel_functions;
33*1b191cb5SApple OSS Distributions extern void mig_os_release(void* ptr);
34*1b191cb5SApple OSS Distributions 
35*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
36*1b191cb5SApple OSS Distributions void *
malloc(size_t size)37*1b191cb5SApple OSS Distributions malloc(size_t size)
38*1b191cb5SApple OSS Distributions {
39*1b191cb5SApple OSS Distributions 	if (_libkernel_functions->malloc) {
40*1b191cb5SApple OSS Distributions 		return _libkernel_functions->malloc(size);
41*1b191cb5SApple OSS Distributions 	}
42*1b191cb5SApple OSS Distributions 	return NULL;
43*1b191cb5SApple OSS Distributions }
44*1b191cb5SApple OSS Distributions 
45*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
46*1b191cb5SApple OSS Distributions void
free(void * ptr)47*1b191cb5SApple OSS Distributions free(void *ptr)
48*1b191cb5SApple OSS Distributions {
49*1b191cb5SApple OSS Distributions 	if (_libkernel_functions->free) {
50*1b191cb5SApple OSS Distributions 		_libkernel_functions->free(ptr);
51*1b191cb5SApple OSS Distributions 	}
52*1b191cb5SApple OSS Distributions }
53*1b191cb5SApple OSS Distributions 
54*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
55*1b191cb5SApple OSS Distributions void *
realloc(void * ptr,size_t size)56*1b191cb5SApple OSS Distributions realloc(void *ptr, size_t size)
57*1b191cb5SApple OSS Distributions {
58*1b191cb5SApple OSS Distributions 	if (_libkernel_functions->realloc) {
59*1b191cb5SApple OSS Distributions 		return _libkernel_functions->realloc(ptr, size);
60*1b191cb5SApple OSS Distributions 	}
61*1b191cb5SApple OSS Distributions 	return NULL;
62*1b191cb5SApple OSS Distributions }
63*1b191cb5SApple OSS Distributions 
64*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
65*1b191cb5SApple OSS Distributions void *
reallocf(void * ptr,size_t size)66*1b191cb5SApple OSS Distributions reallocf(void *ptr, size_t size)
67*1b191cb5SApple OSS Distributions {
68*1b191cb5SApple OSS Distributions 	void *nptr = realloc(ptr, size);
69*1b191cb5SApple OSS Distributions 	if (!nptr && ptr) {
70*1b191cb5SApple OSS Distributions 		free(ptr);
71*1b191cb5SApple OSS Distributions 	}
72*1b191cb5SApple OSS Distributions 	return nptr;
73*1b191cb5SApple OSS Distributions }
74*1b191cb5SApple OSS Distributions 
75*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
76*1b191cb5SApple OSS Distributions void
_pthread_exit_if_canceled(int error)77*1b191cb5SApple OSS Distributions _pthread_exit_if_canceled(int error)
78*1b191cb5SApple OSS Distributions {
79*1b191cb5SApple OSS Distributions 	return _libkernel_functions->_pthread_exit_if_canceled(error);
80*1b191cb5SApple OSS Distributions }
81*1b191cb5SApple OSS Distributions 
82*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
83*1b191cb5SApple OSS Distributions void
_pthread_set_self(void * ptr)84*1b191cb5SApple OSS Distributions _pthread_set_self(void *ptr __attribute__((__unused__)))
85*1b191cb5SApple OSS Distributions {
86*1b191cb5SApple OSS Distributions }
87*1b191cb5SApple OSS Distributions 
88*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
89*1b191cb5SApple OSS Distributions void
_pthread_clear_qos_tsd(mach_port_t thread_port)90*1b191cb5SApple OSS Distributions _pthread_clear_qos_tsd(mach_port_t thread_port)
91*1b191cb5SApple OSS Distributions {
92*1b191cb5SApple OSS Distributions 	if (_libkernel_functions->version >= 3 &&
93*1b191cb5SApple OSS Distributions 	    _libkernel_functions->pthread_clear_qos_tsd) {
94*1b191cb5SApple OSS Distributions 		return _libkernel_functions->pthread_clear_qos_tsd(thread_port);
95*1b191cb5SApple OSS Distributions 	}
96*1b191cb5SApple OSS Distributions }
97*1b191cb5SApple OSS Distributions 
98*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
99*1b191cb5SApple OSS Distributions int
pthread_current_stack_contains_np(const void * addr,size_t len)100*1b191cb5SApple OSS Distributions pthread_current_stack_contains_np(const void *addr, size_t len)
101*1b191cb5SApple OSS Distributions {
102*1b191cb5SApple OSS Distributions 	if (_libkernel_functions->version >= 4 &&
103*1b191cb5SApple OSS Distributions 	    _libkernel_functions->pthread_current_stack_contains_np) {
104*1b191cb5SApple OSS Distributions 		return _libkernel_functions->pthread_current_stack_contains_np(addr, len);
105*1b191cb5SApple OSS Distributions 	}
106*1b191cb5SApple OSS Distributions 
107*1b191cb5SApple OSS Distributions 	return 0;
108*1b191cb5SApple OSS Distributions }
109*1b191cb5SApple OSS Distributions 
110*1b191cb5SApple OSS Distributions /*
111*1b191cb5SApple OSS Distributions  * Upcalls to optimized libplatform string functions
112*1b191cb5SApple OSS Distributions  */
113*1b191cb5SApple OSS Distributions 
114*1b191cb5SApple OSS Distributions static const struct _libkernel_string_functions
115*1b191cb5SApple OSS Distributions     _libkernel_generic_string_functions = {
116*1b191cb5SApple OSS Distributions 	.bzero = _libkernel_bzero,
117*1b191cb5SApple OSS Distributions 	.memmove = _libkernel_memmove,
118*1b191cb5SApple OSS Distributions 	.memset = _libkernel_memset,
119*1b191cb5SApple OSS Distributions 	.strchr = _libkernel_strchr,
120*1b191cb5SApple OSS Distributions 	.strcmp = _libkernel_strcmp,
121*1b191cb5SApple OSS Distributions 	.strcpy = _libkernel_strcpy,
122*1b191cb5SApple OSS Distributions 	.strlcpy = _libkernel_strlcpy,
123*1b191cb5SApple OSS Distributions 	.strlen = _libkernel_strlen,
124*1b191cb5SApple OSS Distributions };
125*1b191cb5SApple OSS Distributions static _libkernel_string_functions_t _libkernel_string_functions =
126*1b191cb5SApple OSS Distributions     &_libkernel_generic_string_functions;
127*1b191cb5SApple OSS Distributions 
128*1b191cb5SApple OSS Distributions kern_return_t
__libkernel_platform_init(_libkernel_string_functions_t fns)129*1b191cb5SApple OSS Distributions __libkernel_platform_init(_libkernel_string_functions_t fns)
130*1b191cb5SApple OSS Distributions {
131*1b191cb5SApple OSS Distributions 	_libkernel_string_functions = fns;
132*1b191cb5SApple OSS Distributions 	return KERN_SUCCESS;
133*1b191cb5SApple OSS Distributions }
134*1b191cb5SApple OSS Distributions 
135*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
136*1b191cb5SApple OSS Distributions void
bzero(void * s,size_t n)137*1b191cb5SApple OSS Distributions bzero(void *s, size_t n)
138*1b191cb5SApple OSS Distributions {
139*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->bzero(s, n);
140*1b191cb5SApple OSS Distributions }
141*1b191cb5SApple OSS Distributions 
142*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
143*1b191cb5SApple OSS Distributions void
__bzero(void * s,size_t n)144*1b191cb5SApple OSS Distributions __bzero(void *s, size_t n)
145*1b191cb5SApple OSS Distributions {
146*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->bzero(s, n);
147*1b191cb5SApple OSS Distributions }
148*1b191cb5SApple OSS Distributions 
149*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
150*1b191cb5SApple OSS Distributions void *
memchr(const void * s,int c,size_t n)151*1b191cb5SApple OSS Distributions memchr(const void *s, int c, size_t n)
152*1b191cb5SApple OSS Distributions {
153*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->memchr(s, c, n);
154*1b191cb5SApple OSS Distributions }
155*1b191cb5SApple OSS Distributions 
156*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
157*1b191cb5SApple OSS Distributions int
memcmp(const void * s1,const void * s2,size_t n)158*1b191cb5SApple OSS Distributions memcmp(const void *s1, const void *s2, size_t n)
159*1b191cb5SApple OSS Distributions {
160*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->memcmp(s1, s2, n);
161*1b191cb5SApple OSS Distributions }
162*1b191cb5SApple OSS Distributions 
163*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
164*1b191cb5SApple OSS Distributions void *
memmove(void * dst,const void * src,size_t n)165*1b191cb5SApple OSS Distributions memmove(void *dst, const void *src, size_t n)
166*1b191cb5SApple OSS Distributions {
167*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->memmove(dst, src, n);
168*1b191cb5SApple OSS Distributions }
169*1b191cb5SApple OSS Distributions 
170*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
171*1b191cb5SApple OSS Distributions void *
memcpy(void * dst,const void * src,size_t n)172*1b191cb5SApple OSS Distributions memcpy(void *dst, const void *src, size_t n)
173*1b191cb5SApple OSS Distributions {
174*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->memmove(dst, src, n);
175*1b191cb5SApple OSS Distributions }
176*1b191cb5SApple OSS Distributions 
177*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
178*1b191cb5SApple OSS Distributions void *
memccpy(void * __restrict dst,const void * __restrict src,int c,size_t n)179*1b191cb5SApple OSS Distributions memccpy(void *__restrict dst, const void *__restrict src, int c, size_t n)
180*1b191cb5SApple OSS Distributions {
181*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->memccpy(dst, src, c, n);
182*1b191cb5SApple OSS Distributions }
183*1b191cb5SApple OSS Distributions 
184*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
185*1b191cb5SApple OSS Distributions void *
memset(void * b,int c,size_t len)186*1b191cb5SApple OSS Distributions memset(void *b, int c, size_t len)
187*1b191cb5SApple OSS Distributions {
188*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->memset(b, c, len);
189*1b191cb5SApple OSS Distributions }
190*1b191cb5SApple OSS Distributions 
191*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
192*1b191cb5SApple OSS Distributions char *
strchr(const char * s,int c)193*1b191cb5SApple OSS Distributions strchr(const char *s, int c)
194*1b191cb5SApple OSS Distributions {
195*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strchr(s, c);
196*1b191cb5SApple OSS Distributions }
197*1b191cb5SApple OSS Distributions 
198*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
199*1b191cb5SApple OSS Distributions char *
index(const char * s,int c)200*1b191cb5SApple OSS Distributions index(const char *s, int c)
201*1b191cb5SApple OSS Distributions {
202*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strchr(s, c);
203*1b191cb5SApple OSS Distributions }
204*1b191cb5SApple OSS Distributions 
205*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
206*1b191cb5SApple OSS Distributions int
strcmp(const char * s1,const char * s2)207*1b191cb5SApple OSS Distributions strcmp(const char *s1, const char *s2)
208*1b191cb5SApple OSS Distributions {
209*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strcmp(s1, s2);
210*1b191cb5SApple OSS Distributions }
211*1b191cb5SApple OSS Distributions 
212*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
213*1b191cb5SApple OSS Distributions char *
strcpy(char * restrict dst,const char * restrict src)214*1b191cb5SApple OSS Distributions strcpy(char * restrict dst, const char * restrict src)
215*1b191cb5SApple OSS Distributions {
216*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strcpy(dst, src);
217*1b191cb5SApple OSS Distributions }
218*1b191cb5SApple OSS Distributions 
219*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
220*1b191cb5SApple OSS Distributions size_t
strlcat(char * restrict dst,const char * restrict src,size_t maxlen)221*1b191cb5SApple OSS Distributions strlcat(char * restrict dst, const char * restrict src, size_t maxlen)
222*1b191cb5SApple OSS Distributions {
223*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strlcat(dst, src, maxlen);
224*1b191cb5SApple OSS Distributions }
225*1b191cb5SApple OSS Distributions 
226*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
227*1b191cb5SApple OSS Distributions size_t
strlcpy(char * restrict dst,const char * restrict src,size_t maxlen)228*1b191cb5SApple OSS Distributions strlcpy(char * restrict dst, const char * restrict src, size_t maxlen)
229*1b191cb5SApple OSS Distributions {
230*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strlcpy(dst, src, maxlen);
231*1b191cb5SApple OSS Distributions }
232*1b191cb5SApple OSS Distributions 
233*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
234*1b191cb5SApple OSS Distributions size_t
strlen(const char * str)235*1b191cb5SApple OSS Distributions strlen(const char *str)
236*1b191cb5SApple OSS Distributions {
237*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strlen(str);
238*1b191cb5SApple OSS Distributions }
239*1b191cb5SApple OSS Distributions 
240*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
241*1b191cb5SApple OSS Distributions int
strncmp(const char * s1,const char * s2,size_t n)242*1b191cb5SApple OSS Distributions strncmp(const char *s1, const char *s2, size_t n)
243*1b191cb5SApple OSS Distributions {
244*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strncmp(s1, s2, n);
245*1b191cb5SApple OSS Distributions }
246*1b191cb5SApple OSS Distributions 
247*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
248*1b191cb5SApple OSS Distributions char *
strncpy(char * restrict dst,const char * restrict src,size_t maxlen)249*1b191cb5SApple OSS Distributions strncpy(char * restrict dst, const char * restrict src, size_t maxlen)
250*1b191cb5SApple OSS Distributions {
251*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strncpy(dst, src, maxlen);
252*1b191cb5SApple OSS Distributions }
253*1b191cb5SApple OSS Distributions 
254*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
255*1b191cb5SApple OSS Distributions size_t
strnlen(const char * s,size_t maxlen)256*1b191cb5SApple OSS Distributions strnlen(const char *s, size_t maxlen)
257*1b191cb5SApple OSS Distributions {
258*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strnlen(s, maxlen);
259*1b191cb5SApple OSS Distributions }
260*1b191cb5SApple OSS Distributions 
261*1b191cb5SApple OSS Distributions __attribute__((visibility("hidden")))
262*1b191cb5SApple OSS Distributions char *
strstr(const char * s,const char * find)263*1b191cb5SApple OSS Distributions strstr(const char *s, const char *find)
264*1b191cb5SApple OSS Distributions {
265*1b191cb5SApple OSS Distributions 	return _libkernel_string_functions->strstr(s, find);
266*1b191cb5SApple OSS Distributions }
267*1b191cb5SApple OSS Distributions 
268*1b191cb5SApple OSS Distributions /*
269*1b191cb5SApple OSS Distributions  * mach/mach.h voucher_mach_msg API
270*1b191cb5SApple OSS Distributions  */
271*1b191cb5SApple OSS Distributions 
272*1b191cb5SApple OSS Distributions static const struct _libkernel_voucher_functions
273*1b191cb5SApple OSS Distributions     _libkernel_voucher_functions_empty;
274*1b191cb5SApple OSS Distributions static _libkernel_voucher_functions_t _libkernel_voucher_functions =
275*1b191cb5SApple OSS Distributions     &_libkernel_voucher_functions_empty;
276*1b191cb5SApple OSS Distributions 
277*1b191cb5SApple OSS Distributions kern_return_t
__libkernel_voucher_init(_libkernel_voucher_functions_t fns)278*1b191cb5SApple OSS Distributions __libkernel_voucher_init(_libkernel_voucher_functions_t fns)
279*1b191cb5SApple OSS Distributions {
280*1b191cb5SApple OSS Distributions 	_libkernel_voucher_functions = fns;
281*1b191cb5SApple OSS Distributions 	return KERN_SUCCESS;
282*1b191cb5SApple OSS Distributions }
283*1b191cb5SApple OSS Distributions 
284*1b191cb5SApple OSS Distributions boolean_t
voucher_mach_msg_set(mach_msg_header_t * msg)285*1b191cb5SApple OSS Distributions voucher_mach_msg_set(mach_msg_header_t *msg)
286*1b191cb5SApple OSS Distributions {
287*1b191cb5SApple OSS Distributions 	if (_libkernel_voucher_functions->voucher_mach_msg_set) {
288*1b191cb5SApple OSS Distributions 		return _libkernel_voucher_functions->voucher_mach_msg_set(msg);
289*1b191cb5SApple OSS Distributions 	}
290*1b191cb5SApple OSS Distributions 	return FALSE;
291*1b191cb5SApple OSS Distributions }
292*1b191cb5SApple OSS Distributions 
293*1b191cb5SApple OSS Distributions void
voucher_mach_msg_clear(mach_msg_header_t * msg)294*1b191cb5SApple OSS Distributions voucher_mach_msg_clear(mach_msg_header_t *msg)
295*1b191cb5SApple OSS Distributions {
296*1b191cb5SApple OSS Distributions 	if (_libkernel_voucher_functions->voucher_mach_msg_clear) {
297*1b191cb5SApple OSS Distributions 		_libkernel_voucher_functions->voucher_mach_msg_clear(msg);
298*1b191cb5SApple OSS Distributions 	}
299*1b191cb5SApple OSS Distributions }
300*1b191cb5SApple OSS Distributions 
301*1b191cb5SApple OSS Distributions voucher_mach_msg_state_t
voucher_mach_msg_adopt(mach_msg_header_t * msg)302*1b191cb5SApple OSS Distributions voucher_mach_msg_adopt(mach_msg_header_t *msg)
303*1b191cb5SApple OSS Distributions {
304*1b191cb5SApple OSS Distributions 	if (_libkernel_voucher_functions->voucher_mach_msg_adopt) {
305*1b191cb5SApple OSS Distributions 		return _libkernel_voucher_functions->voucher_mach_msg_adopt(msg);
306*1b191cb5SApple OSS Distributions 	}
307*1b191cb5SApple OSS Distributions 	return VOUCHER_MACH_MSG_STATE_UNCHANGED;
308*1b191cb5SApple OSS Distributions }
309*1b191cb5SApple OSS Distributions 
310*1b191cb5SApple OSS Distributions void
voucher_mach_msg_revert(voucher_mach_msg_state_t state)311*1b191cb5SApple OSS Distributions voucher_mach_msg_revert(voucher_mach_msg_state_t state)
312*1b191cb5SApple OSS Distributions {
313*1b191cb5SApple OSS Distributions 	if (_libkernel_voucher_functions->voucher_mach_msg_revert) {
314*1b191cb5SApple OSS Distributions 		_libkernel_voucher_functions->voucher_mach_msg_revert(state);
315*1b191cb5SApple OSS Distributions 	}
316*1b191cb5SApple OSS Distributions }
317*1b191cb5SApple OSS Distributions 
318*1b191cb5SApple OSS Distributions mach_msg_size_t
voucher_mach_msg_fill_aux(mach_msg_aux_header_t * aux_hdr,mach_msg_size_t sz)319*1b191cb5SApple OSS Distributions voucher_mach_msg_fill_aux(mach_msg_aux_header_t *aux_hdr, mach_msg_size_t sz)
320*1b191cb5SApple OSS Distributions {
321*1b191cb5SApple OSS Distributions 	if (_libkernel_voucher_functions->version < 3) {
322*1b191cb5SApple OSS Distributions 		return 0;
323*1b191cb5SApple OSS Distributions 	}
324*1b191cb5SApple OSS Distributions 	if (_libkernel_voucher_functions->voucher_mach_msg_fill_aux) {
325*1b191cb5SApple OSS Distributions 		return _libkernel_voucher_functions->voucher_mach_msg_fill_aux(aux_hdr, sz);
326*1b191cb5SApple OSS Distributions 	}
327*1b191cb5SApple OSS Distributions 	return 0;
328*1b191cb5SApple OSS Distributions }
329*1b191cb5SApple OSS Distributions 
330*1b191cb5SApple OSS Distributions boolean_t
voucher_mach_msg_fill_aux_supported(void)331*1b191cb5SApple OSS Distributions voucher_mach_msg_fill_aux_supported(void)
332*1b191cb5SApple OSS Distributions {
333*1b191cb5SApple OSS Distributions 	if (_libkernel_voucher_functions->version < 3) {
334*1b191cb5SApple OSS Distributions 		return FALSE;
335*1b191cb5SApple OSS Distributions 	}
336*1b191cb5SApple OSS Distributions 	return NULL != _libkernel_voucher_functions->voucher_mach_msg_fill_aux;
337*1b191cb5SApple OSS Distributions }
338