authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-11-09 18:44:34+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-11-09 18:47:09+01:00
log09cc61bfe4bac8d3e8e7178a95f4378a39cd0b1c
tree47da7e4c3152dfd7c0e5907ee15acbb98d760222
parent267116d62609613d00f6a280829262fe8a1e09e5

Add more missing libc headers used by frameworks

See https://github.com/ziglang/fetch-them-macos-headers/commit/76f22c39052034a19d8c0f41bd4010872fd032cd.

168 files changed, 50776 insertions(+), 613 deletions(-)

lib/libc/include/x86_64-macos-gnu/AssertMacros.h created+1441
......@@ -0,0 +1,1441 @@
1/*
2 * Copyright (c) 2002-2017 by Apple Inc.. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25/*
26 File: AssertMacros.h
27
28 Contains: This file defines structured error handling and assertion macros for
29 programming in C. Originally used in QuickDraw GX and later enhanced.
30 These macros are used throughout Apple's software.
31
32 New code may not want to begin adopting these macros and instead use
33 existing language functionality.
34
35 See "Living In an Exceptional World" by Sean Parent
36 (develop, The Apple Technical Journal, Issue 11, August/September 1992)
37 <http://developer.apple.com/dev/techsupport/develop/issue11toc.shtml> or
38 <http://www.mactech.com/articles/develop/issue_11/Parent_final.html>
39 for the methodology behind these error handling and assertion macros.
40
41 Bugs?: For bug reports, consult the following page on
42 the World Wide Web:
43
44 http://developer.apple.com/bugreporter/
45*/
46#ifndef __ASSERTMACROS__
47#define __ASSERTMACROS__
48
49#ifdef DEBUG_ASSERT_CONFIG_INCLUDE
50 #include DEBUG_ASSERT_CONFIG_INCLUDE
51#endif
52
53/*
54 * Macro overview:
55 *
56 * check(assertion)
57 * In production builds, pre-processed away
58 * In debug builds, if assertion evaluates to false, calls DEBUG_ASSERT_MESSAGE
59 *
60 * verify(assertion)
61 * In production builds, evaluates assertion and does nothing
62 * In debug builds, if assertion evaluates to false, calls DEBUG_ASSERT_MESSAGE
63 *
64 * require(assertion, exceptionLabel)
65 * In production builds, if the assertion expression evaluates to false, goto exceptionLabel
66 * In debug builds, if the assertion expression evaluates to false, calls DEBUG_ASSERT_MESSAGE
67 * and jumps to exceptionLabel
68 *
69 * In addition the following suffixes are available:
70 *
71 * _noerr Adds "!= 0" to assertion. Useful for asserting and OSStatus or OSErr is noErr (zero)
72 * _action Adds statement to be executued if assertion fails
73 * _quiet Suppress call to DEBUG_ASSERT_MESSAGE
74 * _string Allows you to add explanitory message to DEBUG_ASSERT_MESSAGE
75 *
76 * For instance, require_noerr_string(resultCode, label, msg) will do nothing if
77 * resultCode is zero, otherwise it will call DEBUG_ASSERT_MESSAGE with msg
78 * and jump to label.
79 *
80 * Configuration:
81 *
82 * By default all macros generate "production code" (i.e non-debug). If
83 * DEBUG_ASSERT_PRODUCTION_CODE is defined to zero or DEBUG is defined to non-zero
84 * while this header is included, the macros will generated debug code.
85 *
86 * If DEBUG_ASSERT_COMPONENT_NAME_STRING is defined, all debug messages will
87 * be prefixed with it.
88 *
89 * By default, all messages write to stderr. If you would like to write a custom
90 * error message formater, defined DEBUG_ASSERT_MESSAGE to your function name.
91 *
92 * Each individual macro will only be defined if it is not already defined, so
93 * you can redefine their behavior singly by providing your own definition before
94 * this file is included.
95 *
96 * If you define __ASSERTMACROS__ before this file is included, then nothing in
97 * this file will take effect.
98 *
99 * Prior to Mac OS X 10.6 the macro names used in this file conflicted with some
100 * user code, including libraries in boost and the proposed C++ standards efforts,
101 * and there was no way for a client of this header to resolve this conflict. Because
102 * of this, most of the macros have been changed so that they are prefixed with
103 * __ and contain at least one capital letter, which should alleviate the current
104 * and future conflicts. However, to allow current sources to continue to compile,
105 * compatibility macros are defined at the end with the old names. A tops script
106 * at the end of this file will convert all of the old macro names used in a directory
107 * to the new names. Clients are recommended to migrate over to these new macros as
108 * they update their sources because a future release of Mac OS X will remove the
109 * old macro definitions ( without the double-underscore prefix ). Clients who
110 * want to compile without the old macro definitions can define the macro
111 * __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES to 0 before this file is
112 * included.
113 */
114
115
116/*
117 * Before including this file, #define DEBUG_ASSERT_COMPONENT_NAME_STRING to
118 * a C-string containing the name of your client. This string will be passed to
119 * the DEBUG_ASSERT_MESSAGE macro for inclusion in any assertion messages.
120 *
121 * If you do not define DEBUG_ASSERT_COMPONENT_NAME_STRING, the default
122 * DEBUG_ASSERT_COMPONENT_NAME_STRING value, an empty string, will be used by
123 * the assertion macros.
124 */
125#ifndef DEBUG_ASSERT_COMPONENT_NAME_STRING
126 #define DEBUG_ASSERT_COMPONENT_NAME_STRING ""
127#endif
128
129
130/*
131 * To activate the additional assertion code and messages for non-production builds,
132 * #define DEBUG_ASSERT_PRODUCTION_CODE to zero before including this file.
133 *
134 * If you do not define DEBUG_ASSERT_PRODUCTION_CODE, the default value 1 will be used
135 * (production code = no assertion code and no messages).
136 */
137#ifndef DEBUG_ASSERT_PRODUCTION_CODE
138 #define DEBUG_ASSERT_PRODUCTION_CODE !DEBUG
139#endif
140
141
142/*
143 * DEBUG_ASSERT_MESSAGE(component, assertion, label, error, file, line, errorCode)
144 *
145 * Summary:
146 * All assertion messages are routed through this macro. If you wish to use your
147 * own routine to display assertion messages, you can override DEBUG_ASSERT_MESSAGE
148 * by #defining DEBUG_ASSERT_MESSAGE before including this file.
149 *
150 * Parameters:
151 *
152 * componentNameString:
153 * A pointer to a string constant containing the name of the
154 * component this code is part of. This must be a string constant
155 * (and not a string variable or NULL) because the preprocessor
156 * concatenates it with other string constants.
157 *
158 * assertionString:
159 * A pointer to a string constant containing the assertion.
160 * This must be a string constant (and not a string variable or
161 * NULL) because the Preprocessor concatenates it with other
162 * string constants.
163 *
164 * exceptionLabelString:
165 * A pointer to a string containing the exceptionLabel, or NULL.
166 *
167 * errorString:
168 * A pointer to the error string, or NULL. DEBUG_ASSERT_MESSAGE macros
169 * must not attempt to concatenate this string with constant
170 * character strings.
171 *
172 * fileName:
173 * A pointer to the fileName or pathname (generated by the
174 * preprocessor __FILE__ identifier), or NULL.
175 *
176 * lineNumber:
177 * The line number in the file (generated by the preprocessor
178 * __LINE__ identifier), or 0 (zero).
179 *
180 * errorCode:
181 * A value associated with the assertion, or 0.
182 *
183 * Here is an example of a DEBUG_ASSERT_MESSAGE macro and a routine which displays
184 * assertion messsages:
185 *
186 * #define DEBUG_ASSERT_COMPONENT_NAME_STRING "MyCoolProgram"
187 *
188 * #define DEBUG_ASSERT_MESSAGE(componentNameString, assertionString, \
189 * exceptionLabelString, errorString, fileName, lineNumber, errorCode) \
190 * MyProgramDebugAssert(componentNameString, assertionString, \
191 * exceptionLabelString, errorString, fileName, lineNumber, errorCode)
192 *
193 * static void
194 * MyProgramDebugAssert(const char *componentNameString, const char *assertionString,
195 * const char *exceptionLabelString, const char *errorString,
196 * const char *fileName, long lineNumber, int errorCode)
197 * {
198 * if ( (assertionString != NULL) && (*assertionString != '\0') )
199 * fprintf(stderr, "Assertion failed: %s: %s\n", componentNameString, assertionString);
200 * else
201 * fprintf(stderr, "Check failed: %s:\n", componentNameString);
202 * if ( exceptionLabelString != NULL )
203 * fprintf(stderr, " %s\n", exceptionLabelString);
204 * if ( errorString != NULL )
205 * fprintf(stderr, " %s\n", errorString);
206 * if ( fileName != NULL )
207 * fprintf(stderr, " file: %s\n", fileName);
208 * if ( lineNumber != 0 )
209 * fprintf(stderr, " line: %ld\n", lineNumber);
210 * if ( errorCode != 0 )
211 * fprintf(stderr, " error: %d\n", errorCode);
212 * }
213 *
214 * If you do not define DEBUG_ASSERT_MESSAGE, a simple printf to stderr will be used.
215 */
216#ifndef DEBUG_ASSERT_MESSAGE
217 #ifdef KERNEL
218 #include <libkern/libkern.h>
219 #define DEBUG_ASSERT_MESSAGE(name, assertion, label, message, file, line, value) \
220 printf( "AssertMacros: %s, %s file: %s, line: %d, value: %ld\n", assertion, (message!=0) ? message : "", file, line, (long) (value));
221 #else
222 #include <stdio.h>
223 #define DEBUG_ASSERT_MESSAGE(name, assertion, label, message, file, line, value) \
224 fprintf(stderr, "AssertMacros: %s, %s file: %s, line: %d, value: %ld\n", assertion, (message!=0) ? message : "", file, line, (long) (value));
225 #endif
226#endif
227
228
229
230
231
232/*
233 * __Debug_String(message)
234 *
235 * Summary:
236 * Production builds: does nothing and produces no code.
237 *
238 * Non-production builds: call DEBUG_ASSERT_MESSAGE.
239 *
240 * Parameters:
241 *
242 * message:
243 * The C string to display.
244 *
245 */
246#ifndef __Debug_String
247 #if DEBUG_ASSERT_PRODUCTION_CODE
248 #define __Debug_String(message)
249 #else
250 #define __Debug_String(message) \
251 do \
252 { \
253 DEBUG_ASSERT_MESSAGE( \
254 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
255 "", \
256 0, \
257 message, \
258 __FILE__, \
259 __LINE__, \
260 0); \
261 } while ( 0 )
262 #endif
263#endif
264
265/*
266 * __Check(assertion)
267 *
268 * Summary:
269 * Production builds: does nothing and produces no code.
270 *
271 * Non-production builds: if the assertion expression evaluates to false,
272 * call DEBUG_ASSERT_MESSAGE.
273 *
274 * Parameters:
275 *
276 * assertion:
277 * The assertion expression.
278 */
279#ifndef __Check
280 #if DEBUG_ASSERT_PRODUCTION_CODE
281 #define __Check(assertion)
282 #else
283 #define __Check(assertion) \
284 do \
285 { \
286 if ( __builtin_expect(!(assertion), 0) ) \
287 { \
288 DEBUG_ASSERT_MESSAGE( \
289 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
290 #assertion, 0, 0, __FILE__, __LINE__, 0 ); \
291 } \
292 } while ( 0 )
293 #endif
294#endif
295
296#ifndef __nCheck
297 #define __nCheck(assertion) __Check(!(assertion))
298#endif
299
300/*
301 * __Check_String(assertion, message)
302 *
303 * Summary:
304 * Production builds: does nothing and produces no code.
305 *
306 * Non-production builds: if the assertion expression evaluates to false,
307 * call DEBUG_ASSERT_MESSAGE.
308 *
309 * Parameters:
310 *
311 * assertion:
312 * The assertion expression.
313 *
314 * message:
315 * The C string to display.
316 */
317#ifndef __Check_String
318 #if DEBUG_ASSERT_PRODUCTION_CODE
319 #define __Check_String(assertion, message)
320 #else
321 #define __Check_String(assertion, message) \
322 do \
323 { \
324 if ( __builtin_expect(!(assertion), 0) ) \
325 { \
326 DEBUG_ASSERT_MESSAGE( \
327 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
328 #assertion, 0, message, __FILE__, __LINE__, 0 ); \
329 } \
330 } while ( 0 )
331 #endif
332#endif
333
334#ifndef __nCheck_String
335 #define __nCheck_String(assertion, message) __Check_String(!(assertion), message)
336#endif
337
338/*
339 * __Check_noErr(errorCode)
340 *
341 * Summary:
342 * Production builds: does nothing and produces no code.
343 *
344 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
345 * call DEBUG_ASSERT_MESSAGE.
346 *
347 * Parameters:
348 *
349 * errorCode:
350 * The errorCode expression to compare with 0.
351 */
352#ifndef __Check_noErr
353 #if DEBUG_ASSERT_PRODUCTION_CODE
354 #define __Check_noErr(errorCode)
355 #else
356 #define __Check_noErr(errorCode) \
357 do \
358 { \
359 long evalOnceErrorCode = (errorCode); \
360 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \
361 { \
362 DEBUG_ASSERT_MESSAGE( \
363 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
364 #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \
365 } \
366 } while ( 0 )
367 #endif
368#endif
369
370/*
371 * __Check_noErr_String(errorCode, message)
372 *
373 * Summary:
374 * Production builds: check_noerr_string() does nothing and produces
375 * no code.
376 *
377 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
378 * call DEBUG_ASSERT_MESSAGE.
379 *
380 * Parameters:
381 *
382 * errorCode:
383 * The errorCode expression to compare to 0.
384 *
385 * message:
386 * The C string to display.
387 */
388#ifndef __Check_noErr_String
389 #if DEBUG_ASSERT_PRODUCTION_CODE
390 #define __Check_noErr_String(errorCode, message)
391 #else
392 #define __Check_noErr_String(errorCode, message) \
393 do \
394 { \
395 long evalOnceErrorCode = (errorCode); \
396 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \
397 { \
398 DEBUG_ASSERT_MESSAGE( \
399 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
400 #errorCode " == 0 ", 0, message, __FILE__, __LINE__, evalOnceErrorCode ); \
401 } \
402 } while ( 0 )
403 #endif
404#endif
405
406/*
407 * __Verify(assertion)
408 *
409 * Summary:
410 * Production builds: evaluate the assertion expression, but ignore
411 * the result.
412 *
413 * Non-production builds: if the assertion expression evaluates to false,
414 * call DEBUG_ASSERT_MESSAGE.
415 *
416 * Parameters:
417 *
418 * assertion:
419 * The assertion expression.
420 */
421#ifndef __Verify
422 #if DEBUG_ASSERT_PRODUCTION_CODE
423 #define __Verify(assertion) \
424 do \
425 { \
426 if ( !(assertion) ) \
427 { \
428 } \
429 } while ( 0 )
430 #else
431 #define __Verify(assertion) \
432 do \
433 { \
434 if ( __builtin_expect(!(assertion), 0) ) \
435 { \
436 DEBUG_ASSERT_MESSAGE( \
437 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
438 #assertion, 0, 0, __FILE__, __LINE__, 0 ); \
439 } \
440 } while ( 0 )
441 #endif
442#endif
443
444#ifndef __nVerify
445 #define __nVerify(assertion) __Verify(!(assertion))
446#endif
447
448/*
449 * __Verify_String(assertion, message)
450 *
451 * Summary:
452 * Production builds: evaluate the assertion expression, but ignore
453 * the result.
454 *
455 * Non-production builds: if the assertion expression evaluates to false,
456 * call DEBUG_ASSERT_MESSAGE.
457 *
458 * Parameters:
459 *
460 * assertion:
461 * The assertion expression.
462 *
463 * message:
464 * The C string to display.
465 */
466#ifndef __Verify_String
467 #if DEBUG_ASSERT_PRODUCTION_CODE
468 #define __Verify_String(assertion, message) \
469 do \
470 { \
471 if ( !(assertion) ) \
472 { \
473 } \
474 } while ( 0 )
475 #else
476 #define __Verify_String(assertion, message) \
477 do \
478 { \
479 if ( __builtin_expect(!(assertion), 0) ) \
480 { \
481 DEBUG_ASSERT_MESSAGE( \
482 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
483 #assertion, 0, message, __FILE__, __LINE__, 0 ); \
484 } \
485 } while ( 0 )
486 #endif
487#endif
488
489#ifndef __nVerify_String
490 #define __nVerify_String(assertion, message) __Verify_String(!(assertion), message)
491#endif
492
493/*
494 * __Verify_noErr(errorCode)
495 *
496 * Summary:
497 * Production builds: evaluate the errorCode expression, but ignore
498 * the result.
499 *
500 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
501 * call DEBUG_ASSERT_MESSAGE.
502 *
503 * Parameters:
504 *
505 * errorCode:
506 * The expression to compare to 0.
507 */
508#ifndef __Verify_noErr
509 #if DEBUG_ASSERT_PRODUCTION_CODE
510 #define __Verify_noErr(errorCode) \
511 do \
512 { \
513 if ( 0 != (errorCode) ) \
514 { \
515 } \
516 } while ( 0 )
517 #else
518 #define __Verify_noErr(errorCode) \
519 do \
520 { \
521 long evalOnceErrorCode = (errorCode); \
522 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \
523 { \
524 DEBUG_ASSERT_MESSAGE( \
525 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
526 #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \
527 } \
528 } while ( 0 )
529 #endif
530#endif
531
532/*
533 * __Verify_noErr_String(errorCode, message)
534 *
535 * Summary:
536 * Production builds: evaluate the errorCode expression, but ignore
537 * the result.
538 *
539 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
540 * call DEBUG_ASSERT_MESSAGE.
541 *
542 * Parameters:
543 *
544 * errorCode:
545 * The expression to compare to 0.
546 *
547 * message:
548 * The C string to display.
549 */
550#ifndef __Verify_noErr_String
551 #if DEBUG_ASSERT_PRODUCTION_CODE
552 #define __Verify_noErr_String(errorCode, message) \
553 do \
554 { \
555 if ( 0 != (errorCode) ) \
556 { \
557 } \
558 } while ( 0 )
559 #else
560 #define __Verify_noErr_String(errorCode, message) \
561 do \
562 { \
563 long evalOnceErrorCode = (errorCode); \
564 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \
565 { \
566 DEBUG_ASSERT_MESSAGE( \
567 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
568 #errorCode " == 0 ", 0, message, __FILE__, __LINE__, evalOnceErrorCode ); \
569 } \
570 } while ( 0 )
571 #endif
572#endif
573
574/*
575 * __Verify_noErr_Action(errorCode, action)
576 *
577 * Summary:
578 * Production builds: if the errorCode expression does not equal 0 (noErr),
579 * execute the action statement or compound statement (block).
580 *
581 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
582 * call DEBUG_ASSERT_MESSAGE and then execute the action statement or compound
583 * statement (block).
584 *
585 * Parameters:
586 *
587 * errorCode:
588 * The expression to compare to 0.
589 *
590 * action:
591 * The statement or compound statement (block).
592 */
593#ifndef __Verify_noErr_Action
594 #if DEBUG_ASSERT_PRODUCTION_CODE
595 #define __Verify_noErr_Action(errorCode, action) \
596 if ( 0 != (errorCode) ) { \
597 action; \
598 } \
599 else do {} while (0)
600 #else
601 #define __Verify_noErr_Action(errorCode, action) \
602 do { \
603 long evalOnceErrorCode = (errorCode); \
604 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) { \
605 DEBUG_ASSERT_MESSAGE( \
606 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
607 #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \
608 action; \
609 } \
610 } while (0)
611 #endif
612#endif
613
614/*
615 * __Verify_Action(assertion, action)
616 *
617 * Summary:
618 * Production builds: if the assertion expression evaluates to false,
619 * then execute the action statement or compound statement (block).
620 *
621 * Non-production builds: if the assertion expression evaluates to false,
622 * call DEBUG_ASSERT_MESSAGE and then execute the action statement or compound
623 * statement (block).
624 *
625 * Parameters:
626 *
627 * assertion:
628 * The assertion expression.
629 *
630 * action:
631 * The statement or compound statement (block).
632 */
633#ifndef __Verify_Action
634 #if DEBUG_ASSERT_PRODUCTION_CODE
635 #define __Verify_Action(assertion, action) \
636 if ( __builtin_expect(!(assertion), 0) ) { \
637 action; \
638 } \
639 else do {} while (0)
640 #else
641 #define __Verify_Action(assertion, action) \
642 if ( __builtin_expect(!(assertion), 0) ) { \
643 DEBUG_ASSERT_MESSAGE( \
644 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
645 #assertion, 0, 0, __FILE__, __LINE__, 0 ); \
646 action; \
647 } \
648 else do {} while (0)
649 #endif
650#endif
651
652/*
653 * __Require(assertion, exceptionLabel)
654 *
655 * Summary:
656 * Production builds: if the assertion expression evaluates to false,
657 * goto exceptionLabel.
658 *
659 * Non-production builds: if the assertion expression evaluates to false,
660 * call DEBUG_ASSERT_MESSAGE and then goto exceptionLabel.
661 *
662 * Parameters:
663 *
664 * assertion:
665 * The assertion expression.
666 *
667 * exceptionLabel:
668 * The label.
669 */
670#ifndef __Require
671 #if DEBUG_ASSERT_PRODUCTION_CODE
672 #define __Require(assertion, exceptionLabel) \
673 do \
674 { \
675 if ( __builtin_expect(!(assertion), 0) ) \
676 { \
677 goto exceptionLabel; \
678 } \
679 } while ( 0 )
680 #else
681 #define __Require(assertion, exceptionLabel) \
682 do \
683 { \
684 if ( __builtin_expect(!(assertion), 0) ) { \
685 DEBUG_ASSERT_MESSAGE( \
686 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
687 #assertion, #exceptionLabel, 0, __FILE__, __LINE__, 0); \
688 goto exceptionLabel; \
689 } \
690 } while ( 0 )
691 #endif
692#endif
693
694#ifndef __nRequire
695 #define __nRequire(assertion, exceptionLabel) __Require(!(assertion), exceptionLabel)
696#endif
697
698/*
699 * __Require_Action(assertion, exceptionLabel, action)
700 *
701 * Summary:
702 * Production builds: if the assertion expression evaluates to false,
703 * execute the action statement or compound statement (block) and then
704 * goto exceptionLabel.
705 *
706 * Non-production builds: if the assertion expression evaluates to false,
707 * call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
708 * statement (block), and then goto exceptionLabel.
709 *
710 * Parameters:
711 *
712 * assertion:
713 * The assertion expression.
714 *
715 * exceptionLabel:
716 * The label.
717 *
718 * action:
719 * The statement or compound statement (block).
720 */
721#ifndef __Require_Action
722 #if DEBUG_ASSERT_PRODUCTION_CODE
723 #define __Require_Action(assertion, exceptionLabel, action) \
724 do \
725 { \
726 if ( __builtin_expect(!(assertion), 0) ) \
727 { \
728 { \
729 action; \
730 } \
731 goto exceptionLabel; \
732 } \
733 } while ( 0 )
734 #else
735 #define __Require_Action(assertion, exceptionLabel, action) \
736 do \
737 { \
738 if ( __builtin_expect(!(assertion), 0) ) \
739 { \
740 DEBUG_ASSERT_MESSAGE( \
741 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
742 #assertion, #exceptionLabel, 0, __FILE__, __LINE__, 0); \
743 { \
744 action; \
745 } \
746 goto exceptionLabel; \
747 } \
748 } while ( 0 )
749 #endif
750#endif
751
752#ifndef __nRequire_Action
753 #define __nRequire_Action(assertion, exceptionLabel, action) \
754 __Require_Action(!(assertion), exceptionLabel, action)
755#endif
756
757/*
758 * __Require_Quiet(assertion, exceptionLabel)
759 *
760 * Summary:
761 * If the assertion expression evaluates to false, goto exceptionLabel.
762 *
763 * Parameters:
764 *
765 * assertion:
766 * The assertion expression.
767 *
768 * exceptionLabel:
769 * The label.
770 */
771#ifndef __Require_Quiet
772 #define __Require_Quiet(assertion, exceptionLabel) \
773 do \
774 { \
775 if ( __builtin_expect(!(assertion), 0) ) \
776 { \
777 goto exceptionLabel; \
778 } \
779 } while ( 0 )
780#endif
781
782#ifndef __nRequire_Quiet
783 #define __nRequire_Quiet(assertion, exceptionLabel) __Require_Quiet(!(assertion), exceptionLabel)
784#endif
785
786/*
787 * __Require_Action_Quiet(assertion, exceptionLabel, action)
788 *
789 * Summary:
790 * If the assertion expression evaluates to false, execute the action
791 * statement or compound statement (block), and goto exceptionLabel.
792 *
793 * Parameters:
794 *
795 * assertion:
796 * The assertion expression.
797 *
798 * exceptionLabel:
799 * The label.
800 *
801 * action:
802 * The statement or compound statement (block).
803 */
804#ifndef __Require_Action_Quiet
805 #define __Require_Action_Quiet(assertion, exceptionLabel, action) \
806 do \
807 { \
808 if ( __builtin_expect(!(assertion), 0) ) \
809 { \
810 { \
811 action; \
812 } \
813 goto exceptionLabel; \
814 } \
815 } while ( 0 )
816#endif
817
818#ifndef __nRequire_Action_Quiet
819 #define __nRequire_Action_Quiet(assertion, exceptionLabel, action) \
820 __Require_Action_Quiet(!(assertion), exceptionLabel, action)
821#endif
822
823/*
824 * __Require_String(assertion, exceptionLabel, message)
825 *
826 * Summary:
827 * Production builds: if the assertion expression evaluates to false,
828 * goto exceptionLabel.
829 *
830 * Non-production builds: if the assertion expression evaluates to false,
831 * call DEBUG_ASSERT_MESSAGE, and then goto exceptionLabel.
832 *
833 * Parameters:
834 *
835 * assertion:
836 * The assertion expression.
837 *
838 * exceptionLabel:
839 * The label.
840 *
841 * message:
842 * The C string to display.
843 */
844#ifndef __Require_String
845 #if DEBUG_ASSERT_PRODUCTION_CODE
846 #define __Require_String(assertion, exceptionLabel, message) \
847 do \
848 { \
849 if ( __builtin_expect(!(assertion), 0) ) \
850 { \
851 goto exceptionLabel; \
852 } \
853 } while ( 0 )
854 #else
855 #define __Require_String(assertion, exceptionLabel, message) \
856 do \
857 { \
858 if ( __builtin_expect(!(assertion), 0) ) \
859 { \
860 DEBUG_ASSERT_MESSAGE( \
861 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
862 #assertion, #exceptionLabel, message, __FILE__, __LINE__, 0); \
863 goto exceptionLabel; \
864 } \
865 } while ( 0 )
866 #endif
867#endif
868
869#ifndef __nRequire_String
870 #define __nRequire_String(assertion, exceptionLabel, string) \
871 __Require_String(!(assertion), exceptionLabel, string)
872#endif
873
874/*
875 * __Require_Action_String(assertion, exceptionLabel, action, message)
876 *
877 * Summary:
878 * Production builds: if the assertion expression evaluates to false,
879 * execute the action statement or compound statement (block), and then
880 * goto exceptionLabel.
881 *
882 * Non-production builds: if the assertion expression evaluates to false,
883 * call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
884 * statement (block), and then goto exceptionLabel.
885 *
886 * Parameters:
887 *
888 * assertion:
889 * The assertion expression.
890 *
891 * exceptionLabel:
892 * The label.
893 *
894 * action:
895 * The statement or compound statement (block).
896 *
897 * message:
898 * The C string to display.
899 */
900#ifndef __Require_Action_String
901 #if DEBUG_ASSERT_PRODUCTION_CODE
902 #define __Require_Action_String(assertion, exceptionLabel, action, message) \
903 do \
904 { \
905 if ( __builtin_expect(!(assertion), 0) ) \
906 { \
907 { \
908 action; \
909 } \
910 goto exceptionLabel; \
911 } \
912 } while ( 0 )
913 #else
914 #define __Require_Action_String(assertion, exceptionLabel, action, message) \
915 do \
916 { \
917 if ( __builtin_expect(!(assertion), 0) ) \
918 { \
919 DEBUG_ASSERT_MESSAGE( \
920 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
921 #assertion, #exceptionLabel, message, __FILE__, __LINE__, 0); \
922 { \
923 action; \
924 } \
925 goto exceptionLabel; \
926 } \
927 } while ( 0 )
928 #endif
929#endif
930
931#ifndef __nRequire_Action_String
932 #define __nRequire_Action_String(assertion, exceptionLabel, action, message) \
933 __Require_Action_String(!(assertion), exceptionLabel, action, message)
934#endif
935
936/*
937 * __Require_noErr(errorCode, exceptionLabel)
938 *
939 * Summary:
940 * Production builds: if the errorCode expression does not equal 0 (noErr),
941 * goto exceptionLabel.
942 *
943 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
944 * call DEBUG_ASSERT_MESSAGE and then goto exceptionLabel.
945 *
946 * Parameters:
947 *
948 * errorCode:
949 * The expression to compare to 0.
950 *
951 * exceptionLabel:
952 * The label.
953 */
954#ifndef __Require_noErr
955 #if DEBUG_ASSERT_PRODUCTION_CODE
956 #define __Require_noErr(errorCode, exceptionLabel) \
957 do \
958 { \
959 if ( __builtin_expect(0 != (errorCode), 0) ) \
960 { \
961 goto exceptionLabel; \
962 } \
963 } while ( 0 )
964 #else
965 #define __Require_noErr(errorCode, exceptionLabel) \
966 do \
967 { \
968 long evalOnceErrorCode = (errorCode); \
969 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \
970 { \
971 DEBUG_ASSERT_MESSAGE( \
972 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
973 #errorCode " == 0 ", #exceptionLabel, 0, __FILE__, __LINE__, evalOnceErrorCode); \
974 goto exceptionLabel; \
975 } \
976 } while ( 0 )
977 #endif
978#endif
979
980/*
981 * __Require_noErr_Action(errorCode, exceptionLabel, action)
982 *
983 * Summary:
984 * Production builds: if the errorCode expression does not equal 0 (noErr),
985 * execute the action statement or compound statement (block) and
986 * goto exceptionLabel.
987 *
988 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
989 * call DEBUG_ASSERT_MESSAGE, execute the action statement or
990 * compound statement (block), and then goto exceptionLabel.
991 *
992 * Parameters:
993 *
994 * errorCode:
995 * The expression to compare to 0.
996 *
997 * exceptionLabel:
998 * The label.
999 *
1000 * action:
1001 * The statement or compound statement (block).
1002 */
1003#ifndef __Require_noErr_Action
1004 #if DEBUG_ASSERT_PRODUCTION_CODE
1005 #define __Require_noErr_Action(errorCode, exceptionLabel, action) \
1006 do \
1007 { \
1008 if ( __builtin_expect(0 != (errorCode), 0) ) \
1009 { \
1010 { \
1011 action; \
1012 } \
1013 goto exceptionLabel; \
1014 } \
1015 } while ( 0 )
1016 #else
1017 #define __Require_noErr_Action(errorCode, exceptionLabel, action) \
1018 do \
1019 { \
1020 long evalOnceErrorCode = (errorCode); \
1021 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \
1022 { \
1023 DEBUG_ASSERT_MESSAGE( \
1024 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
1025 #errorCode " == 0 ", #exceptionLabel, 0, __FILE__, __LINE__, evalOnceErrorCode); \
1026 { \
1027 action; \
1028 } \
1029 goto exceptionLabel; \
1030 } \
1031 } while ( 0 )
1032 #endif
1033#endif
1034
1035/*
1036 * __Require_noErr_Quiet(errorCode, exceptionLabel)
1037 *
1038 * Summary:
1039 * If the errorCode expression does not equal 0 (noErr),
1040 * goto exceptionLabel.
1041 *
1042 * Parameters:
1043 *
1044 * errorCode:
1045 * The expression to compare to 0.
1046 *
1047 * exceptionLabel:
1048 * The label.
1049 */
1050#ifndef __Require_noErr_Quiet
1051 #define __Require_noErr_Quiet(errorCode, exceptionLabel) \
1052 do \
1053 { \
1054 if ( __builtin_expect(0 != (errorCode), 0) ) \
1055 { \
1056 goto exceptionLabel; \
1057 } \
1058 } while ( 0 )
1059#endif
1060
1061/*
1062 * __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action)
1063 *
1064 * Summary:
1065 * If the errorCode expression does not equal 0 (noErr),
1066 * execute the action statement or compound statement (block) and
1067 * goto exceptionLabel.
1068 *
1069 * Parameters:
1070 *
1071 * errorCode:
1072 * The expression to compare to 0.
1073 *
1074 * exceptionLabel:
1075 * The label.
1076 *
1077 * action:
1078 * The statement or compound statement (block).
1079 */
1080#ifndef __Require_noErr_Action_Quiet
1081 #define __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action) \
1082 do \
1083 { \
1084 if ( __builtin_expect(0 != (errorCode), 0) ) \
1085 { \
1086 { \
1087 action; \
1088 } \
1089 goto exceptionLabel; \
1090 } \
1091 } while ( 0 )
1092#endif
1093
1094/*
1095 * __Require_noErr_String(errorCode, exceptionLabel, message)
1096 *
1097 * Summary:
1098 * Production builds: if the errorCode expression does not equal 0 (noErr),
1099 * goto exceptionLabel.
1100 *
1101 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
1102 * call DEBUG_ASSERT_MESSAGE, and then goto exceptionLabel.
1103 *
1104 * Parameters:
1105 *
1106 * errorCode:
1107 * The expression to compare to 0.
1108 *
1109 * exceptionLabel:
1110 * The label.
1111 *
1112 * message:
1113 * The C string to display.
1114 */
1115#ifndef __Require_noErr_String
1116 #if DEBUG_ASSERT_PRODUCTION_CODE
1117 #define __Require_noErr_String(errorCode, exceptionLabel, message) \
1118 do \
1119 { \
1120 if ( __builtin_expect(0 != (errorCode), 0) ) \
1121 { \
1122 goto exceptionLabel; \
1123 } \
1124 } while ( 0 )
1125 #else
1126 #define __Require_noErr_String(errorCode, exceptionLabel, message) \
1127 do \
1128 { \
1129 long evalOnceErrorCode = (errorCode); \
1130 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \
1131 { \
1132 DEBUG_ASSERT_MESSAGE( \
1133 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
1134 #errorCode " == 0 ", #exceptionLabel, message, __FILE__, __LINE__, evalOnceErrorCode); \
1135 goto exceptionLabel; \
1136 } \
1137 } while ( 0 )
1138 #endif
1139#endif
1140
1141/*
1142 * __Require_noErr_Action_String(errorCode, exceptionLabel, action, message)
1143 *
1144 * Summary:
1145 * Production builds: if the errorCode expression does not equal 0 (noErr),
1146 * execute the action statement or compound statement (block) and
1147 * goto exceptionLabel.
1148 *
1149 * Non-production builds: if the errorCode expression does not equal 0 (noErr),
1150 * call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
1151 * statement (block), and then goto exceptionLabel.
1152 *
1153 * Parameters:
1154 *
1155 * errorCode:
1156 * The expression to compare to 0.
1157 *
1158 * exceptionLabel:
1159 * The label.
1160 *
1161 * action:
1162 * The statement or compound statement (block).
1163 *
1164 * message:
1165 * The C string to display.
1166 */
1167#ifndef __Require_noErr_Action_String
1168 #if DEBUG_ASSERT_PRODUCTION_CODE
1169 #define __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) \
1170 do \
1171 { \
1172 if ( __builtin_expect(0 != (errorCode), 0) ) \
1173 { \
1174 { \
1175 action; \
1176 } \
1177 goto exceptionLabel; \
1178 } \
1179 } while ( 0 )
1180 #else
1181 #define __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) \
1182 do \
1183 { \
1184 long evalOnceErrorCode = (errorCode); \
1185 if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \
1186 { \
1187 DEBUG_ASSERT_MESSAGE( \
1188 DEBUG_ASSERT_COMPONENT_NAME_STRING, \
1189 #errorCode " == 0 ", #exceptionLabel, message, __FILE__, __LINE__, evalOnceErrorCode); \
1190 { \
1191 action; \
1192 } \
1193 goto exceptionLabel; \
1194 } \
1195 } while ( 0 )
1196 #endif
1197#endif
1198
1199/*
1200 * __Check_Compile_Time(expr)
1201 *
1202 * Summary:
1203 * any build: if the expression is not true, generated a compile time error.
1204 *
1205 * Parameters:
1206 *
1207 * expr:
1208 * The compile time expression that should evaluate to non-zero.
1209 *
1210 * Discussion:
1211 * This declares an array with a size that is determined by a compile-time expression.
1212 * If false, it declares a negatively sized array, which generates a compile-time error.
1213 *
1214 * Examples:
1215 * __Check_Compile_Time( sizeof( int ) == 4 );
1216 * __Check_Compile_Time( offsetof( MyStruct, myField ) == 4 );
1217 * __Check_Compile_Time( ( kMyBufferSize % 512 ) == 0 );
1218 *
1219 * Note: This only works with compile-time expressions.
1220 * Note: This only works in places where extern declarations are allowed (e.g. global scope).
1221 */
1222#ifndef __Check_Compile_Time
1223 #ifdef __GNUC__
1224 #if (__cplusplus >= 201103L)
1225 #define __Check_Compile_Time( expr ) static_assert( expr , "__Check_Compile_Time")
1226 #elif (__STDC_VERSION__ >= 201112L)
1227 #define __Check_Compile_Time( expr ) _Static_assert( expr , "__Check_Compile_Time")
1228 #else
1229 #define __Check_Compile_Time( expr ) \
1230 extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ] __attribute__( ( unused ) )
1231 #endif
1232 #else
1233 #define __Check_Compile_Time( expr ) \
1234 extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ]
1235 #endif
1236#endif
1237
1238/*
1239 * For time immemorial, Mac OS X has defined version of most of these macros without the __ prefix, which
1240 * could collide with similarly named functions or macros in user code, including new functionality in
1241 * Boost and the C++ standard library.
1242 *
1243 * macOS High Sierra and iOS 11 will now require that clients move to the new macros as defined above.
1244 *
1245 * If you would like to enable the macros for use within your own project, you can define the
1246 * __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES macro via an Xcode Build Configuration.
1247 * See "Add a build configuration (xcconfig) file" in Xcode Help.
1248 *
1249 * To aid users of these macros in converting their sources, the following tops script will convert usages
1250 * of the old macros into the new equivalents. To do so, in Terminal go into the directory containing the
1251 * sources to be converted and run this command.
1252 *
1253 find -E . -regex '.*\.(c|cc|cp|cpp|m|mm|h)' -print0 | xargs -0 tops -verbose \
1254 replace "check(<b args>)" with "__Check(<args>)" \
1255 replace "check_noerr(<b args>)" with "__Check_noErr(<args>)" \
1256 replace "check_noerr_string(<b args>)" with "__Check_noErr_String(<args>)" \
1257 replace "check_string(<b args>)" with "__Check_String(<args>)" \
1258 replace "require(<b args>)" with "__Require(<args>)" \
1259 replace "require_action(<b args>)" with "__Require_Action(<args>)" \
1260 replace "require_action_string(<b args>)" with "__Require_Action_String(<args>)" \
1261 replace "require_noerr(<b args>)" with "__Require_noErr(<args>)" \
1262 replace "require_noerr_action(<b args>)" with "__Require_noErr_Action(<args>)" \
1263 replace "require_noerr_action_string(<b args>)" with "__Require_noErr_Action_String(<args>)" \
1264 replace "require_noerr_string(<b args>)" with "__Require_noErr_String(<args>)" \
1265 replace "require_string(<b args>)" with "__Require_String(<args>)" \
1266 replace "verify(<b args>)" with "__Verify(<args>)" \
1267 replace "verify_action(<b args>)" with "__Verify_Action(<args>)" \
1268 replace "verify_noerr(<b args>)" with "__Verify_noErr(<args>)" \
1269 replace "verify_noerr_action(<b args>)" with "__Verify_noErr_Action(<args>)" \
1270 replace "verify_noerr_string(<b args>)" with "__Verify_noErr_String(<args>)" \
1271 replace "verify_string(<b args>)" with "__Verify_String(<args>)" \
1272 replace "ncheck(<b args>)" with "__nCheck(<args>)" \
1273 replace "ncheck_string(<b args>)" with "__nCheck_String(<args>)" \
1274 replace "nrequire(<b args>)" with "__nRequire(<args>)" \
1275 replace "nrequire_action(<b args>)" with "__nRequire_Action(<args>)" \
1276 replace "nrequire_action_quiet(<b args>)" with "__nRequire_Action_Quiet(<args>)" \
1277 replace "nrequire_action_string(<b args>)" with "__nRequire_Action_String(<args>)" \
1278 replace "nrequire_quiet(<b args>)" with "__nRequire_Quiet(<args>)" \
1279 replace "nrequire_string(<b args>)" with "__nRequire_String(<args>)" \
1280 replace "nverify(<b args>)" with "__nVerify(<args>)" \
1281 replace "nverify_string(<b args>)" with "__nVerify_String(<args>)" \
1282 replace "require_action_quiet(<b args>)" with "__Require_Action_Quiet(<args>)" \
1283 replace "require_noerr_action_quiet(<b args>)" with "__Require_noErr_Action_Quiet(<args>)" \
1284 replace "require_noerr_quiet(<b args>)" with "__Require_noErr_Quiet(<args>)" \
1285 replace "require_quiet(<b args>)" with "__Require_Quiet(<args>)" \
1286 replace "check_compile_time(<b args>)" with "__Check_Compile_Time(<args>)" \
1287 replace "debug_string(<b args>)" with "__Debug_String(<args>)"
1288 *
1289 */
1290
1291#ifndef __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES
1292 #if __has_include(<AssertMacrosInternal.h>)
1293 #include <AssertMacrosInternal.h>
1294 #else
1295 /* In macOS High Sierra and iOS 11, if we haven't set this yet, it now defaults to off. */
1296 #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
1297 #endif
1298#endif
1299
1300#if __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES
1301
1302 #ifndef check
1303 #define check(assertion) __Check(assertion)
1304 #endif
1305
1306 #ifndef check_noerr
1307 #define check_noerr(errorCode) __Check_noErr(errorCode)
1308 #endif
1309
1310 #ifndef check_noerr_string
1311 #define check_noerr_string(errorCode, message) __Check_noErr_String(errorCode, message)
1312 #endif
1313
1314 #ifndef check_string
1315 #define check_string(assertion, message) __Check_String(assertion, message)
1316 #endif
1317
1318 #ifndef require
1319 #define require(assertion, exceptionLabel) __Require(assertion, exceptionLabel)
1320 #endif
1321
1322 #ifndef require_action
1323 #define require_action(assertion, exceptionLabel, action) __Require_Action(assertion, exceptionLabel, action)
1324 #endif
1325
1326 #ifndef require_action_string
1327 #define require_action_string(assertion, exceptionLabel, action, message) __Require_Action_String(assertion, exceptionLabel, action, message)
1328 #endif
1329
1330 #ifndef require_noerr
1331 #define require_noerr(errorCode, exceptionLabel) __Require_noErr(errorCode, exceptionLabel)
1332 #endif
1333
1334 #ifndef require_noerr_action
1335 #define require_noerr_action(errorCode, exceptionLabel, action) __Require_noErr_Action(errorCode, exceptionLabel, action)
1336 #endif
1337
1338 #ifndef require_noerr_action_string
1339 #define require_noerr_action_string(errorCode, exceptionLabel, action, message) __Require_noErr_Action_String(errorCode, exceptionLabel, action, message)
1340 #endif
1341
1342 #ifndef require_noerr_string
1343 #define require_noerr_string(errorCode, exceptionLabel, message) __Require_noErr_String(errorCode, exceptionLabel, message)
1344 #endif
1345
1346 #ifndef require_string
1347 #define require_string(assertion, exceptionLabel, message) __Require_String(assertion, exceptionLabel, message)
1348 #endif
1349
1350 #ifndef verify
1351 #define verify(assertion) __Verify(assertion)
1352 #endif
1353
1354 #ifndef verify_action
1355 #define verify_action(assertion, action) __Verify_Action(assertion, action)
1356 #endif
1357
1358 #ifndef verify_noerr
1359 #define verify_noerr(errorCode) __Verify_noErr(errorCode)
1360 #endif
1361
1362 #ifndef verify_noerr_action
1363 #define verify_noerr_action(errorCode, action) __Verify_noErr_Action(errorCode, action)
1364 #endif
1365
1366 #ifndef verify_noerr_string
1367 #define verify_noerr_string(errorCode, message) __Verify_noErr_String(errorCode, message)
1368 #endif
1369
1370 #ifndef verify_string
1371 #define verify_string(assertion, message) __Verify_String(assertion, message)
1372 #endif
1373
1374 #ifndef ncheck
1375 #define ncheck(assertion) __nCheck(assertion)
1376 #endif
1377
1378 #ifndef ncheck_string
1379 #define ncheck_string(assertion, message) __nCheck_String(assertion, message)
1380 #endif
1381
1382 #ifndef nrequire
1383 #define nrequire(assertion, exceptionLabel) __nRequire(assertion, exceptionLabel)
1384 #endif
1385
1386 #ifndef nrequire_action
1387 #define nrequire_action(assertion, exceptionLabel, action) __nRequire_Action(assertion, exceptionLabel, action)
1388 #endif
1389
1390 #ifndef nrequire_action_quiet
1391 #define nrequire_action_quiet(assertion, exceptionLabel, action) __nRequire_Action_Quiet(assertion, exceptionLabel, action)
1392 #endif
1393
1394 #ifndef nrequire_action_string
1395 #define nrequire_action_string(assertion, exceptionLabel, action, message) __nRequire_Action_String(assertion, exceptionLabel, action, message)
1396 #endif
1397
1398 #ifndef nrequire_quiet
1399 #define nrequire_quiet(assertion, exceptionLabel) __nRequire_Quiet(assertion, exceptionLabel)
1400 #endif
1401
1402 #ifndef nrequire_string
1403 #define nrequire_string(assertion, exceptionLabel, string) __nRequire_String(assertion, exceptionLabel, string)
1404 #endif
1405
1406 #ifndef nverify
1407 #define nverify(assertion) __nVerify(assertion)
1408 #endif
1409
1410 #ifndef nverify_string
1411 #define nverify_string(assertion, message) __nVerify_String(assertion, message)
1412 #endif
1413
1414 #ifndef require_action_quiet
1415 #define require_action_quiet(assertion, exceptionLabel, action) __Require_Action_Quiet(assertion, exceptionLabel, action)
1416 #endif
1417
1418 #ifndef require_noerr_action_quiet
1419 #define require_noerr_action_quiet(errorCode, exceptionLabel, action) __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action)
1420 #endif
1421
1422 #ifndef require_noerr_quiet
1423 #define require_noerr_quiet(errorCode, exceptionLabel) __Require_noErr_Quiet(errorCode, exceptionLabel)
1424 #endif
1425
1426 #ifndef require_quiet
1427 #define require_quiet(assertion, exceptionLabel) __Require_Quiet(assertion, exceptionLabel)
1428 #endif
1429
1430 #ifndef check_compile_time
1431 #define check_compile_time( expr ) __Check_Compile_Time( expr )
1432 #endif
1433
1434 #ifndef debug_string
1435 #define debug_string(message) __Debug_String(message)
1436 #endif
1437
1438#endif /* ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES */
1439
1440
1441#endif /* __ASSERTMACROS__ */
lib/libc/include/x86_64-macos-gnu/Availability.h+1-124
......@@ -132,130 +132,7 @@
132132#define __API_TO_BE_DEPRECATED 100000
133133#endif
134134
135#ifndef __MAC_10_0
136#define __MAC_10_0 1000
137#define __MAC_10_1 1010
138#define __MAC_10_2 1020
139#define __MAC_10_3 1030
140#define __MAC_10_4 1040
141#define __MAC_10_5 1050
142#define __MAC_10_6 1060
143#define __MAC_10_7 1070
144#define __MAC_10_8 1080
145#define __MAC_10_9 1090
146#define __MAC_10_10 101000
147#define __MAC_10_10_2 101002
148#define __MAC_10_10_3 101003
149#define __MAC_10_11 101100
150#define __MAC_10_11_2 101102
151#define __MAC_10_11_3 101103
152#define __MAC_10_11_4 101104
153#define __MAC_10_12 101200
154#define __MAC_10_12_1 101201
155#define __MAC_10_12_2 101202
156#define __MAC_10_12_4 101204
157#define __MAC_10_13 101300
158#define __MAC_10_13_1 101301
159#define __MAC_10_13_2 101302
160#define __MAC_10_13_4 101304
161#define __MAC_10_14 101400
162#define __MAC_10_14_1 101401
163#define __MAC_10_14_4 101404
164#define __MAC_10_15 101500
165#define __MAC_10_15_1 101501
166#define __MAC_10_15_4 101504
167/* __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */
168
169#define __IPHONE_2_0 20000
170#define __IPHONE_2_1 20100
171#define __IPHONE_2_2 20200
172#define __IPHONE_3_0 30000
173#define __IPHONE_3_1 30100
174#define __IPHONE_3_2 30200
175#define __IPHONE_4_0 40000
176#define __IPHONE_4_1 40100
177#define __IPHONE_4_2 40200
178#define __IPHONE_4_3 40300
179#define __IPHONE_5_0 50000
180#define __IPHONE_5_1 50100
181#define __IPHONE_6_0 60000
182#define __IPHONE_6_1 60100
183#define __IPHONE_7_0 70000
184#define __IPHONE_7_1 70100
185#define __IPHONE_8_0 80000
186#define __IPHONE_8_1 80100
187#define __IPHONE_8_2 80200
188#define __IPHONE_8_3 80300
189#define __IPHONE_8_4 80400
190#define __IPHONE_9_0 90000
191#define __IPHONE_9_1 90100
192#define __IPHONE_9_2 90200
193#define __IPHONE_9_3 90300
194#define __IPHONE_10_0 100000
195#define __IPHONE_10_1 100100
196#define __IPHONE_10_2 100200
197#define __IPHONE_10_3 100300
198#define __IPHONE_11_0 110000
199#define __IPHONE_11_1 110100
200#define __IPHONE_11_2 110200
201#define __IPHONE_11_3 110300
202#define __IPHONE_11_4 110400
203#define __IPHONE_12_0 120000
204#define __IPHONE_12_1 120100
205#define __IPHONE_12_2 120200
206#define __IPHONE_12_3 120300
207#define __IPHONE_13_0 130000
208#define __IPHONE_13_1 130100
209#define __IPHONE_13_2 130200
210#define __IPHONE_13_3 130300
211#define __IPHONE_13_4 130400
212#define __IPHONE_13_5 130500
213#define __IPHONE_13_6 130600
214/* __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */
215
216#define __TVOS_9_0 90000
217#define __TVOS_9_1 90100
218#define __TVOS_9_2 90200
219#define __TVOS_10_0 100000
220#define __TVOS_10_0_1 100001
221#define __TVOS_10_1 100100
222#define __TVOS_10_2 100200
223#define __TVOS_11_0 110000
224#define __TVOS_11_1 110100
225#define __TVOS_11_2 110200
226#define __TVOS_11_3 110300
227#define __TVOS_11_4 110400
228#define __TVOS_12_0 120000
229#define __TVOS_12_1 120100
230#define __TVOS_12_2 120200
231#define __TVOS_12_3 120300
232#define __TVOS_13_0 130000
233#define __TVOS_13_2 130200
234#define __TVOS_13_3 130300
235#define __TVOS_13_4 130400
236
237#define __WATCHOS_1_0 10000
238#define __WATCHOS_2_0 20000
239#define __WATCHOS_2_1 20100
240#define __WATCHOS_2_2 20200
241#define __WATCHOS_3_0 30000
242#define __WATCHOS_3_1 30100
243#define __WATCHOS_3_1_1 30101
244#define __WATCHOS_3_2 30200
245#define __WATCHOS_4_0 40000
246#define __WATCHOS_4_1 40100
247#define __WATCHOS_4_2 40200
248#define __WATCHOS_4_3 40300
249#define __WATCHOS_5_0 50000
250#define __WATCHOS_5_1 50100
251#define __WATCHOS_5_2 50200
252#define __WATCHOS_6_0 60000
253#define __WATCHOS_6_1 60100
254#define __WATCHOS_6_2 60200
255
256#define __DRIVERKIT_19_0 190000
257#endif /* __MAC_10_0 */
258
135#include <AvailabilityVersions.h>
259136#include <AvailabilityInternal.h>
260137
261138#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h+9-6
......@@ -45,6 +45,9 @@
4545 #ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
4646 /* compiler sets __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ when -miphoneos-version-min is used */
4747 #define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
48 /* set to 1 when RC_FALLBACK_PLATFORM=iphoneos */
49 #elif 0
50 #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_14_0
4851 #endif
4952#endif /* __IPHONE_OS_VERSION_MIN_REQUIRED */
5053
......@@ -52,7 +55,7 @@
5255 #ifdef __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__
5356 /* compiler sets __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ when -mtvos-version-min is used */
5457 #define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__
55 #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_13_0
58 #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_14_2
5659 /* for compatibility with existing code. New code should use platform specific checks */
5760 #define __IPHONE_OS_VERSION_MIN_REQUIRED 90000
5861 #endif
......@@ -62,7 +65,7 @@
6265 #ifdef __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__
6366 /* compiler sets __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ when -mwatchos-version-min is used */
6467 #define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__
65 #define __WATCH_OS_VERSION_MAX_ALLOWED 60000
68 #define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_7_1
6669 /* for compatibility with existing code. New code should use platform specific checks */
6770 #define __IPHONE_OS_VERSION_MIN_REQUIRED 90000
6871 #endif
......@@ -72,7 +75,7 @@
7275 #ifdef __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__
7376
7477 #define __BRIDGE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__
75 #define __BRIDGE_OS_VERSION_MAX_ALLOWED 20000
78 #define __BRIDGE_OS_VERSION_MAX_ALLOWED 50000
7679 /* for compatibility with existing code. New code should use platform specific checks */
7780 #define __IPHONE_OS_VERSION_MIN_REQUIRED 110000
7881 #endif
......@@ -87,14 +90,14 @@
8790#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
8891 /* make sure a default max version is set */
8992 #ifndef __MAC_OS_X_VERSION_MAX_ALLOWED
90 #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_10_15
93 #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_11_0
9194 #endif
9295#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */
9396
9497#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
9598 /* make sure a default max version is set */
9699 #ifndef __IPHONE_OS_VERSION_MAX_ALLOWED
97 #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_13_0
100 #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_14_2
98101 #endif
99102 /* make sure a valid min is set */
100103 #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_2_0
......@@ -2887,7 +2890,7 @@
28872890 #if __has_builtin(__is_target_environment)
28882891 #if __has_builtin(__is_target_variant_os)
28892892 #if __has_builtin(__is_target_variant_environment)
2890 #if (__is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi))
2893 #if ((__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi))
28912894 #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION __attribute__((availability(ios,introduced=4.0)))
28922895 #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION __attribute__((availability(ios,unavailable)))
28932896 #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION_MSG(_msg) __attribute__((availability(ios,unavailable)))
lib/libc/include/x86_64-macos-gnu/AvailabilityMacros.h created+4015
......@@ -0,0 +1,4015 @@
1/*
2 * Copyright (c) 2001-2010 by Apple Inc.. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 File: AvailabilityMacros.h
26
27 More Info: See the SDK Compatibility Guide
28
29 Contains: Autoconfiguration of AVAILABLE_ macros for Mac OS X
30
31 This header enables a developer to specify build time
32 constraints on what Mac OS X versions the resulting
33 application will be run. There are two bounds a developer
34 can specify:
35
36 MAC_OS_X_VERSION_MIN_REQUIRED
37 MAC_OS_X_VERSION_MAX_ALLOWED
38
39 The lower bound controls which calls to OS functions will
40 be weak-importing (allowed to be unresolved at launch time).
41 The upper bound controls which OS functionality, if used,
42 will result in a compiler error because that functionality is
43 not available on any OS in the specifed range.
44
45 For example, suppose an application is compiled with:
46
47 MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_2
48 MAC_OS_X_VERSION_MAX_ALLOWED = MAC_OS_X_VERSION_10_3
49
50 and an OS header contains:
51
52 extern void funcA(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
53 extern void funcB(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2;
54 extern void funcC(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3;
55 extern void funcD(void) AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER;
56 extern void funcE(void) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;
57 extern void funcF(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
58 extern void funcG(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
59
60 typedef long TypeA DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER;
61 typedef long TypeB DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER;
62 typedef long TypeC DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER;
63 typedef long TypeD DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER;
64 typedef long TypeE DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER;
65
66 Any application code which uses these declarations will get the following:
67
68 compile link run
69 ------- ------ -------
70 funcA: normal normal normal
71 funcB: warning normal normal
72 funcC: normal normal normal
73 funcD: normal normal normal
74 funcE: normal normal normal
75 funcF: normal weak on 10.3 normal, on 10.2 (&funcF == NULL)
76 funcG: error error n/a
77 typeA: warning
78 typeB: warning
79 typeC: warning
80 typeD: normal
81 typeE: normal
82
83
84*/
85#ifndef __AVAILABILITYMACROS__
86#define __AVAILABILITYMACROS__
87
88/*
89 * Set up standard Mac OS X versions
90 */
91#define MAC_OS_X_VERSION_10_0 1000
92#define MAC_OS_X_VERSION_10_1 1010
93#define MAC_OS_X_VERSION_10_2 1020
94#define MAC_OS_X_VERSION_10_3 1030
95#define MAC_OS_X_VERSION_10_4 1040
96#define MAC_OS_X_VERSION_10_5 1050
97#define MAC_OS_X_VERSION_10_6 1060
98#define MAC_OS_X_VERSION_10_7 1070
99#define MAC_OS_X_VERSION_10_8 1080
100#define MAC_OS_X_VERSION_10_9 1090
101#define MAC_OS_X_VERSION_10_10 101000
102#define MAC_OS_X_VERSION_10_10_2 101002
103#define MAC_OS_X_VERSION_10_10_3 101003
104#define MAC_OS_X_VERSION_10_11 101100
105#define MAC_OS_X_VERSION_10_11_2 101102
106#define MAC_OS_X_VERSION_10_11_3 101103
107#define MAC_OS_X_VERSION_10_11_4 101104
108#define MAC_OS_X_VERSION_10_12 101200
109#define MAC_OS_X_VERSION_10_12_1 101201
110#define MAC_OS_X_VERSION_10_12_2 101202
111#define MAC_OS_X_VERSION_10_12_4 101204
112#define MAC_OS_X_VERSION_10_13 101300
113#define MAC_OS_X_VERSION_10_13_1 101301
114#define MAC_OS_X_VERSION_10_13_2 101302
115#define MAC_OS_X_VERSION_10_13_4 101304
116#define MAC_OS_X_VERSION_10_14 101400
117#define MAC_OS_X_VERSION_10_14_1 101401
118#define MAC_OS_X_VERSION_10_14_4 101404
119#define MAC_OS_X_VERSION_10_15 101500
120#define MAC_OS_VERSION_11_0 110000
121
122/*
123 * If min OS not specified, assume 10.4 for intel
124 * Note: compiler driver may set _ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED_ based on MACOSX_DEPLOYMENT_TARGET environment variable
125 */
126#ifndef MAC_OS_X_VERSION_MIN_REQUIRED
127 #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
128 #if (__i386__ || __x86_64__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < MAC_OS_X_VERSION_10_4)
129 #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid.
130 #endif
131 #define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
132 #else
133 #if __i386__ || __x86_64__
134 #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
135 #elif __arm__ || __arm64__
136 #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_5
137 #else
138 #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_1
139 #endif
140 #endif
141#endif
142
143/*
144 * if max OS not specified, assume larger of (10.15, min)
145 */
146#ifndef MAC_OS_X_VERSION_MAX_ALLOWED
147 #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_VERSION_11_0
148 #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_MIN_REQUIRED
149 #else
150 #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_VERSION_11_0
151 #endif
152#endif
153
154/*
155 * Error on bad values
156 */
157#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_MIN_REQUIRED
158 #error MAC_OS_X_VERSION_MAX_ALLOWED must be >= MAC_OS_X_VERSION_MIN_REQUIRED
159#endif
160#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_0
161 #error MAC_OS_X_VERSION_MIN_REQUIRED must be >= MAC_OS_X_VERSION_10_0
162#endif
163
164/*
165 * only certain compilers support __attribute__((weak_import))
166 */
167#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1020)
168 #define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import))
169#elif defined(__MWERKS__) && (__MWERKS__ >= 0x3205) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1020) && !defined(__INTEL__)
170 #define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import))
171#else
172 #define WEAK_IMPORT_ATTRIBUTE
173#endif
174
175/*
176 * only certain compilers support __attribute__((deprecated))
177 */
178#if defined(__has_feature) && defined(__has_attribute)
179 #if __has_attribute(deprecated)
180 #define DEPRECATED_ATTRIBUTE __attribute__((deprecated))
181 #if __has_feature(attribute_deprecated_with_message)
182 #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
183 #else
184 #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated))
185 #endif
186 #else
187 #define DEPRECATED_ATTRIBUTE
188 #define DEPRECATED_MSG_ATTRIBUTE(s)
189 #endif
190#elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
191 #define DEPRECATED_ATTRIBUTE __attribute__((deprecated))
192 #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
193 #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
194 #else
195 #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated))
196 #endif
197#else
198 #define DEPRECATED_ATTRIBUTE
199 #define DEPRECATED_MSG_ATTRIBUTE(s)
200#endif
201
202/*
203 * only certain compilers support __attribute__((unavailable))
204 */
205#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
206 #define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable))
207#else
208 #define UNAVAILABLE_ATTRIBUTE
209#endif
210
211
212/*
213 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
214 *
215 * Used on functions introduced in Mac OS X 10.0
216 */
217#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
218
219/*
220 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED
221 *
222 * Used on functions introduced in Mac OS X 10.0,
223 * and deprecated in Mac OS X 10.0
224 */
225#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
226
227/*
228 * DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER
229 *
230 * Used on types deprecated in Mac OS X 10.0
231 */
232#define DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER DEPRECATED_ATTRIBUTE
233
234#ifndef __AVAILABILITY_MACROS_USES_AVAILABILITY
235 #ifdef __has_attribute
236 #if __has_attribute(availability)
237 #include <Availability.h>
238 #define __AVAILABILITY_MACROS_USES_AVAILABILITY 1
239 #endif
240 #endif
241#endif
242
243#if TARGET_OS_OSX
244#define __IPHONE_COMPAT_VERSION __IPHONE_NA
245#elif TARGET_OS_MACCATALYST
246#define __IPHONE_COMPAT_VERSION __IPHONE_NA
247#else
248#define __IPHONE_COMPAT_VERSION __IPHONE_4_0
249#endif
250
251/*
252 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
253 *
254 * Used on declarations introduced in Mac OS X 10.1
255 */
256#if __AVAILABILITY_MACROS_USES_AVAILABILITY
257 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_COMPAT_VERSION)
258#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_1
259 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER UNAVAILABLE_ATTRIBUTE
260#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_1
261 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER WEAK_IMPORT_ATTRIBUTE
262#else
263 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
264#endif
265
266/*
267 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED
268 *
269 * Used on declarations introduced in Mac OS X 10.1,
270 * and deprecated in Mac OS X 10.1
271 */
272#if __AVAILABILITY_MACROS_USES_AVAILABILITY
273 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
274#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1
275 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
276#else
277 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
278#endif
279
280/*
281 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1
282 *
283 * Used on declarations introduced in Mac OS X 10.0,
284 * but later deprecated in Mac OS X 10.1
285 */
286#if __AVAILABILITY_MACROS_USES_AVAILABILITY
287 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
288#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1
289 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 DEPRECATED_ATTRIBUTE
290#else
291 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
292#endif
293
294/*
295 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
296 *
297 * Used on declarations introduced in Mac OS X 10.2
298 */
299#if __AVAILABILITY_MACROS_USES_AVAILABILITY
300 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_COMPAT_VERSION)
301#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_2
302 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER UNAVAILABLE_ATTRIBUTE
303#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2
304 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER WEAK_IMPORT_ATTRIBUTE
305#else
306 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
307#endif
308
309/*
310 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED
311 *
312 * Used on declarations introduced in Mac OS X 10.2,
313 * and deprecated in Mac OS X 10.2
314 */
315#if __AVAILABILITY_MACROS_USES_AVAILABILITY
316 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
317#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
318 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
319#else
320 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
321#endif
322
323/*
324 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2
325 *
326 * Used on declarations introduced in Mac OS X 10.0,
327 * but later deprecated in Mac OS X 10.2
328 */
329#if __AVAILABILITY_MACROS_USES_AVAILABILITY
330 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
331#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
332 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 DEPRECATED_ATTRIBUTE
333#else
334 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
335#endif
336
337/*
338 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2
339 *
340 * Used on declarations introduced in Mac OS X 10.1,
341 * but later deprecated in Mac OS X 10.2
342 */
343#if __AVAILABILITY_MACROS_USES_AVAILABILITY
344 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
345#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
346 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 DEPRECATED_ATTRIBUTE
347#else
348 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
349#endif
350
351/*
352 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
353 *
354 * Used on declarations introduced in Mac OS X 10.3
355 */
356#if __AVAILABILITY_MACROS_USES_AVAILABILITY
357 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_COMPAT_VERSION)
358#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
359 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER UNAVAILABLE_ATTRIBUTE
360#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
361 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER WEAK_IMPORT_ATTRIBUTE
362#else
363 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
364#endif
365
366/*
367 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED
368 *
369 * Used on declarations introduced in Mac OS X 10.3,
370 * and deprecated in Mac OS X 10.3
371 */
372#if __AVAILABILITY_MACROS_USES_AVAILABILITY
373 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
374#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
375 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
376#else
377 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
378#endif
379
380/*
381 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3
382 *
383 * Used on declarations introduced in Mac OS X 10.0,
384 * but later deprecated in Mac OS X 10.3
385 */
386#if __AVAILABILITY_MACROS_USES_AVAILABILITY
387 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
388#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
389 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE
390#else
391 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
392#endif
393
394/*
395 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3
396 *
397 * Used on declarations introduced in Mac OS X 10.1,
398 * but later deprecated in Mac OS X 10.3
399 */
400#if __AVAILABILITY_MACROS_USES_AVAILABILITY
401 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
402#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
403 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE
404#else
405 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
406#endif
407
408/*
409 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3
410 *
411 * Used on declarations introduced in Mac OS X 10.2,
412 * but later deprecated in Mac OS X 10.3
413 */
414#if __AVAILABILITY_MACROS_USES_AVAILABILITY
415 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
416#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
417 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE
418#else
419 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
420#endif
421
422/*
423 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
424 *
425 * Used on declarations introduced in Mac OS X 10.4
426 */
427#if __AVAILABILITY_MACROS_USES_AVAILABILITY
428 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_COMPAT_VERSION)
429#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
430 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER UNAVAILABLE_ATTRIBUTE
431#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
432 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER WEAK_IMPORT_ATTRIBUTE
433#else
434 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
435#endif
436
437/*
438 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED
439 *
440 * Used on declarations introduced in Mac OS X 10.4,
441 * and deprecated in Mac OS X 10.4
442 */
443#if __AVAILABILITY_MACROS_USES_AVAILABILITY
444 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
445#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
446 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
447#else
448 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
449#endif
450
451/*
452 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
453 *
454 * Used on declarations introduced in Mac OS X 10.0,
455 * but later deprecated in Mac OS X 10.4
456 */
457#if __AVAILABILITY_MACROS_USES_AVAILABILITY
458 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
459#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
460 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE
461#else
462 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
463#endif
464
465/*
466 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
467 *
468 * Used on declarations introduced in Mac OS X 10.1,
469 * but later deprecated in Mac OS X 10.4
470 */
471#if __AVAILABILITY_MACROS_USES_AVAILABILITY
472 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
473#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
474 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE
475#else
476 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
477#endif
478
479/*
480 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
481 *
482 * Used on declarations introduced in Mac OS X 10.2,
483 * but later deprecated in Mac OS X 10.4
484 */
485#if __AVAILABILITY_MACROS_USES_AVAILABILITY
486 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
487#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
488 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE
489#else
490 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
491#endif
492
493/*
494 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
495 *
496 * Used on declarations introduced in Mac OS X 10.3,
497 * but later deprecated in Mac OS X 10.4
498 */
499#if __AVAILABILITY_MACROS_USES_AVAILABILITY
500 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
501#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
502 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE
503#else
504 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
505#endif
506
507/*
508 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
509 *
510 * Used on declarations introduced in Mac OS X 10.5
511 */
512#if __AVAILABILITY_MACROS_USES_AVAILABILITY
513 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_COMPAT_VERSION)
514#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
515 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER UNAVAILABLE_ATTRIBUTE
516#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
517 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER WEAK_IMPORT_ATTRIBUTE
518#else
519 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
520#endif
521
522/*
523 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED
524 *
525 * Used on declarations introduced in Mac OS X 10.5,
526 * and deprecated in Mac OS X 10.5
527 */
528#if __AVAILABILITY_MACROS_USES_AVAILABILITY
529 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
530#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
531 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
532#else
533 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
534#endif
535
536/*
537 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
538 *
539 * Used on declarations introduced in Mac OS X 10.0,
540 * but later deprecated in Mac OS X 10.5
541 */
542#if __AVAILABILITY_MACROS_USES_AVAILABILITY
543 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
544#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
545 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE
546#else
547 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
548#endif
549
550/*
551 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
552 *
553 * Used on declarations introduced in Mac OS X 10.1,
554 * but later deprecated in Mac OS X 10.5
555 */
556#if __AVAILABILITY_MACROS_USES_AVAILABILITY
557 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
558#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
559 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE
560#else
561 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
562#endif
563
564/*
565 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
566 *
567 * Used on declarations introduced in Mac OS X 10.2,
568 * but later deprecated in Mac OS X 10.5
569 */
570#if __AVAILABILITY_MACROS_USES_AVAILABILITY
571 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
572#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
573 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE
574#else
575 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
576#endif
577
578/*
579 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
580 *
581 * Used on declarations introduced in Mac OS X 10.3,
582 * but later deprecated in Mac OS X 10.5
583 */
584#if __AVAILABILITY_MACROS_USES_AVAILABILITY
585 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
586#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
587 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE
588#else
589 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
590#endif
591
592/*
593 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
594 *
595 * Used on declarations introduced in Mac OS X 10.4,
596 * but later deprecated in Mac OS X 10.5
597 */
598#if __AVAILABILITY_MACROS_USES_AVAILABILITY
599 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
600#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
601 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE
602#else
603 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
604#endif
605
606/*
607 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
608 *
609 * Used on declarations introduced in Mac OS X 10.6
610 */
611#if __AVAILABILITY_MACROS_USES_AVAILABILITY
612 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_COMPAT_VERSION)
613#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
614 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER UNAVAILABLE_ATTRIBUTE
615#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
616 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE
617#else
618 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
619#endif
620
621/*
622 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED
623 *
624 * Used on declarations introduced in Mac OS X 10.6,
625 * and deprecated in Mac OS X 10.6
626 */
627#if __AVAILABILITY_MACROS_USES_AVAILABILITY
628 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
629#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
630 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
631#else
632 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
633#endif
634
635/*
636 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6
637 *
638 * Used on declarations introduced in Mac OS X 10.0,
639 * but later deprecated in Mac OS X 10.6
640 */
641#if __AVAILABILITY_MACROS_USES_AVAILABILITY
642 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
643#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
644 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE
645#else
646 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
647#endif
648
649/*
650 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6
651 *
652 * Used on declarations introduced in Mac OS X 10.1,
653 * but later deprecated in Mac OS X 10.6
654 */
655#if __AVAILABILITY_MACROS_USES_AVAILABILITY
656 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
657#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
658 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE
659#else
660 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
661#endif
662
663/*
664 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6
665 *
666 * Used on declarations introduced in Mac OS X 10.2,
667 * but later deprecated in Mac OS X 10.6
668 */
669#if __AVAILABILITY_MACROS_USES_AVAILABILITY
670 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
671#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
672 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE
673#else
674 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
675#endif
676
677/*
678 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6
679 *
680 * Used on declarations introduced in Mac OS X 10.3,
681 * but later deprecated in Mac OS X 10.6
682 */
683#if __AVAILABILITY_MACROS_USES_AVAILABILITY
684 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
685#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
686 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE
687#else
688 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
689#endif
690
691/*
692 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6
693 *
694 * Used on declarations introduced in Mac OS X 10.4,
695 * but later deprecated in Mac OS X 10.6
696 */
697#if __AVAILABILITY_MACROS_USES_AVAILABILITY
698 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
699#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
700 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE
701#else
702 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
703#endif
704
705/*
706 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6
707 *
708 * Used on declarations introduced in Mac OS X 10.5,
709 * but later deprecated in Mac OS X 10.6
710 */
711#if __AVAILABILITY_MACROS_USES_AVAILABILITY
712 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
713#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
714 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE
715#else
716 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
717#endif
718
719/*
720 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
721 *
722 * Used on declarations introduced in Mac OS X 10.7
723 */
724#if __AVAILABILITY_MACROS_USES_AVAILABILITY
725 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_COMPAT_VERSION)
726#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
727 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER UNAVAILABLE_ATTRIBUTE
728#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
729 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER WEAK_IMPORT_ATTRIBUTE
730#else
731 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
732#endif
733
734/*
735 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED
736 *
737 * Used on declarations introduced in Mac OS X 10.7,
738 * and deprecated in Mac OS X 10.7
739 */
740#if __AVAILABILITY_MACROS_USES_AVAILABILITY
741 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
742#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
743 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
744#else
745 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
746#endif
747
748/*
749 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
750 *
751 * Used on declarations introduced in Mac OS X 10.0,
752 * but later deprecated in Mac OS X 10.7
753 */
754#if __AVAILABILITY_MACROS_USES_AVAILABILITY
755 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
756#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
757 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE
758#else
759 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
760#endif
761
762/*
763 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
764 *
765 * Used on declarations introduced in Mac OS X 10.1,
766 * but later deprecated in Mac OS X 10.7
767 */
768#if __AVAILABILITY_MACROS_USES_AVAILABILITY
769 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
770#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
771 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE
772#else
773 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
774#endif
775
776/*
777 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
778 *
779 * Used on declarations introduced in Mac OS X 10.2,
780 * but later deprecated in Mac OS X 10.7
781 */
782#if __AVAILABILITY_MACROS_USES_AVAILABILITY
783 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
784#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
785 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE
786#else
787 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
788#endif
789
790/*
791 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
792 *
793 * Used on declarations introduced in Mac OS X 10.3,
794 * but later deprecated in Mac OS X 10.7
795 */
796#if __AVAILABILITY_MACROS_USES_AVAILABILITY
797 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
798#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
799 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE
800#else
801 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
802#endif
803
804/*
805 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
806 *
807 * Used on declarations introduced in Mac OS X 10.4,
808 * but later deprecated in Mac OS X 10.7
809 */
810#if __AVAILABILITY_MACROS_USES_AVAILABILITY
811 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
812#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
813 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE
814#else
815 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
816#endif
817
818/*
819 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
820 *
821 * Used on declarations introduced in Mac OS X 10.5,
822 * but later deprecated in Mac OS X 10.7
823 */
824#if __AVAILABILITY_MACROS_USES_AVAILABILITY
825 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
826#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
827 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE
828#else
829 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
830#endif
831
832/*
833 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
834 *
835 * Used on declarations introduced in Mac OS X 10.6,
836 * but later deprecated in Mac OS X 10.7
837 */
838#if __AVAILABILITY_MACROS_USES_AVAILABILITY
839 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
840#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
841 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE
842#else
843 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
844#endif
845
846/*
847 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13
848 *
849 * Used on declarations introduced in Mac OS X 10.6,
850 * but later deprecated in Mac OS X 10.13
851 */
852#if __AVAILABILITY_MACROS_USES_AVAILABILITY
853#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_13, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
854#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
855#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 DEPRECATED_ATTRIBUTE
856#else
857#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
858#endif
859
860/*
861 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
862 *
863 * Used on declarations introduced in Mac OS X 10.8
864 */
865#if __AVAILABILITY_MACROS_USES_AVAILABILITY
866 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_COMPAT_VERSION)
867#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
868 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER UNAVAILABLE_ATTRIBUTE
869#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
870 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER WEAK_IMPORT_ATTRIBUTE
871#else
872 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
873#endif
874
875/*
876 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED
877 *
878 * Used on declarations introduced in Mac OS X 10.8,
879 * and deprecated in Mac OS X 10.8
880 */
881#if __AVAILABILITY_MACROS_USES_AVAILABILITY
882 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
883#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
884 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
885#else
886 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
887#endif
888
889/*
890 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
891 *
892 * Used on declarations introduced in Mac OS X 10.0,
893 * but later deprecated in Mac OS X 10.8
894 */
895#if __AVAILABILITY_MACROS_USES_AVAILABILITY
896 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
897#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
898 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE
899#else
900 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
901#endif
902
903/*
904 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
905 *
906 * Used on declarations introduced in Mac OS X 10.1,
907 * but later deprecated in Mac OS X 10.8
908 */
909#if __AVAILABILITY_MACROS_USES_AVAILABILITY
910 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
911#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
912 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE
913#else
914 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
915#endif
916
917/*
918 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
919 *
920 * Used on declarations introduced in Mac OS X 10.2,
921 * but later deprecated in Mac OS X 10.8
922 */
923#if __AVAILABILITY_MACROS_USES_AVAILABILITY
924 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
925#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
926 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE
927#else
928 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
929#endif
930
931/*
932 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
933 *
934 * Used on declarations introduced in Mac OS X 10.3,
935 * but later deprecated in Mac OS X 10.8
936 */
937#if __AVAILABILITY_MACROS_USES_AVAILABILITY
938 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
939#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
940 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE
941#else
942 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
943#endif
944
945/*
946 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
947 *
948 * Used on declarations introduced in Mac OS X 10.4,
949 * but later deprecated in Mac OS X 10.8
950 */
951#if __AVAILABILITY_MACROS_USES_AVAILABILITY
952 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
953#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
954 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE
955#else
956 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
957#endif
958
959/*
960 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
961 *
962 * Used on declarations introduced in Mac OS X 10.5,
963 * but later deprecated in Mac OS X 10.8
964 */
965#if __AVAILABILITY_MACROS_USES_AVAILABILITY
966 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
967#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
968 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE
969#else
970 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
971#endif
972
973/*
974 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
975 *
976 * Used on declarations introduced in Mac OS X 10.6,
977 * but later deprecated in Mac OS X 10.8
978 */
979#if __AVAILABILITY_MACROS_USES_AVAILABILITY
980 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
981#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
982 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE
983#else
984 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
985#endif
986
987/*
988 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
989 *
990 * Used on declarations introduced in Mac OS X 10.7,
991 * but later deprecated in Mac OS X 10.8
992 */
993#if __AVAILABILITY_MACROS_USES_AVAILABILITY
994 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
995#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
996 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE
997#else
998 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
999#endif
1000
1001/*
1002 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
1003 *
1004 * Used on declarations introduced in Mac OS X 10.9
1005 */
1006#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1007 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_COMPAT_VERSION)
1008#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
1009 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER UNAVAILABLE_ATTRIBUTE
1010#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
1011 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER WEAK_IMPORT_ATTRIBUTE
1012#else
1013 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
1014#endif
1015
1016/*
1017 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED
1018 *
1019 * Used on declarations introduced in Mac OS X 10.9,
1020 * and deprecated in Mac OS X 10.9
1021 */
1022#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1023 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1024#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1025 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
1026#else
1027 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
1028#endif
1029
1030/*
1031 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1032 *
1033 * Used on declarations introduced in Mac OS X 10.0,
1034 * but later deprecated in Mac OS X 10.9
1035 */
1036#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1037 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1038#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1039 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1040#else
1041 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
1042#endif
1043
1044/*
1045 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1046 *
1047 * Used on declarations introduced in Mac OS X 10.1,
1048 * but later deprecated in Mac OS X 10.9
1049 */
1050#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1051 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1052#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1053 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1054#else
1055 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
1056#endif
1057
1058/*
1059 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1060 *
1061 * Used on declarations introduced in Mac OS X 10.2,
1062 * but later deprecated in Mac OS X 10.9
1063 */
1064#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1065 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1066#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1067 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1068#else
1069 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
1070#endif
1071
1072/*
1073 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1074 *
1075 * Used on declarations introduced in Mac OS X 10.3,
1076 * but later deprecated in Mac OS X 10.9
1077 */
1078#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1079 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1080#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1081 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1082#else
1083 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
1084#endif
1085
1086/*
1087 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1088 *
1089 * Used on declarations introduced in Mac OS X 10.4,
1090 * but later deprecated in Mac OS X 10.9
1091 */
1092#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1093 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1094#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1095 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1096#else
1097 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
1098#endif
1099
1100/*
1101 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1102 *
1103 * Used on declarations introduced in Mac OS X 10.5,
1104 * but later deprecated in Mac OS X 10.9
1105 */
1106#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1107 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1108#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1109 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1110#else
1111 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
1112#endif
1113
1114/*
1115 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1116 *
1117 * Used on declarations introduced in Mac OS X 10.6,
1118 * but later deprecated in Mac OS X 10.9
1119 */
1120#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1121 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1122#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1123 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1124#else
1125 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
1126#endif
1127
1128/*
1129 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1130 *
1131 * Used on declarations introduced in Mac OS X 10.7,
1132 * but later deprecated in Mac OS X 10.9
1133 */
1134#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1135 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1136#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1137 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1138#else
1139 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
1140#endif
1141
1142/*
1143 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
1144 *
1145 * Used on declarations introduced in Mac OS X 10.8,
1146 * but later deprecated in Mac OS X 10.9
1147 */
1148#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1149 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1150#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
1151 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE
1152#else
1153 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
1154#endif
1155
1156/*
1157 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
1158 *
1159 * Used on declarations introduced in Mac OS X 10.10
1160 */
1161#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1162 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_COMPAT_VERSION)
1163#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10
1164 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER UNAVAILABLE_ATTRIBUTE
1165#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
1166 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER WEAK_IMPORT_ATTRIBUTE
1167#else
1168 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
1169#endif
1170
1171/*
1172 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED
1173 *
1174 * Used on declarations introduced in Mac OS X 10.10,
1175 * and deprecated in Mac OS X 10.10
1176 */
1177#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1178 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1179#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1180 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
1181#else
1182 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
1183#endif
1184
1185/*
1186 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1187 *
1188 * Used on declarations introduced in Mac OS X 10.0,
1189 * but later deprecated in Mac OS X 10.10
1190 */
1191#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1192 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1193#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1194 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1195#else
1196 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
1197#endif
1198
1199/*
1200 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1201 *
1202 * Used on declarations introduced in Mac OS X 10.1,
1203 * but later deprecated in Mac OS X 10.10
1204 */
1205#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1206 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1207#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1208 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1209#else
1210 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
1211#endif
1212
1213/*
1214 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1215 *
1216 * Used on declarations introduced in Mac OS X 10.2,
1217 * but later deprecated in Mac OS X 10.10
1218 */
1219#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1220 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1221#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1222 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1223#else
1224 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
1225#endif
1226
1227/*
1228 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1229 *
1230 * Used on declarations introduced in Mac OS X 10.3,
1231 * but later deprecated in Mac OS X 10.10
1232 */
1233#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1234 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1235#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1236 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1237#else
1238 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
1239#endif
1240
1241/*
1242 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1243 *
1244 * Used on declarations introduced in Mac OS X 10.4,
1245 * but later deprecated in Mac OS X 10.10
1246 */
1247#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1248 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1249#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1250 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1251#else
1252 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
1253#endif
1254
1255/*
1256 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1257 *
1258 * Used on declarations introduced in Mac OS X 10.5,
1259 * but later deprecated in Mac OS X 10.10
1260 */
1261#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1262 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1263#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1264 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1265#else
1266 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
1267#endif
1268
1269/*
1270 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1271 *
1272 * Used on declarations introduced in Mac OS X 10.6,
1273 * but later deprecated in Mac OS X 10.10
1274 */
1275#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1276 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1277#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1278 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1279#else
1280 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
1281#endif
1282
1283/*
1284 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1285 *
1286 * Used on declarations introduced in Mac OS X 10.7,
1287 * but later deprecated in Mac OS X 10.10
1288 */
1289#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1290 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1291#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1292 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1293#else
1294 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
1295#endif
1296
1297/*
1298 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1299 *
1300 * Used on declarations introduced in Mac OS X 10.8,
1301 * but later deprecated in Mac OS X 10.10
1302 */
1303#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1304 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1305#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1306 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1307#else
1308 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
1309#endif
1310
1311/*
1312 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10
1313 *
1314 * Used on declarations introduced in Mac OS X 10.9,
1315 * but later deprecated in Mac OS X 10.10
1316 */
1317#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1318 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1319#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
1320 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE
1321#else
1322 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
1323#endif
1324
1325/*
1326 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
1327 *
1328 * Used on declarations introduced in Mac OS X 10.10.2
1329 */
1330#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1331 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10_2, __IPHONE_COMPAT_VERSION)
1332#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10_2
1333 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER UNAVAILABLE_ATTRIBUTE
1334#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10_2
1335 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER WEAK_IMPORT_ATTRIBUTE
1336#else
1337 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
1338#endif
1339
1340/*
1341 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED
1342 *
1343 * Used on declarations introduced in Mac OS X 10.10.2,
1344 * and deprecated in Mac OS X 10.10.2
1345 */
1346#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1347 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1348#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1349 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
1350#else
1351 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
1352#endif
1353
1354/*
1355 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1356 *
1357 * Used on declarations introduced in Mac OS X 10.0,
1358 * but later deprecated in Mac OS X 10.10.2
1359 */
1360#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1361 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1362#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1363 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1364#else
1365 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
1366#endif
1367
1368/*
1369 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1370 *
1371 * Used on declarations introduced in Mac OS X 10.1,
1372 * but later deprecated in Mac OS X 10.10.2
1373 */
1374#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1375 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1376#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1377 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1378#else
1379 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
1380#endif
1381
1382/*
1383 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1384 *
1385 * Used on declarations introduced in Mac OS X 10.2,
1386 * but later deprecated in Mac OS X 10.10.2
1387 */
1388#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1389 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1390#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1391 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1392#else
1393 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
1394#endif
1395
1396/*
1397 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1398 *
1399 * Used on declarations introduced in Mac OS X 10.3,
1400 * but later deprecated in Mac OS X 10.10.2
1401 */
1402#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1403 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1404#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1405 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1406#else
1407 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
1408#endif
1409
1410/*
1411 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1412 *
1413 * Used on declarations introduced in Mac OS X 10.4,
1414 * but later deprecated in Mac OS X 10.10.2
1415 */
1416#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1417 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1418#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1419 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1420#else
1421 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
1422#endif
1423
1424/*
1425 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1426 *
1427 * Used on declarations introduced in Mac OS X 10.5,
1428 * but later deprecated in Mac OS X 10.10.2
1429 */
1430#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1431 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1432#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1433 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1434#else
1435 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
1436#endif
1437
1438/*
1439 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1440 *
1441 * Used on declarations introduced in Mac OS X 10.6,
1442 * but later deprecated in Mac OS X 10.10.2
1443 */
1444#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1445 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1446#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1447 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1448#else
1449 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
1450#endif
1451
1452/*
1453 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1454 *
1455 * Used on declarations introduced in Mac OS X 10.7,
1456 * but later deprecated in Mac OS X 10.10.2
1457 */
1458#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1459 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1460#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1461 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1462#else
1463 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
1464#endif
1465
1466/*
1467 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1468 *
1469 * Used on declarations introduced in Mac OS X 10.8,
1470 * but later deprecated in Mac OS X 10.10.2
1471 */
1472#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1473 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1474#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1475 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1476#else
1477 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
1478#endif
1479
1480/*
1481 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1482 *
1483 * Used on declarations introduced in Mac OS X 10.9,
1484 * but later deprecated in Mac OS X 10.10.2
1485 */
1486#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1487 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1488#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1489 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1490#else
1491 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
1492#endif
1493
1494/*
1495 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2
1496 *
1497 * Used on declarations introduced in Mac OS X 10.10,
1498 * but later deprecated in Mac OS X 10.10.2
1499 */
1500#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1501 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1502#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2
1503 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE
1504#else
1505 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
1506#endif
1507
1508/*
1509 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
1510 *
1511 * Used on declarations introduced in Mac OS X 10.10.3
1512 */
1513#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1514 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10_3, __IPHONE_COMPAT_VERSION)
1515#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10_3
1516 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER UNAVAILABLE_ATTRIBUTE
1517#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10_3
1518 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER WEAK_IMPORT_ATTRIBUTE
1519#else
1520 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
1521#endif
1522
1523/*
1524 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED
1525 *
1526 * Used on declarations introduced in Mac OS X 10.10.3,
1527 * and deprecated in Mac OS X 10.10.3
1528 */
1529#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1530 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1531#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1532 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
1533#else
1534 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
1535#endif
1536
1537/*
1538 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1539 *
1540 * Used on declarations introduced in Mac OS X 10.0,
1541 * but later deprecated in Mac OS X 10.10.3
1542 */
1543#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1544 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1545#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1546 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1547#else
1548 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
1549#endif
1550
1551/*
1552 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1553 *
1554 * Used on declarations introduced in Mac OS X 10.1,
1555 * but later deprecated in Mac OS X 10.10.3
1556 */
1557#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1558 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1559#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1560 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1561#else
1562 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
1563#endif
1564
1565/*
1566 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1567 *
1568 * Used on declarations introduced in Mac OS X 10.2,
1569 * but later deprecated in Mac OS X 10.10.3
1570 */
1571#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1572 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1573#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1574 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1575#else
1576 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
1577#endif
1578
1579/*
1580 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1581 *
1582 * Used on declarations introduced in Mac OS X 10.3,
1583 * but later deprecated in Mac OS X 10.10.3
1584 */
1585#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1586 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1587#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1588 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1589#else
1590 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
1591#endif
1592
1593/*
1594 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1595 *
1596 * Used on declarations introduced in Mac OS X 10.4,
1597 * but later deprecated in Mac OS X 10.10.3
1598 */
1599#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1600 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1601#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1602 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1603#else
1604 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
1605#endif
1606
1607/*
1608 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1609 *
1610 * Used on declarations introduced in Mac OS X 10.5,
1611 * but later deprecated in Mac OS X 10.10.3
1612 */
1613#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1614 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1615#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1616 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1617#else
1618 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
1619#endif
1620
1621/*
1622 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1623 *
1624 * Used on declarations introduced in Mac OS X 10.6,
1625 * but later deprecated in Mac OS X 10.10.3
1626 */
1627#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1628 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1629#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1630 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1631#else
1632 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
1633#endif
1634
1635/*
1636 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1637 *
1638 * Used on declarations introduced in Mac OS X 10.7,
1639 * but later deprecated in Mac OS X 10.10.3
1640 */
1641#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1642 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1643#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1644 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1645#else
1646 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
1647#endif
1648
1649/*
1650 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1651 *
1652 * Used on declarations introduced in Mac OS X 10.8,
1653 * but later deprecated in Mac OS X 10.10.3
1654 */
1655#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1656 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1657#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1658 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1659#else
1660 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
1661#endif
1662
1663/*
1664 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1665 *
1666 * Used on declarations introduced in Mac OS X 10.9,
1667 * but later deprecated in Mac OS X 10.10.3
1668 */
1669#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1670 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1671#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1672 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1673#else
1674 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
1675#endif
1676
1677/*
1678 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1679 *
1680 * Used on declarations introduced in Mac OS X 10.10,
1681 * but later deprecated in Mac OS X 10.10.3
1682 */
1683#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1684 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1685#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1686 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1687#else
1688 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
1689#endif
1690
1691/*
1692 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3
1693 *
1694 * Used on declarations introduced in Mac OS X 10.10.2,
1695 * but later deprecated in Mac OS X 10.10.3
1696 */
1697#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1698 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1699#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3
1700 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE
1701#else
1702 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
1703#endif
1704
1705/*
1706 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
1707 *
1708 * Used on declarations introduced in Mac OS X 10.11
1709 */
1710#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1711 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_COMPAT_VERSION)
1712#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11
1713 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER UNAVAILABLE_ATTRIBUTE
1714#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
1715 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER WEAK_IMPORT_ATTRIBUTE
1716#else
1717 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
1718#endif
1719
1720/*
1721 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED
1722 *
1723 * Used on declarations introduced in Mac OS X 10.11,
1724 * and deprecated in Mac OS X 10.11
1725 */
1726#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1727 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1728#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1729 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
1730#else
1731 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
1732#endif
1733
1734/*
1735 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1736 *
1737 * Used on declarations introduced in Mac OS X 10.0,
1738 * but later deprecated in Mac OS X 10.11
1739 */
1740#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1741 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1742#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1743 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1744#else
1745 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
1746#endif
1747
1748/*
1749 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1750 *
1751 * Used on declarations introduced in Mac OS X 10.1,
1752 * but later deprecated in Mac OS X 10.11
1753 */
1754#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1755 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1756#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1757 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1758#else
1759 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
1760#endif
1761
1762/*
1763 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1764 *
1765 * Used on declarations introduced in Mac OS X 10.2,
1766 * but later deprecated in Mac OS X 10.11
1767 */
1768#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1769 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1770#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1771 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1772#else
1773 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
1774#endif
1775
1776/*
1777 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1778 *
1779 * Used on declarations introduced in Mac OS X 10.3,
1780 * but later deprecated in Mac OS X 10.11
1781 */
1782#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1783 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1784#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1785 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1786#else
1787 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
1788#endif
1789
1790/*
1791 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1792 *
1793 * Used on declarations introduced in Mac OS X 10.4,
1794 * but later deprecated in Mac OS X 10.11
1795 */
1796#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1797 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1798#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1799 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1800#else
1801 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
1802#endif
1803
1804/*
1805 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1806 *
1807 * Used on declarations introduced in Mac OS X 10.5,
1808 * but later deprecated in Mac OS X 10.11
1809 */
1810#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1811 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1812#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1813 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1814#else
1815 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
1816#endif
1817
1818/*
1819 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1820 *
1821 * Used on declarations introduced in Mac OS X 10.6,
1822 * but later deprecated in Mac OS X 10.11
1823 */
1824#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1825 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1826#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1827 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1828#else
1829 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
1830#endif
1831
1832/*
1833 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1834 *
1835 * Used on declarations introduced in Mac OS X 10.7,
1836 * but later deprecated in Mac OS X 10.11
1837 */
1838#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1839 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1840#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1841 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1842#else
1843 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
1844#endif
1845
1846/*
1847 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1848 *
1849 * Used on declarations introduced in Mac OS X 10.8,
1850 * but later deprecated in Mac OS X 10.11
1851 */
1852#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1853 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1854#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1855 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1856#else
1857 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
1858#endif
1859
1860/*
1861 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1862 *
1863 * Used on declarations introduced in Mac OS X 10.9,
1864 * but later deprecated in Mac OS X 10.11
1865 */
1866#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1867 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1868#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1869 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1870#else
1871 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
1872#endif
1873
1874/*
1875 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1876 *
1877 * Used on declarations introduced in Mac OS X 10.10,
1878 * but later deprecated in Mac OS X 10.11
1879 */
1880#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1881 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1882#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1883 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1884#else
1885 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
1886#endif
1887
1888/*
1889 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1890 *
1891 * Used on declarations introduced in Mac OS X 10.10.2,
1892 * but later deprecated in Mac OS X 10.11
1893 */
1894#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1895 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1896#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1897 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1898#else
1899 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
1900#endif
1901
1902/*
1903 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11
1904 *
1905 * Used on declarations introduced in Mac OS X 10.10.3,
1906 * but later deprecated in Mac OS X 10.11
1907 */
1908#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1909 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1910#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
1911 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE
1912#else
1913 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
1914#endif
1915
1916/*
1917 * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
1918 *
1919 * Used on declarations introduced in Mac OS X 10.11.2
1920 */
1921#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1922 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_2, __IPHONE_COMPAT_VERSION)
1923#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_2
1924 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER UNAVAILABLE_ATTRIBUTE
1925#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_2
1926 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER WEAK_IMPORT_ATTRIBUTE
1927#else
1928 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
1929#endif
1930
1931/*
1932 * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED
1933 *
1934 * Used on declarations introduced in Mac OS X 10.11.2,
1935 * and deprecated in Mac OS X 10.11.2
1936 */
1937#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1938 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1939#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
1940 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
1941#else
1942 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
1943#endif
1944
1945/*
1946 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
1947 *
1948 * Used on declarations introduced in Mac OS X 10.0,
1949 * but later deprecated in Mac OS X 10.11.2
1950 */
1951#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1952 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1953#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
1954 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
1955#else
1956 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
1957#endif
1958
1959/*
1960 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
1961 *
1962 * Used on declarations introduced in Mac OS X 10.1,
1963 * but later deprecated in Mac OS X 10.11.2
1964 */
1965#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1966 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1967#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
1968 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
1969#else
1970 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
1971#endif
1972
1973/*
1974 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
1975 *
1976 * Used on declarations introduced in Mac OS X 10.2,
1977 * but later deprecated in Mac OS X 10.11.2
1978 */
1979#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1980 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1981#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
1982 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
1983#else
1984 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
1985#endif
1986
1987/*
1988 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
1989 *
1990 * Used on declarations introduced in Mac OS X 10.3,
1991 * but later deprecated in Mac OS X 10.11.2
1992 */
1993#if __AVAILABILITY_MACROS_USES_AVAILABILITY
1994 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
1995#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
1996 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
1997#else
1998 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
1999#endif
2000
2001/*
2002 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2003 *
2004 * Used on declarations introduced in Mac OS X 10.4,
2005 * but later deprecated in Mac OS X 10.11.2
2006 */
2007#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2008 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2009#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2010 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2011#else
2012 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
2013#endif
2014
2015/*
2016 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2017 *
2018 * Used on declarations introduced in Mac OS X 10.5,
2019 * but later deprecated in Mac OS X 10.11.2
2020 */
2021#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2022 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2023#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2024 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2025#else
2026 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
2027#endif
2028
2029/*
2030 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2031 *
2032 * Used on declarations introduced in Mac OS X 10.6,
2033 * but later deprecated in Mac OS X 10.11.2
2034 */
2035#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2036 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2037#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2038 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2039#else
2040 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
2041#endif
2042
2043/*
2044 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2045 *
2046 * Used on declarations introduced in Mac OS X 10.7,
2047 * but later deprecated in Mac OS X 10.11.2
2048 */
2049#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2050 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2051#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2052 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2053#else
2054 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
2055#endif
2056
2057/*
2058 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2059 *
2060 * Used on declarations introduced in Mac OS X 10.8,
2061 * but later deprecated in Mac OS X 10.11.2
2062 */
2063#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2064 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2065#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2066 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2067#else
2068 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
2069#endif
2070
2071/*
2072 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2073 *
2074 * Used on declarations introduced in Mac OS X 10.9,
2075 * but later deprecated in Mac OS X 10.11.2
2076 */
2077#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2078 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2079#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2080 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2081#else
2082 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
2083#endif
2084
2085/*
2086 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2087 *
2088 * Used on declarations introduced in Mac OS X 10.10,
2089 * but later deprecated in Mac OS X 10.11.2
2090 */
2091#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2092 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2093#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2094 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2095#else
2096 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
2097#endif
2098
2099/*
2100 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2101 *
2102 * Used on declarations introduced in Mac OS X 10.10.2,
2103 * but later deprecated in Mac OS X 10.11.2
2104 */
2105#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2106 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2107#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2108 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2109#else
2110 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
2111#endif
2112
2113/*
2114 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2115 *
2116 * Used on declarations introduced in Mac OS X 10.10.3,
2117 * but later deprecated in Mac OS X 10.11.2
2118 */
2119#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2120 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2121#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2122 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2123#else
2124 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
2125#endif
2126
2127/*
2128 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2
2129 *
2130 * Used on declarations introduced in Mac OS X 10.11,
2131 * but later deprecated in Mac OS X 10.11.2
2132 */
2133#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2134 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2135#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2
2136 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE
2137#else
2138 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
2139#endif
2140
2141/*
2142 * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER
2143 *
2144 * Used on declarations introduced in Mac OS X 10.11.3
2145 */
2146#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2147 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_3, __IPHONE_COMPAT_VERSION)
2148#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_3
2149 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER UNAVAILABLE_ATTRIBUTE
2150#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_3
2151 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER WEAK_IMPORT_ATTRIBUTE
2152#else
2153 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER
2154#endif
2155
2156/*
2157 * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED
2158 *
2159 * Used on declarations introduced in Mac OS X 10.11.3,
2160 * and deprecated in Mac OS X 10.11.3
2161 */
2162#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2163 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2164#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2165 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
2166#else
2167 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER
2168#endif
2169
2170/*
2171 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2172 *
2173 * Used on declarations introduced in Mac OS X 10.0,
2174 * but later deprecated in Mac OS X 10.11.3
2175 */
2176#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2177 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2178#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2179 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2180#else
2181 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
2182#endif
2183
2184/*
2185 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2186 *
2187 * Used on declarations introduced in Mac OS X 10.1,
2188 * but later deprecated in Mac OS X 10.11.3
2189 */
2190#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2191 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2192#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2193 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2194#else
2195 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
2196#endif
2197
2198/*
2199 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2200 *
2201 * Used on declarations introduced in Mac OS X 10.2,
2202 * but later deprecated in Mac OS X 10.11.3
2203 */
2204#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2205 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2206#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2207 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2208#else
2209 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
2210#endif
2211
2212/*
2213 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2214 *
2215 * Used on declarations introduced in Mac OS X 10.3,
2216 * but later deprecated in Mac OS X 10.11.3
2217 */
2218#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2219 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2220#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2221 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2222#else
2223 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
2224#endif
2225
2226/*
2227 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2228 *
2229 * Used on declarations introduced in Mac OS X 10.4,
2230 * but later deprecated in Mac OS X 10.11.3
2231 */
2232#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2233 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2234#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2235 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2236#else
2237 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
2238#endif
2239
2240/*
2241 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2242 *
2243 * Used on declarations introduced in Mac OS X 10.5,
2244 * but later deprecated in Mac OS X 10.11.3
2245 */
2246#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2247 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2248#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2249 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2250#else
2251 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
2252#endif
2253
2254/*
2255 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2256 *
2257 * Used on declarations introduced in Mac OS X 10.6,
2258 * but later deprecated in Mac OS X 10.11.3
2259 */
2260#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2261 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2262#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2263 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2264#else
2265 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
2266#endif
2267
2268/*
2269 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2270 *
2271 * Used on declarations introduced in Mac OS X 10.7,
2272 * but later deprecated in Mac OS X 10.11.3
2273 */
2274#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2275 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2276#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2277 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2278#else
2279 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
2280#endif
2281
2282/*
2283 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2284 *
2285 * Used on declarations introduced in Mac OS X 10.8,
2286 * but later deprecated in Mac OS X 10.11.3
2287 */
2288#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2289 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2290#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2291 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2292#else
2293 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
2294#endif
2295
2296/*
2297 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2298 *
2299 * Used on declarations introduced in Mac OS X 10.9,
2300 * but later deprecated in Mac OS X 10.11.3
2301 */
2302#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2303 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2304#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2305 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2306#else
2307 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
2308#endif
2309
2310/*
2311 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2312 *
2313 * Used on declarations introduced in Mac OS X 10.10,
2314 * but later deprecated in Mac OS X 10.11.3
2315 */
2316#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2317 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2318#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2319 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2320#else
2321 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
2322#endif
2323
2324/*
2325 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2326 *
2327 * Used on declarations introduced in Mac OS X 10.10.2,
2328 * but later deprecated in Mac OS X 10.11.3
2329 */
2330#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2331 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2332#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2333 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2334#else
2335 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
2336#endif
2337
2338/*
2339 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2340 *
2341 * Used on declarations introduced in Mac OS X 10.10.3,
2342 * but later deprecated in Mac OS X 10.11.3
2343 */
2344#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2345 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2346#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2347 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2348#else
2349 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
2350#endif
2351
2352/*
2353 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2354 *
2355 * Used on declarations introduced in Mac OS X 10.11,
2356 * but later deprecated in Mac OS X 10.11.3
2357 */
2358#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2359 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2360#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2361 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2362#else
2363 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
2364#endif
2365
2366/*
2367 * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3
2368 *
2369 * Used on declarations introduced in Mac OS X 10.11.2,
2370 * but later deprecated in Mac OS X 10.11.3
2371 */
2372#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2373 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2374#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3
2375 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE
2376#else
2377 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
2378#endif
2379
2380/*
2381 * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER
2382 *
2383 * Used on declarations introduced in Mac OS X 10.11.4
2384 */
2385#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2386 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_4, __IPHONE_COMPAT_VERSION)
2387#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_4
2388 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER UNAVAILABLE_ATTRIBUTE
2389#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_4
2390 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER WEAK_IMPORT_ATTRIBUTE
2391#else
2392 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER
2393#endif
2394
2395/*
2396 * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED
2397 *
2398 * Used on declarations introduced in Mac OS X 10.11.4,
2399 * and deprecated in Mac OS X 10.11.4
2400 */
2401#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2402 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2403#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2404 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
2405#else
2406 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER
2407#endif
2408
2409/*
2410 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2411 *
2412 * Used on declarations introduced in Mac OS X 10.0,
2413 * but later deprecated in Mac OS X 10.11.4
2414 */
2415#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2416 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2417#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2418 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2419#else
2420 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
2421#endif
2422
2423/*
2424 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2425 *
2426 * Used on declarations introduced in Mac OS X 10.1,
2427 * but later deprecated in Mac OS X 10.11.4
2428 */
2429#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2430 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2431#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2432 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2433#else
2434 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
2435#endif
2436
2437/*
2438 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2439 *
2440 * Used on declarations introduced in Mac OS X 10.2,
2441 * but later deprecated in Mac OS X 10.11.4
2442 */
2443#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2444 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2445#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2446 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2447#else
2448 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
2449#endif
2450
2451/*
2452 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2453 *
2454 * Used on declarations introduced in Mac OS X 10.3,
2455 * but later deprecated in Mac OS X 10.11.4
2456 */
2457#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2458 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2459#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2460 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2461#else
2462 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
2463#endif
2464
2465/*
2466 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2467 *
2468 * Used on declarations introduced in Mac OS X 10.4,
2469 * but later deprecated in Mac OS X 10.11.4
2470 */
2471#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2472 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2473#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2474 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2475#else
2476 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
2477#endif
2478
2479/*
2480 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2481 *
2482 * Used on declarations introduced in Mac OS X 10.5,
2483 * but later deprecated in Mac OS X 10.11.4
2484 */
2485#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2486 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2487#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2488 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2489#else
2490 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
2491#endif
2492
2493/*
2494 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2495 *
2496 * Used on declarations introduced in Mac OS X 10.6,
2497 * but later deprecated in Mac OS X 10.11.4
2498 */
2499#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2500 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2501#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2502 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2503#else
2504 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
2505#endif
2506
2507/*
2508 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2509 *
2510 * Used on declarations introduced in Mac OS X 10.7,
2511 * but later deprecated in Mac OS X 10.11.4
2512 */
2513#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2514 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2515#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2516 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2517#else
2518 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
2519#endif
2520
2521/*
2522 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2523 *
2524 * Used on declarations introduced in Mac OS X 10.8,
2525 * but later deprecated in Mac OS X 10.11.4
2526 */
2527#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2528 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2529#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2530 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2531#else
2532 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
2533#endif
2534
2535/*
2536 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2537 *
2538 * Used on declarations introduced in Mac OS X 10.9,
2539 * but later deprecated in Mac OS X 10.11.4
2540 */
2541#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2542 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2543#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2544 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2545#else
2546 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
2547#endif
2548
2549/*
2550 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2551 *
2552 * Used on declarations introduced in Mac OS X 10.10,
2553 * but later deprecated in Mac OS X 10.11.4
2554 */
2555#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2556 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2557#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2558 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2559#else
2560 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
2561#endif
2562
2563/*
2564 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2565 *
2566 * Used on declarations introduced in Mac OS X 10.10.2,
2567 * but later deprecated in Mac OS X 10.11.4
2568 */
2569#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2570 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2571#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2572 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2573#else
2574 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
2575#endif
2576
2577/*
2578 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2579 *
2580 * Used on declarations introduced in Mac OS X 10.10.3,
2581 * but later deprecated in Mac OS X 10.11.4
2582 */
2583#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2584 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2585#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2586 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2587#else
2588 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
2589#endif
2590
2591/*
2592 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2593 *
2594 * Used on declarations introduced in Mac OS X 10.11,
2595 * but later deprecated in Mac OS X 10.11.4
2596 */
2597#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2598 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2599#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2600 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2601#else
2602 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
2603#endif
2604
2605/*
2606 * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2607 *
2608 * Used on declarations introduced in Mac OS X 10.11.2,
2609 * but later deprecated in Mac OS X 10.11.4
2610 */
2611#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2612 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2613#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2614 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2615#else
2616 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
2617#endif
2618
2619/*
2620 * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4
2621 *
2622 * Used on declarations introduced in Mac OS X 10.11.3,
2623 * but later deprecated in Mac OS X 10.11.4
2624 */
2625#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2626 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2627#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4
2628 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE
2629#else
2630 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER
2631#endif
2632
2633/*
2634 * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
2635 *
2636 * Used on declarations introduced in Mac OS X 10.12
2637 */
2638#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2639 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_COMPAT_VERSION)
2640#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
2641 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER UNAVAILABLE_ATTRIBUTE
2642#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
2643 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER WEAK_IMPORT_ATTRIBUTE
2644#else
2645 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
2646#endif
2647
2648/*
2649 * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED
2650 *
2651 * Used on declarations introduced in Mac OS X 10.12,
2652 * and deprecated in Mac OS X 10.12
2653 */
2654#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2655 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2656#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2657 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
2658#else
2659 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
2660#endif
2661
2662/*
2663 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2664 *
2665 * Used on declarations introduced in Mac OS X 10.0,
2666 * but later deprecated in Mac OS X 10.12
2667 */
2668#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2669 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2670#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2671 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2672#else
2673 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
2674#endif
2675
2676/*
2677 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2678 *
2679 * Used on declarations introduced in Mac OS X 10.1,
2680 * but later deprecated in Mac OS X 10.12
2681 */
2682#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2683 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2684#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2685 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2686#else
2687 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
2688#endif
2689
2690/*
2691 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2692 *
2693 * Used on declarations introduced in Mac OS X 10.2,
2694 * but later deprecated in Mac OS X 10.12
2695 */
2696#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2697 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2698#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2699 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2700#else
2701 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
2702#endif
2703
2704/*
2705 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2706 *
2707 * Used on declarations introduced in Mac OS X 10.3,
2708 * but later deprecated in Mac OS X 10.12
2709 */
2710#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2711 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2712#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2713 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2714#else
2715 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
2716#endif
2717
2718/*
2719 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2720 *
2721 * Used on declarations introduced in Mac OS X 10.4,
2722 * but later deprecated in Mac OS X 10.12
2723 */
2724#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2725 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2726#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2727 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2728#else
2729 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
2730#endif
2731
2732/*
2733 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2734 *
2735 * Used on declarations introduced in Mac OS X 10.5,
2736 * but later deprecated in Mac OS X 10.12
2737 */
2738#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2739 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2740#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2741 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2742#else
2743 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
2744#endif
2745
2746/*
2747 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2748 *
2749 * Used on declarations introduced in Mac OS X 10.6,
2750 * but later deprecated in Mac OS X 10.12
2751 */
2752#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2753 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2754#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2755 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2756#else
2757 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
2758#endif
2759
2760/*
2761 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2762 *
2763 * Used on declarations introduced in Mac OS X 10.7,
2764 * but later deprecated in Mac OS X 10.12
2765 */
2766#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2767 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2768#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2769 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2770#else
2771 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
2772#endif
2773
2774/*
2775 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2776 *
2777 * Used on declarations introduced in Mac OS X 10.8,
2778 * but later deprecated in Mac OS X 10.12
2779 */
2780#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2781 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2782#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2783 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2784#else
2785 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
2786#endif
2787
2788/*
2789 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2790 *
2791 * Used on declarations introduced in Mac OS X 10.9,
2792 * but later deprecated in Mac OS X 10.12
2793 */
2794#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2795 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2796#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2797 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2798#else
2799 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
2800#endif
2801
2802/*
2803 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2804 *
2805 * Used on declarations introduced in Mac OS X 10.10,
2806 * but later deprecated in Mac OS X 10.12
2807 */
2808#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2809 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2810#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2811 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2812#else
2813 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
2814#endif
2815
2816/*
2817 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2818 *
2819 * Used on declarations introduced in Mac OS X 10.10.2,
2820 * but later deprecated in Mac OS X 10.12
2821 */
2822#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2823 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2824#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2825 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2826#else
2827 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
2828#endif
2829
2830/*
2831 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2832 *
2833 * Used on declarations introduced in Mac OS X 10.10.3,
2834 * but later deprecated in Mac OS X 10.12
2835 */
2836#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2837 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2838#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2839 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2840#else
2841 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
2842#endif
2843
2844/*
2845 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2846 *
2847 * Used on declarations introduced in Mac OS X 10.11,
2848 * but later deprecated in Mac OS X 10.12
2849 */
2850#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2851 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2852#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2853 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2854#else
2855 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
2856#endif
2857
2858/*
2859 * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2860 *
2861 * Used on declarations introduced in Mac OS X 10.11.2,
2862 * but later deprecated in Mac OS X 10.12
2863 */
2864#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2865 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2866#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2867 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2868#else
2869 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
2870#endif
2871
2872/*
2873 * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2874 *
2875 * Used on declarations introduced in Mac OS X 10.11.3,
2876 * but later deprecated in Mac OS X 10.12
2877 */
2878#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2879 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2880#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2881 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2882#else
2883 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER
2884#endif
2885
2886/*
2887 * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12
2888 *
2889 * Used on declarations introduced in Mac OS X 10.11.4,
2890 * but later deprecated in Mac OS X 10.12
2891 */
2892#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2893 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2894#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
2895 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE
2896#else
2897 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER
2898#endif
2899
2900/*
2901 * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER
2902 *
2903 * Used on declarations introduced in Mac OS X 10.12.1
2904 */
2905#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2906 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_COMPAT_VERSION)
2907#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_1
2908 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER UNAVAILABLE_ATTRIBUTE
2909#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1
2910 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER WEAK_IMPORT_ATTRIBUTE
2911#else
2912 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER
2913#endif
2914
2915/*
2916 * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED
2917 *
2918 * Used on declarations introduced in Mac OS X 10.12.1,
2919 * and deprecated in Mac OS X 10.12.1
2920 */
2921#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2922 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2923#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
2924 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
2925#else
2926 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER
2927#endif
2928
2929/*
2930 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
2931 *
2932 * Used on declarations introduced in Mac OS X 10.0,
2933 * but later deprecated in Mac OS X 10.12.1
2934 */
2935#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2936 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2937#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
2938 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
2939#else
2940 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
2941#endif
2942
2943/*
2944 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
2945 *
2946 * Used on declarations introduced in Mac OS X 10.1,
2947 * but later deprecated in Mac OS X 10.12.1
2948 */
2949#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2950 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2951#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
2952 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
2953#else
2954 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
2955#endif
2956
2957/*
2958 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
2959 *
2960 * Used on declarations introduced in Mac OS X 10.2,
2961 * but later deprecated in Mac OS X 10.12.1
2962 */
2963#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2964 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2965#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
2966 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
2967#else
2968 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
2969#endif
2970
2971/*
2972 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
2973 *
2974 * Used on declarations introduced in Mac OS X 10.3,
2975 * but later deprecated in Mac OS X 10.12.1
2976 */
2977#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2978 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2979#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
2980 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
2981#else
2982 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
2983#endif
2984
2985/*
2986 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
2987 *
2988 * Used on declarations introduced in Mac OS X 10.4,
2989 * but later deprecated in Mac OS X 10.12.1
2990 */
2991#if __AVAILABILITY_MACROS_USES_AVAILABILITY
2992 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
2993#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
2994 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
2995#else
2996 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
2997#endif
2998
2999/*
3000 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3001 *
3002 * Used on declarations introduced in Mac OS X 10.5,
3003 * but later deprecated in Mac OS X 10.12.1
3004 */
3005#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3006 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3007#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3008 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3009#else
3010 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
3011#endif
3012
3013/*
3014 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3015 *
3016 * Used on declarations introduced in Mac OS X 10.6,
3017 * but later deprecated in Mac OS X 10.12.1
3018 */
3019#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3020 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3021#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3022 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3023#else
3024 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
3025#endif
3026
3027/*
3028 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3029 *
3030 * Used on declarations introduced in Mac OS X 10.7,
3031 * but later deprecated in Mac OS X 10.12.1
3032 */
3033#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3034 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3035#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3036 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3037#else
3038 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
3039#endif
3040
3041/*
3042 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3043 *
3044 * Used on declarations introduced in Mac OS X 10.8,
3045 * but later deprecated in Mac OS X 10.12.1
3046 */
3047#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3048 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3049#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3050 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3051#else
3052 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
3053#endif
3054
3055/*
3056 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3057 *
3058 * Used on declarations introduced in Mac OS X 10.9,
3059 * but later deprecated in Mac OS X 10.12.1
3060 */
3061#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3062 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3063#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3064 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3065#else
3066 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
3067#endif
3068
3069/*
3070 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3071 *
3072 * Used on declarations introduced in Mac OS X 10.10,
3073 * but later deprecated in Mac OS X 10.12.1
3074 */
3075#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3076 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3077#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3078 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3079#else
3080 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
3081#endif
3082
3083/*
3084 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3085 *
3086 * Used on declarations introduced in Mac OS X 10.10.2,
3087 * but later deprecated in Mac OS X 10.12.1
3088 */
3089#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3090 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3091#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3092 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3093#else
3094 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
3095#endif
3096
3097/*
3098 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3099 *
3100 * Used on declarations introduced in Mac OS X 10.10.3,
3101 * but later deprecated in Mac OS X 10.12.1
3102 */
3103#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3104 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3105#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3106 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3107#else
3108 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
3109#endif
3110
3111/*
3112 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3113 *
3114 * Used on declarations introduced in Mac OS X 10.11,
3115 * but later deprecated in Mac OS X 10.12.1
3116 */
3117#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3118 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3119#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3120 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3121#else
3122 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
3123#endif
3124
3125/*
3126 * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3127 *
3128 * Used on declarations introduced in Mac OS X 10.11.2,
3129 * but later deprecated in Mac OS X 10.12.1
3130 */
3131#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3132 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3133#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3134 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3135#else
3136 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
3137#endif
3138
3139/*
3140 * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3141 *
3142 * Used on declarations introduced in Mac OS X 10.11.3,
3143 * but later deprecated in Mac OS X 10.12.1
3144 */
3145#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3146 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3147#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3148 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3149#else
3150 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER
3151#endif
3152
3153/*
3154 * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3155 *
3156 * Used on declarations introduced in Mac OS X 10.11.4,
3157 * but later deprecated in Mac OS X 10.12.1
3158 */
3159#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3160 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3161#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3162 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3163#else
3164 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER
3165#endif
3166
3167/*
3168 * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1
3169 *
3170 * Used on declarations introduced in Mac OS X 10.12,
3171 * but later deprecated in Mac OS X 10.12.1
3172 */
3173#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3174 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3175#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1
3176 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE
3177#else
3178 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
3179#endif
3180
3181/*
3182 * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER
3183 *
3184 * Used on declarations introduced in Mac OS X 10.12.2
3185 */
3186#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3187 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_2, __IPHONE_COMPAT_VERSION)
3188#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2
3189 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER UNAVAILABLE_ATTRIBUTE
3190#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_2
3191 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER WEAK_IMPORT_ATTRIBUTE
3192#else
3193 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER
3194#endif
3195
3196/*
3197 * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED
3198 *
3199 * Used on declarations introduced in Mac OS X 10.12.2,
3200 * and deprecated in Mac OS X 10.12.2
3201 */
3202#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3203 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3204#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3205 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
3206#else
3207 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER
3208#endif
3209
3210/*
3211 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3212 *
3213 * Used on declarations introduced in Mac OS X 10.0,
3214 * but later deprecated in Mac OS X 10.12.2
3215 */
3216#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3217 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3218#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3219 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3220#else
3221 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
3222#endif
3223
3224/*
3225 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3226 *
3227 * Used on declarations introduced in Mac OS X 10.1,
3228 * but later deprecated in Mac OS X 10.12.2
3229 */
3230#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3231 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3232#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3233 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3234#else
3235 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
3236#endif
3237
3238/*
3239 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3240 *
3241 * Used on declarations introduced in Mac OS X 10.2,
3242 * but later deprecated in Mac OS X 10.12.2
3243 */
3244#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3245 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3246#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3247 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3248#else
3249 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
3250#endif
3251
3252/*
3253 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3254 *
3255 * Used on declarations introduced in Mac OS X 10.3,
3256 * but later deprecated in Mac OS X 10.12.2
3257 */
3258#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3259 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3260#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3261 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3262#else
3263 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
3264#endif
3265
3266/*
3267 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3268 *
3269 * Used on declarations introduced in Mac OS X 10.4,
3270 * but later deprecated in Mac OS X 10.12.2
3271 */
3272#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3273 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3274#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3275 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3276#else
3277 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
3278#endif
3279
3280/*
3281 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3282 *
3283 * Used on declarations introduced in Mac OS X 10.5,
3284 * but later deprecated in Mac OS X 10.12.2
3285 */
3286#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3287 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3288#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3289 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3290#else
3291 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
3292#endif
3293
3294/*
3295 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3296 *
3297 * Used on declarations introduced in Mac OS X 10.6,
3298 * but later deprecated in Mac OS X 10.12.2
3299 */
3300#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3301 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3302#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3303 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3304#else
3305 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
3306#endif
3307
3308/*
3309 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3310 *
3311 * Used on declarations introduced in Mac OS X 10.7,
3312 * but later deprecated in Mac OS X 10.12.2
3313 */
3314#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3315 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3316#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3317 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3318#else
3319 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
3320#endif
3321
3322/*
3323 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3324 *
3325 * Used on declarations introduced in Mac OS X 10.8,
3326 * but later deprecated in Mac OS X 10.12.2
3327 */
3328#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3329 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3330#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3331 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3332#else
3333 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
3334#endif
3335
3336/*
3337 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3338 *
3339 * Used on declarations introduced in Mac OS X 10.9,
3340 * but later deprecated in Mac OS X 10.12.2
3341 */
3342#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3343 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3344#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3345 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3346#else
3347 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
3348#endif
3349
3350/*
3351 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3352 *
3353 * Used on declarations introduced in Mac OS X 10.10,
3354 * but later deprecated in Mac OS X 10.12.2
3355 */
3356#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3357 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3358#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3359 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3360#else
3361 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
3362#endif
3363
3364/*
3365 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3366 *
3367 * Used on declarations introduced in Mac OS X 10.10.2,
3368 * but later deprecated in Mac OS X 10.12.2
3369 */
3370#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3371 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3372#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3373 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3374#else
3375 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
3376#endif
3377
3378/*
3379 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3380 *
3381 * Used on declarations introduced in Mac OS X 10.10.3,
3382 * but later deprecated in Mac OS X 10.12.2
3383 */
3384#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3385 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3386#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3387 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3388#else
3389 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
3390#endif
3391
3392/*
3393 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3394 *
3395 * Used on declarations introduced in Mac OS X 10.11,
3396 * but later deprecated in Mac OS X 10.12.2
3397 */
3398#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3399 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3400#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3401 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3402#else
3403 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
3404#endif
3405
3406/*
3407 * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3408 *
3409 * Used on declarations introduced in Mac OS X 10.11.2,
3410 * but later deprecated in Mac OS X 10.12.2
3411 */
3412#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3413 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3414#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3415 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3416#else
3417 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
3418#endif
3419
3420/*
3421 * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3422 *
3423 * Used on declarations introduced in Mac OS X 10.11.3,
3424 * but later deprecated in Mac OS X 10.12.2
3425 */
3426#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3427 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3428#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3429 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3430#else
3431 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER
3432#endif
3433
3434/*
3435 * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3436 *
3437 * Used on declarations introduced in Mac OS X 10.11.4,
3438 * but later deprecated in Mac OS X 10.12.2
3439 */
3440#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3441 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3442#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3443 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3444#else
3445 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER
3446#endif
3447
3448/*
3449 * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3450 *
3451 * Used on declarations introduced in Mac OS X 10.12,
3452 * but later deprecated in Mac OS X 10.12.2
3453 */
3454#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3455 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3456#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3457 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3458#else
3459 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
3460#endif
3461
3462/*
3463 * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2
3464 *
3465 * Used on declarations introduced in Mac OS X 10.12.1,
3466 * but later deprecated in Mac OS X 10.12.2
3467 */
3468#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3469 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3470#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2
3471 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE
3472#else
3473 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER
3474#endif
3475
3476/*
3477 * AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER
3478 *
3479 * Used on declarations introduced in Mac OS X 10.12.4
3480 */
3481#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3482 #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_4, __IPHONE_COMPAT_VERSION)
3483#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_4
3484 #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER UNAVAILABLE_ATTRIBUTE
3485#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_4
3486 #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER WEAK_IMPORT_ATTRIBUTE
3487#else
3488 #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER
3489#endif
3490
3491/*
3492 * AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED
3493 *
3494 * Used on declarations introduced in Mac OS X 10.12.4,
3495 * and deprecated in Mac OS X 10.12.4
3496 */
3497#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3498 #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3499#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3500 #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
3501#else
3502 #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER
3503#endif
3504
3505/*
3506 * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3507 *
3508 * Used on declarations introduced in Mac OS X 10.0,
3509 * but later deprecated in Mac OS X 10.12.4
3510 */
3511#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3512 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3513#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3514 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3515#else
3516 #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
3517#endif
3518
3519/*
3520 * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3521 *
3522 * Used on declarations introduced in Mac OS X 10.1,
3523 * but later deprecated in Mac OS X 10.12.4
3524 */
3525#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3526 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3527#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3528 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3529#else
3530 #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
3531#endif
3532
3533/*
3534 * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3535 *
3536 * Used on declarations introduced in Mac OS X 10.2,
3537 * but later deprecated in Mac OS X 10.12.4
3538 */
3539#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3540 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3541#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3542 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3543#else
3544 #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
3545#endif
3546
3547/*
3548 * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3549 *
3550 * Used on declarations introduced in Mac OS X 10.3,
3551 * but later deprecated in Mac OS X 10.12.4
3552 */
3553#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3554 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3555#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3556 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3557#else
3558 #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
3559#endif
3560
3561/*
3562 * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3563 *
3564 * Used on declarations introduced in Mac OS X 10.4,
3565 * but later deprecated in Mac OS X 10.12.4
3566 */
3567#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3568 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3569#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3570 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3571#else
3572 #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
3573#endif
3574
3575/*
3576 * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3577 *
3578 * Used on declarations introduced in Mac OS X 10.5,
3579 * but later deprecated in Mac OS X 10.12.4
3580 */
3581#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3582 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3583#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3584 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3585#else
3586 #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
3587#endif
3588
3589/*
3590 * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3591 *
3592 * Used on declarations introduced in Mac OS X 10.6,
3593 * but later deprecated in Mac OS X 10.12.4
3594 */
3595#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3596 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3597#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3598 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3599#else
3600 #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
3601#endif
3602
3603/*
3604 * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3605 *
3606 * Used on declarations introduced in Mac OS X 10.7,
3607 * but later deprecated in Mac OS X 10.12.4
3608 */
3609#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3610 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3611#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3612 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3613#else
3614 #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
3615#endif
3616
3617/*
3618 * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3619 *
3620 * Used on declarations introduced in Mac OS X 10.8,
3621 * but later deprecated in Mac OS X 10.12.4
3622 */
3623#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3624 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3625#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3626 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3627#else
3628 #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
3629#endif
3630
3631/*
3632 * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3633 *
3634 * Used on declarations introduced in Mac OS X 10.9,
3635 * but later deprecated in Mac OS X 10.12.4
3636 */
3637#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3638 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3639#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3640 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3641#else
3642 #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
3643#endif
3644
3645/*
3646 * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3647 *
3648 * Used on declarations introduced in Mac OS X 10.10,
3649 * but later deprecated in Mac OS X 10.12.4
3650 */
3651#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3652 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3653#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3654 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3655#else
3656 #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
3657#endif
3658
3659/*
3660 * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3661 *
3662 * Used on declarations introduced in Mac OS X 10.10.2,
3663 * but later deprecated in Mac OS X 10.12.4
3664 */
3665#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3666 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3667#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3668 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3669#else
3670 #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER
3671#endif
3672
3673/*
3674 * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3675 *
3676 * Used on declarations introduced in Mac OS X 10.10.3,
3677 * but later deprecated in Mac OS X 10.12.4
3678 */
3679#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3680 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3681#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3682 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3683#else
3684 #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER
3685#endif
3686
3687/*
3688 * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3689 *
3690 * Used on declarations introduced in Mac OS X 10.11,
3691 * but later deprecated in Mac OS X 10.12.4
3692 */
3693#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3694 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3695#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3696 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3697#else
3698 #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER
3699#endif
3700
3701/*
3702 * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3703 *
3704 * Used on declarations introduced in Mac OS X 10.11.2,
3705 * but later deprecated in Mac OS X 10.12.4
3706 */
3707#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3708 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3709#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3710 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3711#else
3712 #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER
3713#endif
3714
3715/*
3716 * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3717 *
3718 * Used on declarations introduced in Mac OS X 10.11.3,
3719 * but later deprecated in Mac OS X 10.12.4
3720 */
3721#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3722 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3723#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3724 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3725#else
3726 #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER
3727#endif
3728
3729/*
3730 * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3731 *
3732 * Used on declarations introduced in Mac OS X 10.11.4,
3733 * but later deprecated in Mac OS X 10.12.4
3734 */
3735#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3736 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3737#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3738 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3739#else
3740 #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER
3741#endif
3742
3743/*
3744 * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3745 *
3746 * Used on declarations introduced in Mac OS X 10.12,
3747 * but later deprecated in Mac OS X 10.12.4
3748 */
3749#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3750 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3751#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3752 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3753#else
3754 #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
3755#endif
3756
3757/*
3758 * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3759 *
3760 * Used on declarations introduced in Mac OS X 10.12.1,
3761 * but later deprecated in Mac OS X 10.12.4
3762 */
3763#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3764 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3765#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3766 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3767#else
3768 #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER
3769#endif
3770
3771/*
3772 * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4
3773 *
3774 * Used on declarations introduced in Mac OS X 10.12.2,
3775 * but later deprecated in Mac OS X 10.12.4
3776 */
3777#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3778 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3779#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4
3780 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE
3781#else
3782 #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER
3783#endif
3784
3785/*
3786 * AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
3787 *
3788 * Used on declarations introduced in Mac OS X 10.13
3789 */
3790#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3791 #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_13, __IPHONE_COMPAT_VERSION)
3792#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
3793 #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER UNAVAILABLE_ATTRIBUTE
3794#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13
3795 #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER WEAK_IMPORT_ATTRIBUTE
3796#else
3797 #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
3798#endif
3799
3800/*
3801 * AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER
3802 *
3803 * Used on declarations introduced in Mac OS X 10.14
3804 */
3805#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3806 #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_14, __IPHONE_COMPAT_VERSION)
3807#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_14
3808 #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER UNAVAILABLE_ATTRIBUTE
3809#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
3810 #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER WEAK_IMPORT_ATTRIBUTE
3811#else
3812 #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER
3813#endif
3814
3815/*
3816 * AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
3817 *
3818 * Used on declarations introduced in Mac OS X 10.15
3819 */
3820#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3821 #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_15, __IPHONE_COMPAT_VERSION)
3822#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_15
3823 #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER UNAVAILABLE_ATTRIBUTE
3824#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
3825 #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER WEAK_IMPORT_ATTRIBUTE
3826#else
3827 #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
3828#endif
3829
3830/*
3831 * DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER
3832 *
3833 * Used on types deprecated in Mac OS X 10.1
3834 */
3835#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3836 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3837#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1
3838 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER DEPRECATED_ATTRIBUTE
3839#else
3840 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER
3841#endif
3842
3843/*
3844 * DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER
3845 *
3846 * Used on types deprecated in Mac OS X 10.2
3847 */
3848#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3849 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3850#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
3851 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER DEPRECATED_ATTRIBUTE
3852#else
3853 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER
3854#endif
3855
3856/*
3857 * DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER
3858 *
3859 * Used on types deprecated in Mac OS X 10.3
3860 */
3861#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3862 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3863#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
3864 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER DEPRECATED_ATTRIBUTE
3865#else
3866 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER
3867#endif
3868
3869/*
3870 * DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER
3871 *
3872 * Used on types deprecated in Mac OS X 10.4
3873 */
3874#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3875 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3876#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
3877 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER DEPRECATED_ATTRIBUTE
3878#else
3879 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER
3880#endif
3881
3882
3883/*
3884 * DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
3885 *
3886 * Used on types deprecated in Mac OS X 10.5
3887 */
3888#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3889 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3890#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
3891 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER DEPRECATED_ATTRIBUTE
3892#else
3893 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
3894#endif
3895
3896/*
3897 * DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER
3898 *
3899 * Used on types deprecated in Mac OS X 10.6
3900 */
3901#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3902 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3903#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
3904 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER DEPRECATED_ATTRIBUTE
3905#else
3906 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER
3907#endif
3908
3909/*
3910 * DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
3911 *
3912 * Used on types deprecated in Mac OS X 10.7
3913 */
3914#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3915 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3916#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
3917 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER DEPRECATED_ATTRIBUTE
3918#else
3919 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
3920#endif
3921
3922/*
3923 * DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER
3924 *
3925 * Used on types deprecated in Mac OS X 10.8
3926 */
3927#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3928 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3929#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
3930 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER DEPRECATED_ATTRIBUTE
3931#else
3932 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER
3933#endif
3934
3935/*
3936 * DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER
3937 *
3938 * Used on types deprecated in Mac OS X 10.9
3939 */
3940#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3941 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3942#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
3943 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER DEPRECATED_ATTRIBUTE
3944#else
3945 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER
3946#endif
3947
3948/*
3949 * DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER
3950 *
3951 * Used on types deprecated in Mac OS X 10.10
3952 */
3953#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3954 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3955#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
3956 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER DEPRECATED_ATTRIBUTE
3957#else
3958 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER
3959#endif
3960
3961/*
3962 * DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER
3963 *
3964 * Used on types deprecated in Mac OS X 10.11
3965 */
3966#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3967 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3968#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
3969 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER DEPRECATED_ATTRIBUTE
3970#else
3971 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER
3972#endif
3973
3974/*
3975 * DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER
3976 *
3977 * Used on types deprecated in Mac OS X 10.12
3978 */
3979#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3980 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3981#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
3982 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER DEPRECATED_ATTRIBUTE
3983#else
3984 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER
3985#endif
3986
3987/*
3988 * DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER
3989 *
3990 * Used on types deprecated in Mac OS X 10.13
3991 */
3992#if __AVAILABILITY_MACROS_USES_AVAILABILITY
3993 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_13, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
3994#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
3995 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER DEPRECATED_ATTRIBUTE
3996#else
3997 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER
3998#endif
3999
4000/*
4001 * DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER
4002 *
4003 * Used on types deprecated in Mac OS X 10.14.4
4004 */
4005#if __AVAILABILITY_MACROS_USES_AVAILABILITY
4006 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_14_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION)
4007#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_14_4
4008 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER DEPRECATED_ATTRIBUTE
4009#else
4010 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER
4011#endif
4012
4013#endif /* __AVAILABILITYMACROS__ */
4014
4015
lib/libc/include/x86_64-macos-gnu/AvailabilityVersions.h created+208
......@@ -0,0 +1,208 @@
1/*
2 * Copyright (c) 2019 by Apple Inc.. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef __AVAILABILITY_VERSIONS__
25#define __AVAILABILITY_VERSIONS__
26
27#define __MAC_10_0 1000
28#define __MAC_10_1 1010
29#define __MAC_10_2 1020
30#define __MAC_10_3 1030
31#define __MAC_10_4 1040
32#define __MAC_10_5 1050
33#define __MAC_10_6 1060
34#define __MAC_10_7 1070
35#define __MAC_10_8 1080
36#define __MAC_10_9 1090
37#define __MAC_10_10 101000
38#define __MAC_10_10_2 101002
39#define __MAC_10_10_3 101003
40#define __MAC_10_11 101100
41#define __MAC_10_11_2 101102
42#define __MAC_10_11_3 101103
43#define __MAC_10_11_4 101104
44#define __MAC_10_12 101200
45#define __MAC_10_12_1 101201
46#define __MAC_10_12_2 101202
47#define __MAC_10_12_4 101204
48#define __MAC_10_13 101300
49#define __MAC_10_13_1 101301
50#define __MAC_10_13_2 101302
51#define __MAC_10_13_4 101304
52#define __MAC_10_14 101400
53#define __MAC_10_14_1 101401
54#define __MAC_10_14_4 101404
55#define __MAC_10_14_6 101406
56#define __MAC_10_15 101500
57#define __MAC_10_15_1 101501
58#define __MAC_10_15_4 101504
59#define __MAC_10_16 101600
60#define __MAC_11_0 110000
61/* __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
62
63#define __IPHONE_2_0 20000
64#define __IPHONE_2_1 20100
65#define __IPHONE_2_2 20200
66#define __IPHONE_3_0 30000
67#define __IPHONE_3_1 30100
68#define __IPHONE_3_2 30200
69#define __IPHONE_4_0 40000
70#define __IPHONE_4_1 40100
71#define __IPHONE_4_2 40200
72#define __IPHONE_4_3 40300
73#define __IPHONE_5_0 50000
74#define __IPHONE_5_1 50100
75#define __IPHONE_6_0 60000
76#define __IPHONE_6_1 60100
77#define __IPHONE_7_0 70000
78#define __IPHONE_7_1 70100
79#define __IPHONE_8_0 80000
80#define __IPHONE_8_1 80100
81#define __IPHONE_8_2 80200
82#define __IPHONE_8_3 80300
83#define __IPHONE_8_4 80400
84#define __IPHONE_9_0 90000
85#define __IPHONE_9_1 90100
86#define __IPHONE_9_2 90200
87#define __IPHONE_9_3 90300
88#define __IPHONE_10_0 100000
89#define __IPHONE_10_1 100100
90#define __IPHONE_10_2 100200
91#define __IPHONE_10_3 100300
92#define __IPHONE_11_0 110000
93#define __IPHONE_11_1 110100
94#define __IPHONE_11_2 110200
95#define __IPHONE_11_3 110300
96#define __IPHONE_11_4 110400
97#define __IPHONE_12_0 120000
98#define __IPHONE_12_1 120100
99#define __IPHONE_12_2 120200
100#define __IPHONE_12_3 120300
101#define __IPHONE_12_4 120400
102#define __IPHONE_13_0 130000
103#define __IPHONE_13_1 130100
104#define __IPHONE_13_2 130200
105#define __IPHONE_13_3 130300
106#define __IPHONE_13_4 130400
107#define __IPHONE_13_5 130500
108#define __IPHONE_13_6 130600
109#define __IPHONE_13_7 130700
110#define __IPHONE_14_0 140000
111#define __IPHONE_14_1 140100
112#define __IPHONE_14_2 140200
113/* __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
114
115#define __TVOS_9_0 90000
116#define __TVOS_9_1 90100
117#define __TVOS_9_2 90200
118#define __TVOS_10_0 100000
119#define __TVOS_10_0_1 100001
120#define __TVOS_10_1 100100
121#define __TVOS_10_2 100200
122#define __TVOS_11_0 110000
123#define __TVOS_11_1 110100
124#define __TVOS_11_2 110200
125#define __TVOS_11_3 110300
126#define __TVOS_11_4 110400
127#define __TVOS_12_0 120000
128#define __TVOS_12_1 120100
129#define __TVOS_12_2 120200
130#define __TVOS_12_3 120300
131#define __TVOS_12_4 120400
132#define __TVOS_13_0 130000
133#define __TVOS_13_2 130200
134#define __TVOS_13_3 130300
135#define __TVOS_13_4 130400
136#define __TVOS_14_0 140000
137#define __TVOS_14_1 140100
138#define __TVOS_14_2 140200
139
140#define __WATCHOS_1_0 10000
141#define __WATCHOS_2_0 20000
142#define __WATCHOS_2_1 20100
143#define __WATCHOS_2_2 20200
144#define __WATCHOS_3_0 30000
145#define __WATCHOS_3_1 30100
146#define __WATCHOS_3_1_1 30101
147#define __WATCHOS_3_2 30200
148#define __WATCHOS_4_0 40000
149#define __WATCHOS_4_1 40100
150#define __WATCHOS_4_2 40200
151#define __WATCHOS_4_3 40300
152#define __WATCHOS_5_0 50000
153#define __WATCHOS_5_1 50100
154#define __WATCHOS_5_2 50200
155#define __WATCHOS_5_3 50300
156#define __WATCHOS_6_0 60000
157#define __WATCHOS_6_1 60100
158#define __WATCHOS_6_2 60200
159#define __WATCHOS_7_0 70000
160#define __WATCHOS_7_1 70100
161
162/*
163 * Set up standard Mac OS X versions
164 */
165
166#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
167
168#define MAC_OS_X_VERSION_10_0 1000
169#define MAC_OS_X_VERSION_10_1 1010
170#define MAC_OS_X_VERSION_10_2 1020
171#define MAC_OS_X_VERSION_10_3 1030
172#define MAC_OS_X_VERSION_10_4 1040
173#define MAC_OS_X_VERSION_10_5 1050
174#define MAC_OS_X_VERSION_10_6 1060
175#define MAC_OS_X_VERSION_10_7 1070
176#define MAC_OS_X_VERSION_10_8 1080
177#define MAC_OS_X_VERSION_10_9 1090
178#define MAC_OS_X_VERSION_10_10 101000
179#define MAC_OS_X_VERSION_10_10_2 101002
180#define MAC_OS_X_VERSION_10_10_3 101003
181#define MAC_OS_X_VERSION_10_11 101100
182#define MAC_OS_X_VERSION_10_11_2 101102
183#define MAC_OS_X_VERSION_10_11_3 101103
184#define MAC_OS_X_VERSION_10_11_4 101104
185#define MAC_OS_X_VERSION_10_12 101200
186#define MAC_OS_X_VERSION_10_12_1 101201
187#define MAC_OS_X_VERSION_10_12_2 101202
188#define MAC_OS_X_VERSION_10_12_4 101204
189#define MAC_OS_X_VERSION_10_13 101300
190#define MAC_OS_X_VERSION_10_13_1 101301
191#define MAC_OS_X_VERSION_10_13_2 101302
192#define MAC_OS_X_VERSION_10_13_4 101304
193#define MAC_OS_X_VERSION_10_14 101400
194#define MAC_OS_X_VERSION_10_14_1 101401
195#define MAC_OS_X_VERSION_10_14_4 101404
196#define MAC_OS_X_VERSION_10_14_6 101406
197#define MAC_OS_X_VERSION_10_15 101500
198#define MAC_OS_X_VERSION_10_15_1 101501
199#define MAC_OS_X_VERSION_10_16 101600
200#define MAC_OS_VERSION_11_0 110000
201
202#endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */
203
204#define __DRIVERKIT_19_0 190000
205#define __DRIVERKIT_20_0 200000
206
207#endif /* __AVAILABILITY_VERSIONS__ */
208
lib/libc/include/x86_64-macos-gnu/ConditionalMacros.h created+619
......@@ -0,0 +1,619 @@
1/*
2 * Copyright (c) 1993-2011 by Apple Inc.. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 File: ConditionalMacros.h
26
27 Contains: Set up for compiler independent conditionals
28
29 Version: CarbonCore-769~1
30
31 Bugs?: For bug reports, consult the following page on
32 the World Wide Web:
33
34 http://developer.apple.com/bugreporter/
35
36*/
37#ifndef __CONDITIONALMACROS__
38#define __CONDITIONALMACROS__
39
40#include <Availability.h>
41/****************************************************************************************************
42 UNIVERSAL_INTERFACES_VERSION
43
44 0x0400 --> version 4.0 (Mac OS X only)
45 0x0335 --> version 3.4
46 0x0331 --> version 3.3.1
47 0x0330 --> version 3.3
48 0x0320 --> version 3.2
49 0x0310 --> version 3.1
50 0x0301 --> version 3.0.1
51 0x0300 --> version 3.0
52 0x0210 --> version 2.1
53 This conditional did not exist prior to version 2.1
54****************************************************************************************************/
55#define UNIVERSAL_INTERFACES_VERSION 0x0400
56/****************************************************************************************************
57
58 All TARGET_* condtionals are set up by TargetConditionals.h
59
60****************************************************************************************************/
61#include <TargetConditionals.h>
62
63
64
65
66/****************************************************************************************************
67
68 PRAGMA_*
69 These conditionals specify whether the compiler supports particular #pragma's
70
71 PRAGMA_IMPORT - Compiler supports: #pragma import on/off/reset
72 PRAGMA_ONCE - Compiler supports: #pragma once
73 PRAGMA_STRUCT_ALIGN - Compiler supports: #pragma options align=mac68k/power/reset
74 PRAGMA_STRUCT_PACK - Compiler supports: #pragma pack(n)
75 PRAGMA_STRUCT_PACKPUSH - Compiler supports: #pragma pack(push, n)/pack(pop)
76 PRAGMA_ENUM_PACK - Compiler supports: #pragma options(!pack_enums)
77 PRAGMA_ENUM_ALWAYSINT - Compiler supports: #pragma enumsalwaysint on/off/reset
78 PRAGMA_ENUM_OPTIONS - Compiler supports: #pragma options enum=int/small/reset
79
80
81 FOUR_CHAR_CODE
82 This conditional is deprecated. It was used to work around a bug in one obscure compiler that did not pack multiple characters in single quotes rationally.
83 It was never intended for endian swapping.
84
85 FOUR_CHAR_CODE('abcd') - Convert a four-char-code to the correct 32-bit value
86
87
88 TYPE_*
89 These conditionals specify whether the compiler supports particular types.
90
91 TYPE_LONGLONG - Compiler supports "long long" 64-bit integers
92 TYPE_EXTENDED - Compiler supports "extended" 80/96 bit floating point
93 TYPE_LONGDOUBLE_IS_DOUBLE - Compiler implements "long double" same as "double"
94
95
96 FUNCTION_*
97 These conditionals specify whether the compiler supports particular language extensions
98 to function prototypes and definitions.
99
100 FUNCTION_PASCAL - Compiler supports "pascal void Foo()"
101 FUNCTION_DECLSPEC - Compiler supports "__declspec(xxx) void Foo()"
102 FUNCTION_WIN32CC - Compiler supports "void __cdecl Foo()" and "void __stdcall Foo()"
103
104****************************************************************************************************/
105
106#if defined(__GNUC__) && (defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__NEXT_CPP__) || defined(__MACOS_CLASSIC__))
107 /*
108 gcc based compilers used on Mac OS X
109 */
110 #define PRAGMA_IMPORT 0
111 #define PRAGMA_ONCE 0
112
113 #if __GNUC__ >= 4
114 #define PRAGMA_STRUCT_PACK 1
115 #define PRAGMA_STRUCT_PACKPUSH 1
116 #else
117 #define PRAGMA_STRUCT_PACK 0
118 #define PRAGMA_STRUCT_PACKPUSH 0
119 #endif
120
121 #if __LP64__ || __arm64__ || __ARM_ARCH_7K
122 #define PRAGMA_STRUCT_ALIGN 0
123 #else
124 #define PRAGMA_STRUCT_ALIGN 1
125 #endif
126
127 #define PRAGMA_ENUM_PACK 0
128 #define PRAGMA_ENUM_ALWAYSINT 0
129 #define PRAGMA_ENUM_OPTIONS 0
130 #define FOUR_CHAR_CODE(x) (x)
131
132 #define TYPE_EXTENDED 0
133
134 #ifdef __ppc__
135 #ifdef __LONG_DOUBLE_128__
136 #define TYPE_LONGDOUBLE_IS_DOUBLE 0
137 #else
138 #define TYPE_LONGDOUBLE_IS_DOUBLE 1
139 #endif
140 #else
141 #define TYPE_LONGDOUBLE_IS_DOUBLE 0
142 #endif
143
144 #define TYPE_LONGLONG 1
145
146 #define FUNCTION_PASCAL 0
147 #define FUNCTION_DECLSPEC 0
148 #define FUNCTION_WIN32CC 0
149
150 #ifdef __MACOS_CLASSIC__
151 #ifndef TARGET_API_MAC_CARBON /* gcc cfm cross compiler assumes you're building Carbon code */
152 #define TARGET_API_MAC_CARBON 1
153 #endif
154 #endif
155
156
157
158#elif defined(__MWERKS__)
159 /*
160 CodeWarrior compiler from Metrowerks/Motorola
161 */
162 #define PRAGMA_ONCE 1
163 #define PRAGMA_IMPORT 0
164 #define PRAGMA_STRUCT_ALIGN 1
165 #define PRAGMA_STRUCT_PACK 1
166 #define PRAGMA_STRUCT_PACKPUSH 0
167 #define PRAGMA_ENUM_PACK 0
168 #define PRAGMA_ENUM_ALWAYSINT 1
169 #define PRAGMA_ENUM_OPTIONS 0
170 #if __option(enumsalwaysint) && __option(ANSI_strict)
171 #define FOUR_CHAR_CODE(x) ((long)(x)) /* otherwise compiler will complain about values with high bit set */
172 #else
173 #define FOUR_CHAR_CODE(x) (x)
174 #endif
175 #define FUNCTION_PASCAL 1
176 #define FUNCTION_DECLSPEC 1
177 #define FUNCTION_WIN32CC 0
178
179 #if __option(longlong)
180 #define TYPE_LONGLONG 1
181 #else
182 #define TYPE_LONGLONG 0
183 #endif
184 #define TYPE_EXTENDED 0
185 #define TYPE_LONGDOUBLE_IS_DOUBLE 1
186
187
188
189#else
190 /*
191 Unknown compiler, perhaps set up from the command line
192 */
193 #error unknown compiler
194 #ifndef PRAGMA_IMPORT
195 #define PRAGMA_IMPORT 0
196 #endif
197 #ifndef PRAGMA_STRUCT_ALIGN
198 #define PRAGMA_STRUCT_ALIGN 0
199 #endif
200 #ifndef PRAGMA_ONCE
201 #define PRAGMA_ONCE 0
202 #endif
203 #ifndef PRAGMA_STRUCT_PACK
204 #define PRAGMA_STRUCT_PACK 0
205 #endif
206 #ifndef PRAGMA_STRUCT_PACKPUSH
207 #define PRAGMA_STRUCT_PACKPUSH 0
208 #endif
209 #ifndef PRAGMA_ENUM_PACK
210 #define PRAGMA_ENUM_PACK 0
211 #endif
212 #ifndef PRAGMA_ENUM_ALWAYSINT
213 #define PRAGMA_ENUM_ALWAYSINT 0
214 #endif
215 #ifndef PRAGMA_ENUM_OPTIONS
216 #define PRAGMA_ENUM_OPTIONS 0
217 #endif
218 #ifndef FOUR_CHAR_CODE
219 #define FOUR_CHAR_CODE(x) (x)
220 #endif
221
222 #ifndef TYPE_LONGDOUBLE_IS_DOUBLE
223 #define TYPE_LONGDOUBLE_IS_DOUBLE 1
224 #endif
225 #ifndef TYPE_EXTENDED
226 #define TYPE_EXTENDED 0
227 #endif
228 #ifndef TYPE_LONGLONG
229 #define TYPE_LONGLONG 0
230 #endif
231 #ifndef FUNCTION_PASCAL
232 #define FUNCTION_PASCAL 0
233 #endif
234 #ifndef FUNCTION_DECLSPEC
235 #define FUNCTION_DECLSPEC 0
236 #endif
237 #ifndef FUNCTION_WIN32CC
238 #define FUNCTION_WIN32CC 0
239 #endif
240#endif
241
242
243
244
245/****************************************************************************************************
246
247 Under MacOS, the classic 68k runtime has two calling conventions: pascal or C
248 Under Win32, there are two calling conventions: __cdecl or __stdcall
249 Headers and implementation files can use the following macros to make their
250 source more portable by hiding the calling convention details:
251
252 EXTERN_API*
253 These macros are used to specify the calling convention on a function prototype.
254
255 EXTERN_API - Classic 68k: pascal, Win32: __cdecl
256 EXTERN_API_C - Classic 68k: C, Win32: __cdecl
257 EXTERN_API_STDCALL - Classic 68k: pascal, Win32: __stdcall
258 EXTERN_API_C_STDCALL - Classic 68k: C, Win32: __stdcall
259
260
261 DEFINE_API*
262 These macros are used to specify the calling convention on a function definition.
263
264 DEFINE_API - Classic 68k: pascal, Win32: __cdecl
265 DEFINE_API_C - Classic 68k: C, Win32: __cdecl
266 DEFINE_API_STDCALL - Classic 68k: pascal, Win32: __stdcall
267 DEFINE_API_C_STDCALL - Classic 68k: C, Win32: __stdcall
268
269
270 CALLBACK_API*
271 These macros are used to specify the calling convention of a function pointer.
272
273 CALLBACK_API - Classic 68k: pascal, Win32: __stdcall
274 CALLBACK_API_C - Classic 68k: C, Win32: __stdcall
275 CALLBACK_API_STDCALL - Classic 68k: pascal, Win32: __cdecl
276 CALLBACK_API_C_STDCALL - Classic 68k: C, Win32: __cdecl
277
278****************************************************************************************************/
279
280#if FUNCTION_PASCAL && !FUNCTION_DECLSPEC && !FUNCTION_WIN32CC
281 /* compiler supports pascal keyword only */
282 #define EXTERN_API(_type) extern pascal _type
283 #define EXTERN_API_C(_type) extern _type
284 #define EXTERN_API_STDCALL(_type) extern pascal _type
285 #define EXTERN_API_C_STDCALL(_type) extern _type
286
287 #define DEFINE_API(_type) pascal _type
288 #define DEFINE_API_C(_type) _type
289 #define DEFINE_API_STDCALL(_type) pascal _type
290 #define DEFINE_API_C_STDCALL(_type) _type
291
292 #define CALLBACK_API(_type, _name) pascal _type (*_name)
293 #define CALLBACK_API_C(_type, _name) _type (*_name)
294 #define CALLBACK_API_STDCALL(_type, _name) pascal _type (*_name)
295 #define CALLBACK_API_C_STDCALL(_type, _name) _type (*_name)
296
297#elif FUNCTION_PASCAL && FUNCTION_DECLSPEC && !FUNCTION_WIN32CC
298 /* compiler supports pascal and __declspec() */
299 #define EXTERN_API(_type) extern pascal __declspec(dllimport) _type
300 #define EXTERN_API_C(_type) extern __declspec(dllimport) _type
301 #define EXTERN_API_STDCALL(_type) extern pascal __declspec(dllimport) _type
302 #define EXTERN_API_C_STDCALL(_type) extern __declspec(dllimport) _type
303
304 #define DEFINE_API(_type) pascal __declspec(dllexport) _type
305 #define DEFINE_API_C(_type) __declspec(dllexport) _type
306 #define DEFINE_API_STDCALL(_type) pascal __declspec(dllexport) _type
307 #define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type
308
309 #define CALLBACK_API(_type, _name) pascal _type (*_name)
310 #define CALLBACK_API_C(_type, _name) _type (*_name)
311 #define CALLBACK_API_STDCALL(_type, _name) pascal _type (*_name)
312 #define CALLBACK_API_C_STDCALL(_type, _name) _type (*_name)
313
314#elif !FUNCTION_PASCAL && FUNCTION_DECLSPEC && !FUNCTION_WIN32CC
315 /* compiler supports __declspec() */
316 #define EXTERN_API(_type) extern __declspec(dllimport) _type
317 #define EXTERN_API_C(_type) extern __declspec(dllimport) _type
318 #define EXTERN_API_STDCALL(_type) extern __declspec(dllimport) _type
319 #define EXTERN_API_C_STDCALL(_type) extern __declspec(dllimport) _type
320
321 #define DEFINE_API(_type) __declspec(dllexport) _type
322 #define DEFINE_API_C(_type) __declspec(dllexport) _type
323 #define DEFINE_API_STDCALL(_type) __declspec(dllexport) _type
324 #define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type
325
326 #define CALLBACK_API(_type, _name) _type ( * _name)
327 #define CALLBACK_API_C(_type, _name) _type ( * _name)
328 #define CALLBACK_API_STDCALL(_type, _name) _type ( * _name)
329 #define CALLBACK_API_C_STDCALL(_type, _name) _type ( * _name)
330
331#elif !FUNCTION_PASCAL && FUNCTION_DECLSPEC && FUNCTION_WIN32CC
332 /* compiler supports __declspec() and __cdecl */
333 #define EXTERN_API(_type) __declspec(dllimport) _type __cdecl
334 #define EXTERN_API_C(_type) __declspec(dllimport) _type __cdecl
335 #define EXTERN_API_STDCALL(_type) __declspec(dllimport) _type __stdcall
336 #define EXTERN_API_C_STDCALL(_type) __declspec(dllimport) _type __stdcall
337
338 #define DEFINE_API(_type) __declspec(dllexport) _type __cdecl
339 #define DEFINE_API_C(_type) __declspec(dllexport) _type __cdecl
340 #define DEFINE_API_STDCALL(_type) __declspec(dllexport) _type __stdcall
341 #define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type __stdcall
342
343 #define CALLBACK_API(_type, _name) _type (__cdecl * _name)
344 #define CALLBACK_API_C(_type, _name) _type (__cdecl * _name)
345 #define CALLBACK_API_STDCALL(_type, _name) _type (__stdcall * _name)
346 #define CALLBACK_API_C_STDCALL(_type, _name) _type (__stdcall * _name)
347
348#elif !FUNCTION_PASCAL && !FUNCTION_DECLSPEC && FUNCTION_WIN32CC
349 /* compiler supports __cdecl */
350 #define EXTERN_API(_type) _type __cdecl
351 #define EXTERN_API_C(_type) _type __cdecl
352 #define EXTERN_API_STDCALL(_type) _type __stdcall
353 #define EXTERN_API_C_STDCALL(_type) _type __stdcall
354
355 #define DEFINE_API(_type) _type __cdecl
356 #define DEFINE_API_C(_type) _type __cdecl
357 #define DEFINE_API_STDCALL(_type) _type __stdcall
358 #define DEFINE_API_C_STDCALL(_type) _type __stdcall
359
360 #define CALLBACK_API(_type, _name) _type (__cdecl * _name)
361 #define CALLBACK_API_C(_type, _name) _type (__cdecl * _name)
362 #define CALLBACK_API_STDCALL(_type, _name) _type (__stdcall * _name)
363 #define CALLBACK_API_C_STDCALL(_type, _name) _type (__stdcall * _name)
364
365#else
366 /* compiler supports no extensions */
367 #define EXTERN_API(_type) extern _type
368 #define EXTERN_API_C(_type) extern _type
369 #define EXTERN_API_STDCALL(_type) extern _type
370 #define EXTERN_API_C_STDCALL(_type) extern _type
371
372 #define DEFINE_API(_type) _type
373 #define DEFINE_API_C(_type) _type
374 #define DEFINE_API_STDCALL(_type) _type
375 #define DEFINE_API_C_STDCALL(_type) _type
376
377 #define CALLBACK_API(_type, _name) _type ( * _name)
378 #define CALLBACK_API_C(_type, _name) _type ( * _name)
379 #define CALLBACK_API_STDCALL(_type, _name) _type ( * _name)
380 #define CALLBACK_API_C_STDCALL(_type, _name) _type ( * _name)
381 #undef pascal
382 #define pascal
383#endif
384
385/****************************************************************************************************
386
387 Set up TARGET_API_*_* values
388
389****************************************************************************************************/
390#if !defined(TARGET_API_MAC_OS8) && !defined(TARGET_API_MAC_OSX) && !defined(TARGET_API_MAC_CARBON)
391/* No TARGET_API_MAC_* predefined on command line */
392#if TARGET_RT_MAC_MACHO
393/* Looks like MachO style compiler */
394#define TARGET_API_MAC_OS8 0
395#define TARGET_API_MAC_CARBON 1
396#define TARGET_API_MAC_OSX 1
397#elif defined(TARGET_CARBON) && TARGET_CARBON
398/* grandfather in use of TARGET_CARBON */
399#define TARGET_API_MAC_OS8 0
400#define TARGET_API_MAC_CARBON 1
401#define TARGET_API_MAC_OSX 0
402#elif TARGET_CPU_PPC && TARGET_RT_MAC_CFM
403/* Looks like CFM style PPC compiler */
404#define TARGET_API_MAC_OS8 1
405#define TARGET_API_MAC_CARBON 0
406#define TARGET_API_MAC_OSX 0
407#else
408/* 68k or some other compiler */
409#define TARGET_API_MAC_OS8 1
410#define TARGET_API_MAC_CARBON 0
411#define TARGET_API_MAC_OSX 0
412#endif /* */
413
414#else
415#ifndef TARGET_API_MAC_OS8
416#define TARGET_API_MAC_OS8 0
417#endif /* !defined(TARGET_API_MAC_OS8) */
418
419#ifndef TARGET_API_MAC_OSX
420#define TARGET_API_MAC_OSX TARGET_RT_MAC_MACHO
421#endif /* !defined(TARGET_API_MAC_OSX) */
422
423#ifndef TARGET_API_MAC_CARBON
424#define TARGET_API_MAC_CARBON TARGET_API_MAC_OSX
425#endif /* !defined(TARGET_API_MAC_CARBON) */
426
427#endif /* !defined(TARGET_API_MAC_OS8) && !defined(TARGET_API_MAC_OSX) && !defined(TARGET_API_MAC_CARBON) */
428
429#if TARGET_API_MAC_OS8 && TARGET_API_MAC_OSX
430#error TARGET_API_MAC_OS8 and TARGET_API_MAC_OSX are mutually exclusive
431#endif /* TARGET_API_MAC_OS8 && TARGET_API_MAC_OSX */
432
433#if !TARGET_API_MAC_OS8 && !TARGET_API_MAC_CARBON && !TARGET_API_MAC_OSX
434#error At least one of TARGET_API_MAC_* must be true
435#endif /* !TARGET_API_MAC_OS8 && !TARGET_API_MAC_CARBON && !TARGET_API_MAC_OSX */
436
437/* Support source code still using TARGET_CARBON */
438#ifndef TARGET_CARBON
439#if TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8
440#define TARGET_CARBON 1
441#else
442#define TARGET_CARBON 0
443#endif /* TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8 */
444
445#endif /* !defined(TARGET_CARBON) */
446
447/****************************************************************************************************
448 Backward compatibility for clients expecting 2.x version on ConditionalMacros.h
449
450 GENERATINGPOWERPC - Compiler is generating PowerPC instructions
451 GENERATING68K - Compiler is generating 68k family instructions
452 GENERATING68881 - Compiler is generating mc68881 floating point instructions
453 GENERATINGCFM - Code being generated assumes CFM calling conventions
454 CFMSYSTEMCALLS - No A-traps. Systems calls are made using CFM and UPP's
455 PRAGMA_ALIGN_SUPPORTED - Compiler supports: #pragma options align=mac68k/power/reset
456 PRAGMA_IMPORT_SUPPORTED - Compiler supports: #pragma import on/off/reset
457 CGLUESUPPORTED - Clients can use all lowercase toolbox functions that take C strings instead of pascal strings
458
459****************************************************************************************************/
460#if !TARGET_API_MAC_CARBON
461#define GENERATINGPOWERPC TARGET_CPU_PPC
462#define GENERATING68K 0
463#define GENERATING68881 TARGET_RT_MAC_68881
464#define GENERATINGCFM TARGET_RT_MAC_CFM
465#define CFMSYSTEMCALLS TARGET_RT_MAC_CFM
466#ifndef CGLUESUPPORTED
467#define CGLUESUPPORTED 0
468#endif /* !defined(CGLUESUPPORTED) */
469
470#ifndef OLDROUTINELOCATIONS
471#define OLDROUTINELOCATIONS 0
472#endif /* !defined(OLDROUTINELOCATIONS) */
473
474#define PRAGMA_ALIGN_SUPPORTED PRAGMA_STRUCT_ALIGN
475#define PRAGMA_IMPORT_SUPPORTED PRAGMA_IMPORT
476#else
477/* Carbon code should not use old conditionals */
478#define PRAGMA_ALIGN_SUPPORTED ..PRAGMA_ALIGN_SUPPORTED_is_obsolete..
479#define GENERATINGPOWERPC ..GENERATINGPOWERPC_is_obsolete..
480#define GENERATING68K ..GENERATING68K_is_obsolete..
481#define GENERATING68881 ..GENERATING68881_is_obsolete..
482#define GENERATINGCFM ..GENERATINGCFM_is_obsolete..
483#define CFMSYSTEMCALLS ..CFMSYSTEMCALLS_is_obsolete..
484#endif /* !TARGET_API_MAC_CARBON */
485
486
487
488/****************************************************************************************************
489
490 OLDROUTINENAMES - "Old" names for Macintosh system calls are allowed in source code.
491 (e.g. DisposPtr instead of DisposePtr). The names of system routine
492 are now more sensitive to change because CFM binds by name. In the
493 past, system routine names were compiled out to just an A-Trap.
494 Macros have been added that each map an old name to its new name.
495 This allows old routine names to be used in existing source files,
496 but the macros only work if OLDROUTINENAMES is true. This support
497 will be removed in the near future. Thus, all source code should
498 be changed to use the new names! You can set OLDROUTINENAMES to false
499 to see if your code has any old names left in it.
500
501****************************************************************************************************/
502#ifndef OLDROUTINENAMES
503#define OLDROUTINENAMES 0
504#endif /* !defined(OLDROUTINENAMES) */
505
506
507
508/****************************************************************************************************
509 The following macros isolate the use of 68K inlines in function prototypes.
510 On the Mac OS under the Classic 68K runtime, function prototypes were followed
511 by a list of 68K opcodes which the compiler inserted in the generated code instead
512 of a JSR. Under Classic 68K on the Mac OS, this macro will put the opcodes
513 in the right syntax. For all other OS's and runtimes the macro suppress the opcodes.
514 Example:
515
516 EXTERN_P void DrawPicture(PicHandle myPicture, const Rect *dstRect)
517 ONEWORDINLINE(0xA8F6);
518
519****************************************************************************************************/
520
521#if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
522 #define ONEWORDINLINE(w1) = w1
523 #define TWOWORDINLINE(w1,w2) = {w1,w2}
524 #define THREEWORDINLINE(w1,w2,w3) = {w1,w2,w3}
525 #define FOURWORDINLINE(w1,w2,w3,w4) = {w1,w2,w3,w4}
526 #define FIVEWORDINLINE(w1,w2,w3,w4,w5) = {w1,w2,w3,w4,w5}
527 #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6) = {w1,w2,w3,w4,w5,w6}
528 #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7) = {w1,w2,w3,w4,w5,w6,w7}
529 #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8) = {w1,w2,w3,w4,w5,w6,w7,w8}
530 #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9) = {w1,w2,w3,w4,w5,w6,w7,w8,w9}
531 #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10) = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10}
532 #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11) = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11}
533 #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12) = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12}
534#else
535 #define ONEWORDINLINE(w1)
536 #define TWOWORDINLINE(w1,w2)
537 #define THREEWORDINLINE(w1,w2,w3)
538 #define FOURWORDINLINE(w1,w2,w3,w4)
539 #define FIVEWORDINLINE(w1,w2,w3,w4,w5)
540 #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)
541 #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)
542 #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)
543 #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)
544 #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)
545 #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)
546 #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)
547#endif
548
549
550/****************************************************************************************************
551
552 TARGET_CARBON - default: false. Switches all of the above as described. Overrides all others
553 - NOTE: If you set TARGET_CARBON to 1, then the other switches will be setup by
554 ConditionalMacros, and should not be set manually.
555
556 If you wish to do development for pre-Carbon Systems, you can set the following:
557
558 OPAQUE_TOOLBOX_STRUCTS - default: false. True for Carbon builds, hides struct fields.
559 OPAQUE_UPP_TYPES - default: false. True for Carbon builds, UPP types are unique and opaque.
560 ACCESSOR_CALLS_ARE_FUNCTIONS - default: false. True for Carbon builds, enables accessor functions.
561 CALL_NOT_IN_CARBON - default: true. False for Carbon builds, hides calls not supported in Carbon.
562
563 Specifically, if you are building a non-Carbon application (one that links against InterfaceLib)
564 but you wish to use some of the accessor functions, you can set ACCESSOR_CALLS_ARE_FUNCTIONS to 1
565 and link with CarbonAccessors.o, which implements just the accessor functions. This will help you
566 preserve source compatibility between your Carbon and non-Carbon application targets.
567
568 MIXEDMODE_CALLS_ARE_FUNCTIONS - deprecated.
569
570****************************************************************************************************/
571#if TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8
572#ifndef OPAQUE_TOOLBOX_STRUCTS
573#define OPAQUE_TOOLBOX_STRUCTS 1
574#endif /* !defined(OPAQUE_TOOLBOX_STRUCTS) */
575
576#ifndef OPAQUE_UPP_TYPES
577#define OPAQUE_UPP_TYPES 1
578#endif /* !defined(OPAQUE_UPP_TYPES) */
579
580#ifndef ACCESSOR_CALLS_ARE_FUNCTIONS
581#define ACCESSOR_CALLS_ARE_FUNCTIONS 1
582#endif /* !defined(ACCESSOR_CALLS_ARE_FUNCTIONS) */
583
584#ifndef CALL_NOT_IN_CARBON
585#define CALL_NOT_IN_CARBON 0
586#endif /* !defined(CALL_NOT_IN_CARBON) */
587
588#ifndef MIXEDMODE_CALLS_ARE_FUNCTIONS
589#define MIXEDMODE_CALLS_ARE_FUNCTIONS 1
590#endif /* !defined(MIXEDMODE_CALLS_ARE_FUNCTIONS) */
591
592#else
593#ifndef OPAQUE_TOOLBOX_STRUCTS
594#define OPAQUE_TOOLBOX_STRUCTS 0
595#endif /* !defined(OPAQUE_TOOLBOX_STRUCTS) */
596
597#ifndef ACCESSOR_CALLS_ARE_FUNCTIONS
598#define ACCESSOR_CALLS_ARE_FUNCTIONS 0
599#endif /* !defined(ACCESSOR_CALLS_ARE_FUNCTIONS) */
600
601/*
602 * It's possible to have ACCESSOR_CALLS_ARE_FUNCTIONS set to true and OPAQUE_TOOLBOX_STRUCTS
603 * set to false, but not the other way around, so make sure the defines are not set this way.
604 */
605#ifndef CALL_NOT_IN_CARBON
606#define CALL_NOT_IN_CARBON 1
607#endif /* !defined(CALL_NOT_IN_CARBON) */
608
609#ifndef MIXEDMODE_CALLS_ARE_FUNCTIONS
610#define MIXEDMODE_CALLS_ARE_FUNCTIONS 0
611#endif /* !defined(MIXEDMODE_CALLS_ARE_FUNCTIONS) */
612
613#endif /* TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8 */
614
615
616
617
618#endif /* __CONDITIONALMACROS__ */
619
lib/libc/include/x86_64-macos-gnu/MacTypes.h created+808
......@@ -0,0 +1,808 @@
1/*
2 * Copyright (c) 1985-2011 by Apple Inc.. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 File: MacTypes.h
26
27 Contains: Basic Macintosh data types.
28
29 Version: CarbonCore-769~1
30
31 Bugs?: For bug reports, consult the following page on
32 the World Wide Web:
33
34 http://developer.apple.com/bugreporter/
35
36*/
37#ifndef __MACTYPES__
38#define __MACTYPES__
39
40#ifndef __CONDITIONALMACROS__
41#include <ConditionalMacros.h>
42#endif
43
44#include <stdbool.h>
45
46#include <sys/types.h>
47
48#include <Availability.h>
49
50#if PRAGMA_ONCE
51#pragma once
52#endif
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#pragma pack(push, 2)
59
60
61/*
62 CarbonCore Deprecation flags.
63
64 Certain Carbon API functions are deprecated in 10.3 and later
65 systems. These will produce a warning when compiling on 10.3.
66
67 Other functions and constants do not produce meaningful
68 results when building Carbon for Mac OS X. For these
69 functions, no-op macros are provided, but only when the
70 ALLOW_OBSOLETE_CARBON flag is defined to be 0: eg
71 -DALLOW_OBSOLETE_CARBON=0.
72*/
73
74#if ! defined(ALLOW_OBSOLETE_CARBON) || ! ALLOW_OBSOLETE_CARBON
75
76#define ALLOW_OBSOLETE_CARBON_MACMEMORY 0
77#define ALLOW_OBSOLETE_CARBON_OSUTILS 0
78
79#else
80
81#define ALLOW_OBSOLETE_CARBON_MACMEMORY 1 /* Removes obsolete constants; turns HLock/HUnlock into no-op macros */
82#define ALLOW_OBSOLETE_CARBON_OSUTILS 1 /* Removes obsolete structures */
83
84#endif
85
86#ifndef NULL
87#define NULL __DARWIN_NULL
88#endif /* ! NULL */
89#ifndef nil
90 #if defined(__has_feature)
91 #if __has_feature(cxx_nullptr)
92 #define nil nullptr
93 #else
94 #define nil __DARWIN_NULL
95 #endif
96 #else
97 #define nil __DARWIN_NULL
98 #endif
99#endif
100
101/********************************************************************************
102
103 Base integer types for all target OS's and CPU's
104
105 UInt8 8-bit unsigned integer
106 SInt8 8-bit signed integer
107 UInt16 16-bit unsigned integer
108 SInt16 16-bit signed integer
109 UInt32 32-bit unsigned integer
110 SInt32 32-bit signed integer
111 UInt64 64-bit unsigned integer
112 SInt64 64-bit signed integer
113
114*********************************************************************************/
115typedef unsigned char UInt8;
116typedef signed char SInt8;
117typedef unsigned short UInt16;
118typedef signed short SInt16;
119
120#if __LP64__
121typedef unsigned int UInt32;
122typedef signed int SInt32;
123#else
124typedef unsigned long UInt32;
125typedef signed long SInt32;
126#endif
127
128/* avoid redeclaration if libkern/OSTypes.h */
129#ifndef _OS_OSTYPES_H
130#if TARGET_RT_BIG_ENDIAN
131struct wide {
132 SInt32 hi;
133 UInt32 lo;
134};
135typedef struct wide wide;
136struct UnsignedWide {
137 UInt32 hi;
138 UInt32 lo;
139};
140typedef struct UnsignedWide UnsignedWide;
141#else
142struct wide {
143 UInt32 lo;
144 SInt32 hi;
145};
146typedef struct wide wide;
147struct UnsignedWide {
148 UInt32 lo;
149 UInt32 hi;
150};
151typedef struct UnsignedWide UnsignedWide;
152#endif /* TARGET_RT_BIG_ENDIAN */
153
154#endif
155
156#if TYPE_LONGLONG
157/*
158 Note: wide and UnsignedWide must always be structs for source code
159 compatibility. On the other hand UInt64 and SInt64 can be
160 either a struct or a long long, depending on the compiler.
161
162 If you use UInt64 and SInt64 you should do all operations on
163 those data types through the functions/macros in Math64.h.
164 This will assure that your code compiles with compilers that
165 support long long and those that don't.
166
167 The MS Visual C/C++ compiler uses __int64 instead of long long.
168*/
169 #if defined(_MSC_VER) && !defined(__MWERKS__) && defined(_M_IX86)
170 typedef signed __int64 SInt64;
171 typedef unsigned __int64 UInt64;
172 #else
173 typedef signed long long SInt64;
174 typedef unsigned long long UInt64;
175 #endif
176#else
177
178
179typedef wide SInt64;
180typedef UnsignedWide UInt64;
181#endif /* TYPE_LONGLONG */
182
183/********************************************************************************
184
185 Base fixed point types
186
187 Fixed 16-bit signed integer plus 16-bit fraction
188 UnsignedFixed 16-bit unsigned integer plus 16-bit fraction
189 Fract 2-bit signed integer plus 30-bit fraction
190 ShortFixed 8-bit signed integer plus 8-bit fraction
191
192*********************************************************************************/
193typedef SInt32 Fixed;
194typedef Fixed * FixedPtr;
195typedef SInt32 Fract;
196typedef Fract * FractPtr;
197typedef UInt32 UnsignedFixed;
198typedef UnsignedFixed * UnsignedFixedPtr;
199typedef short ShortFixed;
200typedef ShortFixed * ShortFixedPtr;
201
202
203/********************************************************************************
204
205 Base floating point types
206
207 Float32 32 bit IEEE float: 1 sign bit, 8 exponent bits, 23 fraction bits
208 Float64 64 bit IEEE float: 1 sign bit, 11 exponent bits, 52 fraction bits
209 Float80 80 bit MacOS float: 1 sign bit, 15 exponent bits, 1 integer bit, 63 fraction bits
210 Float96 96 bit 68881 float: 1 sign bit, 15 exponent bits, 16 pad bits, 1 integer bit, 63 fraction bits
211
212 Note: These are fixed size floating point types, useful when writing a floating
213 point value to disk. If your compiler does not support a particular size
214 float, a struct is used instead.
215 Use one of the NCEG types (e.g. double_t) or an ANSI C type (e.g. double) if
216 you want a floating point representation that is natural for any given
217 compiler, but might be a different size on different compilers.
218
219*********************************************************************************/
220typedef float Float32;
221typedef double Float64;
222struct Float80 {
223 SInt16 exp;
224 UInt16 man[4];
225};
226typedef struct Float80 Float80;
227
228struct Float96 {
229 SInt16 exp[2]; /* the second 16-bits are undefined */
230 UInt16 man[4];
231};
232typedef struct Float96 Float96;
233struct Float32Point {
234 Float32 x;
235 Float32 y;
236};
237typedef struct Float32Point Float32Point;
238
239/********************************************************************************
240
241 MacOS Memory Manager types
242
243 Ptr Pointer to a non-relocatable block
244 Handle Pointer to a master pointer to a relocatable block
245 Size The number of bytes in a block (signed for historical reasons)
246
247*********************************************************************************/
248typedef char * Ptr;
249typedef Ptr * Handle;
250typedef long Size;
251
252/********************************************************************************
253
254 Higher level basic types
255
256 OSErr 16-bit result error code
257 OSStatus 32-bit result error code
258 LogicalAddress Address in the clients virtual address space
259 ConstLogicalAddress Address in the clients virtual address space that will only be read
260 PhysicalAddress Real address as used on the hardware bus
261 BytePtr Pointer to an array of bytes
262 ByteCount The size of an array of bytes
263 ByteOffset An offset into an array of bytes
264 ItemCount 32-bit iteration count
265 OptionBits Standard 32-bit set of bit flags
266 PBVersion ?
267 Duration 32-bit millisecond timer for drivers
268 AbsoluteTime 64-bit clock
269 ScriptCode A particular set of written characters (e.g. Roman vs Cyrillic) and their encoding
270 LangCode A particular language (e.g. English), as represented using a particular ScriptCode
271 RegionCode Designates a language as used in a particular region (e.g. British vs American
272 English) together with other region-dependent characteristics (e.g. date format)
273 FourCharCode A 32-bit value made by packing four 1 byte characters together
274 OSType A FourCharCode used in the OS and file system (e.g. creator)
275 ResType A FourCharCode used to tag resources (e.g. 'DLOG')
276
277*********************************************************************************/
278typedef SInt16 OSErr;
279typedef SInt32 OSStatus;
280typedef void * LogicalAddress;
281typedef const void * ConstLogicalAddress;
282typedef void * PhysicalAddress;
283typedef UInt8 * BytePtr;
284typedef unsigned long ByteCount;
285typedef unsigned long ByteOffset;
286typedef SInt32 Duration;
287typedef UnsignedWide AbsoluteTime;
288typedef UInt32 OptionBits;
289typedef unsigned long ItemCount;
290typedef UInt32 PBVersion;
291typedef SInt16 ScriptCode;
292typedef SInt16 LangCode;
293typedef SInt16 RegionCode;
294typedef UInt32 FourCharCode;
295typedef FourCharCode OSType;
296typedef FourCharCode ResType;
297typedef OSType * OSTypePtr;
298typedef ResType * ResTypePtr;
299/********************************************************************************
300
301 Boolean types and values
302
303 Boolean Mac OS historic type, sizeof(Boolean)==1
304 bool Defined in stdbool.h, ISO C/C++ standard type
305 false Now defined in stdbool.h
306 true Now defined in stdbool.h
307
308*********************************************************************************/
309typedef unsigned char Boolean;
310/********************************************************************************
311
312 Function Pointer Types
313
314 ProcPtr Generic pointer to a function
315 Register68kProcPtr Pointer to a 68K function that expects parameters in registers
316 UniversalProcPtr Pointer to classic 68K code or a RoutineDescriptor
317
318 ProcHandle Pointer to a ProcPtr
319 UniversalProcHandle Pointer to a UniversalProcPtr
320
321*********************************************************************************/
322typedef CALLBACK_API_C( long , ProcPtr )(void);
323typedef CALLBACK_API( void , Register68kProcPtr )(void);
324#if TARGET_RT_MAC_CFM
325/* The RoutineDescriptor structure is defined in MixedMode.h */
326typedef struct RoutineDescriptor *UniversalProcPtr;
327#else
328typedef ProcPtr UniversalProcPtr;
329#endif /* TARGET_RT_MAC_CFM */
330
331typedef ProcPtr * ProcHandle;
332typedef UniversalProcPtr * UniversalProcHandle;
333/********************************************************************************
334
335 RefCon Types
336
337 For access to private data in callbacks, etc.; refcons are generally
338 used as a pointer to something, but in the 32-bit world refcons in
339 different APIs have had various types: pointer, unsigned scalar, and
340 signed scalar. The RefCon types defined here support the current 32-bit
341 usage but provide normalization to pointer types for 64-bit.
342
343 PRefCon is preferred for new APIs; URefCon and SRefCon are primarily
344 for compatibility with existing APIs.
345
346*********************************************************************************/
347typedef void * PRefCon;
348#if __LP64__
349typedef void * URefCon;
350typedef void * SRefCon;
351#else
352typedef UInt32 URefCon;
353typedef SInt32 SRefCon;
354#endif /* __LP64__ */
355
356/********************************************************************************
357
358 Common Constants
359
360 noErr OSErr: function performed properly - no error
361 kNilOptions OptionBits: all flags false
362 kInvalidID KernelID: NULL is for pointers as kInvalidID is for ID's
363 kVariableLengthArray array bounds: variable length array
364
365 Note: kVariableLengthArray was used in array bounds to specify a variable length array,
366 usually the last field in a struct. Now that the C language supports
367 the concept of flexible array members, you can instead use:
368
369 struct BarList
370 {
371 short listLength;
372 Bar elements[];
373 };
374
375 However, this changes the semantics somewhat, as sizeof( BarList ) contains
376 no space for any of the elements, so to allocate a list with space for
377 the count elements
378
379 struct BarList* l = (struct BarList*) malloc( sizeof(BarList) + count * sizeof(Bar) );
380
381*********************************************************************************/
382enum {
383 noErr = 0
384};
385
386enum {
387 kNilOptions = 0
388};
389
390#define kInvalidID 0
391enum {
392 kVariableLengthArray
393#ifdef __has_extension
394 #if __has_extension(enumerator_attributes)
395 __attribute__((deprecated))
396 #endif
397#endif
398 = 1
399};
400
401enum {
402 kUnknownType = 0x3F3F3F3F /* "????" QuickTime 3.0: default unknown ResType or OSType */
403};
404
405
406
407/********************************************************************************
408
409 String Types and Unicode Types
410
411 UnicodeScalarValue, A complete Unicode character in UTF-32 format, with
412 UTF32Char values from 0 through 0x10FFFF (excluding the surrogate
413 range 0xD800-0xDFFF and certain disallowed values).
414
415 UniChar, A 16-bit Unicode code value in the default UTF-16 format.
416 UTF16Char UnicodeScalarValues 0-0xFFFF are expressed in UTF-16
417 format using a single UTF16Char with the same value.
418 UnicodeScalarValues 0x10000-0x10FFFF are expressed in
419 UTF-16 format using a pair of UTF16Chars - one in the
420 high surrogate range (0xD800-0xDBFF) followed by one in
421 the low surrogate range (0xDC00-0xDFFF). All of the
422 characters defined in Unicode versions through 3.0 are
423 in the range 0-0xFFFF and can be expressed using a single
424 UTF16Char, thus the term "Unicode character" generally
425 refers to a UniChar = UTF16Char.
426
427 UTF8Char An 8-bit code value in UTF-8 format. UnicodeScalarValues
428 0-0x7F are expressed in UTF-8 format using one UTF8Char
429 with the same value. UnicodeScalarValues above 0x7F are
430 expressed in UTF-8 format using 2-4 UTF8Chars, all with
431 values in the range 0x80-0xF4 (UnicodeScalarValues
432 0x100-0xFFFF use two or three UTF8Chars,
433 UnicodeScalarValues 0x10000-0x10FFFF use four UTF8Chars).
434
435 UniCharCount A count of UTF-16 code values in an array or buffer.
436
437 StrNNN Pascal string holding up to NNN bytes
438 StringPtr Pointer to a pascal string
439 StringHandle Pointer to a StringPtr
440 ConstStringPtr Pointer to a read-only pascal string
441 ConstStrNNNParam For function parameters only - means string is const
442
443 CStringPtr Pointer to a C string (in C: char*)
444 ConstCStringPtr Pointer to a read-only C string (in C: const char*)
445
446 Note: The length of a pascal string is stored as the first byte.
447 A pascal string does not have a termination byte.
448 A pascal string can hold at most 255 bytes of data.
449 The first character in a pascal string is offset one byte from the start of the string.
450
451 A C string is terminated with a byte of value zero.
452 A C string has no length limitation.
453 The first character in a C string is the zeroth byte of the string.
454
455
456*********************************************************************************/
457typedef UInt32 UnicodeScalarValue;
458typedef UInt32 UTF32Char;
459typedef UInt16 UniChar;
460typedef UInt16 UTF16Char;
461typedef UInt8 UTF8Char;
462typedef UniChar * UniCharPtr;
463typedef unsigned long UniCharCount;
464typedef UniCharCount * UniCharCountPtr;
465typedef unsigned char Str255[256];
466typedef unsigned char Str63[64];
467typedef unsigned char Str32[33];
468typedef unsigned char Str31[32];
469typedef unsigned char Str27[28];
470typedef unsigned char Str15[16];
471/*
472 The type Str32 is used in many AppleTalk based data structures.
473 It holds up to 32 one byte chars. The problem is that with the
474 length byte it is 33 bytes long. This can cause weird alignment
475 problems in structures. To fix this the type "Str32Field" has
476 been created. It should only be used to hold 32 chars, but
477 it is 34 bytes long so that there are no alignment problems.
478*/
479typedef unsigned char Str32Field[34];
480/*
481 QuickTime 3.0:
482 The type StrFileName is used to make MacOS structs work
483 cross-platform. For example FSSpec or SFReply previously
484 contained a Str63 field. They now contain a StrFileName
485 field which is the same when targeting the MacOS but is
486 a 256 char buffer for Win32 and unix, allowing them to
487 contain long file names.
488*/
489typedef Str63 StrFileName;
490typedef unsigned char * StringPtr;
491typedef StringPtr * StringHandle;
492typedef const unsigned char * ConstStringPtr;
493typedef const unsigned char * ConstStr255Param;
494typedef const unsigned char * ConstStr63Param;
495typedef const unsigned char * ConstStr32Param;
496typedef const unsigned char * ConstStr31Param;
497typedef const unsigned char * ConstStr27Param;
498typedef const unsigned char * ConstStr15Param;
499typedef ConstStr63Param ConstStrFileNameParam;
500#ifdef __cplusplus
501inline unsigned char StrLength(ConstStr255Param string) { return (*string); }
502#else
503#define StrLength(string) (*(const unsigned char *)(string))
504#endif /* defined(__cplusplus) */
505
506#if OLDROUTINENAMES
507#define Length(string) StrLength(string)
508#endif /* OLDROUTINENAMES */
509
510/********************************************************************************
511
512 Process Manager type ProcessSerialNumber (previously in Processes.h)
513
514*********************************************************************************/
515/* type for unique process identifier */
516struct ProcessSerialNumber {
517 UInt32 highLongOfPSN;
518 UInt32 lowLongOfPSN;
519};
520typedef struct ProcessSerialNumber ProcessSerialNumber;
521typedef ProcessSerialNumber * ProcessSerialNumberPtr;
522/********************************************************************************
523
524 Quickdraw Types
525
526 Point 2D Quickdraw coordinate, range: -32K to +32K
527 Rect Rectangular Quickdraw area
528 Style Quickdraw font rendering styles
529 StyleParameter Style when used as a parameter (historical 68K convention)
530 StyleField Style when used as a field (historical 68K convention)
531 CharParameter Char when used as a parameter (historical 68K convention)
532
533 Note: The original Macintosh toolbox in 68K Pascal defined Style as a SET.
534 Both Style and CHAR occupy 8-bits in packed records or 16-bits when
535 used as fields in non-packed records or as parameters.
536
537*********************************************************************************/
538struct Point {
539 short v;
540 short h;
541};
542typedef struct Point Point;
543typedef Point * PointPtr;
544struct Rect {
545 short top;
546 short left;
547 short bottom;
548 short right;
549};
550typedef struct Rect Rect;
551typedef Rect * RectPtr;
552struct FixedPoint {
553 Fixed x;
554 Fixed y;
555};
556typedef struct FixedPoint FixedPoint;
557struct FixedRect {
558 Fixed left;
559 Fixed top;
560 Fixed right;
561 Fixed bottom;
562};
563typedef struct FixedRect FixedRect;
564
565typedef short CharParameter;
566enum {
567 normal = 0,
568 bold = 1,
569 italic = 2,
570 underline = 4,
571 outline = 8,
572 shadow = 0x10,
573 condense = 0x20,
574 extend = 0x40
575};
576
577typedef unsigned char Style;
578typedef short StyleParameter;
579typedef Style StyleField;
580
581
582/********************************************************************************
583
584 QuickTime TimeBase types (previously in Movies.h)
585
586 TimeValue Count of units
587 TimeScale Units per second
588 CompTimeValue 64-bit count of units (always a struct)
589 TimeValue64 64-bit count of units (long long or struct)
590 TimeBase An opaque reference to a time base
591 TimeRecord Package of TimeBase, duration, and scale
592
593*********************************************************************************/
594typedef SInt32 TimeValue;
595typedef SInt32 TimeScale;
596typedef wide CompTimeValue;
597typedef SInt64 TimeValue64;
598typedef struct TimeBaseRecord* TimeBase;
599struct TimeRecord {
600 CompTimeValue value; /* units (duration or absolute) */
601 TimeScale scale; /* units per second */
602 TimeBase base; /* refernce to the time base */
603};
604typedef struct TimeRecord TimeRecord;
605
606/********************************************************************************
607
608 THINK C base objects
609
610 HandleObject Root class for handle based THINK C++ objects
611 PascalObject Root class for pascal style objects in THINK C++
612
613*********************************************************************************/
614#if defined(__SC__) && !defined(__STDC__) && defined(__cplusplus)
615 class __machdl HandleObject {};
616 #if TARGET_CPU_68K
617 class __pasobj PascalObject {};
618 #endif
619#endif
620
621
622/********************************************************************************
623
624 MacOS versioning structures
625
626 VersRec Contents of a 'vers' resource
627 VersRecPtr Pointer to a VersRecPtr
628 VersRecHndl Resource Handle containing a VersRec
629 NumVersion Packed BCD version representation (e.g. "4.2.1a3" is 0x04214003)
630 UniversalProcPtr Pointer to classic 68K code or a RoutineDescriptor
631
632 ProcHandle Pointer to a ProcPtr
633 UniversalProcHandle Pointer to a UniversalProcPtr
634
635*********************************************************************************/
636#if TARGET_RT_BIG_ENDIAN
637struct NumVersion {
638 /* Numeric version part of 'vers' resource */
639 UInt8 majorRev; /*1st part of version number in BCD*/
640 UInt8 minorAndBugRev; /*2nd & 3rd part of version number share a byte*/
641 UInt8 stage; /*stage code: dev, alpha, beta, final*/
642 UInt8 nonRelRev; /*revision level of non-released version*/
643};
644typedef struct NumVersion NumVersion;
645#else
646struct NumVersion {
647 /* Numeric version part of 'vers' resource accessable in little endian format */
648 UInt8 nonRelRev; /*revision level of non-released version*/
649 UInt8 stage; /*stage code: dev, alpha, beta, final*/
650 UInt8 minorAndBugRev; /*2nd & 3rd part of version number share a byte*/
651 UInt8 majorRev; /*1st part of version number in BCD*/
652};
653typedef struct NumVersion NumVersion;
654#endif /* TARGET_RT_BIG_ENDIAN */
655
656enum {
657 /* Version Release Stage Codes */
658 developStage = 0x20,
659 alphaStage = 0x40,
660 betaStage = 0x60,
661 finalStage = 0x80
662};
663
664union NumVersionVariant {
665 /* NumVersionVariant is a wrapper so NumVersion can be accessed as a 32-bit value */
666 NumVersion parts;
667 UInt32 whole;
668};
669typedef union NumVersionVariant NumVersionVariant;
670typedef NumVersionVariant * NumVersionVariantPtr;
671typedef NumVersionVariantPtr * NumVersionVariantHandle;
672struct VersRec {
673 /* 'vers' resource format */
674 NumVersion numericVersion; /*encoded version number*/
675 short countryCode; /*country code from intl utilities*/
676 Str255 shortVersion; /*version number string - worst case*/
677 Str255 reserved; /*longMessage string packed after shortVersion*/
678};
679typedef struct VersRec VersRec;
680typedef VersRec * VersRecPtr;
681typedef VersRecPtr * VersRecHndl;
682/*********************************************************************************
683
684 Old names for types
685
686*********************************************************************************/
687typedef UInt8 Byte;
688typedef SInt8 SignedByte;
689typedef wide * WidePtr;
690typedef UnsignedWide * UnsignedWidePtr;
691typedef Float80 extended80;
692typedef Float96 extended96;
693typedef SInt8 VHSelect;
694/*********************************************************************************
695
696 Debugger functions
697
698*********************************************************************************/
699/*
700 * Debugger()
701 *
702 * Availability:
703 * Mac OS X: in version 10.0 and later in CoreServices.framework
704 * CarbonLib: in CarbonLib 1.0 and later
705 * Non-Carbon CFM: in InterfaceLib 7.1 and later
706 */
707extern void
708Debugger(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
709
710
711/*
712 * DebugStr()
713 *
714 * Availability:
715 * Mac OS X: in version 10.0 and later in CoreServices.framework
716 * CarbonLib: in CarbonLib 1.0 and later
717 * Non-Carbon CFM: in InterfaceLib 7.1 and later
718 */
719extern void
720DebugStr(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
721
722
723/*
724 * debugstr()
725 *
726 * Availability:
727 * Mac OS X: not available
728 * CarbonLib: not available
729 * Non-Carbon CFM: in InterfaceLib 7.1 and later
730 */
731
732
733#if TARGET_CPU_PPC
734/* Only for Mac OS native drivers */
735/*
736 * SysDebug()
737 *
738 * Availability:
739 * Mac OS X: not available
740 * CarbonLib: not available
741 * Non-Carbon CFM: in DriverServicesLib 1.0 and later
742 */
743
744
745/*
746 * SysDebugStr()
747 *
748 * Availability:
749 * Mac OS X: not available
750 * CarbonLib: not available
751 * Non-Carbon CFM: in DriverServicesLib 1.0 and later
752 */
753
754
755#endif /* TARGET_CPU_PPC */
756
757/* SADE break points */
758/*
759 * SysBreak()
760 *
761 * Availability:
762 * Mac OS X: in version 10.0 and later in CoreServices.framework
763 * CarbonLib: in CarbonLib 1.0 and later
764 * Non-Carbon CFM: in InterfaceLib 7.1 and later
765 */
766extern void
767SysBreak(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
768
769
770/*
771 * SysBreakStr()
772 *
773 * Availability:
774 * Mac OS X: in version 10.0 and later in CoreServices.framework
775 * CarbonLib: in CarbonLib 1.0 and later
776 * Non-Carbon CFM: in InterfaceLib 7.1 and later
777 */
778extern void
779SysBreakStr(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
780
781
782/*
783 * SysBreakFunc()
784 *
785 * Availability:
786 * Mac OS X: in version 10.0 and later in CoreServices.framework
787 * CarbonLib: in CarbonLib 1.0 and later
788 * Non-Carbon CFM: in InterfaceLib 7.1 and later
789 */
790extern void
791SysBreakFunc(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
792
793
794/* old names for Debugger and DebugStr */
795#if OLDROUTINENAMES && TARGET_CPU_68K
796 #define Debugger68k() Debugger()
797 #define DebugStr68k(s) DebugStr(s)
798#endif
799
800
801#pragma pack(pop)
802
803#ifdef __cplusplus
804}
805#endif
806
807#endif /* __MACTYPES__ */
808
lib/libc/include/x86_64-macos-gnu/TargetConditionals.h+74-68
......@@ -35,71 +35,72 @@
3535#ifndef __TARGETCONDITIONALS__
3636#define __TARGETCONDITIONALS__
3737
38/****************************************************************************************************
39
40 TARGET_CPU_*
41 These conditionals specify which microprocessor instruction set is being
42 generated. At most one of these is true, the rest are false.
43
44 TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode
45 TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode
46 TARGET_CPU_68K - Compiler is generating 680x0 instructions
47 TARGET_CPU_X86 - Compiler is generating x86 instructions for 32-bit mode
48 TARGET_CPU_X86_64 - Compiler is generating x86 instructions for 64-bit mode
49 TARGET_CPU_ARM - Compiler is generating ARM instructions for 32-bit mode
50 TARGET_CPU_ARM64 - Compiler is generating ARM instructions for 64-bit mode
51 TARGET_CPU_MIPS - Compiler is generating MIPS instructions
52 TARGET_CPU_SPARC - Compiler is generating Sparc instructions
53 TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions
54
55
56 TARGET_OS_*
57 These conditionals specify in which Operating System the generated code will
58 run. Indention is used to show which conditionals are evolutionary subclasses.
59
60 The MAC/WIN32/UNIX conditionals are mutually exclusive.
61 The IOS/TV/WATCH conditionals are mutually exclusive.
62
63
64 TARGET_OS_WIN32 - Generated code will run under 32-bit Windows
65 TARGET_OS_UNIX - Generated code will run under some Unix (not OSX)
66 TARGET_OS_MAC - Generated code will run under Mac OS X variant
67 TARGET_OS_OSX - Generated code will run under OS X devices
68 TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator
69 TARGET_OS_IOS - Generated code will run under iOS
70 TARGET_OS_TV - Generated code will run under Apple TV OS
71 TARGET_OS_WATCH - Generated code will run under Apple Watch OS
72 TARGET_OS_BRIDGE - Generated code will run under Bridge devices
73 TARGET_OS_MACCATALYST - Generated code will run under macOS
74 TARGET_OS_SIMULATOR - Generated code will run under a simulator
75
76 TARGET_OS_EMBEDDED - DEPRECATED: Use TARGET_OS_IPHONE and/or TARGET_OS_SIMULATOR instead
77 TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR
78 TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH
79
80 +----------------------------------------------------------------+
81 | TARGET_OS_MAC |
82 | +---+ +-----------------------------------------------------+ |
83 | | | | TARGET_OS_IPHONE | |
84 | |OSX| | +-----+ +----+ +-------+ +--------+ +-------------+ | |
85 | | | | | IOS | | TV | | WATCH | | BRIDGE | | MACCATALYST | | |
86 | | | | +-----+ +----+ +-------+ +--------+ +-------------+ | |
87 | +---+ +-----------------------------------------------------+ |
88 +----------------------------------------------------------------+
89
90 TARGET_RT_*
91 These conditionals specify in which runtime the generated code will
92 run. This is needed when the OS and CPU support more than one runtime
93 (e.g. Mac OS X supports CFM and mach-o).
94
95 TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers
96 TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers
97 TARGET_RT_64_BIT - Generated code uses 64-bit pointers
98 TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used
99 TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used
100
101
102****************************************************************************************************/
38/*
39 *
40 * TARGET_CPU_*
41 * These conditionals specify which microprocessor instruction set is being
42 * generated. At most one of these is true, the rest are false.
43 *
44 * TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode
45 * TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode
46 * TARGET_CPU_68K - Compiler is generating 680x0 instructions
47 * TARGET_CPU_X86 - Compiler is generating x86 instructions for 32-bit mode
48 * TARGET_CPU_X86_64 - Compiler is generating x86 instructions for 64-bit mode
49 * TARGET_CPU_ARM - Compiler is generating ARM instructions for 32-bit mode
50 * TARGET_CPU_ARM64 - Compiler is generating ARM instructions for 64-bit mode
51 * TARGET_CPU_MIPS - Compiler is generating MIPS instructions
52 * TARGET_CPU_SPARC - Compiler is generating Sparc instructions
53 * TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions
54 *
55 *
56 * TARGET_OS_*
57 * These conditionals specify in which Operating System the generated code will
58 * run. Indention is used to show which conditionals are evolutionary subclasses.
59 *
60 * The MAC/WIN32/UNIX conditionals are mutually exclusive.
61 * The IOS/TV/WATCH conditionals are mutually exclusive.
62 *
63 *
64 * TARGET_OS_WIN32 - Generated code will run under 32-bit Windows
65 * TARGET_OS_UNIX - Generated code will run under some Unix (not OSX)
66 * TARGET_OS_MAC - Generated code will run under Mac OS X variant
67 * TARGET_OS_OSX - Generated code will run under OS X devices
68 * TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator
69 * TARGET_OS_IOS - Generated code will run under iOS
70 * TARGET_OS_TV - Generated code will run under Apple TV OS
71 * TARGET_OS_WATCH - Generated code will run under Apple Watch OS
72 * TARGET_OS_BRIDGE - Generated code will run under Bridge devices
73 * TARGET_OS_MACCATALYST - Generated code will run under macOS
74 * TARGET_OS_SIMULATOR - Generated code will run under a simulator
75 *
76 * TARGET_OS_EMBEDDED - DEPRECATED: Use TARGET_OS_IPHONE and/or TARGET_OS_SIMULATOR instead
77 * TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR
78 * TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH
79 *
80 * +---------------------------------------------------------------------+
81 * | TARGET_OS_MAC |
82 * | +---+ +-----------------------------------------------+ +---------+ |
83 * | | | | TARGET_OS_IPHONE | | | |
84 * | | | | +---------------+ +----+ +-------+ +--------+ | | | |
85 * | | | | | IOS | | | | | | | | | | |
86 * | |OSX| | |+-------------+| | TV | | WATCH | | BRIDGE | | |DRIVERKIT| |
87 * | | | | || MACCATALYST || | | | | | | | | | |
88 * | | | | |+-------------+| | | | | | | | | | |
89 * | | | | +---------------+ +----+ +-------+ +--------+ | | | |
90 * | +---+ +-----------------------------------------------+ +---------+ |
91 * +---------------------------------------------------------------------+
92 *
93 * TARGET_RT_*
94 * These conditionals specify in which runtime the generated code will
95 * run. This is needed when the OS and CPU support more than one runtime
96 * (e.g. Mac OS X supports CFM and mach-o).
97 *
98 * TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers
99 * TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers
100 * TARGET_RT_64_BIT - Generated code uses 64-bit pointers
101 * TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used
102 * TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used
103 */
103104
104105 /*
105106 * TARGET_OS conditionals can be enabled via clang preprocessor extensions:
......@@ -133,7 +134,9 @@
133134 #if __has_builtin(__is_target_environment)
134135
135136 /* “-target=x86_64-apple-ios12-macabi” */
136 #if __is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi)
137 /* “-target=arm64-apple-ios12-macabi” */
138 /* “-target=arm64e-apple-ios12-macabi” */
139 #if (__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi)
137140 #define TARGET_OS_OSX 0
138141 #define TARGET_OS_IPHONE 1
139142 #define TARGET_OS_IOS 1
......@@ -173,7 +176,9 @@
173176 #endif
174177
175178 /* -target=x86_64-apple-driverkit19.0 */
176 #if __is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(driverkit)
179 /* -target=arm64-apple-driverkit19.0 */
180 /* -target=arm64e-apple-driverkit19.0 */
181 #if (__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(driverkit)
177182 #define TARGET_OS_OSX 0
178183 #define TARGET_OS_IPHONE 0
179184 #define TARGET_OS_IOS 0
......@@ -231,7 +236,8 @@
231236
232237 #define TARGET_IPHONE_SIMULATOR TARGET_OS_SIMULATOR /* deprecated */
233238 #define TARGET_OS_NANO TARGET_OS_WATCH /* deprecated */
234 #define TARGET_ABI_USES_IOS_VALUES (TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST)
239
240 #define TARGET_ABI_USES_IOS_VALUES (!TARGET_CPU_X86_64 || (TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST))
235241 #if defined(__ppc__)
236242 #define TARGET_CPU_PPC 1
237243 #define TARGET_CPU_PPC64 0
lib/libc/include/x86_64-macos-gnu/_ctermid.h+9-1
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2000, 2002-2006, 2008-2010, 2012 Apple Inc. All rights reserved.
2 * Copyright (c) 2000, 2002-2006, 2008-2010, 2012, 2020 Apple Inc. All rights reserved.
33 *
44 * @APPLE_LICENSE_HEADER_START@
55 *
......@@ -23,5 +23,13 @@
2323
2424#ifndef _CTERMID_H_
2525#define _CTERMID_H_
26
27#include <sys/cdefs.h>
28
29__BEGIN_DECLS
30
2631char *ctermid(char *);
32
33__END_DECLS
34
2735#endif
lib/libc/include/x86_64-macos-gnu/bsm/audit.h+18-5
......@@ -332,13 +332,24 @@ struct au_evclass_map {
332332};
333333typedef struct au_evclass_map au_evclass_map_t;
334334
335
336#if !defined(_KERNEL) && !defined(KERNEL)
337#include <Availability.h>
338#define __AUDIT_API_DEPRECATED __API_DEPRECATED("audit is deprecated", macos(10.4, 11.0))
339#else
340#define __AUDIT_API_DEPRECATED
341#endif
342
335343/*
336344 * Audit system calls.
337345 */
338346#if !defined(_KERNEL) && !defined(KERNEL)
339int audit(const void *, int);
340int auditon(int, void *, int);
341int auditctl(const char *);
347int audit(const void *, int)
348__AUDIT_API_DEPRECATED;
349int auditon(int, void *, int)
350__AUDIT_API_DEPRECATED;
351int auditctl(const char *)
352__AUDIT_API_DEPRECATED;
342353int getauid(au_id_t *);
343354int setauid(const au_id_t *);
344355int getaudit_addr(struct auditinfo_addr *, int);
......@@ -360,8 +371,10 @@ __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8,
360371 __IPHONE_2_0, __IPHONE_6_0);
361372#else
362373
363int getaudit(struct auditinfo *);
364int setaudit(const struct auditinfo *);
374int getaudit(struct auditinfo *)
375__AUDIT_API_DEPRECATED;
376int setaudit(const struct auditinfo *)
377__AUDIT_API_DEPRECATED;
365378#endif /* !__APPLE__ */
366379
367380#ifdef __APPLE_API_PRIVATE
lib/libc/include/x86_64-macos-gnu/device/device_types.h created+118
......@@ -0,0 +1,118 @@
1/*
2 * Copyright (c) 2000-2004 Apple Computer, 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 * @OSF_COPYRIGHT@
30 */
31/*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56/*
57 */
58/*
59 * Author: David B. Golub, Carnegie Mellon University
60 * Date: 3/89
61 */
62
63#ifndef DEVICE_TYPES_H
64#define DEVICE_TYPES_H
65
66/*
67 * Types for device interface.
68 */
69#include <mach/std_types.h>
70#include <mach/mach_types.h>
71#include <mach/message.h>
72#include <mach/port.h>
73
74
75
76/*
77 * IO buffer - out-of-line array of characters.
78 */
79typedef char * io_buf_ptr_t;
80
81/*
82 * Some types for IOKit.
83 */
84
85#ifdef IOKIT
86
87/* must match device_types.defs */
88typedef char io_name_t[128];
89typedef char io_string_t[512];
90typedef char io_string_inband_t[4096];
91typedef char io_struct_inband_t[4096];
92
93#if __LP64__
94typedef uint64_t io_user_scalar_t;
95typedef uint64_t io_user_reference_t;
96typedef io_user_scalar_t io_scalar_inband_t[16];
97typedef io_user_reference_t io_async_ref_t[8];
98typedef io_user_scalar_t io_scalar_inband64_t[16];
99typedef io_user_reference_t io_async_ref64_t[8];
100#else
101typedef int io_user_scalar_t;
102typedef natural_t io_user_reference_t;
103typedef io_user_scalar_t io_scalar_inband_t[16];
104typedef io_user_reference_t io_async_ref_t[8];
105typedef uint64_t io_scalar_inband64_t[16];
106typedef uint64_t io_async_ref64_t[8];
107#endif // __LP64__
108
109
110#ifndef __IOKIT_PORTS_DEFINED__
111#define __IOKIT_PORTS_DEFINED__
112typedef mach_port_t io_object_t;
113#endif /* __IOKIT_PORTS_DEFINED__ */
114
115
116#endif /* IOKIT */
117
118#endif /* DEVICE_TYPES_H */
lib/libc/include/x86_64-macos-gnu/dispatch/base.h created+306
......@@ -0,0 +1,306 @@
1/*
2 * Copyright (c) 2008-2012 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_BASE__
22#define __DISPATCH_BASE__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#endif
27
28#ifndef __has_builtin
29#define __has_builtin(x) 0
30#endif
31#ifndef __has_include
32#define __has_include(x) 0
33#endif
34#ifndef __has_feature
35#define __has_feature(x) 0
36#endif
37#ifndef __has_attribute
38#define __has_attribute(x) 0
39#endif
40#ifndef __has_extension
41#define __has_extension(x) 0
42#endif
43
44#if __GNUC__
45#define DISPATCH_NORETURN __attribute__((__noreturn__))
46#define DISPATCH_NOTHROW __attribute__((__nothrow__))
47#define DISPATCH_NONNULL1 __attribute__((__nonnull__(1)))
48#define DISPATCH_NONNULL2 __attribute__((__nonnull__(2)))
49#define DISPATCH_NONNULL3 __attribute__((__nonnull__(3)))
50#define DISPATCH_NONNULL4 __attribute__((__nonnull__(4)))
51#define DISPATCH_NONNULL5 __attribute__((__nonnull__(5)))
52#define DISPATCH_NONNULL6 __attribute__((__nonnull__(6)))
53#define DISPATCH_NONNULL7 __attribute__((__nonnull__(7)))
54#if __clang__ && __clang_major__ < 3
55// rdar://problem/6857843
56#define DISPATCH_NONNULL_ALL
57#else
58#define DISPATCH_NONNULL_ALL __attribute__((__nonnull__))
59#endif
60#define DISPATCH_SENTINEL __attribute__((__sentinel__))
61#define DISPATCH_PURE __attribute__((__pure__))
62#define DISPATCH_CONST __attribute__((__const__))
63#define DISPATCH_WARN_RESULT __attribute__((__warn_unused_result__))
64#define DISPATCH_MALLOC __attribute__((__malloc__))
65#define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__))
66#define DISPATCH_UNAVAILABLE __attribute__((__unavailable__))
67#define DISPATCH_UNAVAILABLE_MSG(msg) __attribute__((__unavailable__(msg)))
68#elif defined(_MSC_VER)
69#define DISPATCH_NORETURN __declspec(noreturn)
70#define DISPATCH_NOTHROW __declspec(nothrow)
71#define DISPATCH_NONNULL1
72#define DISPATCH_NONNULL2
73#define DISPATCH_NONNULL3
74#define DISPATCH_NONNULL4
75#define DISPATCH_NONNULL5
76#define DISPATCH_NONNULL6
77#define DISPATCH_NONNULL7
78#define DISPATCH_NONNULL_ALL
79#define DISPATCH_SENTINEL
80#define DISPATCH_PURE
81#define DISPATCH_CONST
82#if (_MSC_VER >= 1700)
83#define DISPATCH_WARN_RESULT _Check_return_
84#else
85#define DISPATCH_WARN_RESULT
86#endif
87#define DISPATCH_MALLOC
88#define DISPATCH_ALWAYS_INLINE __forceinline
89#define DISPATCH_UNAVAILABLE
90#define DISPATCH_UNAVAILABLE_MSG(msg)
91#else
92/*! @parseOnly */
93#define DISPATCH_NORETURN
94/*! @parseOnly */
95#define DISPATCH_NOTHROW
96/*! @parseOnly */
97#define DISPATCH_NONNULL1
98/*! @parseOnly */
99#define DISPATCH_NONNULL2
100/*! @parseOnly */
101#define DISPATCH_NONNULL3
102/*! @parseOnly */
103#define DISPATCH_NONNULL4
104/*! @parseOnly */
105#define DISPATCH_NONNULL5
106/*! @parseOnly */
107#define DISPATCH_NONNULL6
108/*! @parseOnly */
109#define DISPATCH_NONNULL7
110/*! @parseOnly */
111#define DISPATCH_NONNULL_ALL
112/*! @parseOnly */
113#define DISPATCH_SENTINEL
114/*! @parseOnly */
115#define DISPATCH_PURE
116/*! @parseOnly */
117#define DISPATCH_CONST
118/*! @parseOnly */
119#define DISPATCH_WARN_RESULT
120/*! @parseOnly */
121#define DISPATCH_MALLOC
122/*! @parseOnly */
123#define DISPATCH_ALWAYS_INLINE
124/*! @parseOnly */
125#define DISPATCH_UNAVAILABLE
126/*! @parseOnly */
127#define DISPATCH_UNAVAILABLE_MSG(msg)
128#endif
129
130#define DISPATCH_LINUX_UNAVAILABLE()
131
132#ifdef __FreeBSD__
133#define DISPATCH_FREEBSD_UNAVAILABLE() \
134 DISPATCH_UNAVAILABLE_MSG( \
135 "This interface is unavailable on FreeBSD systems")
136#else
137#define DISPATCH_FREEBSD_UNAVAILABLE()
138#endif
139
140#ifndef DISPATCH_ALIAS_V2
141#if TARGET_OS_MAC
142#define DISPATCH_ALIAS_V2(sym) __asm__("_" #sym "$V2")
143#else
144#define DISPATCH_ALIAS_V2(sym)
145#endif
146#endif
147
148#if defined(_WIN32)
149#if defined(__cplusplus)
150#define DISPATCH_EXPORT extern "C" __declspec(dllimport)
151#else
152#define DISPATCH_EXPORT extern __declspec(dllimport)
153#endif
154#elif __GNUC__
155#define DISPATCH_EXPORT extern __attribute__((visibility("default")))
156#else
157#define DISPATCH_EXPORT extern
158#endif
159
160#if __GNUC__
161#define DISPATCH_INLINE static __inline__
162#else
163#define DISPATCH_INLINE static inline
164#endif
165
166#if __GNUC__
167#define DISPATCH_EXPECT(x, v) __builtin_expect((x), (v))
168#define dispatch_compiler_barrier() __asm__ __volatile__("" ::: "memory")
169#else
170#define DISPATCH_EXPECT(x, v) (x)
171#define dispatch_compiler_barrier() do { } while (0)
172#endif
173
174#if __has_attribute(not_tail_called)
175#define DISPATCH_NOT_TAIL_CALLED __attribute__((__not_tail_called__))
176#else
177#define DISPATCH_NOT_TAIL_CALLED
178#endif
179
180#if __has_builtin(__builtin_assume)
181#define DISPATCH_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
182#else
183#define DISPATCH_COMPILER_CAN_ASSUME(expr) ((void)(expr))
184#endif
185
186#if __has_attribute(noescape)
187#define DISPATCH_NOESCAPE __attribute__((__noescape__))
188#else
189#define DISPATCH_NOESCAPE
190#endif
191
192#if __has_attribute(cold)
193#define DISPATCH_COLD __attribute__((__cold__))
194#else
195#define DISPATCH_COLD
196#endif
197
198#if __has_feature(assume_nonnull)
199#define DISPATCH_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
200#define DISPATCH_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
201#else
202#define DISPATCH_ASSUME_NONNULL_BEGIN
203#define DISPATCH_ASSUME_NONNULL_END
204#endif
205
206#if !__has_feature(nullability)
207#ifndef _Nullable
208#define _Nullable
209#endif
210#ifndef _Nonnull
211#define _Nonnull
212#endif
213#ifndef _Null_unspecified
214#define _Null_unspecified
215#endif
216#endif
217
218#ifndef DISPATCH_RETURNS_RETAINED_BLOCK
219#if __has_attribute(ns_returns_retained)
220#define DISPATCH_RETURNS_RETAINED_BLOCK __attribute__((__ns_returns_retained__))
221#else
222#define DISPATCH_RETURNS_RETAINED_BLOCK
223#endif
224#endif
225
226#if __has_attribute(enum_extensibility)
227#define __DISPATCH_ENUM_ATTR __attribute__((__enum_extensibility__(open)))
228#define __DISPATCH_ENUM_ATTR_CLOSED __attribute__((__enum_extensibility__(closed)))
229#else
230#define __DISPATCH_ENUM_ATTR
231#define __DISPATCH_ENUM_ATTR_CLOSED
232#endif // __has_attribute(enum_extensibility)
233
234#if __has_attribute(flag_enum)
235#define __DISPATCH_OPTIONS_ATTR __attribute__((__flag_enum__))
236#else
237#define __DISPATCH_OPTIONS_ATTR
238#endif // __has_attribute(flag_enum)
239
240
241#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums) || \
242 __has_extension(cxx_fixed_enum) || defined(_WIN32)
243#define DISPATCH_ENUM(name, type, ...) \
244 typedef enum : type { __VA_ARGS__ } __DISPATCH_ENUM_ATTR name##_t
245#define DISPATCH_OPTIONS(name, type, ...) \
246 typedef enum : type { __VA_ARGS__ } __DISPATCH_OPTIONS_ATTR __DISPATCH_ENUM_ATTR name##_t
247#else
248#define DISPATCH_ENUM(name, type, ...) \
249 enum { __VA_ARGS__ } __DISPATCH_ENUM_ATTR; typedef type name##_t
250#define DISPATCH_OPTIONS(name, type, ...) \
251 enum { __VA_ARGS__ } __DISPATCH_OPTIONS_ATTR __DISPATCH_ENUM_ATTR; typedef type name##_t
252#endif // __has_feature(objc_fixed_enum) ...
253
254
255
256#if __has_feature(enumerator_attributes)
257#define DISPATCH_ENUM_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__)
258#define DISPATCH_ENUM_API_DEPRECATED(...) API_DEPRECATED(__VA_ARGS__)
259#define DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...) \
260 API_DEPRECATED_WITH_REPLACEMENT(__VA_ARGS__)
261#else
262#define DISPATCH_ENUM_API_AVAILABLE(...)
263#define DISPATCH_ENUM_API_DEPRECATED(...)
264#define DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...)
265#endif
266
267#ifdef __swift__
268#define DISPATCH_SWIFT3_OVERLAY 1
269#else // __swift__
270#define DISPATCH_SWIFT3_OVERLAY 0
271#endif // __swift__
272
273#if __has_feature(attribute_availability_swift)
274#define DISPATCH_SWIFT_UNAVAILABLE(_msg) \
275 __attribute__((__availability__(swift, unavailable, message=_msg)))
276#else
277#define DISPATCH_SWIFT_UNAVAILABLE(_msg)
278#endif
279
280#if DISPATCH_SWIFT3_OVERLAY
281#define DISPATCH_SWIFT3_UNAVAILABLE(_msg) DISPATCH_SWIFT_UNAVAILABLE(_msg)
282#else
283#define DISPATCH_SWIFT3_UNAVAILABLE(_msg)
284#endif
285
286#if __has_attribute(swift_private)
287#define DISPATCH_REFINED_FOR_SWIFT __attribute__((__swift_private__))
288#else
289#define DISPATCH_REFINED_FOR_SWIFT
290#endif
291
292#if __has_attribute(swift_name)
293#define DISPATCH_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
294#else
295#define DISPATCH_SWIFT_NAME(_name)
296#endif
297
298#ifndef __cplusplus
299#define DISPATCH_TRANSPARENT_UNION __attribute__((__transparent_union__))
300#else
301#define DISPATCH_TRANSPARENT_UNION
302#endif
303
304typedef void (*dispatch_function_t)(void *_Nullable);
305
306#endif
lib/libc/include/x86_64-macos-gnu/dispatch/block.h created+428
......@@ -0,0 +1,428 @@
1/*
2 * Copyright (c) 2014 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_BLOCK__
22#define __DISPATCH_BLOCK__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29#ifdef __BLOCKS__
30
31/*!
32 * @group Dispatch block objects
33 */
34
35DISPATCH_ASSUME_NONNULL_BEGIN
36
37__BEGIN_DECLS
38
39/*!
40 * @typedef dispatch_block_flags_t
41 * Flags to pass to the dispatch_block_create* functions.
42 *
43 * @const DISPATCH_BLOCK_BARRIER
44 * Flag indicating that a dispatch block object should act as a barrier block
45 * when submitted to a DISPATCH_QUEUE_CONCURRENT queue.
46 * See dispatch_barrier_async() for details.
47 * This flag has no effect when the dispatch block object is invoked directly.
48 *
49 * @const DISPATCH_BLOCK_DETACHED
50 * Flag indicating that a dispatch block object should execute disassociated
51 * from current execution context attributes such as os_activity_t
52 * and properties of the current IPC request (if any). With regard to QoS class,
53 * the behavior is the same as for DISPATCH_BLOCK_NO_QOS. If invoked directly,
54 * the block object will remove the other attributes from the calling thread for
55 * the duration of the block body (before applying attributes assigned to the
56 * block object, if any). If submitted to a queue, the block object will be
57 * executed with the attributes of the queue (or any attributes specifically
58 * assigned to the block object).
59 *
60 * @const DISPATCH_BLOCK_ASSIGN_CURRENT
61 * Flag indicating that a dispatch block object should be assigned the execution
62 * context attributes that are current at the time the block object is created.
63 * This applies to attributes such as QOS class, os_activity_t and properties of
64 * the current IPC request (if any). If invoked directly, the block object will
65 * apply these attributes to the calling thread for the duration of the block
66 * body. If the block object is submitted to a queue, this flag replaces the
67 * default behavior of associating the submitted block instance with the
68 * execution context attributes that are current at the time of submission.
69 * If a specific QOS class is assigned with DISPATCH_BLOCK_NO_QOS_CLASS or
70 * dispatch_block_create_with_qos_class(), that QOS class takes precedence over
71 * the QOS class assignment indicated by this flag.
72 *
73 * @const DISPATCH_BLOCK_NO_QOS_CLASS
74 * Flag indicating that a dispatch block object should be not be assigned a QOS
75 * class. If invoked directly, the block object will be executed with the QOS
76 * class of the calling thread. If the block object is submitted to a queue,
77 * this replaces the default behavior of associating the submitted block
78 * instance with the QOS class current at the time of submission.
79 * This flag is ignored if a specific QOS class is assigned with
80 * dispatch_block_create_with_qos_class().
81 *
82 * @const DISPATCH_BLOCK_INHERIT_QOS_CLASS
83 * Flag indicating that execution of a dispatch block object submitted to a
84 * queue should prefer the QOS class assigned to the queue over the QOS class
85 * assigned to the block (resp. associated with the block at the time of
86 * submission). The latter will only be used if the queue in question does not
87 * have an assigned QOS class, as long as doing so does not result in a QOS
88 * class lower than the QOS class inherited from the queue's target queue.
89 * This flag is the default when a dispatch block object is submitted to a queue
90 * for asynchronous execution and has no effect when the dispatch block object
91 * is invoked directly. It is ignored if DISPATCH_BLOCK_ENFORCE_QOS_CLASS is
92 * also passed.
93 *
94 * @const DISPATCH_BLOCK_ENFORCE_QOS_CLASS
95 * Flag indicating that execution of a dispatch block object submitted to a
96 * queue should prefer the QOS class assigned to the block (resp. associated
97 * with the block at the time of submission) over the QOS class assigned to the
98 * queue, as long as doing so will not result in a lower QOS class.
99 * This flag is the default when a dispatch block object is submitted to a queue
100 * for synchronous execution or when the dispatch block object is invoked
101 * directly.
102 */
103DISPATCH_OPTIONS(dispatch_block_flags, unsigned long,
104 DISPATCH_BLOCK_BARRIER
105 DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x1,
106 DISPATCH_BLOCK_DETACHED
107 DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x2,
108 DISPATCH_BLOCK_ASSIGN_CURRENT
109 DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x4,
110 DISPATCH_BLOCK_NO_QOS_CLASS
111 DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x8,
112 DISPATCH_BLOCK_INHERIT_QOS_CLASS
113 DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x10,
114 DISPATCH_BLOCK_ENFORCE_QOS_CLASS
115 DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x20,
116);
117
118/*!
119 * @function dispatch_block_create
120 *
121 * @abstract
122 * Create a new dispatch block object on the heap from an existing block and
123 * the given flags.
124 *
125 * @discussion
126 * The provided block is Block_copy'ed to the heap and retained by the newly
127 * created dispatch block object.
128 *
129 * The returned dispatch block object is intended to be submitted to a dispatch
130 * queue with dispatch_async() and related functions, but may also be invoked
131 * directly. Both operations can be performed an arbitrary number of times but
132 * only the first completed execution of a dispatch block object can be waited
133 * on with dispatch_block_wait() or observed with dispatch_block_notify().
134 *
135 * If the returned dispatch block object is submitted to a dispatch queue, the
136 * submitted block instance will be associated with the QOS class current at the
137 * time of submission, unless one of the following flags assigned a specific QOS
138 * class (or no QOS class) at the time of block creation:
139 * - DISPATCH_BLOCK_ASSIGN_CURRENT
140 * - DISPATCH_BLOCK_NO_QOS_CLASS
141 * - DISPATCH_BLOCK_DETACHED
142 * The QOS class the block object will be executed with also depends on the QOS
143 * class assigned to the queue and which of the following flags was specified or
144 * defaulted to:
145 * - DISPATCH_BLOCK_INHERIT_QOS_CLASS (default for asynchronous execution)
146 * - DISPATCH_BLOCK_ENFORCE_QOS_CLASS (default for synchronous execution)
147 * See description of dispatch_block_flags_t for details.
148 *
149 * If the returned dispatch block object is submitted directly to a serial queue
150 * and is configured to execute with a specific QOS class, the system will make
151 * a best effort to apply the necessary QOS overrides to ensure that blocks
152 * submitted earlier to the serial queue are executed at that same QOS class or
153 * higher.
154 *
155 * @param flags
156 * Configuration flags for the block object.
157 * Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t
158 * results in NULL being returned.
159 *
160 * @param block
161 * The block to create the dispatch block object from.
162 *
163 * @result
164 * The newly created dispatch block object, or NULL.
165 * When not building with Objective-C ARC, must be released with a -[release]
166 * message or the Block_release() function.
167 */
168API_AVAILABLE(macos(10.10), ios(8.0))
169DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_RETURNS_RETAINED_BLOCK
170DISPATCH_WARN_RESULT DISPATCH_NOTHROW
171dispatch_block_t
172dispatch_block_create(dispatch_block_flags_t flags, dispatch_block_t block);
173
174/*!
175 * @function dispatch_block_create_with_qos_class
176 *
177 * @abstract
178 * Create a new dispatch block object on the heap from an existing block and
179 * the given flags, and assign it the specified QOS class and relative priority.
180 *
181 * @discussion
182 * The provided block is Block_copy'ed to the heap and retained by the newly
183 * created dispatch block object.
184 *
185 * The returned dispatch block object is intended to be submitted to a dispatch
186 * queue with dispatch_async() and related functions, but may also be invoked
187 * directly. Both operations can be performed an arbitrary number of times but
188 * only the first completed execution of a dispatch block object can be waited
189 * on with dispatch_block_wait() or observed with dispatch_block_notify().
190 *
191 * If invoked directly, the returned dispatch block object will be executed with
192 * the assigned QOS class as long as that does not result in a lower QOS class
193 * than what is current on the calling thread.
194 *
195 * If the returned dispatch block object is submitted to a dispatch queue, the
196 * QOS class it will be executed with depends on the QOS class assigned to the
197 * block, the QOS class assigned to the queue and which of the following flags
198 * was specified or defaulted to:
199 * - DISPATCH_BLOCK_INHERIT_QOS_CLASS: default for asynchronous execution
200 * - DISPATCH_BLOCK_ENFORCE_QOS_CLASS: default for synchronous execution
201 * See description of dispatch_block_flags_t for details.
202 *
203 * If the returned dispatch block object is submitted directly to a serial queue
204 * and is configured to execute with a specific QOS class, the system will make
205 * a best effort to apply the necessary QOS overrides to ensure that blocks
206 * submitted earlier to the serial queue are executed at that same QOS class or
207 * higher.
208 *
209 * @param flags
210 * Configuration flags for the new block object.
211 * Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t
212 * results in NULL being returned.
213 *
214 * @param qos_class
215 * A QOS class value:
216 * - QOS_CLASS_USER_INTERACTIVE
217 * - QOS_CLASS_USER_INITIATED
218 * - QOS_CLASS_DEFAULT
219 * - QOS_CLASS_UTILITY
220 * - QOS_CLASS_BACKGROUND
221 * - QOS_CLASS_UNSPECIFIED
222 * Passing QOS_CLASS_UNSPECIFIED is equivalent to specifying the
223 * DISPATCH_BLOCK_NO_QOS_CLASS flag. Passing any other value results in NULL
224 * being returned.
225 *
226 * @param relative_priority
227 * A relative priority within the QOS class. This value is a negative
228 * offset from the maximum supported scheduler priority for the given class.
229 * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
230 * results in NULL being returned.
231 *
232 * @param block
233 * The block to create the dispatch block object from.
234 *
235 * @result
236 * The newly created dispatch block object, or NULL.
237 * When not building with Objective-C ARC, must be released with a -[release]
238 * message or the Block_release() function.
239 */
240API_AVAILABLE(macos(10.10), ios(8.0))
241DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_RETURNS_RETAINED_BLOCK
242DISPATCH_WARN_RESULT DISPATCH_NOTHROW
243dispatch_block_t
244dispatch_block_create_with_qos_class(dispatch_block_flags_t flags,
245 dispatch_qos_class_t qos_class, int relative_priority,
246 dispatch_block_t block);
247
248/*!
249 * @function dispatch_block_perform
250 *
251 * @abstract
252 * Create, synchronously execute and release a dispatch block object from the
253 * specified block and flags.
254 *
255 * @discussion
256 * Behaves identically to the sequence
257 * <code>
258 * dispatch_block_t b = dispatch_block_create(flags, block);
259 * b();
260 * Block_release(b);
261 * </code>
262 * but may be implemented more efficiently internally by not requiring a copy
263 * to the heap of the specified block or the allocation of a new block object.
264 *
265 * @param flags
266 * Configuration flags for the temporary block object.
267 * The result of passing a value that is not a bitwise OR of flags from
268 * dispatch_block_flags_t is undefined.
269 *
270 * @param block
271 * The block to create the temporary block object from.
272 */
273API_AVAILABLE(macos(10.10), ios(8.0))
274DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW
275void
276dispatch_block_perform(dispatch_block_flags_t flags,
277 DISPATCH_NOESCAPE dispatch_block_t block);
278
279/*!
280 * @function dispatch_block_wait
281 *
282 * @abstract
283 * Wait synchronously until execution of the specified dispatch block object has
284 * completed or until the specified timeout has elapsed.
285 *
286 * @discussion
287 * This function will return immediately if execution of the block object has
288 * already completed.
289 *
290 * It is not possible to wait for multiple executions of the same block object
291 * with this interface; use dispatch_group_wait() for that purpose. A single
292 * dispatch block object may either be waited on once and executed once,
293 * or it may be executed any number of times. The behavior of any other
294 * combination is undefined. Submission to a dispatch queue counts as an
295 * execution, even if cancellation (dispatch_block_cancel) means the block's
296 * code never runs.
297 *
298 * The result of calling this function from multiple threads simultaneously
299 * with the same dispatch block object is undefined, but note that doing so
300 * would violate the rules described in the previous paragraph.
301 *
302 * If this function returns indicating that the specified timeout has elapsed,
303 * then that invocation does not count as the one allowed wait.
304 *
305 * If at the time this function is called, the specified dispatch block object
306 * has been submitted directly to a serial queue, the system will make a best
307 * effort to apply the necessary QOS overrides to ensure that the block and any
308 * blocks submitted earlier to that serial queue are executed at the QOS class
309 * (or higher) of the thread calling dispatch_block_wait().
310 *
311 * @param block
312 * The dispatch block object to wait on.
313 * The result of passing NULL or a block object not returned by one of the
314 * dispatch_block_create* functions is undefined.
315 *
316 * @param timeout
317 * When to timeout (see dispatch_time). As a convenience, there are the
318 * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
319 *
320 * @result
321 * Returns zero on success (the dispatch block object completed within the
322 * specified timeout) or non-zero on error (i.e. timed out).
323 */
324API_AVAILABLE(macos(10.10), ios(8.0))
325DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
326intptr_t
327dispatch_block_wait(dispatch_block_t block, dispatch_time_t timeout);
328
329/*!
330 * @function dispatch_block_notify
331 *
332 * @abstract
333 * Schedule a notification block to be submitted to a queue when the execution
334 * of a specified dispatch block object has completed.
335 *
336 * @discussion
337 * This function will submit the notification block immediately if execution of
338 * the observed block object has already completed.
339 *
340 * It is not possible to be notified of multiple executions of the same block
341 * object with this interface, use dispatch_group_notify() for that purpose.
342 *
343 * A single dispatch block object may either be observed one or more times
344 * and executed once, or it may be executed any number of times. The behavior
345 * of any other combination is undefined. Submission to a dispatch queue
346 * counts as an execution, even if cancellation (dispatch_block_cancel) means
347 * the block's code never runs.
348 *
349 * If multiple notification blocks are scheduled for a single block object,
350 * there is no defined order in which the notification blocks will be submitted
351 * to their associated queues.
352 *
353 * @param block
354 * The dispatch block object to observe.
355 * The result of passing NULL or a block object not returned by one of the
356 * dispatch_block_create* functions is undefined.
357 *
358 * @param queue
359 * The queue to which the supplied notification block will be submitted when
360 * the observed block completes.
361 *
362 * @param notification_block
363 * The notification block to submit when the observed block object completes.
364 */
365API_AVAILABLE(macos(10.10), ios(8.0))
366DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
367void
368dispatch_block_notify(dispatch_block_t block, dispatch_queue_t queue,
369 dispatch_block_t notification_block);
370
371/*!
372 * @function dispatch_block_cancel
373 *
374 * @abstract
375 * Asynchronously cancel the specified dispatch block object.
376 *
377 * @discussion
378 * Cancellation causes any future execution of the dispatch block object to
379 * return immediately, but does not affect any execution of the block object
380 * that is already in progress.
381 *
382 * Release of any resources associated with the block object will be delayed
383 * until execution of the block object is next attempted (or any execution
384 * already in progress completes).
385 *
386 * NOTE: care needs to be taken to ensure that a block object that may be
387 * canceled does not capture any resources that require execution of the
388 * block body in order to be released (e.g. memory allocated with
389 * malloc(3) that the block body calls free(3) on). Such resources will
390 * be leaked if the block body is never executed due to cancellation.
391 *
392 * @param block
393 * The dispatch block object to cancel.
394 * The result of passing NULL or a block object not returned by one of the
395 * dispatch_block_create* functions is undefined.
396 */
397API_AVAILABLE(macos(10.10), ios(8.0))
398DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
399void
400dispatch_block_cancel(dispatch_block_t block);
401
402/*!
403 * @function dispatch_block_testcancel
404 *
405 * @abstract
406 * Tests whether the given dispatch block object has been canceled.
407 *
408 * @param block
409 * The dispatch block object to test.
410 * The result of passing NULL or a block object not returned by one of the
411 * dispatch_block_create* functions is undefined.
412 *
413 * @result
414 * Non-zero if canceled and zero if not canceled.
415 */
416API_AVAILABLE(macos(10.10), ios(8.0))
417DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
418DISPATCH_NOTHROW
419intptr_t
420dispatch_block_testcancel(dispatch_block_t block);
421
422__END_DECLS
423
424DISPATCH_ASSUME_NONNULL_END
425
426#endif // __BLOCKS__
427
428#endif // __DISPATCH_BLOCK__
lib/libc/include/x86_64-macos-gnu/dispatch/data.h created+278
......@@ -0,0 +1,278 @@
1/*
2 * Copyright (c) 2009-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_DATA__
22#define __DISPATCH_DATA__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29DISPATCH_ASSUME_NONNULL_BEGIN
30
31__BEGIN_DECLS
32
33/*! @header
34 * Dispatch data objects describe contiguous or sparse regions of memory that
35 * may be managed by the system or by the application.
36 * Dispatch data objects are immutable, any direct access to memory regions
37 * represented by dispatch objects must not modify that memory.
38 */
39
40/*!
41 * @typedef dispatch_data_t
42 * A dispatch object representing memory regions.
43 */
44DISPATCH_DATA_DECL(dispatch_data);
45
46/*!
47 * @var dispatch_data_empty
48 * @discussion The singleton dispatch data object representing a zero-length
49 * memory region.
50 */
51#define dispatch_data_empty \
52 DISPATCH_GLOBAL_OBJECT(dispatch_data_t, _dispatch_data_empty)
53API_AVAILABLE(macos(10.7), ios(5.0))
54DISPATCH_EXPORT struct dispatch_data_s _dispatch_data_empty;
55
56/*!
57 * @const DISPATCH_DATA_DESTRUCTOR_DEFAULT
58 * @discussion The default destructor for dispatch data objects.
59 * Used at data object creation to indicate that the supplied buffer should
60 * be copied into internal storage managed by the system.
61 */
62#define DISPATCH_DATA_DESTRUCTOR_DEFAULT NULL
63
64#ifdef __BLOCKS__
65/*! @parseOnly */
66#define DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(name) \
67 DISPATCH_EXPORT const dispatch_block_t _dispatch_data_destructor_##name
68#else
69#define DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(name) \
70 DISPATCH_EXPORT const dispatch_function_t \
71 _dispatch_data_destructor_##name
72#endif /* __BLOCKS__ */
73
74/*!
75 * @const DISPATCH_DATA_DESTRUCTOR_FREE
76 * @discussion The destructor for dispatch data objects created from a malloc'd
77 * buffer. Used at data object creation to indicate that the supplied buffer
78 * was allocated by the malloc() family and should be destroyed with free(3).
79 */
80#define DISPATCH_DATA_DESTRUCTOR_FREE (_dispatch_data_destructor_free)
81API_AVAILABLE(macos(10.7), ios(5.0))
82DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(free);
83
84/*!
85 * @const DISPATCH_DATA_DESTRUCTOR_MUNMAP
86 * @discussion The destructor for dispatch data objects that have been created
87 * from buffers that require deallocation with munmap(2).
88 */
89#define DISPATCH_DATA_DESTRUCTOR_MUNMAP (_dispatch_data_destructor_munmap)
90API_AVAILABLE(macos(10.9), ios(7.0))
91DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(munmap);
92
93#ifdef __BLOCKS__
94/*!
95 * @function dispatch_data_create
96 * Creates a dispatch data object from the given contiguous buffer of memory. If
97 * a non-default destructor is provided, ownership of the buffer remains with
98 * the caller (i.e. the bytes will not be copied). The last release of the data
99 * object will result in the invocation of the specified destructor on the
100 * specified queue to free the buffer.
101 *
102 * If the DISPATCH_DATA_DESTRUCTOR_FREE destructor is provided the buffer will
103 * be freed via free(3) and the queue argument ignored.
104 *
105 * If the DISPATCH_DATA_DESTRUCTOR_DEFAULT destructor is provided, data object
106 * creation will copy the buffer into internal memory managed by the system.
107 *
108 * @param buffer A contiguous buffer of data.
109 * @param size The size of the contiguous buffer of data.
110 * @param queue The queue to which the destructor should be submitted.
111 * @param destructor The destructor responsible for freeing the data when it
112 * is no longer needed.
113 * @result A newly created dispatch data object.
114 */
115API_AVAILABLE(macos(10.7), ios(5.0))
116DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT DISPATCH_NOTHROW
117dispatch_data_t
118dispatch_data_create(const void *buffer,
119 size_t size,
120 dispatch_queue_t _Nullable queue,
121 dispatch_block_t _Nullable destructor);
122#endif /* __BLOCKS__ */
123
124/*!
125 * @function dispatch_data_get_size
126 * Returns the logical size of the memory region(s) represented by the specified
127 * dispatch data object.
128 *
129 * @param data The dispatch data object to query.
130 * @result The number of bytes represented by the data object.
131 */
132API_AVAILABLE(macos(10.7), ios(5.0))
133DISPATCH_EXPORT DISPATCH_PURE DISPATCH_NONNULL1 DISPATCH_NOTHROW
134size_t
135dispatch_data_get_size(dispatch_data_t data);
136
137/*!
138 * @function dispatch_data_create_map
139 * Maps the memory represented by the specified dispatch data object as a single
140 * contiguous memory region and returns a new data object representing it.
141 * If non-NULL references to a pointer and a size variable are provided, they
142 * are filled with the location and extent of that region. These allow direct
143 * read access to the represented memory, but are only valid until the returned
144 * object is released. Under ARC, if that object is held in a variable with
145 * automatic storage, care needs to be taken to ensure that it is not released
146 * by the compiler before memory access via the pointer has been completed.
147 *
148 * @param data The dispatch data object to map.
149 * @param buffer_ptr A pointer to a pointer variable to be filled with the
150 * location of the mapped contiguous memory region, or
151 * NULL.
152 * @param size_ptr A pointer to a size_t variable to be filled with the
153 * size of the mapped contiguous memory region, or NULL.
154 * @result A newly created dispatch data object.
155 */
156API_AVAILABLE(macos(10.7), ios(5.0))
157DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_RETURNS_RETAINED
158DISPATCH_WARN_RESULT DISPATCH_NOTHROW
159dispatch_data_t
160dispatch_data_create_map(dispatch_data_t data,
161 const void *_Nullable *_Nullable buffer_ptr,
162 size_t *_Nullable size_ptr);
163
164/*!
165 * @function dispatch_data_create_concat
166 * Returns a new dispatch data object representing the concatenation of the
167 * specified data objects. Those objects may be released by the application
168 * after the call returns (however, the system might not deallocate the memory
169 * region(s) described by them until the newly created object has also been
170 * released).
171 *
172 * @param data1 The data object representing the region(s) of memory to place
173 * at the beginning of the newly created object.
174 * @param data2 The data object representing the region(s) of memory to place
175 * at the end of the newly created object.
176 * @result A newly created object representing the concatenation of the
177 * data1 and data2 objects.
178 */
179API_AVAILABLE(macos(10.7), ios(5.0))
180DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_RETURNS_RETAINED
181DISPATCH_WARN_RESULT DISPATCH_NOTHROW
182dispatch_data_t
183dispatch_data_create_concat(dispatch_data_t data1, dispatch_data_t data2);
184
185/*!
186 * @function dispatch_data_create_subrange
187 * Returns a new dispatch data object representing a subrange of the specified
188 * data object, which may be released by the application after the call returns
189 * (however, the system might not deallocate the memory region(s) described by
190 * that object until the newly created object has also been released).
191 *
192 * @param data The data object representing the region(s) of memory to
193 * create a subrange of.
194 * @param offset The offset into the data object where the subrange
195 * starts.
196 * @param length The length of the range.
197 * @result A newly created object representing the specified
198 * subrange of the data object.
199 */
200API_AVAILABLE(macos(10.7), ios(5.0))
201DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_RETURNS_RETAINED
202DISPATCH_WARN_RESULT DISPATCH_NOTHROW
203dispatch_data_t
204dispatch_data_create_subrange(dispatch_data_t data,
205 size_t offset,
206 size_t length);
207
208#ifdef __BLOCKS__
209/*!
210 * @typedef dispatch_data_applier_t
211 * A block to be invoked for every contiguous memory region in a data object.
212 *
213 * @param region A data object representing the current region.
214 * @param offset The logical offset of the current region to the start
215 * of the data object.
216 * @param buffer The location of the memory for the current region.
217 * @param size The size of the memory for the current region.
218 * @result A Boolean indicating whether traversal should continue.
219 */
220typedef bool (^dispatch_data_applier_t)(dispatch_data_t region,
221 size_t offset,
222 const void *buffer,
223 size_t size);
224
225/*!
226 * @function dispatch_data_apply
227 * Traverse the memory regions represented by the specified dispatch data object
228 * in logical order and invoke the specified block once for every contiguous
229 * memory region encountered.
230 *
231 * Each invocation of the block is passed a data object representing the current
232 * region and its logical offset, along with the memory location and extent of
233 * the region. These allow direct read access to the memory region, but are only
234 * valid until the passed-in region object is released. Note that the region
235 * object is released by the system when the block returns, it is the
236 * responsibility of the application to retain it if the region object or the
237 * associated memory location are needed after the block returns.
238 *
239 * @param data The data object to traverse.
240 * @param applier The block to be invoked for every contiguous memory
241 * region in the data object.
242 * @result A Boolean indicating whether traversal completed
243 * successfully.
244 */
245API_AVAILABLE(macos(10.7), ios(5.0))
246DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
247bool
248dispatch_data_apply(dispatch_data_t data,
249 DISPATCH_NOESCAPE dispatch_data_applier_t applier);
250#endif /* __BLOCKS__ */
251
252/*!
253 * @function dispatch_data_copy_region
254 * Finds the contiguous memory region containing the specified location among
255 * the regions represented by the specified object and returns a copy of the
256 * internal dispatch data object representing that region along with its logical
257 * offset in the specified object.
258 *
259 * @param data The dispatch data object to query.
260 * @param location The logical position in the data object to query.
261 * @param offset_ptr A pointer to a size_t variable to be filled with the
262 * logical offset of the returned region object to the
263 * start of the queried data object.
264 * @result A newly created dispatch data object.
265 */
266API_AVAILABLE(macos(10.7), ios(5.0))
267DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_RETURNS_RETAINED
268DISPATCH_WARN_RESULT DISPATCH_NOTHROW
269dispatch_data_t
270dispatch_data_copy_region(dispatch_data_t data,
271 size_t location,
272 size_t *offset_ptr);
273
274__END_DECLS
275
276DISPATCH_ASSUME_NONNULL_END
277
278#endif /* __DISPATCH_DATA__ */
lib/libc/include/x86_64-macos-gnu/dispatch/dispatch.h created+80
......@@ -0,0 +1,80 @@
1/*
2 * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_PUBLIC__
22#define __DISPATCH_PUBLIC__
23
24#ifdef __APPLE__
25#include <Availability.h>
26#include <os/availability.h>
27#include <TargetConditionals.h>
28#include <os/base.h>
29#elif defined(_WIN32)
30#include <os/generic_win_base.h>
31#elif defined(__unix__)
32#include <os/generic_unix_base.h>
33#endif
34
35#include <sys/types.h>
36#include <stddef.h>
37#include <stdint.h>
38#include <stdbool.h>
39#include <stdarg.h>
40#include <string.h>
41#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
42#include <unistd.h>
43#endif
44#include <fcntl.h>
45#if defined(_WIN32)
46#include <time.h>
47#endif
48
49#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__has_feature)
50#if __has_feature(modules)
51#if !defined(__arm__)
52#include <stdio.h> // for off_t (to match Glibc.modulemap)
53#endif
54#endif
55#endif
56
57#define DISPATCH_API_VERSION 20181008
58
59#ifndef __DISPATCH_INDIRECT__
60#define __DISPATCH_INDIRECT__
61#endif
62
63#include <os/object.h>
64#include <os/workgroup.h>
65#include <dispatch/base.h>
66#include <dispatch/time.h>
67#include <dispatch/object.h>
68#include <dispatch/queue.h>
69#include <dispatch/block.h>
70#include <dispatch/source.h>
71#include <dispatch/group.h>
72#include <dispatch/semaphore.h>
73#include <dispatch/once.h>
74#include <dispatch/data.h>
75#include <dispatch/io.h>
76#include <dispatch/workloop.h>
77
78#undef __DISPATCH_INDIRECT__
79
80#endif
lib/libc/include/x86_64-macos-gnu/dispatch/group.h created+279
......@@ -0,0 +1,279 @@
1/*
2 * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_GROUP__
22#define __DISPATCH_GROUP__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29DISPATCH_ASSUME_NONNULL_BEGIN
30
31/*!
32 * @typedef dispatch_group_t
33 * @abstract
34 * A group of blocks submitted to queues for asynchronous invocation.
35 */
36DISPATCH_DECL(dispatch_group);
37
38__BEGIN_DECLS
39
40/*!
41 * @function dispatch_group_create
42 *
43 * @abstract
44 * Creates new group with which blocks may be associated.
45 *
46 * @discussion
47 * This function creates a new group with which blocks may be associated.
48 * The dispatch group may be used to wait for the completion of the blocks it
49 * references. The group object memory is freed with dispatch_release().
50 *
51 * @result
52 * The newly created group, or NULL on failure.
53 */
54API_AVAILABLE(macos(10.6), ios(4.0))
55DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
56DISPATCH_NOTHROW
57dispatch_group_t
58dispatch_group_create(void);
59
60/*!
61 * @function dispatch_group_async
62 *
63 * @abstract
64 * Submits a block to a dispatch queue and associates the block with the given
65 * dispatch group.
66 *
67 * @discussion
68 * Submits a block to a dispatch queue and associates the block with the given
69 * dispatch group. The dispatch group may be used to wait for the completion
70 * of the blocks it references.
71 *
72 * @param group
73 * A dispatch group to associate with the submitted block.
74 * The result of passing NULL in this parameter is undefined.
75 *
76 * @param queue
77 * The dispatch queue to which the block will be submitted for asynchronous
78 * invocation.
79 *
80 * @param block
81 * The block to perform asynchronously.
82 */
83#ifdef __BLOCKS__
84API_AVAILABLE(macos(10.6), ios(4.0))
85DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
86void
87dispatch_group_async(dispatch_group_t group,
88 dispatch_queue_t queue,
89 dispatch_block_t block);
90#endif /* __BLOCKS__ */
91
92/*!
93 * @function dispatch_group_async_f
94 *
95 * @abstract
96 * Submits a function to a dispatch queue and associates the block with the
97 * given dispatch group.
98 *
99 * @discussion
100 * See dispatch_group_async() for details.
101 *
102 * @param group
103 * A dispatch group to associate with the submitted function.
104 * The result of passing NULL in this parameter is undefined.
105 *
106 * @param queue
107 * The dispatch queue to which the function will be submitted for asynchronous
108 * invocation.
109 *
110 * @param context
111 * The application-defined context parameter to pass to the function.
112 *
113 * @param work
114 * The application-defined function to invoke on the target queue. The first
115 * parameter passed to this function is the context provided to
116 * dispatch_group_async_f().
117 */
118API_AVAILABLE(macos(10.6), ios(4.0))
119DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_NONNULL4
120DISPATCH_NOTHROW
121void
122dispatch_group_async_f(dispatch_group_t group,
123 dispatch_queue_t queue,
124 void *_Nullable context,
125 dispatch_function_t work);
126
127/*!
128 * @function dispatch_group_wait
129 *
130 * @abstract
131 * Wait synchronously until all the blocks associated with a group have
132 * completed or until the specified timeout has elapsed.
133 *
134 * @discussion
135 * This function waits for the completion of the blocks associated with the
136 * given dispatch group, and returns after all blocks have completed or when
137 * the specified timeout has elapsed.
138 *
139 * This function will return immediately if there are no blocks associated
140 * with the dispatch group (i.e. the group is empty).
141 *
142 * The result of calling this function from multiple threads simultaneously
143 * with the same dispatch group is undefined.
144 *
145 * After the successful return of this function, the dispatch group is empty.
146 * It may either be released with dispatch_release() or re-used for additional
147 * blocks. See dispatch_group_async() for more information.
148 *
149 * @param group
150 * The dispatch group to wait on.
151 * The result of passing NULL in this parameter is undefined.
152 *
153 * @param timeout
154 * When to timeout (see dispatch_time). As a convenience, there are the
155 * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
156 *
157 * @result
158 * Returns zero on success (all blocks associated with the group completed
159 * within the specified timeout) or non-zero on error (i.e. timed out).
160 */
161API_AVAILABLE(macos(10.6), ios(4.0))
162DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
163intptr_t
164dispatch_group_wait(dispatch_group_t group, dispatch_time_t timeout);
165
166/*!
167 * @function dispatch_group_notify
168 *
169 * @abstract
170 * Schedule a block to be submitted to a queue when all the blocks associated
171 * with a group have completed.
172 *
173 * @discussion
174 * This function schedules a notification block to be submitted to the specified
175 * queue once all blocks associated with the dispatch group have completed.
176 *
177 * If no blocks are associated with the dispatch group (i.e. the group is empty)
178 * then the notification block will be submitted immediately.
179 *
180 * The group will be empty at the time the notification block is submitted to
181 * the target queue. The group may either be released with dispatch_release()
182 * or reused for additional operations.
183 * See dispatch_group_async() for more information.
184 *
185 * @param group
186 * The dispatch group to observe.
187 * The result of passing NULL in this parameter is undefined.
188 *
189 * @param queue
190 * The queue to which the supplied block will be submitted when the group
191 * completes.
192 *
193 * @param block
194 * The block to submit when the group completes.
195 */
196#ifdef __BLOCKS__
197API_AVAILABLE(macos(10.6), ios(4.0))
198DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
199void
200dispatch_group_notify(dispatch_group_t group,
201 dispatch_queue_t queue,
202 dispatch_block_t block);
203#endif /* __BLOCKS__ */
204
205/*!
206 * @function dispatch_group_notify_f
207 *
208 * @abstract
209 * Schedule a function to be submitted to a queue when all the blocks
210 * associated with a group have completed.
211 *
212 * @discussion
213 * See dispatch_group_notify() for details.
214 *
215 * @param group
216 * The dispatch group to observe.
217 * The result of passing NULL in this parameter is undefined.
218 *
219 * @param context
220 * The application-defined context parameter to pass to the function.
221 *
222 * @param work
223 * The application-defined function to invoke on the target queue. The first
224 * parameter passed to this function is the context provided to
225 * dispatch_group_notify_f().
226 */
227API_AVAILABLE(macos(10.6), ios(4.0))
228DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_NONNULL4
229DISPATCH_NOTHROW
230void
231dispatch_group_notify_f(dispatch_group_t group,
232 dispatch_queue_t queue,
233 void *_Nullable context,
234 dispatch_function_t work);
235
236/*!
237 * @function dispatch_group_enter
238 *
239 * @abstract
240 * Manually indicate a block has entered the group
241 *
242 * @discussion
243 * Calling this function indicates another block has joined the group through
244 * a means other than dispatch_group_async(). Calls to this function must be
245 * balanced with dispatch_group_leave().
246 *
247 * @param group
248 * The dispatch group to update.
249 * The result of passing NULL in this parameter is undefined.
250 */
251API_AVAILABLE(macos(10.6), ios(4.0))
252DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
253void
254dispatch_group_enter(dispatch_group_t group);
255
256/*!
257 * @function dispatch_group_leave
258 *
259 * @abstract
260 * Manually indicate a block in the group has completed
261 *
262 * @discussion
263 * Calling this function indicates block has completed and left the dispatch
264 * group by a means other than dispatch_group_async().
265 *
266 * @param group
267 * The dispatch group to update.
268 * The result of passing NULL in this parameter is undefined.
269 */
270API_AVAILABLE(macos(10.6), ios(4.0))
271DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
272void
273dispatch_group_leave(dispatch_group_t group);
274
275__END_DECLS
276
277DISPATCH_ASSUME_NONNULL_END
278
279#endif
lib/libc/include/x86_64-macos-gnu/dispatch/io.h created+597
......@@ -0,0 +1,597 @@
1/*
2 * Copyright (c) 2009-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_IO__
22#define __DISPATCH_IO__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29DISPATCH_ASSUME_NONNULL_BEGIN
30
31__BEGIN_DECLS
32
33/*! @header
34 * Dispatch I/O provides both stream and random access asynchronous read and
35 * write operations on file descriptors. One or more dispatch I/O channels may
36 * be created from a file descriptor as either the DISPATCH_IO_STREAM type or
37 * DISPATCH_IO_RANDOM type. Once a channel has been created the application may
38 * schedule asynchronous read and write operations.
39 *
40 * The application may set policies on the dispatch I/O channel to indicate the
41 * desired frequency of I/O handlers for long-running operations.
42 *
43 * Dispatch I/O also provides a memory management model for I/O buffers that
44 * avoids unnecessary copying of data when pipelined between channels. Dispatch
45 * I/O monitors the overall memory pressure and I/O access patterns for the
46 * application to optimize resource utilization.
47 */
48
49/*!
50 * @typedef dispatch_fd_t
51 * Native file descriptor type for the platform.
52 */
53#if defined(_WIN32)
54typedef intptr_t dispatch_fd_t;
55#else
56typedef int dispatch_fd_t;
57#endif
58
59/*!
60 * @functiongroup Dispatch I/O Convenience API
61 * Convenience wrappers around the dispatch I/O channel API, with simpler
62 * callback handler semantics and no explicit management of channel objects.
63 * File descriptors passed to the convenience API are treated as streams, and
64 * scheduling multiple operations on one file descriptor via the convenience API
65 * may incur more overhead than by using the dispatch I/O channel API directly.
66 */
67
68#ifdef __BLOCKS__
69/*!
70 * @function dispatch_read
71 * Schedule a read operation for asynchronous execution on the specified file
72 * descriptor. The specified handler is enqueued with the data read from the
73 * file descriptor when the operation has completed or an error occurs.
74 *
75 * The data object passed to the handler will be automatically released by the
76 * system when the handler returns. It is the responsibility of the application
77 * to retain, concatenate or copy the data object if it is needed after the
78 * handler returns.
79 *
80 * The data object passed to the handler will only contain as much data as is
81 * currently available from the file descriptor (up to the specified length).
82 *
83 * If an unrecoverable error occurs on the file descriptor, the handler will be
84 * enqueued with the appropriate error code along with a data object of any data
85 * that could be read successfully.
86 *
87 * An invocation of the handler with an error code of zero and an empty data
88 * object indicates that EOF was reached.
89 *
90 * The system takes control of the file descriptor until the handler is
91 * enqueued, and during this time file descriptor flags such as O_NONBLOCK will
92 * be modified by the system on behalf of the application. It is an error for
93 * the application to modify a file descriptor directly while it is under the
94 * control of the system, but it may create additional dispatch I/O convenience
95 * operations or dispatch I/O channels associated with that file descriptor.
96 *
97 * @param fd The file descriptor from which to read the data.
98 * @param length The length of data to read from the file descriptor,
99 * or SIZE_MAX to indicate that all of the data currently
100 * available from the file descriptor should be read.
101 * @param queue The dispatch queue to which the handler should be
102 * submitted.
103 * @param handler The handler to enqueue when data is ready to be
104 * delivered.
105 * param data The data read from the file descriptor.
106 * param error An errno condition for the read operation or
107 * zero if the read was successful.
108 */
109API_AVAILABLE(macos(10.7), ios(5.0))
110DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
111void
112dispatch_read(dispatch_fd_t fd,
113 size_t length,
114 dispatch_queue_t queue,
115 void (^handler)(dispatch_data_t data, int error));
116
117/*!
118 * @function dispatch_write
119 * Schedule a write operation for asynchronous execution on the specified file
120 * descriptor. The specified handler is enqueued when the operation has
121 * completed or an error occurs.
122 *
123 * If an unrecoverable error occurs on the file descriptor, the handler will be
124 * enqueued with the appropriate error code along with the data that could not
125 * be successfully written.
126 *
127 * An invocation of the handler with an error code of zero indicates that the
128 * data was fully written to the channel.
129 *
130 * The system takes control of the file descriptor until the handler is
131 * enqueued, and during this time file descriptor flags such as O_NONBLOCK will
132 * be modified by the system on behalf of the application. It is an error for
133 * the application to modify a file descriptor directly while it is under the
134 * control of the system, but it may create additional dispatch I/O convenience
135 * operations or dispatch I/O channels associated with that file descriptor.
136 *
137 * @param fd The file descriptor to which to write the data.
138 * @param data The data object to write to the file descriptor.
139 * @param queue The dispatch queue to which the handler should be
140 * submitted.
141 * @param handler The handler to enqueue when the data has been written.
142 * param data The data that could not be written to the I/O
143 * channel, or NULL.
144 * param error An errno condition for the write operation or
145 * zero if the write was successful.
146 */
147API_AVAILABLE(macos(10.7), ios(5.0))
148DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NONNULL4
149DISPATCH_NOTHROW
150void
151dispatch_write(dispatch_fd_t fd,
152 dispatch_data_t data,
153 dispatch_queue_t queue,
154 void (^handler)(dispatch_data_t _Nullable data, int error));
155#endif /* __BLOCKS__ */
156
157/*!
158 * @functiongroup Dispatch I/O Channel API
159 */
160
161/*!
162 * @typedef dispatch_io_t
163 * A dispatch I/O channel represents the asynchronous I/O policy applied to a
164 * file descriptor. I/O channels are first class dispatch objects and may be
165 * retained and released, suspended and resumed, etc.
166 */
167DISPATCH_DECL(dispatch_io);
168
169/*!
170 * @typedef dispatch_io_type_t
171 * The type of a dispatch I/O channel:
172 *
173 * @const DISPATCH_IO_STREAM A dispatch I/O channel representing a stream of
174 * bytes. Read and write operations on a channel of this type are performed
175 * serially (in order of creation) and read/write data at the file pointer
176 * position that is current at the time the operation starts executing.
177 * Operations of different type (read vs. write) may be performed simultaneously.
178 * Offsets passed to operations on a channel of this type are ignored.
179 *
180 * @const DISPATCH_IO_RANDOM A dispatch I/O channel representing a random
181 * access file. Read and write operations on a channel of this type may be
182 * performed concurrently and read/write data at the specified offset. Offsets
183 * are interpreted relative to the file pointer position current at the time the
184 * I/O channel is created. Attempting to create a channel of this type for a
185 * file descriptor that is not seekable will result in an error.
186 */
187#define DISPATCH_IO_STREAM 0
188#define DISPATCH_IO_RANDOM 1
189
190typedef unsigned long dispatch_io_type_t;
191
192#ifdef __BLOCKS__
193/*!
194 * @function dispatch_io_create
195 * Create a dispatch I/O channel associated with a file descriptor. The system
196 * takes control of the file descriptor until the channel is closed, an error
197 * occurs on the file descriptor or all references to the channel are released.
198 * At that time the specified cleanup handler will be enqueued and control over
199 * the file descriptor relinquished.
200 *
201 * While a file descriptor is under the control of a dispatch I/O channel, file
202 * descriptor flags such as O_NONBLOCK will be modified by the system on behalf
203 * of the application. It is an error for the application to modify a file
204 * descriptor directly while it is under the control of a dispatch I/O channel,
205 * but it may create additional channels associated with that file descriptor.
206 *
207 * @param type The desired type of I/O channel (DISPATCH_IO_STREAM
208 * or DISPATCH_IO_RANDOM).
209 * @param fd The file descriptor to associate with the I/O channel.
210 * @param queue The dispatch queue to which the handler should be submitted.
211 * @param cleanup_handler The handler to enqueue when the system
212 * relinquishes control over the file descriptor.
213 * param error An errno condition if control is relinquished
214 * because channel creation failed, zero otherwise.
215 * @result The newly created dispatch I/O channel or NULL if an error
216 * occurred (invalid type specified).
217 */
218API_AVAILABLE(macos(10.7), ios(5.0))
219DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
220DISPATCH_NOTHROW
221dispatch_io_t
222dispatch_io_create(dispatch_io_type_t type,
223 dispatch_fd_t fd,
224 dispatch_queue_t queue,
225 void (^cleanup_handler)(int error));
226
227/*!
228 * @function dispatch_io_create_with_path
229 * Create a dispatch I/O channel associated with a path name. The specified
230 * path, oflag and mode parameters will be passed to open(2) when the first I/O
231 * operation on the channel is ready to execute and the resulting file
232 * descriptor will remain open and under the control of the system until the
233 * channel is closed, an error occurs on the file descriptor or all references
234 * to the channel are released. At that time the file descriptor will be closed
235 * and the specified cleanup handler will be enqueued.
236 *
237 * @param type The desired type of I/O channel (DISPATCH_IO_STREAM
238 * or DISPATCH_IO_RANDOM).
239 * @param path The absolute path to associate with the I/O channel.
240 * @param oflag The flags to pass to open(2) when opening the file at
241 * path.
242 * @param mode The mode to pass to open(2) when creating the file at
243 * path (i.e. with flag O_CREAT), zero otherwise.
244 * @param queue The dispatch queue to which the handler should be
245 * submitted.
246 * @param cleanup_handler The handler to enqueue when the system
247 * has closed the file at path.
248 * param error An errno condition if control is relinquished
249 * because channel creation or opening of the
250 * specified file failed, zero otherwise.
251 * @result The newly created dispatch I/O channel or NULL if an error
252 * occurred (invalid type or non-absolute path specified).
253 */
254API_AVAILABLE(macos(10.7), ios(5.0))
255DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED
256DISPATCH_WARN_RESULT DISPATCH_NOTHROW
257dispatch_io_t
258dispatch_io_create_with_path(dispatch_io_type_t type,
259 const char *path, int oflag, mode_t mode,
260 dispatch_queue_t queue,
261 void (^cleanup_handler)(int error));
262
263/*!
264 * @function dispatch_io_create_with_io
265 * Create a new dispatch I/O channel from an existing dispatch I/O channel.
266 * The new channel inherits the file descriptor or path name associated with
267 * the existing channel, but not its channel type or policies.
268 *
269 * If the existing channel is associated with a file descriptor, control by the
270 * system over that file descriptor is extended until the new channel is also
271 * closed, an error occurs on the file descriptor, or all references to both
272 * channels are released. At that time the specified cleanup handler will be
273 * enqueued and control over the file descriptor relinquished.
274 *
275 * While a file descriptor is under the control of a dispatch I/O channel, file
276 * descriptor flags such as O_NONBLOCK will be modified by the system on behalf
277 * of the application. It is an error for the application to modify a file
278 * descriptor directly while it is under the control of a dispatch I/O channel,
279 * but it may create additional channels associated with that file descriptor.
280 *
281 * @param type The desired type of I/O channel (DISPATCH_IO_STREAM
282 * or DISPATCH_IO_RANDOM).
283 * @param io The existing channel to create the new I/O channel from.
284 * @param queue The dispatch queue to which the handler should be submitted.
285 * @param cleanup_handler The handler to enqueue when the system
286 * relinquishes control over the file descriptor
287 * (resp. closes the file at path) associated with
288 * the existing channel.
289 * param error An errno condition if control is relinquished
290 * because channel creation failed, zero otherwise.
291 * @result The newly created dispatch I/O channel or NULL if an error
292 * occurred (invalid type specified).
293 */
294API_AVAILABLE(macos(10.7), ios(5.0))
295DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED
296DISPATCH_WARN_RESULT DISPATCH_NOTHROW
297dispatch_io_t
298dispatch_io_create_with_io(dispatch_io_type_t type,
299 dispatch_io_t io,
300 dispatch_queue_t queue,
301 void (^cleanup_handler)(int error));
302
303/*!
304 * @typedef dispatch_io_handler_t
305 * The prototype of I/O handler blocks for dispatch I/O operations.
306 *
307 * @param done A flag indicating whether the operation is complete.
308 * @param data The data object to be handled.
309 * @param error An errno condition for the operation.
310 */
311typedef void (^dispatch_io_handler_t)(bool done, dispatch_data_t _Nullable data,
312 int error);
313
314/*!
315 * @function dispatch_io_read
316 * Schedule a read operation for asynchronous execution on the specified I/O
317 * channel. The I/O handler is enqueued one or more times depending on the
318 * general load of the system and the policy specified on the I/O channel.
319 *
320 * Any data read from the channel is described by the dispatch data object
321 * passed to the I/O handler. This object will be automatically released by the
322 * system when the I/O handler returns. It is the responsibility of the
323 * application to retain, concatenate or copy the data object if it is needed
324 * after the I/O handler returns.
325 *
326 * Dispatch I/O handlers are not reentrant. The system will ensure that no new
327 * I/O handler instance is invoked until the previously enqueued handler block
328 * has returned.
329 *
330 * An invocation of the I/O handler with the done flag set indicates that the
331 * read operation is complete and that the handler will not be enqueued again.
332 *
333 * If an unrecoverable error occurs on the I/O channel's underlying file
334 * descriptor, the I/O handler will be enqueued with the done flag set, the
335 * appropriate error code and a NULL data object.
336 *
337 * An invocation of the I/O handler with the done flag set, an error code of
338 * zero and an empty data object indicates that EOF was reached.
339 *
340 * @param channel The dispatch I/O channel from which to read the data.
341 * @param offset The offset relative to the channel position from which
342 * to start reading (only for DISPATCH_IO_RANDOM).
343 * @param length The length of data to read from the I/O channel, or
344 * SIZE_MAX to indicate that data should be read until EOF
345 * is reached.
346 * @param queue The dispatch queue to which the I/O handler should be
347 * submitted.
348 * @param io_handler The I/O handler to enqueue when data is ready to be
349 * delivered.
350 * param done A flag indicating whether the operation is complete.
351 * param data An object with the data most recently read from the
352 * I/O channel as part of this read operation, or NULL.
353 * param error An errno condition for the read operation or zero if
354 * the read was successful.
355 */
356API_AVAILABLE(macos(10.7), ios(5.0))
357DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL4 DISPATCH_NONNULL5
358DISPATCH_NOTHROW
359void
360dispatch_io_read(dispatch_io_t channel,
361 off_t offset,
362 size_t length,
363 dispatch_queue_t queue,
364 dispatch_io_handler_t io_handler);
365
366/*!
367 * @function dispatch_io_write
368 * Schedule a write operation for asynchronous execution on the specified I/O
369 * channel. The I/O handler is enqueued one or more times depending on the
370 * general load of the system and the policy specified on the I/O channel.
371 *
372 * Any data remaining to be written to the I/O channel is described by the
373 * dispatch data object passed to the I/O handler. This object will be
374 * automatically released by the system when the I/O handler returns. It is the
375 * responsibility of the application to retain, concatenate or copy the data
376 * object if it is needed after the I/O handler returns.
377 *
378 * Dispatch I/O handlers are not reentrant. The system will ensure that no new
379 * I/O handler instance is invoked until the previously enqueued handler block
380 * has returned.
381 *
382 * An invocation of the I/O handler with the done flag set indicates that the
383 * write operation is complete and that the handler will not be enqueued again.
384 *
385 * If an unrecoverable error occurs on the I/O channel's underlying file
386 * descriptor, the I/O handler will be enqueued with the done flag set, the
387 * appropriate error code and an object containing the data that could not be
388 * written.
389 *
390 * An invocation of the I/O handler with the done flag set and an error code of
391 * zero indicates that the data was fully written to the channel.
392 *
393 * @param channel The dispatch I/O channel on which to write the data.
394 * @param offset The offset relative to the channel position from which
395 * to start writing (only for DISPATCH_IO_RANDOM).
396 * @param data The data to write to the I/O channel. The data object
397 * will be retained by the system until the write operation
398 * is complete.
399 * @param queue The dispatch queue to which the I/O handler should be
400 * submitted.
401 * @param io_handler The I/O handler to enqueue when data has been delivered.
402 * param done A flag indicating whether the operation is complete.
403 * param data An object of the data remaining to be
404 * written to the I/O channel as part of this write
405 * operation, or NULL.
406 * param error An errno condition for the write operation or zero
407 * if the write was successful.
408 */
409API_AVAILABLE(macos(10.7), ios(5.0))
410DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NONNULL4
411DISPATCH_NONNULL5 DISPATCH_NOTHROW
412void
413dispatch_io_write(dispatch_io_t channel,
414 off_t offset,
415 dispatch_data_t data,
416 dispatch_queue_t queue,
417 dispatch_io_handler_t io_handler);
418#endif /* __BLOCKS__ */
419
420/*!
421 * @typedef dispatch_io_close_flags_t
422 * The type of flags you can set on a dispatch_io_close() call
423 *
424 * @const DISPATCH_IO_STOP Stop outstanding operations on a channel when
425 * the channel is closed.
426 */
427#define DISPATCH_IO_STOP 0x1
428
429typedef unsigned long dispatch_io_close_flags_t;
430
431/*!
432 * @function dispatch_io_close
433 * Close the specified I/O channel to new read or write operations; scheduling
434 * operations on a closed channel results in their handler returning an error.
435 *
436 * If the DISPATCH_IO_STOP flag is provided, the system will make a best effort
437 * to interrupt any outstanding read and write operations on the I/O channel,
438 * otherwise those operations will run to completion normally.
439 * Partial results of read and write operations may be returned even after a
440 * channel is closed with the DISPATCH_IO_STOP flag.
441 * The final invocation of an I/O handler of an interrupted operation will be
442 * passed an ECANCELED error code, as will the I/O handler of an operation
443 * scheduled on a closed channel.
444 *
445 * @param channel The dispatch I/O channel to close.
446 * @param flags The flags for the close operation.
447 */
448API_AVAILABLE(macos(10.7), ios(5.0))
449DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
450void
451dispatch_io_close(dispatch_io_t channel, dispatch_io_close_flags_t flags);
452
453#ifdef __BLOCKS__
454/*!
455 * @function dispatch_io_barrier
456 * Schedule a barrier operation on the specified I/O channel; all previously
457 * scheduled operations on the channel will complete before the provided
458 * barrier block is enqueued onto the global queue determined by the channel's
459 * target queue, and no subsequently scheduled operations will start until the
460 * barrier block has returned.
461 *
462 * If multiple channels are associated with the same file descriptor, a barrier
463 * operation scheduled on any of these channels will act as a barrier across all
464 * channels in question, i.e. all previously scheduled operations on any of the
465 * channels will complete before the barrier block is enqueued, and no
466 * operations subsequently scheduled on any of the channels will start until the
467 * barrier block has returned.
468 *
469 * While the barrier block is running, it may safely operate on the channel's
470 * underlying file descriptor with fsync(2), lseek(2) etc. (but not close(2)).
471 *
472 * @param channel The dispatch I/O channel to schedule the barrier on.
473 * @param barrier The barrier block.
474 */
475API_AVAILABLE(macos(10.7), ios(5.0))
476DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
477void
478dispatch_io_barrier(dispatch_io_t channel, dispatch_block_t barrier);
479#endif /* __BLOCKS__ */
480
481/*!
482 * @function dispatch_io_get_descriptor
483 * Returns the file descriptor underlying a dispatch I/O channel.
484 *
485 * Will return -1 for a channel closed with dispatch_io_close() and for a
486 * channel associated with a path name that has not yet been open(2)ed.
487 *
488 * If called from a barrier block scheduled on a channel associated with a path
489 * name that has not yet been open(2)ed, this will trigger the channel open(2)
490 * operation and return the resulting file descriptor.
491 *
492 * @param channel The dispatch I/O channel to query.
493 * @result The file descriptor underlying the channel, or -1.
494 */
495API_AVAILABLE(macos(10.7), ios(5.0))
496DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
497dispatch_fd_t
498dispatch_io_get_descriptor(dispatch_io_t channel);
499
500/*!
501 * @function dispatch_io_set_high_water
502 * Set a high water mark on the I/O channel for all operations.
503 *
504 * The system will make a best effort to enqueue I/O handlers with partial
505 * results as soon the number of bytes processed by an operation (i.e. read or
506 * written) reaches the high water mark.
507 *
508 * The size of data objects passed to I/O handlers for this channel will never
509 * exceed the specified high water mark.
510 *
511 * The default value for the high water mark is unlimited (i.e. SIZE_MAX).
512 *
513 * @param channel The dispatch I/O channel on which to set the policy.
514 * @param high_water The number of bytes to use as a high water mark.
515 */
516API_AVAILABLE(macos(10.7), ios(5.0))
517DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
518void
519dispatch_io_set_high_water(dispatch_io_t channel, size_t high_water);
520
521/*!
522 * @function dispatch_io_set_low_water
523 * Set a low water mark on the I/O channel for all operations.
524 *
525 * The system will process (i.e. read or write) at least the low water mark
526 * number of bytes for an operation before enqueueing I/O handlers with partial
527 * results.
528 *
529 * The size of data objects passed to intermediate I/O handler invocations for
530 * this channel (i.e. excluding the final invocation) will never be smaller than
531 * the specified low water mark, except if the channel has an interval with the
532 * DISPATCH_IO_STRICT_INTERVAL flag set or if EOF or an error was encountered.
533 *
534 * I/O handlers should be prepared to receive amounts of data significantly
535 * larger than the low water mark in general. If an I/O handler requires
536 * intermediate results of fixed size, set both the low and and the high water
537 * mark to that size.
538 *
539 * The default value for the low water mark is unspecified, but must be assumed
540 * to be such that intermediate handler invocations may occur.
541 * If I/O handler invocations with partial results are not desired, set the
542 * low water mark to SIZE_MAX.
543 *
544 * @param channel The dispatch I/O channel on which to set the policy.
545 * @param low_water The number of bytes to use as a low water mark.
546 */
547API_AVAILABLE(macos(10.7), ios(5.0))
548DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
549void
550dispatch_io_set_low_water(dispatch_io_t channel, size_t low_water);
551
552/*!
553 * @typedef dispatch_io_interval_flags_t
554 * Type of flags to set on dispatch_io_set_interval()
555 *
556 * @const DISPATCH_IO_STRICT_INTERVAL Enqueue I/O handlers at a channel's
557 * interval setting even if the amount of data ready to be delivered is inferior
558 * to the low water mark (or zero).
559 */
560#define DISPATCH_IO_STRICT_INTERVAL 0x1
561
562typedef unsigned long dispatch_io_interval_flags_t;
563
564/*!
565 * @function dispatch_io_set_interval
566 * Set a nanosecond interval at which I/O handlers are to be enqueued on the
567 * I/O channel for all operations.
568 *
569 * This allows an application to receive periodic feedback on the progress of
570 * read and write operations, e.g. for the purposes of displaying progress bars.
571 *
572 * If the amount of data ready to be delivered to an I/O handler at the interval
573 * is inferior to the channel low water mark, the handler will only be enqueued
574 * if the DISPATCH_IO_STRICT_INTERVAL flag is set.
575 *
576 * Note that the system may defer enqueueing interval I/O handlers by a small
577 * unspecified amount of leeway in order to align with other system activity for
578 * improved system performance or power consumption.
579 *
580 * @param channel The dispatch I/O channel on which to set the policy.
581 * @param interval The interval in nanoseconds at which delivery of the I/O
582 * handler is desired.
583 * @param flags Flags indicating desired data delivery behavior at
584 * interval time.
585 */
586API_AVAILABLE(macos(10.7), ios(5.0))
587DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
588void
589dispatch_io_set_interval(dispatch_io_t channel,
590 uint64_t interval,
591 dispatch_io_interval_flags_t flags);
592
593__END_DECLS
594
595DISPATCH_ASSUME_NONNULL_END
596
597#endif /* __DISPATCH_IO__ */
lib/libc/include/x86_64-macos-gnu/dispatch/object.h created+606
......@@ -0,0 +1,606 @@
1/*
2 * Copyright (c) 2008-2012 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_OBJECT__
22#define __DISPATCH_OBJECT__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29#if __has_include(<sys/qos.h>)
30#include <sys/qos.h>
31#endif
32
33DISPATCH_ASSUME_NONNULL_BEGIN
34
35/*!
36 * @typedef dispatch_object_t
37 *
38 * @abstract
39 * Abstract base type for all dispatch objects.
40 * The details of the type definition are language-specific.
41 *
42 * @discussion
43 * Dispatch objects are reference counted via calls to dispatch_retain() and
44 * dispatch_release().
45 */
46
47#if OS_OBJECT_USE_OBJC
48/*
49 * By default, dispatch objects are declared as Objective-C types when building
50 * with an Objective-C compiler. This allows them to participate in ARC, in RR
51 * management by the Blocks runtime and in leaks checking by the static
52 * analyzer, and enables them to be added to Cocoa collections.
53 * See <os/object.h> for details.
54 */
55OS_OBJECT_DECL_CLASS(dispatch_object);
56
57#if OS_OBJECT_SWIFT3
58#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS_SWIFT(name, dispatch_object)
59#define DISPATCH_DECL_SUBCLASS(name, base) OS_OBJECT_DECL_SUBCLASS_SWIFT(name, base)
60#else // OS_OBJECT_SWIFT3
61#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS(name, dispatch_object)
62#define DISPATCH_DECL_SUBCLASS(name, base) OS_OBJECT_DECL_SUBCLASS(name, base)
63
64DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
65void
66_dispatch_object_validate(dispatch_object_t object)
67{
68 void *isa = *(void *volatile*)(OS_OBJECT_BRIDGE void*)object;
69 (void)isa;
70}
71#endif // OS_OBJECT_SWIFT3
72
73#define DISPATCH_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object))
74#define DISPATCH_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
75#elif defined(__cplusplus) && !defined(__DISPATCH_BUILDING_DISPATCH__)
76/*
77 * Dispatch objects are NOT C++ objects. Nevertheless, we can at least keep C++
78 * aware of type compatibility.
79 */
80typedef struct dispatch_object_s {
81private:
82 dispatch_object_s();
83 ~dispatch_object_s();
84 dispatch_object_s(const dispatch_object_s &);
85 void operator=(const dispatch_object_s &);
86} *dispatch_object_t;
87#define DISPATCH_DECL(name) \
88 typedef struct name##_s : public dispatch_object_s {} *name##_t
89#define DISPATCH_DECL_SUBCLASS(name, base) \
90 typedef struct name##_s : public base##_s {} *name##_t
91#define DISPATCH_GLOBAL_OBJECT(type, object) (static_cast<type>(&(object)))
92#define DISPATCH_RETURNS_RETAINED
93#else /* Plain C */
94typedef union {
95 struct _os_object_s *_os_obj;
96 struct dispatch_object_s *_do;
97 struct dispatch_queue_s *_dq;
98 struct dispatch_queue_attr_s *_dqa;
99 struct dispatch_group_s *_dg;
100 struct dispatch_source_s *_ds;
101 struct dispatch_channel_s *_dch;
102 struct dispatch_mach_s *_dm;
103 struct dispatch_mach_msg_s *_dmsg;
104 struct dispatch_semaphore_s *_dsema;
105 struct dispatch_data_s *_ddata;
106 struct dispatch_io_s *_dchannel;
107} dispatch_object_t DISPATCH_TRANSPARENT_UNION;
108#define DISPATCH_DECL(name) typedef struct name##_s *name##_t
109#define DISPATCH_DECL_SUBCLASS(name, base) typedef base##_t name##_t
110#define DISPATCH_GLOBAL_OBJECT(type, object) ((type)&(object))
111#define DISPATCH_RETURNS_RETAINED
112#endif
113
114#if OS_OBJECT_SWIFT3 && OS_OBJECT_USE_OBJC
115#define DISPATCH_SOURCE_TYPE_DECL(name) \
116 DISPATCH_EXPORT struct dispatch_source_type_s \
117 _dispatch_source_type_##name; \
118 OS_OBJECT_DECL_PROTOCOL(dispatch_source_##name, <OS_dispatch_source>); \
119 OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL( \
120 dispatch_source, dispatch_source_##name)
121#define DISPATCH_SOURCE_DECL(name) \
122 DISPATCH_DECL(name); \
123 OS_OBJECT_DECL_PROTOCOL(name, <NSObject>); \
124 OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, name)
125#ifndef DISPATCH_DATA_DECL
126#define DISPATCH_DATA_DECL(name) OS_OBJECT_DECL_SWIFT(name)
127#endif // DISPATCH_DATA_DECL
128#else
129#define DISPATCH_SOURCE_DECL(name) \
130 DISPATCH_DECL(name);
131#define DISPATCH_DATA_DECL(name) DISPATCH_DECL(name)
132#define DISPATCH_SOURCE_TYPE_DECL(name) \
133 DISPATCH_EXPORT const struct dispatch_source_type_s \
134 _dispatch_source_type_##name
135#endif
136
137#ifdef __BLOCKS__
138/*!
139 * @typedef dispatch_block_t
140 *
141 * @abstract
142 * The type of blocks submitted to dispatch queues, which take no arguments
143 * and have no return value.
144 *
145 * @discussion
146 * When not building with Objective-C ARC, a block object allocated on or
147 * copied to the heap must be released with a -[release] message or the
148 * Block_release() function.
149 *
150 * The declaration of a block literal allocates storage on the stack.
151 * Therefore, this is an invalid construct:
152 * <code>
153 * dispatch_block_t block;
154 * if (x) {
155 * block = ^{ printf("true\n"); };
156 * } else {
157 * block = ^{ printf("false\n"); };
158 * }
159 * block(); // unsafe!!!
160 * </code>
161 *
162 * What is happening behind the scenes:
163 * <code>
164 * if (x) {
165 * struct Block __tmp_1 = ...; // setup details
166 * block = &__tmp_1;
167 * } else {
168 * struct Block __tmp_2 = ...; // setup details
169 * block = &__tmp_2;
170 * }
171 * </code>
172 *
173 * As the example demonstrates, the address of a stack variable is escaping the
174 * scope in which it is allocated. That is a classic C bug.
175 *
176 * Instead, the block literal must be copied to the heap with the Block_copy()
177 * function or by sending it a -[copy] message.
178 */
179typedef void (^dispatch_block_t)(void);
180#endif // __BLOCKS__
181
182__BEGIN_DECLS
183
184/*!
185 * @typedef dispatch_qos_class_t
186 * Alias for qos_class_t type.
187 */
188#if __has_include(<sys/qos.h>)
189typedef qos_class_t dispatch_qos_class_t;
190#else
191typedef unsigned int dispatch_qos_class_t;
192#endif
193
194/*!
195 * @function dispatch_retain
196 *
197 * @abstract
198 * Increment the reference count of a dispatch object.
199 *
200 * @discussion
201 * Calls to dispatch_retain() must be balanced with calls to
202 * dispatch_release().
203 *
204 * @param object
205 * The object to retain.
206 * The result of passing NULL in this parameter is undefined.
207 */
208API_AVAILABLE(macos(10.6), ios(4.0))
209DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
210DISPATCH_SWIFT_UNAVAILABLE("Can't be used with ARC")
211void
212dispatch_retain(dispatch_object_t object);
213#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
214#undef dispatch_retain
215#define dispatch_retain(object) \
216 __extension__({ dispatch_object_t _o = (object); \
217 _dispatch_object_validate(_o); (void)[_o retain]; })
218#endif
219
220/*!
221 * @function dispatch_release
222 *
223 * @abstract
224 * Decrement the reference count of a dispatch object.
225 *
226 * @discussion
227 * A dispatch object is asynchronously deallocated once all references are
228 * released (i.e. the reference count becomes zero). The system does not
229 * guarantee that a given client is the last or only reference to a given
230 * object.
231 *
232 * @param object
233 * The object to release.
234 * The result of passing NULL in this parameter is undefined.
235 */
236API_AVAILABLE(macos(10.6), ios(4.0))
237DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
238DISPATCH_SWIFT_UNAVAILABLE("Can't be used with ARC")
239void
240dispatch_release(dispatch_object_t object);
241#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
242#undef dispatch_release
243#define dispatch_release(object) \
244 __extension__({ dispatch_object_t _o = (object); \
245 _dispatch_object_validate(_o); [_o release]; })
246#endif
247
248/*!
249 * @function dispatch_get_context
250 *
251 * @abstract
252 * Returns the application defined context of the object.
253 *
254 * @param object
255 * The result of passing NULL in this parameter is undefined.
256 *
257 * @result
258 * The context of the object; may be NULL.
259 */
260API_AVAILABLE(macos(10.6), ios(4.0))
261DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_PURE DISPATCH_WARN_RESULT
262DISPATCH_NOTHROW
263void *_Nullable
264dispatch_get_context(dispatch_object_t object);
265
266/*!
267 * @function dispatch_set_context
268 *
269 * @abstract
270 * Associates an application defined context with the object.
271 *
272 * @param object
273 * The result of passing NULL in this parameter is undefined.
274 *
275 * @param context
276 * The new client defined context for the object. This may be NULL.
277 *
278 */
279API_AVAILABLE(macos(10.6), ios(4.0))
280DISPATCH_EXPORT DISPATCH_NOTHROW
281void
282dispatch_set_context(dispatch_object_t object, void *_Nullable context);
283
284/*!
285 * @function dispatch_set_finalizer_f
286 *
287 * @abstract
288 * Set the finalizer function for a dispatch object.
289 *
290 * @param object
291 * The dispatch object to modify.
292 * The result of passing NULL in this parameter is undefined.
293 *
294 * @param finalizer
295 * The finalizer function pointer.
296 *
297 * @discussion
298 * A dispatch object's finalizer will be invoked on the object's target queue
299 * after all references to the object have been released. This finalizer may be
300 * used by the application to release any resources associated with the object,
301 * such as freeing the object's context.
302 * The context parameter passed to the finalizer function is the current
303 * context of the dispatch object at the time the finalizer call is made.
304 */
305API_AVAILABLE(macos(10.6), ios(4.0))
306DISPATCH_EXPORT DISPATCH_NOTHROW
307void
308dispatch_set_finalizer_f(dispatch_object_t object,
309 dispatch_function_t _Nullable finalizer);
310
311/*!
312 * @function dispatch_activate
313 *
314 * @abstract
315 * Activates the specified dispatch object.
316 *
317 * @discussion
318 * Dispatch objects such as queues and sources may be created in an inactive
319 * state. Objects in this state have to be activated before any blocks
320 * associated with them will be invoked.
321 *
322 * The target queue of inactive objects can be changed using
323 * dispatch_set_target_queue(). Change of target queue is no longer permitted
324 * once an initially inactive object has been activated.
325 *
326 * Calling dispatch_activate() on an active object has no effect.
327 * Releasing the last reference count on an inactive object is undefined.
328 *
329 * @param object
330 * The object to be activated.
331 * The result of passing NULL in this parameter is undefined.
332 */
333API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
334DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
335void
336dispatch_activate(dispatch_object_t object);
337
338/*!
339 * @function dispatch_suspend
340 *
341 * @abstract
342 * Suspends the invocation of blocks on a dispatch object.
343 *
344 * @discussion
345 * A suspended object will not invoke any blocks associated with it. The
346 * suspension of an object will occur after any running block associated with
347 * the object completes.
348 *
349 * Calls to dispatch_suspend() must be balanced with calls
350 * to dispatch_resume().
351 *
352 * @param object
353 * The object to be suspended.
354 * The result of passing NULL in this parameter is undefined.
355 */
356API_AVAILABLE(macos(10.6), ios(4.0))
357DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
358void
359dispatch_suspend(dispatch_object_t object);
360
361/*!
362 * @function dispatch_resume
363 *
364 * @abstract
365 * Resumes the invocation of blocks on a dispatch object.
366 *
367 * @discussion
368 * Dispatch objects can be suspended with dispatch_suspend(), which increments
369 * an internal suspension count. dispatch_resume() is the inverse operation,
370 * and consumes suspension counts. When the last suspension count is consumed,
371 * blocks associated with the object will be invoked again.
372 *
373 * For backward compatibility reasons, dispatch_resume() on an inactive and not
374 * otherwise suspended dispatch source object has the same effect as calling
375 * dispatch_activate(). For new code, using dispatch_activate() is preferred.
376 *
377 * If the specified object has zero suspension count and is not an inactive
378 * source, this function will result in an assertion and the process being
379 * terminated.
380 *
381 * @param object
382 * The object to be resumed.
383 * The result of passing NULL in this parameter is undefined.
384 */
385API_AVAILABLE(macos(10.6), ios(4.0))
386DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
387void
388dispatch_resume(dispatch_object_t object);
389
390/*!
391 * @function dispatch_set_qos_class_floor
392 *
393 * @abstract
394 * Sets the QOS class floor on a dispatch queue, source or workloop.
395 *
396 * @discussion
397 * The QOS class of workitems submitted to this object asynchronously will be
398 * elevated to at least the specified QOS class floor. The QOS of the workitem
399 * will be used if higher than the floor even when the workitem has been created
400 * without "ENFORCE" semantics.
401 *
402 * Setting the QOS class floor is equivalent to the QOS effects of configuring
403 * a queue whose target queue has a QoS class set to the same value.
404 *
405 * @param object
406 * A dispatch queue, workloop, or source to configure.
407 * The object must be inactive.
408 *
409 * Passing another object type or an object that has been activated is undefined
410 * and will cause the process to be terminated.
411 *
412 * @param qos_class
413 * A QOS class value:
414 * - QOS_CLASS_USER_INTERACTIVE
415 * - QOS_CLASS_USER_INITIATED
416 * - QOS_CLASS_DEFAULT
417 * - QOS_CLASS_UTILITY
418 * - QOS_CLASS_BACKGROUND
419 * Passing any other value is undefined.
420 *
421 * @param relative_priority
422 * A relative priority within the QOS class. This value is a negative
423 * offset from the maximum supported scheduler priority for the given class.
424 * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
425 * is undefined.
426 */
427API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
428DISPATCH_EXPORT DISPATCH_NOTHROW
429void
430dispatch_set_qos_class_floor(dispatch_object_t object,
431 dispatch_qos_class_t qos_class, int relative_priority);
432
433#ifdef __BLOCKS__
434/*!
435 * @function dispatch_wait
436 *
437 * @abstract
438 * Wait synchronously for an object or until the specified timeout has elapsed.
439 *
440 * @discussion
441 * Type-generic macro that maps to dispatch_block_wait, dispatch_group_wait or
442 * dispatch_semaphore_wait, depending on the type of the first argument.
443 * See documentation for these functions for more details.
444 * This function is unavailable for any other object type.
445 *
446 * @param object
447 * The object to wait on.
448 * The result of passing NULL in this parameter is undefined.
449 *
450 * @param timeout
451 * When to timeout (see dispatch_time). As a convenience, there are the
452 * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
453 *
454 * @result
455 * Returns zero on success or non-zero on error (i.e. timed out).
456 */
457DISPATCH_UNAVAILABLE
458DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
459intptr_t
460dispatch_wait(void *object, dispatch_time_t timeout);
461#if __has_extension(c_generic_selections)
462#define dispatch_wait(object, timeout) \
463 _Generic((object), \
464 dispatch_block_t:dispatch_block_wait, \
465 dispatch_group_t:dispatch_group_wait, \
466 dispatch_semaphore_t:dispatch_semaphore_wait \
467 )((object),(timeout))
468#endif
469
470/*!
471 * @function dispatch_notify
472 *
473 * @abstract
474 * Schedule a notification block to be submitted to a queue when the execution
475 * of a specified object has completed.
476 *
477 * @discussion
478 * Type-generic macro that maps to dispatch_block_notify or
479 * dispatch_group_notify, depending on the type of the first argument.
480 * See documentation for these functions for more details.
481 * This function is unavailable for any other object type.
482 *
483 * @param object
484 * The object to observe.
485 * The result of passing NULL in this parameter is undefined.
486 *
487 * @param queue
488 * The queue to which the supplied notification block will be submitted when
489 * the observed object completes.
490 *
491 * @param notification_block
492 * The block to submit when the observed object completes.
493 */
494DISPATCH_UNAVAILABLE
495DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
496void
497dispatch_notify(void *object, dispatch_object_t queue,
498 dispatch_block_t notification_block);
499#if __has_extension(c_generic_selections)
500#define dispatch_notify(object, queue, notification_block) \
501 _Generic((object), \
502 dispatch_block_t:dispatch_block_notify, \
503 dispatch_group_t:dispatch_group_notify \
504 )((object),(queue), (notification_block))
505#endif
506
507/*!
508 * @function dispatch_cancel
509 *
510 * @abstract
511 * Cancel the specified object.
512 *
513 * @discussion
514 * Type-generic macro that maps to dispatch_block_cancel or
515 * dispatch_source_cancel, depending on the type of the first argument.
516 * See documentation for these functions for more details.
517 * This function is unavailable for any other object type.
518 *
519 * @param object
520 * The object to cancel.
521 * The result of passing NULL in this parameter is undefined.
522 */
523DISPATCH_UNAVAILABLE
524DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
525void
526dispatch_cancel(void *object);
527#if __has_extension(c_generic_selections)
528#define dispatch_cancel(object) \
529 _Generic((object), \
530 dispatch_block_t:dispatch_block_cancel, \
531 dispatch_source_t:dispatch_source_cancel \
532 )((object))
533#endif
534
535/*!
536 * @function dispatch_testcancel
537 *
538 * @abstract
539 * Test whether the specified object has been canceled
540 *
541 * @discussion
542 * Type-generic macro that maps to dispatch_block_testcancel or
543 * dispatch_source_testcancel, depending on the type of the first argument.
544 * See documentation for these functions for more details.
545 * This function is unavailable for any other object type.
546 *
547 * @param object
548 * The object to test.
549 * The result of passing NULL in this parameter is undefined.
550 *
551 * @result
552 * Non-zero if canceled and zero if not canceled.
553 */
554DISPATCH_UNAVAILABLE
555DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
556DISPATCH_NOTHROW
557intptr_t
558dispatch_testcancel(void *object);
559#if __has_extension(c_generic_selections)
560#define dispatch_testcancel(object) \
561 _Generic((object), \
562 dispatch_block_t:dispatch_block_testcancel, \
563 dispatch_source_t:dispatch_source_testcancel \
564 )((object))
565#endif
566#endif // __BLOCKS__
567
568/*!
569 * @function dispatch_debug
570 *
571 * @abstract
572 * Programmatically log debug information about a dispatch object.
573 *
574 * @discussion
575 * Programmatically log debug information about a dispatch object. By default,
576 * the log output is sent to syslog at notice level. In the debug version of
577 * the library, the log output is sent to a file in /var/tmp.
578 * The log output destination can be configured via the LIBDISPATCH_LOG
579 * environment variable, valid values are: YES, NO, syslog, stderr, file.
580 *
581 * This function is deprecated and will be removed in a future release.
582 * Objective-C callers may use -debugDescription instead.
583 *
584 * @param object
585 * The object to introspect.
586 *
587 * @param message
588 * The message to log above and beyond the introspection.
589 */
590API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0))
591DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW DISPATCH_COLD
592__attribute__((__format__(printf,2,3)))
593void
594dispatch_debug(dispatch_object_t object, const char *message, ...);
595
596API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0))
597DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW DISPATCH_COLD
598__attribute__((__format__(printf,2,0)))
599void
600dispatch_debugv(dispatch_object_t object, const char *message, va_list ap);
601
602__END_DECLS
603
604DISPATCH_ASSUME_NONNULL_END
605
606#endif
lib/libc/include/x86_64-macos-gnu/dispatch/once.h created+125
......@@ -0,0 +1,125 @@
1/*
2 * Copyright (c) 2008-2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_ONCE__
22#define __DISPATCH_ONCE__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29DISPATCH_ASSUME_NONNULL_BEGIN
30
31__BEGIN_DECLS
32
33/*!
34 * @typedef dispatch_once_t
35 *
36 * @abstract
37 * A predicate for use with dispatch_once(). It must be initialized to zero.
38 * Note: static and global variables default to zero.
39 */
40DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
41typedef intptr_t dispatch_once_t;
42
43#if defined(__x86_64__) || defined(__i386__) || defined(__s390x__)
44#define DISPATCH_ONCE_INLINE_FASTPATH 1
45#elif defined(__APPLE__)
46#define DISPATCH_ONCE_INLINE_FASTPATH 1
47#else
48#define DISPATCH_ONCE_INLINE_FASTPATH 0
49#endif
50
51/*!
52 * @function dispatch_once
53 *
54 * @abstract
55 * Execute a block once and only once.
56 *
57 * @param predicate
58 * A pointer to a dispatch_once_t that is used to test whether the block has
59 * completed or not.
60 *
61 * @param block
62 * The block to execute once.
63 *
64 * @discussion
65 * Always call dispatch_once() before using or testing any variables that are
66 * initialized by the block.
67 */
68#ifdef __BLOCKS__
69API_AVAILABLE(macos(10.6), ios(4.0))
70DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
71DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
72void
73dispatch_once(dispatch_once_t *predicate,
74 DISPATCH_NOESCAPE dispatch_block_t block);
75
76#if DISPATCH_ONCE_INLINE_FASTPATH
77DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
78DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
79void
80_dispatch_once(dispatch_once_t *predicate,
81 DISPATCH_NOESCAPE dispatch_block_t block)
82{
83 if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
84 dispatch_once(predicate, block);
85 } else {
86 dispatch_compiler_barrier();
87 }
88 DISPATCH_COMPILER_CAN_ASSUME(*predicate == ~0l);
89}
90#undef dispatch_once
91#define dispatch_once _dispatch_once
92#endif
93#endif // DISPATCH_ONCE_INLINE_FASTPATH
94
95API_AVAILABLE(macos(10.6), ios(4.0))
96DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
97DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
98void
99dispatch_once_f(dispatch_once_t *predicate, void *_Nullable context,
100 dispatch_function_t function);
101
102#if DISPATCH_ONCE_INLINE_FASTPATH
103DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL1 DISPATCH_NONNULL3
104DISPATCH_NOTHROW
105DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
106void
107_dispatch_once_f(dispatch_once_t *predicate, void *_Nullable context,
108 dispatch_function_t function)
109{
110 if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
111 dispatch_once_f(predicate, context, function);
112 } else {
113 dispatch_compiler_barrier();
114 }
115 DISPATCH_COMPILER_CAN_ASSUME(*predicate == ~0l);
116}
117#undef dispatch_once_f
118#define dispatch_once_f _dispatch_once_f
119#endif // DISPATCH_ONCE_INLINE_FASTPATH
120
121__END_DECLS
122
123DISPATCH_ASSUME_NONNULL_END
124
125#endif
lib/libc/include/x86_64-macos-gnu/dispatch/queue.h created+1674
......@@ -0,0 +1,1674 @@
1/*
2 * Copyright (c) 2008-2014 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_QUEUE__
22#define __DISPATCH_QUEUE__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29DISPATCH_ASSUME_NONNULL_BEGIN
30
31/*!
32 * @header
33 *
34 * Dispatch is an abstract model for expressing concurrency via simple but
35 * powerful API.
36 *
37 * At the core, dispatch provides serial FIFO queues to which blocks may be
38 * submitted. Blocks submitted to these dispatch queues are invoked on a pool
39 * of threads fully managed by the system. No guarantee is made regarding
40 * which thread a block will be invoked on; however, it is guaranteed that only
41 * one block submitted to the FIFO dispatch queue will be invoked at a time.
42 *
43 * When multiple queues have blocks to be processed, the system is free to
44 * allocate additional threads to invoke the blocks concurrently. When the
45 * queues become empty, these threads are automatically released.
46 */
47
48/*!
49 * @typedef dispatch_queue_t
50 *
51 * @abstract
52 * Dispatch queues invoke workitems submitted to them.
53 *
54 * @discussion
55 * Dispatch queues come in many flavors, the most common one being the dispatch
56 * serial queue (See dispatch_queue_serial_t).
57 *
58 * The system manages a pool of threads which process dispatch queues and invoke
59 * workitems submitted to them.
60 *
61 * Conceptually a dispatch queue may have its own thread of execution, and
62 * interaction between queues is highly asynchronous.
63 *
64 * Dispatch queues are reference counted via calls to dispatch_retain() and
65 * dispatch_release(). Pending workitems submitted to a queue also hold a
66 * reference to the queue until they have finished. Once all references to a
67 * queue have been released, the queue will be deallocated by the system.
68 */
69DISPATCH_DECL(dispatch_queue);
70
71/*!
72 * @typedef dispatch_queue_global_t
73 *
74 * @abstract
75 * Dispatch global concurrent queues are an abstraction around the system thread
76 * pool which invokes workitems that are submitted to dispatch queues.
77 *
78 * @discussion
79 * Dispatch global concurrent queues provide buckets of priorities on top of the
80 * thread pool the system manages. The system will decide how many threads
81 * to allocate to this pool depending on demand and system load. In particular,
82 * the system tries to maintain a good level of concurrency for this resource,
83 * and will create new threads when too many existing worker threads block in
84 * system calls.
85 *
86 * The global concurrent queues are a shared resource and as such it is the
87 * responsiblity of every user of this resource to not submit an unbounded
88 * amount of work to this pool, especially work that may block, as this can
89 * cause the system to spawn very large numbers of threads (aka. thread
90 * explosion).
91 *
92 * Work items submitted to the global concurrent queues have no ordering
93 * guarantee with respect to the order of submission, and workitems submitted
94 * to these queues may be invoked concurrently.
95 *
96 * Dispatch global concurrent queues are well-known global objects that are
97 * returned by dispatch_get_global_queue(). These objects cannot be modified.
98 * Calls to dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc.,
99 * will have no effect when used with queues of this type.
100 */
101DISPATCH_DECL_SUBCLASS(dispatch_queue_global, dispatch_queue);
102
103/*!
104 * @typedef dispatch_queue_serial_t
105 *
106 * @abstract
107 * Dispatch serial queues invoke workitems submitted to them serially in FIFO
108 * order.
109 *
110 * @discussion
111 * Dispatch serial queues are lightweight objects to which workitems may be
112 * submitted to be invoked in FIFO order. A serial queue will only invoke one
113 * workitem at a time, but independent serial queues may each invoke their work
114 * items concurrently with respect to each other.
115 *
116 * Serial queues can target each other (See dispatch_set_target_queue()). The
117 * serial queue at the bottom of a queue hierarchy provides an exclusion
118 * context: at most one workitem submitted to any of the queues in such
119 * a hiearchy will run at any given time.
120 *
121 * Such hierarchies provide a natural construct to organize an application
122 * subsystem around.
123 *
124 * Serial queues are created by passing a dispatch queue attribute derived from
125 * DISPATCH_QUEUE_SERIAL to dispatch_queue_create_with_target().
126 */
127DISPATCH_DECL_SUBCLASS(dispatch_queue_serial, dispatch_queue);
128
129/*!
130 * @typedef dispatch_queue_main_t
131 *
132 * @abstract
133 * The type of the default queue that is bound to the main thread.
134 *
135 * @discussion
136 * The main queue is a serial queue (See dispatch_queue_serial_t) which is bound
137 * to the main thread of an application.
138 *
139 * In order to invoke workitems submitted to the main queue, the application
140 * must call dispatch_main(), NSApplicationMain(), or use a CFRunLoop on the
141 * main thread.
142 *
143 * The main queue is a well known global object that is made automatically on
144 * behalf of the main thread during process initialization and is returned by
145 * dispatch_get_main_queue(). This object cannot be modified. Calls to
146 * dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc., will
147 * have no effect when used on the main queue.
148 */
149DISPATCH_DECL_SUBCLASS(dispatch_queue_main, dispatch_queue_serial);
150
151/*!
152 * @typedef dispatch_queue_concurrent_t
153 *
154 * @abstract
155 * Dispatch concurrent queues invoke workitems submitted to them concurrently,
156 * and admit a notion of barrier workitems.
157 *
158 * @discussion
159 * Dispatch concurrent queues are lightweight objects to which regular and
160 * barrier workitems may be submited. Barrier workitems are invoked in
161 * exclusion of any other kind of workitem in FIFO order.
162 *
163 * Regular workitems can be invoked concurrently for the same concurrent queue,
164 * in any order. However, regular workitems will not be invoked before any
165 * barrier workitem submited ahead of them has been invoked.
166 *
167 * In other words, if a serial queue is equivalent to a mutex in the Dispatch
168 * world, a concurrent queue is equivalent to a reader-writer lock, where
169 * regular items are readers and barriers are writers.
170 *
171 * Concurrent queues are created by passing a dispatch queue attribute derived
172 * from DISPATCH_QUEUE_CONCURRENT to dispatch_queue_create_with_target().
173 *
174 * Caveat:
175 * Dispatch concurrent queues at this time do not implement priority inversion
176 * avoidance when lower priority regular workitems (readers) are being invoked
177 * and are preventing a higher priority barrier (writer) from being invoked.
178 */
179DISPATCH_DECL_SUBCLASS(dispatch_queue_concurrent, dispatch_queue);
180
181__BEGIN_DECLS
182
183/*!
184 * @function dispatch_async
185 *
186 * @abstract
187 * Submits a block for asynchronous execution on a dispatch queue.
188 *
189 * @discussion
190 * The dispatch_async() function is the fundamental mechanism for submitting
191 * blocks to a dispatch queue.
192 *
193 * Calls to dispatch_async() always return immediately after the block has
194 * been submitted, and never wait for the block to be invoked.
195 *
196 * The target queue determines whether the block will be invoked serially or
197 * concurrently with respect to other blocks submitted to that same queue.
198 * Serial queues are processed concurrently with respect to each other.
199 *
200 * @param queue
201 * The target dispatch queue to which the block is submitted.
202 * The system will hold a reference on the target queue until the block
203 * has finished.
204 * The result of passing NULL in this parameter is undefined.
205 *
206 * @param block
207 * The block to submit to the target dispatch queue. This function performs
208 * Block_copy() and Block_release() on behalf of callers.
209 * The result of passing NULL in this parameter is undefined.
210 */
211#ifdef __BLOCKS__
212API_AVAILABLE(macos(10.6), ios(4.0))
213DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
214void
215dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
216#endif
217
218/*!
219 * @function dispatch_async_f
220 *
221 * @abstract
222 * Submits a function for asynchronous execution on a dispatch queue.
223 *
224 * @discussion
225 * See dispatch_async() for details.
226 *
227 * @param queue
228 * The target dispatch queue to which the function is submitted.
229 * The system will hold a reference on the target queue until the function
230 * has returned.
231 * The result of passing NULL in this parameter is undefined.
232 *
233 * @param context
234 * The application-defined context parameter to pass to the function.
235 *
236 * @param work
237 * The application-defined function to invoke on the target queue. The first
238 * parameter passed to this function is the context provided to
239 * dispatch_async_f().
240 * The result of passing NULL in this parameter is undefined.
241 */
242API_AVAILABLE(macos(10.6), ios(4.0))
243DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
244void
245dispatch_async_f(dispatch_queue_t queue,
246 void *_Nullable context, dispatch_function_t work);
247
248/*!
249 * @function dispatch_sync
250 *
251 * @abstract
252 * Submits a block for synchronous execution on a dispatch queue.
253 *
254 * @discussion
255 * Submits a workitem to a dispatch queue like dispatch_async(), however
256 * dispatch_sync() will not return until the workitem has finished.
257 *
258 * Work items submitted to a queue with dispatch_sync() do not observe certain
259 * queue attributes of that queue when invoked (such as autorelease frequency
260 * and QOS class).
261 *
262 * Calls to dispatch_sync() targeting the current queue will result
263 * in dead-lock. Use of dispatch_sync() is also subject to the same
264 * multi-party dead-lock problems that may result from the use of a mutex.
265 * Use of dispatch_async() is preferred.
266 *
267 * Unlike dispatch_async(), no retain is performed on the target queue. Because
268 * calls to this function are synchronous, the dispatch_sync() "borrows" the
269 * reference of the caller.
270 *
271 * As an optimization, dispatch_sync() invokes the workitem on the thread which
272 * submitted the workitem, except when the passed queue is the main queue or
273 * a queue targetting it (See dispatch_queue_main_t,
274 * dispatch_set_target_queue()).
275 *
276 * @param queue
277 * The target dispatch queue to which the block is submitted.
278 * The result of passing NULL in this parameter is undefined.
279 *
280 * @param block
281 * The block to be invoked on the target dispatch queue.
282 * The result of passing NULL in this parameter is undefined.
283 */
284#ifdef __BLOCKS__
285API_AVAILABLE(macos(10.6), ios(4.0))
286DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
287void
288dispatch_sync(dispatch_queue_t queue, DISPATCH_NOESCAPE dispatch_block_t block);
289#endif
290
291/*!
292 * @function dispatch_sync_f
293 *
294 * @abstract
295 * Submits a function for synchronous execution on a dispatch queue.
296 *
297 * @discussion
298 * See dispatch_sync() for details.
299 *
300 * @param queue
301 * The target dispatch queue to which the function is submitted.
302 * The result of passing NULL in this parameter is undefined.
303 *
304 * @param context
305 * The application-defined context parameter to pass to the function.
306 *
307 * @param work
308 * The application-defined function to invoke on the target queue. The first
309 * parameter passed to this function is the context provided to
310 * dispatch_sync_f().
311 * The result of passing NULL in this parameter is undefined.
312 */
313API_AVAILABLE(macos(10.6), ios(4.0))
314DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
315void
316dispatch_sync_f(dispatch_queue_t queue,
317 void *_Nullable context, dispatch_function_t work);
318
319/*!
320 * @function dispatch_async_and_wait
321 *
322 * @abstract
323 * Submits a block for synchronous execution on a dispatch queue.
324 *
325 * @discussion
326 * Submits a workitem to a dispatch queue like dispatch_async(), however
327 * dispatch_async_and_wait() will not return until the workitem has finished.
328 *
329 * Like functions of the dispatch_sync family, dispatch_async_and_wait() is
330 * subject to dead-lock (See dispatch_sync() for details).
331 *
332 * However, dispatch_async_and_wait() differs from functions of the
333 * dispatch_sync family in two fundamental ways: how it respects queue
334 * attributes and how it chooses the execution context invoking the workitem.
335 *
336 * <b>Differences with dispatch_sync()</b>
337 *
338 * Work items submitted to a queue with dispatch_async_and_wait() observe all
339 * queue attributes of that queue when invoked (inluding autorelease frequency
340 * or QOS class).
341 *
342 * When the runtime has brought up a thread to invoke the asynchronous workitems
343 * already submitted to the specified queue, that servicing thread will also be
344 * used to execute synchronous work submitted to the queue with
345 * dispatch_async_and_wait().
346 *
347 * However, if the runtime has not brought up a thread to service the specified
348 * queue (because it has no workitems enqueued, or only synchronous workitems),
349 * then dispatch_async_and_wait() will invoke the workitem on the calling thread,
350 * similar to the behaviour of functions in the dispatch_sync family.
351 *
352 * As an exception, if the queue the work is submitted to doesn't target
353 * a global concurrent queue (for example because it targets the main queue),
354 * then the workitem will never be invoked by the thread calling
355 * dispatch_async_and_wait().
356 *
357 * In other words, dispatch_async_and_wait() is similar to submitting
358 * a dispatch_block_create()d workitem to a queue and then waiting on it, as
359 * shown in the code example below. However, dispatch_async_and_wait() is
360 * significantly more efficient when a new thread is not required to execute
361 * the workitem (as it will use the stack of the submitting thread instead of
362 * requiring heap allocations).
363 *
364 * <code>
365 * dispatch_block_t b = dispatch_block_create(0, block);
366 * dispatch_async(queue, b);
367 * dispatch_block_wait(b, DISPATCH_TIME_FOREVER);
368 * Block_release(b);
369 * </code>
370 *
371 * @param queue
372 * The target dispatch queue to which the block is submitted.
373 * The result of passing NULL in this parameter is undefined.
374 *
375 * @param block
376 * The block to be invoked on the target dispatch queue.
377 * The result of passing NULL in this parameter is undefined.
378 */
379#ifdef __BLOCKS__
380API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
381DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
382void
383dispatch_async_and_wait(dispatch_queue_t queue,
384 DISPATCH_NOESCAPE dispatch_block_t block);
385#endif
386
387/*!
388 * @function dispatch_async_and_wait_f
389 *
390 * @abstract
391 * Submits a function for synchronous execution on a dispatch queue.
392 *
393 * @discussion
394 * See dispatch_async_and_wait() for details.
395 *
396 * @param queue
397 * The target dispatch queue to which the function is submitted.
398 * The result of passing NULL in this parameter is undefined.
399 *
400 * @param context
401 * The application-defined context parameter to pass to the function.
402 *
403 * @param work
404 * The application-defined function to invoke on the target queue. The first
405 * parameter passed to this function is the context provided to
406 * dispatch_async_and_wait_f().
407 * The result of passing NULL in this parameter is undefined.
408 */
409API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
410DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
411void
412dispatch_async_and_wait_f(dispatch_queue_t queue,
413 void *_Nullable context, dispatch_function_t work);
414
415
416#if defined(__APPLE__) && \
417 (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
418 __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0) || \
419 (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
420 __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9)
421#define DISPATCH_APPLY_AUTO_AVAILABLE 0
422#define DISPATCH_APPLY_QUEUE_ARG_NULLABILITY _Nonnull
423#else
424#define DISPATCH_APPLY_AUTO_AVAILABLE 1
425#define DISPATCH_APPLY_QUEUE_ARG_NULLABILITY _Nullable
426#endif
427
428/*!
429 * @constant DISPATCH_APPLY_AUTO
430 *
431 * @abstract
432 * Constant to pass to dispatch_apply() or dispatch_apply_f() to request that
433 * the system automatically use worker threads that match the configuration of
434 * the current thread as closely as possible.
435 *
436 * @discussion
437 * When submitting a block for parallel invocation, passing this constant as the
438 * queue argument will automatically use the global concurrent queue that
439 * matches the Quality of Service of the caller most closely.
440 *
441 * No assumptions should be made about which global concurrent queue will
442 * actually be used.
443 *
444 * Using this constant deploys backward to macOS 10.9, iOS 7.0 and any tvOS or
445 * watchOS version.
446 */
447#if DISPATCH_APPLY_AUTO_AVAILABLE
448#define DISPATCH_APPLY_AUTO ((dispatch_queue_t _Nonnull)0)
449#endif
450
451/*!
452 * @function dispatch_apply
453 *
454 * @abstract
455 * Submits a block to a dispatch queue for parallel invocation.
456 *
457 * @discussion
458 * Submits a block to a dispatch queue for parallel invocation. This function
459 * waits for the task block to complete before returning. If the specified queue
460 * is concurrent, the block may be invoked concurrently, and it must therefore
461 * be reentrant safe.
462 *
463 * Each invocation of the block will be passed the current index of iteration.
464 *
465 * @param iterations
466 * The number of iterations to perform.
467 *
468 * @param queue
469 * The dispatch queue to which the block is submitted.
470 * The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use
471 * a queue appropriate for the calling thread.
472 *
473 * @param block
474 * The block to be invoked the specified number of iterations.
475 * The result of passing NULL in this parameter is undefined.
476 */
477#ifdef __BLOCKS__
478API_AVAILABLE(macos(10.6), ios(4.0))
479DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NOTHROW
480void
481dispatch_apply(size_t iterations,
482 dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue,
483 DISPATCH_NOESCAPE void (^block)(size_t));
484#endif
485
486/*!
487 * @function dispatch_apply_f
488 *
489 * @abstract
490 * Submits a function to a dispatch queue for parallel invocation.
491 *
492 * @discussion
493 * See dispatch_apply() for details.
494 *
495 * @param iterations
496 * The number of iterations to perform.
497 *
498 * @param queue
499 * The dispatch queue to which the function is submitted.
500 * The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use
501 * a queue appropriate for the calling thread.
502 *
503 * @param context
504 * The application-defined context parameter to pass to the function.
505 *
506 * @param work
507 * The application-defined function to invoke on the specified queue. The first
508 * parameter passed to this function is the context provided to
509 * dispatch_apply_f(). The second parameter passed to this function is the
510 * current index of iteration.
511 * The result of passing NULL in this parameter is undefined.
512 */
513API_AVAILABLE(macos(10.6), ios(4.0))
514DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_NOTHROW
515void
516dispatch_apply_f(size_t iterations,
517 dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue,
518 void *_Nullable context, void (*work)(void *_Nullable, size_t));
519
520/*!
521 * @function dispatch_get_current_queue
522 *
523 * @abstract
524 * Returns the queue on which the currently executing block is running.
525 *
526 * @discussion
527 * Returns the queue on which the currently executing block is running.
528 *
529 * When dispatch_get_current_queue() is called outside of the context of a
530 * submitted block, it will return the default concurrent queue.
531 *
532 * Recommended for debugging and logging purposes only:
533 * The code must not make any assumptions about the queue returned, unless it
534 * is one of the global queues or a queue the code has itself created.
535 * The code must not assume that synchronous execution onto a queue is safe
536 * from deadlock if that queue is not the one returned by
537 * dispatch_get_current_queue().
538 *
539 * When dispatch_get_current_queue() is called on the main thread, it may
540 * or may not return the same value as dispatch_get_main_queue(). Comparing
541 * the two is not a valid way to test whether code is executing on the
542 * main thread (see dispatch_assert_queue() and dispatch_assert_queue_not()).
543 *
544 * This function is deprecated and will be removed in a future release.
545 *
546 * @result
547 * Returns the current queue.
548 */
549API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0))
550DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
551dispatch_queue_t
552dispatch_get_current_queue(void);
553
554API_AVAILABLE(macos(10.6), ios(4.0))
555DISPATCH_EXPORT
556struct dispatch_queue_s _dispatch_main_q;
557
558/*!
559 * @function dispatch_get_main_queue
560 *
561 * @abstract
562 * Returns the default queue that is bound to the main thread.
563 *
564 * @discussion
565 * In order to invoke blocks submitted to the main queue, the application must
566 * call dispatch_main(), NSApplicationMain(), or use a CFRunLoop on the main
567 * thread.
568 *
569 * The main queue is meant to be used in application context to interact with
570 * the main thread and the main runloop.
571 *
572 * Because the main queue doesn't behave entirely like a regular serial queue,
573 * it may have unwanted side-effects when used in processes that are not UI apps
574 * (daemons). For such processes, the main queue should be avoided.
575 *
576 * @see dispatch_queue_main_t
577 *
578 * @result
579 * Returns the main queue. This queue is created automatically on behalf of
580 * the main thread before main() is called.
581 */
582DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_CONST DISPATCH_NOTHROW
583dispatch_queue_main_t
584dispatch_get_main_queue(void)
585{
586 return DISPATCH_GLOBAL_OBJECT(dispatch_queue_main_t, _dispatch_main_q);
587}
588
589/*!
590 * @typedef dispatch_queue_priority_t
591 * Type of dispatch_queue_priority
592 *
593 * @constant DISPATCH_QUEUE_PRIORITY_HIGH
594 * Items dispatched to the queue will run at high priority,
595 * i.e. the queue will be scheduled for execution before
596 * any default priority or low priority queue.
597 *
598 * @constant DISPATCH_QUEUE_PRIORITY_DEFAULT
599 * Items dispatched to the queue will run at the default
600 * priority, i.e. the queue will be scheduled for execution
601 * after all high priority queues have been scheduled, but
602 * before any low priority queues have been scheduled.
603 *
604 * @constant DISPATCH_QUEUE_PRIORITY_LOW
605 * Items dispatched to the queue will run at low priority,
606 * i.e. the queue will be scheduled for execution after all
607 * default priority and high priority queues have been
608 * scheduled.
609 *
610 * @constant DISPATCH_QUEUE_PRIORITY_BACKGROUND
611 * Items dispatched to the queue will run at background priority, i.e. the queue
612 * will be scheduled for execution after all higher priority queues have been
613 * scheduled and the system will run items on this queue on a thread with
614 * background status as per setpriority(2) (i.e. disk I/O is throttled and the
615 * thread's scheduling priority is set to lowest value).
616 */
617#define DISPATCH_QUEUE_PRIORITY_HIGH 2
618#define DISPATCH_QUEUE_PRIORITY_DEFAULT 0
619#define DISPATCH_QUEUE_PRIORITY_LOW (-2)
620#define DISPATCH_QUEUE_PRIORITY_BACKGROUND INT16_MIN
621
622typedef long dispatch_queue_priority_t;
623
624/*!
625 * @function dispatch_get_global_queue
626 *
627 * @abstract
628 * Returns a well-known global concurrent queue of a given quality of service
629 * class.
630 *
631 * @discussion
632 * See dispatch_queue_global_t.
633 *
634 * @param identifier
635 * A quality of service class defined in qos_class_t or a priority defined in
636 * dispatch_queue_priority_t.
637 *
638 * It is recommended to use quality of service class values to identify the
639 * well-known global concurrent queues:
640 * - QOS_CLASS_USER_INTERACTIVE
641 * - QOS_CLASS_USER_INITIATED
642 * - QOS_CLASS_DEFAULT
643 * - QOS_CLASS_UTILITY
644 * - QOS_CLASS_BACKGROUND
645 *
646 * The global concurrent queues may still be identified by their priority,
647 * which map to the following QOS classes:
648 * - DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED
649 * - DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT
650 * - DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY
651 * - DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND
652 *
653 * @param flags
654 * Reserved for future use. Passing any value other than zero may result in
655 * a NULL return value.
656 *
657 * @result
658 * Returns the requested global queue or NULL if the requested global queue
659 * does not exist.
660 */
661API_AVAILABLE(macos(10.6), ios(4.0))
662DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW
663dispatch_queue_global_t
664dispatch_get_global_queue(intptr_t identifier, uintptr_t flags);
665
666/*!
667 * @typedef dispatch_queue_attr_t
668 *
669 * @abstract
670 * Attribute for dispatch queues.
671 */
672DISPATCH_DECL(dispatch_queue_attr);
673
674/*!
675 * @const DISPATCH_QUEUE_SERIAL
676 *
677 * @discussion
678 * An attribute that can be used to create a dispatch queue that invokes blocks
679 * serially in FIFO order.
680 *
681 * See dispatch_queue_serial_t.
682 */
683#define DISPATCH_QUEUE_SERIAL NULL
684
685/*!
686 * @const DISPATCH_QUEUE_SERIAL_INACTIVE
687 *
688 * @discussion
689 * An attribute that can be used to create a dispatch queue that invokes blocks
690 * serially in FIFO order, and that is initially inactive.
691 *
692 * See dispatch_queue_attr_make_initially_inactive().
693 */
694#define DISPATCH_QUEUE_SERIAL_INACTIVE \
695 dispatch_queue_attr_make_initially_inactive(DISPATCH_QUEUE_SERIAL)
696
697/*!
698 * @const DISPATCH_QUEUE_CONCURRENT
699 *
700 * @discussion
701 * An attribute that can be used to create a dispatch queue that may invoke
702 * blocks concurrently and supports barrier blocks submitted with the dispatch
703 * barrier API.
704 *
705 * See dispatch_queue_concurrent_t.
706 */
707#define DISPATCH_QUEUE_CONCURRENT \
708 DISPATCH_GLOBAL_OBJECT(dispatch_queue_attr_t, \
709 _dispatch_queue_attr_concurrent)
710API_AVAILABLE(macos(10.7), ios(4.3))
711DISPATCH_EXPORT
712struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent;
713
714/*!
715 * @const DISPATCH_QUEUE_CONCURRENT_INACTIVE
716 *
717 * @discussion
718 * An attribute that can be used to create a dispatch queue that may invoke
719 * blocks concurrently and supports barrier blocks submitted with the dispatch
720 * barrier API, and that is initially inactive.
721 *
722 * See dispatch_queue_attr_make_initially_inactive().
723 */
724#define DISPATCH_QUEUE_CONCURRENT_INACTIVE \
725 dispatch_queue_attr_make_initially_inactive(DISPATCH_QUEUE_CONCURRENT)
726
727/*!
728 * @function dispatch_queue_attr_make_initially_inactive
729 *
730 * @abstract
731 * Returns an attribute value which may be provided to dispatch_queue_create()
732 * or dispatch_queue_create_with_target(), in order to make the created queue
733 * initially inactive.
734 *
735 * @discussion
736 * Dispatch queues may be created in an inactive state. Queues in this state
737 * have to be activated before any blocks associated with them will be invoked.
738 *
739 * A queue in inactive state cannot be deallocated, dispatch_activate() must be
740 * called before the last reference to a queue created with this attribute is
741 * released.
742 *
743 * The target queue of a queue in inactive state can be changed using
744 * dispatch_set_target_queue(). Change of target queue is no longer permitted
745 * once an initially inactive queue has been activated.
746 *
747 * @param attr
748 * A queue attribute value to be combined with the initially inactive attribute.
749 *
750 * @return
751 * Returns an attribute value which may be provided to dispatch_queue_create()
752 * and dispatch_queue_create_with_target().
753 * The new value combines the attributes specified by the 'attr' parameter with
754 * the initially inactive attribute.
755 */
756API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
757DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW
758dispatch_queue_attr_t
759dispatch_queue_attr_make_initially_inactive(
760 dispatch_queue_attr_t _Nullable attr);
761
762/*!
763 * @const DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL
764 *
765 * @discussion
766 * A dispatch queue created with this attribute invokes blocks serially in FIFO
767 * order, and surrounds execution of any block submitted asynchronously to it
768 * with the equivalent of a individual Objective-C <code>@autoreleasepool</code>
769 * scope.
770 *
771 * See dispatch_queue_attr_make_with_autorelease_frequency().
772 */
773#define DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL \
774 dispatch_queue_attr_make_with_autorelease_frequency(\
775 DISPATCH_QUEUE_SERIAL, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM)
776
777/*!
778 * @const DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL
779 *
780 * @discussion
781 * A dispatch queue created with this attribute may invokes blocks concurrently
782 * and supports barrier blocks submitted with the dispatch barrier API. It also
783 * surrounds execution of any block submitted asynchronously to it with the
784 * equivalent of a individual Objective-C <code>@autoreleasepool</code>
785 *
786 * See dispatch_queue_attr_make_with_autorelease_frequency().
787 */
788#define DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL \
789 dispatch_queue_attr_make_with_autorelease_frequency(\
790 DISPATCH_QUEUE_CONCURRENT, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM)
791
792/*!
793 * @typedef dispatch_autorelease_frequency_t
794 * Values to pass to the dispatch_queue_attr_make_with_autorelease_frequency()
795 * function.
796 *
797 * @const DISPATCH_AUTORELEASE_FREQUENCY_INHERIT
798 * Dispatch queues with this autorelease frequency inherit the behavior from
799 * their target queue. This is the default behavior for manually created queues.
800 *
801 * @const DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM
802 * Dispatch queues with this autorelease frequency push and pop an autorelease
803 * pool around the execution of every block that was submitted to it
804 * asynchronously.
805 * @see dispatch_queue_attr_make_with_autorelease_frequency().
806 *
807 * @const DISPATCH_AUTORELEASE_FREQUENCY_NEVER
808 * Dispatch queues with this autorelease frequency never set up an individual
809 * autorelease pool around the execution of a block that is submitted to it
810 * asynchronously. This is the behavior of the global concurrent queues.
811 */
812DISPATCH_ENUM(dispatch_autorelease_frequency, unsigned long,
813 DISPATCH_AUTORELEASE_FREQUENCY_INHERIT DISPATCH_ENUM_API_AVAILABLE(
814 macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 0,
815 DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM DISPATCH_ENUM_API_AVAILABLE(
816 macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 1,
817 DISPATCH_AUTORELEASE_FREQUENCY_NEVER DISPATCH_ENUM_API_AVAILABLE(
818 macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 2,
819);
820
821/*!
822 * @function dispatch_queue_attr_make_with_autorelease_frequency
823 *
824 * @abstract
825 * Returns a dispatch queue attribute value with the autorelease frequency
826 * set to the specified value.
827 *
828 * @discussion
829 * When a queue uses the per-workitem autorelease frequency (either directly
830 * or inherithed from its target queue), any block submitted asynchronously to
831 * this queue (via dispatch_async(), dispatch_barrier_async(),
832 * dispatch_group_notify(), etc...) is executed as if surrounded by a individual
833 * Objective-C <code>@autoreleasepool</code> scope.
834 *
835 * Autorelease frequency has no effect on blocks that are submitted
836 * synchronously to a queue (via dispatch_sync(), dispatch_barrier_sync()).
837 *
838 * The global concurrent queues have the DISPATCH_AUTORELEASE_FREQUENCY_NEVER
839 * behavior. Manually created dispatch queues use
840 * DISPATCH_AUTORELEASE_FREQUENCY_INHERIT by default.
841 *
842 * Queues created with this attribute cannot change target queues after having
843 * been activated. See dispatch_set_target_queue() and dispatch_activate().
844 *
845 * @param attr
846 * A queue attribute value to be combined with the specified autorelease
847 * frequency or NULL.
848 *
849 * @param frequency
850 * The requested autorelease frequency.
851 *
852 * @return
853 * Returns an attribute value which may be provided to dispatch_queue_create()
854 * or NULL if an invalid autorelease frequency was requested.
855 * This new value combines the attributes specified by the 'attr' parameter and
856 * the chosen autorelease frequency.
857 */
858API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
859DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW
860dispatch_queue_attr_t
861dispatch_queue_attr_make_with_autorelease_frequency(
862 dispatch_queue_attr_t _Nullable attr,
863 dispatch_autorelease_frequency_t frequency);
864
865/*!
866 * @function dispatch_queue_attr_make_with_qos_class
867 *
868 * @abstract
869 * Returns an attribute value which may be provided to dispatch_queue_create()
870 * or dispatch_queue_create_with_target(), in order to assign a QOS class and
871 * relative priority to the queue.
872 *
873 * @discussion
874 * When specified in this manner, the QOS class and relative priority take
875 * precedence over those inherited from the dispatch queue's target queue (if
876 * any) as long that does not result in a lower QOS class and relative priority.
877 *
878 * The global queue priorities map to the following QOS classes:
879 * - DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED
880 * - DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT
881 * - DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY
882 * - DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND
883 *
884 * Example:
885 * <code>
886 * dispatch_queue_t queue;
887 * dispatch_queue_attr_t attr;
888 * attr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL,
889 * QOS_CLASS_UTILITY, 0);
890 * queue = dispatch_queue_create("com.example.myqueue", attr);
891 * </code>
892 *
893 * The QOS class and relative priority set this way on a queue have no effect on
894 * blocks that are submitted synchronously to a queue (via dispatch_sync(),
895 * dispatch_barrier_sync()).
896 *
897 * @param attr
898 * A queue attribute value to be combined with the QOS class, or NULL.
899 *
900 * @param qos_class
901 * A QOS class value:
902 * - QOS_CLASS_USER_INTERACTIVE
903 * - QOS_CLASS_USER_INITIATED
904 * - QOS_CLASS_DEFAULT
905 * - QOS_CLASS_UTILITY
906 * - QOS_CLASS_BACKGROUND
907 * Passing any other value results in NULL being returned.
908 *
909 * @param relative_priority
910 * A relative priority within the QOS class. This value is a negative
911 * offset from the maximum supported scheduler priority for the given class.
912 * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
913 * results in NULL being returned.
914 *
915 * @return
916 * Returns an attribute value which may be provided to dispatch_queue_create()
917 * and dispatch_queue_create_with_target(), or NULL if an invalid QOS class was
918 * requested.
919 * The new value combines the attributes specified by the 'attr' parameter and
920 * the new QOS class and relative priority.
921 */
922API_AVAILABLE(macos(10.10), ios(8.0))
923DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW
924dispatch_queue_attr_t
925dispatch_queue_attr_make_with_qos_class(dispatch_queue_attr_t _Nullable attr,
926 dispatch_qos_class_t qos_class, int relative_priority);
927
928/*!
929 * @const DISPATCH_TARGET_QUEUE_DEFAULT
930 * @discussion Constant to pass to the dispatch_queue_create_with_target(),
931 * dispatch_set_target_queue() and dispatch_source_create() functions to
932 * indicate that the default target queue for the object type in question
933 * should be used.
934 */
935#define DISPATCH_TARGET_QUEUE_DEFAULT NULL
936
937/*!
938 * @function dispatch_queue_create_with_target
939 *
940 * @abstract
941 * Creates a new dispatch queue with a specified target queue.
942 *
943 * @discussion
944 * Dispatch queues created with the DISPATCH_QUEUE_SERIAL or a NULL attribute
945 * invoke blocks serially in FIFO order.
946 *
947 * Dispatch queues created with the DISPATCH_QUEUE_CONCURRENT attribute may
948 * invoke blocks concurrently (similarly to the global concurrent queues, but
949 * potentially with more overhead), and support barrier blocks submitted with
950 * the dispatch barrier API, which e.g. enables the implementation of efficient
951 * reader-writer schemes.
952 *
953 * When a dispatch queue is no longer needed, it should be released with
954 * dispatch_release(). Note that any pending blocks submitted asynchronously to
955 * a queue will hold a reference to that queue. Therefore a queue will not be
956 * deallocated until all pending blocks have finished.
957 *
958 * When using a dispatch queue attribute @a attr specifying a QoS class (derived
959 * from the result of dispatch_queue_attr_make_with_qos_class()), passing the
960 * result of dispatch_get_global_queue() in @a target will ignore the QoS class
961 * of that global queue and will use the global queue with the QoS class
962 * specified by attr instead.
963 *
964 * Queues created with dispatch_queue_create_with_target() cannot have their
965 * target queue changed, unless created inactive (See
966 * dispatch_queue_attr_make_initially_inactive()), in which case the target
967 * queue can be changed until the newly created queue is activated with
968 * dispatch_activate().
969 *
970 * @param label
971 * A string label to attach to the queue.
972 * This parameter is optional and may be NULL.
973 *
974 * @param attr
975 * A predefined attribute such as DISPATCH_QUEUE_SERIAL,
976 * DISPATCH_QUEUE_CONCURRENT, or the result of a call to
977 * a dispatch_queue_attr_make_with_* function.
978 *
979 * @param target
980 * The target queue for the newly created queue. The target queue is retained.
981 * If this parameter is DISPATCH_TARGET_QUEUE_DEFAULT, sets the queue's target
982 * queue to the default target queue for the given queue type.
983 *
984 * @result
985 * The newly created dispatch queue.
986 */
987API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
988DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
989DISPATCH_NOTHROW
990dispatch_queue_t
991dispatch_queue_create_with_target(const char *_Nullable label,
992 dispatch_queue_attr_t _Nullable attr, dispatch_queue_t _Nullable target)
993 DISPATCH_ALIAS_V2(dispatch_queue_create_with_target);
994
995/*!
996 * @function dispatch_queue_create
997 *
998 * @abstract
999 * Creates a new dispatch queue to which blocks may be submitted.
1000 *
1001 * @discussion
1002 * Dispatch queues created with the DISPATCH_QUEUE_SERIAL or a NULL attribute
1003 * invoke blocks serially in FIFO order.
1004 *
1005 * Dispatch queues created with the DISPATCH_QUEUE_CONCURRENT attribute may
1006 * invoke blocks concurrently (similarly to the global concurrent queues, but
1007 * potentially with more overhead), and support barrier blocks submitted with
1008 * the dispatch barrier API, which e.g. enables the implementation of efficient
1009 * reader-writer schemes.
1010 *
1011 * When a dispatch queue is no longer needed, it should be released with
1012 * dispatch_release(). Note that any pending blocks submitted asynchronously to
1013 * a queue will hold a reference to that queue. Therefore a queue will not be
1014 * deallocated until all pending blocks have finished.
1015 *
1016 * Passing the result of the dispatch_queue_attr_make_with_qos_class() function
1017 * to the attr parameter of this function allows a quality of service class and
1018 * relative priority to be specified for the newly created queue.
1019 * The quality of service class so specified takes precedence over the quality
1020 * of service class of the newly created dispatch queue's target queue (if any)
1021 * as long that does not result in a lower QOS class and relative priority.
1022 *
1023 * When no quality of service class is specified, the target queue of a newly
1024 * created dispatch queue is the default priority global concurrent queue.
1025 *
1026 * @param label
1027 * A string label to attach to the queue.
1028 * This parameter is optional and may be NULL.
1029 *
1030 * @param attr
1031 * A predefined attribute such as DISPATCH_QUEUE_SERIAL,
1032 * DISPATCH_QUEUE_CONCURRENT, or the result of a call to
1033 * a dispatch_queue_attr_make_with_* function.
1034 *
1035 * @result
1036 * The newly created dispatch queue.
1037 */
1038API_AVAILABLE(macos(10.6), ios(4.0))
1039DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
1040DISPATCH_NOTHROW
1041dispatch_queue_t
1042dispatch_queue_create(const char *_Nullable label,
1043 dispatch_queue_attr_t _Nullable attr);
1044
1045/*!
1046 * @const DISPATCH_CURRENT_QUEUE_LABEL
1047 * @discussion Constant to pass to the dispatch_queue_get_label() function to
1048 * retrieve the label of the current queue.
1049 */
1050#define DISPATCH_CURRENT_QUEUE_LABEL NULL
1051
1052/*!
1053 * @function dispatch_queue_get_label
1054 *
1055 * @abstract
1056 * Returns the label of the given queue, as specified when the queue was
1057 * created, or the empty string if a NULL label was specified.
1058 *
1059 * Passing DISPATCH_CURRENT_QUEUE_LABEL will return the label of the current
1060 * queue.
1061 *
1062 * @param queue
1063 * The queue to query, or DISPATCH_CURRENT_QUEUE_LABEL.
1064 *
1065 * @result
1066 * The label of the queue.
1067 */
1068API_AVAILABLE(macos(10.6), ios(4.0))
1069DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
1070const char *
1071dispatch_queue_get_label(dispatch_queue_t _Nullable queue);
1072
1073/*!
1074 * @function dispatch_queue_get_qos_class
1075 *
1076 * @abstract
1077 * Returns the QOS class and relative priority of the given queue.
1078 *
1079 * @discussion
1080 * If the given queue was created with an attribute value returned from
1081 * dispatch_queue_attr_make_with_qos_class(), this function returns the QOS
1082 * class and relative priority specified at that time; for any other attribute
1083 * value it returns a QOS class of QOS_CLASS_UNSPECIFIED and a relative
1084 * priority of 0.
1085 *
1086 * If the given queue is one of the global queues, this function returns its
1087 * assigned QOS class value as documented under dispatch_get_global_queue() and
1088 * a relative priority of 0; in the case of the main queue it returns the QOS
1089 * value provided by qos_class_main() and a relative priority of 0.
1090 *
1091 * @param queue
1092 * The queue to query.
1093 *
1094 * @param relative_priority_ptr
1095 * A pointer to an int variable to be filled with the relative priority offset
1096 * within the QOS class, or NULL.
1097 *
1098 * @return
1099 * A QOS class value:
1100 * - QOS_CLASS_USER_INTERACTIVE
1101 * - QOS_CLASS_USER_INITIATED
1102 * - QOS_CLASS_DEFAULT
1103 * - QOS_CLASS_UTILITY
1104 * - QOS_CLASS_BACKGROUND
1105 * - QOS_CLASS_UNSPECIFIED
1106 */
1107API_AVAILABLE(macos(10.10), ios(8.0))
1108DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NONNULL1 DISPATCH_NOTHROW
1109dispatch_qos_class_t
1110dispatch_queue_get_qos_class(dispatch_queue_t queue,
1111 int *_Nullable relative_priority_ptr);
1112
1113/*!
1114 * @function dispatch_set_target_queue
1115 *
1116 * @abstract
1117 * Sets the target queue for the given object.
1118 *
1119 * @discussion
1120 * An object's target queue is responsible for processing the object.
1121 *
1122 * When no quality of service class and relative priority is specified for a
1123 * dispatch queue at the time of creation, a dispatch queue's quality of service
1124 * class is inherited from its target queue. The dispatch_get_global_queue()
1125 * function may be used to obtain a target queue of a specific quality of
1126 * service class, however the use of dispatch_queue_attr_make_with_qos_class()
1127 * is recommended instead.
1128 *
1129 * Blocks submitted to a serial queue whose target queue is another serial
1130 * queue will not be invoked concurrently with blocks submitted to the target
1131 * queue or to any other queue with that same target queue.
1132 *
1133 * The result of introducing a cycle into the hierarchy of target queues is
1134 * undefined.
1135 *
1136 * A dispatch source's target queue specifies where its event handler and
1137 * cancellation handler blocks will be submitted.
1138 *
1139 * A dispatch I/O channel's target queue specifies where where its I/O
1140 * operations are executed. If the channel's target queue's priority is set to
1141 * DISPATCH_QUEUE_PRIORITY_BACKGROUND, then the I/O operations performed by
1142 * dispatch_io_read() or dispatch_io_write() on that queue will be
1143 * throttled when there is I/O contention.
1144 *
1145 * For all other dispatch object types, the only function of the target queue
1146 * is to determine where an object's finalizer function is invoked.
1147 *
1148 * In general, changing the target queue of an object is an asynchronous
1149 * operation that doesn't take effect immediately, and doesn't affect blocks
1150 * already associated with the specified object.
1151 *
1152 * However, if an object is inactive at the time dispatch_set_target_queue() is
1153 * called, then the target queue change takes effect immediately, and will
1154 * affect blocks already associated with the specified object. After an
1155 * initially inactive object has been activated, calling
1156 * dispatch_set_target_queue() results in an assertion and the process being
1157 * terminated.
1158 *
1159 * If a dispatch queue is active and targeted by other dispatch objects,
1160 * changing its target queue results in undefined behavior.
1161 *
1162 * @param object
1163 * The object to modify.
1164 * The result of passing NULL in this parameter is undefined.
1165 *
1166 * @param queue
1167 * The new target queue for the object. The queue is retained, and the
1168 * previous target queue, if any, is released.
1169 * If queue is DISPATCH_TARGET_QUEUE_DEFAULT, set the object's target queue
1170 * to the default target queue for the given object type.
1171 */
1172API_AVAILABLE(macos(10.6), ios(4.0))
1173DISPATCH_EXPORT DISPATCH_NOTHROW
1174void
1175dispatch_set_target_queue(dispatch_object_t object,
1176 dispatch_queue_t _Nullable queue);
1177
1178/*!
1179 * @function dispatch_main
1180 *
1181 * @abstract
1182 * Execute blocks submitted to the main queue.
1183 *
1184 * @discussion
1185 * This function "parks" the main thread and waits for blocks to be submitted
1186 * to the main queue. This function never returns.
1187 *
1188 * Applications that call NSApplicationMain() or CFRunLoopRun() on the
1189 * main thread do not need to call dispatch_main().
1190 */
1191API_AVAILABLE(macos(10.6), ios(4.0))
1192DISPATCH_EXPORT DISPATCH_NOTHROW DISPATCH_NORETURN
1193void
1194dispatch_main(void);
1195
1196/*!
1197 * @function dispatch_after
1198 *
1199 * @abstract
1200 * Schedule a block for execution on a given queue at a specified time.
1201 *
1202 * @discussion
1203 * Passing DISPATCH_TIME_NOW as the "when" parameter is supported, but not as
1204 * optimal as calling dispatch_async() instead. Passing DISPATCH_TIME_FOREVER
1205 * is undefined.
1206 *
1207 * @param when
1208 * A temporal milestone returned by dispatch_time() or dispatch_walltime().
1209 *
1210 * @param queue
1211 * A queue to which the given block will be submitted at the specified time.
1212 * The result of passing NULL in this parameter is undefined.
1213 *
1214 * @param block
1215 * The block of code to execute.
1216 * The result of passing NULL in this parameter is undefined.
1217 */
1218#ifdef __BLOCKS__
1219API_AVAILABLE(macos(10.6), ios(4.0))
1220DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NOTHROW
1221void
1222dispatch_after(dispatch_time_t when, dispatch_queue_t queue,
1223 dispatch_block_t block);
1224#endif
1225
1226/*!
1227 * @function dispatch_after_f
1228 *
1229 * @abstract
1230 * Schedule a function for execution on a given queue at a specified time.
1231 *
1232 * @discussion
1233 * See dispatch_after() for details.
1234 *
1235 * @param when
1236 * A temporal milestone returned by dispatch_time() or dispatch_walltime().
1237 *
1238 * @param queue
1239 * A queue to which the given function will be submitted at the specified time.
1240 * The result of passing NULL in this parameter is undefined.
1241 *
1242 * @param context
1243 * The application-defined context parameter to pass to the function.
1244 *
1245 * @param work
1246 * The application-defined function to invoke on the target queue. The first
1247 * parameter passed to this function is the context provided to
1248 * dispatch_after_f().
1249 * The result of passing NULL in this parameter is undefined.
1250 */
1251API_AVAILABLE(macos(10.6), ios(4.0))
1252DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL4 DISPATCH_NOTHROW
1253void
1254dispatch_after_f(dispatch_time_t when, dispatch_queue_t queue,
1255 void *_Nullable context, dispatch_function_t work);
1256
1257/*!
1258 * @functiongroup Dispatch Barrier API
1259 * The dispatch barrier API is a mechanism for submitting barrier blocks to a
1260 * dispatch queue, analogous to the dispatch_async()/dispatch_sync() API.
1261 * It enables the implementation of efficient reader/writer schemes.
1262 * Barrier blocks only behave specially when submitted to queues created with
1263 * the DISPATCH_QUEUE_CONCURRENT attribute; on such a queue, a barrier block
1264 * will not run until all blocks submitted to the queue earlier have completed,
1265 * and any blocks submitted to the queue after a barrier block will not run
1266 * until the barrier block has completed.
1267 * When submitted to a a global queue or to a queue not created with the
1268 * DISPATCH_QUEUE_CONCURRENT attribute, barrier blocks behave identically to
1269 * blocks submitted with the dispatch_async()/dispatch_sync() API.
1270 */
1271
1272/*!
1273 * @function dispatch_barrier_async
1274 *
1275 * @abstract
1276 * Submits a barrier block for asynchronous execution on a dispatch queue.
1277 *
1278 * @discussion
1279 * Submits a block to a dispatch queue like dispatch_async(), but marks that
1280 * block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
1281 *
1282 * See dispatch_async() for details and "Dispatch Barrier API" for a description
1283 * of the barrier semantics.
1284 *
1285 * @param queue
1286 * The target dispatch queue to which the block is submitted.
1287 * The system will hold a reference on the target queue until the block
1288 * has finished.
1289 * The result of passing NULL in this parameter is undefined.
1290 *
1291 * @param block
1292 * The block to submit to the target dispatch queue. This function performs
1293 * Block_copy() and Block_release() on behalf of callers.
1294 * The result of passing NULL in this parameter is undefined.
1295 */
1296#ifdef __BLOCKS__
1297API_AVAILABLE(macos(10.7), ios(4.3))
1298DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
1299void
1300dispatch_barrier_async(dispatch_queue_t queue, dispatch_block_t block);
1301#endif
1302
1303/*!
1304 * @function dispatch_barrier_async_f
1305 *
1306 * @abstract
1307 * Submits a barrier function for asynchronous execution on a dispatch queue.
1308 *
1309 * @discussion
1310 * Submits a function to a dispatch queue like dispatch_async_f(), but marks
1311 * that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT
1312 * queues).
1313 *
1314 * See dispatch_async_f() for details and "Dispatch Barrier API" for a
1315 * description of the barrier semantics.
1316 *
1317 * @param queue
1318 * The target dispatch queue to which the function is submitted.
1319 * The system will hold a reference on the target queue until the function
1320 * has returned.
1321 * The result of passing NULL in this parameter is undefined.
1322 *
1323 * @param context
1324 * The application-defined context parameter to pass to the function.
1325 *
1326 * @param work
1327 * The application-defined function to invoke on the target queue. The first
1328 * parameter passed to this function is the context provided to
1329 * dispatch_barrier_async_f().
1330 * The result of passing NULL in this parameter is undefined.
1331 */
1332API_AVAILABLE(macos(10.7), ios(4.3))
1333DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
1334void
1335dispatch_barrier_async_f(dispatch_queue_t queue,
1336 void *_Nullable context, dispatch_function_t work);
1337
1338/*!
1339 * @function dispatch_barrier_sync
1340 *
1341 * @abstract
1342 * Submits a barrier block for synchronous execution on a dispatch queue.
1343 *
1344 * @discussion
1345 * Submits a block to a dispatch queue like dispatch_sync(), but marks that
1346 * block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
1347 *
1348 * See dispatch_sync() for details and "Dispatch Barrier API" for a description
1349 * of the barrier semantics.
1350 *
1351 * @param queue
1352 * The target dispatch queue to which the block is submitted.
1353 * The result of passing NULL in this parameter is undefined.
1354 *
1355 * @param block
1356 * The block to be invoked on the target dispatch queue.
1357 * The result of passing NULL in this parameter is undefined.
1358 */
1359#ifdef __BLOCKS__
1360API_AVAILABLE(macos(10.7), ios(4.3))
1361DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
1362void
1363dispatch_barrier_sync(dispatch_queue_t queue,
1364 DISPATCH_NOESCAPE dispatch_block_t block);
1365#endif
1366
1367/*!
1368 * @function dispatch_barrier_sync_f
1369 *
1370 * @abstract
1371 * Submits a barrier function for synchronous execution on a dispatch queue.
1372 *
1373 * @discussion
1374 * Submits a function to a dispatch queue like dispatch_sync_f(), but marks that
1375 * fuction as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
1376 *
1377 * See dispatch_sync_f() for details.
1378 *
1379 * @param queue
1380 * The target dispatch queue to which the function is submitted.
1381 * The result of passing NULL in this parameter is undefined.
1382 *
1383 * @param context
1384 * The application-defined context parameter to pass to the function.
1385 *
1386 * @param work
1387 * The application-defined function to invoke on the target queue. The first
1388 * parameter passed to this function is the context provided to
1389 * dispatch_barrier_sync_f().
1390 * The result of passing NULL in this parameter is undefined.
1391 */
1392API_AVAILABLE(macos(10.7), ios(4.3))
1393DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
1394void
1395dispatch_barrier_sync_f(dispatch_queue_t queue,
1396 void *_Nullable context, dispatch_function_t work);
1397
1398/*!
1399 * @function dispatch_barrier_async_and_wait
1400 *
1401 * @abstract
1402 * Submits a block for synchronous execution on a dispatch queue.
1403 *
1404 * @discussion
1405 * Submits a block to a dispatch queue like dispatch_async_and_wait(), but marks
1406 * that block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT
1407 * queues).
1408 *
1409 * See "Dispatch Barrier API" for a description of the barrier semantics.
1410 *
1411 * @param queue
1412 * The target dispatch queue to which the block is submitted.
1413 * The result of passing NULL in this parameter is undefined.
1414 *
1415 * @param work
1416 * The application-defined block to invoke on the target queue.
1417 * The result of passing NULL in this parameter is undefined.
1418 */
1419#ifdef __BLOCKS__
1420API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
1421DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
1422void
1423dispatch_barrier_async_and_wait(dispatch_queue_t queue,
1424 DISPATCH_NOESCAPE dispatch_block_t block);
1425#endif
1426
1427/*!
1428 * @function dispatch_barrier_async_and_wait_f
1429 *
1430 * @abstract
1431 * Submits a function for synchronous execution on a dispatch queue.
1432 *
1433 * @discussion
1434 * Submits a function to a dispatch queue like dispatch_async_and_wait_f(), but
1435 * marks that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT
1436 * queues).
1437 *
1438 * See "Dispatch Barrier API" for a description of the barrier semantics.
1439 *
1440 * @param queue
1441 * The target dispatch queue to which the function is submitted.
1442 * The result of passing NULL in this parameter is undefined.
1443 *
1444 * @param context
1445 * The application-defined context parameter to pass to the function.
1446 *
1447 * @param work
1448 * The application-defined function to invoke on the target queue. The first
1449 * parameter passed to this function is the context provided to
1450 * dispatch_barrier_async_and_wait_f().
1451 * The result of passing NULL in this parameter is undefined.
1452 */
1453API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
1454DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
1455void
1456dispatch_barrier_async_and_wait_f(dispatch_queue_t queue,
1457 void *_Nullable context, dispatch_function_t work);
1458
1459/*!
1460 * @functiongroup Dispatch queue-specific contexts
1461 * This API allows different subsystems to associate context to a shared queue
1462 * without risk of collision and to retrieve that context from blocks executing
1463 * on that queue or any of its child queues in the target queue hierarchy.
1464 */
1465
1466/*!
1467 * @function dispatch_queue_set_specific
1468 *
1469 * @abstract
1470 * Associates a subsystem-specific context with a dispatch queue, for a key
1471 * unique to the subsystem.
1472 *
1473 * @discussion
1474 * The specified destructor will be invoked with the context on the default
1475 * priority global concurrent queue when a new context is set for the same key,
1476 * or after all references to the queue have been released.
1477 *
1478 * @param queue
1479 * The dispatch queue to modify.
1480 * The result of passing NULL in this parameter is undefined.
1481 *
1482 * @param key
1483 * The key to set the context for, typically a pointer to a static variable
1484 * specific to the subsystem. Keys are only compared as pointers and never
1485 * dereferenced. Passing a string constant directly is not recommended.
1486 * The NULL key is reserved and attempts to set a context for it are ignored.
1487 *
1488 * @param context
1489 * The new subsystem-specific context for the object. This may be NULL.
1490 *
1491 * @param destructor
1492 * The destructor function pointer. This may be NULL and is ignored if context
1493 * is NULL.
1494 */
1495API_AVAILABLE(macos(10.7), ios(5.0))
1496DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
1497void
1498dispatch_queue_set_specific(dispatch_queue_t queue, const void *key,
1499 void *_Nullable context, dispatch_function_t _Nullable destructor);
1500
1501/*!
1502 * @function dispatch_queue_get_specific
1503 *
1504 * @abstract
1505 * Returns the subsystem-specific context associated with a dispatch queue, for
1506 * a key unique to the subsystem.
1507 *
1508 * @discussion
1509 * Returns the context for the specified key if it has been set on the specified
1510 * queue.
1511 *
1512 * @param queue
1513 * The dispatch queue to query.
1514 * The result of passing NULL in this parameter is undefined.
1515 *
1516 * @param key
1517 * The key to get the context for, typically a pointer to a static variable
1518 * specific to the subsystem. Keys are only compared as pointers and never
1519 * dereferenced. Passing a string constant directly is not recommended.
1520 *
1521 * @result
1522 * The context for the specified key or NULL if no context was found.
1523 */
1524API_AVAILABLE(macos(10.7), ios(5.0))
1525DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_PURE DISPATCH_WARN_RESULT
1526DISPATCH_NOTHROW
1527void *_Nullable
1528dispatch_queue_get_specific(dispatch_queue_t queue, const void *key);
1529
1530/*!
1531 * @function dispatch_get_specific
1532 *
1533 * @abstract
1534 * Returns the current subsystem-specific context for a key unique to the
1535 * subsystem.
1536 *
1537 * @discussion
1538 * When called from a block executing on a queue, returns the context for the
1539 * specified key if it has been set on the queue, otherwise returns the result
1540 * of dispatch_get_specific() executed on the queue's target queue or NULL
1541 * if the current queue is a global concurrent queue.
1542 *
1543 * @param key
1544 * The key to get the context for, typically a pointer to a static variable
1545 * specific to the subsystem. Keys are only compared as pointers and never
1546 * dereferenced. Passing a string constant directly is not recommended.
1547 *
1548 * @result
1549 * The context for the specified key or NULL if no context was found.
1550 */
1551API_AVAILABLE(macos(10.7), ios(5.0))
1552DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
1553void *_Nullable
1554dispatch_get_specific(const void *key);
1555
1556/*!
1557 * @functiongroup Dispatch assertion API
1558 *
1559 * This API asserts at runtime that code is executing in (or out of) the context
1560 * of a given queue. It can be used to check that a block accessing a resource
1561 * does so from the proper queue protecting the resource. It also can be used
1562 * to verify that a block that could cause a deadlock if run on a given queue
1563 * never executes on that queue.
1564 */
1565
1566/*!
1567 * @function dispatch_assert_queue
1568 *
1569 * @abstract
1570 * Verifies that the current block is executing on a given dispatch queue.
1571 *
1572 * @discussion
1573 * Some code expects to be run on a specific dispatch queue. This function
1574 * verifies that that expectation is true.
1575 *
1576 * If the currently executing block was submitted to the specified queue or to
1577 * any queue targeting it (see dispatch_set_target_queue()), this function
1578 * returns.
1579 *
1580 * If the currently executing block was submitted with a synchronous API
1581 * (dispatch_sync(), dispatch_barrier_sync(), ...), the context of the
1582 * submitting block is also evaluated (recursively).
1583 * If a synchronously submitting block is found that was itself submitted to
1584 * the specified queue or to any queue targeting it, this function returns.
1585 *
1586 * Otherwise this function asserts: it logs an explanation to the system log and
1587 * terminates the application.
1588 *
1589 * Passing the result of dispatch_get_main_queue() to this function verifies
1590 * that the current block was submitted to the main queue, or to a queue
1591 * targeting it, or is running on the main thread (in any context).
1592 *
1593 * When dispatch_assert_queue() is called outside of the context of a
1594 * submitted block (for example from the context of a thread created manually
1595 * with pthread_create()) then this function will also assert and terminate
1596 * the application.
1597 *
1598 * The variant dispatch_assert_queue_debug() is compiled out when the
1599 * preprocessor macro NDEBUG is defined. (See also assert(3)).
1600 *
1601 * @param queue
1602 * The dispatch queue that the current block is expected to run on.
1603 * The result of passing NULL in this parameter is undefined.
1604 */
1605API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
1606DISPATCH_EXPORT DISPATCH_NONNULL1
1607void
1608dispatch_assert_queue(dispatch_queue_t queue)
1609 DISPATCH_ALIAS_V2(dispatch_assert_queue);
1610
1611/*!
1612 * @function dispatch_assert_queue_barrier
1613 *
1614 * @abstract
1615 * Verifies that the current block is executing on a given dispatch queue,
1616 * and that the block acts as a barrier on that queue.
1617 *
1618 * @discussion
1619 * This behaves exactly like dispatch_assert_queue(), with the additional check
1620 * that the current block acts as a barrier on the specified queue, which is
1621 * always true if the specified queue is serial (see DISPATCH_BLOCK_BARRIER or
1622 * dispatch_barrier_async() for details).
1623 *
1624 * The variant dispatch_assert_queue_barrier_debug() is compiled out when the
1625 * preprocessor macro NDEBUG is defined. (See also assert()).
1626 *
1627 * @param queue
1628 * The dispatch queue that the current block is expected to run as a barrier on.
1629 * The result of passing NULL in this parameter is undefined.
1630 */
1631API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
1632DISPATCH_EXPORT DISPATCH_NONNULL1
1633void
1634dispatch_assert_queue_barrier(dispatch_queue_t queue);
1635
1636/*!
1637 * @function dispatch_assert_queue_not
1638 *
1639 * @abstract
1640 * Verifies that the current block is not executing on a given dispatch queue.
1641 *
1642 * @discussion
1643 * This function is the equivalent of dispatch_assert_queue() with the test for
1644 * equality inverted. That means that it will terminate the application when
1645 * dispatch_assert_queue() would return, and vice-versa. See discussion there.
1646 *
1647 * The variant dispatch_assert_queue_not_debug() is compiled out when the
1648 * preprocessor macro NDEBUG is defined. (See also assert(3)).
1649 *
1650 * @param queue
1651 * The dispatch queue that the current block is expected not to run on.
1652 * The result of passing NULL in this parameter is undefined.
1653 */
1654API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
1655DISPATCH_EXPORT DISPATCH_NONNULL1
1656void
1657dispatch_assert_queue_not(dispatch_queue_t queue)
1658 DISPATCH_ALIAS_V2(dispatch_assert_queue_not);
1659
1660#ifdef NDEBUG
1661#define dispatch_assert_queue_debug(q) ((void)(0 && (q)))
1662#define dispatch_assert_queue_barrier_debug(q) ((void)(0 && (q)))
1663#define dispatch_assert_queue_not_debug(q) ((void)(0 && (q)))
1664#else
1665#define dispatch_assert_queue_debug(q) dispatch_assert_queue(q)
1666#define dispatch_assert_queue_barrier_debug(q) dispatch_assert_queue_barrier(q)
1667#define dispatch_assert_queue_not_debug(q) dispatch_assert_queue_not(q)
1668#endif
1669
1670__END_DECLS
1671
1672DISPATCH_ASSUME_NONNULL_END
1673
1674#endif
lib/libc/include/x86_64-macos-gnu/dispatch/semaphore.h created+117
......@@ -0,0 +1,117 @@
1/*
2 * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_SEMAPHORE__
22#define __DISPATCH_SEMAPHORE__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29DISPATCH_ASSUME_NONNULL_BEGIN
30
31/*!
32 * @typedef dispatch_semaphore_t
33 *
34 * @abstract
35 * A counting semaphore.
36 */
37DISPATCH_DECL(dispatch_semaphore);
38
39__BEGIN_DECLS
40
41/*!
42 * @function dispatch_semaphore_create
43 *
44 * @abstract
45 * Creates new counting semaphore with an initial value.
46 *
47 * @discussion
48 * Passing zero for the value is useful for when two threads need to reconcile
49 * the completion of a particular event. Passing a value greater than zero is
50 * useful for managing a finite pool of resources, where the pool size is equal
51 * to the value.
52 *
53 * @param value
54 * The starting value for the semaphore. Passing a value less than zero will
55 * cause NULL to be returned.
56 *
57 * @result
58 * The newly created semaphore, or NULL on failure.
59 */
60API_AVAILABLE(macos(10.6), ios(4.0))
61DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
62DISPATCH_NOTHROW
63dispatch_semaphore_t
64dispatch_semaphore_create(intptr_t value);
65
66/*!
67 * @function dispatch_semaphore_wait
68 *
69 * @abstract
70 * Wait (decrement) for a semaphore.
71 *
72 * @discussion
73 * Decrement the counting semaphore. If the resulting value is less than zero,
74 * this function waits for a signal to occur before returning.
75 *
76 * @param dsema
77 * The semaphore. The result of passing NULL in this parameter is undefined.
78 *
79 * @param timeout
80 * When to timeout (see dispatch_time). As a convenience, there are the
81 * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
82 *
83 * @result
84 * Returns zero on success, or non-zero if the timeout occurred.
85 */
86API_AVAILABLE(macos(10.6), ios(4.0))
87DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
88intptr_t
89dispatch_semaphore_wait(dispatch_semaphore_t dsema, dispatch_time_t timeout);
90
91/*!
92 * @function dispatch_semaphore_signal
93 *
94 * @abstract
95 * Signal (increment) a semaphore.
96 *
97 * @discussion
98 * Increment the counting semaphore. If the previous value was less than zero,
99 * this function wakes a waiting thread before returning.
100 *
101 * @param dsema The counting semaphore.
102 * The result of passing NULL in this parameter is undefined.
103 *
104 * @result
105 * This function returns non-zero if a thread is woken. Otherwise, zero is
106 * returned.
107 */
108API_AVAILABLE(macos(10.6), ios(4.0))
109DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
110intptr_t
111dispatch_semaphore_signal(dispatch_semaphore_t dsema);
112
113__END_DECLS
114
115DISPATCH_ASSUME_NONNULL_END
116
117#endif /* __DISPATCH_SEMAPHORE__ */
lib/libc/include/x86_64-macos-gnu/dispatch/source.h created+780
......@@ -0,0 +1,780 @@
1/*
2 * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_SOURCE__
22#define __DISPATCH_SOURCE__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29#if TARGET_OS_MAC
30#include <mach/port.h>
31#include <mach/message.h>
32#endif
33
34#if !defined(_WIN32)
35#include <sys/signal.h>
36#endif
37
38DISPATCH_ASSUME_NONNULL_BEGIN
39
40/*!
41 * @header
42 * The dispatch framework provides a suite of interfaces for monitoring low-
43 * level system objects (file descriptors, Mach ports, signals, VFS nodes, etc.)
44 * for activity and automatically submitting event handler blocks to dispatch
45 * queues when such activity occurs.
46 *
47 * This suite of interfaces is known as the Dispatch Source API.
48 */
49
50/*!
51 * @typedef dispatch_source_t
52 *
53 * @abstract
54 * Dispatch sources are used to automatically submit event handler blocks to
55 * dispatch queues in response to external events.
56 */
57DISPATCH_SOURCE_DECL(dispatch_source);
58
59__BEGIN_DECLS
60
61/*!
62 * @typedef dispatch_source_type_t
63 *
64 * @abstract
65 * Constants of this type represent the class of low-level system object that
66 * is being monitored by the dispatch source. Constants of this type are
67 * passed as a parameter to dispatch_source_create() and determine how the
68 * handle argument is interpreted (i.e. as a file descriptor, mach port,
69 * signal number, process identifier, etc.), and how the mask argument is
70 * interpreted.
71 */
72typedef const struct dispatch_source_type_s *dispatch_source_type_t;
73
74/*!
75 * @const DISPATCH_SOURCE_TYPE_DATA_ADD
76 * @discussion A dispatch source that coalesces data obtained via calls to
77 * dispatch_source_merge_data(). An ADD is used to coalesce the data.
78 * The handle is unused (pass zero for now).
79 * The mask is unused (pass zero for now).
80 */
81#define DISPATCH_SOURCE_TYPE_DATA_ADD (&_dispatch_source_type_data_add)
82API_AVAILABLE(macos(10.6), ios(4.0))
83DISPATCH_SOURCE_TYPE_DECL(data_add);
84
85/*!
86 * @const DISPATCH_SOURCE_TYPE_DATA_OR
87 * @discussion A dispatch source that coalesces data obtained via calls to
88 * dispatch_source_merge_data(). A bitwise OR is used to coalesce the data.
89 * The handle is unused (pass zero for now).
90 * The mask is unused (pass zero for now).
91 */
92#define DISPATCH_SOURCE_TYPE_DATA_OR (&_dispatch_source_type_data_or)
93API_AVAILABLE(macos(10.6), ios(4.0))
94DISPATCH_SOURCE_TYPE_DECL(data_or);
95
96/*!
97 * @const DISPATCH_SOURCE_TYPE_DATA_REPLACE
98 * @discussion A dispatch source that tracks data obtained via calls to
99 * dispatch_source_merge_data(). Newly obtained data values replace existing
100 * data values not yet delivered to the source handler
101 *
102 * A data value of zero will cause the source handler to not be invoked.
103 *
104 * The handle is unused (pass zero for now).
105 * The mask is unused (pass zero for now).
106 */
107#define DISPATCH_SOURCE_TYPE_DATA_REPLACE (&_dispatch_source_type_data_replace)
108API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
109DISPATCH_SOURCE_TYPE_DECL(data_replace);
110
111/*!
112 * @const DISPATCH_SOURCE_TYPE_MACH_SEND
113 * @discussion A dispatch source that monitors a Mach port for dead name
114 * notifications (send right no longer has any corresponding receive right).
115 * The handle is a Mach port with a send or send-once right (mach_port_t).
116 * The mask is a mask of desired events from dispatch_source_mach_send_flags_t.
117 */
118#define DISPATCH_SOURCE_TYPE_MACH_SEND (&_dispatch_source_type_mach_send)
119API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
120DISPATCH_SOURCE_TYPE_DECL(mach_send);
121
122/*!
123 * @const DISPATCH_SOURCE_TYPE_MACH_RECV
124 * @discussion A dispatch source that monitors a Mach port for pending messages.
125 * The handle is a Mach port with a receive right (mach_port_t).
126 * The mask is a mask of desired events from dispatch_source_mach_recv_flags_t,
127 * but no flags are currently defined (pass zero for now).
128 */
129#define DISPATCH_SOURCE_TYPE_MACH_RECV (&_dispatch_source_type_mach_recv)
130API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
131DISPATCH_SOURCE_TYPE_DECL(mach_recv);
132
133/*!
134 * @const DISPATCH_SOURCE_TYPE_MEMORYPRESSURE
135 * @discussion A dispatch source that monitors the system for changes in
136 * memory pressure condition.
137 * The handle is unused (pass zero for now).
138 * The mask is a mask of desired events from
139 * dispatch_source_memorypressure_flags_t.
140 */
141#define DISPATCH_SOURCE_TYPE_MEMORYPRESSURE \
142 (&_dispatch_source_type_memorypressure)
143API_AVAILABLE(macos(10.9), ios(8.0)) DISPATCH_LINUX_UNAVAILABLE()
144DISPATCH_SOURCE_TYPE_DECL(memorypressure);
145
146/*!
147 * @const DISPATCH_SOURCE_TYPE_PROC
148 * @discussion A dispatch source that monitors an external process for events
149 * defined by dispatch_source_proc_flags_t.
150 * The handle is a process identifier (pid_t).
151 * The mask is a mask of desired events from dispatch_source_proc_flags_t.
152 */
153#define DISPATCH_SOURCE_TYPE_PROC (&_dispatch_source_type_proc)
154API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
155DISPATCH_SOURCE_TYPE_DECL(proc);
156
157/*!
158 * @const DISPATCH_SOURCE_TYPE_READ
159 * @discussion A dispatch source that monitors a file descriptor for pending
160 * bytes available to be read.
161 * The handle is a file descriptor (int).
162 * The mask is unused (pass zero for now).
163 */
164#define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read)
165API_AVAILABLE(macos(10.6), ios(4.0))
166DISPATCH_SOURCE_TYPE_DECL(read);
167
168/*!
169 * @const DISPATCH_SOURCE_TYPE_SIGNAL
170 * @discussion A dispatch source that monitors the current process for signals.
171 * The handle is a signal number (int).
172 * The mask is unused (pass zero for now).
173 */
174#define DISPATCH_SOURCE_TYPE_SIGNAL (&_dispatch_source_type_signal)
175API_AVAILABLE(macos(10.6), ios(4.0))
176DISPATCH_SOURCE_TYPE_DECL(signal);
177
178/*!
179 * @const DISPATCH_SOURCE_TYPE_TIMER
180 * @discussion A dispatch source that submits the event handler block based
181 * on a timer.
182 * The handle is unused (pass zero for now).
183 * The mask specifies which flags from dispatch_source_timer_flags_t to apply.
184 */
185#define DISPATCH_SOURCE_TYPE_TIMER (&_dispatch_source_type_timer)
186API_AVAILABLE(macos(10.6), ios(4.0))
187DISPATCH_SOURCE_TYPE_DECL(timer);
188
189/*!
190 * @const DISPATCH_SOURCE_TYPE_VNODE
191 * @discussion A dispatch source that monitors a file descriptor for events
192 * defined by dispatch_source_vnode_flags_t.
193 * The handle is a file descriptor (int).
194 * The mask is a mask of desired events from dispatch_source_vnode_flags_t.
195 */
196#define DISPATCH_SOURCE_TYPE_VNODE (&_dispatch_source_type_vnode)
197API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
198DISPATCH_SOURCE_TYPE_DECL(vnode);
199
200/*!
201 * @const DISPATCH_SOURCE_TYPE_WRITE
202 * @discussion A dispatch source that monitors a file descriptor for available
203 * buffer space to write bytes.
204 * The handle is a file descriptor (int).
205 * The mask is unused (pass zero for now).
206 */
207#define DISPATCH_SOURCE_TYPE_WRITE (&_dispatch_source_type_write)
208API_AVAILABLE(macos(10.6), ios(4.0))
209DISPATCH_SOURCE_TYPE_DECL(write);
210
211/*!
212 * @typedef dispatch_source_mach_send_flags_t
213 * Type of dispatch_source_mach_send flags
214 *
215 * @constant DISPATCH_MACH_SEND_DEAD
216 * The receive right corresponding to the given send right was destroyed.
217 */
218#define DISPATCH_MACH_SEND_DEAD 0x1
219
220typedef unsigned long dispatch_source_mach_send_flags_t;
221
222/*!
223 * @typedef dispatch_source_mach_recv_flags_t
224 * Type of dispatch_source_mach_recv flags
225 */
226typedef unsigned long dispatch_source_mach_recv_flags_t;
227
228/*!
229 * @typedef dispatch_source_memorypressure_flags_t
230 * Type of dispatch_source_memorypressure flags
231 *
232 * @constant DISPATCH_MEMORYPRESSURE_NORMAL
233 * The system memory pressure condition has returned to normal.
234 *
235 * @constant DISPATCH_MEMORYPRESSURE_WARN
236 * The system memory pressure condition has changed to warning.
237 *
238 * @constant DISPATCH_MEMORYPRESSURE_CRITICAL
239 * The system memory pressure condition has changed to critical.
240 *
241 * @discussion
242 * Elevated memory pressure is a system-wide condition that applications
243 * registered for this source should react to by changing their future memory
244 * use behavior, e.g. by reducing cache sizes of newly initiated operations
245 * until memory pressure returns back to normal.
246 * NOTE: applications should NOT traverse and discard existing caches for past
247 * operations when the system memory pressure enters an elevated state, as that
248 * is likely to trigger VM operations that will further aggravate system memory
249 * pressure.
250 */
251
252#define DISPATCH_MEMORYPRESSURE_NORMAL 0x01
253#define DISPATCH_MEMORYPRESSURE_WARN 0x02
254#define DISPATCH_MEMORYPRESSURE_CRITICAL 0x04
255
256typedef unsigned long dispatch_source_memorypressure_flags_t;
257
258/*!
259 * @typedef dispatch_source_proc_flags_t
260 * Type of dispatch_source_proc flags
261 *
262 * @constant DISPATCH_PROC_EXIT
263 * The process has exited (perhaps cleanly, perhaps not).
264 *
265 * @constant DISPATCH_PROC_FORK
266 * The process has created one or more child processes.
267 *
268 * @constant DISPATCH_PROC_EXEC
269 * The process has become another executable image via
270 * exec*() or posix_spawn*().
271 *
272 * @constant DISPATCH_PROC_SIGNAL
273 * A Unix signal was delivered to the process.
274 */
275#define DISPATCH_PROC_EXIT 0x80000000
276#define DISPATCH_PROC_FORK 0x40000000
277#define DISPATCH_PROC_EXEC 0x20000000
278#define DISPATCH_PROC_SIGNAL 0x08000000
279
280typedef unsigned long dispatch_source_proc_flags_t;
281
282/*!
283 * @typedef dispatch_source_vnode_flags_t
284 * Type of dispatch_source_vnode flags
285 *
286 * @constant DISPATCH_VNODE_DELETE
287 * The filesystem object was deleted from the namespace.
288 *
289 * @constant DISPATCH_VNODE_WRITE
290 * The filesystem object data changed.
291 *
292 * @constant DISPATCH_VNODE_EXTEND
293 * The filesystem object changed in size.
294 *
295 * @constant DISPATCH_VNODE_ATTRIB
296 * The filesystem object metadata changed.
297 *
298 * @constant DISPATCH_VNODE_LINK
299 * The filesystem object link count changed.
300 *
301 * @constant DISPATCH_VNODE_RENAME
302 * The filesystem object was renamed in the namespace.
303 *
304 * @constant DISPATCH_VNODE_REVOKE
305 * The filesystem object was revoked.
306 *
307 * @constant DISPATCH_VNODE_FUNLOCK
308 * The filesystem object was unlocked.
309 */
310
311#define DISPATCH_VNODE_DELETE 0x1
312#define DISPATCH_VNODE_WRITE 0x2
313#define DISPATCH_VNODE_EXTEND 0x4
314#define DISPATCH_VNODE_ATTRIB 0x8
315#define DISPATCH_VNODE_LINK 0x10
316#define DISPATCH_VNODE_RENAME 0x20
317#define DISPATCH_VNODE_REVOKE 0x40
318#define DISPATCH_VNODE_FUNLOCK 0x100
319
320typedef unsigned long dispatch_source_vnode_flags_t;
321
322/*!
323 * @typedef dispatch_source_timer_flags_t
324 * Type of dispatch_source_timer flags
325 *
326 * @constant DISPATCH_TIMER_STRICT
327 * Specifies that the system should make a best effort to strictly observe the
328 * leeway value specified for the timer via dispatch_source_set_timer(), even
329 * if that value is smaller than the default leeway value that would be applied
330 * to the timer otherwise. A minimal amount of leeway will be applied to the
331 * timer even if this flag is specified.
332 *
333 * CAUTION: Use of this flag may override power-saving techniques employed by
334 * the system and cause higher power consumption, so it must be used with care
335 * and only when absolutely necessary.
336 */
337
338#define DISPATCH_TIMER_STRICT 0x1
339
340typedef unsigned long dispatch_source_timer_flags_t;
341
342/*!
343 * @function dispatch_source_create
344 *
345 * @abstract
346 * Creates a new dispatch source to monitor low-level system objects and auto-
347 * matically submit a handler block to a dispatch queue in response to events.
348 *
349 * @discussion
350 * Dispatch sources are not reentrant. Any events received while the dispatch
351 * source is suspended or while the event handler block is currently executing
352 * will be coalesced and delivered after the dispatch source is resumed or the
353 * event handler block has returned.
354 *
355 * Dispatch sources are created in an inactive state. After creating the
356 * source and setting any desired attributes (i.e. the handler, context, etc.),
357 * a call must be made to dispatch_activate() in order to begin event delivery.
358 *
359 * Calling dispatch_set_target_queue() on a source once it has been activated
360 * is not allowed (see dispatch_activate() and dispatch_set_target_queue()).
361 *
362 * For backward compatibility reasons, dispatch_resume() on an inactive,
363 * and not otherwise suspended source has the same effect as calling
364 * dispatch_activate(). For new code, using dispatch_activate() is preferred.
365 *
366 * @param type
367 * Declares the type of the dispatch source. Must be one of the defined
368 * dispatch_source_type_t constants.
369 *
370 * @param handle
371 * The underlying system handle to monitor. The interpretation of this argument
372 * is determined by the constant provided in the type parameter.
373 *
374 * @param mask
375 * A mask of flags specifying which events are desired. The interpretation of
376 * this argument is determined by the constant provided in the type parameter.
377 *
378 * @param queue
379 * The dispatch queue to which the event handler block will be submitted.
380 * If queue is DISPATCH_TARGET_QUEUE_DEFAULT, the source will submit the event
381 * handler block to the default priority global queue.
382 *
383 * @result
384 * The newly created dispatch source. Or NULL if invalid arguments are passed.
385 */
386API_AVAILABLE(macos(10.6), ios(4.0))
387DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
388DISPATCH_NOTHROW
389dispatch_source_t
390dispatch_source_create(dispatch_source_type_t type,
391 uintptr_t handle,
392 uintptr_t mask,
393 dispatch_queue_t _Nullable queue);
394
395/*!
396 * @function dispatch_source_set_event_handler
397 *
398 * @abstract
399 * Sets the event handler block for the given dispatch source.
400 *
401 * @param source
402 * The dispatch source to modify.
403 * The result of passing NULL in this parameter is undefined.
404 *
405 * @param handler
406 * The event handler block to submit to the source's target queue.
407 */
408#ifdef __BLOCKS__
409API_AVAILABLE(macos(10.6), ios(4.0))
410DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
411void
412dispatch_source_set_event_handler(dispatch_source_t source,
413 dispatch_block_t _Nullable handler);
414#endif /* __BLOCKS__ */
415
416/*!
417 * @function dispatch_source_set_event_handler_f
418 *
419 * @abstract
420 * Sets the event handler function for the given dispatch source.
421 *
422 * @param source
423 * The dispatch source to modify.
424 * The result of passing NULL in this parameter is undefined.
425 *
426 * @param handler
427 * The event handler function to submit to the source's target queue.
428 * The context parameter passed to the event handler function is the context of
429 * the dispatch source current at the time the event handler was set.
430 */
431API_AVAILABLE(macos(10.6), ios(4.0))
432DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
433void
434dispatch_source_set_event_handler_f(dispatch_source_t source,
435 dispatch_function_t _Nullable handler);
436
437/*!
438 * @function dispatch_source_set_cancel_handler
439 *
440 * @abstract
441 * Sets the cancellation handler block for the given dispatch source.
442 *
443 * @discussion
444 * The cancellation handler (if specified) will be submitted to the source's
445 * target queue in response to a call to dispatch_source_cancel() once the
446 * system has released all references to the source's underlying handle and
447 * the source's event handler block has returned.
448 *
449 * IMPORTANT:
450 * Source cancellation and a cancellation handler are required for file
451 * descriptor and mach port based sources in order to safely close the
452 * descriptor or destroy the port.
453 * Closing the descriptor or port before the cancellation handler is invoked may
454 * result in a race condition. If a new descriptor is allocated with the same
455 * value as the recently closed descriptor while the source's event handler is
456 * still running, the event handler may read/write data to the wrong descriptor.
457 *
458 * @param source
459 * The dispatch source to modify.
460 * The result of passing NULL in this parameter is undefined.
461 *
462 * @param handler
463 * The cancellation handler block to submit to the source's target queue.
464 */
465#ifdef __BLOCKS__
466API_AVAILABLE(macos(10.6), ios(4.0))
467DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
468void
469dispatch_source_set_cancel_handler(dispatch_source_t source,
470 dispatch_block_t _Nullable handler);
471#endif /* __BLOCKS__ */
472
473/*!
474 * @function dispatch_source_set_cancel_handler_f
475 *
476 * @abstract
477 * Sets the cancellation handler function for the given dispatch source.
478 *
479 * @discussion
480 * See dispatch_source_set_cancel_handler() for more details.
481 *
482 * @param source
483 * The dispatch source to modify.
484 * The result of passing NULL in this parameter is undefined.
485 *
486 * @param handler
487 * The cancellation handler function to submit to the source's target queue.
488 * The context parameter passed to the event handler function is the current
489 * context of the dispatch source at the time the handler call is made.
490 */
491API_AVAILABLE(macos(10.6), ios(4.0))
492DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
493void
494dispatch_source_set_cancel_handler_f(dispatch_source_t source,
495 dispatch_function_t _Nullable handler);
496
497/*!
498 * @function dispatch_source_cancel
499 *
500 * @abstract
501 * Asynchronously cancel the dispatch source, preventing any further invocation
502 * of its event handler block.
503 *
504 * @discussion
505 * Cancellation prevents any further invocation of the event handler block for
506 * the specified dispatch source, but does not interrupt an event handler
507 * block that is already in progress.
508 *
509 * The cancellation handler is submitted to the source's target queue once the
510 * the source's event handler has finished, indicating it is now safe to close
511 * the source's handle (i.e. file descriptor or mach port).
512 *
513 * See dispatch_source_set_cancel_handler() for more information.
514 *
515 * @param source
516 * The dispatch source to be canceled.
517 * The result of passing NULL in this parameter is undefined.
518 */
519API_AVAILABLE(macos(10.6), ios(4.0))
520DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
521void
522dispatch_source_cancel(dispatch_source_t source);
523
524/*!
525 * @function dispatch_source_testcancel
526 *
527 * @abstract
528 * Tests whether the given dispatch source has been canceled.
529 *
530 * @param source
531 * The dispatch source to be tested.
532 * The result of passing NULL in this parameter is undefined.
533 *
534 * @result
535 * Non-zero if canceled and zero if not canceled.
536 */
537API_AVAILABLE(macos(10.6), ios(4.0))
538DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
539DISPATCH_NOTHROW
540intptr_t
541dispatch_source_testcancel(dispatch_source_t source);
542
543/*!
544 * @function dispatch_source_get_handle
545 *
546 * @abstract
547 * Returns the underlying system handle associated with this dispatch source.
548 *
549 * @param source
550 * The result of passing NULL in this parameter is undefined.
551 *
552 * @result
553 * The return value should be interpreted according to the type of the dispatch
554 * source, and may be one of the following handles:
555 *
556 * DISPATCH_SOURCE_TYPE_DATA_ADD: n/a
557 * DISPATCH_SOURCE_TYPE_DATA_OR: n/a
558 * DISPATCH_SOURCE_TYPE_DATA_REPLACE: n/a
559 * DISPATCH_SOURCE_TYPE_MACH_SEND: mach port (mach_port_t)
560 * DISPATCH_SOURCE_TYPE_MACH_RECV: mach port (mach_port_t)
561 * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE n/a
562 * DISPATCH_SOURCE_TYPE_PROC: process identifier (pid_t)
563 * DISPATCH_SOURCE_TYPE_READ: file descriptor (int)
564 * DISPATCH_SOURCE_TYPE_SIGNAL: signal number (int)
565 * DISPATCH_SOURCE_TYPE_TIMER: n/a
566 * DISPATCH_SOURCE_TYPE_VNODE: file descriptor (int)
567 * DISPATCH_SOURCE_TYPE_WRITE: file descriptor (int)
568 */
569API_AVAILABLE(macos(10.6), ios(4.0))
570DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
571DISPATCH_NOTHROW
572uintptr_t
573dispatch_source_get_handle(dispatch_source_t source);
574
575/*!
576 * @function dispatch_source_get_mask
577 *
578 * @abstract
579 * Returns the mask of events monitored by the dispatch source.
580 *
581 * @param source
582 * The result of passing NULL in this parameter is undefined.
583 *
584 * @result
585 * The return value should be interpreted according to the type of the dispatch
586 * source, and may be one of the following flag sets:
587 *
588 * DISPATCH_SOURCE_TYPE_DATA_ADD: n/a
589 * DISPATCH_SOURCE_TYPE_DATA_OR: n/a
590 * DISPATCH_SOURCE_TYPE_DATA_REPLACE: n/a
591 * DISPATCH_SOURCE_TYPE_MACH_SEND: dispatch_source_mach_send_flags_t
592 * DISPATCH_SOURCE_TYPE_MACH_RECV: dispatch_source_mach_recv_flags_t
593 * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE dispatch_source_memorypressure_flags_t
594 * DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_flags_t
595 * DISPATCH_SOURCE_TYPE_READ: n/a
596 * DISPATCH_SOURCE_TYPE_SIGNAL: n/a
597 * DISPATCH_SOURCE_TYPE_TIMER: dispatch_source_timer_flags_t
598 * DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_vnode_flags_t
599 * DISPATCH_SOURCE_TYPE_WRITE: n/a
600 */
601API_AVAILABLE(macos(10.6), ios(4.0))
602DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
603DISPATCH_NOTHROW
604uintptr_t
605dispatch_source_get_mask(dispatch_source_t source);
606
607/*!
608 * @function dispatch_source_get_data
609 *
610 * @abstract
611 * Returns pending data for the dispatch source.
612 *
613 * @discussion
614 * This function is intended to be called from within the event handler block.
615 * The result of calling this function outside of the event handler callback is
616 * undefined.
617 *
618 * @param source
619 * The result of passing NULL in this parameter is undefined.
620 *
621 * @result
622 * The return value should be interpreted according to the type of the dispatch
623 * source, and may be one of the following:
624 *
625 * DISPATCH_SOURCE_TYPE_DATA_ADD: application defined data
626 * DISPATCH_SOURCE_TYPE_DATA_OR: application defined data
627 * DISPATCH_SOURCE_TYPE_DATA_REPLACE: application defined data
628 * DISPATCH_SOURCE_TYPE_MACH_SEND: dispatch_source_mach_send_flags_t
629 * DISPATCH_SOURCE_TYPE_MACH_RECV: dispatch_source_mach_recv_flags_t
630 * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE dispatch_source_memorypressure_flags_t
631 * DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_flags_t
632 * DISPATCH_SOURCE_TYPE_READ: estimated bytes available to read
633 * DISPATCH_SOURCE_TYPE_SIGNAL: number of signals delivered since
634 * the last handler invocation
635 * DISPATCH_SOURCE_TYPE_TIMER: number of times the timer has fired
636 * since the last handler invocation
637 * DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_vnode_flags_t
638 * DISPATCH_SOURCE_TYPE_WRITE: estimated buffer space available
639 */
640API_AVAILABLE(macos(10.6), ios(4.0))
641DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
642DISPATCH_NOTHROW
643uintptr_t
644dispatch_source_get_data(dispatch_source_t source);
645
646/*!
647 * @function dispatch_source_merge_data
648 *
649 * @abstract
650 * Merges data into a dispatch source of type DISPATCH_SOURCE_TYPE_DATA_ADD,
651 * DISPATCH_SOURCE_TYPE_DATA_OR or DISPATCH_SOURCE_TYPE_DATA_REPLACE,
652 * and submits its event handler block to its target queue.
653 *
654 * @param source
655 * The result of passing NULL in this parameter is undefined.
656 *
657 * @param value
658 * The value to coalesce with the pending data using a logical OR or an ADD
659 * as specified by the dispatch source type. A value of zero has no effect
660 * and will not result in the submission of the event handler block.
661 */
662API_AVAILABLE(macos(10.6), ios(4.0))
663DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
664void
665dispatch_source_merge_data(dispatch_source_t source, uintptr_t value);
666
667/*!
668 * @function dispatch_source_set_timer
669 *
670 * @abstract
671 * Sets a start time, interval, and leeway value for a timer source.
672 *
673 * @discussion
674 * Once this function returns, any pending source data accumulated for the
675 * previous timer values has been cleared; the next fire of the timer will
676 * occur at 'start', and every 'interval' nanoseconds thereafter until the
677 * timer source is canceled.
678 *
679 * Any fire of the timer may be delayed by the system in order to improve power
680 * consumption and system performance. The upper limit to the allowable delay
681 * may be configured with the 'leeway' argument, the lower limit is under the
682 * control of the system.
683 *
684 * For the initial timer fire at 'start', the upper limit to the allowable
685 * delay is set to 'leeway' nanoseconds. For the subsequent timer fires at
686 * 'start' + N * 'interval', the upper limit is MIN('leeway','interval'/2).
687 *
688 * The lower limit to the allowable delay may vary with process state such as
689 * visibility of application UI. If the specified timer source was created with
690 * a mask of DISPATCH_TIMER_STRICT, the system will make a best effort to
691 * strictly observe the provided 'leeway' value even if it is smaller than the
692 * current lower limit. Note that a minimal amount of delay is to be expected
693 * even if this flag is specified.
694 *
695 * The 'start' argument also determines which clock will be used for the timer:
696 * If 'start' is DISPATCH_TIME_NOW or was created with dispatch_time(3), the
697 * timer is based on up time (which is obtained from mach_absolute_time() on
698 * Apple platforms). If 'start' was created with dispatch_walltime(3), the
699 * timer is based on gettimeofday(3).
700 *
701 * Calling this function has no effect if the timer source has already been
702 * canceled.
703 *
704 * @param start
705 * The start time of the timer. See dispatch_time() and dispatch_walltime()
706 * for more information.
707 *
708 * @param interval
709 * The nanosecond interval for the timer. Use DISPATCH_TIME_FOREVER for a
710 * one-shot timer.
711 *
712 * @param leeway
713 * The nanosecond leeway for the timer.
714 */
715API_AVAILABLE(macos(10.6), ios(4.0))
716DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
717void
718dispatch_source_set_timer(dispatch_source_t source,
719 dispatch_time_t start,
720 uint64_t interval,
721 uint64_t leeway);
722
723/*!
724 * @function dispatch_source_set_registration_handler
725 *
726 * @abstract
727 * Sets the registration handler block for the given dispatch source.
728 *
729 * @discussion
730 * The registration handler (if specified) will be submitted to the source's
731 * target queue once the corresponding kevent() has been registered with the
732 * system, following the initial dispatch_resume() of the source.
733 *
734 * If a source is already registered when the registration handler is set, the
735 * registration handler will be invoked immediately.
736 *
737 * @param source
738 * The dispatch source to modify.
739 * The result of passing NULL in this parameter is undefined.
740 *
741 * @param handler
742 * The registration handler block to submit to the source's target queue.
743 */
744#ifdef __BLOCKS__
745API_AVAILABLE(macos(10.7), ios(4.3))
746DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
747void
748dispatch_source_set_registration_handler(dispatch_source_t source,
749 dispatch_block_t _Nullable handler);
750#endif /* __BLOCKS__ */
751
752/*!
753 * @function dispatch_source_set_registration_handler_f
754 *
755 * @abstract
756 * Sets the registration handler function for the given dispatch source.
757 *
758 * @discussion
759 * See dispatch_source_set_registration_handler() for more details.
760 *
761 * @param source
762 * The dispatch source to modify.
763 * The result of passing NULL in this parameter is undefined.
764 *
765 * @param handler
766 * The registration handler function to submit to the source's target queue.
767 * The context parameter passed to the registration handler function is the
768 * current context of the dispatch source at the time the handler call is made.
769 */
770API_AVAILABLE(macos(10.7), ios(4.3))
771DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
772void
773dispatch_source_set_registration_handler_f(dispatch_source_t source,
774 dispatch_function_t _Nullable handler);
775
776__END_DECLS
777
778DISPATCH_ASSUME_NONNULL_END
779
780#endif
lib/libc/include/x86_64-macos-gnu/dispatch/time.h created+136
......@@ -0,0 +1,136 @@
1/*
2 * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_TIME__
22#define __DISPATCH_TIME__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29#include <stdint.h>
30
31// <rdar://problem/6368156&7563559>
32#if TARGET_OS_MAC
33#include <mach/clock_types.h>
34#endif
35
36DISPATCH_ASSUME_NONNULL_BEGIN
37
38#ifdef NSEC_PER_SEC
39#undef NSEC_PER_SEC
40#endif
41#ifdef USEC_PER_SEC
42#undef USEC_PER_SEC
43#endif
44#ifdef NSEC_PER_USEC
45#undef NSEC_PER_USEC
46#endif
47#ifdef NSEC_PER_MSEC
48#undef NSEC_PER_MSEC
49#endif
50#define NSEC_PER_SEC 1000000000ull
51#define NSEC_PER_MSEC 1000000ull
52#define USEC_PER_SEC 1000000ull
53#define NSEC_PER_USEC 1000ull
54
55__BEGIN_DECLS
56
57struct timespec;
58
59/*!
60 * @typedef dispatch_time_t
61 *
62 * @abstract
63 * A somewhat abstract representation of time; where zero means "now" and
64 * DISPATCH_TIME_FOREVER means "infinity" and every value in between is an
65 * opaque encoding.
66 */
67typedef uint64_t dispatch_time_t;
68
69enum {
70 DISPATCH_WALLTIME_NOW DISPATCH_ENUM_API_AVAILABLE
71 (macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = ~1ull,
72};
73
74#define DISPATCH_TIME_NOW (0ull)
75#define DISPATCH_TIME_FOREVER (~0ull)
76
77/*!
78 * @function dispatch_time
79 *
80 * @abstract
81 * Create a dispatch_time_t relative to the current value of the default or
82 * wall time clock, or modify an existing dispatch_time_t.
83 *
84 * @discussion
85 * On Apple platforms, the default clock is based on mach_absolute_time().
86 *
87 * @param when
88 * An optional dispatch_time_t to add nanoseconds to. If DISPATCH_TIME_NOW is
89 * passed, then dispatch_time() will use the default clock (which is based on
90 * mach_absolute_time() on Apple platforms). If DISPATCH_WALLTIME_NOW is used,
91 * dispatch_time() will use the value returned by gettimeofday(3).
92 * dispatch_time(DISPATCH_WALLTIME_NOW, delta) is equivalent to
93 * dispatch_walltime(NULL, delta).
94 *
95 * @param delta
96 * Nanoseconds to add.
97 *
98 * @result
99 * A new dispatch_time_t.
100 */
101API_AVAILABLE(macos(10.6), ios(4.0))
102DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
103dispatch_time_t
104dispatch_time(dispatch_time_t when, int64_t delta);
105
106/*!
107 * @function dispatch_walltime
108 *
109 * @abstract
110 * Create a dispatch_time_t using the wall clock.
111 *
112 * @discussion
113 * On Mac OS X the wall clock is based on gettimeofday(3).
114 *
115 * @param when
116 * A struct timespec to add time to. If NULL is passed, then
117 * dispatch_walltime() will use the result of gettimeofday(3).
118 * dispatch_walltime(NULL, delta) returns the same value as
119 * dispatch_time(DISPATCH_WALLTIME_NOW, delta).
120 *
121 * @param delta
122 * Nanoseconds to add.
123 *
124 * @result
125 * A new dispatch_time_t.
126 */
127API_AVAILABLE(macos(10.6), ios(4.0))
128DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
129dispatch_time_t
130dispatch_walltime(const struct timespec *_Nullable when, int64_t delta);
131
132__END_DECLS
133
134DISPATCH_ASSUME_NONNULL_END
135
136#endif
lib/libc/include/x86_64-macos-gnu/dispatch/workloop.h created+163
......@@ -0,0 +1,163 @@
1/*
2 * Copyright (c) 2017-2019 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_WORKLOOP__
22#define __DISPATCH_WORKLOOP__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29DISPATCH_ASSUME_NONNULL_BEGIN
30
31__BEGIN_DECLS
32
33/*!
34 * @typedef dispatch_workloop_t
35 *
36 * @abstract
37 * Dispatch workloops invoke workitems submitted to them in priority order.
38 *
39 * @discussion
40 * A dispatch workloop is a flavor of dispatch_queue_t that is a priority
41 * ordered queue (using the QOS class of the submitted workitems as the
42 * ordering).
43 *
44 * Between each workitem invocation, the workloop will evaluate whether higher
45 * priority workitems have since been submitted, either directly to the
46 * workloop or to any queues that target the workloop, and execute these first.
47 *
48 * Serial queues targeting a workloop maintain FIFO execution of their
49 * workitems. However, the workloop may reorder workitems submitted to
50 * independent serial queues targeting it with respect to each other,
51 * based on their priorities, while preserving FIFO execution with respect to
52 * each serial queue.
53 *
54 * A dispatch workloop is a "subclass" of dispatch_queue_t which can be passed
55 * to all APIs accepting a dispatch queue, except for functions from the
56 * dispatch_sync() family. dispatch_async_and_wait() must be used for workloop
57 * objects. Functions from the dispatch_sync() family on queues targeting
58 * a workloop are still permitted but discouraged for performance reasons.
59 */
60DISPATCH_DECL_SUBCLASS(dispatch_workloop, dispatch_queue);
61
62/*!
63 * @function dispatch_workloop_create
64 *
65 * @abstract
66 * Creates a new dispatch workloop to which workitems may be submitted.
67 *
68 * @param label
69 * A string label to attach to the workloop.
70 *
71 * @result
72 * The newly created dispatch workloop.
73 */
74API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
75DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
76DISPATCH_NOTHROW
77dispatch_workloop_t
78dispatch_workloop_create(const char *_Nullable label);
79
80/*!
81 * @function dispatch_workloop_create_inactive
82 *
83 * @abstract
84 * Creates a new inactive dispatch workloop that can be setup and then
85 * activated.
86 *
87 * @discussion
88 * Creating an inactive workloop allows for it to receive further configuration
89 * before it is activated, and workitems can be submitted to it.
90 *
91 * Submitting workitems to an inactive workloop is undefined and will cause the
92 * process to be terminated.
93 *
94 * @param label
95 * A string label to attach to the workloop.
96 *
97 * @result
98 * The newly created dispatch workloop.
99 */
100API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
101DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
102DISPATCH_NOTHROW
103dispatch_workloop_t
104dispatch_workloop_create_inactive(const char *_Nullable label);
105
106/*!
107 * @function dispatch_workloop_set_autorelease_frequency
108 *
109 * @abstract
110 * Sets the autorelease frequency of the workloop.
111 *
112 * @discussion
113 * See dispatch_queue_attr_make_with_autorelease_frequency().
114 * The default policy for a workloop is
115 * DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM.
116 *
117 * @param workloop
118 * The dispatch workloop to modify.
119 *
120 * This workloop must be inactive, passing an activated object is undefined
121 * and will cause the process to be terminated.
122 *
123 * @param frequency
124 * The requested autorelease frequency.
125 */
126API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
127DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
128void
129dispatch_workloop_set_autorelease_frequency(dispatch_workloop_t workloop,
130 dispatch_autorelease_frequency_t frequency);
131
132/*!
133 * @function dispatch_workloop_set_os_workgroup
134 *
135 * @abstract
136 * Associates an os_workgroup_t with the specified dispatch workloop.
137 *
138 * The worker thread will be a member of the specified os_workgroup_t while executing
139 * work items submitted to the workloop.
140 *
141 * @param workloop
142 * The dispatch workloop to modify.
143 *
144 * This workloop must be inactive, passing an activated object is undefined
145 * and will cause the process to be terminated.
146 *
147 * @param workgroup
148 * The workgroup to associate with this workloop.
149 *
150 * The workgroup specified is retained and the previously associated workgroup
151 * (if any) is released.
152 */
153API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
154DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
155void
156dispatch_workloop_set_os_workgroup(dispatch_workloop_t workloop,
157 os_workgroup_t workgroup);
158
159__END_DECLS
160
161DISPATCH_ASSUME_NONNULL_END
162
163#endif
lib/libc/include/x86_64-macos-gnu/hfs/hfs_format.h created+818
......@@ -0,0 +1,818 @@
1/*
2 * Copyright (c) 2000-2015 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#ifndef __HFS_FORMAT__
29#define __HFS_FORMAT__
30
31#include <sys/types.h>
32#include <sys/appleapiopts.h>
33#include "hfs_unistr.h"
34
35/*
36 * hfs_format.h
37 *
38 * This file describes the on-disk format for HFS and HFS Plus volumes.
39 *
40 * Note: Starting 10.9, definition of struct HFSUniStr255 exists in hfs_unitstr.h
41 *
42 */
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/* some on-disk hfs structures have 68K alignment (misaligned) */
49
50/* Signatures used to differentiate between HFS and HFS Plus volumes */
51enum {
52 kHFSSigWord = 0x4244, /* 'BD' in ASCII */
53 kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */
54 kHFSXSigWord = 0x4858, /* 'HX' in ASCII */
55
56 kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */
57 kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */
58
59 kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */
60 kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */
61 kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */
62};
63
64
65#ifdef __APPLE_API_PRIVATE
66/*
67 * Mac OS X has two special directories on HFS+ volumes for hardlinked files
68 * and hardlinked directories as well as for open-unlinked files.
69 *
70 * These directories and their contents are not exported from the filesystem
71 * under Mac OS X.
72 */
73#define HFSPLUSMETADATAFOLDER "\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80HFS+ Private Data"
74#define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd"
75
76/*
77 * Files in the "HFS+ Private Data" folder have one of the following prefixes
78 * followed by a decimal number (no leading zeros) for the file ID.
79 *
80 * Note: Earlier version of Mac OS X used a 32 bit random number for the link
81 * ref number instead of the file id.
82 *
83 * e.g. iNode7182000 and temp3296
84 */
85#define HFS_INODE_PREFIX "iNode"
86#define HFS_DELETE_PREFIX "temp"
87
88/*
89 * Files in the ".HFS+ Private Directory Data" folder have the following
90 * prefix followed by a decimal number (no leading zeros) for the file ID.
91 *
92 * e.g. dir_555
93 */
94#define HFS_DIRINODE_PREFIX "dir_"
95
96/*
97 * Hardlink inodes save the head of the link chain in
98 * an extended attribute named FIRST_LINK_XATTR_NAME.
99 * The attribute data is the decimal value in ASCII
100 * of the cnid for the first link in the chain.
101 *
102 * This extended attribute is private (i.e. its not
103 * exported in the getxattr/listxattr POSIX APIs).
104 */
105#define FIRST_LINK_XATTR_NAME "com.apple.system.hfs.firstlink"
106#define FIRST_LINK_XATTR_REC_SIZE (sizeof(HFSPlusAttrData) - 2 + 12)
107
108/*
109 * The name space ID for generating an HFS volume UUID
110 *
111 * B3E20F39-F292-11D6-97A4-00306543ECAC
112 */
113#define HFS_UUID_NAMESPACE_ID "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC"
114
115#endif /* __APPLE_API_PRIVATE */
116
117/*
118 * Indirect link files (hard links) have the following type/creator.
119 */
120enum {
121 kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */
122 kHFSPlusCreator = 0x6866732B /* 'hfs+' */
123};
124
125
126/*
127 * File type and creator for symbolic links
128 */
129enum {
130 kSymLinkFileType = 0x736C6E6B, /* 'slnk' */
131 kSymLinkCreator = 0x72686170 /* 'rhap' */
132};
133
134
135enum {
136 kHFSMaxVolumeNameChars = 27,
137 kHFSMaxFileNameChars = 31,
138 kHFSPlusMaxFileNameChars = 255
139};
140
141
142/* Extent overflow file data structures */
143
144/* HFS Extent key */
145struct HFSExtentKey {
146 u_int8_t keyLength; /* length of key, excluding this field */
147 u_int8_t forkType; /* 0 = data fork, FF = resource fork */
148 u_int32_t fileID; /* file ID */
149 u_int16_t startBlock; /* first file allocation block number in this extent */
150} __attribute__((aligned(2), packed));
151typedef struct HFSExtentKey HFSExtentKey;
152
153/* HFS Plus Extent key */
154struct HFSPlusExtentKey {
155 u_int16_t keyLength; /* length of key, excluding this field */
156 u_int8_t forkType; /* 0 = data fork, FF = resource fork */
157 u_int8_t pad; /* make the other fields align on 32-bit boundary */
158 u_int32_t fileID; /* file ID */
159 u_int32_t startBlock; /* first file allocation block number in this extent */
160} __attribute__((aligned(2), packed));
161typedef struct HFSPlusExtentKey HFSPlusExtentKey;
162
163/* Number of extent descriptors per extent record */
164enum {
165 kHFSExtentDensity = 3,
166 kHFSPlusExtentDensity = 8
167};
168
169/* HFS extent descriptor */
170struct HFSExtentDescriptor {
171 u_int16_t startBlock; /* first allocation block */
172 u_int16_t blockCount; /* number of allocation blocks */
173} __attribute__((aligned(2), packed));
174typedef struct HFSExtentDescriptor HFSExtentDescriptor;
175
176/* HFS Plus extent descriptor */
177struct HFSPlusExtentDescriptor {
178 u_int32_t startBlock; /* first allocation block */
179 u_int32_t blockCount; /* number of allocation blocks */
180} __attribute__((aligned(2), packed));
181typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
182
183/* HFS extent record */
184typedef HFSExtentDescriptor HFSExtentRecord[3];
185
186/* HFS Plus extent record */
187typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
188
189
190/* Finder information */
191struct FndrFileInfo {
192 u_int32_t fdType; /* file type */
193 u_int32_t fdCreator; /* file creator */
194 u_int16_t fdFlags; /* Finder flags */
195 struct {
196 int16_t v; /* file's location */
197 int16_t h;
198 } fdLocation;
199 int16_t opaque;
200} __attribute__((aligned(2), packed));
201typedef struct FndrFileInfo FndrFileInfo;
202
203struct FndrDirInfo {
204 struct { /* folder's window rectangle */
205 int16_t top;
206 int16_t left;
207 int16_t bottom;
208 int16_t right;
209 } frRect;
210 unsigned short frFlags; /* Finder flags */
211 struct {
212 u_int16_t v; /* folder's location */
213 u_int16_t h;
214 } frLocation;
215 int16_t opaque;
216} __attribute__((aligned(2), packed));
217typedef struct FndrDirInfo FndrDirInfo;
218
219struct FndrOpaqueInfo {
220 int8_t opaque[16];
221} __attribute__((aligned(2), packed));
222typedef struct FndrOpaqueInfo FndrOpaqueInfo;
223
224struct FndrExtendedDirInfo {
225 u_int32_t document_id;
226 u_int32_t date_added;
227 u_int16_t extended_flags;
228 u_int16_t reserved3;
229 u_int32_t write_gen_counter;
230} __attribute__((aligned(2), packed));
231
232struct FndrExtendedFileInfo {
233 u_int32_t document_id;
234 u_int32_t date_added;
235 u_int16_t extended_flags;
236 u_int16_t reserved2;
237 u_int32_t write_gen_counter;
238} __attribute__((aligned(2), packed));
239
240/* HFS Plus Fork data info - 80 bytes */
241struct HFSPlusForkData {
242 u_int64_t logicalSize; /* fork's logical size in bytes */
243 u_int32_t clumpSize; /* fork's clump size in bytes */
244 u_int32_t totalBlocks; /* total blocks used by this fork */
245 HFSPlusExtentRecord extents; /* initial set of extents */
246} __attribute__((aligned(2), packed));
247typedef struct HFSPlusForkData HFSPlusForkData;
248
249
250/* Mac OS X has 16 bytes worth of "BSD" info.
251 *
252 * Note: Mac OS 9 implementations and applications
253 * should preserve, but not change, this information.
254 */
255struct HFSPlusBSDInfo {
256 u_int32_t ownerID; /* user-id of owner or hard link chain previous link */
257 u_int32_t groupID; /* group-id of owner or hard link chain next link */
258 u_int8_t adminFlags; /* super-user changeable flags */
259 u_int8_t ownerFlags; /* owner changeable flags */
260 u_int16_t fileMode; /* file type and permission bits */
261 union {
262 u_int32_t iNodeNum; /* indirect node number (hard links only) */
263 u_int32_t linkCount; /* links that refer to this indirect node */
264 u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */
265 } special;
266} __attribute__((aligned(2), packed));
267typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
268
269/*
270 * Hardlink "links" resolve to an inode
271 * and the actual uid/gid comes from that
272 * inode.
273 *
274 * We repurpose the links's uid/gid fields
275 * for the hardlink link chain. The chain
276 * consists of a doubly linked list of file
277 * ids.
278 */
279
280#define hl_firstLinkID reserved1 /* Valid only if HasLinkChain flag is set (indirect nodes only) */
281
282#define hl_prevLinkID bsdInfo.ownerID /* Valid only if HasLinkChain flag is set */
283#define hl_nextLinkID bsdInfo.groupID /* Valid only if HasLinkChain flag is set */
284
285#define hl_linkReference bsdInfo.special.iNodeNum
286#define hl_linkCount bsdInfo.special.linkCount
287
288
289/* Catalog file data structures */
290
291enum {
292 kHFSRootParentID = 1, /* Parent ID of the root folder */
293 kHFSRootFolderID = 2, /* Folder ID of the root folder */
294 kHFSExtentsFileID = 3, /* File ID of the extents file */
295 kHFSCatalogFileID = 4, /* File ID of the catalog file */
296 kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */
297 kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */
298 kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */
299 kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */
300 kHFSAttributeDataFileID = 13, /* Used in Mac OS X runtime for extent based attributes */
301 /* kHFSAttributeDataFileID is never stored on disk. */
302 kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */
303 kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */
304 kHFSFirstUserCatalogNodeID = 16
305};
306
307/* HFS catalog key */
308struct HFSCatalogKey {
309 u_int8_t keyLength; /* key length (in bytes) */
310 u_int8_t reserved; /* reserved (set to zero) */
311 u_int32_t parentID; /* parent folder ID */
312 u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */
313} __attribute__((aligned(2), packed));
314typedef struct HFSCatalogKey HFSCatalogKey;
315
316/* HFS Plus catalog key */
317struct HFSPlusCatalogKey {
318 u_int16_t keyLength; /* key length (in bytes) */
319 u_int32_t parentID; /* parent folder ID */
320 HFSUniStr255 nodeName; /* catalog node name */
321} __attribute__((aligned(2), packed));
322typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
323
324/* Catalog record types */
325enum {
326 /* HFS Catalog Records */
327 kHFSFolderRecord = 0x0100, /* Folder record */
328 kHFSFileRecord = 0x0200, /* File record */
329 kHFSFolderThreadRecord = 0x0300, /* Folder thread record */
330 kHFSFileThreadRecord = 0x0400, /* File thread record */
331
332 /* HFS Plus Catalog Records */
333 kHFSPlusFolderRecord = 1, /* Folder record */
334 kHFSPlusFileRecord = 2, /* File record */
335 kHFSPlusFolderThreadRecord = 3, /* Folder thread record */
336 kHFSPlusFileThreadRecord = 4 /* File thread record */
337};
338
339
340/* Catalog file record flags */
341enum {
342 kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */
343 kHFSFileLockedMask = 0x0001,
344
345 kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */
346 kHFSThreadExistsMask = 0x0002,
347
348 kHFSHasAttributesBit = 0x0002, /* object has extended attributes */
349 kHFSHasAttributesMask = 0x0004,
350
351 kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */
352 kHFSHasSecurityMask = 0x0008,
353
354 kHFSHasFolderCountBit = 0x0004, /* only for HFSX, folder maintains a separate sub-folder count */
355 kHFSHasFolderCountMask = 0x0010, /* (sum of folder records and directory hard links) */
356
357 kHFSHasLinkChainBit = 0x0005, /* has hardlink chain (inode or link) */
358 kHFSHasLinkChainMask = 0x0020,
359
360 kHFSHasChildLinkBit = 0x0006, /* folder has a child that's a dir link */
361 kHFSHasChildLinkMask = 0x0040,
362
363 kHFSHasDateAddedBit = 0x0007, /* File/Folder has the date-added stored in the finder info. */
364 kHFSHasDateAddedMask = 0x0080,
365
366 kHFSFastDevPinnedBit = 0x0008, /* this file has been pinned to the fast-device by the hot-file code on cooperative fusion */
367 kHFSFastDevPinnedMask = 0x0100,
368
369 kHFSDoNotFastDevPinBit = 0x0009, /* this file can not be pinned to the fast-device */
370 kHFSDoNotFastDevPinMask = 0x0200,
371
372 kHFSFastDevCandidateBit = 0x000a, /* this item is a potential candidate for fast-dev pinning (as are any of its descendents */
373 kHFSFastDevCandidateMask = 0x0400,
374
375 kHFSAutoCandidateBit = 0x000b, /* this item was automatically marked as a fast-dev candidate by the kernel */
376 kHFSAutoCandidateMask = 0x0800
377
378 // There are only 4 flag bits remaining: 0x1000, 0x2000, 0x4000, 0x8000
379
380};
381
382
383/* HFS catalog folder record - 70 bytes */
384struct HFSCatalogFolder {
385 int16_t recordType; /* == kHFSFolderRecord */
386 u_int16_t flags; /* folder flags */
387 u_int16_t valence; /* folder valence */
388 u_int32_t folderID; /* folder ID */
389 u_int32_t createDate; /* date and time of creation */
390 u_int32_t modifyDate; /* date and time of last modification */
391 u_int32_t backupDate; /* date and time of last backup */
392 FndrDirInfo userInfo; /* Finder information */
393 FndrOpaqueInfo finderInfo; /* additional Finder information */
394 u_int32_t reserved[4]; /* reserved - initialized as zero */
395} __attribute__((aligned(2), packed));
396typedef struct HFSCatalogFolder HFSCatalogFolder;
397
398/* HFS Plus catalog folder record - 88 bytes */
399struct HFSPlusCatalogFolder {
400 int16_t recordType; /* == kHFSPlusFolderRecord */
401 u_int16_t flags; /* file flags */
402 u_int32_t valence; /* folder's item count */
403 u_int32_t folderID; /* folder ID */
404 u_int32_t createDate; /* date and time of creation */
405 u_int32_t contentModDate; /* date and time of last content modification */
406 u_int32_t attributeModDate; /* date and time of last attribute modification */
407 u_int32_t accessDate; /* date and time of last access (MacOS X only) */
408 u_int32_t backupDate; /* date and time of last backup */
409 HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
410 FndrDirInfo userInfo; /* Finder information */
411 FndrOpaqueInfo finderInfo; /* additional Finder information */
412 u_int32_t textEncoding; /* hint for name conversions */
413 u_int32_t folderCount; /* number of enclosed folders, active when HasFolderCount is set */
414} __attribute__((aligned(2), packed));
415typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
416
417/* HFS catalog file record - 102 bytes */
418struct HFSCatalogFile {
419 int16_t recordType; /* == kHFSFileRecord */
420 u_int8_t flags; /* file flags */
421 int8_t fileType; /* file type (unused ?) */
422 FndrFileInfo userInfo; /* Finder information */
423 u_int32_t fileID; /* file ID */
424 u_int16_t dataStartBlock; /* not used - set to zero */
425 int32_t dataLogicalSize; /* logical EOF of data fork */
426 int32_t dataPhysicalSize; /* physical EOF of data fork */
427 u_int16_t rsrcStartBlock; /* not used - set to zero */
428 int32_t rsrcLogicalSize; /* logical EOF of resource fork */
429 int32_t rsrcPhysicalSize; /* physical EOF of resource fork */
430 u_int32_t createDate; /* date and time of creation */
431 u_int32_t modifyDate; /* date and time of last modification */
432 u_int32_t backupDate; /* date and time of last backup */
433 FndrOpaqueInfo finderInfo; /* additional Finder information */
434 u_int16_t clumpSize; /* file clump size (not used) */
435 HFSExtentRecord dataExtents; /* first data fork extent record */
436 HFSExtentRecord rsrcExtents; /* first resource fork extent record */
437 u_int32_t reserved; /* reserved - initialized as zero */
438} __attribute__((aligned(2), packed));
439typedef struct HFSCatalogFile HFSCatalogFile;
440
441/* HFS Plus catalog file record - 248 bytes */
442struct HFSPlusCatalogFile {
443 int16_t recordType; /* == kHFSPlusFileRecord */
444 u_int16_t flags; /* file flags */
445 u_int32_t reserved1; /* reserved - initialized as zero */
446 u_int32_t fileID; /* file ID */
447 u_int32_t createDate; /* date and time of creation */
448 u_int32_t contentModDate; /* date and time of last content modification */
449 u_int32_t attributeModDate; /* date and time of last attribute modification */
450 u_int32_t accessDate; /* date and time of last access (MacOS X only) */
451 u_int32_t backupDate; /* date and time of last backup */
452 HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
453 FndrFileInfo userInfo; /* Finder information */
454 FndrOpaqueInfo finderInfo; /* additional Finder information */
455 u_int32_t textEncoding; /* hint for name conversions */
456 u_int32_t reserved2; /* reserved - initialized as zero */
457
458 /* Note: these start on double long (64 bit) boundary */
459 HFSPlusForkData dataFork; /* size and block data for data fork */
460 HFSPlusForkData resourceFork; /* size and block data for resource fork */
461} __attribute__((aligned(2), packed));
462typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
463
464/* HFS catalog thread record - 46 bytes */
465struct HFSCatalogThread {
466 int16_t recordType; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
467 int32_t reserved[2]; /* reserved - initialized as zero */
468 u_int32_t parentID; /* parent ID for this catalog node */
469 u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */
470} __attribute__((aligned(2), packed));
471typedef struct HFSCatalogThread HFSCatalogThread;
472
473/* HFS Plus catalog thread record -- 264 bytes */
474struct HFSPlusCatalogThread {
475 int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
476 int16_t reserved; /* reserved - initialized as zero */
477 u_int32_t parentID; /* parent ID for this catalog node */
478 HFSUniStr255 nodeName; /* name of this catalog node (variable length) */
479} __attribute__((aligned(2), packed));
480typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
481
482#ifdef __APPLE_API_UNSTABLE
483/*
484 * These are the types of records in the attribute B-tree. The values were
485 * chosen so that they wouldn't conflict with the catalog record types.
486 */
487enum {
488 kHFSPlusAttrInlineData = 0x10, /* attributes whose data fits in a b-tree node */
489 kHFSPlusAttrForkData = 0x20, /* extent based attributes (data lives in extents) */
490 kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */
491};
492
493
494/*
495 * HFSPlusAttrForkData
496 * For larger attributes, whose value is stored in allocation blocks.
497 * If the attribute has more than 8 extents, there will be additional
498 * records (of type HFSPlusAttrExtents) for this attribute.
499 */
500struct HFSPlusAttrForkData {
501 u_int32_t recordType; /* == kHFSPlusAttrForkData*/
502 u_int32_t reserved;
503 HFSPlusForkData theFork; /* size and first extents of value*/
504} __attribute__((aligned(2), packed));
505typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
506
507/*
508 * HFSPlusAttrExtents
509 * This record contains information about overflow extents for large,
510 * fragmented attributes.
511 */
512struct HFSPlusAttrExtents {
513 u_int32_t recordType; /* == kHFSPlusAttrExtents*/
514 u_int32_t reserved;
515 HFSPlusExtentRecord extents; /* additional extents*/
516} __attribute__((aligned(2), packed));
517typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
518
519/*
520 * Atrributes B-tree Data Record
521 *
522 * For small attributes, whose entire value is stored
523 * within a single B-tree record.
524 */
525struct HFSPlusAttrData {
526 u_int32_t recordType; /* == kHFSPlusAttrInlineData */
527 u_int32_t reserved[2];
528 u_int32_t attrSize; /* size of attribute data in bytes */
529 u_int8_t attrData[2]; /* variable length */
530} __attribute__((aligned(2), packed));
531typedef struct HFSPlusAttrData HFSPlusAttrData;
532
533
534/* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */
535struct HFSPlusAttrInlineData {
536 u_int32_t recordType;
537 u_int32_t reserved;
538 u_int32_t logicalSize;
539 u_int8_t userData[2];
540} __attribute__((aligned(2), packed));
541typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
542
543
544/* A generic Attribute Record */
545union HFSPlusAttrRecord {
546 u_int32_t recordType;
547 HFSPlusAttrInlineData inlineData; /* NOT USED */
548 HFSPlusAttrData attrData;
549 HFSPlusAttrForkData forkData;
550 HFSPlusAttrExtents overflowExtents;
551};
552typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
553
554/* Attribute key */
555enum { kHFSMaxAttrNameLen = 127 };
556struct HFSPlusAttrKey {
557 u_int16_t keyLength; /* key length (in bytes) */
558 u_int16_t pad; /* set to zero */
559 u_int32_t fileID; /* file associated with attribute */
560 u_int32_t startBlock; /* first allocation block number for extents */
561 u_int16_t attrNameLen; /* number of unicode characters */
562 u_int16_t attrName[kHFSMaxAttrNameLen]; /* attribute name (Unicode) */
563} __attribute__((aligned(2), packed));
564typedef struct HFSPlusAttrKey HFSPlusAttrKey;
565
566#define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
567#define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - kHFSMaxAttrNameLen*sizeof(u_int16_t))
568
569#endif /* __APPLE_API_UNSTABLE */
570
571
572/* Key and node lengths */
573enum {
574 kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t),
575 kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t),
576 kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t),
577 kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t),
578 kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(u_int8_t),
579 kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t),
580 kHFSPlusCatalogMinNodeSize = 4096,
581 kHFSPlusExtentMinNodeSize = 512,
582 kHFSPlusAttrMinNodeSize = 4096
583};
584
585/* HFS and HFS Plus volume attribute bits */
586enum {
587 /* Bits 0-6 are reserved (always cleared by MountVol call) */
588 kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */
589 kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */
590 kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */
591 kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
592 kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */
593 kHFSCatalogNodeIDsReusedBit = 12,
594 kHFSVolumeJournaledBit = 13, /* this volume has a journal on it */
595 kHFSVolumeInconsistentBit = 14, /* serious inconsistencies detected at runtime */
596 kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */
597 /*
598 * HFS only has 16 bits of attributes in the MDB, but HFS Plus has 32 bits.
599 * Therefore, bits 16-31 can only be used on HFS Plus.
600 */
601 kHFSUnusedNodeFixBit = 31, /* Unused nodes in the Catalog B-tree have been zero-filled. See Radar #6947811. */
602 kHFSContentProtectionBit = 30, /* Volume has per-file content protection */
603
604 /*** Keep these in sync with the bits above ! ****/
605 kHFSVolumeHardwareLockMask = 0x00000080,
606 kHFSVolumeUnmountedMask = 0x00000100,
607 kHFSVolumeSparedBlocksMask = 0x00000200,
608 kHFSVolumeNoCacheRequiredMask = 0x00000400,
609 kHFSBootVolumeInconsistentMask = 0x00000800,
610 kHFSCatalogNodeIDsReusedMask = 0x00001000,
611 kHFSVolumeJournaledMask = 0x00002000,
612 kHFSVolumeInconsistentMask = 0x00004000,
613 kHFSVolumeSoftwareLockMask = 0x00008000,
614
615 /* Bits 16-31 are allocated from high to low */
616
617 kHFSContentProtectionMask = 0x40000000,
618 kHFSUnusedNodeFixMask = 0x80000000,
619
620 kHFSMDBAttributesMask = 0x8380
621};
622
623enum {
624 kHFSUnusedNodesFixDate = 0xc5ef2480 /* March 25, 2009 */
625};
626
627/* HFS Master Directory Block - 162 bytes */
628/* Stored at sector #2 (3rd sector) and second-to-last sector. */
629struct HFSMasterDirectoryBlock {
630 u_int16_t drSigWord; /* == kHFSSigWord */
631 u_int32_t drCrDate; /* date and time of volume creation */
632 u_int32_t drLsMod; /* date and time of last modification */
633 u_int16_t drAtrb; /* volume attributes */
634 u_int16_t drNmFls; /* number of files in root folder */
635 u_int16_t drVBMSt; /* first block of volume bitmap */
636 u_int16_t drAllocPtr; /* start of next allocation search */
637 u_int16_t drNmAlBlks; /* number of allocation blocks in volume */
638 u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */
639 u_int32_t drClpSiz; /* default clump size */
640 u_int16_t drAlBlSt; /* first allocation block in volume */
641 u_int32_t drNxtCNID; /* next unused catalog node ID */
642 u_int16_t drFreeBks; /* number of unused allocation blocks */
643 u_int8_t drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */
644 u_int32_t drVolBkUp; /* date and time of last backup */
645 u_int16_t drVSeqNum; /* volume backup sequence number */
646 u_int32_t drWrCnt; /* volume write count */
647 u_int32_t drXTClpSiz; /* clump size for extents overflow file */
648 u_int32_t drCTClpSiz; /* clump size for catalog file */
649 u_int16_t drNmRtDirs; /* number of directories in root folder */
650 u_int32_t drFilCnt; /* number of files in volume */
651 u_int32_t drDirCnt; /* number of directories in volume */
652 u_int32_t drFndrInfo[8]; /* information used by the Finder */
653 u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
654 HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
655 u_int32_t drXTFlSize; /* size of extents overflow file */
656 HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */
657 u_int32_t drCTFlSize; /* size of catalog file */
658 HFSExtentRecord drCTExtRec; /* extent record for catalog file */
659} __attribute__((aligned(2), packed));
660typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
661
662
663#ifdef __APPLE_API_UNSTABLE
664#define SET_HFS_TEXT_ENCODING(hint) \
665 (0x656e6300 | ((hint) & 0xff))
666#define GET_HFS_TEXT_ENCODING(hint) \
667 (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
668#endif /* __APPLE_API_UNSTABLE */
669
670
671/* HFS Plus Volume Header - 512 bytes */
672/* Stored at sector #2 (3rd sector) and second-to-last sector. */
673struct HFSPlusVolumeHeader {
674 u_int16_t signature; /* == kHFSPlusSigWord */
675 u_int16_t version; /* == kHFSPlusVersion */
676 u_int32_t attributes; /* volume attributes */
677 u_int32_t lastMountedVersion; /* implementation version which last mounted volume */
678 u_int32_t journalInfoBlock; /* block addr of journal info (if volume is journaled, zero otherwise) */
679
680 u_int32_t createDate; /* date and time of volume creation */
681 u_int32_t modifyDate; /* date and time of last modification */
682 u_int32_t backupDate; /* date and time of last backup */
683 u_int32_t checkedDate; /* date and time of last disk check */
684
685 u_int32_t fileCount; /* number of files in volume */
686 u_int32_t folderCount; /* number of directories in volume */
687
688 u_int32_t blockSize; /* size (in bytes) of allocation blocks */
689 u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/
690 u_int32_t freeBlocks; /* number of unused allocation blocks */
691
692 u_int32_t nextAllocation; /* start of next allocation search */
693 u_int32_t rsrcClumpSize; /* default resource fork clump size */
694 u_int32_t dataClumpSize; /* default data fork clump size */
695 u_int32_t nextCatalogID; /* next unused catalog node ID */
696
697 u_int32_t writeCount; /* volume write count */
698 u_int64_t encodingsBitmap; /* which encodings have been use on this volume */
699
700 u_int8_t finderInfo[32]; /* information used by the Finder */
701
702 HFSPlusForkData allocationFile; /* allocation bitmap file */
703 HFSPlusForkData extentsFile; /* extents B-tree file */
704 HFSPlusForkData catalogFile; /* catalog B-tree file */
705 HFSPlusForkData attributesFile; /* extended attributes B-tree file */
706 HFSPlusForkData startupFile; /* boot file (secondary loader) */
707} __attribute__((aligned(2), packed));
708typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
709
710
711/* B-tree structures */
712
713enum BTreeKeyLimits{
714 kMaxKeyLength = 520
715};
716
717union BTreeKey{
718 u_int8_t length8;
719 u_int16_t length16;
720 u_int8_t rawData [kMaxKeyLength+2];
721};
722typedef union BTreeKey BTreeKey;
723
724/* BTNodeDescriptor -- Every B-tree node starts with these fields. */
725struct BTNodeDescriptor {
726 u_int32_t fLink; /* next node at this level*/
727 u_int32_t bLink; /* previous node at this level*/
728 int8_t kind; /* kind of node (leaf, index, header, map)*/
729 u_int8_t height; /* zero for header, map; child is one more than parent*/
730 u_int16_t numRecords; /* number of records in this node*/
731 u_int16_t reserved; /* reserved - initialized as zero */
732} __attribute__((aligned(2), packed));
733typedef struct BTNodeDescriptor BTNodeDescriptor;
734
735/* Constants for BTNodeDescriptor kind */
736enum {
737 kBTLeafNode = -1,
738 kBTIndexNode = 0,
739 kBTHeaderNode = 1,
740 kBTMapNode = 2
741};
742
743/* BTHeaderRec -- The first record of a B-tree header node */
744struct BTHeaderRec {
745 u_int16_t treeDepth; /* maximum height (usually leaf nodes) */
746 u_int32_t rootNode; /* node number of root node */
747 u_int32_t leafRecords; /* number of leaf records in all leaf nodes */
748 u_int32_t firstLeafNode; /* node number of first leaf node */
749 u_int32_t lastLeafNode; /* node number of last leaf node */
750 u_int16_t nodeSize; /* size of a node, in bytes */
751 u_int16_t maxKeyLength; /* reserved */
752 u_int32_t totalNodes; /* total number of nodes in tree */
753 u_int32_t freeNodes; /* number of unused (free) nodes in tree */
754 u_int16_t reserved1; /* unused */
755 u_int32_t clumpSize; /* reserved */
756 u_int8_t btreeType; /* reserved */
757 u_int8_t keyCompareType; /* Key string Comparison Type */
758 u_int32_t attributes; /* persistent attributes about the tree */
759 u_int32_t reserved3[16]; /* reserved */
760} __attribute__((aligned(2), packed));
761typedef struct BTHeaderRec BTHeaderRec;
762
763/* Constants for BTHeaderRec attributes */
764enum {
765 kBTBadCloseMask = 0x00000001, /* reserved */
766 kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */
767 kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */
768};
769
770
771/* Catalog Key Name Comparison Type */
772enum {
773 kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */
774 kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */
775};
776
777#include <uuid/uuid.h>
778
779/* JournalInfoBlock - Structure that describes where our journal lives */
780
781// the original size of the reserved field in the JournalInfoBlock was
782// 32*sizeof(u_int32_t). To keep the total size of the structure the
783// same we subtract the size of new fields (currently: ext_jnl_uuid and
784// machine_uuid). If you add additional fields, place them before the
785// reserved field and subtract their size in this macro.
786//
787#define JIB_RESERVED_SIZE ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48)
788
789struct JournalInfoBlock {
790 u_int32_t flags;
791 u_int32_t device_signature[8]; // signature used to locate our device.
792 u_int64_t offset; // byte offset to the journal on the device
793 u_int64_t size; // size in bytes of the journal
794 uuid_string_t ext_jnl_uuid;
795 char machine_serial_num[48];
796 char reserved[JIB_RESERVED_SIZE];
797} __attribute__((aligned(2), packed));
798typedef struct JournalInfoBlock JournalInfoBlock;
799
800enum {
801 kJIJournalInFSMask = 0x00000001,
802 kJIJournalOnOtherDeviceMask = 0x00000002,
803 kJIJournalNeedInitMask = 0x00000004
804};
805
806//
807// This the content type uuid for "external journal" GPT
808// partitions. Each instance of a partition also has a
809// uuid that uniquely identifies that instance.
810//
811#define EXTJNL_CONTENT_TYPE_UUID "4A6F7572-6E61-11AA-AA11-00306543ECAC"
812
813
814#ifdef __cplusplus
815}
816#endif
817
818#endif /* __HFS_FORMAT__ */
lib/libc/include/x86_64-macos-gnu/hfs/hfs_unistr.h created+64
......@@ -0,0 +1,64 @@
1/*
2 * Copyright (c) 2013 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 __HFS_UNISTR__
30#define __HFS_UNISTR__
31
32#include <sys/types.h>
33
34/*
35 * hfs_unitstr.h
36 *
37 * This file contains definition of the unicode string used for HFS Plus
38 * files and folder names, as described by the on-disk format.
39 *
40 */
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46
47#ifndef _HFSUNISTR255_DEFINED_
48#define _HFSUNISTR255_DEFINED_
49/* Unicode strings are used for HFS Plus file and folder names */
50struct HFSUniStr255 {
51 u_int16_t length; /* number of unicode characters */
52 u_int16_t unicode[255]; /* unicode characters */
53} __attribute__((aligned(2), packed));
54typedef struct HFSUniStr255 HFSUniStr255;
55typedef const HFSUniStr255 *ConstHFSUniStr255Param;
56#endif /* _HFSUNISTR255_DEFINED_ */
57
58
59#ifdef __cplusplus
60}
61#endif
62
63
64#endif /* __HFS_UNISTR__ */
lib/libc/include/x86_64-macos-gnu/i386/_param.h+2-2
......@@ -37,10 +37,10 @@
3737 * cast to any desired pointer type.
3838 */
3939#define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1)
40#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
40#define __DARWIN_ALIGN(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
4141
4242#define __DARWIN_ALIGNBYTES32 (sizeof(__uint32_t) - 1)
43#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
43#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
4444
4545
4646#endif /* _I386__PARAM_H_ */
lib/libc/include/x86_64-macos-gnu/launch.h created+409
......@@ -0,0 +1,409 @@
1#ifndef __XPC_LAUNCH_H__
2#define __XPC_LAUNCH_H__
3
4/*!
5 * @header
6 * These interfaces were only ever documented for the purpose of allowing a
7 * launchd job to obtain file descriptors associated with the sockets it
8 * advertised in its launchd.plist(5). That functionality is now available in a
9 * much more straightforward fashion through the {@link launch_activate_socket}
10 * API.
11 *
12 * There are currently no replacements for other uses of the {@link launch_msg}
13 * API, including submitting, removing, starting, stopping and listing jobs.
14 */
15
16#include <os/base.h>
17#include <Availability.h>
18
19#include <mach/mach.h>
20#include <stddef.h>
21#include <stdbool.h>
22#include <sys/cdefs.h>
23
24#if __has_feature(assume_nonnull)
25_Pragma("clang assume_nonnull begin")
26#endif
27__BEGIN_DECLS
28
29#define LAUNCH_KEY_SUBMITJOB "SubmitJob"
30#define LAUNCH_KEY_REMOVEJOB "RemoveJob"
31#define LAUNCH_KEY_STARTJOB "StartJob"
32#define LAUNCH_KEY_STOPJOB "StopJob"
33#define LAUNCH_KEY_GETJOB "GetJob"
34#define LAUNCH_KEY_GETJOBS "GetJobs"
35#define LAUNCH_KEY_CHECKIN "CheckIn"
36
37#define LAUNCH_JOBKEY_LABEL "Label"
38#define LAUNCH_JOBKEY_DISABLED "Disabled"
39#define LAUNCH_JOBKEY_USERNAME "UserName"
40#define LAUNCH_JOBKEY_GROUPNAME "GroupName"
41#define LAUNCH_JOBKEY_TIMEOUT "TimeOut"
42#define LAUNCH_JOBKEY_EXITTIMEOUT "ExitTimeOut"
43#define LAUNCH_JOBKEY_INITGROUPS "InitGroups"
44#define LAUNCH_JOBKEY_SOCKETS "Sockets"
45#define LAUNCH_JOBKEY_MACHSERVICES "MachServices"
46#define LAUNCH_JOBKEY_MACHSERVICELOOKUPPOLICIES "MachServiceLookupPolicies"
47#define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility"
48#define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing"
49#define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments"
50#define LAUNCH_JOBKEY_PROGRAM "Program"
51#define LAUNCH_JOBKEY_ONDEMAND "OnDemand"
52#define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive"
53#define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts"
54#define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts"
55#define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType"
56#define LAUNCH_JOBKEY_LIMITLOADTOHARDWARE "LimitLoadToHardware"
57#define LAUNCH_JOBKEY_LIMITLOADFROMHARDWARE "LimitLoadFromHardware"
58#define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad"
59#define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory"
60#define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory"
61#define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables"
62#define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables"
63#define LAUNCH_JOBKEY_UMASK "Umask"
64#define LAUNCH_JOBKEY_NICE "Nice"
65#define LAUNCH_JOBKEY_HOPEFULLYEXITSFIRST "HopefullyExitsFirst"
66#define LAUNCH_JOBKEY_HOPEFULLYEXITSLAST "HopefullyExitsLast"
67#define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO"
68#define LAUNCH_JOBKEY_LOWPRIORITYBACKGROUNDIO "LowPriorityBackgroundIO"
69#define LAUNCH_JOBKEY_MATERIALIZEDATALESSFILES "MaterializeDatalessFiles"
70#define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate"
71#define LAUNCH_JOBKEY_STARTONMOUNT "StartOnMount"
72#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits"
73#define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits"
74#define LAUNCH_JOBKEY_STANDARDINPATH "StandardInPath"
75#define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath"
76#define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath"
77#define LAUNCH_JOBKEY_DEBUG "Debug"
78#define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger"
79#define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories"
80#define LAUNCH_JOBKEY_HOMERELATIVEQUEUEDIRECTORIES "HomeRelativeQueueDirectories"
81#define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths"
82#define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval"
83#define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval"
84#define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs"
85#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus"
86#define LAUNCH_JOBKEY_PID "PID"
87#define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval"
88#define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce"
89#define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup"
90#define LAUNCH_JOBKEY_IGNOREPROCESSGROUPATSHUTDOWN \
91 "IgnoreProcessGroupAtShutdown"
92#define LAUNCH_JOBKEY_LEGACYTIMERS "LegacyTimers"
93#define LAUNCH_JOBKEY_ENABLEPRESSUREDEXIT "EnablePressuredExit"
94#define LAUNCH_JOBKEY_ENABLETRANSACTIONS "EnableTransactions"
95#define LAUNCH_JOBKEY_DRAINMESSAGESONFAILEDINIT "DrainMessagesOnFailedInit"
96#define LAUNCH_JOBKEY_POLICIES "Policies"
97
98#define LAUNCH_JOBKEY_PUBLISHESEVENTS "PublishesEvents"
99#define LAUNCH_KEY_PUBLISHESEVENTS_DOMAININTERNAL "DomainInternal"
100
101#define LAUNCH_JOBPOLICY_DENYCREATINGOTHERJOBS "DenyCreatingOtherJobs"
102
103#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait"
104#define LAUNCH_JOBINETDCOMPATIBILITY_INSTANCES "Instances"
105
106#define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose"
107#define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn"
108
109#define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit"
110#define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState"
111#define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState"
112#define LAUNCH_JOBKEY_KEEPALIVE_HOMERELATIVEPATHSTATE "HomeRelativePathState"
113#define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBACTIVE "OtherJobActive"
114#define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBENABLED "OtherJobEnabled"
115#define LAUNCH_JOBKEY_KEEPALIVE_AFTERINITIALDEMAND "AfterInitialDemand"
116#define LAUNCH_JOBKEY_KEEPALIVE_CRASHED "Crashed"
117
118#define LAUNCH_JOBKEY_LAUNCHEVENTS "LaunchEvents"
119
120#define LAUNCH_JOBKEY_CAL_MINUTE "Minute"
121#define LAUNCH_JOBKEY_CAL_HOUR "Hour"
122#define LAUNCH_JOBKEY_CAL_DAY "Day"
123#define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday"
124#define LAUNCH_JOBKEY_CAL_MONTH "Month"
125
126#define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core"
127#define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU"
128#define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data"
129#define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize"
130#define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock"
131#define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles"
132#define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses"
133#define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize"
134#define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack"
135
136#define LAUNCH_JOBKEY_DISABLED_MACHINETYPE "MachineType"
137#define LAUNCH_JOBKEY_DISABLED_MODELNAME "ModelName"
138
139#define LAUNCH_JOBKEY_DATASTORES "Datastores"
140#define LAUNCH_JOBKEY_DATASTORES_SIZELIMIT "SizeLimit"
141
142#define LAUNCH_JOBSOCKETKEY_TYPE "SockType"
143#define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive"
144#define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour"
145#define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey"
146#define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName"
147#define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode"
148#define LAUNCH_JOBSOCKETKEY_PATHOWNER "SockPathOwner"
149#define LAUNCH_JOBSOCKETKEY_PATHGROUP "SockPathGroup"
150#define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName"
151#define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName"
152#define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily"
153#define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol"
154#define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup"
155
156#define LAUNCH_JOBKEY_PROCESSTYPE "ProcessType"
157#define LAUNCH_KEY_PROCESSTYPE_APP "App"
158#define LAUNCH_KEY_PROCESSTYPE_STANDARD "Standard"
159#define LAUNCH_KEY_PROCESSTYPE_BACKGROUND "Background"
160#define LAUNCH_KEY_PROCESSTYPE_INTERACTIVE "Interactive"
161#define LAUNCH_KEY_PROCESSTYPE_ADAPTIVE "Adaptive"
162
163/*!
164 * @function launch_activate_socket
165 *
166 * @abstract
167 * Retrieves the file descriptors for sockets specified in the process'
168 * launchd.plist(5).
169 *
170 * @param name
171 * The name of the socket entry in the service's Sockets dictionary.
172 *
173 * @param fds
174 * On return, this parameter will be populated with an array of file
175 * descriptors. One socket can have many descriptors associated with it
176 * depending on the characteristics of the network interfaces on the system.
177 * The descriptors in this array are the results of calling getaddrinfo(3) with
178 * the parameters described in launchd.plist(5).
179 *
180 * The caller is responsible for calling free(3) on the returned pointer.
181 *
182 * @param cnt
183 * The number of file descriptor entries in the returned array.
184 *
185 * @result
186 * On success, zero is returned. Otherwise, an appropriate POSIX-domain is
187 * returned. Possible error codes are:
188 *
189 * ENOENT -> There was no socket of the specified name owned by the caller.
190 * ESRCH -> The caller is not a process managed by launchd.
191 * EALREADY -> The socket has already been activated by the caller.
192 */
193__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
194OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3
195int
196launch_activate_socket(const char *name,
197 int * _Nonnull * _Nullable fds, size_t *cnt);
198
199typedef struct _launch_data *launch_data_t;
200typedef void (*launch_data_dict_iterator_t)(const launch_data_t lval,
201 const char *key, void * _Nullable ctx);
202
203typedef enum {
204 LAUNCH_DATA_DICTIONARY = 1,
205 LAUNCH_DATA_ARRAY,
206 LAUNCH_DATA_FD,
207 LAUNCH_DATA_INTEGER,
208 LAUNCH_DATA_REAL,
209 LAUNCH_DATA_BOOL,
210 LAUNCH_DATA_STRING,
211 LAUNCH_DATA_OPAQUE,
212 LAUNCH_DATA_ERRNO,
213 LAUNCH_DATA_MACHPORT,
214} launch_data_type_t;
215
216__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
217OS_EXPORT OS_MALLOC OS_WARN_RESULT
218launch_data_t
219launch_data_alloc(launch_data_type_t type);
220
221__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
222OS_EXPORT OS_MALLOC OS_WARN_RESULT OS_NONNULL1
223launch_data_t
224launch_data_copy(launch_data_t ld);
225
226__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
227OS_EXPORT OS_WARN_RESULT OS_NONNULL1
228launch_data_type_t
229launch_data_get_type(const launch_data_t ld);
230
231__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
232OS_EXPORT OS_NONNULL1
233void
234launch_data_free(launch_data_t ld);
235
236__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
237OS_EXPORT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3
238bool
239launch_data_dict_insert(launch_data_t ldict, const launch_data_t lval,
240 const char *key);
241
242__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
243OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2
244launch_data_t _Nullable
245launch_data_dict_lookup(const launch_data_t ldict, const char *key);
246
247__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
248OS_EXPORT OS_NONNULL1 OS_NONNULL2
249bool
250launch_data_dict_remove(launch_data_t ldict, const char *key);
251
252__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
253OS_EXPORT OS_NONNULL1 OS_NONNULL2
254void
255launch_data_dict_iterate(const launch_data_t ldict,
256 launch_data_dict_iterator_t iterator, void * _Nullable ctx);
257
258__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
259OS_EXPORT OS_WARN_RESULT OS_NONNULL1
260size_t
261launch_data_dict_get_count(const launch_data_t ldict);
262
263__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
264OS_EXPORT OS_NONNULL1 OS_NONNULL2
265bool
266launch_data_array_set_index(launch_data_t larray, const launch_data_t lval,
267 size_t idx);
268
269__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
270OS_EXPORT OS_WARN_RESULT OS_NONNULL1
271launch_data_t
272launch_data_array_get_index(const launch_data_t larray, size_t idx);
273
274__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
275OS_EXPORT OS_WARN_RESULT OS_NONNULL1
276size_t
277launch_data_array_get_count(const launch_data_t larray);
278
279__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
280OS_EXPORT OS_MALLOC OS_WARN_RESULT
281launch_data_t
282launch_data_new_fd(int fd);
283
284__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
285OS_EXPORT OS_MALLOC OS_WARN_RESULT
286launch_data_t
287launch_data_new_machport(mach_port_t val);
288
289__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
290OS_EXPORT OS_MALLOC OS_WARN_RESULT
291launch_data_t
292launch_data_new_integer(long long val);
293
294__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
295OS_EXPORT OS_MALLOC OS_WARN_RESULT
296launch_data_t
297launch_data_new_bool(bool val);
298
299__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
300OS_EXPORT OS_MALLOC OS_WARN_RESULT
301launch_data_t
302launch_data_new_real(double val);
303
304__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
305OS_EXPORT OS_MALLOC OS_WARN_RESULT
306launch_data_t
307launch_data_new_string(const char *val);
308
309__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
310OS_EXPORT OS_MALLOC OS_WARN_RESULT
311launch_data_t
312launch_data_new_opaque(const void *bytes, size_t sz);
313
314__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
315OS_EXPORT OS_NONNULL1
316bool
317launch_data_set_fd(launch_data_t ld, int fd);
318
319__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
320OS_EXPORT OS_NONNULL1
321bool
322launch_data_set_machport(launch_data_t ld, mach_port_t mp);
323
324__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
325OS_EXPORT OS_NONNULL1
326bool
327launch_data_set_integer(launch_data_t ld, long long val);
328
329__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
330OS_EXPORT OS_NONNULL1
331bool
332launch_data_set_bool(launch_data_t ld, bool val);
333
334__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
335OS_EXPORT OS_NONNULL1
336bool
337launch_data_set_real(launch_data_t ld, double val);
338
339__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
340OS_EXPORT OS_NONNULL1
341bool
342launch_data_set_string(launch_data_t ld, const char *val);
343
344__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
345OS_EXPORT OS_NONNULL1
346bool
347launch_data_set_opaque(launch_data_t ld, const void *bytes, size_t sz);
348
349__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
350OS_EXPORT OS_WARN_RESULT OS_NONNULL1
351int
352launch_data_get_fd(const launch_data_t ld);
353
354__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
355OS_EXPORT OS_WARN_RESULT OS_NONNULL1
356mach_port_t
357launch_data_get_machport(const launch_data_t ld);
358
359__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
360OS_EXPORT OS_WARN_RESULT OS_NONNULL1
361long long
362launch_data_get_integer(const launch_data_t ld);
363
364__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
365OS_EXPORT OS_WARN_RESULT OS_NONNULL1
366bool
367launch_data_get_bool(const launch_data_t ld);
368
369__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
370OS_EXPORT OS_WARN_RESULT OS_NONNULL1
371double
372launch_data_get_real(const launch_data_t ld);
373
374__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
375OS_EXPORT OS_WARN_RESULT OS_NONNULL1
376const char *
377launch_data_get_string(const launch_data_t ld);
378
379__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
380OS_EXPORT OS_WARN_RESULT OS_NONNULL1
381void *
382launch_data_get_opaque(const launch_data_t ld);
383
384__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
385OS_EXPORT OS_WARN_RESULT OS_NONNULL1
386size_t
387launch_data_get_opaque_size(const launch_data_t ld);
388
389__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
390OS_EXPORT OS_WARN_RESULT OS_NONNULL1
391int
392launch_data_get_errno(const launch_data_t ld);
393
394__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
395OS_EXPORT OS_WARN_RESULT
396int
397launch_get_fd(void);
398
399__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
400OS_EXPORT OS_MALLOC OS_WARN_RESULT OS_NONNULL1
401launch_data_t
402launch_msg(const launch_data_t request);
403
404__END_DECLS
405#if __has_feature(assume_nonnull)
406_Pragma("clang assume_nonnull end")
407#endif
408
409#endif // __XPC_LAUNCH_H__
lib/libc/include/x86_64-macos-gnu/libDER/DERItem.h created+47
......@@ -0,0 +1,47 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef _DER_ITEM_H_
25#define _DER_ITEM_H_
26
27#if __has_include(<security_libDER/libDER/libDER_config.h>)
28 #include <security_libDER/libDER/libDER_config.h>
29#else
30 #include <libDER/libDER_config.h>
31#endif
32
33__BEGIN_DECLS
34
35/*
36 * Primary representation of a block of memory.
37 */
38typedef struct {
39 DERByte *data;
40 DERSize length;
41} DERItem;
42
43__END_DECLS
44
45#endif /* _DER_ITEM_H_ */
46
47
lib/libc/include/x86_64-macos-gnu/libDER/libDER_config.h created+121
......@@ -0,0 +1,121 @@
1/*
2 * Copyright (c) 2005-2007,2011-2012,2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25/*
26 * libDER_config.h - platform dependent #defines and typedefs for libDER
27 *
28 */
29
30#ifndef _LIB_DER_CONFIG_H_
31#define _LIB_DER_CONFIG_H_
32
33#include <stddef.h>
34#include <stdint.h>
35#include <string.h>
36
37#if defined(WIN32) && defined(__cplusplus)
38
39#if !defined(__BEGIN_DECLS) || !defined(__END_DECLS)
40#define __BEGIN_DECLS extern "C" {
41#define __END_DECLS }
42#endif // __BEGIN_DECLS || __END_DECLS
43
44#else
45#include <sys/cdefs.h>
46#endif // defined(WIN32) && defined(__cplusplus)
47
48__BEGIN_DECLS
49
50/*
51 * Basic data types: unsigned 8-bit integer, unsigned 32-bit integer
52 */
53typedef uint8_t DERByte;
54typedef uint16_t DERShort;
55typedef size_t DERSize;
56
57
58/*
59 * Use these #defines of you have memset, memmove, and memcmp; else
60 * write your own equivalents.
61 */
62
63#define DERMemset(ptr, c, len) memset(ptr, c, len)
64#define DERMemmove(dst, src, len) memmove(dst, src, len)
65#define DERMemcmp(b1, b2, len) memcmp(b1, b2, len)
66
67
68/***
69 *** Compile time options to trim size of the library.
70 ***/
71
72/* enable general DER encode */
73#define DER_ENCODE_ENABLE 1
74
75/* enable general DER decode */
76#define DER_DECODE_ENABLE 1
77
78#ifndef DER_MULTIBYTE_TAGS
79/* enable multibyte tag support. */
80#define DER_MULTIBYTE_TAGS 1
81#endif
82
83#ifndef DER_TAG_SIZE
84/* Iff DER_MULTIBYTE_TAGS is 1 this is the sizeof(DERTag) in bytes. Note that
85 tags are still encoded and decoded from a minimally encoded DER
86 represantation. This value maintains compatibility with libImg4Decode/Encode. */
87#define DER_TAG_SIZE 8
88#endif
89
90
91/* ---------------------- Do not edit below this line ---------------------- */
92
93/*
94 * Logical representation of a tag (the encoded representation is always in
95 * the minimal number of bytes). The top 3 bits encode class and method
96 * The remaining bits encode the tag value. To obtain smaller DERItemSpecs
97 * sizes, choose the smallest type that fits your needs. Most standard ASN.1
98 * usage only needs single byte tags, but ocasionally custom applications
99 * require a larger tag namespace.
100 */
101#if DER_MULTIBYTE_TAGS
102
103#if DER_TAG_SIZE == 1
104typedef uint8_t DERTag;
105#elif DER_TAG_SIZE == 2
106typedef uint16_t DERTag;
107#elif DER_TAG_SIZE == 4
108typedef uint32_t DERTag;
109#elif DER_TAG_SIZE == 8
110typedef uint64_t DERTag;
111#else
112#error DER_TAG_SIZE invalid
113#endif
114
115#else /* DER_MULTIBYTE_TAGS */
116typedef DERByte DERTag;
117#endif /* !DER_MULTIBYTE_TAGS */
118
119__END_DECLS
120
121#endif /* _LIB_DER_CONFIG_H_ */
lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h created+47
......@@ -0,0 +1,47 @@
1/*
2 * Copyright (c) 2004-2016 Apple Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef _OSATOMIC_H_
25#define _OSATOMIC_H_
26
27/*! @header
28 * These are deprecated legacy interfaces for atomic and synchronization
29 * operations.
30 *
31 * Define OSATOMIC_USE_INLINED=1 to get inline implementations of the
32 * OSAtomic interfaces in terms of the <stdatomic.h> primitives.
33 *
34 * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of the
35 * OSSpinLock interfaces in terms of the <os/lock.h> primitives.
36 *
37 * These are intended as a transition convenience, direct use of those
38 * primitives should be preferred.
39 */
40
41#include <sys/cdefs.h>
42
43#include "OSAtomicDeprecated.h"
44#include "OSSpinLockDeprecated.h"
45#include "OSAtomicQueue.h"
46
47#endif /* _OSATOMIC_H_ */
lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicDeprecated.h created+1266
......@@ -0,0 +1,1266 @@
1/*
2 * Copyright (c) 2004-2016 Apple Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef _OSATOMIC_DEPRECATED_H_
25#define _OSATOMIC_DEPRECATED_H_
26
27/*! @header
28 * These are deprecated legacy interfaces for atomic operations.
29 * The C11 interfaces in <stdatomic.h> resp. C++11 interfaces in <atomic>
30 * should be used instead.
31 *
32 * Define OSATOMIC_USE_INLINED=1 to get inline implementations of these
33 * interfaces in terms of the <stdatomic.h> resp. <atomic> primitives.
34 * This is intended as a transition convenience, direct use of those primitives
35 * is preferred.
36 */
37
38#include <Availability.h>
39
40#if !(defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED)
41
42#include <sys/cdefs.h>
43#include <stddef.h>
44#include <stdint.h>
45#include <stdbool.h>
46
47#ifndef OSATOMIC_DEPRECATED
48#define OSATOMIC_DEPRECATED 1
49#ifndef __cplusplus
50#define OSATOMIC_BARRIER_DEPRECATED_MSG(_r) \
51 "Use " #_r "() from <stdatomic.h> instead"
52#define OSATOMIC_DEPRECATED_MSG(_r) \
53 "Use " #_r "_explicit(memory_order_relaxed) from <stdatomic.h> instead"
54#else
55#define OSATOMIC_BARRIER_DEPRECATED_MSG(_r) \
56 "Use std::" #_r "() from <atomic> instead"
57#define OSATOMIC_DEPRECATED_MSG(_r) \
58 "Use std::" #_r "_explicit(std::memory_order_relaxed) from <atomic> instead"
59#endif
60#define OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(_r) \
61 __OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
62 __OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
63 __OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
64 __OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r))
65#define OSATOMIC_DEPRECATED_REPLACE_WITH(_r) \
66 __OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSATOMIC_DEPRECATED_MSG(_r)) \
67 __OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSATOMIC_DEPRECATED_MSG(_r)) \
68 __OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSATOMIC_DEPRECATED_MSG(_r)) \
69 __OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSATOMIC_DEPRECATED_MSG(_r))
70#else
71#undef OSATOMIC_DEPRECATED
72#define OSATOMIC_DEPRECATED 0
73#define OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(_r)
74#define OSATOMIC_DEPRECATED_REPLACE_WITH(_r)
75#endif
76
77/*
78 * WARNING: all addresses passed to these functions must be "naturally aligned",
79 * i.e. <code>int32_t</code> pointers must be 32-bit aligned (low 2 bits of
80 * address are zeroes), and <code>int64_t</code> pointers must be 64-bit
81 * aligned (low 3 bits of address are zeroes.).
82 * Note that this is not the default alignment of the <code>int64_t</code> type
83 * in the iOS ARMv7 ABI, see
84 * {@link //apple_ref/doc/uid/TP40009021-SW8 iPhoneOSABIReference}
85 *
86 * Note that some versions of the atomic functions incorporate memory barriers
87 * and some do not. Barriers strictly order memory access on weakly-ordered
88 * architectures such as ARM. All loads and stores that appear (in sequential
89 * program order) before the barrier are guaranteed to complete before any
90 * load or store that appears after the barrier.
91 *
92 * The barrier operation is typically a no-op on uniprocessor systems and
93 * fully enabled on multiprocessor systems. On some platforms, such as ARM,
94 * the barrier can be quite expensive.
95 *
96 * Most code should use the barrier functions to ensure that memory shared
97 * between threads is properly synchronized. For example, if you want to
98 * initialize a shared data structure and then atomically increment a variable
99 * to indicate that the initialization is complete, you must use
100 * {@link OSAtomicIncrement32Barrier} to ensure that the stores to your data
101 * structure complete before the atomic increment.
102 *
103 * Likewise, the consumer of that data structure must use
104 * {@link OSAtomicDecrement32Barrier},
105 * in order to ensure that their loads of the structure are not executed before
106 * the atomic decrement. On the other hand, if you are simply incrementing a
107 * global counter, then it is safe and potentially faster to use
108 * {@link OSAtomicIncrement32}.
109 *
110 * If you are unsure which version to use, prefer the barrier variants as they
111 * are safer.
112 *
113 * For the kernel-space version of this header, see
114 * {@link //apple_ref/doc/header/OSAtomic.h OSAtomic.h (Kernel Framework)}
115 *
116 * @apiuid //apple_ref/doc/header/user_space_OSAtomic.h
117 */
118
119__BEGIN_DECLS
120
121/*! @typedef OSAtomic_int64_aligned64_t
122 * 64-bit aligned <code>int64_t</code> type.
123 * Use for variables whose addresses are passed to OSAtomic*64() functions to
124 * get the compiler to generate the required alignment.
125 */
126
127#if __has_attribute(aligned)
128typedef int64_t __attribute__((__aligned__((sizeof(int64_t)))))
129 OSAtomic_int64_aligned64_t;
130#else
131typedef int64_t OSAtomic_int64_aligned64_t;
132#endif
133
134/*! @group Arithmetic functions
135 All functions in this group return the new value.
136 */
137
138/*! @abstract Atomically adds two 32-bit values.
139 @discussion
140 This function adds the value given by <code>__theAmount</code> to the
141 value in the memory location referenced by <code>__theValue</code>,
142 storing the result back to that memory location atomically.
143 @result Returns the new value.
144 */
145OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
146__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
147int32_t OSAtomicAdd32( int32_t __theAmount, volatile int32_t *__theValue );
148
149
150/*! @abstract Atomically adds two 32-bit values.
151 @discussion
152 This function adds the value given by <code>__theAmount</code> to the
153 value in the memory location referenced by <code>__theValue</code>,
154 storing the result back to that memory location atomically.
155
156 This function is equivalent to {@link OSAtomicAdd32}
157 except that it also introduces a barrier.
158 @result Returns the new value.
159 */
160OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
161__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
162int32_t OSAtomicAdd32Barrier( int32_t __theAmount, volatile int32_t *__theValue );
163
164
165#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1 || TARGET_OS_DRIVERKIT
166
167/*! @abstract Atomically increments a 32-bit value.
168 @result Returns the new value.
169 */
170OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
171__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
172int32_t OSAtomicIncrement32( volatile int32_t *__theValue );
173
174
175/*! @abstract Atomically increments a 32-bit value with a barrier.
176 @discussion
177 This function is equivalent to {@link OSAtomicIncrement32}
178 except that it also introduces a barrier.
179 @result Returns the new value.
180 */
181OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
182__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
183int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue );
184
185
186/*! @abstract Atomically decrements a 32-bit value.
187 @result Returns the new value.
188 */
189OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
190__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
191int32_t OSAtomicDecrement32( volatile int32_t *__theValue );
192
193
194/*! @abstract Atomically decrements a 32-bit value with a barrier.
195 @discussion
196 This function is equivalent to {@link OSAtomicDecrement32}
197 except that it also introduces a barrier.
198 @result Returns the new value.
199 */
200OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
201__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
202int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue );
203
204#else
205__inline static
206int32_t OSAtomicIncrement32( volatile int32_t *__theValue )
207 { return OSAtomicAdd32( 1, __theValue); }
208
209__inline static
210int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue )
211 { return OSAtomicAdd32Barrier( 1, __theValue); }
212
213__inline static
214int32_t OSAtomicDecrement32( volatile int32_t *__theValue )
215 { return OSAtomicAdd32( -1, __theValue); }
216
217__inline static
218int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue )
219 { return OSAtomicAdd32Barrier( -1, __theValue); }
220#endif
221
222
223/*! @abstract Atomically adds two 64-bit values.
224 @discussion
225 This function adds the value given by <code>__theAmount</code> to the
226 value in the memory location referenced by <code>__theValue</code>,
227 storing the result back to that memory location atomically.
228 @result Returns the new value.
229 */
230OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
231__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
232int64_t OSAtomicAdd64( int64_t __theAmount,
233 volatile OSAtomic_int64_aligned64_t *__theValue );
234
235
236/*! @abstract Atomically adds two 64-bit values with a barrier.
237 @discussion
238 This function adds the value given by <code>__theAmount</code> to the
239 value in the memory location referenced by <code>__theValue</code>,
240 storing the result back to that memory location atomically.
241
242 This function is equivalent to {@link OSAtomicAdd64}
243 except that it also introduces a barrier.
244 @result Returns the new value.
245 */
246OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
247__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_3_2)
248int64_t OSAtomicAdd64Barrier( int64_t __theAmount,
249 volatile OSAtomic_int64_aligned64_t *__theValue );
250
251
252#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1 || TARGET_OS_DRIVERKIT
253
254/*! @abstract Atomically increments a 64-bit value.
255 @result Returns the new value.
256 */
257OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
258__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
259int64_t OSAtomicIncrement64( volatile OSAtomic_int64_aligned64_t *__theValue );
260
261
262/*! @abstract Atomically increments a 64-bit value with a barrier.
263 @discussion
264 This function is equivalent to {@link OSAtomicIncrement64}
265 except that it also introduces a barrier.
266 @result Returns the new value.
267 */
268OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
269__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
270int64_t OSAtomicIncrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue );
271
272
273/*! @abstract Atomically decrements a 64-bit value.
274 @result Returns the new value.
275 */
276OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
277__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
278int64_t OSAtomicDecrement64( volatile OSAtomic_int64_aligned64_t *__theValue );
279
280
281/*! @abstract Atomically decrements a 64-bit value with a barrier.
282 @discussion
283 This function is equivalent to {@link OSAtomicDecrement64}
284 except that it also introduces a barrier.
285 @result Returns the new value.
286 */
287OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
288__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
289int64_t OSAtomicDecrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue );
290
291#else
292__inline static
293int64_t OSAtomicIncrement64( volatile OSAtomic_int64_aligned64_t *__theValue )
294 { return OSAtomicAdd64( 1, __theValue); }
295
296__inline static
297int64_t OSAtomicIncrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue )
298 { return OSAtomicAdd64Barrier( 1, __theValue); }
299
300__inline static
301int64_t OSAtomicDecrement64( volatile OSAtomic_int64_aligned64_t *__theValue )
302 { return OSAtomicAdd64( -1, __theValue); }
303
304__inline static
305int64_t OSAtomicDecrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue )
306 { return OSAtomicAdd64Barrier( -1, __theValue); }
307#endif
308
309
310/*! @group Boolean functions (AND, OR, XOR)
311 *
312 * @discussion Functions in this group come in four variants for each operation:
313 * with and without barriers, and functions that return the original value or
314 * the result value of the operation.
315 *
316 * The "Orig" versions return the original value, (before the operation); the non-Orig
317 * versions return the value after the operation. All are layered on top of
318 * {@link OSAtomicCompareAndSwap32} and similar.
319 */
320
321/*! @abstract Atomic bitwise OR of two 32-bit values.
322 @discussion
323 This function performs the bitwise OR of the value given by <code>__theMask</code>
324 with the value in the memory location referenced by <code>__theValue</code>,
325 storing the result back to that memory location atomically.
326 @result Returns the new value.
327 */
328OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
329__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
330int32_t OSAtomicOr32( uint32_t __theMask, volatile uint32_t *__theValue );
331
332
333/*! @abstract Atomic bitwise OR of two 32-bit values with barrier.
334 @discussion
335 This function performs the bitwise OR of the value given by <code>__theMask</code>
336 with the value in the memory location referenced by <code>__theValue</code>,
337 storing the result back to that memory location atomically.
338
339 This function is equivalent to {@link OSAtomicOr32}
340 except that it also introduces a barrier.
341 @result Returns the new value.
342 */
343OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
344__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
345int32_t OSAtomicOr32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
346
347
348/*! @abstract Atomic bitwise OR of two 32-bit values returning original.
349 @discussion
350 This function performs the bitwise OR of the value given by <code>__theMask</code>
351 with the value in the memory location referenced by <code>__theValue</code>,
352 storing the result back to that memory location atomically.
353 @result Returns the original value referenced by <code>__theValue</code>.
354 */
355OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
356__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
357int32_t OSAtomicOr32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
358
359
360/*! @abstract Atomic bitwise OR of two 32-bit values returning original with barrier.
361 @discussion
362 This function performs the bitwise OR of the value given by <code>__theMask</code>
363 with the value in the memory location referenced by <code>__theValue</code>,
364 storing the result back to that memory location atomically.
365
366 This function is equivalent to {@link OSAtomicOr32Orig}
367 except that it also introduces a barrier.
368 @result Returns the original value referenced by <code>__theValue</code>.
369 */
370OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
371__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
372int32_t OSAtomicOr32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
373
374
375
376
377/*! @abstract Atomic bitwise AND of two 32-bit values.
378 @discussion
379 This function performs the bitwise AND of the value given by <code>__theMask</code>
380 with the value in the memory location referenced by <code>__theValue</code>,
381 storing the result back to that memory location atomically.
382 @result Returns the new value.
383 */
384OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
385__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
386int32_t OSAtomicAnd32( uint32_t __theMask, volatile uint32_t *__theValue );
387
388
389/*! @abstract Atomic bitwise AND of two 32-bit values with barrier.
390 @discussion
391 This function performs the bitwise AND of the value given by <code>__theMask</code>
392 with the value in the memory location referenced by <code>__theValue</code>,
393 storing the result back to that memory location atomically.
394
395 This function is equivalent to {@link OSAtomicAnd32}
396 except that it also introduces a barrier.
397 @result Returns the new value.
398 */
399OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
400__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
401int32_t OSAtomicAnd32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
402
403
404/*! @abstract Atomic bitwise AND of two 32-bit values returning original.
405 @discussion
406 This function performs the bitwise AND of the value given by <code>__theMask</code>
407 with the value in the memory location referenced by <code>__theValue</code>,
408 storing the result back to that memory location atomically.
409 @result Returns the original value referenced by <code>__theValue</code>.
410 */
411OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
412__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
413int32_t OSAtomicAnd32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
414
415
416/*! @abstract Atomic bitwise AND of two 32-bit values returning original with barrier.
417 @discussion
418 This function performs the bitwise AND of the value given by <code>__theMask</code>
419 with the value in the memory location referenced by <code>__theValue</code>,
420 storing the result back to that memory location atomically.
421
422 This function is equivalent to {@link OSAtomicAnd32Orig}
423 except that it also introduces a barrier.
424 @result Returns the original value referenced by <code>__theValue</code>.
425 */
426OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
427__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
428int32_t OSAtomicAnd32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
429
430
431
432
433/*! @abstract Atomic bitwise XOR of two 32-bit values.
434 @discussion
435 This function performs the bitwise XOR of the value given by <code>__theMask</code>
436 with the value in the memory location referenced by <code>__theValue</code>,
437 storing the result back to that memory location atomically.
438 @result Returns the new value.
439 */
440OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
441__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
442int32_t OSAtomicXor32( uint32_t __theMask, volatile uint32_t *__theValue );
443
444
445/*! @abstract Atomic bitwise XOR of two 32-bit values with barrier.
446 @discussion
447 This function performs the bitwise XOR of the value given by <code>__theMask</code>
448 with the value in the memory location referenced by <code>__theValue</code>,
449 storing the result back to that memory location atomically.
450
451 This function is equivalent to {@link OSAtomicXor32}
452 except that it also introduces a barrier.
453 @result Returns the new value.
454 */
455OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
456__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
457int32_t OSAtomicXor32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
458
459
460/*! @abstract Atomic bitwise XOR of two 32-bit values returning original.
461 @discussion
462 This function performs the bitwise XOR of the value given by <code>__theMask</code>
463 with the value in the memory location referenced by <code>__theValue</code>,
464 storing the result back to that memory location atomically.
465 @result Returns the original value referenced by <code>__theValue</code>.
466 */
467OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
468__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
469int32_t OSAtomicXor32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
470
471
472/*! @abstract Atomic bitwise XOR of two 32-bit values returning original with barrier.
473 @discussion
474 This function performs the bitwise XOR of the value given by <code>__theMask</code>
475 with the value in the memory location referenced by <code>__theValue</code>,
476 storing the result back to that memory location atomically.
477
478 This function is equivalent to {@link OSAtomicXor32Orig}
479 except that it also introduces a barrier.
480 @result Returns the original value referenced by <code>__theValue</code>.
481 */
482OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
483__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
484int32_t OSAtomicXor32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
485
486
487/*! @group Compare and swap
488 * Functions in this group return true if the swap occured. There are several versions,
489 * depending on data type and on whether or not a barrier is used.
490 */
491
492
493/*! @abstract Compare and swap for 32-bit values.
494 @discussion
495 This function compares the value in <code>__oldValue</code> to the value
496 in the memory location referenced by <code>__theValue</code>. If the values
497 match, this function stores the value from <code>__newValue</code> into
498 that memory location atomically.
499 @result Returns TRUE on a match, FALSE otherwise.
500 */
501OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
502__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
503bool OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
504
505
506/*! @abstract Compare and swap for 32-bit values with barrier.
507 @discussion
508 This function compares the value in <code>__oldValue</code> to the value
509 in the memory location referenced by <code>__theValue</code>. If the values
510 match, this function stores the value from <code>__newValue</code> into
511 that memory location atomically.
512
513 This function is equivalent to {@link OSAtomicCompareAndSwap32}
514 except that it also introduces a barrier.
515 @result Returns TRUE on a match, FALSE otherwise.
516 */
517OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
518__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
519bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
520
521
522/*! @abstract Compare and swap pointers.
523 @discussion
524 This function compares the pointer stored in <code>__oldValue</code> to the pointer
525 in the memory location referenced by <code>__theValue</code>. If the pointers
526 match, this function stores the pointer from <code>__newValue</code> into
527 that memory location atomically.
528 @result Returns TRUE on a match, FALSE otherwise.
529 */
530OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
531__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
532bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue );
533
534
535/*! @abstract Compare and swap pointers with barrier.
536 @discussion
537 This function compares the pointer stored in <code>__oldValue</code> to the pointer
538 in the memory location referenced by <code>__theValue</code>. If the pointers
539 match, this function stores the pointer from <code>__newValue</code> into
540 that memory location atomically.
541
542 This function is equivalent to {@link OSAtomicCompareAndSwapPtr}
543 except that it also introduces a barrier.
544 @result Returns TRUE on a match, FALSE otherwise.
545 */
546OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
547__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
548bool OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue );
549
550
551/*! @abstract Compare and swap for <code>int</code> values.
552 @discussion
553 This function compares the value in <code>__oldValue</code> to the value
554 in the memory location referenced by <code>__theValue</code>. If the values
555 match, this function stores the value from <code>__newValue</code> into
556 that memory location atomically.
557
558 This function is equivalent to {@link OSAtomicCompareAndSwap32}.
559 @result Returns TRUE on a match, FALSE otherwise.
560 */
561OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
562__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
563bool OSAtomicCompareAndSwapInt( int __oldValue, int __newValue, volatile int *__theValue );
564
565
566/*! @abstract Compare and swap for <code>int</code> values.
567 @discussion
568 This function compares the value in <code>__oldValue</code> to the value
569 in the memory location referenced by <code>__theValue</code>. If the values
570 match, this function stores the value from <code>__newValue</code> into
571 that memory location atomically.
572
573 This function is equivalent to {@link OSAtomicCompareAndSwapInt}
574 except that it also introduces a barrier.
575
576 This function is equivalent to {@link OSAtomicCompareAndSwap32Barrier}.
577 @result Returns TRUE on a match, FALSE otherwise.
578 */
579OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
580__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
581bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue );
582
583
584/*! @abstract Compare and swap for <code>long</code> values.
585 @discussion
586 This function compares the value in <code>__oldValue</code> to the value
587 in the memory location referenced by <code>__theValue</code>. If the values
588 match, this function stores the value from <code>__newValue</code> into
589 that memory location atomically.
590
591 This function is equivalent to {@link OSAtomicCompareAndSwap32} on 32-bit architectures,
592 or {@link OSAtomicCompareAndSwap64} on 64-bit architectures.
593 @result Returns TRUE on a match, FALSE otherwise.
594 */
595OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
596__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
597bool OSAtomicCompareAndSwapLong( long __oldValue, long __newValue, volatile long *__theValue );
598
599
600/*! @abstract Compare and swap for <code>long</code> values.
601 @discussion
602 This function compares the value in <code>__oldValue</code> to the value
603 in the memory location referenced by <code>__theValue</code>. If the values
604 match, this function stores the value from <code>__newValue</code> into
605 that memory location atomically.
606
607 This function is equivalent to {@link OSAtomicCompareAndSwapLong}
608 except that it also introduces a barrier.
609
610 This function is equivalent to {@link OSAtomicCompareAndSwap32} on 32-bit architectures,
611 or {@link OSAtomicCompareAndSwap64} on 64-bit architectures.
612 @result Returns TRUE on a match, FALSE otherwise.
613 */
614OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
615__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
616bool OSAtomicCompareAndSwapLongBarrier( long __oldValue, long __newValue, volatile long *__theValue );
617
618
619/*! @abstract Compare and swap for <code>uint64_t</code> values.
620 @discussion
621 This function compares the value in <code>__oldValue</code> to the value
622 in the memory location referenced by <code>__theValue</code>. If the values
623 match, this function stores the value from <code>__newValue</code> into
624 that memory location atomically.
625 @result Returns TRUE on a match, FALSE otherwise.
626 */
627OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
628__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
629bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue,
630 volatile OSAtomic_int64_aligned64_t *__theValue );
631
632
633/*! @abstract Compare and swap for <code>uint64_t</code> values.
634 @discussion
635 This function compares the value in <code>__oldValue</code> to the value
636 in the memory location referenced by <code>__theValue</code>. If the values
637 match, this function stores the value from <code>__newValue</code> into
638 that memory location atomically.
639
640 This function is equivalent to {@link OSAtomicCompareAndSwap64}
641 except that it also introduces a barrier.
642 @result Returns TRUE on a match, FALSE otherwise.
643 */
644OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
645__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_3_2)
646bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue,
647 volatile OSAtomic_int64_aligned64_t *__theValue );
648
649
650/* Test and set.
651 * They return the original value of the bit, and operate on bit (0x80>>(n&7))
652 * in byte ((char*)theAddress + (n>>3)).
653 */
654/*! @abstract Atomic test and set
655 @discussion
656 This function tests a bit in the value referenced by
657 <code>__theAddress</code> and if it is not set, sets it.
658
659 The bit is chosen by the value of <code>__n</code> such that the
660 operation will be performed on bit <code>(0x80 >> (__n & 7))</code>
661 of byte <code>((char *)__theAddress + (n >> 3))</code>.
662
663 For example, if <code>__theAddress</code> points to a 64-bit value,
664 to compare the value of the most significant bit, you would specify
665 <code>56</code> for <code>__n</code>.
666 @result
667 Returns the original value of the bit being tested.
668 */
669OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
670__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
671bool OSAtomicTestAndSet( uint32_t __n, volatile void *__theAddress );
672
673
674/*! @abstract Atomic test and set with barrier
675 @discussion
676 This function tests a bit in the value referenced by <code>__theAddress</code>
677 and if it is not set, sets it.
678
679 The bit is chosen by the value of <code>__n</code> such that the
680 operation will be performed on bit <code>(0x80 >> (__n & 7))</code>
681 of byte <code>((char *)__theAddress + (n >> 3))</code>.
682
683 For example, if <code>__theAddress</code> points to a 64-bit value,
684 to compare the value of the most significant bit, you would specify
685 <code>56</code> for <code>__n</code>.
686
687 This function is equivalent to {@link OSAtomicTestAndSet}
688 except that it also introduces a barrier.
689 @result
690 Returns the original value of the bit being tested.
691 */
692OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
693__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
694bool OSAtomicTestAndSetBarrier( uint32_t __n, volatile void *__theAddress );
695
696
697
698/*! @abstract Atomic test and clear
699 @discussion
700 This function tests a bit in the value referenced by <code>__theAddress</code>
701 and if it is not cleared, clears it.
702
703 The bit is chosen by the value of <code>__n</code> such that the
704 operation will be performed on bit <code>(0x80 >> (__n & 7))</code>
705 of byte <code>((char *)__theAddress + (n >> 3))</code>.
706
707 For example, if <code>__theAddress</code> points to a 64-bit value,
708 to compare the value of the most significant bit, you would specify
709 <code>56</code> for <code>__n</code>.
710
711 @result
712 Returns the original value of the bit being tested.
713 */
714OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
715__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
716bool OSAtomicTestAndClear( uint32_t __n, volatile void *__theAddress );
717
718
719/*! @abstract Atomic test and clear
720 @discussion
721 This function tests a bit in the value referenced by <code>__theAddress</code>
722 and if it is not cleared, clears it.
723
724 The bit is chosen by the value of <code>__n</code> such that the
725 operation will be performed on bit <code>(0x80 >> (__n & 7))</code>
726 of byte <code>((char *)__theAddress + (n >> 3))</code>.
727
728 For example, if <code>__theAddress</code> points to a 64-bit value,
729 to compare the value of the most significant bit, you would specify
730 <code>56</code> for <code>__n</code>.
731
732 This function is equivalent to {@link OSAtomicTestAndSet}
733 except that it also introduces a barrier.
734 @result
735 Returns the original value of the bit being tested.
736 */
737OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
738__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
739bool OSAtomicTestAndClearBarrier( uint32_t __n, volatile void *__theAddress );
740
741
742/*! @group Memory barriers */
743
744/*! @abstract Memory barrier.
745 @discussion
746 This function serves as both a read and write barrier.
747 */
748OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_thread_fence)
749__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
750void OSMemoryBarrier( void );
751
752__END_DECLS
753
754#else // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED
755
756/*
757 * Inline implementations of the legacy OSAtomic interfaces in terms of
758 * C11 <stdatomic.h> resp. C++11 <atomic> primitives.
759 * Direct use of those primitives is preferred.
760 */
761
762#include <sys/cdefs.h>
763
764#include <stddef.h>
765#include <stdint.h>
766#include <stdbool.h>
767
768#ifdef __cplusplus
769extern "C++" {
770#if !(__has_include(<atomic>) && __has_extension(cxx_atomic))
771#error Cannot use inlined OSAtomic without <atomic> and C++11 atomics
772#endif
773#include <atomic>
774typedef std::atomic<uint8_t> _OSAtomic_uint8_t;
775typedef std::atomic<int32_t> _OSAtomic_int32_t;
776typedef std::atomic<uint32_t> _OSAtomic_uint32_t;
777typedef std::atomic<int64_t> _OSAtomic_int64_t;
778typedef std::atomic<void*> _OSAtomic_void_ptr_t;
779#define OSATOMIC_STD(_a) std::_a
780__BEGIN_DECLS
781#else
782#if !(__has_include(<stdatomic.h>) && __has_extension(c_atomic))
783#error Cannot use inlined OSAtomic without <stdatomic.h> and C11 atomics
784#endif
785#include <stdatomic.h>
786typedef _Atomic(uint8_t) _OSAtomic_uint8_t;
787typedef _Atomic(int32_t) _OSAtomic_int32_t;
788typedef _Atomic(uint32_t) _OSAtomic_uint32_t;
789typedef _Atomic(int64_t) _OSAtomic_int64_t;
790typedef _Atomic(void*) _OSAtomic_void_ptr_t;
791#define OSATOMIC_STD(_a) _a
792#endif
793
794#if __has_extension(c_alignof) && __has_attribute(aligned)
795typedef int64_t __attribute__((__aligned__(_Alignof(_OSAtomic_int64_t))))
796 OSAtomic_int64_aligned64_t;
797#elif __has_attribute(aligned)
798typedef int64_t __attribute__((__aligned__((sizeof(_OSAtomic_int64_t)))))
799 OSAtomic_int64_aligned64_t;
800#else
801typedef int64_t OSAtomic_int64_aligned64_t;
802#endif
803
804#if __has_attribute(always_inline)
805#define OSATOMIC_INLINE static __inline __attribute__((__always_inline__))
806#else
807#define OSATOMIC_INLINE static __inline
808#endif
809
810OSATOMIC_INLINE
811int32_t
812OSAtomicAdd32(int32_t __theAmount, volatile int32_t *__theValue)
813{
814 return (OSATOMIC_STD(atomic_fetch_add_explicit)(
815 (volatile _OSAtomic_int32_t*) __theValue, __theAmount,
816 OSATOMIC_STD(memory_order_relaxed)) + __theAmount);
817}
818
819OSATOMIC_INLINE
820int32_t
821OSAtomicAdd32Barrier(int32_t __theAmount, volatile int32_t *__theValue)
822{
823 return (OSATOMIC_STD(atomic_fetch_add_explicit)(
824 (volatile _OSAtomic_int32_t*) __theValue, __theAmount,
825 OSATOMIC_STD(memory_order_seq_cst)) + __theAmount);
826}
827
828OSATOMIC_INLINE
829int32_t
830OSAtomicIncrement32(volatile int32_t *__theValue)
831{
832 return OSAtomicAdd32(1, __theValue);
833}
834
835OSATOMIC_INLINE
836int32_t
837OSAtomicIncrement32Barrier(volatile int32_t *__theValue)
838{
839 return OSAtomicAdd32Barrier(1, __theValue);
840}
841
842OSATOMIC_INLINE
843int32_t
844OSAtomicDecrement32(volatile int32_t *__theValue)
845{
846 return OSAtomicAdd32(-1, __theValue);
847}
848
849OSATOMIC_INLINE
850int32_t
851OSAtomicDecrement32Barrier(volatile int32_t *__theValue)
852{
853 return OSAtomicAdd32Barrier(-1, __theValue);
854}
855
856OSATOMIC_INLINE
857int64_t
858OSAtomicAdd64(int64_t __theAmount,
859 volatile OSAtomic_int64_aligned64_t *__theValue)
860{
861 return (OSATOMIC_STD(atomic_fetch_add_explicit)(
862 (volatile _OSAtomic_int64_t*) __theValue, __theAmount,
863 OSATOMIC_STD(memory_order_relaxed)) + __theAmount);
864}
865
866OSATOMIC_INLINE
867int64_t
868OSAtomicAdd64Barrier(int64_t __theAmount,
869 volatile OSAtomic_int64_aligned64_t *__theValue)
870{
871 return (OSATOMIC_STD(atomic_fetch_add_explicit)(
872 (volatile _OSAtomic_int64_t*) __theValue, __theAmount,
873 OSATOMIC_STD(memory_order_seq_cst)) + __theAmount);
874}
875
876OSATOMIC_INLINE
877int64_t
878OSAtomicIncrement64(volatile OSAtomic_int64_aligned64_t *__theValue)
879{
880 return OSAtomicAdd64(1, __theValue);
881}
882
883OSATOMIC_INLINE
884int64_t
885OSAtomicIncrement64Barrier(volatile OSAtomic_int64_aligned64_t *__theValue)
886{
887 return OSAtomicAdd64Barrier(1, __theValue);
888}
889
890OSATOMIC_INLINE
891int64_t
892OSAtomicDecrement64(volatile OSAtomic_int64_aligned64_t *__theValue)
893{
894 return OSAtomicAdd64(-1, __theValue);
895}
896
897OSATOMIC_INLINE
898int64_t
899OSAtomicDecrement64Barrier(volatile OSAtomic_int64_aligned64_t *__theValue)
900{
901 return OSAtomicAdd64Barrier(-1, __theValue);
902}
903
904OSATOMIC_INLINE
905int32_t
906OSAtomicOr32(uint32_t __theMask, volatile uint32_t *__theValue)
907{
908 return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
909 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
910 OSATOMIC_STD(memory_order_relaxed)) | __theMask);
911}
912
913OSATOMIC_INLINE
914int32_t
915OSAtomicOr32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
916{
917 return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
918 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
919 OSATOMIC_STD(memory_order_seq_cst)) | __theMask);
920}
921
922OSATOMIC_INLINE
923int32_t
924OSAtomicOr32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
925{
926 return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
927 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
928 OSATOMIC_STD(memory_order_relaxed)));
929}
930
931OSATOMIC_INLINE
932int32_t
933OSAtomicOr32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
934{
935 return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
936 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
937 OSATOMIC_STD(memory_order_seq_cst)));
938}
939
940OSATOMIC_INLINE
941int32_t
942OSAtomicAnd32(uint32_t __theMask, volatile uint32_t *__theValue)
943{
944 return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
945 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
946 OSATOMIC_STD(memory_order_relaxed)) & __theMask);
947}
948
949OSATOMIC_INLINE
950int32_t
951OSAtomicAnd32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
952{
953 return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
954 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
955 OSATOMIC_STD(memory_order_seq_cst)) & __theMask);
956}
957
958OSATOMIC_INLINE
959int32_t
960OSAtomicAnd32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
961{
962 return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
963 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
964 OSATOMIC_STD(memory_order_relaxed)));
965}
966
967OSATOMIC_INLINE
968int32_t
969OSAtomicAnd32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
970{
971 return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
972 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
973 OSATOMIC_STD(memory_order_seq_cst)));
974}
975
976OSATOMIC_INLINE
977int32_t
978OSAtomicXor32(uint32_t __theMask, volatile uint32_t *__theValue)
979{
980 return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
981 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
982 OSATOMIC_STD(memory_order_relaxed)) ^ __theMask);
983}
984
985OSATOMIC_INLINE
986int32_t
987OSAtomicXor32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
988{
989 return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
990 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
991 OSATOMIC_STD(memory_order_seq_cst)) ^ __theMask);
992}
993
994OSATOMIC_INLINE
995int32_t
996OSAtomicXor32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
997{
998 return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
999 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
1000 OSATOMIC_STD(memory_order_relaxed)));
1001}
1002
1003OSATOMIC_INLINE
1004int32_t
1005OSAtomicXor32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
1006{
1007 return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
1008 (volatile _OSAtomic_uint32_t*)__theValue, __theMask,
1009 OSATOMIC_STD(memory_order_seq_cst)));
1010}
1011
1012OSATOMIC_INLINE
1013bool
1014OSAtomicCompareAndSwap32(int32_t __oldValue, int32_t __newValue,
1015 volatile int32_t *__theValue)
1016{
1017 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1018 (volatile _OSAtomic_int32_t*)__theValue, &__oldValue, __newValue,
1019 OSATOMIC_STD(memory_order_relaxed),
1020 OSATOMIC_STD(memory_order_relaxed)));
1021}
1022
1023OSATOMIC_INLINE
1024bool
1025OSAtomicCompareAndSwap32Barrier(int32_t __oldValue, int32_t __newValue,
1026 volatile int32_t *__theValue)
1027{
1028 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1029 (volatile _OSAtomic_int32_t*)__theValue, &__oldValue, __newValue,
1030 OSATOMIC_STD(memory_order_seq_cst),
1031 OSATOMIC_STD(memory_order_relaxed)));
1032}
1033
1034OSATOMIC_INLINE
1035bool
1036OSAtomicCompareAndSwapPtr(void *__oldValue, void *__newValue,
1037 void * volatile *__theValue)
1038{
1039 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1040 (volatile _OSAtomic_void_ptr_t*)__theValue, &__oldValue, __newValue,
1041 OSATOMIC_STD(memory_order_relaxed),
1042 OSATOMIC_STD(memory_order_relaxed)));
1043}
1044
1045OSATOMIC_INLINE
1046bool
1047OSAtomicCompareAndSwapPtrBarrier(void *__oldValue, void *__newValue,
1048 void * volatile *__theValue)
1049{
1050 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1051 (volatile _OSAtomic_void_ptr_t*)__theValue, &__oldValue, __newValue,
1052 OSATOMIC_STD(memory_order_seq_cst),
1053 OSATOMIC_STD(memory_order_relaxed)));
1054}
1055
1056OSATOMIC_INLINE
1057bool
1058OSAtomicCompareAndSwapInt(int __oldValue, int __newValue,
1059 volatile int *__theValue)
1060{
1061 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1062 (volatile OSATOMIC_STD(atomic_int)*)__theValue, &__oldValue,
1063 __newValue, OSATOMIC_STD(memory_order_relaxed),
1064 OSATOMIC_STD(memory_order_relaxed)));
1065}
1066
1067OSATOMIC_INLINE
1068bool
1069OSAtomicCompareAndSwapIntBarrier(int __oldValue, int __newValue,
1070 volatile int *__theValue)
1071{
1072 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1073 (volatile OSATOMIC_STD(atomic_int)*)__theValue, &__oldValue,
1074 __newValue, OSATOMIC_STD(memory_order_seq_cst),
1075 OSATOMIC_STD(memory_order_relaxed)));
1076}
1077
1078OSATOMIC_INLINE
1079bool
1080OSAtomicCompareAndSwapLong(long __oldValue, long __newValue,
1081 volatile long *__theValue)
1082{
1083 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1084 (volatile OSATOMIC_STD(atomic_long)*)__theValue, &__oldValue,
1085 __newValue, OSATOMIC_STD(memory_order_relaxed),
1086 OSATOMIC_STD(memory_order_relaxed)));
1087}
1088
1089OSATOMIC_INLINE
1090bool
1091OSAtomicCompareAndSwapLongBarrier(long __oldValue, long __newValue,
1092 volatile long *__theValue)
1093{
1094 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1095 (volatile OSATOMIC_STD(atomic_long)*)__theValue, &__oldValue,
1096 __newValue, OSATOMIC_STD(memory_order_seq_cst),
1097 OSATOMIC_STD(memory_order_relaxed)));
1098}
1099
1100OSATOMIC_INLINE
1101bool
1102OSAtomicCompareAndSwap64(int64_t __oldValue, int64_t __newValue,
1103 volatile OSAtomic_int64_aligned64_t *__theValue)
1104{
1105 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1106 (volatile _OSAtomic_int64_t*)__theValue, &__oldValue, __newValue,
1107 OSATOMIC_STD(memory_order_relaxed),
1108 OSATOMIC_STD(memory_order_relaxed)));
1109}
1110
1111OSATOMIC_INLINE
1112bool
1113OSAtomicCompareAndSwap64Barrier(int64_t __oldValue, int64_t __newValue,
1114 volatile OSAtomic_int64_aligned64_t *__theValue)
1115{
1116 return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
1117 (volatile _OSAtomic_int64_t*)__theValue, &__oldValue, __newValue,
1118 OSATOMIC_STD(memory_order_seq_cst),
1119 OSATOMIC_STD(memory_order_relaxed)));
1120}
1121
1122OSATOMIC_INLINE
1123bool
1124OSAtomicTestAndSet(uint32_t __n, volatile void *__theAddress)
1125{
1126 uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
1127 uint8_t v = (0x80u >> (__n & 7));
1128 return (OSATOMIC_STD(atomic_fetch_or_explicit)((_OSAtomic_uint8_t*)a, v,
1129 OSATOMIC_STD(memory_order_relaxed)) & v);
1130}
1131
1132OSATOMIC_INLINE
1133bool
1134OSAtomicTestAndSetBarrier(uint32_t __n, volatile void *__theAddress)
1135{
1136 uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
1137 uint8_t v = (0x80u >> (__n & 7));
1138 return (OSATOMIC_STD(atomic_fetch_or_explicit)((_OSAtomic_uint8_t*)a, v,
1139 OSATOMIC_STD(memory_order_seq_cst)) & v);
1140}
1141
1142OSATOMIC_INLINE
1143bool
1144OSAtomicTestAndClear(uint32_t __n, volatile void *__theAddress)
1145{
1146 uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
1147 uint8_t v = (0x80u >> (__n & 7));
1148 return (OSATOMIC_STD(atomic_fetch_and_explicit)((_OSAtomic_uint8_t*)a,
1149 (uint8_t)~v, OSATOMIC_STD(memory_order_relaxed)) & v);
1150}
1151
1152OSATOMIC_INLINE
1153bool
1154OSAtomicTestAndClearBarrier(uint32_t __n, volatile void *__theAddress)
1155{
1156 uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
1157 uint8_t v = (0x80u >> (__n & 7));
1158 return (OSATOMIC_STD(atomic_fetch_and_explicit)((_OSAtomic_uint8_t*)a,
1159 (uint8_t)~v, OSATOMIC_STD(memory_order_seq_cst)) & v);
1160}
1161
1162OSATOMIC_INLINE
1163void
1164OSMemoryBarrier(void)
1165{
1166 OSATOMIC_STD(atomic_thread_fence)(OSATOMIC_STD(memory_order_seq_cst));
1167}
1168
1169#undef OSATOMIC_INLINE
1170#undef OSATOMIC_STD
1171#ifdef __cplusplus
1172__END_DECLS
1173} // extern "C++"
1174#endif
1175
1176#endif // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED
1177
1178#if TARGET_OS_OSX || TARGET_OS_DRIVERKIT
1179
1180__BEGIN_DECLS
1181
1182/*! @group Lockless atomic fifo enqueue and dequeue
1183 * These routines manipulate singly-linked FIFO lists.
1184 *
1185 * This API is deprecated and no longer recommended
1186 */
1187
1188/*! @abstract The data structure for a fifo queue head.
1189 @discussion
1190 You should always initialize a fifo queue head structure with the
1191 initialization vector {@link OS_ATOMIC_FIFO_QUEUE_INIT} before use.
1192 */
1193#if defined(__LP64__)
1194
1195typedef volatile struct {
1196 void *opaque1;
1197 void *opaque2;
1198 int opaque3;
1199} __attribute__ ((aligned (16))) OSFifoQueueHead;
1200
1201#else
1202
1203typedef volatile struct {
1204 void *opaque1;
1205 void *opaque2;
1206 int opaque3;
1207} OSFifoQueueHead;
1208
1209#endif
1210/*! @abstract The initialization vector for a fifo queue head. */
1211#define OS_ATOMIC_FIFO_QUEUE_INIT { NULL, NULL, 0 }
1212
1213/*! @abstract Enqueue an element onto a list.
1214 @discussion
1215 Memory barriers are incorporated as needed to permit thread-safe access
1216 to the queue element.
1217 @param __list
1218 The list on which you want to enqueue the element.
1219 @param __new
1220 The element to add.
1221 @param __offset
1222 The "offset" parameter is the offset (in bytes) of the link field
1223 from the beginning of the data structure being queued (<code>__new</code>).
1224 The link field should be a pointer type.
1225 The <code>__offset</code> value needs to be same for all enqueuing and
1226 dequeuing operations on the same list, even if different structure types
1227 are enqueued on that list. The use of <code>offsetset()</code>, defined in
1228 <code>stddef.h</code> is the common way to specify the <code>__offset</code>
1229 value.
1230
1231 @note
1232 This API is deprecated and no longer recommended
1233 */
1234__API_DEPRECATED("No longer supported", macos(10.7, 11.0))
1235void OSAtomicFifoEnqueue( OSFifoQueueHead *__list, void *__new, size_t __offset);
1236
1237/*! @abstract Dequeue an element from a list.
1238 @discussion
1239 Memory barriers are incorporated as needed to permit thread-safe access
1240 to the queue element.
1241 @param __list
1242 The list from which you want to dequeue an element.
1243 @param __offset
1244 The "offset" parameter is the offset (in bytes) of the link field
1245 from the beginning of the data structure being dequeued (<code>__new</code>).
1246 The link field should be a pointer type.
1247 The <code>__offset</code> value needs to be same for all enqueuing and
1248 dequeuing operations on the same list, even if different structure types
1249 are enqueued on that list. The use of <code>offsetset()</code>, defined in
1250 <code>stddef.h</code> is the common way to specify the <code>__offset</code>
1251 value.
1252 @result
1253 Returns the oldest enqueued element, or <code>NULL</code> if the
1254 list is empty.
1255
1256 @note
1257 This API is deprecated and no longer recommended
1258 */
1259__API_DEPRECATED("No longer supported", macos(10.7, 11.0))
1260void* OSAtomicFifoDequeue( OSFifoQueueHead *__list, size_t __offset);
1261
1262__END_DECLS
1263
1264#endif /* TARGET_OS_OSX || TARGET_OS_DRIVERKIT */
1265
1266#endif /* _OSATOMIC_DEPRECATED_H_ */
lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicQueue.h created+115
......@@ -0,0 +1,115 @@
1/*
2 * Copyright (c) 2004-2016 Apple Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef _OSATOMICQUEUE_H_
25#define _OSATOMICQUEUE_H_
26
27#include <stddef.h>
28#include <sys/cdefs.h>
29#include <stdint.h>
30#include <stdbool.h>
31#include "OSAtomicDeprecated.h"
32
33#include <Availability.h>
34
35/*! @header Lockless atomic enqueue and dequeue
36 * These routines manipulate singly-linked LIFO lists.
37 */
38
39__BEGIN_DECLS
40
41/*! @abstract The data structure for a queue head.
42 @discussion
43 You should always initialize a queue head structure with the
44 initialization vector {@link OS_ATOMIC_QUEUE_INIT} before use.
45 */
46#if defined(__LP64__)
47
48typedef volatile struct {
49 void *opaque1;
50 long opaque2;
51} __attribute__ ((aligned (16))) OSQueueHead;
52
53#else
54
55typedef volatile struct {
56 void *opaque1;
57 long opaque2;
58} OSQueueHead;
59
60#endif
61
62/*! @abstract The initialization vector for a queue head. */
63#define OS_ATOMIC_QUEUE_INIT { NULL, 0 }
64
65/*! @abstract Enqueue an element onto a list.
66 @discussion
67 Memory barriers are incorporated as needed to permit thread-safe access
68 to the queue element.
69 @param __list
70 The list on which you want to enqueue the element.
71 @param __new
72 The element to add.
73 @param __offset
74 The "offset" parameter is the offset (in bytes) of the link field
75 from the beginning of the data structure being queued (<code>__new</code>).
76 The link field should be a pointer type.
77 The <code>__offset</code> value needs to be same for all enqueuing and
78 dequeuing operations on the same list, even if different structure types
79 are enqueued on that list. The use of <code>offsetset()</code>, defined in
80 <code>stddef.h</code> is the common way to specify the <code>__offset</code>
81 value.
82 */
83__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0)
84void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset);
85
86
87/*! @abstract Dequeue an element from a list.
88 @discussion
89 Memory barriers are incorporated as needed to permit thread-safe access
90 to the queue element.
91 @param __list
92 The list from which you want to dequeue an element.
93 @param __offset
94 The "offset" parameter is the offset (in bytes) of the link field
95 from the beginning of the data structure being dequeued (<code>__new</code>).
96 The link field should be a pointer type.
97 The <code>__offset</code> value needs to be same for all enqueuing and
98 dequeuing operations on the same list, even if different structure types
99 are enqueued on that list. The use of <code>offsetset()</code>, defined in
100 <code>stddef.h</code> is the common way to specify the <code>__offset</code>
101 value.
102 IMPORTANT: the memory backing the link field of a queue element must not be
103 unmapped after OSAtomicDequeue() returns until all concurrent calls to
104 OSAtomicDequeue() for the same list on other threads have also returned,
105 as they may still be accessing that memory location.
106 @result
107 Returns the most recently enqueued element, or <code>NULL</code> if the
108 list is empty.
109 */
110__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0)
111void* OSAtomicDequeue( OSQueueHead *__list, size_t __offset);
112
113__END_DECLS
114
115#endif /* _OSATOMICQUEUE_H_ */
lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h+19-7
......@@ -37,10 +37,22 @@
3737#define OSSwapConstInt32(x) __DARWIN_OSSwapConstInt32(x)
3838#define OSSwapConstInt64(x) __DARWIN_OSSwapConstInt64(x)
3939
40#if !defined(__DARWIN_OS_INLINE)
41# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
42# define __DARWIN_OS_INLINE static inline
43# elif defined(__MWERKS__) || defined(__cplusplus)
44# define __DARWIN_OS_INLINE static inline
45# else
46# define __DARWIN_OS_INLINE static __inline__
47# endif
48#endif
49
4050#if defined(__GNUC__)
4151
4252#if (defined(__i386__) || defined(__x86_64__))
4353#include <libkern/i386/OSByteOrder.h>
54#elif defined (__arm__) || defined(__arm64__)
55#include <libkern/arm/OSByteOrder.h>
4456#else
4557#include <libkern/machine/OSByteOrder.h>
4658#endif
......@@ -61,7 +73,7 @@ enum {
6173 OSBigEndian
6274};
6375
64OS_INLINE
76__DARWIN_OS_INLINE
6577int32_t
6678OSHostByteOrder(void)
6779{
......@@ -85,7 +97,7 @@ OSHostByteOrder(void)
8597
8698/* Functions for loading native endian values. */
8799
88OS_INLINE
100__DARWIN_OS_INLINE
89101uint16_t
90102_OSReadInt16(
91103 const volatile void * base,
......@@ -95,7 +107,7 @@ _OSReadInt16(
95107 return *(volatile uint16_t *)((uintptr_t)base + byteOffset);
96108}
97109
98OS_INLINE
110__DARWIN_OS_INLINE
99111uint32_t
100112_OSReadInt32(
101113 const volatile void * base,
......@@ -105,7 +117,7 @@ _OSReadInt32(
105117 return *(volatile uint32_t *)((uintptr_t)base + byteOffset);
106118}
107119
108OS_INLINE
120__DARWIN_OS_INLINE
109121uint64_t
110122_OSReadInt64(
111123 const volatile void * base,
......@@ -117,7 +129,7 @@ _OSReadInt64(
117129
118130/* Functions for storing native endian values. */
119131
120OS_INLINE
132__DARWIN_OS_INLINE
121133void
122134_OSWriteInt16(
123135 volatile void * base,
......@@ -128,7 +140,7 @@ _OSWriteInt16(
128140 *(volatile uint16_t *)((uintptr_t)base + byteOffset) = data;
129141}
130142
131OS_INLINE
143__DARWIN_OS_INLINE
132144void
133145_OSWriteInt32(
134146 volatile void * base,
......@@ -139,7 +151,7 @@ _OSWriteInt32(
139151 *(volatile uint32_t *)((uintptr_t)base + byteOffset) = data;
140152}
141153
142OS_INLINE
154__DARWIN_OS_INLINE
143155void
144156_OSWriteInt64(
145157 volatile void * base,
lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h created+212
......@@ -0,0 +1,212 @@
1/*
2 * Copyright (c) 2004-2016 Apple Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef _OSSPINLOCK_DEPRECATED_H_
25#define _OSSPINLOCK_DEPRECATED_H_
26
27/*! @header
28 * These are deprecated legacy interfaces for userspace spinlocks.
29 *
30 * These interfaces should no longer be used, particularily in situations where
31 * threads of differing priorities may contend on the same spinlock.
32 *
33 * The interfaces in <os/lock.h> should be used instead in cases where a very
34 * low-level lock primitive is required. In general however, using higher level
35 * synchronization primitives such as those provided by the pthread or dispatch
36 * subsystems should be preferred.
37 *
38 * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of these
39 * interfaces in terms of the <os/lock.h> primitives. This is intended as a
40 * transition convenience, direct use of those primitives is preferred.
41 */
42
43#ifndef OSSPINLOCK_DEPRECATED
44#define OSSPINLOCK_DEPRECATED 1
45#define OSSPINLOCK_DEPRECATED_MSG(_r) "Use " #_r "() from <os/lock.h> instead"
46#define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) \
47 __OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSSPINLOCK_DEPRECATED_MSG(_r)) \
48 __OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \
49 __OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \
50 __OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSSPINLOCK_DEPRECATED_MSG(_r))
51#else
52#undef OSSPINLOCK_DEPRECATED
53#define OSSPINLOCK_DEPRECATED 0
54#define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r)
55#endif
56
57#if !(defined(OSSPINLOCK_USE_INLINED) && OSSPINLOCK_USE_INLINED)
58
59#include <sys/cdefs.h>
60#include <stddef.h>
61#include <stdint.h>
62#include <stdbool.h>
63#include <Availability.h>
64
65__BEGIN_DECLS
66
67/*! @abstract The default value for an <code>OSSpinLock</code>.
68 @discussion
69 The convention is that unlocked is zero, locked is nonzero.
70 */
71#define OS_SPINLOCK_INIT 0
72
73
74/*! @abstract Data type for a spinlock.
75 @discussion
76 You should always initialize a spinlock to {@link OS_SPINLOCK_INIT} before
77 using it.
78 */
79typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
80
81
82/*! @abstract Locks a spinlock if it would not block
83 @result
84 Returns <code>false</code> if the lock was already held by another thread,
85 <code>true</code> if it took the lock successfully.
86 */
87OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
88__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
89bool OSSpinLockTry( volatile OSSpinLock *__lock );
90
91
92/*! @abstract Locks a spinlock
93 @discussion
94 Although the lock operation spins, it employs various strategies to back
95 off if the lock is held.
96 */
97OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
98__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
99void OSSpinLockLock( volatile OSSpinLock *__lock );
100
101
102/*! @abstract Unlocks a spinlock */
103OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
104__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
105void OSSpinLockUnlock( volatile OSSpinLock *__lock );
106
107__END_DECLS
108
109#else /* OSSPINLOCK_USE_INLINED */
110
111/*
112 * Inline implementations of the legacy OSSpinLock interfaces in terms of the
113 * of the <os/lock.h> primitives. Direct use of those primitives is preferred.
114 *
115 * NOTE: the locked value of os_unfair_lock is implementation defined and
116 * subject to change, code that relies on the specific locked value used by the
117 * legacy OSSpinLock interface WILL break when using these inline
118 * implementations in terms of os_unfair_lock.
119 */
120
121#if !OSSPINLOCK_USE_INLINED_TRANSPARENT
122
123#include <os/lock.h>
124
125__BEGIN_DECLS
126
127#if __has_attribute(always_inline)
128#define OSSPINLOCK_INLINE static __inline
129#else
130#define OSSPINLOCK_INLINE static __inline __attribute__((__always_inline__))
131#endif
132
133#define OS_SPINLOCK_INIT 0
134typedef int32_t OSSpinLock;
135
136#if __has_extension(c_static_assert)
137_Static_assert(sizeof(OSSpinLock) == sizeof(os_unfair_lock),
138 "Incompatible os_unfair_lock type");
139#endif
140
141OSSPINLOCK_INLINE
142void
143OSSpinLockLock(volatile OSSpinLock *__lock)
144{
145 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
146 return os_unfair_lock_lock(lock);
147}
148
149OSSPINLOCK_INLINE
150bool
151OSSpinLockTry(volatile OSSpinLock *__lock)
152{
153 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
154 return os_unfair_lock_trylock(lock);
155}
156
157OSSPINLOCK_INLINE
158void
159OSSpinLockUnlock(volatile OSSpinLock *__lock)
160{
161 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
162 return os_unfair_lock_unlock(lock);
163}
164
165#undef OSSPINLOCK_INLINE
166
167__END_DECLS
168
169#else /* OSSPINLOCK_USE_INLINED_TRANSPARENT */
170
171#include <sys/cdefs.h>
172#include <stddef.h>
173#include <stdint.h>
174#include <stdbool.h>
175#include <Availability.h>
176
177#define OS_NOSPIN_LOCK_AVAILABILITY \
178 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) \
179 __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
180
181__BEGIN_DECLS
182
183#define OS_SPINLOCK_INIT 0
184typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
185typedef volatile OSSpinLock *_os_nospin_lock_t
186 OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t);
187
188OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
189OS_NOSPIN_LOCK_AVAILABILITY
190void _os_nospin_lock_lock(_os_nospin_lock_t lock);
191#undef OSSpinLockLock
192#define OSSpinLockLock(lock) _os_nospin_lock_lock(lock)
193
194OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
195OS_NOSPIN_LOCK_AVAILABILITY
196bool _os_nospin_lock_trylock(_os_nospin_lock_t lock);
197#undef OSSpinLockTry
198#define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock)
199
200OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
201OS_NOSPIN_LOCK_AVAILABILITY
202void _os_nospin_lock_unlock(_os_nospin_lock_t lock);
203#undef OSSpinLockUnlock
204#define OSSpinLockUnlock(lock) _os_nospin_lock_unlock(lock)
205
206__END_DECLS
207
208#endif /* OSSPINLOCK_USE_INLINED_TRANSPARENT */
209
210#endif /* OSSPINLOCK_USE_INLINED */
211
212#endif /* _OSSPINLOCK_DEPRECATED_H_ */
lib/libc/include/x86_64-macos-gnu/libkern/OSTypes.h created+42
......@@ -0,0 +1,42 @@
1/*
2 * Copyright (c) 1999-2012 Apple Computer, 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#include <MacTypes.h>
30
31#ifndef _OS_OSTYPES_H
32#define _OS_OSTYPES_H
33
34#define OSTYPES_K64_REV 2
35
36typedef unsigned int UInt;
37typedef signed int SInt;
38
39
40#include <sys/_types/_os_inline.h>
41
42#endif /* _OS_OSTYPES_H */
lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h+19-16
......@@ -41,14 +41,14 @@
4141
4242/* Macros for swapping constant values in the preprocessing stage. */
4343#define __DARWIN_OSSwapConstInt16(x) \
44 ((__uint16_t)((((__uint16_t)(x) & 0xff00) >> 8) | \
45 (((__uint16_t)(x) & 0x00ff) << 8)))
44 ((__uint16_t)((((__uint16_t)(x) & 0xff00U) >> 8) | \
45 (((__uint16_t)(x) & 0x00ffU) << 8)))
4646
4747#define __DARWIN_OSSwapConstInt32(x) \
48 ((__uint32_t)((((__uint32_t)(x) & 0xff000000) >> 24) | \
49 (((__uint32_t)(x) & 0x00ff0000) >> 8) | \
50 (((__uint32_t)(x) & 0x0000ff00) << 8) | \
51 (((__uint32_t)(x) & 0x000000ff) << 24)))
48 ((__uint32_t)((((__uint32_t)(x) & 0xff000000U) >> 24) | \
49 (((__uint32_t)(x) & 0x00ff0000U) >> 8) | \
50 (((__uint32_t)(x) & 0x0000ff00U) << 8) | \
51 (((__uint32_t)(x) & 0x000000ffU) << 24)))
5252
5353#define __DARWIN_OSSwapConstInt64(x) \
5454 ((__uint64_t)((((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \
......@@ -62,10 +62,23 @@
6262
6363#if defined(__GNUC__)
6464
65#if !defined(__DARWIN_OS_INLINE)
66# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
67# define __DARWIN_OS_INLINE static inline
68# elif defined(__MWERKS__) || defined(__cplusplus)
69# define __DARWIN_OS_INLINE static inline
70# else
71# define __DARWIN_OS_INLINE static __inline__
72# endif
73#endif
74
6575#if defined(__i386__) || defined(__x86_64__)
6676#include <libkern/i386/_OSByteOrder.h>
6777#endif
6878
79#if defined (__arm__) || defined(__arm64__)
80#include <libkern/arm/OSByteOrder.h>
81#endif
6982
7083
7184#define __DARWIN_OSSwapInt16(x) \
......@@ -81,16 +94,6 @@
8194
8295#if defined(__i386__) || defined(__x86_64__)
8396
84#if !defined(__DARWIN_OS_INLINE)
85# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
86# define __DARWIN_OS_INLINE static inline
87# elif defined(__MWERKS__) || defined(__cplusplus)
88# define __DARWIN_OS_INLINE static inline
89# else
90# define __DARWIN_OS_INLINE static __inline__
91# endif
92#endif
93
9497__DARWIN_OS_INLINE
9598uint16_t
9699_OSSwapInt16(
lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h+9
......@@ -112,6 +112,15 @@ extern void _tlv_atexit(void (*termFunc)(void* objAddr), void* objAddr) __O
112112 */
113113extern void _tlv_bootstrap(void) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) DYLD_DRIVERKIT_UNAVAILABLE ;
114114
115
116/*
117 * Dylibs that are incorporated into the dyld cache are removed from disk. That means code
118 * cannot stat() the file to see if it "exists". This function is like a stat() call that checks if a
119 * path is to a dylib that was removed from disk and is incorporated into the active dyld cache.
120 */
121extern bool _dyld_shared_cache_contains_path(const char* path) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) DYLD_DRIVERKIT_UNAVAILABLE;
122
123
115124/*
116125 * The following dyld API's are deprecated as of Mac OS X 10.5. They are either
117126 * no longer necessary or are superceeded by dlopen and friends in <dlfcn.h>.
lib/libc/include/x86_64-macos-gnu/mach-o/loader.h+31-7
......@@ -115,11 +115,14 @@ struct mach_header_64 {
115115#define MH_DYLIB 0x6 /* dynamically bound shared library */
116116#define MH_DYLINKER 0x7 /* dynamic link editor */
117117#define MH_BUNDLE 0x8 /* dynamically bound bundle file */
118#define MH_DYLIB_STUB 0x9 /* shared library stub for static */
119 /* linking only, no section contents */
120#define MH_DSYM 0xa /* companion file with only debug */
121 /* sections */
118#define MH_DYLIB_STUB 0x9 /* shared library stub for static
119 linking only, no section contents */
120#define MH_DSYM 0xa /* companion file with only debug
121 sections */
122122#define MH_KEXT_BUNDLE 0xb /* x86_64 kexts */
123#define MH_FILESET 0xc /* a file composed of other Mach-Os to
124 be run in the same userspace sharing
125 a single linkedit. */
123126
124127/* Constants for the flags field of the mach_header */
125128#define MH_NOUNDEFS 0x1 /* the object file has no undefined
......@@ -322,6 +325,7 @@ struct load_command {
322325#define LC_BUILD_VERSION 0x32 /* build for platform min OS version */
323326#define LC_DYLD_EXPORTS_TRIE (0x33 | LC_REQ_DYLD) /* used with linkedit_data_command, payload is trie */
324327#define LC_DYLD_CHAINED_FIXUPS (0x34 | LC_REQ_DYLD) /* used with linkedit_data_command */
328#define LC_FILESET_ENTRY (0x35 | LC_REQ_DYLD) /* used with fileset_entry_command */
325329
326330/*
327331 * A variable length string in a load command is represented by an lc_str
......@@ -1265,9 +1269,6 @@ struct build_tool_version {
12651269#define PLATFORM_WATCHOS 4
12661270#define PLATFORM_BRIDGEOS 5
12671271#define PLATFORM_MACCATALYST 6
1268#if (!defined(PLATFORM_MACCATALYST))
1269#define PLATFORM_MACCATALYST 6
1270#endif
12711272#define PLATFORM_IOSSIMULATOR 7
12721273#define PLATFORM_TVOSSIMULATOR 8
12731274#define PLATFORM_WATCHOSSIMULATOR 9
......@@ -1574,4 +1575,27 @@ struct note_command {
15741575 uint64_t size; /* length of data region */
15751576};
15761577
1578/*
1579 * LC_FILESET_ENTRY commands describe constituent Mach-O files that are part
1580 * of a fileset. In one implementation, entries are dylibs with individual
1581 * mach headers and repositionable text and data segments. Each entry is
1582 * further described by its own mach header.
1583 */
1584struct fileset_entry_command {
1585 uint32_t cmd; /* LC_FILESET_ENTRY */
1586 uint32_t cmdsize; /* includes entry_id string */
1587 uint64_t vmaddr; /* memory address of the entry */
1588 uint64_t fileoff; /* file offset of the entry */
1589 union lc_str entry_id; /* contained entry id */
1590 uint32_t reserved; /* reserved */
1591};
1592
1593/*
1594 * These deprecated values may still be used within Apple but are mechanically
1595 * removed from public API. The mechanical process may produce unusual results.
1596 */
1597#if (!defined(PLATFORM_MACCATALYST))
1598#define PLATFORM_MACCATALYST PLATFORM_MACCATALYST
1599#endif
1600
15771601#endif /* _MACHO_LOADER_H_ */
lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h+80
......@@ -603,7 +603,48 @@ _STRUCT_X86_DEBUG_STATE32
603603 unsigned int __dr6;
604604 unsigned int __dr7;
605605};
606
607#define _STRUCT_X86_INSTRUCTION_STATE struct __x86_instruction_state
608_STRUCT_X86_INSTRUCTION_STATE
609{
610 int __insn_stream_valid_bytes;
611 int __insn_offset;
612 int __out_of_synch; /*
613 * non-zero when the cacheline that includes the insn_offset
614 * is replaced in the insn_bytes array due to a mismatch
615 * detected when comparing it with the same cacheline in memory
616 */
617#define _X86_INSTRUCTION_STATE_MAX_INSN_BYTES (2448 - 64 - 4)
618 __uint8_t __insn_bytes[_X86_INSTRUCTION_STATE_MAX_INSN_BYTES];
619#define _X86_INSTRUCTION_STATE_CACHELINE_SIZE 64
620 __uint8_t __insn_cacheline[_X86_INSTRUCTION_STATE_CACHELINE_SIZE];
621};
622
623#define _STRUCT_LAST_BRANCH_RECORD struct __last_branch_record
624_STRUCT_LAST_BRANCH_RECORD
625{
626 __uint64_t __from_ip;
627 __uint64_t __to_ip;
628 __uint32_t __mispredict : 1,
629 __tsx_abort : 1,
630 __in_tsx : 1,
631 __cycle_count: 16,
632 __reserved : 13;
633};
634
635#define _STRUCT_LAST_BRANCH_STATE struct __last_branch_state
636_STRUCT_LAST_BRANCH_STATE
637{
638 int __lbr_count;
639 __uint32_t __lbr_supported_tsx : 1,
640 __lbr_supported_cycle_count : 1,
641 __reserved : 30;
642#define __LASTBRANCH_MAX 32
643 _STRUCT_LAST_BRANCH_RECORD __lbrs[__LASTBRANCH_MAX];
644};
645
606646#else /* !__DARWIN_UNIX03 */
647
607648#define _STRUCT_X86_DEBUG_STATE32 struct x86_debug_state32
608649_STRUCT_X86_DEBUG_STATE32
609650{
......@@ -616,6 +657,45 @@ _STRUCT_X86_DEBUG_STATE32
616657 unsigned int dr6;
617658 unsigned int dr7;
618659};
660
661#define _STRUCT_X86_INSTRUCTION_STATE struct __x86_instruction_state
662_STRUCT_X86_INSTRUCTION_STATE
663{
664 int insn_stream_valid_bytes;
665 int insn_offset;
666 int out_of_synch; /*
667 * non-zero when the cacheline that includes the insn_offset
668 * is replaced in the insn_bytes array due to a mismatch
669 * detected when comparing it with the same cacheline in memory
670 */
671#define x86_INSTRUCTION_STATE_MAX_INSN_BYTES (2448 - 64 - 4)
672 __uint8_t insn_bytes[x86_INSTRUCTION_STATE_MAX_INSN_BYTES];
673#define x86_INSTRUCTION_STATE_CACHELINE_SIZE 64
674 __uint8_t insn_cacheline[x86_INSTRUCTION_STATE_CACHELINE_SIZE];
675};
676
677#define _STRUCT_LAST_BRANCH_RECORD struct __last_branch_record
678_STRUCT_LAST_BRANCH_RECORD
679{
680 __uint64_t from_ip;
681 __uint64_t to_ip;
682 __uint32_t mispredict : 1,
683 tsx_abort : 1,
684 in_tsx : 1,
685 cycle_count: 16,
686 reserved : 13;
687};
688
689#define _STRUCT_LAST_BRANCH_STATE struct __last_branch_state
690_STRUCT_LAST_BRANCH_STATE
691{
692 int lbr_count;
693 __uint32_t lbr_supported_tsx : 1,
694 lbr_supported_cycle_count : 1,
695 reserved : 30;
696#define __LASTBRANCH_MAX 32
697 _STRUCT_LAST_BRANCH_RECORD lbrs[__LASTBRANCH_MAX];
698};
619699#endif /* !__DARWIN_UNIX03 */
620700
621701#define _STRUCT_X86_PAGEIN_STATE struct __x86_pagein_state
lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h+1-1
......@@ -32,7 +32,7 @@
3232#ifndef _MACH_I386_THREAD_STATE_H_
3333#define _MACH_I386_THREAD_STATE_H_
3434
35/* Size of maximum exported thread state in words */
35/* Size of maximum exported thread state in 32-bit words */
3636#define I386_THREAD_STATE_MAX (614) /* Size of biggest state possible */
3737
3838#if defined (__i386__) || defined(__x86_64__)
lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h+18-1
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
2 * Copyright (c) 2000-2020 Apple Computer, Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55 *
......@@ -121,6 +121,8 @@
121121#define x86_AVX512_STATE (x86_AVX512_STATE32 + 2)
122122#define x86_PAGEIN_STATE 22
123123#define x86_THREAD_FULL_STATE64 23
124#define x86_INSTRUCTION_STATE 24
125#define x86_LAST_BRANCH_STATE 25
124126
125127/*
126128 * Largest state on this machine:
......@@ -155,6 +157,8 @@
155157 (x == x86_AVX512_STATE64) || \
156158 (x == x86_AVX512_STATE) || \
157159 (x == x86_PAGEIN_STATE) || \
160 (x == x86_INSTRUCTION_STATE) || \
161 (x == x86_LAST_BRANCH_STATE) || \
158162 (x == THREAD_STATE_NONE))
159163
160164struct x86_state_hdr {
......@@ -259,6 +263,19 @@ typedef _STRUCT_X86_PAGEIN_STATE x86_pagein_state_t;
259263
260264#define X86_PAGEIN_STATE_COUNT x86_PAGEIN_STATE_COUNT
261265
266typedef _STRUCT_X86_INSTRUCTION_STATE x86_instruction_state_t;
267#define x86_INSTRUCTION_STATE_COUNT \
268 ((mach_msg_type_number_t)(sizeof(x86_instruction_state_t) / sizeof(int)))
269
270#define X86_INSTRUCTION_STATE_COUNT x86_INSTRUCTION_STATE_COUNT
271
272typedef _STRUCT_LAST_BRANCH_STATE last_branch_state_t;
273#define x86_LAST_BRANCH_STATE_COUNT \
274 ((mach_msg_type_number_t)(sizeof(last_branch_state_t) / sizeof(int)))
275
276#define X86_LAST_BRANCH_STATE_COUNT x86_LAST_BRANCH_STATE_COUNT
277
278
262279/*
263280 * Combined thread, float and exception states
264281 */
lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h+22-35
......@@ -90,47 +90,34 @@
9090#ifndef _MACH_I386_VM_PARAM_H_
9191#define _MACH_I386_VM_PARAM_H_
9292
93#if !defined(KERNEL) && !defined(__ASSEMBLER__)
94
95#include <mach/vm_page_size.h>
96#endif
97
9398#define BYTE_SIZE 8 /* byte size in bits */
9499
95100#define I386_PGBYTES 4096 /* bytes per 80386 page */
96101#define I386_PGSHIFT 12 /* bitshift for pages */
97102
98#define PAGE_SIZE I386_PGBYTES
99#define PAGE_SHIFT I386_PGSHIFT
100#define PAGE_MASK (PAGE_SIZE - 1)
101
102#define PAGE_MAX_SHIFT PAGE_SHIFT
103#define PAGE_MAX_SIZE PAGE_SIZE
104#define PAGE_MAX_MASK PAGE_MASK
105
106#define PAGE_MIN_SHIFT PAGE_SHIFT
107#define PAGE_MIN_SIZE PAGE_SIZE
108#define PAGE_MIN_MASK PAGE_MASK
109
110#define I386_LPGBYTES 2*1024*1024 /* bytes per large page */
111#define I386_LPGSHIFT 21 /* bitshift for large pages */
112#define I386_LPGMASK (I386_LPGBYTES-1)
113
114/*
115 * Convert bytes to pages and convert pages to bytes.
116 * No rounding is used.
117 */
118
119#define i386_btop(x) ((ppnum_t)((x) >> I386_PGSHIFT))
120#define machine_btop(x) i386_btop(x)
121#define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT)
122#define machine_ptob(x) i386_ptob(x)
123
124/*
125 * Round off or truncate to the nearest page. These will work
126 * for either addresses or counts. (i.e. 1 byte rounds to 1 page
127 * bytes.
128 */
129
130#define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
131 ~(I386_PGBYTES-1))
132#define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
133103
104#if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600)
105#define PAGE_SHIFT I386_PGSHIFT
106#define PAGE_SIZE I386_PGBYTES
107#define PAGE_MASK (PAGE_SIZE-1)
108#else /* !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) */
109#define PAGE_SHIFT vm_page_shift
110#define PAGE_SIZE vm_page_size
111#define PAGE_MASK vm_page_mask
112#endif /* !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) */
113
114#define PAGE_MAX_SHIFT 14
115#define PAGE_MAX_SIZE (1 << PAGE_MAX_SHIFT)
116#define PAGE_MAX_MASK (PAGE_MAX_SIZE-1)
117
118#define PAGE_MIN_SHIFT 12
119#define PAGE_MIN_SIZE (1 << PAGE_MIN_SHIFT)
120#define PAGE_MIN_MASK (PAGE_MIN_SIZE-1)
134121
135122
136123#define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL)
lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h-1
......@@ -70,7 +70,6 @@
7070#ifndef ASSEMBLER
7171
7272#include <i386/_types.h>
73#include <mach/i386/vm_param.h>
7473#include <stdint.h>
7574
7675/*
lib/libc/include/x86_64-macos-gnu/mach/kern_return.h+4
......@@ -323,6 +323,10 @@
323323/* The provided buffer is of insufficient size for the requested data.
324324 */
325325
326#define KERN_DENIED 53
327/* Denied by security policy
328 */
329
326330#define KERN_RETURN_MAX 0x100
327331/* Maximum return value allowable
328332 */
lib/libc/include/x86_64-macos-gnu/mach/mach_port.h+7-7
......@@ -226,7 +226,7 @@ extern
226226#endif /* mig_external */
227227kern_return_t mach_port_get_set_status
228228(
229 ipc_space_inspect_t task,
229 ipc_space_read_t task,
230230 mach_port_name_t name,
231231 mach_port_name_array_t *members,
232232 mach_msg_type_number_t *membersCnt
......@@ -312,7 +312,7 @@ extern
312312#endif /* mig_external */
313313kern_return_t mach_port_get_attributes
314314(
315 ipc_space_inspect_t task,
315 ipc_space_read_t task,
316316 mach_port_name_t name,
317317 mach_port_flavor_t flavor,
318318 mach_port_info_t port_info_out,
......@@ -398,7 +398,7 @@ extern
398398#endif /* mig_external */
399399kern_return_t mach_port_space_info
400400(
401 ipc_space_inspect_t task,
401 ipc_space_read_t space,
402402 ipc_info_space_t *space_info,
403403 ipc_info_name_array_t *table_info,
404404 mach_msg_type_number_t *table_infoCnt,
......@@ -428,7 +428,7 @@ extern
428428#endif /* mig_external */
429429kern_return_t mach_port_kernel_object
430430(
431 ipc_space_inspect_t task,
431 ipc_space_read_t task,
432432 mach_port_name_t name,
433433 unsigned *object_type,
434434 unsigned *object_addr
......@@ -468,7 +468,7 @@ extern
468468#endif /* mig_external */
469469kern_return_t mach_port_get_context
470470(
471 ipc_space_inspect_t task,
471 ipc_space_read_t task,
472472 mach_port_name_t name,
473473 mach_port_context_t *context
474474);
......@@ -494,7 +494,7 @@ extern
494494#endif /* mig_external */
495495kern_return_t mach_port_kobject
496496(
497 ipc_space_inspect_t task,
497 ipc_space_read_t task,
498498 mach_port_name_t name,
499499 natural_t *object_type,
500500 mach_vm_address_t *object_addr
......@@ -603,7 +603,7 @@ extern
603603#endif /* mig_external */
604604kern_return_t mach_port_kobject_description
605605(
606 ipc_space_inspect_t task,
606 ipc_space_read_t task,
607607 mach_port_name_t name,
608608 natural_t *object_type,
609609 mach_vm_address_t *object_addr,
lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h-6
......@@ -131,12 +131,6 @@ extern kern_return_t _kernelrpc_mach_port_allocate_trap(
131131 mach_port_name_t *name
132132 );
133133
134
135extern kern_return_t _kernelrpc_mach_port_destroy_trap(
136 mach_port_name_t target,
137 mach_port_name_t name
138 );
139
140134extern kern_return_t _kernelrpc_mach_port_deallocate_trap(
141135 mach_port_name_t target,
142136 mach_port_name_t name
lib/libc/include/x86_64-macos-gnu/mach/mach_types.h+31-2
......@@ -117,12 +117,17 @@
117117 */
118118typedef mach_port_t task_t;
119119typedef mach_port_t task_name_t;
120typedef mach_port_t task_policy_set_t;
121typedef mach_port_t task_policy_get_t;
120122typedef mach_port_t task_inspect_t;
123typedef mach_port_t task_read_t;
121124typedef mach_port_t task_suspension_token_t;
122125typedef mach_port_t thread_t;
123126typedef mach_port_t thread_act_t;
124127typedef mach_port_t thread_inspect_t;
128typedef mach_port_t thread_read_t;
125129typedef mach_port_t ipc_space_t;
130typedef mach_port_t ipc_space_read_t;
126131typedef mach_port_t ipc_space_inspect_t;
127132typedef mach_port_t coalition_t;
128133typedef mach_port_t host_t;
......@@ -138,6 +143,8 @@ typedef mach_port_t alarm_t;
138143typedef mach_port_t clock_serv_t;
139144typedef mach_port_t clock_ctrl_t;
140145typedef mach_port_t arcade_register_t;
146typedef mach_port_t ipc_eventlink_t;
147typedef mach_port_t eventlink_port_pair_t[2];
141148typedef mach_port_t suid_cred_t;
142149
143150
......@@ -159,6 +166,7 @@ typedef exception_handler_t *exception_handler_array_t;
159166typedef mach_port_t vm_task_entry_t;
160167typedef mach_port_t io_master_t;
161168typedef mach_port_t UNDServerRef;
169typedef mach_port_t mach_eventlink_t;
162170
163171/*
164172 * Mig doesn't translate the components of an array.
......@@ -212,12 +220,15 @@ typedef uint32_t suid_cred_uid_t;
212220
213221#define TASK_NULL ((task_t) 0)
214222#define TASK_NAME_NULL ((task_name_t) 0)
215#define TASK_INSPECT_NULL ((task_inspect_t) 0)
223#define TASK_INSPECT_NULL ((task_inspect_t) 0)
224#define TASK_READ_NULL ((task_read_t) 0)
216225#define THREAD_NULL ((thread_t) 0)
217226#define THREAD_INSPECT_NULL ((thread_inspect_t) 0)
227#define THREAD_READ_NULL ((thread_read_t) 0)
218228#define TID_NULL ((uint64_t) 0)
219229#define THR_ACT_NULL ((thread_act_t) 0)
220230#define IPC_SPACE_NULL ((ipc_space_t) 0)
231#define IPC_SPACE_READ_NULL ((ipc_space_read_t) 0)
221232#define IPC_SPACE_INSPECT_NULL ((ipc_space_inspect_t) 0)
222233#define COALITION_NULL ((coalition_t) 0)
223234#define HOST_NULL ((host_t) 0)
......@@ -232,7 +243,25 @@ typedef uint32_t suid_cred_uid_t;
232243#define CLOCK_NULL ((clock_t) 0)
233244#define UND_SERVER_NULL ((UNDServerRef) 0)
234245#define ARCADE_REG_NULL ((arcade_register_t) 0)
235#define SUID_CRED_NULL ((suid_cred_t) 0)
246#define MACH_EVENTLINK_NULL ((mach_eventlink_t) 0)
247#define IPC_EVENTLINK_NULL ((ipc_eventlink_t) 0)
248#define SUID_CRED_NULL ((suid_cred_t) 0)
249
250/* capability strictly _DECREASING_.
251 * not ordered the other way around because we want TASK_FLAVOR_CONTROL
252 * to be closest to the itk_lock. see task.h.
253 */
254typedef unsigned int mach_task_flavor_t;
255#define TASK_FLAVOR_CONTROL 0 /* a task_t */
256#define TASK_FLAVOR_READ 1 /* a task_read_t */
257#define TASK_FLAVOR_INSPECT 2 /* a task_inspect_t */
258#define TASK_FLAVOR_NAME 3 /* a task_name_t */
259
260/* capability strictly _DECREASING_ */
261typedef unsigned int mach_thread_flavor_t;
262#define THREAD_FLAVOR_CONTROL 0 /* a thread_t */
263#define THREAD_FLAVOR_READ 1 /* a thread_read_t */
264#define THREAD_FLAVOR_INSPECT 2 /* a thread_inspect_t */
236265
237266/* DEPRECATED */
238267typedef natural_t ledger_item_t;
lib/libc/include/x86_64-macos-gnu/mach/machine.h+18-2
......@@ -118,6 +118,9 @@ typedef integer_t cpu_threadtype_t;
118118#define CPU_TYPE_POWERPC ((cpu_type_t) 18)
119119#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
120120/* skip ((cpu_type_t) 19) */
121/* skip ((cpu_type_t) 20 */
122/* skip ((cpu_type_t) 21 */
123/* skip ((cpu_type_t) 22 */
121124
122125/*
123126 * Machine subtypes (these are defined here, instead of in a machine
......@@ -130,7 +133,14 @@ typedef integer_t cpu_threadtype_t;
130133 */
131134#define CPU_SUBTYPE_MASK 0xff000000 /* mask for feature flags */
132135#define CPU_SUBTYPE_LIB64 0x80000000 /* 64 bit libraries */
136#define CPU_SUBTYPE_PTRAUTH_ABI 0x80000000 /* pointer authentication with versioned ABI */
133137
138/*
139 * When selecting a slice, ANY will pick the slice with the best
140 * grading for the selected cpu_type_t, unlike the "ALL" subtypes,
141 * which are the slices that can run on any hardware for that cpu type.
142 */
143#define CPU_SUBTYPE_ANY ((cpu_subtype_t) -1)
134144
135145/*
136146 * Object files that are hand-crafted to run on any
......@@ -365,9 +375,7 @@ typedef integer_t cpu_threadtype_t;
365375#define CPUFAMILY_INTEL_BROADWELL 0x582ed09c
366376#define CPUFAMILY_INTEL_SKYLAKE 0x37fc219f
367377#define CPUFAMILY_INTEL_KABYLAKE 0x0f817246
368#if !defined(RC_HIDE_XNU_ICELAKE)
369378#define CPUFAMILY_INTEL_ICELAKE 0x38435547
370#endif /* not RC_HIDE_XNU_ICELAKE */
371379#if !defined(RC_HIDE_XNU_COMETLAKE)
372380#define CPUFAMILY_INTEL_COMETLAKE 0x1cf8a03e
373381#endif /* not RC_HIDE_XNU_COMETLAKE */
......@@ -386,6 +394,14 @@ typedef integer_t cpu_threadtype_t;
386394#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
387395#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
388396#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
397#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
398
399#define CPUSUBFAMILY_UNKNOWN 0
400#define CPUSUBFAMILY_ARM_HP 1
401#define CPUSUBFAMILY_ARM_HG 2
402#define CPUSUBFAMILY_ARM_M 3
403#define CPUSUBFAMILY_ARM_HS 4
404#define CPUSUBFAMILY_ARM_HC_HD 5
389405
390406/* The following synonyms are deprecated: */
391407#define CPUFAMILY_INTEL_6_23 CPUFAMILY_INTEL_PENRYN
lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/_structs.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/_structs.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/boolean.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/boolean.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/exception.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/exception.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/kern_return.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/kern_return.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/processor_info.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/processor_info.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/rpc.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/rpc.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/thread_state.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/thread_state.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/thread_status.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/thread_status.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/vm_param.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/vm_param.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h+2
......@@ -31,6 +31,8 @@
3131
3232#if defined (__i386__) || defined(__x86_64__)
3333#include "mach/i386/vm_types.h"
34#elif defined (__arm__) || defined (__arm64__)
35#include "mach/arm/vm_types.h"
3436#else
3537#error architecture not supported
3638#endif
lib/libc/include/x86_64-macos-gnu/mach/message.h+7-1
......@@ -228,6 +228,7 @@ typedef unsigned int mach_msg_priority_t;
228228
229229#define MACH_MSG_PRIORITY_UNSPECIFIED (mach_msg_priority_t) 0
230230
231
231232typedef unsigned int mach_msg_type_name_t;
232233
233234#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */
......@@ -499,6 +500,9 @@ typedef struct{
499500 mach_port_name_t sender;
500501} msg_labels_t;
501502
503typedef int mach_msg_filter_id;
504#define MACH_MSG_FILTER_POLICY_ALLOW (mach_msg_filter_id)0
505
502506/*
503507 * Trailer type to pass MAC policy label info as a mach message trailer.
504508 *
......@@ -511,7 +515,7 @@ typedef struct{
511515 security_token_t msgh_sender;
512516 audit_token_t msgh_audit;
513517 mach_port_context_t msgh_context;
514 int msgh_ad;
518 mach_msg_filter_id msgh_ad;
515519 msg_labels_t msgh_labels;
516520} mach_msg_mac_trailer_t;
517521
......@@ -799,6 +803,8 @@ typedef kern_return_t mach_msg_return_t;
799803/* compatibility: no longer a returned error */
800804#define MACH_SEND_NO_GRANT_DEST 0x10000016
801805/* The destination port doesn't accept ports in body */
806#define MACH_SEND_MSG_FILTERED 0x10000017
807/* Message send was rejected by message filter */
802808
803809#define MACH_RCV_IN_PROGRESS 0x10004001
804810/* Thread is waiting for receive. (Internal use only.) */
lib/libc/include/x86_64-macos-gnu/mach/port.h+8-1
......@@ -339,6 +339,9 @@ typedef struct mach_port_qos {
339339#define MPO_STRICT 0x20 /* Apply strict guarding for port */
340340#define MPO_DENAP_RECEIVER 0x40 /* Mark the port as App de-nap receiver */
341341#define MPO_IMMOVABLE_RECEIVE 0x80 /* Mark the port as immovable; protected by the guard context */
342#define MPO_FILTER_MSG 0x100 /* Allow message filtering */
343#define MPO_TG_BLOCK_TRACKING 0x200 /* Track blocking relationship for thread group during sync IPC */
344
342345/*
343346 * Structure to define optional attributes for a newly
344347 * constructed port.
......@@ -346,7 +349,10 @@ typedef struct mach_port_qos {
346349typedef struct mach_port_options {
347350 uint32_t flags; /* Flags defining attributes for port */
348351 mach_port_limits_t mpl; /* Message queue limit for port */
349 uint64_t reserved[2]; /* Reserved */
352 union {
353 uint64_t reserved[2]; /* Reserved */
354 mach_port_name_t work_interval_port; /* Work interval port */
355 };
350356}mach_port_options_t;
351357
352358typedef mach_port_options_t *mach_port_options_ptr_t;
......@@ -367,6 +373,7 @@ enum mach_port_guard_exception_codes {
367373 kGUARD_EXC_INCORRECT_GUARD = 1u << 4,
368374 kGUARD_EXC_IMMOVABLE = 1u << 5,
369375 kGUARD_EXC_STRICT_REPLY = 1u << 6,
376 kGUARD_EXC_MSG_FILTERED = 1u << 7,
370377 /* start of [optionally] non-fatal guards */
371378 kGUARD_EXC_INVALID_RIGHT = 1u << 8,
372379 kGUARD_EXC_INVALID_NAME = 1u << 9,
lib/libc/include/x86_64-macos-gnu/mach/processor_set.h+47-2
......@@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t;
4949#endif /* AUTOTEST */
5050
5151#ifndef processor_set_MSG_COUNT
52#define processor_set_MSG_COUNT 10
52#define processor_set_MSG_COUNT 11
5353#endif /* processor_set_MSG_COUNT */
5454
5555#include <mach/std_types.h>
......@@ -200,6 +200,20 @@ kern_return_t processor_set_info
200200 mach_msg_type_number_t *info_outCnt
201201);
202202
203/* Routine processor_set_tasks_with_flavor */
204#ifdef mig_external
205mig_external
206#else
207extern
208#endif /* mig_external */
209kern_return_t processor_set_tasks_with_flavor
210(
211 processor_set_t processor_set,
212 mach_task_flavor_t flavor,
213 task_array_t *task_list,
214 mach_msg_type_number_t *task_listCnt
215);
216
203217__END_DECLS
204218
205219/********************** Caution **************************/
......@@ -336,6 +350,18 @@ __END_DECLS
336350#ifdef __MigPackStructs
337351#pragma pack(pop)
338352#endif
353
354#ifdef __MigPackStructs
355#pragma pack(push, 4)
356#endif
357 typedef struct {
358 mach_msg_header_t Head;
359 NDR_record_t NDR;
360 mach_task_flavor_t flavor;
361 } __Request__processor_set_tasks_with_flavor_t __attribute__((unused));
362#ifdef __MigPackStructs
363#pragma pack(pop)
364#endif
339365#endif /* !__Request__processor_set_subsystem__defined */
340366
341367/* union of all requests */
......@@ -353,6 +379,7 @@ union __RequestUnion__processor_set_subsystem {
353379 __Request__processor_set_policy_control_t Request_processor_set_policy_control;
354380 __Request__processor_set_stack_usage_t Request_processor_set_stack_usage;
355381 __Request__processor_set_info_t Request_processor_set_info;
382 __Request__processor_set_tasks_with_flavor_t Request_processor_set_tasks_with_flavor;
356383};
357384#endif /* !__RequestUnion__processor_set_subsystem__defined */
358385/* typedefs for all replies */
......@@ -499,6 +526,22 @@ union __RequestUnion__processor_set_subsystem {
499526#ifdef __MigPackStructs
500527#pragma pack(pop)
501528#endif
529
530#ifdef __MigPackStructs
531#pragma pack(push, 4)
532#endif
533 typedef struct {
534 mach_msg_header_t Head;
535 /* start of the kernel processed data */
536 mach_msg_body_t msgh_body;
537 mach_msg_ool_ports_descriptor_t task_list;
538 /* end of the kernel processed data */
539 NDR_record_t NDR;
540 mach_msg_type_number_t task_listCnt;
541 } __Reply__processor_set_tasks_with_flavor_t __attribute__((unused));
542#ifdef __MigPackStructs
543#pragma pack(pop)
544#endif
502545#endif /* !__Reply__processor_set_subsystem__defined */
503546
504547/* union of all replies */
......@@ -516,6 +559,7 @@ union __ReplyUnion__processor_set_subsystem {
516559 __Reply__processor_set_policy_control_t Reply_processor_set_policy_control;
517560 __Reply__processor_set_stack_usage_t Reply_processor_set_stack_usage;
518561 __Reply__processor_set_info_t Reply_processor_set_info;
562 __Reply__processor_set_tasks_with_flavor_t Reply_processor_set_tasks_with_flavor;
519563};
520564#endif /* !__RequestUnion__processor_set_subsystem__defined */
521565
......@@ -530,7 +574,8 @@ union __ReplyUnion__processor_set_subsystem {
530574 { "processor_set_threads", 4006 },\
531575 { "processor_set_policy_control", 4007 },\
532576 { "processor_set_stack_usage", 4008 },\
533 { "processor_set_info", 4009 }
577 { "processor_set_info", 4009 },\
578 { "processor_set_tasks_with_flavor", 4010 }
534579#endif
535580
536581#ifdef __AfterMigUserHeader
lib/libc/include/x86_64-macos-gnu/mach/task.h+14-14
......@@ -279,7 +279,7 @@ __WATCHOS_PROHIBITED
279279__TVOS_PROHIBITED
280280kern_return_t task_get_exception_ports
281281(
282 task_inspect_t task,
282 task_t task,
283283 exception_mask_t exception_mask,
284284 exception_mask_array_t masks,
285285 mach_msg_type_number_t *masksCnt,
......@@ -372,7 +372,7 @@ __WATCHOS_PROHIBITED
372372__TVOS_PROHIBITED
373373kern_return_t task_policy_set
374374(
375 task_t task,
375 task_policy_set_t task,
376376 task_policy_flavor_t flavor,
377377 task_policy_t policy_info,
378378 mach_msg_type_number_t policy_infoCnt
......@@ -388,7 +388,7 @@ __WATCHOS_PROHIBITED
388388__TVOS_PROHIBITED
389389kern_return_t task_policy_get
390390(
391 task_t task,
391 task_policy_get_t task,
392392 task_policy_flavor_t flavor,
393393 task_policy_t policy_info,
394394 mach_msg_type_number_t *policy_infoCnt,
......@@ -487,7 +487,7 @@ __WATCHOS_PROHIBITED
487487__TVOS_PROHIBITED
488488kern_return_t task_zone_info
489489(
490 task_t target_task,
490 task_inspect_t target_task,
491491 mach_zone_name_array_t *names,
492492 mach_msg_type_number_t *namesCnt,
493493 task_zone_info_array_t *info,
......@@ -527,7 +527,7 @@ extern
527527#endif /* mig_external */
528528kern_return_t task_get_assignment
529529(
530 task_t task,
530 task_inspect_t task,
531531 processor_set_name_t *assigned_set
532532);
533533
......@@ -559,7 +559,7 @@ __WATCHOS_PROHIBITED
559559__TVOS_PROHIBITED
560560kern_return_t task_get_state
561561(
562 task_t task,
562 task_read_t task,
563563 thread_state_flavor_t flavor,
564564 thread_state_t old_state,
565565 mach_msg_type_number_t *old_stateCnt
......@@ -631,7 +631,7 @@ extern
631631#endif /* mig_external */
632632kern_return_t task_purgable_info
633633(
634 task_t task,
634 task_inspect_t task,
635635 task_purgable_info_t *stats
636636);
637637
......@@ -645,7 +645,7 @@ __WATCHOS_PROHIBITED
645645__TVOS_PROHIBITED
646646kern_return_t task_get_mach_voucher
647647(
648 task_t task,
648 task_read_t task,
649649 mach_voucher_selector_t which,
650650 ipc_voucher_t *voucher
651651);
......@@ -700,7 +700,7 @@ extern
700700kern_return_t task_map_corpse_info
701701(
702702 task_t task,
703 task_t corspe_task,
703 task_read_t corspe_task,
704704 vm_address_t *kcd_addr_begin,
705705 uint32_t *kcd_size
706706);
......@@ -739,7 +739,7 @@ extern
739739#endif /* mig_external */
740740kern_return_t task_get_dyld_image_infos
741741(
742 task_inspect_t task,
742 task_read_t task,
743743 dyld_kernel_image_info_array_t *dyld_images,
744744 mach_msg_type_number_t *dyld_imagesCnt
745745);
......@@ -791,7 +791,7 @@ extern
791791kern_return_t task_map_corpse_info_64
792792(
793793 task_t task,
794 task_t corspe_task,
794 task_read_t corspe_task,
795795 mach_vm_address_t *kcd_addr_begin,
796796 mach_vm_size_t *kcd_size
797797);
......@@ -1022,7 +1022,7 @@ __END_DECLS
10221022 NDR_record_t NDR;
10231023 thread_state_flavor_t flavor;
10241024 mach_msg_type_number_t new_stateCnt;
1025 natural_t new_state[614];
1025 natural_t new_state[1296];
10261026 } __Request__thread_create_running_t __attribute__((unused));
10271027#ifdef __MigPackStructs
10281028#pragma pack(pop)
......@@ -1331,7 +1331,7 @@ __END_DECLS
13311331 NDR_record_t NDR;
13321332 thread_state_flavor_t flavor;
13331333 mach_msg_type_number_t new_stateCnt;
1334 natural_t new_state[614];
1334 natural_t new_state[1296];
13351335 } __Request__task_set_state_t __attribute__((unused));
13361336#ifdef __MigPackStructs
13371337#pragma pack(pop)
......@@ -2111,7 +2111,7 @@ union __RequestUnion__task_subsystem {
21112111 NDR_record_t NDR;
21122112 kern_return_t RetCode;
21132113 mach_msg_type_number_t old_stateCnt;
2114 natural_t old_state[614];
2114 natural_t old_state[1296];
21152115 } __Reply__task_get_state_t __attribute__((unused));
21162116#ifdef __MigPackStructs
21172117#pragma pack(pop)
lib/libc/include/x86_64-macos-gnu/mach/task_info.h+47-1
......@@ -112,8 +112,13 @@ typedef struct task_basic_info_32 *task_basic_info_32_t;
112112/* Don't use this, use MACH_TASK_BASIC_INFO instead */
113113struct task_basic_info_64 {
114114 integer_t suspend_count; /* suspend count for task */
115#if defined(__arm__) || defined(__arm64__)
115116 mach_vm_size_t virtual_size; /* virtual memory size (bytes) */
116117 mach_vm_size_t resident_size; /* resident memory size (bytes) */
118#else /* defined(__arm__) || defined(__arm64__) */
119 mach_vm_size_t virtual_size; /* virtual memory size (bytes) */
120 mach_vm_size_t resident_size; /* resident memory size (bytes) */
121#endif /* defined(__arm__) || defined(__arm64__) */
117122 time_value_t user_time; /* total user run time for
118123 * terminated threads */
119124 time_value_t system_time; /* total system run time for
......@@ -123,9 +128,26 @@ struct task_basic_info_64 {
123128typedef struct task_basic_info_64 task_basic_info_64_data_t;
124129typedef struct task_basic_info_64 *task_basic_info_64_t;
125130
131#if defined(__arm__) || defined(__arm64__)
132 #if defined(__arm__) && defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0)
133/*
134 * Note: arm64 can't use the old flavor. If you somehow manage to,
135 * you can cope with the nonsense data yourself.
136 */
137 #define TASK_BASIC_INFO_64 5
138 #define TASK_BASIC_INFO_64_COUNT \
139 (sizeof(task_basic_info_64_data_t) / sizeof(natural_t))
140
141 #else
142
143 #define TASK_BASIC_INFO_64 TASK_BASIC_INFO_64_2
144 #define TASK_BASIC_INFO_64_COUNT TASK_BASIC_INFO_64_2_COUNT
145 #endif
146#else /* defined(__arm__) || defined(__arm64__) */
126147#define TASK_BASIC_INFO_64 5 /* 64-bit capable basic info */
127148#define TASK_BASIC_INFO_64_COUNT \
128149 (sizeof(task_basic_info_64_data_t) / sizeof(natural_t))
150#endif
129151
130152
131153/* localized structure - cannot be safely passed between tasks of differing sizes */
......@@ -249,6 +271,27 @@ typedef struct task_dyld_info *task_dyld_info_t;
249271#define TASK_DYLD_ALL_IMAGE_INFO_32 0 /* format value */
250272#define TASK_DYLD_ALL_IMAGE_INFO_64 1 /* format value */
251273
274#if defined(__arm__) || defined(__arm64__)
275
276/* Don't use this, use MACH_TASK_BASIC_INFO instead */
277/* Compatibility for old 32-bit mach_vm_*_t */
278#define TASK_BASIC_INFO_64_2 18 /* 64-bit capable basic info */
279
280struct task_basic_info_64_2 {
281 integer_t suspend_count; /* suspend count for task */
282 mach_vm_size_t virtual_size; /* virtual memory size (bytes) */
283 mach_vm_size_t resident_size; /* resident memory size (bytes) */
284 time_value_t user_time; /* total user run time for
285 * terminated threads */
286 time_value_t system_time; /* total system run time for
287 * terminated threads */
288 policy_t policy; /* default policy for new threads */
289};
290typedef struct task_basic_info_64_2 task_basic_info_64_2_data_t;
291typedef struct task_basic_info_64_2 *task_basic_info_64_2_t;
292#define TASK_BASIC_INFO_64_2_COUNT \
293 (sizeof(task_basic_info_64_2_data_t) / sizeof(natural_t))
294#endif
252295
253296#define TASK_EXTMOD_INFO 19
254297
......@@ -377,7 +420,7 @@ typedef struct task_vm_info *task_vm_info_t;
377420typedef struct vm_purgeable_info task_purgable_info_t;
378421
379422
380#define TASK_TRACE_MEMORY_INFO 24
423#define TASK_TRACE_MEMORY_INFO 24 /* no longer supported */
381424struct task_trace_memory_info {
382425 uint64_t user_memory_address; /* address of start of trace memory buffer */
383426 uint64_t buffer_size; /* size of buffer in bytes */
......@@ -412,6 +455,9 @@ typedef gpu_energy_data *gpu_energy_data_t;
412455struct task_power_info_v2 {
413456 task_power_info_data_t cpu_energy;
414457 gpu_energy_data gpu_energy;
458#if defined(__arm__) || defined(__arm64__)
459 uint64_t task_energy;
460#endif /* defined(__arm__) || defined(__arm64__) */
415461 uint64_t task_ptime;
416462 uint64_t task_pset_switches;
417463};
lib/libc/include/x86_64-macos-gnu/mach/task_policy.h+2-5
......@@ -110,8 +110,7 @@ typedef integer_t *task_policy_t;
110110#define TASK_BASE_LATENCY_QOS_POLICY 10
111111#define TASK_BASE_THROUGHPUT_QOS_POLICY 11
112112
113
114enum task_role {
113typedef enum task_role {
115114 TASK_RENICED = -1,
116115 TASK_UNSPECIFIED = 0,
117116 TASK_FOREGROUND_APPLICATION = 1,
......@@ -122,9 +121,7 @@ enum task_role {
122121 TASK_NONUI_APPLICATION = 6,
123122 TASK_DEFAULT_APPLICATION = 7,
124123 TASK_DARWINBG_APPLICATION = 8,
125};
126
127typedef integer_t task_role_t;
124} task_role_t;
128125
129126struct task_category_policy {
130127 task_role_t role;
lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h+7-6
......@@ -69,18 +69,19 @@
6969
7070typedef int task_special_port_t;
7171
72#define TASK_KERNEL_PORT 1 /* Represents task to the outside
73 * world.*/
72#define TASK_KERNEL_PORT 1 /* The full task port for task. */
7473
7574#define TASK_HOST_PORT 2 /* The host (priv) port for task. */
7675
77#define TASK_NAME_PORT 3 /* the name (unpriv) port for task */
76#define TASK_NAME_PORT 3 /* The name port for task. */
7877
7978#define TASK_BOOTSTRAP_PORT 4 /* Bootstrap environment for task. */
8079
81/*
82 * Evolving and likely to change.
83 */
80#define TASK_INSPECT_PORT 5 /* The inspect port for task. */
81
82#define TASK_READ_PORT 6 /* The read port for task. */
83
84
8485
8586#define TASK_SEATBELT_PORT 7 /* Seatbelt compiler/DEM port for task. */
8687
lib/libc/include/x86_64-macos-gnu/mach/thread_act.h+62-12
......@@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t;
4949#endif /* AUTOTEST */
5050
5151#ifndef thread_act_MSG_COUNT
52#define thread_act_MSG_COUNT 28
52#define thread_act_MSG_COUNT 29
5353#endif /* thread_act_MSG_COUNT */
5454
5555#include <mach/std_types.h>
......@@ -88,7 +88,7 @@ __WATCHOS_PROHIBITED
8888__TVOS_PROHIBITED
8989kern_return_t act_get_state
9090(
91 thread_act_t target_act,
91 thread_read_t target_act,
9292 int flavor,
9393 thread_state_t old_state,
9494 mach_msg_type_number_t *old_stateCnt
......@@ -119,7 +119,7 @@ extern
119119__WATCHOS_PROHIBITED
120120kern_return_t thread_get_state
121121(
122 thread_act_t target_act,
122 thread_read_t target_act,
123123 thread_state_flavor_t flavor,
124124 thread_state_t old_state,
125125 mach_msg_type_number_t *old_stateCnt
......@@ -211,7 +211,7 @@ __WATCHOS_PROHIBITED
211211__TVOS_PROHIBITED
212212kern_return_t thread_get_special_port
213213(
214 thread_act_t thr_act,
214 thread_inspect_t thr_act,
215215 int which_port,
216216 mach_port_t *special_port
217217);
......@@ -272,7 +272,7 @@ __WATCHOS_PROHIBITED
272272__TVOS_PROHIBITED
273273kern_return_t thread_get_exception_ports
274274(
275 thread_inspect_t thread,
275 thread_act_t thread,
276276 exception_mask_t exception_mask,
277277 exception_mask_array_t masks,
278278 mach_msg_type_number_t *masksCnt,
......@@ -402,7 +402,7 @@ extern
402402#endif /* mig_external */
403403kern_return_t thread_get_assignment
404404(
405 thread_act_t thread,
405 thread_inspect_t thread,
406406 processor_set_name_t *assigned_set
407407);
408408
......@@ -433,7 +433,7 @@ __WATCHOS_PROHIBITED
433433__TVOS_PROHIBITED
434434kern_return_t thread_get_mach_voucher
435435(
436 thread_act_t thr_act,
436 thread_read_t thr_act,
437437 mach_voucher_selector_t which,
438438 ipc_voucher_t *voucher
439439);
......@@ -467,6 +467,23 @@ kern_return_t thread_swap_mach_voucher
467467 ipc_voucher_t *old_voucher
468468);
469469
470/* Routine thread_convert_thread_state */
471#ifdef mig_external
472mig_external
473#else
474extern
475#endif /* mig_external */
476kern_return_t thread_convert_thread_state
477(
478 thread_act_t thread,
479 int direction,
480 thread_state_flavor_t flavor,
481 thread_state_t in_state,
482 mach_msg_type_number_t in_stateCnt,
483 thread_state_t out_state,
484 mach_msg_type_number_t *out_stateCnt
485);
486
470487__END_DECLS
471488
472489/********************** Caution **************************/
......@@ -516,7 +533,7 @@ __END_DECLS
516533 NDR_record_t NDR;
517534 int flavor;
518535 mach_msg_type_number_t new_stateCnt;
519 natural_t new_state[614];
536 natural_t new_state[1296];
520537 } __Request__act_set_state_t __attribute__((unused));
521538#ifdef __MigPackStructs
522539#pragma pack(pop)
......@@ -543,7 +560,7 @@ __END_DECLS
543560 NDR_record_t NDR;
544561 thread_state_flavor_t flavor;
545562 mach_msg_type_number_t new_stateCnt;
546 natural_t new_state[614];
563 natural_t new_state[1296];
547564 } __Request__thread_set_state_t __attribute__((unused));
548565#ifdef __MigPackStructs
549566#pragma pack(pop)
......@@ -851,6 +868,22 @@ __END_DECLS
851868#ifdef __MigPackStructs
852869#pragma pack(pop)
853870#endif
871
872#ifdef __MigPackStructs
873#pragma pack(push, 4)
874#endif
875 typedef struct {
876 mach_msg_header_t Head;
877 NDR_record_t NDR;
878 int direction;
879 thread_state_flavor_t flavor;
880 mach_msg_type_number_t in_stateCnt;
881 natural_t in_state[1296];
882 mach_msg_type_number_t out_stateCnt;
883 } __Request__thread_convert_thread_state_t __attribute__((unused));
884#ifdef __MigPackStructs
885#pragma pack(pop)
886#endif
854887#endif /* !__Request__thread_act_subsystem__defined */
855888
856889/* union of all requests */
......@@ -886,6 +919,7 @@ union __RequestUnion__thread_act_subsystem {
886919 __Request__thread_get_mach_voucher_t Request_thread_get_mach_voucher;
887920 __Request__thread_set_mach_voucher_t Request_thread_set_mach_voucher;
888921 __Request__thread_swap_mach_voucher_t Request_thread_swap_mach_voucher;
922 __Request__thread_convert_thread_state_t Request_thread_convert_thread_state;
889923};
890924#endif /* !__RequestUnion__thread_act_subsystem__defined */
891925/* typedefs for all replies */
......@@ -913,7 +947,7 @@ union __RequestUnion__thread_act_subsystem {
913947 NDR_record_t NDR;
914948 kern_return_t RetCode;
915949 mach_msg_type_number_t old_stateCnt;
916 natural_t old_state[614];
950 natural_t old_state[1296];
917951 } __Reply__act_get_state_t __attribute__((unused));
918952#ifdef __MigPackStructs
919953#pragma pack(pop)
......@@ -939,7 +973,7 @@ union __RequestUnion__thread_act_subsystem {
939973 NDR_record_t NDR;
940974 kern_return_t RetCode;
941975 mach_msg_type_number_t old_stateCnt;
942 natural_t old_state[614];
976 natural_t old_state[1296];
943977 } __Reply__thread_get_state_t __attribute__((unused));
944978#ifdef __MigPackStructs
945979#pragma pack(pop)
......@@ -1259,6 +1293,20 @@ union __RequestUnion__thread_act_subsystem {
12591293#ifdef __MigPackStructs
12601294#pragma pack(pop)
12611295#endif
1296
1297#ifdef __MigPackStructs
1298#pragma pack(push, 4)
1299#endif
1300 typedef struct {
1301 mach_msg_header_t Head;
1302 NDR_record_t NDR;
1303 kern_return_t RetCode;
1304 mach_msg_type_number_t out_stateCnt;
1305 natural_t out_state[1296];
1306 } __Reply__thread_convert_thread_state_t __attribute__((unused));
1307#ifdef __MigPackStructs
1308#pragma pack(pop)
1309#endif
12621310#endif /* !__Reply__thread_act_subsystem__defined */
12631311
12641312/* union of all replies */
......@@ -1294,6 +1342,7 @@ union __ReplyUnion__thread_act_subsystem {
12941342 __Reply__thread_get_mach_voucher_t Reply_thread_get_mach_voucher;
12951343 __Reply__thread_set_mach_voucher_t Reply_thread_set_mach_voucher;
12961344 __Reply__thread_swap_mach_voucher_t Reply_thread_swap_mach_voucher;
1345 __Reply__thread_convert_thread_state_t Reply_thread_convert_thread_state;
12971346};
12981347#endif /* !__RequestUnion__thread_act_subsystem__defined */
12991348
......@@ -1326,7 +1375,8 @@ union __ReplyUnion__thread_act_subsystem {
13261375 { "thread_set_policy", 3624 },\
13271376 { "thread_get_mach_voucher", 3625 },\
13281377 { "thread_set_mach_voucher", 3626 },\
1329 { "thread_swap_mach_voucher", 3627 }
1378 { "thread_swap_mach_voucher", 3627 },\
1379 { "thread_convert_thread_state", 3628 }
13301380#endif
13311381
13321382#ifdef __AfterMigUserHeader
lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h+5-2
......@@ -67,8 +67,11 @@
6767#ifndef _MACH_THREAD_SPECIAL_PORTS_H_
6868#define _MACH_THREAD_SPECIAL_PORTS_H_
6969
70#define THREAD_KERNEL_PORT 1 /* Represents the thread to the outside
71 * world.*/
70#define THREAD_KERNEL_PORT 1 /* The full thread port for thread. */
71
72#define THREAD_INSPECT_PORT 2 /* The inspect port for thread. */
73
74#define THREAD_READ_PORT 3 /* The read port for thread. */
7275
7376/*
7477 * Definitions for ease of use
lib/libc/include/x86_64-macos-gnu/mach/thread_status.h+3
......@@ -94,4 +94,7 @@ typedef natural_t thread_state_data_t[THREAD_STATE_MAX];
9494typedef int thread_state_flavor_t;
9595typedef thread_state_flavor_t *thread_state_flavor_array_t;
9696
97#define THREAD_CONVERT_THREAD_STATE_TO_SELF 1
98#define THREAD_CONVERT_THREAD_STATE_FROM_SELF 2
99
97100#endif /* _MACH_THREAD_STATUS_H_ */
lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h+1
......@@ -149,4 +149,5 @@ typedef int vm_prot_t;
149149#define VM_PROT_STRIP_READ ((vm_prot_t) 0x80)
150150#define VM_PROT_EXECUTE_ONLY (VM_PROT_EXECUTE|VM_PROT_STRIP_READ)
151151
152
152153#endif /* _MACH_VM_PROT_H_ */
lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h+29-2
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
2 * Copyright (c) 2000-2020 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55 *
......@@ -66,8 +66,12 @@
6666#ifndef _MACH_VM_STATISTICS_H_
6767#define _MACH_VM_STATISTICS_H_
6868
69#include <mach/machine/vm_types.h>
69#ifdef __cplusplus
70extern "C" {
71#endif
7072
73#include <mach/machine/vm_types.h>
74#include <mach/machine/kern_return.h>
7175
7276/*
7377 * vm_statistics
......@@ -167,6 +171,8 @@ struct vm_statistics64 {
167171typedef struct vm_statistics64 *vm_statistics64_t;
168172typedef struct vm_statistics64 vm_statistics64_data_t;
169173
174kern_return_t vm_stats(void *info, unsigned int *count);
175
170176/*
171177 * VM_STATISTICS_TRUNCATE_TO_32_BIT
172178 *
......@@ -352,6 +358,7 @@ enum virtual_memory_guard_exception_codes {
352358
353359#define VM_MEMORY_MALLOC_NANO 11
354360#define VM_MEMORY_MALLOC_MEDIUM 12
361#define VM_MEMORY_MALLOC_PGUARD 13
355362
356363#define VM_MEMORY_MACH_MSG 20
357364#define VM_MEMORY_IOKIT 21
......@@ -512,6 +519,22 @@ enum virtual_memory_guard_exception_codes {
512519/* memory allocated by CoreMedia for global image registration of frames */
513520#define VM_MEMORY_CM_REGWARP 101
514521
522/* memory allocated by EmbeddedAcousticRecognition for speech decoder */
523#define VM_MEMORY_EAR_DECODER 102
524
525/* CoreUI cached image data */
526#define VM_MEMORY_COREUI_CACHED_IMAGE_DATA 103
527
528/* Reserve 230-239 for Rosetta */
529#define VM_MEMORY_ROSETTA 230
530#define VM_MEMORY_ROSETTA_THREAD_CONTEXT 231
531#define VM_MEMORY_ROSETTA_INDIRECT_BRANCH_MAP 232
532#define VM_MEMORY_ROSETTA_RETURN_STACK 233
533#define VM_MEMORY_ROSETTA_EXECUTABLE_HEAP 234
534#define VM_MEMORY_ROSETTA_USER_LDT 235
535#define VM_MEMORY_ROSETTA_ARENA 236
536#define VM_MEMORY_ROSETTA_10 239
537
515538/* Reserve 240-255 for application */
516539#define VM_MEMORY_APPLICATION_SPECIFIC_1 240
517540#define VM_MEMORY_APPLICATION_SPECIFIC_16 255
......@@ -520,4 +543,8 @@ enum virtual_memory_guard_exception_codes {
520543
521544
522545
546#ifdef __cplusplus
547}
548#endif
549
523550#endif /* _MACH_VM_STATISTICS_H_ */
lib/libc/include/x86_64-macos-gnu/mach/vm_types.h+3-1
......@@ -70,10 +70,12 @@ typedef uint32_t ppnum_t; /* Physical page number */
7070
7171
7272
73typedef mach_port_t vm_map_t;
73typedef mach_port_t vm_map_t, vm_map_read_t, vm_map_inspect_t;
7474
7575
7676#define VM_MAP_NULL ((vm_map_t) 0)
77#define VM_MAP_INSPECT_NULL ((vm_map_inspect_t) 0)
78#define VM_MAP_READ_NULL ((vm_map_read_t) 0)
7779
7880/*
7981 * Evolving definitions, likely to change.
lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h+2
......@@ -27,6 +27,8 @@
2727 */
2828#if defined (__i386__) || defined (__x86_64__)
2929#include "i386/_mcontext.h"
30#elif defined (__arm__) || defined (__arm64__)
31#include "arm/_mcontext.h"
3032#else
3133#error architecture not supported
3234#endif
lib/libc/include/x86_64-macos-gnu/machine/_param.h+3-1
......@@ -26,7 +26,9 @@
2626 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727 */
2828#if defined (__i386__) || defined (__x86_64__)
29#include "i386/_param.h"
29#include <i386/_param.h>
30#elif defined (__arm__) || defined (__arm64__)
31#include <arm/_param.h>
3032#else
3133#error architecture not supported
3234#endif
lib/libc/include/x86_64-macos-gnu/machine/_types.h+2
......@@ -30,6 +30,8 @@
3030
3131#if defined (__i386__) || defined(__x86_64__)
3232#include "i386/_types.h"
33#elif defined (__arm__) || defined (__arm64__)
34#include "arm/_types.h"
3335#else
3436#error architecture not supported
3537#endif
lib/libc/include/x86_64-macos-gnu/machine/endian.h+2
......@@ -33,6 +33,8 @@
3333
3434#if defined (__i386__) || defined(__x86_64__)
3535#include "i386/endian.h"
36#elif defined (__arm__) || defined (__arm64__)
37#include "arm/endian.h"
3638#else
3739#error architecture not supported
3840#endif
lib/libc/include/x86_64-macos-gnu/machine/limits.h+2
......@@ -4,6 +4,8 @@
44 * This file is public domain. */
55#if defined (__i386__) || defined(__x86_64__)
66#include <i386/limits.h>
7#elif defined (__arm__) || defined (__arm64__)
8#include <arm/limits.h>
79#else
810#error architecture not supported
911#endif
lib/libc/include/x86_64-macos-gnu/machine/param.h+3-1
......@@ -32,7 +32,9 @@
3232#define _BSD_MACHINE_PARAM_H_
3333
3434#if defined (__i386__) || defined(__x86_64__)
35#include "i386/param.h"
35#include <i386/param.h>
36#elif defined (__arm__) || defined (__arm64__)
37#include <arm/param.h>
3638#else
3739#error architecture not supported
3840#endif
lib/libc/include/x86_64-macos-gnu/machine/signal.h+2
......@@ -30,6 +30,8 @@
3030
3131#if defined (__i386__) || defined(__x86_64__)
3232#include "i386/signal.h"
33#elif defined (__arm__) || defined (__arm64__)
34#include "arm/signal.h"
3335#else
3436#error architecture not supported
3537#endif
lib/libc/include/x86_64-macos-gnu/machine/types.h+2
......@@ -33,6 +33,8 @@
3333
3434#if defined (__i386__) || defined(__x86_64__)
3535#include "i386/types.h"
36#elif defined (__arm__) || defined (__arm64__)
37#include "arm/types.h"
3638#else
3739#error architecture not supported
3840#endif
lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h+3-3
......@@ -44,9 +44,9 @@ void *realloc(void *__ptr, size_t __size) __result_use_check __alloc_size(2);
4444#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
4545void *valloc(size_t) __alloc_size(1);
4646#endif // !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
47#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) && \
48 ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
49 (defined(__cplusplus) && __cplusplus >= 201703L))
47#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \
48 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
49 (defined(__cplusplus) && __cplusplus >= 201703L)
5050void *aligned_alloc(size_t __alignment, size_t __size) __result_use_check __alloc_size(2) __OSX_AVAILABLE(10.15) __IOS_AVAILABLE(13.0) __TVOS_AVAILABLE(13.0) __WATCHOS_AVAILABLE(6.0);
5151#endif
5252int posix_memalign(void **__memptr, size_t __alignment, size_t __size) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);
lib/libc/include/x86_64-macos-gnu/math.h+4
......@@ -547,6 +547,7 @@ extern long double fmal(long double, long double, long double);
547547#define islessgreater(x, y) __builtin_islessgreater((x),(y))
548548#define isunordered(x, y) __builtin_isunordered((x),(y))
549549
550#if defined __i386__ || defined __x86_64__
550551/* Deprecated functions; use the INFINITY and NAN macros instead. */
551552extern float __inff(void)
552553__API_DEPRECATED("use `(float)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
......@@ -556,6 +557,7 @@ extern long double __infl(void)
556557__API_DEPRECATED("use `(long double)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
557558extern float __nan(void)
558559__API_DEPRECATED("use `NAN` instead", macos(10.0, 10.14)) __API_UNAVAILABLE(ios, watchos, tvos);
560#endif
559561
560562/******************************************************************************
561563 * Reentrant variants of lgamma[fl] *
......@@ -736,6 +738,7 @@ extern int signgam;
736738#define TLOSS 5
737739#define PLOSS 6
738740
741#if defined __i386__ || defined __x86_64__
739742/* Legacy BSD API; use the C99 `lrint( )` function instead. */
740743extern long int rinttol(double)
741744__API_DEPRECATED_WITH_REPLACEMENT("lrint", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
......@@ -754,6 +757,7 @@ __API_DEPRECATED_WITH_REPLACEMENT("tgamma", macos(10.0, 10.9)) __API_UNAVAILABLE
754757/* Legacy BSD API; use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead. */
755758extern double significand(double)
756759__API_DEPRECATED("Use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead.", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
760#endif
757761
758762#if !defined __cplusplus
759763struct exception {
lib/libc/include/x86_64-macos-gnu/net/if.h+1-1
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
2 * Copyright (c) 2000-2020 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55 *
lib/libc/include/x86_64-macos-gnu/net/if_var.h+2-1
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
2 * Copyright (c) 2000-2020 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55 *
......@@ -70,6 +70,7 @@
7070#include <sys/time.h>
7171#include <sys/queue.h> /* get TAILQ macros */
7272#ifdef BSD_KERN_PRIVATE
73#include <net/pktsched/pktsched.h>
7374#include <sys/eventhandler.h>
7475#endif
7576
lib/libc/include/x86_64-macos-gnu/netinet/in.h+3-2
......@@ -63,14 +63,14 @@
6363
6464#ifndef _NETINET_IN_H_
6565#define _NETINET_IN_H_
66
6667#include <sys/appleapiopts.h>
67#include <sys/_types.h>
6868#include <stdint.h> /* uint(8|16|32)_t */
6969
7070#include <Availability.h>
7171
72#include <sys/_types/_in_addr_t.h>
7372
73#include <sys/_types/_in_addr_t.h>
7474#include <sys/_types/_in_port_t.h>
7575
7676/*
......@@ -435,6 +435,7 @@ struct ip_opts {
435435#define IP_PKTINFO 26 /* get pktinfo on recv socket, set src on sent dgram */
436436#define IP_RECVPKTINFO IP_PKTINFO /* receive pktinfo w/dgram */
437437#define IP_RECVTOS 27 /* bool; receive IP TOS w/dgram */
438#define IP_DONTFRAG 28 /* don't fragment packet */
438439
439440#define IP_FW_ADD 40 /* add a firewall rule to chain */
440441#define IP_FW_DEL 41 /* delete a firewall rule from chain */
lib/libc/include/x86_64-macos-gnu/netinet/tcp.h+3-1
......@@ -63,11 +63,13 @@
6363
6464#ifndef _NETINET_TCP_H_
6565#define _NETINET_TCP_H_
66#include <sys/types.h>
6766#include <sys/appleapiopts.h>
67
6868#include <machine/endian.h>
6969#include <machine/types.h> /* __uint32_t */
7070
71#include <sys/types.h>
72
7173#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
7274typedef __uint32_t tcp_seq;
7375typedef __uint32_t tcp_cc; /* connection count per rfc1644 */
lib/libc/include/x86_64-macos-gnu/netinet6/in6.h+21-7
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
2 * Copyright (c) 2008-2020 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55 *
......@@ -98,6 +98,7 @@
9898#ifndef _NETINET6_IN6_H_
9999#define _NETINET6_IN6_H_
100100#include <sys/appleapiopts.h>
101
101102#include <sys/_types.h>
102103#include <sys/_types/_sa_family_t.h>
103104
......@@ -178,6 +179,7 @@ struct sockaddr_in6 {
178179
179180
180181
182
181183/*
182184 * Definition of some useful macros to handle IP6 addresses
183185 */
......@@ -206,6 +208,7 @@ struct sockaddr_in6 {
206208#define IN6ADDR_V4MAPPED_INIT \
207209 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
208210 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
211#define IN6ADDR_MULTICAST_PREFIX IN6MASK8
209212#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
210213
211214extern const struct in6_addr in6addr_any;
......@@ -297,6 +300,16 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
297300 */
298301#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
299302
303#define IPV6_ADDR_MC_FLAGS(a) ((a)->s6_addr[1] & 0xf0)
304
305#define IPV6_ADDR_MC_FLAGS_TRANSIENT 0x10
306#define IPV6_ADDR_MC_FLAGS_PREFIX 0x20
307#define IPV6_ADDR_MC_FLAGS_UNICAST_BASED (IPV6_ADDR_MC_FLAGS_TRANSIENT | IPV6_ADDR_MC_FLAGS_PREFIX)
308
309#define IN6_IS_ADDR_UNICAST_BASED_MULTICAST(a) \
310 (IN6_IS_ADDR_MULTICAST(a) && \
311 (IPV6_ADDR_MC_FLAGS(a) == IPV6_ADDR_MC_FLAGS_UNICAST_BASED))
312
300313/*
301314 * Unique Local IPv6 Unicast Addresses (per RFC 4193)
302315 */
......@@ -311,8 +324,9 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
311324#define IN6_IS_ADDR_MC_NODELOCAL(a) \
312325 (IN6_IS_ADDR_MULTICAST(a) && \
313326 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
314#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
315 (IN6_IS_ADDR_MULTICAST(a) && \
327#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
328 (IN6_IS_ADDR_MULTICAST(a) && \
329 (IPV6_ADDR_MC_FLAGS(a) != IPV6_ADDR_MC_FLAGS_UNICAST_BASED) && \
316330 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
317331#define IN6_IS_ADDR_MC_SITELOCAL(a) \
318332 (IN6_IS_ADDR_MULTICAST(a) && \
......@@ -369,9 +383,9 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
369383#define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */
370384#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
371385#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
372#define IPV6_MULTICAST_IF 9 /* __uint8_t; set/get IP6 multicast i/f */
373#define IPV6_MULTICAST_HOPS 10 /* __uint8_t; set/get IP6 multicast hops */
374#define IPV6_MULTICAST_LOOP 11 /* __uint8_t; set/get IP6 mcast loopback */
386#define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */
387#define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */
388#define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 mcast loopback */
375389#define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */
376390#define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */
377391
......@@ -663,5 +677,5 @@ extern int inet6_rth_segments(const void *);
663677extern struct in6_addr *inet6_rth_getaddr(const void *, int);
664678
665679__END_DECLS
666#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
680#endif /* PLATFORM_DriverKit */
667681#endif /* !_NETINET6_IN6_H_ */
lib/libc/include/x86_64-macos-gnu/objc/NSObjCRuntime.h created+33
......@@ -0,0 +1,33 @@
1/* NSObjCRuntime.h
2 Copyright (c) 1994-2012, Apple Inc. All rights reserved.
3*/
4
5#ifndef _OBJC_NSOBJCRUNTIME_H_
6#define _OBJC_NSOBJCRUNTIME_H_
7
8#include <TargetConditionals.h>
9#include <objc/objc.h>
10
11#if __LP64__ || 0 || NS_BUILD_32_LIKE_64
12typedef long NSInteger;
13typedef unsigned long NSUInteger;
14#else
15typedef int NSInteger;
16typedef unsigned int NSUInteger;
17#endif
18
19#define NSIntegerMax LONG_MAX
20#define NSIntegerMin LONG_MIN
21#define NSUIntegerMax ULONG_MAX
22
23#define NSINTEGER_DEFINED 1
24
25#ifndef NS_DESIGNATED_INITIALIZER
26#if __has_attribute(objc_designated_initializer)
27#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
28#else
29#define NS_DESIGNATED_INITIALIZER
30#endif
31#endif
32
33#endif
lib/libc/include/x86_64-macos-gnu/objc/NSObject.h created+112
......@@ -0,0 +1,112 @@
1/* NSObject.h
2 Copyright (c) 1994-2012, Apple Inc. All rights reserved.
3*/
4
5#ifndef _OBJC_NSOBJECT_H_
6#define _OBJC_NSOBJECT_H_
7
8#if __OBJC__
9
10#include <objc/objc.h>
11#include <objc/NSObjCRuntime.h>
12
13@class NSString, NSMethodSignature, NSInvocation;
14
15@protocol NSObject
16
17- (BOOL)isEqual:(id)object;
18@property (readonly) NSUInteger hash;
19
20@property (readonly) Class superclass;
21- (Class)class OBJC_SWIFT_UNAVAILABLE("use 'type(of: anObject)' instead");
22- (instancetype)self;
23
24- (id)performSelector:(SEL)aSelector;
25- (id)performSelector:(SEL)aSelector withObject:(id)object;
26- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
27
28- (BOOL)isProxy;
29
30- (BOOL)isKindOfClass:(Class)aClass;
31- (BOOL)isMemberOfClass:(Class)aClass;
32- (BOOL)conformsToProtocol:(Protocol *)aProtocol;
33
34- (BOOL)respondsToSelector:(SEL)aSelector;
35
36- (instancetype)retain OBJC_ARC_UNAVAILABLE;
37- (oneway void)release OBJC_ARC_UNAVAILABLE;
38- (instancetype)autorelease OBJC_ARC_UNAVAILABLE;
39- (NSUInteger)retainCount OBJC_ARC_UNAVAILABLE;
40
41- (struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
42
43@property (readonly, copy) NSString *description;
44@optional
45@property (readonly, copy) NSString *debugDescription;
46
47@end
48
49
50OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0)
51OBJC_ROOT_CLASS
52OBJC_EXPORT
53@interface NSObject <NSObject> {
54#pragma clang diagnostic push
55#pragma clang diagnostic ignored "-Wobjc-interface-ivars"
56 Class isa OBJC_ISA_AVAILABILITY;
57#pragma clang diagnostic pop
58}
59
60+ (void)load;
61
62+ (void)initialize;
63- (instancetype)init
64#if NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER
65 NS_DESIGNATED_INITIALIZER
66#endif
67 ;
68
69+ (instancetype)new OBJC_SWIFT_UNAVAILABLE("use object initializers instead");
70+ (instancetype)allocWithZone:(struct _NSZone *)zone OBJC_SWIFT_UNAVAILABLE("use object initializers instead");
71+ (instancetype)alloc OBJC_SWIFT_UNAVAILABLE("use object initializers instead");
72- (void)dealloc OBJC_SWIFT_UNAVAILABLE("use 'deinit' to define a de-initializer");
73
74- (void)finalize OBJC_DEPRECATED("Objective-C garbage collection is no longer supported");
75
76- (id)copy;
77- (id)mutableCopy;
78
79+ (id)copyWithZone:(struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
80+ (id)mutableCopyWithZone:(struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
81
82+ (BOOL)instancesRespondToSelector:(SEL)aSelector;
83+ (BOOL)conformsToProtocol:(Protocol *)protocol;
84- (IMP)methodForSelector:(SEL)aSelector;
85+ (IMP)instanceMethodForSelector:(SEL)aSelector;
86- (void)doesNotRecognizeSelector:(SEL)aSelector;
87
88- (id)forwardingTargetForSelector:(SEL)aSelector OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
89- (void)forwardInvocation:(NSInvocation *)anInvocation OBJC_SWIFT_UNAVAILABLE("");
90- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector OBJC_SWIFT_UNAVAILABLE("");
91
92+ (NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)aSelector OBJC_SWIFT_UNAVAILABLE("");
93
94- (BOOL)allowsWeakReference UNAVAILABLE_ATTRIBUTE;
95- (BOOL)retainWeakReference UNAVAILABLE_ATTRIBUTE;
96
97+ (BOOL)isSubclassOfClass:(Class)aClass;
98
99+ (BOOL)resolveClassMethod:(SEL)sel OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
100+ (BOOL)resolveInstanceMethod:(SEL)sel OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
101
102+ (NSUInteger)hash;
103+ (Class)superclass;
104+ (Class)class OBJC_SWIFT_UNAVAILABLE("use 'aClass.self' instead");
105+ (NSString *)description;
106+ (NSString *)debugDescription;
107
108@end
109
110#endif
111
112#endif
lib/libc/include/x86_64-macos-gnu/objc/objc-api.h created+286
......@@ -0,0 +1,286 @@
1/*
2 * Copyright (c) 1999-2006 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23// Copyright 1988-1996 NeXT Software, Inc.
24
25#ifndef _OBJC_OBJC_API_H_
26#define _OBJC_OBJC_API_H_
27
28#include <Availability.h>
29#include <AvailabilityMacros.h>
30#include <TargetConditionals.h>
31#include <sys/types.h>
32
33#ifndef __has_feature
34# define __has_feature(x) 0
35#endif
36
37#ifndef __has_extension
38# define __has_extension __has_feature
39#endif
40
41#ifndef __has_attribute
42# define __has_attribute(x) 0
43#endif
44
45#if !__has_feature(nullability)
46# ifndef _Nullable
47# define _Nullable
48# endif
49# ifndef _Nonnull
50# define _Nonnull
51# endif
52# ifndef _Null_unspecified
53# define _Null_unspecified
54# endif
55#endif
56
57
58
59/*
60 * OBJC_API_VERSION 0 or undef: Tiger and earlier API only
61 * OBJC_API_VERSION 2: Leopard and later API available
62 */
63#if !defined(OBJC_API_VERSION)
64# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5
65# define OBJC_API_VERSION 0
66# else
67# define OBJC_API_VERSION 2
68# endif
69#endif
70
71
72/*
73 * OBJC_NO_GC 1: GC is not supported
74 * OBJC_NO_GC undef: GC is supported. This SDK no longer supports this mode.
75 *
76 * OBJC_NO_GC_API undef: Libraries must export any symbols that
77 * dual-mode code may links to.
78 * OBJC_NO_GC_API 1: Libraries need not export GC-related symbols.
79 */
80#if defined(__OBJC_GC__)
81# error Objective-C garbage collection is not supported.
82#elif TARGET_OS_OSX
83 /* GC is unsupported. GC API symbols are exported. */
84# define OBJC_NO_GC 1
85# undef OBJC_NO_GC_API
86#else
87 /* GC is unsupported. GC API symbols are not exported. */
88# define OBJC_NO_GC 1
89# define OBJC_NO_GC_API 1
90#endif
91
92
93/* NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER == 1
94 * marks -[NSObject init] as a designated initializer. */
95#if !defined(NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER)
96# define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1
97#endif
98
99/* The arm64 ABI requires proper casting to ensure arguments are passed
100 * * correctly. */
101#if defined(__arm64__) && !__swift__
102# undef OBJC_OLD_DISPATCH_PROTOTYPES
103# define OBJC_OLD_DISPATCH_PROTOTYPES 0
104#endif
105
106/* OBJC_OLD_DISPATCH_PROTOTYPES == 0 enforces the rule that the dispatch
107 * functions must be cast to an appropriate function pointer type. */
108#if !defined(OBJC_OLD_DISPATCH_PROTOTYPES)
109# if __swift__
110 // Existing Swift code expects IMP to be Comparable.
111 // Variadic IMP is comparable via OpaquePointer; non-variadic IMP isn't.
112# define OBJC_OLD_DISPATCH_PROTOTYPES 1
113# else
114# define OBJC_OLD_DISPATCH_PROTOTYPES 0
115# endif
116#endif
117
118
119/* OBJC_AVAILABLE: shorthand for all-OS availability */
120
121# if !defined(OBJC_AVAILABLE)
122# define OBJC_AVAILABLE(x, i, t, w, b) \
123 __OSX_AVAILABLE(x) __IOS_AVAILABLE(i) __TVOS_AVAILABLE(t) \
124 __WATCHOS_AVAILABLE(w)
125# endif
126
127
128
129/* OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE: Deprecated on OS X,
130 * unavailable everywhere else. */
131
132# if !defined(OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE)
133# define OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(_start, _dep, _msg) \
134 __OSX_DEPRECATED(_start, _dep, _msg) \
135 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \
136 __WATCHOS_UNAVAILABLE
137# endif
138
139
140
141/* OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE: Available on OS X,
142 * unavailable everywhere else. */
143
144# if !defined(OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE)
145# define OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(vers) \
146 __OSX_AVAILABLE(vers) \
147 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \
148 __WATCHOS_UNAVAILABLE
149# endif
150
151
152
153/* OBJC_ISA_AVAILABILITY: `isa` will be deprecated or unavailable
154 * in the future */
155#if !defined(OBJC_ISA_AVAILABILITY)
156# if __OBJC2__
157# define OBJC_ISA_AVAILABILITY __attribute__((deprecated))
158# else
159# define OBJC_ISA_AVAILABILITY /* still available */
160# endif
161#endif
162
163
164/* OBJC2_UNAVAILABLE: unavailable in objc 2.0, deprecated in Leopard */
165#if !defined(OBJC2_UNAVAILABLE)
166# if __OBJC2__
167# define OBJC2_UNAVAILABLE UNAVAILABLE_ATTRIBUTE
168# else
169 /* plain C code also falls here, but this is close enough */
170# define OBJC2_UNAVAILABLE \
171 __OSX_DEPRECATED(10.5, 10.5, "not available in __OBJC2__") \
172 __IOS_DEPRECATED(2.0, 2.0, "not available in __OBJC2__") \
173 __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
174# endif
175#endif
176
177/* OBJC_UNAVAILABLE: unavailable, with a message where supported */
178#if !defined(OBJC_UNAVAILABLE)
179# if __has_extension(attribute_unavailable_with_message)
180# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable(_msg)))
181# else
182# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable))
183# endif
184#endif
185
186/* OBJC_DEPRECATED: deprecated, with a message where supported */
187#if !defined(OBJC_DEPRECATED)
188# if __has_extension(attribute_deprecated_with_message)
189# define OBJC_DEPRECATED(_msg) __attribute__((deprecated(_msg)))
190# else
191# define OBJC_DEPRECATED(_msg) __attribute__((deprecated))
192# endif
193#endif
194
195/* OBJC_ARC_UNAVAILABLE: unavailable with -fobjc-arc */
196#if !defined(OBJC_ARC_UNAVAILABLE)
197# if __has_feature(objc_arc)
198# define OBJC_ARC_UNAVAILABLE OBJC_UNAVAILABLE("not available in automatic reference counting mode")
199# else
200# define OBJC_ARC_UNAVAILABLE
201# endif
202#endif
203
204/* OBJC_SWIFT_UNAVAILABLE: unavailable in Swift */
205#if !defined(OBJC_SWIFT_UNAVAILABLE)
206# if __has_feature(attribute_availability_swift)
207# define OBJC_SWIFT_UNAVAILABLE(_msg) __attribute__((availability(swift, unavailable, message=_msg)))
208# else
209# define OBJC_SWIFT_UNAVAILABLE(_msg)
210# endif
211#endif
212
213/* OBJC_ARM64_UNAVAILABLE: unavailable on arm64 (i.e. stret dispatch) */
214#if !defined(OBJC_ARM64_UNAVAILABLE)
215# if defined(__arm64__)
216# define OBJC_ARM64_UNAVAILABLE OBJC_UNAVAILABLE("not available in arm64")
217# else
218# define OBJC_ARM64_UNAVAILABLE
219# endif
220#endif
221
222/* OBJC_GC_UNAVAILABLE: unavailable with -fobjc-gc or -fobjc-gc-only */
223#if !defined(OBJC_GC_UNAVAILABLE)
224# define OBJC_GC_UNAVAILABLE
225#endif
226
227#if !defined(OBJC_EXTERN)
228# if defined(__cplusplus)
229# define OBJC_EXTERN extern "C"
230# else
231# define OBJC_EXTERN extern
232# endif
233#endif
234
235#if !defined(OBJC_VISIBLE)
236
237# define OBJC_VISIBLE __attribute__((visibility("default")))
238
239#endif
240
241#if !defined(OBJC_EXPORT)
242# define OBJC_EXPORT OBJC_EXTERN OBJC_VISIBLE
243#endif
244
245#if !defined(OBJC_IMPORT)
246# define OBJC_IMPORT extern
247#endif
248
249#if !defined(OBJC_ROOT_CLASS)
250# if __has_attribute(objc_root_class)
251# define OBJC_ROOT_CLASS __attribute__((objc_root_class))
252# else
253# define OBJC_ROOT_CLASS
254# endif
255#endif
256
257#ifndef __DARWIN_NULL
258#define __DARWIN_NULL NULL
259#endif
260
261#if !defined(OBJC_INLINE)
262# define OBJC_INLINE __inline
263#endif
264
265// Declares an enum type or option bits type as appropriate for each language.
266#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
267#define OBJC_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
268#if (__cplusplus)
269#define OBJC_OPTIONS(_type, _name) _type _name; enum : _type
270#else
271#define OBJC_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
272#endif
273#else
274#define OBJC_ENUM(_type, _name) _type _name; enum
275#define OBJC_OPTIONS(_type, _name) _type _name; enum
276#endif
277
278#if !defined(OBJC_RETURNS_RETAINED)
279# if __OBJC__ && __has_attribute(ns_returns_retained)
280# define OBJC_RETURNS_RETAINED __attribute__((ns_returns_retained))
281# else
282# define OBJC_RETURNS_RETAINED
283# endif
284#endif
285
286#endif
lib/libc/include/x86_64-macos-gnu/objc/objc.h created+259
......@@ -0,0 +1,259 @@
1/*
2 * Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 * objc.h
25 * Copyright 1988-1996, NeXT Software, Inc.
26 */
27
28#ifndef _OBJC_OBJC_H_
29#define _OBJC_OBJC_H_
30
31#include <sys/types.h> // for __DARWIN_NULL
32#include <Availability.h>
33#include <objc/objc-api.h>
34#include <stdbool.h>
35
36#if !OBJC_TYPES_DEFINED
37/// An opaque type that represents an Objective-C class.
38typedef struct objc_class *Class;
39
40/// Represents an instance of a class.
41struct objc_object {
42 Class _Nonnull isa OBJC_ISA_AVAILABILITY;
43};
44
45/// A pointer to an instance of a class.
46typedef struct objc_object *id;
47#endif
48
49/// An opaque type that represents a method selector.
50typedef struct objc_selector *SEL;
51
52/// A pointer to the function of a method implementation.
53#if !OBJC_OLD_DISPATCH_PROTOTYPES
54typedef void (*IMP)(void /* id, SEL, ... */ );
55#else
56typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...);
57#endif
58
59/// Type to represent a boolean value.
60
61#if defined(__OBJC_BOOL_IS_BOOL)
62 // Honor __OBJC_BOOL_IS_BOOL when available.
63# if __OBJC_BOOL_IS_BOOL
64# define OBJC_BOOL_IS_BOOL 1
65# else
66# define OBJC_BOOL_IS_BOOL 0
67# endif
68#else
69 // __OBJC_BOOL_IS_BOOL not set.
70# if TARGET_OS_OSX || TARGET_OS_MACCATALYST || ((TARGET_OS_IOS || 0) && !__LP64__ && !__ARM_ARCH_7K)
71# define OBJC_BOOL_IS_BOOL 0
72# else
73# define OBJC_BOOL_IS_BOOL 1
74# endif
75#endif
76
77#if OBJC_BOOL_IS_BOOL
78 typedef bool BOOL;
79#else
80# define OBJC_BOOL_IS_CHAR 1
81 typedef signed char BOOL;
82 // BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C"
83 // even if -funsigned-char is used.
84#endif
85
86#define OBJC_BOOL_DEFINED
87
88#if __has_feature(objc_bool)
89#define YES __objc_yes
90#define NO __objc_no
91#else
92#define YES ((BOOL)1)
93#define NO ((BOOL)0)
94#endif
95
96#ifndef Nil
97# if __has_feature(cxx_nullptr)
98# define Nil nullptr
99# else
100# define Nil __DARWIN_NULL
101# endif
102#endif
103
104#ifndef nil
105# if __has_feature(cxx_nullptr)
106# define nil nullptr
107# else
108# define nil __DARWIN_NULL
109# endif
110#endif
111
112#ifndef __strong
113# if !__has_feature(objc_arc)
114# define __strong /* empty */
115# endif
116#endif
117
118#ifndef __unsafe_unretained
119# if !__has_feature(objc_arc)
120# define __unsafe_unretained /* empty */
121# endif
122#endif
123
124#ifndef __autoreleasing
125# if !__has_feature(objc_arc)
126# define __autoreleasing /* empty */
127# endif
128#endif
129
130
131/**
132 * Returns the name of the method specified by a given selector.
133 *
134 * @param sel A pointer of type \c SEL. Pass the selector whose name you wish to determine.
135 *
136 * @return A C string indicating the name of the selector.
137 */
138OBJC_EXPORT const char * _Nonnull sel_getName(SEL _Nonnull sel)
139 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
140
141/**
142 * Registers a method with the Objective-C runtime system, maps the method
143 * name to a selector, and returns the selector value.
144 *
145 * @param str A pointer to a C string. Pass the name of the method you wish to register.
146 *
147 * @return A pointer of type SEL specifying the selector for the named method.
148 *
149 * @note You must register a method name with the Objective-C runtime system to obtain the
150 * method’s selector before you can add the method to a class definition. If the method name
151 * has already been registered, this function simply returns the selector.
152 */
153OBJC_EXPORT SEL _Nonnull sel_registerName(const char * _Nonnull str)
154 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
155
156/**
157 * Returns the class name of a given object.
158 *
159 * @param obj An Objective-C object.
160 *
161 * @return The name of the class of which \e obj is an instance.
162 */
163OBJC_EXPORT const char * _Nonnull object_getClassName(id _Nullable obj)
164 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
165
166/**
167 * Returns a pointer to any extra bytes allocated with an instance given object.
168 *
169 * @param obj An Objective-C object.
170 *
171 * @return A pointer to any extra bytes allocated with \e obj. If \e obj was
172 * not allocated with any extra bytes, then dereferencing the returned pointer is undefined.
173 *
174 * @note This function returns a pointer to any extra bytes allocated with the instance
175 * (as specified by \c class_createInstance with extraBytes>0). This memory follows the
176 * object's ordinary ivars, but may not be adjacent to the last ivar.
177 * @note The returned pointer is guaranteed to be pointer-size aligned, even if the area following
178 * the object's last ivar is less aligned than that. Alignment greater than pointer-size is never
179 * guaranteed, even if the area following the object's last ivar is more aligned than that.
180 * @note In a garbage-collected environment, the memory is scanned conservatively.
181 */
182OBJC_EXPORT void * _Nullable object_getIndexedIvars(id _Nullable obj)
183 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
184
185/**
186 * Identifies a selector as being valid or invalid.
187 *
188 * @param sel The selector you want to identify.
189 *
190 * @return YES if selector is valid and has a function implementation, NO otherwise.
191 *
192 * @warning On some platforms, an invalid reference (to invalid memory addresses) can cause
193 * a crash.
194 */
195OBJC_EXPORT BOOL sel_isMapped(SEL _Nonnull sel)
196 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
197
198/**
199 * Registers a method name with the Objective-C runtime system.
200 *
201 * @param str A pointer to a C string. Pass the name of the method you wish to register.
202 *
203 * @return A pointer of type SEL specifying the selector for the named method.
204 *
205 * @note The implementation of this method is identical to the implementation of \c sel_registerName.
206 * @note Prior to OS X version 10.0, this method tried to find the selector mapped to the given name
207 * and returned \c NULL if the selector was not found. This was changed for safety, because it was
208 * observed that many of the callers of this function did not check the return value for \c NULL.
209 */
210OBJC_EXPORT SEL _Nonnull sel_getUid(const char * _Nonnull str)
211 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
212
213typedef const void* objc_objectptr_t;
214
215
216// Obsolete ARC conversions.
217
218OBJC_EXPORT id _Nullable objc_retainedObject(objc_objectptr_t _Nullable obj)
219#if !OBJC_DECLARE_SYMBOLS
220 OBJC_UNAVAILABLE("use CFBridgingRelease() or a (__bridge_transfer id) cast instead")
221#endif
222 ;
223OBJC_EXPORT id _Nullable objc_unretainedObject(objc_objectptr_t _Nullable obj)
224#if !OBJC_DECLARE_SYMBOLS
225 OBJC_UNAVAILABLE("use a (__bridge id) cast instead")
226#endif
227 ;
228OBJC_EXPORT objc_objectptr_t _Nullable objc_unretainedPointer(id _Nullable obj)
229#if !OBJC_DECLARE_SYMBOLS
230 OBJC_UNAVAILABLE("use a __bridge cast instead")
231#endif
232 ;
233
234
235#if !__OBJC2__
236
237// The following declarations are provided here for source compatibility.
238
239#if defined(__LP64__)
240 typedef long arith_t;
241 typedef unsigned long uarith_t;
242# define ARITH_SHIFT 32
243#else
244 typedef int arith_t;
245 typedef unsigned uarith_t;
246# define ARITH_SHIFT 16
247#endif
248
249typedef char *STR;
250
251#define ISSELECTOR(sel) sel_isMapped(sel)
252#define SELNAME(sel) sel_getName(sel)
253#define SELUID(str) sel_getUid(str)
254#define NAMEOF(obj) object_getClassName(obj)
255#define IV(obj) object_getIndexedIvars(obj)
256
257#endif
258
259#endif /* _OBJC_OBJC_H_ */
lib/libc/include/x86_64-macos-gnu/os/base.h+27-30
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
2 * Copyright (c) 2008-2020 Apple Inc. All rights reserved.
33 *
44 * @APPLE_APACHE_LICENSE_HEADER_START@
55 *
......@@ -23,6 +23,7 @@
2323
2424#include <sys/cdefs.h>
2525
26
2627#ifndef __has_builtin
2728#define __has_builtin(x) 0
2829#endif
......@@ -73,7 +74,7 @@
7374#define OS_ALWAYS_INLINE __attribute__((__always_inline__))
7475#define OS_TRANSPARENT_UNION __attribute__((__transparent_union__))
7576#define OS_ALIGNED(n) __attribute__((__aligned__((n))))
76#define OS_FORMAT_PRINTF(x,y) __attribute__((__format__(printf,x,y)))
77#define OS_FORMAT_PRINTF(x, y) __attribute__((__format__(printf,x,y)))
7778#define OS_EXPORT extern __attribute__((__visibility__("default")))
7879#define OS_INLINE static __inline__
7980#define OS_EXPECT(x, v) __builtin_expect((x), (v))
......@@ -110,7 +111,7 @@
110111#define OS_ALWAYS_INLINE
111112#define OS_TRANSPARENT_UNION
112113#define OS_ALIGNED(n)
113#define OS_FORMAT_PRINTF(x,y)
114#define OS_FORMAT_PRINTF(x, y)
114115#define OS_EXPORT extern
115116#define OS_INLINE static inline
116117#define OS_EXPECT(x, v) (x)
......@@ -124,6 +125,8 @@
124125
125126#if defined(__cplusplus) && defined(__clang__)
126127#define OS_FALLTHROUGH [[clang::fallthrough]]
128#elif __has_attribute(fallthrough)
129#define OS_FALLTHROUGH __attribute__((__fallthrough__))
127130#else
128131#define OS_FALLTHROUGH
129132#endif
......@@ -164,30 +167,21 @@
164167 * -Wassign-enum prevents you from assigning illegal values to a variable of the
165168 * enum type.
166169 */
167#ifndef __OPEN_SOURCE__
168/*!
169 * @internal
170 * <rdar://problem/37799789>
171 */
172#endif // __OPEN_SOURCE__
173170#define __OS_OPTIONS_ATTR __attribute__((flag_enum))
174171#else
175172#define __OS_OPTIONS_ATTR
176173#endif // __has_attribute(flag_enum)
177174
178175#if __has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum) || \
179 __has_extension(cxx_strong_enums)
176 __has_extension(cxx_strong_enums)
180177#define OS_ENUM(_name, _type, ...) \
181 typedef enum : _type { __VA_ARGS__ } _name##_t
178 typedef enum : _type { __VA_ARGS__ } _name##_t
182179#define OS_CLOSED_ENUM(_name, _type, ...) \
183 typedef enum : _type { __VA_ARGS__ } \
184 __OS_ENUM_ATTR_CLOSED _name##_t
180 typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR_CLOSED _name##_t
185181#define OS_OPTIONS(_name, _type, ...) \
186 typedef enum : _type { __VA_ARGS__ } \
187 __OS_ENUM_ATTR __OS_OPTIONS_ATTR _name##_t
182 typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR __OS_OPTIONS_ATTR _name##_t
188183#define OS_CLOSED_OPTIONS(_name, _type, ...) \
189 typedef enum : _type { __VA_ARGS__ } \
190 __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR _name##_t
184 typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR _name##_t
191185#else
192186/*!
193187 * There is unfortunately no good way in plain C to have both fixed-type enums
......@@ -220,25 +214,25 @@
220214 * When compiling in ObjC or C++, both of the above assignments are illegal.
221215 */
222216#define __OS_ENUM_C_FALLBACK(_name, _type, ...) \
223 typedef _type _name##_t; enum _name { __VA_ARGS__ }
217 typedef _type _name##_t; enum _name { __VA_ARGS__ }
224218
225219#define OS_ENUM(_name, _type, ...) \
226 typedef _type _name##_t; enum { __VA_ARGS__ }
220 typedef _type _name##_t; enum { __VA_ARGS__ }
227221#define OS_CLOSED_ENUM(_name, _type, ...) \
228 __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
229 __OS_ENUM_ATTR_CLOSED
222 __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
223 __OS_ENUM_ATTR_CLOSED
230224#define OS_OPTIONS(_name, _type, ...) \
231 __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
232 __OS_ENUM_ATTR __OS_OPTIONS_ATTR
225 __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
226 __OS_ENUM_ATTR __OS_OPTIONS_ATTR
233227#define OS_CLOSED_OPTIONS(_name, _type, ...) \
234 __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
235 __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR
228 __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
229 __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR
236230#endif // __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
237231
238232#if __has_feature(attribute_availability_swift)
239233// equivalent to __SWIFT_UNAVAILABLE from Availability.h
240234#define OS_SWIFT_UNAVAILABLE(_msg) \
241 __attribute__((__availability__(swift, unavailable, message=_msg)))
235 __attribute__((__availability__(swift, unavailable, message=_msg)))
242236#else
243237#define OS_SWIFT_UNAVAILABLE(_msg)
244238#endif
......@@ -262,12 +256,12 @@
262256
263257#ifdef __GNUC__
264258#define os_prevent_tail_call_optimization() __asm__("")
265#define os_is_compile_time_constant(expr) __builtin_constant_p(expr)
266#define os_compiler_barrier() __asm__ __volatile__("" ::: "memory")
259#define os_is_compile_time_constant(expr) __builtin_constant_p(expr)
260#define os_compiler_barrier() __asm__ __volatile__("" ::: "memory")
267261#else
268262#define os_prevent_tail_call_optimization() do { } while (0)
269#define os_is_compile_time_constant(expr) 0
270#define os_compiler_barrier() do { } while (0)
263#define os_is_compile_time_constant(expr) 0
264#define os_compiler_barrier() do { } while (0)
271265#endif
272266
273267#if __has_attribute(not_tail_called)
......@@ -276,6 +270,7 @@
276270#define OS_NOT_TAIL_CALLED
277271#endif
278272
273
279274typedef void (*os_function_t)(void *_Nullable);
280275
281276#ifdef __BLOCKS__
......@@ -322,4 +317,6 @@ typedef void (*os_function_t)(void *_Nullable);
322317typedef void (^os_block_t)(void);
323318#endif
324319
320
321
325322#endif // __OS_BASE__
lib/libc/include/x86_64-macos-gnu/os/clock.h created+18
......@@ -0,0 +1,18 @@
1#ifndef __OS_CLOCK__
2#define __OS_CLOCK__
3
4#include <os/base.h>
5#include <stdint.h>
6
7/*
8 * @typedef os_clockid_t
9 *
10 * @abstract
11 * Describes the kind of clock that the workgroup timestamp parameters are
12 * specified in
13 */
14OS_ENUM(os_clockid, uint32_t,
15 OS_CLOCK_MACH_ABSOLUTE_TIME = 32,
16);
17
18#endif /* __OS_CLOCK__ */
lib/libc/include/x86_64-macos-gnu/os/lock.h created+189
......@@ -0,0 +1,189 @@
1/*
2 * Copyright (c) 2016 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_LOCK__
22#define __OS_LOCK__
23
24#include <Availability.h>
25#include <sys/cdefs.h>
26#include <stddef.h>
27#include <stdint.h>
28#include <stdbool.h>
29#include <os/base.h>
30
31OS_ASSUME_NONNULL_BEGIN
32
33/*! @header
34 * Low-level lock API.
35 */
36
37#define OS_LOCK_API_VERSION 20160309
38
39__BEGIN_DECLS
40
41#define OS_UNFAIR_LOCK_AVAILABILITY \
42 __API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
43
44/*!
45 * @typedef os_unfair_lock
46 *
47 * @abstract
48 * Low-level lock that allows waiters to block efficiently on contention.
49 *
50 * In general, higher level synchronization primitives such as those provided by
51 * the pthread or dispatch subsystems should be preferred.
52 *
53 * The values stored in the lock should be considered opaque and implementation
54 * defined, they contain thread ownership information that the system may use
55 * to attempt to resolve priority inversions.
56 *
57 * This lock must be unlocked from the same thread that locked it, attempts to
58 * unlock from a different thread will cause an assertion aborting the process.
59 *
60 * This lock must not be accessed from multiple processes or threads via shared
61 * or multiply-mapped memory, the lock implementation relies on the address of
62 * the lock value and owning process.
63 *
64 * Must be initialized with OS_UNFAIR_LOCK_INIT
65 *
66 * @discussion
67 * Replacement for the deprecated OSSpinLock. Does not spin on contention but
68 * waits in the kernel to be woken up by an unlock.
69 *
70 * As with OSSpinLock there is no attempt at fairness or lock ordering, e.g. an
71 * unlocker can potentially immediately reacquire the lock before a woken up
72 * waiter gets an opportunity to attempt to acquire the lock. This may be
73 * advantageous for performance reasons, but also makes starvation of waiters a
74 * possibility.
75 */
76OS_UNFAIR_LOCK_AVAILABILITY
77typedef struct os_unfair_lock_s {
78 uint32_t _os_unfair_lock_opaque;
79} os_unfair_lock, *os_unfair_lock_t;
80
81#ifndef OS_UNFAIR_LOCK_INIT
82#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
83#define OS_UNFAIR_LOCK_INIT ((os_unfair_lock){0})
84#elif defined(__cplusplus) && __cplusplus >= 201103L
85#define OS_UNFAIR_LOCK_INIT (os_unfair_lock{})
86#elif defined(__cplusplus)
87#define OS_UNFAIR_LOCK_INIT (os_unfair_lock())
88#else
89#define OS_UNFAIR_LOCK_INIT {0}
90#endif
91#endif // OS_UNFAIR_LOCK_INIT
92
93/*!
94 * @function os_unfair_lock_lock
95 *
96 * @abstract
97 * Locks an os_unfair_lock.
98 *
99 * @param lock
100 * Pointer to an os_unfair_lock.
101 */
102OS_UNFAIR_LOCK_AVAILABILITY
103OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
104void os_unfair_lock_lock(os_unfair_lock_t lock);
105
106/*!
107 * @function os_unfair_lock_trylock
108 *
109 * @abstract
110 * Locks an os_unfair_lock if it is not already locked.
111 *
112 * @discussion
113 * It is invalid to surround this function with a retry loop, if this function
114 * returns false, the program must be able to proceed without having acquired
115 * the lock, or it must call os_unfair_lock_lock() directly (a retry loop around
116 * os_unfair_lock_trylock() amounts to an inefficient implementation of
117 * os_unfair_lock_lock() that hides the lock waiter from the system and prevents
118 * resolution of priority inversions).
119 *
120 * @param lock
121 * Pointer to an os_unfair_lock.
122 *
123 * @result
124 * Returns true if the lock was succesfully locked and false if the lock was
125 * already locked.
126 */
127OS_UNFAIR_LOCK_AVAILABILITY
128OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NONNULL_ALL
129bool os_unfair_lock_trylock(os_unfair_lock_t lock);
130
131/*!
132 * @function os_unfair_lock_unlock
133 *
134 * @abstract
135 * Unlocks an os_unfair_lock.
136 *
137 * @param lock
138 * Pointer to an os_unfair_lock.
139 */
140OS_UNFAIR_LOCK_AVAILABILITY
141OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
142void os_unfair_lock_unlock(os_unfair_lock_t lock);
143
144/*!
145 * @function os_unfair_lock_assert_owner
146 *
147 * @abstract
148 * Asserts that the calling thread is the current owner of the specified
149 * unfair lock.
150 *
151 * @discussion
152 * If the lock is currently owned by the calling thread, this function returns.
153 *
154 * If the lock is unlocked or owned by a different thread, this function
155 * asserts and terminates the process.
156 *
157 * @param lock
158 * Pointer to an os_unfair_lock.
159 */
160OS_UNFAIR_LOCK_AVAILABILITY
161OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
162void os_unfair_lock_assert_owner(os_unfair_lock_t lock);
163
164/*!
165 * @function os_unfair_lock_assert_not_owner
166 *
167 * @abstract
168 * Asserts that the calling thread is not the current owner of the specified
169 * unfair lock.
170 *
171 * @discussion
172 * If the lock is unlocked or owned by a different thread, this function
173 * returns.
174 *
175 * If the lock is currently owned by the current thread, this function asserts
176 * and terminates the process.
177 *
178 * @param lock
179 * Pointer to an os_unfair_lock.
180 */
181OS_UNFAIR_LOCK_AVAILABILITY
182OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
183void os_unfair_lock_assert_not_owner(os_unfair_lock_t lock);
184
185__END_DECLS
186
187OS_ASSUME_NONNULL_END
188
189#endif // __OS_LOCK__
lib/libc/include/x86_64-macos-gnu/os/object.h created+303
......@@ -0,0 +1,303 @@
1/*
2 * Copyright (c) 2011-2014 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_OBJECT__
22#define __OS_OBJECT__
23
24#ifdef __APPLE__
25#include <Availability.h>
26#include <os/availability.h>
27#include <TargetConditionals.h>
28#include <os/base.h>
29#elif defined(_WIN32)
30#include <os/generic_win_base.h>
31#elif defined(__unix__)
32#include <os/generic_unix_base.h>
33#endif
34
35/*!
36 * @header
37 *
38 * @preprocinfo
39 * By default, libSystem objects such as GCD and XPC objects are declared as
40 * Objective-C types when building with an Objective-C compiler. This allows
41 * them to participate in ARC, in RR management by the Blocks runtime and in
42 * leaks checking by the static analyzer, and enables them to be added to Cocoa
43 * collections.
44 *
45 * NOTE: this requires explicit cancellation of dispatch sources and xpc
46 * connections whose handler blocks capture the source/connection object,
47 * resp. ensuring that such captures do not form retain cycles (e.g. by
48 * declaring the source as __weak).
49 *
50 * To opt-out of this default behavior, add -DOS_OBJECT_USE_OBJC=0 to your
51 * compiler flags.
52 *
53 * This mode requires a platform with the modern Objective-C runtime, the
54 * Objective-C GC compiler option to be disabled, and at least a Mac OS X 10.8
55 * or iOS 6.0 deployment target.
56 */
57
58#ifndef OS_OBJECT_HAVE_OBJC_SUPPORT
59#if !defined(__OBJC__) || defined(__OBJC_GC__)
60# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
61#elif !defined(TARGET_OS_MAC) || !TARGET_OS_MAC
62# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
63#elif TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0
64# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
65#elif TARGET_OS_MAC && !TARGET_OS_IPHONE
66# if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8
67# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
68# elif defined(__i386__) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12
69# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
70# else
71# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
72# endif
73#else
74# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
75#endif
76#endif // OS_OBJECT_HAVE_OBJC_SUPPORT
77
78#if OS_OBJECT_HAVE_OBJC_SUPPORT
79#if defined(__swift__) && __swift__ && !OS_OBJECT_USE_OBJC
80#define OS_OBJECT_USE_OBJC 1
81#endif
82#ifndef OS_OBJECT_USE_OBJC
83#define OS_OBJECT_USE_OBJC 1
84#endif
85#elif defined(OS_OBJECT_USE_OBJC) && OS_OBJECT_USE_OBJC
86/* Unsupported platform for OS_OBJECT_USE_OBJC=1 */
87#undef OS_OBJECT_USE_OBJC
88#define OS_OBJECT_USE_OBJC 0
89#else
90#define OS_OBJECT_USE_OBJC 0
91#endif
92
93#ifndef OS_OBJECT_SWIFT3
94#ifdef __swift__
95#define OS_OBJECT_SWIFT3 1
96#else // __swift__
97#define OS_OBJECT_SWIFT3 0
98#endif // __swift__
99#endif // OS_OBJECT_SWIFT3
100
101#if __has_feature(assume_nonnull)
102#define OS_OBJECT_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
103#define OS_OBJECT_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
104#else
105#define OS_OBJECT_ASSUME_NONNULL_BEGIN
106#define OS_OBJECT_ASSUME_NONNULL_END
107#endif
108#define OS_OBJECT_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
109
110#if OS_OBJECT_USE_OBJC
111#import <objc/NSObject.h>
112#if __has_attribute(objc_independent_class)
113#define OS_OBJC_INDEPENDENT_CLASS __attribute__((objc_independent_class))
114#endif // __has_attribute(objc_independent_class)
115#ifndef OS_OBJC_INDEPENDENT_CLASS
116#define OS_OBJC_INDEPENDENT_CLASS
117#endif
118#define OS_OBJECT_CLASS(name) OS_##name
119#define OS_OBJECT_DECL_PROTOCOL(name, ...) \
120 @protocol OS_OBJECT_CLASS(name) __VA_ARGS__ \
121 @end
122#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL(name, proto) \
123 @interface name () <proto> \
124 @end
125#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, proto) \
126 OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL( \
127 OS_OBJECT_CLASS(name), OS_OBJECT_CLASS(proto))
128#define OS_OBJECT_DECL_IMPL(name, adhere, ...) \
129 OS_OBJECT_DECL_PROTOCOL(name, __VA_ARGS__) \
130 typedef adhere<OS_OBJECT_CLASS(name)> \
131 * OS_OBJC_INDEPENDENT_CLASS name##_t
132#define OS_OBJECT_DECL_BASE(name, ...) \
133 @interface OS_OBJECT_CLASS(name) : __VA_ARGS__ \
134 - (instancetype)init OS_SWIFT_UNAVAILABLE("Unavailable in Swift"); \
135 @end
136#define OS_OBJECT_DECL_IMPL_CLASS(name, ...) \
137 OS_OBJECT_DECL_BASE(name, ## __VA_ARGS__) \
138 typedef OS_OBJECT_CLASS(name) \
139 * OS_OBJC_INDEPENDENT_CLASS name##_t
140#define OS_OBJECT_DECL(name, ...) \
141 OS_OBJECT_DECL_IMPL(name, NSObject, <NSObject>)
142#define OS_OBJECT_DECL_SUBCLASS(name, super) \
143 OS_OBJECT_DECL_IMPL(name, NSObject, <OS_OBJECT_CLASS(super)>)
144#if __has_attribute(ns_returns_retained)
145#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
146#else
147#define OS_OBJECT_RETURNS_RETAINED
148#endif
149#if __has_attribute(ns_consumed)
150#define OS_OBJECT_CONSUMED __attribute__((__ns_consumed__))
151#else
152#define OS_OBJECT_CONSUMED
153#endif
154#if __has_feature(objc_arc)
155#define OS_OBJECT_BRIDGE __bridge
156#define OS_WARN_RESULT_NEEDS_RELEASE
157#else
158#define OS_OBJECT_BRIDGE
159#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT
160#endif
161
162
163#if __has_attribute(objc_runtime_visible) && \
164 ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
165 __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12) || \
166 (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
167 !defined(__TV_OS_VERSION_MIN_REQUIRED) && \
168 !defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \
169 __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) || \
170 (defined(__TV_OS_VERSION_MIN_REQUIRED) && \
171 __TV_OS_VERSION_MIN_REQUIRED < __TVOS_10_0) || \
172 (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \
173 __WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_3_0))
174/*
175 * To provide backward deployment of ObjC objects in Swift on pre-10.12
176 * SDKs, OS_object classes can be marked as OS_OBJECT_OBJC_RUNTIME_VISIBLE.
177 * When compiling with a deployment target earlier than OS X 10.12 (iOS 10.0,
178 * tvOS 10.0, watchOS 3.0) the Swift compiler will only refer to this type at
179 * runtime (using the ObjC runtime).
180 */
181#define OS_OBJECT_OBJC_RUNTIME_VISIBLE __attribute__((objc_runtime_visible))
182#else
183#define OS_OBJECT_OBJC_RUNTIME_VISIBLE
184#endif
185#ifndef OS_OBJECT_USE_OBJC_RETAIN_RELEASE
186#if defined(__clang_analyzer__)
187#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1
188#elif __has_feature(objc_arc) && !OS_OBJECT_SWIFT3
189#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1
190#else
191#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0
192#endif
193#endif
194#if OS_OBJECT_SWIFT3
195#define OS_OBJECT_DECL_SWIFT(name) \
196 OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
197 OS_OBJECT_DECL_IMPL_CLASS(name, NSObject)
198#define OS_OBJECT_DECL_SUBCLASS_SWIFT(name, super) \
199 OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
200 OS_OBJECT_DECL_IMPL_CLASS(name, OS_OBJECT_CLASS(super))
201#endif // OS_OBJECT_SWIFT3
202OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE
203OS_OBJECT_DECL_BASE(object, NSObject);
204#else
205/*! @parseOnly */
206#define OS_OBJECT_RETURNS_RETAINED
207/*! @parseOnly */
208#define OS_OBJECT_CONSUMED
209/*! @parseOnly */
210#define OS_OBJECT_BRIDGE
211/*! @parseOnly */
212#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT
213/*! @parseOnly */
214#define OS_OBJECT_OBJC_RUNTIME_VISIBLE
215#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0
216#endif
217
218#if OS_OBJECT_SWIFT3
219#define OS_OBJECT_DECL_CLASS(name) \
220 OS_OBJECT_DECL_SUBCLASS_SWIFT(name, object)
221#elif OS_OBJECT_USE_OBJC
222#define OS_OBJECT_DECL_CLASS(name) \
223 OS_OBJECT_DECL(name)
224#else
225#define OS_OBJECT_DECL_CLASS(name) \
226 typedef struct name##_s *name##_t
227#endif
228
229#if OS_OBJECT_USE_OBJC
230/* Declares a class of the specific name and exposes the interface and typedefs
231 * name##_t to the pointer to the class */
232#define OS_OBJECT_SHOW_CLASS(name, ...) \
233 OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
234 OS_OBJECT_DECL_IMPL_CLASS(name, ## __VA_ARGS__ )
235/* Declares a subclass of the same name, and
236 * subclass adheres to protocol specified. Typedefs baseclass<proto> * to subclass##_t */
237#define OS_OBJECT_SHOW_SUBCLASS(subclass_name, super, proto_name) \
238 OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
239 OS_OBJECT_DECL_BASE(subclass_name, OS_OBJECT_CLASS(super)<OS_OBJECT_CLASS(proto_name)>); \
240 typedef OS_OBJECT_CLASS(super)<OS_OBJECT_CLASS(proto_name)> \
241 * OS_OBJC_INDEPENDENT_CLASS subclass_name##_t
242#else /* Plain C */
243#define OS_OBJECT_DECL_PROTOCOL(name, ...)
244#define OS_OBJECT_SHOW_CLASS(name, ...) \
245 typedef struct name##_s *name##_t
246#define OS_OBJECT_SHOW_SUBCLASS(name, super, ...) \
247 typedef super##_t name##_t
248#endif
249
250#define OS_OBJECT_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object))
251
252__BEGIN_DECLS
253
254/*!
255 * @function os_retain
256 *
257 * @abstract
258 * Increment the reference count of an os_object.
259 *
260 * @discussion
261 * On a platform with the modern Objective-C runtime this is exactly equivalent
262 * to sending the object the -[retain] message.
263 *
264 * @param object
265 * The object to retain.
266 *
267 * @result
268 * The retained object.
269 */
270API_AVAILABLE(macos(10.10), ios(8.0))
271OS_EXPORT OS_SWIFT_UNAVAILABLE("Can't be used with ARC")
272void*
273os_retain(void *object);
274#if OS_OBJECT_USE_OBJC
275#undef os_retain
276#define os_retain(object) [object retain]
277#endif
278
279/*!
280 * @function os_release
281 *
282 * @abstract
283 * Decrement the reference count of a os_object.
284 *
285 * @discussion
286 * On a platform with the modern Objective-C runtime this is exactly equivalent
287 * to sending the object the -[release] message.
288 *
289 * @param object
290 * The object to release.
291 */
292API_AVAILABLE(macos(10.10), ios(8.0))
293OS_EXPORT
294void OS_SWIFT_UNAVAILABLE("Can't be used with ARC")
295os_release(void *object);
296#if OS_OBJECT_USE_OBJC
297#undef os_release
298#define os_release(object) [object release]
299#endif
300
301__END_DECLS
302
303#endif
lib/libc/include/x86_64-macos-gnu/os/workgroup.h created+37
......@@ -0,0 +1,37 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_WORKGROUP__
22#define __OS_WORKGROUP__
23
24#ifndef __DISPATCH_BUILDING_DISPATCH__
25#ifndef __OS_WORKGROUP_INDIRECT__
26#define __OS_WORKGROUP_INDIRECT__
27#endif /* __OS_WORKGROUP_INDIRECT__ */
28
29#include <os/workgroup_base.h>
30#include <os/workgroup_object.h>
31#include <os/workgroup_interval.h>
32#include <os/workgroup_parallel.h>
33
34#undef __OS_WORKGROUP_INDIRECT__
35#endif /* __DISPATCH_BUILDING_DISPATCH__ */
36
37#endif /* __OS_WORKGROUP__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup_base.h created+78
......@@ -0,0 +1,78 @@
1#ifndef __OS_WORKGROUP_BASE__
2#define __OS_WORKGROUP_BASE__
3
4#ifndef __OS_WORKGROUP_INDIRECT__
5#error "Please #include <os/workgroup.h> instead of this file directly."
6#endif
7
8#include <sys/types.h>
9#include <stddef.h>
10#include <stdint.h>
11#include <stdbool.h>
12#include <string.h>
13#include <stdlib.h>
14
15#include <mach/port.h>
16
17#include <Availability.h>
18#include <os/base.h>
19#include <os/object.h>
20#include <os/clock.h>
21
22#if __has_feature(assume_nonnull)
23#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
24#define OS_WORKGROUP_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
25#else
26#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN
27#define OS_WORKGROUP_ASSUME_NONNULL_END
28#endif
29#define OS_WORKGROUP_WARN_RESULT __attribute__((__warn_unused_result__))
30#define OS_WORKGROUP_EXPORT OS_EXPORT
31#define OS_WORKGROUP_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
32
33#define OS_WORKGROUP_DECL(name, swift_name) \
34 OS_SWIFT_NAME(swift_name) \
35 OS_OBJECT_SHOW_CLASS(name, OS_OBJECT_CLASS(object))
36
37#if OS_OBJECT_USE_OBJC
38#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...) \
39 OS_SWIFT_NAME(swift_name) \
40 OS_OBJECT_DECL_PROTOCOL(name ## __VA_ARGS__ )
41#else
42#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...)
43#endif
44
45#define OS_WORKGROUP_SUBCLASS_DECL(name, super, swift_name, ...) \
46 OS_SWIFT_NAME(swift_name) \
47 OS_OBJECT_SHOW_SUBCLASS(name, super, name, ## __VA_ARGS__)
48
49#if defined(__LP64__)
50#define __OS_WORKGROUP_ATTR_SIZE__ 60
51#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56
52#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 36
53#else
54#define __OS_WORKGROUP_ATTR_SIZE__ 60
55#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56
56#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 28
57#endif
58
59#define _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT 0x2FA863B4
60#define _OS_WORKGROUP_ATTR_SIG_EMPTY_INIT 0x2FA863C4
61
62struct OS_REFINED_FOR_SWIFT os_workgroup_attr_opaque_s {
63 uint32_t sig;
64 char opaque[__OS_WORKGROUP_ATTR_SIZE__];
65};
66
67#define _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT 0x52A74C4D
68struct OS_REFINED_FOR_SWIFT os_workgroup_interval_data_opaque_s {
69 uint32_t sig;
70 char opaque[__OS_WORKGROUP_INTERVAL_DATA_SIZE__];
71};
72
73struct OS_REFINED_FOR_SWIFT os_workgroup_join_token_opaque_s {
74 uint32_t sig;
75 char opaque[__OS_WORKGROUP_JOIN_TOKEN_SIZE__];
76};
77
78#endif /* __OS_WORKGROUP_BASE__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup_interval.h created+155
......@@ -0,0 +1,155 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_WORKGROUP_INTERVAL__
22#define __OS_WORKGROUP_INTERVAL__
23
24#ifndef __OS_WORKGROUP_INDIRECT__
25#error "Please #include <os/workgroup.h> instead of this file directly."
26#include <os/workgroup_base.h> // For header doc
27#endif
28
29__BEGIN_DECLS
30
31OS_WORKGROUP_ASSUME_NONNULL_BEGIN
32
33/*!
34 * @typedef os_workgroup_interval_t
35 *
36 * @abstract
37 * A subclass of an os_workgroup_t for tracking work performed as part of
38 * a repeating interval-driven workload.
39 */
40OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_interval, Repeatable);
41OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_interval, os_workgroup, WorkGroupInterval);
42
43/* During the first instance of this API, the only supported interval
44 * workgroups are for audio workloads. Please refer to the AudioToolbox
45 * framework for more information.
46 */
47
48/*
49 * @typedef os_workgroup_interval_data, os_workgroup_interval_data_t
50 *
51 * @abstract
52 * An opaque structure containing additional configuration for the workgroup
53 * interval.
54 */
55typedef struct os_workgroup_interval_data_opaque_s os_workgroup_interval_data_s;
56typedef struct os_workgroup_interval_data_opaque_s *os_workgroup_interval_data_t;
57#define OS_WORKGROUP_INTERVAL_DATA_INITIALIZER \
58 { .sig = _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT }
59
60/*!
61 * @function os_workgroup_interval_start
62 *
63 * @abstract
64 * Indicates to the system that the member threads of this
65 * os_workgroup_interval_t have begun working on an instance of the repeatable
66 * interval workload with the specified timestamps. This function is real time
67 * safe.
68 *
69 * This function will set and return an errno in the following cases:
70 *
71 * - The current thread is not a member of the os_workgroup_interval_t
72 * - The os_workgroup_interval_t has been cancelled
73 * - The timestamps passed in are malformed
74 * - os_workgroup_interval_start() was previously called on the
75 * os_workgroup_interval_t without an intervening os_workgroup_interval_finish()
76 * - A concurrent workgroup interval configuration operation is taking place.
77 *
78 * @param start
79 * Start timestamp specified in the os_clockid_t with which the
80 * os_workgroup_interval_t was created. This is generally a time in the past and
81 * indicates when the workgroup started working on an interval period
82 *
83 * @param deadline
84 * Deadline timestamp specified in the os_clockid_t with which the
85 * os_workgroup_interval_t was created. This specifies the deadline which the
86 * interval period would like to meet.
87 *
88 * @param data
89 * This field is currently unused and should be NULL
90 */
91API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
92OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
93int
94os_workgroup_interval_start(os_workgroup_interval_t wg, uint64_t start, uint64_t
95 deadline, os_workgroup_interval_data_t _Nullable data);
96
97/*!
98 * @function os_workgroup_interval_update
99 *
100 * @abstract
101 * Updates an already started interval workgroup to have the new
102 * deadline specified. This function is real time safe.
103 *
104 * This function will return an error in the following cases:
105 * - The current thread is not a member of the os_workgroup_interval_t
106 * - The os_workgroup_interval_t has been cancelled
107 * - The timestamp passed in is malformed
108 * - os_workgroup_interval_start() was not previously called on the
109 * os_workgroup_interval_t or was already matched with an
110 * os_workgroup_interval_finish()
111 * - A concurrent workgroup interval configuration operation is taking place
112 *
113 * @param deadline
114 * Timestamp specified in the os_clockid_t with
115 * which the os_workgroup_interval_t was created.
116 *
117 * @param data
118 * This field is currently unused and should be NULL
119 */
120API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
121OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
122int
123os_workgroup_interval_update(os_workgroup_interval_t wg, uint64_t deadline,
124 os_workgroup_interval_data_t _Nullable data);
125
126/*!
127 * @function os_workgroup_interval_finish
128 *
129 * @abstract
130 * Indicates to the system that the member threads of
131 * this os_workgroup_interval_t have finished working on the current instance
132 * of the interval workload. This function is real time safe.
133 *
134 * This function will return an error in the following cases:
135 * - The current thread is not a member of the os_workgroup_interval_t
136 * - os_workgroup_interval_start() was not previously called on the
137 * os_workgroup_interval_t or was already matched with an
138 * os_workgroup_interval_finish()
139 * - A concurrent workgroup interval configuration operation is taking place.
140 *
141 * @param data
142 * This field is currently unused and should be NULL
143 *
144 */
145API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
146OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
147int
148os_workgroup_interval_finish(os_workgroup_interval_t wg,
149 os_workgroup_interval_data_t _Nullable data);
150
151OS_WORKGROUP_ASSUME_NONNULL_END
152
153__END_DECLS
154
155#endif /* __OS_WORKGROUP_INTERVAL__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup_object.h created+357
......@@ -0,0 +1,357 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_WORKGROUP_OBJECT__
22#define __OS_WORKGROUP_OBJECT__
23
24#ifndef __OS_WORKGROUP_INDIRECT__
25#error "Please #include <os/workgroup.h> instead of this file directly."
26#include <os/workgroup_base.h> // For header doc
27#endif
28
29__BEGIN_DECLS
30
31OS_WORKGROUP_ASSUME_NONNULL_BEGIN
32
33/*!
34 * @typedef os_workgroup_t
35 *
36 * @abstract
37 * A reference counted os object representing a workload that needs to
38 * be distinctly recognized and tracked by the system. The workgroup
39 * tracks a collection of threads all working cooperatively. An os_workgroup
40 * object - when not an instance of a specific os_workgroup_t subclass -
41 * represents a generic workload and makes no assumptions about the kind of
42 * work done.
43 *
44 * @discussion
45 * Threads can explicitly join an os_workgroup_t to mark themselves as
46 * participants in the workload.
47 */
48OS_WORKGROUP_DECL(os_workgroup, WorkGroup);
49
50
51/* Attribute creation and specification */
52
53/*!
54 * @typedef os_workgroup_attr_t
55 *
56 * @abstract
57 * Pointer to an opaque structure for describing attributes that can be
58 * configured on a workgroup at creation.
59 */
60typedef struct os_workgroup_attr_opaque_s os_workgroup_attr_s;
61typedef struct os_workgroup_attr_opaque_s *os_workgroup_attr_t;
62
63/* os_workgroup_t attributes need to be initialized before use. This initializer
64 * allows you to create a workgroup with the system default attributes. */
65#define OS_WORKGROUP_ATTR_INITIALIZER_DEFAULT \
66 { .sig = _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT }
67
68
69
70/* The main use of the workgroup API is through instantiations of the concrete
71 * subclasses - please refer to os/workgroup_interval.h and
72 * os/workgroup_parallel.h for more information on creating workgroups.
73 *
74 * The functions below operate on all subclasses of os_workgroup_t.
75 */
76
77/*!
78 * @function os_workgroup_copy_port
79 *
80 * @abstract
81 * Returns a reference to a send right representing this workgroup that is to be
82 * sent to other processes. This port is to be passed to
83 * os_workgroup_create_with_port() to create a workgroup object.
84 *
85 * It is the client's responsibility to release the send right reference.
86 *
87 * If an error is encountered, errno is set and returned.
88 */
89API_AVAILABLE(macos(11.0))
90API_UNAVAILABLE(ios, tvos, watchos)
91OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
92int
93os_workgroup_copy_port(os_workgroup_t wg, mach_port_t *mach_port_out);
94
95/*!
96 * @function os_workgroup_create_with_port
97 *
98 * @abstract
99 * Create an os_workgroup_t object from a send right returned by a previous
100 * call to os_workgroup_copy_port, potentially in a different process.
101 *
102 * A newly created os_workgroup_t has no initial member threads - in particular
103 * the creating thread does not join the os_workgroup_t implicitly.
104 *
105 * @param name
106 * A client specified string for labelling the workgroup. This parameter is
107 * optional and can be NULL.
108 *
109 * @param mach_port
110 * The send right to create the workgroup from. No reference is consumed
111 * on the specified send right.
112 */
113API_AVAILABLE(macos(11.0))
114API_UNAVAILABLE(ios, tvos, watchos)
115OS_SWIFT_NAME(WorkGroup.init(__name:port:)) OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
116os_workgroup_t _Nullable
117os_workgroup_create_with_port(const char *_Nullable name, mach_port_t mach_port);
118
119/*!
120 * @function os_workgroup_create_with_workgroup
121 *
122 * @abstract
123 * Create a new os_workgroup object from an existing os_workgroup.
124 *
125 * The newly created os_workgroup has no initial member threads - in particular
126 * the creating threaad does not join the os_workgroup_t implicitly.
127 *
128 * @param name
129 * A client specified string for labelling the workgroup. This parameter is
130 * optional and can be NULL.
131 *
132 * @param wg
133 * The existing workgroup to create a new workgroup object from.
134 */
135API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
136OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
137os_workgroup_t _Nullable
138os_workgroup_create_with_workgroup(const char * _Nullable name, os_workgroup_t wg);
139
140/*!
141 * @typedef os_workgroup_join_token, os_workgroup_join_token_t
142 *
143 * @abstract
144 * An opaque join token which the client needs to pass to os_workgroup_join
145 * and os_workgroup_leave
146 */
147OS_REFINED_FOR_SWIFT
148typedef struct os_workgroup_join_token_opaque_s os_workgroup_join_token_s;
149OS_REFINED_FOR_SWIFT
150typedef struct os_workgroup_join_token_opaque_s *os_workgroup_join_token_t;
151
152
153/*!
154 * @function os_workgroup_join
155 *
156 * @abstract
157 * Joins the current thread to the specified workgroup and populates the join
158 * token that has been passed in. This API is real-time safe.
159 *
160 * @param wg
161 * The workgroup that the current thread would like to join
162 *
163 * @param token_out
164 * Pointer to a client allocated struct which the function will populate
165 * with the join token. This token must be passed in by the thread when it calls
166 * os_workgroup_leave().
167 *
168 * Errors will be returned in the following cases:
169 *
170 * EALREADY The thread is already part of a workgroup that the specified
171 * workgroup does not nest with
172 * EINVAL The workgroup has been cancelled
173 */
174API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
175OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
176int
177os_workgroup_join(os_workgroup_t wg, os_workgroup_join_token_t token_out);
178
179/*!
180 * @function os_workgroup_leave
181 *
182 * @abstract
183 * This removes the current thread from a workgroup it has previously
184 * joined. Threads must leave all workgroups in the reverse order that they
185 * have joined them. Failing to do so before exiting will result in undefined
186 * behavior.
187 *
188 * If the join token is malformed, the process will be aborted.
189 *
190 * This API is real time safe.
191 *
192 * @param wg
193 * The workgroup that the current thread would like to leave.
194 *
195 * @param token
196 * This is the join token populated by the most recent call to
197 * os_workgroup_join().
198 */
199API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
200OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
201void
202os_workgroup_leave(os_workgroup_t wg, os_workgroup_join_token_t token);
203
204/* Working Arena index of a thread in a workgroup */
205typedef uint32_t os_workgroup_index;
206/* Destructor for Working Arena */
207typedef void (*os_workgroup_working_arena_destructor_t)(void * _Nullable);
208
209/*!
210 * @function os_workgroup_set_working_arena
211 *
212 * @abstract
213 * Associates a client defined working arena with the workgroup. The arena
214 * is local to the workgroup object in the process. This is intended for
215 * distributing a manually managed memory allocation between member threads
216 * of the workgroup.
217 *
218 * This function can be called multiple times and the client specified
219 * destructor will be called on the previously assigned arena, if any. This
220 * function can only be called when no threads have currently joined the
221 * workgroup and all workloops associated with the workgroup are idle.
222 *
223 * @param wg
224 * The workgroup to associate the working arena with
225 *
226 * @param arena
227 * The client managed arena to associate with the workgroup. This value can
228 * be NULL.
229 *
230 * @param max_workers
231 * The maximum number of threads that will ever query the workgroup for the
232 * arena and request an index into it. If the arena is not used to partition
233 * work amongst member threads, then this field can be 0.
234 *
235 * @param destructor
236 * A destructor to call on the previously assigned working arena, if any
237 */
238API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
239OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
240int
241os_workgroup_set_working_arena(os_workgroup_t wg, void * _Nullable arena,
242 uint32_t max_workers, os_workgroup_working_arena_destructor_t destructor);
243
244/*!
245 * @function os_workgroup_get_working_arena
246 *
247 * @abstract
248 * Returns the working arena associated with the workgroup and the current
249 * thread's index in the workgroup. This function can only be called by a member
250 * of the workgroup. Multiple calls to this API by a member thread will return
251 * the same arena and index until the thread leaves the workgroup.
252 *
253 * For workloops with an associated workgroup, every work item on the workloop
254 * will receive the same index in the arena.
255 *
256 * This method returns NULL if no arena is set on the workgroup. The index
257 * returned by this function is zero-based and is namespaced per workgroup
258 * object in the process. The indices provided are strictly monotonic and never
259 * reused until a future call to os_workgroup_set_working_arena.
260 *
261 * @param wg
262 * The workgroup to get the working arena from.
263 *
264 * @param index_out
265 * A pointer to a os_workgroup_index which will be populated by the caller's
266 * index in the workgroup.
267 */
268API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
269OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
270void * _Nullable
271os_workgroup_get_working_arena(os_workgroup_t wg,
272 os_workgroup_index * _Nullable index_out);
273
274/*!
275 * @function os_workgroup_cancel
276 *
277 * @abstract
278 * This API invalidates a workgroup and indicates to the system that the
279 * workload is no longer relevant to the caller.
280 *
281 * No new work should be initiated for a cancelled workgroup and
282 * work that is already underway should periodically check for
283 * cancellation with os_workgroup_testcancel and initiate cleanup if needed.
284 *
285 * Threads currently in the workgroup continue to be tracked together but no
286 * new threads may join this workgroup - the only possible operation allowed is
287 * to leave the workgroup. Other actions may have undefined behavior or
288 * otherwise fail.
289 *
290 * This API is idempotent. Cancellation is local to the workgroup object
291 * it is called on and does not affect other workgroups.
292 *
293 * @param wg
294 * The workgroup that that the thread would like to cancel
295 */
296API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
297OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
298void
299os_workgroup_cancel(os_workgroup_t wg);
300
301/*!
302 * @function os_workgroup_testcancel
303 *
304 * @abstract
305 * Returns true if the workgroup object has been cancelled. See also
306 * os_workgroup_cancel
307 */
308API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
309OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
310bool
311os_workgroup_testcancel(os_workgroup_t wg);
312
313/*!
314 * @typedef os_workgroup_max_parallel_threads_attr_t
315 *
316 * @abstract
317 * A pointer to a structure describing the set of properties of a workgroup to
318 * override with the explicitly specified values in the structure.
319 *
320 * See also os_workgroup_max_parallel_threads.
321 */
322OS_REFINED_FOR_SWIFT
323typedef struct os_workgroup_max_parallel_threads_attr_s os_workgroup_mpt_attr_s;
324OS_REFINED_FOR_SWIFT
325typedef struct os_workgroup_max_parallel_threads_attr_s *os_workgroup_mpt_attr_t;
326
327/*!
328 * @function os_workgroup_max_parallel_threads
329 *
330 * @abstract
331 * Returns the system's recommendation for maximum number of threads the client
332 * should make for a multi-threaded workload in a given workgroup.
333 *
334 * This API takes into consideration the current hardware the code is running on
335 * and the attributes of the workgroup. It does not take into consideration the
336 * current load of the system and therefore always provides the most optimal
337 * recommendation for the workload.
338 *
339 * @param wg
340 * The workgroup in which the multi-threaded workload will be performed in. The
341 * threads performing the multi-threaded workload are expected to join this
342 * workgroup.
343 *
344 * @param attr
345 * This value is currently unused and should be NULL.
346 */
347API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
348OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
349int
350os_workgroup_max_parallel_threads(os_workgroup_t wg, os_workgroup_mpt_attr_t
351 _Nullable attr);
352
353OS_WORKGROUP_ASSUME_NONNULL_END
354
355__END_DECLS
356
357#endif /* __OS_WORKGROUP_OBJECT__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup_parallel.h created+74
......@@ -0,0 +1,74 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_WORKGROUP_PARALLEL__
22#define __OS_WORKGROUP_PARALLEL__
23
24#ifndef __OS_WORKGROUP_INDIRECT__
25#error "Please #include <os/workgroup.h> instead of this file directly."
26#include <os/workgroup_base.h> // For header doc
27#endif
28
29#include <os/workgroup_object.h>
30
31__BEGIN_DECLS
32
33OS_WORKGROUP_ASSUME_NONNULL_BEGIN
34
35/*!
36 * @typedef os_workgroup_parallel_t
37 *
38 * @abstract
39 * A subclass of an os_workgroup_t for tracking parallel work.
40 */
41OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_parallel, Parallelizable);
42OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_parallel, os_workgroup, WorkGroupParallel);
43
44/*!
45 * @function os_workgroup_parallel_create
46 *
47 * @abstract
48 * Creates an os_workgroup_t which tracks a parallel workload.
49 * A newly created os_workgroup_interval_t has no initial member threads -
50 * in particular the creating thread does not join the os_workgroup_parallel_t
51 * implicitly.
52 *
53 * See also os_workgroup_max_parallel_threads().
54 *
55 * @param name
56 * A client specified string for labelling the workgroup. This parameter is
57 * optional and can be NULL.
58 *
59 * @param attr
60 * The requested set of workgroup attributes. NULL is to be specified for the
61 * default set of attributes.
62 */
63API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
64OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
65OS_SWIFT_NAME(WorkGroupParallel.init(__name:attr:))
66os_workgroup_parallel_t _Nullable
67os_workgroup_parallel_create(const char * _Nullable name,
68 os_workgroup_attr_t _Nullable attr);
69
70OS_WORKGROUP_ASSUME_NONNULL_END
71
72__END_DECLS
73
74#endif /* __OS_WORKGROUP_PARALLEL__ */
lib/libc/include/x86_64-macos-gnu/pthread.h+27-3
......@@ -53,9 +53,6 @@
5353#define _PTHREAD_H
5454
5555#include <_types.h>
56#ifndef __POSIX_LIB__
57#include <pthread/pthread_impl.h>
58#endif
5956#include <pthread/sched.h>
6057#include <time.h>
6158#include <sys/_pthread/_pthread_types.h>
......@@ -559,6 +556,33 @@ int pthread_sigmask(int, const sigset_t * _Nullable, sigset_t * _Nullable)
559556__API_AVAILABLE(macos(10.4), ios(2.0))
560557void pthread_yield_np(void);
561558
559__API_AVAILABLE(macos(11.0))
560__API_UNAVAILABLE(ios, tvos, watchos)
561void pthread_jit_write_protect_np(int enabled);
562
563__API_AVAILABLE(macos(11.0))
564__API_UNAVAILABLE(ios, tvos, watchos)
565int pthread_jit_write_protect_supported_np(void);
566
567/*!
568 * @function pthread_cpu_number_np
569 *
570 * @param cpu_number_out
571 * The CPU number that the thread was running on at the time of query.
572 * This cpu number is in the interval [0, ncpus) (from sysctlbyname("hw.ncpu"))
573 *
574 * @result
575 * This function returns 0 or the value of errno if an error occurred.
576 *
577 * @note
578 * Optimizations of per-CPU datastructures based on the result of this function
579 * still require synchronization since it is not guaranteed that the thread will
580 * still be on the same CPU by the time the function returns.
581 */
582__API_AVAILABLE(macos(11.0), ios(14.2), tvos(14.2), watchos(7.1))
583int
584pthread_cpu_number_np(size_t *cpu_number_out);
585
562586#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE || __cplusplus */
563587__END_DECLS
564588#if __has_feature(assume_nonnull)
lib/libc/include/x86_64-macos-gnu/pthread/sched.h+3-1
......@@ -25,7 +25,7 @@
2525#define _SCHED_H_
2626
2727#include <sys/cdefs.h>
28#include <pthread_impl.h>
28#include <pthread/pthread_impl.h>
2929
3030__BEGIN_DECLS
3131/*
......@@ -33,6 +33,8 @@ __BEGIN_DECLS
3333 */
3434#ifndef __POSIX_LIB__
3535struct sched_param { int sched_priority; char __opaque[__SCHED_PARAM_SIZE__]; };
36#else
37struct sched_param;
3638#endif
3739
3840extern int sched_yield(void);
lib/libc/include/x86_64-macos-gnu/pthread_impl.h deleted-66
......@@ -1,66 +0,0 @@
1/*
2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef _PTHREAD_IMPL_H_
25#define _PTHREAD_IMPL_H_
26/*
27 * Internal implementation details
28 */
29
30/* This whole header file will disappear, so don't depend on it... */
31
32#if __has_feature(assume_nonnull)
33_Pragma("clang assume_nonnull begin")
34#endif
35
36#ifndef __POSIX_LIB__
37
38/*
39 * [Internal] data structure signatures
40 */
41#define _PTHREAD_MUTEX_SIG_init 0x32AAABA7
42
43#define _PTHREAD_ERRORCHECK_MUTEX_SIG_init 0x32AAABA1
44#define _PTHREAD_RECURSIVE_MUTEX_SIG_init 0x32AAABA2
45#define _PTHREAD_FIRSTFIT_MUTEX_SIG_init 0x32AAABA3
46
47#define _PTHREAD_COND_SIG_init 0x3CB0B1BB
48#define _PTHREAD_ONCE_SIG_init 0x30B1BCBA
49#define _PTHREAD_RWLOCK_SIG_init 0x2DA8B3B4
50
51/*
52 * POSIX scheduling policies
53 */
54#define SCHED_OTHER 1
55#define SCHED_FIFO 4
56#define SCHED_RR 2
57
58#define __SCHED_PARAM_SIZE__ 4
59
60#endif /* __POSIX_LIB__ */
61
62#if __has_feature(assume_nonnull)
63_Pragma("clang assume_nonnull end")
64#endif
65
66#endif /* _PTHREAD_IMPL_H_ */
lib/libc/include/x86_64-macos-gnu/sched.h+3-1
......@@ -25,7 +25,7 @@
2525#define _SCHED_H_
2626
2727#include <sys/cdefs.h>
28#include <pthread_impl.h>
28#include <pthread/pthread_impl.h>
2929
3030__BEGIN_DECLS
3131/*
......@@ -33,6 +33,8 @@ __BEGIN_DECLS
3333 */
3434#ifndef __POSIX_LIB__
3535struct sched_param { int sched_priority; char __opaque[__SCHED_PARAM_SIZE__]; };
36#else
37struct sched_param;
3638#endif
3739
3840extern int sched_yield(void);
lib/libc/include/x86_64-macos-gnu/signal.h-5
......@@ -108,16 +108,11 @@ int sigvec(int, struct sigvec *, struct sigvec *);
108108__END_DECLS
109109
110110/* List definitions after function declarations, or Reiser cpp gets upset. */
111#if defined(__i386__) || defined(__x86_64__)
112/* The left shift operator on intel is modulo 32 */
113111__header_always_inline int
114112__sigbits(int __signo)
115113{
116114 return __signo > __DARWIN_NSIG ? 0 : (1 << (__signo - 1));
117115}
118#else /* !__i386__ && !__x86_64__ */
119#define __sigbits(signo) (1 << ((signo) - 1))
120#endif /* __i386__ || __x86_64__ */
121116
122117#define sigaddset(set, signo) (*(set) |= __sigbits(signo), 0)
123118#define sigdelset(set, signo) (*(set) &= ~__sigbits(signo), 0)
lib/libc/include/x86_64-macos-gnu/simd/base.h created+122
......@@ -0,0 +1,122 @@
1/*! @header
2 * This header defines macros used in the implementation of <simd/simd.h>
3 * types and functions. Even though they are exposed in a public header,
4 * the macros defined in this header are implementation details, and you
5 * should not use or rely on them. They may be changed or removed entirely
6 * in a future release.
7 *
8 * @copyright 2016-2017 Apple, Inc. All rights reserved.
9 * @unsorted */
10
11#ifndef SIMD_BASE
12#define SIMD_BASE
13
14/* Define __has_attribute and __has_include if they aren't available */
15# ifndef __has_attribute
16# define __has_attribute(__x) 0
17# endif
18# ifndef __has_include
19# define __has_include(__x) 0
20# endif
21# ifndef __has_feature
22# define __has_feature(__x) 0
23# endif
24
25# if __has_attribute(__ext_vector_type__) && __has_attribute(__overloadable__)
26# define SIMD_COMPILER_HAS_REQUIRED_FEATURES 1
27# else
28/* Your compiler is missing one or more features that are hard requirements
29 * for any <simd/simd.h> support. None of the types or functions defined by
30 * the simd headers will be available. */
31# define SIMD_COMPILER_HAS_REQUIRED_FEATURES 0
32# endif
33
34# if SIMD_COMPILER_HAS_REQUIRED_FEATURES
35# if __has_include(<Availability.h>)
36# include <Availability.h>
37/* A number of new features are added in newer releases; most of these are
38 * inline in the header, which makes them available even when targeting older
39 * OS versions. Those that make external calls, however, are only available
40 * when targeting the release in which they became available. Because of the
41 * way in which simd functions are overloaded, the usual weak-linking tricks
42 * do not work; these functions are simply unavailable when targeting older
43 * versions of the library. */
44# if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13 || \
45 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_11_0 || \
46 __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_4_0 || \
47 __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_11_0 || \
48 __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_19_0
49# define SIMD_LIBRARY_VERSION 3
50# elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12 || \
51 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0 || \
52 __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0 || \
53 __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0
54# define SIMD_LIBRARY_VERSION 2
55# elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || \
56 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0
57# define SIMD_LIBRARY_VERSION 1
58# else
59# define SIMD_LIBRARY_VERSION 0
60# endif
61# else /* !__has_include(<Availability.h>) */
62# define SIMD_LIBRARY_VERSION 3
63# define __API_AVAILABLE(...) /* Nothing */
64# endif
65
66/* The simd types interoperate with the native simd intrinsic types for each
67 * architecture; the headers that define those types and operations are
68 * automatically included with simd.h */
69# if defined __ARM_NEON__
70# include <arm_neon.h>
71# elif defined __i386__ || defined __x86_64__
72# include <immintrin.h>
73# endif
74
75/* Define a number of function attributes used by the simd functions. */
76# if __has_attribute(__always_inline__)
77# define SIMD_INLINE __attribute__((__always_inline__))
78# else
79# define SIMD_INLINE inline
80# endif
81
82# if __has_attribute(__const__)
83# define SIMD_CONST __attribute__((__const__))
84# else
85# define SIMD_CONST /* nothing */
86# endif
87
88# if __has_attribute(__nodebug__)
89# define SIMD_NODEBUG __attribute__((__nodebug__))
90# else
91# define SIMD_NODEBUG /* nothing */
92# endif
93
94# if __has_attribute(__deprecated__)
95# define SIMD_DEPRECATED(message) __attribute__((__deprecated__(message)))
96# else
97# define SIMD_DEPRECATED(message) /* nothing */
98# endif
99
100#define SIMD_OVERLOAD __attribute__((__overloadable__))
101#define SIMD_CPPFUNC SIMD_INLINE SIMD_CONST SIMD_NODEBUG
102#define SIMD_CFUNC SIMD_CPPFUNC SIMD_OVERLOAD
103#define SIMD_NOINLINE SIMD_CONST SIMD_NODEBUG SIMD_OVERLOAD
104#define SIMD_NONCONST SIMD_INLINE SIMD_NODEBUG SIMD_OVERLOAD
105#define __SIMD_INLINE__ SIMD_CPPFUNC
106#define __SIMD_ATTRIBUTES__ SIMD_CFUNC
107#define __SIMD_OVERLOAD__ SIMD_OVERLOAD
108
109#if defined __cplusplus
110/*! @abstract A boolean scalar. */
111typedef bool simd_bool;
112#else
113/*! @abstract A boolean scalar. */
114typedef _Bool simd_bool;
115#endif
116/*! @abstract A boolean scalar.
117 * @discussion This type is deprecated; In C or Objective-C sources, use
118 * `_Bool` instead. In C++ sources, use `bool`. */
119typedef simd_bool __SIMD_BOOLEAN_TYPE__;
120
121# endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
122#endif /* defined SIMD_BASE */
lib/libc/include/x86_64-macos-gnu/simd/common.h created+4458
......@@ -0,0 +1,4458 @@
1/*! @header
2 * The interfaces declared in this header provide "common" elementwise
3 * operations that are neither math nor logic functions. These are available
4 * only for floating-point vectors and scalars, except for min, max, abs,
5 * clamp, and the reduce operations, which also support integer vectors.
6 *
7 * simd_abs(x) Absolute value of x. Also available as fabs
8 * for floating-point vectors. If x is the
9 * smallest signed integer, x is returned.
10 *
11 * simd_max(x,y) Returns the maximum of x and y. Also available
12 * as fmax for floating-point vectors.
13 *
14 * simd_min(x,y) Returns the minimum of x and y. Also available
15 * as fmin for floating-point vectors.
16 *
17 * simd_clamp(x,min,max) x clamped to the range [min, max].
18 *
19 * simd_sign(x) -1 if x is less than zero, 0 if x is zero or
20 * NaN, and +1 if x is greater than zero.
21 *
22 * simd_mix(x,y,t) If t is not in the range [0,1], the result is
23 * undefined. Otherwise the result is x+(y-x)*t,
24 * which linearly interpolates between x and y.
25 *
26 * simd_recip(x) An approximation to 1/x. If x is very near the
27 * limits of representable values, or is infinity
28 * or NaN, the result is undefined. There are
29 * two variants of this function:
30 *
31 * simd_precise_recip(x)
32 *
33 * and
34 *
35 * simd_fast_recip(x).
36 *
37 * The "precise" variant is accurate to a few ULPs,
38 * whereas the "fast" variant may have as little
39 * as 11 bits of accuracy in float and about 22
40 * bits in double.
41 *
42 * The function simd_recip(x) resolves to
43 * simd_precise_recip(x) ordinarily, but to
44 * simd_fast_recip(x) when used in a translation
45 * unit compiled with -ffast-math (when
46 * -ffast-math is in effect, you may still use the
47 * precise version of this function by calling it
48 * explicitly by name).
49 *
50 * simd_rsqrt(x) An approximation to 1/sqrt(x). If x is
51 * infinity or NaN, the result is undefined.
52 * There are two variants of this function:
53 *
54 * simd_precise_rsqrt(x)
55 *
56 * and
57 *
58 * simd_fast_rsqrt(x).
59 *
60 * The "precise" variant is accurate to a few ULPs,
61 * whereas the "fast" variant may have as little
62 * as 11 bits of accuracy in float and about 22
63 * bits in double.
64 *
65 * The function simd_rsqrt(x) resolves to
66 * simd_precise_rsqrt(x) ordinarily, but to
67 * simd_fast_rsqrt(x) when used in a translation
68 * unit compiled with -ffast-math (when
69 * -ffast-math is in effect, you may still use the
70 * precise version of this function by calling it
71 * explicitly by name).
72 *
73 * simd_fract(x) The "fractional part" of x, which lies strictly
74 * in the range [0, 0x1.fffffep-1].
75 *
76 * simd_step(edge,x) 0 if x < edge, and 1 otherwise.
77 *
78 * simd_smoothstep(edge0,edge1,x) 0 if x <= edge0, 1 if x >= edge1, and
79 * a Hermite interpolation between 0 and 1 if
80 * edge0 < x < edge1.
81 *
82 * simd_reduce_add(x) Sum of the elements of x.
83 *
84 * simd_reduce_min(x) Minimum of the elements of x.
85 *
86 * simd_reduce_max(x) Maximum of the elements of x.
87 *
88 * simd_equal(x,y) True if and only if every lane of x is equal
89 * to the corresponding lane of y.
90 *
91 * The following common functions are available in the simd:: namespace:
92 *
93 * C++ Function Equivalent C Function
94 * --------------------------------------------------------------------
95 * simd::abs(x) simd_abs(x)
96 * simd::max(x,y) simd_max(x,y)
97 * simd::min(x,y) simd_min(x,y)
98 * simd::clamp(x,min,max) simd_clamp(x,min,max)
99 * simd::sign(x) simd_sign(x)
100 * simd::mix(x,y,t) simd_mix(x,y,t)
101 * simd::recip(x) simd_recip(x)
102 * simd::rsqrt(x) simd_rsqrt(x)
103 * simd::fract(x) simd_fract(x)
104 * simd::step(edge,x) simd_step(edge,x)
105 * simd::smoothstep(e0,e1,x) simd_smoothstep(e0,e1,x)
106 * simd::reduce_add(x) simd_reduce_add(x)
107 * simd::reduce_max(x) simd_reduce_max(x)
108 * simd::reduce_min(x) simd_reduce_min(x)
109 * simd::equal(x,y) simd_equal(x,y)
110 *
111 * simd::precise::recip(x) simd_precise_recip(x)
112 * simd::precise::rsqrt(x) simd_precise_rsqrt(x)
113 *
114 * simd::fast::recip(x) simd_fast_recip(x)
115 * simd::fast::rsqrt(x) simd_fast_rsqrt(x)
116 *
117 * @copyright 2014-2017 Apple, Inc. All rights reserved.
118 * @unsorted */
119
120#ifndef SIMD_COMMON_HEADER
121#define SIMD_COMMON_HEADER
122
123#include <simd/base.h>
124#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
125#include <simd/vector_make.h>
126#include <simd/logic.h>
127#include <simd/math.h>
128
129#ifdef __cplusplus
130extern "C" {
131#endif
132
133/*! @abstract The elementwise absolute value of x. */
134static inline SIMD_CFUNC simd_char2 simd_abs(simd_char2 x);
135/*! @abstract The elementwise absolute value of x. */
136static inline SIMD_CFUNC simd_char3 simd_abs(simd_char3 x);
137/*! @abstract The elementwise absolute value of x. */
138static inline SIMD_CFUNC simd_char4 simd_abs(simd_char4 x);
139/*! @abstract The elementwise absolute value of x. */
140static inline SIMD_CFUNC simd_char8 simd_abs(simd_char8 x);
141/*! @abstract The elementwise absolute value of x. */
142static inline SIMD_CFUNC simd_char16 simd_abs(simd_char16 x);
143/*! @abstract The elementwise absolute value of x. */
144static inline SIMD_CFUNC simd_char32 simd_abs(simd_char32 x);
145/*! @abstract The elementwise absolute value of x. */
146static inline SIMD_CFUNC simd_char64 simd_abs(simd_char64 x);
147/*! @abstract The elementwise absolute value of x. */
148static inline SIMD_CFUNC simd_short2 simd_abs(simd_short2 x);
149/*! @abstract The elementwise absolute value of x. */
150static inline SIMD_CFUNC simd_short3 simd_abs(simd_short3 x);
151/*! @abstract The elementwise absolute value of x. */
152static inline SIMD_CFUNC simd_short4 simd_abs(simd_short4 x);
153/*! @abstract The elementwise absolute value of x. */
154static inline SIMD_CFUNC simd_short8 simd_abs(simd_short8 x);
155/*! @abstract The elementwise absolute value of x. */
156static inline SIMD_CFUNC simd_short16 simd_abs(simd_short16 x);
157/*! @abstract The elementwise absolute value of x. */
158static inline SIMD_CFUNC simd_short32 simd_abs(simd_short32 x);
159/*! @abstract The elementwise absolute value of x. */
160static inline SIMD_CFUNC simd_int2 simd_abs(simd_int2 x);
161/*! @abstract The elementwise absolute value of x. */
162static inline SIMD_CFUNC simd_int3 simd_abs(simd_int3 x);
163/*! @abstract The elementwise absolute value of x. */
164static inline SIMD_CFUNC simd_int4 simd_abs(simd_int4 x);
165/*! @abstract The elementwise absolute value of x. */
166static inline SIMD_CFUNC simd_int8 simd_abs(simd_int8 x);
167/*! @abstract The elementwise absolute value of x. */
168static inline SIMD_CFUNC simd_int16 simd_abs(simd_int16 x);
169/*! @abstract The elementwise absolute value of x. */
170static inline SIMD_CFUNC simd_float2 simd_abs(simd_float2 x);
171/*! @abstract The elementwise absolute value of x. */
172static inline SIMD_CFUNC simd_float3 simd_abs(simd_float3 x);
173/*! @abstract The elementwise absolute value of x. */
174static inline SIMD_CFUNC simd_float4 simd_abs(simd_float4 x);
175/*! @abstract The elementwise absolute value of x. */
176static inline SIMD_CFUNC simd_float8 simd_abs(simd_float8 x);
177/*! @abstract The elementwise absolute value of x. */
178static inline SIMD_CFUNC simd_float16 simd_abs(simd_float16 x);
179/*! @abstract The elementwise absolute value of x. */
180static inline SIMD_CFUNC simd_long2 simd_abs(simd_long2 x);
181/*! @abstract The elementwise absolute value of x. */
182static inline SIMD_CFUNC simd_long3 simd_abs(simd_long3 x);
183/*! @abstract The elementwise absolute value of x. */
184static inline SIMD_CFUNC simd_long4 simd_abs(simd_long4 x);
185/*! @abstract The elementwise absolute value of x. */
186static inline SIMD_CFUNC simd_long8 simd_abs(simd_long8 x);
187/*! @abstract The elementwise absolute value of x. */
188static inline SIMD_CFUNC simd_double2 simd_abs(simd_double2 x);
189/*! @abstract The elementwise absolute value of x. */
190static inline SIMD_CFUNC simd_double3 simd_abs(simd_double3 x);
191/*! @abstract The elementwise absolute value of x. */
192static inline SIMD_CFUNC simd_double4 simd_abs(simd_double4 x);
193/*! @abstract The elementwise absolute value of x. */
194static inline SIMD_CFUNC simd_double8 simd_abs(simd_double8 x);
195/*! @abstract The elementwise absolute value of x.
196 * @discussion Deprecated. Use simd_abs(x) instead. */
197#define vector_abs simd_abs
198
199/*! @abstract The elementwise maximum of x and y. */
200static inline SIMD_CFUNC simd_char2 simd_max(simd_char2 x, simd_char2 y);
201/*! @abstract The elementwise maximum of x and y. */
202static inline SIMD_CFUNC simd_char3 simd_max(simd_char3 x, simd_char3 y);
203/*! @abstract The elementwise maximum of x and y. */
204static inline SIMD_CFUNC simd_char4 simd_max(simd_char4 x, simd_char4 y);
205/*! @abstract The elementwise maximum of x and y. */
206static inline SIMD_CFUNC simd_char8 simd_max(simd_char8 x, simd_char8 y);
207/*! @abstract The elementwise maximum of x and y. */
208static inline SIMD_CFUNC simd_char16 simd_max(simd_char16 x, simd_char16 y);
209/*! @abstract The elementwise maximum of x and y. */
210static inline SIMD_CFUNC simd_char32 simd_max(simd_char32 x, simd_char32 y);
211/*! @abstract The elementwise maximum of x and y. */
212static inline SIMD_CFUNC simd_char64 simd_max(simd_char64 x, simd_char64 y);
213/*! @abstract The elementwise maximum of x and y. */
214static inline SIMD_CFUNC simd_uchar2 simd_max(simd_uchar2 x, simd_uchar2 y);
215/*! @abstract The elementwise maximum of x and y. */
216static inline SIMD_CFUNC simd_uchar3 simd_max(simd_uchar3 x, simd_uchar3 y);
217/*! @abstract The elementwise maximum of x and y. */
218static inline SIMD_CFUNC simd_uchar4 simd_max(simd_uchar4 x, simd_uchar4 y);
219/*! @abstract The elementwise maximum of x and y. */
220static inline SIMD_CFUNC simd_uchar8 simd_max(simd_uchar8 x, simd_uchar8 y);
221/*! @abstract The elementwise maximum of x and y. */
222static inline SIMD_CFUNC simd_uchar16 simd_max(simd_uchar16 x, simd_uchar16 y);
223/*! @abstract The elementwise maximum of x and y. */
224static inline SIMD_CFUNC simd_uchar32 simd_max(simd_uchar32 x, simd_uchar32 y);
225/*! @abstract The elementwise maximum of x and y. */
226static inline SIMD_CFUNC simd_uchar64 simd_max(simd_uchar64 x, simd_uchar64 y);
227/*! @abstract The elementwise maximum of x and y. */
228static inline SIMD_CFUNC simd_short2 simd_max(simd_short2 x, simd_short2 y);
229/*! @abstract The elementwise maximum of x and y. */
230static inline SIMD_CFUNC simd_short3 simd_max(simd_short3 x, simd_short3 y);
231/*! @abstract The elementwise maximum of x and y. */
232static inline SIMD_CFUNC simd_short4 simd_max(simd_short4 x, simd_short4 y);
233/*! @abstract The elementwise maximum of x and y. */
234static inline SIMD_CFUNC simd_short8 simd_max(simd_short8 x, simd_short8 y);
235/*! @abstract The elementwise maximum of x and y. */
236static inline SIMD_CFUNC simd_short16 simd_max(simd_short16 x, simd_short16 y);
237/*! @abstract The elementwise maximum of x and y. */
238static inline SIMD_CFUNC simd_short32 simd_max(simd_short32 x, simd_short32 y);
239/*! @abstract The elementwise maximum of x and y. */
240static inline SIMD_CFUNC simd_ushort2 simd_max(simd_ushort2 x, simd_ushort2 y);
241/*! @abstract The elementwise maximum of x and y. */
242static inline SIMD_CFUNC simd_ushort3 simd_max(simd_ushort3 x, simd_ushort3 y);
243/*! @abstract The elementwise maximum of x and y. */
244static inline SIMD_CFUNC simd_ushort4 simd_max(simd_ushort4 x, simd_ushort4 y);
245/*! @abstract The elementwise maximum of x and y. */
246static inline SIMD_CFUNC simd_ushort8 simd_max(simd_ushort8 x, simd_ushort8 y);
247/*! @abstract The elementwise maximum of x and y. */
248static inline SIMD_CFUNC simd_ushort16 simd_max(simd_ushort16 x, simd_ushort16 y);
249/*! @abstract The elementwise maximum of x and y. */
250static inline SIMD_CFUNC simd_ushort32 simd_max(simd_ushort32 x, simd_ushort32 y);
251/*! @abstract The elementwise maximum of x and y. */
252static inline SIMD_CFUNC simd_int2 simd_max(simd_int2 x, simd_int2 y);
253/*! @abstract The elementwise maximum of x and y. */
254static inline SIMD_CFUNC simd_int3 simd_max(simd_int3 x, simd_int3 y);
255/*! @abstract The elementwise maximum of x and y. */
256static inline SIMD_CFUNC simd_int4 simd_max(simd_int4 x, simd_int4 y);
257/*! @abstract The elementwise maximum of x and y. */
258static inline SIMD_CFUNC simd_int8 simd_max(simd_int8 x, simd_int8 y);
259/*! @abstract The elementwise maximum of x and y. */
260static inline SIMD_CFUNC simd_int16 simd_max(simd_int16 x, simd_int16 y);
261/*! @abstract The elementwise maximum of x and y. */
262static inline SIMD_CFUNC simd_uint2 simd_max(simd_uint2 x, simd_uint2 y);
263/*! @abstract The elementwise maximum of x and y. */
264static inline SIMD_CFUNC simd_uint3 simd_max(simd_uint3 x, simd_uint3 y);
265/*! @abstract The elementwise maximum of x and y. */
266static inline SIMD_CFUNC simd_uint4 simd_max(simd_uint4 x, simd_uint4 y);
267/*! @abstract The elementwise maximum of x and y. */
268static inline SIMD_CFUNC simd_uint8 simd_max(simd_uint8 x, simd_uint8 y);
269/*! @abstract The elementwise maximum of x and y. */
270static inline SIMD_CFUNC simd_uint16 simd_max(simd_uint16 x, simd_uint16 y);
271/*! @abstract The elementwise maximum of x and y. */
272static inline SIMD_CFUNC float simd_max(float x, float y);
273/*! @abstract The elementwise maximum of x and y. */
274static inline SIMD_CFUNC simd_float2 simd_max(simd_float2 x, simd_float2 y);
275/*! @abstract The elementwise maximum of x and y. */
276static inline SIMD_CFUNC simd_float3 simd_max(simd_float3 x, simd_float3 y);
277/*! @abstract The elementwise maximum of x and y. */
278static inline SIMD_CFUNC simd_float4 simd_max(simd_float4 x, simd_float4 y);
279/*! @abstract The elementwise maximum of x and y. */
280static inline SIMD_CFUNC simd_float8 simd_max(simd_float8 x, simd_float8 y);
281/*! @abstract The elementwise maximum of x and y. */
282static inline SIMD_CFUNC simd_float16 simd_max(simd_float16 x, simd_float16 y);
283/*! @abstract The elementwise maximum of x and y. */
284static inline SIMD_CFUNC simd_long2 simd_max(simd_long2 x, simd_long2 y);
285/*! @abstract The elementwise maximum of x and y. */
286static inline SIMD_CFUNC simd_long3 simd_max(simd_long3 x, simd_long3 y);
287/*! @abstract The elementwise maximum of x and y. */
288static inline SIMD_CFUNC simd_long4 simd_max(simd_long4 x, simd_long4 y);
289/*! @abstract The elementwise maximum of x and y. */
290static inline SIMD_CFUNC simd_long8 simd_max(simd_long8 x, simd_long8 y);
291/*! @abstract The elementwise maximum of x and y. */
292static inline SIMD_CFUNC simd_ulong2 simd_max(simd_ulong2 x, simd_ulong2 y);
293/*! @abstract The elementwise maximum of x and y. */
294static inline SIMD_CFUNC simd_ulong3 simd_max(simd_ulong3 x, simd_ulong3 y);
295/*! @abstract The elementwise maximum of x and y. */
296static inline SIMD_CFUNC simd_ulong4 simd_max(simd_ulong4 x, simd_ulong4 y);
297/*! @abstract The elementwise maximum of x and y. */
298static inline SIMD_CFUNC simd_ulong8 simd_max(simd_ulong8 x, simd_ulong8 y);
299/*! @abstract The elementwise maximum of x and y. */
300static inline SIMD_CFUNC double simd_max(double x, double y);
301/*! @abstract The elementwise maximum of x and y. */
302static inline SIMD_CFUNC simd_double2 simd_max(simd_double2 x, simd_double2 y);
303/*! @abstract The elementwise maximum of x and y. */
304static inline SIMD_CFUNC simd_double3 simd_max(simd_double3 x, simd_double3 y);
305/*! @abstract The elementwise maximum of x and y. */
306static inline SIMD_CFUNC simd_double4 simd_max(simd_double4 x, simd_double4 y);
307/*! @abstract The elementwise maximum of x and y. */
308static inline SIMD_CFUNC simd_double8 simd_max(simd_double8 x, simd_double8 y);
309/*! @abstract The elementwise maximum of x and y.
310 * @discussion Deprecated. Use simd_max(x,y) instead. */
311#define vector_max simd_max
312
313/*! @abstract The elementwise minimum of x and y. */
314static inline SIMD_CFUNC simd_char2 simd_min(simd_char2 x, simd_char2 y);
315/*! @abstract The elementwise minimum of x and y. */
316static inline SIMD_CFUNC simd_char3 simd_min(simd_char3 x, simd_char3 y);
317/*! @abstract The elementwise minimum of x and y. */
318static inline SIMD_CFUNC simd_char4 simd_min(simd_char4 x, simd_char4 y);
319/*! @abstract The elementwise minimum of x and y. */
320static inline SIMD_CFUNC simd_char8 simd_min(simd_char8 x, simd_char8 y);
321/*! @abstract The elementwise minimum of x and y. */
322static inline SIMD_CFUNC simd_char16 simd_min(simd_char16 x, simd_char16 y);
323/*! @abstract The elementwise minimum of x and y. */
324static inline SIMD_CFUNC simd_char32 simd_min(simd_char32 x, simd_char32 y);
325/*! @abstract The elementwise minimum of x and y. */
326static inline SIMD_CFUNC simd_char64 simd_min(simd_char64 x, simd_char64 y);
327/*! @abstract The elementwise minimum of x and y. */
328static inline SIMD_CFUNC simd_uchar2 simd_min(simd_uchar2 x, simd_uchar2 y);
329/*! @abstract The elementwise minimum of x and y. */
330static inline SIMD_CFUNC simd_uchar3 simd_min(simd_uchar3 x, simd_uchar3 y);
331/*! @abstract The elementwise minimum of x and y. */
332static inline SIMD_CFUNC simd_uchar4 simd_min(simd_uchar4 x, simd_uchar4 y);
333/*! @abstract The elementwise minimum of x and y. */
334static inline SIMD_CFUNC simd_uchar8 simd_min(simd_uchar8 x, simd_uchar8 y);
335/*! @abstract The elementwise minimum of x and y. */
336static inline SIMD_CFUNC simd_uchar16 simd_min(simd_uchar16 x, simd_uchar16 y);
337/*! @abstract The elementwise minimum of x and y. */
338static inline SIMD_CFUNC simd_uchar32 simd_min(simd_uchar32 x, simd_uchar32 y);
339/*! @abstract The elementwise minimum of x and y. */
340static inline SIMD_CFUNC simd_uchar64 simd_min(simd_uchar64 x, simd_uchar64 y);
341/*! @abstract The elementwise minimum of x and y. */
342static inline SIMD_CFUNC simd_short2 simd_min(simd_short2 x, simd_short2 y);
343/*! @abstract The elementwise minimum of x and y. */
344static inline SIMD_CFUNC simd_short3 simd_min(simd_short3 x, simd_short3 y);
345/*! @abstract The elementwise minimum of x and y. */
346static inline SIMD_CFUNC simd_short4 simd_min(simd_short4 x, simd_short4 y);
347/*! @abstract The elementwise minimum of x and y. */
348static inline SIMD_CFUNC simd_short8 simd_min(simd_short8 x, simd_short8 y);
349/*! @abstract The elementwise minimum of x and y. */
350static inline SIMD_CFUNC simd_short16 simd_min(simd_short16 x, simd_short16 y);
351/*! @abstract The elementwise minimum of x and y. */
352static inline SIMD_CFUNC simd_short32 simd_min(simd_short32 x, simd_short32 y);
353/*! @abstract The elementwise minimum of x and y. */
354static inline SIMD_CFUNC simd_ushort2 simd_min(simd_ushort2 x, simd_ushort2 y);
355/*! @abstract The elementwise minimum of x and y. */
356static inline SIMD_CFUNC simd_ushort3 simd_min(simd_ushort3 x, simd_ushort3 y);
357/*! @abstract The elementwise minimum of x and y. */
358static inline SIMD_CFUNC simd_ushort4 simd_min(simd_ushort4 x, simd_ushort4 y);
359/*! @abstract The elementwise minimum of x and y. */
360static inline SIMD_CFUNC simd_ushort8 simd_min(simd_ushort8 x, simd_ushort8 y);
361/*! @abstract The elementwise minimum of x and y. */
362static inline SIMD_CFUNC simd_ushort16 simd_min(simd_ushort16 x, simd_ushort16 y);
363/*! @abstract The elementwise minimum of x and y. */
364static inline SIMD_CFUNC simd_ushort32 simd_min(simd_ushort32 x, simd_ushort32 y);
365/*! @abstract The elementwise minimum of x and y. */
366static inline SIMD_CFUNC simd_int2 simd_min(simd_int2 x, simd_int2 y);
367/*! @abstract The elementwise minimum of x and y. */
368static inline SIMD_CFUNC simd_int3 simd_min(simd_int3 x, simd_int3 y);
369/*! @abstract The elementwise minimum of x and y. */
370static inline SIMD_CFUNC simd_int4 simd_min(simd_int4 x, simd_int4 y);
371/*! @abstract The elementwise minimum of x and y. */
372static inline SIMD_CFUNC simd_int8 simd_min(simd_int8 x, simd_int8 y);
373/*! @abstract The elementwise minimum of x and y. */
374static inline SIMD_CFUNC simd_int16 simd_min(simd_int16 x, simd_int16 y);
375/*! @abstract The elementwise minimum of x and y. */
376static inline SIMD_CFUNC simd_uint2 simd_min(simd_uint2 x, simd_uint2 y);
377/*! @abstract The elementwise minimum of x and y. */
378static inline SIMD_CFUNC simd_uint3 simd_min(simd_uint3 x, simd_uint3 y);
379/*! @abstract The elementwise minimum of x and y. */
380static inline SIMD_CFUNC simd_uint4 simd_min(simd_uint4 x, simd_uint4 y);
381/*! @abstract The elementwise minimum of x and y. */
382static inline SIMD_CFUNC simd_uint8 simd_min(simd_uint8 x, simd_uint8 y);
383/*! @abstract The elementwise minimum of x and y. */
384static inline SIMD_CFUNC simd_uint16 simd_min(simd_uint16 x, simd_uint16 y);
385/*! @abstract The elementwise minimum of x and y. */
386static inline SIMD_CFUNC float simd_min(float x, float y);
387/*! @abstract The elementwise minimum of x and y. */
388static inline SIMD_CFUNC simd_float2 simd_min(simd_float2 x, simd_float2 y);
389/*! @abstract The elementwise minimum of x and y. */
390static inline SIMD_CFUNC simd_float3 simd_min(simd_float3 x, simd_float3 y);
391/*! @abstract The elementwise minimum of x and y. */
392static inline SIMD_CFUNC simd_float4 simd_min(simd_float4 x, simd_float4 y);
393/*! @abstract The elementwise minimum of x and y. */
394static inline SIMD_CFUNC simd_float8 simd_min(simd_float8 x, simd_float8 y);
395/*! @abstract The elementwise minimum of x and y. */
396static inline SIMD_CFUNC simd_float16 simd_min(simd_float16 x, simd_float16 y);
397/*! @abstract The elementwise minimum of x and y. */
398static inline SIMD_CFUNC simd_long2 simd_min(simd_long2 x, simd_long2 y);
399/*! @abstract The elementwise minimum of x and y. */
400static inline SIMD_CFUNC simd_long3 simd_min(simd_long3 x, simd_long3 y);
401/*! @abstract The elementwise minimum of x and y. */
402static inline SIMD_CFUNC simd_long4 simd_min(simd_long4 x, simd_long4 y);
403/*! @abstract The elementwise minimum of x and y. */
404static inline SIMD_CFUNC simd_long8 simd_min(simd_long8 x, simd_long8 y);
405/*! @abstract The elementwise minimum of x and y. */
406static inline SIMD_CFUNC simd_ulong2 simd_min(simd_ulong2 x, simd_ulong2 y);
407/*! @abstract The elementwise minimum of x and y. */
408static inline SIMD_CFUNC simd_ulong3 simd_min(simd_ulong3 x, simd_ulong3 y);
409/*! @abstract The elementwise minimum of x and y. */
410static inline SIMD_CFUNC simd_ulong4 simd_min(simd_ulong4 x, simd_ulong4 y);
411/*! @abstract The elementwise minimum of x and y. */
412static inline SIMD_CFUNC simd_ulong8 simd_min(simd_ulong8 x, simd_ulong8 y);
413/*! @abstract The elementwise minimum of x and y. */
414static inline SIMD_CFUNC double simd_min(double x, double y);
415/*! @abstract The elementwise minimum of x and y. */
416static inline SIMD_CFUNC simd_double2 simd_min(simd_double2 x, simd_double2 y);
417/*! @abstract The elementwise minimum of x and y. */
418static inline SIMD_CFUNC simd_double3 simd_min(simd_double3 x, simd_double3 y);
419/*! @abstract The elementwise minimum of x and y. */
420static inline SIMD_CFUNC simd_double4 simd_min(simd_double4 x, simd_double4 y);
421/*! @abstract The elementwise minimum of x and y. */
422static inline SIMD_CFUNC simd_double8 simd_min(simd_double8 x, simd_double8 y);
423/*! @abstract The elementwise minimum of x and y.
424 * @discussion Deprecated. Use simd_min(x,y) instead. */
425#define vector_min simd_min
426
427
428/*! @abstract x clamped to the range [min, max].
429 * @discussion Note that if you want to clamp all lanes to the same range,
430 * you can use a scalar value for min and max. */
431static inline SIMD_CFUNC simd_char2 simd_clamp(simd_char2 x, simd_char2 min, simd_char2 max);
432/*! @abstract x clamped to the range [min, max].
433 * @discussion Note that if you want to clamp all lanes to the same range,
434 * you can use a scalar value for min and max. */
435static inline SIMD_CFUNC simd_char3 simd_clamp(simd_char3 x, simd_char3 min, simd_char3 max);
436/*! @abstract x clamped to the range [min, max].
437 * @discussion Note that if you want to clamp all lanes to the same range,
438 * you can use a scalar value for min and max. */
439static inline SIMD_CFUNC simd_char4 simd_clamp(simd_char4 x, simd_char4 min, simd_char4 max);
440/*! @abstract x clamped to the range [min, max].
441 * @discussion Note that if you want to clamp all lanes to the same range,
442 * you can use a scalar value for min and max. */
443static inline SIMD_CFUNC simd_char8 simd_clamp(simd_char8 x, simd_char8 min, simd_char8 max);
444/*! @abstract x clamped to the range [min, max].
445 * @discussion Note that if you want to clamp all lanes to the same range,
446 * you can use a scalar value for min and max. */
447static inline SIMD_CFUNC simd_char16 simd_clamp(simd_char16 x, simd_char16 min, simd_char16 max);
448/*! @abstract x clamped to the range [min, max].
449 * @discussion Note that if you want to clamp all lanes to the same range,
450 * you can use a scalar value for min and max. */
451static inline SIMD_CFUNC simd_char32 simd_clamp(simd_char32 x, simd_char32 min, simd_char32 max);
452/*! @abstract x clamped to the range [min, max].
453 * @discussion Note that if you want to clamp all lanes to the same range,
454 * you can use a scalar value for min and max. */
455static inline SIMD_CFUNC simd_char64 simd_clamp(simd_char64 x, simd_char64 min, simd_char64 max);
456/*! @abstract x clamped to the range [min, max].
457 * @discussion Note that if you want to clamp all lanes to the same range,
458 * you can use a scalar value for min and max. */
459static inline SIMD_CFUNC simd_uchar2 simd_clamp(simd_uchar2 x, simd_uchar2 min, simd_uchar2 max);
460/*! @abstract x clamped to the range [min, max].
461 * @discussion Note that if you want to clamp all lanes to the same range,
462 * you can use a scalar value for min and max. */
463static inline SIMD_CFUNC simd_uchar3 simd_clamp(simd_uchar3 x, simd_uchar3 min, simd_uchar3 max);
464/*! @abstract x clamped to the range [min, max].
465 * @discussion Note that if you want to clamp all lanes to the same range,
466 * you can use a scalar value for min and max. */
467static inline SIMD_CFUNC simd_uchar4 simd_clamp(simd_uchar4 x, simd_uchar4 min, simd_uchar4 max);
468/*! @abstract x clamped to the range [min, max].
469 * @discussion Note that if you want to clamp all lanes to the same range,
470 * you can use a scalar value for min and max. */
471static inline SIMD_CFUNC simd_uchar8 simd_clamp(simd_uchar8 x, simd_uchar8 min, simd_uchar8 max);
472/*! @abstract x clamped to the range [min, max].
473 * @discussion Note that if you want to clamp all lanes to the same range,
474 * you can use a scalar value for min and max. */
475static inline SIMD_CFUNC simd_uchar16 simd_clamp(simd_uchar16 x, simd_uchar16 min, simd_uchar16 max);
476/*! @abstract x clamped to the range [min, max].
477 * @discussion Note that if you want to clamp all lanes to the same range,
478 * you can use a scalar value for min and max. */
479static inline SIMD_CFUNC simd_uchar32 simd_clamp(simd_uchar32 x, simd_uchar32 min, simd_uchar32 max);
480/*! @abstract x clamped to the range [min, max].
481 * @discussion Note that if you want to clamp all lanes to the same range,
482 * you can use a scalar value for min and max. */
483static inline SIMD_CFUNC simd_uchar64 simd_clamp(simd_uchar64 x, simd_uchar64 min, simd_uchar64 max);
484/*! @abstract x clamped to the range [min, max].
485 * @discussion Note that if you want to clamp all lanes to the same range,
486 * you can use a scalar value for min and max. */
487static inline SIMD_CFUNC simd_short2 simd_clamp(simd_short2 x, simd_short2 min, simd_short2 max);
488/*! @abstract x clamped to the range [min, max].
489 * @discussion Note that if you want to clamp all lanes to the same range,
490 * you can use a scalar value for min and max. */
491static inline SIMD_CFUNC simd_short3 simd_clamp(simd_short3 x, simd_short3 min, simd_short3 max);
492/*! @abstract x clamped to the range [min, max].
493 * @discussion Note that if you want to clamp all lanes to the same range,
494 * you can use a scalar value for min and max. */
495static inline SIMD_CFUNC simd_short4 simd_clamp(simd_short4 x, simd_short4 min, simd_short4 max);
496/*! @abstract x clamped to the range [min, max].
497 * @discussion Note that if you want to clamp all lanes to the same range,
498 * you can use a scalar value for min and max. */
499static inline SIMD_CFUNC simd_short8 simd_clamp(simd_short8 x, simd_short8 min, simd_short8 max);
500/*! @abstract x clamped to the range [min, max].
501 * @discussion Note that if you want to clamp all lanes to the same range,
502 * you can use a scalar value for min and max. */
503static inline SIMD_CFUNC simd_short16 simd_clamp(simd_short16 x, simd_short16 min, simd_short16 max);
504/*! @abstract x clamped to the range [min, max].
505 * @discussion Note that if you want to clamp all lanes to the same range,
506 * you can use a scalar value for min and max. */
507static inline SIMD_CFUNC simd_short32 simd_clamp(simd_short32 x, simd_short32 min, simd_short32 max);
508/*! @abstract x clamped to the range [min, max].
509 * @discussion Note that if you want to clamp all lanes to the same range,
510 * you can use a scalar value for min and max. */
511static inline SIMD_CFUNC simd_ushort2 simd_clamp(simd_ushort2 x, simd_ushort2 min, simd_ushort2 max);
512/*! @abstract x clamped to the range [min, max].
513 * @discussion Note that if you want to clamp all lanes to the same range,
514 * you can use a scalar value for min and max. */
515static inline SIMD_CFUNC simd_ushort3 simd_clamp(simd_ushort3 x, simd_ushort3 min, simd_ushort3 max);
516/*! @abstract x clamped to the range [min, max].
517 * @discussion Note that if you want to clamp all lanes to the same range,
518 * you can use a scalar value for min and max. */
519static inline SIMD_CFUNC simd_ushort4 simd_clamp(simd_ushort4 x, simd_ushort4 min, simd_ushort4 max);
520/*! @abstract x clamped to the range [min, max].
521 * @discussion Note that if you want to clamp all lanes to the same range,
522 * you can use a scalar value for min and max. */
523static inline SIMD_CFUNC simd_ushort8 simd_clamp(simd_ushort8 x, simd_ushort8 min, simd_ushort8 max);
524/*! @abstract x clamped to the range [min, max].
525 * @discussion Note that if you want to clamp all lanes to the same range,
526 * you can use a scalar value for min and max. */
527static inline SIMD_CFUNC simd_ushort16 simd_clamp(simd_ushort16 x, simd_ushort16 min, simd_ushort16 max);
528/*! @abstract x clamped to the range [min, max].
529 * @discussion Note that if you want to clamp all lanes to the same range,
530 * you can use a scalar value for min and max. */
531static inline SIMD_CFUNC simd_ushort32 simd_clamp(simd_ushort32 x, simd_ushort32 min, simd_ushort32 max);
532/*! @abstract x clamped to the range [min, max].
533 * @discussion Note that if you want to clamp all lanes to the same range,
534 * you can use a scalar value for min and max. */
535static inline SIMD_CFUNC simd_int2 simd_clamp(simd_int2 x, simd_int2 min, simd_int2 max);
536/*! @abstract x clamped to the range [min, max].
537 * @discussion Note that if you want to clamp all lanes to the same range,
538 * you can use a scalar value for min and max. */
539static inline SIMD_CFUNC simd_int3 simd_clamp(simd_int3 x, simd_int3 min, simd_int3 max);
540/*! @abstract x clamped to the range [min, max].
541 * @discussion Note that if you want to clamp all lanes to the same range,
542 * you can use a scalar value for min and max. */
543static inline SIMD_CFUNC simd_int4 simd_clamp(simd_int4 x, simd_int4 min, simd_int4 max);
544/*! @abstract x clamped to the range [min, max].
545 * @discussion Note that if you want to clamp all lanes to the same range,
546 * you can use a scalar value for min and max. */
547static inline SIMD_CFUNC simd_int8 simd_clamp(simd_int8 x, simd_int8 min, simd_int8 max);
548/*! @abstract x clamped to the range [min, max].
549 * @discussion Note that if you want to clamp all lanes to the same range,
550 * you can use a scalar value for min and max. */
551static inline SIMD_CFUNC simd_int16 simd_clamp(simd_int16 x, simd_int16 min, simd_int16 max);
552/*! @abstract x clamped to the range [min, max].
553 * @discussion Note that if you want to clamp all lanes to the same range,
554 * you can use a scalar value for min and max. */
555static inline SIMD_CFUNC simd_uint2 simd_clamp(simd_uint2 x, simd_uint2 min, simd_uint2 max);
556/*! @abstract x clamped to the range [min, max].
557 * @discussion Note that if you want to clamp all lanes to the same range,
558 * you can use a scalar value for min and max. */
559static inline SIMD_CFUNC simd_uint3 simd_clamp(simd_uint3 x, simd_uint3 min, simd_uint3 max);
560/*! @abstract x clamped to the range [min, max].
561 * @discussion Note that if you want to clamp all lanes to the same range,
562 * you can use a scalar value for min and max. */
563static inline SIMD_CFUNC simd_uint4 simd_clamp(simd_uint4 x, simd_uint4 min, simd_uint4 max);
564/*! @abstract x clamped to the range [min, max].
565 * @discussion Note that if you want to clamp all lanes to the same range,
566 * you can use a scalar value for min and max. */
567static inline SIMD_CFUNC simd_uint8 simd_clamp(simd_uint8 x, simd_uint8 min, simd_uint8 max);
568/*! @abstract x clamped to the range [min, max].
569 * @discussion Note that if you want to clamp all lanes to the same range,
570 * you can use a scalar value for min and max. */
571static inline SIMD_CFUNC simd_uint16 simd_clamp(simd_uint16 x, simd_uint16 min, simd_uint16 max);
572/*! @abstract x clamped to the range [min, max].
573 * @discussion Note that if you want to clamp all lanes to the same range,
574 * you can use a scalar value for min and max. */
575static inline SIMD_CFUNC float simd_clamp(float x, float min, float max);
576/*! @abstract x clamped to the range [min, max].
577 * @discussion Note that if you want to clamp all lanes to the same range,
578 * you can use a scalar value for min and max. */
579static inline SIMD_CFUNC simd_float2 simd_clamp(simd_float2 x, simd_float2 min, simd_float2 max);
580/*! @abstract x clamped to the range [min, max].
581 * @discussion Note that if you want to clamp all lanes to the same range,
582 * you can use a scalar value for min and max. */
583static inline SIMD_CFUNC simd_float3 simd_clamp(simd_float3 x, simd_float3 min, simd_float3 max);
584/*! @abstract x clamped to the range [min, max].
585 * @discussion Note that if you want to clamp all lanes to the same range,
586 * you can use a scalar value for min and max. */
587static inline SIMD_CFUNC simd_float4 simd_clamp(simd_float4 x, simd_float4 min, simd_float4 max);
588/*! @abstract x clamped to the range [min, max].
589 * @discussion Note that if you want to clamp all lanes to the same range,
590 * you can use a scalar value for min and max. */
591static inline SIMD_CFUNC simd_float8 simd_clamp(simd_float8 x, simd_float8 min, simd_float8 max);
592/*! @abstract x clamped to the range [min, max].
593 * @discussion Note that if you want to clamp all lanes to the same range,
594 * you can use a scalar value for min and max. */
595static inline SIMD_CFUNC simd_float16 simd_clamp(simd_float16 x, simd_float16 min, simd_float16 max);
596/*! @abstract x clamped to the range [min, max].
597 * @discussion Note that if you want to clamp all lanes to the same range,
598 * you can use a scalar value for min and max. */
599static inline SIMD_CFUNC simd_long2 simd_clamp(simd_long2 x, simd_long2 min, simd_long2 max);
600/*! @abstract x clamped to the range [min, max].
601 * @discussion Note that if you want to clamp all lanes to the same range,
602 * you can use a scalar value for min and max. */
603static inline SIMD_CFUNC simd_long3 simd_clamp(simd_long3 x, simd_long3 min, simd_long3 max);
604/*! @abstract x clamped to the range [min, max].
605 * @discussion Note that if you want to clamp all lanes to the same range,
606 * you can use a scalar value for min and max. */
607static inline SIMD_CFUNC simd_long4 simd_clamp(simd_long4 x, simd_long4 min, simd_long4 max);
608/*! @abstract x clamped to the range [min, max].
609 * @discussion Note that if you want to clamp all lanes to the same range,
610 * you can use a scalar value for min and max. */
611static inline SIMD_CFUNC simd_long8 simd_clamp(simd_long8 x, simd_long8 min, simd_long8 max);
612/*! @abstract x clamped to the range [min, max].
613 * @discussion Note that if you want to clamp all lanes to the same range,
614 * you can use a scalar value for min and max. */
615static inline SIMD_CFUNC simd_ulong2 simd_clamp(simd_ulong2 x, simd_ulong2 min, simd_ulong2 max);
616/*! @abstract x clamped to the range [min, max].
617 * @discussion Note that if you want to clamp all lanes to the same range,
618 * you can use a scalar value for min and max. */
619static inline SIMD_CFUNC simd_ulong3 simd_clamp(simd_ulong3 x, simd_ulong3 min, simd_ulong3 max);
620/*! @abstract x clamped to the range [min, max].
621 * @discussion Note that if you want to clamp all lanes to the same range,
622 * you can use a scalar value for min and max. */
623static inline SIMD_CFUNC simd_ulong4 simd_clamp(simd_ulong4 x, simd_ulong4 min, simd_ulong4 max);
624/*! @abstract x clamped to the range [min, max].
625 * @discussion Note that if you want to clamp all lanes to the same range,
626 * you can use a scalar value for min and max. */
627static inline SIMD_CFUNC simd_ulong8 simd_clamp(simd_ulong8 x, simd_ulong8 min, simd_ulong8 max);
628/*! @abstract x clamped to the range [min, max].
629 * @discussion Note that if you want to clamp all lanes to the same range,
630 * you can use a scalar value for min and max. */
631static inline SIMD_CFUNC double simd_clamp(double x, double min, double max);
632/*! @abstract x clamped to the range [min, max].
633 * @discussion Note that if you want to clamp all lanes to the same range,
634 * you can use a scalar value for min and max. */
635static inline SIMD_CFUNC simd_double2 simd_clamp(simd_double2 x, simd_double2 min, simd_double2 max);
636/*! @abstract x clamped to the range [min, max].
637 * @discussion Note that if you want to clamp all lanes to the same range,
638 * you can use a scalar value for min and max. */
639static inline SIMD_CFUNC simd_double3 simd_clamp(simd_double3 x, simd_double3 min, simd_double3 max);
640/*! @abstract x clamped to the range [min, max].
641 * @discussion Note that if you want to clamp all lanes to the same range,
642 * you can use a scalar value for min and max. */
643static inline SIMD_CFUNC simd_double4 simd_clamp(simd_double4 x, simd_double4 min, simd_double4 max);
644/*! @abstract x clamped to the range [min, max].
645 * @discussion Note that if you want to clamp all lanes to the same range,
646 * you can use a scalar value for min and max. */
647static inline SIMD_CFUNC simd_double8 simd_clamp(simd_double8 x, simd_double8 min, simd_double8 max);
648/*! @abstract x clamped to the range [min, max].
649 * @discussion Deprecated. Use simd_clamp(x,min,max) instead. */
650#define vector_clamp simd_clamp
651
652/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
653static inline SIMD_CFUNC float simd_sign(float x);
654/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
655static inline SIMD_CFUNC simd_float2 simd_sign(simd_float2 x);
656/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
657static inline SIMD_CFUNC simd_float3 simd_sign(simd_float3 x);
658/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
659static inline SIMD_CFUNC simd_float4 simd_sign(simd_float4 x);
660/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
661static inline SIMD_CFUNC simd_float8 simd_sign(simd_float8 x);
662/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
663static inline SIMD_CFUNC simd_float16 simd_sign(simd_float16 x);
664/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
665static inline SIMD_CFUNC double simd_sign(double x);
666/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
667static inline SIMD_CFUNC simd_double2 simd_sign(simd_double2 x);
668/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
669static inline SIMD_CFUNC simd_double3 simd_sign(simd_double3 x);
670/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
671static inline SIMD_CFUNC simd_double4 simd_sign(simd_double4 x);
672/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */
673static inline SIMD_CFUNC simd_double8 simd_sign(simd_double8 x);
674/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise.
675 * @discussion Deprecated. Use simd_sign(x) instead. */
676#define vector_sign simd_sign
677
678/*! @abstract Linearly interpolates between x and y, taking the value x when
679 * t=0 and y when t=1 */
680static inline SIMD_CFUNC float simd_mix(float x, float y, float t);
681/*! @abstract Linearly interpolates between x and y, taking the value x when
682 * t=0 and y when t=1 */
683static inline SIMD_CFUNC simd_float2 simd_mix(simd_float2 x, simd_float2 y, simd_float2 t);
684/*! @abstract Linearly interpolates between x and y, taking the value x when
685 * t=0 and y when t=1 */
686static inline SIMD_CFUNC simd_float3 simd_mix(simd_float3 x, simd_float3 y, simd_float3 t);
687/*! @abstract Linearly interpolates between x and y, taking the value x when
688 * t=0 and y when t=1 */
689static inline SIMD_CFUNC simd_float4 simd_mix(simd_float4 x, simd_float4 y, simd_float4 t);
690/*! @abstract Linearly interpolates between x and y, taking the value x when
691 * t=0 and y when t=1 */
692static inline SIMD_CFUNC simd_float8 simd_mix(simd_float8 x, simd_float8 y, simd_float8 t);
693/*! @abstract Linearly interpolates between x and y, taking the value x when
694 * t=0 and y when t=1 */
695static inline SIMD_CFUNC simd_float16 simd_mix(simd_float16 x, simd_float16 y, simd_float16 t);
696/*! @abstract Linearly interpolates between x and y, taking the value x when
697 * t=0 and y when t=1 */
698static inline SIMD_CFUNC double simd_mix(double x, double y, double t);
699/*! @abstract Linearly interpolates between x and y, taking the value x when
700 * t=0 and y when t=1 */
701static inline SIMD_CFUNC simd_double2 simd_mix(simd_double2 x, simd_double2 y, simd_double2 t);
702/*! @abstract Linearly interpolates between x and y, taking the value x when
703 * t=0 and y when t=1 */
704static inline SIMD_CFUNC simd_double3 simd_mix(simd_double3 x, simd_double3 y, simd_double3 t);
705/*! @abstract Linearly interpolates between x and y, taking the value x when
706 * t=0 and y when t=1 */
707static inline SIMD_CFUNC simd_double4 simd_mix(simd_double4 x, simd_double4 y, simd_double4 t);
708/*! @abstract Linearly interpolates between x and y, taking the value x when
709 * t=0 and y when t=1 */
710static inline SIMD_CFUNC simd_double8 simd_mix(simd_double8 x, simd_double8 y, simd_double8 t);
711/*! @abstract Linearly interpolates between x and y, taking the value x when
712 * t=0 and y when t=1
713 * @discussion Deprecated. Use simd_mix(x, y, t) instead. */
714#define vector_mix simd_mix
715
716/*! @abstract A good approximation to 1/x.
717 * @discussion If x is very close to the limits of representation, the
718 * result may overflow or underflow; otherwise this function is accurate to
719 * a few units in the last place (ULPs). */
720static inline SIMD_CFUNC float simd_precise_recip(float x);
721/*! @abstract A good approximation to 1/x.
722 * @discussion If x is very close to the limits of representation, the
723 * result may overflow or underflow; otherwise this function is accurate to
724 * a few units in the last place (ULPs). */
725static inline SIMD_CFUNC simd_float2 simd_precise_recip(simd_float2 x);
726/*! @abstract A good approximation to 1/x.
727 * @discussion If x is very close to the limits of representation, the
728 * result may overflow or underflow; otherwise this function is accurate to
729 * a few units in the last place (ULPs). */
730static inline SIMD_CFUNC simd_float3 simd_precise_recip(simd_float3 x);
731/*! @abstract A good approximation to 1/x.
732 * @discussion If x is very close to the limits of representation, the
733 * result may overflow or underflow; otherwise this function is accurate to
734 * a few units in the last place (ULPs). */
735static inline SIMD_CFUNC simd_float4 simd_precise_recip(simd_float4 x);
736/*! @abstract A good approximation to 1/x.
737 * @discussion If x is very close to the limits of representation, the
738 * result may overflow or underflow; otherwise this function is accurate to
739 * a few units in the last place (ULPs). */
740static inline SIMD_CFUNC simd_float8 simd_precise_recip(simd_float8 x);
741/*! @abstract A good approximation to 1/x.
742 * @discussion If x is very close to the limits of representation, the
743 * result may overflow or underflow; otherwise this function is accurate to
744 * a few units in the last place (ULPs). */
745static inline SIMD_CFUNC simd_float16 simd_precise_recip(simd_float16 x);
746/*! @abstract A good approximation to 1/x.
747 * @discussion If x is very close to the limits of representation, the
748 * result may overflow or underflow; otherwise this function is accurate to
749 * a few units in the last place (ULPs). */
750static inline SIMD_CFUNC double simd_precise_recip(double x);
751/*! @abstract A good approximation to 1/x.
752 * @discussion If x is very close to the limits of representation, the
753 * result may overflow or underflow; otherwise this function is accurate to
754 * a few units in the last place (ULPs). */
755static inline SIMD_CFUNC simd_double2 simd_precise_recip(simd_double2 x);
756/*! @abstract A good approximation to 1/x.
757 * @discussion If x is very close to the limits of representation, the
758 * result may overflow or underflow; otherwise this function is accurate to
759 * a few units in the last place (ULPs). */
760static inline SIMD_CFUNC simd_double3 simd_precise_recip(simd_double3 x);
761/*! @abstract A good approximation to 1/x.
762 * @discussion If x is very close to the limits of representation, the
763 * result may overflow or underflow; otherwise this function is accurate to
764 * a few units in the last place (ULPs). */
765static inline SIMD_CFUNC simd_double4 simd_precise_recip(simd_double4 x);
766/*! @abstract A good approximation to 1/x.
767 * @discussion If x is very close to the limits of representation, the
768 * result may overflow or underflow; otherwise this function is accurate to
769 * a few units in the last place (ULPs). */
770static inline SIMD_CFUNC simd_double8 simd_precise_recip(simd_double8 x);
771/*! @abstract A good approximation to 1/x.
772 * @discussion Deprecated. Use simd_precise_recip(x) instead. */
773#define vector_precise_recip simd_precise_recip
774
775/*! @abstract A fast approximation to 1/x.
776 * @discussion If x is very close to the limits of representation, the
777 * result may overflow or underflow; otherwise this function is accurate to
778 * at least 11 bits for float and 22 bits for double. */
779static inline SIMD_CFUNC float simd_fast_recip(float x);
780/*! @abstract A fast approximation to 1/x.
781 * @discussion If x is very close to the limits of representation, the
782 * result may overflow or underflow; otherwise this function is accurate to
783 * at least 11 bits for float and 22 bits for double. */
784static inline SIMD_CFUNC simd_float2 simd_fast_recip(simd_float2 x);
785/*! @abstract A fast approximation to 1/x.
786 * @discussion If x is very close to the limits of representation, the
787 * result may overflow or underflow; otherwise this function is accurate to
788 * at least 11 bits for float and 22 bits for double. */
789static inline SIMD_CFUNC simd_float3 simd_fast_recip(simd_float3 x);
790/*! @abstract A fast approximation to 1/x.
791 * @discussion If x is very close to the limits of representation, the
792 * result may overflow or underflow; otherwise this function is accurate to
793 * at least 11 bits for float and 22 bits for double. */
794static inline SIMD_CFUNC simd_float4 simd_fast_recip(simd_float4 x);
795/*! @abstract A fast approximation to 1/x.
796 * @discussion If x is very close to the limits of representation, the
797 * result may overflow or underflow; otherwise this function is accurate to
798 * at least 11 bits for float and 22 bits for double. */
799static inline SIMD_CFUNC simd_float8 simd_fast_recip(simd_float8 x);
800/*! @abstract A fast approximation to 1/x.
801 * @discussion If x is very close to the limits of representation, the
802 * result may overflow or underflow; otherwise this function is accurate to
803 * at least 11 bits for float and 22 bits for double. */
804static inline SIMD_CFUNC simd_float16 simd_fast_recip(simd_float16 x);
805/*! @abstract A fast approximation to 1/x.
806 * @discussion If x is very close to the limits of representation, the
807 * result may overflow or underflow; otherwise this function is accurate to
808 * at least 11 bits for float and 22 bits for double. */
809static inline SIMD_CFUNC double simd_fast_recip(double x);
810/*! @abstract A fast approximation to 1/x.
811 * @discussion If x is very close to the limits of representation, the
812 * result may overflow or underflow; otherwise this function is accurate to
813 * at least 11 bits for float and 22 bits for double. */
814static inline SIMD_CFUNC simd_double2 simd_fast_recip(simd_double2 x);
815/*! @abstract A fast approximation to 1/x.
816 * @discussion If x is very close to the limits of representation, the
817 * result may overflow or underflow; otherwise this function is accurate to
818 * at least 11 bits for float and 22 bits for double. */
819static inline SIMD_CFUNC simd_double3 simd_fast_recip(simd_double3 x);
820/*! @abstract A fast approximation to 1/x.
821 * @discussion If x is very close to the limits of representation, the
822 * result may overflow or underflow; otherwise this function is accurate to
823 * at least 11 bits for float and 22 bits for double. */
824static inline SIMD_CFUNC simd_double4 simd_fast_recip(simd_double4 x);
825/*! @abstract A fast approximation to 1/x.
826 * @discussion If x is very close to the limits of representation, the
827 * result may overflow or underflow; otherwise this function is accurate to
828 * at least 11 bits for float and 22 bits for double. */
829static inline SIMD_CFUNC simd_double8 simd_fast_recip(simd_double8 x);
830/*! @abstract A fast approximation to 1/x.
831 * @discussion Deprecated. Use simd_fast_recip(x) instead. */
832#define vector_fast_recip simd_fast_recip
833
834/*! @abstract An approximation to 1/x.
835 * @discussion If x is very close to the limits of representation, the
836 * result may overflow or underflow. This function maps to
837 * simd_fast_recip(x) if -ffast-math is specified, and to
838 * simd_precise_recip(x) otherwise. */
839static inline SIMD_CFUNC float simd_recip(float x);
840/*! @abstract An approximation to 1/x.
841 * @discussion If x is very close to the limits of representation, the
842 * result may overflow or underflow. This function maps to
843 * simd_fast_recip(x) if -ffast-math is specified, and to
844 * simd_precise_recip(x) otherwise. */
845static inline SIMD_CFUNC simd_float2 simd_recip(simd_float2 x);
846/*! @abstract An approximation to 1/x.
847 * @discussion If x is very close to the limits of representation, the
848 * result may overflow or underflow. This function maps to
849 * simd_fast_recip(x) if -ffast-math is specified, and to
850 * simd_precise_recip(x) otherwise. */
851static inline SIMD_CFUNC simd_float3 simd_recip(simd_float3 x);
852/*! @abstract An approximation to 1/x.
853 * @discussion If x is very close to the limits of representation, the
854 * result may overflow or underflow. This function maps to
855 * simd_fast_recip(x) if -ffast-math is specified, and to
856 * simd_precise_recip(x) otherwise. */
857static inline SIMD_CFUNC simd_float4 simd_recip(simd_float4 x);
858/*! @abstract An approximation to 1/x.
859 * @discussion If x is very close to the limits of representation, the
860 * result may overflow or underflow. This function maps to
861 * simd_fast_recip(x) if -ffast-math is specified, and to
862 * simd_precise_recip(x) otherwise. */
863static inline SIMD_CFUNC simd_float8 simd_recip(simd_float8 x);
864/*! @abstract An approximation to 1/x.
865 * @discussion If x is very close to the limits of representation, the
866 * result may overflow or underflow. This function maps to
867 * simd_fast_recip(x) if -ffast-math is specified, and to
868 * simd_precise_recip(x) otherwise. */
869static inline SIMD_CFUNC simd_float16 simd_recip(simd_float16 x);
870/*! @abstract An approximation to 1/x.
871 * @discussion If x is very close to the limits of representation, the
872 * result may overflow or underflow. This function maps to
873 * simd_fast_recip(x) if -ffast-math is specified, and to
874 * simd_precise_recip(x) otherwise. */
875static inline SIMD_CFUNC double simd_recip(double x);
876/*! @abstract An approximation to 1/x.
877 * @discussion If x is very close to the limits of representation, the
878 * result may overflow or underflow. This function maps to
879 * simd_fast_recip(x) if -ffast-math is specified, and to
880 * simd_precise_recip(x) otherwise. */
881static inline SIMD_CFUNC simd_double2 simd_recip(simd_double2 x);
882/*! @abstract An approximation to 1/x.
883 * @discussion If x is very close to the limits of representation, the
884 * result may overflow or underflow. This function maps to
885 * simd_fast_recip(x) if -ffast-math is specified, and to
886 * simd_precise_recip(x) otherwise. */
887static inline SIMD_CFUNC simd_double3 simd_recip(simd_double3 x);
888/*! @abstract An approximation to 1/x.
889 * @discussion If x is very close to the limits of representation, the
890 * result may overflow or underflow. This function maps to
891 * simd_fast_recip(x) if -ffast-math is specified, and to
892 * simd_precise_recip(x) otherwise. */
893static inline SIMD_CFUNC simd_double4 simd_recip(simd_double4 x);
894/*! @abstract An approximation to 1/x.
895 * @discussion If x is very close to the limits of representation, the
896 * result may overflow or underflow. This function maps to
897 * simd_fast_recip(x) if -ffast-math is specified, and to
898 * simd_precise_recip(x) otherwise. */
899static inline SIMD_CFUNC simd_double8 simd_recip(simd_double8 x);
900/*! @abstract An approximation to 1/x.
901 * @discussion Deprecated. Use simd_recip(x) instead. */
902#define vector_recip simd_recip
903
904/*! @abstract A good approximation to 1/sqrt(x).
905 * @discussion This function is accurate to a few units in the last place
906 * (ULPs). */
907static inline SIMD_CFUNC float simd_precise_rsqrt(float x);
908/*! @abstract A good approximation to 1/sqrt(x).
909 * @discussion This function is accurate to a few units in the last place
910 * (ULPs). */
911static inline SIMD_CFUNC simd_float2 simd_precise_rsqrt(simd_float2 x);
912/*! @abstract A good approximation to 1/sqrt(x).
913 * @discussion This function is accurate to a few units in the last place
914 * (ULPs). */
915static inline SIMD_CFUNC simd_float3 simd_precise_rsqrt(simd_float3 x);
916/*! @abstract A good approximation to 1/sqrt(x).
917 * @discussion This function is accurate to a few units in the last place
918 * (ULPs). */
919static inline SIMD_CFUNC simd_float4 simd_precise_rsqrt(simd_float4 x);
920/*! @abstract A good approximation to 1/sqrt(x).
921 * @discussion This function is accurate to a few units in the last place
922 * (ULPs). */
923static inline SIMD_CFUNC simd_float8 simd_precise_rsqrt(simd_float8 x);
924/*! @abstract A good approximation to 1/sqrt(x).
925 * @discussion This function is accurate to a few units in the last place
926 * (ULPs). */
927static inline SIMD_CFUNC simd_float16 simd_precise_rsqrt(simd_float16 x);
928/*! @abstract A good approximation to 1/sqrt(x).
929 * @discussion This function is accurate to a few units in the last place
930 * (ULPs). */
931static inline SIMD_CFUNC double simd_precise_rsqrt(double x);
932/*! @abstract A good approximation to 1/sqrt(x).
933 * @discussion This function is accurate to a few units in the last place
934 * (ULPs). */
935static inline SIMD_CFUNC simd_double2 simd_precise_rsqrt(simd_double2 x);
936/*! @abstract A good approximation to 1/sqrt(x).
937 * @discussion This function is accurate to a few units in the last place
938 * (ULPs). */
939static inline SIMD_CFUNC simd_double3 simd_precise_rsqrt(simd_double3 x);
940/*! @abstract A good approximation to 1/sqrt(x).
941 * @discussion This function is accurate to a few units in the last place
942 * (ULPs). */
943static inline SIMD_CFUNC simd_double4 simd_precise_rsqrt(simd_double4 x);
944/*! @abstract A good approximation to 1/sqrt(x).
945 * @discussion This function is accurate to a few units in the last place
946 * (ULPs). */
947static inline SIMD_CFUNC simd_double8 simd_precise_rsqrt(simd_double8 x);
948/*! @abstract A good approximation to 1/sqrt(x).
949 * @discussion Deprecated. Use simd_precise_rsqrt(x) instead. */
950#define vector_precise_rsqrt simd_precise_rsqrt
951
952/*! @abstract A fast approximation to 1/sqrt(x).
953 * @discussion This function is accurate to at least 11 bits for float and
954 * 22 bits for double. */
955static inline SIMD_CFUNC float simd_fast_rsqrt(float x);
956/*! @abstract A fast approximation to 1/sqrt(x).
957 * @discussion This function is accurate to at least 11 bits for float and
958 * 22 bits for double. */
959static inline SIMD_CFUNC simd_float2 simd_fast_rsqrt(simd_float2 x);
960/*! @abstract A fast approximation to 1/sqrt(x).
961 * @discussion This function is accurate to at least 11 bits for float and
962 * 22 bits for double. */
963static inline SIMD_CFUNC simd_float3 simd_fast_rsqrt(simd_float3 x);
964/*! @abstract A fast approximation to 1/sqrt(x).
965 * @discussion This function is accurate to at least 11 bits for float and
966 * 22 bits for double. */
967static inline SIMD_CFUNC simd_float4 simd_fast_rsqrt(simd_float4 x);
968/*! @abstract A fast approximation to 1/sqrt(x).
969 * @discussion This function is accurate to at least 11 bits for float and
970 * 22 bits for double. */
971static inline SIMD_CFUNC simd_float8 simd_fast_rsqrt(simd_float8 x);
972/*! @abstract A fast approximation to 1/sqrt(x).
973 * @discussion This function is accurate to at least 11 bits for float and
974 * 22 bits for double. */
975static inline SIMD_CFUNC simd_float16 simd_fast_rsqrt(simd_float16 x);
976/*! @abstract A fast approximation to 1/sqrt(x).
977 * @discussion This function is accurate to at least 11 bits for float and
978 * 22 bits for double. */
979static inline SIMD_CFUNC double simd_fast_rsqrt(double x);
980/*! @abstract A fast approximation to 1/sqrt(x).
981 * @discussion This function is accurate to at least 11 bits for float and
982 * 22 bits for double. */
983static inline SIMD_CFUNC simd_double2 simd_fast_rsqrt(simd_double2 x);
984/*! @abstract A fast approximation to 1/sqrt(x).
985 * @discussion This function is accurate to at least 11 bits for float and
986 * 22 bits for double. */
987static inline SIMD_CFUNC simd_double3 simd_fast_rsqrt(simd_double3 x);
988/*! @abstract A fast approximation to 1/sqrt(x).
989 * @discussion This function is accurate to at least 11 bits for float and
990 * 22 bits for double. */
991static inline SIMD_CFUNC simd_double4 simd_fast_rsqrt(simd_double4 x);
992/*! @abstract A fast approximation to 1/sqrt(x).
993 * @discussion This function is accurate to at least 11 bits for float and
994 * 22 bits for double. */
995static inline SIMD_CFUNC simd_double8 simd_fast_rsqrt(simd_double8 x);
996/*! @abstract A fast approximation to 1/sqrt(x).
997 * @discussion Deprecated. Use simd_fast_rsqrt(x) instead. */
998#define vector_fast_rsqrt simd_fast_rsqrt
999
1000/*! @abstract An approximation to 1/sqrt(x).
1001 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1002 * specified, and to simd_precise_recip(x) otherwise. */
1003static inline SIMD_CFUNC float simd_rsqrt(float x);
1004/*! @abstract An approximation to 1/sqrt(x).
1005 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1006 * specified, and to simd_precise_recip(x) otherwise. */
1007static inline SIMD_CFUNC simd_float2 simd_rsqrt(simd_float2 x);
1008/*! @abstract An approximation to 1/sqrt(x).
1009 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1010 * specified, and to simd_precise_recip(x) otherwise. */
1011static inline SIMD_CFUNC simd_float3 simd_rsqrt(simd_float3 x);
1012/*! @abstract An approximation to 1/sqrt(x).
1013 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1014 * specified, and to simd_precise_recip(x) otherwise. */
1015static inline SIMD_CFUNC simd_float4 simd_rsqrt(simd_float4 x);
1016/*! @abstract An approximation to 1/sqrt(x).
1017 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1018 * specified, and to simd_precise_recip(x) otherwise. */
1019static inline SIMD_CFUNC simd_float8 simd_rsqrt(simd_float8 x);
1020/*! @abstract An approximation to 1/sqrt(x).
1021 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1022 * specified, and to simd_precise_recip(x) otherwise. */
1023static inline SIMD_CFUNC simd_float16 simd_rsqrt(simd_float16 x);
1024/*! @abstract An approximation to 1/sqrt(x).
1025 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1026 * specified, and to simd_precise_recip(x) otherwise. */
1027static inline SIMD_CFUNC double simd_rsqrt(double x);
1028/*! @abstract An approximation to 1/sqrt(x).
1029 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1030 * specified, and to simd_precise_recip(x) otherwise. */
1031static inline SIMD_CFUNC simd_double2 simd_rsqrt(simd_double2 x);
1032/*! @abstract An approximation to 1/sqrt(x).
1033 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1034 * specified, and to simd_precise_recip(x) otherwise. */
1035static inline SIMD_CFUNC simd_double3 simd_rsqrt(simd_double3 x);
1036/*! @abstract An approximation to 1/sqrt(x).
1037 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1038 * specified, and to simd_precise_recip(x) otherwise. */
1039static inline SIMD_CFUNC simd_double4 simd_rsqrt(simd_double4 x);
1040/*! @abstract An approximation to 1/sqrt(x).
1041 * @discussion This function maps to simd_fast_recip(x) if -ffast-math is
1042 * specified, and to simd_precise_recip(x) otherwise. */
1043static inline SIMD_CFUNC simd_double8 simd_rsqrt(simd_double8 x);
1044/*! @abstract An approximation to 1/sqrt(x).
1045 * @discussion Deprecated. Use simd_rsqrt(x) instead. */
1046#define vector_rsqrt simd_rsqrt
1047
1048/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1049 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1050 * positive and finite, then the two values are exactly equal. */
1051static inline SIMD_CFUNC float simd_fract(float x);
1052/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1053 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1054 * positive and finite, then the two values are exactly equal. */
1055static inline SIMD_CFUNC simd_float2 simd_fract(simd_float2 x);
1056/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1057 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1058 * positive and finite, then the two values are exactly equal. */
1059static inline SIMD_CFUNC simd_float3 simd_fract(simd_float3 x);
1060/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1061 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1062 * positive and finite, then the two values are exactly equal. */
1063static inline SIMD_CFUNC simd_float4 simd_fract(simd_float4 x);
1064/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1065 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1066 * positive and finite, then the two values are exactly equal. */
1067static inline SIMD_CFUNC simd_float8 simd_fract(simd_float8 x);
1068/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1069 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1070 * positive and finite, then the two values are exactly equal. */
1071static inline SIMD_CFUNC simd_float16 simd_fract(simd_float16 x);
1072/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1073 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1074 * positive and finite, then the two values are exactly equal. */
1075static inline SIMD_CFUNC double simd_fract(double x);
1076/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1077 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1078 * positive and finite, then the two values are exactly equal. */
1079static inline SIMD_CFUNC simd_double2 simd_fract(simd_double2 x);
1080/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1081 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1082 * positive and finite, then the two values are exactly equal. */
1083static inline SIMD_CFUNC simd_double3 simd_fract(simd_double3 x);
1084/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1085 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1086 * positive and finite, then the two values are exactly equal. */
1087static inline SIMD_CFUNC simd_double4 simd_fract(simd_double4 x);
1088/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1089 * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is
1090 * positive and finite, then the two values are exactly equal. */
1091static inline SIMD_CFUNC simd_double8 simd_fract(simd_double8 x);
1092/*! @abstract The "fractional part" of x, lying in the range [0, 1).
1093 * @discussion Deprecated. Use simd_fract(x) instead. */
1094#define vector_fract simd_fract
1095
1096/*! @abstract 0 if x < edge, and 1 otherwise.
1097 * @discussion Use a scalar value for edge if you want to apply the same
1098 * threshold to all lanes. */
1099static inline SIMD_CFUNC float simd_step(float edge, float x);
1100/*! @abstract 0 if x < edge, and 1 otherwise.
1101 * @discussion Use a scalar value for edge if you want to apply the same
1102 * threshold to all lanes. */
1103static inline SIMD_CFUNC simd_float2 simd_step(simd_float2 edge, simd_float2 x);
1104/*! @abstract 0 if x < edge, and 1 otherwise.
1105 * @discussion Use a scalar value for edge if you want to apply the same
1106 * threshold to all lanes. */
1107static inline SIMD_CFUNC simd_float3 simd_step(simd_float3 edge, simd_float3 x);
1108/*! @abstract 0 if x < edge, and 1 otherwise.
1109 * @discussion Use a scalar value for edge if you want to apply the same
1110 * threshold to all lanes. */
1111static inline SIMD_CFUNC simd_float4 simd_step(simd_float4 edge, simd_float4 x);
1112/*! @abstract 0 if x < edge, and 1 otherwise.
1113 * @discussion Use a scalar value for edge if you want to apply the same
1114 * threshold to all lanes. */
1115static inline SIMD_CFUNC simd_float8 simd_step(simd_float8 edge, simd_float8 x);
1116/*! @abstract 0 if x < edge, and 1 otherwise.
1117 * @discussion Use a scalar value for edge if you want to apply the same
1118 * threshold to all lanes. */
1119static inline SIMD_CFUNC simd_float16 simd_step(simd_float16 edge, simd_float16 x);
1120/*! @abstract 0 if x < edge, and 1 otherwise.
1121 * @discussion Use a scalar value for edge if you want to apply the same
1122 * threshold to all lanes. */
1123static inline SIMD_CFUNC double simd_step(double edge, double x);
1124/*! @abstract 0 if x < edge, and 1 otherwise.
1125 * @discussion Use a scalar value for edge if you want to apply the same
1126 * threshold to all lanes. */
1127static inline SIMD_CFUNC simd_double2 simd_step(simd_double2 edge, simd_double2 x);
1128/*! @abstract 0 if x < edge, and 1 otherwise.
1129 * @discussion Use a scalar value for edge if you want to apply the same
1130 * threshold to all lanes. */
1131static inline SIMD_CFUNC simd_double3 simd_step(simd_double3 edge, simd_double3 x);
1132/*! @abstract 0 if x < edge, and 1 otherwise.
1133 * @discussion Use a scalar value for edge if you want to apply the same
1134 * threshold to all lanes. */
1135static inline SIMD_CFUNC simd_double4 simd_step(simd_double4 edge, simd_double4 x);
1136/*! @abstract 0 if x < edge, and 1 otherwise.
1137 * @discussion Use a scalar value for edge if you want to apply the same
1138 * threshold to all lanes. */
1139static inline SIMD_CFUNC simd_double8 simd_step(simd_double8 edge, simd_double8 x);
1140/*! @abstract 0 if x < edge, and 1 otherwise.
1141 * @discussion Deprecated. Use simd_step(edge, x) instead. */
1142#define vector_step simd_step
1143
1144/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1145 * @discussion You can use a scalar value for edge0 and edge1 if you want
1146 * to clamp all lanes at the same points. */
1147static inline SIMD_CFUNC float simd_smoothstep(float edge0, float edge1, float x);
1148/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1149 * @discussion You can use a scalar value for edge0 and edge1 if you want
1150 * to clamp all lanes at the same points. */
1151static inline SIMD_CFUNC simd_float2 simd_smoothstep(simd_float2 edge0, simd_float2 edge1, simd_float2 x);
1152/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1153 * @discussion You can use a scalar value for edge0 and edge1 if you want
1154 * to clamp all lanes at the same points. */
1155static inline SIMD_CFUNC simd_float3 simd_smoothstep(simd_float3 edge0, simd_float3 edge1, simd_float3 x);
1156/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1157 * @discussion You can use a scalar value for edge0 and edge1 if you want
1158 * to clamp all lanes at the same points. */
1159static inline SIMD_CFUNC simd_float4 simd_smoothstep(simd_float4 edge0, simd_float4 edge1, simd_float4 x);
1160/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1161 * @discussion You can use a scalar value for edge0 and edge1 if you want
1162 * to clamp all lanes at the same points. */
1163static inline SIMD_CFUNC simd_float8 simd_smoothstep(simd_float8 edge0, simd_float8 edge1, simd_float8 x);
1164/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1165 * @discussion You can use a scalar value for edge0 and edge1 if you want
1166 * to clamp all lanes at the same points. */
1167static inline SIMD_CFUNC simd_float16 simd_smoothstep(simd_float16 edge0, simd_float16 edge1, simd_float16 x);
1168/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1169 * @discussion You can use a scalar value for edge0 and edge1 if you want
1170 * to clamp all lanes at the same points. */
1171static inline SIMD_CFUNC double simd_smoothstep(double edge0, double edge1, double x);
1172/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1173 * @discussion You can use a scalar value for edge0 and edge1 if you want
1174 * to clamp all lanes at the same points. */
1175static inline SIMD_CFUNC simd_double2 simd_smoothstep(simd_double2 edge0, simd_double2 edge1, simd_double2 x);
1176/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1177 * @discussion You can use a scalar value for edge0 and edge1 if you want
1178 * to clamp all lanes at the same points. */
1179static inline SIMD_CFUNC simd_double3 simd_smoothstep(simd_double3 edge0, simd_double3 edge1, simd_double3 x);
1180/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1181 * @discussion You can use a scalar value for edge0 and edge1 if you want
1182 * to clamp all lanes at the same points. */
1183static inline SIMD_CFUNC simd_double4 simd_smoothstep(simd_double4 edge0, simd_double4 edge1, simd_double4 x);
1184/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1185 * @discussion You can use a scalar value for edge0 and edge1 if you want
1186 * to clamp all lanes at the same points. */
1187static inline SIMD_CFUNC simd_double8 simd_smoothstep(simd_double8 edge0, simd_double8 edge1, simd_double8 x);
1188/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1
1189 * @discussion Deprecated. Use simd_smoothstep(edge0, edge1, x) instead. */
1190#define vector_smoothstep simd_smoothstep
1191
1192/*! @abstract Sum of elements in x.
1193 * @discussion This computation may overflow; especial for 8-bit types you
1194 * may need to convert to a wider type before reducing. */
1195static inline SIMD_CFUNC char simd_reduce_add(simd_char2 x);
1196/*! @abstract Sum of elements in x.
1197 * @discussion This computation may overflow; especial for 8-bit types you
1198 * may need to convert to a wider type before reducing. */
1199static inline SIMD_CFUNC char simd_reduce_add(simd_char3 x);
1200/*! @abstract Sum of elements in x.
1201 * @discussion This computation may overflow; especial for 8-bit types you
1202 * may need to convert to a wider type before reducing. */
1203static inline SIMD_CFUNC char simd_reduce_add(simd_char4 x);
1204/*! @abstract Sum of elements in x.
1205 * @discussion This computation may overflow; especial for 8-bit types you
1206 * may need to convert to a wider type before reducing. */
1207static inline SIMD_CFUNC char simd_reduce_add(simd_char8 x);
1208/*! @abstract Sum of elements in x.
1209 * @discussion This computation may overflow; especial for 8-bit types you
1210 * may need to convert to a wider type before reducing. */
1211static inline SIMD_CFUNC char simd_reduce_add(simd_char16 x);
1212/*! @abstract Sum of elements in x.
1213 * @discussion This computation may overflow; especial for 8-bit types you
1214 * may need to convert to a wider type before reducing. */
1215static inline SIMD_CFUNC char simd_reduce_add(simd_char32 x);
1216/*! @abstract Sum of elements in x.
1217 * @discussion This computation may overflow; especial for 8-bit types you
1218 * may need to convert to a wider type before reducing. */
1219static inline SIMD_CFUNC char simd_reduce_add(simd_char64 x);
1220/*! @abstract Sum of elements in x.
1221 * @discussion This computation may overflow; especial for 8-bit types you
1222 * may need to convert to a wider type before reducing. */
1223static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar2 x);
1224/*! @abstract Sum of elements in x.
1225 * @discussion This computation may overflow; especial for 8-bit types you
1226 * may need to convert to a wider type before reducing. */
1227static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar3 x);
1228/*! @abstract Sum of elements in x.
1229 * @discussion This computation may overflow; especial for 8-bit types you
1230 * may need to convert to a wider type before reducing. */
1231static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar4 x);
1232/*! @abstract Sum of elements in x.
1233 * @discussion This computation may overflow; especial for 8-bit types you
1234 * may need to convert to a wider type before reducing. */
1235static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar8 x);
1236/*! @abstract Sum of elements in x.
1237 * @discussion This computation may overflow; especial for 8-bit types you
1238 * may need to convert to a wider type before reducing. */
1239static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar16 x);
1240/*! @abstract Sum of elements in x.
1241 * @discussion This computation may overflow; especial for 8-bit types you
1242 * may need to convert to a wider type before reducing. */
1243static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar32 x);
1244/*! @abstract Sum of elements in x.
1245 * @discussion This computation may overflow; especial for 8-bit types you
1246 * may need to convert to a wider type before reducing. */
1247static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar64 x);
1248/*! @abstract Sum of elements in x.
1249 * @discussion This computation may overflow; especial for 8-bit types you
1250 * may need to convert to a wider type before reducing. */
1251static inline SIMD_CFUNC short simd_reduce_add(simd_short2 x);
1252/*! @abstract Sum of elements in x.
1253 * @discussion This computation may overflow; especial for 8-bit types you
1254 * may need to convert to a wider type before reducing. */
1255static inline SIMD_CFUNC short simd_reduce_add(simd_short3 x);
1256/*! @abstract Sum of elements in x.
1257 * @discussion This computation may overflow; especial for 8-bit types you
1258 * may need to convert to a wider type before reducing. */
1259static inline SIMD_CFUNC short simd_reduce_add(simd_short4 x);
1260/*! @abstract Sum of elements in x.
1261 * @discussion This computation may overflow; especial for 8-bit types you
1262 * may need to convert to a wider type before reducing. */
1263static inline SIMD_CFUNC short simd_reduce_add(simd_short8 x);
1264/*! @abstract Sum of elements in x.
1265 * @discussion This computation may overflow; especial for 8-bit types you
1266 * may need to convert to a wider type before reducing. */
1267static inline SIMD_CFUNC short simd_reduce_add(simd_short16 x);
1268/*! @abstract Sum of elements in x.
1269 * @discussion This computation may overflow; especial for 8-bit types you
1270 * may need to convert to a wider type before reducing. */
1271static inline SIMD_CFUNC short simd_reduce_add(simd_short32 x);
1272/*! @abstract Sum of elements in x.
1273 * @discussion This computation may overflow; especial for 8-bit types you
1274 * may need to convert to a wider type before reducing. */
1275static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort2 x);
1276/*! @abstract Sum of elements in x.
1277 * @discussion This computation may overflow; especial for 8-bit types you
1278 * may need to convert to a wider type before reducing. */
1279static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort3 x);
1280/*! @abstract Sum of elements in x.
1281 * @discussion This computation may overflow; especial for 8-bit types you
1282 * may need to convert to a wider type before reducing. */
1283static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort4 x);
1284/*! @abstract Sum of elements in x.
1285 * @discussion This computation may overflow; especial for 8-bit types you
1286 * may need to convert to a wider type before reducing. */
1287static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort8 x);
1288/*! @abstract Sum of elements in x.
1289 * @discussion This computation may overflow; especial for 8-bit types you
1290 * may need to convert to a wider type before reducing. */
1291static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort16 x);
1292/*! @abstract Sum of elements in x.
1293 * @discussion This computation may overflow; especial for 8-bit types you
1294 * may need to convert to a wider type before reducing. */
1295static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort32 x);
1296/*! @abstract Sum of elements in x.
1297 * @discussion This computation may overflow; especial for 8-bit types you
1298 * may need to convert to a wider type before reducing. */
1299static inline SIMD_CFUNC int simd_reduce_add(simd_int2 x);
1300/*! @abstract Sum of elements in x.
1301 * @discussion This computation may overflow; especial for 8-bit types you
1302 * may need to convert to a wider type before reducing. */
1303static inline SIMD_CFUNC int simd_reduce_add(simd_int3 x);
1304/*! @abstract Sum of elements in x.
1305 * @discussion This computation may overflow; especial for 8-bit types you
1306 * may need to convert to a wider type before reducing. */
1307static inline SIMD_CFUNC int simd_reduce_add(simd_int4 x);
1308/*! @abstract Sum of elements in x.
1309 * @discussion This computation may overflow; especial for 8-bit types you
1310 * may need to convert to a wider type before reducing. */
1311static inline SIMD_CFUNC int simd_reduce_add(simd_int8 x);
1312/*! @abstract Sum of elements in x.
1313 * @discussion This computation may overflow; especial for 8-bit types you
1314 * may need to convert to a wider type before reducing. */
1315static inline SIMD_CFUNC int simd_reduce_add(simd_int16 x);
1316/*! @abstract Sum of elements in x.
1317 * @discussion This computation may overflow; especial for 8-bit types you
1318 * may need to convert to a wider type before reducing. */
1319static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint2 x);
1320/*! @abstract Sum of elements in x.
1321 * @discussion This computation may overflow; especial for 8-bit types you
1322 * may need to convert to a wider type before reducing. */
1323static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint3 x);
1324/*! @abstract Sum of elements in x.
1325 * @discussion This computation may overflow; especial for 8-bit types you
1326 * may need to convert to a wider type before reducing. */
1327static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint4 x);
1328/*! @abstract Sum of elements in x.
1329 * @discussion This computation may overflow; especial for 8-bit types you
1330 * may need to convert to a wider type before reducing. */
1331static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint8 x);
1332/*! @abstract Sum of elements in x.
1333 * @discussion This computation may overflow; especial for 8-bit types you
1334 * may need to convert to a wider type before reducing. */
1335static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint16 x);
1336/*! @abstract Sum of elements in x.
1337 * @discussion This computation may overflow; especial for 8-bit types you
1338 * may need to convert to a wider type before reducing. */
1339static inline SIMD_CFUNC float simd_reduce_add(simd_float2 x);
1340/*! @abstract Sum of elements in x.
1341 * @discussion This computation may overflow; especial for 8-bit types you
1342 * may need to convert to a wider type before reducing. */
1343static inline SIMD_CFUNC float simd_reduce_add(simd_float3 x);
1344/*! @abstract Sum of elements in x.
1345 * @discussion This computation may overflow; especial for 8-bit types you
1346 * may need to convert to a wider type before reducing. */
1347static inline SIMD_CFUNC float simd_reduce_add(simd_float4 x);
1348/*! @abstract Sum of elements in x.
1349 * @discussion This computation may overflow; especial for 8-bit types you
1350 * may need to convert to a wider type before reducing. */
1351static inline SIMD_CFUNC float simd_reduce_add(simd_float8 x);
1352/*! @abstract Sum of elements in x.
1353 * @discussion This computation may overflow; especial for 8-bit types you
1354 * may need to convert to a wider type before reducing. */
1355static inline SIMD_CFUNC float simd_reduce_add(simd_float16 x);
1356/*! @abstract Sum of elements in x.
1357 * @discussion This computation may overflow; especial for 8-bit types you
1358 * may need to convert to a wider type before reducing. */
1359static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long2 x);
1360/*! @abstract Sum of elements in x.
1361 * @discussion This computation may overflow; especial for 8-bit types you
1362 * may need to convert to a wider type before reducing. */
1363static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long3 x);
1364/*! @abstract Sum of elements in x.
1365 * @discussion This computation may overflow; especial for 8-bit types you
1366 * may need to convert to a wider type before reducing. */
1367static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long4 x);
1368/*! @abstract Sum of elements in x.
1369 * @discussion This computation may overflow; especial for 8-bit types you
1370 * may need to convert to a wider type before reducing. */
1371static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long8 x);
1372/*! @abstract Sum of elements in x.
1373 * @discussion This computation may overflow; especial for 8-bit types you
1374 * may need to convert to a wider type before reducing. */
1375static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong2 x);
1376/*! @abstract Sum of elements in x.
1377 * @discussion This computation may overflow; especial for 8-bit types you
1378 * may need to convert to a wider type before reducing. */
1379static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong3 x);
1380/*! @abstract Sum of elements in x.
1381 * @discussion This computation may overflow; especial for 8-bit types you
1382 * may need to convert to a wider type before reducing. */
1383static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong4 x);
1384/*! @abstract Sum of elements in x.
1385 * @discussion This computation may overflow; especial for 8-bit types you
1386 * may need to convert to a wider type before reducing. */
1387static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong8 x);
1388/*! @abstract Sum of elements in x.
1389 * @discussion This computation may overflow; especial for 8-bit types you
1390 * may need to convert to a wider type before reducing. */
1391static inline SIMD_CFUNC double simd_reduce_add(simd_double2 x);
1392/*! @abstract Sum of elements in x.
1393 * @discussion This computation may overflow; especial for 8-bit types you
1394 * may need to convert to a wider type before reducing. */
1395static inline SIMD_CFUNC double simd_reduce_add(simd_double3 x);
1396/*! @abstract Sum of elements in x.
1397 * @discussion This computation may overflow; especial for 8-bit types you
1398 * may need to convert to a wider type before reducing. */
1399static inline SIMD_CFUNC double simd_reduce_add(simd_double4 x);
1400/*! @abstract Sum of elements in x.
1401 * @discussion This computation may overflow; especial for 8-bit types you
1402 * may need to convert to a wider type before reducing. */
1403static inline SIMD_CFUNC double simd_reduce_add(simd_double8 x);
1404/*! @abstract Sum of elements in x.
1405 * @discussion Deprecated. Use simd_add(x) instead. */
1406#define vector_reduce_add simd_reduce_add
1407
1408/*! @abstract Minimum of elements in x. */
1409static inline SIMD_CFUNC char simd_reduce_min(simd_char2 x);
1410/*! @abstract Minimum of elements in x. */
1411static inline SIMD_CFUNC char simd_reduce_min(simd_char3 x);
1412/*! @abstract Minimum of elements in x. */
1413static inline SIMD_CFUNC char simd_reduce_min(simd_char4 x);
1414/*! @abstract Minimum of elements in x. */
1415static inline SIMD_CFUNC char simd_reduce_min(simd_char8 x);
1416/*! @abstract Minimum of elements in x. */
1417static inline SIMD_CFUNC char simd_reduce_min(simd_char16 x);
1418/*! @abstract Minimum of elements in x. */
1419static inline SIMD_CFUNC char simd_reduce_min(simd_char32 x);
1420/*! @abstract Minimum of elements in x. */
1421static inline SIMD_CFUNC char simd_reduce_min(simd_char64 x);
1422/*! @abstract Minimum of elements in x. */
1423static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar2 x);
1424/*! @abstract Minimum of elements in x. */
1425static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar3 x);
1426/*! @abstract Minimum of elements in x. */
1427static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar4 x);
1428/*! @abstract Minimum of elements in x. */
1429static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar8 x);
1430/*! @abstract Minimum of elements in x. */
1431static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar16 x);
1432/*! @abstract Minimum of elements in x. */
1433static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar32 x);
1434/*! @abstract Minimum of elements in x. */
1435static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar64 x);
1436/*! @abstract Minimum of elements in x. */
1437static inline SIMD_CFUNC short simd_reduce_min(simd_short2 x);
1438/*! @abstract Minimum of elements in x. */
1439static inline SIMD_CFUNC short simd_reduce_min(simd_short3 x);
1440/*! @abstract Minimum of elements in x. */
1441static inline SIMD_CFUNC short simd_reduce_min(simd_short4 x);
1442/*! @abstract Minimum of elements in x. */
1443static inline SIMD_CFUNC short simd_reduce_min(simd_short8 x);
1444/*! @abstract Minimum of elements in x. */
1445static inline SIMD_CFUNC short simd_reduce_min(simd_short16 x);
1446/*! @abstract Minimum of elements in x. */
1447static inline SIMD_CFUNC short simd_reduce_min(simd_short32 x);
1448/*! @abstract Minimum of elements in x. */
1449static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort2 x);
1450/*! @abstract Minimum of elements in x. */
1451static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort3 x);
1452/*! @abstract Minimum of elements in x. */
1453static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort4 x);
1454/*! @abstract Minimum of elements in x. */
1455static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort8 x);
1456/*! @abstract Minimum of elements in x. */
1457static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort16 x);
1458/*! @abstract Minimum of elements in x. */
1459static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort32 x);
1460/*! @abstract Minimum of elements in x. */
1461static inline SIMD_CFUNC int simd_reduce_min(simd_int2 x);
1462/*! @abstract Minimum of elements in x. */
1463static inline SIMD_CFUNC int simd_reduce_min(simd_int3 x);
1464/*! @abstract Minimum of elements in x. */
1465static inline SIMD_CFUNC int simd_reduce_min(simd_int4 x);
1466/*! @abstract Minimum of elements in x. */
1467static inline SIMD_CFUNC int simd_reduce_min(simd_int8 x);
1468/*! @abstract Minimum of elements in x. */
1469static inline SIMD_CFUNC int simd_reduce_min(simd_int16 x);
1470/*! @abstract Minimum of elements in x. */
1471static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint2 x);
1472/*! @abstract Minimum of elements in x. */
1473static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint3 x);
1474/*! @abstract Minimum of elements in x. */
1475static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint4 x);
1476/*! @abstract Minimum of elements in x. */
1477static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint8 x);
1478/*! @abstract Minimum of elements in x. */
1479static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint16 x);
1480/*! @abstract Minimum of elements in x. */
1481static inline SIMD_CFUNC float simd_reduce_min(simd_float2 x);
1482/*! @abstract Minimum of elements in x. */
1483static inline SIMD_CFUNC float simd_reduce_min(simd_float3 x);
1484/*! @abstract Minimum of elements in x. */
1485static inline SIMD_CFUNC float simd_reduce_min(simd_float4 x);
1486/*! @abstract Minimum of elements in x. */
1487static inline SIMD_CFUNC float simd_reduce_min(simd_float8 x);
1488/*! @abstract Minimum of elements in x. */
1489static inline SIMD_CFUNC float simd_reduce_min(simd_float16 x);
1490/*! @abstract Minimum of elements in x. */
1491static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long2 x);
1492/*! @abstract Minimum of elements in x. */
1493static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long3 x);
1494/*! @abstract Minimum of elements in x. */
1495static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long4 x);
1496/*! @abstract Minimum of elements in x. */
1497static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long8 x);
1498/*! @abstract Minimum of elements in x. */
1499static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong2 x);
1500/*! @abstract Minimum of elements in x. */
1501static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong3 x);
1502/*! @abstract Minimum of elements in x. */
1503static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong4 x);
1504/*! @abstract Minimum of elements in x. */
1505static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong8 x);
1506/*! @abstract Minimum of elements in x. */
1507static inline SIMD_CFUNC double simd_reduce_min(simd_double2 x);
1508/*! @abstract Minimum of elements in x. */
1509static inline SIMD_CFUNC double simd_reduce_min(simd_double3 x);
1510/*! @abstract Minimum of elements in x. */
1511static inline SIMD_CFUNC double simd_reduce_min(simd_double4 x);
1512/*! @abstract Minimum of elements in x. */
1513static inline SIMD_CFUNC double simd_reduce_min(simd_double8 x);
1514/*! @abstract Minimum of elements in x.
1515 * @discussion Deprecated. Use simd_min(x) instead. */
1516#define vector_reduce_min simd_reduce_min
1517
1518/*! @abstract Maximum of elements in x. */
1519static inline SIMD_CFUNC char simd_reduce_max(simd_char2 x);
1520/*! @abstract Maximum of elements in x. */
1521static inline SIMD_CFUNC char simd_reduce_max(simd_char3 x);
1522/*! @abstract Maximum of elements in x. */
1523static inline SIMD_CFUNC char simd_reduce_max(simd_char4 x);
1524/*! @abstract Maximum of elements in x. */
1525static inline SIMD_CFUNC char simd_reduce_max(simd_char8 x);
1526/*! @abstract Maximum of elements in x. */
1527static inline SIMD_CFUNC char simd_reduce_max(simd_char16 x);
1528/*! @abstract Maximum of elements in x. */
1529static inline SIMD_CFUNC char simd_reduce_max(simd_char32 x);
1530/*! @abstract Maximum of elements in x. */
1531static inline SIMD_CFUNC char simd_reduce_max(simd_char64 x);
1532/*! @abstract Maximum of elements in x. */
1533static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar2 x);
1534/*! @abstract Maximum of elements in x. */
1535static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar3 x);
1536/*! @abstract Maximum of elements in x. */
1537static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar4 x);
1538/*! @abstract Maximum of elements in x. */
1539static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar8 x);
1540/*! @abstract Maximum of elements in x. */
1541static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar16 x);
1542/*! @abstract Maximum of elements in x. */
1543static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar32 x);
1544/*! @abstract Maximum of elements in x. */
1545static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar64 x);
1546/*! @abstract Maximum of elements in x. */
1547static inline SIMD_CFUNC short simd_reduce_max(simd_short2 x);
1548/*! @abstract Maximum of elements in x. */
1549static inline SIMD_CFUNC short simd_reduce_max(simd_short3 x);
1550/*! @abstract Maximum of elements in x. */
1551static inline SIMD_CFUNC short simd_reduce_max(simd_short4 x);
1552/*! @abstract Maximum of elements in x. */
1553static inline SIMD_CFUNC short simd_reduce_max(simd_short8 x);
1554/*! @abstract Maximum of elements in x. */
1555static inline SIMD_CFUNC short simd_reduce_max(simd_short16 x);
1556/*! @abstract Maximum of elements in x. */
1557static inline SIMD_CFUNC short simd_reduce_max(simd_short32 x);
1558/*! @abstract Maximum of elements in x. */
1559static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort2 x);
1560/*! @abstract Maximum of elements in x. */
1561static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort3 x);
1562/*! @abstract Maximum of elements in x. */
1563static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort4 x);
1564/*! @abstract Maximum of elements in x. */
1565static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort8 x);
1566/*! @abstract Maximum of elements in x. */
1567static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort16 x);
1568/*! @abstract Maximum of elements in x. */
1569static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort32 x);
1570/*! @abstract Maximum of elements in x. */
1571static inline SIMD_CFUNC int simd_reduce_max(simd_int2 x);
1572/*! @abstract Maximum of elements in x. */
1573static inline SIMD_CFUNC int simd_reduce_max(simd_int3 x);
1574/*! @abstract Maximum of elements in x. */
1575static inline SIMD_CFUNC int simd_reduce_max(simd_int4 x);
1576/*! @abstract Maximum of elements in x. */
1577static inline SIMD_CFUNC int simd_reduce_max(simd_int8 x);
1578/*! @abstract Maximum of elements in x. */
1579static inline SIMD_CFUNC int simd_reduce_max(simd_int16 x);
1580/*! @abstract Maximum of elements in x. */
1581static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint2 x);
1582/*! @abstract Maximum of elements in x. */
1583static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint3 x);
1584/*! @abstract Maximum of elements in x. */
1585static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint4 x);
1586/*! @abstract Maximum of elements in x. */
1587static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint8 x);
1588/*! @abstract Maximum of elements in x. */
1589static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint16 x);
1590/*! @abstract Maximum of elements in x. */
1591static inline SIMD_CFUNC float simd_reduce_max(simd_float2 x);
1592/*! @abstract Maximum of elements in x. */
1593static inline SIMD_CFUNC float simd_reduce_max(simd_float3 x);
1594/*! @abstract Maximum of elements in x. */
1595static inline SIMD_CFUNC float simd_reduce_max(simd_float4 x);
1596/*! @abstract Maximum of elements in x. */
1597static inline SIMD_CFUNC float simd_reduce_max(simd_float8 x);
1598/*! @abstract Maximum of elements in x. */
1599static inline SIMD_CFUNC float simd_reduce_max(simd_float16 x);
1600/*! @abstract Maximum of elements in x. */
1601static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long2 x);
1602/*! @abstract Maximum of elements in x. */
1603static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long3 x);
1604/*! @abstract Maximum of elements in x. */
1605static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long4 x);
1606/*! @abstract Maximum of elements in x. */
1607static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long8 x);
1608/*! @abstract Maximum of elements in x. */
1609static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong2 x);
1610/*! @abstract Maximum of elements in x. */
1611static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong3 x);
1612/*! @abstract Maximum of elements in x. */
1613static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong4 x);
1614/*! @abstract Maximum of elements in x. */
1615static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong8 x);
1616/*! @abstract Maximum of elements in x. */
1617static inline SIMD_CFUNC double simd_reduce_max(simd_double2 x);
1618/*! @abstract Maximum of elements in x. */
1619static inline SIMD_CFUNC double simd_reduce_max(simd_double3 x);
1620/*! @abstract Maximum of elements in x. */
1621static inline SIMD_CFUNC double simd_reduce_max(simd_double4 x);
1622/*! @abstract Maximum of elements in x. */
1623static inline SIMD_CFUNC double simd_reduce_max(simd_double8 x);
1624/*! @abstract Maximum of elements in x.
1625 * @discussion Deprecated. Use simd_max(x) instead. */
1626#define vector_reduce_max simd_reduce_max
1627
1628/*! @abstract True if and only if each lane of x is equal to the
1629 * corresponding lane of y. */
1630static inline SIMD_CFUNC simd_bool simd_equal(simd_char2 x, simd_char2 y) {
1631 return simd_all(x == y);
1632}
1633/*! @abstract True if and only if each lane of x is equal to the
1634 * corresponding lane of y. */
1635static inline SIMD_CFUNC simd_bool simd_equal(simd_char3 x, simd_char3 y) {
1636 return simd_all(x == y);
1637}
1638/*! @abstract True if and only if each lane of x is equal to the
1639 * corresponding lane of y. */
1640static inline SIMD_CFUNC simd_bool simd_equal(simd_char4 x, simd_char4 y) {
1641 return simd_all(x == y);
1642}
1643/*! @abstract True if and only if each lane of x is equal to the
1644 * corresponding lane of y. */
1645static inline SIMD_CFUNC simd_bool simd_equal(simd_char8 x, simd_char8 y) {
1646 return simd_all(x == y);
1647}
1648/*! @abstract True if and only if each lane of x is equal to the
1649 * corresponding lane of y. */
1650static inline SIMD_CFUNC simd_bool simd_equal(simd_char16 x, simd_char16 y) {
1651 return simd_all(x == y);
1652}
1653/*! @abstract True if and only if each lane of x is equal to the
1654 * corresponding lane of y. */
1655static inline SIMD_CFUNC simd_bool simd_equal(simd_char32 x, simd_char32 y) {
1656 return simd_all(x == y);
1657}
1658/*! @abstract True if and only if each lane of x is equal to the
1659 * corresponding lane of y. */
1660static inline SIMD_CFUNC simd_bool simd_equal(simd_char64 x, simd_char64 y) {
1661 return simd_all(x == y);
1662}
1663/*! @abstract True if and only if each lane of x is equal to the
1664 * corresponding lane of y. */
1665static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar2 x, simd_uchar2 y) {
1666 return simd_all(x == y);
1667}
1668/*! @abstract True if and only if each lane of x is equal to the
1669 * corresponding lane of y. */
1670static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar3 x, simd_uchar3 y) {
1671 return simd_all(x == y);
1672}
1673/*! @abstract True if and only if each lane of x is equal to the
1674 * corresponding lane of y. */
1675static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar4 x, simd_uchar4 y) {
1676 return simd_all(x == y);
1677}
1678/*! @abstract True if and only if each lane of x is equal to the
1679 * corresponding lane of y. */
1680static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar8 x, simd_uchar8 y) {
1681 return simd_all(x == y);
1682}
1683/*! @abstract True if and only if each lane of x is equal to the
1684 * corresponding lane of y. */
1685static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar16 x, simd_uchar16 y) {
1686 return simd_all(x == y);
1687}
1688/*! @abstract True if and only if each lane of x is equal to the
1689 * corresponding lane of y. */
1690static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar32 x, simd_uchar32 y) {
1691 return simd_all(x == y);
1692}
1693/*! @abstract True if and only if each lane of x is equal to the
1694 * corresponding lane of y. */
1695static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar64 x, simd_uchar64 y) {
1696 return simd_all(x == y);
1697}
1698/*! @abstract True if and only if each lane of x is equal to the
1699 * corresponding lane of y. */
1700static inline SIMD_CFUNC simd_bool simd_equal(simd_short2 x, simd_short2 y) {
1701 return simd_all(x == y);
1702}
1703/*! @abstract True if and only if each lane of x is equal to the
1704 * corresponding lane of y. */
1705static inline SIMD_CFUNC simd_bool simd_equal(simd_short3 x, simd_short3 y) {
1706 return simd_all(x == y);
1707}
1708/*! @abstract True if and only if each lane of x is equal to the
1709 * corresponding lane of y. */
1710static inline SIMD_CFUNC simd_bool simd_equal(simd_short4 x, simd_short4 y) {
1711 return simd_all(x == y);
1712}
1713/*! @abstract True if and only if each lane of x is equal to the
1714 * corresponding lane of y. */
1715static inline SIMD_CFUNC simd_bool simd_equal(simd_short8 x, simd_short8 y) {
1716 return simd_all(x == y);
1717}
1718/*! @abstract True if and only if each lane of x is equal to the
1719 * corresponding lane of y. */
1720static inline SIMD_CFUNC simd_bool simd_equal(simd_short16 x, simd_short16 y) {
1721 return simd_all(x == y);
1722}
1723/*! @abstract True if and only if each lane of x is equal to the
1724 * corresponding lane of y. */
1725static inline SIMD_CFUNC simd_bool simd_equal(simd_short32 x, simd_short32 y) {
1726 return simd_all(x == y);
1727}
1728/*! @abstract True if and only if each lane of x is equal to the
1729 * corresponding lane of y. */
1730static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort2 x, simd_ushort2 y) {
1731 return simd_all(x == y);
1732}
1733/*! @abstract True if and only if each lane of x is equal to the
1734 * corresponding lane of y. */
1735static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort3 x, simd_ushort3 y) {
1736 return simd_all(x == y);
1737}
1738/*! @abstract True if and only if each lane of x is equal to the
1739 * corresponding lane of y. */
1740static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort4 x, simd_ushort4 y) {
1741 return simd_all(x == y);
1742}
1743/*! @abstract True if and only if each lane of x is equal to the
1744 * corresponding lane of y. */
1745static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort8 x, simd_ushort8 y) {
1746 return simd_all(x == y);
1747}
1748/*! @abstract True if and only if each lane of x is equal to the
1749 * corresponding lane of y. */
1750static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort16 x, simd_ushort16 y) {
1751 return simd_all(x == y);
1752}
1753/*! @abstract True if and only if each lane of x is equal to the
1754 * corresponding lane of y. */
1755static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort32 x, simd_ushort32 y) {
1756 return simd_all(x == y);
1757}
1758/*! @abstract True if and only if each lane of x is equal to the
1759 * corresponding lane of y. */
1760static inline SIMD_CFUNC simd_bool simd_equal(simd_int2 x, simd_int2 y) {
1761 return simd_all(x == y);
1762}
1763/*! @abstract True if and only if each lane of x is equal to the
1764 * corresponding lane of y. */
1765static inline SIMD_CFUNC simd_bool simd_equal(simd_int3 x, simd_int3 y) {
1766 return simd_all(x == y);
1767}
1768/*! @abstract True if and only if each lane of x is equal to the
1769 * corresponding lane of y. */
1770static inline SIMD_CFUNC simd_bool simd_equal(simd_int4 x, simd_int4 y) {
1771 return simd_all(x == y);
1772}
1773/*! @abstract True if and only if each lane of x is equal to the
1774 * corresponding lane of y. */
1775static inline SIMD_CFUNC simd_bool simd_equal(simd_int8 x, simd_int8 y) {
1776 return simd_all(x == y);
1777}
1778/*! @abstract True if and only if each lane of x is equal to the
1779 * corresponding lane of y. */
1780static inline SIMD_CFUNC simd_bool simd_equal(simd_int16 x, simd_int16 y) {
1781 return simd_all(x == y);
1782}
1783/*! @abstract True if and only if each lane of x is equal to the
1784 * corresponding lane of y. */
1785static inline SIMD_CFUNC simd_bool simd_equal(simd_uint2 x, simd_uint2 y) {
1786 return simd_all(x == y);
1787}
1788/*! @abstract True if and only if each lane of x is equal to the
1789 * corresponding lane of y. */
1790static inline SIMD_CFUNC simd_bool simd_equal(simd_uint3 x, simd_uint3 y) {
1791 return simd_all(x == y);
1792}
1793/*! @abstract True if and only if each lane of x is equal to the
1794 * corresponding lane of y. */
1795static inline SIMD_CFUNC simd_bool simd_equal(simd_uint4 x, simd_uint4 y) {
1796 return simd_all(x == y);
1797}
1798/*! @abstract True if and only if each lane of x is equal to the
1799 * corresponding lane of y. */
1800static inline SIMD_CFUNC simd_bool simd_equal(simd_uint8 x, simd_uint8 y) {
1801 return simd_all(x == y);
1802}
1803/*! @abstract True if and only if each lane of x is equal to the
1804 * corresponding lane of y. */
1805static inline SIMD_CFUNC simd_bool simd_equal(simd_uint16 x, simd_uint16 y) {
1806 return simd_all(x == y);
1807}
1808/*! @abstract True if and only if each lane of x is equal to the
1809 * corresponding lane of y. */
1810static inline SIMD_CFUNC simd_bool simd_equal(simd_float2 x, simd_float2 y) {
1811 return simd_all(x == y);
1812}
1813/*! @abstract True if and only if each lane of x is equal to the
1814 * corresponding lane of y. */
1815static inline SIMD_CFUNC simd_bool simd_equal(simd_float3 x, simd_float3 y) {
1816 return simd_all(x == y);
1817}
1818/*! @abstract True if and only if each lane of x is equal to the
1819 * corresponding lane of y. */
1820static inline SIMD_CFUNC simd_bool simd_equal(simd_float4 x, simd_float4 y) {
1821 return simd_all(x == y);
1822}
1823/*! @abstract True if and only if each lane of x is equal to the
1824 * corresponding lane of y. */
1825static inline SIMD_CFUNC simd_bool simd_equal(simd_float8 x, simd_float8 y) {
1826 return simd_all(x == y);
1827}
1828/*! @abstract True if and only if each lane of x is equal to the
1829 * corresponding lane of y. */
1830static inline SIMD_CFUNC simd_bool simd_equal(simd_float16 x, simd_float16 y) {
1831 return simd_all(x == y);
1832}
1833/*! @abstract True if and only if each lane of x is equal to the
1834 * corresponding lane of y. */
1835static inline SIMD_CFUNC simd_bool simd_equal(simd_long2 x, simd_long2 y) {
1836 return simd_all(x == y);
1837}
1838/*! @abstract True if and only if each lane of x is equal to the
1839 * corresponding lane of y. */
1840static inline SIMD_CFUNC simd_bool simd_equal(simd_long3 x, simd_long3 y) {
1841 return simd_all(x == y);
1842}
1843/*! @abstract True if and only if each lane of x is equal to the
1844 * corresponding lane of y. */
1845static inline SIMD_CFUNC simd_bool simd_equal(simd_long4 x, simd_long4 y) {
1846 return simd_all(x == y);
1847}
1848/*! @abstract True if and only if each lane of x is equal to the
1849 * corresponding lane of y. */
1850static inline SIMD_CFUNC simd_bool simd_equal(simd_long8 x, simd_long8 y) {
1851 return simd_all(x == y);
1852}
1853/*! @abstract True if and only if each lane of x is equal to the
1854 * corresponding lane of y. */
1855static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong2 x, simd_ulong2 y) {
1856 return simd_all(x == y);
1857}
1858/*! @abstract True if and only if each lane of x is equal to the
1859 * corresponding lane of y. */
1860static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong3 x, simd_ulong3 y) {
1861 return simd_all(x == y);
1862}
1863/*! @abstract True if and only if each lane of x is equal to the
1864 * corresponding lane of y. */
1865static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong4 x, simd_ulong4 y) {
1866 return simd_all(x == y);
1867}
1868/*! @abstract True if and only if each lane of x is equal to the
1869 * corresponding lane of y. */
1870static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong8 x, simd_ulong8 y) {
1871 return simd_all(x == y);
1872}
1873/*! @abstract True if and only if each lane of x is equal to the
1874 * corresponding lane of y. */
1875static inline SIMD_CFUNC simd_bool simd_equal(simd_double2 x, simd_double2 y) {
1876 return simd_all(x == y);
1877}
1878/*! @abstract True if and only if each lane of x is equal to the
1879 * corresponding lane of y. */
1880static inline SIMD_CFUNC simd_bool simd_equal(simd_double3 x, simd_double3 y) {
1881 return simd_all(x == y);
1882}
1883/*! @abstract True if and only if each lane of x is equal to the
1884 * corresponding lane of y. */
1885static inline SIMD_CFUNC simd_bool simd_equal(simd_double4 x, simd_double4 y) {
1886 return simd_all(x == y);
1887}
1888/*! @abstract True if and only if each lane of x is equal to the
1889 * corresponding lane of y. */
1890static inline SIMD_CFUNC simd_bool simd_equal(simd_double8 x, simd_double8 y) {
1891 return simd_all(x == y);
1892}
1893
1894#ifdef __cplusplus
1895} /* extern "C" */
1896
1897namespace simd {
1898 /*! @abstract The lanewise absolute value of x. */
1899 template <typename typeN> static SIMD_CPPFUNC typeN abs(const typeN x) { return ::simd_abs(x); }
1900 /*! @abstract The lanewise maximum of x and y. */
1901 template <typename typeN> static SIMD_CPPFUNC typeN max(const typeN x, const typeN y) { return ::simd_max(x,y); }
1902 /*! @abstract The lanewise minimum of x and y. */
1903 template <typename typeN> static SIMD_CPPFUNC typeN min(const typeN x, const typeN y) { return ::simd_min(x,y); }
1904 /*! @abstract x clamped to the interval [min, max]. */
1905 template <typename typeN> static SIMD_CPPFUNC typeN clamp(const typeN x, const typeN min, const typeN max) { return ::simd_clamp(x,min,max); }
1906 /*! @abstract -1 if x < 0, +1 if x > 0, and 0 otherwise. */
1907 template <typename fptypeN> static SIMD_CPPFUNC fptypeN sign(const fptypeN x) { return ::simd_sign(x); }
1908 /*! @abstract Linearly interpolates between x and y, taking the value x when t=0 and y when t=1 */
1909 template <typename fptypeN> static SIMD_CPPFUNC fptypeN mix(const fptypeN x, const fptypeN y, const fptypeN t) { return ::simd_mix(x,y,t); }
1910 /*! @abstract An approximation to 1/x. */
1911 template <typename fptypeN> static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return simd_recip(x); }
1912 /*! @abstract An approximation to 1/sqrt(x). */
1913 template <typename fptypeN> static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return simd_rsqrt(x); }
1914 /*! @abstract The "fracional part" of x, in the range [0,1). */
1915 template <typename fptypeN> static SIMD_CPPFUNC fptypeN fract(const fptypeN x) { return ::simd_fract(x); }
1916 /*! @abstract 0 if x < edge, 1 otherwise. */
1917 template <typename fptypeN> static SIMD_CPPFUNC fptypeN step(const fptypeN edge, const fptypeN x) { return ::simd_step(edge,x); }
1918 /*! @abstract smoothly interpolates from 0 at edge0 to 1 at edge1. */
1919 template <typename fptypeN> static SIMD_CPPFUNC fptypeN smoothstep(const fptypeN edge0, const fptypeN edge1, const fptypeN x) { return ::simd_smoothstep(edge0,edge1,x); }
1920 /*! @abstract True if and only if each lane of x is equal to the
1921 * corresponding lane of y.
1922 *
1923 * @discussion This isn't operator== because that's already defined by
1924 * the compiler to return a lane mask. */
1925 template <typename fptypeN> static SIMD_CPPFUNC simd_bool equal(const fptypeN x, const fptypeN y) { return ::simd_equal(x, y); }
1926#if __cpp_decltype_auto
1927 /* If you are targeting an earlier version of the C++ standard that lacks
1928 decltype_auto support, you may use the C-style simd_reduce_* functions
1929 instead. */
1930 /*! @abstract The sum of the elements in x. May overflow. */
1931 template <typename typeN> static SIMD_CPPFUNC auto reduce_add(typeN x) { return ::simd_reduce_add(x); }
1932 /*! @abstract The least element in x. */
1933 template <typename typeN> static SIMD_CPPFUNC auto reduce_min(typeN x) { return ::simd_reduce_min(x); }
1934 /*! @abstract The greatest element in x. */
1935 template <typename typeN> static SIMD_CPPFUNC auto reduce_max(typeN x) { return ::simd_reduce_max(x); }
1936#endif
1937 namespace precise {
1938 /*! @abstract An approximation to 1/x. */
1939 template <typename fptypeN> static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return ::simd_precise_recip(x); }
1940 /*! @abstract An approximation to 1/sqrt(x). */
1941 template <typename fptypeN> static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return ::simd_precise_rsqrt(x); }
1942 }
1943 namespace fast {
1944 /*! @abstract An approximation to 1/x. */
1945 template <typename fptypeN> static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return ::simd_fast_recip(x); }
1946 /*! @abstract An approximation to 1/sqrt(x). */
1947 template <typename fptypeN> static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return ::simd_fast_rsqrt(x); }
1948 }
1949}
1950
1951extern "C" {
1952#endif /* __cplusplus */
1953
1954#pragma mark - Implementation
1955
1956static inline SIMD_CFUNC simd_char2 simd_abs(simd_char2 x) {
1957 return simd_make_char2(simd_abs(simd_make_char8_undef(x)));
1958}
1959
1960static inline SIMD_CFUNC simd_char3 simd_abs(simd_char3 x) {
1961 return simd_make_char3(simd_abs(simd_make_char8_undef(x)));
1962}
1963
1964static inline SIMD_CFUNC simd_char4 simd_abs(simd_char4 x) {
1965 return simd_make_char4(simd_abs(simd_make_char8_undef(x)));
1966}
1967
1968static inline SIMD_CFUNC simd_char8 simd_abs(simd_char8 x) {
1969#if defined __arm__ || defined __arm64__
1970 return vabs_s8(x);
1971#else
1972 return simd_make_char8(simd_abs(simd_make_char16_undef(x)));
1973#endif
1974}
1975
1976static inline SIMD_CFUNC simd_char16 simd_abs(simd_char16 x) {
1977#if defined __arm__ || defined __arm64__
1978 return vabsq_s8(x);
1979#elif defined __SSE4_1__
1980 return (simd_char16) _mm_abs_epi8((__m128i)x);
1981#else
1982 simd_char16 mask = x >> 7; return (x ^ mask) - mask;
1983#endif
1984}
1985
1986static inline SIMD_CFUNC simd_char32 simd_abs(simd_char32 x) {
1987#if defined __AVX2__
1988 return _mm256_abs_epi8(x);
1989#else
1990 return simd_make_char32(simd_abs(x.lo), simd_abs(x.hi));
1991#endif
1992}
1993
1994static inline SIMD_CFUNC simd_char64 simd_abs(simd_char64 x) {
1995#if defined __AVX512BW__
1996 return _mm512_abs_epi8(x);
1997#else
1998 return simd_make_char64(simd_abs(x.lo), simd_abs(x.hi));
1999#endif
2000}
2001
2002static inline SIMD_CFUNC simd_short2 simd_abs(simd_short2 x) {
2003 return simd_make_short2(simd_abs(simd_make_short4_undef(x)));
2004}
2005
2006static inline SIMD_CFUNC simd_short3 simd_abs(simd_short3 x) {
2007 return simd_make_short3(simd_abs(simd_make_short4_undef(x)));
2008}
2009
2010static inline SIMD_CFUNC simd_short4 simd_abs(simd_short4 x) {
2011#if defined __arm__ || defined __arm64__
2012 return vabs_s16(x);
2013#else
2014 return simd_make_short4(simd_abs(simd_make_short8_undef(x)));
2015#endif
2016}
2017
2018static inline SIMD_CFUNC simd_short8 simd_abs(simd_short8 x) {
2019#if defined __arm__ || defined __arm64__
2020 return vabsq_s16(x);
2021#elif defined __SSE4_1__
2022 return (simd_short8) _mm_abs_epi16((__m128i)x);
2023#else
2024 simd_short8 mask = x >> 15; return (x ^ mask) - mask;
2025#endif
2026}
2027
2028static inline SIMD_CFUNC simd_short16 simd_abs(simd_short16 x) {
2029#if defined __AVX2__
2030 return _mm256_abs_epi16(x);
2031#else
2032 return simd_make_short16(simd_abs(x.lo), simd_abs(x.hi));
2033#endif
2034}
2035
2036static inline SIMD_CFUNC simd_short32 simd_abs(simd_short32 x) {
2037#if defined __AVX512BW__
2038 return _mm512_abs_epi16(x);
2039#else
2040 return simd_make_short32(simd_abs(x.lo), simd_abs(x.hi));
2041#endif
2042}
2043
2044static inline SIMD_CFUNC simd_int2 simd_abs(simd_int2 x) {
2045#if defined __arm__ || defined __arm64__
2046 return vabs_s32(x);
2047#else
2048 return simd_make_int2(simd_abs(simd_make_int4_undef(x)));
2049#endif
2050}
2051
2052static inline SIMD_CFUNC simd_int3 simd_abs(simd_int3 x) {
2053 return simd_make_int3(simd_abs(simd_make_int4_undef(x)));
2054}
2055
2056static inline SIMD_CFUNC simd_int4 simd_abs(simd_int4 x) {
2057#if defined __arm__ || defined __arm64__
2058 return vabsq_s32(x);
2059#elif defined __SSE4_1__
2060 return (simd_int4) _mm_abs_epi32((__m128i)x);
2061#else
2062 simd_int4 mask = x >> 31; return (x ^ mask) - mask;
2063#endif
2064}
2065
2066static inline SIMD_CFUNC simd_int8 simd_abs(simd_int8 x) {
2067#if defined __AVX2__
2068 return _mm256_abs_epi32(x);
2069#else
2070 return simd_make_int8(simd_abs(x.lo), simd_abs(x.hi));
2071#endif
2072}
2073
2074static inline SIMD_CFUNC simd_int16 simd_abs(simd_int16 x) {
2075#if defined __AVX512F__
2076 return _mm512_abs_epi32(x);
2077#else
2078 return simd_make_int16(simd_abs(x.lo), simd_abs(x.hi));
2079#endif
2080}
2081
2082static inline SIMD_CFUNC simd_float2 simd_abs(simd_float2 x) {
2083 return __tg_fabs(x);
2084}
2085
2086static inline SIMD_CFUNC simd_float3 simd_abs(simd_float3 x) {
2087 return __tg_fabs(x);
2088}
2089
2090static inline SIMD_CFUNC simd_float4 simd_abs(simd_float4 x) {
2091 return __tg_fabs(x);
2092}
2093
2094static inline SIMD_CFUNC simd_float8 simd_abs(simd_float8 x) {
2095 return __tg_fabs(x);
2096}
2097
2098static inline SIMD_CFUNC simd_float16 simd_abs(simd_float16 x) {
2099 return __tg_fabs(x);
2100}
2101
2102static inline SIMD_CFUNC simd_long2 simd_abs(simd_long2 x) {
2103#if defined __arm64__
2104 return vabsq_s64(x);
2105#elif defined __SSE4_1__
2106 return (simd_long2) _mm_abs_epi64((__m128i)x);
2107#else
2108 simd_long2 mask = x >> 63; return (x ^ mask) - mask;
2109#endif
2110}
2111
2112static inline SIMD_CFUNC simd_long3 simd_abs(simd_long3 x) {
2113 return simd_make_long3(simd_abs(simd_make_long4_undef(x)));
2114}
2115
2116static inline SIMD_CFUNC simd_long4 simd_abs(simd_long4 x) {
2117#if defined __AVX2__
2118 return _mm256_abs_epi64(x);
2119#else
2120 return simd_make_long4(simd_abs(x.lo), simd_abs(x.hi));
2121#endif
2122}
2123
2124static inline SIMD_CFUNC simd_long8 simd_abs(simd_long8 x) {
2125#if defined __AVX512F__
2126 return _mm512_abs_epi64(x);
2127#else
2128 return simd_make_long8(simd_abs(x.lo), simd_abs(x.hi));
2129#endif
2130}
2131
2132static inline SIMD_CFUNC simd_double2 simd_abs(simd_double2 x) {
2133 return __tg_fabs(x);
2134}
2135
2136static inline SIMD_CFUNC simd_double3 simd_abs(simd_double3 x) {
2137 return __tg_fabs(x);
2138}
2139
2140static inline SIMD_CFUNC simd_double4 simd_abs(simd_double4 x) {
2141 return __tg_fabs(x);
2142}
2143
2144static inline SIMD_CFUNC simd_double8 simd_abs(simd_double8 x) {
2145 return __tg_fabs(x);
2146}
2147
2148static inline SIMD_CFUNC simd_char2 simd_min(simd_char2 x, simd_char2 y) {
2149 return simd_make_char2(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y)));
2150}
2151
2152static inline SIMD_CFUNC simd_char3 simd_min(simd_char3 x, simd_char3 y) {
2153 return simd_make_char3(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y)));
2154}
2155
2156static inline SIMD_CFUNC simd_char4 simd_min(simd_char4 x, simd_char4 y) {
2157 return simd_make_char4(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y)));
2158}
2159
2160static inline SIMD_CFUNC simd_char8 simd_min(simd_char8 x, simd_char8 y) {
2161#if defined __arm__ || defined __arm64__
2162 return vmin_s8(x, y);
2163#else
2164 return simd_make_char8(simd_min(simd_make_char16_undef(x), simd_make_char16_undef(y)));
2165#endif
2166
2167}
2168
2169static inline SIMD_CFUNC simd_char16 simd_min(simd_char16 x, simd_char16 y) {
2170#if defined __arm__ || defined __arm64__
2171 return vminq_s8(x, y);
2172#elif defined __SSE4_1__
2173 return (simd_char16) _mm_min_epi8((__m128i)x, (__m128i)y);
2174#else
2175 return simd_bitselect(x, y, y < x);
2176#endif
2177}
2178
2179static inline SIMD_CFUNC simd_char32 simd_min(simd_char32 x, simd_char32 y) {
2180#if defined __AVX2__
2181 return _mm256_min_epi8(x, y);
2182#else
2183 return simd_bitselect(x, y, y < x);
2184#endif
2185}
2186
2187static inline SIMD_CFUNC simd_char64 simd_min(simd_char64 x, simd_char64 y) {
2188#if defined __AVX512BW__
2189 return _mm512_min_epi8(x, y);
2190#else
2191 return simd_bitselect(x, y, y < x);
2192#endif
2193}
2194
2195static inline SIMD_CFUNC simd_uchar2 simd_min(simd_uchar2 x, simd_uchar2 y) {
2196 return simd_make_uchar2(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y)));
2197}
2198
2199static inline SIMD_CFUNC simd_uchar3 simd_min(simd_uchar3 x, simd_uchar3 y) {
2200 return simd_make_uchar3(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y)));
2201}
2202
2203static inline SIMD_CFUNC simd_uchar4 simd_min(simd_uchar4 x, simd_uchar4 y) {
2204 return simd_make_uchar4(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y)));
2205}
2206
2207static inline SIMD_CFUNC simd_uchar8 simd_min(simd_uchar8 x, simd_uchar8 y) {
2208#if defined __arm__ || defined __arm64__
2209 return vmin_u8(x, y);
2210#else
2211 return simd_make_uchar8(simd_min(simd_make_uchar16_undef(x), simd_make_uchar16_undef(y)));
2212#endif
2213
2214}
2215
2216static inline SIMD_CFUNC simd_uchar16 simd_min(simd_uchar16 x, simd_uchar16 y) {
2217#if defined __arm__ || defined __arm64__
2218 return vminq_u8(x, y);
2219#elif defined __SSE4_1__
2220 return (simd_uchar16) _mm_min_epu8((__m128i)x, (__m128i)y);
2221#else
2222 return simd_bitselect(x, y, y < x);
2223#endif
2224}
2225
2226static inline SIMD_CFUNC simd_uchar32 simd_min(simd_uchar32 x, simd_uchar32 y) {
2227#if defined __AVX2__
2228 return _mm256_min_epu8(x, y);
2229#else
2230 return simd_bitselect(x, y, y < x);
2231#endif
2232}
2233
2234static inline SIMD_CFUNC simd_uchar64 simd_min(simd_uchar64 x, simd_uchar64 y) {
2235#if defined __AVX512BW__
2236 return _mm512_min_epu8(x, y);
2237#else
2238 return simd_bitselect(x, y, y < x);
2239#endif
2240}
2241
2242static inline SIMD_CFUNC simd_short2 simd_min(simd_short2 x, simd_short2 y) {
2243 return simd_make_short2(simd_min(simd_make_short4_undef(x), simd_make_short4_undef(y)));
2244}
2245
2246static inline SIMD_CFUNC simd_short3 simd_min(simd_short3 x, simd_short3 y) {
2247 return simd_make_short3(simd_min(simd_make_short4_undef(x), simd_make_short4_undef(y)));
2248}
2249
2250static inline SIMD_CFUNC simd_short4 simd_min(simd_short4 x, simd_short4 y) {
2251#if defined __arm__ || defined __arm64__
2252 return vmin_s16(x, y);
2253#else
2254 return simd_make_short4(simd_min(simd_make_short8_undef(x), simd_make_short8_undef(y)));
2255#endif
2256
2257}
2258
2259static inline SIMD_CFUNC simd_short8 simd_min(simd_short8 x, simd_short8 y) {
2260#if defined __arm__ || defined __arm64__
2261 return vminq_s16(x, y);
2262#elif defined __SSE4_1__
2263 return (simd_short8) _mm_min_epi16((__m128i)x, (__m128i)y);
2264#else
2265 return simd_bitselect(x, y, y < x);
2266#endif
2267}
2268
2269static inline SIMD_CFUNC simd_short16 simd_min(simd_short16 x, simd_short16 y) {
2270#if defined __AVX2__
2271 return _mm256_min_epi16(x, y);
2272#else
2273 return simd_bitselect(x, y, y < x);
2274#endif
2275}
2276
2277static inline SIMD_CFUNC simd_short32 simd_min(simd_short32 x, simd_short32 y) {
2278#if defined __AVX512BW__
2279 return _mm512_min_epi16(x, y);
2280#else
2281 return simd_bitselect(x, y, y < x);
2282#endif
2283}
2284
2285static inline SIMD_CFUNC simd_ushort2 simd_min(simd_ushort2 x, simd_ushort2 y) {
2286 return simd_make_ushort2(simd_min(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y)));
2287}
2288
2289static inline SIMD_CFUNC simd_ushort3 simd_min(simd_ushort3 x, simd_ushort3 y) {
2290 return simd_make_ushort3(simd_min(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y)));
2291}
2292
2293static inline SIMD_CFUNC simd_ushort4 simd_min(simd_ushort4 x, simd_ushort4 y) {
2294#if defined __arm__ || defined __arm64__
2295 return vmin_u16(x, y);
2296#else
2297 return simd_make_ushort4(simd_min(simd_make_ushort8_undef(x), simd_make_ushort8_undef(y)));
2298#endif
2299
2300}
2301
2302static inline SIMD_CFUNC simd_ushort8 simd_min(simd_ushort8 x, simd_ushort8 y) {
2303#if defined __arm__ || defined __arm64__
2304 return vminq_u16(x, y);
2305#elif defined __SSE4_1__
2306 return (simd_ushort8) _mm_min_epu16((__m128i)x, (__m128i)y);
2307#else
2308 return simd_bitselect(x, y, y < x);
2309#endif
2310}
2311
2312static inline SIMD_CFUNC simd_ushort16 simd_min(simd_ushort16 x, simd_ushort16 y) {
2313#if defined __AVX2__
2314 return _mm256_min_epu16(x, y);
2315#else
2316 return simd_bitselect(x, y, y < x);
2317#endif
2318}
2319
2320static inline SIMD_CFUNC simd_ushort32 simd_min(simd_ushort32 x, simd_ushort32 y) {
2321#if defined __AVX512BW__
2322 return _mm512_min_epu16(x, y);
2323#else
2324 return simd_bitselect(x, y, y < x);
2325#endif
2326}
2327
2328static inline SIMD_CFUNC simd_int2 simd_min(simd_int2 x, simd_int2 y) {
2329#if defined __arm__ || defined __arm64__
2330 return vmin_s32(x, y);
2331#else
2332 return simd_make_int2(simd_min(simd_make_int4_undef(x), simd_make_int4_undef(y)));
2333#endif
2334
2335}
2336
2337static inline SIMD_CFUNC simd_int3 simd_min(simd_int3 x, simd_int3 y) {
2338 return simd_make_int3(simd_min(simd_make_int4_undef(x), simd_make_int4_undef(y)));
2339}
2340
2341static inline SIMD_CFUNC simd_int4 simd_min(simd_int4 x, simd_int4 y) {
2342#if defined __arm__ || defined __arm64__
2343 return vminq_s32(x, y);
2344#elif defined __SSE4_1__
2345 return (simd_int4) _mm_min_epi32((__m128i)x, (__m128i)y);
2346#else
2347 return simd_bitselect(x, y, y < x);
2348#endif
2349}
2350
2351static inline SIMD_CFUNC simd_int8 simd_min(simd_int8 x, simd_int8 y) {
2352#if defined __AVX2__
2353 return _mm256_min_epi32(x, y);
2354#else
2355 return simd_bitselect(x, y, y < x);
2356#endif
2357}
2358
2359static inline SIMD_CFUNC simd_int16 simd_min(simd_int16 x, simd_int16 y) {
2360#if defined __AVX512F__
2361 return _mm512_min_epi32(x, y);
2362#else
2363 return simd_bitselect(x, y, y < x);
2364#endif
2365}
2366
2367static inline SIMD_CFUNC simd_uint2 simd_min(simd_uint2 x, simd_uint2 y) {
2368#if defined __arm__ || defined __arm64__
2369 return vmin_u32(x, y);
2370#else
2371 return simd_make_uint2(simd_min(simd_make_uint4_undef(x), simd_make_uint4_undef(y)));
2372#endif
2373
2374}
2375
2376static inline SIMD_CFUNC simd_uint3 simd_min(simd_uint3 x, simd_uint3 y) {
2377 return simd_make_uint3(simd_min(simd_make_uint4_undef(x), simd_make_uint4_undef(y)));
2378}
2379
2380static inline SIMD_CFUNC simd_uint4 simd_min(simd_uint4 x, simd_uint4 y) {
2381#if defined __arm__ || defined __arm64__
2382 return vminq_u32(x, y);
2383#elif defined __SSE4_1__
2384 return (simd_uint4) _mm_min_epu32((__m128i)x, (__m128i)y);
2385#else
2386 return simd_bitselect(x, y, y < x);
2387#endif
2388}
2389
2390static inline SIMD_CFUNC simd_uint8 simd_min(simd_uint8 x, simd_uint8 y) {
2391#if defined __AVX2__
2392 return _mm256_min_epu32(x, y);
2393#else
2394 return simd_bitselect(x, y, y < x);
2395#endif
2396}
2397
2398static inline SIMD_CFUNC simd_uint16 simd_min(simd_uint16 x, simd_uint16 y) {
2399#if defined __AVX512F__
2400 return _mm512_min_epu32(x, y);
2401#else
2402 return simd_bitselect(x, y, y < x);
2403#endif
2404}
2405
2406static inline SIMD_CFUNC float simd_min(float x, float y) {
2407 return __tg_fmin(x,y);
2408}
2409
2410static inline SIMD_CFUNC simd_float2 simd_min(simd_float2 x, simd_float2 y) {
2411 return __tg_fmin(x,y);
2412}
2413
2414static inline SIMD_CFUNC simd_float3 simd_min(simd_float3 x, simd_float3 y) {
2415 return __tg_fmin(x,y);
2416}
2417
2418static inline SIMD_CFUNC simd_float4 simd_min(simd_float4 x, simd_float4 y) {
2419 return __tg_fmin(x,y);
2420}
2421
2422static inline SIMD_CFUNC simd_float8 simd_min(simd_float8 x, simd_float8 y) {
2423 return __tg_fmin(x,y);
2424}
2425
2426static inline SIMD_CFUNC simd_float16 simd_min(simd_float16 x, simd_float16 y) {
2427 return __tg_fmin(x,y);
2428}
2429
2430static inline SIMD_CFUNC simd_long2 simd_min(simd_long2 x, simd_long2 y) {
2431#if defined __AVX512VL__
2432 return _mm_min_epi64(x, y);
2433#else
2434 return simd_bitselect(x, y, y < x);
2435#endif
2436}
2437
2438static inline SIMD_CFUNC simd_long3 simd_min(simd_long3 x, simd_long3 y) {
2439 return simd_make_long3(simd_min(simd_make_long4_undef(x), simd_make_long4_undef(y)));
2440}
2441
2442static inline SIMD_CFUNC simd_long4 simd_min(simd_long4 x, simd_long4 y) {
2443#if defined __AVX512VL__
2444 return _mm256_min_epi64(x, y);
2445#else
2446 return simd_bitselect(x, y, y < x);
2447#endif
2448}
2449
2450static inline SIMD_CFUNC simd_long8 simd_min(simd_long8 x, simd_long8 y) {
2451#if defined __AVX512F__
2452 return _mm512_min_epi64(x, y);
2453#else
2454 return simd_bitselect(x, y, y < x);
2455#endif
2456}
2457
2458static inline SIMD_CFUNC simd_ulong2 simd_min(simd_ulong2 x, simd_ulong2 y) {
2459#if defined __AVX512VL__
2460 return _mm_min_epu64(x, y);
2461#else
2462 return simd_bitselect(x, y, y < x);
2463#endif
2464}
2465
2466static inline SIMD_CFUNC simd_ulong3 simd_min(simd_ulong3 x, simd_ulong3 y) {
2467 return simd_make_ulong3(simd_min(simd_make_ulong4_undef(x), simd_make_ulong4_undef(y)));
2468}
2469
2470static inline SIMD_CFUNC simd_ulong4 simd_min(simd_ulong4 x, simd_ulong4 y) {
2471#if defined __AVX512VL__
2472 return _mm256_min_epu64(x, y);
2473#else
2474 return simd_bitselect(x, y, y < x);
2475#endif
2476}
2477
2478static inline SIMD_CFUNC simd_ulong8 simd_min(simd_ulong8 x, simd_ulong8 y) {
2479#if defined __AVX512F__
2480 return _mm512_min_epu64(x, y);
2481#else
2482 return simd_bitselect(x, y, y < x);
2483#endif
2484}
2485
2486static inline SIMD_CFUNC double simd_min(double x, double y) {
2487 return __tg_fmin(x,y);
2488}
2489
2490static inline SIMD_CFUNC simd_double2 simd_min(simd_double2 x, simd_double2 y) {
2491 return __tg_fmin(x,y);
2492}
2493
2494static inline SIMD_CFUNC simd_double3 simd_min(simd_double3 x, simd_double3 y) {
2495 return __tg_fmin(x,y);
2496}
2497
2498static inline SIMD_CFUNC simd_double4 simd_min(simd_double4 x, simd_double4 y) {
2499 return __tg_fmin(x,y);
2500}
2501
2502static inline SIMD_CFUNC simd_double8 simd_min(simd_double8 x, simd_double8 y) {
2503 return __tg_fmin(x,y);
2504}
2505
2506static inline SIMD_CFUNC simd_char2 simd_max(simd_char2 x, simd_char2 y) {
2507 return simd_make_char2(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y)));
2508}
2509
2510static inline SIMD_CFUNC simd_char3 simd_max(simd_char3 x, simd_char3 y) {
2511 return simd_make_char3(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y)));
2512}
2513
2514static inline SIMD_CFUNC simd_char4 simd_max(simd_char4 x, simd_char4 y) {
2515 return simd_make_char4(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y)));
2516}
2517
2518static inline SIMD_CFUNC simd_char8 simd_max(simd_char8 x, simd_char8 y) {
2519#if defined __arm__ || defined __arm64__
2520 return vmax_s8(x, y);
2521#else
2522 return simd_make_char8(simd_max(simd_make_char16_undef(x), simd_make_char16_undef(y)));
2523#endif
2524
2525}
2526
2527static inline SIMD_CFUNC simd_char16 simd_max(simd_char16 x, simd_char16 y) {
2528#if defined __arm__ || defined __arm64__
2529 return vmaxq_s8(x, y);
2530#elif defined __SSE4_1__
2531 return (simd_char16) _mm_max_epi8((__m128i)x, (__m128i)y);
2532#else
2533 return simd_bitselect(x, y, x < y);
2534#endif
2535}
2536
2537static inline SIMD_CFUNC simd_char32 simd_max(simd_char32 x, simd_char32 y) {
2538#if defined __AVX2__
2539 return _mm256_max_epi8(x, y);
2540#else
2541 return simd_bitselect(x, y, x < y);
2542#endif
2543}
2544
2545static inline SIMD_CFUNC simd_char64 simd_max(simd_char64 x, simd_char64 y) {
2546#if defined __AVX512BW__
2547 return _mm512_max_epi8(x, y);
2548#else
2549 return simd_bitselect(x, y, x < y);
2550#endif
2551}
2552
2553static inline SIMD_CFUNC simd_uchar2 simd_max(simd_uchar2 x, simd_uchar2 y) {
2554 return simd_make_uchar2(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y)));
2555}
2556
2557static inline SIMD_CFUNC simd_uchar3 simd_max(simd_uchar3 x, simd_uchar3 y) {
2558 return simd_make_uchar3(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y)));
2559}
2560
2561static inline SIMD_CFUNC simd_uchar4 simd_max(simd_uchar4 x, simd_uchar4 y) {
2562 return simd_make_uchar4(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y)));
2563}
2564
2565static inline SIMD_CFUNC simd_uchar8 simd_max(simd_uchar8 x, simd_uchar8 y) {
2566#if defined __arm__ || defined __arm64__
2567 return vmax_u8(x, y);
2568#else
2569 return simd_make_uchar8(simd_max(simd_make_uchar16_undef(x), simd_make_uchar16_undef(y)));
2570#endif
2571
2572}
2573
2574static inline SIMD_CFUNC simd_uchar16 simd_max(simd_uchar16 x, simd_uchar16 y) {
2575#if defined __arm__ || defined __arm64__
2576 return vmaxq_u8(x, y);
2577#elif defined __SSE4_1__
2578 return (simd_uchar16) _mm_max_epu8((__m128i)x, (__m128i)y);
2579#else
2580 return simd_bitselect(x, y, x < y);
2581#endif
2582}
2583
2584static inline SIMD_CFUNC simd_uchar32 simd_max(simd_uchar32 x, simd_uchar32 y) {
2585#if defined __AVX2__
2586 return _mm256_max_epu8(x, y);
2587#else
2588 return simd_bitselect(x, y, x < y);
2589#endif
2590}
2591
2592static inline SIMD_CFUNC simd_uchar64 simd_max(simd_uchar64 x, simd_uchar64 y) {
2593#if defined __AVX512BW__
2594 return _mm512_max_epu8(x, y);
2595#else
2596 return simd_bitselect(x, y, x < y);
2597#endif
2598}
2599
2600static inline SIMD_CFUNC simd_short2 simd_max(simd_short2 x, simd_short2 y) {
2601 return simd_make_short2(simd_max(simd_make_short4_undef(x), simd_make_short4_undef(y)));
2602}
2603
2604static inline SIMD_CFUNC simd_short3 simd_max(simd_short3 x, simd_short3 y) {
2605 return simd_make_short3(simd_max(simd_make_short4_undef(x), simd_make_short4_undef(y)));
2606}
2607
2608static inline SIMD_CFUNC simd_short4 simd_max(simd_short4 x, simd_short4 y) {
2609#if defined __arm__ || defined __arm64__
2610 return vmax_s16(x, y);
2611#else
2612 return simd_make_short4(simd_max(simd_make_short8_undef(x), simd_make_short8_undef(y)));
2613#endif
2614
2615}
2616
2617static inline SIMD_CFUNC simd_short8 simd_max(simd_short8 x, simd_short8 y) {
2618#if defined __arm__ || defined __arm64__
2619 return vmaxq_s16(x, y);
2620#elif defined __SSE4_1__
2621 return (simd_short8) _mm_max_epi16((__m128i)x, (__m128i)y);
2622#else
2623 return simd_bitselect(x, y, x < y);
2624#endif
2625}
2626
2627static inline SIMD_CFUNC simd_short16 simd_max(simd_short16 x, simd_short16 y) {
2628#if defined __AVX2__
2629 return _mm256_max_epi16(x, y);
2630#else
2631 return simd_bitselect(x, y, x < y);
2632#endif
2633}
2634
2635static inline SIMD_CFUNC simd_short32 simd_max(simd_short32 x, simd_short32 y) {
2636#if defined __AVX512BW__
2637 return _mm512_max_epi16(x, y);
2638#else
2639 return simd_bitselect(x, y, x < y);
2640#endif
2641}
2642
2643static inline SIMD_CFUNC simd_ushort2 simd_max(simd_ushort2 x, simd_ushort2 y) {
2644 return simd_make_ushort2(simd_max(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y)));
2645}
2646
2647static inline SIMD_CFUNC simd_ushort3 simd_max(simd_ushort3 x, simd_ushort3 y) {
2648 return simd_make_ushort3(simd_max(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y)));
2649}
2650
2651static inline SIMD_CFUNC simd_ushort4 simd_max(simd_ushort4 x, simd_ushort4 y) {
2652#if defined __arm__ || defined __arm64__
2653 return vmax_u16(x, y);
2654#else
2655 return simd_make_ushort4(simd_max(simd_make_ushort8_undef(x), simd_make_ushort8_undef(y)));
2656#endif
2657
2658}
2659
2660static inline SIMD_CFUNC simd_ushort8 simd_max(simd_ushort8 x, simd_ushort8 y) {
2661#if defined __arm__ || defined __arm64__
2662 return vmaxq_u16(x, y);
2663#elif defined __SSE4_1__
2664 return (simd_ushort8) _mm_max_epu16((__m128i)x, (__m128i)y);
2665#else
2666 return simd_bitselect(x, y, x < y);
2667#endif
2668}
2669
2670static inline SIMD_CFUNC simd_ushort16 simd_max(simd_ushort16 x, simd_ushort16 y) {
2671#if defined __AVX2__
2672 return _mm256_max_epu16(x, y);
2673#else
2674 return simd_bitselect(x, y, x < y);
2675#endif
2676}
2677
2678static inline SIMD_CFUNC simd_ushort32 simd_max(simd_ushort32 x, simd_ushort32 y) {
2679#if defined __AVX512BW__
2680 return _mm512_max_epu16(x, y);
2681#else
2682 return simd_bitselect(x, y, x < y);
2683#endif
2684}
2685
2686static inline SIMD_CFUNC simd_int2 simd_max(simd_int2 x, simd_int2 y) {
2687#if defined __arm__ || defined __arm64__
2688 return vmax_s32(x, y);
2689#else
2690 return simd_make_int2(simd_max(simd_make_int4_undef(x), simd_make_int4_undef(y)));
2691#endif
2692
2693}
2694
2695static inline SIMD_CFUNC simd_int3 simd_max(simd_int3 x, simd_int3 y) {
2696 return simd_make_int3(simd_max(simd_make_int4_undef(x), simd_make_int4_undef(y)));
2697}
2698
2699static inline SIMD_CFUNC simd_int4 simd_max(simd_int4 x, simd_int4 y) {
2700#if defined __arm__ || defined __arm64__
2701 return vmaxq_s32(x, y);
2702#elif defined __SSE4_1__
2703 return (simd_int4) _mm_max_epi32((__m128i)x, (__m128i)y);
2704#else
2705 return simd_bitselect(x, y, x < y);
2706#endif
2707}
2708
2709static inline SIMD_CFUNC simd_int8 simd_max(simd_int8 x, simd_int8 y) {
2710#if defined __AVX2__
2711 return _mm256_max_epi32(x, y);
2712#else
2713 return simd_bitselect(x, y, x < y);
2714#endif
2715}
2716
2717static inline SIMD_CFUNC simd_int16 simd_max(simd_int16 x, simd_int16 y) {
2718#if defined __AVX512F__
2719 return _mm512_max_epi32(x, y);
2720#else
2721 return simd_bitselect(x, y, x < y);
2722#endif
2723}
2724
2725static inline SIMD_CFUNC simd_uint2 simd_max(simd_uint2 x, simd_uint2 y) {
2726#if defined __arm__ || defined __arm64__
2727 return vmax_u32(x, y);
2728#else
2729 return simd_make_uint2(simd_max(simd_make_uint4_undef(x), simd_make_uint4_undef(y)));
2730#endif
2731
2732}
2733
2734static inline SIMD_CFUNC simd_uint3 simd_max(simd_uint3 x, simd_uint3 y) {
2735 return simd_make_uint3(simd_max(simd_make_uint4_undef(x), simd_make_uint4_undef(y)));
2736}
2737
2738static inline SIMD_CFUNC simd_uint4 simd_max(simd_uint4 x, simd_uint4 y) {
2739#if defined __arm__ || defined __arm64__
2740 return vmaxq_u32(x, y);
2741#elif defined __SSE4_1__
2742 return (simd_uint4) _mm_max_epu32((__m128i)x, (__m128i)y);
2743#else
2744 return simd_bitselect(x, y, x < y);
2745#endif
2746}
2747
2748static inline SIMD_CFUNC simd_uint8 simd_max(simd_uint8 x, simd_uint8 y) {
2749#if defined __AVX2__
2750 return _mm256_max_epu32(x, y);
2751#else
2752 return simd_bitselect(x, y, x < y);
2753#endif
2754}
2755
2756static inline SIMD_CFUNC simd_uint16 simd_max(simd_uint16 x, simd_uint16 y) {
2757#if defined __AVX512F__
2758 return _mm512_max_epu32(x, y);
2759#else
2760 return simd_bitselect(x, y, x < y);
2761#endif
2762}
2763
2764static inline SIMD_CFUNC float simd_max(float x, float y) {
2765 return __tg_fmax(x,y);
2766}
2767
2768static inline SIMD_CFUNC simd_float2 simd_max(simd_float2 x, simd_float2 y) {
2769 return __tg_fmax(x,y);
2770}
2771
2772static inline SIMD_CFUNC simd_float3 simd_max(simd_float3 x, simd_float3 y) {
2773 return __tg_fmax(x,y);
2774}
2775
2776static inline SIMD_CFUNC simd_float4 simd_max(simd_float4 x, simd_float4 y) {
2777 return __tg_fmax(x,y);
2778}
2779
2780static inline SIMD_CFUNC simd_float8 simd_max(simd_float8 x, simd_float8 y) {
2781 return __tg_fmax(x,y);
2782}
2783
2784static inline SIMD_CFUNC simd_float16 simd_max(simd_float16 x, simd_float16 y) {
2785 return __tg_fmax(x,y);
2786}
2787
2788static inline SIMD_CFUNC simd_long2 simd_max(simd_long2 x, simd_long2 y) {
2789#if defined __AVX512VL__
2790 return _mm_max_epi64(x, y);
2791#else
2792 return simd_bitselect(x, y, x < y);
2793#endif
2794}
2795
2796static inline SIMD_CFUNC simd_long3 simd_max(simd_long3 x, simd_long3 y) {
2797 return simd_make_long3(simd_max(simd_make_long4_undef(x), simd_make_long4_undef(y)));
2798}
2799
2800static inline SIMD_CFUNC simd_long4 simd_max(simd_long4 x, simd_long4 y) {
2801#if defined __AVX512VL__
2802 return _mm256_max_epi64(x, y);
2803#else
2804 return simd_bitselect(x, y, x < y);
2805#endif
2806}
2807
2808static inline SIMD_CFUNC simd_long8 simd_max(simd_long8 x, simd_long8 y) {
2809#if defined __AVX512F__
2810 return _mm512_max_epi64(x, y);
2811#else
2812 return simd_bitselect(x, y, x < y);
2813#endif
2814}
2815
2816static inline SIMD_CFUNC simd_ulong2 simd_max(simd_ulong2 x, simd_ulong2 y) {
2817#if defined __AVX512VL__
2818 return _mm_max_epu64(x, y);
2819#else
2820 return simd_bitselect(x, y, x < y);
2821#endif
2822}
2823
2824static inline SIMD_CFUNC simd_ulong3 simd_max(simd_ulong3 x, simd_ulong3 y) {
2825 return simd_make_ulong3(simd_max(simd_make_ulong4_undef(x), simd_make_ulong4_undef(y)));
2826}
2827
2828static inline SIMD_CFUNC simd_ulong4 simd_max(simd_ulong4 x, simd_ulong4 y) {
2829#if defined __AVX512VL__
2830 return _mm256_max_epu64(x, y);
2831#else
2832 return simd_bitselect(x, y, x < y);
2833#endif
2834}
2835
2836static inline SIMD_CFUNC simd_ulong8 simd_max(simd_ulong8 x, simd_ulong8 y) {
2837#if defined __AVX512F__
2838 return _mm512_max_epu64(x, y);
2839#else
2840 return simd_bitselect(x, y, x < y);
2841#endif
2842}
2843
2844static inline SIMD_CFUNC double simd_max(double x, double y) {
2845 return __tg_fmax(x,y);
2846}
2847
2848static inline SIMD_CFUNC simd_double2 simd_max(simd_double2 x, simd_double2 y) {
2849 return __tg_fmax(x,y);
2850}
2851
2852static inline SIMD_CFUNC simd_double3 simd_max(simd_double3 x, simd_double3 y) {
2853 return __tg_fmax(x,y);
2854}
2855
2856static inline SIMD_CFUNC simd_double4 simd_max(simd_double4 x, simd_double4 y) {
2857 return __tg_fmax(x,y);
2858}
2859
2860static inline SIMD_CFUNC simd_double8 simd_max(simd_double8 x, simd_double8 y) {
2861 return __tg_fmax(x,y);
2862}
2863
2864static inline SIMD_CFUNC simd_char2 simd_clamp(simd_char2 x, simd_char2 min, simd_char2 max) {
2865 return simd_min(simd_max(x, min), max);
2866}
2867
2868static inline SIMD_CFUNC simd_char3 simd_clamp(simd_char3 x, simd_char3 min, simd_char3 max) {
2869 return simd_min(simd_max(x, min), max);
2870}
2871
2872static inline SIMD_CFUNC simd_char4 simd_clamp(simd_char4 x, simd_char4 min, simd_char4 max) {
2873 return simd_min(simd_max(x, min), max);
2874}
2875
2876static inline SIMD_CFUNC simd_char8 simd_clamp(simd_char8 x, simd_char8 min, simd_char8 max) {
2877 return simd_min(simd_max(x, min), max);
2878}
2879
2880static inline SIMD_CFUNC simd_char16 simd_clamp(simd_char16 x, simd_char16 min, simd_char16 max) {
2881 return simd_min(simd_max(x, min), max);
2882}
2883
2884static inline SIMD_CFUNC simd_char32 simd_clamp(simd_char32 x, simd_char32 min, simd_char32 max) {
2885 return simd_min(simd_max(x, min), max);
2886}
2887
2888static inline SIMD_CFUNC simd_char64 simd_clamp(simd_char64 x, simd_char64 min, simd_char64 max) {
2889 return simd_min(simd_max(x, min), max);
2890}
2891
2892static inline SIMD_CFUNC simd_uchar2 simd_clamp(simd_uchar2 x, simd_uchar2 min, simd_uchar2 max) {
2893 return simd_min(simd_max(x, min), max);
2894}
2895
2896static inline SIMD_CFUNC simd_uchar3 simd_clamp(simd_uchar3 x, simd_uchar3 min, simd_uchar3 max) {
2897 return simd_min(simd_max(x, min), max);
2898}
2899
2900static inline SIMD_CFUNC simd_uchar4 simd_clamp(simd_uchar4 x, simd_uchar4 min, simd_uchar4 max) {
2901 return simd_min(simd_max(x, min), max);
2902}
2903
2904static inline SIMD_CFUNC simd_uchar8 simd_clamp(simd_uchar8 x, simd_uchar8 min, simd_uchar8 max) {
2905 return simd_min(simd_max(x, min), max);
2906}
2907
2908static inline SIMD_CFUNC simd_uchar16 simd_clamp(simd_uchar16 x, simd_uchar16 min, simd_uchar16 max) {
2909 return simd_min(simd_max(x, min), max);
2910}
2911
2912static inline SIMD_CFUNC simd_uchar32 simd_clamp(simd_uchar32 x, simd_uchar32 min, simd_uchar32 max) {
2913 return simd_min(simd_max(x, min), max);
2914}
2915
2916static inline SIMD_CFUNC simd_uchar64 simd_clamp(simd_uchar64 x, simd_uchar64 min, simd_uchar64 max) {
2917 return simd_min(simd_max(x, min), max);
2918}
2919
2920static inline SIMD_CFUNC simd_short2 simd_clamp(simd_short2 x, simd_short2 min, simd_short2 max) {
2921 return simd_min(simd_max(x, min), max);
2922}
2923
2924static inline SIMD_CFUNC simd_short3 simd_clamp(simd_short3 x, simd_short3 min, simd_short3 max) {
2925 return simd_min(simd_max(x, min), max);
2926}
2927
2928static inline SIMD_CFUNC simd_short4 simd_clamp(simd_short4 x, simd_short4 min, simd_short4 max) {
2929 return simd_min(simd_max(x, min), max);
2930}
2931
2932static inline SIMD_CFUNC simd_short8 simd_clamp(simd_short8 x, simd_short8 min, simd_short8 max) {
2933 return simd_min(simd_max(x, min), max);
2934}
2935
2936static inline SIMD_CFUNC simd_short16 simd_clamp(simd_short16 x, simd_short16 min, simd_short16 max) {
2937 return simd_min(simd_max(x, min), max);
2938}
2939
2940static inline SIMD_CFUNC simd_short32 simd_clamp(simd_short32 x, simd_short32 min, simd_short32 max) {
2941 return simd_min(simd_max(x, min), max);
2942}
2943
2944static inline SIMD_CFUNC simd_ushort2 simd_clamp(simd_ushort2 x, simd_ushort2 min, simd_ushort2 max) {
2945 return simd_min(simd_max(x, min), max);
2946}
2947
2948static inline SIMD_CFUNC simd_ushort3 simd_clamp(simd_ushort3 x, simd_ushort3 min, simd_ushort3 max) {
2949 return simd_min(simd_max(x, min), max);
2950}
2951
2952static inline SIMD_CFUNC simd_ushort4 simd_clamp(simd_ushort4 x, simd_ushort4 min, simd_ushort4 max) {
2953 return simd_min(simd_max(x, min), max);
2954}
2955
2956static inline SIMD_CFUNC simd_ushort8 simd_clamp(simd_ushort8 x, simd_ushort8 min, simd_ushort8 max) {
2957 return simd_min(simd_max(x, min), max);
2958}
2959
2960static inline SIMD_CFUNC simd_ushort16 simd_clamp(simd_ushort16 x, simd_ushort16 min, simd_ushort16 max) {
2961 return simd_min(simd_max(x, min), max);
2962}
2963
2964static inline SIMD_CFUNC simd_ushort32 simd_clamp(simd_ushort32 x, simd_ushort32 min, simd_ushort32 max) {
2965 return simd_min(simd_max(x, min), max);
2966}
2967
2968static inline SIMD_CFUNC simd_int2 simd_clamp(simd_int2 x, simd_int2 min, simd_int2 max) {
2969 return simd_min(simd_max(x, min), max);
2970}
2971
2972static inline SIMD_CFUNC simd_int3 simd_clamp(simd_int3 x, simd_int3 min, simd_int3 max) {
2973 return simd_min(simd_max(x, min), max);
2974}
2975
2976static inline SIMD_CFUNC simd_int4 simd_clamp(simd_int4 x, simd_int4 min, simd_int4 max) {
2977 return simd_min(simd_max(x, min), max);
2978}
2979
2980static inline SIMD_CFUNC simd_int8 simd_clamp(simd_int8 x, simd_int8 min, simd_int8 max) {
2981 return simd_min(simd_max(x, min), max);
2982}
2983
2984static inline SIMD_CFUNC simd_int16 simd_clamp(simd_int16 x, simd_int16 min, simd_int16 max) {
2985 return simd_min(simd_max(x, min), max);
2986}
2987
2988static inline SIMD_CFUNC simd_uint2 simd_clamp(simd_uint2 x, simd_uint2 min, simd_uint2 max) {
2989 return simd_min(simd_max(x, min), max);
2990}
2991
2992static inline SIMD_CFUNC simd_uint3 simd_clamp(simd_uint3 x, simd_uint3 min, simd_uint3 max) {
2993 return simd_min(simd_max(x, min), max);
2994}
2995
2996static inline SIMD_CFUNC simd_uint4 simd_clamp(simd_uint4 x, simd_uint4 min, simd_uint4 max) {
2997 return simd_min(simd_max(x, min), max);
2998}
2999
3000static inline SIMD_CFUNC simd_uint8 simd_clamp(simd_uint8 x, simd_uint8 min, simd_uint8 max) {
3001 return simd_min(simd_max(x, min), max);
3002}
3003
3004static inline SIMD_CFUNC simd_uint16 simd_clamp(simd_uint16 x, simd_uint16 min, simd_uint16 max) {
3005 return simd_min(simd_max(x, min), max);
3006}
3007
3008static inline SIMD_CFUNC float simd_clamp(float x, float min, float max) {
3009 return simd_min(simd_max(x, min), max);
3010}
3011
3012static inline SIMD_CFUNC simd_float2 simd_clamp(simd_float2 x, simd_float2 min, simd_float2 max) {
3013 return simd_min(simd_max(x, min), max);
3014}
3015
3016static inline SIMD_CFUNC simd_float3 simd_clamp(simd_float3 x, simd_float3 min, simd_float3 max) {
3017 return simd_min(simd_max(x, min), max);
3018}
3019
3020static inline SIMD_CFUNC simd_float4 simd_clamp(simd_float4 x, simd_float4 min, simd_float4 max) {
3021 return simd_min(simd_max(x, min), max);
3022}
3023
3024static inline SIMD_CFUNC simd_float8 simd_clamp(simd_float8 x, simd_float8 min, simd_float8 max) {
3025 return simd_min(simd_max(x, min), max);
3026}
3027
3028static inline SIMD_CFUNC simd_float16 simd_clamp(simd_float16 x, simd_float16 min, simd_float16 max) {
3029 return simd_min(simd_max(x, min), max);
3030}
3031
3032static inline SIMD_CFUNC simd_long2 simd_clamp(simd_long2 x, simd_long2 min, simd_long2 max) {
3033 return simd_min(simd_max(x, min), max);
3034}
3035
3036static inline SIMD_CFUNC simd_long3 simd_clamp(simd_long3 x, simd_long3 min, simd_long3 max) {
3037 return simd_min(simd_max(x, min), max);
3038}
3039
3040static inline SIMD_CFUNC simd_long4 simd_clamp(simd_long4 x, simd_long4 min, simd_long4 max) {
3041 return simd_min(simd_max(x, min), max);
3042}
3043
3044static inline SIMD_CFUNC simd_long8 simd_clamp(simd_long8 x, simd_long8 min, simd_long8 max) {
3045 return simd_min(simd_max(x, min), max);
3046}
3047
3048static inline SIMD_CFUNC simd_ulong2 simd_clamp(simd_ulong2 x, simd_ulong2 min, simd_ulong2 max) {
3049 return simd_min(simd_max(x, min), max);
3050}
3051
3052static inline SIMD_CFUNC simd_ulong3 simd_clamp(simd_ulong3 x, simd_ulong3 min, simd_ulong3 max) {
3053 return simd_min(simd_max(x, min), max);
3054}
3055
3056static inline SIMD_CFUNC simd_ulong4 simd_clamp(simd_ulong4 x, simd_ulong4 min, simd_ulong4 max) {
3057 return simd_min(simd_max(x, min), max);
3058}
3059
3060static inline SIMD_CFUNC simd_ulong8 simd_clamp(simd_ulong8 x, simd_ulong8 min, simd_ulong8 max) {
3061 return simd_min(simd_max(x, min), max);
3062}
3063
3064static inline SIMD_CFUNC double simd_clamp(double x, double min, double max) {
3065 return simd_min(simd_max(x, min), max);
3066}
3067
3068static inline SIMD_CFUNC simd_double2 simd_clamp(simd_double2 x, simd_double2 min, simd_double2 max) {
3069 return simd_min(simd_max(x, min), max);
3070}
3071
3072static inline SIMD_CFUNC simd_double3 simd_clamp(simd_double3 x, simd_double3 min, simd_double3 max) {
3073 return simd_min(simd_max(x, min), max);
3074}
3075
3076static inline SIMD_CFUNC simd_double4 simd_clamp(simd_double4 x, simd_double4 min, simd_double4 max) {
3077 return simd_min(simd_max(x, min), max);
3078}
3079
3080static inline SIMD_CFUNC simd_double8 simd_clamp(simd_double8 x, simd_double8 min, simd_double8 max) {
3081 return simd_min(simd_max(x, min), max);
3082}
3083
3084
3085static inline SIMD_CFUNC float simd_sign(float x) {
3086 return (x == 0 | x != x) ? 0 : copysign(1,x);
3087}
3088
3089static inline SIMD_CFUNC simd_float2 simd_sign(simd_float2 x) {
3090 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3091}
3092
3093static inline SIMD_CFUNC simd_float3 simd_sign(simd_float3 x) {
3094 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3095}
3096
3097static inline SIMD_CFUNC simd_float4 simd_sign(simd_float4 x) {
3098 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3099}
3100
3101static inline SIMD_CFUNC simd_float8 simd_sign(simd_float8 x) {
3102 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3103}
3104
3105static inline SIMD_CFUNC simd_float16 simd_sign(simd_float16 x) {
3106 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3107}
3108
3109static inline SIMD_CFUNC double simd_sign(double x) {
3110 return (x == 0 | x != x) ? 0 : copysign(1,x);
3111}
3112
3113static inline SIMD_CFUNC simd_double2 simd_sign(simd_double2 x) {
3114 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3115}
3116
3117static inline SIMD_CFUNC simd_double3 simd_sign(simd_double3 x) {
3118 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3119}
3120
3121static inline SIMD_CFUNC simd_double4 simd_sign(simd_double4 x) {
3122 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3123}
3124
3125static inline SIMD_CFUNC simd_double8 simd_sign(simd_double8 x) {
3126 return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x);
3127}
3128
3129static inline SIMD_CFUNC float simd_mix(float x, float y, float t) {
3130 return x + t*(y - x);
3131}
3132
3133static inline SIMD_CFUNC simd_float2 simd_mix(simd_float2 x, simd_float2 y, simd_float2 t) {
3134 return x + t*(y - x);
3135}
3136
3137static inline SIMD_CFUNC simd_float3 simd_mix(simd_float3 x, simd_float3 y, simd_float3 t) {
3138 return x + t*(y - x);
3139}
3140
3141static inline SIMD_CFUNC simd_float4 simd_mix(simd_float4 x, simd_float4 y, simd_float4 t) {
3142 return x + t*(y - x);
3143}
3144
3145static inline SIMD_CFUNC simd_float8 simd_mix(simd_float8 x, simd_float8 y, simd_float8 t) {
3146 return x + t*(y - x);
3147}
3148
3149static inline SIMD_CFUNC simd_float16 simd_mix(simd_float16 x, simd_float16 y, simd_float16 t) {
3150 return x + t*(y - x);
3151}
3152
3153static inline SIMD_CFUNC double simd_mix(double x, double y, double t) {
3154 return x + t*(y - x);
3155}
3156
3157static inline SIMD_CFUNC simd_double2 simd_mix(simd_double2 x, simd_double2 y, simd_double2 t) {
3158 return x + t*(y - x);
3159}
3160
3161static inline SIMD_CFUNC simd_double3 simd_mix(simd_double3 x, simd_double3 y, simd_double3 t) {
3162 return x + t*(y - x);
3163}
3164
3165static inline SIMD_CFUNC simd_double4 simd_mix(simd_double4 x, simd_double4 y, simd_double4 t) {
3166 return x + t*(y - x);
3167}
3168
3169static inline SIMD_CFUNC simd_double8 simd_mix(simd_double8 x, simd_double8 y, simd_double8 t) {
3170 return x + t*(y - x);
3171}
3172
3173static inline SIMD_CFUNC float simd_recip(float x) {
3174#if __FAST_MATH__
3175 return simd_fast_recip(x);
3176#else
3177 return simd_precise_recip(x);
3178#endif
3179}
3180
3181static inline SIMD_CFUNC simd_float2 simd_recip(simd_float2 x) {
3182#if __FAST_MATH__
3183 return simd_fast_recip(x);
3184#else
3185 return simd_precise_recip(x);
3186#endif
3187}
3188
3189static inline SIMD_CFUNC simd_float3 simd_recip(simd_float3 x) {
3190#if __FAST_MATH__
3191 return simd_fast_recip(x);
3192#else
3193 return simd_precise_recip(x);
3194#endif
3195}
3196
3197static inline SIMD_CFUNC simd_float4 simd_recip(simd_float4 x) {
3198#if __FAST_MATH__
3199 return simd_fast_recip(x);
3200#else
3201 return simd_precise_recip(x);
3202#endif
3203}
3204
3205static inline SIMD_CFUNC simd_float8 simd_recip(simd_float8 x) {
3206#if __FAST_MATH__
3207 return simd_fast_recip(x);
3208#else
3209 return simd_precise_recip(x);
3210#endif
3211}
3212
3213static inline SIMD_CFUNC simd_float16 simd_recip(simd_float16 x) {
3214#if __FAST_MATH__
3215 return simd_fast_recip(x);
3216#else
3217 return simd_precise_recip(x);
3218#endif
3219}
3220
3221static inline SIMD_CFUNC double simd_recip(double x) {
3222#if __FAST_MATH__
3223 return simd_fast_recip(x);
3224#else
3225 return simd_precise_recip(x);
3226#endif
3227}
3228
3229static inline SIMD_CFUNC simd_double2 simd_recip(simd_double2 x) {
3230#if __FAST_MATH__
3231 return simd_fast_recip(x);
3232#else
3233 return simd_precise_recip(x);
3234#endif
3235}
3236
3237static inline SIMD_CFUNC simd_double3 simd_recip(simd_double3 x) {
3238#if __FAST_MATH__
3239 return simd_fast_recip(x);
3240#else
3241 return simd_precise_recip(x);
3242#endif
3243}
3244
3245static inline SIMD_CFUNC simd_double4 simd_recip(simd_double4 x) {
3246#if __FAST_MATH__
3247 return simd_fast_recip(x);
3248#else
3249 return simd_precise_recip(x);
3250#endif
3251}
3252
3253static inline SIMD_CFUNC simd_double8 simd_recip(simd_double8 x) {
3254#if __FAST_MATH__
3255 return simd_fast_recip(x);
3256#else
3257 return simd_precise_recip(x);
3258#endif
3259}
3260
3261static inline SIMD_CFUNC float simd_fast_recip(float x) {
3262#if defined __AVX512VL__
3263 simd_float4 x4 = simd_make_float4(x);
3264 return ((simd_float4)_mm_rcp14_ss(x4, x4)).x;
3265#elif defined __SSE__
3266 return ((simd_float4)_mm_rcp_ss(simd_make_float4(x))).x;
3267#elif defined __ARM_NEON__
3268 return simd_fast_recip(simd_make_float2_undef(x)).x;
3269#else
3270 return simd_precise_recip(x);
3271#endif
3272}
3273
3274static inline SIMD_CFUNC simd_float2 simd_fast_recip(simd_float2 x) {
3275#if defined __SSE__
3276 return simd_make_float2(simd_fast_recip(simd_make_float4_undef(x)));
3277#elif defined __ARM_NEON__
3278 simd_float2 r = vrecpe_f32(x);
3279 return r * vrecps_f32(x, r);
3280#else
3281 return simd_precise_recip(x);
3282#endif
3283}
3284
3285static inline SIMD_CFUNC simd_float3 simd_fast_recip(simd_float3 x) {
3286 return simd_make_float3(simd_fast_recip(simd_make_float4_undef(x)));
3287}
3288
3289static inline SIMD_CFUNC simd_float4 simd_fast_recip(simd_float4 x) {
3290#if defined __AVX512VL__
3291 return _mm_rcp14_ps(x);
3292#elif defined __SSE__
3293 return _mm_rcp_ps(x);
3294#elif defined __ARM_NEON__
3295 simd_float4 r = vrecpeq_f32(x);
3296 return r * vrecpsq_f32(x, r);
3297#else
3298 return simd_precise_recip(x);
3299#endif
3300}
3301
3302static inline SIMD_CFUNC simd_float8 simd_fast_recip(simd_float8 x) {
3303#if defined __AVX512VL__
3304 return _mm256_rcp14_ps(x);
3305#elif defined __AVX__
3306 return _mm256_rcp_ps(x);
3307#else
3308 return simd_make_float8(simd_fast_recip(x.lo), simd_fast_recip(x.hi));
3309#endif
3310}
3311
3312static inline SIMD_CFUNC simd_float16 simd_fast_recip(simd_float16 x) {
3313#if defined __AVX512F__
3314 return _mm512_rcp14_ps(x);
3315#else
3316 return simd_make_float16(simd_fast_recip(x.lo), simd_fast_recip(x.hi));
3317#endif
3318}
3319
3320static inline SIMD_CFUNC double simd_fast_recip(double x) {
3321 return simd_precise_recip(x);
3322}
3323
3324static inline SIMD_CFUNC simd_double2 simd_fast_recip(simd_double2 x) {
3325 return simd_precise_recip(x);
3326}
3327
3328static inline SIMD_CFUNC simd_double3 simd_fast_recip(simd_double3 x) {
3329 return simd_precise_recip(x);
3330}
3331
3332static inline SIMD_CFUNC simd_double4 simd_fast_recip(simd_double4 x) {
3333 return simd_precise_recip(x);
3334}
3335
3336static inline SIMD_CFUNC simd_double8 simd_fast_recip(simd_double8 x) {
3337 return simd_precise_recip(x);
3338}
3339
3340static inline SIMD_CFUNC float simd_precise_recip(float x) {
3341#if defined __SSE__
3342 float r = simd_fast_recip(x);
3343 return r*(2 - (x == 0 ? -INFINITY : x)*r);
3344#elif defined __ARM_NEON__
3345 return simd_precise_recip(simd_make_float2_undef(x)).x;
3346#else
3347 return 1/x;
3348#endif
3349}
3350
3351static inline SIMD_CFUNC simd_float2 simd_precise_recip(simd_float2 x) {
3352#if defined __SSE__
3353 return simd_make_float2(simd_precise_recip(simd_make_float4_undef(x)));
3354#elif defined __ARM_NEON__
3355 simd_float2 r = simd_fast_recip(x);
3356 return r*vrecps_f32(x, r);
3357#else
3358 return 1/x;
3359#endif
3360}
3361
3362static inline SIMD_CFUNC simd_float3 simd_precise_recip(simd_float3 x) {
3363 return simd_make_float3(simd_precise_recip(simd_make_float4_undef(x)));
3364}
3365
3366static inline SIMD_CFUNC simd_float4 simd_precise_recip(simd_float4 x) {
3367#if defined __SSE__
3368 simd_float4 r = simd_fast_recip(x);
3369 return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r);
3370#elif defined __ARM_NEON__
3371 simd_float4 r = simd_fast_recip(x);
3372 return r*vrecpsq_f32(x, r);
3373#else
3374 return 1/x;
3375#endif
3376}
3377
3378static inline SIMD_CFUNC simd_float8 simd_precise_recip(simd_float8 x) {
3379#if defined __AVX__
3380 simd_float8 r = simd_fast_recip(x);
3381 return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r);
3382#else
3383 return simd_make_float8(simd_precise_recip(x.lo), simd_precise_recip(x.hi));
3384#endif
3385}
3386
3387static inline SIMD_CFUNC simd_float16 simd_precise_recip(simd_float16 x) {
3388#if defined __AVX512F__
3389 simd_float16 r = simd_fast_recip(x);
3390 return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r);
3391#else
3392 return simd_make_float16(simd_precise_recip(x.lo), simd_precise_recip(x.hi));
3393#endif
3394}
3395
3396static inline SIMD_CFUNC double simd_precise_recip(double x) {
3397 return 1/x;
3398}
3399
3400static inline SIMD_CFUNC simd_double2 simd_precise_recip(simd_double2 x) {
3401 return 1/x;
3402}
3403
3404static inline SIMD_CFUNC simd_double3 simd_precise_recip(simd_double3 x) {
3405 return 1/x;
3406}
3407
3408static inline SIMD_CFUNC simd_double4 simd_precise_recip(simd_double4 x) {
3409 return 1/x;
3410}
3411
3412static inline SIMD_CFUNC simd_double8 simd_precise_recip(simd_double8 x) {
3413 return 1/x;
3414}
3415
3416static inline SIMD_CFUNC float simd_rsqrt(float x) {
3417#if __FAST_MATH__
3418 return simd_fast_rsqrt(x);
3419#else
3420 return simd_precise_rsqrt(x);
3421#endif
3422}
3423
3424static inline SIMD_CFUNC simd_float2 simd_rsqrt(simd_float2 x) {
3425#if __FAST_MATH__
3426 return simd_fast_rsqrt(x);
3427#else
3428 return simd_precise_rsqrt(x);
3429#endif
3430}
3431
3432static inline SIMD_CFUNC simd_float3 simd_rsqrt(simd_float3 x) {
3433#if __FAST_MATH__
3434 return simd_fast_rsqrt(x);
3435#else
3436 return simd_precise_rsqrt(x);
3437#endif
3438}
3439
3440static inline SIMD_CFUNC simd_float4 simd_rsqrt(simd_float4 x) {
3441#if __FAST_MATH__
3442 return simd_fast_rsqrt(x);
3443#else
3444 return simd_precise_rsqrt(x);
3445#endif
3446}
3447
3448static inline SIMD_CFUNC simd_float8 simd_rsqrt(simd_float8 x) {
3449#if __FAST_MATH__
3450 return simd_fast_rsqrt(x);
3451#else
3452 return simd_precise_rsqrt(x);
3453#endif
3454}
3455
3456static inline SIMD_CFUNC simd_float16 simd_rsqrt(simd_float16 x) {
3457#if __FAST_MATH__
3458 return simd_fast_rsqrt(x);
3459#else
3460 return simd_precise_rsqrt(x);
3461#endif
3462}
3463
3464static inline SIMD_CFUNC double simd_rsqrt(double x) {
3465#if __FAST_MATH__
3466 return simd_fast_rsqrt(x);
3467#else
3468 return simd_precise_rsqrt(x);
3469#endif
3470}
3471
3472static inline SIMD_CFUNC simd_double2 simd_rsqrt(simd_double2 x) {
3473#if __FAST_MATH__
3474 return simd_fast_rsqrt(x);
3475#else
3476 return simd_precise_rsqrt(x);
3477#endif
3478}
3479
3480static inline SIMD_CFUNC simd_double3 simd_rsqrt(simd_double3 x) {
3481#if __FAST_MATH__
3482 return simd_fast_rsqrt(x);
3483#else
3484 return simd_precise_rsqrt(x);
3485#endif
3486}
3487
3488static inline SIMD_CFUNC simd_double4 simd_rsqrt(simd_double4 x) {
3489#if __FAST_MATH__
3490 return simd_fast_rsqrt(x);
3491#else
3492 return simd_precise_rsqrt(x);
3493#endif
3494}
3495
3496static inline SIMD_CFUNC simd_double8 simd_rsqrt(simd_double8 x) {
3497#if __FAST_MATH__
3498 return simd_fast_rsqrt(x);
3499#else
3500 return simd_precise_rsqrt(x);
3501#endif
3502}
3503
3504static inline SIMD_CFUNC float simd_fast_rsqrt(float x) {
3505#if defined __AVX512VL__
3506 simd_float4 x4 = simd_make_float4(x);
3507 return ((simd_float4)_mm_rsqrt14_ss(x4, x4)).x;
3508#elif defined __SSE__
3509 return ((simd_float4)_mm_rsqrt_ss(simd_make_float4(x))).x;
3510#elif defined __ARM_NEON__
3511 return simd_fast_rsqrt(simd_make_float2_undef(x)).x;
3512#else
3513 return simd_precise_rsqrt(x);
3514#endif
3515}
3516
3517static inline SIMD_CFUNC simd_float2 simd_fast_rsqrt(simd_float2 x) {
3518#if defined __SSE__
3519 return simd_make_float2(simd_fast_rsqrt(simd_make_float4_undef(x)));
3520#elif defined __ARM_NEON__
3521 simd_float2 r = vrsqrte_f32(x);
3522 return r * vrsqrts_f32(x, r*r);
3523#else
3524 return simd_precise_rsqrt(x);
3525#endif
3526}
3527
3528static inline SIMD_CFUNC simd_float3 simd_fast_rsqrt(simd_float3 x) {
3529 return simd_make_float3(simd_fast_rsqrt(simd_make_float4_undef(x)));
3530}
3531
3532static inline SIMD_CFUNC simd_float4 simd_fast_rsqrt(simd_float4 x) {
3533#if defined __AVX512VL__
3534 return _mm_rsqrt14_ps(x);
3535#elif defined __SSE__
3536 return _mm_rsqrt_ps(x);
3537#elif defined __ARM_NEON__
3538 simd_float4 r = vrsqrteq_f32(x);
3539 return r * vrsqrtsq_f32(x, r*r);
3540#else
3541 return simd_precise_rsqrt(x);
3542#endif
3543}
3544
3545static inline SIMD_CFUNC simd_float8 simd_fast_rsqrt(simd_float8 x) {
3546#if defined __AVX512VL__
3547 return _mm256_rsqrt14_ps(x);
3548#elif defined __AVX__
3549 return _mm256_rsqrt_ps(x);
3550#else
3551 return simd_make_float8(simd_fast_rsqrt(x.lo), simd_fast_rsqrt(x.hi));
3552#endif
3553}
3554
3555static inline SIMD_CFUNC simd_float16 simd_fast_rsqrt(simd_float16 x) {
3556#if defined __AVX512F__
3557 return _mm512_rsqrt14_ps(x);
3558#else
3559 return simd_make_float16(simd_fast_rsqrt(x.lo), simd_fast_rsqrt(x.hi));
3560#endif
3561}
3562
3563static inline SIMD_CFUNC double simd_fast_rsqrt(double x) {
3564 return simd_precise_rsqrt(x);
3565}
3566
3567static inline SIMD_CFUNC simd_double2 simd_fast_rsqrt(simd_double2 x) {
3568 return simd_precise_rsqrt(x);
3569}
3570
3571static inline SIMD_CFUNC simd_double3 simd_fast_rsqrt(simd_double3 x) {
3572 return simd_precise_rsqrt(x);
3573}
3574
3575static inline SIMD_CFUNC simd_double4 simd_fast_rsqrt(simd_double4 x) {
3576 return simd_precise_rsqrt(x);
3577}
3578
3579static inline SIMD_CFUNC simd_double8 simd_fast_rsqrt(simd_double8 x) {
3580 return simd_precise_rsqrt(x);
3581}
3582
3583static inline SIMD_CFUNC float simd_precise_rsqrt(float x) {
3584#if defined __SSE__
3585 float r = simd_fast_rsqrt(x);
3586 return r*(1.5f - 0.5f*(r == INFINITY ? -INFINITY : x)*r*r);
3587#elif defined __ARM_NEON__
3588 return simd_precise_rsqrt(simd_make_float2_undef(x)).x;
3589#else
3590 return 1/sqrt(x);
3591#endif
3592}
3593
3594static inline SIMD_CFUNC simd_float2 simd_precise_rsqrt(simd_float2 x) {
3595#if defined __SSE__
3596 return simd_make_float2(simd_precise_rsqrt(simd_make_float4_undef(x)));
3597#elif defined __ARM_NEON__
3598 simd_float2 r = simd_fast_rsqrt(x);
3599 return r*vrsqrts_f32(x, r*r);
3600#else
3601 return 1/__tg_sqrt(x);
3602#endif
3603}
3604
3605static inline SIMD_CFUNC simd_float3 simd_precise_rsqrt(simd_float3 x) {
3606 return simd_make_float3(simd_precise_rsqrt(simd_make_float4_undef(x)));
3607}
3608
3609static inline SIMD_CFUNC simd_float4 simd_precise_rsqrt(simd_float4 x) {
3610#if defined __SSE__
3611 simd_float4 r = simd_fast_rsqrt(x);
3612 return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r);
3613#elif defined __ARM_NEON__
3614 simd_float4 r = simd_fast_rsqrt(x);
3615 return r*vrsqrtsq_f32(x, r*r);
3616#else
3617 return 1/__tg_sqrt(x);
3618#endif
3619}
3620
3621static inline SIMD_CFUNC simd_float8 simd_precise_rsqrt(simd_float8 x) {
3622#if defined __AVX__
3623 simd_float8 r = simd_fast_rsqrt(x);
3624 return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r);
3625#else
3626 return simd_make_float8(simd_precise_rsqrt(x.lo), simd_precise_rsqrt(x.hi));
3627#endif
3628}
3629
3630static inline SIMD_CFUNC simd_float16 simd_precise_rsqrt(simd_float16 x) {
3631#if defined __AVX512F__
3632 simd_float16 r = simd_fast_rsqrt(x);
3633 return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r);
3634#else
3635 return simd_make_float16(simd_precise_rsqrt(x.lo), simd_precise_rsqrt(x.hi));
3636#endif
3637}
3638
3639static inline SIMD_CFUNC double simd_precise_rsqrt(double x) {
3640 return 1/sqrt(x);
3641}
3642
3643static inline SIMD_CFUNC simd_double2 simd_precise_rsqrt(simd_double2 x) {
3644 return 1/__tg_sqrt(x);
3645}
3646
3647static inline SIMD_CFUNC simd_double3 simd_precise_rsqrt(simd_double3 x) {
3648 return 1/__tg_sqrt(x);
3649}
3650
3651static inline SIMD_CFUNC simd_double4 simd_precise_rsqrt(simd_double4 x) {
3652 return 1/__tg_sqrt(x);
3653}
3654
3655static inline SIMD_CFUNC simd_double8 simd_precise_rsqrt(simd_double8 x) {
3656 return 1/__tg_sqrt(x);
3657}
3658
3659static inline SIMD_CFUNC float simd_fract(float x) {
3660 return fmin(x - floor(x), 0x1.fffffep-1f);
3661}
3662
3663static inline SIMD_CFUNC simd_float2 simd_fract(simd_float2 x) {
3664 return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f);
3665}
3666
3667static inline SIMD_CFUNC simd_float3 simd_fract(simd_float3 x) {
3668 return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f);
3669}
3670
3671static inline SIMD_CFUNC simd_float4 simd_fract(simd_float4 x) {
3672 return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f);
3673}
3674
3675static inline SIMD_CFUNC simd_float8 simd_fract(simd_float8 x) {
3676 return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f);
3677}
3678
3679static inline SIMD_CFUNC simd_float16 simd_fract(simd_float16 x) {
3680 return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f);
3681}
3682
3683static inline SIMD_CFUNC double simd_fract(double x) {
3684 return fmin(x - floor(x), 0x1.fffffffffffffp-1);
3685}
3686
3687static inline SIMD_CFUNC simd_double2 simd_fract(simd_double2 x) {
3688 return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1);
3689}
3690
3691static inline SIMD_CFUNC simd_double3 simd_fract(simd_double3 x) {
3692 return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1);
3693}
3694
3695static inline SIMD_CFUNC simd_double4 simd_fract(simd_double4 x) {
3696 return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1);
3697}
3698
3699static inline SIMD_CFUNC simd_double8 simd_fract(simd_double8 x) {
3700 return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1);
3701}
3702
3703static inline SIMD_CFUNC float simd_step(float edge, float x) {
3704 return !(x < edge);
3705}
3706
3707static inline SIMD_CFUNC simd_float2 simd_step(simd_float2 edge, simd_float2 x) {
3708 return simd_bitselect((simd_float2)1, 0, x < edge);
3709}
3710
3711static inline SIMD_CFUNC simd_float3 simd_step(simd_float3 edge, simd_float3 x) {
3712 return simd_bitselect((simd_float3)1, 0, x < edge);
3713}
3714
3715static inline SIMD_CFUNC simd_float4 simd_step(simd_float4 edge, simd_float4 x) {
3716 return simd_bitselect((simd_float4)1, 0, x < edge);
3717}
3718
3719static inline SIMD_CFUNC simd_float8 simd_step(simd_float8 edge, simd_float8 x) {
3720 return simd_bitselect((simd_float8)1, 0, x < edge);
3721}
3722
3723static inline SIMD_CFUNC simd_float16 simd_step(simd_float16 edge, simd_float16 x) {
3724 return simd_bitselect((simd_float16)1, 0, x < edge);
3725}
3726
3727static inline SIMD_CFUNC double simd_step(double edge, double x) {
3728 return !(x < edge);
3729}
3730
3731static inline SIMD_CFUNC simd_double2 simd_step(simd_double2 edge, simd_double2 x) {
3732 return simd_bitselect((simd_double2)1, 0, x < edge);
3733}
3734
3735static inline SIMD_CFUNC simd_double3 simd_step(simd_double3 edge, simd_double3 x) {
3736 return simd_bitselect((simd_double3)1, 0, x < edge);
3737}
3738
3739static inline SIMD_CFUNC simd_double4 simd_step(simd_double4 edge, simd_double4 x) {
3740 return simd_bitselect((simd_double4)1, 0, x < edge);
3741}
3742
3743static inline SIMD_CFUNC simd_double8 simd_step(simd_double8 edge, simd_double8 x) {
3744 return simd_bitselect((simd_double8)1, 0, x < edge);
3745}
3746
3747static inline SIMD_CFUNC float simd_smoothstep(float edge0, float edge1, float x) {
3748 float t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3749 return t*t*(3 - 2*t);
3750}
3751
3752static inline SIMD_CFUNC simd_float2 simd_smoothstep(simd_float2 edge0, simd_float2 edge1, simd_float2 x) {
3753 simd_float2 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3754 return t*t*(3 - 2*t);
3755}
3756
3757static inline SIMD_CFUNC simd_float3 simd_smoothstep(simd_float3 edge0, simd_float3 edge1, simd_float3 x) {
3758 simd_float3 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3759 return t*t*(3 - 2*t);
3760}
3761
3762static inline SIMD_CFUNC simd_float4 simd_smoothstep(simd_float4 edge0, simd_float4 edge1, simd_float4 x) {
3763 simd_float4 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3764 return t*t*(3 - 2*t);
3765}
3766
3767static inline SIMD_CFUNC simd_float8 simd_smoothstep(simd_float8 edge0, simd_float8 edge1, simd_float8 x) {
3768 simd_float8 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3769 return t*t*(3 - 2*t);
3770}
3771
3772static inline SIMD_CFUNC simd_float16 simd_smoothstep(simd_float16 edge0, simd_float16 edge1, simd_float16 x) {
3773 simd_float16 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3774 return t*t*(3 - 2*t);
3775}
3776
3777static inline SIMD_CFUNC double simd_smoothstep(double edge0, double edge1, double x) {
3778 double t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3779 return t*t*(3 - 2*t);
3780}
3781
3782static inline SIMD_CFUNC simd_double2 simd_smoothstep(simd_double2 edge0, simd_double2 edge1, simd_double2 x) {
3783 simd_double2 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3784 return t*t*(3 - 2*t);
3785}
3786
3787static inline SIMD_CFUNC simd_double3 simd_smoothstep(simd_double3 edge0, simd_double3 edge1, simd_double3 x) {
3788 simd_double3 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3789 return t*t*(3 - 2*t);
3790}
3791
3792static inline SIMD_CFUNC simd_double4 simd_smoothstep(simd_double4 edge0, simd_double4 edge1, simd_double4 x) {
3793 simd_double4 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3794 return t*t*(3 - 2*t);
3795}
3796
3797static inline SIMD_CFUNC simd_double8 simd_smoothstep(simd_double8 edge0, simd_double8 edge1, simd_double8 x) {
3798 simd_double8 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1);
3799 return t*t*(3 - 2*t);
3800}
3801
3802static inline SIMD_CFUNC char simd_reduce_add(simd_char2 x) {
3803 return x.x + x.y;
3804}
3805
3806static inline SIMD_CFUNC char simd_reduce_add(simd_char3 x) {
3807 return x.x + x.y + x.z;
3808}
3809
3810static inline SIMD_CFUNC char simd_reduce_add(simd_char4 x) {
3811 return simd_reduce_add(x.lo + x.hi);
3812}
3813
3814static inline SIMD_CFUNC char simd_reduce_add(simd_char8 x) {
3815 return simd_reduce_add(x.lo + x.hi);
3816}
3817
3818static inline SIMD_CFUNC char simd_reduce_add(simd_char16 x) {
3819 return simd_reduce_add(x.lo + x.hi);
3820}
3821
3822static inline SIMD_CFUNC char simd_reduce_add(simd_char32 x) {
3823 return simd_reduce_add(x.lo + x.hi);
3824}
3825
3826static inline SIMD_CFUNC char simd_reduce_add(simd_char64 x) {
3827 return simd_reduce_add(x.lo + x.hi);
3828}
3829
3830static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar2 x) {
3831 return x.x + x.y;
3832}
3833
3834static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar3 x) {
3835 return x.x + x.y + x.z;
3836}
3837
3838static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar4 x) {
3839 return simd_reduce_add(x.lo + x.hi);
3840}
3841
3842static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar8 x) {
3843 return simd_reduce_add(x.lo + x.hi);
3844}
3845
3846static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar16 x) {
3847 return simd_reduce_add(x.lo + x.hi);
3848}
3849
3850static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar32 x) {
3851 return simd_reduce_add(x.lo + x.hi);
3852}
3853
3854static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar64 x) {
3855 return simd_reduce_add(x.lo + x.hi);
3856}
3857
3858static inline SIMD_CFUNC short simd_reduce_add(simd_short2 x) {
3859 return x.x + x.y;
3860}
3861
3862static inline SIMD_CFUNC short simd_reduce_add(simd_short3 x) {
3863 return x.x + x.y + x.z;
3864}
3865
3866static inline SIMD_CFUNC short simd_reduce_add(simd_short4 x) {
3867 return simd_reduce_add(x.lo + x.hi);
3868}
3869
3870static inline SIMD_CFUNC short simd_reduce_add(simd_short8 x) {
3871 return simd_reduce_add(x.lo + x.hi);
3872}
3873
3874static inline SIMD_CFUNC short simd_reduce_add(simd_short16 x) {
3875 return simd_reduce_add(x.lo + x.hi);
3876}
3877
3878static inline SIMD_CFUNC short simd_reduce_add(simd_short32 x) {
3879 return simd_reduce_add(x.lo + x.hi);
3880}
3881
3882static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort2 x) {
3883 return x.x + x.y;
3884}
3885
3886static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort3 x) {
3887 return x.x + x.y + x.z;
3888}
3889
3890static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort4 x) {
3891 return simd_reduce_add(x.lo + x.hi);
3892}
3893
3894static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort8 x) {
3895 return simd_reduce_add(x.lo + x.hi);
3896}
3897
3898static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort16 x) {
3899 return simd_reduce_add(x.lo + x.hi);
3900}
3901
3902static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort32 x) {
3903 return simd_reduce_add(x.lo + x.hi);
3904}
3905
3906static inline SIMD_CFUNC int simd_reduce_add(simd_int2 x) {
3907 return x.x + x.y;
3908}
3909
3910static inline SIMD_CFUNC int simd_reduce_add(simd_int3 x) {
3911 return x.x + x.y + x.z;
3912}
3913
3914static inline SIMD_CFUNC int simd_reduce_add(simd_int4 x) {
3915 return simd_reduce_add(x.lo + x.hi);
3916}
3917
3918static inline SIMD_CFUNC int simd_reduce_add(simd_int8 x) {
3919 return simd_reduce_add(x.lo + x.hi);
3920}
3921
3922static inline SIMD_CFUNC int simd_reduce_add(simd_int16 x) {
3923 return simd_reduce_add(x.lo + x.hi);
3924}
3925
3926static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint2 x) {
3927 return x.x + x.y;
3928}
3929
3930static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint3 x) {
3931 return x.x + x.y + x.z;
3932}
3933
3934static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint4 x) {
3935 return simd_reduce_add(x.lo + x.hi);
3936}
3937
3938static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint8 x) {
3939 return simd_reduce_add(x.lo + x.hi);
3940}
3941
3942static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint16 x) {
3943 return simd_reduce_add(x.lo + x.hi);
3944}
3945
3946static inline SIMD_CFUNC float simd_reduce_add(simd_float2 x) {
3947 return x.x + x.y;
3948}
3949
3950static inline SIMD_CFUNC float simd_reduce_add(simd_float3 x) {
3951 return x.x + x.y + x.z;
3952}
3953
3954static inline SIMD_CFUNC float simd_reduce_add(simd_float4 x) {
3955 return simd_reduce_add(x.lo + x.hi);
3956}
3957
3958static inline SIMD_CFUNC float simd_reduce_add(simd_float8 x) {
3959 return simd_reduce_add(x.lo + x.hi);
3960}
3961
3962static inline SIMD_CFUNC float simd_reduce_add(simd_float16 x) {
3963 return simd_reduce_add(x.lo + x.hi);
3964}
3965
3966static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long2 x) {
3967 return x.x + x.y;
3968}
3969
3970static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long3 x) {
3971 return x.x + x.y + x.z;
3972}
3973
3974static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long4 x) {
3975 return simd_reduce_add(x.lo + x.hi);
3976}
3977
3978static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long8 x) {
3979 return simd_reduce_add(x.lo + x.hi);
3980}
3981
3982static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong2 x) {
3983 return x.x + x.y;
3984}
3985
3986static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong3 x) {
3987 return x.x + x.y + x.z;
3988}
3989
3990static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong4 x) {
3991 return simd_reduce_add(x.lo + x.hi);
3992}
3993
3994static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong8 x) {
3995 return simd_reduce_add(x.lo + x.hi);
3996}
3997
3998static inline SIMD_CFUNC double simd_reduce_add(simd_double2 x) {
3999 return x.x + x.y;
4000}
4001
4002static inline SIMD_CFUNC double simd_reduce_add(simd_double3 x) {
4003 return x.x + x.y + x.z;
4004}
4005
4006static inline SIMD_CFUNC double simd_reduce_add(simd_double4 x) {
4007 return simd_reduce_add(x.lo + x.hi);
4008}
4009
4010static inline SIMD_CFUNC double simd_reduce_add(simd_double8 x) {
4011 return simd_reduce_add(x.lo + x.hi);
4012}
4013
4014static inline SIMD_CFUNC char simd_reduce_min(simd_char2 x) {
4015 return x.y < x.x ? x.y : x.x;
4016}
4017
4018static inline SIMD_CFUNC char simd_reduce_min(simd_char3 x) {
4019 char t = x.z < x.x ? x.z : x.x;
4020 return x.y < t ? x.y : t;
4021}
4022
4023static inline SIMD_CFUNC char simd_reduce_min(simd_char4 x) {
4024 return simd_reduce_min(simd_min(x.lo, x.hi));
4025}
4026
4027static inline SIMD_CFUNC char simd_reduce_min(simd_char8 x) {
4028 return simd_reduce_min(simd_min(x.lo, x.hi));
4029}
4030
4031static inline SIMD_CFUNC char simd_reduce_min(simd_char16 x) {
4032 return simd_reduce_min(simd_min(x.lo, x.hi));
4033}
4034
4035static inline SIMD_CFUNC char simd_reduce_min(simd_char32 x) {
4036 return simd_reduce_min(simd_min(x.lo, x.hi));
4037}
4038
4039static inline SIMD_CFUNC char simd_reduce_min(simd_char64 x) {
4040 return simd_reduce_min(simd_min(x.lo, x.hi));
4041}
4042
4043static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar2 x) {
4044 return x.y < x.x ? x.y : x.x;
4045}
4046
4047static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar3 x) {
4048 unsigned char t = x.z < x.x ? x.z : x.x;
4049 return x.y < t ? x.y : t;
4050}
4051
4052static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar4 x) {
4053 return simd_reduce_min(simd_min(x.lo, x.hi));
4054}
4055
4056static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar8 x) {
4057 return simd_reduce_min(simd_min(x.lo, x.hi));
4058}
4059
4060static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar16 x) {
4061 return simd_reduce_min(simd_min(x.lo, x.hi));
4062}
4063
4064static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar32 x) {
4065 return simd_reduce_min(simd_min(x.lo, x.hi));
4066}
4067
4068static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar64 x) {
4069 return simd_reduce_min(simd_min(x.lo, x.hi));
4070}
4071
4072static inline SIMD_CFUNC short simd_reduce_min(simd_short2 x) {
4073 return x.y < x.x ? x.y : x.x;
4074}
4075
4076static inline SIMD_CFUNC short simd_reduce_min(simd_short3 x) {
4077 short t = x.z < x.x ? x.z : x.x;
4078 return x.y < t ? x.y : t;
4079}
4080
4081static inline SIMD_CFUNC short simd_reduce_min(simd_short4 x) {
4082 return simd_reduce_min(simd_min(x.lo, x.hi));
4083}
4084
4085static inline SIMD_CFUNC short simd_reduce_min(simd_short8 x) {
4086 return simd_reduce_min(simd_min(x.lo, x.hi));
4087}
4088
4089static inline SIMD_CFUNC short simd_reduce_min(simd_short16 x) {
4090 return simd_reduce_min(simd_min(x.lo, x.hi));
4091}
4092
4093static inline SIMD_CFUNC short simd_reduce_min(simd_short32 x) {
4094 return simd_reduce_min(simd_min(x.lo, x.hi));
4095}
4096
4097static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort2 x) {
4098 return x.y < x.x ? x.y : x.x;
4099}
4100
4101static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort3 x) {
4102 unsigned short t = x.z < x.x ? x.z : x.x;
4103 return x.y < t ? x.y : t;
4104}
4105
4106static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort4 x) {
4107 return simd_reduce_min(simd_min(x.lo, x.hi));
4108}
4109
4110static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort8 x) {
4111 return simd_reduce_min(simd_min(x.lo, x.hi));
4112}
4113
4114static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort16 x) {
4115 return simd_reduce_min(simd_min(x.lo, x.hi));
4116}
4117
4118static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort32 x) {
4119 return simd_reduce_min(simd_min(x.lo, x.hi));
4120}
4121
4122static inline SIMD_CFUNC int simd_reduce_min(simd_int2 x) {
4123 return x.y < x.x ? x.y : x.x;
4124}
4125
4126static inline SIMD_CFUNC int simd_reduce_min(simd_int3 x) {
4127 int t = x.z < x.x ? x.z : x.x;
4128 return x.y < t ? x.y : t;
4129}
4130
4131static inline SIMD_CFUNC int simd_reduce_min(simd_int4 x) {
4132 return simd_reduce_min(simd_min(x.lo, x.hi));
4133}
4134
4135static inline SIMD_CFUNC int simd_reduce_min(simd_int8 x) {
4136 return simd_reduce_min(simd_min(x.lo, x.hi));
4137}
4138
4139static inline SIMD_CFUNC int simd_reduce_min(simd_int16 x) {
4140 return simd_reduce_min(simd_min(x.lo, x.hi));
4141}
4142
4143static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint2 x) {
4144 return x.y < x.x ? x.y : x.x;
4145}
4146
4147static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint3 x) {
4148 unsigned int t = x.z < x.x ? x.z : x.x;
4149 return x.y < t ? x.y : t;
4150}
4151
4152static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint4 x) {
4153 return simd_reduce_min(simd_min(x.lo, x.hi));
4154}
4155
4156static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint8 x) {
4157 return simd_reduce_min(simd_min(x.lo, x.hi));
4158}
4159
4160static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint16 x) {
4161 return simd_reduce_min(simd_min(x.lo, x.hi));
4162}
4163
4164static inline SIMD_CFUNC float simd_reduce_min(simd_float2 x) {
4165 return fmin(x.x, x.y);
4166}
4167
4168static inline SIMD_CFUNC float simd_reduce_min(simd_float3 x) {
4169 return fmin(fmin(x.x, x.z), x.y);
4170}
4171
4172static inline SIMD_CFUNC float simd_reduce_min(simd_float4 x) {
4173 return simd_reduce_min(simd_min(x.lo, x.hi));
4174}
4175
4176static inline SIMD_CFUNC float simd_reduce_min(simd_float8 x) {
4177 return simd_reduce_min(simd_min(x.lo, x.hi));
4178}
4179
4180static inline SIMD_CFUNC float simd_reduce_min(simd_float16 x) {
4181 return simd_reduce_min(simd_min(x.lo, x.hi));
4182}
4183
4184static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long2 x) {
4185 return x.y < x.x ? x.y : x.x;
4186}
4187
4188static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long3 x) {
4189 simd_long1 t = x.z < x.x ? x.z : x.x;
4190 return x.y < t ? x.y : t;
4191}
4192
4193static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long4 x) {
4194 return simd_reduce_min(simd_min(x.lo, x.hi));
4195}
4196
4197static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long8 x) {
4198 return simd_reduce_min(simd_min(x.lo, x.hi));
4199}
4200
4201static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong2 x) {
4202 return x.y < x.x ? x.y : x.x;
4203}
4204
4205static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong3 x) {
4206 simd_ulong1 t = x.z < x.x ? x.z : x.x;
4207 return x.y < t ? x.y : t;
4208}
4209
4210static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong4 x) {
4211 return simd_reduce_min(simd_min(x.lo, x.hi));
4212}
4213
4214static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong8 x) {
4215 return simd_reduce_min(simd_min(x.lo, x.hi));
4216}
4217
4218static inline SIMD_CFUNC double simd_reduce_min(simd_double2 x) {
4219 return fmin(x.x, x.y);
4220}
4221
4222static inline SIMD_CFUNC double simd_reduce_min(simd_double3 x) {
4223 return fmin(fmin(x.x, x.z), x.y);
4224}
4225
4226static inline SIMD_CFUNC double simd_reduce_min(simd_double4 x) {
4227 return simd_reduce_min(simd_min(x.lo, x.hi));
4228}
4229
4230static inline SIMD_CFUNC double simd_reduce_min(simd_double8 x) {
4231 return simd_reduce_min(simd_min(x.lo, x.hi));
4232}
4233
4234static inline SIMD_CFUNC char simd_reduce_max(simd_char2 x) {
4235 return x.y > x.x ? x.y : x.x;
4236}
4237
4238static inline SIMD_CFUNC char simd_reduce_max(simd_char3 x) {
4239 char t = x.z > x.x ? x.z : x.x;
4240 return x.y > t ? x.y : t;
4241}
4242
4243static inline SIMD_CFUNC char simd_reduce_max(simd_char4 x) {
4244 return simd_reduce_max(simd_max(x.lo, x.hi));
4245}
4246
4247static inline SIMD_CFUNC char simd_reduce_max(simd_char8 x) {
4248 return simd_reduce_max(simd_max(x.lo, x.hi));
4249}
4250
4251static inline SIMD_CFUNC char simd_reduce_max(simd_char16 x) {
4252 return simd_reduce_max(simd_max(x.lo, x.hi));
4253}
4254
4255static inline SIMD_CFUNC char simd_reduce_max(simd_char32 x) {
4256 return simd_reduce_max(simd_max(x.lo, x.hi));
4257}
4258
4259static inline SIMD_CFUNC char simd_reduce_max(simd_char64 x) {
4260 return simd_reduce_max(simd_max(x.lo, x.hi));
4261}
4262
4263static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar2 x) {
4264 return x.y > x.x ? x.y : x.x;
4265}
4266
4267static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar3 x) {
4268 unsigned char t = x.z > x.x ? x.z : x.x;
4269 return x.y > t ? x.y : t;
4270}
4271
4272static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar4 x) {
4273 return simd_reduce_max(simd_max(x.lo, x.hi));
4274}
4275
4276static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar8 x) {
4277 return simd_reduce_max(simd_max(x.lo, x.hi));
4278}
4279
4280static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar16 x) {
4281 return simd_reduce_max(simd_max(x.lo, x.hi));
4282}
4283
4284static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar32 x) {
4285 return simd_reduce_max(simd_max(x.lo, x.hi));
4286}
4287
4288static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar64 x) {
4289 return simd_reduce_max(simd_max(x.lo, x.hi));
4290}
4291
4292static inline SIMD_CFUNC short simd_reduce_max(simd_short2 x) {
4293 return x.y > x.x ? x.y : x.x;
4294}
4295
4296static inline SIMD_CFUNC short simd_reduce_max(simd_short3 x) {
4297 short t = x.z > x.x ? x.z : x.x;
4298 return x.y > t ? x.y : t;
4299}
4300
4301static inline SIMD_CFUNC short simd_reduce_max(simd_short4 x) {
4302 return simd_reduce_max(simd_max(x.lo, x.hi));
4303}
4304
4305static inline SIMD_CFUNC short simd_reduce_max(simd_short8 x) {
4306 return simd_reduce_max(simd_max(x.lo, x.hi));
4307}
4308
4309static inline SIMD_CFUNC short simd_reduce_max(simd_short16 x) {
4310 return simd_reduce_max(simd_max(x.lo, x.hi));
4311}
4312
4313static inline SIMD_CFUNC short simd_reduce_max(simd_short32 x) {
4314 return simd_reduce_max(simd_max(x.lo, x.hi));
4315}
4316
4317static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort2 x) {
4318 return x.y > x.x ? x.y : x.x;
4319}
4320
4321static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort3 x) {
4322 unsigned short t = x.z > x.x ? x.z : x.x;
4323 return x.y > t ? x.y : t;
4324}
4325
4326static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort4 x) {
4327 return simd_reduce_max(simd_max(x.lo, x.hi));
4328}
4329
4330static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort8 x) {
4331 return simd_reduce_max(simd_max(x.lo, x.hi));
4332}
4333
4334static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort16 x) {
4335 return simd_reduce_max(simd_max(x.lo, x.hi));
4336}
4337
4338static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort32 x) {
4339 return simd_reduce_max(simd_max(x.lo, x.hi));
4340}
4341
4342static inline SIMD_CFUNC int simd_reduce_max(simd_int2 x) {
4343 return x.y > x.x ? x.y : x.x;
4344}
4345
4346static inline SIMD_CFUNC int simd_reduce_max(simd_int3 x) {
4347 int t = x.z > x.x ? x.z : x.x;
4348 return x.y > t ? x.y : t;
4349}
4350
4351static inline SIMD_CFUNC int simd_reduce_max(simd_int4 x) {
4352 return simd_reduce_max(simd_max(x.lo, x.hi));
4353}
4354
4355static inline SIMD_CFUNC int simd_reduce_max(simd_int8 x) {
4356 return simd_reduce_max(simd_max(x.lo, x.hi));
4357}
4358
4359static inline SIMD_CFUNC int simd_reduce_max(simd_int16 x) {
4360 return simd_reduce_max(simd_max(x.lo, x.hi));
4361}
4362
4363static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint2 x) {
4364 return x.y > x.x ? x.y : x.x;
4365}
4366
4367static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint3 x) {
4368 unsigned int t = x.z > x.x ? x.z : x.x;
4369 return x.y > t ? x.y : t;
4370}
4371
4372static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint4 x) {
4373 return simd_reduce_max(simd_max(x.lo, x.hi));
4374}
4375
4376static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint8 x) {
4377 return simd_reduce_max(simd_max(x.lo, x.hi));
4378}
4379
4380static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint16 x) {
4381 return simd_reduce_max(simd_max(x.lo, x.hi));
4382}
4383
4384static inline SIMD_CFUNC float simd_reduce_max(simd_float2 x) {
4385 return fmax(x.x, x.y);
4386}
4387
4388static inline SIMD_CFUNC float simd_reduce_max(simd_float3 x) {
4389 return fmax(fmax(x.x, x.z), x.y);
4390}
4391
4392static inline SIMD_CFUNC float simd_reduce_max(simd_float4 x) {
4393 return simd_reduce_max(simd_max(x.lo, x.hi));
4394}
4395
4396static inline SIMD_CFUNC float simd_reduce_max(simd_float8 x) {
4397 return simd_reduce_max(simd_max(x.lo, x.hi));
4398}
4399
4400static inline SIMD_CFUNC float simd_reduce_max(simd_float16 x) {
4401 return simd_reduce_max(simd_max(x.lo, x.hi));
4402}
4403
4404static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long2 x) {
4405 return x.y > x.x ? x.y : x.x;
4406}
4407
4408static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long3 x) {
4409 simd_long1 t = x.z > x.x ? x.z : x.x;
4410 return x.y > t ? x.y : t;
4411}
4412
4413static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long4 x) {
4414 return simd_reduce_max(simd_max(x.lo, x.hi));
4415}
4416
4417static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long8 x) {
4418 return simd_reduce_max(simd_max(x.lo, x.hi));
4419}
4420
4421static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong2 x) {
4422 return x.y > x.x ? x.y : x.x;
4423}
4424
4425static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong3 x) {
4426 simd_ulong1 t = x.z > x.x ? x.z : x.x;
4427 return x.y > t ? x.y : t;
4428}
4429
4430static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong4 x) {
4431 return simd_reduce_max(simd_max(x.lo, x.hi));
4432}
4433
4434static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong8 x) {
4435 return simd_reduce_max(simd_max(x.lo, x.hi));
4436}
4437
4438static inline SIMD_CFUNC double simd_reduce_max(simd_double2 x) {
4439 return fmax(x.x, x.y);
4440}
4441
4442static inline SIMD_CFUNC double simd_reduce_max(simd_double3 x) {
4443 return fmax(fmax(x.x, x.z), x.y);
4444}
4445
4446static inline SIMD_CFUNC double simd_reduce_max(simd_double4 x) {
4447 return simd_reduce_max(simd_max(x.lo, x.hi));
4448}
4449
4450static inline SIMD_CFUNC double simd_reduce_max(simd_double8 x) {
4451 return simd_reduce_max(simd_max(x.lo, x.hi));
4452}
4453
4454#ifdef __cplusplus
4455}
4456#endif
4457#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
4458#endif /* SIMD_COMMON_HEADER */
lib/libc/include/x86_64-macos-gnu/simd/conversion.h created+1967
......@@ -0,0 +1,1967 @@
1/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved.
2 *
3 * The interfaces declared in this header provide conversions between vector
4 * types. The following functions are available:
5 *
6 * simd_char(x) simd_uchar(x)
7 * simd_short(x) simd_ushort(x)
8 * simd_int(x) simd_uint(x)
9 * simd_long(x) simd_ulong(x)
10 * simd_float(x)
11 * simd_double(x)
12 *
13 * Each of these functions converts x to a vector whose elements have the
14 * type named by the function, with the same number of elements as x. Unlike
15 * a vector cast, these functions convert the elements to the new element
16 * type. These conversions behave exactly as C scalar conversions, except
17 * that conversions from integer vector types to signed integer vector types
18 * are guaranteed to wrap modulo 2^N (where N is the number of bits in an
19 * element of the result type).
20 *
21 * For integer vector types, saturating conversions are also available:
22 *
23 * simd_char_sat(x) simd_uchar_sat(x)
24 * simd_short_sat(x) simd_ushort_sat(x)
25 * simd_int_sat(x) simd_uint_sat(x)
26 * simd_long_sat(x) simd_ulong_sat(x)
27 *
28 * These conversions clamp x to the representable range of the result type
29 * before converting.
30 *
31 * Unlike most vector operations in <simd/>, there are no abbreviated C++
32 * names for these functions in the simd:: namespace.
33 */
34
35#ifndef __SIMD_CONVERSION_HEADER__
36#define __SIMD_CONVERSION_HEADER__
37
38#include <simd/base.h>
39#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
40#include <simd/vector_types.h>
41#include <simd/common.h>
42#include <simd/logic.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48static simd_char2 SIMD_CFUNC simd_char(simd_char2 __x);
49static simd_char3 SIMD_CFUNC simd_char(simd_char3 __x);
50static simd_char4 SIMD_CFUNC simd_char(simd_char4 __x);
51static simd_char8 SIMD_CFUNC simd_char(simd_char8 __x);
52static simd_char16 SIMD_CFUNC simd_char(simd_char16 __x);
53static simd_char32 SIMD_CFUNC simd_char(simd_char32 __x);
54static simd_char2 SIMD_CFUNC simd_char(simd_uchar2 __x);
55static simd_char3 SIMD_CFUNC simd_char(simd_uchar3 __x);
56static simd_char4 SIMD_CFUNC simd_char(simd_uchar4 __x);
57static simd_char8 SIMD_CFUNC simd_char(simd_uchar8 __x);
58static simd_char16 SIMD_CFUNC simd_char(simd_uchar16 __x);
59static simd_char32 SIMD_CFUNC simd_char(simd_uchar32 __x);
60static simd_char2 SIMD_CFUNC simd_char(simd_short2 __x);
61static simd_char3 SIMD_CFUNC simd_char(simd_short3 __x);
62static simd_char4 SIMD_CFUNC simd_char(simd_short4 __x);
63static simd_char8 SIMD_CFUNC simd_char(simd_short8 __x);
64static simd_char16 SIMD_CFUNC simd_char(simd_short16 __x);
65static simd_char32 SIMD_CFUNC simd_char(simd_short32 __x);
66static simd_char2 SIMD_CFUNC simd_char(simd_ushort2 __x);
67static simd_char3 SIMD_CFUNC simd_char(simd_ushort3 __x);
68static simd_char4 SIMD_CFUNC simd_char(simd_ushort4 __x);
69static simd_char8 SIMD_CFUNC simd_char(simd_ushort8 __x);
70static simd_char16 SIMD_CFUNC simd_char(simd_ushort16 __x);
71static simd_char32 SIMD_CFUNC simd_char(simd_ushort32 __x);
72static simd_char2 SIMD_CFUNC simd_char(simd_int2 __x);
73static simd_char3 SIMD_CFUNC simd_char(simd_int3 __x);
74static simd_char4 SIMD_CFUNC simd_char(simd_int4 __x);
75static simd_char8 SIMD_CFUNC simd_char(simd_int8 __x);
76static simd_char16 SIMD_CFUNC simd_char(simd_int16 __x);
77static simd_char2 SIMD_CFUNC simd_char(simd_uint2 __x);
78static simd_char3 SIMD_CFUNC simd_char(simd_uint3 __x);
79static simd_char4 SIMD_CFUNC simd_char(simd_uint4 __x);
80static simd_char8 SIMD_CFUNC simd_char(simd_uint8 __x);
81static simd_char16 SIMD_CFUNC simd_char(simd_uint16 __x);
82static simd_char2 SIMD_CFUNC simd_char(simd_float2 __x);
83static simd_char3 SIMD_CFUNC simd_char(simd_float3 __x);
84static simd_char4 SIMD_CFUNC simd_char(simd_float4 __x);
85static simd_char8 SIMD_CFUNC simd_char(simd_float8 __x);
86static simd_char16 SIMD_CFUNC simd_char(simd_float16 __x);
87static simd_char2 SIMD_CFUNC simd_char(simd_long2 __x);
88static simd_char3 SIMD_CFUNC simd_char(simd_long3 __x);
89static simd_char4 SIMD_CFUNC simd_char(simd_long4 __x);
90static simd_char8 SIMD_CFUNC simd_char(simd_long8 __x);
91static simd_char2 SIMD_CFUNC simd_char(simd_ulong2 __x);
92static simd_char3 SIMD_CFUNC simd_char(simd_ulong3 __x);
93static simd_char4 SIMD_CFUNC simd_char(simd_ulong4 __x);
94static simd_char8 SIMD_CFUNC simd_char(simd_ulong8 __x);
95static simd_char2 SIMD_CFUNC simd_char(simd_double2 __x);
96static simd_char3 SIMD_CFUNC simd_char(simd_double3 __x);
97static simd_char4 SIMD_CFUNC simd_char(simd_double4 __x);
98static simd_char8 SIMD_CFUNC simd_char(simd_double8 __x);
99static simd_char2 SIMD_CFUNC simd_char_sat(simd_char2 __x);
100static simd_char3 SIMD_CFUNC simd_char_sat(simd_char3 __x);
101static simd_char4 SIMD_CFUNC simd_char_sat(simd_char4 __x);
102static simd_char8 SIMD_CFUNC simd_char_sat(simd_char8 __x);
103static simd_char16 SIMD_CFUNC simd_char_sat(simd_char16 __x);
104static simd_char32 SIMD_CFUNC simd_char_sat(simd_char32 __x);
105static simd_char2 SIMD_CFUNC simd_char_sat(simd_short2 __x);
106static simd_char3 SIMD_CFUNC simd_char_sat(simd_short3 __x);
107static simd_char4 SIMD_CFUNC simd_char_sat(simd_short4 __x);
108static simd_char8 SIMD_CFUNC simd_char_sat(simd_short8 __x);
109static simd_char16 SIMD_CFUNC simd_char_sat(simd_short16 __x);
110static simd_char32 SIMD_CFUNC simd_char_sat(simd_short32 __x);
111static simd_char2 SIMD_CFUNC simd_char_sat(simd_int2 __x);
112static simd_char3 SIMD_CFUNC simd_char_sat(simd_int3 __x);
113static simd_char4 SIMD_CFUNC simd_char_sat(simd_int4 __x);
114static simd_char8 SIMD_CFUNC simd_char_sat(simd_int8 __x);
115static simd_char16 SIMD_CFUNC simd_char_sat(simd_int16 __x);
116static simd_char2 SIMD_CFUNC simd_char_sat(simd_float2 __x);
117static simd_char3 SIMD_CFUNC simd_char_sat(simd_float3 __x);
118static simd_char4 SIMD_CFUNC simd_char_sat(simd_float4 __x);
119static simd_char8 SIMD_CFUNC simd_char_sat(simd_float8 __x);
120static simd_char16 SIMD_CFUNC simd_char_sat(simd_float16 __x);
121static simd_char2 SIMD_CFUNC simd_char_sat(simd_long2 __x);
122static simd_char3 SIMD_CFUNC simd_char_sat(simd_long3 __x);
123static simd_char4 SIMD_CFUNC simd_char_sat(simd_long4 __x);
124static simd_char8 SIMD_CFUNC simd_char_sat(simd_long8 __x);
125static simd_char2 SIMD_CFUNC simd_char_sat(simd_double2 __x);
126static simd_char3 SIMD_CFUNC simd_char_sat(simd_double3 __x);
127static simd_char4 SIMD_CFUNC simd_char_sat(simd_double4 __x);
128static simd_char8 SIMD_CFUNC simd_char_sat(simd_double8 __x);
129static simd_char2 SIMD_CFUNC simd_char_sat(simd_uchar2 __x);
130static simd_char3 SIMD_CFUNC simd_char_sat(simd_uchar3 __x);
131static simd_char4 SIMD_CFUNC simd_char_sat(simd_uchar4 __x);
132static simd_char8 SIMD_CFUNC simd_char_sat(simd_uchar8 __x);
133static simd_char16 SIMD_CFUNC simd_char_sat(simd_uchar16 __x);
134static simd_char32 SIMD_CFUNC simd_char_sat(simd_uchar32 __x);
135static simd_char2 SIMD_CFUNC simd_char_sat(simd_ushort2 __x);
136static simd_char3 SIMD_CFUNC simd_char_sat(simd_ushort3 __x);
137static simd_char4 SIMD_CFUNC simd_char_sat(simd_ushort4 __x);
138static simd_char8 SIMD_CFUNC simd_char_sat(simd_ushort8 __x);
139static simd_char16 SIMD_CFUNC simd_char_sat(simd_ushort16 __x);
140static simd_char32 SIMD_CFUNC simd_char_sat(simd_ushort32 __x);
141static simd_char2 SIMD_CFUNC simd_char_sat(simd_uint2 __x);
142static simd_char3 SIMD_CFUNC simd_char_sat(simd_uint3 __x);
143static simd_char4 SIMD_CFUNC simd_char_sat(simd_uint4 __x);
144static simd_char8 SIMD_CFUNC simd_char_sat(simd_uint8 __x);
145static simd_char16 SIMD_CFUNC simd_char_sat(simd_uint16 __x);
146static simd_char2 SIMD_CFUNC simd_char_sat(simd_ulong2 __x);
147static simd_char3 SIMD_CFUNC simd_char_sat(simd_ulong3 __x);
148static simd_char4 SIMD_CFUNC simd_char_sat(simd_ulong4 __x);
149static simd_char8 SIMD_CFUNC simd_char_sat(simd_ulong8 __x);
150#define vector_char simd_char
151#define vector_char_sat simd_char_sat
152
153static simd_uchar2 SIMD_CFUNC simd_uchar(simd_char2 __x);
154static simd_uchar3 SIMD_CFUNC simd_uchar(simd_char3 __x);
155static simd_uchar4 SIMD_CFUNC simd_uchar(simd_char4 __x);
156static simd_uchar8 SIMD_CFUNC simd_uchar(simd_char8 __x);
157static simd_uchar16 SIMD_CFUNC simd_uchar(simd_char16 __x);
158static simd_uchar32 SIMD_CFUNC simd_uchar(simd_char32 __x);
159static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uchar2 __x);
160static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uchar3 __x);
161static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uchar4 __x);
162static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uchar8 __x);
163static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uchar16 __x);
164static simd_uchar32 SIMD_CFUNC simd_uchar(simd_uchar32 __x);
165static simd_uchar2 SIMD_CFUNC simd_uchar(simd_short2 __x);
166static simd_uchar3 SIMD_CFUNC simd_uchar(simd_short3 __x);
167static simd_uchar4 SIMD_CFUNC simd_uchar(simd_short4 __x);
168static simd_uchar8 SIMD_CFUNC simd_uchar(simd_short8 __x);
169static simd_uchar16 SIMD_CFUNC simd_uchar(simd_short16 __x);
170static simd_uchar32 SIMD_CFUNC simd_uchar(simd_short32 __x);
171static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ushort2 __x);
172static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ushort3 __x);
173static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ushort4 __x);
174static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ushort8 __x);
175static simd_uchar16 SIMD_CFUNC simd_uchar(simd_ushort16 __x);
176static simd_uchar32 SIMD_CFUNC simd_uchar(simd_ushort32 __x);
177static simd_uchar2 SIMD_CFUNC simd_uchar(simd_int2 __x);
178static simd_uchar3 SIMD_CFUNC simd_uchar(simd_int3 __x);
179static simd_uchar4 SIMD_CFUNC simd_uchar(simd_int4 __x);
180static simd_uchar8 SIMD_CFUNC simd_uchar(simd_int8 __x);
181static simd_uchar16 SIMD_CFUNC simd_uchar(simd_int16 __x);
182static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uint2 __x);
183static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uint3 __x);
184static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uint4 __x);
185static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uint8 __x);
186static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uint16 __x);
187static simd_uchar2 SIMD_CFUNC simd_uchar(simd_float2 __x);
188static simd_uchar3 SIMD_CFUNC simd_uchar(simd_float3 __x);
189static simd_uchar4 SIMD_CFUNC simd_uchar(simd_float4 __x);
190static simd_uchar8 SIMD_CFUNC simd_uchar(simd_float8 __x);
191static simd_uchar16 SIMD_CFUNC simd_uchar(simd_float16 __x);
192static simd_uchar2 SIMD_CFUNC simd_uchar(simd_long2 __x);
193static simd_uchar3 SIMD_CFUNC simd_uchar(simd_long3 __x);
194static simd_uchar4 SIMD_CFUNC simd_uchar(simd_long4 __x);
195static simd_uchar8 SIMD_CFUNC simd_uchar(simd_long8 __x);
196static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ulong2 __x);
197static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ulong3 __x);
198static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ulong4 __x);
199static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ulong8 __x);
200static simd_uchar2 SIMD_CFUNC simd_uchar(simd_double2 __x);
201static simd_uchar3 SIMD_CFUNC simd_uchar(simd_double3 __x);
202static simd_uchar4 SIMD_CFUNC simd_uchar(simd_double4 __x);
203static simd_uchar8 SIMD_CFUNC simd_uchar(simd_double8 __x);
204static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_char2 __x);
205static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_char3 __x);
206static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_char4 __x);
207static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_char8 __x);
208static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_char16 __x);
209static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_char32 __x);
210static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_short2 __x);
211static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_short3 __x);
212static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_short4 __x);
213static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_short8 __x);
214static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_short16 __x);
215static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_short32 __x);
216static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_int2 __x);
217static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_int3 __x);
218static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_int4 __x);
219static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_int8 __x);
220static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_int16 __x);
221static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_float2 __x);
222static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_float3 __x);
223static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_float4 __x);
224static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_float8 __x);
225static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_float16 __x);
226static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_long2 __x);
227static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_long3 __x);
228static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_long4 __x);
229static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_long8 __x);
230static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_double2 __x);
231static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_double3 __x);
232static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_double4 __x);
233static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_double8 __x);
234static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uchar2 __x);
235static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uchar3 __x);
236static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uchar4 __x);
237static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uchar8 __x);
238static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uchar16 __x);
239static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_uchar32 __x);
240static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ushort2 __x);
241static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ushort3 __x);
242static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ushort4 __x);
243static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ushort8 __x);
244static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_ushort16 __x);
245static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_ushort32 __x);
246static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uint2 __x);
247static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uint3 __x);
248static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uint4 __x);
249static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uint8 __x);
250static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uint16 __x);
251static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ulong2 __x);
252static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ulong3 __x);
253static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ulong4 __x);
254static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ulong8 __x);
255#define vector_uchar simd_uchar
256#define vector_uchar_sat simd_uchar_sat
257
258static simd_short2 SIMD_CFUNC simd_short(simd_char2 __x);
259static simd_short3 SIMD_CFUNC simd_short(simd_char3 __x);
260static simd_short4 SIMD_CFUNC simd_short(simd_char4 __x);
261static simd_short8 SIMD_CFUNC simd_short(simd_char8 __x);
262static simd_short16 SIMD_CFUNC simd_short(simd_char16 __x);
263static simd_short32 SIMD_CFUNC simd_short(simd_char32 __x);
264static simd_short2 SIMD_CFUNC simd_short(simd_uchar2 __x);
265static simd_short3 SIMD_CFUNC simd_short(simd_uchar3 __x);
266static simd_short4 SIMD_CFUNC simd_short(simd_uchar4 __x);
267static simd_short8 SIMD_CFUNC simd_short(simd_uchar8 __x);
268static simd_short16 SIMD_CFUNC simd_short(simd_uchar16 __x);
269static simd_short32 SIMD_CFUNC simd_short(simd_uchar32 __x);
270static simd_short2 SIMD_CFUNC simd_short(simd_short2 __x);
271static simd_short3 SIMD_CFUNC simd_short(simd_short3 __x);
272static simd_short4 SIMD_CFUNC simd_short(simd_short4 __x);
273static simd_short8 SIMD_CFUNC simd_short(simd_short8 __x);
274static simd_short16 SIMD_CFUNC simd_short(simd_short16 __x);
275static simd_short32 SIMD_CFUNC simd_short(simd_short32 __x);
276static simd_short2 SIMD_CFUNC simd_short(simd_ushort2 __x);
277static simd_short3 SIMD_CFUNC simd_short(simd_ushort3 __x);
278static simd_short4 SIMD_CFUNC simd_short(simd_ushort4 __x);
279static simd_short8 SIMD_CFUNC simd_short(simd_ushort8 __x);
280static simd_short16 SIMD_CFUNC simd_short(simd_ushort16 __x);
281static simd_short32 SIMD_CFUNC simd_short(simd_ushort32 __x);
282static simd_short2 SIMD_CFUNC simd_short(simd_int2 __x);
283static simd_short3 SIMD_CFUNC simd_short(simd_int3 __x);
284static simd_short4 SIMD_CFUNC simd_short(simd_int4 __x);
285static simd_short8 SIMD_CFUNC simd_short(simd_int8 __x);
286static simd_short16 SIMD_CFUNC simd_short(simd_int16 __x);
287static simd_short2 SIMD_CFUNC simd_short(simd_uint2 __x);
288static simd_short3 SIMD_CFUNC simd_short(simd_uint3 __x);
289static simd_short4 SIMD_CFUNC simd_short(simd_uint4 __x);
290static simd_short8 SIMD_CFUNC simd_short(simd_uint8 __x);
291static simd_short16 SIMD_CFUNC simd_short(simd_uint16 __x);
292static simd_short2 SIMD_CFUNC simd_short(simd_float2 __x);
293static simd_short3 SIMD_CFUNC simd_short(simd_float3 __x);
294static simd_short4 SIMD_CFUNC simd_short(simd_float4 __x);
295static simd_short8 SIMD_CFUNC simd_short(simd_float8 __x);
296static simd_short16 SIMD_CFUNC simd_short(simd_float16 __x);
297static simd_short2 SIMD_CFUNC simd_short(simd_long2 __x);
298static simd_short3 SIMD_CFUNC simd_short(simd_long3 __x);
299static simd_short4 SIMD_CFUNC simd_short(simd_long4 __x);
300static simd_short8 SIMD_CFUNC simd_short(simd_long8 __x);
301static simd_short2 SIMD_CFUNC simd_short(simd_ulong2 __x);
302static simd_short3 SIMD_CFUNC simd_short(simd_ulong3 __x);
303static simd_short4 SIMD_CFUNC simd_short(simd_ulong4 __x);
304static simd_short8 SIMD_CFUNC simd_short(simd_ulong8 __x);
305static simd_short2 SIMD_CFUNC simd_short(simd_double2 __x);
306static simd_short3 SIMD_CFUNC simd_short(simd_double3 __x);
307static simd_short4 SIMD_CFUNC simd_short(simd_double4 __x);
308static simd_short8 SIMD_CFUNC simd_short(simd_double8 __x);
309static simd_short2 SIMD_CFUNC simd_short_sat(simd_char2 __x);
310static simd_short3 SIMD_CFUNC simd_short_sat(simd_char3 __x);
311static simd_short4 SIMD_CFUNC simd_short_sat(simd_char4 __x);
312static simd_short8 SIMD_CFUNC simd_short_sat(simd_char8 __x);
313static simd_short16 SIMD_CFUNC simd_short_sat(simd_char16 __x);
314static simd_short32 SIMD_CFUNC simd_short_sat(simd_char32 __x);
315static simd_short2 SIMD_CFUNC simd_short_sat(simd_short2 __x);
316static simd_short3 SIMD_CFUNC simd_short_sat(simd_short3 __x);
317static simd_short4 SIMD_CFUNC simd_short_sat(simd_short4 __x);
318static simd_short8 SIMD_CFUNC simd_short_sat(simd_short8 __x);
319static simd_short16 SIMD_CFUNC simd_short_sat(simd_short16 __x);
320static simd_short32 SIMD_CFUNC simd_short_sat(simd_short32 __x);
321static simd_short2 SIMD_CFUNC simd_short_sat(simd_int2 __x);
322static simd_short3 SIMD_CFUNC simd_short_sat(simd_int3 __x);
323static simd_short4 SIMD_CFUNC simd_short_sat(simd_int4 __x);
324static simd_short8 SIMD_CFUNC simd_short_sat(simd_int8 __x);
325static simd_short16 SIMD_CFUNC simd_short_sat(simd_int16 __x);
326static simd_short2 SIMD_CFUNC simd_short_sat(simd_float2 __x);
327static simd_short3 SIMD_CFUNC simd_short_sat(simd_float3 __x);
328static simd_short4 SIMD_CFUNC simd_short_sat(simd_float4 __x);
329static simd_short8 SIMD_CFUNC simd_short_sat(simd_float8 __x);
330static simd_short16 SIMD_CFUNC simd_short_sat(simd_float16 __x);
331static simd_short2 SIMD_CFUNC simd_short_sat(simd_long2 __x);
332static simd_short3 SIMD_CFUNC simd_short_sat(simd_long3 __x);
333static simd_short4 SIMD_CFUNC simd_short_sat(simd_long4 __x);
334static simd_short8 SIMD_CFUNC simd_short_sat(simd_long8 __x);
335static simd_short2 SIMD_CFUNC simd_short_sat(simd_double2 __x);
336static simd_short3 SIMD_CFUNC simd_short_sat(simd_double3 __x);
337static simd_short4 SIMD_CFUNC simd_short_sat(simd_double4 __x);
338static simd_short8 SIMD_CFUNC simd_short_sat(simd_double8 __x);
339static simd_short2 SIMD_CFUNC simd_short_sat(simd_uchar2 __x);
340static simd_short3 SIMD_CFUNC simd_short_sat(simd_uchar3 __x);
341static simd_short4 SIMD_CFUNC simd_short_sat(simd_uchar4 __x);
342static simd_short8 SIMD_CFUNC simd_short_sat(simd_uchar8 __x);
343static simd_short16 SIMD_CFUNC simd_short_sat(simd_uchar16 __x);
344static simd_short32 SIMD_CFUNC simd_short_sat(simd_uchar32 __x);
345static simd_short2 SIMD_CFUNC simd_short_sat(simd_ushort2 __x);
346static simd_short3 SIMD_CFUNC simd_short_sat(simd_ushort3 __x);
347static simd_short4 SIMD_CFUNC simd_short_sat(simd_ushort4 __x);
348static simd_short8 SIMD_CFUNC simd_short_sat(simd_ushort8 __x);
349static simd_short16 SIMD_CFUNC simd_short_sat(simd_ushort16 __x);
350static simd_short32 SIMD_CFUNC simd_short_sat(simd_ushort32 __x);
351static simd_short2 SIMD_CFUNC simd_short_sat(simd_uint2 __x);
352static simd_short3 SIMD_CFUNC simd_short_sat(simd_uint3 __x);
353static simd_short4 SIMD_CFUNC simd_short_sat(simd_uint4 __x);
354static simd_short8 SIMD_CFUNC simd_short_sat(simd_uint8 __x);
355static simd_short16 SIMD_CFUNC simd_short_sat(simd_uint16 __x);
356static simd_short2 SIMD_CFUNC simd_short_sat(simd_ulong2 __x);
357static simd_short3 SIMD_CFUNC simd_short_sat(simd_ulong3 __x);
358static simd_short4 SIMD_CFUNC simd_short_sat(simd_ulong4 __x);
359static simd_short8 SIMD_CFUNC simd_short_sat(simd_ulong8 __x);
360#define vector_short simd_short
361#define vector_short_sat simd_short_sat
362
363static simd_ushort2 SIMD_CFUNC simd_ushort(simd_char2 __x);
364static simd_ushort3 SIMD_CFUNC simd_ushort(simd_char3 __x);
365static simd_ushort4 SIMD_CFUNC simd_ushort(simd_char4 __x);
366static simd_ushort8 SIMD_CFUNC simd_ushort(simd_char8 __x);
367static simd_ushort16 SIMD_CFUNC simd_ushort(simd_char16 __x);
368static simd_ushort32 SIMD_CFUNC simd_ushort(simd_char32 __x);
369static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uchar2 __x);
370static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uchar3 __x);
371static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uchar4 __x);
372static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uchar8 __x);
373static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uchar16 __x);
374static simd_ushort32 SIMD_CFUNC simd_ushort(simd_uchar32 __x);
375static simd_ushort2 SIMD_CFUNC simd_ushort(simd_short2 __x);
376static simd_ushort3 SIMD_CFUNC simd_ushort(simd_short3 __x);
377static simd_ushort4 SIMD_CFUNC simd_ushort(simd_short4 __x);
378static simd_ushort8 SIMD_CFUNC simd_ushort(simd_short8 __x);
379static simd_ushort16 SIMD_CFUNC simd_ushort(simd_short16 __x);
380static simd_ushort32 SIMD_CFUNC simd_ushort(simd_short32 __x);
381static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ushort2 __x);
382static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ushort3 __x);
383static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ushort4 __x);
384static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ushort8 __x);
385static simd_ushort16 SIMD_CFUNC simd_ushort(simd_ushort16 __x);
386static simd_ushort32 SIMD_CFUNC simd_ushort(simd_ushort32 __x);
387static simd_ushort2 SIMD_CFUNC simd_ushort(simd_int2 __x);
388static simd_ushort3 SIMD_CFUNC simd_ushort(simd_int3 __x);
389static simd_ushort4 SIMD_CFUNC simd_ushort(simd_int4 __x);
390static simd_ushort8 SIMD_CFUNC simd_ushort(simd_int8 __x);
391static simd_ushort16 SIMD_CFUNC simd_ushort(simd_int16 __x);
392static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uint2 __x);
393static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uint3 __x);
394static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uint4 __x);
395static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uint8 __x);
396static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uint16 __x);
397static simd_ushort2 SIMD_CFUNC simd_ushort(simd_float2 __x);
398static simd_ushort3 SIMD_CFUNC simd_ushort(simd_float3 __x);
399static simd_ushort4 SIMD_CFUNC simd_ushort(simd_float4 __x);
400static simd_ushort8 SIMD_CFUNC simd_ushort(simd_float8 __x);
401static simd_ushort16 SIMD_CFUNC simd_ushort(simd_float16 __x);
402static simd_ushort2 SIMD_CFUNC simd_ushort(simd_long2 __x);
403static simd_ushort3 SIMD_CFUNC simd_ushort(simd_long3 __x);
404static simd_ushort4 SIMD_CFUNC simd_ushort(simd_long4 __x);
405static simd_ushort8 SIMD_CFUNC simd_ushort(simd_long8 __x);
406static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ulong2 __x);
407static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ulong3 __x);
408static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ulong4 __x);
409static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ulong8 __x);
410static simd_ushort2 SIMD_CFUNC simd_ushort(simd_double2 __x);
411static simd_ushort3 SIMD_CFUNC simd_ushort(simd_double3 __x);
412static simd_ushort4 SIMD_CFUNC simd_ushort(simd_double4 __x);
413static simd_ushort8 SIMD_CFUNC simd_ushort(simd_double8 __x);
414static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_char2 __x);
415static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_char3 __x);
416static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_char4 __x);
417static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_char8 __x);
418static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_char16 __x);
419static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_char32 __x);
420static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_short2 __x);
421static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_short3 __x);
422static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_short4 __x);
423static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_short8 __x);
424static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_short16 __x);
425static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_short32 __x);
426static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_int2 __x);
427static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_int3 __x);
428static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_int4 __x);
429static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_int8 __x);
430static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_int16 __x);
431static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_float2 __x);
432static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_float3 __x);
433static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_float4 __x);
434static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_float8 __x);
435static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_float16 __x);
436static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_long2 __x);
437static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_long3 __x);
438static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_long4 __x);
439static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_long8 __x);
440static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_double2 __x);
441static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_double3 __x);
442static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_double4 __x);
443static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_double8 __x);
444static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uchar2 __x);
445static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uchar3 __x);
446static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uchar4 __x);
447static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uchar8 __x);
448static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uchar16 __x);
449static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_uchar32 __x);
450static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ushort2 __x);
451static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ushort3 __x);
452static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ushort4 __x);
453static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ushort8 __x);
454static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_ushort16 __x);
455static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_ushort32 __x);
456static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uint2 __x);
457static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uint3 __x);
458static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uint4 __x);
459static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uint8 __x);
460static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uint16 __x);
461static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ulong2 __x);
462static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ulong3 __x);
463static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ulong4 __x);
464static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ulong8 __x);
465#define vector_ushort simd_ushort
466#define vector_ushort_sat simd_ushort_sat
467
468static simd_int2 SIMD_CFUNC simd_int(simd_char2 __x);
469static simd_int3 SIMD_CFUNC simd_int(simd_char3 __x);
470static simd_int4 SIMD_CFUNC simd_int(simd_char4 __x);
471static simd_int8 SIMD_CFUNC simd_int(simd_char8 __x);
472static simd_int16 SIMD_CFUNC simd_int(simd_char16 __x);
473static simd_int2 SIMD_CFUNC simd_int(simd_uchar2 __x);
474static simd_int3 SIMD_CFUNC simd_int(simd_uchar3 __x);
475static simd_int4 SIMD_CFUNC simd_int(simd_uchar4 __x);
476static simd_int8 SIMD_CFUNC simd_int(simd_uchar8 __x);
477static simd_int16 SIMD_CFUNC simd_int(simd_uchar16 __x);
478static simd_int2 SIMD_CFUNC simd_int(simd_short2 __x);
479static simd_int3 SIMD_CFUNC simd_int(simd_short3 __x);
480static simd_int4 SIMD_CFUNC simd_int(simd_short4 __x);
481static simd_int8 SIMD_CFUNC simd_int(simd_short8 __x);
482static simd_int16 SIMD_CFUNC simd_int(simd_short16 __x);
483static simd_int2 SIMD_CFUNC simd_int(simd_ushort2 __x);
484static simd_int3 SIMD_CFUNC simd_int(simd_ushort3 __x);
485static simd_int4 SIMD_CFUNC simd_int(simd_ushort4 __x);
486static simd_int8 SIMD_CFUNC simd_int(simd_ushort8 __x);
487static simd_int16 SIMD_CFUNC simd_int(simd_ushort16 __x);
488static simd_int2 SIMD_CFUNC simd_int(simd_int2 __x);
489static simd_int3 SIMD_CFUNC simd_int(simd_int3 __x);
490static simd_int4 SIMD_CFUNC simd_int(simd_int4 __x);
491static simd_int8 SIMD_CFUNC simd_int(simd_int8 __x);
492static simd_int16 SIMD_CFUNC simd_int(simd_int16 __x);
493static simd_int2 SIMD_CFUNC simd_int(simd_uint2 __x);
494static simd_int3 SIMD_CFUNC simd_int(simd_uint3 __x);
495static simd_int4 SIMD_CFUNC simd_int(simd_uint4 __x);
496static simd_int8 SIMD_CFUNC simd_int(simd_uint8 __x);
497static simd_int16 SIMD_CFUNC simd_int(simd_uint16 __x);
498static simd_int2 SIMD_CFUNC simd_int(simd_float2 __x);
499static simd_int3 SIMD_CFUNC simd_int(simd_float3 __x);
500static simd_int4 SIMD_CFUNC simd_int(simd_float4 __x);
501static simd_int8 SIMD_CFUNC simd_int(simd_float8 __x);
502static simd_int16 SIMD_CFUNC simd_int(simd_float16 __x);
503static simd_int2 SIMD_CFUNC simd_int(simd_long2 __x);
504static simd_int3 SIMD_CFUNC simd_int(simd_long3 __x);
505static simd_int4 SIMD_CFUNC simd_int(simd_long4 __x);
506static simd_int8 SIMD_CFUNC simd_int(simd_long8 __x);
507static simd_int2 SIMD_CFUNC simd_int(simd_ulong2 __x);
508static simd_int3 SIMD_CFUNC simd_int(simd_ulong3 __x);
509static simd_int4 SIMD_CFUNC simd_int(simd_ulong4 __x);
510static simd_int8 SIMD_CFUNC simd_int(simd_ulong8 __x);
511static simd_int2 SIMD_CFUNC simd_int(simd_double2 __x);
512static simd_int3 SIMD_CFUNC simd_int(simd_double3 __x);
513static simd_int4 SIMD_CFUNC simd_int(simd_double4 __x);
514static simd_int8 SIMD_CFUNC simd_int(simd_double8 __x);
515static simd_int2 SIMD_CFUNC simd_int_sat(simd_char2 __x);
516static simd_int3 SIMD_CFUNC simd_int_sat(simd_char3 __x);
517static simd_int4 SIMD_CFUNC simd_int_sat(simd_char4 __x);
518static simd_int8 SIMD_CFUNC simd_int_sat(simd_char8 __x);
519static simd_int16 SIMD_CFUNC simd_int_sat(simd_char16 __x);
520static simd_int2 SIMD_CFUNC simd_int_sat(simd_short2 __x);
521static simd_int3 SIMD_CFUNC simd_int_sat(simd_short3 __x);
522static simd_int4 SIMD_CFUNC simd_int_sat(simd_short4 __x);
523static simd_int8 SIMD_CFUNC simd_int_sat(simd_short8 __x);
524static simd_int16 SIMD_CFUNC simd_int_sat(simd_short16 __x);
525static simd_int2 SIMD_CFUNC simd_int_sat(simd_int2 __x);
526static simd_int3 SIMD_CFUNC simd_int_sat(simd_int3 __x);
527static simd_int4 SIMD_CFUNC simd_int_sat(simd_int4 __x);
528static simd_int8 SIMD_CFUNC simd_int_sat(simd_int8 __x);
529static simd_int16 SIMD_CFUNC simd_int_sat(simd_int16 __x);
530static simd_int2 SIMD_CFUNC simd_int_sat(simd_float2 __x);
531static simd_int3 SIMD_CFUNC simd_int_sat(simd_float3 __x);
532static simd_int4 SIMD_CFUNC simd_int_sat(simd_float4 __x);
533static simd_int8 SIMD_CFUNC simd_int_sat(simd_float8 __x);
534static simd_int16 SIMD_CFUNC simd_int_sat(simd_float16 __x);
535static simd_int2 SIMD_CFUNC simd_int_sat(simd_long2 __x);
536static simd_int3 SIMD_CFUNC simd_int_sat(simd_long3 __x);
537static simd_int4 SIMD_CFUNC simd_int_sat(simd_long4 __x);
538static simd_int8 SIMD_CFUNC simd_int_sat(simd_long8 __x);
539static simd_int2 SIMD_CFUNC simd_int_sat(simd_double2 __x);
540static simd_int3 SIMD_CFUNC simd_int_sat(simd_double3 __x);
541static simd_int4 SIMD_CFUNC simd_int_sat(simd_double4 __x);
542static simd_int8 SIMD_CFUNC simd_int_sat(simd_double8 __x);
543static simd_int2 SIMD_CFUNC simd_int_sat(simd_uchar2 __x);
544static simd_int3 SIMD_CFUNC simd_int_sat(simd_uchar3 __x);
545static simd_int4 SIMD_CFUNC simd_int_sat(simd_uchar4 __x);
546static simd_int8 SIMD_CFUNC simd_int_sat(simd_uchar8 __x);
547static simd_int16 SIMD_CFUNC simd_int_sat(simd_uchar16 __x);
548static simd_int2 SIMD_CFUNC simd_int_sat(simd_ushort2 __x);
549static simd_int3 SIMD_CFUNC simd_int_sat(simd_ushort3 __x);
550static simd_int4 SIMD_CFUNC simd_int_sat(simd_ushort4 __x);
551static simd_int8 SIMD_CFUNC simd_int_sat(simd_ushort8 __x);
552static simd_int16 SIMD_CFUNC simd_int_sat(simd_ushort16 __x);
553static simd_int2 SIMD_CFUNC simd_int_sat(simd_uint2 __x);
554static simd_int3 SIMD_CFUNC simd_int_sat(simd_uint3 __x);
555static simd_int4 SIMD_CFUNC simd_int_sat(simd_uint4 __x);
556static simd_int8 SIMD_CFUNC simd_int_sat(simd_uint8 __x);
557static simd_int16 SIMD_CFUNC simd_int_sat(simd_uint16 __x);
558static simd_int2 SIMD_CFUNC simd_int_sat(simd_ulong2 __x);
559static simd_int3 SIMD_CFUNC simd_int_sat(simd_ulong3 __x);
560static simd_int4 SIMD_CFUNC simd_int_sat(simd_ulong4 __x);
561static simd_int8 SIMD_CFUNC simd_int_sat(simd_ulong8 __x);
562static simd_int2 SIMD_CFUNC simd_int_rte(simd_float2 __x);
563static simd_int3 SIMD_CFUNC simd_int_rte(simd_float3 __x);
564static simd_int4 SIMD_CFUNC simd_int_rte(simd_float4 __x);
565static simd_int8 SIMD_CFUNC simd_int_rte(simd_float8 __x);
566static simd_int16 SIMD_CFUNC simd_int_rte(simd_float16 __x);
567#define vector_int simd_int
568#define vector_int_sat simd_int_sat
569
570static simd_uint2 SIMD_CFUNC simd_uint(simd_char2 __x);
571static simd_uint3 SIMD_CFUNC simd_uint(simd_char3 __x);
572static simd_uint4 SIMD_CFUNC simd_uint(simd_char4 __x);
573static simd_uint8 SIMD_CFUNC simd_uint(simd_char8 __x);
574static simd_uint16 SIMD_CFUNC simd_uint(simd_char16 __x);
575static simd_uint2 SIMD_CFUNC simd_uint(simd_uchar2 __x);
576static simd_uint3 SIMD_CFUNC simd_uint(simd_uchar3 __x);
577static simd_uint4 SIMD_CFUNC simd_uint(simd_uchar4 __x);
578static simd_uint8 SIMD_CFUNC simd_uint(simd_uchar8 __x);
579static simd_uint16 SIMD_CFUNC simd_uint(simd_uchar16 __x);
580static simd_uint2 SIMD_CFUNC simd_uint(simd_short2 __x);
581static simd_uint3 SIMD_CFUNC simd_uint(simd_short3 __x);
582static simd_uint4 SIMD_CFUNC simd_uint(simd_short4 __x);
583static simd_uint8 SIMD_CFUNC simd_uint(simd_short8 __x);
584static simd_uint16 SIMD_CFUNC simd_uint(simd_short16 __x);
585static simd_uint2 SIMD_CFUNC simd_uint(simd_ushort2 __x);
586static simd_uint3 SIMD_CFUNC simd_uint(simd_ushort3 __x);
587static simd_uint4 SIMD_CFUNC simd_uint(simd_ushort4 __x);
588static simd_uint8 SIMD_CFUNC simd_uint(simd_ushort8 __x);
589static simd_uint16 SIMD_CFUNC simd_uint(simd_ushort16 __x);
590static simd_uint2 SIMD_CFUNC simd_uint(simd_int2 __x);
591static simd_uint3 SIMD_CFUNC simd_uint(simd_int3 __x);
592static simd_uint4 SIMD_CFUNC simd_uint(simd_int4 __x);
593static simd_uint8 SIMD_CFUNC simd_uint(simd_int8 __x);
594static simd_uint16 SIMD_CFUNC simd_uint(simd_int16 __x);
595static simd_uint2 SIMD_CFUNC simd_uint(simd_uint2 __x);
596static simd_uint3 SIMD_CFUNC simd_uint(simd_uint3 __x);
597static simd_uint4 SIMD_CFUNC simd_uint(simd_uint4 __x);
598static simd_uint8 SIMD_CFUNC simd_uint(simd_uint8 __x);
599static simd_uint16 SIMD_CFUNC simd_uint(simd_uint16 __x);
600static simd_uint2 SIMD_CFUNC simd_uint(simd_float2 __x);
601static simd_uint3 SIMD_CFUNC simd_uint(simd_float3 __x);
602static simd_uint4 SIMD_CFUNC simd_uint(simd_float4 __x);
603static simd_uint8 SIMD_CFUNC simd_uint(simd_float8 __x);
604static simd_uint16 SIMD_CFUNC simd_uint(simd_float16 __x);
605static simd_uint2 SIMD_CFUNC simd_uint(simd_long2 __x);
606static simd_uint3 SIMD_CFUNC simd_uint(simd_long3 __x);
607static simd_uint4 SIMD_CFUNC simd_uint(simd_long4 __x);
608static simd_uint8 SIMD_CFUNC simd_uint(simd_long8 __x);
609static simd_uint2 SIMD_CFUNC simd_uint(simd_ulong2 __x);
610static simd_uint3 SIMD_CFUNC simd_uint(simd_ulong3 __x);
611static simd_uint4 SIMD_CFUNC simd_uint(simd_ulong4 __x);
612static simd_uint8 SIMD_CFUNC simd_uint(simd_ulong8 __x);
613static simd_uint2 SIMD_CFUNC simd_uint(simd_double2 __x);
614static simd_uint3 SIMD_CFUNC simd_uint(simd_double3 __x);
615static simd_uint4 SIMD_CFUNC simd_uint(simd_double4 __x);
616static simd_uint8 SIMD_CFUNC simd_uint(simd_double8 __x);
617static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_char2 __x);
618static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_char3 __x);
619static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_char4 __x);
620static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_char8 __x);
621static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_char16 __x);
622static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_short2 __x);
623static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_short3 __x);
624static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_short4 __x);
625static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_short8 __x);
626static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_short16 __x);
627static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_int2 __x);
628static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_int3 __x);
629static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_int4 __x);
630static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_int8 __x);
631static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_int16 __x);
632static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_float2 __x);
633static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_float3 __x);
634static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_float4 __x);
635static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_float8 __x);
636static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_float16 __x);
637static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_long2 __x);
638static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_long3 __x);
639static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_long4 __x);
640static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_long8 __x);
641static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_double2 __x);
642static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_double3 __x);
643static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_double4 __x);
644static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_double8 __x);
645static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uchar2 __x);
646static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uchar3 __x);
647static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uchar4 __x);
648static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uchar8 __x);
649static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uchar16 __x);
650static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ushort2 __x);
651static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ushort3 __x);
652static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ushort4 __x);
653static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ushort8 __x);
654static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_ushort16 __x);
655static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uint2 __x);
656static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uint3 __x);
657static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uint4 __x);
658static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uint8 __x);
659static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uint16 __x);
660static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ulong2 __x);
661static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ulong3 __x);
662static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ulong4 __x);
663static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ulong8 __x);
664#define vector_uint simd_uint
665#define vector_uint_sat simd_uint_sat
666
667static simd_float2 SIMD_CFUNC simd_float(simd_char2 __x);
668static simd_float3 SIMD_CFUNC simd_float(simd_char3 __x);
669static simd_float4 SIMD_CFUNC simd_float(simd_char4 __x);
670static simd_float8 SIMD_CFUNC simd_float(simd_char8 __x);
671static simd_float16 SIMD_CFUNC simd_float(simd_char16 __x);
672static simd_float2 SIMD_CFUNC simd_float(simd_uchar2 __x);
673static simd_float3 SIMD_CFUNC simd_float(simd_uchar3 __x);
674static simd_float4 SIMD_CFUNC simd_float(simd_uchar4 __x);
675static simd_float8 SIMD_CFUNC simd_float(simd_uchar8 __x);
676static simd_float16 SIMD_CFUNC simd_float(simd_uchar16 __x);
677static simd_float2 SIMD_CFUNC simd_float(simd_short2 __x);
678static simd_float3 SIMD_CFUNC simd_float(simd_short3 __x);
679static simd_float4 SIMD_CFUNC simd_float(simd_short4 __x);
680static simd_float8 SIMD_CFUNC simd_float(simd_short8 __x);
681static simd_float16 SIMD_CFUNC simd_float(simd_short16 __x);
682static simd_float2 SIMD_CFUNC simd_float(simd_ushort2 __x);
683static simd_float3 SIMD_CFUNC simd_float(simd_ushort3 __x);
684static simd_float4 SIMD_CFUNC simd_float(simd_ushort4 __x);
685static simd_float8 SIMD_CFUNC simd_float(simd_ushort8 __x);
686static simd_float16 SIMD_CFUNC simd_float(simd_ushort16 __x);
687static simd_float2 SIMD_CFUNC simd_float(simd_int2 __x);
688static simd_float3 SIMD_CFUNC simd_float(simd_int3 __x);
689static simd_float4 SIMD_CFUNC simd_float(simd_int4 __x);
690static simd_float8 SIMD_CFUNC simd_float(simd_int8 __x);
691static simd_float16 SIMD_CFUNC simd_float(simd_int16 __x);
692static simd_float2 SIMD_CFUNC simd_float(simd_uint2 __x);
693static simd_float3 SIMD_CFUNC simd_float(simd_uint3 __x);
694static simd_float4 SIMD_CFUNC simd_float(simd_uint4 __x);
695static simd_float8 SIMD_CFUNC simd_float(simd_uint8 __x);
696static simd_float16 SIMD_CFUNC simd_float(simd_uint16 __x);
697static simd_float2 SIMD_CFUNC simd_float(simd_float2 __x);
698static simd_float3 SIMD_CFUNC simd_float(simd_float3 __x);
699static simd_float4 SIMD_CFUNC simd_float(simd_float4 __x);
700static simd_float8 SIMD_CFUNC simd_float(simd_float8 __x);
701static simd_float16 SIMD_CFUNC simd_float(simd_float16 __x);
702static simd_float2 SIMD_CFUNC simd_float(simd_long2 __x);
703static simd_float3 SIMD_CFUNC simd_float(simd_long3 __x);
704static simd_float4 SIMD_CFUNC simd_float(simd_long4 __x);
705static simd_float8 SIMD_CFUNC simd_float(simd_long8 __x);
706static simd_float2 SIMD_CFUNC simd_float(simd_ulong2 __x);
707static simd_float3 SIMD_CFUNC simd_float(simd_ulong3 __x);
708static simd_float4 SIMD_CFUNC simd_float(simd_ulong4 __x);
709static simd_float8 SIMD_CFUNC simd_float(simd_ulong8 __x);
710static simd_float2 SIMD_CFUNC simd_float(simd_double2 __x);
711static simd_float3 SIMD_CFUNC simd_float(simd_double3 __x);
712static simd_float4 SIMD_CFUNC simd_float(simd_double4 __x);
713static simd_float8 SIMD_CFUNC simd_float(simd_double8 __x);
714#define vector_float simd_float
715
716static simd_long2 SIMD_CFUNC simd_long(simd_char2 __x);
717static simd_long3 SIMD_CFUNC simd_long(simd_char3 __x);
718static simd_long4 SIMD_CFUNC simd_long(simd_char4 __x);
719static simd_long8 SIMD_CFUNC simd_long(simd_char8 __x);
720static simd_long2 SIMD_CFUNC simd_long(simd_uchar2 __x);
721static simd_long3 SIMD_CFUNC simd_long(simd_uchar3 __x);
722static simd_long4 SIMD_CFUNC simd_long(simd_uchar4 __x);
723static simd_long8 SIMD_CFUNC simd_long(simd_uchar8 __x);
724static simd_long2 SIMD_CFUNC simd_long(simd_short2 __x);
725static simd_long3 SIMD_CFUNC simd_long(simd_short3 __x);
726static simd_long4 SIMD_CFUNC simd_long(simd_short4 __x);
727static simd_long8 SIMD_CFUNC simd_long(simd_short8 __x);
728static simd_long2 SIMD_CFUNC simd_long(simd_ushort2 __x);
729static simd_long3 SIMD_CFUNC simd_long(simd_ushort3 __x);
730static simd_long4 SIMD_CFUNC simd_long(simd_ushort4 __x);
731static simd_long8 SIMD_CFUNC simd_long(simd_ushort8 __x);
732static simd_long2 SIMD_CFUNC simd_long(simd_int2 __x);
733static simd_long3 SIMD_CFUNC simd_long(simd_int3 __x);
734static simd_long4 SIMD_CFUNC simd_long(simd_int4 __x);
735static simd_long8 SIMD_CFUNC simd_long(simd_int8 __x);
736static simd_long2 SIMD_CFUNC simd_long(simd_uint2 __x);
737static simd_long3 SIMD_CFUNC simd_long(simd_uint3 __x);
738static simd_long4 SIMD_CFUNC simd_long(simd_uint4 __x);
739static simd_long8 SIMD_CFUNC simd_long(simd_uint8 __x);
740static simd_long2 SIMD_CFUNC simd_long(simd_float2 __x);
741static simd_long3 SIMD_CFUNC simd_long(simd_float3 __x);
742static simd_long4 SIMD_CFUNC simd_long(simd_float4 __x);
743static simd_long8 SIMD_CFUNC simd_long(simd_float8 __x);
744static simd_long2 SIMD_CFUNC simd_long(simd_long2 __x);
745static simd_long3 SIMD_CFUNC simd_long(simd_long3 __x);
746static simd_long4 SIMD_CFUNC simd_long(simd_long4 __x);
747static simd_long8 SIMD_CFUNC simd_long(simd_long8 __x);
748static simd_long2 SIMD_CFUNC simd_long(simd_ulong2 __x);
749static simd_long3 SIMD_CFUNC simd_long(simd_ulong3 __x);
750static simd_long4 SIMD_CFUNC simd_long(simd_ulong4 __x);
751static simd_long8 SIMD_CFUNC simd_long(simd_ulong8 __x);
752static simd_long2 SIMD_CFUNC simd_long(simd_double2 __x);
753static simd_long3 SIMD_CFUNC simd_long(simd_double3 __x);
754static simd_long4 SIMD_CFUNC simd_long(simd_double4 __x);
755static simd_long8 SIMD_CFUNC simd_long(simd_double8 __x);
756static simd_long2 SIMD_CFUNC simd_long_sat(simd_char2 __x);
757static simd_long3 SIMD_CFUNC simd_long_sat(simd_char3 __x);
758static simd_long4 SIMD_CFUNC simd_long_sat(simd_char4 __x);
759static simd_long8 SIMD_CFUNC simd_long_sat(simd_char8 __x);
760static simd_long2 SIMD_CFUNC simd_long_sat(simd_short2 __x);
761static simd_long3 SIMD_CFUNC simd_long_sat(simd_short3 __x);
762static simd_long4 SIMD_CFUNC simd_long_sat(simd_short4 __x);
763static simd_long8 SIMD_CFUNC simd_long_sat(simd_short8 __x);
764static simd_long2 SIMD_CFUNC simd_long_sat(simd_int2 __x);
765static simd_long3 SIMD_CFUNC simd_long_sat(simd_int3 __x);
766static simd_long4 SIMD_CFUNC simd_long_sat(simd_int4 __x);
767static simd_long8 SIMD_CFUNC simd_long_sat(simd_int8 __x);
768static simd_long2 SIMD_CFUNC simd_long_sat(simd_float2 __x);
769static simd_long3 SIMD_CFUNC simd_long_sat(simd_float3 __x);
770static simd_long4 SIMD_CFUNC simd_long_sat(simd_float4 __x);
771static simd_long8 SIMD_CFUNC simd_long_sat(simd_float8 __x);
772static simd_long2 SIMD_CFUNC simd_long_sat(simd_long2 __x);
773static simd_long3 SIMD_CFUNC simd_long_sat(simd_long3 __x);
774static simd_long4 SIMD_CFUNC simd_long_sat(simd_long4 __x);
775static simd_long8 SIMD_CFUNC simd_long_sat(simd_long8 __x);
776static simd_long2 SIMD_CFUNC simd_long_sat(simd_double2 __x);
777static simd_long3 SIMD_CFUNC simd_long_sat(simd_double3 __x);
778static simd_long4 SIMD_CFUNC simd_long_sat(simd_double4 __x);
779static simd_long8 SIMD_CFUNC simd_long_sat(simd_double8 __x);
780static simd_long2 SIMD_CFUNC simd_long_sat(simd_uchar2 __x);
781static simd_long3 SIMD_CFUNC simd_long_sat(simd_uchar3 __x);
782static simd_long4 SIMD_CFUNC simd_long_sat(simd_uchar4 __x);
783static simd_long8 SIMD_CFUNC simd_long_sat(simd_uchar8 __x);
784static simd_long2 SIMD_CFUNC simd_long_sat(simd_ushort2 __x);
785static simd_long3 SIMD_CFUNC simd_long_sat(simd_ushort3 __x);
786static simd_long4 SIMD_CFUNC simd_long_sat(simd_ushort4 __x);
787static simd_long8 SIMD_CFUNC simd_long_sat(simd_ushort8 __x);
788static simd_long2 SIMD_CFUNC simd_long_sat(simd_uint2 __x);
789static simd_long3 SIMD_CFUNC simd_long_sat(simd_uint3 __x);
790static simd_long4 SIMD_CFUNC simd_long_sat(simd_uint4 __x);
791static simd_long8 SIMD_CFUNC simd_long_sat(simd_uint8 __x);
792static simd_long2 SIMD_CFUNC simd_long_sat(simd_ulong2 __x);
793static simd_long3 SIMD_CFUNC simd_long_sat(simd_ulong3 __x);
794static simd_long4 SIMD_CFUNC simd_long_sat(simd_ulong4 __x);
795static simd_long8 SIMD_CFUNC simd_long_sat(simd_ulong8 __x);
796static simd_long2 SIMD_CFUNC simd_long_rte(simd_double2 __x);
797static simd_long3 SIMD_CFUNC simd_long_rte(simd_double3 __x);
798static simd_long4 SIMD_CFUNC simd_long_rte(simd_double4 __x);
799static simd_long8 SIMD_CFUNC simd_long_rte(simd_double8 __x);
800#define vector_long simd_long
801#define vector_long_sat simd_long_sat
802
803static simd_ulong2 SIMD_CFUNC simd_ulong(simd_char2 __x);
804static simd_ulong3 SIMD_CFUNC simd_ulong(simd_char3 __x);
805static simd_ulong4 SIMD_CFUNC simd_ulong(simd_char4 __x);
806static simd_ulong8 SIMD_CFUNC simd_ulong(simd_char8 __x);
807static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uchar2 __x);
808static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uchar3 __x);
809static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uchar4 __x);
810static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uchar8 __x);
811static simd_ulong2 SIMD_CFUNC simd_ulong(simd_short2 __x);
812static simd_ulong3 SIMD_CFUNC simd_ulong(simd_short3 __x);
813static simd_ulong4 SIMD_CFUNC simd_ulong(simd_short4 __x);
814static simd_ulong8 SIMD_CFUNC simd_ulong(simd_short8 __x);
815static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ushort2 __x);
816static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ushort3 __x);
817static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ushort4 __x);
818static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ushort8 __x);
819static simd_ulong2 SIMD_CFUNC simd_ulong(simd_int2 __x);
820static simd_ulong3 SIMD_CFUNC simd_ulong(simd_int3 __x);
821static simd_ulong4 SIMD_CFUNC simd_ulong(simd_int4 __x);
822static simd_ulong8 SIMD_CFUNC simd_ulong(simd_int8 __x);
823static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uint2 __x);
824static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uint3 __x);
825static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uint4 __x);
826static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uint8 __x);
827static simd_ulong2 SIMD_CFUNC simd_ulong(simd_float2 __x);
828static simd_ulong3 SIMD_CFUNC simd_ulong(simd_float3 __x);
829static simd_ulong4 SIMD_CFUNC simd_ulong(simd_float4 __x);
830static simd_ulong8 SIMD_CFUNC simd_ulong(simd_float8 __x);
831static simd_ulong2 SIMD_CFUNC simd_ulong(simd_long2 __x);
832static simd_ulong3 SIMD_CFUNC simd_ulong(simd_long3 __x);
833static simd_ulong4 SIMD_CFUNC simd_ulong(simd_long4 __x);
834static simd_ulong8 SIMD_CFUNC simd_ulong(simd_long8 __x);
835static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ulong2 __x);
836static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ulong3 __x);
837static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ulong4 __x);
838static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ulong8 __x);
839static simd_ulong2 SIMD_CFUNC simd_ulong(simd_double2 __x);
840static simd_ulong3 SIMD_CFUNC simd_ulong(simd_double3 __x);
841static simd_ulong4 SIMD_CFUNC simd_ulong(simd_double4 __x);
842static simd_ulong8 SIMD_CFUNC simd_ulong(simd_double8 __x);
843static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_char2 __x);
844static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_char3 __x);
845static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_char4 __x);
846static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_char8 __x);
847static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_short2 __x);
848static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_short3 __x);
849static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_short4 __x);
850static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_short8 __x);
851static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_int2 __x);
852static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_int3 __x);
853static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_int4 __x);
854static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_int8 __x);
855static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_float2 __x);
856static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_float3 __x);
857static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_float4 __x);
858static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_float8 __x);
859static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_long2 __x);
860static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_long3 __x);
861static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_long4 __x);
862static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_long8 __x);
863static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_double2 __x);
864static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_double3 __x);
865static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_double4 __x);
866static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_double8 __x);
867static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uchar2 __x);
868static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uchar3 __x);
869static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uchar4 __x);
870static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uchar8 __x);
871static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ushort2 __x);
872static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ushort3 __x);
873static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ushort4 __x);
874static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ushort8 __x);
875static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uint2 __x);
876static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uint3 __x);
877static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uint4 __x);
878static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uint8 __x);
879static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ulong2 __x);
880static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ulong3 __x);
881static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ulong4 __x);
882static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ulong8 __x);
883#define vector_ulong simd_ulong
884#define vector_ulong_sat simd_ulong_sat
885
886static simd_double2 SIMD_CFUNC simd_double(simd_char2 __x);
887static simd_double3 SIMD_CFUNC simd_double(simd_char3 __x);
888static simd_double4 SIMD_CFUNC simd_double(simd_char4 __x);
889static simd_double8 SIMD_CFUNC simd_double(simd_char8 __x);
890static simd_double2 SIMD_CFUNC simd_double(simd_uchar2 __x);
891static simd_double3 SIMD_CFUNC simd_double(simd_uchar3 __x);
892static simd_double4 SIMD_CFUNC simd_double(simd_uchar4 __x);
893static simd_double8 SIMD_CFUNC simd_double(simd_uchar8 __x);
894static simd_double2 SIMD_CFUNC simd_double(simd_short2 __x);
895static simd_double3 SIMD_CFUNC simd_double(simd_short3 __x);
896static simd_double4 SIMD_CFUNC simd_double(simd_short4 __x);
897static simd_double8 SIMD_CFUNC simd_double(simd_short8 __x);
898static simd_double2 SIMD_CFUNC simd_double(simd_ushort2 __x);
899static simd_double3 SIMD_CFUNC simd_double(simd_ushort3 __x);
900static simd_double4 SIMD_CFUNC simd_double(simd_ushort4 __x);
901static simd_double8 SIMD_CFUNC simd_double(simd_ushort8 __x);
902static simd_double2 SIMD_CFUNC simd_double(simd_int2 __x);
903static simd_double3 SIMD_CFUNC simd_double(simd_int3 __x);
904static simd_double4 SIMD_CFUNC simd_double(simd_int4 __x);
905static simd_double8 SIMD_CFUNC simd_double(simd_int8 __x);
906static simd_double2 SIMD_CFUNC simd_double(simd_uint2 __x);
907static simd_double3 SIMD_CFUNC simd_double(simd_uint3 __x);
908static simd_double4 SIMD_CFUNC simd_double(simd_uint4 __x);
909static simd_double8 SIMD_CFUNC simd_double(simd_uint8 __x);
910static simd_double2 SIMD_CFUNC simd_double(simd_float2 __x);
911static simd_double3 SIMD_CFUNC simd_double(simd_float3 __x);
912static simd_double4 SIMD_CFUNC simd_double(simd_float4 __x);
913static simd_double8 SIMD_CFUNC simd_double(simd_float8 __x);
914static simd_double2 SIMD_CFUNC simd_double(simd_long2 __x);
915static simd_double3 SIMD_CFUNC simd_double(simd_long3 __x);
916static simd_double4 SIMD_CFUNC simd_double(simd_long4 __x);
917static simd_double8 SIMD_CFUNC simd_double(simd_long8 __x);
918static simd_double2 SIMD_CFUNC simd_double(simd_ulong2 __x);
919static simd_double3 SIMD_CFUNC simd_double(simd_ulong3 __x);
920static simd_double4 SIMD_CFUNC simd_double(simd_ulong4 __x);
921static simd_double8 SIMD_CFUNC simd_double(simd_ulong8 __x);
922static simd_double2 SIMD_CFUNC simd_double(simd_double2 __x);
923static simd_double3 SIMD_CFUNC simd_double(simd_double3 __x);
924static simd_double4 SIMD_CFUNC simd_double(simd_double4 __x);
925static simd_double8 SIMD_CFUNC simd_double(simd_double8 __x);
926#define vector_double simd_double
927
928static simd_char2 SIMD_CFUNC vector2(char __x, char __y) { return ( simd_char2){__x, __y}; }
929static simd_uchar2 SIMD_CFUNC vector2(unsigned char __x, unsigned char __y) { return ( simd_uchar2){__x, __y}; }
930static simd_short2 SIMD_CFUNC vector2(short __x, short __y) { return ( simd_short2){__x, __y}; }
931static simd_ushort2 SIMD_CFUNC vector2(unsigned short __x, unsigned short __y) { return (simd_ushort2){__x, __y}; }
932static simd_int2 SIMD_CFUNC vector2(int __x, int __y) { return ( simd_int2){__x, __y}; }
933static simd_uint2 SIMD_CFUNC vector2(unsigned int __x, unsigned int __y) { return ( simd_uint2){__x, __y}; }
934static simd_float2 SIMD_CFUNC vector2(float __x, float __y) { return ( simd_float2){__x, __y}; }
935static simd_long2 SIMD_CFUNC vector2(simd_long1 __x, simd_long1 __y) { return ( simd_long2){__x, __y}; }
936static simd_ulong2 SIMD_CFUNC vector2(simd_ulong1 __x, simd_ulong1 __y) { return ( simd_ulong2){__x, __y}; }
937static simd_double2 SIMD_CFUNC vector2(double __x, double __y) { return (simd_double2){__x, __y}; }
938
939static simd_char3 SIMD_CFUNC vector3(char __x, char __y, char __z) { return ( simd_char3){__x, __y, __z}; }
940static simd_uchar3 SIMD_CFUNC vector3(unsigned char __x, unsigned char __y, unsigned char __z) { return ( simd_uchar3){__x, __y, __z}; }
941static simd_short3 SIMD_CFUNC vector3(short __x, short __y, short __z) { return ( simd_short3){__x, __y, __z}; }
942static simd_ushort3 SIMD_CFUNC vector3(unsigned short __x, unsigned short __y, unsigned short __z) { return (simd_ushort3){__x, __y, __z}; }
943static simd_int3 SIMD_CFUNC vector3(int __x, int __y, int __z) { return ( simd_int3){__x, __y, __z}; }
944static simd_uint3 SIMD_CFUNC vector3(unsigned int __x, unsigned int __y, unsigned int __z) { return ( simd_uint3){__x, __y, __z}; }
945static simd_float3 SIMD_CFUNC vector3(float __x, float __y, float __z) { return ( simd_float3){__x, __y, __z}; }
946static simd_long3 SIMD_CFUNC vector3(simd_long1 __x, simd_long1 __y, simd_long1 __z) { return ( simd_long3){__x, __y, __z}; }
947static simd_ulong3 SIMD_CFUNC vector3(simd_ulong1 __x, simd_ulong1 __y, simd_ulong1 __z) { return ( simd_ulong3){__x, __y, __z}; }
948static simd_double3 SIMD_CFUNC vector3(double __x, double __y, double __z) { return (simd_double3){__x, __y, __z}; }
949
950static simd_char3 SIMD_CFUNC vector3(simd_char2 __xy, char __z) { simd_char3 __r; __r.xy = __xy; __r.z = __z; return __r; }
951static simd_uchar3 SIMD_CFUNC vector3(simd_uchar2 __xy, unsigned char __z) { simd_uchar3 __r; __r.xy = __xy; __r.z = __z; return __r; }
952static simd_short3 SIMD_CFUNC vector3(simd_short2 __xy, short __z) { simd_short3 __r; __r.xy = __xy; __r.z = __z; return __r; }
953static simd_ushort3 SIMD_CFUNC vector3(simd_ushort2 __xy, unsigned short __z) { simd_ushort3 __r; __r.xy = __xy; __r.z = __z; return __r; }
954static simd_int3 SIMD_CFUNC vector3(simd_int2 __xy, int __z) { simd_int3 __r; __r.xy = __xy; __r.z = __z; return __r; }
955static simd_uint3 SIMD_CFUNC vector3(simd_uint2 __xy, unsigned int __z) { simd_uint3 __r; __r.xy = __xy; __r.z = __z; return __r; }
956static simd_float3 SIMD_CFUNC vector3(simd_float2 __xy, float __z) { simd_float3 __r; __r.xy = __xy; __r.z = __z; return __r; }
957static simd_long3 SIMD_CFUNC vector3(simd_long2 __xy, simd_long1 __z) { simd_long3 __r; __r.xy = __xy; __r.z = __z; return __r; }
958static simd_ulong3 SIMD_CFUNC vector3(simd_ulong2 __xy, simd_ulong1 __z) { simd_ulong3 __r; __r.xy = __xy; __r.z = __z; return __r; }
959static simd_double3 SIMD_CFUNC vector3(simd_double2 __xy, double __z) { simd_double3 __r; __r.xy = __xy; __r.z = __z; return __r; }
960
961static simd_char4 SIMD_CFUNC vector4(char __x, char __y, char __z, char __w) { return ( simd_char4){__x, __y, __z, __w}; }
962static simd_uchar4 SIMD_CFUNC vector4(unsigned char __x, unsigned char __y, unsigned char __z, unsigned char __w) { return ( simd_uchar4){__x, __y, __z, __w}; }
963static simd_short4 SIMD_CFUNC vector4(short __x, short __y, short __z, short __w) { return ( simd_short4){__x, __y, __z, __w}; }
964static simd_ushort4 SIMD_CFUNC vector4(unsigned short __x, unsigned short __y, unsigned short __z, unsigned short __w) { return (simd_ushort4){__x, __y, __z, __w}; }
965static simd_int4 SIMD_CFUNC vector4(int __x, int __y, int __z, int __w) { return ( simd_int4){__x, __y, __z, __w}; }
966static simd_uint4 SIMD_CFUNC vector4(unsigned int __x, unsigned int __y, unsigned int __z, unsigned int __w) { return ( simd_uint4){__x, __y, __z, __w}; }
967static simd_float4 SIMD_CFUNC vector4(float __x, float __y, float __z, float __w) { return ( simd_float4){__x, __y, __z, __w}; }
968static simd_long4 SIMD_CFUNC vector4(simd_long1 __x, simd_long1 __y, simd_long1 __z, simd_long1 __w) { return ( simd_long4){__x, __y, __z, __w}; }
969static simd_ulong4 SIMD_CFUNC vector4(simd_ulong1 __x, simd_ulong1 __y, simd_ulong1 __z, simd_ulong1 __w) { return ( simd_ulong4){__x, __y, __z, __w}; }
970static simd_double4 SIMD_CFUNC vector4(double __x, double __y, double __z, double __w) { return (simd_double4){__x, __y, __z, __w}; }
971
972static simd_char4 SIMD_CFUNC vector4(simd_char2 __xy, simd_char2 __zw) { simd_char4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
973static simd_uchar4 SIMD_CFUNC vector4(simd_uchar2 __xy, simd_uchar2 __zw) { simd_uchar4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
974static simd_short4 SIMD_CFUNC vector4(simd_short2 __xy, simd_short2 __zw) { simd_short4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
975static simd_ushort4 SIMD_CFUNC vector4(simd_ushort2 __xy, simd_ushort2 __zw) { simd_ushort4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
976static simd_int4 SIMD_CFUNC vector4(simd_int2 __xy, simd_int2 __zw) { simd_int4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
977static simd_uint4 SIMD_CFUNC vector4(simd_uint2 __xy, simd_uint2 __zw) { simd_uint4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
978static simd_float4 SIMD_CFUNC vector4(simd_float2 __xy, simd_float2 __zw) { simd_float4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
979static simd_long4 SIMD_CFUNC vector4(simd_long2 __xy, simd_long2 __zw) { simd_long4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
980static simd_ulong4 SIMD_CFUNC vector4(simd_ulong2 __xy, simd_ulong2 __zw) { simd_ulong4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
981static simd_double4 SIMD_CFUNC vector4(simd_double2 __xy, simd_double2 __zw) { simd_double4 __r; __r.xy = __xy; __r.zw = __zw; return __r; }
982
983static simd_char4 SIMD_CFUNC vector4(simd_char3 __xyz, char __w) { simd_char4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
984static simd_uchar4 SIMD_CFUNC vector4(simd_uchar3 __xyz, unsigned char __w) { simd_uchar4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
985static simd_short4 SIMD_CFUNC vector4(simd_short3 __xyz, short __w) { simd_short4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
986static simd_ushort4 SIMD_CFUNC vector4(simd_ushort3 __xyz, unsigned short __w) { simd_ushort4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
987static simd_int4 SIMD_CFUNC vector4(simd_int3 __xyz, int __w) { simd_int4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
988static simd_uint4 SIMD_CFUNC vector4(simd_uint3 __xyz, unsigned int __w) { simd_uint4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
989static simd_float4 SIMD_CFUNC vector4(simd_float3 __xyz, float __w) { simd_float4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
990static simd_long4 SIMD_CFUNC vector4(simd_long3 __xyz, simd_long1 __w) { simd_long4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
991static simd_ulong4 SIMD_CFUNC vector4(simd_ulong3 __xyz, simd_ulong1 __w) { simd_ulong4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
992static simd_double4 SIMD_CFUNC vector4(simd_double3 __xyz, double __w) { simd_double4 __r; __r.xyz = __xyz; __r.w = __w; return __r; }
993
994static simd_char8 SIMD_CFUNC vector8(simd_char4 __lo, simd_char4 __hi) { simd_char8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
995static simd_uchar8 SIMD_CFUNC vector8(simd_uchar4 __lo, simd_uchar4 __hi) { simd_uchar8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
996static simd_short8 SIMD_CFUNC vector8(simd_short4 __lo, simd_short4 __hi) { simd_short8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
997static simd_ushort8 SIMD_CFUNC vector8(simd_ushort4 __lo, simd_ushort4 __hi) { simd_ushort8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
998static simd_int8 SIMD_CFUNC vector8(simd_int4 __lo, simd_int4 __hi) { simd_int8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
999static simd_uint8 SIMD_CFUNC vector8(simd_uint4 __lo, simd_uint4 __hi) { simd_uint8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1000static simd_float8 SIMD_CFUNC vector8(simd_float4 __lo, simd_float4 __hi) { simd_float8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1001static simd_long8 SIMD_CFUNC vector8(simd_long4 __lo, simd_long4 __hi) { simd_long8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1002static simd_ulong8 SIMD_CFUNC vector8(simd_ulong4 __lo, simd_ulong4 __hi) { simd_ulong8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1003static simd_double8 SIMD_CFUNC vector8(simd_double4 __lo, simd_double4 __hi) { simd_double8 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1004
1005static simd_char16 SIMD_CFUNC vector16(simd_char8 __lo, simd_char8 __hi) { simd_char16 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1006static simd_uchar16 SIMD_CFUNC vector16(simd_uchar8 __lo, simd_uchar8 __hi) { simd_uchar16 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1007static simd_short16 SIMD_CFUNC vector16(simd_short8 __lo, simd_short8 __hi) { simd_short16 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1008static simd_ushort16 SIMD_CFUNC vector16(simd_ushort8 __lo, simd_ushort8 __hi) { simd_ushort16 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1009static simd_int16 SIMD_CFUNC vector16(simd_int8 __lo, simd_int8 __hi) { simd_int16 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1010static simd_uint16 SIMD_CFUNC vector16(simd_uint8 __lo, simd_uint8 __hi) { simd_uint16 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1011static simd_float16 SIMD_CFUNC vector16(simd_float8 __lo, simd_float8 __hi) { simd_float16 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1012
1013static simd_char32 SIMD_CFUNC vector32(simd_char16 __lo, simd_char16 __hi) { simd_char32 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1014static simd_uchar32 SIMD_CFUNC vector32(simd_uchar16 __lo, simd_uchar16 __hi) { simd_uchar32 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1015static simd_short32 SIMD_CFUNC vector32(simd_short16 __lo, simd_short16 __hi) { simd_short32 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1016static simd_ushort32 SIMD_CFUNC vector32(simd_ushort16 __lo, simd_ushort16 __hi) { simd_ushort32 __r; __r.lo = __lo; __r.hi = __hi; return __r; }
1017
1018#pragma mark - Implementation
1019
1020static simd_char2 SIMD_CFUNC simd_char(simd_char2 __x) { return __x; }
1021static simd_char3 SIMD_CFUNC simd_char(simd_char3 __x) { return __x; }
1022static simd_char4 SIMD_CFUNC simd_char(simd_char4 __x) { return __x; }
1023static simd_char8 SIMD_CFUNC simd_char(simd_char8 __x) { return __x; }
1024static simd_char16 SIMD_CFUNC simd_char(simd_char16 __x) { return __x; }
1025static simd_char32 SIMD_CFUNC simd_char(simd_char32 __x) { return __x; }
1026static simd_char2 SIMD_CFUNC simd_char(simd_uchar2 __x) { return (simd_char2)__x; }
1027static simd_char3 SIMD_CFUNC simd_char(simd_uchar3 __x) { return (simd_char3)__x; }
1028static simd_char4 SIMD_CFUNC simd_char(simd_uchar4 __x) { return (simd_char4)__x; }
1029static simd_char8 SIMD_CFUNC simd_char(simd_uchar8 __x) { return (simd_char8)__x; }
1030static simd_char16 SIMD_CFUNC simd_char(simd_uchar16 __x) { return (simd_char16)__x; }
1031static simd_char32 SIMD_CFUNC simd_char(simd_uchar32 __x) { return (simd_char32)__x; }
1032static simd_char2 SIMD_CFUNC simd_char(simd_short2 __x) { return __builtin_convertvector(__x & 0xff, simd_char2); }
1033static simd_char3 SIMD_CFUNC simd_char(simd_short3 __x) { return __builtin_convertvector(__x & 0xff, simd_char3); }
1034static simd_char4 SIMD_CFUNC simd_char(simd_short4 __x) { return __builtin_convertvector(__x & 0xff, simd_char4); }
1035static simd_char8 SIMD_CFUNC simd_char(simd_short8 __x) { return __builtin_convertvector(__x & 0xff, simd_char8); }
1036static simd_char16 SIMD_CFUNC simd_char(simd_short16 __x) { return __builtin_convertvector(__x & 0xff, simd_char16); }
1037static simd_char32 SIMD_CFUNC simd_char(simd_short32 __x) { return __builtin_convertvector(__x & 0xff, simd_char32); }
1038static simd_char2 SIMD_CFUNC simd_char(simd_ushort2 __x) { return simd_char(simd_short(__x)); }
1039static simd_char3 SIMD_CFUNC simd_char(simd_ushort3 __x) { return simd_char(simd_short(__x)); }
1040static simd_char4 SIMD_CFUNC simd_char(simd_ushort4 __x) { return simd_char(simd_short(__x)); }
1041static simd_char8 SIMD_CFUNC simd_char(simd_ushort8 __x) { return simd_char(simd_short(__x)); }
1042static simd_char16 SIMD_CFUNC simd_char(simd_ushort16 __x) { return simd_char(simd_short(__x)); }
1043static simd_char32 SIMD_CFUNC simd_char(simd_ushort32 __x) { return simd_char(simd_short(__x)); }
1044static simd_char2 SIMD_CFUNC simd_char(simd_int2 __x) { return simd_char(simd_short(__x)); }
1045static simd_char3 SIMD_CFUNC simd_char(simd_int3 __x) { return simd_char(simd_short(__x)); }
1046static simd_char4 SIMD_CFUNC simd_char(simd_int4 __x) { return simd_char(simd_short(__x)); }
1047static simd_char8 SIMD_CFUNC simd_char(simd_int8 __x) { return simd_char(simd_short(__x)); }
1048static simd_char16 SIMD_CFUNC simd_char(simd_int16 __x) { return simd_char(simd_short(__x)); }
1049static simd_char2 SIMD_CFUNC simd_char(simd_uint2 __x) { return simd_char(simd_short(__x)); }
1050static simd_char3 SIMD_CFUNC simd_char(simd_uint3 __x) { return simd_char(simd_short(__x)); }
1051static simd_char4 SIMD_CFUNC simd_char(simd_uint4 __x) { return simd_char(simd_short(__x)); }
1052static simd_char8 SIMD_CFUNC simd_char(simd_uint8 __x) { return simd_char(simd_short(__x)); }
1053static simd_char16 SIMD_CFUNC simd_char(simd_uint16 __x) { return simd_char(simd_short(__x)); }
1054static simd_char2 SIMD_CFUNC simd_char(simd_float2 __x) { return simd_char(simd_short(__x)); }
1055static simd_char3 SIMD_CFUNC simd_char(simd_float3 __x) { return simd_char(simd_short(__x)); }
1056static simd_char4 SIMD_CFUNC simd_char(simd_float4 __x) { return simd_char(simd_short(__x)); }
1057static simd_char8 SIMD_CFUNC simd_char(simd_float8 __x) { return simd_char(simd_short(__x)); }
1058static simd_char16 SIMD_CFUNC simd_char(simd_float16 __x) { return simd_char(simd_short(__x)); }
1059static simd_char2 SIMD_CFUNC simd_char(simd_long2 __x) { return simd_char(simd_short(__x)); }
1060static simd_char3 SIMD_CFUNC simd_char(simd_long3 __x) { return simd_char(simd_short(__x)); }
1061static simd_char4 SIMD_CFUNC simd_char(simd_long4 __x) { return simd_char(simd_short(__x)); }
1062static simd_char8 SIMD_CFUNC simd_char(simd_long8 __x) { return simd_char(simd_short(__x)); }
1063static simd_char2 SIMD_CFUNC simd_char(simd_ulong2 __x) { return simd_char(simd_short(__x)); }
1064static simd_char3 SIMD_CFUNC simd_char(simd_ulong3 __x) { return simd_char(simd_short(__x)); }
1065static simd_char4 SIMD_CFUNC simd_char(simd_ulong4 __x) { return simd_char(simd_short(__x)); }
1066static simd_char8 SIMD_CFUNC simd_char(simd_ulong8 __x) { return simd_char(simd_short(__x)); }
1067static simd_char2 SIMD_CFUNC simd_char(simd_double2 __x) { return simd_char(simd_short(__x)); }
1068static simd_char3 SIMD_CFUNC simd_char(simd_double3 __x) { return simd_char(simd_short(__x)); }
1069static simd_char4 SIMD_CFUNC simd_char(simd_double4 __x) { return simd_char(simd_short(__x)); }
1070static simd_char8 SIMD_CFUNC simd_char(simd_double8 __x) { return simd_char(simd_short(__x)); }
1071
1072static simd_char2 SIMD_CFUNC simd_char_sat(simd_char2 __x) { return __x; }
1073static simd_char3 SIMD_CFUNC simd_char_sat(simd_char3 __x) { return __x; }
1074static simd_char4 SIMD_CFUNC simd_char_sat(simd_char4 __x) { return __x; }
1075static simd_char8 SIMD_CFUNC simd_char_sat(simd_char8 __x) { return __x; }
1076static simd_char16 SIMD_CFUNC simd_char_sat(simd_char16 __x) { return __x; }
1077static simd_char32 SIMD_CFUNC simd_char_sat(simd_char32 __x) { return __x; }
1078static simd_char2 SIMD_CFUNC simd_char_sat(simd_short2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1079static simd_char3 SIMD_CFUNC simd_char_sat(simd_short3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1080static simd_char4 SIMD_CFUNC simd_char_sat(simd_short4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1081static simd_char8 SIMD_CFUNC simd_char_sat(simd_short8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1082static simd_char16 SIMD_CFUNC simd_char_sat(simd_short16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1083static simd_char32 SIMD_CFUNC simd_char_sat(simd_short32 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1084static simd_char2 SIMD_CFUNC simd_char_sat(simd_int2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1085static simd_char3 SIMD_CFUNC simd_char_sat(simd_int3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1086static simd_char4 SIMD_CFUNC simd_char_sat(simd_int4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1087static simd_char8 SIMD_CFUNC simd_char_sat(simd_int8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1088static simd_char16 SIMD_CFUNC simd_char_sat(simd_int16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1089static simd_char2 SIMD_CFUNC simd_char_sat(simd_float2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1090static simd_char3 SIMD_CFUNC simd_char_sat(simd_float3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1091static simd_char4 SIMD_CFUNC simd_char_sat(simd_float4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1092static simd_char8 SIMD_CFUNC simd_char_sat(simd_float8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1093static simd_char16 SIMD_CFUNC simd_char_sat(simd_float16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1094static simd_char2 SIMD_CFUNC simd_char_sat(simd_long2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1095static simd_char3 SIMD_CFUNC simd_char_sat(simd_long3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1096static simd_char4 SIMD_CFUNC simd_char_sat(simd_long4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1097static simd_char8 SIMD_CFUNC simd_char_sat(simd_long8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1098static simd_char2 SIMD_CFUNC simd_char_sat(simd_double2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1099static simd_char3 SIMD_CFUNC simd_char_sat(simd_double3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1100static simd_char4 SIMD_CFUNC simd_char_sat(simd_double4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1101static simd_char8 SIMD_CFUNC simd_char_sat(simd_double8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); }
1102static simd_char2 SIMD_CFUNC simd_char_sat(simd_uchar2 __x) { return simd_char(simd_min(__x,0x7f)); }
1103static simd_char3 SIMD_CFUNC simd_char_sat(simd_uchar3 __x) { return simd_char(simd_min(__x,0x7f)); }
1104static simd_char4 SIMD_CFUNC simd_char_sat(simd_uchar4 __x) { return simd_char(simd_min(__x,0x7f)); }
1105static simd_char8 SIMD_CFUNC simd_char_sat(simd_uchar8 __x) { return simd_char(simd_min(__x,0x7f)); }
1106static simd_char16 SIMD_CFUNC simd_char_sat(simd_uchar16 __x) { return simd_char(simd_min(__x,0x7f)); }
1107static simd_char32 SIMD_CFUNC simd_char_sat(simd_uchar32 __x) { return simd_char(simd_min(__x,0x7f)); }
1108static simd_char2 SIMD_CFUNC simd_char_sat(simd_ushort2 __x) { return simd_char(simd_min(__x,0x7f)); }
1109static simd_char3 SIMD_CFUNC simd_char_sat(simd_ushort3 __x) { return simd_char(simd_min(__x,0x7f)); }
1110static simd_char4 SIMD_CFUNC simd_char_sat(simd_ushort4 __x) { return simd_char(simd_min(__x,0x7f)); }
1111static simd_char8 SIMD_CFUNC simd_char_sat(simd_ushort8 __x) { return simd_char(simd_min(__x,0x7f)); }
1112static simd_char16 SIMD_CFUNC simd_char_sat(simd_ushort16 __x) { return simd_char(simd_min(__x,0x7f)); }
1113static simd_char32 SIMD_CFUNC simd_char_sat(simd_ushort32 __x) { return simd_char(simd_min(__x,0x7f)); }
1114static simd_char2 SIMD_CFUNC simd_char_sat(simd_uint2 __x) { return simd_char(simd_min(__x,0x7f)); }
1115static simd_char3 SIMD_CFUNC simd_char_sat(simd_uint3 __x) { return simd_char(simd_min(__x,0x7f)); }
1116static simd_char4 SIMD_CFUNC simd_char_sat(simd_uint4 __x) { return simd_char(simd_min(__x,0x7f)); }
1117static simd_char8 SIMD_CFUNC simd_char_sat(simd_uint8 __x) { return simd_char(simd_min(__x,0x7f)); }
1118static simd_char16 SIMD_CFUNC simd_char_sat(simd_uint16 __x) { return simd_char(simd_min(__x,0x7f)); }
1119static simd_char2 SIMD_CFUNC simd_char_sat(simd_ulong2 __x) { return simd_char(simd_min(__x,0x7f)); }
1120static simd_char3 SIMD_CFUNC simd_char_sat(simd_ulong3 __x) { return simd_char(simd_min(__x,0x7f)); }
1121static simd_char4 SIMD_CFUNC simd_char_sat(simd_ulong4 __x) { return simd_char(simd_min(__x,0x7f)); }
1122static simd_char8 SIMD_CFUNC simd_char_sat(simd_ulong8 __x) { return simd_char(simd_min(__x,0x7f)); }
1123
1124
1125static simd_uchar2 SIMD_CFUNC simd_uchar(simd_char2 __x) { return (simd_uchar2)__x; }
1126static simd_uchar3 SIMD_CFUNC simd_uchar(simd_char3 __x) { return (simd_uchar3)__x; }
1127static simd_uchar4 SIMD_CFUNC simd_uchar(simd_char4 __x) { return (simd_uchar4)__x; }
1128static simd_uchar8 SIMD_CFUNC simd_uchar(simd_char8 __x) { return (simd_uchar8)__x; }
1129static simd_uchar16 SIMD_CFUNC simd_uchar(simd_char16 __x) { return (simd_uchar16)__x; }
1130static simd_uchar32 SIMD_CFUNC simd_uchar(simd_char32 __x) { return (simd_uchar32)__x; }
1131static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uchar2 __x) { return __x; }
1132static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uchar3 __x) { return __x; }
1133static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uchar4 __x) { return __x; }
1134static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uchar8 __x) { return __x; }
1135static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uchar16 __x) { return __x; }
1136static simd_uchar32 SIMD_CFUNC simd_uchar(simd_uchar32 __x) { return __x; }
1137static simd_uchar2 SIMD_CFUNC simd_uchar(simd_short2 __x) { return simd_uchar(simd_char(__x)); }
1138static simd_uchar3 SIMD_CFUNC simd_uchar(simd_short3 __x) { return simd_uchar(simd_char(__x)); }
1139static simd_uchar4 SIMD_CFUNC simd_uchar(simd_short4 __x) { return simd_uchar(simd_char(__x)); }
1140static simd_uchar8 SIMD_CFUNC simd_uchar(simd_short8 __x) { return simd_uchar(simd_char(__x)); }
1141static simd_uchar16 SIMD_CFUNC simd_uchar(simd_short16 __x) { return simd_uchar(simd_char(__x)); }
1142static simd_uchar32 SIMD_CFUNC simd_uchar(simd_short32 __x) { return simd_uchar(simd_char(__x)); }
1143static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ushort2 __x) { return simd_uchar(simd_char(__x)); }
1144static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ushort3 __x) { return simd_uchar(simd_char(__x)); }
1145static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ushort4 __x) { return simd_uchar(simd_char(__x)); }
1146static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ushort8 __x) { return simd_uchar(simd_char(__x)); }
1147static simd_uchar16 SIMD_CFUNC simd_uchar(simd_ushort16 __x) { return simd_uchar(simd_char(__x)); }
1148static simd_uchar32 SIMD_CFUNC simd_uchar(simd_ushort32 __x) { return simd_uchar(simd_char(__x)); }
1149static simd_uchar2 SIMD_CFUNC simd_uchar(simd_int2 __x) { return simd_uchar(simd_char(__x)); }
1150static simd_uchar3 SIMD_CFUNC simd_uchar(simd_int3 __x) { return simd_uchar(simd_char(__x)); }
1151static simd_uchar4 SIMD_CFUNC simd_uchar(simd_int4 __x) { return simd_uchar(simd_char(__x)); }
1152static simd_uchar8 SIMD_CFUNC simd_uchar(simd_int8 __x) { return simd_uchar(simd_char(__x)); }
1153static simd_uchar16 SIMD_CFUNC simd_uchar(simd_int16 __x) { return simd_uchar(simd_char(__x)); }
1154static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uint2 __x) { return simd_uchar(simd_char(__x)); }
1155static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uint3 __x) { return simd_uchar(simd_char(__x)); }
1156static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uint4 __x) { return simd_uchar(simd_char(__x)); }
1157static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uint8 __x) { return simd_uchar(simd_char(__x)); }
1158static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uint16 __x) { return simd_uchar(simd_char(__x)); }
1159static simd_uchar2 SIMD_CFUNC simd_uchar(simd_float2 __x) { return simd_uchar(simd_char(__x)); }
1160static simd_uchar3 SIMD_CFUNC simd_uchar(simd_float3 __x) { return simd_uchar(simd_char(__x)); }
1161static simd_uchar4 SIMD_CFUNC simd_uchar(simd_float4 __x) { return simd_uchar(simd_char(__x)); }
1162static simd_uchar8 SIMD_CFUNC simd_uchar(simd_float8 __x) { return simd_uchar(simd_char(__x)); }
1163static simd_uchar16 SIMD_CFUNC simd_uchar(simd_float16 __x) { return simd_uchar(simd_char(__x)); }
1164static simd_uchar2 SIMD_CFUNC simd_uchar(simd_long2 __x) { return simd_uchar(simd_char(__x)); }
1165static simd_uchar3 SIMD_CFUNC simd_uchar(simd_long3 __x) { return simd_uchar(simd_char(__x)); }
1166static simd_uchar4 SIMD_CFUNC simd_uchar(simd_long4 __x) { return simd_uchar(simd_char(__x)); }
1167static simd_uchar8 SIMD_CFUNC simd_uchar(simd_long8 __x) { return simd_uchar(simd_char(__x)); }
1168static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ulong2 __x) { return simd_uchar(simd_char(__x)); }
1169static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ulong3 __x) { return simd_uchar(simd_char(__x)); }
1170static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ulong4 __x) { return simd_uchar(simd_char(__x)); }
1171static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ulong8 __x) { return simd_uchar(simd_char(__x)); }
1172static simd_uchar2 SIMD_CFUNC simd_uchar(simd_double2 __x) { return simd_uchar(simd_char(__x)); }
1173static simd_uchar3 SIMD_CFUNC simd_uchar(simd_double3 __x) { return simd_uchar(simd_char(__x)); }
1174static simd_uchar4 SIMD_CFUNC simd_uchar(simd_double4 __x) { return simd_uchar(simd_char(__x)); }
1175static simd_uchar8 SIMD_CFUNC simd_uchar(simd_double8 __x) { return simd_uchar(simd_char(__x)); }
1176
1177static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_char2 __x) { return simd_uchar(simd_max(0,__x)); }
1178static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_char3 __x) { return simd_uchar(simd_max(0,__x)); }
1179static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_char4 __x) { return simd_uchar(simd_max(0,__x)); }
1180static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_char8 __x) { return simd_uchar(simd_max(0,__x)); }
1181static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_char16 __x) { return simd_uchar(simd_max(0,__x)); }
1182static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_char32 __x) { return simd_uchar(simd_max(0,__x)); }
1183static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_short2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1184static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_short3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1185static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_short4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1186static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_short8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1187static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_short16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1188static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_short32 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1189static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_int2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1190static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_int3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1191static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_int4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1192static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_int8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1193static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_int16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1194static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_float2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1195static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_float3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1196static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_float4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1197static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_float8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1198static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_float16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1199static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_long2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1200static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_long3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1201static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_long4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1202static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_long8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1203static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_double2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1204static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_double3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1205static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_double4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1206static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_double8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); }
1207static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uchar2 __x) { return __x; }
1208static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uchar3 __x) { return __x; }
1209static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uchar4 __x) { return __x; }
1210static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uchar8 __x) { return __x; }
1211static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uchar16 __x) { return __x; }
1212static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_uchar32 __x) { return __x; }
1213static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ushort2 __x) { return simd_uchar(simd_min(__x,0xff)); }
1214static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ushort3 __x) { return simd_uchar(simd_min(__x,0xff)); }
1215static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ushort4 __x) { return simd_uchar(simd_min(__x,0xff)); }
1216static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ushort8 __x) { return simd_uchar(simd_min(__x,0xff)); }
1217static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_ushort16 __x) { return simd_uchar(simd_min(__x,0xff)); }
1218static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_ushort32 __x) { return simd_uchar(simd_min(__x,0xff)); }
1219static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uint2 __x) { return simd_uchar(simd_min(__x,0xff)); }
1220static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uint3 __x) { return simd_uchar(simd_min(__x,0xff)); }
1221static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uint4 __x) { return simd_uchar(simd_min(__x,0xff)); }
1222static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uint8 __x) { return simd_uchar(simd_min(__x,0xff)); }
1223static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uint16 __x) { return simd_uchar(simd_min(__x,0xff)); }
1224static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ulong2 __x) { return simd_uchar(simd_min(__x,0xff)); }
1225static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ulong3 __x) { return simd_uchar(simd_min(__x,0xff)); }
1226static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ulong4 __x) { return simd_uchar(simd_min(__x,0xff)); }
1227static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ulong8 __x) { return simd_uchar(simd_min(__x,0xff)); }
1228
1229
1230static simd_short2 SIMD_CFUNC simd_short(simd_char2 __x) { return __builtin_convertvector(__x, simd_short2); }
1231static simd_short3 SIMD_CFUNC simd_short(simd_char3 __x) { return __builtin_convertvector(__x, simd_short3); }
1232static simd_short4 SIMD_CFUNC simd_short(simd_char4 __x) { return __builtin_convertvector(__x, simd_short4); }
1233static simd_short8 SIMD_CFUNC simd_short(simd_char8 __x) { return __builtin_convertvector(__x, simd_short8); }
1234static simd_short16 SIMD_CFUNC simd_short(simd_char16 __x) { return __builtin_convertvector(__x, simd_short16); }
1235static simd_short32 SIMD_CFUNC simd_short(simd_char32 __x) { return __builtin_convertvector(__x, simd_short32); }
1236static simd_short2 SIMD_CFUNC simd_short(simd_uchar2 __x) { return __builtin_convertvector(__x, simd_short2); }
1237static simd_short3 SIMD_CFUNC simd_short(simd_uchar3 __x) { return __builtin_convertvector(__x, simd_short3); }
1238static simd_short4 SIMD_CFUNC simd_short(simd_uchar4 __x) { return __builtin_convertvector(__x, simd_short4); }
1239static simd_short8 SIMD_CFUNC simd_short(simd_uchar8 __x) { return __builtin_convertvector(__x, simd_short8); }
1240static simd_short16 SIMD_CFUNC simd_short(simd_uchar16 __x) { return __builtin_convertvector(__x, simd_short16); }
1241static simd_short32 SIMD_CFUNC simd_short(simd_uchar32 __x) { return __builtin_convertvector(__x, simd_short32); }
1242static simd_short2 SIMD_CFUNC simd_short(simd_short2 __x) { return __x; }
1243static simd_short3 SIMD_CFUNC simd_short(simd_short3 __x) { return __x; }
1244static simd_short4 SIMD_CFUNC simd_short(simd_short4 __x) { return __x; }
1245static simd_short8 SIMD_CFUNC simd_short(simd_short8 __x) { return __x; }
1246static simd_short16 SIMD_CFUNC simd_short(simd_short16 __x) { return __x; }
1247static simd_short32 SIMD_CFUNC simd_short(simd_short32 __x) { return __x; }
1248static simd_short2 SIMD_CFUNC simd_short(simd_ushort2 __x) { return (simd_short2)__x; }
1249static simd_short3 SIMD_CFUNC simd_short(simd_ushort3 __x) { return (simd_short3)__x; }
1250static simd_short4 SIMD_CFUNC simd_short(simd_ushort4 __x) { return (simd_short4)__x; }
1251static simd_short8 SIMD_CFUNC simd_short(simd_ushort8 __x) { return (simd_short8)__x; }
1252static simd_short16 SIMD_CFUNC simd_short(simd_ushort16 __x) { return (simd_short16)__x; }
1253static simd_short32 SIMD_CFUNC simd_short(simd_ushort32 __x) { return (simd_short32)__x; }
1254static simd_short2 SIMD_CFUNC simd_short(simd_int2 __x) { return __builtin_convertvector(__x & 0xffff, simd_short2); }
1255static simd_short3 SIMD_CFUNC simd_short(simd_int3 __x) { return __builtin_convertvector(__x & 0xffff, simd_short3); }
1256static simd_short4 SIMD_CFUNC simd_short(simd_int4 __x) { return __builtin_convertvector(__x & 0xffff, simd_short4); }
1257static simd_short8 SIMD_CFUNC simd_short(simd_int8 __x) { return __builtin_convertvector(__x & 0xffff, simd_short8); }
1258static simd_short16 SIMD_CFUNC simd_short(simd_int16 __x) { return __builtin_convertvector(__x & 0xffff, simd_short16); }
1259static simd_short2 SIMD_CFUNC simd_short(simd_uint2 __x) { return simd_short(simd_int(__x)); }
1260static simd_short3 SIMD_CFUNC simd_short(simd_uint3 __x) { return simd_short(simd_int(__x)); }
1261static simd_short4 SIMD_CFUNC simd_short(simd_uint4 __x) { return simd_short(simd_int(__x)); }
1262static simd_short8 SIMD_CFUNC simd_short(simd_uint8 __x) { return simd_short(simd_int(__x)); }
1263static simd_short16 SIMD_CFUNC simd_short(simd_uint16 __x) { return simd_short(simd_int(__x)); }
1264static simd_short2 SIMD_CFUNC simd_short(simd_float2 __x) { return simd_short(simd_int(__x)); }
1265static simd_short3 SIMD_CFUNC simd_short(simd_float3 __x) { return simd_short(simd_int(__x)); }
1266static simd_short4 SIMD_CFUNC simd_short(simd_float4 __x) { return simd_short(simd_int(__x)); }
1267static simd_short8 SIMD_CFUNC simd_short(simd_float8 __x) { return simd_short(simd_int(__x)); }
1268static simd_short16 SIMD_CFUNC simd_short(simd_float16 __x) { return simd_short(simd_int(__x)); }
1269static simd_short2 SIMD_CFUNC simd_short(simd_long2 __x) { return simd_short(simd_int(__x)); }
1270static simd_short3 SIMD_CFUNC simd_short(simd_long3 __x) { return simd_short(simd_int(__x)); }
1271static simd_short4 SIMD_CFUNC simd_short(simd_long4 __x) { return simd_short(simd_int(__x)); }
1272static simd_short8 SIMD_CFUNC simd_short(simd_long8 __x) { return simd_short(simd_int(__x)); }
1273static simd_short2 SIMD_CFUNC simd_short(simd_ulong2 __x) { return simd_short(simd_int(__x)); }
1274static simd_short3 SIMD_CFUNC simd_short(simd_ulong3 __x) { return simd_short(simd_int(__x)); }
1275static simd_short4 SIMD_CFUNC simd_short(simd_ulong4 __x) { return simd_short(simd_int(__x)); }
1276static simd_short8 SIMD_CFUNC simd_short(simd_ulong8 __x) { return simd_short(simd_int(__x)); }
1277static simd_short2 SIMD_CFUNC simd_short(simd_double2 __x) { return simd_short(simd_int(__x)); }
1278static simd_short3 SIMD_CFUNC simd_short(simd_double3 __x) { return simd_short(simd_int(__x)); }
1279static simd_short4 SIMD_CFUNC simd_short(simd_double4 __x) { return simd_short(simd_int(__x)); }
1280static simd_short8 SIMD_CFUNC simd_short(simd_double8 __x) { return simd_short(simd_int(__x)); }
1281
1282static simd_short2 SIMD_CFUNC simd_short_sat(simd_char2 __x) { return simd_short(__x); }
1283static simd_short3 SIMD_CFUNC simd_short_sat(simd_char3 __x) { return simd_short(__x); }
1284static simd_short4 SIMD_CFUNC simd_short_sat(simd_char4 __x) { return simd_short(__x); }
1285static simd_short8 SIMD_CFUNC simd_short_sat(simd_char8 __x) { return simd_short(__x); }
1286static simd_short16 SIMD_CFUNC simd_short_sat(simd_char16 __x) { return simd_short(__x); }
1287static simd_short32 SIMD_CFUNC simd_short_sat(simd_char32 __x) { return simd_short(__x); }
1288static simd_short2 SIMD_CFUNC simd_short_sat(simd_short2 __x) { return __x; }
1289static simd_short3 SIMD_CFUNC simd_short_sat(simd_short3 __x) { return __x; }
1290static simd_short4 SIMD_CFUNC simd_short_sat(simd_short4 __x) { return __x; }
1291static simd_short8 SIMD_CFUNC simd_short_sat(simd_short8 __x) { return __x; }
1292static simd_short16 SIMD_CFUNC simd_short_sat(simd_short16 __x) { return __x; }
1293static simd_short32 SIMD_CFUNC simd_short_sat(simd_short32 __x) { return __x; }
1294static simd_short2 SIMD_CFUNC simd_short_sat(simd_int2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1295static simd_short3 SIMD_CFUNC simd_short_sat(simd_int3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1296static simd_short4 SIMD_CFUNC simd_short_sat(simd_int4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1297static simd_short8 SIMD_CFUNC simd_short_sat(simd_int8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1298static simd_short16 SIMD_CFUNC simd_short_sat(simd_int16 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1299static simd_short2 SIMD_CFUNC simd_short_sat(simd_float2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1300static simd_short3 SIMD_CFUNC simd_short_sat(simd_float3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1301static simd_short4 SIMD_CFUNC simd_short_sat(simd_float4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1302static simd_short8 SIMD_CFUNC simd_short_sat(simd_float8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1303static simd_short16 SIMD_CFUNC simd_short_sat(simd_float16 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1304static simd_short2 SIMD_CFUNC simd_short_sat(simd_long2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1305static simd_short3 SIMD_CFUNC simd_short_sat(simd_long3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1306static simd_short4 SIMD_CFUNC simd_short_sat(simd_long4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1307static simd_short8 SIMD_CFUNC simd_short_sat(simd_long8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1308static simd_short2 SIMD_CFUNC simd_short_sat(simd_double2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1309static simd_short3 SIMD_CFUNC simd_short_sat(simd_double3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1310static simd_short4 SIMD_CFUNC simd_short_sat(simd_double4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1311static simd_short8 SIMD_CFUNC simd_short_sat(simd_double8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); }
1312static simd_short2 SIMD_CFUNC simd_short_sat(simd_uchar2 __x) { return simd_short(__x); }
1313static simd_short3 SIMD_CFUNC simd_short_sat(simd_uchar3 __x) { return simd_short(__x); }
1314static simd_short4 SIMD_CFUNC simd_short_sat(simd_uchar4 __x) { return simd_short(__x); }
1315static simd_short8 SIMD_CFUNC simd_short_sat(simd_uchar8 __x) { return simd_short(__x); }
1316static simd_short16 SIMD_CFUNC simd_short_sat(simd_uchar16 __x) { return simd_short(__x); }
1317static simd_short32 SIMD_CFUNC simd_short_sat(simd_uchar32 __x) { return simd_short(__x); }
1318static simd_short2 SIMD_CFUNC simd_short_sat(simd_ushort2 __x) { return simd_short(simd_min(__x,0x7fff)); }
1319static simd_short3 SIMD_CFUNC simd_short_sat(simd_ushort3 __x) { return simd_short(simd_min(__x,0x7fff)); }
1320static simd_short4 SIMD_CFUNC simd_short_sat(simd_ushort4 __x) { return simd_short(simd_min(__x,0x7fff)); }
1321static simd_short8 SIMD_CFUNC simd_short_sat(simd_ushort8 __x) { return simd_short(simd_min(__x,0x7fff)); }
1322static simd_short16 SIMD_CFUNC simd_short_sat(simd_ushort16 __x) { return simd_short(simd_min(__x,0x7fff)); }
1323static simd_short32 SIMD_CFUNC simd_short_sat(simd_ushort32 __x) { return simd_short(simd_min(__x,0x7fff)); }
1324static simd_short2 SIMD_CFUNC simd_short_sat(simd_uint2 __x) { return simd_short(simd_min(__x,0x7fff)); }
1325static simd_short3 SIMD_CFUNC simd_short_sat(simd_uint3 __x) { return simd_short(simd_min(__x,0x7fff)); }
1326static simd_short4 SIMD_CFUNC simd_short_sat(simd_uint4 __x) { return simd_short(simd_min(__x,0x7fff)); }
1327static simd_short8 SIMD_CFUNC simd_short_sat(simd_uint8 __x) { return simd_short(simd_min(__x,0x7fff)); }
1328static simd_short16 SIMD_CFUNC simd_short_sat(simd_uint16 __x) { return simd_short(simd_min(__x,0x7fff)); }
1329static simd_short2 SIMD_CFUNC simd_short_sat(simd_ulong2 __x) { return simd_short(simd_min(__x,0x7fff)); }
1330static simd_short3 SIMD_CFUNC simd_short_sat(simd_ulong3 __x) { return simd_short(simd_min(__x,0x7fff)); }
1331static simd_short4 SIMD_CFUNC simd_short_sat(simd_ulong4 __x) { return simd_short(simd_min(__x,0x7fff)); }
1332static simd_short8 SIMD_CFUNC simd_short_sat(simd_ulong8 __x) { return simd_short(simd_min(__x,0x7fff)); }
1333
1334
1335static simd_ushort2 SIMD_CFUNC simd_ushort(simd_char2 __x) { return simd_ushort(simd_short(__x)); }
1336static simd_ushort3 SIMD_CFUNC simd_ushort(simd_char3 __x) { return simd_ushort(simd_short(__x)); }
1337static simd_ushort4 SIMD_CFUNC simd_ushort(simd_char4 __x) { return simd_ushort(simd_short(__x)); }
1338static simd_ushort8 SIMD_CFUNC simd_ushort(simd_char8 __x) { return simd_ushort(simd_short(__x)); }
1339static simd_ushort16 SIMD_CFUNC simd_ushort(simd_char16 __x) { return simd_ushort(simd_short(__x)); }
1340static simd_ushort32 SIMD_CFUNC simd_ushort(simd_char32 __x) { return simd_ushort(simd_short(__x)); }
1341static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uchar2 __x) { return simd_ushort(simd_short(__x)); }
1342static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uchar3 __x) { return simd_ushort(simd_short(__x)); }
1343static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uchar4 __x) { return simd_ushort(simd_short(__x)); }
1344static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uchar8 __x) { return simd_ushort(simd_short(__x)); }
1345static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uchar16 __x) { return simd_ushort(simd_short(__x)); }
1346static simd_ushort32 SIMD_CFUNC simd_ushort(simd_uchar32 __x) { return simd_ushort(simd_short(__x)); }
1347static simd_ushort2 SIMD_CFUNC simd_ushort(simd_short2 __x) { return (simd_ushort2)__x; }
1348static simd_ushort3 SIMD_CFUNC simd_ushort(simd_short3 __x) { return (simd_ushort3)__x; }
1349static simd_ushort4 SIMD_CFUNC simd_ushort(simd_short4 __x) { return (simd_ushort4)__x; }
1350static simd_ushort8 SIMD_CFUNC simd_ushort(simd_short8 __x) { return (simd_ushort8)__x; }
1351static simd_ushort16 SIMD_CFUNC simd_ushort(simd_short16 __x) { return (simd_ushort16)__x; }
1352static simd_ushort32 SIMD_CFUNC simd_ushort(simd_short32 __x) { return (simd_ushort32)__x; }
1353static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ushort2 __x) { return __x; }
1354static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ushort3 __x) { return __x; }
1355static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ushort4 __x) { return __x; }
1356static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ushort8 __x) { return __x; }
1357static simd_ushort16 SIMD_CFUNC simd_ushort(simd_ushort16 __x) { return __x; }
1358static simd_ushort32 SIMD_CFUNC simd_ushort(simd_ushort32 __x) { return __x; }
1359static simd_ushort2 SIMD_CFUNC simd_ushort(simd_int2 __x) { return simd_ushort(simd_short(__x)); }
1360static simd_ushort3 SIMD_CFUNC simd_ushort(simd_int3 __x) { return simd_ushort(simd_short(__x)); }
1361static simd_ushort4 SIMD_CFUNC simd_ushort(simd_int4 __x) { return simd_ushort(simd_short(__x)); }
1362static simd_ushort8 SIMD_CFUNC simd_ushort(simd_int8 __x) { return simd_ushort(simd_short(__x)); }
1363static simd_ushort16 SIMD_CFUNC simd_ushort(simd_int16 __x) { return simd_ushort(simd_short(__x)); }
1364static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uint2 __x) { return simd_ushort(simd_short(__x)); }
1365static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uint3 __x) { return simd_ushort(simd_short(__x)); }
1366static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uint4 __x) { return simd_ushort(simd_short(__x)); }
1367static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uint8 __x) { return simd_ushort(simd_short(__x)); }
1368static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uint16 __x) { return simd_ushort(simd_short(__x)); }
1369static simd_ushort2 SIMD_CFUNC simd_ushort(simd_float2 __x) { return simd_ushort(simd_short(__x)); }
1370static simd_ushort3 SIMD_CFUNC simd_ushort(simd_float3 __x) { return simd_ushort(simd_short(__x)); }
1371static simd_ushort4 SIMD_CFUNC simd_ushort(simd_float4 __x) { return simd_ushort(simd_short(__x)); }
1372static simd_ushort8 SIMD_CFUNC simd_ushort(simd_float8 __x) { return simd_ushort(simd_short(__x)); }
1373static simd_ushort16 SIMD_CFUNC simd_ushort(simd_float16 __x) { return simd_ushort(simd_short(__x)); }
1374static simd_ushort2 SIMD_CFUNC simd_ushort(simd_long2 __x) { return simd_ushort(simd_short(__x)); }
1375static simd_ushort3 SIMD_CFUNC simd_ushort(simd_long3 __x) { return simd_ushort(simd_short(__x)); }
1376static simd_ushort4 SIMD_CFUNC simd_ushort(simd_long4 __x) { return simd_ushort(simd_short(__x)); }
1377static simd_ushort8 SIMD_CFUNC simd_ushort(simd_long8 __x) { return simd_ushort(simd_short(__x)); }
1378static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ulong2 __x) { return simd_ushort(simd_short(__x)); }
1379static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ulong3 __x) { return simd_ushort(simd_short(__x)); }
1380static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ulong4 __x) { return simd_ushort(simd_short(__x)); }
1381static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ulong8 __x) { return simd_ushort(simd_short(__x)); }
1382static simd_ushort2 SIMD_CFUNC simd_ushort(simd_double2 __x) { return simd_ushort(simd_short(__x)); }
1383static simd_ushort3 SIMD_CFUNC simd_ushort(simd_double3 __x) { return simd_ushort(simd_short(__x)); }
1384static simd_ushort4 SIMD_CFUNC simd_ushort(simd_double4 __x) { return simd_ushort(simd_short(__x)); }
1385static simd_ushort8 SIMD_CFUNC simd_ushort(simd_double8 __x) { return simd_ushort(simd_short(__x)); }
1386
1387static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_char2 __x) { return simd_ushort(simd_max(__x, 0)); }
1388static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_char3 __x) { return simd_ushort(simd_max(__x, 0)); }
1389static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_char4 __x) { return simd_ushort(simd_max(__x, 0)); }
1390static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_char8 __x) { return simd_ushort(simd_max(__x, 0)); }
1391static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_char16 __x) { return simd_ushort(simd_max(__x, 0)); }
1392static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_char32 __x) { return simd_ushort(simd_max(__x, 0)); }
1393static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_short2 __x) { return simd_ushort(simd_max(__x, 0)); }
1394static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_short3 __x) { return simd_ushort(simd_max(__x, 0)); }
1395static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_short4 __x) { return simd_ushort(simd_max(__x, 0)); }
1396static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_short8 __x) { return simd_ushort(simd_max(__x, 0)); }
1397static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_short16 __x) { return simd_ushort(simd_max(__x, 0)); }
1398static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_short32 __x) { return simd_ushort(simd_max(__x, 0)); }
1399static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_int2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1400static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_int3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1401static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_int4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1402static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_int8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1403static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_int16 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1404static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_float2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1405static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_float3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1406static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_float4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1407static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_float8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1408static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_float16 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1409static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_long2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1410static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_long3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1411static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_long4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1412static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_long8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1413static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_double2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1414static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_double3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1415static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_double4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1416static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_double8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); }
1417static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uchar2 __x) { return simd_ushort(__x); }
1418static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uchar3 __x) { return simd_ushort(__x); }
1419static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uchar4 __x) { return simd_ushort(__x); }
1420static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uchar8 __x) { return simd_ushort(__x); }
1421static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uchar16 __x) { return simd_ushort(__x); }
1422static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_uchar32 __x) { return simd_ushort(__x); }
1423static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ushort2 __x) { return __x; }
1424static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ushort3 __x) { return __x; }
1425static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ushort4 __x) { return __x; }
1426static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ushort8 __x) { return __x; }
1427static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_ushort16 __x) { return __x; }
1428static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_ushort32 __x) { return __x; }
1429static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uint2 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1430static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uint3 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1431static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uint4 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1432static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uint8 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1433static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uint16 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1434static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ulong2 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1435static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ulong3 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1436static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ulong4 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1437static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ulong8 __x) { return simd_ushort(simd_min(__x, 0xffff)); }
1438
1439
1440static simd_int2 SIMD_CFUNC simd_int(simd_char2 __x) { return __builtin_convertvector(__x, simd_int2); }
1441static simd_int3 SIMD_CFUNC simd_int(simd_char3 __x) { return __builtin_convertvector(__x, simd_int3); }
1442static simd_int4 SIMD_CFUNC simd_int(simd_char4 __x) { return __builtin_convertvector(__x, simd_int4); }
1443static simd_int8 SIMD_CFUNC simd_int(simd_char8 __x) { return __builtin_convertvector(__x, simd_int8); }
1444static simd_int16 SIMD_CFUNC simd_int(simd_char16 __x) { return __builtin_convertvector(__x, simd_int16); }
1445static simd_int2 SIMD_CFUNC simd_int(simd_uchar2 __x) { return __builtin_convertvector(__x, simd_int2); }
1446static simd_int3 SIMD_CFUNC simd_int(simd_uchar3 __x) { return __builtin_convertvector(__x, simd_int3); }
1447static simd_int4 SIMD_CFUNC simd_int(simd_uchar4 __x) { return __builtin_convertvector(__x, simd_int4); }
1448static simd_int8 SIMD_CFUNC simd_int(simd_uchar8 __x) { return __builtin_convertvector(__x, simd_int8); }
1449static simd_int16 SIMD_CFUNC simd_int(simd_uchar16 __x) { return __builtin_convertvector(__x, simd_int16); }
1450static simd_int2 SIMD_CFUNC simd_int(simd_short2 __x) { return __builtin_convertvector(__x, simd_int2); }
1451static simd_int3 SIMD_CFUNC simd_int(simd_short3 __x) { return __builtin_convertvector(__x, simd_int3); }
1452static simd_int4 SIMD_CFUNC simd_int(simd_short4 __x) { return __builtin_convertvector(__x, simd_int4); }
1453static simd_int8 SIMD_CFUNC simd_int(simd_short8 __x) { return __builtin_convertvector(__x, simd_int8); }
1454static simd_int16 SIMD_CFUNC simd_int(simd_short16 __x) { return __builtin_convertvector(__x, simd_int16); }
1455static simd_int2 SIMD_CFUNC simd_int(simd_ushort2 __x) { return __builtin_convertvector(__x, simd_int2); }
1456static simd_int3 SIMD_CFUNC simd_int(simd_ushort3 __x) { return __builtin_convertvector(__x, simd_int3); }
1457static simd_int4 SIMD_CFUNC simd_int(simd_ushort4 __x) { return __builtin_convertvector(__x, simd_int4); }
1458static simd_int8 SIMD_CFUNC simd_int(simd_ushort8 __x) { return __builtin_convertvector(__x, simd_int8); }
1459static simd_int16 SIMD_CFUNC simd_int(simd_ushort16 __x) { return __builtin_convertvector(__x, simd_int16); }
1460static simd_int2 SIMD_CFUNC simd_int(simd_int2 __x) { return __x; }
1461static simd_int3 SIMD_CFUNC simd_int(simd_int3 __x) { return __x; }
1462static simd_int4 SIMD_CFUNC simd_int(simd_int4 __x) { return __x; }
1463static simd_int8 SIMD_CFUNC simd_int(simd_int8 __x) { return __x; }
1464static simd_int16 SIMD_CFUNC simd_int(simd_int16 __x) { return __x; }
1465static simd_int2 SIMD_CFUNC simd_int(simd_uint2 __x) { return (simd_int2)__x; }
1466static simd_int3 SIMD_CFUNC simd_int(simd_uint3 __x) { return (simd_int3)__x; }
1467static simd_int4 SIMD_CFUNC simd_int(simd_uint4 __x) { return (simd_int4)__x; }
1468static simd_int8 SIMD_CFUNC simd_int(simd_uint8 __x) { return (simd_int8)__x; }
1469static simd_int16 SIMD_CFUNC simd_int(simd_uint16 __x) { return (simd_int16)__x; }
1470static simd_int2 SIMD_CFUNC simd_int(simd_float2 __x) { return __builtin_convertvector(__x, simd_int2); }
1471static simd_int3 SIMD_CFUNC simd_int(simd_float3 __x) { return __builtin_convertvector(__x, simd_int3); }
1472static simd_int4 SIMD_CFUNC simd_int(simd_float4 __x) { return __builtin_convertvector(__x, simd_int4); }
1473static simd_int8 SIMD_CFUNC simd_int(simd_float8 __x) { return __builtin_convertvector(__x, simd_int8); }
1474static simd_int16 SIMD_CFUNC simd_int(simd_float16 __x) { return __builtin_convertvector(__x, simd_int16); }
1475static simd_int2 SIMD_CFUNC simd_int(simd_long2 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int2); }
1476static simd_int3 SIMD_CFUNC simd_int(simd_long3 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int3); }
1477static simd_int4 SIMD_CFUNC simd_int(simd_long4 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int4); }
1478static simd_int8 SIMD_CFUNC simd_int(simd_long8 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int8); }
1479static simd_int2 SIMD_CFUNC simd_int(simd_ulong2 __x) { return simd_int(simd_long(__x)); }
1480static simd_int3 SIMD_CFUNC simd_int(simd_ulong3 __x) { return simd_int(simd_long(__x)); }
1481static simd_int4 SIMD_CFUNC simd_int(simd_ulong4 __x) { return simd_int(simd_long(__x)); }
1482static simd_int8 SIMD_CFUNC simd_int(simd_ulong8 __x) { return simd_int(simd_long(__x)); }
1483static simd_int2 SIMD_CFUNC simd_int(simd_double2 __x) { return __builtin_convertvector(__x, simd_int2); }
1484static simd_int3 SIMD_CFUNC simd_int(simd_double3 __x) { return __builtin_convertvector(__x, simd_int3); }
1485static simd_int4 SIMD_CFUNC simd_int(simd_double4 __x) { return __builtin_convertvector(__x, simd_int4); }
1486static simd_int8 SIMD_CFUNC simd_int(simd_double8 __x) { return __builtin_convertvector(__x, simd_int8); }
1487
1488static simd_int2 SIMD_CFUNC simd_int_sat(simd_char2 __x) { return simd_int(__x); }
1489static simd_int3 SIMD_CFUNC simd_int_sat(simd_char3 __x) { return simd_int(__x); }
1490static simd_int4 SIMD_CFUNC simd_int_sat(simd_char4 __x) { return simd_int(__x); }
1491static simd_int8 SIMD_CFUNC simd_int_sat(simd_char8 __x) { return simd_int(__x); }
1492static simd_int16 SIMD_CFUNC simd_int_sat(simd_char16 __x) { return simd_int(__x); }
1493static simd_int2 SIMD_CFUNC simd_int_sat(simd_short2 __x) { return simd_int(__x); }
1494static simd_int3 SIMD_CFUNC simd_int_sat(simd_short3 __x) { return simd_int(__x); }
1495static simd_int4 SIMD_CFUNC simd_int_sat(simd_short4 __x) { return simd_int(__x); }
1496static simd_int8 SIMD_CFUNC simd_int_sat(simd_short8 __x) { return simd_int(__x); }
1497static simd_int16 SIMD_CFUNC simd_int_sat(simd_short16 __x) { return simd_int(__x); }
1498static simd_int2 SIMD_CFUNC simd_int_sat(simd_int2 __x) { return __x; }
1499static simd_int3 SIMD_CFUNC simd_int_sat(simd_int3 __x) { return __x; }
1500static simd_int4 SIMD_CFUNC simd_int_sat(simd_int4 __x) { return __x; }
1501static simd_int8 SIMD_CFUNC simd_int_sat(simd_int8 __x) { return __x; }
1502static simd_int16 SIMD_CFUNC simd_int_sat(simd_int16 __x) { return __x; }
1503static simd_int2 SIMD_CFUNC simd_int_sat(simd_float2 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); }
1504static simd_int3 SIMD_CFUNC simd_int_sat(simd_float3 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); }
1505static simd_int4 SIMD_CFUNC simd_int_sat(simd_float4 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); }
1506static simd_int8 SIMD_CFUNC simd_int_sat(simd_float8 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); }
1507static simd_int16 SIMD_CFUNC simd_int_sat(simd_float16 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); }
1508static simd_int2 SIMD_CFUNC simd_int_sat(simd_long2 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); }
1509static simd_int3 SIMD_CFUNC simd_int_sat(simd_long3 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); }
1510static simd_int4 SIMD_CFUNC simd_int_sat(simd_long4 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); }
1511static simd_int8 SIMD_CFUNC simd_int_sat(simd_long8 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); }
1512static simd_int2 SIMD_CFUNC simd_int_sat(simd_double2 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); }
1513static simd_int3 SIMD_CFUNC simd_int_sat(simd_double3 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); }
1514static simd_int4 SIMD_CFUNC simd_int_sat(simd_double4 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); }
1515static simd_int8 SIMD_CFUNC simd_int_sat(simd_double8 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); }
1516static simd_int2 SIMD_CFUNC simd_int_sat(simd_uchar2 __x) { return simd_int(__x); }
1517static simd_int3 SIMD_CFUNC simd_int_sat(simd_uchar3 __x) { return simd_int(__x); }
1518static simd_int4 SIMD_CFUNC simd_int_sat(simd_uchar4 __x) { return simd_int(__x); }
1519static simd_int8 SIMD_CFUNC simd_int_sat(simd_uchar8 __x) { return simd_int(__x); }
1520static simd_int16 SIMD_CFUNC simd_int_sat(simd_uchar16 __x) { return simd_int(__x); }
1521static simd_int2 SIMD_CFUNC simd_int_sat(simd_ushort2 __x) { return simd_int(__x); }
1522static simd_int3 SIMD_CFUNC simd_int_sat(simd_ushort3 __x) { return simd_int(__x); }
1523static simd_int4 SIMD_CFUNC simd_int_sat(simd_ushort4 __x) { return simd_int(__x); }
1524static simd_int8 SIMD_CFUNC simd_int_sat(simd_ushort8 __x) { return simd_int(__x); }
1525static simd_int16 SIMD_CFUNC simd_int_sat(simd_ushort16 __x) { return simd_int(__x); }
1526static simd_int2 SIMD_CFUNC simd_int_sat(simd_uint2 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1527static simd_int3 SIMD_CFUNC simd_int_sat(simd_uint3 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1528static simd_int4 SIMD_CFUNC simd_int_sat(simd_uint4 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1529static simd_int8 SIMD_CFUNC simd_int_sat(simd_uint8 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1530static simd_int16 SIMD_CFUNC simd_int_sat(simd_uint16 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1531static simd_int2 SIMD_CFUNC simd_int_sat(simd_ulong2 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1532static simd_int3 SIMD_CFUNC simd_int_sat(simd_ulong3 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1533static simd_int4 SIMD_CFUNC simd_int_sat(simd_ulong4 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1534static simd_int8 SIMD_CFUNC simd_int_sat(simd_ulong8 __x) { return simd_int(simd_min(__x,0x7fffffff)); }
1535
1536static simd_int2 SIMD_CFUNC simd_int_rte(simd_float2 __x) {
1537#if defined __arm64__
1538 return vcvtn_s32_f32(__x);
1539#else
1540 return simd_make_int2(simd_int_rte(simd_make_float4_undef(__x)));
1541#endif
1542}
1543
1544static simd_int3 SIMD_CFUNC simd_int_rte(simd_float3 __x) {
1545 return simd_make_int3(simd_int_rte(simd_make_float4_undef(__x)));
1546}
1547
1548static simd_int4 SIMD_CFUNC simd_int_rte(simd_float4 __x) {
1549#if defined __SSE2__
1550 return _mm_cvtps_epi32(__x);
1551#elif defined __arm64__
1552 return vcvtnq_s32_f32(__x);
1553#else
1554 simd_float4 magic = __tg_copysign(0x1.0p23, __x);
1555 simd_int4 x_is_small = __tg_fabs(__x) < 0x1.0p23;
1556 return __builtin_convertvector(simd_bitselect(__x, (__x + magic) - magic, x_is_small & 0x7fffffff), simd_int4);
1557#endif
1558}
1559
1560static simd_int8 SIMD_CFUNC simd_int_rte(simd_float8 __x) {
1561#if defined __AVX__
1562 return _mm256_cvtps_epi32(__x);
1563#else
1564 return simd_make_int8(simd_int_rte(__x.lo), simd_int_rte(__x.hi));
1565#endif
1566}
1567
1568static simd_int16 SIMD_CFUNC simd_int_rte(simd_float16 __x) {
1569#if defined __AVX512F__
1570 return _mm512_cvt_roundps_epi32(__x, _MM_FROUND_RINT);
1571#else
1572 return simd_make_int16(simd_int_rte(__x.lo), simd_int_rte(__x.hi));
1573#endif
1574}
1575
1576static simd_uint2 SIMD_CFUNC simd_uint(simd_char2 __x) { return simd_uint(simd_int(__x)); }
1577static simd_uint3 SIMD_CFUNC simd_uint(simd_char3 __x) { return simd_uint(simd_int(__x)); }
1578static simd_uint4 SIMD_CFUNC simd_uint(simd_char4 __x) { return simd_uint(simd_int(__x)); }
1579static simd_uint8 SIMD_CFUNC simd_uint(simd_char8 __x) { return simd_uint(simd_int(__x)); }
1580static simd_uint16 SIMD_CFUNC simd_uint(simd_char16 __x) { return simd_uint(simd_int(__x)); }
1581static simd_uint2 SIMD_CFUNC simd_uint(simd_uchar2 __x) { return simd_uint(simd_int(__x)); }
1582static simd_uint3 SIMD_CFUNC simd_uint(simd_uchar3 __x) { return simd_uint(simd_int(__x)); }
1583static simd_uint4 SIMD_CFUNC simd_uint(simd_uchar4 __x) { return simd_uint(simd_int(__x)); }
1584static simd_uint8 SIMD_CFUNC simd_uint(simd_uchar8 __x) { return simd_uint(simd_int(__x)); }
1585static simd_uint16 SIMD_CFUNC simd_uint(simd_uchar16 __x) { return simd_uint(simd_int(__x)); }
1586static simd_uint2 SIMD_CFUNC simd_uint(simd_short2 __x) { return simd_uint(simd_int(__x)); }
1587static simd_uint3 SIMD_CFUNC simd_uint(simd_short3 __x) { return simd_uint(simd_int(__x)); }
1588static simd_uint4 SIMD_CFUNC simd_uint(simd_short4 __x) { return simd_uint(simd_int(__x)); }
1589static simd_uint8 SIMD_CFUNC simd_uint(simd_short8 __x) { return simd_uint(simd_int(__x)); }
1590static simd_uint16 SIMD_CFUNC simd_uint(simd_short16 __x) { return simd_uint(simd_int(__x)); }
1591static simd_uint2 SIMD_CFUNC simd_uint(simd_ushort2 __x) { return simd_uint(simd_int(__x)); }
1592static simd_uint3 SIMD_CFUNC simd_uint(simd_ushort3 __x) { return simd_uint(simd_int(__x)); }
1593static simd_uint4 SIMD_CFUNC simd_uint(simd_ushort4 __x) { return simd_uint(simd_int(__x)); }
1594static simd_uint8 SIMD_CFUNC simd_uint(simd_ushort8 __x) { return simd_uint(simd_int(__x)); }
1595static simd_uint16 SIMD_CFUNC simd_uint(simd_ushort16 __x) { return simd_uint(simd_int(__x)); }
1596static simd_uint2 SIMD_CFUNC simd_uint(simd_int2 __x) { return (simd_uint2)__x; }
1597static simd_uint3 SIMD_CFUNC simd_uint(simd_int3 __x) { return (simd_uint3)__x; }
1598static simd_uint4 SIMD_CFUNC simd_uint(simd_int4 __x) { return (simd_uint4)__x; }
1599static simd_uint8 SIMD_CFUNC simd_uint(simd_int8 __x) { return (simd_uint8)__x; }
1600static simd_uint16 SIMD_CFUNC simd_uint(simd_int16 __x) { return (simd_uint16)__x; }
1601static simd_uint2 SIMD_CFUNC simd_uint(simd_uint2 __x) { return __x; }
1602static simd_uint3 SIMD_CFUNC simd_uint(simd_uint3 __x) { return __x; }
1603static simd_uint4 SIMD_CFUNC simd_uint(simd_uint4 __x) { return __x; }
1604static simd_uint8 SIMD_CFUNC simd_uint(simd_uint8 __x) { return __x; }
1605static simd_uint16 SIMD_CFUNC simd_uint(simd_uint16 __x) { return __x; }
1606static simd_uint2 SIMD_CFUNC simd_uint(simd_float2 __x) { simd_int2 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float2)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint2)0,0x80000000,__big); }
1607static simd_uint3 SIMD_CFUNC simd_uint(simd_float3 __x) { simd_int3 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float3)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint3)0,0x80000000,__big); }
1608static simd_uint4 SIMD_CFUNC simd_uint(simd_float4 __x) { simd_int4 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float4)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint4)0,0x80000000,__big); }
1609static simd_uint8 SIMD_CFUNC simd_uint(simd_float8 __x) { simd_int8 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float8)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint8)0,0x80000000,__big); }
1610static simd_uint16 SIMD_CFUNC simd_uint(simd_float16 __x) { simd_int16 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float16)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint16)0,0x80000000,__big); }
1611static simd_uint2 SIMD_CFUNC simd_uint(simd_long2 __x) { return simd_uint(simd_int(__x)); }
1612static simd_uint3 SIMD_CFUNC simd_uint(simd_long3 __x) { return simd_uint(simd_int(__x)); }
1613static simd_uint4 SIMD_CFUNC simd_uint(simd_long4 __x) { return simd_uint(simd_int(__x)); }
1614static simd_uint8 SIMD_CFUNC simd_uint(simd_long8 __x) { return simd_uint(simd_int(__x)); }
1615static simd_uint2 SIMD_CFUNC simd_uint(simd_ulong2 __x) { return simd_uint(simd_int(__x)); }
1616static simd_uint3 SIMD_CFUNC simd_uint(simd_ulong3 __x) { return simd_uint(simd_int(__x)); }
1617static simd_uint4 SIMD_CFUNC simd_uint(simd_ulong4 __x) { return simd_uint(simd_int(__x)); }
1618static simd_uint8 SIMD_CFUNC simd_uint(simd_ulong8 __x) { return simd_uint(simd_int(__x)); }
1619static simd_uint2 SIMD_CFUNC simd_uint(simd_double2 __x) { simd_long2 __big = __x > 0x1.fffffffcp30; return simd_uint(simd_int(__x - simd_bitselect((simd_double2)0,0x1.0p31,__big))) + simd_bitselect((simd_uint2)0,0x80000000,simd_int(__big)); }
1620static simd_uint3 SIMD_CFUNC simd_uint(simd_double3 __x) { simd_long3 __big = __x > 0x1.fffffffcp30; return simd_uint(simd_int(__x - simd_bitselect((simd_double3)0,0x1.0p31,__big))) + simd_bitselect((simd_uint3)0,0x80000000,simd_int(__big)); }
1621static simd_uint4 SIMD_CFUNC simd_uint(simd_double4 __x) { simd_long4 __big = __x > 0x1.fffffffcp30; return simd_uint(simd_int(__x - simd_bitselect((simd_double4)0,0x1.0p31,__big))) + simd_bitselect((simd_uint4)0,0x80000000,simd_int(__big)); }
1622static simd_uint8 SIMD_CFUNC simd_uint(simd_double8 __x) { simd_long8 __big = __x > 0x1.fffffffcp30; return simd_uint(simd_int(__x - simd_bitselect((simd_double8)0,0x1.0p31,__big))) + simd_bitselect((simd_uint8)0,0x80000000,simd_int(__big)); }
1623
1624static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_char2 __x) { return simd_uint(simd_max(__x,0)); }
1625static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_char3 __x) { return simd_uint(simd_max(__x,0)); }
1626static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_char4 __x) { return simd_uint(simd_max(__x,0)); }
1627static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_char8 __x) { return simd_uint(simd_max(__x,0)); }
1628static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_char16 __x) { return simd_uint(simd_max(__x,0)); }
1629static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_short2 __x) { return simd_uint(simd_max(__x,0)); }
1630static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_short3 __x) { return simd_uint(simd_max(__x,0)); }
1631static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_short4 __x) { return simd_uint(simd_max(__x,0)); }
1632static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_short8 __x) { return simd_uint(simd_max(__x,0)); }
1633static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_short16 __x) { return simd_uint(simd_max(__x,0)); }
1634static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_int2 __x) { return simd_uint(simd_max(__x,0)); }
1635static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_int3 __x) { return simd_uint(simd_max(__x,0)); }
1636static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_int4 __x) { return simd_uint(simd_max(__x,0)); }
1637static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_int8 __x) { return simd_uint(simd_max(__x,0)); }
1638static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_int16 __x) { return simd_uint(simd_max(__x,0)); }
1639static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_float2 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); }
1640static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_float3 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); }
1641static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_float4 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); }
1642static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_float8 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); }
1643static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_float16 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); }
1644static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_long2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1645static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_long3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1646static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_long4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1647static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_long8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1648static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_double2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1649static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_double3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1650static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_double4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1651static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_double8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1652static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uchar2 __x) { return simd_uint(__x); }
1653static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uchar3 __x) { return simd_uint(__x); }
1654static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uchar4 __x) { return simd_uint(__x); }
1655static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uchar8 __x) { return simd_uint(__x); }
1656static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uchar16 __x) { return simd_uint(__x); }
1657static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ushort2 __x) { return simd_uint(__x); }
1658static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ushort3 __x) { return simd_uint(__x); }
1659static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ushort4 __x) { return simd_uint(__x); }
1660static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ushort8 __x) { return simd_uint(__x); }
1661static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_ushort16 __x) { return simd_uint(__x); }
1662static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uint2 __x) { return __x; }
1663static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uint3 __x) { return __x; }
1664static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uint4 __x) { return __x; }
1665static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uint8 __x) { return __x; }
1666static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uint16 __x) { return __x; }
1667static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ulong2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1668static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ulong3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1669static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ulong4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1670static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ulong8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); }
1671
1672
1673static simd_float2 SIMD_CFUNC simd_float(simd_char2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1674static simd_float3 SIMD_CFUNC simd_float(simd_char3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1675static simd_float4 SIMD_CFUNC simd_float(simd_char4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1676static simd_float8 SIMD_CFUNC simd_float(simd_char8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1677static simd_float16 SIMD_CFUNC simd_float(simd_char16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1678static simd_float2 SIMD_CFUNC simd_float(simd_uchar2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1679static simd_float3 SIMD_CFUNC simd_float(simd_uchar3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1680static simd_float4 SIMD_CFUNC simd_float(simd_uchar4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1681static simd_float8 SIMD_CFUNC simd_float(simd_uchar8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1682static simd_float16 SIMD_CFUNC simd_float(simd_uchar16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1683static simd_float2 SIMD_CFUNC simd_float(simd_short2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1684static simd_float3 SIMD_CFUNC simd_float(simd_short3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1685static simd_float4 SIMD_CFUNC simd_float(simd_short4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1686static simd_float8 SIMD_CFUNC simd_float(simd_short8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1687static simd_float16 SIMD_CFUNC simd_float(simd_short16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1688static simd_float2 SIMD_CFUNC simd_float(simd_ushort2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1689static simd_float3 SIMD_CFUNC simd_float(simd_ushort3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1690static simd_float4 SIMD_CFUNC simd_float(simd_ushort4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1691static simd_float8 SIMD_CFUNC simd_float(simd_ushort8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1692static simd_float16 SIMD_CFUNC simd_float(simd_ushort16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; }
1693static simd_float2 SIMD_CFUNC simd_float(simd_int2 __x) { return __builtin_convertvector(__x,simd_float2); }
1694static simd_float3 SIMD_CFUNC simd_float(simd_int3 __x) { return __builtin_convertvector(__x,simd_float3); }
1695static simd_float4 SIMD_CFUNC simd_float(simd_int4 __x) { return __builtin_convertvector(__x,simd_float4); }
1696static simd_float8 SIMD_CFUNC simd_float(simd_int8 __x) { return __builtin_convertvector(__x,simd_float8); }
1697static simd_float16 SIMD_CFUNC simd_float(simd_int16 __x) { return __builtin_convertvector(__x,simd_float16); }
1698static simd_float2 SIMD_CFUNC simd_float(simd_uint2 __x) { return __builtin_convertvector(__x,simd_float2); }
1699static simd_float3 SIMD_CFUNC simd_float(simd_uint3 __x) { return __builtin_convertvector(__x,simd_float3); }
1700static simd_float4 SIMD_CFUNC simd_float(simd_uint4 __x) { return __builtin_convertvector(__x,simd_float4); }
1701static simd_float8 SIMD_CFUNC simd_float(simd_uint8 __x) { return __builtin_convertvector(__x,simd_float8); }
1702static simd_float16 SIMD_CFUNC simd_float(simd_uint16 __x) { return __builtin_convertvector(__x,simd_float16); }
1703static simd_float2 SIMD_CFUNC simd_float(simd_float2 __x) { return __x; }
1704static simd_float3 SIMD_CFUNC simd_float(simd_float3 __x) { return __x; }
1705static simd_float4 SIMD_CFUNC simd_float(simd_float4 __x) { return __x; }
1706static simd_float8 SIMD_CFUNC simd_float(simd_float8 __x) { return __x; }
1707static simd_float16 SIMD_CFUNC simd_float(simd_float16 __x) { return __x; }
1708static simd_float2 SIMD_CFUNC simd_float(simd_long2 __x) { return __builtin_convertvector(__x,simd_float2); }
1709static simd_float3 SIMD_CFUNC simd_float(simd_long3 __x) { return __builtin_convertvector(__x,simd_float3); }
1710static simd_float4 SIMD_CFUNC simd_float(simd_long4 __x) { return __builtin_convertvector(__x,simd_float4); }
1711static simd_float8 SIMD_CFUNC simd_float(simd_long8 __x) { return __builtin_convertvector(__x,simd_float8); }
1712static simd_float2 SIMD_CFUNC simd_float(simd_ulong2 __x) { return __builtin_convertvector(__x,simd_float2); }
1713static simd_float3 SIMD_CFUNC simd_float(simd_ulong3 __x) { return __builtin_convertvector(__x,simd_float3); }
1714static simd_float4 SIMD_CFUNC simd_float(simd_ulong4 __x) { return __builtin_convertvector(__x,simd_float4); }
1715static simd_float8 SIMD_CFUNC simd_float(simd_ulong8 __x) { return __builtin_convertvector(__x,simd_float8); }
1716static simd_float2 SIMD_CFUNC simd_float(simd_double2 __x) { return __builtin_convertvector(__x,simd_float2); }
1717static simd_float3 SIMD_CFUNC simd_float(simd_double3 __x) { return __builtin_convertvector(__x,simd_float3); }
1718static simd_float4 SIMD_CFUNC simd_float(simd_double4 __x) { return __builtin_convertvector(__x,simd_float4); }
1719static simd_float8 SIMD_CFUNC simd_float(simd_double8 __x) { return __builtin_convertvector(__x,simd_float8); }
1720
1721
1722static simd_long2 SIMD_CFUNC simd_long(simd_char2 __x) { return __builtin_convertvector(__x,simd_long2); }
1723static simd_long3 SIMD_CFUNC simd_long(simd_char3 __x) { return __builtin_convertvector(__x,simd_long3); }
1724static simd_long4 SIMD_CFUNC simd_long(simd_char4 __x) { return __builtin_convertvector(__x,simd_long4); }
1725static simd_long8 SIMD_CFUNC simd_long(simd_char8 __x) { return __builtin_convertvector(__x,simd_long8); }
1726static simd_long2 SIMD_CFUNC simd_long(simd_uchar2 __x) { return __builtin_convertvector(__x,simd_long2); }
1727static simd_long3 SIMD_CFUNC simd_long(simd_uchar3 __x) { return __builtin_convertvector(__x,simd_long3); }
1728static simd_long4 SIMD_CFUNC simd_long(simd_uchar4 __x) { return __builtin_convertvector(__x,simd_long4); }
1729static simd_long8 SIMD_CFUNC simd_long(simd_uchar8 __x) { return __builtin_convertvector(__x,simd_long8); }
1730static simd_long2 SIMD_CFUNC simd_long(simd_short2 __x) { return __builtin_convertvector(__x,simd_long2); }
1731static simd_long3 SIMD_CFUNC simd_long(simd_short3 __x) { return __builtin_convertvector(__x,simd_long3); }
1732static simd_long4 SIMD_CFUNC simd_long(simd_short4 __x) { return __builtin_convertvector(__x,simd_long4); }
1733static simd_long8 SIMD_CFUNC simd_long(simd_short8 __x) { return __builtin_convertvector(__x,simd_long8); }
1734static simd_long2 SIMD_CFUNC simd_long(simd_ushort2 __x) { return __builtin_convertvector(__x,simd_long2); }
1735static simd_long3 SIMD_CFUNC simd_long(simd_ushort3 __x) { return __builtin_convertvector(__x,simd_long3); }
1736static simd_long4 SIMD_CFUNC simd_long(simd_ushort4 __x) { return __builtin_convertvector(__x,simd_long4); }
1737static simd_long8 SIMD_CFUNC simd_long(simd_ushort8 __x) { return __builtin_convertvector(__x,simd_long8); }
1738static simd_long2 SIMD_CFUNC simd_long(simd_int2 __x) { return __builtin_convertvector(__x,simd_long2); }
1739static simd_long3 SIMD_CFUNC simd_long(simd_int3 __x) { return __builtin_convertvector(__x,simd_long3); }
1740static simd_long4 SIMD_CFUNC simd_long(simd_int4 __x) { return __builtin_convertvector(__x,simd_long4); }
1741static simd_long8 SIMD_CFUNC simd_long(simd_int8 __x) { return __builtin_convertvector(__x,simd_long8); }
1742static simd_long2 SIMD_CFUNC simd_long(simd_uint2 __x) { return __builtin_convertvector(__x,simd_long2); }
1743static simd_long3 SIMD_CFUNC simd_long(simd_uint3 __x) { return __builtin_convertvector(__x,simd_long3); }
1744static simd_long4 SIMD_CFUNC simd_long(simd_uint4 __x) { return __builtin_convertvector(__x,simd_long4); }
1745static simd_long8 SIMD_CFUNC simd_long(simd_uint8 __x) { return __builtin_convertvector(__x,simd_long8); }
1746static simd_long2 SIMD_CFUNC simd_long(simd_float2 __x) { return __builtin_convertvector(__x,simd_long2); }
1747static simd_long3 SIMD_CFUNC simd_long(simd_float3 __x) { return __builtin_convertvector(__x,simd_long3); }
1748static simd_long4 SIMD_CFUNC simd_long(simd_float4 __x) { return __builtin_convertvector(__x,simd_long4); }
1749static simd_long8 SIMD_CFUNC simd_long(simd_float8 __x) { return __builtin_convertvector(__x,simd_long8); }
1750static simd_long2 SIMD_CFUNC simd_long(simd_long2 __x) { return __x; }
1751static simd_long3 SIMD_CFUNC simd_long(simd_long3 __x) { return __x; }
1752static simd_long4 SIMD_CFUNC simd_long(simd_long4 __x) { return __x; }
1753static simd_long8 SIMD_CFUNC simd_long(simd_long8 __x) { return __x; }
1754static simd_long2 SIMD_CFUNC simd_long(simd_ulong2 __x) { return (simd_long2)__x; }
1755static simd_long3 SIMD_CFUNC simd_long(simd_ulong3 __x) { return (simd_long3)__x; }
1756static simd_long4 SIMD_CFUNC simd_long(simd_ulong4 __x) { return (simd_long4)__x; }
1757static simd_long8 SIMD_CFUNC simd_long(simd_ulong8 __x) { return (simd_long8)__x; }
1758static simd_long2 SIMD_CFUNC simd_long(simd_double2 __x) { return __builtin_convertvector(__x,simd_long2); }
1759static simd_long3 SIMD_CFUNC simd_long(simd_double3 __x) { return __builtin_convertvector(__x,simd_long3); }
1760static simd_long4 SIMD_CFUNC simd_long(simd_double4 __x) { return __builtin_convertvector(__x,simd_long4); }
1761static simd_long8 SIMD_CFUNC simd_long(simd_double8 __x) { return __builtin_convertvector(__x,simd_long8); }
1762
1763static simd_long2 SIMD_CFUNC simd_long_sat(simd_char2 __x) { return simd_long(__x); }
1764static simd_long3 SIMD_CFUNC simd_long_sat(simd_char3 __x) { return simd_long(__x); }
1765static simd_long4 SIMD_CFUNC simd_long_sat(simd_char4 __x) { return simd_long(__x); }
1766static simd_long8 SIMD_CFUNC simd_long_sat(simd_char8 __x) { return simd_long(__x); }
1767static simd_long2 SIMD_CFUNC simd_long_sat(simd_short2 __x) { return simd_long(__x); }
1768static simd_long3 SIMD_CFUNC simd_long_sat(simd_short3 __x) { return simd_long(__x); }
1769static simd_long4 SIMD_CFUNC simd_long_sat(simd_short4 __x) { return simd_long(__x); }
1770static simd_long8 SIMD_CFUNC simd_long_sat(simd_short8 __x) { return simd_long(__x); }
1771static simd_long2 SIMD_CFUNC simd_long_sat(simd_int2 __x) { return simd_long(__x); }
1772static simd_long3 SIMD_CFUNC simd_long_sat(simd_int3 __x) { return simd_long(__x); }
1773static simd_long4 SIMD_CFUNC simd_long_sat(simd_int4 __x) { return simd_long(__x); }
1774static simd_long8 SIMD_CFUNC simd_long_sat(simd_int8 __x) { return simd_long(__x); }
1775static simd_long2 SIMD_CFUNC simd_long_sat(simd_float2 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63f)), 0x7fffffffffffffff, simd_long(__x >= 0x1.0p63f)); }
1776static simd_long3 SIMD_CFUNC simd_long_sat(simd_float3 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63f)), 0x7fffffffffffffff, simd_long(__x >= 0x1.0p63f)); }
1777static simd_long4 SIMD_CFUNC simd_long_sat(simd_float4 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63f)), 0x7fffffffffffffff, simd_long(__x >= 0x1.0p63f)); }
1778static simd_long8 SIMD_CFUNC simd_long_sat(simd_float8 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63f)), 0x7fffffffffffffff, simd_long(__x >= 0x1.0p63f)); }
1779static simd_long2 SIMD_CFUNC simd_long_sat(simd_long2 __x) { return __x; }
1780static simd_long3 SIMD_CFUNC simd_long_sat(simd_long3 __x) { return __x; }
1781static simd_long4 SIMD_CFUNC simd_long_sat(simd_long4 __x) { return __x; }
1782static simd_long8 SIMD_CFUNC simd_long_sat(simd_long8 __x) { return __x; }
1783static simd_long2 SIMD_CFUNC simd_long_sat(simd_double2 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); }
1784static simd_long3 SIMD_CFUNC simd_long_sat(simd_double3 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); }
1785static simd_long4 SIMD_CFUNC simd_long_sat(simd_double4 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); }
1786static simd_long8 SIMD_CFUNC simd_long_sat(simd_double8 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); }
1787static simd_long2 SIMD_CFUNC simd_long_sat(simd_uchar2 __x) { return simd_long(__x); }
1788static simd_long3 SIMD_CFUNC simd_long_sat(simd_uchar3 __x) { return simd_long(__x); }
1789static simd_long4 SIMD_CFUNC simd_long_sat(simd_uchar4 __x) { return simd_long(__x); }
1790static simd_long8 SIMD_CFUNC simd_long_sat(simd_uchar8 __x) { return simd_long(__x); }
1791static simd_long2 SIMD_CFUNC simd_long_sat(simd_ushort2 __x) { return simd_long(__x); }
1792static simd_long3 SIMD_CFUNC simd_long_sat(simd_ushort3 __x) { return simd_long(__x); }
1793static simd_long4 SIMD_CFUNC simd_long_sat(simd_ushort4 __x) { return simd_long(__x); }
1794static simd_long8 SIMD_CFUNC simd_long_sat(simd_ushort8 __x) { return simd_long(__x); }
1795static simd_long2 SIMD_CFUNC simd_long_sat(simd_uint2 __x) { return simd_long(__x); }
1796static simd_long3 SIMD_CFUNC simd_long_sat(simd_uint3 __x) { return simd_long(__x); }
1797static simd_long4 SIMD_CFUNC simd_long_sat(simd_uint4 __x) { return simd_long(__x); }
1798static simd_long8 SIMD_CFUNC simd_long_sat(simd_uint8 __x) { return simd_long(__x); }
1799static simd_long2 SIMD_CFUNC simd_long_sat(simd_ulong2 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); }
1800static simd_long3 SIMD_CFUNC simd_long_sat(simd_ulong3 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); }
1801static simd_long4 SIMD_CFUNC simd_long_sat(simd_ulong4 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); }
1802static simd_long8 SIMD_CFUNC simd_long_sat(simd_ulong8 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); }
1803
1804static simd_long2 SIMD_CFUNC simd_long_rte(simd_double2 __x) {
1805#if defined __AVX512F__
1806 return _mm_cvtpd_epi64(__x);
1807#elif defined __arm64__
1808 return vcvtnq_s64_f64(__x);
1809#else
1810 simd_double2 magic = __tg_copysign(0x1.0p52, __x);
1811 simd_long2 x_is_small = __tg_fabs(__x) < 0x1.0p52;
1812 return __builtin_convertvector(simd_bitselect(__x, (__x + magic) - magic, x_is_small & 0x7fffffffffffffff), simd_long2);
1813#endif
1814}
1815
1816static simd_long3 SIMD_CFUNC simd_long_rte(simd_double3 __x) {
1817 return simd_make_long3(simd_long_rte(simd_make_double4_undef(__x)));
1818}
1819
1820static simd_long4 SIMD_CFUNC simd_long_rte(simd_double4 __x) {
1821#if defined __AVX512F__
1822 return _mm256_cvtpd_epi64(__x);
1823#else
1824 return simd_make_long4(simd_long_rte(__x.lo), simd_long_rte(__x.hi));
1825#endif
1826}
1827
1828static simd_long8 SIMD_CFUNC simd_long_rte(simd_double8 __x) {
1829#if defined __AVX512F__
1830 return _mm512_cvt_roundpd_epi64(__x, _MM_FROUND_RINT);
1831#else
1832 return simd_make_long8(simd_long_rte(__x.lo), simd_long_rte(__x.hi));
1833#endif
1834}
1835
1836
1837static simd_ulong2 SIMD_CFUNC simd_ulong(simd_char2 __x) { return simd_ulong(simd_long(__x)); }
1838static simd_ulong3 SIMD_CFUNC simd_ulong(simd_char3 __x) { return simd_ulong(simd_long(__x)); }
1839static simd_ulong4 SIMD_CFUNC simd_ulong(simd_char4 __x) { return simd_ulong(simd_long(__x)); }
1840static simd_ulong8 SIMD_CFUNC simd_ulong(simd_char8 __x) { return simd_ulong(simd_long(__x)); }
1841static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uchar2 __x) { return simd_ulong(simd_long(__x)); }
1842static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uchar3 __x) { return simd_ulong(simd_long(__x)); }
1843static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uchar4 __x) { return simd_ulong(simd_long(__x)); }
1844static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uchar8 __x) { return simd_ulong(simd_long(__x)); }
1845static simd_ulong2 SIMD_CFUNC simd_ulong(simd_short2 __x) { return simd_ulong(simd_long(__x)); }
1846static simd_ulong3 SIMD_CFUNC simd_ulong(simd_short3 __x) { return simd_ulong(simd_long(__x)); }
1847static simd_ulong4 SIMD_CFUNC simd_ulong(simd_short4 __x) { return simd_ulong(simd_long(__x)); }
1848static simd_ulong8 SIMD_CFUNC simd_ulong(simd_short8 __x) { return simd_ulong(simd_long(__x)); }
1849static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ushort2 __x) { return simd_ulong(simd_long(__x)); }
1850static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ushort3 __x) { return simd_ulong(simd_long(__x)); }
1851static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ushort4 __x) { return simd_ulong(simd_long(__x)); }
1852static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ushort8 __x) { return simd_ulong(simd_long(__x)); }
1853static simd_ulong2 SIMD_CFUNC simd_ulong(simd_int2 __x) { return simd_ulong(simd_long(__x)); }
1854static simd_ulong3 SIMD_CFUNC simd_ulong(simd_int3 __x) { return simd_ulong(simd_long(__x)); }
1855static simd_ulong4 SIMD_CFUNC simd_ulong(simd_int4 __x) { return simd_ulong(simd_long(__x)); }
1856static simd_ulong8 SIMD_CFUNC simd_ulong(simd_int8 __x) { return simd_ulong(simd_long(__x)); }
1857static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uint2 __x) { return simd_ulong(simd_long(__x)); }
1858static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uint3 __x) { return simd_ulong(simd_long(__x)); }
1859static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uint4 __x) { return simd_ulong(simd_long(__x)); }
1860static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uint8 __x) { return simd_ulong(simd_long(__x)); }
1861static simd_ulong2 SIMD_CFUNC simd_ulong(simd_float2 __x) { simd_int2 __big = __x >= 0x1.0p63f; return simd_ulong(simd_long(__x - simd_bitselect((simd_float2)0,0x1.0p63f,__big))) + simd_bitselect((simd_ulong2)0,0x8000000000000000,simd_long(__big)); }
1862static simd_ulong3 SIMD_CFUNC simd_ulong(simd_float3 __x) { simd_int3 __big = __x >= 0x1.0p63f; return simd_ulong(simd_long(__x - simd_bitselect((simd_float3)0,0x1.0p63f,__big))) + simd_bitselect((simd_ulong3)0,0x8000000000000000,simd_long(__big)); }
1863static simd_ulong4 SIMD_CFUNC simd_ulong(simd_float4 __x) { simd_int4 __big = __x >= 0x1.0p63f; return simd_ulong(simd_long(__x - simd_bitselect((simd_float4)0,0x1.0p63f,__big))) + simd_bitselect((simd_ulong4)0,0x8000000000000000,simd_long(__big)); }
1864static simd_ulong8 SIMD_CFUNC simd_ulong(simd_float8 __x) { simd_int8 __big = __x >= 0x1.0p63f; return simd_ulong(simd_long(__x - simd_bitselect((simd_float8)0,0x1.0p63f,__big))) + simd_bitselect((simd_ulong8)0,0x8000000000000000,simd_long(__big)); }
1865static simd_ulong2 SIMD_CFUNC simd_ulong(simd_long2 __x) { return (simd_ulong2)__x; }
1866static simd_ulong3 SIMD_CFUNC simd_ulong(simd_long3 __x) { return (simd_ulong3)__x; }
1867static simd_ulong4 SIMD_CFUNC simd_ulong(simd_long4 __x) { return (simd_ulong4)__x; }
1868static simd_ulong8 SIMD_CFUNC simd_ulong(simd_long8 __x) { return (simd_ulong8)__x; }
1869static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ulong2 __x) { return __x; }
1870static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ulong3 __x) { return __x; }
1871static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ulong4 __x) { return __x; }
1872static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ulong8 __x) { return __x; }
1873static simd_ulong2 SIMD_CFUNC simd_ulong(simd_double2 __x) { simd_long2 __big = __x >= 0x1.0p63; return simd_ulong(simd_long(__x - simd_bitselect((simd_double2)0,0x1.0p63,__big))) + simd_bitselect((simd_ulong2)0,0x8000000000000000,__big); }
1874static simd_ulong3 SIMD_CFUNC simd_ulong(simd_double3 __x) { simd_long3 __big = __x >= 0x1.0p63; return simd_ulong(simd_long(__x - simd_bitselect((simd_double3)0,0x1.0p63,__big))) + simd_bitselect((simd_ulong3)0,0x8000000000000000,__big); }
1875static simd_ulong4 SIMD_CFUNC simd_ulong(simd_double4 __x) { simd_long4 __big = __x >= 0x1.0p63; return simd_ulong(simd_long(__x - simd_bitselect((simd_double4)0,0x1.0p63,__big))) + simd_bitselect((simd_ulong4)0,0x8000000000000000,__big); }
1876static simd_ulong8 SIMD_CFUNC simd_ulong(simd_double8 __x) { simd_long8 __big = __x >= 0x1.0p63; return simd_ulong(simd_long(__x - simd_bitselect((simd_double8)0,0x1.0p63,__big))) + simd_bitselect((simd_ulong8)0,0x8000000000000000,__big); }
1877
1878static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_char2 __x) { return simd_ulong(simd_max(__x,0)); }
1879static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_char3 __x) { return simd_ulong(simd_max(__x,0)); }
1880static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_char4 __x) { return simd_ulong(simd_max(__x,0)); }
1881static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_char8 __x) { return simd_ulong(simd_max(__x,0)); }
1882static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_short2 __x) { return simd_ulong(simd_max(__x,0)); }
1883static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_short3 __x) { return simd_ulong(simd_max(__x,0)); }
1884static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_short4 __x) { return simd_ulong(simd_max(__x,0)); }
1885static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_short8 __x) { return simd_ulong(simd_max(__x,0)); }
1886static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_int2 __x) { return simd_ulong(simd_max(__x,0)); }
1887static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_int3 __x) { return simd_ulong(simd_max(__x,0)); }
1888static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_int4 __x) { return simd_ulong(simd_max(__x,0)); }
1889static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_int8 __x) { return simd_ulong(simd_max(__x,0)); }
1890static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_float2 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.f)), 0xffffffffffffffff, simd_long(__x >= 0x1.0p64f)); }
1891static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_float3 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.f)), 0xffffffffffffffff, simd_long(__x >= 0x1.0p64f)); }
1892static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_float4 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.f)), 0xffffffffffffffff, simd_long(__x >= 0x1.0p64f)); }
1893static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_float8 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.f)), 0xffffffffffffffff, simd_long(__x >= 0x1.0p64f)); }
1894static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_long2 __x) { return simd_ulong(simd_max(__x,0)); }
1895static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_long3 __x) { return simd_ulong(simd_max(__x,0)); }
1896static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_long4 __x) { return simd_ulong(simd_max(__x,0)); }
1897static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_long8 __x) { return simd_ulong(simd_max(__x,0)); }
1898static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_double2 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); }
1899static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_double3 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); }
1900static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_double4 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); }
1901static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_double8 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); }
1902static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uchar2 __x) { return simd_ulong(__x); }
1903static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uchar3 __x) { return simd_ulong(__x); }
1904static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uchar4 __x) { return simd_ulong(__x); }
1905static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uchar8 __x) { return simd_ulong(__x); }
1906static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ushort2 __x) { return simd_ulong(__x); }
1907static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ushort3 __x) { return simd_ulong(__x); }
1908static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ushort4 __x) { return simd_ulong(__x); }
1909static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ushort8 __x) { return simd_ulong(__x); }
1910static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uint2 __x) { return simd_ulong(__x); }
1911static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uint3 __x) { return simd_ulong(__x); }
1912static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uint4 __x) { return simd_ulong(__x); }
1913static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uint8 __x) { return simd_ulong(__x); }
1914static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ulong2 __x) { return __x; }
1915static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ulong3 __x) { return __x; }
1916static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ulong4 __x) { return __x; }
1917static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ulong8 __x) { return __x; }
1918
1919
1920static simd_double2 SIMD_CFUNC simd_double(simd_char2 __x) { return simd_double(simd_int(__x)); }
1921static simd_double3 SIMD_CFUNC simd_double(simd_char3 __x) { return simd_double(simd_int(__x)); }
1922static simd_double4 SIMD_CFUNC simd_double(simd_char4 __x) { return simd_double(simd_int(__x)); }
1923static simd_double8 SIMD_CFUNC simd_double(simd_char8 __x) { return simd_double(simd_int(__x)); }
1924static simd_double2 SIMD_CFUNC simd_double(simd_uchar2 __x) { return simd_double(simd_int(__x)); }
1925static simd_double3 SIMD_CFUNC simd_double(simd_uchar3 __x) { return simd_double(simd_int(__x)); }
1926static simd_double4 SIMD_CFUNC simd_double(simd_uchar4 __x) { return simd_double(simd_int(__x)); }
1927static simd_double8 SIMD_CFUNC simd_double(simd_uchar8 __x) { return simd_double(simd_int(__x)); }
1928static simd_double2 SIMD_CFUNC simd_double(simd_short2 __x) { return simd_double(simd_int(__x)); }
1929static simd_double3 SIMD_CFUNC simd_double(simd_short3 __x) { return simd_double(simd_int(__x)); }
1930static simd_double4 SIMD_CFUNC simd_double(simd_short4 __x) { return simd_double(simd_int(__x)); }
1931static simd_double8 SIMD_CFUNC simd_double(simd_short8 __x) { return simd_double(simd_int(__x)); }
1932static simd_double2 SIMD_CFUNC simd_double(simd_ushort2 __x) { return simd_double(simd_int(__x)); }
1933static simd_double3 SIMD_CFUNC simd_double(simd_ushort3 __x) { return simd_double(simd_int(__x)); }
1934static simd_double4 SIMD_CFUNC simd_double(simd_ushort4 __x) { return simd_double(simd_int(__x)); }
1935static simd_double8 SIMD_CFUNC simd_double(simd_ushort8 __x) { return simd_double(simd_int(__x)); }
1936static simd_double2 SIMD_CFUNC simd_double(simd_int2 __x) { return __builtin_convertvector(__x, simd_double2); }
1937static simd_double3 SIMD_CFUNC simd_double(simd_int3 __x) { return __builtin_convertvector(__x, simd_double3); }
1938static simd_double4 SIMD_CFUNC simd_double(simd_int4 __x) { return __builtin_convertvector(__x, simd_double4); }
1939static simd_double8 SIMD_CFUNC simd_double(simd_int8 __x) { return __builtin_convertvector(__x, simd_double8); }
1940static simd_double2 SIMD_CFUNC simd_double(simd_uint2 __x) { return __builtin_convertvector(__x, simd_double2); }
1941static simd_double3 SIMD_CFUNC simd_double(simd_uint3 __x) { return __builtin_convertvector(__x, simd_double3); }
1942static simd_double4 SIMD_CFUNC simd_double(simd_uint4 __x) { return __builtin_convertvector(__x, simd_double4); }
1943static simd_double8 SIMD_CFUNC simd_double(simd_uint8 __x) { return __builtin_convertvector(__x, simd_double8); }
1944static simd_double2 SIMD_CFUNC simd_double(simd_float2 __x) { return __builtin_convertvector(__x, simd_double2); }
1945static simd_double3 SIMD_CFUNC simd_double(simd_float3 __x) { return __builtin_convertvector(__x, simd_double3); }
1946static simd_double4 SIMD_CFUNC simd_double(simd_float4 __x) { return __builtin_convertvector(__x, simd_double4); }
1947static simd_double8 SIMD_CFUNC simd_double(simd_float8 __x) { return __builtin_convertvector(__x, simd_double8); }
1948static simd_double2 SIMD_CFUNC simd_double(simd_long2 __x) { return __builtin_convertvector(__x, simd_double2); }
1949static simd_double3 SIMD_CFUNC simd_double(simd_long3 __x) { return __builtin_convertvector(__x, simd_double3); }
1950static simd_double4 SIMD_CFUNC simd_double(simd_long4 __x) { return __builtin_convertvector(__x, simd_double4); }
1951static simd_double8 SIMD_CFUNC simd_double(simd_long8 __x) { return __builtin_convertvector(__x, simd_double8); }
1952static simd_double2 SIMD_CFUNC simd_double(simd_ulong2 __x) { return __builtin_convertvector(__x, simd_double2); }
1953static simd_double3 SIMD_CFUNC simd_double(simd_ulong3 __x) { return __builtin_convertvector(__x, simd_double3); }
1954static simd_double4 SIMD_CFUNC simd_double(simd_ulong4 __x) { return __builtin_convertvector(__x, simd_double4); }
1955static simd_double8 SIMD_CFUNC simd_double(simd_ulong8 __x) { return __builtin_convertvector(__x, simd_double8); }
1956static simd_double2 SIMD_CFUNC simd_double(simd_double2 __x) { return __builtin_convertvector(__x, simd_double2); }
1957static simd_double3 SIMD_CFUNC simd_double(simd_double3 __x) { return __builtin_convertvector(__x, simd_double3); }
1958static simd_double4 SIMD_CFUNC simd_double(simd_double4 __x) { return __builtin_convertvector(__x, simd_double4); }
1959static simd_double8 SIMD_CFUNC simd_double(simd_double8 __x) { return __builtin_convertvector(__x, simd_double8); }
1960
1961
1962#ifdef __cplusplus
1963}
1964#endif
1965#endif // SIMD_COMPILER_HAS_REQUIRED_FEATURES
1966#endif // __SIMD_CONVERSION_HEADER__
1967
lib/libc/include/x86_64-macos-gnu/simd/extern.h created+49
......@@ -0,0 +1,49 @@
1/* Copyright (c) 2014 Apple, Inc. All rights reserved. */
2
3#ifndef __SIMD_EXTERN_HEADER__
4#define __SIMD_EXTERN_HEADER__
5
6#include <simd/base.h>
7#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
8#include <simd/types.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#pragma mark - geometry
15#if SIMD_LIBRARY_VERSION >= 2
16extern float _simd_orient_vf2(simd_float2, simd_float2);
17extern float _simd_orient_pf2(simd_float2, simd_float2, simd_float2);
18extern float _simd_incircle_pf2(simd_float2, simd_float2, simd_float2, simd_float2);
19
20extern float _simd_orient_vf3(simd_float3, simd_float3, simd_float3);
21extern float _simd_orient_pf3(simd_float3, simd_float3, simd_float3, simd_float3);
22extern float _simd_insphere_pf3(simd_float3, simd_float3, simd_float3, simd_float3, simd_float3);
23
24extern double _simd_orient_vd2(simd_double2, simd_double2);
25extern double _simd_orient_pd2(simd_double2, simd_double2, simd_double2);
26extern double _simd_incircle_pd2(simd_double2, simd_double2, simd_double2, simd_double2);
27
28/* The double3 variants of these functions take their arguments in a buffer
29 * to workaround the fact that double3 calling conventions are different
30 * depending on whether or not the executable has been compiled with AVX
31 * enabled. */
32extern double _simd_orient_vd3(const double *);
33extern double _simd_orient_pd3(const double *);
34extern double _simd_insphere_pd3(const double *);
35#endif /* SIMD_LIBRARY_VERSION */
36
37#pragma mark - matrix
38extern simd_float2x2 __invert_f2(simd_float2x2);
39extern simd_double2x2 __invert_d2(simd_double2x2);
40extern simd_float3x3 __invert_f3(simd_float3x3);
41extern simd_double3x3 __invert_d3(simd_double3x3);
42extern simd_float4x4 __invert_f4(simd_float4x4);
43extern simd_double4x4 __invert_d4(simd_double4x4);
44
45#ifdef __cplusplus
46}
47#endif
48#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
49#endif /* __SIMD_EXTERN_HEADER__ */
lib/libc/include/x86_64-macos-gnu/simd/geometry.h created+1083
......@@ -0,0 +1,1083 @@
1/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved.
2 *
3 * The interfaces declared in this header provide operations for mathematical
4 * vectors; these functions and macros operate on vectors of floating-point
5 * data only.
6 *
7 * Function Result
8 * ------------------------------------------------------------------
9 * simd_dot(x,y) The dot product of x and y.
10 *
11 * simd_project(x,y) x projected onto y. There are two variants
12 * of this function, simd_precise_project
13 * and simd_fast_project. simd_project
14 * is equivalent to simd_precise_project
15 * unless you are compiling with -ffast-math
16 * specified, in which case it is equivalent
17 * to simd_fast_project.
18 *
19 * simd_length(x) The length (two-norm) of x. Undefined if
20 * x is poorly scaled such that an
21 * intermediate computation overflows or
22 * underflows. There are two variants
23 * of this function, simd_precise_length
24 * and simd_fast_length. simd_length
25 * is equivalent to simd_precise_length
26 * unless you are compiling with -ffast-math
27 * specified, in which case it is equivalent
28 * to simd_fast_length.
29 *
30 * simd_length_squared(x) The square of the length of x. If you
31 * simply need to compare relative magnitudes,
32 * use this instead of simd_length; it is
33 * faster than simd_fast_length and as
34 * accurate as simd_precise_length.
35 *
36 * simd_norm_one(x) The one-norm (sum of absolute values) of x.
37 *
38 * simd_norm_inf(x) The inf-norm (max absolute value) of x.
39 *
40 * simd_distance(x,y) The distance between x and y. Undefined if
41 * x and y are poorly scaled such that an
42 * intermediate computation overflows
43 * or underflows. There are two variants
44 * of this function, simd_precise_distance
45 * and simd_fast_distance. simd_distance
46 * is equivalent to simd_precise_distance
47 * unless you are compiling with -ffast-math
48 * specified, in which case it is equivalent
49 * to simd_fast_distance.
50 *
51 * simd_distance_squared(x,y) The square of the distance between x and y.
52 *
53 * simd_normalize(x) A vector pointing in the direction of x
54 * with length 1.0. Undefined if x is
55 * the zero vector, or if x is poorly scaled
56 * such that an intermediate computation
57 * overflows or underflows. There are two
58 * variants of this function,
59 * simd_precise_normalize and
60 * simd_fast_normalize. simd_normalize
61 * is equivalent to simd_precise_normalize
62 * unless you are compiling with -ffast-math
63 * specified, in which case it is equivalent
64 * to simd_fast_normalize.
65 *
66 * simd_cross(x,y) If x and y are vectors of dimension 3,
67 * the cross-product of x and y.
68 *
69 * If x and y are vectors of dimension 2,
70 * the cross-product of x and y interpreted as
71 * vectors in the z == 0 plane of a three-
72 * dimensional space.
73 *
74 * If x and y are vectors with a length that
75 * is neither 2 nor 3, this operation is not
76 * available.
77 *
78 * simd_reflect(x,n) Reflects x through the plane perpendicular
79 * to the normal vector n. Only available
80 * for vectors of length 2, 3, or 4.
81 *
82 * simd_refract(x,n,eta) Calculates the refraction direction given
83 * unit incident vector x, unit normal vector
84 * n, and index of refraction eta. If the
85 * angle between the incident vector and the
86 * surface normal is too great for the
87 * specified index of refraction, zero is
88 * returned.
89 * Available for vectors of length 2, 3, or 4.
90 *
91 * In C++ the following geometric functions are available in the simd::
92 * namespace:
93 *
94 * C++ Function Equivalent C Function
95 * -----------------------------------------------------------
96 * simd::dot(x,y) simd_dot(x,y)
97 * simd::project(x,y) simd_project(x,y)
98 * simd::length_squared(x) simd_length_squared(x)
99 * simd::length(x) simd_length(x)
100 * simd::distance_squared(x,y) simd_distance_squared(x,y)
101 * simd::norm_one(x) simd_norm_one(x)
102 * simd::norm_inf(x) simd_norm_inf(x)
103 * simd::distance(x,y) simd_distance(x,y)
104 * simd::normalize(x) simd_normalize(x)
105 * simd::cross(x,y) simd_cross(x,y)
106 * simd::reflect(x,n) simd_reflect(x,n)
107 * simd::refract(x,n,eta) simd_refract(x,n,eta)
108 *
109 * simd::precise::project(x,y) simd_precise_project(x,y)
110 * simd::precise::length(x) simd_precise_length(x)
111 * simd::precise::distance(x,y) simd_precise_distance(x,y)
112 * simd::precise::normalize(x) simd_precise_normalize(x)
113 *
114 * simd::fast::project(x,y) simd_fast_project(x,y)
115 * simd::fast::length(x) simd_fast_length(x)
116 * simd::fast::distance(x,y) simd_fast_distance(x,y)
117 * simd::fast::normalize(x) simd_fast_normalize(x)
118 */
119
120#ifndef __SIMD_GEOMETRY_HEADER__
121#define __SIMD_GEOMETRY_HEADER__
122
123#include <simd/base.h>
124#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
125#include <simd/vector_types.h>
126#include <simd/common.h>
127#include <simd/extern.h>
128
129#ifdef __cplusplus
130extern "C" {
131#endif
132
133static float SIMD_CFUNC simd_dot(simd_float2 __x, simd_float2 __y);
134static float SIMD_CFUNC simd_dot(simd_float3 __x, simd_float3 __y);
135static float SIMD_CFUNC simd_dot(simd_float4 __x, simd_float4 __y);
136static float SIMD_CFUNC simd_dot(simd_float8 __x, simd_float8 __y);
137static float SIMD_CFUNC simd_dot(simd_float16 __x, simd_float16 __y);
138static double SIMD_CFUNC simd_dot(simd_double2 __x, simd_double2 __y);
139static double SIMD_CFUNC simd_dot(simd_double3 __x, simd_double3 __y);
140static double SIMD_CFUNC simd_dot(simd_double4 __x, simd_double4 __y);
141static double SIMD_CFUNC simd_dot(simd_double8 __x, simd_double8 __y);
142#define vector_dot simd_dot
143
144static simd_float2 SIMD_CFUNC simd_precise_project(simd_float2 __x, simd_float2 __y);
145static simd_float3 SIMD_CFUNC simd_precise_project(simd_float3 __x, simd_float3 __y);
146static simd_float4 SIMD_CFUNC simd_precise_project(simd_float4 __x, simd_float4 __y);
147static simd_float8 SIMD_CFUNC simd_precise_project(simd_float8 __x, simd_float8 __y);
148static simd_float16 SIMD_CFUNC simd_precise_project(simd_float16 __x, simd_float16 __y);
149static simd_double2 SIMD_CFUNC simd_precise_project(simd_double2 __x, simd_double2 __y);
150static simd_double3 SIMD_CFUNC simd_precise_project(simd_double3 __x, simd_double3 __y);
151static simd_double4 SIMD_CFUNC simd_precise_project(simd_double4 __x, simd_double4 __y);
152static simd_double8 SIMD_CFUNC simd_precise_project(simd_double8 __x, simd_double8 __y);
153#define vector_precise_project simd_precise_project
154
155static simd_float2 SIMD_CFUNC simd_fast_project(simd_float2 __x, simd_float2 __y);
156static simd_float3 SIMD_CFUNC simd_fast_project(simd_float3 __x, simd_float3 __y);
157static simd_float4 SIMD_CFUNC simd_fast_project(simd_float4 __x, simd_float4 __y);
158static simd_float8 SIMD_CFUNC simd_fast_project(simd_float8 __x, simd_float8 __y);
159static simd_float16 SIMD_CFUNC simd_fast_project(simd_float16 __x, simd_float16 __y);
160static simd_double2 SIMD_CFUNC simd_fast_project(simd_double2 __x, simd_double2 __y);
161static simd_double3 SIMD_CFUNC simd_fast_project(simd_double3 __x, simd_double3 __y);
162static simd_double4 SIMD_CFUNC simd_fast_project(simd_double4 __x, simd_double4 __y);
163static simd_double8 SIMD_CFUNC simd_fast_project(simd_double8 __x, simd_double8 __y);
164#define vector_fast_project simd_fast_project
165
166static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y);
167static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y);
168static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y);
169static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y);
170static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y);
171static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y);
172static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y);
173static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y);
174static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y);
175#define vector_project simd_project
176
177static float SIMD_CFUNC simd_precise_length(simd_float2 __x);
178static float SIMD_CFUNC simd_precise_length(simd_float3 __x);
179static float SIMD_CFUNC simd_precise_length(simd_float4 __x);
180static float SIMD_CFUNC simd_precise_length(simd_float8 __x);
181static float SIMD_CFUNC simd_precise_length(simd_float16 __x);
182static double SIMD_CFUNC simd_precise_length(simd_double2 __x);
183static double SIMD_CFUNC simd_precise_length(simd_double3 __x);
184static double SIMD_CFUNC simd_precise_length(simd_double4 __x);
185static double SIMD_CFUNC simd_precise_length(simd_double8 __x);
186#define vector_precise_length simd_precise_length
187
188static float SIMD_CFUNC simd_fast_length(simd_float2 __x);
189static float SIMD_CFUNC simd_fast_length(simd_float3 __x);
190static float SIMD_CFUNC simd_fast_length(simd_float4 __x);
191static float SIMD_CFUNC simd_fast_length(simd_float8 __x);
192static float SIMD_CFUNC simd_fast_length(simd_float16 __x);
193static double SIMD_CFUNC simd_fast_length(simd_double2 __x);
194static double SIMD_CFUNC simd_fast_length(simd_double3 __x);
195static double SIMD_CFUNC simd_fast_length(simd_double4 __x);
196static double SIMD_CFUNC simd_fast_length(simd_double8 __x);
197#define vector_fast_length simd_fast_length
198
199static float SIMD_CFUNC simd_length(simd_float2 __x);
200static float SIMD_CFUNC simd_length(simd_float3 __x);
201static float SIMD_CFUNC simd_length(simd_float4 __x);
202static float SIMD_CFUNC simd_length(simd_float8 __x);
203static float SIMD_CFUNC simd_length(simd_float16 __x);
204static double SIMD_CFUNC simd_length(simd_double2 __x);
205static double SIMD_CFUNC simd_length(simd_double3 __x);
206static double SIMD_CFUNC simd_length(simd_double4 __x);
207static double SIMD_CFUNC simd_length(simd_double8 __x);
208#define vector_length simd_length
209
210static float SIMD_CFUNC simd_length_squared(simd_float2 __x);
211static float SIMD_CFUNC simd_length_squared(simd_float3 __x);
212static float SIMD_CFUNC simd_length_squared(simd_float4 __x);
213static float SIMD_CFUNC simd_length_squared(simd_float8 __x);
214static float SIMD_CFUNC simd_length_squared(simd_float16 __x);
215static double SIMD_CFUNC simd_length_squared(simd_double2 __x);
216static double SIMD_CFUNC simd_length_squared(simd_double3 __x);
217static double SIMD_CFUNC simd_length_squared(simd_double4 __x);
218static double SIMD_CFUNC simd_length_squared(simd_double8 __x);
219#define vector_length_squared simd_length_squared
220
221static float SIMD_CFUNC simd_norm_one(simd_float2 __x);
222static float SIMD_CFUNC simd_norm_one(simd_float3 __x);
223static float SIMD_CFUNC simd_norm_one(simd_float4 __x);
224static float SIMD_CFUNC simd_norm_one(simd_float8 __x);
225static float SIMD_CFUNC simd_norm_one(simd_float16 __x);
226static double SIMD_CFUNC simd_norm_one(simd_double2 __x);
227static double SIMD_CFUNC simd_norm_one(simd_double3 __x);
228static double SIMD_CFUNC simd_norm_one(simd_double4 __x);
229static double SIMD_CFUNC simd_norm_one(simd_double8 __x);
230#define vector_norm_one simd_norm_one
231
232static float SIMD_CFUNC simd_norm_inf(simd_float2 __x);
233static float SIMD_CFUNC simd_norm_inf(simd_float3 __x);
234static float SIMD_CFUNC simd_norm_inf(simd_float4 __x);
235static float SIMD_CFUNC simd_norm_inf(simd_float8 __x);
236static float SIMD_CFUNC simd_norm_inf(simd_float16 __x);
237static double SIMD_CFUNC simd_norm_inf(simd_double2 __x);
238static double SIMD_CFUNC simd_norm_inf(simd_double3 __x);
239static double SIMD_CFUNC simd_norm_inf(simd_double4 __x);
240static double SIMD_CFUNC simd_norm_inf(simd_double8 __x);
241#define vector_norm_inf simd_norm_inf
242
243static float SIMD_CFUNC simd_precise_distance(simd_float2 __x, simd_float2 __y);
244static float SIMD_CFUNC simd_precise_distance(simd_float3 __x, simd_float3 __y);
245static float SIMD_CFUNC simd_precise_distance(simd_float4 __x, simd_float4 __y);
246static float SIMD_CFUNC simd_precise_distance(simd_float8 __x, simd_float8 __y);
247static float SIMD_CFUNC simd_precise_distance(simd_float16 __x, simd_float16 __y);
248static double SIMD_CFUNC simd_precise_distance(simd_double2 __x, simd_double2 __y);
249static double SIMD_CFUNC simd_precise_distance(simd_double3 __x, simd_double3 __y);
250static double SIMD_CFUNC simd_precise_distance(simd_double4 __x, simd_double4 __y);
251static double SIMD_CFUNC simd_precise_distance(simd_double8 __x, simd_double8 __y);
252#define vector_precise_distance simd_precise_distance
253
254static float SIMD_CFUNC simd_fast_distance(simd_float2 __x, simd_float2 __y);
255static float SIMD_CFUNC simd_fast_distance(simd_float3 __x, simd_float3 __y);
256static float SIMD_CFUNC simd_fast_distance(simd_float4 __x, simd_float4 __y);
257static float SIMD_CFUNC simd_fast_distance(simd_float8 __x, simd_float8 __y);
258static float SIMD_CFUNC simd_fast_distance(simd_float16 __x, simd_float16 __y);
259static double SIMD_CFUNC simd_fast_distance(simd_double2 __x, simd_double2 __y);
260static double SIMD_CFUNC simd_fast_distance(simd_double3 __x, simd_double3 __y);
261static double SIMD_CFUNC simd_fast_distance(simd_double4 __x, simd_double4 __y);
262static double SIMD_CFUNC simd_fast_distance(simd_double8 __x, simd_double8 __y);
263#define vector_fast_distance simd_fast_distance
264
265static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y);
266static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y);
267static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y);
268static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y);
269static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y);
270static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y);
271static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y);
272static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y);
273static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y);
274#define vector_distance simd_distance
275
276static float SIMD_CFUNC simd_distance_squared(simd_float2 __x, simd_float2 __y);
277static float SIMD_CFUNC simd_distance_squared(simd_float3 __x, simd_float3 __y);
278static float SIMD_CFUNC simd_distance_squared(simd_float4 __x, simd_float4 __y);
279static float SIMD_CFUNC simd_distance_squared(simd_float8 __x, simd_float8 __y);
280static float SIMD_CFUNC simd_distance_squared(simd_float16 __x, simd_float16 __y);
281static double SIMD_CFUNC simd_distance_squared(simd_double2 __x, simd_double2 __y);
282static double SIMD_CFUNC simd_distance_squared(simd_double3 __x, simd_double3 __y);
283static double SIMD_CFUNC simd_distance_squared(simd_double4 __x, simd_double4 __y);
284static double SIMD_CFUNC simd_distance_squared(simd_double8 __x, simd_double8 __y);
285#define vector_distance_squared simd_distance_squared
286
287static simd_float2 SIMD_CFUNC simd_precise_normalize(simd_float2 __x);
288static simd_float3 SIMD_CFUNC simd_precise_normalize(simd_float3 __x);
289static simd_float4 SIMD_CFUNC simd_precise_normalize(simd_float4 __x);
290static simd_float8 SIMD_CFUNC simd_precise_normalize(simd_float8 __x);
291static simd_float16 SIMD_CFUNC simd_precise_normalize(simd_float16 __x);
292static simd_double2 SIMD_CFUNC simd_precise_normalize(simd_double2 __x);
293static simd_double3 SIMD_CFUNC simd_precise_normalize(simd_double3 __x);
294static simd_double4 SIMD_CFUNC simd_precise_normalize(simd_double4 __x);
295static simd_double8 SIMD_CFUNC simd_precise_normalize(simd_double8 __x);
296#define vector_precise_normalize simd_precise_normalize
297
298static simd_float2 SIMD_CFUNC simd_fast_normalize(simd_float2 __x);
299static simd_float3 SIMD_CFUNC simd_fast_normalize(simd_float3 __x);
300static simd_float4 SIMD_CFUNC simd_fast_normalize(simd_float4 __x);
301static simd_float8 SIMD_CFUNC simd_fast_normalize(simd_float8 __x);
302static simd_float16 SIMD_CFUNC simd_fast_normalize(simd_float16 __x);
303static simd_double2 SIMD_CFUNC simd_fast_normalize(simd_double2 __x);
304static simd_double3 SIMD_CFUNC simd_fast_normalize(simd_double3 __x);
305static simd_double4 SIMD_CFUNC simd_fast_normalize(simd_double4 __x);
306static simd_double8 SIMD_CFUNC simd_fast_normalize(simd_double8 __x);
307#define vector_fast_normalize simd_fast_normalize
308
309static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x);
310static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x);
311static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x);
312static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x);
313static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x);
314static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x);
315static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x);
316static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x);
317static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x);
318#define vector_normalize simd_normalize
319
320static simd_float3 SIMD_CFUNC simd_cross(simd_float2 __x, simd_float2 __y);
321static simd_float3 SIMD_CFUNC simd_cross(simd_float3 __x, simd_float3 __y);
322static simd_double3 SIMD_CFUNC simd_cross(simd_double2 __x, simd_double2 __y);
323static simd_double3 SIMD_CFUNC simd_cross(simd_double3 __x, simd_double3 __y);
324#define vector_cross simd_cross
325
326static simd_float2 SIMD_CFUNC simd_reflect(simd_float2 __x, simd_float2 __n);
327static simd_float3 SIMD_CFUNC simd_reflect(simd_float3 __x, simd_float3 __n);
328static simd_float4 SIMD_CFUNC simd_reflect(simd_float4 __x, simd_float4 __n);
329static simd_double2 SIMD_CFUNC simd_reflect(simd_double2 __x, simd_double2 __n);
330static simd_double3 SIMD_CFUNC simd_reflect(simd_double3 __x, simd_double3 __n);
331static simd_double4 SIMD_CFUNC simd_reflect(simd_double4 __x, simd_double4 __n);
332#define vector_reflect simd_reflect
333
334static simd_float2 SIMD_CFUNC simd_refract(simd_float2 __x, simd_float2 __n, float __eta);
335static simd_float3 SIMD_CFUNC simd_refract(simd_float3 __x, simd_float3 __n, float __eta);
336static simd_float4 SIMD_CFUNC simd_refract(simd_float4 __x, simd_float4 __n, float __eta);
337static simd_double2 SIMD_CFUNC simd_refract(simd_double2 __x, simd_double2 __n, double __eta);
338static simd_double3 SIMD_CFUNC simd_refract(simd_double3 __x, simd_double3 __n, double __eta);
339static simd_double4 SIMD_CFUNC simd_refract(simd_double4 __x, simd_double4 __n, double __eta);
340#define vector_refract simd_refract
341
342#if SIMD_LIBRARY_VERSION >= 2
343/* These functions require that you are building for OS X 10.12 or later,
344 * iOS 10.0 or later, watchOS 3.0 or later, and tvOS 10.0 or later. On
345 * earlier OS versions, the library functions that implement these
346 * operations are not available. */
347
348/*! @functiongroup vector orientation
349 *
350 * @discussion These functions return a positive value if the origin and
351 * their ordered arguments determine a positively oriented parallelepiped,
352 * zero if it is degenerate, and a negative value if it is negatively
353 * oriented. This is equivalent to saying that the matrix with rows equal
354 * to the vectors has a positive, zero, or negative determinant,
355 * respectively.
356 *
357 * Naive evaluation of the determinant is prone to producing incorrect
358 * results if the vectors are nearly degenerate (e.g. floating-point
359 * rounding might cause the determinant to be zero or negative when
360 * the points are very nearly coplanar but positively oriented). If
361 * the vectors are very large or small, computing the determininat is
362 * also prone to premature overflow, which may cause the result to be
363 * NaN even though the vectors contain normal floating-point numbers.
364 *
365 * These routines take care to avoid those issues and always return a
366 * result with correct sign, even when the problem is very ill-
367 * conditioned. */
368
369/*! @abstract Test the orientation of two 2d vectors.
370 *
371 * @param __x The first vector.
372 * @param __y The second vector.
373 *
374 * @result Positive if (x, y) are positively oriented, zero if they are
375 * colinear, and negative if they are negatively oriented.
376 *
377 * @discussion For two-dimensional vectors, "positively oriented" is
378 * equivalent to the ordering (0, x, y) proceeding counter-clockwise
379 * when viewed down the z axis, or to the cross product of x and y
380 * extended to three-dimensions having positive z-component. */
381static float SIMD_CFUNC simd_orient(simd_float2 __x, simd_float2 __y);
382
383/*! @abstract Test the orientation of two 2d vectors.
384 *
385 * @param __x The first vector.
386 * @param __y The second vector.
387 *
388 * @result Positive if (x, y) are positively oriented, zero if they are
389 * colinear, and negative if they are negatively oriented.
390 *
391 * @discussion For two-dimensional vectors, "positively oriented" is
392 * equivalent to the ordering (0, x, y) proceeding counter- clockwise
393 * when viewed down the z axis, or to the cross product of x and y
394 * extended to three-dimensions having positive z-component. */
395static double SIMD_CFUNC simd_orient(simd_double2 __x, simd_double2 __y);
396
397/*! @abstract Test the orientation of three 3d vectors.
398 *
399 * @param __x The first vector.
400 * @param __y The second vector.
401 * @param __z The third vector.
402 *
403 * @result Positive if (x, y, z) are positively oriented, zero if they
404 * are coplanar, and negative if they are negatively oriented.
405 *
406 * @discussion For three-dimensional vectors, "positively oriented" is
407 * equivalent to the ordering (x, y, z) following the "right hand rule",
408 * or to the dot product of z with the cross product of x and y being
409 * positive. */
410static float SIMD_CFUNC simd_orient(simd_float3 __x, simd_float3 __y, simd_float3 __z);
411
412/*! @abstract Test the orientation of three 3d vectors.
413 *
414 * @param __x The first vector.
415 * @param __y The second vector.
416 * @param __z The third vector.
417 *
418 * @result Positive if (x, y, c) are positively oriented, zero if they
419 * are coplanar, and negative if they are negatively oriented.
420 *
421 * @discussion For three-dimensional vectors, "positively oriented" is
422 * equivalent to the ordering (x, y, z) following the "right hand rule",
423 * or to the dot product of z with the cross product of x and y being
424 * positive. */
425static double SIMD_CFUNC simd_orient(simd_double3 __x, simd_double3 __y, simd_double3 __z);
426
427/*! @functiongroup point (affine) orientation
428 *
429 * @discussion These functions return a positive value if their ordered
430 * arguments determine a positively oriented parallelepiped, zero if it
431 * is degenerate, and a negative value if it is negatively oriented.
432 *
433 * simd_orient(a, b, c) is formally equivalent to simd_orient(b-a, c-a),
434 * but it is not effected by rounding error from subtraction of points,
435 * as that implementation would be. Care is taken so that the sign of
436 * the result is always correct, even if the problem is ill-conditioned. */
437
438/*! @abstract Test the orientation of a triangle in 2d.
439 *
440 * @param __a The first point of the triangle.
441 * @param __b The second point of the triangle.
442 * @param __c The third point of the triangle.
443 *
444 * @result Positive if the triangle is positively oriented, zero if it
445 * is degenerate (three points in a line), and negative if it is negatively
446 * oriented.
447 *
448 * @discussion "Positively oriented" is equivalent to the ordering
449 * (a, b, c) proceeding counter-clockwise when viewed down the z axis,
450 * or to the cross product of a-c and b-c extended to three-dimensions
451 * having positive z-component. */
452static float SIMD_CFUNC simd_orient(simd_float2 __a, simd_float2 __b, simd_float2 __c);
453
454/*! @abstract Test the orientation of a triangle in 2d.
455 *
456 * @param __a The first point of the triangle.
457 * @param __b The second point of the triangle.
458 * @param __c The third point of the triangle.
459 *
460 * @result Positive if the triangle is positively oriented, zero if it
461 * is degenerate (three points in a line), and negative if it is negatively
462 * oriented.
463 *
464 * @discussion "Positively oriented" is equivalent to the ordering
465 * (a, b, c) proceeding counter-clockwise when viewed down the z axis,
466 * or to the cross product of a-c and b-c extended to three-dimensions
467 * having positive z-component. */
468static double SIMD_CFUNC simd_orient(simd_double2 __a, simd_double2 __b, simd_double2 __c);
469
470/*! @abstract Test the orientation of a tetrahedron in 3d.
471 *
472 * @param __a The first point of the tetrahedron.
473 * @param __b The second point of the tetrahedron.
474 * @param __c The third point of the tetrahedron.
475 * @param __d The fourth point of the tetrahedron.
476 *
477 * @result Positive if the tetrahedron is positively oriented, zero if it
478 * is degenerate (four points in a plane), and negative if it is negatively
479 * oriented.
480 *
481 * @discussion "Positively oriented" is equivalent to the vectors
482 * (a-d, b-d, c-d) following the "right hand rule", or to the dot product
483 * of c-d with the the cross product of a-d and b-d being positive. */
484static float SIMD_CFUNC simd_orient(simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d);
485
486/*! @abstract Test the orientation of a tetrahedron in 3d.
487 *
488 * @param __a The first point of the tetrahedron.
489 * @param __b The second point of the tetrahedron.
490 * @param __c The third point of the tetrahedron.
491 * @param __d The fourth point of the tetrahedron.
492 *
493 * @result Positive if the tetrahedron is positively oriented, zero if it
494 * is degenerate (four points in a plane), and negative if it is negatively
495 * oriented.
496 *
497 * @discussion "Positively oriented" is equivalent to the vectors
498 * (a-d, b-d, c-d) following the "right hand rule", or to the dot product
499 * of c-d with the the cross product of a-d and b-d being positive. */
500static double SIMD_CFUNC simd_orient(simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d);
501
502/*! @functiongroup incircle (points) tests
503 *
504 * @discussion These functions determine whether the point x is inside, on,
505 * or outside the circle or sphere passing through a group of points. If
506 * x is inside the circle, the result is positive; if x is on the circle,
507 * the result is zero; if x is outside the circle the result is negative.
508 *
509 * These functions are always exact, even if the problem is ill-
510 * conditioned (meaning that the points are nearly co-linear or
511 * co-planar).
512 *
513 * If the points are negatively-oriented, the the notions of "inside" and
514 * "outside" are flipped. If the points are degenerate, then the result
515 * is undefined. */
516
517/*! @abstract Test if x lies inside, on, or outside the circle passing
518 * through a, b, and c.
519 *
520 * @param __x The point being tested.
521 * @param __a The first point determining the circle.
522 * @param __b The second point determining the circle.
523 * @param __c The third point determining the circle.
524 *
525 * @result Assuming that (a,b,c) are positively-oriented, positive if x is
526 * inside the circle, zero if x is on the circle, and negative if x is
527 * outside the circle. The sign of the result is flipped if (a,b,c) are
528 * negatively-oriented. */
529static float SIMD_CFUNC simd_incircle(simd_float2 __x, simd_float2 __a, simd_float2 __b, simd_float2 __c);
530
531/*! @abstract Test if x lies inside, on, or outside the circle passing
532 * through a, b, and c.
533 *
534 * @param __x The point being tested.
535 * @param __a The first point determining the circle.
536 * @param __b The second point determining the circle.
537 * @param __c The third point determining the circle.
538 *
539 * @result Assuming that (a,b,c) are positively-oriented, positive if x is
540 * inside the circle, zero if x is on the circle, and negative if x is
541 * outside the circle. The sign of the result is flipped if (a,b,c) are
542 * negatively-oriented. */
543static double SIMD_CFUNC simd_incircle(simd_double2 __x, simd_double2 __a, simd_double2 __b, simd_double2 __c);
544
545/*! @abstract Test if x lies inside, on, or outside the sphere passing
546 * through a, b, c, and d.
547 *
548 * @param __x The point being tested.
549 * @param __a The first point determining the sphere.
550 * @param __b The second point determining the sphere.
551 * @param __c The third point determining the sphere.
552 * @param __d The fourth point determining the sphere.
553 *
554 * @result Assuming that the points are positively-oriented, positive if x
555 * is inside the sphere, zero if x is on the sphere, and negative if x is
556 * outside the sphere. The sign of the result is flipped if the points are
557 * negatively-oriented. */
558static float SIMD_CFUNC simd_insphere(simd_float3 __x, simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d);
559
560/*! @abstract Test if x lies inside, on, or outside the sphere passing
561 * through a, b, c, and d.
562 *
563 * @param __x The point being tested.
564 * @param __a The first point determining the sphere.
565 * @param __b The second point determining the sphere.
566 * @param __c The third point determining the sphere.
567 * @param __d The fourth point determining the sphere.
568 *
569 * @result Assuming that the points are positively-oriented, positive if x
570 * is inside the sphere, zero if x is on the sphere, and negative if x is
571 * outside the sphere. The sign of the result is flipped if the points are
572 * negatively-oriented. */
573static double SIMD_CFUNC simd_insphere(simd_double3 __x, simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d);
574#endif /* SIMD_LIBRARY_VERSION */
575
576#ifdef __cplusplus
577} /* extern "C" */
578
579namespace simd {
580 static SIMD_CPPFUNC float dot(const float2 x, const float2 y) { return ::simd_dot(x, y); }
581 static SIMD_CPPFUNC float dot(const float3 x, const float3 y) { return ::simd_dot(x, y); }
582 static SIMD_CPPFUNC float dot(const float4 x, const float4 y) { return ::simd_dot(x, y); }
583 static SIMD_CPPFUNC float dot(const float8 x, const float8 y) { return ::simd_dot(x, y); }
584 static SIMD_CPPFUNC float dot(const float16 x, const float16 y) { return ::simd_dot(x, y); }
585 static SIMD_CPPFUNC double dot(const double2 x, const double2 y) { return ::simd_dot(x, y); }
586 static SIMD_CPPFUNC double dot(const double3 x, const double3 y) { return ::simd_dot(x, y); }
587 static SIMD_CPPFUNC double dot(const double4 x, const double4 y) { return ::simd_dot(x, y); }
588 static SIMD_CPPFUNC double dot(const double8 x, const double8 y) { return ::simd_dot(x, y); }
589
590 static SIMD_CPPFUNC float2 project(const float2 x, const float2 y) { return ::simd_project(x, y); }
591 static SIMD_CPPFUNC float3 project(const float3 x, const float3 y) { return ::simd_project(x, y); }
592 static SIMD_CPPFUNC float4 project(const float4 x, const float4 y) { return ::simd_project(x, y); }
593 static SIMD_CPPFUNC float8 project(const float8 x, const float8 y) { return ::simd_project(x, y); }
594 static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_project(x, y); }
595 static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_project(x, y); }
596 static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_project(x, y); }
597 static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_project(x, y); }
598 static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_project(x, y); }
599
600 static SIMD_CPPFUNC float length_squared(const float2 x) { return ::simd_length_squared(x); }
601 static SIMD_CPPFUNC float length_squared(const float3 x) { return ::simd_length_squared(x); }
602 static SIMD_CPPFUNC float length_squared(const float4 x) { return ::simd_length_squared(x); }
603 static SIMD_CPPFUNC float length_squared(const float8 x) { return ::simd_length_squared(x); }
604 static SIMD_CPPFUNC float length_squared(const float16 x) { return ::simd_length_squared(x); }
605 static SIMD_CPPFUNC double length_squared(const double2 x) { return ::simd_length_squared(x); }
606 static SIMD_CPPFUNC double length_squared(const double3 x) { return ::simd_length_squared(x); }
607 static SIMD_CPPFUNC double length_squared(const double4 x) { return ::simd_length_squared(x); }
608 static SIMD_CPPFUNC double length_squared(const double8 x) { return ::simd_length_squared(x); }
609
610 static SIMD_CPPFUNC float norm_one(const float2 x) { return ::simd_norm_one(x); }
611 static SIMD_CPPFUNC float norm_one(const float3 x) { return ::simd_norm_one(x); }
612 static SIMD_CPPFUNC float norm_one(const float4 x) { return ::simd_norm_one(x); }
613 static SIMD_CPPFUNC float norm_one(const float8 x) { return ::simd_norm_one(x); }
614 static SIMD_CPPFUNC float norm_one(const float16 x) { return ::simd_norm_one(x); }
615 static SIMD_CPPFUNC double norm_one(const double2 x) { return ::simd_norm_one(x); }
616 static SIMD_CPPFUNC double norm_one(const double3 x) { return ::simd_norm_one(x); }
617 static SIMD_CPPFUNC double norm_one(const double4 x) { return ::simd_norm_one(x); }
618 static SIMD_CPPFUNC double norm_one(const double8 x) { return ::simd_norm_one(x); }
619
620 static SIMD_CPPFUNC float norm_inf(const float2 x) { return ::simd_norm_inf(x); }
621 static SIMD_CPPFUNC float norm_inf(const float3 x) { return ::simd_norm_inf(x); }
622 static SIMD_CPPFUNC float norm_inf(const float4 x) { return ::simd_norm_inf(x); }
623 static SIMD_CPPFUNC float norm_inf(const float8 x) { return ::simd_norm_inf(x); }
624 static SIMD_CPPFUNC float norm_inf(const float16 x) { return ::simd_norm_inf(x); }
625 static SIMD_CPPFUNC double norm_inf(const double2 x) { return ::simd_norm_inf(x); }
626 static SIMD_CPPFUNC double norm_inf(const double3 x) { return ::simd_norm_inf(x); }
627 static SIMD_CPPFUNC double norm_inf(const double4 x) { return ::simd_norm_inf(x); }
628 static SIMD_CPPFUNC double norm_inf(const double8 x) { return ::simd_norm_inf(x); }
629
630 static SIMD_CPPFUNC float length(const float2 x) { return ::simd_length(x); }
631 static SIMD_CPPFUNC float length(const float3 x) { return ::simd_length(x); }
632 static SIMD_CPPFUNC float length(const float4 x) { return ::simd_length(x); }
633 static SIMD_CPPFUNC float length(const float8 x) { return ::simd_length(x); }
634 static SIMD_CPPFUNC float length(const float16 x) { return ::simd_length(x); }
635 static SIMD_CPPFUNC double length(const double2 x) { return ::simd_length(x); }
636 static SIMD_CPPFUNC double length(const double3 x) { return ::simd_length(x); }
637 static SIMD_CPPFUNC double length(const double4 x) { return ::simd_length(x); }
638 static SIMD_CPPFUNC double length(const double8 x) { return ::simd_length(x); }
639
640 static SIMD_CPPFUNC float distance_squared(const float2 x, const float2 y) { return ::simd_distance_squared(x, y); }
641 static SIMD_CPPFUNC float distance_squared(const float3 x, const float3 y) { return ::simd_distance_squared(x, y); }
642 static SIMD_CPPFUNC float distance_squared(const float4 x, const float4 y) { return ::simd_distance_squared(x, y); }
643 static SIMD_CPPFUNC float distance_squared(const float8 x, const float8 y) { return ::simd_distance_squared(x, y); }
644 static SIMD_CPPFUNC float distance_squared(const float16 x, const float16 y) { return ::simd_distance_squared(x, y); }
645 static SIMD_CPPFUNC double distance_squared(const double2 x, const double2 y) { return ::simd_distance_squared(x, y); }
646 static SIMD_CPPFUNC double distance_squared(const double3 x, const double3 y) { return ::simd_distance_squared(x, y); }
647 static SIMD_CPPFUNC double distance_squared(const double4 x, const double4 y) { return ::simd_distance_squared(x, y); }
648 static SIMD_CPPFUNC double distance_squared(const double8 x, const double8 y) { return ::simd_distance_squared(x, y); }
649
650 static SIMD_CPPFUNC float distance(const float2 x, const float2 y) { return ::simd_distance(x, y); }
651 static SIMD_CPPFUNC float distance(const float3 x, const float3 y) { return ::simd_distance(x, y); }
652 static SIMD_CPPFUNC float distance(const float4 x, const float4 y) { return ::simd_distance(x, y); }
653 static SIMD_CPPFUNC float distance(const float8 x, const float8 y) { return ::simd_distance(x, y); }
654 static SIMD_CPPFUNC float distance(const float16 x, const float16 y) { return ::simd_distance(x, y); }
655 static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_distance(x, y); }
656 static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_distance(x, y); }
657 static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_distance(x, y); }
658 static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_distance(x, y); }
659
660 static SIMD_CPPFUNC float2 normalize(const float2 x) { return ::simd_normalize(x); }
661 static SIMD_CPPFUNC float3 normalize(const float3 x) { return ::simd_normalize(x); }
662 static SIMD_CPPFUNC float4 normalize(const float4 x) { return ::simd_normalize(x); }
663 static SIMD_CPPFUNC float8 normalize(const float8 x) { return ::simd_normalize(x); }
664 static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_normalize(x); }
665 static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_normalize(x); }
666 static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_normalize(x); }
667 static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_normalize(x); }
668 static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_normalize(x); }
669
670 static SIMD_CPPFUNC float3 cross(const float2 x, const float2 y) { return ::simd_cross(x,y); }
671 static SIMD_CPPFUNC float3 cross(const float3 x, const float3 y) { return ::simd_cross(x,y); }
672 static SIMD_CPPFUNC double3 cross(const double2 x, const double2 y) { return ::simd_cross(x,y); }
673 static SIMD_CPPFUNC double3 cross(const double3 x, const double3 y) { return ::simd_cross(x,y); }
674
675 static SIMD_CPPFUNC float2 reflect(const float2 x, const float2 n) { return ::simd_reflect(x,n); }
676 static SIMD_CPPFUNC float3 reflect(const float3 x, const float3 n) { return ::simd_reflect(x,n); }
677 static SIMD_CPPFUNC float4 reflect(const float4 x, const float4 n) { return ::simd_reflect(x,n); }
678 static SIMD_CPPFUNC double2 reflect(const double2 x, const double2 n) { return ::simd_reflect(x,n); }
679 static SIMD_CPPFUNC double3 reflect(const double3 x, const double3 n) { return ::simd_reflect(x,n); }
680 static SIMD_CPPFUNC double4 reflect(const double4 x, const double4 n) { return ::simd_reflect(x,n); }
681
682 static SIMD_CPPFUNC float2 refract(const float2 x, const float2 n, const float eta) { return ::simd_refract(x,n,eta); }
683 static SIMD_CPPFUNC float3 refract(const float3 x, const float3 n, const float eta) { return ::simd_refract(x,n,eta); }
684 static SIMD_CPPFUNC float4 refract(const float4 x, const float4 n, const float eta) { return ::simd_refract(x,n,eta); }
685 static SIMD_CPPFUNC double2 refract(const double2 x, const double2 n, const float eta) { return ::simd_refract(x,n,eta); }
686 static SIMD_CPPFUNC double3 refract(const double3 x, const double3 n, const float eta) { return ::simd_refract(x,n,eta); }
687 static SIMD_CPPFUNC double4 refract(const double4 x, const double4 n, const float eta) { return ::simd_refract(x,n,eta); }
688
689 /* precise and fast sub-namespaces */
690 namespace precise {
691 static SIMD_CPPFUNC float2 project(const float2 x, const float2 y) { return ::simd_precise_project(x, y); }
692 static SIMD_CPPFUNC float3 project(const float3 x, const float3 y) { return ::simd_precise_project(x, y); }
693 static SIMD_CPPFUNC float4 project(const float4 x, const float4 y) { return ::simd_precise_project(x, y); }
694 static SIMD_CPPFUNC float8 project(const float8 x, const float8 y) { return ::simd_precise_project(x, y); }
695 static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_precise_project(x, y); }
696 static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_precise_project(x, y); }
697 static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_precise_project(x, y); }
698 static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_precise_project(x, y); }
699 static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_precise_project(x, y); }
700
701 static SIMD_CPPFUNC float length(const float2 x) { return ::simd_precise_length(x); }
702 static SIMD_CPPFUNC float length(const float3 x) { return ::simd_precise_length(x); }
703 static SIMD_CPPFUNC float length(const float4 x) { return ::simd_precise_length(x); }
704 static SIMD_CPPFUNC float length(const float8 x) { return ::simd_precise_length(x); }
705 static SIMD_CPPFUNC float length(const float16 x) { return ::simd_precise_length(x); }
706 static SIMD_CPPFUNC double length(const double2 x) { return ::simd_precise_length(x); }
707 static SIMD_CPPFUNC double length(const double3 x) { return ::simd_precise_length(x); }
708 static SIMD_CPPFUNC double length(const double4 x) { return ::simd_precise_length(x); }
709 static SIMD_CPPFUNC double length(const double8 x) { return ::simd_precise_length(x); }
710
711 static SIMD_CPPFUNC float distance(const float2 x, const float2 y) { return ::simd_precise_distance(x, y); }
712 static SIMD_CPPFUNC float distance(const float3 x, const float3 y) { return ::simd_precise_distance(x, y); }
713 static SIMD_CPPFUNC float distance(const float4 x, const float4 y) { return ::simd_precise_distance(x, y); }
714 static SIMD_CPPFUNC float distance(const float8 x, const float8 y) { return ::simd_precise_distance(x, y); }
715 static SIMD_CPPFUNC float distance(const float16 x, const float16 y) { return ::simd_precise_distance(x, y); }
716 static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_precise_distance(x, y); }
717 static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_precise_distance(x, y); }
718 static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_precise_distance(x, y); }
719 static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_precise_distance(x, y); }
720
721 static SIMD_CPPFUNC float2 normalize(const float2 x) { return ::simd_precise_normalize(x); }
722 static SIMD_CPPFUNC float3 normalize(const float3 x) { return ::simd_precise_normalize(x); }
723 static SIMD_CPPFUNC float4 normalize(const float4 x) { return ::simd_precise_normalize(x); }
724 static SIMD_CPPFUNC float8 normalize(const float8 x) { return ::simd_precise_normalize(x); }
725 static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_precise_normalize(x); }
726 static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_precise_normalize(x); }
727 static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_precise_normalize(x); }
728 static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_precise_normalize(x); }
729 static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_precise_normalize(x); }
730 }
731
732 namespace fast {
733 static SIMD_CPPFUNC float2 project(const float2 x, const float2 y) { return ::simd_fast_project(x, y); }
734 static SIMD_CPPFUNC float3 project(const float3 x, const float3 y) { return ::simd_fast_project(x, y); }
735 static SIMD_CPPFUNC float4 project(const float4 x, const float4 y) { return ::simd_fast_project(x, y); }
736 static SIMD_CPPFUNC float8 project(const float8 x, const float8 y) { return ::simd_fast_project(x, y); }
737 static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_fast_project(x, y); }
738 static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_fast_project(x, y); }
739 static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_fast_project(x, y); }
740 static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_fast_project(x, y); }
741 static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_fast_project(x, y); }
742
743 static SIMD_CPPFUNC float length(const float2 x) { return ::simd_fast_length(x); }
744 static SIMD_CPPFUNC float length(const float3 x) { return ::simd_fast_length(x); }
745 static SIMD_CPPFUNC float length(const float4 x) { return ::simd_fast_length(x); }
746 static SIMD_CPPFUNC float length(const float8 x) { return ::simd_fast_length(x); }
747 static SIMD_CPPFUNC float length(const float16 x) { return ::simd_fast_length(x); }
748 static SIMD_CPPFUNC double length(const double2 x) { return ::simd_fast_length(x); }
749 static SIMD_CPPFUNC double length(const double3 x) { return ::simd_fast_length(x); }
750 static SIMD_CPPFUNC double length(const double4 x) { return ::simd_fast_length(x); }
751 static SIMD_CPPFUNC double length(const double8 x) { return ::simd_fast_length(x); }
752
753 static SIMD_CPPFUNC float distance(const float2 x, const float2 y) { return ::simd_fast_distance(x, y); }
754 static SIMD_CPPFUNC float distance(const float3 x, const float3 y) { return ::simd_fast_distance(x, y); }
755 static SIMD_CPPFUNC float distance(const float4 x, const float4 y) { return ::simd_fast_distance(x, y); }
756 static SIMD_CPPFUNC float distance(const float8 x, const float8 y) { return ::simd_fast_distance(x, y); }
757 static SIMD_CPPFUNC float distance(const float16 x, const float16 y) { return ::simd_fast_distance(x, y); }
758 static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_fast_distance(x, y); }
759 static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_fast_distance(x, y); }
760 static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_fast_distance(x, y); }
761 static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_fast_distance(x, y); }
762
763 static SIMD_CPPFUNC float2 normalize(const float2 x) { return ::simd_fast_normalize(x); }
764 static SIMD_CPPFUNC float3 normalize(const float3 x) { return ::simd_fast_normalize(x); }
765 static SIMD_CPPFUNC float4 normalize(const float4 x) { return ::simd_fast_normalize(x); }
766 static SIMD_CPPFUNC float8 normalize(const float8 x) { return ::simd_fast_normalize(x); }
767 static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_fast_normalize(x); }
768 static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_fast_normalize(x); }
769 static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_fast_normalize(x); }
770 static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_fast_normalize(x); }
771 static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_fast_normalize(x); }
772 }
773}
774
775extern "C" {
776#endif /* __cplusplus */
777
778#pragma mark - Implementation
779
780static float SIMD_CFUNC simd_dot(simd_float2 __x, simd_float2 __y) { return simd_reduce_add(__x*__y); }
781static float SIMD_CFUNC simd_dot(simd_float3 __x, simd_float3 __y) { return simd_reduce_add(__x*__y); }
782static float SIMD_CFUNC simd_dot(simd_float4 __x, simd_float4 __y) { return simd_reduce_add(__x*__y); }
783static float SIMD_CFUNC simd_dot(simd_float8 __x, simd_float8 __y) { return simd_reduce_add(__x*__y); }
784static float SIMD_CFUNC simd_dot(simd_float16 __x, simd_float16 __y) { return simd_reduce_add(__x*__y); }
785static double SIMD_CFUNC simd_dot(simd_double2 __x, simd_double2 __y) { return simd_reduce_add(__x*__y); }
786static double SIMD_CFUNC simd_dot(simd_double3 __x, simd_double3 __y) { return simd_reduce_add(__x*__y); }
787static double SIMD_CFUNC simd_dot(simd_double4 __x, simd_double4 __y) { return simd_reduce_add(__x*__y); }
788static double SIMD_CFUNC simd_dot(simd_double8 __x, simd_double8 __y) { return simd_reduce_add(__x*__y); }
789
790static simd_float2 SIMD_CFUNC simd_precise_project(simd_float2 __x, simd_float2 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
791static simd_float3 SIMD_CFUNC simd_precise_project(simd_float3 __x, simd_float3 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
792static simd_float4 SIMD_CFUNC simd_precise_project(simd_float4 __x, simd_float4 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
793static simd_float8 SIMD_CFUNC simd_precise_project(simd_float8 __x, simd_float8 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
794static simd_float16 SIMD_CFUNC simd_precise_project(simd_float16 __x, simd_float16 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
795static simd_double2 SIMD_CFUNC simd_precise_project(simd_double2 __x, simd_double2 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
796static simd_double3 SIMD_CFUNC simd_precise_project(simd_double3 __x, simd_double3 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
797static simd_double4 SIMD_CFUNC simd_precise_project(simd_double4 __x, simd_double4 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
798static simd_double8 SIMD_CFUNC simd_precise_project(simd_double8 __x, simd_double8 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
799
800static simd_float2 SIMD_CFUNC simd_fast_project(simd_float2 __x, simd_float2 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
801static simd_float3 SIMD_CFUNC simd_fast_project(simd_float3 __x, simd_float3 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
802static simd_float4 SIMD_CFUNC simd_fast_project(simd_float4 __x, simd_float4 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
803static simd_float8 SIMD_CFUNC simd_fast_project(simd_float8 __x, simd_float8 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
804static simd_float16 SIMD_CFUNC simd_fast_project(simd_float16 __x, simd_float16 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
805static simd_double2 SIMD_CFUNC simd_fast_project(simd_double2 __x, simd_double2 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
806static simd_double3 SIMD_CFUNC simd_fast_project(simd_double3 __x, simd_double3 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
807static simd_double4 SIMD_CFUNC simd_fast_project(simd_double4 __x, simd_double4 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
808static simd_double8 SIMD_CFUNC simd_fast_project(simd_double8 __x, simd_double8 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
809
810#if defined __FAST_MATH__
811static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y) { return simd_fast_project(__x,__y); }
812static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y) { return simd_fast_project(__x,__y); }
813static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y) { return simd_fast_project(__x,__y); }
814static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y) { return simd_fast_project(__x,__y); }
815static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y) { return simd_fast_project(__x,__y); }
816static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y) { return simd_fast_project(__x,__y); }
817static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y) { return simd_fast_project(__x,__y); }
818static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y) { return simd_fast_project(__x,__y); }
819static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y) { return simd_fast_project(__x,__y); }
820#else
821static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y) { return simd_precise_project(__x,__y); }
822static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y) { return simd_precise_project(__x,__y); }
823static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y) { return simd_precise_project(__x,__y); }
824static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y) { return simd_precise_project(__x,__y); }
825static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y) { return simd_precise_project(__x,__y); }
826static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y) { return simd_precise_project(__x,__y); }
827static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y) { return simd_precise_project(__x,__y); }
828static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y) { return simd_precise_project(__x,__y); }
829static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y) { return simd_precise_project(__x,__y); }
830#endif
831
832static float SIMD_CFUNC simd_precise_length(simd_float2 __x) { return sqrtf(simd_length_squared(__x)); }
833static float SIMD_CFUNC simd_precise_length(simd_float3 __x) { return sqrtf(simd_length_squared(__x)); }
834static float SIMD_CFUNC simd_precise_length(simd_float4 __x) { return sqrtf(simd_length_squared(__x)); }
835static float SIMD_CFUNC simd_precise_length(simd_float8 __x) { return sqrtf(simd_length_squared(__x)); }
836static float SIMD_CFUNC simd_precise_length(simd_float16 __x) { return sqrtf(simd_length_squared(__x)); }
837static double SIMD_CFUNC simd_precise_length(simd_double2 __x) { return sqrt(simd_length_squared(__x)); }
838static double SIMD_CFUNC simd_precise_length(simd_double3 __x) { return sqrt(simd_length_squared(__x)); }
839static double SIMD_CFUNC simd_precise_length(simd_double4 __x) { return sqrt(simd_length_squared(__x)); }
840static double SIMD_CFUNC simd_precise_length(simd_double8 __x) { return sqrt(simd_length_squared(__x)); }
841
842static float SIMD_CFUNC simd_fast_length(simd_float2 __x) { return simd_precise_length(__x); }
843static float SIMD_CFUNC simd_fast_length(simd_float3 __x) { return simd_precise_length(__x); }
844static float SIMD_CFUNC simd_fast_length(simd_float4 __x) { return simd_precise_length(__x); }
845static float SIMD_CFUNC simd_fast_length(simd_float8 __x) { return simd_precise_length(__x); }
846static float SIMD_CFUNC simd_fast_length(simd_float16 __x) { return simd_precise_length(__x); }
847static double SIMD_CFUNC simd_fast_length(simd_double2 __x) { return simd_precise_length(__x); }
848static double SIMD_CFUNC simd_fast_length(simd_double3 __x) { return simd_precise_length(__x); }
849static double SIMD_CFUNC simd_fast_length(simd_double4 __x) { return simd_precise_length(__x); }
850static double SIMD_CFUNC simd_fast_length(simd_double8 __x) { return simd_precise_length(__x); }
851
852#if defined __FAST_MATH__
853static float SIMD_CFUNC simd_length(simd_float2 __x) { return simd_fast_length(__x); }
854static float SIMD_CFUNC simd_length(simd_float3 __x) { return simd_fast_length(__x); }
855static float SIMD_CFUNC simd_length(simd_float4 __x) { return simd_fast_length(__x); }
856static float SIMD_CFUNC simd_length(simd_float8 __x) { return simd_fast_length(__x); }
857static float SIMD_CFUNC simd_length(simd_float16 __x) { return simd_fast_length(__x); }
858static double SIMD_CFUNC simd_length(simd_double2 __x) { return simd_fast_length(__x); }
859static double SIMD_CFUNC simd_length(simd_double3 __x) { return simd_fast_length(__x); }
860static double SIMD_CFUNC simd_length(simd_double4 __x) { return simd_fast_length(__x); }
861static double SIMD_CFUNC simd_length(simd_double8 __x) { return simd_fast_length(__x); }
862#else
863static float SIMD_CFUNC simd_length(simd_float2 __x) { return simd_precise_length(__x); }
864static float SIMD_CFUNC simd_length(simd_float3 __x) { return simd_precise_length(__x); }
865static float SIMD_CFUNC simd_length(simd_float4 __x) { return simd_precise_length(__x); }
866static float SIMD_CFUNC simd_length(simd_float8 __x) { return simd_precise_length(__x); }
867static float SIMD_CFUNC simd_length(simd_float16 __x) { return simd_precise_length(__x); }
868static double SIMD_CFUNC simd_length(simd_double2 __x) { return simd_precise_length(__x); }
869static double SIMD_CFUNC simd_length(simd_double3 __x) { return simd_precise_length(__x); }
870static double SIMD_CFUNC simd_length(simd_double4 __x) { return simd_precise_length(__x); }
871static double SIMD_CFUNC simd_length(simd_double8 __x) { return simd_precise_length(__x); }
872#endif
873
874static float SIMD_CFUNC simd_length_squared(simd_float2 __x) { return simd_dot(__x,__x); }
875static float SIMD_CFUNC simd_length_squared(simd_float3 __x) { return simd_dot(__x,__x); }
876static float SIMD_CFUNC simd_length_squared(simd_float4 __x) { return simd_dot(__x,__x); }
877static float SIMD_CFUNC simd_length_squared(simd_float8 __x) { return simd_dot(__x,__x); }
878static float SIMD_CFUNC simd_length_squared(simd_float16 __x) { return simd_dot(__x,__x); }
879static double SIMD_CFUNC simd_length_squared(simd_double2 __x) { return simd_dot(__x,__x); }
880static double SIMD_CFUNC simd_length_squared(simd_double3 __x) { return simd_dot(__x,__x); }
881static double SIMD_CFUNC simd_length_squared(simd_double4 __x) { return simd_dot(__x,__x); }
882static double SIMD_CFUNC simd_length_squared(simd_double8 __x) { return simd_dot(__x,__x); }
883
884static float SIMD_CFUNC simd_norm_one(simd_float2 __x) { return simd_reduce_add(__tg_fabs(__x)); }
885static float SIMD_CFUNC simd_norm_one(simd_float3 __x) { return simd_reduce_add(__tg_fabs(__x)); }
886static float SIMD_CFUNC simd_norm_one(simd_float4 __x) { return simd_reduce_add(__tg_fabs(__x)); }
887static float SIMD_CFUNC simd_norm_one(simd_float8 __x) { return simd_reduce_add(__tg_fabs(__x)); }
888static float SIMD_CFUNC simd_norm_one(simd_float16 __x) { return simd_reduce_add(__tg_fabs(__x)); }
889static double SIMD_CFUNC simd_norm_one(simd_double2 __x) { return simd_reduce_add(__tg_fabs(__x)); }
890static double SIMD_CFUNC simd_norm_one(simd_double3 __x) { return simd_reduce_add(__tg_fabs(__x)); }
891static double SIMD_CFUNC simd_norm_one(simd_double4 __x) { return simd_reduce_add(__tg_fabs(__x)); }
892static double SIMD_CFUNC simd_norm_one(simd_double8 __x) { return simd_reduce_add(__tg_fabs(__x)); }
893
894static float SIMD_CFUNC simd_norm_inf(simd_float2 __x) { return simd_reduce_max(__tg_fabs(__x)); }
895static float SIMD_CFUNC simd_norm_inf(simd_float3 __x) { return simd_reduce_max(__tg_fabs(__x)); }
896static float SIMD_CFUNC simd_norm_inf(simd_float4 __x) { return simd_reduce_max(__tg_fabs(__x)); }
897static float SIMD_CFUNC simd_norm_inf(simd_float8 __x) { return simd_reduce_max(__tg_fabs(__x)); }
898static float SIMD_CFUNC simd_norm_inf(simd_float16 __x) { return simd_reduce_max(__tg_fabs(__x)); }
899static double SIMD_CFUNC simd_norm_inf(simd_double2 __x) { return simd_reduce_max(__tg_fabs(__x)); }
900static double SIMD_CFUNC simd_norm_inf(simd_double3 __x) { return simd_reduce_max(__tg_fabs(__x)); }
901static double SIMD_CFUNC simd_norm_inf(simd_double4 __x) { return simd_reduce_max(__tg_fabs(__x)); }
902static double SIMD_CFUNC simd_norm_inf(simd_double8 __x) { return simd_reduce_max(__tg_fabs(__x)); }
903
904static float SIMD_CFUNC simd_precise_distance(simd_float2 __x, simd_float2 __y) { return simd_precise_length(__x - __y); }
905static float SIMD_CFUNC simd_precise_distance(simd_float3 __x, simd_float3 __y) { return simd_precise_length(__x - __y); }
906static float SIMD_CFUNC simd_precise_distance(simd_float4 __x, simd_float4 __y) { return simd_precise_length(__x - __y); }
907static float SIMD_CFUNC simd_precise_distance(simd_float8 __x, simd_float8 __y) { return simd_precise_length(__x - __y); }
908static float SIMD_CFUNC simd_precise_distance(simd_float16 __x, simd_float16 __y) { return simd_precise_length(__x - __y); }
909static double SIMD_CFUNC simd_precise_distance(simd_double2 __x, simd_double2 __y) { return simd_precise_length(__x - __y); }
910static double SIMD_CFUNC simd_precise_distance(simd_double3 __x, simd_double3 __y) { return simd_precise_length(__x - __y); }
911static double SIMD_CFUNC simd_precise_distance(simd_double4 __x, simd_double4 __y) { return simd_precise_length(__x - __y); }
912static double SIMD_CFUNC simd_precise_distance(simd_double8 __x, simd_double8 __y) { return simd_precise_length(__x - __y); }
913
914static float SIMD_CFUNC simd_fast_distance(simd_float2 __x, simd_float2 __y) { return simd_fast_length(__x - __y); }
915static float SIMD_CFUNC simd_fast_distance(simd_float3 __x, simd_float3 __y) { return simd_fast_length(__x - __y); }
916static float SIMD_CFUNC simd_fast_distance(simd_float4 __x, simd_float4 __y) { return simd_fast_length(__x - __y); }
917static float SIMD_CFUNC simd_fast_distance(simd_float8 __x, simd_float8 __y) { return simd_fast_length(__x - __y); }
918static float SIMD_CFUNC simd_fast_distance(simd_float16 __x, simd_float16 __y) { return simd_fast_length(__x - __y); }
919static double SIMD_CFUNC simd_fast_distance(simd_double2 __x, simd_double2 __y) { return simd_fast_length(__x - __y); }
920static double SIMD_CFUNC simd_fast_distance(simd_double3 __x, simd_double3 __y) { return simd_fast_length(__x - __y); }
921static double SIMD_CFUNC simd_fast_distance(simd_double4 __x, simd_double4 __y) { return simd_fast_length(__x - __y); }
922static double SIMD_CFUNC simd_fast_distance(simd_double8 __x, simd_double8 __y) { return simd_fast_length(__x - __y); }
923
924#if defined __FAST_MATH__
925static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y) { return simd_fast_distance(__x,__y); }
926static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y) { return simd_fast_distance(__x,__y); }
927static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y) { return simd_fast_distance(__x,__y); }
928static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y) { return simd_fast_distance(__x,__y); }
929static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y) { return simd_fast_distance(__x,__y); }
930static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y) { return simd_fast_distance(__x,__y); }
931static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y) { return simd_fast_distance(__x,__y); }
932static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y) { return simd_fast_distance(__x,__y); }
933static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y) { return simd_fast_distance(__x,__y); }
934#else
935static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y) { return simd_precise_distance(__x,__y); }
936static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y) { return simd_precise_distance(__x,__y); }
937static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y) { return simd_precise_distance(__x,__y); }
938static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y) { return simd_precise_distance(__x,__y); }
939static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y) { return simd_precise_distance(__x,__y); }
940static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y) { return simd_precise_distance(__x,__y); }
941static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y) { return simd_precise_distance(__x,__y); }
942static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y) { return simd_precise_distance(__x,__y); }
943static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y) { return simd_precise_distance(__x,__y); }
944#endif
945
946static float SIMD_CFUNC simd_distance_squared(simd_float2 __x, simd_float2 __y) { return simd_length_squared(__x - __y); }
947static float SIMD_CFUNC simd_distance_squared(simd_float3 __x, simd_float3 __y) { return simd_length_squared(__x - __y); }
948static float SIMD_CFUNC simd_distance_squared(simd_float4 __x, simd_float4 __y) { return simd_length_squared(__x - __y); }
949static float SIMD_CFUNC simd_distance_squared(simd_float8 __x, simd_float8 __y) { return simd_length_squared(__x - __y); }
950static float SIMD_CFUNC simd_distance_squared(simd_float16 __x, simd_float16 __y) { return simd_length_squared(__x - __y); }
951static double SIMD_CFUNC simd_distance_squared(simd_double2 __x, simd_double2 __y) { return simd_length_squared(__x - __y); }
952static double SIMD_CFUNC simd_distance_squared(simd_double3 __x, simd_double3 __y) { return simd_length_squared(__x - __y); }
953static double SIMD_CFUNC simd_distance_squared(simd_double4 __x, simd_double4 __y) { return simd_length_squared(__x - __y); }
954static double SIMD_CFUNC simd_distance_squared(simd_double8 __x, simd_double8 __y) { return simd_length_squared(__x - __y); }
955
956static simd_float2 SIMD_CFUNC simd_precise_normalize(simd_float2 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
957static simd_float3 SIMD_CFUNC simd_precise_normalize(simd_float3 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
958static simd_float4 SIMD_CFUNC simd_precise_normalize(simd_float4 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
959static simd_float8 SIMD_CFUNC simd_precise_normalize(simd_float8 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
960static simd_float16 SIMD_CFUNC simd_precise_normalize(simd_float16 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
961static simd_double2 SIMD_CFUNC simd_precise_normalize(simd_double2 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
962static simd_double3 SIMD_CFUNC simd_precise_normalize(simd_double3 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
963static simd_double4 SIMD_CFUNC simd_precise_normalize(simd_double4 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
964static simd_double8 SIMD_CFUNC simd_precise_normalize(simd_double8 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
965
966static simd_float2 SIMD_CFUNC simd_fast_normalize(simd_float2 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
967static simd_float3 SIMD_CFUNC simd_fast_normalize(simd_float3 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
968static simd_float4 SIMD_CFUNC simd_fast_normalize(simd_float4 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
969static simd_float8 SIMD_CFUNC simd_fast_normalize(simd_float8 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
970static simd_float16 SIMD_CFUNC simd_fast_normalize(simd_float16 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
971static simd_double2 SIMD_CFUNC simd_fast_normalize(simd_double2 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
972static simd_double3 SIMD_CFUNC simd_fast_normalize(simd_double3 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
973static simd_double4 SIMD_CFUNC simd_fast_normalize(simd_double4 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
974static simd_double8 SIMD_CFUNC simd_fast_normalize(simd_double8 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
975
976#if defined __FAST_MATH__
977static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x) { return simd_fast_normalize(__x); }
978static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x) { return simd_fast_normalize(__x); }
979static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x) { return simd_fast_normalize(__x); }
980static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x) { return simd_fast_normalize(__x); }
981static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x) { return simd_fast_normalize(__x); }
982static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x) { return simd_fast_normalize(__x); }
983static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x) { return simd_fast_normalize(__x); }
984static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x) { return simd_fast_normalize(__x); }
985static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x) { return simd_fast_normalize(__x); }
986#else
987static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x) { return simd_precise_normalize(__x); }
988static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x) { return simd_precise_normalize(__x); }
989static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x) { return simd_precise_normalize(__x); }
990static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x) { return simd_precise_normalize(__x); }
991static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x) { return simd_precise_normalize(__x); }
992static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x) { return simd_precise_normalize(__x); }
993static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x) { return simd_precise_normalize(__x); }
994static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x) { return simd_precise_normalize(__x); }
995static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x) { return simd_precise_normalize(__x); }
996#endif
997
998static simd_float3 SIMD_CFUNC simd_cross(simd_float2 __x, simd_float2 __y) { return (simd_float3){ 0, 0, __x.x*__y.y - __x.y*__y.x }; }
999static simd_float3 SIMD_CFUNC simd_cross(simd_float3 __x, simd_float3 __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; }
1000static simd_double3 SIMD_CFUNC simd_cross(simd_double2 __x, simd_double2 __y) { return (simd_double3){ 0, 0, __x.x*__y.y - __x.y*__y.x }; }
1001static simd_double3 SIMD_CFUNC simd_cross(simd_double3 __x, simd_double3 __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; }
1002
1003static simd_float2 SIMD_CFUNC simd_reflect(simd_float2 __x, simd_float2 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1004static simd_float3 SIMD_CFUNC simd_reflect(simd_float3 __x, simd_float3 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1005static simd_float4 SIMD_CFUNC simd_reflect(simd_float4 __x, simd_float4 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1006static simd_double2 SIMD_CFUNC simd_reflect(simd_double2 __x, simd_double2 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1007static simd_double3 SIMD_CFUNC simd_reflect(simd_double3 __x, simd_double3 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1008static simd_double4 SIMD_CFUNC simd_reflect(simd_double4 __x, simd_double4 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1009
1010static simd_float2 SIMD_CFUNC simd_refract(simd_float2 __x, simd_float2 __n, float __eta) {
1011 const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n));
1012 return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float2)0.0f;
1013}
1014static simd_float3 SIMD_CFUNC simd_refract(simd_float3 __x, simd_float3 __n, float __eta) {
1015 const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n));
1016 return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float3)0.0f;
1017}
1018static simd_float4 SIMD_CFUNC simd_refract(simd_float4 __x, simd_float4 __n, float __eta) {
1019 const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n));
1020 return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float4)0.0f;
1021}
1022static simd_double2 SIMD_CFUNC simd_refract(simd_double2 __x, simd_double2 __n, double __eta) {
1023 const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n));
1024 return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double2)0.0;
1025}
1026static simd_double3 SIMD_CFUNC simd_refract(simd_double3 __x, simd_double3 __n, double __eta) {
1027 const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n));
1028 return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double3)0.0;
1029}
1030static simd_double4 SIMD_CFUNC simd_refract(simd_double4 __x, simd_double4 __n, double __eta) {
1031 const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n));
1032 return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double4)0.0;
1033}
1034
1035#if SIMD_LIBRARY_VERSION >= 2
1036static float SIMD_CFUNC simd_orient(simd_float2 __x, simd_float2 __y) {
1037 return _simd_orient_vf2(__x, __y);
1038}
1039static double SIMD_CFUNC simd_orient(simd_double2 __x, simd_double2 __y) {
1040 return _simd_orient_vd2(__x, __y);
1041}
1042static float SIMD_CFUNC simd_orient(simd_float3 __x, simd_float3 __y, simd_float3 __z) {
1043 return _simd_orient_vf3(__x, __y, __z);
1044}
1045static double SIMD_CFUNC simd_orient(simd_double3 __x, simd_double3 __y, simd_double3 __z) {
1046 simd_double3 __args[3] = { __x, __y, __z };
1047 return _simd_orient_vd3((const double *)__args);
1048}
1049
1050static float SIMD_CFUNC simd_orient(simd_float2 __a, simd_float2 __b, simd_float2 __c) {
1051 return _simd_orient_pf2(__a, __b, __c);
1052}
1053static double SIMD_CFUNC simd_orient(simd_double2 __a, simd_double2 __b, simd_double2 __c) {
1054 return _simd_orient_pd2(__a, __b, __c);
1055}
1056static float SIMD_CFUNC simd_orient(simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d) {
1057 return _simd_orient_pf3(__a, __b, __c, __d);
1058}
1059static double SIMD_CFUNC simd_orient(simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d) {
1060 simd_double3 __args[4] = { __a, __b, __c, __d };
1061 return _simd_orient_vd3((const double *)__args);
1062}
1063
1064static float SIMD_CFUNC simd_incircle(simd_float2 __x, simd_float2 __a, simd_float2 __b, simd_float2 __c) {
1065 return _simd_incircle_pf2(__x, __a, __b, __c);
1066}
1067static double SIMD_CFUNC simd_incircle(simd_double2 __x, simd_double2 __a, simd_double2 __b, simd_double2 __c) {
1068 return _simd_incircle_pd2(__x, __a, __b, __c);
1069}
1070static float SIMD_CFUNC simd_insphere(simd_float3 __x, simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d) {
1071 return _simd_insphere_pf3(__x, __a, __b, __c, __d);
1072}
1073static double SIMD_CFUNC simd_insphere(simd_double3 __x, simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d) {
1074 simd_double3 __args[5] = { __x, __a, __b, __c, __d };
1075 return _simd_insphere_pd3((const double *)__args);
1076}
1077#endif /* SIMD_LIBRARY_VERSION */
1078
1079#ifdef __cplusplus
1080}
1081#endif
1082#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
1083#endif /* __SIMD_COMMON_HEADER__ */
lib/libc/include/x86_64-macos-gnu/simd/logic.h created+1315
......@@ -0,0 +1,1315 @@
1/*! @header
2 * The interfaces declared in this header provide logical and bitwise
3 * operations on vectors. Some of these function operate elementwise,
4 * and some produce a scalar result that depends on all lanes of the input.
5 *
6 * For functions returning a boolean value, the return type in C and
7 * Objective-C is _Bool; for C++ it is bool.
8 *
9 * Function Result
10 * ------------------------------------------------------------------
11 * simd_all(comparison) True if and only if the comparison is true
12 * in every vector lane. e.g.:
13 *
14 * if (simd_all(x == 0.0f)) {
15 * // executed if every lane of x
16 * // contains zero.
17 * }
18 *
19 * The precise function of simd_all is to
20 * return the high-order bit of the result
21 * of a horizontal bitwise AND of all vector
22 * lanes.
23 *
24 * simd_any(comparison) True if and only if the comparison is true
25 * in at least one vector lane. e.g.:
26 *
27 * if (simd_any(x < 0.0f)) {
28 * // executed if any lane of x
29 * // contains a negative value.
30 * }
31 *
32 * The precise function of simd_all is to
33 * return the high-order bit of the result
34 * of a horizontal bitwise OR of all vector
35 * lanes.
36 *
37 * simd_select(x,y,mask) For each lane in the result, selects the
38 * corresponding element of x if the high-
39 * order bit of the corresponding element of
40 * mask is 0, and the corresponding element
41 * of y otherwise.
42 *
43 * simd_bitselect(x,y,mask) For each bit in the result, selects the
44 * corresponding bit of x if the corresponding
45 * bit of mask is clear, and the corresponding
46 * of y otherwise.
47 *
48 * In C++, these functions are available under the simd:: namespace:
49 *
50 * C++ Function Equivalent C Function
51 * --------------------------------------------------------------------
52 * simd::all(comparison) simd_all(comparison)
53 * simd::any(comparison) simd_any(comparison)
54 * simd::select(x,y,mask) simd_select(x,y,mask)
55 * simd::bitselect(x,y,mask) simd_bitselect(x,y,mask)
56 *
57 * @copyright 2014-2017 Apple, Inc. All rights reserved.
58 * @unsorted */
59
60#ifndef SIMD_LOGIC_HEADER
61#define SIMD_LOGIC_HEADER
62
63#include <simd/base.h>
64#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
65#include <simd/vector_make.h>
66#include <stdint.h>
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
72/*! @abstract True if and only if the high-order bit of any lane of the
73 * vector is set. */
74static inline SIMD_CFUNC simd_bool simd_any(simd_char2 x);
75/*! @abstract True if and only if the high-order bit of any lane of the
76 * vector is set. */
77static inline SIMD_CFUNC simd_bool simd_any(simd_char3 x);
78/*! @abstract True if and only if the high-order bit of any lane of the
79 * vector is set. */
80static inline SIMD_CFUNC simd_bool simd_any(simd_char4 x);
81/*! @abstract True if and only if the high-order bit of any lane of the
82 * vector is set. */
83static inline SIMD_CFUNC simd_bool simd_any(simd_char8 x);
84/*! @abstract True if and only if the high-order bit of any lane of the
85 * vector is set. */
86static inline SIMD_CFUNC simd_bool simd_any(simd_char16 x);
87/*! @abstract True if and only if the high-order bit of any lane of the
88 * vector is set. */
89static inline SIMD_CFUNC simd_bool simd_any(simd_char32 x);
90/*! @abstract True if and only if the high-order bit of any lane of the
91 * vector is set. */
92static inline SIMD_CFUNC simd_bool simd_any(simd_char64 x);
93/*! @abstract True if and only if the high-order bit of any lane of the
94 * vector is set. */
95static inline SIMD_CFUNC simd_bool simd_any(simd_uchar2 x);
96/*! @abstract True if and only if the high-order bit of any lane of the
97 * vector is set. */
98static inline SIMD_CFUNC simd_bool simd_any(simd_uchar3 x);
99/*! @abstract True if and only if the high-order bit of any lane of the
100 * vector is set. */
101static inline SIMD_CFUNC simd_bool simd_any(simd_uchar4 x);
102/*! @abstract True if and only if the high-order bit of any lane of the
103 * vector is set. */
104static inline SIMD_CFUNC simd_bool simd_any(simd_uchar8 x);
105/*! @abstract True if and only if the high-order bit of any lane of the
106 * vector is set. */
107static inline SIMD_CFUNC simd_bool simd_any(simd_uchar16 x);
108/*! @abstract True if and only if the high-order bit of any lane of the
109 * vector is set. */
110static inline SIMD_CFUNC simd_bool simd_any(simd_uchar32 x);
111/*! @abstract True if and only if the high-order bit of any lane of the
112 * vector is set. */
113static inline SIMD_CFUNC simd_bool simd_any(simd_uchar64 x);
114/*! @abstract True if and only if the high-order bit of any lane of the
115 * vector is set. */
116static inline SIMD_CFUNC simd_bool simd_any(simd_short2 x);
117/*! @abstract True if and only if the high-order bit of any lane of the
118 * vector is set. */
119static inline SIMD_CFUNC simd_bool simd_any(simd_short3 x);
120/*! @abstract True if and only if the high-order bit of any lane of the
121 * vector is set. */
122static inline SIMD_CFUNC simd_bool simd_any(simd_short4 x);
123/*! @abstract True if and only if the high-order bit of any lane of the
124 * vector is set. */
125static inline SIMD_CFUNC simd_bool simd_any(simd_short8 x);
126/*! @abstract True if and only if the high-order bit of any lane of the
127 * vector is set. */
128static inline SIMD_CFUNC simd_bool simd_any(simd_short16 x);
129/*! @abstract True if and only if the high-order bit of any lane of the
130 * vector is set. */
131static inline SIMD_CFUNC simd_bool simd_any(simd_short32 x);
132/*! @abstract True if and only if the high-order bit of any lane of the
133 * vector is set. */
134static inline SIMD_CFUNC simd_bool simd_any(simd_ushort2 x);
135/*! @abstract True if and only if the high-order bit of any lane of the
136 * vector is set. */
137static inline SIMD_CFUNC simd_bool simd_any(simd_ushort3 x);
138/*! @abstract True if and only if the high-order bit of any lane of the
139 * vector is set. */
140static inline SIMD_CFUNC simd_bool simd_any(simd_ushort4 x);
141/*! @abstract True if and only if the high-order bit of any lane of the
142 * vector is set. */
143static inline SIMD_CFUNC simd_bool simd_any(simd_ushort8 x);
144/*! @abstract True if and only if the high-order bit of any lane of the
145 * vector is set. */
146static inline SIMD_CFUNC simd_bool simd_any(simd_ushort16 x);
147/*! @abstract True if and only if the high-order bit of any lane of the
148 * vector is set. */
149static inline SIMD_CFUNC simd_bool simd_any(simd_ushort32 x);
150/*! @abstract True if and only if the high-order bit of any lane of the
151 * vector is set. */
152static inline SIMD_CFUNC simd_bool simd_any(simd_int2 x);
153/*! @abstract True if and only if the high-order bit of any lane of the
154 * vector is set. */
155static inline SIMD_CFUNC simd_bool simd_any(simd_int3 x);
156/*! @abstract True if and only if the high-order bit of any lane of the
157 * vector is set. */
158static inline SIMD_CFUNC simd_bool simd_any(simd_int4 x);
159/*! @abstract True if and only if the high-order bit of any lane of the
160 * vector is set. */
161static inline SIMD_CFUNC simd_bool simd_any(simd_int8 x);
162/*! @abstract True if and only if the high-order bit of any lane of the
163 * vector is set. */
164static inline SIMD_CFUNC simd_bool simd_any(simd_int16 x);
165/*! @abstract True if and only if the high-order bit of any lane of the
166 * vector is set. */
167static inline SIMD_CFUNC simd_bool simd_any(simd_uint2 x);
168/*! @abstract True if and only if the high-order bit of any lane of the
169 * vector is set. */
170static inline SIMD_CFUNC simd_bool simd_any(simd_uint3 x);
171/*! @abstract True if and only if the high-order bit of any lane of the
172 * vector is set. */
173static inline SIMD_CFUNC simd_bool simd_any(simd_uint4 x);
174/*! @abstract True if and only if the high-order bit of any lane of the
175 * vector is set. */
176static inline SIMD_CFUNC simd_bool simd_any(simd_uint8 x);
177/*! @abstract True if and only if the high-order bit of any lane of the
178 * vector is set. */
179static inline SIMD_CFUNC simd_bool simd_any(simd_uint16 x);
180/*! @abstract True if and only if the high-order bit of any lane of the
181 * vector is set. */
182static inline SIMD_CFUNC simd_bool simd_any(simd_long2 x);
183/*! @abstract True if and only if the high-order bit of any lane of the
184 * vector is set. */
185static inline SIMD_CFUNC simd_bool simd_any(simd_long3 x);
186/*! @abstract True if and only if the high-order bit of any lane of the
187 * vector is set. */
188static inline SIMD_CFUNC simd_bool simd_any(simd_long4 x);
189/*! @abstract True if and only if the high-order bit of any lane of the
190 * vector is set. */
191static inline SIMD_CFUNC simd_bool simd_any(simd_long8 x);
192/*! @abstract True if and only if the high-order bit of any lane of the
193 * vector is set. */
194static inline SIMD_CFUNC simd_bool simd_any(simd_ulong2 x);
195/*! @abstract True if and only if the high-order bit of any lane of the
196 * vector is set. */
197static inline SIMD_CFUNC simd_bool simd_any(simd_ulong3 x);
198/*! @abstract True if and only if the high-order bit of any lane of the
199 * vector is set. */
200static inline SIMD_CFUNC simd_bool simd_any(simd_ulong4 x);
201/*! @abstract True if and only if the high-order bit of any lane of the
202 * vector is set. */
203static inline SIMD_CFUNC simd_bool simd_any(simd_ulong8 x);
204/*! @abstract True if and only if the high-order bit of any lane of the
205 * vector is set.
206 * @discussion Deprecated. Use simd_any instead. */
207#define vector_any simd_any
208
209/*! @abstract True if and only if the high-order bit of every lane of the
210 * vector is set. */
211static inline SIMD_CFUNC simd_bool simd_all(simd_char2 x);
212/*! @abstract True if and only if the high-order bit of every lane of the
213 * vector is set. */
214static inline SIMD_CFUNC simd_bool simd_all(simd_char3 x);
215/*! @abstract True if and only if the high-order bit of every lane of the
216 * vector is set. */
217static inline SIMD_CFUNC simd_bool simd_all(simd_char4 x);
218/*! @abstract True if and only if the high-order bit of every lane of the
219 * vector is set. */
220static inline SIMD_CFUNC simd_bool simd_all(simd_char8 x);
221/*! @abstract True if and only if the high-order bit of every lane of the
222 * vector is set. */
223static inline SIMD_CFUNC simd_bool simd_all(simd_char16 x);
224/*! @abstract True if and only if the high-order bit of every lane of the
225 * vector is set. */
226static inline SIMD_CFUNC simd_bool simd_all(simd_char32 x);
227/*! @abstract True if and only if the high-order bit of every lane of the
228 * vector is set. */
229static inline SIMD_CFUNC simd_bool simd_all(simd_char64 x);
230/*! @abstract True if and only if the high-order bit of every lane of the
231 * vector is set. */
232static inline SIMD_CFUNC simd_bool simd_all(simd_uchar2 x);
233/*! @abstract True if and only if the high-order bit of every lane of the
234 * vector is set. */
235static inline SIMD_CFUNC simd_bool simd_all(simd_uchar3 x);
236/*! @abstract True if and only if the high-order bit of every lane of the
237 * vector is set. */
238static inline SIMD_CFUNC simd_bool simd_all(simd_uchar4 x);
239/*! @abstract True if and only if the high-order bit of every lane of the
240 * vector is set. */
241static inline SIMD_CFUNC simd_bool simd_all(simd_uchar8 x);
242/*! @abstract True if and only if the high-order bit of every lane of the
243 * vector is set. */
244static inline SIMD_CFUNC simd_bool simd_all(simd_uchar16 x);
245/*! @abstract True if and only if the high-order bit of every lane of the
246 * vector is set. */
247static inline SIMD_CFUNC simd_bool simd_all(simd_uchar32 x);
248/*! @abstract True if and only if the high-order bit of every lane of the
249 * vector is set. */
250static inline SIMD_CFUNC simd_bool simd_all(simd_uchar64 x);
251/*! @abstract True if and only if the high-order bit of every lane of the
252 * vector is set. */
253static inline SIMD_CFUNC simd_bool simd_all(simd_short2 x);
254/*! @abstract True if and only if the high-order bit of every lane of the
255 * vector is set. */
256static inline SIMD_CFUNC simd_bool simd_all(simd_short3 x);
257/*! @abstract True if and only if the high-order bit of every lane of the
258 * vector is set. */
259static inline SIMD_CFUNC simd_bool simd_all(simd_short4 x);
260/*! @abstract True if and only if the high-order bit of every lane of the
261 * vector is set. */
262static inline SIMD_CFUNC simd_bool simd_all(simd_short8 x);
263/*! @abstract True if and only if the high-order bit of every lane of the
264 * vector is set. */
265static inline SIMD_CFUNC simd_bool simd_all(simd_short16 x);
266/*! @abstract True if and only if the high-order bit of every lane of the
267 * vector is set. */
268static inline SIMD_CFUNC simd_bool simd_all(simd_short32 x);
269/*! @abstract True if and only if the high-order bit of every lane of the
270 * vector is set. */
271static inline SIMD_CFUNC simd_bool simd_all(simd_ushort2 x);
272/*! @abstract True if and only if the high-order bit of every lane of the
273 * vector is set. */
274static inline SIMD_CFUNC simd_bool simd_all(simd_ushort3 x);
275/*! @abstract True if and only if the high-order bit of every lane of the
276 * vector is set. */
277static inline SIMD_CFUNC simd_bool simd_all(simd_ushort4 x);
278/*! @abstract True if and only if the high-order bit of every lane of the
279 * vector is set. */
280static inline SIMD_CFUNC simd_bool simd_all(simd_ushort8 x);
281/*! @abstract True if and only if the high-order bit of every lane of the
282 * vector is set. */
283static inline SIMD_CFUNC simd_bool simd_all(simd_ushort16 x);
284/*! @abstract True if and only if the high-order bit of every lane of the
285 * vector is set. */
286static inline SIMD_CFUNC simd_bool simd_all(simd_ushort32 x);
287/*! @abstract True if and only if the high-order bit of every lane of the
288 * vector is set. */
289static inline SIMD_CFUNC simd_bool simd_all(simd_int2 x);
290/*! @abstract True if and only if the high-order bit of every lane of the
291 * vector is set. */
292static inline SIMD_CFUNC simd_bool simd_all(simd_int3 x);
293/*! @abstract True if and only if the high-order bit of every lane of the
294 * vector is set. */
295static inline SIMD_CFUNC simd_bool simd_all(simd_int4 x);
296/*! @abstract True if and only if the high-order bit of every lane of the
297 * vector is set. */
298static inline SIMD_CFUNC simd_bool simd_all(simd_int8 x);
299/*! @abstract True if and only if the high-order bit of every lane of the
300 * vector is set. */
301static inline SIMD_CFUNC simd_bool simd_all(simd_int16 x);
302/*! @abstract True if and only if the high-order bit of every lane of the
303 * vector is set. */
304static inline SIMD_CFUNC simd_bool simd_all(simd_uint2 x);
305/*! @abstract True if and only if the high-order bit of every lane of the
306 * vector is set. */
307static inline SIMD_CFUNC simd_bool simd_all(simd_uint3 x);
308/*! @abstract True if and only if the high-order bit of every lane of the
309 * vector is set. */
310static inline SIMD_CFUNC simd_bool simd_all(simd_uint4 x);
311/*! @abstract True if and only if the high-order bit of every lane of the
312 * vector is set. */
313static inline SIMD_CFUNC simd_bool simd_all(simd_uint8 x);
314/*! @abstract True if and only if the high-order bit of every lane of the
315 * vector is set. */
316static inline SIMD_CFUNC simd_bool simd_all(simd_uint16 x);
317/*! @abstract True if and only if the high-order bit of every lane of the
318 * vector is set. */
319static inline SIMD_CFUNC simd_bool simd_all(simd_long2 x);
320/*! @abstract True if and only if the high-order bit of every lane of the
321 * vector is set. */
322static inline SIMD_CFUNC simd_bool simd_all(simd_long3 x);
323/*! @abstract True if and only if the high-order bit of every lane of the
324 * vector is set. */
325static inline SIMD_CFUNC simd_bool simd_all(simd_long4 x);
326/*! @abstract True if and only if the high-order bit of every lane of the
327 * vector is set. */
328static inline SIMD_CFUNC simd_bool simd_all(simd_long8 x);
329/*! @abstract True if and only if the high-order bit of every lane of the
330 * vector is set. */
331static inline SIMD_CFUNC simd_bool simd_all(simd_ulong2 x);
332/*! @abstract True if and only if the high-order bit of every lane of the
333 * vector is set. */
334static inline SIMD_CFUNC simd_bool simd_all(simd_ulong3 x);
335/*! @abstract True if and only if the high-order bit of every lane of the
336 * vector is set. */
337static inline SIMD_CFUNC simd_bool simd_all(simd_ulong4 x);
338/*! @abstract True if and only if the high-order bit of every lane of the
339 * vector is set. */
340static inline SIMD_CFUNC simd_bool simd_all(simd_ulong8 x);
341/*! @abstract True if and only if the high-order bit of every lane of the
342 * vector is set.
343 * @discussion Deprecated. Use simd_all instead. */
344#define vector_all simd_all
345
346/*! @abstract For each lane in the result, selects the corresponding element
347 * of x or y according to whether the high-order bit of the corresponding
348 * lane of mask is 0 or 1, respectively. */
349static inline SIMD_CFUNC simd_float2 simd_select(simd_float2 x, simd_float2 y, simd_int2 mask);
350/*! @abstract For each lane in the result, selects the corresponding element
351 * of x or y according to whether the high-order bit of the corresponding
352 * lane of mask is 0 or 1, respectively. */
353static inline SIMD_CFUNC simd_float3 simd_select(simd_float3 x, simd_float3 y, simd_int3 mask);
354/*! @abstract For each lane in the result, selects the corresponding element
355 * of x or y according to whether the high-order bit of the corresponding
356 * lane of mask is 0 or 1, respectively. */
357static inline SIMD_CFUNC simd_float4 simd_select(simd_float4 x, simd_float4 y, simd_int4 mask);
358/*! @abstract For each lane in the result, selects the corresponding element
359 * of x or y according to whether the high-order bit of the corresponding
360 * lane of mask is 0 or 1, respectively. */
361static inline SIMD_CFUNC simd_float8 simd_select(simd_float8 x, simd_float8 y, simd_int8 mask);
362/*! @abstract For each lane in the result, selects the corresponding element
363 * of x or y according to whether the high-order bit of the corresponding
364 * lane of mask is 0 or 1, respectively. */
365static inline SIMD_CFUNC simd_float16 simd_select(simd_float16 x, simd_float16 y, simd_int16 mask);
366/*! @abstract For each lane in the result, selects the corresponding element
367 * of x or y according to whether the high-order bit of the corresponding
368 * lane of mask is 0 or 1, respectively. */
369static inline SIMD_CFUNC simd_double2 simd_select(simd_double2 x, simd_double2 y, simd_long2 mask);
370/*! @abstract For each lane in the result, selects the corresponding element
371 * of x or y according to whether the high-order bit of the corresponding
372 * lane of mask is 0 or 1, respectively. */
373static inline SIMD_CFUNC simd_double3 simd_select(simd_double3 x, simd_double3 y, simd_long3 mask);
374/*! @abstract For each lane in the result, selects the corresponding element
375 * of x or y according to whether the high-order bit of the corresponding
376 * lane of mask is 0 or 1, respectively. */
377static inline SIMD_CFUNC simd_double4 simd_select(simd_double4 x, simd_double4 y, simd_long4 mask);
378/*! @abstract For each lane in the result, selects the corresponding element
379 * of x or y according to whether the high-order bit of the corresponding
380 * lane of mask is 0 or 1, respectively. */
381static inline SIMD_CFUNC simd_double8 simd_select(simd_double8 x, simd_double8 y, simd_long8 mask);
382/*! @abstract For each lane in the result, selects the corresponding element
383 * of x or y according to whether the high-order bit of the corresponding
384 * lane of mask is 0 or 1, respectively.
385 * @discussion Deprecated. Use simd_select instead. */
386#define vector_select simd_select
387
388/*! @abstract For each bit in the result, selects the corresponding bit of x
389 * or y according to whether the corresponding bit of mask is 0 or 1,
390 * respectively. */
391static inline SIMD_CFUNC simd_char2 simd_bitselect(simd_char2 x, simd_char2 y, simd_char2 mask);
392/*! @abstract For each bit in the result, selects the corresponding bit of x
393 * or y according to whether the corresponding bit of mask is 0 or 1,
394 * respectively. */
395static inline SIMD_CFUNC simd_char3 simd_bitselect(simd_char3 x, simd_char3 y, simd_char3 mask);
396/*! @abstract For each bit in the result, selects the corresponding bit of x
397 * or y according to whether the corresponding bit of mask is 0 or 1,
398 * respectively. */
399static inline SIMD_CFUNC simd_char4 simd_bitselect(simd_char4 x, simd_char4 y, simd_char4 mask);
400/*! @abstract For each bit in the result, selects the corresponding bit of x
401 * or y according to whether the corresponding bit of mask is 0 or 1,
402 * respectively. */
403static inline SIMD_CFUNC simd_char8 simd_bitselect(simd_char8 x, simd_char8 y, simd_char8 mask);
404/*! @abstract For each bit in the result, selects the corresponding bit of x
405 * or y according to whether the corresponding bit of mask is 0 or 1,
406 * respectively. */
407static inline SIMD_CFUNC simd_char16 simd_bitselect(simd_char16 x, simd_char16 y, simd_char16 mask);
408/*! @abstract For each bit in the result, selects the corresponding bit of x
409 * or y according to whether the corresponding bit of mask is 0 or 1,
410 * respectively. */
411static inline SIMD_CFUNC simd_char32 simd_bitselect(simd_char32 x, simd_char32 y, simd_char32 mask);
412/*! @abstract For each bit in the result, selects the corresponding bit of x
413 * or y according to whether the corresponding bit of mask is 0 or 1,
414 * respectively. */
415static inline SIMD_CFUNC simd_char64 simd_bitselect(simd_char64 x, simd_char64 y, simd_char64 mask);
416/*! @abstract For each bit in the result, selects the corresponding bit of x
417 * or y according to whether the corresponding bit of mask is 0 or 1,
418 * respectively. */
419static inline SIMD_CFUNC simd_uchar2 simd_bitselect(simd_uchar2 x, simd_uchar2 y, simd_char2 mask);
420/*! @abstract For each bit in the result, selects the corresponding bit of x
421 * or y according to whether the corresponding bit of mask is 0 or 1,
422 * respectively. */
423static inline SIMD_CFUNC simd_uchar3 simd_bitselect(simd_uchar3 x, simd_uchar3 y, simd_char3 mask);
424/*! @abstract For each bit in the result, selects the corresponding bit of x
425 * or y according to whether the corresponding bit of mask is 0 or 1,
426 * respectively. */
427static inline SIMD_CFUNC simd_uchar4 simd_bitselect(simd_uchar4 x, simd_uchar4 y, simd_char4 mask);
428/*! @abstract For each bit in the result, selects the corresponding bit of x
429 * or y according to whether the corresponding bit of mask is 0 or 1,
430 * respectively. */
431static inline SIMD_CFUNC simd_uchar8 simd_bitselect(simd_uchar8 x, simd_uchar8 y, simd_char8 mask);
432/*! @abstract For each bit in the result, selects the corresponding bit of x
433 * or y according to whether the corresponding bit of mask is 0 or 1,
434 * respectively. */
435static inline SIMD_CFUNC simd_uchar16 simd_bitselect(simd_uchar16 x, simd_uchar16 y, simd_char16 mask);
436/*! @abstract For each bit in the result, selects the corresponding bit of x
437 * or y according to whether the corresponding bit of mask is 0 or 1,
438 * respectively. */
439static inline SIMD_CFUNC simd_uchar32 simd_bitselect(simd_uchar32 x, simd_uchar32 y, simd_char32 mask);
440/*! @abstract For each bit in the result, selects the corresponding bit of x
441 * or y according to whether the corresponding bit of mask is 0 or 1,
442 * respectively. */
443static inline SIMD_CFUNC simd_uchar64 simd_bitselect(simd_uchar64 x, simd_uchar64 y, simd_char64 mask);
444/*! @abstract For each bit in the result, selects the corresponding bit of x
445 * or y according to whether the corresponding bit of mask is 0 or 1,
446 * respectively. */
447static inline SIMD_CFUNC simd_short2 simd_bitselect(simd_short2 x, simd_short2 y, simd_short2 mask);
448/*! @abstract For each bit in the result, selects the corresponding bit of x
449 * or y according to whether the corresponding bit of mask is 0 or 1,
450 * respectively. */
451static inline SIMD_CFUNC simd_short3 simd_bitselect(simd_short3 x, simd_short3 y, simd_short3 mask);
452/*! @abstract For each bit in the result, selects the corresponding bit of x
453 * or y according to whether the corresponding bit of mask is 0 or 1,
454 * respectively. */
455static inline SIMD_CFUNC simd_short4 simd_bitselect(simd_short4 x, simd_short4 y, simd_short4 mask);
456/*! @abstract For each bit in the result, selects the corresponding bit of x
457 * or y according to whether the corresponding bit of mask is 0 or 1,
458 * respectively. */
459static inline SIMD_CFUNC simd_short8 simd_bitselect(simd_short8 x, simd_short8 y, simd_short8 mask);
460/*! @abstract For each bit in the result, selects the corresponding bit of x
461 * or y according to whether the corresponding bit of mask is 0 or 1,
462 * respectively. */
463static inline SIMD_CFUNC simd_short16 simd_bitselect(simd_short16 x, simd_short16 y, simd_short16 mask);
464/*! @abstract For each bit in the result, selects the corresponding bit of x
465 * or y according to whether the corresponding bit of mask is 0 or 1,
466 * respectively. */
467static inline SIMD_CFUNC simd_short32 simd_bitselect(simd_short32 x, simd_short32 y, simd_short32 mask);
468/*! @abstract For each bit in the result, selects the corresponding bit of x
469 * or y according to whether the corresponding bit of mask is 0 or 1,
470 * respectively. */
471static inline SIMD_CFUNC simd_ushort2 simd_bitselect(simd_ushort2 x, simd_ushort2 y, simd_short2 mask);
472/*! @abstract For each bit in the result, selects the corresponding bit of x
473 * or y according to whether the corresponding bit of mask is 0 or 1,
474 * respectively. */
475static inline SIMD_CFUNC simd_ushort3 simd_bitselect(simd_ushort3 x, simd_ushort3 y, simd_short3 mask);
476/*! @abstract For each bit in the result, selects the corresponding bit of x
477 * or y according to whether the corresponding bit of mask is 0 or 1,
478 * respectively. */
479static inline SIMD_CFUNC simd_ushort4 simd_bitselect(simd_ushort4 x, simd_ushort4 y, simd_short4 mask);
480/*! @abstract For each bit in the result, selects the corresponding bit of x
481 * or y according to whether the corresponding bit of mask is 0 or 1,
482 * respectively. */
483static inline SIMD_CFUNC simd_ushort8 simd_bitselect(simd_ushort8 x, simd_ushort8 y, simd_short8 mask);
484/*! @abstract For each bit in the result, selects the corresponding bit of x
485 * or y according to whether the corresponding bit of mask is 0 or 1,
486 * respectively. */
487static inline SIMD_CFUNC simd_ushort16 simd_bitselect(simd_ushort16 x, simd_ushort16 y, simd_short16 mask);
488/*! @abstract For each bit in the result, selects the corresponding bit of x
489 * or y according to whether the corresponding bit of mask is 0 or 1,
490 * respectively. */
491static inline SIMD_CFUNC simd_ushort32 simd_bitselect(simd_ushort32 x, simd_ushort32 y, simd_short32 mask);
492/*! @abstract For each bit in the result, selects the corresponding bit of x
493 * or y according to whether the corresponding bit of mask is 0 or 1,
494 * respectively. */
495static inline SIMD_CFUNC simd_int2 simd_bitselect(simd_int2 x, simd_int2 y, simd_int2 mask);
496/*! @abstract For each bit in the result, selects the corresponding bit of x
497 * or y according to whether the corresponding bit of mask is 0 or 1,
498 * respectively. */
499static inline SIMD_CFUNC simd_int3 simd_bitselect(simd_int3 x, simd_int3 y, simd_int3 mask);
500/*! @abstract For each bit in the result, selects the corresponding bit of x
501 * or y according to whether the corresponding bit of mask is 0 or 1,
502 * respectively. */
503static inline SIMD_CFUNC simd_int4 simd_bitselect(simd_int4 x, simd_int4 y, simd_int4 mask);
504/*! @abstract For each bit in the result, selects the corresponding bit of x
505 * or y according to whether the corresponding bit of mask is 0 or 1,
506 * respectively. */
507static inline SIMD_CFUNC simd_int8 simd_bitselect(simd_int8 x, simd_int8 y, simd_int8 mask);
508/*! @abstract For each bit in the result, selects the corresponding bit of x
509 * or y according to whether the corresponding bit of mask is 0 or 1,
510 * respectively. */
511static inline SIMD_CFUNC simd_int16 simd_bitselect(simd_int16 x, simd_int16 y, simd_int16 mask);
512/*! @abstract For each bit in the result, selects the corresponding bit of x
513 * or y according to whether the corresponding bit of mask is 0 or 1,
514 * respectively. */
515static inline SIMD_CFUNC simd_uint2 simd_bitselect(simd_uint2 x, simd_uint2 y, simd_int2 mask);
516/*! @abstract For each bit in the result, selects the corresponding bit of x
517 * or y according to whether the corresponding bit of mask is 0 or 1,
518 * respectively. */
519static inline SIMD_CFUNC simd_uint3 simd_bitselect(simd_uint3 x, simd_uint3 y, simd_int3 mask);
520/*! @abstract For each bit in the result, selects the corresponding bit of x
521 * or y according to whether the corresponding bit of mask is 0 or 1,
522 * respectively. */
523static inline SIMD_CFUNC simd_uint4 simd_bitselect(simd_uint4 x, simd_uint4 y, simd_int4 mask);
524/*! @abstract For each bit in the result, selects the corresponding bit of x
525 * or y according to whether the corresponding bit of mask is 0 or 1,
526 * respectively. */
527static inline SIMD_CFUNC simd_uint8 simd_bitselect(simd_uint8 x, simd_uint8 y, simd_int8 mask);
528/*! @abstract For each bit in the result, selects the corresponding bit of x
529 * or y according to whether the corresponding bit of mask is 0 or 1,
530 * respectively. */
531static inline SIMD_CFUNC simd_uint16 simd_bitselect(simd_uint16 x, simd_uint16 y, simd_int16 mask);
532/*! @abstract For each bit in the result, selects the corresponding bit of x
533 * or y according to whether the corresponding bit of mask is 0 or 1,
534 * respectively. */
535static inline SIMD_CFUNC simd_float2 simd_bitselect(simd_float2 x, simd_float2 y, simd_int2 mask);
536/*! @abstract For each bit in the result, selects the corresponding bit of x
537 * or y according to whether the corresponding bit of mask is 0 or 1,
538 * respectively. */
539static inline SIMD_CFUNC simd_float3 simd_bitselect(simd_float3 x, simd_float3 y, simd_int3 mask);
540/*! @abstract For each bit in the result, selects the corresponding bit of x
541 * or y according to whether the corresponding bit of mask is 0 or 1,
542 * respectively. */
543static inline SIMD_CFUNC simd_float4 simd_bitselect(simd_float4 x, simd_float4 y, simd_int4 mask);
544/*! @abstract For each bit in the result, selects the corresponding bit of x
545 * or y according to whether the corresponding bit of mask is 0 or 1,
546 * respectively. */
547static inline SIMD_CFUNC simd_float8 simd_bitselect(simd_float8 x, simd_float8 y, simd_int8 mask);
548/*! @abstract For each bit in the result, selects the corresponding bit of x
549 * or y according to whether the corresponding bit of mask is 0 or 1,
550 * respectively. */
551static inline SIMD_CFUNC simd_float16 simd_bitselect(simd_float16 x, simd_float16 y, simd_int16 mask);
552/*! @abstract For each bit in the result, selects the corresponding bit of x
553 * or y according to whether the corresponding bit of mask is 0 or 1,
554 * respectively. */
555static inline SIMD_CFUNC simd_long2 simd_bitselect(simd_long2 x, simd_long2 y, simd_long2 mask);
556/*! @abstract For each bit in the result, selects the corresponding bit of x
557 * or y according to whether the corresponding bit of mask is 0 or 1,
558 * respectively. */
559static inline SIMD_CFUNC simd_long3 simd_bitselect(simd_long3 x, simd_long3 y, simd_long3 mask);
560/*! @abstract For each bit in the result, selects the corresponding bit of x
561 * or y according to whether the corresponding bit of mask is 0 or 1,
562 * respectively. */
563static inline SIMD_CFUNC simd_long4 simd_bitselect(simd_long4 x, simd_long4 y, simd_long4 mask);
564/*! @abstract For each bit in the result, selects the corresponding bit of x
565 * or y according to whether the corresponding bit of mask is 0 or 1,
566 * respectively. */
567static inline SIMD_CFUNC simd_long8 simd_bitselect(simd_long8 x, simd_long8 y, simd_long8 mask);
568/*! @abstract For each bit in the result, selects the corresponding bit of x
569 * or y according to whether the corresponding bit of mask is 0 or 1,
570 * respectively. */
571static inline SIMD_CFUNC simd_ulong2 simd_bitselect(simd_ulong2 x, simd_ulong2 y, simd_long2 mask);
572/*! @abstract For each bit in the result, selects the corresponding bit of x
573 * or y according to whether the corresponding bit of mask is 0 or 1,
574 * respectively. */
575static inline SIMD_CFUNC simd_ulong3 simd_bitselect(simd_ulong3 x, simd_ulong3 y, simd_long3 mask);
576/*! @abstract For each bit in the result, selects the corresponding bit of x
577 * or y according to whether the corresponding bit of mask is 0 or 1,
578 * respectively. */
579static inline SIMD_CFUNC simd_ulong4 simd_bitselect(simd_ulong4 x, simd_ulong4 y, simd_long4 mask);
580/*! @abstract For each bit in the result, selects the corresponding bit of x
581 * or y according to whether the corresponding bit of mask is 0 or 1,
582 * respectively. */
583static inline SIMD_CFUNC simd_ulong8 simd_bitselect(simd_ulong8 x, simd_ulong8 y, simd_long8 mask);
584/*! @abstract For each bit in the result, selects the corresponding bit of x
585 * or y according to whether the corresponding bit of mask is 0 or 1,
586 * respectively. */
587static inline SIMD_CFUNC simd_double2 simd_bitselect(simd_double2 x, simd_double2 y, simd_long2 mask);
588/*! @abstract For each bit in the result, selects the corresponding bit of x
589 * or y according to whether the corresponding bit of mask is 0 or 1,
590 * respectively. */
591static inline SIMD_CFUNC simd_double3 simd_bitselect(simd_double3 x, simd_double3 y, simd_long3 mask);
592/*! @abstract For each bit in the result, selects the corresponding bit of x
593 * or y according to whether the corresponding bit of mask is 0 or 1,
594 * respectively. */
595static inline SIMD_CFUNC simd_double4 simd_bitselect(simd_double4 x, simd_double4 y, simd_long4 mask);
596/*! @abstract For each bit in the result, selects the corresponding bit of x
597 * or y according to whether the corresponding bit of mask is 0 or 1,
598 * respectively. */
599static inline SIMD_CFUNC simd_double8 simd_bitselect(simd_double8 x, simd_double8 y, simd_long8 mask);
600/*! @abstract For each bit in the result, selects the corresponding bit of x
601 * or y according to whether the corresponding bit of mask is 0 or 1,
602 * respectively.
603 * @discussion Deprecated. Use simd_bitselect instead. */
604#define vector_bitselect simd_bitselect
605
606#ifdef __cplusplus
607} /* extern "C" */
608
609namespace simd {
610 /*! @abstract True if and only if the high-order bit of every lane is set. */
611 template <typename inttypeN> static SIMD_CPPFUNC simd_bool all(const inttypeN predicate) { return ::simd_all(predicate); }
612 /*! @abstract True if and only if the high-order bit of any lane is set. */
613 template <typename inttypeN> static SIMD_CPPFUNC simd_bool any(const inttypeN predicate) { return ::simd_any(predicate); }
614 /*! @abstract Each lane of the result is selected from the corresponding lane
615 * of x or y according to whether the high-order bit of the corresponding
616 * lane of mask is 0 or 1, respectively. */
617 template <typename inttypeN, typename fptypeN> static SIMD_CPPFUNC fptypeN select(const fptypeN x, const fptypeN y, const inttypeN predicate) { return ::simd_select(x,y,predicate); }
618 /*! @abstract For each bit in the result, selects the corresponding bit of x
619 * or y according to whether the corresponding bit of mask is 0 or 1,
620 * respectively. */
621 template <typename inttypeN, typename typeN> static SIMD_CPPFUNC typeN bitselect(const typeN x, const typeN y, const inttypeN mask) { return ::simd_bitselect(x,y,mask); }
622}
623
624extern "C" {
625#endif /* __cplusplus */
626
627#pragma mark - Implementations
628
629static inline SIMD_CFUNC simd_bool simd_any(simd_char2 x) {
630#if defined __SSE2__
631 return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x3);
632#elif defined __arm64__
633 return simd_any(x.xyxy);
634#else
635 union { uint16_t i; simd_char2 v; } u = { .v = x };
636 return (u.i & 0x8080);
637#endif
638}
639static inline SIMD_CFUNC simd_bool simd_any(simd_char3 x) {
640#if defined __SSE2__
641 return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x7);
642#elif defined __arm64__
643 return simd_any(x.xyzz);
644#else
645 union { uint32_t i; simd_char3 v; } u = { .v = x };
646 return (u.i & 0x808080);
647#endif
648}
649static inline SIMD_CFUNC simd_bool simd_any(simd_char4 x) {
650#if defined __SSE2__
651 return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xf);
652#elif defined __arm64__
653 return simd_any(x.xyzwxyzw);
654#else
655 union { uint32_t i; simd_char4 v; } u = { .v = x };
656 return (u.i & 0x80808080);
657#endif
658}
659static inline SIMD_CFUNC simd_bool simd_any(simd_char8 x) {
660#if defined __SSE2__
661 return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xff);
662#elif defined __arm64__
663 return vmaxv_u8(x) & 0x80;
664#else
665 union { uint64_t i; simd_char8 v; } u = { .v = x };
666 return (u.i & 0x8080808080808080);
667#endif
668}
669static inline SIMD_CFUNC simd_bool simd_any(simd_char16 x) {
670#if defined __SSE2__
671 return _mm_movemask_epi8((__m128i)x);
672#elif defined __arm64__
673 return vmaxvq_u8(x) & 0x80;
674#else
675 return simd_any(x.lo | x.hi);
676#endif
677}
678static inline SIMD_CFUNC simd_bool simd_any(simd_char32 x) {
679#if defined __AVX2__
680 return _mm256_movemask_epi8(x);
681#else
682 return simd_any(x.lo | x.hi);
683#endif
684}
685static inline SIMD_CFUNC simd_bool simd_any(simd_char64 x) {
686 return simd_any(x.lo | x.hi);
687}
688static inline SIMD_CFUNC simd_bool simd_any(simd_uchar2 x) {
689 return simd_any((simd_char2)x);
690}
691static inline SIMD_CFUNC simd_bool simd_any(simd_uchar3 x) {
692 return simd_any((simd_char3)x);
693}
694static inline SIMD_CFUNC simd_bool simd_any(simd_uchar4 x) {
695 return simd_any((simd_char4)x);
696}
697static inline SIMD_CFUNC simd_bool simd_any(simd_uchar8 x) {
698 return simd_any((simd_char8)x);
699}
700static inline SIMD_CFUNC simd_bool simd_any(simd_uchar16 x) {
701 return simd_any((simd_char16)x);
702}
703static inline SIMD_CFUNC simd_bool simd_any(simd_uchar32 x) {
704 return simd_any((simd_char32)x);
705}
706static inline SIMD_CFUNC simd_bool simd_any(simd_uchar64 x) {
707 return simd_any((simd_char64)x);
708}
709static inline SIMD_CFUNC simd_bool simd_any(simd_short2 x) {
710#if defined __SSE2__
711 return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xa);
712#elif defined __arm64__
713 return simd_any(x.xyxy);
714#else
715 union { uint32_t i; simd_short2 v; } u = { .v = x };
716 return (u.i & 0x80008000);
717#endif
718}
719static inline SIMD_CFUNC simd_bool simd_any(simd_short3 x) {
720#if defined __SSE2__
721 return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0x2a);
722#elif defined __arm64__
723 return simd_any(x.xyzz);
724#else
725 union { uint64_t i; simd_short3 v; } u = { .v = x };
726 return (u.i & 0x800080008000);
727#endif
728}
729static inline SIMD_CFUNC simd_bool simd_any(simd_short4 x) {
730#if defined __SSE2__
731 return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xaa);
732#elif defined __arm64__
733 return vmaxv_u16(x) & 0x8000;
734#else
735 union { uint64_t i; simd_short4 v; } u = { .v = x };
736 return (u.i & 0x8000800080008000);
737#endif
738}
739static inline SIMD_CFUNC simd_bool simd_any(simd_short8 x) {
740#if defined __SSE2__
741 return (_mm_movemask_epi8((__m128i)x) & 0xaaaa);
742#elif defined __arm64__
743 return vmaxvq_u16(x) & 0x8000;
744#else
745 return simd_any(x.lo | x.hi);
746#endif
747}
748static inline SIMD_CFUNC simd_bool simd_any(simd_short16 x) {
749#if defined __AVX2__
750 return (_mm256_movemask_epi8(x) & 0xaaaaaaaa);
751#else
752 return simd_any(x.lo | x.hi);
753#endif
754}
755static inline SIMD_CFUNC simd_bool simd_any(simd_short32 x) {
756 return simd_any(x.lo | x.hi);
757}
758static inline SIMD_CFUNC simd_bool simd_any(simd_ushort2 x) {
759 return simd_any((simd_short2)x);
760}
761static inline SIMD_CFUNC simd_bool simd_any(simd_ushort3 x) {
762 return simd_any((simd_short3)x);
763}
764static inline SIMD_CFUNC simd_bool simd_any(simd_ushort4 x) {
765 return simd_any((simd_short4)x);
766}
767static inline SIMD_CFUNC simd_bool simd_any(simd_ushort8 x) {
768 return simd_any((simd_short8)x);
769}
770static inline SIMD_CFUNC simd_bool simd_any(simd_ushort16 x) {
771 return simd_any((simd_short16)x);
772}
773static inline SIMD_CFUNC simd_bool simd_any(simd_ushort32 x) {
774 return simd_any((simd_short32)x);
775}
776static inline SIMD_CFUNC simd_bool simd_any(simd_int2 x) {
777#if defined __SSE2__
778 return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x3);
779#elif defined __arm64__
780 return vmaxv_u32(x) & 0x80000000;
781#else
782 union { uint64_t i; simd_int2 v; } u = { .v = x };
783 return (u.i & 0x8000000080000000);
784#endif
785}
786static inline SIMD_CFUNC simd_bool simd_any(simd_int3 x) {
787#if defined __SSE2__
788 return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x7);
789#elif defined __arm64__
790 return simd_any(x.xyzz);
791#else
792 return (x.x | x.y | x.z) & 0x80000000;
793#endif
794}
795static inline SIMD_CFUNC simd_bool simd_any(simd_int4 x) {
796#if defined __SSE2__
797 return _mm_movemask_ps((__m128)x);
798#elif defined __arm64__
799 return vmaxvq_u32(x) & 0x80000000;
800#else
801 return simd_any(x.lo | x.hi);
802#endif
803}
804static inline SIMD_CFUNC simd_bool simd_any(simd_int8 x) {
805#if defined __AVX__
806 return _mm256_movemask_ps(x);
807#else
808 return simd_any(x.lo | x.hi);
809#endif
810}
811static inline SIMD_CFUNC simd_bool simd_any(simd_int16 x) {
812 return simd_any(x.lo | x.hi);
813}
814static inline SIMD_CFUNC simd_bool simd_any(simd_uint2 x) {
815 return simd_any((simd_int2)x);
816}
817static inline SIMD_CFUNC simd_bool simd_any(simd_uint3 x) {
818 return simd_any((simd_int3)x);
819}
820static inline SIMD_CFUNC simd_bool simd_any(simd_uint4 x) {
821 return simd_any((simd_int4)x);
822}
823static inline SIMD_CFUNC simd_bool simd_any(simd_uint8 x) {
824 return simd_any((simd_int8)x);
825}
826static inline SIMD_CFUNC simd_bool simd_any(simd_uint16 x) {
827 return simd_any((simd_int16)x);
828}
829static inline SIMD_CFUNC simd_bool simd_any(simd_long2 x) {
830#if defined __SSE2__
831 return _mm_movemask_pd((__m128d)x);
832#elif defined __arm64__
833 return (x.x | x.y) & 0x8000000000000000U;
834#else
835 return (x.x | x.y) & 0x8000000000000000U;
836#endif
837}
838static inline SIMD_CFUNC simd_bool simd_any(simd_long3 x) {
839#if defined __AVX__
840 return (_mm256_movemask_pd(simd_make_long4_undef(x)) & 0x7);
841#else
842 return (x.x | x.y | x.z) & 0x8000000000000000U;
843#endif
844}
845static inline SIMD_CFUNC simd_bool simd_any(simd_long4 x) {
846#if defined __AVX__
847 return _mm256_movemask_pd(x);
848#else
849 return simd_any(x.lo | x.hi);
850#endif
851}
852static inline SIMD_CFUNC simd_bool simd_any(simd_long8 x) {
853 return simd_any(x.lo | x.hi);
854}
855static inline SIMD_CFUNC simd_bool simd_any(simd_ulong2 x) {
856 return simd_any((simd_long2)x);
857}
858static inline SIMD_CFUNC simd_bool simd_any(simd_ulong3 x) {
859 return simd_any((simd_long3)x);
860}
861static inline SIMD_CFUNC simd_bool simd_any(simd_ulong4 x) {
862 return simd_any((simd_long4)x);
863}
864static inline SIMD_CFUNC simd_bool simd_any(simd_ulong8 x) {
865 return simd_any((simd_long8)x);
866}
867
868static inline SIMD_CFUNC simd_bool simd_all(simd_char2 x) {
869#if defined __SSE2__
870 return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x3) == 0x3;
871#elif defined __arm64__
872 return simd_all(x.xyxy);
873#else
874 union { uint16_t i; simd_char2 v; } u = { .v = x };
875 return (u.i & 0x8080) == 0x8080;
876#endif
877}
878static inline SIMD_CFUNC simd_bool simd_all(simd_char3 x) {
879#if defined __SSE2__
880 return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x7) == 0x7;
881#elif defined __arm64__
882 return simd_all(x.xyzz);
883#else
884 union { uint32_t i; simd_char3 v; } u = { .v = x };
885 return (u.i & 0x808080) == 0x808080;
886#endif
887}
888static inline SIMD_CFUNC simd_bool simd_all(simd_char4 x) {
889#if defined __SSE2__
890 return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xf) == 0xf;
891#elif defined __arm64__
892 return simd_all(x.xyzwxyzw);
893#else
894 union { uint32_t i; simd_char4 v; } u = { .v = x };
895 return (u.i & 0x80808080) == 0x80808080;
896#endif
897}
898static inline SIMD_CFUNC simd_bool simd_all(simd_char8 x) {
899#if defined __SSE2__
900 return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xff) == 0xff;
901#elif defined __arm64__
902 return vminv_u8(x) & 0x80;
903#else
904 union { uint64_t i; simd_char8 v; } u = { .v = x };
905 return (u.i & 0x8080808080808080) == 0x8080808080808080;
906#endif
907}
908static inline SIMD_CFUNC simd_bool simd_all(simd_char16 x) {
909#if defined __SSE2__
910 return _mm_movemask_epi8((__m128i)x) == 0xffff;
911#elif defined __arm64__
912 return vminvq_u8(x) & 0x80;
913#else
914 return simd_all(x.lo & x.hi);
915#endif
916}
917static inline SIMD_CFUNC simd_bool simd_all(simd_char32 x) {
918#if defined __AVX2__
919 return _mm256_movemask_epi8(x) == 0xffffffff;
920#else
921 return simd_all(x.lo & x.hi);
922#endif
923}
924static inline SIMD_CFUNC simd_bool simd_all(simd_char64 x) {
925 return simd_all(x.lo & x.hi);
926}
927static inline SIMD_CFUNC simd_bool simd_all(simd_uchar2 x) {
928 return simd_all((simd_char2)x);
929}
930static inline SIMD_CFUNC simd_bool simd_all(simd_uchar3 x) {
931 return simd_all((simd_char3)x);
932}
933static inline SIMD_CFUNC simd_bool simd_all(simd_uchar4 x) {
934 return simd_all((simd_char4)x);
935}
936static inline SIMD_CFUNC simd_bool simd_all(simd_uchar8 x) {
937 return simd_all((simd_char8)x);
938}
939static inline SIMD_CFUNC simd_bool simd_all(simd_uchar16 x) {
940 return simd_all((simd_char16)x);
941}
942static inline SIMD_CFUNC simd_bool simd_all(simd_uchar32 x) {
943 return simd_all((simd_char32)x);
944}
945static inline SIMD_CFUNC simd_bool simd_all(simd_uchar64 x) {
946 return simd_all((simd_char64)x);
947}
948static inline SIMD_CFUNC simd_bool simd_all(simd_short2 x) {
949#if defined __SSE2__
950 return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xa) == 0xa;
951#elif defined __arm64__
952 return simd_all(x.xyxy);
953#else
954 union { uint32_t i; simd_short2 v; } u = { .v = x };
955 return (u.i & 0x80008000) == 0x80008000;
956#endif
957}
958static inline SIMD_CFUNC simd_bool simd_all(simd_short3 x) {
959#if defined __SSE2__
960 return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0x2a) == 0x2a;
961#elif defined __arm64__
962 return simd_all(x.xyzz);
963#else
964 union { uint64_t i; simd_short3 v; } u = { .v = x };
965 return (u.i & 0x800080008000) == 0x800080008000;
966#endif
967}
968static inline SIMD_CFUNC simd_bool simd_all(simd_short4 x) {
969#if defined __SSE2__
970 return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xaa) == 0xaa;
971#elif defined __arm64__
972 return vminv_u16(x) & 0x8000;
973#else
974 union { uint64_t i; simd_short4 v; } u = { .v = x };
975 return (u.i & 0x8000800080008000) == 0x8000800080008000;
976#endif
977}
978static inline SIMD_CFUNC simd_bool simd_all(simd_short8 x) {
979#if defined __SSE2__
980 return (_mm_movemask_epi8((__m128i)x) & 0xaaaa) == 0xaaaa;
981#elif defined __arm64__
982 return vminvq_u16(x) & 0x8000;
983#else
984 return simd_all(x.lo & x.hi);
985#endif
986}
987static inline SIMD_CFUNC simd_bool simd_all(simd_short16 x) {
988#if defined __AVX2__
989 return (_mm256_movemask_epi8(x) & 0xaaaaaaaa) == 0xaaaaaaaa;
990#else
991 return simd_all(x.lo & x.hi);
992#endif
993}
994static inline SIMD_CFUNC simd_bool simd_all(simd_short32 x) {
995 return simd_all(x.lo & x.hi);
996}
997static inline SIMD_CFUNC simd_bool simd_all(simd_ushort2 x) {
998 return simd_all((simd_short2)x);
999}
1000static inline SIMD_CFUNC simd_bool simd_all(simd_ushort3 x) {
1001 return simd_all((simd_short3)x);
1002}
1003static inline SIMD_CFUNC simd_bool simd_all(simd_ushort4 x) {
1004 return simd_all((simd_short4)x);
1005}
1006static inline SIMD_CFUNC simd_bool simd_all(simd_ushort8 x) {
1007 return simd_all((simd_short8)x);
1008}
1009static inline SIMD_CFUNC simd_bool simd_all(simd_ushort16 x) {
1010 return simd_all((simd_short16)x);
1011}
1012static inline SIMD_CFUNC simd_bool simd_all(simd_ushort32 x) {
1013 return simd_all((simd_short32)x);
1014}
1015static inline SIMD_CFUNC simd_bool simd_all(simd_int2 x) {
1016#if defined __SSE2__
1017 return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x3) == 0x3;
1018#elif defined __arm64__
1019 return vminv_u32(x) & 0x80000000;
1020#else
1021 union { uint64_t i; simd_int2 v; } u = { .v = x };
1022 return (u.i & 0x8000000080000000) == 0x8000000080000000;
1023#endif
1024}
1025static inline SIMD_CFUNC simd_bool simd_all(simd_int3 x) {
1026#if defined __SSE2__
1027 return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x7) == 0x7;
1028#elif defined __arm64__
1029 return simd_all(x.xyzz);
1030#else
1031 return (x.x & x.y & x.z) & 0x80000000;
1032#endif
1033}
1034static inline SIMD_CFUNC simd_bool simd_all(simd_int4 x) {
1035#if defined __SSE2__
1036 return _mm_movemask_ps((__m128)x) == 0xf;
1037#elif defined __arm64__
1038 return vminvq_u32(x) & 0x80000000;
1039#else
1040 return simd_all(x.lo & x.hi);
1041#endif
1042}
1043static inline SIMD_CFUNC simd_bool simd_all(simd_int8 x) {
1044#if defined __AVX__
1045 return _mm256_movemask_ps(x) == 0xff;
1046#else
1047 return simd_all(x.lo & x.hi);
1048#endif
1049}
1050static inline SIMD_CFUNC simd_bool simd_all(simd_int16 x) {
1051 return simd_all(x.lo & x.hi);
1052}
1053static inline SIMD_CFUNC simd_bool simd_all(simd_uint2 x) {
1054 return simd_all((simd_int2)x);
1055}
1056static inline SIMD_CFUNC simd_bool simd_all(simd_uint3 x) {
1057 return simd_all((simd_int3)x);
1058}
1059static inline SIMD_CFUNC simd_bool simd_all(simd_uint4 x) {
1060 return simd_all((simd_int4)x);
1061}
1062static inline SIMD_CFUNC simd_bool simd_all(simd_uint8 x) {
1063 return simd_all((simd_int8)x);
1064}
1065static inline SIMD_CFUNC simd_bool simd_all(simd_uint16 x) {
1066 return simd_all((simd_int16)x);
1067}
1068static inline SIMD_CFUNC simd_bool simd_all(simd_long2 x) {
1069#if defined __SSE2__
1070 return _mm_movemask_pd((__m128d)x) == 0x3;
1071#elif defined __arm64__
1072 return (x.x & x.y) & 0x8000000000000000U;
1073#else
1074 return (x.x & x.y) & 0x8000000000000000U;
1075#endif
1076}
1077static inline SIMD_CFUNC simd_bool simd_all(simd_long3 x) {
1078#if defined __AVX__
1079 return (_mm256_movemask_pd(simd_make_long4_undef(x)) & 0x7) == 0x7;
1080#else
1081 return (x.x & x.y & x.z) & 0x8000000000000000U;
1082#endif
1083}
1084static inline SIMD_CFUNC simd_bool simd_all(simd_long4 x) {
1085#if defined __AVX__
1086 return _mm256_movemask_pd(x) == 0xf;
1087#else
1088 return simd_all(x.lo & x.hi);
1089#endif
1090}
1091static inline SIMD_CFUNC simd_bool simd_all(simd_long8 x) {
1092 return simd_all(x.lo & x.hi);
1093}
1094static inline SIMD_CFUNC simd_bool simd_all(simd_ulong2 x) {
1095 return simd_all((simd_long2)x);
1096}
1097static inline SIMD_CFUNC simd_bool simd_all(simd_ulong3 x) {
1098 return simd_all((simd_long3)x);
1099}
1100static inline SIMD_CFUNC simd_bool simd_all(simd_ulong4 x) {
1101 return simd_all((simd_long4)x);
1102}
1103static inline SIMD_CFUNC simd_bool simd_all(simd_ulong8 x) {
1104 return simd_all((simd_long8)x);
1105}
1106
1107static inline SIMD_CFUNC simd_float2 simd_select(simd_float2 x, simd_float2 y, simd_int2 mask) {
1108 return simd_make_float2(simd_select(simd_make_float4_undef(x), simd_make_float4_undef(y), simd_make_int4_undef(mask)));
1109}
1110static inline SIMD_CFUNC simd_float3 simd_select(simd_float3 x, simd_float3 y, simd_int3 mask) {
1111 return simd_make_float3(simd_select(simd_make_float4_undef(x), simd_make_float4_undef(y), simd_make_int4_undef(mask)));
1112}
1113static inline SIMD_CFUNC simd_float4 simd_select(simd_float4 x, simd_float4 y, simd_int4 mask) {
1114#if defined __SSE4_1__
1115 return _mm_blendv_ps(x, y, (__m128)mask);
1116#else
1117 return simd_bitselect(x, y, mask >> 31);
1118#endif
1119}
1120static inline SIMD_CFUNC simd_float8 simd_select(simd_float8 x, simd_float8 y, simd_int8 mask) {
1121#if defined __AVX__
1122 return _mm256_blendv_ps(x, y, mask);
1123#else
1124 return simd_bitselect(x, y, mask >> 31);
1125#endif
1126}
1127static inline SIMD_CFUNC simd_float16 simd_select(simd_float16 x, simd_float16 y, simd_int16 mask) {
1128 return simd_bitselect(x, y, mask >> 31);
1129}
1130static inline SIMD_CFUNC simd_double2 simd_select(simd_double2 x, simd_double2 y, simd_long2 mask) {
1131#if defined __SSE4_1__
1132 return _mm_blendv_pd(x, y, (__m128d)mask);
1133#else
1134 return simd_bitselect(x, y, mask >> 63);
1135#endif
1136}
1137static inline SIMD_CFUNC simd_double3 simd_select(simd_double3 x, simd_double3 y, simd_long3 mask) {
1138 return simd_make_double3(simd_select(simd_make_double4_undef(x), simd_make_double4_undef(y), simd_make_long4_undef(mask)));
1139}
1140static inline SIMD_CFUNC simd_double4 simd_select(simd_double4 x, simd_double4 y, simd_long4 mask) {
1141#if defined __AVX__
1142 return _mm256_blendv_pd(x, y, mask);
1143#else
1144 return simd_bitselect(x, y, mask >> 63);
1145#endif
1146}
1147static inline SIMD_CFUNC simd_double8 simd_select(simd_double8 x, simd_double8 y, simd_long8 mask) {
1148 return simd_bitselect(x, y, mask >> 63);
1149}
1150
1151static inline SIMD_CFUNC simd_char2 simd_bitselect(simd_char2 x, simd_char2 y, simd_char2 mask) {
1152 return (x & ~mask) | (y & mask);
1153}
1154static inline SIMD_CFUNC simd_char3 simd_bitselect(simd_char3 x, simd_char3 y, simd_char3 mask) {
1155 return (x & ~mask) | (y & mask);
1156}
1157static inline SIMD_CFUNC simd_char4 simd_bitselect(simd_char4 x, simd_char4 y, simd_char4 mask) {
1158 return (x & ~mask) | (y & mask);
1159}
1160static inline SIMD_CFUNC simd_char8 simd_bitselect(simd_char8 x, simd_char8 y, simd_char8 mask) {
1161 return (x & ~mask) | (y & mask);
1162}
1163static inline SIMD_CFUNC simd_char16 simd_bitselect(simd_char16 x, simd_char16 y, simd_char16 mask) {
1164 return (x & ~mask) | (y & mask);
1165}
1166static inline SIMD_CFUNC simd_char32 simd_bitselect(simd_char32 x, simd_char32 y, simd_char32 mask) {
1167 return (x & ~mask) | (y & mask);
1168}
1169static inline SIMD_CFUNC simd_char64 simd_bitselect(simd_char64 x, simd_char64 y, simd_char64 mask) {
1170 return (x & ~mask) | (y & mask);
1171}
1172static inline SIMD_CFUNC simd_uchar2 simd_bitselect(simd_uchar2 x, simd_uchar2 y, simd_char2 mask) {
1173 return (simd_uchar2)simd_bitselect((simd_char2)x, (simd_char2)y, mask);
1174}
1175static inline SIMD_CFUNC simd_uchar3 simd_bitselect(simd_uchar3 x, simd_uchar3 y, simd_char3 mask) {
1176 return (simd_uchar3)simd_bitselect((simd_char3)x, (simd_char3)y, mask);
1177}
1178static inline SIMD_CFUNC simd_uchar4 simd_bitselect(simd_uchar4 x, simd_uchar4 y, simd_char4 mask) {
1179 return (simd_uchar4)simd_bitselect((simd_char4)x, (simd_char4)y, mask);
1180}
1181static inline SIMD_CFUNC simd_uchar8 simd_bitselect(simd_uchar8 x, simd_uchar8 y, simd_char8 mask) {
1182 return (simd_uchar8)simd_bitselect((simd_char8)x, (simd_char8)y, mask);
1183}
1184static inline SIMD_CFUNC simd_uchar16 simd_bitselect(simd_uchar16 x, simd_uchar16 y, simd_char16 mask) {
1185 return (simd_uchar16)simd_bitselect((simd_char16)x, (simd_char16)y, mask);
1186}
1187static inline SIMD_CFUNC simd_uchar32 simd_bitselect(simd_uchar32 x, simd_uchar32 y, simd_char32 mask) {
1188 return (simd_uchar32)simd_bitselect((simd_char32)x, (simd_char32)y, mask);
1189}
1190static inline SIMD_CFUNC simd_uchar64 simd_bitselect(simd_uchar64 x, simd_uchar64 y, simd_char64 mask) {
1191 return (simd_uchar64)simd_bitselect((simd_char64)x, (simd_char64)y, mask);
1192}
1193static inline SIMD_CFUNC simd_short2 simd_bitselect(simd_short2 x, simd_short2 y, simd_short2 mask) {
1194 return (x & ~mask) | (y & mask);
1195}
1196static inline SIMD_CFUNC simd_short3 simd_bitselect(simd_short3 x, simd_short3 y, simd_short3 mask) {
1197 return (x & ~mask) | (y & mask);
1198}
1199static inline SIMD_CFUNC simd_short4 simd_bitselect(simd_short4 x, simd_short4 y, simd_short4 mask) {
1200 return (x & ~mask) | (y & mask);
1201}
1202static inline SIMD_CFUNC simd_short8 simd_bitselect(simd_short8 x, simd_short8 y, simd_short8 mask) {
1203 return (x & ~mask) | (y & mask);
1204}
1205static inline SIMD_CFUNC simd_short16 simd_bitselect(simd_short16 x, simd_short16 y, simd_short16 mask) {
1206 return (x & ~mask) | (y & mask);
1207}
1208static inline SIMD_CFUNC simd_short32 simd_bitselect(simd_short32 x, simd_short32 y, simd_short32 mask) {
1209 return (x & ~mask) | (y & mask);
1210}
1211static inline SIMD_CFUNC simd_ushort2 simd_bitselect(simd_ushort2 x, simd_ushort2 y, simd_short2 mask) {
1212 return (simd_ushort2)simd_bitselect((simd_short2)x, (simd_short2)y, mask);
1213}
1214static inline SIMD_CFUNC simd_ushort3 simd_bitselect(simd_ushort3 x, simd_ushort3 y, simd_short3 mask) {
1215 return (simd_ushort3)simd_bitselect((simd_short3)x, (simd_short3)y, mask);
1216}
1217static inline SIMD_CFUNC simd_ushort4 simd_bitselect(simd_ushort4 x, simd_ushort4 y, simd_short4 mask) {
1218 return (simd_ushort4)simd_bitselect((simd_short4)x, (simd_short4)y, mask);
1219}
1220static inline SIMD_CFUNC simd_ushort8 simd_bitselect(simd_ushort8 x, simd_ushort8 y, simd_short8 mask) {
1221 return (simd_ushort8)simd_bitselect((simd_short8)x, (simd_short8)y, mask);
1222}
1223static inline SIMD_CFUNC simd_ushort16 simd_bitselect(simd_ushort16 x, simd_ushort16 y, simd_short16 mask) {
1224 return (simd_ushort16)simd_bitselect((simd_short16)x, (simd_short16)y, mask);
1225}
1226static inline SIMD_CFUNC simd_ushort32 simd_bitselect(simd_ushort32 x, simd_ushort32 y, simd_short32 mask) {
1227 return (simd_ushort32)simd_bitselect((simd_short32)x, (simd_short32)y, mask);
1228}
1229static inline SIMD_CFUNC simd_int2 simd_bitselect(simd_int2 x, simd_int2 y, simd_int2 mask) {
1230 return (x & ~mask) | (y & mask);
1231}
1232static inline SIMD_CFUNC simd_int3 simd_bitselect(simd_int3 x, simd_int3 y, simd_int3 mask) {
1233 return (x & ~mask) | (y & mask);
1234}
1235static inline SIMD_CFUNC simd_int4 simd_bitselect(simd_int4 x, simd_int4 y, simd_int4 mask) {
1236 return (x & ~mask) | (y & mask);
1237}
1238static inline SIMD_CFUNC simd_int8 simd_bitselect(simd_int8 x, simd_int8 y, simd_int8 mask) {
1239 return (x & ~mask) | (y & mask);
1240}
1241static inline SIMD_CFUNC simd_int16 simd_bitselect(simd_int16 x, simd_int16 y, simd_int16 mask) {
1242 return (x & ~mask) | (y & mask);
1243}
1244static inline SIMD_CFUNC simd_uint2 simd_bitselect(simd_uint2 x, simd_uint2 y, simd_int2 mask) {
1245 return (simd_uint2)simd_bitselect((simd_int2)x, (simd_int2)y, mask);
1246}
1247static inline SIMD_CFUNC simd_uint3 simd_bitselect(simd_uint3 x, simd_uint3 y, simd_int3 mask) {
1248 return (simd_uint3)simd_bitselect((simd_int3)x, (simd_int3)y, mask);
1249}
1250static inline SIMD_CFUNC simd_uint4 simd_bitselect(simd_uint4 x, simd_uint4 y, simd_int4 mask) {
1251 return (simd_uint4)simd_bitselect((simd_int4)x, (simd_int4)y, mask);
1252}
1253static inline SIMD_CFUNC simd_uint8 simd_bitselect(simd_uint8 x, simd_uint8 y, simd_int8 mask) {
1254 return (simd_uint8)simd_bitselect((simd_int8)x, (simd_int8)y, mask);
1255}
1256static inline SIMD_CFUNC simd_uint16 simd_bitselect(simd_uint16 x, simd_uint16 y, simd_int16 mask) {
1257 return (simd_uint16)simd_bitselect((simd_int16)x, (simd_int16)y, mask);
1258}
1259static inline SIMD_CFUNC simd_float2 simd_bitselect(simd_float2 x, simd_float2 y, simd_int2 mask) {
1260 return (simd_float2)simd_bitselect((simd_int2)x, (simd_int2)y, mask);
1261}
1262static inline SIMD_CFUNC simd_float3 simd_bitselect(simd_float3 x, simd_float3 y, simd_int3 mask) {
1263 return (simd_float3)simd_bitselect((simd_int3)x, (simd_int3)y, mask);
1264}
1265static inline SIMD_CFUNC simd_float4 simd_bitselect(simd_float4 x, simd_float4 y, simd_int4 mask) {
1266 return (simd_float4)simd_bitselect((simd_int4)x, (simd_int4)y, mask);
1267}
1268static inline SIMD_CFUNC simd_float8 simd_bitselect(simd_float8 x, simd_float8 y, simd_int8 mask) {
1269 return (simd_float8)simd_bitselect((simd_int8)x, (simd_int8)y, mask);
1270}
1271static inline SIMD_CFUNC simd_float16 simd_bitselect(simd_float16 x, simd_float16 y, simd_int16 mask) {
1272 return (simd_float16)simd_bitselect((simd_int16)x, (simd_int16)y, mask);
1273}
1274static inline SIMD_CFUNC simd_long2 simd_bitselect(simd_long2 x, simd_long2 y, simd_long2 mask) {
1275 return (x & ~mask) | (y & mask);
1276}
1277static inline SIMD_CFUNC simd_long3 simd_bitselect(simd_long3 x, simd_long3 y, simd_long3 mask) {
1278 return (x & ~mask) | (y & mask);
1279}
1280static inline SIMD_CFUNC simd_long4 simd_bitselect(simd_long4 x, simd_long4 y, simd_long4 mask) {
1281 return (x & ~mask) | (y & mask);
1282}
1283static inline SIMD_CFUNC simd_long8 simd_bitselect(simd_long8 x, simd_long8 y, simd_long8 mask) {
1284 return (x & ~mask) | (y & mask);
1285}
1286static inline SIMD_CFUNC simd_ulong2 simd_bitselect(simd_ulong2 x, simd_ulong2 y, simd_long2 mask) {
1287 return (simd_ulong2)simd_bitselect((simd_long2)x, (simd_long2)y, mask);
1288}
1289static inline SIMD_CFUNC simd_ulong3 simd_bitselect(simd_ulong3 x, simd_ulong3 y, simd_long3 mask) {
1290 return (simd_ulong3)simd_bitselect((simd_long3)x, (simd_long3)y, mask);
1291}
1292static inline SIMD_CFUNC simd_ulong4 simd_bitselect(simd_ulong4 x, simd_ulong4 y, simd_long4 mask) {
1293 return (simd_ulong4)simd_bitselect((simd_long4)x, (simd_long4)y, mask);
1294}
1295static inline SIMD_CFUNC simd_ulong8 simd_bitselect(simd_ulong8 x, simd_ulong8 y, simd_long8 mask) {
1296 return (simd_ulong8)simd_bitselect((simd_long8)x, (simd_long8)y, mask);
1297}
1298static inline SIMD_CFUNC simd_double2 simd_bitselect(simd_double2 x, simd_double2 y, simd_long2 mask) {
1299 return (simd_double2)simd_bitselect((simd_long2)x, (simd_long2)y, mask);
1300}
1301static inline SIMD_CFUNC simd_double3 simd_bitselect(simd_double3 x, simd_double3 y, simd_long3 mask) {
1302 return (simd_double3)simd_bitselect((simd_long3)x, (simd_long3)y, mask);
1303}
1304static inline SIMD_CFUNC simd_double4 simd_bitselect(simd_double4 x, simd_double4 y, simd_long4 mask) {
1305 return (simd_double4)simd_bitselect((simd_long4)x, (simd_long4)y, mask);
1306}
1307static inline SIMD_CFUNC simd_double8 simd_bitselect(simd_double8 x, simd_double8 y, simd_long8 mask) {
1308 return (simd_double8)simd_bitselect((simd_long8)x, (simd_long8)y, mask);
1309}
1310
1311#ifdef __cplusplus
1312}
1313#endif
1314#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
1315#endif /* __SIMD_LOGIC_HEADER__ */
lib/libc/include/x86_64-macos-gnu/simd/math.h created+5380
......@@ -0,0 +1,5380 @@
1/*! @header
2 * The interfaces declared in this header provide elementwise math operations
3 * on vectors; each lane of the result vector depends only on the data in the
4 * corresponding lane of the argument(s) to the function.
5 *
6 * You should not use the C functions declared in this header directly (these
7 * are functions with names like `__tg_cos(x)`). These are merely
8 * implementation details of <tgmath.h> overloading; instead of calling
9 * `__tg_cos(x)`, call `cos(x)`. If you are writing C++, use `simd::cos(x)`.
10 *
11 * Note that while these vector functions are relatively recent additions,
12 * scalar fallback is provided for all of them, so they are available even
13 * when targeting older OS versions.
14 *
15 * The following functions are available:
16 *
17 * C name C++ name Notes
18 * ----------------------------------------------------------------------
19 * acos(x) simd::acos(x)
20 * asin(x) simd::asin(x)
21 * atan(x) simd::atan(x)
22 * atan2(y,x) simd::atan2(y,x) The argument order matches the scalar
23 * atan2 function, which gives the angle
24 * of a line with slope y/x.
25 * cos(x) simd::cos(x)
26 * sin(x) simd::sin(x)
27 * tan(x) simd::tan(x)
28 *
29 * cospi(x) simd::cospi(x) Returns cos(pi*x), sin(pi*x), tan(pi*x)
30 * sinpi(x) simd::sinpi(x) more efficiently and accurately than
31 * tanpi(x) simd::tanpi(x) would otherwise be possible
32 *
33 * acosh(x) simd::acosh(x)
34 * asinh(x) simd::asinh(x)
35 * atanh(x) simd::atanh(x)
36 *
37 * cosh(x) simd::cosh(x)
38 * sinh(x) simd::sinh(x)
39 * tanh(x) simd::tanh(x)
40 *
41 * exp(x) simd::exp(x)
42 * exp2(x) simd::exp2(x)
43 * exp10(x) simd::exp10(x) More efficient that pow(10,x).
44 * expm1(x) simd::expm1(x) exp(x)-1, accurate even for tiny x.
45 *
46 * log(x) simd::log(x)
47 * log2(x) simd::log2(x)
48 * log10(x) simd::log10(x)
49 * log1p(x) simd::log1p(x) log(1+x), accurate even for tiny x.
50 *
51 * fabs(x) simd::fabs(x)
52 * cbrt(x) simd::cbrt(x)
53 * sqrt(x) simd::sqrt(x)
54 * pow(x,y) simd::pow(x,y)
55 * copysign(x,y) simd::copysign(x,y)
56 * hypot(x,y) simd::hypot(x,y) sqrt(x*x + y*y), computed without
57 * overflow.1
58 * erf(x) simd::erf(x)
59 * erfc(x) simd::erfc(x)
60 * tgamma(x) simd::tgamma(x)
61 *
62 * fmod(x,y) simd::fmod(x,y)
63 * remainder(x,y) simd::remainder(x,y)
64 *
65 * ceil(x) simd::ceil(x)
66 * floor(x) simd::floor(x)
67 * rint(x) simd::rint(x)
68 * round(x) simd::round(x)
69 * trunc(x) simd::trunc(x)
70 *
71 * fdim(x,y) simd::fdim(x,y)
72 * fmax(x,y) simd::fmax(x,y) When one argument to fmin or fmax is
73 * fmin(x,y) simd::fmin(x,y) constant, use it as the *second* (y)
74 * argument to get better codegen on some
75 * architectures. E.g., write fmin(x,2)
76 * instead of fmin(2,x).
77 * fma(x,y,z) simd::fma(x,y,z) Fast on arm64 and when targeting AVX2
78 * and later; may be quite expensive on
79 * older hardware.
80 * simd_muladd(x,y,z) simd::muladd(x,y,z)
81 *
82 * @copyright 2014-2017 Apple, Inc. All rights reserved.
83 * @unsorted */
84
85#ifndef SIMD_MATH_HEADER
86#define SIMD_MATH_HEADER
87
88#include <simd/base.h>
89#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
90#include <simd/vector_make.h>
91#include <simd/logic.h>
92
93#ifdef __cplusplus
94extern "C" {
95#endif
96/*! @abstract Do not call this function; instead use `acos` in C and
97 * Objective-C, and `simd::acos` in C++. */
98static inline SIMD_CFUNC simd_float2 __tg_acos(simd_float2 x);
99/*! @abstract Do not call this function; instead use `acos` in C and
100 * Objective-C, and `simd::acos` in C++. */
101static inline SIMD_CFUNC simd_float3 __tg_acos(simd_float3 x);
102/*! @abstract Do not call this function; instead use `acos` in C and
103 * Objective-C, and `simd::acos` in C++. */
104static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x);
105/*! @abstract Do not call this function; instead use `acos` in C and
106 * Objective-C, and `simd::acos` in C++. */
107static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x);
108/*! @abstract Do not call this function; instead use `acos` in C and
109 * Objective-C, and `simd::acos` in C++. */
110static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x);
111/*! @abstract Do not call this function; instead use `acos` in C and
112 * Objective-C, and `simd::acos` in C++. */
113static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x);
114/*! @abstract Do not call this function; instead use `acos` in C and
115 * Objective-C, and `simd::acos` in C++. */
116static inline SIMD_CFUNC simd_double3 __tg_acos(simd_double3 x);
117/*! @abstract Do not call this function; instead use `acos` in C and
118 * Objective-C, and `simd::acos` in C++. */
119static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x);
120/*! @abstract Do not call this function; instead use `acos` in C and
121 * Objective-C, and `simd::acos` in C++. */
122static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x);
123
124/*! @abstract Do not call this function; instead use `asin` in C and
125 * Objective-C, and `simd::asin` in C++. */
126static inline SIMD_CFUNC simd_float2 __tg_asin(simd_float2 x);
127/*! @abstract Do not call this function; instead use `asin` in C and
128 * Objective-C, and `simd::asin` in C++. */
129static inline SIMD_CFUNC simd_float3 __tg_asin(simd_float3 x);
130/*! @abstract Do not call this function; instead use `asin` in C and
131 * Objective-C, and `simd::asin` in C++. */
132static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x);
133/*! @abstract Do not call this function; instead use `asin` in C and
134 * Objective-C, and `simd::asin` in C++. */
135static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x);
136/*! @abstract Do not call this function; instead use `asin` in C and
137 * Objective-C, and `simd::asin` in C++. */
138static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x);
139/*! @abstract Do not call this function; instead use `asin` in C and
140 * Objective-C, and `simd::asin` in C++. */
141static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x);
142/*! @abstract Do not call this function; instead use `asin` in C and
143 * Objective-C, and `simd::asin` in C++. */
144static inline SIMD_CFUNC simd_double3 __tg_asin(simd_double3 x);
145/*! @abstract Do not call this function; instead use `asin` in C and
146 * Objective-C, and `simd::asin` in C++. */
147static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x);
148/*! @abstract Do not call this function; instead use `asin` in C and
149 * Objective-C, and `simd::asin` in C++. */
150static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x);
151
152/*! @abstract Do not call this function; instead use `atan` in C and
153 * Objective-C, and `simd::atan` in C++. */
154static inline SIMD_CFUNC simd_float2 __tg_atan(simd_float2 x);
155/*! @abstract Do not call this function; instead use `atan` in C and
156 * Objective-C, and `simd::atan` in C++. */
157static inline SIMD_CFUNC simd_float3 __tg_atan(simd_float3 x);
158/*! @abstract Do not call this function; instead use `atan` in C and
159 * Objective-C, and `simd::atan` in C++. */
160static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x);
161/*! @abstract Do not call this function; instead use `atan` in C and
162 * Objective-C, and `simd::atan` in C++. */
163static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x);
164/*! @abstract Do not call this function; instead use `atan` in C and
165 * Objective-C, and `simd::atan` in C++. */
166static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x);
167/*! @abstract Do not call this function; instead use `atan` in C and
168 * Objective-C, and `simd::atan` in C++. */
169static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x);
170/*! @abstract Do not call this function; instead use `atan` in C and
171 * Objective-C, and `simd::atan` in C++. */
172static inline SIMD_CFUNC simd_double3 __tg_atan(simd_double3 x);
173/*! @abstract Do not call this function; instead use `atan` in C and
174 * Objective-C, and `simd::atan` in C++. */
175static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x);
176/*! @abstract Do not call this function; instead use `atan` in C and
177 * Objective-C, and `simd::atan` in C++. */
178static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x);
179
180/*! @abstract Do not call this function; instead use `cos` in C and
181 * Objective-C, and `simd::cos` in C++. */
182static inline SIMD_CFUNC simd_float2 __tg_cos(simd_float2 x);
183/*! @abstract Do not call this function; instead use `cos` in C and
184 * Objective-C, and `simd::cos` in C++. */
185static inline SIMD_CFUNC simd_float3 __tg_cos(simd_float3 x);
186/*! @abstract Do not call this function; instead use `cos` in C and
187 * Objective-C, and `simd::cos` in C++. */
188static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x);
189/*! @abstract Do not call this function; instead use `cos` in C and
190 * Objective-C, and `simd::cos` in C++. */
191static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x);
192/*! @abstract Do not call this function; instead use `cos` in C and
193 * Objective-C, and `simd::cos` in C++. */
194static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x);
195/*! @abstract Do not call this function; instead use `cos` in C and
196 * Objective-C, and `simd::cos` in C++. */
197static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x);
198/*! @abstract Do not call this function; instead use `cos` in C and
199 * Objective-C, and `simd::cos` in C++. */
200static inline SIMD_CFUNC simd_double3 __tg_cos(simd_double3 x);
201/*! @abstract Do not call this function; instead use `cos` in C and
202 * Objective-C, and `simd::cos` in C++. */
203static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x);
204/*! @abstract Do not call this function; instead use `cos` in C and
205 * Objective-C, and `simd::cos` in C++. */
206static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x);
207
208/*! @abstract Do not call this function; instead use `sin` in C and
209 * Objective-C, and `simd::sin` in C++. */
210static inline SIMD_CFUNC simd_float2 __tg_sin(simd_float2 x);
211/*! @abstract Do not call this function; instead use `sin` in C and
212 * Objective-C, and `simd::sin` in C++. */
213static inline SIMD_CFUNC simd_float3 __tg_sin(simd_float3 x);
214/*! @abstract Do not call this function; instead use `sin` in C and
215 * Objective-C, and `simd::sin` in C++. */
216static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x);
217/*! @abstract Do not call this function; instead use `sin` in C and
218 * Objective-C, and `simd::sin` in C++. */
219static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x);
220/*! @abstract Do not call this function; instead use `sin` in C and
221 * Objective-C, and `simd::sin` in C++. */
222static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x);
223/*! @abstract Do not call this function; instead use `sin` in C and
224 * Objective-C, and `simd::sin` in C++. */
225static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x);
226/*! @abstract Do not call this function; instead use `sin` in C and
227 * Objective-C, and `simd::sin` in C++. */
228static inline SIMD_CFUNC simd_double3 __tg_sin(simd_double3 x);
229/*! @abstract Do not call this function; instead use `sin` in C and
230 * Objective-C, and `simd::sin` in C++. */
231static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x);
232/*! @abstract Do not call this function; instead use `sin` in C and
233 * Objective-C, and `simd::sin` in C++. */
234static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x);
235
236/*! @abstract Do not call this function; instead use `tan` in C and
237 * Objective-C, and `simd::tan` in C++. */
238static inline SIMD_CFUNC simd_float2 __tg_tan(simd_float2 x);
239/*! @abstract Do not call this function; instead use `tan` in C and
240 * Objective-C, and `simd::tan` in C++. */
241static inline SIMD_CFUNC simd_float3 __tg_tan(simd_float3 x);
242/*! @abstract Do not call this function; instead use `tan` in C and
243 * Objective-C, and `simd::tan` in C++. */
244static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x);
245/*! @abstract Do not call this function; instead use `tan` in C and
246 * Objective-C, and `simd::tan` in C++. */
247static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x);
248/*! @abstract Do not call this function; instead use `tan` in C and
249 * Objective-C, and `simd::tan` in C++. */
250static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x);
251/*! @abstract Do not call this function; instead use `tan` in C and
252 * Objective-C, and `simd::tan` in C++. */
253static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x);
254/*! @abstract Do not call this function; instead use `tan` in C and
255 * Objective-C, and `simd::tan` in C++. */
256static inline SIMD_CFUNC simd_double3 __tg_tan(simd_double3 x);
257/*! @abstract Do not call this function; instead use `tan` in C and
258 * Objective-C, and `simd::tan` in C++. */
259static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x);
260/*! @abstract Do not call this function; instead use `tan` in C and
261 * Objective-C, and `simd::tan` in C++. */
262static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x);
263
264#if SIMD_LIBRARY_VERSION >= 1
265/*! @abstract Do not call this function; instead use `cospi` in C and
266 * Objective-C, and `simd::cospi` in C++. */
267static inline SIMD_CFUNC simd_float2 __tg_cospi(simd_float2 x);
268/*! @abstract Do not call this function; instead use `cospi` in C and
269 * Objective-C, and `simd::cospi` in C++. */
270static inline SIMD_CFUNC simd_float3 __tg_cospi(simd_float3 x);
271/*! @abstract Do not call this function; instead use `cospi` in C and
272 * Objective-C, and `simd::cospi` in C++. */
273static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x);
274/*! @abstract Do not call this function; instead use `cospi` in C and
275 * Objective-C, and `simd::cospi` in C++. */
276static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x);
277/*! @abstract Do not call this function; instead use `cospi` in C and
278 * Objective-C, and `simd::cospi` in C++. */
279static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x);
280/*! @abstract Do not call this function; instead use `cospi` in C and
281 * Objective-C, and `simd::cospi` in C++. */
282static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x);
283/*! @abstract Do not call this function; instead use `cospi` in C and
284 * Objective-C, and `simd::cospi` in C++. */
285static inline SIMD_CFUNC simd_double3 __tg_cospi(simd_double3 x);
286/*! @abstract Do not call this function; instead use `cospi` in C and
287 * Objective-C, and `simd::cospi` in C++. */
288static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x);
289/*! @abstract Do not call this function; instead use `cospi` in C and
290 * Objective-C, and `simd::cospi` in C++. */
291static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x);
292#endif
293
294#if SIMD_LIBRARY_VERSION >= 1
295/*! @abstract Do not call this function; instead use `sinpi` in C and
296 * Objective-C, and `simd::sinpi` in C++. */
297static inline SIMD_CFUNC simd_float2 __tg_sinpi(simd_float2 x);
298/*! @abstract Do not call this function; instead use `sinpi` in C and
299 * Objective-C, and `simd::sinpi` in C++. */
300static inline SIMD_CFUNC simd_float3 __tg_sinpi(simd_float3 x);
301/*! @abstract Do not call this function; instead use `sinpi` in C and
302 * Objective-C, and `simd::sinpi` in C++. */
303static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x);
304/*! @abstract Do not call this function; instead use `sinpi` in C and
305 * Objective-C, and `simd::sinpi` in C++. */
306static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x);
307/*! @abstract Do not call this function; instead use `sinpi` in C and
308 * Objective-C, and `simd::sinpi` in C++. */
309static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x);
310/*! @abstract Do not call this function; instead use `sinpi` in C and
311 * Objective-C, and `simd::sinpi` in C++. */
312static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x);
313/*! @abstract Do not call this function; instead use `sinpi` in C and
314 * Objective-C, and `simd::sinpi` in C++. */
315static inline SIMD_CFUNC simd_double3 __tg_sinpi(simd_double3 x);
316/*! @abstract Do not call this function; instead use `sinpi` in C and
317 * Objective-C, and `simd::sinpi` in C++. */
318static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x);
319/*! @abstract Do not call this function; instead use `sinpi` in C and
320 * Objective-C, and `simd::sinpi` in C++. */
321static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x);
322#endif
323
324#if SIMD_LIBRARY_VERSION >= 1
325/*! @abstract Do not call this function; instead use `tanpi` in C and
326 * Objective-C, and `simd::tanpi` in C++. */
327static inline SIMD_CFUNC simd_float2 __tg_tanpi(simd_float2 x);
328/*! @abstract Do not call this function; instead use `tanpi` in C and
329 * Objective-C, and `simd::tanpi` in C++. */
330static inline SIMD_CFUNC simd_float3 __tg_tanpi(simd_float3 x);
331/*! @abstract Do not call this function; instead use `tanpi` in C and
332 * Objective-C, and `simd::tanpi` in C++. */
333static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x);
334/*! @abstract Do not call this function; instead use `tanpi` in C and
335 * Objective-C, and `simd::tanpi` in C++. */
336static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x);
337/*! @abstract Do not call this function; instead use `tanpi` in C and
338 * Objective-C, and `simd::tanpi` in C++. */
339static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x);
340/*! @abstract Do not call this function; instead use `tanpi` in C and
341 * Objective-C, and `simd::tanpi` in C++. */
342static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x);
343/*! @abstract Do not call this function; instead use `tanpi` in C and
344 * Objective-C, and `simd::tanpi` in C++. */
345static inline SIMD_CFUNC simd_double3 __tg_tanpi(simd_double3 x);
346/*! @abstract Do not call this function; instead use `tanpi` in C and
347 * Objective-C, and `simd::tanpi` in C++. */
348static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x);
349/*! @abstract Do not call this function; instead use `tanpi` in C and
350 * Objective-C, and `simd::tanpi` in C++. */
351static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x);
352#endif
353
354/*! @abstract Do not call this function; instead use `acosh` in C and
355 * Objective-C, and `simd::acosh` in C++. */
356static inline SIMD_CFUNC simd_float2 __tg_acosh(simd_float2 x);
357/*! @abstract Do not call this function; instead use `acosh` in C and
358 * Objective-C, and `simd::acosh` in C++. */
359static inline SIMD_CFUNC simd_float3 __tg_acosh(simd_float3 x);
360/*! @abstract Do not call this function; instead use `acosh` in C and
361 * Objective-C, and `simd::acosh` in C++. */
362static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x);
363/*! @abstract Do not call this function; instead use `acosh` in C and
364 * Objective-C, and `simd::acosh` in C++. */
365static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x);
366/*! @abstract Do not call this function; instead use `acosh` in C and
367 * Objective-C, and `simd::acosh` in C++. */
368static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x);
369/*! @abstract Do not call this function; instead use `acosh` in C and
370 * Objective-C, and `simd::acosh` in C++. */
371static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x);
372/*! @abstract Do not call this function; instead use `acosh` in C and
373 * Objective-C, and `simd::acosh` in C++. */
374static inline SIMD_CFUNC simd_double3 __tg_acosh(simd_double3 x);
375/*! @abstract Do not call this function; instead use `acosh` in C and
376 * Objective-C, and `simd::acosh` in C++. */
377static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x);
378/*! @abstract Do not call this function; instead use `acosh` in C and
379 * Objective-C, and `simd::acosh` in C++. */
380static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x);
381
382/*! @abstract Do not call this function; instead use `asinh` in C and
383 * Objective-C, and `simd::asinh` in C++. */
384static inline SIMD_CFUNC simd_float2 __tg_asinh(simd_float2 x);
385/*! @abstract Do not call this function; instead use `asinh` in C and
386 * Objective-C, and `simd::asinh` in C++. */
387static inline SIMD_CFUNC simd_float3 __tg_asinh(simd_float3 x);
388/*! @abstract Do not call this function; instead use `asinh` in C and
389 * Objective-C, and `simd::asinh` in C++. */
390static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x);
391/*! @abstract Do not call this function; instead use `asinh` in C and
392 * Objective-C, and `simd::asinh` in C++. */
393static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x);
394/*! @abstract Do not call this function; instead use `asinh` in C and
395 * Objective-C, and `simd::asinh` in C++. */
396static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x);
397/*! @abstract Do not call this function; instead use `asinh` in C and
398 * Objective-C, and `simd::asinh` in C++. */
399static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x);
400/*! @abstract Do not call this function; instead use `asinh` in C and
401 * Objective-C, and `simd::asinh` in C++. */
402static inline SIMD_CFUNC simd_double3 __tg_asinh(simd_double3 x);
403/*! @abstract Do not call this function; instead use `asinh` in C and
404 * Objective-C, and `simd::asinh` in C++. */
405static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x);
406/*! @abstract Do not call this function; instead use `asinh` in C and
407 * Objective-C, and `simd::asinh` in C++. */
408static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x);
409
410/*! @abstract Do not call this function; instead use `atanh` in C and
411 * Objective-C, and `simd::atanh` in C++. */
412static inline SIMD_CFUNC simd_float2 __tg_atanh(simd_float2 x);
413/*! @abstract Do not call this function; instead use `atanh` in C and
414 * Objective-C, and `simd::atanh` in C++. */
415static inline SIMD_CFUNC simd_float3 __tg_atanh(simd_float3 x);
416/*! @abstract Do not call this function; instead use `atanh` in C and
417 * Objective-C, and `simd::atanh` in C++. */
418static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x);
419/*! @abstract Do not call this function; instead use `atanh` in C and
420 * Objective-C, and `simd::atanh` in C++. */
421static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x);
422/*! @abstract Do not call this function; instead use `atanh` in C and
423 * Objective-C, and `simd::atanh` in C++. */
424static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x);
425/*! @abstract Do not call this function; instead use `atanh` in C and
426 * Objective-C, and `simd::atanh` in C++. */
427static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x);
428/*! @abstract Do not call this function; instead use `atanh` in C and
429 * Objective-C, and `simd::atanh` in C++. */
430static inline SIMD_CFUNC simd_double3 __tg_atanh(simd_double3 x);
431/*! @abstract Do not call this function; instead use `atanh` in C and
432 * Objective-C, and `simd::atanh` in C++. */
433static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x);
434/*! @abstract Do not call this function; instead use `atanh` in C and
435 * Objective-C, and `simd::atanh` in C++. */
436static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x);
437
438/*! @abstract Do not call this function; instead use `cosh` in C and
439 * Objective-C, and `simd::cosh` in C++. */
440static inline SIMD_CFUNC simd_float2 __tg_cosh(simd_float2 x);
441/*! @abstract Do not call this function; instead use `cosh` in C and
442 * Objective-C, and `simd::cosh` in C++. */
443static inline SIMD_CFUNC simd_float3 __tg_cosh(simd_float3 x);
444/*! @abstract Do not call this function; instead use `cosh` in C and
445 * Objective-C, and `simd::cosh` in C++. */
446static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x);
447/*! @abstract Do not call this function; instead use `cosh` in C and
448 * Objective-C, and `simd::cosh` in C++. */
449static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x);
450/*! @abstract Do not call this function; instead use `cosh` in C and
451 * Objective-C, and `simd::cosh` in C++. */
452static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x);
453/*! @abstract Do not call this function; instead use `cosh` in C and
454 * Objective-C, and `simd::cosh` in C++. */
455static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x);
456/*! @abstract Do not call this function; instead use `cosh` in C and
457 * Objective-C, and `simd::cosh` in C++. */
458static inline SIMD_CFUNC simd_double3 __tg_cosh(simd_double3 x);
459/*! @abstract Do not call this function; instead use `cosh` in C and
460 * Objective-C, and `simd::cosh` in C++. */
461static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x);
462/*! @abstract Do not call this function; instead use `cosh` in C and
463 * Objective-C, and `simd::cosh` in C++. */
464static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x);
465
466/*! @abstract Do not call this function; instead use `sinh` in C and
467 * Objective-C, and `simd::sinh` in C++. */
468static inline SIMD_CFUNC simd_float2 __tg_sinh(simd_float2 x);
469/*! @abstract Do not call this function; instead use `sinh` in C and
470 * Objective-C, and `simd::sinh` in C++. */
471static inline SIMD_CFUNC simd_float3 __tg_sinh(simd_float3 x);
472/*! @abstract Do not call this function; instead use `sinh` in C and
473 * Objective-C, and `simd::sinh` in C++. */
474static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x);
475/*! @abstract Do not call this function; instead use `sinh` in C and
476 * Objective-C, and `simd::sinh` in C++. */
477static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x);
478/*! @abstract Do not call this function; instead use `sinh` in C and
479 * Objective-C, and `simd::sinh` in C++. */
480static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x);
481/*! @abstract Do not call this function; instead use `sinh` in C and
482 * Objective-C, and `simd::sinh` in C++. */
483static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x);
484/*! @abstract Do not call this function; instead use `sinh` in C and
485 * Objective-C, and `simd::sinh` in C++. */
486static inline SIMD_CFUNC simd_double3 __tg_sinh(simd_double3 x);
487/*! @abstract Do not call this function; instead use `sinh` in C and
488 * Objective-C, and `simd::sinh` in C++. */
489static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x);
490/*! @abstract Do not call this function; instead use `sinh` in C and
491 * Objective-C, and `simd::sinh` in C++. */
492static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x);
493
494/*! @abstract Do not call this function; instead use `tanh` in C and
495 * Objective-C, and `simd::tanh` in C++. */
496static inline SIMD_CFUNC simd_float2 __tg_tanh(simd_float2 x);
497/*! @abstract Do not call this function; instead use `tanh` in C and
498 * Objective-C, and `simd::tanh` in C++. */
499static inline SIMD_CFUNC simd_float3 __tg_tanh(simd_float3 x);
500/*! @abstract Do not call this function; instead use `tanh` in C and
501 * Objective-C, and `simd::tanh` in C++. */
502static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x);
503/*! @abstract Do not call this function; instead use `tanh` in C and
504 * Objective-C, and `simd::tanh` in C++. */
505static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x);
506/*! @abstract Do not call this function; instead use `tanh` in C and
507 * Objective-C, and `simd::tanh` in C++. */
508static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x);
509/*! @abstract Do not call this function; instead use `tanh` in C and
510 * Objective-C, and `simd::tanh` in C++. */
511static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x);
512/*! @abstract Do not call this function; instead use `tanh` in C and
513 * Objective-C, and `simd::tanh` in C++. */
514static inline SIMD_CFUNC simd_double3 __tg_tanh(simd_double3 x);
515/*! @abstract Do not call this function; instead use `tanh` in C and
516 * Objective-C, and `simd::tanh` in C++. */
517static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x);
518/*! @abstract Do not call this function; instead use `tanh` in C and
519 * Objective-C, and `simd::tanh` in C++. */
520static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x);
521
522/*! @abstract Do not call this function; instead use `exp` in C and
523 * Objective-C, and `simd::exp` in C++. */
524static inline SIMD_CFUNC simd_float2 __tg_exp(simd_float2 x);
525/*! @abstract Do not call this function; instead use `exp` in C and
526 * Objective-C, and `simd::exp` in C++. */
527static inline SIMD_CFUNC simd_float3 __tg_exp(simd_float3 x);
528/*! @abstract Do not call this function; instead use `exp` in C and
529 * Objective-C, and `simd::exp` in C++. */
530static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x);
531/*! @abstract Do not call this function; instead use `exp` in C and
532 * Objective-C, and `simd::exp` in C++. */
533static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x);
534/*! @abstract Do not call this function; instead use `exp` in C and
535 * Objective-C, and `simd::exp` in C++. */
536static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x);
537/*! @abstract Do not call this function; instead use `exp` in C and
538 * Objective-C, and `simd::exp` in C++. */
539static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x);
540/*! @abstract Do not call this function; instead use `exp` in C and
541 * Objective-C, and `simd::exp` in C++. */
542static inline SIMD_CFUNC simd_double3 __tg_exp(simd_double3 x);
543/*! @abstract Do not call this function; instead use `exp` in C and
544 * Objective-C, and `simd::exp` in C++. */
545static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x);
546/*! @abstract Do not call this function; instead use `exp` in C and
547 * Objective-C, and `simd::exp` in C++. */
548static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x);
549
550/*! @abstract Do not call this function; instead use `exp2` in C and
551 * Objective-C, and `simd::exp2` in C++. */
552static inline SIMD_CFUNC simd_float2 __tg_exp2(simd_float2 x);
553/*! @abstract Do not call this function; instead use `exp2` in C and
554 * Objective-C, and `simd::exp2` in C++. */
555static inline SIMD_CFUNC simd_float3 __tg_exp2(simd_float3 x);
556/*! @abstract Do not call this function; instead use `exp2` in C and
557 * Objective-C, and `simd::exp2` in C++. */
558static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x);
559/*! @abstract Do not call this function; instead use `exp2` in C and
560 * Objective-C, and `simd::exp2` in C++. */
561static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x);
562/*! @abstract Do not call this function; instead use `exp2` in C and
563 * Objective-C, and `simd::exp2` in C++. */
564static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x);
565/*! @abstract Do not call this function; instead use `exp2` in C and
566 * Objective-C, and `simd::exp2` in C++. */
567static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x);
568/*! @abstract Do not call this function; instead use `exp2` in C and
569 * Objective-C, and `simd::exp2` in C++. */
570static inline SIMD_CFUNC simd_double3 __tg_exp2(simd_double3 x);
571/*! @abstract Do not call this function; instead use `exp2` in C and
572 * Objective-C, and `simd::exp2` in C++. */
573static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x);
574/*! @abstract Do not call this function; instead use `exp2` in C and
575 * Objective-C, and `simd::exp2` in C++. */
576static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x);
577
578#if SIMD_LIBRARY_VERSION >= 1
579/*! @abstract Do not call this function; instead use `exp10` in C and
580 * Objective-C, and `simd::exp10` in C++. */
581static inline SIMD_CFUNC simd_float2 __tg_exp10(simd_float2 x);
582/*! @abstract Do not call this function; instead use `exp10` in C and
583 * Objective-C, and `simd::exp10` in C++. */
584static inline SIMD_CFUNC simd_float3 __tg_exp10(simd_float3 x);
585/*! @abstract Do not call this function; instead use `exp10` in C and
586 * Objective-C, and `simd::exp10` in C++. */
587static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x);
588/*! @abstract Do not call this function; instead use `exp10` in C and
589 * Objective-C, and `simd::exp10` in C++. */
590static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x);
591/*! @abstract Do not call this function; instead use `exp10` in C and
592 * Objective-C, and `simd::exp10` in C++. */
593static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x);
594/*! @abstract Do not call this function; instead use `exp10` in C and
595 * Objective-C, and `simd::exp10` in C++. */
596static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x);
597/*! @abstract Do not call this function; instead use `exp10` in C and
598 * Objective-C, and `simd::exp10` in C++. */
599static inline SIMD_CFUNC simd_double3 __tg_exp10(simd_double3 x);
600/*! @abstract Do not call this function; instead use `exp10` in C and
601 * Objective-C, and `simd::exp10` in C++. */
602static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x);
603/*! @abstract Do not call this function; instead use `exp10` in C and
604 * Objective-C, and `simd::exp10` in C++. */
605static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x);
606#endif
607
608/*! @abstract Do not call this function; instead use `expm1` in C and
609 * Objective-C, and `simd::expm1` in C++. */
610static inline SIMD_CFUNC simd_float2 __tg_expm1(simd_float2 x);
611/*! @abstract Do not call this function; instead use `expm1` in C and
612 * Objective-C, and `simd::expm1` in C++. */
613static inline SIMD_CFUNC simd_float3 __tg_expm1(simd_float3 x);
614/*! @abstract Do not call this function; instead use `expm1` in C and
615 * Objective-C, and `simd::expm1` in C++. */
616static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x);
617/*! @abstract Do not call this function; instead use `expm1` in C and
618 * Objective-C, and `simd::expm1` in C++. */
619static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x);
620/*! @abstract Do not call this function; instead use `expm1` in C and
621 * Objective-C, and `simd::expm1` in C++. */
622static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x);
623/*! @abstract Do not call this function; instead use `expm1` in C and
624 * Objective-C, and `simd::expm1` in C++. */
625static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x);
626/*! @abstract Do not call this function; instead use `expm1` in C and
627 * Objective-C, and `simd::expm1` in C++. */
628static inline SIMD_CFUNC simd_double3 __tg_expm1(simd_double3 x);
629/*! @abstract Do not call this function; instead use `expm1` in C and
630 * Objective-C, and `simd::expm1` in C++. */
631static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x);
632/*! @abstract Do not call this function; instead use `expm1` in C and
633 * Objective-C, and `simd::expm1` in C++. */
634static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x);
635
636/*! @abstract Do not call this function; instead use `log` in C and
637 * Objective-C, and `simd::log` in C++. */
638static inline SIMD_CFUNC simd_float2 __tg_log(simd_float2 x);
639/*! @abstract Do not call this function; instead use `log` in C and
640 * Objective-C, and `simd::log` in C++. */
641static inline SIMD_CFUNC simd_float3 __tg_log(simd_float3 x);
642/*! @abstract Do not call this function; instead use `log` in C and
643 * Objective-C, and `simd::log` in C++. */
644static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x);
645/*! @abstract Do not call this function; instead use `log` in C and
646 * Objective-C, and `simd::log` in C++. */
647static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x);
648/*! @abstract Do not call this function; instead use `log` in C and
649 * Objective-C, and `simd::log` in C++. */
650static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x);
651/*! @abstract Do not call this function; instead use `log` in C and
652 * Objective-C, and `simd::log` in C++. */
653static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x);
654/*! @abstract Do not call this function; instead use `log` in C and
655 * Objective-C, and `simd::log` in C++. */
656static inline SIMD_CFUNC simd_double3 __tg_log(simd_double3 x);
657/*! @abstract Do not call this function; instead use `log` in C and
658 * Objective-C, and `simd::log` in C++. */
659static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x);
660/*! @abstract Do not call this function; instead use `log` in C and
661 * Objective-C, and `simd::log` in C++. */
662static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x);
663
664/*! @abstract Do not call this function; instead use `log2` in C and
665 * Objective-C, and `simd::log2` in C++. */
666static inline SIMD_CFUNC simd_float2 __tg_log2(simd_float2 x);
667/*! @abstract Do not call this function; instead use `log2` in C and
668 * Objective-C, and `simd::log2` in C++. */
669static inline SIMD_CFUNC simd_float3 __tg_log2(simd_float3 x);
670/*! @abstract Do not call this function; instead use `log2` in C and
671 * Objective-C, and `simd::log2` in C++. */
672static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x);
673/*! @abstract Do not call this function; instead use `log2` in C and
674 * Objective-C, and `simd::log2` in C++. */
675static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x);
676/*! @abstract Do not call this function; instead use `log2` in C and
677 * Objective-C, and `simd::log2` in C++. */
678static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x);
679/*! @abstract Do not call this function; instead use `log2` in C and
680 * Objective-C, and `simd::log2` in C++. */
681static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x);
682/*! @abstract Do not call this function; instead use `log2` in C and
683 * Objective-C, and `simd::log2` in C++. */
684static inline SIMD_CFUNC simd_double3 __tg_log2(simd_double3 x);
685/*! @abstract Do not call this function; instead use `log2` in C and
686 * Objective-C, and `simd::log2` in C++. */
687static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x);
688/*! @abstract Do not call this function; instead use `log2` in C and
689 * Objective-C, and `simd::log2` in C++. */
690static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x);
691
692/*! @abstract Do not call this function; instead use `log10` in C and
693 * Objective-C, and `simd::log10` in C++. */
694static inline SIMD_CFUNC simd_float2 __tg_log10(simd_float2 x);
695/*! @abstract Do not call this function; instead use `log10` in C and
696 * Objective-C, and `simd::log10` in C++. */
697static inline SIMD_CFUNC simd_float3 __tg_log10(simd_float3 x);
698/*! @abstract Do not call this function; instead use `log10` in C and
699 * Objective-C, and `simd::log10` in C++. */
700static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x);
701/*! @abstract Do not call this function; instead use `log10` in C and
702 * Objective-C, and `simd::log10` in C++. */
703static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x);
704/*! @abstract Do not call this function; instead use `log10` in C and
705 * Objective-C, and `simd::log10` in C++. */
706static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x);
707/*! @abstract Do not call this function; instead use `log10` in C and
708 * Objective-C, and `simd::log10` in C++. */
709static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x);
710/*! @abstract Do not call this function; instead use `log10` in C and
711 * Objective-C, and `simd::log10` in C++. */
712static inline SIMD_CFUNC simd_double3 __tg_log10(simd_double3 x);
713/*! @abstract Do not call this function; instead use `log10` in C and
714 * Objective-C, and `simd::log10` in C++. */
715static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x);
716/*! @abstract Do not call this function; instead use `log10` in C and
717 * Objective-C, and `simd::log10` in C++. */
718static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x);
719
720/*! @abstract Do not call this function; instead use `log1p` in C and
721 * Objective-C, and `simd::log1p` in C++. */
722static inline SIMD_CFUNC simd_float2 __tg_log1p(simd_float2 x);
723/*! @abstract Do not call this function; instead use `log1p` in C and
724 * Objective-C, and `simd::log1p` in C++. */
725static inline SIMD_CFUNC simd_float3 __tg_log1p(simd_float3 x);
726/*! @abstract Do not call this function; instead use `log1p` in C and
727 * Objective-C, and `simd::log1p` in C++. */
728static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x);
729/*! @abstract Do not call this function; instead use `log1p` in C and
730 * Objective-C, and `simd::log1p` in C++. */
731static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x);
732/*! @abstract Do not call this function; instead use `log1p` in C and
733 * Objective-C, and `simd::log1p` in C++. */
734static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x);
735/*! @abstract Do not call this function; instead use `log1p` in C and
736 * Objective-C, and `simd::log1p` in C++. */
737static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x);
738/*! @abstract Do not call this function; instead use `log1p` in C and
739 * Objective-C, and `simd::log1p` in C++. */
740static inline SIMD_CFUNC simd_double3 __tg_log1p(simd_double3 x);
741/*! @abstract Do not call this function; instead use `log1p` in C and
742 * Objective-C, and `simd::log1p` in C++. */
743static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x);
744/*! @abstract Do not call this function; instead use `log1p` in C and
745 * Objective-C, and `simd::log1p` in C++. */
746static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x);
747
748/*! @abstract Do not call this function; instead use `fabs` in C and
749 * Objective-C, and `simd::fabs` in C++. */
750static inline SIMD_CFUNC simd_float2 __tg_fabs(simd_float2 x);
751/*! @abstract Do not call this function; instead use `fabs` in C and
752 * Objective-C, and `simd::fabs` in C++. */
753static inline SIMD_CFUNC simd_float3 __tg_fabs(simd_float3 x);
754/*! @abstract Do not call this function; instead use `fabs` in C and
755 * Objective-C, and `simd::fabs` in C++. */
756static inline SIMD_CFUNC simd_float4 __tg_fabs(simd_float4 x);
757/*! @abstract Do not call this function; instead use `fabs` in C and
758 * Objective-C, and `simd::fabs` in C++. */
759static inline SIMD_CFUNC simd_float8 __tg_fabs(simd_float8 x);
760/*! @abstract Do not call this function; instead use `fabs` in C and
761 * Objective-C, and `simd::fabs` in C++. */
762static inline SIMD_CFUNC simd_float16 __tg_fabs(simd_float16 x);
763/*! @abstract Do not call this function; instead use `fabs` in C and
764 * Objective-C, and `simd::fabs` in C++. */
765static inline SIMD_CFUNC simd_double2 __tg_fabs(simd_double2 x);
766/*! @abstract Do not call this function; instead use `fabs` in C and
767 * Objective-C, and `simd::fabs` in C++. */
768static inline SIMD_CFUNC simd_double3 __tg_fabs(simd_double3 x);
769/*! @abstract Do not call this function; instead use `fabs` in C and
770 * Objective-C, and `simd::fabs` in C++. */
771static inline SIMD_CFUNC simd_double4 __tg_fabs(simd_double4 x);
772/*! @abstract Do not call this function; instead use `fabs` in C and
773 * Objective-C, and `simd::fabs` in C++. */
774static inline SIMD_CFUNC simd_double8 __tg_fabs(simd_double8 x);
775
776/*! @abstract Do not call this function; instead use `cbrt` in C and
777 * Objective-C, and `simd::cbrt` in C++. */
778static inline SIMD_CFUNC simd_float2 __tg_cbrt(simd_float2 x);
779/*! @abstract Do not call this function; instead use `cbrt` in C and
780 * Objective-C, and `simd::cbrt` in C++. */
781static inline SIMD_CFUNC simd_float3 __tg_cbrt(simd_float3 x);
782/*! @abstract Do not call this function; instead use `cbrt` in C and
783 * Objective-C, and `simd::cbrt` in C++. */
784static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x);
785/*! @abstract Do not call this function; instead use `cbrt` in C and
786 * Objective-C, and `simd::cbrt` in C++. */
787static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x);
788/*! @abstract Do not call this function; instead use `cbrt` in C and
789 * Objective-C, and `simd::cbrt` in C++. */
790static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x);
791/*! @abstract Do not call this function; instead use `cbrt` in C and
792 * Objective-C, and `simd::cbrt` in C++. */
793static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x);
794/*! @abstract Do not call this function; instead use `cbrt` in C and
795 * Objective-C, and `simd::cbrt` in C++. */
796static inline SIMD_CFUNC simd_double3 __tg_cbrt(simd_double3 x);
797/*! @abstract Do not call this function; instead use `cbrt` in C and
798 * Objective-C, and `simd::cbrt` in C++. */
799static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x);
800/*! @abstract Do not call this function; instead use `cbrt` in C and
801 * Objective-C, and `simd::cbrt` in C++. */
802static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x);
803
804/*! @abstract Do not call this function; instead use `sqrt` in C and
805 * Objective-C, and `simd::sqrt` in C++. */
806static inline SIMD_CFUNC simd_float2 __tg_sqrt(simd_float2 x);
807/*! @abstract Do not call this function; instead use `sqrt` in C and
808 * Objective-C, and `simd::sqrt` in C++. */
809static inline SIMD_CFUNC simd_float3 __tg_sqrt(simd_float3 x);
810/*! @abstract Do not call this function; instead use `sqrt` in C and
811 * Objective-C, and `simd::sqrt` in C++. */
812static inline SIMD_CFUNC simd_float4 __tg_sqrt(simd_float4 x);
813/*! @abstract Do not call this function; instead use `sqrt` in C and
814 * Objective-C, and `simd::sqrt` in C++. */
815static inline SIMD_CFUNC simd_float8 __tg_sqrt(simd_float8 x);
816/*! @abstract Do not call this function; instead use `sqrt` in C and
817 * Objective-C, and `simd::sqrt` in C++. */
818static inline SIMD_CFUNC simd_float16 __tg_sqrt(simd_float16 x);
819/*! @abstract Do not call this function; instead use `sqrt` in C and
820 * Objective-C, and `simd::sqrt` in C++. */
821static inline SIMD_CFUNC simd_double2 __tg_sqrt(simd_double2 x);
822/*! @abstract Do not call this function; instead use `sqrt` in C and
823 * Objective-C, and `simd::sqrt` in C++. */
824static inline SIMD_CFUNC simd_double3 __tg_sqrt(simd_double3 x);
825/*! @abstract Do not call this function; instead use `sqrt` in C and
826 * Objective-C, and `simd::sqrt` in C++. */
827static inline SIMD_CFUNC simd_double4 __tg_sqrt(simd_double4 x);
828/*! @abstract Do not call this function; instead use `sqrt` in C and
829 * Objective-C, and `simd::sqrt` in C++. */
830static inline SIMD_CFUNC simd_double8 __tg_sqrt(simd_double8 x);
831
832/*! @abstract Do not call this function; instead use `erf` in C and
833 * Objective-C, and `simd::erf` in C++. */
834static inline SIMD_CFUNC simd_float2 __tg_erf(simd_float2 x);
835/*! @abstract Do not call this function; instead use `erf` in C and
836 * Objective-C, and `simd::erf` in C++. */
837static inline SIMD_CFUNC simd_float3 __tg_erf(simd_float3 x);
838/*! @abstract Do not call this function; instead use `erf` in C and
839 * Objective-C, and `simd::erf` in C++. */
840static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x);
841/*! @abstract Do not call this function; instead use `erf` in C and
842 * Objective-C, and `simd::erf` in C++. */
843static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x);
844/*! @abstract Do not call this function; instead use `erf` in C and
845 * Objective-C, and `simd::erf` in C++. */
846static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x);
847/*! @abstract Do not call this function; instead use `erf` in C and
848 * Objective-C, and `simd::erf` in C++. */
849static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x);
850/*! @abstract Do not call this function; instead use `erf` in C and
851 * Objective-C, and `simd::erf` in C++. */
852static inline SIMD_CFUNC simd_double3 __tg_erf(simd_double3 x);
853/*! @abstract Do not call this function; instead use `erf` in C and
854 * Objective-C, and `simd::erf` in C++. */
855static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x);
856/*! @abstract Do not call this function; instead use `erf` in C and
857 * Objective-C, and `simd::erf` in C++. */
858static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x);
859
860/*! @abstract Do not call this function; instead use `erfc` in C and
861 * Objective-C, and `simd::erfc` in C++. */
862static inline SIMD_CFUNC simd_float2 __tg_erfc(simd_float2 x);
863/*! @abstract Do not call this function; instead use `erfc` in C and
864 * Objective-C, and `simd::erfc` in C++. */
865static inline SIMD_CFUNC simd_float3 __tg_erfc(simd_float3 x);
866/*! @abstract Do not call this function; instead use `erfc` in C and
867 * Objective-C, and `simd::erfc` in C++. */
868static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x);
869/*! @abstract Do not call this function; instead use `erfc` in C and
870 * Objective-C, and `simd::erfc` in C++. */
871static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x);
872/*! @abstract Do not call this function; instead use `erfc` in C and
873 * Objective-C, and `simd::erfc` in C++. */
874static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x);
875/*! @abstract Do not call this function; instead use `erfc` in C and
876 * Objective-C, and `simd::erfc` in C++. */
877static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x);
878/*! @abstract Do not call this function; instead use `erfc` in C and
879 * Objective-C, and `simd::erfc` in C++. */
880static inline SIMD_CFUNC simd_double3 __tg_erfc(simd_double3 x);
881/*! @abstract Do not call this function; instead use `erfc` in C and
882 * Objective-C, and `simd::erfc` in C++. */
883static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x);
884/*! @abstract Do not call this function; instead use `erfc` in C and
885 * Objective-C, and `simd::erfc` in C++. */
886static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x);
887
888/*! @abstract Do not call this function; instead use `tgamma` in C and
889 * Objective-C, and `simd::tgamma` in C++. */
890static inline SIMD_CFUNC simd_float2 __tg_tgamma(simd_float2 x);
891/*! @abstract Do not call this function; instead use `tgamma` in C and
892 * Objective-C, and `simd::tgamma` in C++. */
893static inline SIMD_CFUNC simd_float3 __tg_tgamma(simd_float3 x);
894/*! @abstract Do not call this function; instead use `tgamma` in C and
895 * Objective-C, and `simd::tgamma` in C++. */
896static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x);
897/*! @abstract Do not call this function; instead use `tgamma` in C and
898 * Objective-C, and `simd::tgamma` in C++. */
899static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x);
900/*! @abstract Do not call this function; instead use `tgamma` in C and
901 * Objective-C, and `simd::tgamma` in C++. */
902static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x);
903/*! @abstract Do not call this function; instead use `tgamma` in C and
904 * Objective-C, and `simd::tgamma` in C++. */
905static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x);
906/*! @abstract Do not call this function; instead use `tgamma` in C and
907 * Objective-C, and `simd::tgamma` in C++. */
908static inline SIMD_CFUNC simd_double3 __tg_tgamma(simd_double3 x);
909/*! @abstract Do not call this function; instead use `tgamma` in C and
910 * Objective-C, and `simd::tgamma` in C++. */
911static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x);
912/*! @abstract Do not call this function; instead use `tgamma` in C and
913 * Objective-C, and `simd::tgamma` in C++. */
914static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x);
915
916/*! @abstract Do not call this function; instead use `ceil` in C and
917 * Objective-C, and `simd::ceil` in C++. */
918static inline SIMD_CFUNC simd_float2 __tg_ceil(simd_float2 x);
919/*! @abstract Do not call this function; instead use `ceil` in C and
920 * Objective-C, and `simd::ceil` in C++. */
921static inline SIMD_CFUNC simd_float3 __tg_ceil(simd_float3 x);
922/*! @abstract Do not call this function; instead use `ceil` in C and
923 * Objective-C, and `simd::ceil` in C++. */
924static inline SIMD_CFUNC simd_float4 __tg_ceil(simd_float4 x);
925/*! @abstract Do not call this function; instead use `ceil` in C and
926 * Objective-C, and `simd::ceil` in C++. */
927static inline SIMD_CFUNC simd_float8 __tg_ceil(simd_float8 x);
928/*! @abstract Do not call this function; instead use `ceil` in C and
929 * Objective-C, and `simd::ceil` in C++. */
930static inline SIMD_CFUNC simd_float16 __tg_ceil(simd_float16 x);
931/*! @abstract Do not call this function; instead use `ceil` in C and
932 * Objective-C, and `simd::ceil` in C++. */
933static inline SIMD_CFUNC simd_double2 __tg_ceil(simd_double2 x);
934/*! @abstract Do not call this function; instead use `ceil` in C and
935 * Objective-C, and `simd::ceil` in C++. */
936static inline SIMD_CFUNC simd_double3 __tg_ceil(simd_double3 x);
937/*! @abstract Do not call this function; instead use `ceil` in C and
938 * Objective-C, and `simd::ceil` in C++. */
939static inline SIMD_CFUNC simd_double4 __tg_ceil(simd_double4 x);
940/*! @abstract Do not call this function; instead use `ceil` in C and
941 * Objective-C, and `simd::ceil` in C++. */
942static inline SIMD_CFUNC simd_double8 __tg_ceil(simd_double8 x);
943
944/*! @abstract Do not call this function; instead use `floor` in C and
945 * Objective-C, and `simd::floor` in C++. */
946static inline SIMD_CFUNC simd_float2 __tg_floor(simd_float2 x);
947/*! @abstract Do not call this function; instead use `floor` in C and
948 * Objective-C, and `simd::floor` in C++. */
949static inline SIMD_CFUNC simd_float3 __tg_floor(simd_float3 x);
950/*! @abstract Do not call this function; instead use `floor` in C and
951 * Objective-C, and `simd::floor` in C++. */
952static inline SIMD_CFUNC simd_float4 __tg_floor(simd_float4 x);
953/*! @abstract Do not call this function; instead use `floor` in C and
954 * Objective-C, and `simd::floor` in C++. */
955static inline SIMD_CFUNC simd_float8 __tg_floor(simd_float8 x);
956/*! @abstract Do not call this function; instead use `floor` in C and
957 * Objective-C, and `simd::floor` in C++. */
958static inline SIMD_CFUNC simd_float16 __tg_floor(simd_float16 x);
959/*! @abstract Do not call this function; instead use `floor` in C and
960 * Objective-C, and `simd::floor` in C++. */
961static inline SIMD_CFUNC simd_double2 __tg_floor(simd_double2 x);
962/*! @abstract Do not call this function; instead use `floor` in C and
963 * Objective-C, and `simd::floor` in C++. */
964static inline SIMD_CFUNC simd_double3 __tg_floor(simd_double3 x);
965/*! @abstract Do not call this function; instead use `floor` in C and
966 * Objective-C, and `simd::floor` in C++. */
967static inline SIMD_CFUNC simd_double4 __tg_floor(simd_double4 x);
968/*! @abstract Do not call this function; instead use `floor` in C and
969 * Objective-C, and `simd::floor` in C++. */
970static inline SIMD_CFUNC simd_double8 __tg_floor(simd_double8 x);
971
972/*! @abstract Do not call this function; instead use `rint` in C and
973 * Objective-C, and `simd::rint` in C++. */
974static inline SIMD_CFUNC simd_float2 __tg_rint(simd_float2 x);
975/*! @abstract Do not call this function; instead use `rint` in C and
976 * Objective-C, and `simd::rint` in C++. */
977static inline SIMD_CFUNC simd_float3 __tg_rint(simd_float3 x);
978/*! @abstract Do not call this function; instead use `rint` in C and
979 * Objective-C, and `simd::rint` in C++. */
980static inline SIMD_CFUNC simd_float4 __tg_rint(simd_float4 x);
981/*! @abstract Do not call this function; instead use `rint` in C and
982 * Objective-C, and `simd::rint` in C++. */
983static inline SIMD_CFUNC simd_float8 __tg_rint(simd_float8 x);
984/*! @abstract Do not call this function; instead use `rint` in C and
985 * Objective-C, and `simd::rint` in C++. */
986static inline SIMD_CFUNC simd_float16 __tg_rint(simd_float16 x);
987/*! @abstract Do not call this function; instead use `rint` in C and
988 * Objective-C, and `simd::rint` in C++. */
989static inline SIMD_CFUNC simd_double2 __tg_rint(simd_double2 x);
990/*! @abstract Do not call this function; instead use `rint` in C and
991 * Objective-C, and `simd::rint` in C++. */
992static inline SIMD_CFUNC simd_double3 __tg_rint(simd_double3 x);
993/*! @abstract Do not call this function; instead use `rint` in C and
994 * Objective-C, and `simd::rint` in C++. */
995static inline SIMD_CFUNC simd_double4 __tg_rint(simd_double4 x);
996/*! @abstract Do not call this function; instead use `rint` in C and
997 * Objective-C, and `simd::rint` in C++. */
998static inline SIMD_CFUNC simd_double8 __tg_rint(simd_double8 x);
999
1000/*! @abstract Do not call this function; instead use `round` in C and
1001 * Objective-C, and `simd::round` in C++. */
1002static inline SIMD_CFUNC simd_float2 __tg_round(simd_float2 x);
1003/*! @abstract Do not call this function; instead use `round` in C and
1004 * Objective-C, and `simd::round` in C++. */
1005static inline SIMD_CFUNC simd_float3 __tg_round(simd_float3 x);
1006/*! @abstract Do not call this function; instead use `round` in C and
1007 * Objective-C, and `simd::round` in C++. */
1008static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x);
1009/*! @abstract Do not call this function; instead use `round` in C and
1010 * Objective-C, and `simd::round` in C++. */
1011static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x);
1012/*! @abstract Do not call this function; instead use `round` in C and
1013 * Objective-C, and `simd::round` in C++. */
1014static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x);
1015/*! @abstract Do not call this function; instead use `round` in C and
1016 * Objective-C, and `simd::round` in C++. */
1017static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x);
1018/*! @abstract Do not call this function; instead use `round` in C and
1019 * Objective-C, and `simd::round` in C++. */
1020static inline SIMD_CFUNC simd_double3 __tg_round(simd_double3 x);
1021/*! @abstract Do not call this function; instead use `round` in C and
1022 * Objective-C, and `simd::round` in C++. */
1023static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x);
1024/*! @abstract Do not call this function; instead use `round` in C and
1025 * Objective-C, and `simd::round` in C++. */
1026static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x);
1027
1028/*! @abstract Do not call this function; instead use `trunc` in C and
1029 * Objective-C, and `simd::trunc` in C++. */
1030static inline SIMD_CFUNC simd_float2 __tg_trunc(simd_float2 x);
1031/*! @abstract Do not call this function; instead use `trunc` in C and
1032 * Objective-C, and `simd::trunc` in C++. */
1033static inline SIMD_CFUNC simd_float3 __tg_trunc(simd_float3 x);
1034/*! @abstract Do not call this function; instead use `trunc` in C and
1035 * Objective-C, and `simd::trunc` in C++. */
1036static inline SIMD_CFUNC simd_float4 __tg_trunc(simd_float4 x);
1037/*! @abstract Do not call this function; instead use `trunc` in C and
1038 * Objective-C, and `simd::trunc` in C++. */
1039static inline SIMD_CFUNC simd_float8 __tg_trunc(simd_float8 x);
1040/*! @abstract Do not call this function; instead use `trunc` in C and
1041 * Objective-C, and `simd::trunc` in C++. */
1042static inline SIMD_CFUNC simd_float16 __tg_trunc(simd_float16 x);
1043/*! @abstract Do not call this function; instead use `trunc` in C and
1044 * Objective-C, and `simd::trunc` in C++. */
1045static inline SIMD_CFUNC simd_double2 __tg_trunc(simd_double2 x);
1046/*! @abstract Do not call this function; instead use `trunc` in C and
1047 * Objective-C, and `simd::trunc` in C++. */
1048static inline SIMD_CFUNC simd_double3 __tg_trunc(simd_double3 x);
1049/*! @abstract Do not call this function; instead use `trunc` in C and
1050 * Objective-C, and `simd::trunc` in C++. */
1051static inline SIMD_CFUNC simd_double4 __tg_trunc(simd_double4 x);
1052/*! @abstract Do not call this function; instead use `trunc` in C and
1053 * Objective-C, and `simd::trunc` in C++. */
1054static inline SIMD_CFUNC simd_double8 __tg_trunc(simd_double8 x);
1055
1056
1057/*! @abstract Do not call this function; instead use `atan2` in C and
1058 * Objective-C, and `simd::atan2` in C++. */
1059static inline SIMD_CFUNC simd_float2 __tg_atan2(simd_float2 y, simd_float2 x);
1060/*! @abstract Do not call this function; instead use `atan2` in C and
1061 * Objective-C, and `simd::atan2` in C++. */
1062static inline SIMD_CFUNC simd_float3 __tg_atan2(simd_float3 y, simd_float3 x);
1063/*! @abstract Do not call this function; instead use `atan2` in C and
1064 * Objective-C, and `simd::atan2` in C++. */
1065static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x);
1066/*! @abstract Do not call this function; instead use `atan2` in C and
1067 * Objective-C, and `simd::atan2` in C++. */
1068static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x);
1069/*! @abstract Do not call this function; instead use `atan2` in C and
1070 * Objective-C, and `simd::atan2` in C++. */
1071static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x);
1072/*! @abstract Do not call this function; instead use `atan2` in C and
1073 * Objective-C, and `simd::atan2` in C++. */
1074static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x);
1075/*! @abstract Do not call this function; instead use `atan2` in C and
1076 * Objective-C, and `simd::atan2` in C++. */
1077static inline SIMD_CFUNC simd_double3 __tg_atan2(simd_double3 y, simd_double3 x);
1078/*! @abstract Do not call this function; instead use `atan2` in C and
1079 * Objective-C, and `simd::atan2` in C++. */
1080static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x);
1081/*! @abstract Do not call this function; instead use `atan2` in C and
1082 * Objective-C, and `simd::atan2` in C++. */
1083static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x);
1084
1085/*! @abstract Do not call this function; instead use `hypot` in C and
1086 * Objective-C, and `simd::hypot` in C++. */
1087static inline SIMD_CFUNC simd_float2 __tg_hypot(simd_float2 x, simd_float2 y);
1088/*! @abstract Do not call this function; instead use `hypot` in C and
1089 * Objective-C, and `simd::hypot` in C++. */
1090static inline SIMD_CFUNC simd_float3 __tg_hypot(simd_float3 x, simd_float3 y);
1091/*! @abstract Do not call this function; instead use `hypot` in C and
1092 * Objective-C, and `simd::hypot` in C++. */
1093static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y);
1094/*! @abstract Do not call this function; instead use `hypot` in C and
1095 * Objective-C, and `simd::hypot` in C++. */
1096static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y);
1097/*! @abstract Do not call this function; instead use `hypot` in C and
1098 * Objective-C, and `simd::hypot` in C++. */
1099static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y);
1100/*! @abstract Do not call this function; instead use `hypot` in C and
1101 * Objective-C, and `simd::hypot` in C++. */
1102static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y);
1103/*! @abstract Do not call this function; instead use `hypot` in C and
1104 * Objective-C, and `simd::hypot` in C++. */
1105static inline SIMD_CFUNC simd_double3 __tg_hypot(simd_double3 x, simd_double3 y);
1106/*! @abstract Do not call this function; instead use `hypot` in C and
1107 * Objective-C, and `simd::hypot` in C++. */
1108static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y);
1109/*! @abstract Do not call this function; instead use `hypot` in C and
1110 * Objective-C, and `simd::hypot` in C++. */
1111static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y);
1112
1113/*! @abstract Do not call this function; instead use `pow` in C and
1114 * Objective-C, and `simd::pow` in C++. */
1115static inline SIMD_CFUNC simd_float2 __tg_pow(simd_float2 x, simd_float2 y);
1116/*! @abstract Do not call this function; instead use `pow` in C and
1117 * Objective-C, and `simd::pow` in C++. */
1118static inline SIMD_CFUNC simd_float3 __tg_pow(simd_float3 x, simd_float3 y);
1119/*! @abstract Do not call this function; instead use `pow` in C and
1120 * Objective-C, and `simd::pow` in C++. */
1121static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y);
1122/*! @abstract Do not call this function; instead use `pow` in C and
1123 * Objective-C, and `simd::pow` in C++. */
1124static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y);
1125/*! @abstract Do not call this function; instead use `pow` in C and
1126 * Objective-C, and `simd::pow` in C++. */
1127static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y);
1128/*! @abstract Do not call this function; instead use `pow` in C and
1129 * Objective-C, and `simd::pow` in C++. */
1130static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y);
1131/*! @abstract Do not call this function; instead use `pow` in C and
1132 * Objective-C, and `simd::pow` in C++. */
1133static inline SIMD_CFUNC simd_double3 __tg_pow(simd_double3 x, simd_double3 y);
1134/*! @abstract Do not call this function; instead use `pow` in C and
1135 * Objective-C, and `simd::pow` in C++. */
1136static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y);
1137/*! @abstract Do not call this function; instead use `pow` in C and
1138 * Objective-C, and `simd::pow` in C++. */
1139static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y);
1140
1141/*! @abstract Do not call this function; instead use `fmod` in C and
1142 * Objective-C, and `simd::fmod` in C++. */
1143static inline SIMD_CFUNC simd_float2 __tg_fmod(simd_float2 x, simd_float2 y);
1144/*! @abstract Do not call this function; instead use `fmod` in C and
1145 * Objective-C, and `simd::fmod` in C++. */
1146static inline SIMD_CFUNC simd_float3 __tg_fmod(simd_float3 x, simd_float3 y);
1147/*! @abstract Do not call this function; instead use `fmod` in C and
1148 * Objective-C, and `simd::fmod` in C++. */
1149static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y);
1150/*! @abstract Do not call this function; instead use `fmod` in C and
1151 * Objective-C, and `simd::fmod` in C++. */
1152static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y);
1153/*! @abstract Do not call this function; instead use `fmod` in C and
1154 * Objective-C, and `simd::fmod` in C++. */
1155static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y);
1156/*! @abstract Do not call this function; instead use `fmod` in C and
1157 * Objective-C, and `simd::fmod` in C++. */
1158static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y);
1159/*! @abstract Do not call this function; instead use `fmod` in C and
1160 * Objective-C, and `simd::fmod` in C++. */
1161static inline SIMD_CFUNC simd_double3 __tg_fmod(simd_double3 x, simd_double3 y);
1162/*! @abstract Do not call this function; instead use `fmod` in C and
1163 * Objective-C, and `simd::fmod` in C++. */
1164static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y);
1165/*! @abstract Do not call this function; instead use `fmod` in C and
1166 * Objective-C, and `simd::fmod` in C++. */
1167static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y);
1168
1169/*! @abstract Do not call this function; instead use `remainder` in C and
1170 * Objective-C, and `simd::remainder` in C++. */
1171static inline SIMD_CFUNC simd_float2 __tg_remainder(simd_float2 x, simd_float2 y);
1172/*! @abstract Do not call this function; instead use `remainder` in C and
1173 * Objective-C, and `simd::remainder` in C++. */
1174static inline SIMD_CFUNC simd_float3 __tg_remainder(simd_float3 x, simd_float3 y);
1175/*! @abstract Do not call this function; instead use `remainder` in C and
1176 * Objective-C, and `simd::remainder` in C++. */
1177static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y);
1178/*! @abstract Do not call this function; instead use `remainder` in C and
1179 * Objective-C, and `simd::remainder` in C++. */
1180static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y);
1181/*! @abstract Do not call this function; instead use `remainder` in C and
1182 * Objective-C, and `simd::remainder` in C++. */
1183static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y);
1184/*! @abstract Do not call this function; instead use `remainder` in C and
1185 * Objective-C, and `simd::remainder` in C++. */
1186static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y);
1187/*! @abstract Do not call this function; instead use `remainder` in C and
1188 * Objective-C, and `simd::remainder` in C++. */
1189static inline SIMD_CFUNC simd_double3 __tg_remainder(simd_double3 x, simd_double3 y);
1190/*! @abstract Do not call this function; instead use `remainder` in C and
1191 * Objective-C, and `simd::remainder` in C++. */
1192static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y);
1193/*! @abstract Do not call this function; instead use `remainder` in C and
1194 * Objective-C, and `simd::remainder` in C++. */
1195static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y);
1196
1197/*! @abstract Do not call this function; instead use `copysign` in C and
1198 * Objective-C, and `simd::copysign` in C++. */
1199static inline SIMD_CFUNC simd_float2 __tg_copysign(simd_float2 x, simd_float2 y);
1200/*! @abstract Do not call this function; instead use `copysign` in C and
1201 * Objective-C, and `simd::copysign` in C++. */
1202static inline SIMD_CFUNC simd_float3 __tg_copysign(simd_float3 x, simd_float3 y);
1203/*! @abstract Do not call this function; instead use `copysign` in C and
1204 * Objective-C, and `simd::copysign` in C++. */
1205static inline SIMD_CFUNC simd_float4 __tg_copysign(simd_float4 x, simd_float4 y);
1206/*! @abstract Do not call this function; instead use `copysign` in C and
1207 * Objective-C, and `simd::copysign` in C++. */
1208static inline SIMD_CFUNC simd_float8 __tg_copysign(simd_float8 x, simd_float8 y);
1209/*! @abstract Do not call this function; instead use `copysign` in C and
1210 * Objective-C, and `simd::copysign` in C++. */
1211static inline SIMD_CFUNC simd_float16 __tg_copysign(simd_float16 x, simd_float16 y);
1212/*! @abstract Do not call this function; instead use `copysign` in C and
1213 * Objective-C, and `simd::copysign` in C++. */
1214static inline SIMD_CFUNC simd_double2 __tg_copysign(simd_double2 x, simd_double2 y);
1215/*! @abstract Do not call this function; instead use `copysign` in C and
1216 * Objective-C, and `simd::copysign` in C++. */
1217static inline SIMD_CFUNC simd_double3 __tg_copysign(simd_double3 x, simd_double3 y);
1218/*! @abstract Do not call this function; instead use `copysign` in C and
1219 * Objective-C, and `simd::copysign` in C++. */
1220static inline SIMD_CFUNC simd_double4 __tg_copysign(simd_double4 x, simd_double4 y);
1221/*! @abstract Do not call this function; instead use `copysign` in C and
1222 * Objective-C, and `simd::copysign` in C++. */
1223static inline SIMD_CFUNC simd_double8 __tg_copysign(simd_double8 x, simd_double8 y);
1224
1225/*! @abstract Do not call this function; instead use `nextafter` in C and
1226 * Objective-C, and `simd::nextafter` in C++. */
1227static inline SIMD_CFUNC simd_float2 __tg_nextafter(simd_float2 x, simd_float2 y);
1228/*! @abstract Do not call this function; instead use `nextafter` in C and
1229 * Objective-C, and `simd::nextafter` in C++. */
1230static inline SIMD_CFUNC simd_float3 __tg_nextafter(simd_float3 x, simd_float3 y);
1231/*! @abstract Do not call this function; instead use `nextafter` in C and
1232 * Objective-C, and `simd::nextafter` in C++. */
1233static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y);
1234/*! @abstract Do not call this function; instead use `nextafter` in C and
1235 * Objective-C, and `simd::nextafter` in C++. */
1236static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y);
1237/*! @abstract Do not call this function; instead use `nextafter` in C and
1238 * Objective-C, and `simd::nextafter` in C++. */
1239static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y);
1240/*! @abstract Do not call this function; instead use `nextafter` in C and
1241 * Objective-C, and `simd::nextafter` in C++. */
1242static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y);
1243/*! @abstract Do not call this function; instead use `nextafter` in C and
1244 * Objective-C, and `simd::nextafter` in C++. */
1245static inline SIMD_CFUNC simd_double3 __tg_nextafter(simd_double3 x, simd_double3 y);
1246/*! @abstract Do not call this function; instead use `nextafter` in C and
1247 * Objective-C, and `simd::nextafter` in C++. */
1248static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y);
1249/*! @abstract Do not call this function; instead use `nextafter` in C and
1250 * Objective-C, and `simd::nextafter` in C++. */
1251static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y);
1252
1253/*! @abstract Do not call this function; instead use `fdim` in C and
1254 * Objective-C, and `simd::fdim` in C++. */
1255static inline SIMD_CFUNC simd_float2 __tg_fdim(simd_float2 x, simd_float2 y);
1256/*! @abstract Do not call this function; instead use `fdim` in C and
1257 * Objective-C, and `simd::fdim` in C++. */
1258static inline SIMD_CFUNC simd_float3 __tg_fdim(simd_float3 x, simd_float3 y);
1259/*! @abstract Do not call this function; instead use `fdim` in C and
1260 * Objective-C, and `simd::fdim` in C++. */
1261static inline SIMD_CFUNC simd_float4 __tg_fdim(simd_float4 x, simd_float4 y);
1262/*! @abstract Do not call this function; instead use `fdim` in C and
1263 * Objective-C, and `simd::fdim` in C++. */
1264static inline SIMD_CFUNC simd_float8 __tg_fdim(simd_float8 x, simd_float8 y);
1265/*! @abstract Do not call this function; instead use `fdim` in C and
1266 * Objective-C, and `simd::fdim` in C++. */
1267static inline SIMD_CFUNC simd_float16 __tg_fdim(simd_float16 x, simd_float16 y);
1268/*! @abstract Do not call this function; instead use `fdim` in C and
1269 * Objective-C, and `simd::fdim` in C++. */
1270static inline SIMD_CFUNC simd_double2 __tg_fdim(simd_double2 x, simd_double2 y);
1271/*! @abstract Do not call this function; instead use `fdim` in C and
1272 * Objective-C, and `simd::fdim` in C++. */
1273static inline SIMD_CFUNC simd_double3 __tg_fdim(simd_double3 x, simd_double3 y);
1274/*! @abstract Do not call this function; instead use `fdim` in C and
1275 * Objective-C, and `simd::fdim` in C++. */
1276static inline SIMD_CFUNC simd_double4 __tg_fdim(simd_double4 x, simd_double4 y);
1277/*! @abstract Do not call this function; instead use `fdim` in C and
1278 * Objective-C, and `simd::fdim` in C++. */
1279static inline SIMD_CFUNC simd_double8 __tg_fdim(simd_double8 x, simd_double8 y);
1280
1281/*! @abstract Do not call this function; instead use `fmax` in C and
1282 * Objective-C, and `simd::fmax` in C++. */
1283static inline SIMD_CFUNC simd_float2 __tg_fmax(simd_float2 x, simd_float2 y);
1284/*! @abstract Do not call this function; instead use `fmax` in C and
1285 * Objective-C, and `simd::fmax` in C++. */
1286static inline SIMD_CFUNC simd_float3 __tg_fmax(simd_float3 x, simd_float3 y);
1287/*! @abstract Do not call this function; instead use `fmax` in C and
1288 * Objective-C, and `simd::fmax` in C++. */
1289static inline SIMD_CFUNC simd_float4 __tg_fmax(simd_float4 x, simd_float4 y);
1290/*! @abstract Do not call this function; instead use `fmax` in C and
1291 * Objective-C, and `simd::fmax` in C++. */
1292static inline SIMD_CFUNC simd_float8 __tg_fmax(simd_float8 x, simd_float8 y);
1293/*! @abstract Do not call this function; instead use `fmax` in C and
1294 * Objective-C, and `simd::fmax` in C++. */
1295static inline SIMD_CFUNC simd_float16 __tg_fmax(simd_float16 x, simd_float16 y);
1296/*! @abstract Do not call this function; instead use `fmax` in C and
1297 * Objective-C, and `simd::fmax` in C++. */
1298static inline SIMD_CFUNC simd_double2 __tg_fmax(simd_double2 x, simd_double2 y);
1299/*! @abstract Do not call this function; instead use `fmax` in C and
1300 * Objective-C, and `simd::fmax` in C++. */
1301static inline SIMD_CFUNC simd_double3 __tg_fmax(simd_double3 x, simd_double3 y);
1302/*! @abstract Do not call this function; instead use `fmax` in C and
1303 * Objective-C, and `simd::fmax` in C++. */
1304static inline SIMD_CFUNC simd_double4 __tg_fmax(simd_double4 x, simd_double4 y);
1305/*! @abstract Do not call this function; instead use `fmax` in C and
1306 * Objective-C, and `simd::fmax` in C++. */
1307static inline SIMD_CFUNC simd_double8 __tg_fmax(simd_double8 x, simd_double8 y);
1308
1309/*! @abstract Do not call this function; instead use `fmin` in C and
1310 * Objective-C, and `simd::fmin` in C++. */
1311static inline SIMD_CFUNC simd_float2 __tg_fmin(simd_float2 x, simd_float2 y);
1312/*! @abstract Do not call this function; instead use `fmin` in C and
1313 * Objective-C, and `simd::fmin` in C++. */
1314static inline SIMD_CFUNC simd_float3 __tg_fmin(simd_float3 x, simd_float3 y);
1315/*! @abstract Do not call this function; instead use `fmin` in C and
1316 * Objective-C, and `simd::fmin` in C++. */
1317static inline SIMD_CFUNC simd_float4 __tg_fmin(simd_float4 x, simd_float4 y);
1318/*! @abstract Do not call this function; instead use `fmin` in C and
1319 * Objective-C, and `simd::fmin` in C++. */
1320static inline SIMD_CFUNC simd_float8 __tg_fmin(simd_float8 x, simd_float8 y);
1321/*! @abstract Do not call this function; instead use `fmin` in C and
1322 * Objective-C, and `simd::fmin` in C++. */
1323static inline SIMD_CFUNC simd_float16 __tg_fmin(simd_float16 x, simd_float16 y);
1324/*! @abstract Do not call this function; instead use `fmin` in C and
1325 * Objective-C, and `simd::fmin` in C++. */
1326static inline SIMD_CFUNC simd_double2 __tg_fmin(simd_double2 x, simd_double2 y);
1327/*! @abstract Do not call this function; instead use `fmin` in C and
1328 * Objective-C, and `simd::fmin` in C++. */
1329static inline SIMD_CFUNC simd_double3 __tg_fmin(simd_double3 x, simd_double3 y);
1330/*! @abstract Do not call this function; instead use `fmin` in C and
1331 * Objective-C, and `simd::fmin` in C++. */
1332static inline SIMD_CFUNC simd_double4 __tg_fmin(simd_double4 x, simd_double4 y);
1333/*! @abstract Do not call this function; instead use `fmin` in C and
1334 * Objective-C, and `simd::fmin` in C++. */
1335static inline SIMD_CFUNC simd_double8 __tg_fmin(simd_double8 x, simd_double8 y);
1336
1337
1338/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1339 * and `simd::fma` in C++. */
1340static inline SIMD_CFUNC simd_float2 __tg_fma(simd_float2 x, simd_float2 y, simd_float2 z);
1341/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1342 * and `simd::fma` in C++. */
1343static inline SIMD_CFUNC simd_float3 __tg_fma(simd_float3 x, simd_float3 y, simd_float3 z);
1344/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1345 * and `simd::fma` in C++. */
1346static inline SIMD_CFUNC simd_float4 __tg_fma(simd_float4 x, simd_float4 y, simd_float4 z);
1347/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1348 * and `simd::fma` in C++. */
1349static inline SIMD_CFUNC simd_float8 __tg_fma(simd_float8 x, simd_float8 y, simd_float8 z);
1350/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1351 * and `simd::fma` in C++. */
1352static inline SIMD_CFUNC simd_float16 __tg_fma(simd_float16 x, simd_float16 y, simd_float16 z);
1353/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1354 * and `simd::fma` in C++. */
1355static inline SIMD_CFUNC simd_double2 __tg_fma(simd_double2 x, simd_double2 y, simd_double2 z);
1356/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1357 * and `simd::fma` in C++. */
1358static inline SIMD_CFUNC simd_double3 __tg_fma(simd_double3 x, simd_double3 y, simd_double3 z);
1359/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1360 * and `simd::fma` in C++. */
1361static inline SIMD_CFUNC simd_double4 __tg_fma(simd_double4 x, simd_double4 y, simd_double4 z);
1362/*! @abstract Do not call this function; instead use `fma` in C and Objective-C,
1363 * and `simd::fma` in C++. */
1364static inline SIMD_CFUNC simd_double8 __tg_fma(simd_double8 x, simd_double8 y, simd_double8 z);
1365
1366/*! @abstract Computes accum + x*y by the most efficient means available;
1367 * either a fused multiply add or separate multiply and add instructions. */
1368static inline SIMD_CFUNC float simd_muladd(float x, float y, float z);
1369/*! @abstract Computes accum + x*y by the most efficient means available;
1370 * either a fused multiply add or separate multiply and add instructions. */
1371static inline SIMD_CFUNC simd_float2 simd_muladd(simd_float2 x, simd_float2 y, simd_float2 z);
1372/*! @abstract Computes accum + x*y by the most efficient means available;
1373 * either a fused multiply add or separate multiply and add instructions. */
1374static inline SIMD_CFUNC simd_float3 simd_muladd(simd_float3 x, simd_float3 y, simd_float3 z);
1375/*! @abstract Computes accum + x*y by the most efficient means available;
1376 * either a fused multiply add or separate multiply and add instructions. */
1377static inline SIMD_CFUNC simd_float4 simd_muladd(simd_float4 x, simd_float4 y, simd_float4 z);
1378/*! @abstract Computes accum + x*y by the most efficient means available;
1379 * either a fused multiply add or separate multiply and add instructions. */
1380static inline SIMD_CFUNC simd_float8 simd_muladd(simd_float8 x, simd_float8 y, simd_float8 z);
1381/*! @abstract Computes accum + x*y by the most efficient means available;
1382 * either a fused multiply add or separate multiply and add instructions. */
1383static inline SIMD_CFUNC simd_float16 simd_muladd(simd_float16 x, simd_float16 y, simd_float16 z);
1384/*! @abstract Computes accum + x*y by the most efficient means available;
1385 * either a fused multiply add or separate multiply and add instructions. */
1386static inline SIMD_CFUNC double simd_muladd(double x, double y, double z);
1387/*! @abstract Computes accum + x*y by the most efficient means available;
1388 * either a fused multiply add or separate multiply and add instructions. */
1389static inline SIMD_CFUNC simd_double2 simd_muladd(simd_double2 x, simd_double2 y, simd_double2 z);
1390/*! @abstract Computes accum + x*y by the most efficient means available;
1391 * either a fused multiply add or separate multiply and add instructions. */
1392static inline SIMD_CFUNC simd_double3 simd_muladd(simd_double3 x, simd_double3 y, simd_double3 z);
1393/*! @abstract Computes accum + x*y by the most efficient means available;
1394 * either a fused multiply add or separate multiply and add instructions. */
1395static inline SIMD_CFUNC simd_double4 simd_muladd(simd_double4 x, simd_double4 y, simd_double4 z);
1396/*! @abstract Computes accum + x*y by the most efficient means available;
1397 * either a fused multiply add or separate multiply and add instructions. */
1398static inline SIMD_CFUNC simd_double8 simd_muladd(simd_double8 x, simd_double8 y, simd_double8 z);
1399
1400#ifdef __cplusplus
1401} /* extern "C" */
1402
1403#include <cmath>
1404/*! @abstract Do not call this function directly; use simd::acos instead. */
1405static SIMD_CPPFUNC float __tg_acos(float x) { return ::acos(x); }
1406/*! @abstract Do not call this function directly; use simd::acos instead. */
1407static SIMD_CPPFUNC double __tg_acos(double x) { return ::acos(x); }
1408/*! @abstract Do not call this function directly; use simd::asin instead. */
1409static SIMD_CPPFUNC float __tg_asin(float x) { return ::asin(x); }
1410/*! @abstract Do not call this function directly; use simd::asin instead. */
1411static SIMD_CPPFUNC double __tg_asin(double x) { return ::asin(x); }
1412/*! @abstract Do not call this function directly; use simd::atan instead. */
1413static SIMD_CPPFUNC float __tg_atan(float x) { return ::atan(x); }
1414/*! @abstract Do not call this function directly; use simd::atan instead. */
1415static SIMD_CPPFUNC double __tg_atan(double x) { return ::atan(x); }
1416/*! @abstract Do not call this function directly; use simd::cos instead. */
1417static SIMD_CPPFUNC float __tg_cos(float x) { return ::cos(x); }
1418/*! @abstract Do not call this function directly; use simd::cos instead. */
1419static SIMD_CPPFUNC double __tg_cos(double x) { return ::cos(x); }
1420/*! @abstract Do not call this function directly; use simd::sin instead. */
1421static SIMD_CPPFUNC float __tg_sin(float x) { return ::sin(x); }
1422/*! @abstract Do not call this function directly; use simd::sin instead. */
1423static SIMD_CPPFUNC double __tg_sin(double x) { return ::sin(x); }
1424/*! @abstract Do not call this function directly; use simd::tan instead. */
1425static SIMD_CPPFUNC float __tg_tan(float x) { return ::tan(x); }
1426/*! @abstract Do not call this function directly; use simd::tan instead. */
1427static SIMD_CPPFUNC double __tg_tan(double x) { return ::tan(x); }
1428/*! @abstract Do not call this function directly; use simd::cospi instead. */
1429static SIMD_CPPFUNC float __tg_cospi(float x) { return ::__cospi(x); }
1430/*! @abstract Do not call this function directly; use simd::cospi instead. */
1431static SIMD_CPPFUNC double __tg_cospi(double x) { return ::__cospi(x); }
1432/*! @abstract Do not call this function directly; use simd::sinpi instead. */
1433static SIMD_CPPFUNC float __tg_sinpi(float x) { return ::__sinpi(x); }
1434/*! @abstract Do not call this function directly; use simd::sinpi instead. */
1435static SIMD_CPPFUNC double __tg_sinpi(double x) { return ::__sinpi(x); }
1436/*! @abstract Do not call this function directly; use simd::tanpi instead. */
1437static SIMD_CPPFUNC float __tg_tanpi(float x) { return ::__tanpi(x); }
1438/*! @abstract Do not call this function directly; use simd::tanpi instead. */
1439static SIMD_CPPFUNC double __tg_tanpi(double x) { return ::__tanpi(x); }
1440/*! @abstract Do not call this function directly; use simd::acosh instead. */
1441static SIMD_CPPFUNC float __tg_acosh(float x) { return ::acosh(x); }
1442/*! @abstract Do not call this function directly; use simd::acosh instead. */
1443static SIMD_CPPFUNC double __tg_acosh(double x) { return ::acosh(x); }
1444/*! @abstract Do not call this function directly; use simd::asinh instead. */
1445static SIMD_CPPFUNC float __tg_asinh(float x) { return ::asinh(x); }
1446/*! @abstract Do not call this function directly; use simd::asinh instead. */
1447static SIMD_CPPFUNC double __tg_asinh(double x) { return ::asinh(x); }
1448/*! @abstract Do not call this function directly; use simd::atanh instead. */
1449static SIMD_CPPFUNC float __tg_atanh(float x) { return ::atanh(x); }
1450/*! @abstract Do not call this function directly; use simd::atanh instead. */
1451static SIMD_CPPFUNC double __tg_atanh(double x) { return ::atanh(x); }
1452/*! @abstract Do not call this function directly; use simd::cosh instead. */
1453static SIMD_CPPFUNC float __tg_cosh(float x) { return ::cosh(x); }
1454/*! @abstract Do not call this function directly; use simd::cosh instead. */
1455static SIMD_CPPFUNC double __tg_cosh(double x) { return ::cosh(x); }
1456/*! @abstract Do not call this function directly; use simd::sinh instead. */
1457static SIMD_CPPFUNC float __tg_sinh(float x) { return ::sinh(x); }
1458/*! @abstract Do not call this function directly; use simd::sinh instead. */
1459static SIMD_CPPFUNC double __tg_sinh(double x) { return ::sinh(x); }
1460/*! @abstract Do not call this function directly; use simd::tanh instead. */
1461static SIMD_CPPFUNC float __tg_tanh(float x) { return ::tanh(x); }
1462/*! @abstract Do not call this function directly; use simd::tanh instead. */
1463static SIMD_CPPFUNC double __tg_tanh(double x) { return ::tanh(x); }
1464/*! @abstract Do not call this function directly; use simd::exp instead. */
1465static SIMD_CPPFUNC float __tg_exp(float x) { return ::exp(x); }
1466/*! @abstract Do not call this function directly; use simd::exp instead. */
1467static SIMD_CPPFUNC double __tg_exp(double x) { return ::exp(x); }
1468/*! @abstract Do not call this function directly; use simd::exp2 instead. */
1469static SIMD_CPPFUNC float __tg_exp2(float x) { return ::exp2(x); }
1470/*! @abstract Do not call this function directly; use simd::exp2 instead. */
1471static SIMD_CPPFUNC double __tg_exp2(double x) { return ::exp2(x); }
1472/*! @abstract Do not call this function directly; use simd::exp10 instead. */
1473static SIMD_CPPFUNC float __tg_exp10(float x) { return ::__exp10(x); }
1474/*! @abstract Do not call this function directly; use simd::exp10 instead. */
1475static SIMD_CPPFUNC double __tg_exp10(double x) { return ::__exp10(x); }
1476/*! @abstract Do not call this function directly; use simd::expm1 instead. */
1477static SIMD_CPPFUNC float __tg_expm1(float x) { return ::expm1(x); }
1478/*! @abstract Do not call this function directly; use simd::expm1 instead. */
1479static SIMD_CPPFUNC double __tg_expm1(double x) { return ::expm1(x); }
1480/*! @abstract Do not call this function directly; use simd::log instead. */
1481static SIMD_CPPFUNC float __tg_log(float x) { return ::log(x); }
1482/*! @abstract Do not call this function directly; use simd::log instead. */
1483static SIMD_CPPFUNC double __tg_log(double x) { return ::log(x); }
1484/*! @abstract Do not call this function directly; use simd::log2 instead. */
1485static SIMD_CPPFUNC float __tg_log2(float x) { return ::log2(x); }
1486/*! @abstract Do not call this function directly; use simd::log2 instead. */
1487static SIMD_CPPFUNC double __tg_log2(double x) { return ::log2(x); }
1488/*! @abstract Do not call this function directly; use simd::log10 instead. */
1489static SIMD_CPPFUNC float __tg_log10(float x) { return ::log10(x); }
1490/*! @abstract Do not call this function directly; use simd::log10 instead. */
1491static SIMD_CPPFUNC double __tg_log10(double x) { return ::log10(x); }
1492/*! @abstract Do not call this function directly; use simd::log1p instead. */
1493static SIMD_CPPFUNC float __tg_log1p(float x) { return ::log1p(x); }
1494/*! @abstract Do not call this function directly; use simd::log1p instead. */
1495static SIMD_CPPFUNC double __tg_log1p(double x) { return ::log1p(x); }
1496/*! @abstract Do not call this function directly; use simd::fabs instead. */
1497static SIMD_CPPFUNC float __tg_fabs(float x) { return ::fabs(x); }
1498/*! @abstract Do not call this function directly; use simd::fabs instead. */
1499static SIMD_CPPFUNC double __tg_fabs(double x) { return ::fabs(x); }
1500/*! @abstract Do not call this function directly; use simd::cbrt instead. */
1501static SIMD_CPPFUNC float __tg_cbrt(float x) { return ::cbrt(x); }
1502/*! @abstract Do not call this function directly; use simd::cbrt instead. */
1503static SIMD_CPPFUNC double __tg_cbrt(double x) { return ::cbrt(x); }
1504/*! @abstract Do not call this function directly; use simd::sqrt instead. */
1505static SIMD_CPPFUNC float __tg_sqrt(float x) { return ::sqrt(x); }
1506/*! @abstract Do not call this function directly; use simd::sqrt instead. */
1507static SIMD_CPPFUNC double __tg_sqrt(double x) { return ::sqrt(x); }
1508/*! @abstract Do not call this function directly; use simd::erf instead. */
1509static SIMD_CPPFUNC float __tg_erf(float x) { return ::erf(x); }
1510/*! @abstract Do not call this function directly; use simd::erf instead. */
1511static SIMD_CPPFUNC double __tg_erf(double x) { return ::erf(x); }
1512/*! @abstract Do not call this function directly; use simd::erfc instead. */
1513static SIMD_CPPFUNC float __tg_erfc(float x) { return ::erfc(x); }
1514/*! @abstract Do not call this function directly; use simd::erfc instead. */
1515static SIMD_CPPFUNC double __tg_erfc(double x) { return ::erfc(x); }
1516/*! @abstract Do not call this function directly; use simd::tgamma instead. */
1517static SIMD_CPPFUNC float __tg_tgamma(float x) { return ::tgamma(x); }
1518/*! @abstract Do not call this function directly; use simd::tgamma instead. */
1519static SIMD_CPPFUNC double __tg_tgamma(double x) { return ::tgamma(x); }
1520/*! @abstract Do not call this function directly; use simd::ceil instead. */
1521static SIMD_CPPFUNC float __tg_ceil(float x) { return ::ceil(x); }
1522/*! @abstract Do not call this function directly; use simd::ceil instead. */
1523static SIMD_CPPFUNC double __tg_ceil(double x) { return ::ceil(x); }
1524/*! @abstract Do not call this function directly; use simd::floor instead. */
1525static SIMD_CPPFUNC float __tg_floor(float x) { return ::floor(x); }
1526/*! @abstract Do not call this function directly; use simd::floor instead. */
1527static SIMD_CPPFUNC double __tg_floor(double x) { return ::floor(x); }
1528/*! @abstract Do not call this function directly; use simd::rint instead. */
1529static SIMD_CPPFUNC float __tg_rint(float x) { return ::rint(x); }
1530/*! @abstract Do not call this function directly; use simd::rint instead. */
1531static SIMD_CPPFUNC double __tg_rint(double x) { return ::rint(x); }
1532/*! @abstract Do not call this function directly; use simd::round instead. */
1533static SIMD_CPPFUNC float __tg_round(float x) { return ::round(x); }
1534/*! @abstract Do not call this function directly; use simd::round instead. */
1535static SIMD_CPPFUNC double __tg_round(double x) { return ::round(x); }
1536/*! @abstract Do not call this function directly; use simd::trunc instead. */
1537static SIMD_CPPFUNC float __tg_trunc(float x) { return ::trunc(x); }
1538/*! @abstract Do not call this function directly; use simd::trunc instead. */
1539static SIMD_CPPFUNC double __tg_trunc(double x) { return ::trunc(x); }
1540/*! @abstract Do not call this function directly; use simd::atan2 instead. */
1541static SIMD_CPPFUNC float __tg_atan2(float x, float y) { return ::atan2(x, y); }
1542/*! @abstract Do not call this function directly; use simd::atan2 instead. */
1543static SIMD_CPPFUNC double __tg_atan2(double x, float y) { return ::atan2(x, y); }
1544/*! @abstract Do not call this function directly; use simd::hypot instead. */
1545static SIMD_CPPFUNC float __tg_hypot(float x, float y) { return ::hypot(x, y); }
1546/*! @abstract Do not call this function directly; use simd::hypot instead. */
1547static SIMD_CPPFUNC double __tg_hypot(double x, float y) { return ::hypot(x, y); }
1548/*! @abstract Do not call this function directly; use simd::pow instead. */
1549static SIMD_CPPFUNC float __tg_pow(float x, float y) { return ::pow(x, y); }
1550/*! @abstract Do not call this function directly; use simd::pow instead. */
1551static SIMD_CPPFUNC double __tg_pow(double x, float y) { return ::pow(x, y); }
1552/*! @abstract Do not call this function directly; use simd::fmod instead. */
1553static SIMD_CPPFUNC float __tg_fmod(float x, float y) { return ::fmod(x, y); }
1554/*! @abstract Do not call this function directly; use simd::fmod instead. */
1555static SIMD_CPPFUNC double __tg_fmod(double x, float y) { return ::fmod(x, y); }
1556/*! @abstract Do not call this function directly; use simd::remainder
1557 * instead. */
1558static SIMD_CPPFUNC float __tg_remainder(float x, float y) { return ::remainder(x, y); }
1559/*! @abstract Do not call this function directly; use simd::remainder
1560 * instead. */
1561static SIMD_CPPFUNC double __tg_remainder(double x, float y) { return ::remainder(x, y); }
1562/*! @abstract Do not call this function directly; use simd::copysign
1563 * instead. */
1564static SIMD_CPPFUNC float __tg_copysign(float x, float y) { return ::copysign(x, y); }
1565/*! @abstract Do not call this function directly; use simd::copysign
1566 * instead. */
1567static SIMD_CPPFUNC double __tg_copysign(double x, float y) { return ::copysign(x, y); }
1568/*! @abstract Do not call this function directly; use simd::nextafter
1569 * instead. */
1570static SIMD_CPPFUNC float __tg_nextafter(float x, float y) { return ::nextafter(x, y); }
1571/*! @abstract Do not call this function directly; use simd::nextafter
1572 * instead. */
1573static SIMD_CPPFUNC double __tg_nextafter(double x, float y) { return ::nextafter(x, y); }
1574/*! @abstract Do not call this function directly; use simd::fdim instead. */
1575static SIMD_CPPFUNC float __tg_fdim(float x, float y) { return ::fdim(x, y); }
1576/*! @abstract Do not call this function directly; use simd::fdim instead. */
1577static SIMD_CPPFUNC double __tg_fdim(double x, float y) { return ::fdim(x, y); }
1578/*! @abstract Do not call this function directly; use simd::fmax instead. */
1579static SIMD_CPPFUNC float __tg_fmax(float x, float y) { return ::fmax(x, y); }
1580/*! @abstract Do not call this function directly; use simd::fmax instead. */
1581static SIMD_CPPFUNC double __tg_fmax(double x, float y) { return ::fmax(x, y); }
1582/*! @abstract Do not call this function directly; use simd::fmin instead. */
1583static SIMD_CPPFUNC float __tg_fmin(float x, float y) { return ::fmin(x, y); }
1584/*! @abstract Do not call this function directly; use simd::fmin instead. */
1585static SIMD_CPPFUNC double __tg_fmin(double x, float y) { return ::fmin(x, y); }
1586/*! @abstract Do not call this function directly; use simd::fma instead. */
1587static SIMD_CPPFUNC float __tg_fma(float x, float y, float z) { return ::fma(x, y, z); }
1588/*! @abstract Do not call this function directly; use simd::fma instead. */
1589static SIMD_CPPFUNC double __tg_fma(double x, double y, double z) { return ::fma(x, y, z); }
1590
1591namespace simd {
1592/*! @abstract Generalizes the <cmath> function acos to operate on vectors of
1593 * floats and doubles. */
1594 template <typename fptypeN>
1595 static SIMD_CPPFUNC fptypeN acos(fptypeN x) { return ::__tg_acos(x); }
1596
1597/*! @abstract Generalizes the <cmath> function asin to operate on vectors of
1598 * floats and doubles. */
1599 template <typename fptypeN>
1600 static SIMD_CPPFUNC fptypeN asin(fptypeN x) { return ::__tg_asin(x); }
1601
1602/*! @abstract Generalizes the <cmath> function atan to operate on vectors of
1603 * floats and doubles. */
1604 template <typename fptypeN>
1605 static SIMD_CPPFUNC fptypeN atan(fptypeN x) { return ::__tg_atan(x); }
1606
1607/*! @abstract Generalizes the <cmath> function cos to operate on vectors of
1608 * floats and doubles. */
1609 template <typename fptypeN>
1610 static SIMD_CPPFUNC fptypeN cos(fptypeN x) { return ::__tg_cos(x); }
1611
1612/*! @abstract Generalizes the <cmath> function sin to operate on vectors of
1613 * floats and doubles. */
1614 template <typename fptypeN>
1615 static SIMD_CPPFUNC fptypeN sin(fptypeN x) { return ::__tg_sin(x); }
1616
1617/*! @abstract Generalizes the <cmath> function tan to operate on vectors of
1618 * floats and doubles. */
1619 template <typename fptypeN>
1620 static SIMD_CPPFUNC fptypeN tan(fptypeN x) { return ::__tg_tan(x); }
1621
1622#if SIMD_LIBRARY_VERSION >= 1
1623/*! @abstract Generalizes the <cmath> function cospi to operate on vectors
1624 * of floats and doubles. */
1625 template <typename fptypeN>
1626 static SIMD_CPPFUNC fptypeN cospi(fptypeN x) { return ::__tg_cospi(x); }
1627#endif
1628
1629#if SIMD_LIBRARY_VERSION >= 1
1630/*! @abstract Generalizes the <cmath> function sinpi to operate on vectors
1631 * of floats and doubles. */
1632 template <typename fptypeN>
1633 static SIMD_CPPFUNC fptypeN sinpi(fptypeN x) { return ::__tg_sinpi(x); }
1634#endif
1635
1636#if SIMD_LIBRARY_VERSION >= 1
1637/*! @abstract Generalizes the <cmath> function tanpi to operate on vectors
1638 * of floats and doubles. */
1639 template <typename fptypeN>
1640 static SIMD_CPPFUNC fptypeN tanpi(fptypeN x) { return ::__tg_tanpi(x); }
1641#endif
1642
1643/*! @abstract Generalizes the <cmath> function acosh to operate on vectors
1644 * of floats and doubles. */
1645 template <typename fptypeN>
1646 static SIMD_CPPFUNC fptypeN acosh(fptypeN x) { return ::__tg_acosh(x); }
1647
1648/*! @abstract Generalizes the <cmath> function asinh to operate on vectors
1649 * of floats and doubles. */
1650 template <typename fptypeN>
1651 static SIMD_CPPFUNC fptypeN asinh(fptypeN x) { return ::__tg_asinh(x); }
1652
1653/*! @abstract Generalizes the <cmath> function atanh to operate on vectors
1654 * of floats and doubles. */
1655 template <typename fptypeN>
1656 static SIMD_CPPFUNC fptypeN atanh(fptypeN x) { return ::__tg_atanh(x); }
1657
1658/*! @abstract Generalizes the <cmath> function cosh to operate on vectors of
1659 * floats and doubles. */
1660 template <typename fptypeN>
1661 static SIMD_CPPFUNC fptypeN cosh(fptypeN x) { return ::__tg_cosh(x); }
1662
1663/*! @abstract Generalizes the <cmath> function sinh to operate on vectors of
1664 * floats and doubles. */
1665 template <typename fptypeN>
1666 static SIMD_CPPFUNC fptypeN sinh(fptypeN x) { return ::__tg_sinh(x); }
1667
1668/*! @abstract Generalizes the <cmath> function tanh to operate on vectors of
1669 * floats and doubles. */
1670 template <typename fptypeN>
1671 static SIMD_CPPFUNC fptypeN tanh(fptypeN x) { return ::__tg_tanh(x); }
1672
1673/*! @abstract Generalizes the <cmath> function exp to operate on vectors of
1674 * floats and doubles. */
1675 template <typename fptypeN>
1676 static SIMD_CPPFUNC fptypeN exp(fptypeN x) { return ::__tg_exp(x); }
1677
1678/*! @abstract Generalizes the <cmath> function exp2 to operate on vectors of
1679 * floats and doubles. */
1680 template <typename fptypeN>
1681 static SIMD_CPPFUNC fptypeN exp2(fptypeN x) { return ::__tg_exp2(x); }
1682
1683#if SIMD_LIBRARY_VERSION >= 1
1684/*! @abstract Generalizes the <cmath> function exp10 to operate on vectors
1685 * of floats and doubles. */
1686 template <typename fptypeN>
1687 static SIMD_CPPFUNC fptypeN exp10(fptypeN x) { return ::__tg_exp10(x); }
1688#endif
1689
1690/*! @abstract Generalizes the <cmath> function expm1 to operate on vectors
1691 * of floats and doubles. */
1692 template <typename fptypeN>
1693 static SIMD_CPPFUNC fptypeN expm1(fptypeN x) { return ::__tg_expm1(x); }
1694
1695/*! @abstract Generalizes the <cmath> function log to operate on vectors of
1696 * floats and doubles. */
1697 template <typename fptypeN>
1698 static SIMD_CPPFUNC fptypeN log(fptypeN x) { return ::__tg_log(x); }
1699
1700/*! @abstract Generalizes the <cmath> function log2 to operate on vectors of
1701 * floats and doubles. */
1702 template <typename fptypeN>
1703 static SIMD_CPPFUNC fptypeN log2(fptypeN x) { return ::__tg_log2(x); }
1704
1705/*! @abstract Generalizes the <cmath> function log10 to operate on vectors
1706 * of floats and doubles. */
1707 template <typename fptypeN>
1708 static SIMD_CPPFUNC fptypeN log10(fptypeN x) { return ::__tg_log10(x); }
1709
1710/*! @abstract Generalizes the <cmath> function log1p to operate on vectors
1711 * of floats and doubles. */
1712 template <typename fptypeN>
1713 static SIMD_CPPFUNC fptypeN log1p(fptypeN x) { return ::__tg_log1p(x); }
1714
1715/*! @abstract Generalizes the <cmath> function fabs to operate on vectors of
1716 * floats and doubles. */
1717 template <typename fptypeN>
1718 static SIMD_CPPFUNC fptypeN fabs(fptypeN x) { return ::__tg_fabs(x); }
1719
1720/*! @abstract Generalizes the <cmath> function cbrt to operate on vectors of
1721 * floats and doubles. */
1722 template <typename fptypeN>
1723 static SIMD_CPPFUNC fptypeN cbrt(fptypeN x) { return ::__tg_cbrt(x); }
1724
1725/*! @abstract Generalizes the <cmath> function sqrt to operate on vectors of
1726 * floats and doubles. */
1727 template <typename fptypeN>
1728 static SIMD_CPPFUNC fptypeN sqrt(fptypeN x) { return ::__tg_sqrt(x); }
1729
1730/*! @abstract Generalizes the <cmath> function erf to operate on vectors of
1731 * floats and doubles. */
1732 template <typename fptypeN>
1733 static SIMD_CPPFUNC fptypeN erf(fptypeN x) { return ::__tg_erf(x); }
1734
1735/*! @abstract Generalizes the <cmath> function erfc to operate on vectors of
1736 * floats and doubles. */
1737 template <typename fptypeN>
1738 static SIMD_CPPFUNC fptypeN erfc(fptypeN x) { return ::__tg_erfc(x); }
1739
1740/*! @abstract Generalizes the <cmath> function tgamma to operate on vectors
1741 * of floats and doubles. */
1742 template <typename fptypeN>
1743 static SIMD_CPPFUNC fptypeN tgamma(fptypeN x) { return ::__tg_tgamma(x); }
1744
1745/*! @abstract Generalizes the <cmath> function ceil to operate on vectors of
1746 * floats and doubles. */
1747 template <typename fptypeN>
1748 static SIMD_CPPFUNC fptypeN ceil(fptypeN x) { return ::__tg_ceil(x); }
1749
1750/*! @abstract Generalizes the <cmath> function floor to operate on vectors
1751 * of floats and doubles. */
1752 template <typename fptypeN>
1753 static SIMD_CPPFUNC fptypeN floor(fptypeN x) { return ::__tg_floor(x); }
1754
1755/*! @abstract Generalizes the <cmath> function rint to operate on vectors of
1756 * floats and doubles. */
1757 template <typename fptypeN>
1758 static SIMD_CPPFUNC fptypeN rint(fptypeN x) { return ::__tg_rint(x); }
1759
1760/*! @abstract Generalizes the <cmath> function round to operate on vectors
1761 * of floats and doubles. */
1762 template <typename fptypeN>
1763 static SIMD_CPPFUNC fptypeN round(fptypeN x) { return ::__tg_round(x); }
1764
1765/*! @abstract Generalizes the <cmath> function trunc to operate on vectors
1766 * of floats and doubles. */
1767 template <typename fptypeN>
1768 static SIMD_CPPFUNC fptypeN trunc(fptypeN x) { return ::__tg_trunc(x); }
1769
1770/*! @abstract Generalizes the <cmath> function atan2 to operate on vectors
1771 * of floats and doubles. */
1772 template <typename fptypeN>
1773 static SIMD_CPPFUNC fptypeN atan2(fptypeN y, fptypeN x) { return ::__tg_atan2(y, x); }
1774
1775/*! @abstract Generalizes the <cmath> function hypot to operate on vectors
1776 * of floats and doubles. */
1777 template <typename fptypeN>
1778 static SIMD_CPPFUNC fptypeN hypot(fptypeN x, fptypeN y) { return ::__tg_hypot(x, y); }
1779
1780/*! @abstract Generalizes the <cmath> function pow to operate on vectors of
1781 * floats and doubles. */
1782 template <typename fptypeN>
1783 static SIMD_CPPFUNC fptypeN pow(fptypeN x, fptypeN y) { return ::__tg_pow(x, y); }
1784
1785/*! @abstract Generalizes the <cmath> function fmod to operate on vectors of
1786 * floats and doubles. */
1787 template <typename fptypeN>
1788 static SIMD_CPPFUNC fptypeN fmod(fptypeN x, fptypeN y) { return ::__tg_fmod(x, y); }
1789
1790/*! @abstract Generalizes the <cmath> function remainder to operate on
1791 * vectors of floats and doubles. */
1792 template <typename fptypeN>
1793 static SIMD_CPPFUNC fptypeN remainder(fptypeN x, fptypeN y) { return ::__tg_remainder(x, y); }
1794
1795/*! @abstract Generalizes the <cmath> function copysign to operate on
1796 * vectors of floats and doubles. */
1797 template <typename fptypeN>
1798 static SIMD_CPPFUNC fptypeN copysign(fptypeN x, fptypeN y) { return ::__tg_copysign(x, y); }
1799
1800/*! @abstract Generalizes the <cmath> function nextafter to operate on
1801 * vectors of floats and doubles. */
1802 template <typename fptypeN>
1803 static SIMD_CPPFUNC fptypeN nextafter(fptypeN x, fptypeN y) { return ::__tg_nextafter(x, y); }
1804
1805/*! @abstract Generalizes the <cmath> function fdim to operate on vectors of
1806 * floats and doubles. */
1807 template <typename fptypeN>
1808 static SIMD_CPPFUNC fptypeN fdim(fptypeN x, fptypeN y) { return ::__tg_fdim(x, y); }
1809
1810/*! @abstract Generalizes the <cmath> function fmax to operate on vectors of
1811 * floats and doubles. */
1812 template <typename fptypeN>
1813 static SIMD_CPPFUNC fptypeN fmax(fptypeN x, fptypeN y) { return ::__tg_fmax(x, y); }
1814
1815/*! @abstract Generalizes the <cmath> function fmin to operate on vectors of
1816 * floats and doubles. */
1817 template <typename fptypeN>
1818 static SIMD_CPPFUNC fptypeN fmin(fptypeN x, fptypeN y) { return ::__tg_fmin(x, y); }
1819
1820/*! @abstract Generalizes the <cmath> function fma to operate on vectors of
1821 * floats and doubles. */
1822 template <typename fptypeN>
1823 static SIMD_CPPFUNC fptypeN fma(fptypeN x, fptypeN y, fptypeN z) { return ::__tg_fma(x, y, z); }
1824
1825/*! @abstract Computes x*y + z by the most efficient means available; either
1826 * a fused multiply add or separate multiply and add. */
1827 template <typename fptypeN>
1828 static SIMD_CPPFUNC fptypeN muladd(fptypeN x, fptypeN y, fptypeN z) { return ::simd_muladd(x, y, z); }
1829};
1830
1831extern "C" {
1832#else
1833#include <tgmath.h>
1834/* C and Objective-C, we need some infrastructure to piggyback on tgmath.h */
1835static SIMD_OVERLOAD simd_float2 __tg_promote(simd_float2);
1836static SIMD_OVERLOAD simd_float3 __tg_promote(simd_float3);
1837static SIMD_OVERLOAD simd_float4 __tg_promote(simd_float4);
1838static SIMD_OVERLOAD simd_float8 __tg_promote(simd_float8);
1839static SIMD_OVERLOAD simd_float16 __tg_promote(simd_float16);
1840static SIMD_OVERLOAD simd_double2 __tg_promote(simd_double2);
1841static SIMD_OVERLOAD simd_double3 __tg_promote(simd_double3);
1842static SIMD_OVERLOAD simd_double4 __tg_promote(simd_double4);
1843static SIMD_OVERLOAD simd_double8 __tg_promote(simd_double8);
1844
1845/* Apple extensions to <math.h>, added in macOS 10.9 and iOS 7.0 */
1846#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_9 || \
1847 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0 || \
1848 __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_19_0
1849static inline SIMD_CFUNC float __tg_cospi(float x) { return __cospif(x); }
1850static inline SIMD_CFUNC double __tg_cospi(double x) { return __cospi(x); }
1851#undef cospi
1852/*! @abstract `cospi(x)` computes `cos(pi * x)` without intermediate rounding.
1853 *
1854 * @discussion Both faster and more accurate than multiplying by `pi` and then
1855 * calling `cos`. Defined for `float` and `double` as well as vectors of
1856 * floats and doubles as provided by `<simd/simd.h>`. */
1857#define cospi(__x) __tg_cospi(__tg_promote1((__x))(__x))
1858
1859static inline SIMD_CFUNC float __tg_sinpi(float x) { return __sinpif(x); }
1860static inline SIMD_CFUNC double __tg_sinpi(double x) { return __sinpi(x); }
1861#undef sinpi
1862/*! @abstract `sinpi(x)` computes `sin(pi * x)` without intermediate rounding.
1863 *
1864 * @discussion Both faster and more accurate than multiplying by `pi` and then
1865 * calling `sin`. Defined for `float` and `double` as well as vectors
1866 * of floats and doubles as provided by `<simd/simd.h>`. */
1867#define sinpi(__x) __tg_sinpi(__tg_promote1((__x))(__x))
1868
1869static inline SIMD_CFUNC float __tg_tanpi(float x) { return __tanpif(x); }
1870static inline SIMD_CFUNC double __tg_tanpi(double x) { return __tanpi(x); }
1871#undef tanpi
1872/*! @abstract `tanpi(x)` computes `tan(pi * x)` without intermediate rounding.
1873 *
1874 * @discussion Both faster and more accurate than multiplying by `pi` and then
1875 * calling `tan`. Defined for `float` and `double` as well as vectors of
1876 * floats and doubles as provided by `<simd/simd.h>`. */
1877#define tanpi(__x) __tg_tanpi(__tg_promote1((__x))(__x))
1878
1879static inline SIMD_CFUNC float __tg_exp10(float x) { return __exp10f(x); }
1880static inline SIMD_CFUNC double __tg_exp10(double x) { return __exp10(x); }
1881#undef exp10
1882/*! @abstract `exp10(x)` computes `10**x` more efficiently and accurately
1883 * than `pow(10, x)`.
1884 *
1885 * @discussion Defined for `float` and `double` as well as vectors of floats
1886 * and doubles as provided by `<simd/simd.h>`. */
1887#define exp10(__x) __tg_exp10(__tg_promote1((__x))(__x))
1888#endif
1889
1890
1891#endif /* !__cplusplus */
1892
1893#pragma mark - fabs implementation
1894static inline SIMD_CFUNC simd_float2 __tg_fabs(simd_float2 x) { return simd_bitselect(0.0, x, 0x7fffffff); }
1895static inline SIMD_CFUNC simd_float3 __tg_fabs(simd_float3 x) { return simd_bitselect(0.0, x, 0x7fffffff); }
1896static inline SIMD_CFUNC simd_float4 __tg_fabs(simd_float4 x) { return simd_bitselect(0.0, x, 0x7fffffff); }
1897static inline SIMD_CFUNC simd_float8 __tg_fabs(simd_float8 x) { return simd_bitselect(0.0, x, 0x7fffffff); }
1898static inline SIMD_CFUNC simd_float16 __tg_fabs(simd_float16 x) { return simd_bitselect(0.0, x, 0x7fffffff); }
1899static inline SIMD_CFUNC simd_double2 __tg_fabs(simd_double2 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); }
1900static inline SIMD_CFUNC simd_double3 __tg_fabs(simd_double3 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); }
1901static inline SIMD_CFUNC simd_double4 __tg_fabs(simd_double4 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); }
1902static inline SIMD_CFUNC simd_double8 __tg_fabs(simd_double8 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); }
1903
1904#pragma mark - fmin, fmax implementation
1905static SIMD_CFUNC simd_float2 __tg_fmin(simd_float2 x, simd_float2 y) {
1906#if defined __SSE2__
1907 return simd_make_float2(__tg_fmin(simd_make_float4_undef(x), simd_make_float4_undef(y)));
1908#elif defined __arm64__
1909 return vminnm_f32(x, y);
1910#elif defined __arm__ && __FINITE_MATH_ONLY__
1911 return vmin_f32(x, y);
1912#else
1913 return simd_bitselect(y, x, (x <= y) | (y != y));
1914#endif
1915}
1916
1917static SIMD_CFUNC simd_float3 __tg_fmin(simd_float3 x, simd_float3 y) {
1918 return simd_make_float3(__tg_fmin(simd_make_float4_undef(x), simd_make_float4_undef(y)));
1919}
1920
1921static SIMD_CFUNC simd_float4 __tg_fmin(simd_float4 x, simd_float4 y) {
1922#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__
1923 return _mm_range_ps(x, y, 4);
1924#elif defined __SSE2__ && __FINITE_MATH_ONLY__
1925 return _mm_min_ps(x, y);
1926#elif defined __SSE2__
1927 return simd_bitselect(_mm_min_ps(x, y), x, y != y);
1928#elif defined __arm64__
1929 return vminnmq_f32(x, y);
1930#elif defined __arm__ && __FINITE_MATH_ONLY__
1931 return vminq_f32(x, y);
1932#else
1933 return simd_bitselect(y, x, (x <= y) | (y != y));
1934#endif
1935}
1936
1937static SIMD_CFUNC simd_float8 __tg_fmin(simd_float8 x, simd_float8 y) {
1938#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__
1939 return _mm256_range_ps(x, y, 4);
1940#elif defined __AVX__ && __FINITE_MATH_ONLY__
1941 return _mm256_min_ps(x, y);
1942#elif defined __AVX__
1943 return simd_bitselect(_mm256_min_ps(x, y), x, y != y);
1944#else
1945 return simd_make_float8(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi));
1946#endif
1947}
1948
1949static SIMD_CFUNC simd_float16 __tg_fmin(simd_float16 x, simd_float16 y) {
1950#if defined __x86_64__ && defined __AVX512DQ__ && !__FINITE_MATH_ONLY__
1951 return _mm512_range_ps(x, y, 4);
1952#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__
1953 return _mm512_min_ps(x, y);
1954#elif defined __x86_64__ && defined __AVX512F__
1955 return simd_bitselect(_mm512_min_ps(x, y), x, y != y);
1956#else
1957 return simd_make_float16(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi));
1958#endif
1959}
1960
1961static SIMD_CFUNC simd_double2 __tg_fmin(simd_double2 x, simd_double2 y) {
1962#if defined __AVX512DQ__ && defined __AVX512VL__
1963 return _mm_range_pd(x, y, 4);
1964#elif defined __SSE2__ && __FINITE_MATH_ONLY__
1965 return _mm_min_pd(x, y);
1966#elif defined __SSE2__
1967 return simd_bitselect(_mm_min_pd(x, y), x, y != y);
1968#elif defined __arm64__
1969 return vminnmq_f64(x, y);
1970#else
1971 return simd_bitselect(y, x, (x <= y) | (y != y));
1972#endif
1973}
1974
1975static SIMD_CFUNC simd_double3 __tg_fmin(simd_double3 x, simd_double3 y) {
1976 return simd_make_double3(__tg_fmin(simd_make_double4_undef(x), simd_make_double4_undef(y)));
1977}
1978
1979static SIMD_CFUNC simd_double4 __tg_fmin(simd_double4 x, simd_double4 y) {
1980#if defined __AVX512DQ__ && defined __AVX512VL__
1981 return _mm256_range_pd(x, y, 4);
1982#elif defined __AVX__ && __FINITE_MATH_ONLY__
1983 return _mm256_min_pd(x, y);
1984#elif defined __AVX__
1985 return simd_bitselect(_mm256_min_pd(x, y), x, y != y);
1986#else
1987 return simd_make_double4(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi));
1988#endif
1989}
1990
1991static SIMD_CFUNC simd_double8 __tg_fmin(simd_double8 x, simd_double8 y) {
1992#if defined __x86_64__ && defined __AVX512DQ__
1993 return _mm512_range_pd(x, y, 4);
1994#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__
1995 return _mm512_min_pd(x, y);
1996#elif defined __x86_64__ && defined __AVX512F__
1997 return simd_bitselect(_mm512_min_pd(x, y), x, y != y);
1998#else
1999 return simd_make_double8(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi));
2000#endif
2001}
2002
2003static SIMD_CFUNC simd_float2 __tg_fmax(simd_float2 x, simd_float2 y) {
2004#if defined __SSE2__
2005 return simd_make_float2(__tg_fmax(simd_make_float4_undef(x), simd_make_float4_undef(y)));
2006#elif defined __arm64__
2007 return vmaxnm_f32(x, y);
2008#elif defined __arm__ && __FINITE_MATH_ONLY__
2009 return vmax_f32(x, y);
2010#else
2011 return simd_bitselect(y, x, (x >= y) | (y != y));
2012#endif
2013}
2014
2015static SIMD_CFUNC simd_float3 __tg_fmax(simd_float3 x, simd_float3 y) {
2016 return simd_make_float3(__tg_fmax(simd_make_float4_undef(x), simd_make_float4_undef(y)));
2017}
2018
2019static SIMD_CFUNC simd_float4 __tg_fmax(simd_float4 x, simd_float4 y) {
2020#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__
2021 return _mm_range_ps(x, y, 5);
2022#elif defined __SSE2__ && __FINITE_MATH_ONLY__
2023 return _mm_max_ps(x, y);
2024#elif defined __SSE2__
2025 return simd_bitselect(_mm_max_ps(x, y), x, y != y);
2026#elif defined __arm64__
2027 return vmaxnmq_f32(x, y);
2028#elif defined __arm__ && __FINITE_MATH_ONLY__
2029 return vmaxq_f32(x, y);
2030#else
2031 return simd_bitselect(y, x, (x >= y) | (y != y));
2032#endif
2033}
2034
2035static SIMD_CFUNC simd_float8 __tg_fmax(simd_float8 x, simd_float8 y) {
2036#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__
2037 return _mm256_range_ps(x, y, 5);
2038#elif defined __AVX__ && __FINITE_MATH_ONLY__
2039 return _mm256_max_ps(x, y);
2040#elif defined __AVX__
2041 return simd_bitselect(_mm256_max_ps(x, y), x, y != y);
2042#else
2043 return simd_make_float8(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi));
2044#endif
2045}
2046
2047static SIMD_CFUNC simd_float16 __tg_fmax(simd_float16 x, simd_float16 y) {
2048#if defined __x86_64__ && defined __AVX512DQ__ && !__FINITE_MATH_ONLY__
2049 return _mm512_range_ps(x, y, 5);
2050#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__
2051 return _mm512_max_ps(x, y);
2052#elif defined __x86_64__ && defined __AVX512F__
2053 return simd_bitselect(_mm512_max_ps(x, y), x, y != y);
2054#else
2055 return simd_make_float16(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi));
2056#endif
2057}
2058
2059static SIMD_CFUNC simd_double2 __tg_fmax(simd_double2 x, simd_double2 y) {
2060#if defined __AVX512DQ__ && defined __AVX512VL__
2061 return _mm_range_pd(x, y, 5);
2062#elif defined __SSE2__ && __FINITE_MATH_ONLY__
2063 return _mm_max_pd(x, y);
2064#elif defined __SSE2__
2065 return simd_bitselect(_mm_max_pd(x, y), x, y != y);
2066#elif defined __arm64__
2067 return vmaxnmq_f64(x, y);
2068#else
2069 return simd_bitselect(y, x, (x >= y) | (y != y));
2070#endif
2071}
2072
2073static SIMD_CFUNC simd_double3 __tg_fmax(simd_double3 x, simd_double3 y) {
2074 return simd_make_double3(__tg_fmax(simd_make_double4_undef(x), simd_make_double4_undef(y)));
2075}
2076
2077static SIMD_CFUNC simd_double4 __tg_fmax(simd_double4 x, simd_double4 y) {
2078#if defined __AVX512DQ__ && defined __AVX512VL__
2079 return _mm256_range_pd(x, y, 5);
2080#elif defined __AVX__ && __FINITE_MATH_ONLY__
2081 return _mm256_max_pd(x, y);
2082#elif defined __AVX__
2083 return simd_bitselect(_mm256_max_pd(x, y), x, y != y);
2084#else
2085 return simd_make_double4(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi));
2086#endif
2087}
2088
2089static SIMD_CFUNC simd_double8 __tg_fmax(simd_double8 x, simd_double8 y) {
2090#if defined __x86_64__ && defined __AVX512DQ__
2091 return _mm512_range_pd(x, y, 5);
2092#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__
2093 return _mm512_max_pd(x, y);
2094#elif defined __x86_64__ && defined __AVX512F__
2095 return simd_bitselect(_mm512_max_pd(x, y), x, y != y);
2096#else
2097 return simd_make_double8(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi));
2098#endif
2099}
2100
2101#pragma mark - copysign implementation
2102static inline SIMD_CFUNC simd_float2 __tg_copysign(simd_float2 x, simd_float2 y) { return simd_bitselect(y, x, 0x7fffffff); }
2103static inline SIMD_CFUNC simd_float3 __tg_copysign(simd_float3 x, simd_float3 y) { return simd_bitselect(y, x, 0x7fffffff); }
2104static inline SIMD_CFUNC simd_float4 __tg_copysign(simd_float4 x, simd_float4 y) { return simd_bitselect(y, x, 0x7fffffff); }
2105static inline SIMD_CFUNC simd_float8 __tg_copysign(simd_float8 x, simd_float8 y) { return simd_bitselect(y, x, 0x7fffffff); }
2106static inline SIMD_CFUNC simd_float16 __tg_copysign(simd_float16 x, simd_float16 y) { return simd_bitselect(y, x, 0x7fffffff); }
2107static inline SIMD_CFUNC simd_double2 __tg_copysign(simd_double2 x, simd_double2 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); }
2108static inline SIMD_CFUNC simd_double3 __tg_copysign(simd_double3 x, simd_double3 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); }
2109static inline SIMD_CFUNC simd_double4 __tg_copysign(simd_double4 x, simd_double4 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); }
2110static inline SIMD_CFUNC simd_double8 __tg_copysign(simd_double8 x, simd_double8 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); }
2111
2112#pragma mark - sqrt implementation
2113static SIMD_CFUNC simd_float2 __tg_sqrt(simd_float2 x) {
2114#if defined __SSE2__
2115 return simd_make_float2(__tg_sqrt(simd_make_float4_undef(x)));
2116#elif defined __arm64__
2117 return vsqrt_f32(x);
2118#else
2119 return simd_make_float2(sqrt(x.x), sqrt(x.y));
2120#endif
2121}
2122
2123static SIMD_CFUNC simd_float3 __tg_sqrt(simd_float3 x) {
2124 return simd_make_float3(__tg_sqrt(simd_make_float4_undef(x)));
2125}
2126
2127static SIMD_CFUNC simd_float4 __tg_sqrt(simd_float4 x) {
2128#if defined __SSE2__
2129 return _mm_sqrt_ps(x);
2130#elif defined __arm64__
2131 return vsqrtq_f32(x);
2132#else
2133 return simd_make_float4(__tg_sqrt(x.lo), __tg_sqrt(x.hi));
2134#endif
2135}
2136
2137static SIMD_CFUNC simd_float8 __tg_sqrt(simd_float8 x) {
2138#if defined __AVX__
2139 return _mm256_sqrt_ps(x);
2140#else
2141 return simd_make_float8(__tg_sqrt(x.lo), __tg_sqrt(x.hi));
2142#endif
2143}
2144
2145static SIMD_CFUNC simd_float16 __tg_sqrt(simd_float16 x) {
2146#if defined __x86_64__ && defined __AVX512F__
2147 return _mm512_sqrt_ps(x);
2148#else
2149 return simd_make_float16(__tg_sqrt(x.lo), __tg_sqrt(x.hi));
2150#endif
2151}
2152
2153static SIMD_CFUNC simd_double2 __tg_sqrt(simd_double2 x) {
2154#if defined __SSE2__
2155 return _mm_sqrt_pd(x);
2156#elif defined __arm64__
2157 return vsqrtq_f64(x);
2158#else
2159 return simd_make_double2(sqrt(x.x), sqrt(x.y));
2160#endif
2161}
2162
2163static SIMD_CFUNC simd_double3 __tg_sqrt(simd_double3 x) {
2164 return simd_make_double3(__tg_sqrt(simd_make_double4_undef(x)));
2165}
2166
2167static SIMD_CFUNC simd_double4 __tg_sqrt(simd_double4 x) {
2168#if defined __AVX__
2169 return _mm256_sqrt_pd(x);
2170#else
2171 return simd_make_double4(__tg_sqrt(x.lo), __tg_sqrt(x.hi));
2172#endif
2173}
2174
2175static SIMD_CFUNC simd_double8 __tg_sqrt(simd_double8 x) {
2176#if defined __x86_64__ && defined __AVX512F__
2177 return _mm512_sqrt_pd(x);
2178#else
2179 return simd_make_double8(__tg_sqrt(x.lo), __tg_sqrt(x.hi));
2180#endif
2181}
2182
2183#pragma mark - ceil, floor, rint, trunc implementation
2184static SIMD_CFUNC simd_float2 __tg_ceil(simd_float2 x) {
2185#if defined __arm64__
2186 return vrndp_f32(x);
2187#else
2188 return simd_make_float2(__tg_ceil(simd_make_float4_undef(x)));
2189#endif
2190}
2191
2192static SIMD_CFUNC simd_float3 __tg_ceil(simd_float3 x) {
2193 return simd_make_float3(__tg_ceil(simd_make_float4_undef(x)));
2194}
2195
2196#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2197extern simd_float4 _simd_ceil_f4(simd_float4 x);
2198#endif
2199
2200static SIMD_CFUNC simd_float4 __tg_ceil(simd_float4 x) {
2201#if defined __SSE4_1__
2202 return _mm_round_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC);
2203#elif defined __arm64__
2204 return vrndpq_f32(x);
2205#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2206 return _simd_ceil_f4(x);
2207#else
2208 simd_float4 truncated = __tg_trunc(x);
2209 simd_float4 adjust = simd_bitselect((simd_float4)0, 1, truncated < x);
2210 return __tg_copysign(truncated + adjust, x);
2211#endif
2212}
2213
2214static SIMD_CFUNC simd_float8 __tg_ceil(simd_float8 x) {
2215#if defined __AVX__
2216 return _mm256_round_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC);
2217#else
2218 return simd_make_float8(__tg_ceil(x.lo), __tg_ceil(x.hi));
2219#endif
2220}
2221
2222static SIMD_CFUNC simd_float16 __tg_ceil(simd_float16 x) {
2223#if defined __x86_64__ && defined __AVX512F__
2224 return _mm512_roundscale_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC);
2225#else
2226 return simd_make_float16(__tg_ceil(x.lo), __tg_ceil(x.hi));
2227#endif
2228}
2229
2230#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2231extern simd_double2 _simd_ceil_d2(simd_double2 x);
2232#endif
2233
2234static SIMD_CFUNC simd_double2 __tg_ceil(simd_double2 x) {
2235#if defined __SSE4_1__
2236 return _mm_round_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC);
2237#elif defined __arm64__
2238 return vrndpq_f64(x);
2239#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2240 return _simd_ceil_d2(x);
2241#else
2242 simd_double2 truncated = __tg_trunc(x);
2243 simd_double2 adjust = simd_bitselect((simd_double2)0, 1, truncated < x);
2244 return __tg_copysign(truncated + adjust, x);
2245#endif
2246}
2247
2248static SIMD_CFUNC simd_double3 __tg_ceil(simd_double3 x) {
2249 return simd_make_double3(__tg_ceil(simd_make_double4_undef(x)));
2250}
2251
2252static SIMD_CFUNC simd_double4 __tg_ceil(simd_double4 x) {
2253#if defined __AVX__
2254 return _mm256_round_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC);
2255#else
2256 return simd_make_double4(__tg_ceil(x.lo), __tg_ceil(x.hi));
2257#endif
2258}
2259
2260static SIMD_CFUNC simd_double8 __tg_ceil(simd_double8 x) {
2261#if defined __x86_64__ && defined __AVX512F__
2262 return _mm512_roundscale_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC);
2263#else
2264 return simd_make_double8(__tg_ceil(x.lo), __tg_ceil(x.hi));
2265#endif
2266}
2267
2268static SIMD_CFUNC simd_float2 __tg_floor(simd_float2 x) {
2269#if defined __arm64__
2270 return vrndm_f32(x);
2271#else
2272 return simd_make_float2(__tg_floor(simd_make_float4_undef(x)));
2273#endif
2274}
2275
2276static SIMD_CFUNC simd_float3 __tg_floor(simd_float3 x) {
2277 return simd_make_float3(__tg_floor(simd_make_float4_undef(x)));
2278}
2279
2280#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2281extern simd_float4 _simd_floor_f4(simd_float4 x);
2282#endif
2283
2284static SIMD_CFUNC simd_float4 __tg_floor(simd_float4 x) {
2285#if defined __SSE4_1__
2286 return _mm_round_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
2287#elif defined __arm64__
2288 return vrndmq_f32(x);
2289#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2290 return _simd_floor_f4(x);
2291#else
2292 simd_float4 truncated = __tg_trunc(x);
2293 simd_float4 adjust = simd_bitselect((simd_float4)0, 1, truncated > x);
2294 return truncated - adjust;
2295#endif
2296}
2297
2298static SIMD_CFUNC simd_float8 __tg_floor(simd_float8 x) {
2299#if defined __AVX__
2300 return _mm256_round_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
2301#else
2302 return simd_make_float8(__tg_floor(x.lo), __tg_floor(x.hi));
2303#endif
2304}
2305
2306static SIMD_CFUNC simd_float16 __tg_floor(simd_float16 x) {
2307#if defined __x86_64__ && defined __AVX512F__
2308 return _mm512_roundscale_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
2309#else
2310 return simd_make_float16(__tg_floor(x.lo), __tg_floor(x.hi));
2311#endif
2312}
2313
2314#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2315extern simd_double2 _simd_floor_d2(simd_double2 x);
2316#endif
2317
2318static SIMD_CFUNC simd_double2 __tg_floor(simd_double2 x) {
2319#if defined __SSE4_1__
2320 return _mm_round_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
2321#elif defined __arm64__
2322 return vrndmq_f64(x);
2323#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2324 return _simd_floor_d2(x);
2325#else
2326 simd_double2 truncated = __tg_trunc(x);
2327 simd_double2 adjust = simd_bitselect((simd_double2)0, 1, truncated > x);
2328 return truncated - adjust;
2329#endif
2330}
2331
2332static SIMD_CFUNC simd_double3 __tg_floor(simd_double3 x) {
2333 return simd_make_double3(__tg_floor(simd_make_double4_undef(x)));
2334}
2335
2336static SIMD_CFUNC simd_double4 __tg_floor(simd_double4 x) {
2337#if defined __AVX__
2338 return _mm256_round_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
2339#else
2340 return simd_make_double4(__tg_floor(x.lo), __tg_floor(x.hi));
2341#endif
2342}
2343
2344static SIMD_CFUNC simd_double8 __tg_floor(simd_double8 x) {
2345#if defined __x86_64__ && defined __AVX512F__
2346 return _mm512_roundscale_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
2347#else
2348 return simd_make_double8(__tg_floor(x.lo), __tg_floor(x.hi));
2349#endif
2350}
2351
2352static SIMD_CFUNC simd_float2 __tg_rint(simd_float2 x) {
2353#if defined __arm64__
2354 return vrndx_f32(x);
2355#else
2356 return simd_make_float2(__tg_rint(simd_make_float4_undef(x)));
2357#endif
2358}
2359
2360static SIMD_CFUNC simd_float3 __tg_rint(simd_float3 x) {
2361 return simd_make_float3(__tg_rint(simd_make_float4_undef(x)));
2362}
2363
2364#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2365extern simd_float4 _simd_rint_f4(simd_float4 x);
2366#endif
2367
2368static SIMD_CFUNC simd_float4 __tg_rint(simd_float4 x) {
2369#if defined __SSE4_1__
2370 return _mm_round_ps(x, _MM_FROUND_RINT);
2371#elif defined __arm64__
2372 return vrndxq_f32(x);
2373#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2374 return _simd_rint_f4(x);
2375#else
2376 simd_float4 magic = __tg_copysign(0x1.0p23, x);
2377 simd_int4 x_is_small = __tg_fabs(x) < 0x1.0p23;
2378 return simd_bitselect(x, (x + magic) - magic, x_is_small & 0x7fffffff);
2379#endif
2380}
2381
2382static SIMD_CFUNC simd_float8 __tg_rint(simd_float8 x) {
2383#if defined __AVX__
2384 return _mm256_round_ps(x, _MM_FROUND_RINT);
2385#else
2386 return simd_make_float8(__tg_rint(x.lo), __tg_rint(x.hi));
2387#endif
2388}
2389
2390static SIMD_CFUNC simd_float16 __tg_rint(simd_float16 x) {
2391#if defined __x86_64__ && defined __AVX512F__
2392 return _mm512_roundscale_ps(x, _MM_FROUND_RINT);
2393#else
2394 return simd_make_float16(__tg_rint(x.lo), __tg_rint(x.hi));
2395#endif
2396}
2397
2398#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2399extern simd_double2 _simd_rint_d2(simd_double2 x);
2400#endif
2401
2402static SIMD_CFUNC simd_double2 __tg_rint(simd_double2 x) {
2403#if defined __SSE4_1__
2404 return _mm_round_pd(x, _MM_FROUND_RINT);
2405#elif defined __arm64__
2406 return vrndxq_f64(x);
2407#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2408 return _simd_rint_d2(x);
2409#else
2410 simd_double2 magic = __tg_copysign(0x1.0p52, x);
2411 simd_long2 x_is_small = __tg_fabs(x) < 0x1.0p52;
2412 return simd_bitselect(x, (x + magic) - magic, x_is_small & 0x7fffffffffffffff);
2413#endif
2414}
2415
2416static SIMD_CFUNC simd_double3 __tg_rint(simd_double3 x) {
2417 return simd_make_double3(__tg_rint(simd_make_double4_undef(x)));
2418}
2419
2420static SIMD_CFUNC simd_double4 __tg_rint(simd_double4 x) {
2421#if defined __AVX__
2422 return _mm256_round_pd(x, _MM_FROUND_RINT);
2423#else
2424 return simd_make_double4(__tg_rint(x.lo), __tg_rint(x.hi));
2425#endif
2426}
2427
2428static SIMD_CFUNC simd_double8 __tg_rint(simd_double8 x) {
2429#if defined __x86_64__ && defined __AVX512F__
2430 return _mm512_roundscale_pd(x, _MM_FROUND_RINT);
2431#else
2432 return simd_make_double8(__tg_rint(x.lo), __tg_rint(x.hi));
2433#endif
2434}
2435
2436static SIMD_CFUNC simd_float2 __tg_trunc(simd_float2 x) {
2437#if defined __arm64__
2438 return vrnd_f32(x);
2439#else
2440 return simd_make_float2(__tg_trunc(simd_make_float4_undef(x)));
2441#endif
2442}
2443
2444static SIMD_CFUNC simd_float3 __tg_trunc(simd_float3 x) {
2445 return simd_make_float3(__tg_trunc(simd_make_float4_undef(x)));
2446}
2447
2448#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2449extern simd_float4 _simd_trunc_f4(simd_float4 x);
2450#endif
2451
2452static SIMD_CFUNC simd_float4 __tg_trunc(simd_float4 x) {
2453#if defined __SSE4_1__
2454 return _mm_round_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
2455#elif defined __arm64__
2456 return vrndq_f32(x);
2457#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2458 return _simd_trunc_f4(x);
2459#else
2460 simd_float4 binade = simd_bitselect(0, x, 0x7f800000);
2461 simd_int4 mask = (simd_int4)__tg_fmin(-2*binade + 1, -0);
2462 simd_float4 result = simd_bitselect(0, x, mask);
2463 return simd_bitselect(x, result, binade < 0x1.0p23);
2464#endif
2465}
2466
2467static SIMD_CFUNC simd_float8 __tg_trunc(simd_float8 x) {
2468#if defined __AVX__
2469 return _mm256_round_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
2470#else
2471 return simd_make_float8(__tg_trunc(x.lo), __tg_trunc(x.hi));
2472#endif
2473}
2474
2475static SIMD_CFUNC simd_float16 __tg_trunc(simd_float16 x) {
2476#if defined __x86_64__ && defined __AVX512F__
2477 return _mm512_roundscale_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
2478#else
2479 return simd_make_float16(__tg_trunc(x.lo), __tg_trunc(x.hi));
2480#endif
2481}
2482
2483#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2484extern simd_double2 _simd_trunc_d2(simd_double2 x);
2485#endif
2486
2487static SIMD_CFUNC simd_double2 __tg_trunc(simd_double2 x) {
2488#if defined __SSE4_1__
2489 return _mm_round_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
2490#elif defined __arm64__
2491 return vrndq_f64(x);
2492#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3
2493 return _simd_trunc_d2(x);
2494#else
2495 simd_double2 binade = simd_bitselect(0, x, 0x7ff0000000000000);
2496 simd_long2 mask = (simd_long2)__tg_fmin(-2*binade + 1, -0);
2497 simd_double2 result = simd_bitselect(0, x, mask);
2498 return simd_bitselect(x, result, binade < 0x1.0p52);
2499#endif
2500}
2501
2502static SIMD_CFUNC simd_double3 __tg_trunc(simd_double3 x) {
2503 return simd_make_double3(__tg_trunc(simd_make_double4_undef(x)));
2504}
2505
2506static SIMD_CFUNC simd_double4 __tg_trunc(simd_double4 x) {
2507#if defined __AVX__
2508 return _mm256_round_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
2509#else
2510 return simd_make_double4(__tg_trunc(x.lo), __tg_trunc(x.hi));
2511#endif
2512}
2513
2514static SIMD_CFUNC simd_double8 __tg_trunc(simd_double8 x) {
2515#if defined __x86_64__ && defined __AVX512F__
2516 return _mm512_roundscale_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
2517#else
2518 return simd_make_double8(__tg_trunc(x.lo), __tg_trunc(x.hi));
2519#endif
2520}
2521
2522#pragma mark - sine, cosine implementation
2523static inline SIMD_CFUNC simd_float2 __tg_sin(simd_float2 x) {
2524 return simd_make_float2(__tg_sin(simd_make_float4(x)));
2525}
2526
2527static inline SIMD_CFUNC simd_float3 __tg_sin(simd_float3 x) {
2528 return simd_make_float3(__tg_sin(simd_make_float4(x)));
2529}
2530
2531#if SIMD_LIBRARY_VERSION >= 3
2532extern simd_float4 _simd_sin_f4(simd_float4 x);
2533static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) {
2534 return _simd_sin_f4(x);
2535}
2536#elif SIMD_LIBRARY_VERSION == 1
2537extern simd_float4 __sin_f4(simd_float4 x);
2538static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) {
2539 return __sin_f4(x);
2540}
2541#else
2542static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) {
2543 return simd_make_float4(sin(x.x), sin(x.y), sin(x.z), sin(x.w));
2544}
2545#endif
2546
2547#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2548extern simd_float8 _simd_sin_f8(simd_float8 x);
2549static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x) {
2550 return _simd_sin_f8(x);
2551}
2552#else
2553static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x) {
2554 return simd_make_float8(__tg_sin(x.lo), __tg_sin(x.hi));
2555}
2556#endif
2557
2558#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2559extern simd_float16 _simd_sin_f16(simd_float16 x);
2560static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x) {
2561 return _simd_sin_f16(x);
2562}
2563#else
2564static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x) {
2565 return simd_make_float16(__tg_sin(x.lo), __tg_sin(x.hi));
2566}
2567#endif
2568
2569#if SIMD_LIBRARY_VERSION >= 3
2570extern simd_double2 _simd_sin_d2(simd_double2 x);
2571static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) {
2572 return _simd_sin_d2(x);
2573}
2574#elif SIMD_LIBRARY_VERSION == 1
2575extern simd_double2 __sin_d2(simd_double2 x);
2576static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) {
2577 return __sin_d2(x);
2578}
2579#else
2580static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) {
2581 return simd_make_double2(sin(x.x), sin(x.y));
2582}
2583#endif
2584
2585static inline SIMD_CFUNC simd_double3 __tg_sin(simd_double3 x) {
2586 return simd_make_double3(__tg_sin(simd_make_double4(x)));
2587}
2588
2589#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2590extern simd_double4 _simd_sin_d4(simd_double4 x);
2591static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x) {
2592 return _simd_sin_d4(x);
2593}
2594#else
2595static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x) {
2596 return simd_make_double4(__tg_sin(x.lo), __tg_sin(x.hi));
2597}
2598#endif
2599
2600#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2601extern simd_double8 _simd_sin_d8(simd_double8 x);
2602static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x) {
2603 return _simd_sin_d8(x);
2604}
2605#else
2606static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x) {
2607 return simd_make_double8(__tg_sin(x.lo), __tg_sin(x.hi));
2608}
2609#endif
2610
2611static inline SIMD_CFUNC simd_float2 __tg_cos(simd_float2 x) {
2612 return simd_make_float2(__tg_cos(simd_make_float4(x)));
2613}
2614
2615static inline SIMD_CFUNC simd_float3 __tg_cos(simd_float3 x) {
2616 return simd_make_float3(__tg_cos(simd_make_float4(x)));
2617}
2618
2619#if SIMD_LIBRARY_VERSION >= 3
2620extern simd_float4 _simd_cos_f4(simd_float4 x);
2621static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) {
2622 return _simd_cos_f4(x);
2623}
2624#elif SIMD_LIBRARY_VERSION == 1
2625extern simd_float4 __cos_f4(simd_float4 x);
2626static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) {
2627 return __cos_f4(x);
2628}
2629#else
2630static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) {
2631 return simd_make_float4(cos(x.x), cos(x.y), cos(x.z), cos(x.w));
2632}
2633#endif
2634
2635#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2636extern simd_float8 _simd_cos_f8(simd_float8 x);
2637static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x) {
2638 return _simd_cos_f8(x);
2639}
2640#else
2641static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x) {
2642 return simd_make_float8(__tg_cos(x.lo), __tg_cos(x.hi));
2643}
2644#endif
2645
2646#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2647extern simd_float16 _simd_cos_f16(simd_float16 x);
2648static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x) {
2649 return _simd_cos_f16(x);
2650}
2651#else
2652static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x) {
2653 return simd_make_float16(__tg_cos(x.lo), __tg_cos(x.hi));
2654}
2655#endif
2656
2657#if SIMD_LIBRARY_VERSION >= 3
2658extern simd_double2 _simd_cos_d2(simd_double2 x);
2659static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) {
2660 return _simd_cos_d2(x);
2661}
2662#elif SIMD_LIBRARY_VERSION == 1
2663extern simd_double2 __cos_d2(simd_double2 x);
2664static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) {
2665 return __cos_d2(x);
2666}
2667#else
2668static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) {
2669 return simd_make_double2(cos(x.x), cos(x.y));
2670}
2671#endif
2672
2673static inline SIMD_CFUNC simd_double3 __tg_cos(simd_double3 x) {
2674 return simd_make_double3(__tg_cos(simd_make_double4(x)));
2675}
2676
2677#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2678extern simd_double4 _simd_cos_d4(simd_double4 x);
2679static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x) {
2680 return _simd_cos_d4(x);
2681}
2682#else
2683static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x) {
2684 return simd_make_double4(__tg_cos(x.lo), __tg_cos(x.hi));
2685}
2686#endif
2687
2688#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2689extern simd_double8 _simd_cos_d8(simd_double8 x);
2690static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x) {
2691 return _simd_cos_d8(x);
2692}
2693#else
2694static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x) {
2695 return simd_make_double8(__tg_cos(x.lo), __tg_cos(x.hi));
2696}
2697#endif
2698
2699
2700#pragma mark - acos implementation
2701static inline SIMD_CFUNC simd_float2 __tg_acos(simd_float2 x) {
2702 return simd_make_float2(__tg_acos(simd_make_float4(x)));
2703}
2704
2705static inline SIMD_CFUNC simd_float3 __tg_acos(simd_float3 x) {
2706 return simd_make_float3(__tg_acos(simd_make_float4(x)));
2707}
2708
2709#if SIMD_LIBRARY_VERSION >= 3
2710extern simd_float4 _simd_acos_f4(simd_float4 x);
2711static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x) {
2712 return _simd_acos_f4(x);
2713}
2714#else
2715static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x) {
2716 return simd_make_float4(acos(x.x), acos(x.y), acos(x.z), acos(x.w));
2717}
2718#endif
2719
2720#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2721extern simd_float8 _simd_acos_f8(simd_float8 x);
2722static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x) {
2723 return _simd_acos_f8(x);
2724}
2725#else
2726static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x) {
2727 return simd_make_float8(__tg_acos(x.lo), __tg_acos(x.hi));
2728}
2729#endif
2730
2731#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2732extern simd_float16 _simd_acos_f16(simd_float16 x);
2733static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x) {
2734 return _simd_acos_f16(x);
2735}
2736#else
2737static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x) {
2738 return simd_make_float16(__tg_acos(x.lo), __tg_acos(x.hi));
2739}
2740#endif
2741
2742#if SIMD_LIBRARY_VERSION >= 3
2743extern simd_double2 _simd_acos_d2(simd_double2 x);
2744static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x) {
2745 return _simd_acos_d2(x);
2746}
2747#else
2748static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x) {
2749 return simd_make_double2(acos(x.x), acos(x.y));
2750}
2751#endif
2752
2753static inline SIMD_CFUNC simd_double3 __tg_acos(simd_double3 x) {
2754 return simd_make_double3(__tg_acos(simd_make_double4(x)));
2755}
2756
2757#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2758extern simd_double4 _simd_acos_d4(simd_double4 x);
2759static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x) {
2760 return _simd_acos_d4(x);
2761}
2762#else
2763static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x) {
2764 return simd_make_double4(__tg_acos(x.lo), __tg_acos(x.hi));
2765}
2766#endif
2767
2768#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2769extern simd_double8 _simd_acos_d8(simd_double8 x);
2770static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x) {
2771 return _simd_acos_d8(x);
2772}
2773#else
2774static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x) {
2775 return simd_make_double8(__tg_acos(x.lo), __tg_acos(x.hi));
2776}
2777#endif
2778
2779#pragma mark - asin implementation
2780static inline SIMD_CFUNC simd_float2 __tg_asin(simd_float2 x) {
2781 return simd_make_float2(__tg_asin(simd_make_float4(x)));
2782}
2783
2784static inline SIMD_CFUNC simd_float3 __tg_asin(simd_float3 x) {
2785 return simd_make_float3(__tg_asin(simd_make_float4(x)));
2786}
2787
2788#if SIMD_LIBRARY_VERSION >= 3
2789extern simd_float4 _simd_asin_f4(simd_float4 x);
2790static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x) {
2791 return _simd_asin_f4(x);
2792}
2793#else
2794static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x) {
2795 return simd_make_float4(asin(x.x), asin(x.y), asin(x.z), asin(x.w));
2796}
2797#endif
2798
2799#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2800extern simd_float8 _simd_asin_f8(simd_float8 x);
2801static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x) {
2802 return _simd_asin_f8(x);
2803}
2804#else
2805static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x) {
2806 return simd_make_float8(__tg_asin(x.lo), __tg_asin(x.hi));
2807}
2808#endif
2809
2810#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2811extern simd_float16 _simd_asin_f16(simd_float16 x);
2812static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x) {
2813 return _simd_asin_f16(x);
2814}
2815#else
2816static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x) {
2817 return simd_make_float16(__tg_asin(x.lo), __tg_asin(x.hi));
2818}
2819#endif
2820
2821#if SIMD_LIBRARY_VERSION >= 3
2822extern simd_double2 _simd_asin_d2(simd_double2 x);
2823static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x) {
2824 return _simd_asin_d2(x);
2825}
2826#else
2827static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x) {
2828 return simd_make_double2(asin(x.x), asin(x.y));
2829}
2830#endif
2831
2832static inline SIMD_CFUNC simd_double3 __tg_asin(simd_double3 x) {
2833 return simd_make_double3(__tg_asin(simd_make_double4(x)));
2834}
2835
2836#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2837extern simd_double4 _simd_asin_d4(simd_double4 x);
2838static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x) {
2839 return _simd_asin_d4(x);
2840}
2841#else
2842static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x) {
2843 return simd_make_double4(__tg_asin(x.lo), __tg_asin(x.hi));
2844}
2845#endif
2846
2847#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2848extern simd_double8 _simd_asin_d8(simd_double8 x);
2849static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x) {
2850 return _simd_asin_d8(x);
2851}
2852#else
2853static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x) {
2854 return simd_make_double8(__tg_asin(x.lo), __tg_asin(x.hi));
2855}
2856#endif
2857
2858#pragma mark - atan implementation
2859static inline SIMD_CFUNC simd_float2 __tg_atan(simd_float2 x) {
2860 return simd_make_float2(__tg_atan(simd_make_float4(x)));
2861}
2862
2863static inline SIMD_CFUNC simd_float3 __tg_atan(simd_float3 x) {
2864 return simd_make_float3(__tg_atan(simd_make_float4(x)));
2865}
2866
2867#if SIMD_LIBRARY_VERSION >= 3
2868extern simd_float4 _simd_atan_f4(simd_float4 x);
2869static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x) {
2870 return _simd_atan_f4(x);
2871}
2872#else
2873static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x) {
2874 return simd_make_float4(atan(x.x), atan(x.y), atan(x.z), atan(x.w));
2875}
2876#endif
2877
2878#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2879extern simd_float8 _simd_atan_f8(simd_float8 x);
2880static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x) {
2881 return _simd_atan_f8(x);
2882}
2883#else
2884static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x) {
2885 return simd_make_float8(__tg_atan(x.lo), __tg_atan(x.hi));
2886}
2887#endif
2888
2889#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2890extern simd_float16 _simd_atan_f16(simd_float16 x);
2891static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x) {
2892 return _simd_atan_f16(x);
2893}
2894#else
2895static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x) {
2896 return simd_make_float16(__tg_atan(x.lo), __tg_atan(x.hi));
2897}
2898#endif
2899
2900#if SIMD_LIBRARY_VERSION >= 3
2901extern simd_double2 _simd_atan_d2(simd_double2 x);
2902static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x) {
2903 return _simd_atan_d2(x);
2904}
2905#else
2906static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x) {
2907 return simd_make_double2(atan(x.x), atan(x.y));
2908}
2909#endif
2910
2911static inline SIMD_CFUNC simd_double3 __tg_atan(simd_double3 x) {
2912 return simd_make_double3(__tg_atan(simd_make_double4(x)));
2913}
2914
2915#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2916extern simd_double4 _simd_atan_d4(simd_double4 x);
2917static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x) {
2918 return _simd_atan_d4(x);
2919}
2920#else
2921static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x) {
2922 return simd_make_double4(__tg_atan(x.lo), __tg_atan(x.hi));
2923}
2924#endif
2925
2926#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2927extern simd_double8 _simd_atan_d8(simd_double8 x);
2928static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x) {
2929 return _simd_atan_d8(x);
2930}
2931#else
2932static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x) {
2933 return simd_make_double8(__tg_atan(x.lo), __tg_atan(x.hi));
2934}
2935#endif
2936
2937#pragma mark - tan implementation
2938static inline SIMD_CFUNC simd_float2 __tg_tan(simd_float2 x) {
2939 return simd_make_float2(__tg_tan(simd_make_float4(x)));
2940}
2941
2942static inline SIMD_CFUNC simd_float3 __tg_tan(simd_float3 x) {
2943 return simd_make_float3(__tg_tan(simd_make_float4(x)));
2944}
2945
2946#if SIMD_LIBRARY_VERSION >= 3
2947extern simd_float4 _simd_tan_f4(simd_float4 x);
2948static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x) {
2949 return _simd_tan_f4(x);
2950}
2951#else
2952static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x) {
2953 return simd_make_float4(tan(x.x), tan(x.y), tan(x.z), tan(x.w));
2954}
2955#endif
2956
2957#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2958extern simd_float8 _simd_tan_f8(simd_float8 x);
2959static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x) {
2960 return _simd_tan_f8(x);
2961}
2962#else
2963static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x) {
2964 return simd_make_float8(__tg_tan(x.lo), __tg_tan(x.hi));
2965}
2966#endif
2967
2968#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
2969extern simd_float16 _simd_tan_f16(simd_float16 x);
2970static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x) {
2971 return _simd_tan_f16(x);
2972}
2973#else
2974static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x) {
2975 return simd_make_float16(__tg_tan(x.lo), __tg_tan(x.hi));
2976}
2977#endif
2978
2979#if SIMD_LIBRARY_VERSION >= 3
2980extern simd_double2 _simd_tan_d2(simd_double2 x);
2981static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x) {
2982 return _simd_tan_d2(x);
2983}
2984#else
2985static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x) {
2986 return simd_make_double2(tan(x.x), tan(x.y));
2987}
2988#endif
2989
2990static inline SIMD_CFUNC simd_double3 __tg_tan(simd_double3 x) {
2991 return simd_make_double3(__tg_tan(simd_make_double4(x)));
2992}
2993
2994#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
2995extern simd_double4 _simd_tan_d4(simd_double4 x);
2996static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x) {
2997 return _simd_tan_d4(x);
2998}
2999#else
3000static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x) {
3001 return simd_make_double4(__tg_tan(x.lo), __tg_tan(x.hi));
3002}
3003#endif
3004
3005#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3006extern simd_double8 _simd_tan_d8(simd_double8 x);
3007static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x) {
3008 return _simd_tan_d8(x);
3009}
3010#else
3011static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x) {
3012 return simd_make_double8(__tg_tan(x.lo), __tg_tan(x.hi));
3013}
3014#endif
3015
3016#pragma mark - cospi implementation
3017#if SIMD_LIBRARY_VERSION >= 1
3018static inline SIMD_CFUNC simd_float2 __tg_cospi(simd_float2 x) {
3019 return simd_make_float2(__tg_cospi(simd_make_float4(x)));
3020}
3021
3022static inline SIMD_CFUNC simd_float3 __tg_cospi(simd_float3 x) {
3023 return simd_make_float3(__tg_cospi(simd_make_float4(x)));
3024}
3025
3026#if SIMD_LIBRARY_VERSION >= 3
3027extern simd_float4 _simd_cospi_f4(simd_float4 x);
3028static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x) {
3029 return _simd_cospi_f4(x);
3030}
3031#else
3032static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x) {
3033 return simd_make_float4(__cospi(x.x), __cospi(x.y), __cospi(x.z), __cospi(x.w));
3034}
3035#endif
3036
3037#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3038extern simd_float8 _simd_cospi_f8(simd_float8 x);
3039static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x) {
3040 return _simd_cospi_f8(x);
3041}
3042#else
3043static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x) {
3044 return simd_make_float8(__tg_cospi(x.lo), __tg_cospi(x.hi));
3045}
3046#endif
3047
3048#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3049extern simd_float16 _simd_cospi_f16(simd_float16 x);
3050static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x) {
3051 return _simd_cospi_f16(x);
3052}
3053#else
3054static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x) {
3055 return simd_make_float16(__tg_cospi(x.lo), __tg_cospi(x.hi));
3056}
3057#endif
3058
3059#if SIMD_LIBRARY_VERSION >= 3
3060extern simd_double2 _simd_cospi_d2(simd_double2 x);
3061static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x) {
3062 return _simd_cospi_d2(x);
3063}
3064#else
3065static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x) {
3066 return simd_make_double2(__cospi(x.x), __cospi(x.y));
3067}
3068#endif
3069
3070static inline SIMD_CFUNC simd_double3 __tg_cospi(simd_double3 x) {
3071 return simd_make_double3(__tg_cospi(simd_make_double4(x)));
3072}
3073
3074#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3075extern simd_double4 _simd_cospi_d4(simd_double4 x);
3076static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x) {
3077 return _simd_cospi_d4(x);
3078}
3079#else
3080static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x) {
3081 return simd_make_double4(__tg_cospi(x.lo), __tg_cospi(x.hi));
3082}
3083#endif
3084
3085#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3086extern simd_double8 _simd_cospi_d8(simd_double8 x);
3087static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x) {
3088 return _simd_cospi_d8(x);
3089}
3090#else
3091static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x) {
3092 return simd_make_double8(__tg_cospi(x.lo), __tg_cospi(x.hi));
3093}
3094#endif
3095
3096#endif /* SIMD_LIBRARY_VERSION */
3097#pragma mark - sinpi implementation
3098#if SIMD_LIBRARY_VERSION >= 1
3099static inline SIMD_CFUNC simd_float2 __tg_sinpi(simd_float2 x) {
3100 return simd_make_float2(__tg_sinpi(simd_make_float4(x)));
3101}
3102
3103static inline SIMD_CFUNC simd_float3 __tg_sinpi(simd_float3 x) {
3104 return simd_make_float3(__tg_sinpi(simd_make_float4(x)));
3105}
3106
3107#if SIMD_LIBRARY_VERSION >= 3
3108extern simd_float4 _simd_sinpi_f4(simd_float4 x);
3109static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x) {
3110 return _simd_sinpi_f4(x);
3111}
3112#else
3113static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x) {
3114 return simd_make_float4(__sinpi(x.x), __sinpi(x.y), __sinpi(x.z), __sinpi(x.w));
3115}
3116#endif
3117
3118#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3119extern simd_float8 _simd_sinpi_f8(simd_float8 x);
3120static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x) {
3121 return _simd_sinpi_f8(x);
3122}
3123#else
3124static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x) {
3125 return simd_make_float8(__tg_sinpi(x.lo), __tg_sinpi(x.hi));
3126}
3127#endif
3128
3129#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3130extern simd_float16 _simd_sinpi_f16(simd_float16 x);
3131static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x) {
3132 return _simd_sinpi_f16(x);
3133}
3134#else
3135static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x) {
3136 return simd_make_float16(__tg_sinpi(x.lo), __tg_sinpi(x.hi));
3137}
3138#endif
3139
3140#if SIMD_LIBRARY_VERSION >= 3
3141extern simd_double2 _simd_sinpi_d2(simd_double2 x);
3142static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x) {
3143 return _simd_sinpi_d2(x);
3144}
3145#else
3146static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x) {
3147 return simd_make_double2(__sinpi(x.x), __sinpi(x.y));
3148}
3149#endif
3150
3151static inline SIMD_CFUNC simd_double3 __tg_sinpi(simd_double3 x) {
3152 return simd_make_double3(__tg_sinpi(simd_make_double4(x)));
3153}
3154
3155#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3156extern simd_double4 _simd_sinpi_d4(simd_double4 x);
3157static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x) {
3158 return _simd_sinpi_d4(x);
3159}
3160#else
3161static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x) {
3162 return simd_make_double4(__tg_sinpi(x.lo), __tg_sinpi(x.hi));
3163}
3164#endif
3165
3166#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3167extern simd_double8 _simd_sinpi_d8(simd_double8 x);
3168static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x) {
3169 return _simd_sinpi_d8(x);
3170}
3171#else
3172static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x) {
3173 return simd_make_double8(__tg_sinpi(x.lo), __tg_sinpi(x.hi));
3174}
3175#endif
3176
3177#endif /* SIMD_LIBRARY_VERSION */
3178#pragma mark - tanpi implementation
3179#if SIMD_LIBRARY_VERSION >= 1
3180static inline SIMD_CFUNC simd_float2 __tg_tanpi(simd_float2 x) {
3181 return simd_make_float2(__tg_tanpi(simd_make_float4(x)));
3182}
3183
3184static inline SIMD_CFUNC simd_float3 __tg_tanpi(simd_float3 x) {
3185 return simd_make_float3(__tg_tanpi(simd_make_float4(x)));
3186}
3187
3188#if SIMD_LIBRARY_VERSION >= 3
3189extern simd_float4 _simd_tanpi_f4(simd_float4 x);
3190static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x) {
3191 return _simd_tanpi_f4(x);
3192}
3193#else
3194static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x) {
3195 return simd_make_float4(__tanpi(x.x), __tanpi(x.y), __tanpi(x.z), __tanpi(x.w));
3196}
3197#endif
3198
3199#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3200extern simd_float8 _simd_tanpi_f8(simd_float8 x);
3201static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x) {
3202 return _simd_tanpi_f8(x);
3203}
3204#else
3205static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x) {
3206 return simd_make_float8(__tg_tanpi(x.lo), __tg_tanpi(x.hi));
3207}
3208#endif
3209
3210#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3211extern simd_float16 _simd_tanpi_f16(simd_float16 x);
3212static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x) {
3213 return _simd_tanpi_f16(x);
3214}
3215#else
3216static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x) {
3217 return simd_make_float16(__tg_tanpi(x.lo), __tg_tanpi(x.hi));
3218}
3219#endif
3220
3221#if SIMD_LIBRARY_VERSION >= 3
3222extern simd_double2 _simd_tanpi_d2(simd_double2 x);
3223static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x) {
3224 return _simd_tanpi_d2(x);
3225}
3226#else
3227static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x) {
3228 return simd_make_double2(__tanpi(x.x), __tanpi(x.y));
3229}
3230#endif
3231
3232static inline SIMD_CFUNC simd_double3 __tg_tanpi(simd_double3 x) {
3233 return simd_make_double3(__tg_tanpi(simd_make_double4(x)));
3234}
3235
3236#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3237extern simd_double4 _simd_tanpi_d4(simd_double4 x);
3238static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x) {
3239 return _simd_tanpi_d4(x);
3240}
3241#else
3242static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x) {
3243 return simd_make_double4(__tg_tanpi(x.lo), __tg_tanpi(x.hi));
3244}
3245#endif
3246
3247#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3248extern simd_double8 _simd_tanpi_d8(simd_double8 x);
3249static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x) {
3250 return _simd_tanpi_d8(x);
3251}
3252#else
3253static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x) {
3254 return simd_make_double8(__tg_tanpi(x.lo), __tg_tanpi(x.hi));
3255}
3256#endif
3257
3258#endif /* SIMD_LIBRARY_VERSION */
3259#pragma mark - acosh implementation
3260static inline SIMD_CFUNC simd_float2 __tg_acosh(simd_float2 x) {
3261 return simd_make_float2(__tg_acosh(simd_make_float4(x)));
3262}
3263
3264static inline SIMD_CFUNC simd_float3 __tg_acosh(simd_float3 x) {
3265 return simd_make_float3(__tg_acosh(simd_make_float4(x)));
3266}
3267
3268#if SIMD_LIBRARY_VERSION >= 3
3269extern simd_float4 _simd_acosh_f4(simd_float4 x);
3270static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x) {
3271 return _simd_acosh_f4(x);
3272}
3273#else
3274static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x) {
3275 return simd_make_float4(acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w));
3276}
3277#endif
3278
3279#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3280extern simd_float8 _simd_acosh_f8(simd_float8 x);
3281static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x) {
3282 return _simd_acosh_f8(x);
3283}
3284#else
3285static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x) {
3286 return simd_make_float8(__tg_acosh(x.lo), __tg_acosh(x.hi));
3287}
3288#endif
3289
3290#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3291extern simd_float16 _simd_acosh_f16(simd_float16 x);
3292static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x) {
3293 return _simd_acosh_f16(x);
3294}
3295#else
3296static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x) {
3297 return simd_make_float16(__tg_acosh(x.lo), __tg_acosh(x.hi));
3298}
3299#endif
3300
3301#if SIMD_LIBRARY_VERSION >= 3
3302extern simd_double2 _simd_acosh_d2(simd_double2 x);
3303static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x) {
3304 return _simd_acosh_d2(x);
3305}
3306#else
3307static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x) {
3308 return simd_make_double2(acosh(x.x), acosh(x.y));
3309}
3310#endif
3311
3312static inline SIMD_CFUNC simd_double3 __tg_acosh(simd_double3 x) {
3313 return simd_make_double3(__tg_acosh(simd_make_double4(x)));
3314}
3315
3316#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3317extern simd_double4 _simd_acosh_d4(simd_double4 x);
3318static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x) {
3319 return _simd_acosh_d4(x);
3320}
3321#else
3322static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x) {
3323 return simd_make_double4(__tg_acosh(x.lo), __tg_acosh(x.hi));
3324}
3325#endif
3326
3327#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3328extern simd_double8 _simd_acosh_d8(simd_double8 x);
3329static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x) {
3330 return _simd_acosh_d8(x);
3331}
3332#else
3333static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x) {
3334 return simd_make_double8(__tg_acosh(x.lo), __tg_acosh(x.hi));
3335}
3336#endif
3337
3338#pragma mark - asinh implementation
3339static inline SIMD_CFUNC simd_float2 __tg_asinh(simd_float2 x) {
3340 return simd_make_float2(__tg_asinh(simd_make_float4(x)));
3341}
3342
3343static inline SIMD_CFUNC simd_float3 __tg_asinh(simd_float3 x) {
3344 return simd_make_float3(__tg_asinh(simd_make_float4(x)));
3345}
3346
3347#if SIMD_LIBRARY_VERSION >= 3
3348extern simd_float4 _simd_asinh_f4(simd_float4 x);
3349static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x) {
3350 return _simd_asinh_f4(x);
3351}
3352#else
3353static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x) {
3354 return simd_make_float4(asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w));
3355}
3356#endif
3357
3358#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3359extern simd_float8 _simd_asinh_f8(simd_float8 x);
3360static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x) {
3361 return _simd_asinh_f8(x);
3362}
3363#else
3364static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x) {
3365 return simd_make_float8(__tg_asinh(x.lo), __tg_asinh(x.hi));
3366}
3367#endif
3368
3369#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3370extern simd_float16 _simd_asinh_f16(simd_float16 x);
3371static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x) {
3372 return _simd_asinh_f16(x);
3373}
3374#else
3375static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x) {
3376 return simd_make_float16(__tg_asinh(x.lo), __tg_asinh(x.hi));
3377}
3378#endif
3379
3380#if SIMD_LIBRARY_VERSION >= 3
3381extern simd_double2 _simd_asinh_d2(simd_double2 x);
3382static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x) {
3383 return _simd_asinh_d2(x);
3384}
3385#else
3386static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x) {
3387 return simd_make_double2(asinh(x.x), asinh(x.y));
3388}
3389#endif
3390
3391static inline SIMD_CFUNC simd_double3 __tg_asinh(simd_double3 x) {
3392 return simd_make_double3(__tg_asinh(simd_make_double4(x)));
3393}
3394
3395#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3396extern simd_double4 _simd_asinh_d4(simd_double4 x);
3397static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x) {
3398 return _simd_asinh_d4(x);
3399}
3400#else
3401static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x) {
3402 return simd_make_double4(__tg_asinh(x.lo), __tg_asinh(x.hi));
3403}
3404#endif
3405
3406#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3407extern simd_double8 _simd_asinh_d8(simd_double8 x);
3408static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x) {
3409 return _simd_asinh_d8(x);
3410}
3411#else
3412static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x) {
3413 return simd_make_double8(__tg_asinh(x.lo), __tg_asinh(x.hi));
3414}
3415#endif
3416
3417#pragma mark - atanh implementation
3418static inline SIMD_CFUNC simd_float2 __tg_atanh(simd_float2 x) {
3419 return simd_make_float2(__tg_atanh(simd_make_float4(x)));
3420}
3421
3422static inline SIMD_CFUNC simd_float3 __tg_atanh(simd_float3 x) {
3423 return simd_make_float3(__tg_atanh(simd_make_float4(x)));
3424}
3425
3426#if SIMD_LIBRARY_VERSION >= 3
3427extern simd_float4 _simd_atanh_f4(simd_float4 x);
3428static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x) {
3429 return _simd_atanh_f4(x);
3430}
3431#else
3432static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x) {
3433 return simd_make_float4(atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w));
3434}
3435#endif
3436
3437#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3438extern simd_float8 _simd_atanh_f8(simd_float8 x);
3439static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x) {
3440 return _simd_atanh_f8(x);
3441}
3442#else
3443static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x) {
3444 return simd_make_float8(__tg_atanh(x.lo), __tg_atanh(x.hi));
3445}
3446#endif
3447
3448#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3449extern simd_float16 _simd_atanh_f16(simd_float16 x);
3450static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x) {
3451 return _simd_atanh_f16(x);
3452}
3453#else
3454static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x) {
3455 return simd_make_float16(__tg_atanh(x.lo), __tg_atanh(x.hi));
3456}
3457#endif
3458
3459#if SIMD_LIBRARY_VERSION >= 3
3460extern simd_double2 _simd_atanh_d2(simd_double2 x);
3461static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x) {
3462 return _simd_atanh_d2(x);
3463}
3464#else
3465static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x) {
3466 return simd_make_double2(atanh(x.x), atanh(x.y));
3467}
3468#endif
3469
3470static inline SIMD_CFUNC simd_double3 __tg_atanh(simd_double3 x) {
3471 return simd_make_double3(__tg_atanh(simd_make_double4(x)));
3472}
3473
3474#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3475extern simd_double4 _simd_atanh_d4(simd_double4 x);
3476static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x) {
3477 return _simd_atanh_d4(x);
3478}
3479#else
3480static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x) {
3481 return simd_make_double4(__tg_atanh(x.lo), __tg_atanh(x.hi));
3482}
3483#endif
3484
3485#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3486extern simd_double8 _simd_atanh_d8(simd_double8 x);
3487static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x) {
3488 return _simd_atanh_d8(x);
3489}
3490#else
3491static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x) {
3492 return simd_make_double8(__tg_atanh(x.lo), __tg_atanh(x.hi));
3493}
3494#endif
3495
3496#pragma mark - cosh implementation
3497static inline SIMD_CFUNC simd_float2 __tg_cosh(simd_float2 x) {
3498 return simd_make_float2(__tg_cosh(simd_make_float4(x)));
3499}
3500
3501static inline SIMD_CFUNC simd_float3 __tg_cosh(simd_float3 x) {
3502 return simd_make_float3(__tg_cosh(simd_make_float4(x)));
3503}
3504
3505#if SIMD_LIBRARY_VERSION >= 3
3506extern simd_float4 _simd_cosh_f4(simd_float4 x);
3507static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x) {
3508 return _simd_cosh_f4(x);
3509}
3510#else
3511static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x) {
3512 return simd_make_float4(cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w));
3513}
3514#endif
3515
3516#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3517extern simd_float8 _simd_cosh_f8(simd_float8 x);
3518static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x) {
3519 return _simd_cosh_f8(x);
3520}
3521#else
3522static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x) {
3523 return simd_make_float8(__tg_cosh(x.lo), __tg_cosh(x.hi));
3524}
3525#endif
3526
3527#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3528extern simd_float16 _simd_cosh_f16(simd_float16 x);
3529static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x) {
3530 return _simd_cosh_f16(x);
3531}
3532#else
3533static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x) {
3534 return simd_make_float16(__tg_cosh(x.lo), __tg_cosh(x.hi));
3535}
3536#endif
3537
3538#if SIMD_LIBRARY_VERSION >= 3
3539extern simd_double2 _simd_cosh_d2(simd_double2 x);
3540static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x) {
3541 return _simd_cosh_d2(x);
3542}
3543#else
3544static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x) {
3545 return simd_make_double2(cosh(x.x), cosh(x.y));
3546}
3547#endif
3548
3549static inline SIMD_CFUNC simd_double3 __tg_cosh(simd_double3 x) {
3550 return simd_make_double3(__tg_cosh(simd_make_double4(x)));
3551}
3552
3553#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3554extern simd_double4 _simd_cosh_d4(simd_double4 x);
3555static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x) {
3556 return _simd_cosh_d4(x);
3557}
3558#else
3559static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x) {
3560 return simd_make_double4(__tg_cosh(x.lo), __tg_cosh(x.hi));
3561}
3562#endif
3563
3564#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3565extern simd_double8 _simd_cosh_d8(simd_double8 x);
3566static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x) {
3567 return _simd_cosh_d8(x);
3568}
3569#else
3570static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x) {
3571 return simd_make_double8(__tg_cosh(x.lo), __tg_cosh(x.hi));
3572}
3573#endif
3574
3575#pragma mark - sinh implementation
3576static inline SIMD_CFUNC simd_float2 __tg_sinh(simd_float2 x) {
3577 return simd_make_float2(__tg_sinh(simd_make_float4(x)));
3578}
3579
3580static inline SIMD_CFUNC simd_float3 __tg_sinh(simd_float3 x) {
3581 return simd_make_float3(__tg_sinh(simd_make_float4(x)));
3582}
3583
3584#if SIMD_LIBRARY_VERSION >= 3
3585extern simd_float4 _simd_sinh_f4(simd_float4 x);
3586static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x) {
3587 return _simd_sinh_f4(x);
3588}
3589#else
3590static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x) {
3591 return simd_make_float4(sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w));
3592}
3593#endif
3594
3595#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3596extern simd_float8 _simd_sinh_f8(simd_float8 x);
3597static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x) {
3598 return _simd_sinh_f8(x);
3599}
3600#else
3601static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x) {
3602 return simd_make_float8(__tg_sinh(x.lo), __tg_sinh(x.hi));
3603}
3604#endif
3605
3606#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3607extern simd_float16 _simd_sinh_f16(simd_float16 x);
3608static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x) {
3609 return _simd_sinh_f16(x);
3610}
3611#else
3612static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x) {
3613 return simd_make_float16(__tg_sinh(x.lo), __tg_sinh(x.hi));
3614}
3615#endif
3616
3617#if SIMD_LIBRARY_VERSION >= 3
3618extern simd_double2 _simd_sinh_d2(simd_double2 x);
3619static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x) {
3620 return _simd_sinh_d2(x);
3621}
3622#else
3623static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x) {
3624 return simd_make_double2(sinh(x.x), sinh(x.y));
3625}
3626#endif
3627
3628static inline SIMD_CFUNC simd_double3 __tg_sinh(simd_double3 x) {
3629 return simd_make_double3(__tg_sinh(simd_make_double4(x)));
3630}
3631
3632#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3633extern simd_double4 _simd_sinh_d4(simd_double4 x);
3634static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x) {
3635 return _simd_sinh_d4(x);
3636}
3637#else
3638static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x) {
3639 return simd_make_double4(__tg_sinh(x.lo), __tg_sinh(x.hi));
3640}
3641#endif
3642
3643#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3644extern simd_double8 _simd_sinh_d8(simd_double8 x);
3645static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x) {
3646 return _simd_sinh_d8(x);
3647}
3648#else
3649static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x) {
3650 return simd_make_double8(__tg_sinh(x.lo), __tg_sinh(x.hi));
3651}
3652#endif
3653
3654#pragma mark - tanh implementation
3655static inline SIMD_CFUNC simd_float2 __tg_tanh(simd_float2 x) {
3656 return simd_make_float2(__tg_tanh(simd_make_float4(x)));
3657}
3658
3659static inline SIMD_CFUNC simd_float3 __tg_tanh(simd_float3 x) {
3660 return simd_make_float3(__tg_tanh(simd_make_float4(x)));
3661}
3662
3663#if SIMD_LIBRARY_VERSION >= 3
3664extern simd_float4 _simd_tanh_f4(simd_float4 x);
3665static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x) {
3666 return _simd_tanh_f4(x);
3667}
3668#else
3669static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x) {
3670 return simd_make_float4(tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w));
3671}
3672#endif
3673
3674#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3675extern simd_float8 _simd_tanh_f8(simd_float8 x);
3676static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x) {
3677 return _simd_tanh_f8(x);
3678}
3679#else
3680static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x) {
3681 return simd_make_float8(__tg_tanh(x.lo), __tg_tanh(x.hi));
3682}
3683#endif
3684
3685#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3686extern simd_float16 _simd_tanh_f16(simd_float16 x);
3687static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x) {
3688 return _simd_tanh_f16(x);
3689}
3690#else
3691static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x) {
3692 return simd_make_float16(__tg_tanh(x.lo), __tg_tanh(x.hi));
3693}
3694#endif
3695
3696#if SIMD_LIBRARY_VERSION >= 3
3697extern simd_double2 _simd_tanh_d2(simd_double2 x);
3698static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x) {
3699 return _simd_tanh_d2(x);
3700}
3701#else
3702static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x) {
3703 return simd_make_double2(tanh(x.x), tanh(x.y));
3704}
3705#endif
3706
3707static inline SIMD_CFUNC simd_double3 __tg_tanh(simd_double3 x) {
3708 return simd_make_double3(__tg_tanh(simd_make_double4(x)));
3709}
3710
3711#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3712extern simd_double4 _simd_tanh_d4(simd_double4 x);
3713static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x) {
3714 return _simd_tanh_d4(x);
3715}
3716#else
3717static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x) {
3718 return simd_make_double4(__tg_tanh(x.lo), __tg_tanh(x.hi));
3719}
3720#endif
3721
3722#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3723extern simd_double8 _simd_tanh_d8(simd_double8 x);
3724static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x) {
3725 return _simd_tanh_d8(x);
3726}
3727#else
3728static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x) {
3729 return simd_make_double8(__tg_tanh(x.lo), __tg_tanh(x.hi));
3730}
3731#endif
3732
3733#pragma mark - exp implementation
3734static inline SIMD_CFUNC simd_float2 __tg_exp(simd_float2 x) {
3735 return simd_make_float2(__tg_exp(simd_make_float4(x)));
3736}
3737
3738static inline SIMD_CFUNC simd_float3 __tg_exp(simd_float3 x) {
3739 return simd_make_float3(__tg_exp(simd_make_float4(x)));
3740}
3741
3742#if SIMD_LIBRARY_VERSION >= 3
3743extern simd_float4 _simd_exp_f4(simd_float4 x);
3744static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x) {
3745 return _simd_exp_f4(x);
3746}
3747#else
3748static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x) {
3749 return simd_make_float4(exp(x.x), exp(x.y), exp(x.z), exp(x.w));
3750}
3751#endif
3752
3753#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3754extern simd_float8 _simd_exp_f8(simd_float8 x);
3755static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x) {
3756 return _simd_exp_f8(x);
3757}
3758#else
3759static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x) {
3760 return simd_make_float8(__tg_exp(x.lo), __tg_exp(x.hi));
3761}
3762#endif
3763
3764#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3765extern simd_float16 _simd_exp_f16(simd_float16 x);
3766static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x) {
3767 return _simd_exp_f16(x);
3768}
3769#else
3770static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x) {
3771 return simd_make_float16(__tg_exp(x.lo), __tg_exp(x.hi));
3772}
3773#endif
3774
3775#if SIMD_LIBRARY_VERSION >= 3
3776extern simd_double2 _simd_exp_d2(simd_double2 x);
3777static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x) {
3778 return _simd_exp_d2(x);
3779}
3780#else
3781static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x) {
3782 return simd_make_double2(exp(x.x), exp(x.y));
3783}
3784#endif
3785
3786static inline SIMD_CFUNC simd_double3 __tg_exp(simd_double3 x) {
3787 return simd_make_double3(__tg_exp(simd_make_double4(x)));
3788}
3789
3790#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3791extern simd_double4 _simd_exp_d4(simd_double4 x);
3792static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x) {
3793 return _simd_exp_d4(x);
3794}
3795#else
3796static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x) {
3797 return simd_make_double4(__tg_exp(x.lo), __tg_exp(x.hi));
3798}
3799#endif
3800
3801#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3802extern simd_double8 _simd_exp_d8(simd_double8 x);
3803static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x) {
3804 return _simd_exp_d8(x);
3805}
3806#else
3807static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x) {
3808 return simd_make_double8(__tg_exp(x.lo), __tg_exp(x.hi));
3809}
3810#endif
3811
3812#pragma mark - exp2 implementation
3813static inline SIMD_CFUNC simd_float2 __tg_exp2(simd_float2 x) {
3814 return simd_make_float2(__tg_exp2(simd_make_float4(x)));
3815}
3816
3817static inline SIMD_CFUNC simd_float3 __tg_exp2(simd_float3 x) {
3818 return simd_make_float3(__tg_exp2(simd_make_float4(x)));
3819}
3820
3821#if SIMD_LIBRARY_VERSION >= 3
3822extern simd_float4 _simd_exp2_f4(simd_float4 x);
3823static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x) {
3824 return _simd_exp2_f4(x);
3825}
3826#else
3827static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x) {
3828 return simd_make_float4(exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w));
3829}
3830#endif
3831
3832#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3833extern simd_float8 _simd_exp2_f8(simd_float8 x);
3834static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x) {
3835 return _simd_exp2_f8(x);
3836}
3837#else
3838static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x) {
3839 return simd_make_float8(__tg_exp2(x.lo), __tg_exp2(x.hi));
3840}
3841#endif
3842
3843#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3844extern simd_float16 _simd_exp2_f16(simd_float16 x);
3845static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x) {
3846 return _simd_exp2_f16(x);
3847}
3848#else
3849static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x) {
3850 return simd_make_float16(__tg_exp2(x.lo), __tg_exp2(x.hi));
3851}
3852#endif
3853
3854#if SIMD_LIBRARY_VERSION >= 3
3855extern simd_double2 _simd_exp2_d2(simd_double2 x);
3856static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x) {
3857 return _simd_exp2_d2(x);
3858}
3859#else
3860static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x) {
3861 return simd_make_double2(exp2(x.x), exp2(x.y));
3862}
3863#endif
3864
3865static inline SIMD_CFUNC simd_double3 __tg_exp2(simd_double3 x) {
3866 return simd_make_double3(__tg_exp2(simd_make_double4(x)));
3867}
3868
3869#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3870extern simd_double4 _simd_exp2_d4(simd_double4 x);
3871static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x) {
3872 return _simd_exp2_d4(x);
3873}
3874#else
3875static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x) {
3876 return simd_make_double4(__tg_exp2(x.lo), __tg_exp2(x.hi));
3877}
3878#endif
3879
3880#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3881extern simd_double8 _simd_exp2_d8(simd_double8 x);
3882static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x) {
3883 return _simd_exp2_d8(x);
3884}
3885#else
3886static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x) {
3887 return simd_make_double8(__tg_exp2(x.lo), __tg_exp2(x.hi));
3888}
3889#endif
3890
3891#pragma mark - exp10 implementation
3892#if SIMD_LIBRARY_VERSION >= 1
3893static inline SIMD_CFUNC simd_float2 __tg_exp10(simd_float2 x) {
3894 return simd_make_float2(__tg_exp10(simd_make_float4(x)));
3895}
3896
3897static inline SIMD_CFUNC simd_float3 __tg_exp10(simd_float3 x) {
3898 return simd_make_float3(__tg_exp10(simd_make_float4(x)));
3899}
3900
3901#if SIMD_LIBRARY_VERSION >= 3
3902extern simd_float4 _simd_exp10_f4(simd_float4 x);
3903static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x) {
3904 return _simd_exp10_f4(x);
3905}
3906#else
3907static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x) {
3908 return simd_make_float4(__exp10(x.x), __exp10(x.y), __exp10(x.z), __exp10(x.w));
3909}
3910#endif
3911
3912#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3913extern simd_float8 _simd_exp10_f8(simd_float8 x);
3914static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x) {
3915 return _simd_exp10_f8(x);
3916}
3917#else
3918static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x) {
3919 return simd_make_float8(__tg_exp10(x.lo), __tg_exp10(x.hi));
3920}
3921#endif
3922
3923#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3924extern simd_float16 _simd_exp10_f16(simd_float16 x);
3925static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x) {
3926 return _simd_exp10_f16(x);
3927}
3928#else
3929static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x) {
3930 return simd_make_float16(__tg_exp10(x.lo), __tg_exp10(x.hi));
3931}
3932#endif
3933
3934#if SIMD_LIBRARY_VERSION >= 3
3935extern simd_double2 _simd_exp10_d2(simd_double2 x);
3936static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x) {
3937 return _simd_exp10_d2(x);
3938}
3939#else
3940static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x) {
3941 return simd_make_double2(__exp10(x.x), __exp10(x.y));
3942}
3943#endif
3944
3945static inline SIMD_CFUNC simd_double3 __tg_exp10(simd_double3 x) {
3946 return simd_make_double3(__tg_exp10(simd_make_double4(x)));
3947}
3948
3949#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3950extern simd_double4 _simd_exp10_d4(simd_double4 x);
3951static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x) {
3952 return _simd_exp10_d4(x);
3953}
3954#else
3955static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x) {
3956 return simd_make_double4(__tg_exp10(x.lo), __tg_exp10(x.hi));
3957}
3958#endif
3959
3960#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
3961extern simd_double8 _simd_exp10_d8(simd_double8 x);
3962static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x) {
3963 return _simd_exp10_d8(x);
3964}
3965#else
3966static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x) {
3967 return simd_make_double8(__tg_exp10(x.lo), __tg_exp10(x.hi));
3968}
3969#endif
3970
3971#endif /* SIMD_LIBRARY_VERSION */
3972#pragma mark - expm1 implementation
3973static inline SIMD_CFUNC simd_float2 __tg_expm1(simd_float2 x) {
3974 return simd_make_float2(__tg_expm1(simd_make_float4(x)));
3975}
3976
3977static inline SIMD_CFUNC simd_float3 __tg_expm1(simd_float3 x) {
3978 return simd_make_float3(__tg_expm1(simd_make_float4(x)));
3979}
3980
3981#if SIMD_LIBRARY_VERSION >= 3
3982extern simd_float4 _simd_expm1_f4(simd_float4 x);
3983static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x) {
3984 return _simd_expm1_f4(x);
3985}
3986#else
3987static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x) {
3988 return simd_make_float4(expm1(x.x), expm1(x.y), expm1(x.z), expm1(x.w));
3989}
3990#endif
3991
3992#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
3993extern simd_float8 _simd_expm1_f8(simd_float8 x);
3994static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x) {
3995 return _simd_expm1_f8(x);
3996}
3997#else
3998static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x) {
3999 return simd_make_float8(__tg_expm1(x.lo), __tg_expm1(x.hi));
4000}
4001#endif
4002
4003#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4004extern simd_float16 _simd_expm1_f16(simd_float16 x);
4005static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x) {
4006 return _simd_expm1_f16(x);
4007}
4008#else
4009static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x) {
4010 return simd_make_float16(__tg_expm1(x.lo), __tg_expm1(x.hi));
4011}
4012#endif
4013
4014#if SIMD_LIBRARY_VERSION >= 3
4015extern simd_double2 _simd_expm1_d2(simd_double2 x);
4016static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x) {
4017 return _simd_expm1_d2(x);
4018}
4019#else
4020static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x) {
4021 return simd_make_double2(expm1(x.x), expm1(x.y));
4022}
4023#endif
4024
4025static inline SIMD_CFUNC simd_double3 __tg_expm1(simd_double3 x) {
4026 return simd_make_double3(__tg_expm1(simd_make_double4(x)));
4027}
4028
4029#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4030extern simd_double4 _simd_expm1_d4(simd_double4 x);
4031static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x) {
4032 return _simd_expm1_d4(x);
4033}
4034#else
4035static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x) {
4036 return simd_make_double4(__tg_expm1(x.lo), __tg_expm1(x.hi));
4037}
4038#endif
4039
4040#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4041extern simd_double8 _simd_expm1_d8(simd_double8 x);
4042static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x) {
4043 return _simd_expm1_d8(x);
4044}
4045#else
4046static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x) {
4047 return simd_make_double8(__tg_expm1(x.lo), __tg_expm1(x.hi));
4048}
4049#endif
4050
4051#pragma mark - log implementation
4052static inline SIMD_CFUNC simd_float2 __tg_log(simd_float2 x) {
4053 return simd_make_float2(__tg_log(simd_make_float4(x)));
4054}
4055
4056static inline SIMD_CFUNC simd_float3 __tg_log(simd_float3 x) {
4057 return simd_make_float3(__tg_log(simd_make_float4(x)));
4058}
4059
4060#if SIMD_LIBRARY_VERSION >= 3
4061extern simd_float4 _simd_log_f4(simd_float4 x);
4062static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x) {
4063 return _simd_log_f4(x);
4064}
4065#else
4066static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x) {
4067 return simd_make_float4(log(x.x), log(x.y), log(x.z), log(x.w));
4068}
4069#endif
4070
4071#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4072extern simd_float8 _simd_log_f8(simd_float8 x);
4073static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x) {
4074 return _simd_log_f8(x);
4075}
4076#else
4077static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x) {
4078 return simd_make_float8(__tg_log(x.lo), __tg_log(x.hi));
4079}
4080#endif
4081
4082#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4083extern simd_float16 _simd_log_f16(simd_float16 x);
4084static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x) {
4085 return _simd_log_f16(x);
4086}
4087#else
4088static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x) {
4089 return simd_make_float16(__tg_log(x.lo), __tg_log(x.hi));
4090}
4091#endif
4092
4093#if SIMD_LIBRARY_VERSION >= 3
4094extern simd_double2 _simd_log_d2(simd_double2 x);
4095static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x) {
4096 return _simd_log_d2(x);
4097}
4098#else
4099static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x) {
4100 return simd_make_double2(log(x.x), log(x.y));
4101}
4102#endif
4103
4104static inline SIMD_CFUNC simd_double3 __tg_log(simd_double3 x) {
4105 return simd_make_double3(__tg_log(simd_make_double4(x)));
4106}
4107
4108#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4109extern simd_double4 _simd_log_d4(simd_double4 x);
4110static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x) {
4111 return _simd_log_d4(x);
4112}
4113#else
4114static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x) {
4115 return simd_make_double4(__tg_log(x.lo), __tg_log(x.hi));
4116}
4117#endif
4118
4119#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4120extern simd_double8 _simd_log_d8(simd_double8 x);
4121static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x) {
4122 return _simd_log_d8(x);
4123}
4124#else
4125static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x) {
4126 return simd_make_double8(__tg_log(x.lo), __tg_log(x.hi));
4127}
4128#endif
4129
4130#pragma mark - log2 implementation
4131static inline SIMD_CFUNC simd_float2 __tg_log2(simd_float2 x) {
4132 return simd_make_float2(__tg_log2(simd_make_float4(x)));
4133}
4134
4135static inline SIMD_CFUNC simd_float3 __tg_log2(simd_float3 x) {
4136 return simd_make_float3(__tg_log2(simd_make_float4(x)));
4137}
4138
4139#if SIMD_LIBRARY_VERSION >= 3
4140extern simd_float4 _simd_log2_f4(simd_float4 x);
4141static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x) {
4142 return _simd_log2_f4(x);
4143}
4144#else
4145static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x) {
4146 return simd_make_float4(log2(x.x), log2(x.y), log2(x.z), log2(x.w));
4147}
4148#endif
4149
4150#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4151extern simd_float8 _simd_log2_f8(simd_float8 x);
4152static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x) {
4153 return _simd_log2_f8(x);
4154}
4155#else
4156static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x) {
4157 return simd_make_float8(__tg_log2(x.lo), __tg_log2(x.hi));
4158}
4159#endif
4160
4161#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4162extern simd_float16 _simd_log2_f16(simd_float16 x);
4163static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x) {
4164 return _simd_log2_f16(x);
4165}
4166#else
4167static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x) {
4168 return simd_make_float16(__tg_log2(x.lo), __tg_log2(x.hi));
4169}
4170#endif
4171
4172#if SIMD_LIBRARY_VERSION >= 3
4173extern simd_double2 _simd_log2_d2(simd_double2 x);
4174static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x) {
4175 return _simd_log2_d2(x);
4176}
4177#else
4178static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x) {
4179 return simd_make_double2(log2(x.x), log2(x.y));
4180}
4181#endif
4182
4183static inline SIMD_CFUNC simd_double3 __tg_log2(simd_double3 x) {
4184 return simd_make_double3(__tg_log2(simd_make_double4(x)));
4185}
4186
4187#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4188extern simd_double4 _simd_log2_d4(simd_double4 x);
4189static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x) {
4190 return _simd_log2_d4(x);
4191}
4192#else
4193static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x) {
4194 return simd_make_double4(__tg_log2(x.lo), __tg_log2(x.hi));
4195}
4196#endif
4197
4198#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4199extern simd_double8 _simd_log2_d8(simd_double8 x);
4200static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x) {
4201 return _simd_log2_d8(x);
4202}
4203#else
4204static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x) {
4205 return simd_make_double8(__tg_log2(x.lo), __tg_log2(x.hi));
4206}
4207#endif
4208
4209#pragma mark - log10 implementation
4210static inline SIMD_CFUNC simd_float2 __tg_log10(simd_float2 x) {
4211 return simd_make_float2(__tg_log10(simd_make_float4(x)));
4212}
4213
4214static inline SIMD_CFUNC simd_float3 __tg_log10(simd_float3 x) {
4215 return simd_make_float3(__tg_log10(simd_make_float4(x)));
4216}
4217
4218#if SIMD_LIBRARY_VERSION >= 3
4219extern simd_float4 _simd_log10_f4(simd_float4 x);
4220static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x) {
4221 return _simd_log10_f4(x);
4222}
4223#else
4224static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x) {
4225 return simd_make_float4(log10(x.x), log10(x.y), log10(x.z), log10(x.w));
4226}
4227#endif
4228
4229#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4230extern simd_float8 _simd_log10_f8(simd_float8 x);
4231static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x) {
4232 return _simd_log10_f8(x);
4233}
4234#else
4235static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x) {
4236 return simd_make_float8(__tg_log10(x.lo), __tg_log10(x.hi));
4237}
4238#endif
4239
4240#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4241extern simd_float16 _simd_log10_f16(simd_float16 x);
4242static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x) {
4243 return _simd_log10_f16(x);
4244}
4245#else
4246static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x) {
4247 return simd_make_float16(__tg_log10(x.lo), __tg_log10(x.hi));
4248}
4249#endif
4250
4251#if SIMD_LIBRARY_VERSION >= 3
4252extern simd_double2 _simd_log10_d2(simd_double2 x);
4253static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x) {
4254 return _simd_log10_d2(x);
4255}
4256#else
4257static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x) {
4258 return simd_make_double2(log10(x.x), log10(x.y));
4259}
4260#endif
4261
4262static inline SIMD_CFUNC simd_double3 __tg_log10(simd_double3 x) {
4263 return simd_make_double3(__tg_log10(simd_make_double4(x)));
4264}
4265
4266#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4267extern simd_double4 _simd_log10_d4(simd_double4 x);
4268static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x) {
4269 return _simd_log10_d4(x);
4270}
4271#else
4272static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x) {
4273 return simd_make_double4(__tg_log10(x.lo), __tg_log10(x.hi));
4274}
4275#endif
4276
4277#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4278extern simd_double8 _simd_log10_d8(simd_double8 x);
4279static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x) {
4280 return _simd_log10_d8(x);
4281}
4282#else
4283static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x) {
4284 return simd_make_double8(__tg_log10(x.lo), __tg_log10(x.hi));
4285}
4286#endif
4287
4288#pragma mark - log1p implementation
4289static inline SIMD_CFUNC simd_float2 __tg_log1p(simd_float2 x) {
4290 return simd_make_float2(__tg_log1p(simd_make_float4(x)));
4291}
4292
4293static inline SIMD_CFUNC simd_float3 __tg_log1p(simd_float3 x) {
4294 return simd_make_float3(__tg_log1p(simd_make_float4(x)));
4295}
4296
4297#if SIMD_LIBRARY_VERSION >= 3
4298extern simd_float4 _simd_log1p_f4(simd_float4 x);
4299static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x) {
4300 return _simd_log1p_f4(x);
4301}
4302#else
4303static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x) {
4304 return simd_make_float4(log1p(x.x), log1p(x.y), log1p(x.z), log1p(x.w));
4305}
4306#endif
4307
4308#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4309extern simd_float8 _simd_log1p_f8(simd_float8 x);
4310static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x) {
4311 return _simd_log1p_f8(x);
4312}
4313#else
4314static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x) {
4315 return simd_make_float8(__tg_log1p(x.lo), __tg_log1p(x.hi));
4316}
4317#endif
4318
4319#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4320extern simd_float16 _simd_log1p_f16(simd_float16 x);
4321static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x) {
4322 return _simd_log1p_f16(x);
4323}
4324#else
4325static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x) {
4326 return simd_make_float16(__tg_log1p(x.lo), __tg_log1p(x.hi));
4327}
4328#endif
4329
4330#if SIMD_LIBRARY_VERSION >= 3
4331extern simd_double2 _simd_log1p_d2(simd_double2 x);
4332static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x) {
4333 return _simd_log1p_d2(x);
4334}
4335#else
4336static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x) {
4337 return simd_make_double2(log1p(x.x), log1p(x.y));
4338}
4339#endif
4340
4341static inline SIMD_CFUNC simd_double3 __tg_log1p(simd_double3 x) {
4342 return simd_make_double3(__tg_log1p(simd_make_double4(x)));
4343}
4344
4345#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4346extern simd_double4 _simd_log1p_d4(simd_double4 x);
4347static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x) {
4348 return _simd_log1p_d4(x);
4349}
4350#else
4351static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x) {
4352 return simd_make_double4(__tg_log1p(x.lo), __tg_log1p(x.hi));
4353}
4354#endif
4355
4356#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4357extern simd_double8 _simd_log1p_d8(simd_double8 x);
4358static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x) {
4359 return _simd_log1p_d8(x);
4360}
4361#else
4362static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x) {
4363 return simd_make_double8(__tg_log1p(x.lo), __tg_log1p(x.hi));
4364}
4365#endif
4366
4367#pragma mark - cbrt implementation
4368static inline SIMD_CFUNC simd_float2 __tg_cbrt(simd_float2 x) {
4369 return simd_make_float2(__tg_cbrt(simd_make_float4(x)));
4370}
4371
4372static inline SIMD_CFUNC simd_float3 __tg_cbrt(simd_float3 x) {
4373 return simd_make_float3(__tg_cbrt(simd_make_float4(x)));
4374}
4375
4376#if SIMD_LIBRARY_VERSION >= 3
4377extern simd_float4 _simd_cbrt_f4(simd_float4 x);
4378static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x) {
4379 return _simd_cbrt_f4(x);
4380}
4381#else
4382static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x) {
4383 return simd_make_float4(cbrt(x.x), cbrt(x.y), cbrt(x.z), cbrt(x.w));
4384}
4385#endif
4386
4387#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4388extern simd_float8 _simd_cbrt_f8(simd_float8 x);
4389static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x) {
4390 return _simd_cbrt_f8(x);
4391}
4392#else
4393static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x) {
4394 return simd_make_float8(__tg_cbrt(x.lo), __tg_cbrt(x.hi));
4395}
4396#endif
4397
4398#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4399extern simd_float16 _simd_cbrt_f16(simd_float16 x);
4400static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x) {
4401 return _simd_cbrt_f16(x);
4402}
4403#else
4404static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x) {
4405 return simd_make_float16(__tg_cbrt(x.lo), __tg_cbrt(x.hi));
4406}
4407#endif
4408
4409#if SIMD_LIBRARY_VERSION >= 3
4410extern simd_double2 _simd_cbrt_d2(simd_double2 x);
4411static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x) {
4412 return _simd_cbrt_d2(x);
4413}
4414#else
4415static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x) {
4416 return simd_make_double2(cbrt(x.x), cbrt(x.y));
4417}
4418#endif
4419
4420static inline SIMD_CFUNC simd_double3 __tg_cbrt(simd_double3 x) {
4421 return simd_make_double3(__tg_cbrt(simd_make_double4(x)));
4422}
4423
4424#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4425extern simd_double4 _simd_cbrt_d4(simd_double4 x);
4426static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x) {
4427 return _simd_cbrt_d4(x);
4428}
4429#else
4430static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x) {
4431 return simd_make_double4(__tg_cbrt(x.lo), __tg_cbrt(x.hi));
4432}
4433#endif
4434
4435#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4436extern simd_double8 _simd_cbrt_d8(simd_double8 x);
4437static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x) {
4438 return _simd_cbrt_d8(x);
4439}
4440#else
4441static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x) {
4442 return simd_make_double8(__tg_cbrt(x.lo), __tg_cbrt(x.hi));
4443}
4444#endif
4445
4446#pragma mark - erf implementation
4447static inline SIMD_CFUNC simd_float2 __tg_erf(simd_float2 x) {
4448 return simd_make_float2(__tg_erf(simd_make_float4(x)));
4449}
4450
4451static inline SIMD_CFUNC simd_float3 __tg_erf(simd_float3 x) {
4452 return simd_make_float3(__tg_erf(simd_make_float4(x)));
4453}
4454
4455#if SIMD_LIBRARY_VERSION >= 3
4456extern simd_float4 _simd_erf_f4(simd_float4 x);
4457static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x) {
4458 return _simd_erf_f4(x);
4459}
4460#else
4461static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x) {
4462 return simd_make_float4(erf(x.x), erf(x.y), erf(x.z), erf(x.w));
4463}
4464#endif
4465
4466#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4467extern simd_float8 _simd_erf_f8(simd_float8 x);
4468static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x) {
4469 return _simd_erf_f8(x);
4470}
4471#else
4472static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x) {
4473 return simd_make_float8(__tg_erf(x.lo), __tg_erf(x.hi));
4474}
4475#endif
4476
4477#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4478extern simd_float16 _simd_erf_f16(simd_float16 x);
4479static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x) {
4480 return _simd_erf_f16(x);
4481}
4482#else
4483static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x) {
4484 return simd_make_float16(__tg_erf(x.lo), __tg_erf(x.hi));
4485}
4486#endif
4487
4488#if SIMD_LIBRARY_VERSION >= 3
4489extern simd_double2 _simd_erf_d2(simd_double2 x);
4490static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x) {
4491 return _simd_erf_d2(x);
4492}
4493#else
4494static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x) {
4495 return simd_make_double2(erf(x.x), erf(x.y));
4496}
4497#endif
4498
4499static inline SIMD_CFUNC simd_double3 __tg_erf(simd_double3 x) {
4500 return simd_make_double3(__tg_erf(simd_make_double4(x)));
4501}
4502
4503#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4504extern simd_double4 _simd_erf_d4(simd_double4 x);
4505static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x) {
4506 return _simd_erf_d4(x);
4507}
4508#else
4509static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x) {
4510 return simd_make_double4(__tg_erf(x.lo), __tg_erf(x.hi));
4511}
4512#endif
4513
4514#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4515extern simd_double8 _simd_erf_d8(simd_double8 x);
4516static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x) {
4517 return _simd_erf_d8(x);
4518}
4519#else
4520static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x) {
4521 return simd_make_double8(__tg_erf(x.lo), __tg_erf(x.hi));
4522}
4523#endif
4524
4525#pragma mark - erfc implementation
4526static inline SIMD_CFUNC simd_float2 __tg_erfc(simd_float2 x) {
4527 return simd_make_float2(__tg_erfc(simd_make_float4(x)));
4528}
4529
4530static inline SIMD_CFUNC simd_float3 __tg_erfc(simd_float3 x) {
4531 return simd_make_float3(__tg_erfc(simd_make_float4(x)));
4532}
4533
4534#if SIMD_LIBRARY_VERSION >= 3
4535extern simd_float4 _simd_erfc_f4(simd_float4 x);
4536static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x) {
4537 return _simd_erfc_f4(x);
4538}
4539#else
4540static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x) {
4541 return simd_make_float4(erfc(x.x), erfc(x.y), erfc(x.z), erfc(x.w));
4542}
4543#endif
4544
4545#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4546extern simd_float8 _simd_erfc_f8(simd_float8 x);
4547static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x) {
4548 return _simd_erfc_f8(x);
4549}
4550#else
4551static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x) {
4552 return simd_make_float8(__tg_erfc(x.lo), __tg_erfc(x.hi));
4553}
4554#endif
4555
4556#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4557extern simd_float16 _simd_erfc_f16(simd_float16 x);
4558static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x) {
4559 return _simd_erfc_f16(x);
4560}
4561#else
4562static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x) {
4563 return simd_make_float16(__tg_erfc(x.lo), __tg_erfc(x.hi));
4564}
4565#endif
4566
4567#if SIMD_LIBRARY_VERSION >= 3
4568extern simd_double2 _simd_erfc_d2(simd_double2 x);
4569static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x) {
4570 return _simd_erfc_d2(x);
4571}
4572#else
4573static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x) {
4574 return simd_make_double2(erfc(x.x), erfc(x.y));
4575}
4576#endif
4577
4578static inline SIMD_CFUNC simd_double3 __tg_erfc(simd_double3 x) {
4579 return simd_make_double3(__tg_erfc(simd_make_double4(x)));
4580}
4581
4582#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4583extern simd_double4 _simd_erfc_d4(simd_double4 x);
4584static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x) {
4585 return _simd_erfc_d4(x);
4586}
4587#else
4588static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x) {
4589 return simd_make_double4(__tg_erfc(x.lo), __tg_erfc(x.hi));
4590}
4591#endif
4592
4593#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4594extern simd_double8 _simd_erfc_d8(simd_double8 x);
4595static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x) {
4596 return _simd_erfc_d8(x);
4597}
4598#else
4599static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x) {
4600 return simd_make_double8(__tg_erfc(x.lo), __tg_erfc(x.hi));
4601}
4602#endif
4603
4604#pragma mark - tgamma implementation
4605static inline SIMD_CFUNC simd_float2 __tg_tgamma(simd_float2 x) {
4606 return simd_make_float2(__tg_tgamma(simd_make_float4(x)));
4607}
4608
4609static inline SIMD_CFUNC simd_float3 __tg_tgamma(simd_float3 x) {
4610 return simd_make_float3(__tg_tgamma(simd_make_float4(x)));
4611}
4612
4613#if SIMD_LIBRARY_VERSION >= 3
4614extern simd_float4 _simd_tgamma_f4(simd_float4 x);
4615static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x) {
4616 return _simd_tgamma_f4(x);
4617}
4618#else
4619static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x) {
4620 return simd_make_float4(tgamma(x.x), tgamma(x.y), tgamma(x.z), tgamma(x.w));
4621}
4622#endif
4623
4624#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4625extern simd_float8 _simd_tgamma_f8(simd_float8 x);
4626static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x) {
4627 return _simd_tgamma_f8(x);
4628}
4629#else
4630static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x) {
4631 return simd_make_float8(__tg_tgamma(x.lo), __tg_tgamma(x.hi));
4632}
4633#endif
4634
4635#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4636extern simd_float16 _simd_tgamma_f16(simd_float16 x);
4637static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x) {
4638 return _simd_tgamma_f16(x);
4639}
4640#else
4641static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x) {
4642 return simd_make_float16(__tg_tgamma(x.lo), __tg_tgamma(x.hi));
4643}
4644#endif
4645
4646#if SIMD_LIBRARY_VERSION >= 3
4647extern simd_double2 _simd_tgamma_d2(simd_double2 x);
4648static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x) {
4649 return _simd_tgamma_d2(x);
4650}
4651#else
4652static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x) {
4653 return simd_make_double2(tgamma(x.x), tgamma(x.y));
4654}
4655#endif
4656
4657static inline SIMD_CFUNC simd_double3 __tg_tgamma(simd_double3 x) {
4658 return simd_make_double3(__tg_tgamma(simd_make_double4(x)));
4659}
4660
4661#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4662extern simd_double4 _simd_tgamma_d4(simd_double4 x);
4663static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x) {
4664 return _simd_tgamma_d4(x);
4665}
4666#else
4667static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x) {
4668 return simd_make_double4(__tg_tgamma(x.lo), __tg_tgamma(x.hi));
4669}
4670#endif
4671
4672#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4673extern simd_double8 _simd_tgamma_d8(simd_double8 x);
4674static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x) {
4675 return _simd_tgamma_d8(x);
4676}
4677#else
4678static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x) {
4679 return simd_make_double8(__tg_tgamma(x.lo), __tg_tgamma(x.hi));
4680}
4681#endif
4682
4683#pragma mark - round implementation
4684static inline SIMD_CFUNC simd_float2 __tg_round(simd_float2 x) {
4685 return simd_make_float2(__tg_round(simd_make_float4(x)));
4686}
4687
4688static inline SIMD_CFUNC simd_float3 __tg_round(simd_float3 x) {
4689 return simd_make_float3(__tg_round(simd_make_float4(x)));
4690}
4691
4692#if SIMD_LIBRARY_VERSION >= 3
4693extern simd_float4 _simd_round_f4(simd_float4 x);
4694static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x) {
4695#if defined __arm64__
4696 return vrndaq_f32(x);
4697#else
4698 return _simd_round_f4(x);
4699#endif
4700}
4701#else
4702static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x) {
4703 return simd_make_float4(round(x.x), round(x.y), round(x.z), round(x.w));
4704}
4705#endif
4706
4707#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4708extern simd_float8 _simd_round_f8(simd_float8 x);
4709static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x) {
4710 return _simd_round_f8(x);
4711}
4712#else
4713static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x) {
4714 return simd_make_float8(__tg_round(x.lo), __tg_round(x.hi));
4715}
4716#endif
4717
4718#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4719extern simd_float16 _simd_round_f16(simd_float16 x);
4720static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x) {
4721 return _simd_round_f16(x);
4722}
4723#else
4724static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x) {
4725 return simd_make_float16(__tg_round(x.lo), __tg_round(x.hi));
4726}
4727#endif
4728
4729#if SIMD_LIBRARY_VERSION >= 3
4730extern simd_double2 _simd_round_d2(simd_double2 x);
4731static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x) {
4732#if defined __arm64__
4733 return vrndaq_f64(x);
4734#else
4735 return _simd_round_d2(x);
4736#endif
4737}
4738#else
4739static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x) {
4740 return simd_make_double2(round(x.x), round(x.y));
4741}
4742#endif
4743
4744static inline SIMD_CFUNC simd_double3 __tg_round(simd_double3 x) {
4745 return simd_make_double3(__tg_round(simd_make_double4(x)));
4746}
4747
4748#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4749extern simd_double4 _simd_round_d4(simd_double4 x);
4750static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x) {
4751 return _simd_round_d4(x);
4752}
4753#else
4754static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x) {
4755 return simd_make_double4(__tg_round(x.lo), __tg_round(x.hi));
4756}
4757#endif
4758
4759#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4760extern simd_double8 _simd_round_d8(simd_double8 x);
4761static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x) {
4762 return _simd_round_d8(x);
4763}
4764#else
4765static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x) {
4766 return simd_make_double8(__tg_round(x.lo), __tg_round(x.hi));
4767}
4768#endif
4769
4770#pragma mark - atan2 implementation
4771static inline SIMD_CFUNC simd_float2 __tg_atan2(simd_float2 y, simd_float2 x) {
4772 return simd_make_float2(__tg_atan2(simd_make_float4(y), simd_make_float4(x)));
4773}
4774
4775static inline SIMD_CFUNC simd_float3 __tg_atan2(simd_float3 y, simd_float3 x) {
4776 return simd_make_float3(__tg_atan2(simd_make_float4(y), simd_make_float4(x)));
4777}
4778
4779#if SIMD_LIBRARY_VERSION >= 3
4780extern simd_float4 _simd_atan2_f4(simd_float4 y, simd_float4 x);
4781static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x) {
4782 return _simd_atan2_f4(y, x);
4783}
4784#else
4785static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x) {
4786 return simd_make_float4(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w));
4787}
4788#endif
4789
4790#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4791extern simd_float8 _simd_atan2_f8(simd_float8 y, simd_float8 x);
4792static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x) {
4793 return _simd_atan2_f8(y, x);
4794}
4795#else
4796static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x) {
4797 return simd_make_float8(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi));
4798}
4799#endif
4800
4801#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4802extern simd_float16 _simd_atan2_f16(simd_float16 y, simd_float16 x);
4803static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x) {
4804 return _simd_atan2_f16(y, x);
4805}
4806#else
4807static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x) {
4808 return simd_make_float16(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi));
4809}
4810#endif
4811
4812#if SIMD_LIBRARY_VERSION >= 3
4813extern simd_double2 _simd_atan2_d2(simd_double2 y, simd_double2 x);
4814static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x) {
4815 return _simd_atan2_d2(y, x);
4816}
4817#else
4818static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x) {
4819 return simd_make_double2(atan2(y.x, x.x), atan2(y.y, x.y));
4820}
4821#endif
4822
4823static inline SIMD_CFUNC simd_double3 __tg_atan2(simd_double3 y, simd_double3 x) {
4824 return simd_make_double3(__tg_atan2(simd_make_double4(y), simd_make_double4(x)));
4825}
4826
4827#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4828extern simd_double4 _simd_atan2_d4(simd_double4 y, simd_double4 x);
4829static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x) {
4830 return _simd_atan2_d4(y, x);
4831}
4832#else
4833static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x) {
4834 return simd_make_double4(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi));
4835}
4836#endif
4837
4838#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4839extern simd_double8 _simd_atan2_d8(simd_double8 y, simd_double8 x);
4840static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x) {
4841 return _simd_atan2_d8(y, x);
4842}
4843#else
4844static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x) {
4845 return simd_make_double8(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi));
4846}
4847#endif
4848
4849#pragma mark - hypot implementation
4850static inline SIMD_CFUNC simd_float2 __tg_hypot(simd_float2 x, simd_float2 y) {
4851 return simd_make_float2(__tg_hypot(simd_make_float4(x), simd_make_float4(y)));
4852}
4853
4854static inline SIMD_CFUNC simd_float3 __tg_hypot(simd_float3 x, simd_float3 y) {
4855 return simd_make_float3(__tg_hypot(simd_make_float4(x), simd_make_float4(y)));
4856}
4857
4858#if SIMD_LIBRARY_VERSION >= 3
4859extern simd_float4 _simd_hypot_f4(simd_float4 x, simd_float4 y);
4860static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y) {
4861 return _simd_hypot_f4(x, y);
4862}
4863#else
4864static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y) {
4865 return simd_make_float4(hypot(x.x, y.x), hypot(x.y, y.y), hypot(x.z, y.z), hypot(x.w, y.w));
4866}
4867#endif
4868
4869#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4870extern simd_float8 _simd_hypot_f8(simd_float8 x, simd_float8 y);
4871static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y) {
4872 return _simd_hypot_f8(x, y);
4873}
4874#else
4875static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y) {
4876 return simd_make_float8(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi));
4877}
4878#endif
4879
4880#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4881extern simd_float16 _simd_hypot_f16(simd_float16 x, simd_float16 y);
4882static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y) {
4883 return _simd_hypot_f16(x, y);
4884}
4885#else
4886static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y) {
4887 return simd_make_float16(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi));
4888}
4889#endif
4890
4891#if SIMD_LIBRARY_VERSION >= 3
4892extern simd_double2 _simd_hypot_d2(simd_double2 x, simd_double2 y);
4893static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y) {
4894 return _simd_hypot_d2(x, y);
4895}
4896#else
4897static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y) {
4898 return simd_make_double2(hypot(x.x, y.x), hypot(x.y, y.y));
4899}
4900#endif
4901
4902static inline SIMD_CFUNC simd_double3 __tg_hypot(simd_double3 x, simd_double3 y) {
4903 return simd_make_double3(__tg_hypot(simd_make_double4(x), simd_make_double4(y)));
4904}
4905
4906#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4907extern simd_double4 _simd_hypot_d4(simd_double4 x, simd_double4 y);
4908static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y) {
4909 return _simd_hypot_d4(x, y);
4910}
4911#else
4912static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y) {
4913 return simd_make_double4(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi));
4914}
4915#endif
4916
4917#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4918extern simd_double8 _simd_hypot_d8(simd_double8 x, simd_double8 y);
4919static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y) {
4920 return _simd_hypot_d8(x, y);
4921}
4922#else
4923static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y) {
4924 return simd_make_double8(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi));
4925}
4926#endif
4927
4928#pragma mark - pow implementation
4929static inline SIMD_CFUNC simd_float2 __tg_pow(simd_float2 x, simd_float2 y) {
4930 return simd_make_float2(__tg_pow(simd_make_float4(x), simd_make_float4(y)));
4931}
4932
4933static inline SIMD_CFUNC simd_float3 __tg_pow(simd_float3 x, simd_float3 y) {
4934 return simd_make_float3(__tg_pow(simd_make_float4(x), simd_make_float4(y)));
4935}
4936
4937#if SIMD_LIBRARY_VERSION >= 3
4938extern simd_float4 _simd_pow_f4(simd_float4 x, simd_float4 y);
4939static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y) {
4940 return _simd_pow_f4(x, y);
4941}
4942#else
4943static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y) {
4944 return simd_make_float4(pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w));
4945}
4946#endif
4947
4948#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4949extern simd_float8 _simd_pow_f8(simd_float8 x, simd_float8 y);
4950static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y) {
4951 return _simd_pow_f8(x, y);
4952}
4953#else
4954static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y) {
4955 return simd_make_float8(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi));
4956}
4957#endif
4958
4959#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4960extern simd_float16 _simd_pow_f16(simd_float16 x, simd_float16 y);
4961static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y) {
4962 return _simd_pow_f16(x, y);
4963}
4964#else
4965static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y) {
4966 return simd_make_float16(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi));
4967}
4968#endif
4969
4970#if SIMD_LIBRARY_VERSION >= 3
4971extern simd_double2 _simd_pow_d2(simd_double2 x, simd_double2 y);
4972static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y) {
4973 return _simd_pow_d2(x, y);
4974}
4975#else
4976static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y) {
4977 return simd_make_double2(pow(x.x, y.x), pow(x.y, y.y));
4978}
4979#endif
4980
4981static inline SIMD_CFUNC simd_double3 __tg_pow(simd_double3 x, simd_double3 y) {
4982 return simd_make_double3(__tg_pow(simd_make_double4(x), simd_make_double4(y)));
4983}
4984
4985#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
4986extern simd_double4 _simd_pow_d4(simd_double4 x, simd_double4 y);
4987static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y) {
4988 return _simd_pow_d4(x, y);
4989}
4990#else
4991static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y) {
4992 return simd_make_double4(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi));
4993}
4994#endif
4995
4996#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
4997extern simd_double8 _simd_pow_d8(simd_double8 x, simd_double8 y);
4998static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y) {
4999 return _simd_pow_d8(x, y);
5000}
5001#else
5002static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y) {
5003 return simd_make_double8(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi));
5004}
5005#endif
5006
5007#pragma mark - fmod implementation
5008static inline SIMD_CFUNC simd_float2 __tg_fmod(simd_float2 x, simd_float2 y) {
5009 return simd_make_float2(__tg_fmod(simd_make_float4(x), simd_make_float4(y)));
5010}
5011
5012static inline SIMD_CFUNC simd_float3 __tg_fmod(simd_float3 x, simd_float3 y) {
5013 return simd_make_float3(__tg_fmod(simd_make_float4(x), simd_make_float4(y)));
5014}
5015
5016#if SIMD_LIBRARY_VERSION >= 3
5017extern simd_float4 _simd_fmod_f4(simd_float4 x, simd_float4 y);
5018static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y) {
5019 return _simd_fmod_f4(x, y);
5020}
5021#else
5022static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y) {
5023 return simd_make_float4(fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z), fmod(x.w, y.w));
5024}
5025#endif
5026
5027#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
5028extern simd_float8 _simd_fmod_f8(simd_float8 x, simd_float8 y);
5029static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y) {
5030 return _simd_fmod_f8(x, y);
5031}
5032#else
5033static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y) {
5034 return simd_make_float8(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi));
5035}
5036#endif
5037
5038#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
5039extern simd_float16 _simd_fmod_f16(simd_float16 x, simd_float16 y);
5040static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y) {
5041 return _simd_fmod_f16(x, y);
5042}
5043#else
5044static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y) {
5045 return simd_make_float16(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi));
5046}
5047#endif
5048
5049#if SIMD_LIBRARY_VERSION >= 3
5050extern simd_double2 _simd_fmod_d2(simd_double2 x, simd_double2 y);
5051static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y) {
5052 return _simd_fmod_d2(x, y);
5053}
5054#else
5055static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y) {
5056 return simd_make_double2(fmod(x.x, y.x), fmod(x.y, y.y));
5057}
5058#endif
5059
5060static inline SIMD_CFUNC simd_double3 __tg_fmod(simd_double3 x, simd_double3 y) {
5061 return simd_make_double3(__tg_fmod(simd_make_double4(x), simd_make_double4(y)));
5062}
5063
5064#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
5065extern simd_double4 _simd_fmod_d4(simd_double4 x, simd_double4 y);
5066static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y) {
5067 return _simd_fmod_d4(x, y);
5068}
5069#else
5070static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y) {
5071 return simd_make_double4(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi));
5072}
5073#endif
5074
5075#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
5076extern simd_double8 _simd_fmod_d8(simd_double8 x, simd_double8 y);
5077static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y) {
5078 return _simd_fmod_d8(x, y);
5079}
5080#else
5081static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y) {
5082 return simd_make_double8(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi));
5083}
5084#endif
5085
5086#pragma mark - remainder implementation
5087static inline SIMD_CFUNC simd_float2 __tg_remainder(simd_float2 x, simd_float2 y) {
5088 return simd_make_float2(__tg_remainder(simd_make_float4(x), simd_make_float4(y)));
5089}
5090
5091static inline SIMD_CFUNC simd_float3 __tg_remainder(simd_float3 x, simd_float3 y) {
5092 return simd_make_float3(__tg_remainder(simd_make_float4(x), simd_make_float4(y)));
5093}
5094
5095#if SIMD_LIBRARY_VERSION >= 3
5096extern simd_float4 _simd_remainder_f4(simd_float4 x, simd_float4 y);
5097static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y) {
5098 return _simd_remainder_f4(x, y);
5099}
5100#else
5101static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y) {
5102 return simd_make_float4(remainder(x.x, y.x), remainder(x.y, y.y), remainder(x.z, y.z), remainder(x.w, y.w));
5103}
5104#endif
5105
5106#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
5107extern simd_float8 _simd_remainder_f8(simd_float8 x, simd_float8 y);
5108static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y) {
5109 return _simd_remainder_f8(x, y);
5110}
5111#else
5112static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y) {
5113 return simd_make_float8(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi));
5114}
5115#endif
5116
5117#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
5118extern simd_float16 _simd_remainder_f16(simd_float16 x, simd_float16 y);
5119static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y) {
5120 return _simd_remainder_f16(x, y);
5121}
5122#else
5123static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y) {
5124 return simd_make_float16(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi));
5125}
5126#endif
5127
5128#if SIMD_LIBRARY_VERSION >= 3
5129extern simd_double2 _simd_remainder_d2(simd_double2 x, simd_double2 y);
5130static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y) {
5131 return _simd_remainder_d2(x, y);
5132}
5133#else
5134static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y) {
5135 return simd_make_double2(remainder(x.x, y.x), remainder(x.y, y.y));
5136}
5137#endif
5138
5139static inline SIMD_CFUNC simd_double3 __tg_remainder(simd_double3 x, simd_double3 y) {
5140 return simd_make_double3(__tg_remainder(simd_make_double4(x), simd_make_double4(y)));
5141}
5142
5143#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
5144extern simd_double4 _simd_remainder_d4(simd_double4 x, simd_double4 y);
5145static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y) {
5146 return _simd_remainder_d4(x, y);
5147}
5148#else
5149static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y) {
5150 return simd_make_double4(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi));
5151}
5152#endif
5153
5154#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
5155extern simd_double8 _simd_remainder_d8(simd_double8 x, simd_double8 y);
5156static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y) {
5157 return _simd_remainder_d8(x, y);
5158}
5159#else
5160static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y) {
5161 return simd_make_double8(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi));
5162}
5163#endif
5164
5165#pragma mark - nextafter implementation
5166static inline SIMD_CFUNC simd_float2 __tg_nextafter(simd_float2 x, simd_float2 y) {
5167 return simd_make_float2(__tg_nextafter(simd_make_float4(x), simd_make_float4(y)));
5168}
5169
5170static inline SIMD_CFUNC simd_float3 __tg_nextafter(simd_float3 x, simd_float3 y) {
5171 return simd_make_float3(__tg_nextafter(simd_make_float4(x), simd_make_float4(y)));
5172}
5173
5174#if SIMD_LIBRARY_VERSION >= 3
5175extern simd_float4 _simd_nextafter_f4(simd_float4 x, simd_float4 y);
5176static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y) {
5177 return _simd_nextafter_f4(x, y);
5178}
5179#else
5180static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y) {
5181 return simd_make_float4(nextafter(x.x, y.x), nextafter(x.y, y.y), nextafter(x.z, y.z), nextafter(x.w, y.w));
5182}
5183#endif
5184
5185#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
5186extern simd_float8 _simd_nextafter_f8(simd_float8 x, simd_float8 y);
5187static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y) {
5188 return _simd_nextafter_f8(x, y);
5189}
5190#else
5191static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y) {
5192 return simd_make_float8(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi));
5193}
5194#endif
5195
5196#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
5197extern simd_float16 _simd_nextafter_f16(simd_float16 x, simd_float16 y);
5198static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y) {
5199 return _simd_nextafter_f16(x, y);
5200}
5201#else
5202static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y) {
5203 return simd_make_float16(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi));
5204}
5205#endif
5206
5207#if SIMD_LIBRARY_VERSION >= 3
5208extern simd_double2 _simd_nextafter_d2(simd_double2 x, simd_double2 y);
5209static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y) {
5210 return _simd_nextafter_d2(x, y);
5211}
5212#else
5213static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y) {
5214 return simd_make_double2(nextafter(x.x, y.x), nextafter(x.y, y.y));
5215}
5216#endif
5217
5218static inline SIMD_CFUNC simd_double3 __tg_nextafter(simd_double3 x, simd_double3 y) {
5219 return simd_make_double3(__tg_nextafter(simd_make_double4(x), simd_make_double4(y)));
5220}
5221
5222#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__
5223extern simd_double4 _simd_nextafter_d4(simd_double4 x, simd_double4 y);
5224static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y) {
5225 return _simd_nextafter_d4(x, y);
5226}
5227#else
5228static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y) {
5229 return simd_make_double4(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi));
5230}
5231#endif
5232
5233#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__
5234extern simd_double8 _simd_nextafter_d8(simd_double8 x, simd_double8 y);
5235static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y) {
5236 return _simd_nextafter_d8(x, y);
5237}
5238#else
5239static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y) {
5240 return simd_make_double8(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi));
5241}
5242#endif
5243
5244static inline SIMD_CFUNC simd_float2 __tg_fdim(simd_float2 x, simd_float2 y) { return simd_bitselect(x-y, 0, x<y); }
5245static inline SIMD_CFUNC simd_float3 __tg_fdim(simd_float3 x, simd_float3 y) { return simd_bitselect(x-y, 0, x<y); }
5246static inline SIMD_CFUNC simd_float4 __tg_fdim(simd_float4 x, simd_float4 y) { return simd_bitselect(x-y, 0, x<y); }
5247static inline SIMD_CFUNC simd_float8 __tg_fdim(simd_float8 x, simd_float8 y) { return simd_bitselect(x-y, 0, x<y); }
5248static inline SIMD_CFUNC simd_float16 __tg_fdim(simd_float16 x, simd_float16 y) { return simd_bitselect(x-y, 0, x<y); }
5249static inline SIMD_CFUNC simd_double2 __tg_fdim(simd_double2 x, simd_double2 y) { return simd_bitselect(x-y, 0, x<y); }
5250static inline SIMD_CFUNC simd_double3 __tg_fdim(simd_double3 x, simd_double3 y) { return simd_bitselect(x-y, 0, x<y); }
5251static inline SIMD_CFUNC simd_double4 __tg_fdim(simd_double4 x, simd_double4 y) { return simd_bitselect(x-y, 0, x<y); }
5252static inline SIMD_CFUNC simd_double8 __tg_fdim(simd_double8 x, simd_double8 y) { return simd_bitselect(x-y, 0, x<y); }
5253
5254static inline SIMD_CFUNC simd_float2 __tg_fma(simd_float2 x, simd_float2 y, simd_float2 z) {
5255#if defined __arm64__ || defined __ARM_VFPV4__
5256 return vfma_f32(z, x, y);
5257#else
5258 return simd_make_float2(__tg_fma(simd_make_float4_undef(x), simd_make_float4_undef(y), simd_make_float4_undef(z)));
5259#endif
5260}
5261
5262static inline SIMD_CFUNC simd_float3 __tg_fma(simd_float3 x, simd_float3 y, simd_float3 z) {
5263 return simd_make_float3(__tg_fma(simd_make_float4(x), simd_make_float4(y), simd_make_float4(z)));
5264}
5265
5266#if SIMD_LIBRARY_VERSION >= 3
5267extern simd_float4 _simd_fma_f4(simd_float4 x, simd_float4 y, simd_float4 z);
5268#endif
5269static inline SIMD_CFUNC simd_float4 __tg_fma(simd_float4 x, simd_float4 y, simd_float4 z) {
5270#if defined __arm64__ || defined __ARM_VFPV4__
5271 return vfmaq_f32(z, x, y);
5272#elif (defined __i386__ || defined __x86_64__) && defined __FMA__
5273 return _mm_fmadd_ps(x, y, z);
5274#elif SIMD_LIBRARY_VERSION >= 3
5275 return _simd_fma_f4(x, y, z);
5276#else
5277 return simd_make_float4(fma(x.x, y.x, z.x), fma(x.y, y.y, z.y), fma(x.z, y.z, z.z), fma(x.w, y.w, z.w));
5278#endif
5279}
5280
5281static inline SIMD_CFUNC simd_float8 __tg_fma(simd_float8 x, simd_float8 y, simd_float8 z) {
5282#if (defined __i386__ || defined __x86_64__) && defined __FMA__
5283 return _mm256_fmadd_ps(x, y, z);
5284#else
5285 return simd_make_float8(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi));
5286#endif
5287}
5288
5289static inline SIMD_CFUNC simd_float16 __tg_fma(simd_float16 x, simd_float16 y, simd_float16 z) {
5290#if defined __x86_64__ && defined __AVX512F__
5291 return _mm512_fmadd_ps(x, y, z);
5292#else
5293 return simd_make_float16(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi));
5294#endif
5295}
5296
5297#if SIMD_LIBRARY_VERSION >= 3
5298extern simd_double2 _simd_fma_d2(simd_double2 x, simd_double2 y, simd_double2 z);
5299#endif
5300static inline SIMD_CFUNC simd_double2 __tg_fma(simd_double2 x, simd_double2 y, simd_double2 z) {
5301#if defined __arm64__
5302 return vfmaq_f64(z, x, y);
5303#elif (defined __i386__ || defined __x86_64__) && defined __FMA__
5304 return _mm_fmadd_pd(x, y, z);
5305#elif SIMD_LIBRARY_VERSION >= 3
5306 return _simd_fma_d2(x, y, z);
5307#else
5308 return simd_make_double2(fma(x.x, y.x, z.x), fma(x.y, y.y, z.y));
5309#endif
5310}
5311
5312static inline SIMD_CFUNC simd_double3 __tg_fma(simd_double3 x, simd_double3 y, simd_double3 z) {
5313 return simd_make_double3(__tg_fma(simd_make_double4(x), simd_make_double4(y), simd_make_double4(z)));
5314}
5315
5316static inline SIMD_CFUNC simd_double4 __tg_fma(simd_double4 x, simd_double4 y, simd_double4 z) {
5317#if (defined __i386__ || defined __x86_64__) && defined __FMA__
5318 return _mm256_fmadd_pd(x, y, z);
5319#else
5320 return simd_make_double4(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi));
5321#endif
5322}
5323
5324static inline SIMD_CFUNC simd_double8 __tg_fma(simd_double8 x, simd_double8 y, simd_double8 z) {
5325#if defined __x86_64__ && defined __AVX512F__
5326 return _mm512_fmadd_pd(x, y, z);
5327#else
5328 return simd_make_double8(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi));
5329#endif
5330}
5331
5332static inline SIMD_CFUNC float simd_muladd(float x, float y, float z) {
5333#pragma STDC FP_CONTRACT ON
5334 return x*y + z;
5335}
5336static inline SIMD_CFUNC simd_float2 simd_muladd(simd_float2 x, simd_float2 y, simd_float2 z) {
5337#pragma STDC FP_CONTRACT ON
5338 return x*y + z;
5339}
5340static inline SIMD_CFUNC simd_float3 simd_muladd(simd_float3 x, simd_float3 y, simd_float3 z) {
5341#pragma STDC FP_CONTRACT ON
5342 return x*y + z;
5343}
5344static inline SIMD_CFUNC simd_float4 simd_muladd(simd_float4 x, simd_float4 y, simd_float4 z) {
5345#pragma STDC FP_CONTRACT ON
5346 return x*y + z;
5347}
5348static inline SIMD_CFUNC simd_float8 simd_muladd(simd_float8 x, simd_float8 y, simd_float8 z) {
5349#pragma STDC FP_CONTRACT ON
5350 return x*y + z;
5351}
5352static inline SIMD_CFUNC simd_float16 simd_muladd(simd_float16 x, simd_float16 y, simd_float16 z) {
5353#pragma STDC FP_CONTRACT ON
5354 return x*y + z;
5355}
5356static inline SIMD_CFUNC double simd_muladd(double x, double y, double z) {
5357#pragma STDC FP_CONTRACT ON
5358 return x*y + z;
5359}
5360static inline SIMD_CFUNC simd_double2 simd_muladd(simd_double2 x, simd_double2 y, simd_double2 z) {
5361#pragma STDC FP_CONTRACT ON
5362 return x*y + z;
5363}
5364static inline SIMD_CFUNC simd_double3 simd_muladd(simd_double3 x, simd_double3 y, simd_double3 z) {
5365#pragma STDC FP_CONTRACT ON
5366 return x*y + z;
5367}
5368static inline SIMD_CFUNC simd_double4 simd_muladd(simd_double4 x, simd_double4 y, simd_double4 z) {
5369#pragma STDC FP_CONTRACT ON
5370 return x*y + z;
5371}
5372static inline SIMD_CFUNC simd_double8 simd_muladd(simd_double8 x, simd_double8 y, simd_double8 z) {
5373#pragma STDC FP_CONTRACT ON
5374 return x*y + z;
5375}
5376#ifdef __cplusplus
5377} /* extern "C" */
5378#endif
5379#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
5380#endif /* SIMD_MATH_HEADER */
lib/libc/include/x86_64-macos-gnu/simd/matrix.h created+1786
......@@ -0,0 +1,1786 @@
1/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved.
2 *
3 * Function Result
4 * ------------------------------------------------------------------
5 *
6 * simd_diagonal_matrix(x) A square matrix with the vector x
7 * as its diagonal.
8 *
9 * simd_matrix(c0, c1, ... ) A matrix with the specified vectors
10 * as columns.
11 *
12 * simd_matrix_from_rows(r0, r1, ... ) A matrix with the specified vectors
13 * as rows.
14 *
15 * simd_mul(a,x) Scalar product a*x.
16 *
17 * simd_linear_combination(a,x,b,y) a*x + b*y.
18 *
19 * simd_add(x,y) Macro wrapping linear_combination
20 * to compute x + y.
21 *
22 * simd_sub(x,y) Macro wrapping linear_combination
23 * to compute x - y.
24 *
25 * simd_transpose(x) Transpose of the matrix x.
26 *
27 * simd_inverse(x) Inverse of x if x is non-singular. If
28 * x is singular, the result is undefined.
29 *
30 * simd_mul(x,y) If x is a matrix, returns the matrix
31 * product x*y, where y is either a matrix
32 * or a column vector. If x is a vector,
33 * returns the product x*y where x is
34 * interpreted as a row vector.
35 *
36 * simd_equal(x,y) Returns true if and only if every
37 * element of x is exactly equal to the
38 * corresponding element of y.
39 *
40 * simd_almost_equal_elements(x,y,tol)
41 * Returns true if and only if for each
42 * entry xij in x, the corresponding
43 * element yij in y satisfies
44 * |xij - yij| <= tol.
45 *
46 * simd_almost_equal_elements_relative(x,y,tol)
47 * Returns true if and only if for each
48 * entry xij in x, the corresponding
49 * element yij in y satisfies
50 * |xij - yij| <= tol*|xij|.
51 *
52 * The header also defines a few useful global matrix objects:
53 * matrix_identity_floatNxM and matrix_identity_doubleNxM, may be used to get
54 * an identity matrix of the specified size.
55 *
56 * In C++, we are able to use namespacing to make the functions more concise;
57 * we also overload some common arithmetic operators to work with the matrix
58 * types:
59 *
60 * C++ Function Equivalent C Function
61 * --------------------------------------------------------------------
62 * simd::inverse simd_inverse
63 * simd::transpose simd_transpose
64 * operator+ simd_add
65 * operator- simd_sub
66 * operator+= N/A
67 * operator-= N/A
68 * operator* simd_mul or simd_mul
69 * operator*= simd_mul or simd_mul
70 * operator== simd_equal
71 * operator!= !simd_equal
72 * simd::almost_equal_elements simd_almost_equal_elements
73 * simd::almost_equal_elements_relative simd_almost_equal_elements_relative
74 *
75 * <simd/matrix_types.h> provides constructors for C++ matrix types.
76 */
77
78#ifndef SIMD_MATRIX_HEADER
79#define SIMD_MATRIX_HEADER
80
81#include <simd/base.h>
82#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
83#include <simd/matrix_types.h>
84#include <simd/geometry.h>
85#include <simd/extern.h>
86#include <simd/logic.h>
87
88#ifdef __cplusplus
89 extern "C" {
90#endif
91
92extern const simd_float2x2 matrix_identity_float2x2 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
93extern const simd_float3x3 matrix_identity_float3x3 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
94extern const simd_float4x4 matrix_identity_float4x4 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
95extern const simd_double2x2 matrix_identity_double2x2 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
96extern const simd_double3x3 matrix_identity_double3x3 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
97extern const simd_double4x4 matrix_identity_double4x4 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
98
99static simd_float2x2 SIMD_CFUNC simd_diagonal_matrix(simd_float2 __x);
100static simd_float3x3 SIMD_CFUNC simd_diagonal_matrix(simd_float3 __x);
101static simd_float4x4 SIMD_CFUNC simd_diagonal_matrix(simd_float4 __x);
102static simd_double2x2 SIMD_CFUNC simd_diagonal_matrix(simd_double2 __x);
103static simd_double3x3 SIMD_CFUNC simd_diagonal_matrix(simd_double3 __x);
104static simd_double4x4 SIMD_CFUNC simd_diagonal_matrix(simd_double4 __x);
105#define matrix_from_diagonal simd_diagonal_matrix
106
107static simd_float2x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1);
108static simd_float3x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1, simd_float2 col2);
109static simd_float4x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1, simd_float2 col2, simd_float2 col3);
110static simd_float2x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1);
111static simd_float3x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1, simd_float3 col2);
112static simd_float4x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1, simd_float3 col2, simd_float3 col3);
113static simd_float2x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1);
114static simd_float3x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1, simd_float4 col2);
115static simd_float4x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1, simd_float4 col2, simd_float4 col3);
116static simd_double2x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1);
117static simd_double3x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1, simd_double2 col2);
118static simd_double4x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1, simd_double2 col2, simd_double2 col3);
119static simd_double2x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1);
120static simd_double3x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1, simd_double3 col2);
121static simd_double4x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1, simd_double3 col2, simd_double3 col3);
122static simd_double2x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1);
123static simd_double3x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1, simd_double4 col2);
124static simd_double4x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1, simd_double4 col2, simd_double4 col3);
125#define matrix_from_columns simd_matrix
126
127static simd_float2x2 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1);
128static simd_float2x3 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1, simd_float2 row2);
129static simd_float2x4 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1, simd_float2 row2, simd_float2 row3);
130static simd_float3x2 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1);
131static simd_float3x3 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1, simd_float3 row2);
132static simd_float3x4 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1, simd_float3 row2, simd_float3 row3);
133static simd_float4x2 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1);
134static simd_float4x3 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1, simd_float4 row2);
135static simd_float4x4 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1, simd_float4 row2, simd_float4 row3);
136static simd_double2x2 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1);
137static simd_double2x3 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1, simd_double2 row2);
138static simd_double2x4 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1, simd_double2 row2, simd_double2 row3);
139static simd_double3x2 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1);
140static simd_double3x3 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1, simd_double3 row2);
141static simd_double3x4 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1, simd_double3 row2, simd_double3 row3);
142static simd_double4x2 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1);
143static simd_double4x3 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1, simd_double4 row2);
144static simd_double4x4 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1, simd_double4 row2, simd_double4 row3);
145#define matrix_from_rows simd_matrix_from_rows
146
147static simd_float3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatf q);
148static simd_float4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatf q);
149static simd_double3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatd q);
150static simd_double4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatd q);
151
152static simd_float2x2 SIMD_CFUNC simd_mul(float __a, simd_float2x2 __x);
153static simd_float3x2 SIMD_CFUNC simd_mul(float __a, simd_float3x2 __x);
154static simd_float4x2 SIMD_CFUNC simd_mul(float __a, simd_float4x2 __x);
155static simd_float2x3 SIMD_CFUNC simd_mul(float __a, simd_float2x3 __x);
156static simd_float3x3 SIMD_CFUNC simd_mul(float __a, simd_float3x3 __x);
157static simd_float4x3 SIMD_CFUNC simd_mul(float __a, simd_float4x3 __x);
158static simd_float2x4 SIMD_CFUNC simd_mul(float __a, simd_float2x4 __x);
159static simd_float3x4 SIMD_CFUNC simd_mul(float __a, simd_float3x4 __x);
160static simd_float4x4 SIMD_CFUNC simd_mul(float __a, simd_float4x4 __x);
161static simd_double2x2 SIMD_CFUNC simd_mul(double __a, simd_double2x2 __x);
162static simd_double3x2 SIMD_CFUNC simd_mul(double __a, simd_double3x2 __x);
163static simd_double4x2 SIMD_CFUNC simd_mul(double __a, simd_double4x2 __x);
164static simd_double2x3 SIMD_CFUNC simd_mul(double __a, simd_double2x3 __x);
165static simd_double3x3 SIMD_CFUNC simd_mul(double __a, simd_double3x3 __x);
166static simd_double4x3 SIMD_CFUNC simd_mul(double __a, simd_double4x3 __x);
167static simd_double2x4 SIMD_CFUNC simd_mul(double __a, simd_double2x4 __x);
168static simd_double3x4 SIMD_CFUNC simd_mul(double __a, simd_double3x4 __x);
169static simd_double4x4 SIMD_CFUNC simd_mul(double __a, simd_double4x4 __x);
170
171static simd_float2x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x2 __x, float __b, simd_float2x2 __y);
172static simd_float3x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x2 __x, float __b, simd_float3x2 __y);
173static simd_float4x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x2 __x, float __b, simd_float4x2 __y);
174static simd_float2x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x3 __x, float __b, simd_float2x3 __y);
175static simd_float3x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x3 __x, float __b, simd_float3x3 __y);
176static simd_float4x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x3 __x, float __b, simd_float4x3 __y);
177static simd_float2x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x4 __x, float __b, simd_float2x4 __y);
178static simd_float3x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x4 __x, float __b, simd_float3x4 __y);
179static simd_float4x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x4 __x, float __b, simd_float4x4 __y);
180static simd_double2x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x2 __x, double __b, simd_double2x2 __y);
181static simd_double3x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x2 __x, double __b, simd_double3x2 __y);
182static simd_double4x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x2 __x, double __b, simd_double4x2 __y);
183static simd_double2x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x3 __x, double __b, simd_double2x3 __y);
184static simd_double3x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x3 __x, double __b, simd_double3x3 __y);
185static simd_double4x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x3 __x, double __b, simd_double4x3 __y);
186static simd_double2x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x4 __x, double __b, simd_double2x4 __y);
187static simd_double3x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x4 __x, double __b, simd_double3x4 __y);
188static simd_double4x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x4 __x, double __b, simd_double4x4 __y);
189#define matrix_linear_combination simd_linear_combination
190
191static simd_float2x2 SIMD_CFUNC simd_add(simd_float2x2 __x, simd_float2x2 __y);
192static simd_float3x2 SIMD_CFUNC simd_add(simd_float3x2 __x, simd_float3x2 __y);
193static simd_float4x2 SIMD_CFUNC simd_add(simd_float4x2 __x, simd_float4x2 __y);
194static simd_float2x3 SIMD_CFUNC simd_add(simd_float2x3 __x, simd_float2x3 __y);
195static simd_float3x3 SIMD_CFUNC simd_add(simd_float3x3 __x, simd_float3x3 __y);
196static simd_float4x3 SIMD_CFUNC simd_add(simd_float4x3 __x, simd_float4x3 __y);
197static simd_float2x4 SIMD_CFUNC simd_add(simd_float2x4 __x, simd_float2x4 __y);
198static simd_float3x4 SIMD_CFUNC simd_add(simd_float3x4 __x, simd_float3x4 __y);
199static simd_float4x4 SIMD_CFUNC simd_add(simd_float4x4 __x, simd_float4x4 __y);
200static simd_double2x2 SIMD_CFUNC simd_add(simd_double2x2 __x, simd_double2x2 __y);
201static simd_double3x2 SIMD_CFUNC simd_add(simd_double3x2 __x, simd_double3x2 __y);
202static simd_double4x2 SIMD_CFUNC simd_add(simd_double4x2 __x, simd_double4x2 __y);
203static simd_double2x3 SIMD_CFUNC simd_add(simd_double2x3 __x, simd_double2x3 __y);
204static simd_double3x3 SIMD_CFUNC simd_add(simd_double3x3 __x, simd_double3x3 __y);
205static simd_double4x3 SIMD_CFUNC simd_add(simd_double4x3 __x, simd_double4x3 __y);
206static simd_double2x4 SIMD_CFUNC simd_add(simd_double2x4 __x, simd_double2x4 __y);
207static simd_double3x4 SIMD_CFUNC simd_add(simd_double3x4 __x, simd_double3x4 __y);
208static simd_double4x4 SIMD_CFUNC simd_add(simd_double4x4 __x, simd_double4x4 __y);
209#define matrix_add simd_add
210
211static simd_float2x2 SIMD_CFUNC simd_sub(simd_float2x2 __x, simd_float2x2 __y);
212static simd_float3x2 SIMD_CFUNC simd_sub(simd_float3x2 __x, simd_float3x2 __y);
213static simd_float4x2 SIMD_CFUNC simd_sub(simd_float4x2 __x, simd_float4x2 __y);
214static simd_float2x3 SIMD_CFUNC simd_sub(simd_float2x3 __x, simd_float2x3 __y);
215static simd_float3x3 SIMD_CFUNC simd_sub(simd_float3x3 __x, simd_float3x3 __y);
216static simd_float4x3 SIMD_CFUNC simd_sub(simd_float4x3 __x, simd_float4x3 __y);
217static simd_float2x4 SIMD_CFUNC simd_sub(simd_float2x4 __x, simd_float2x4 __y);
218static simd_float3x4 SIMD_CFUNC simd_sub(simd_float3x4 __x, simd_float3x4 __y);
219static simd_float4x4 SIMD_CFUNC simd_sub(simd_float4x4 __x, simd_float4x4 __y);
220static simd_double2x2 SIMD_CFUNC simd_sub(simd_double2x2 __x, simd_double2x2 __y);
221static simd_double3x2 SIMD_CFUNC simd_sub(simd_double3x2 __x, simd_double3x2 __y);
222static simd_double4x2 SIMD_CFUNC simd_sub(simd_double4x2 __x, simd_double4x2 __y);
223static simd_double2x3 SIMD_CFUNC simd_sub(simd_double2x3 __x, simd_double2x3 __y);
224static simd_double3x3 SIMD_CFUNC simd_sub(simd_double3x3 __x, simd_double3x3 __y);
225static simd_double4x3 SIMD_CFUNC simd_sub(simd_double4x3 __x, simd_double4x3 __y);
226static simd_double2x4 SIMD_CFUNC simd_sub(simd_double2x4 __x, simd_double2x4 __y);
227static simd_double3x4 SIMD_CFUNC simd_sub(simd_double3x4 __x, simd_double3x4 __y);
228static simd_double4x4 SIMD_CFUNC simd_sub(simd_double4x4 __x, simd_double4x4 __y);
229#define matrix_sub simd_sub
230
231static simd_float2x2 SIMD_CFUNC simd_transpose(simd_float2x2 __x);
232static simd_float2x3 SIMD_CFUNC simd_transpose(simd_float3x2 __x);
233static simd_float2x4 SIMD_CFUNC simd_transpose(simd_float4x2 __x);
234static simd_float3x2 SIMD_CFUNC simd_transpose(simd_float2x3 __x);
235static simd_float3x3 SIMD_CFUNC simd_transpose(simd_float3x3 __x);
236static simd_float3x4 SIMD_CFUNC simd_transpose(simd_float4x3 __x);
237static simd_float4x2 SIMD_CFUNC simd_transpose(simd_float2x4 __x);
238static simd_float4x3 SIMD_CFUNC simd_transpose(simd_float3x4 __x);
239static simd_float4x4 SIMD_CFUNC simd_transpose(simd_float4x4 __x);
240static simd_double2x2 SIMD_CFUNC simd_transpose(simd_double2x2 __x);
241static simd_double2x3 SIMD_CFUNC simd_transpose(simd_double3x2 __x);
242static simd_double2x4 SIMD_CFUNC simd_transpose(simd_double4x2 __x);
243static simd_double3x2 SIMD_CFUNC simd_transpose(simd_double2x3 __x);
244static simd_double3x3 SIMD_CFUNC simd_transpose(simd_double3x3 __x);
245static simd_double3x4 SIMD_CFUNC simd_transpose(simd_double4x3 __x);
246static simd_double4x2 SIMD_CFUNC simd_transpose(simd_double2x4 __x);
247static simd_double4x3 SIMD_CFUNC simd_transpose(simd_double3x4 __x);
248static simd_double4x4 SIMD_CFUNC simd_transpose(simd_double4x4 __x);
249#define matrix_transpose simd_transpose
250
251static float SIMD_CFUNC simd_determinant(simd_float2x2 __x);
252static float SIMD_CFUNC simd_determinant(simd_float3x3 __x);
253static float SIMD_CFUNC simd_determinant(simd_float4x4 __x);
254static double SIMD_CFUNC simd_determinant(simd_double2x2 __x);
255static double SIMD_CFUNC simd_determinant(simd_double3x3 __x);
256static double SIMD_CFUNC simd_determinant(simd_double4x4 __x);
257#define matrix_determinant simd_determinant
258
259static simd_float2x2 SIMD_CFUNC simd_inverse(simd_float2x2 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
260static simd_float3x3 SIMD_CFUNC simd_inverse(simd_float3x3 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
261static simd_float4x4 SIMD_CFUNC simd_inverse(simd_float4x4 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
262static simd_double2x2 SIMD_CFUNC simd_inverse(simd_double2x2 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
263static simd_double3x3 SIMD_CFUNC simd_inverse(simd_double3x3 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
264static simd_double4x4 SIMD_CFUNC simd_inverse(simd_double4x4 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0));
265#define matrix_invert simd_inverse
266
267static simd_float2 SIMD_CFUNC simd_mul(simd_float2x2 __x, simd_float2 __y);
268static simd_float2 SIMD_CFUNC simd_mul(simd_float3x2 __x, simd_float3 __y);
269static simd_float2 SIMD_CFUNC simd_mul(simd_float4x2 __x, simd_float4 __y);
270static simd_float3 SIMD_CFUNC simd_mul(simd_float2x3 __x, simd_float2 __y);
271static simd_float3 SIMD_CFUNC simd_mul(simd_float3x3 __x, simd_float3 __y);
272static simd_float3 SIMD_CFUNC simd_mul(simd_float4x3 __x, simd_float4 __y);
273static simd_float4 SIMD_CFUNC simd_mul(simd_float2x4 __x, simd_float2 __y);
274static simd_float4 SIMD_CFUNC simd_mul(simd_float3x4 __x, simd_float3 __y);
275static simd_float4 SIMD_CFUNC simd_mul(simd_float4x4 __x, simd_float4 __y);
276static simd_double2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double2 __y);
277static simd_double2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double3 __y);
278static simd_double2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double4 __y);
279static simd_double3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double2 __y);
280static simd_double3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double3 __y);
281static simd_double3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double4 __y);
282static simd_double4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double2 __y);
283static simd_double4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double3 __y);
284static simd_double4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double4 __y);
285static simd_float2 SIMD_CFUNC simd_mul(simd_float2 __x, simd_float2x2 __y);
286static simd_float3 SIMD_CFUNC simd_mul(simd_float2 __x, simd_float3x2 __y);
287static simd_float4 SIMD_CFUNC simd_mul(simd_float2 __x, simd_float4x2 __y);
288static simd_float2 SIMD_CFUNC simd_mul(simd_float3 __x, simd_float2x3 __y);
289static simd_float3 SIMD_CFUNC simd_mul(simd_float3 __x, simd_float3x3 __y);
290static simd_float4 SIMD_CFUNC simd_mul(simd_float3 __x, simd_float4x3 __y);
291static simd_float2 SIMD_CFUNC simd_mul(simd_float4 __x, simd_float2x4 __y);
292static simd_float3 SIMD_CFUNC simd_mul(simd_float4 __x, simd_float3x4 __y);
293static simd_float4 SIMD_CFUNC simd_mul(simd_float4 __x, simd_float4x4 __y);
294static simd_double2 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double2x2 __y);
295static simd_double3 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double3x2 __y);
296static simd_double4 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double4x2 __y);
297static simd_double2 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double2x3 __y);
298static simd_double3 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double3x3 __y);
299static simd_double4 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double4x3 __y);
300static simd_double2 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double2x4 __y);
301static simd_double3 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double3x4 __y);
302static simd_double4 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double4x4 __y);
303static simd_float2x2 SIMD_CFUNC simd_mul(simd_float2x2 __x, simd_float2x2 __y);
304static simd_float3x2 SIMD_CFUNC simd_mul(simd_float2x2 __x, simd_float3x2 __y);
305static simd_float4x2 SIMD_CFUNC simd_mul(simd_float2x2 __x, simd_float4x2 __y);
306static simd_float2x3 SIMD_CFUNC simd_mul(simd_float2x3 __x, simd_float2x2 __y);
307static simd_float3x3 SIMD_CFUNC simd_mul(simd_float2x3 __x, simd_float3x2 __y);
308static simd_float4x3 SIMD_CFUNC simd_mul(simd_float2x3 __x, simd_float4x2 __y);
309static simd_float2x4 SIMD_CFUNC simd_mul(simd_float2x4 __x, simd_float2x2 __y);
310static simd_float3x4 SIMD_CFUNC simd_mul(simd_float2x4 __x, simd_float3x2 __y);
311static simd_float4x4 SIMD_CFUNC simd_mul(simd_float2x4 __x, simd_float4x2 __y);
312static simd_double2x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double2x2 __y);
313static simd_double3x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double3x2 __y);
314static simd_double4x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double4x2 __y);
315static simd_double2x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double2x2 __y);
316static simd_double3x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double3x2 __y);
317static simd_double4x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double4x2 __y);
318static simd_double2x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double2x2 __y);
319static simd_double3x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double3x2 __y);
320static simd_double4x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double4x2 __y);
321static simd_float2x2 SIMD_CFUNC simd_mul(simd_float3x2 __x, simd_float2x3 __y);
322static simd_float3x2 SIMD_CFUNC simd_mul(simd_float3x2 __x, simd_float3x3 __y);
323static simd_float4x2 SIMD_CFUNC simd_mul(simd_float3x2 __x, simd_float4x3 __y);
324static simd_float2x3 SIMD_CFUNC simd_mul(simd_float3x3 __x, simd_float2x3 __y);
325static simd_float3x3 SIMD_CFUNC simd_mul(simd_float3x3 __x, simd_float3x3 __y);
326static simd_float4x3 SIMD_CFUNC simd_mul(simd_float3x3 __x, simd_float4x3 __y);
327static simd_float2x4 SIMD_CFUNC simd_mul(simd_float3x4 __x, simd_float2x3 __y);
328static simd_float3x4 SIMD_CFUNC simd_mul(simd_float3x4 __x, simd_float3x3 __y);
329static simd_float4x4 SIMD_CFUNC simd_mul(simd_float3x4 __x, simd_float4x3 __y);
330static simd_double2x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double2x3 __y);
331static simd_double3x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double3x3 __y);
332static simd_double4x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double4x3 __y);
333static simd_double2x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double2x3 __y);
334static simd_double3x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double3x3 __y);
335static simd_double4x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double4x3 __y);
336static simd_double2x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double2x3 __y);
337static simd_double3x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double3x3 __y);
338static simd_double4x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double4x3 __y);
339static simd_float2x2 SIMD_CFUNC simd_mul(simd_float4x2 __x, simd_float2x4 __y);
340static simd_float3x2 SIMD_CFUNC simd_mul(simd_float4x2 __x, simd_float3x4 __y);
341static simd_float4x2 SIMD_CFUNC simd_mul(simd_float4x2 __x, simd_float4x4 __y);
342static simd_float2x3 SIMD_CFUNC simd_mul(simd_float4x3 __x, simd_float2x4 __y);
343static simd_float3x3 SIMD_CFUNC simd_mul(simd_float4x3 __x, simd_float3x4 __y);
344static simd_float4x3 SIMD_CFUNC simd_mul(simd_float4x3 __x, simd_float4x4 __y);
345static simd_float2x4 SIMD_CFUNC simd_mul(simd_float4x4 __x, simd_float2x4 __y);
346static simd_float3x4 SIMD_CFUNC simd_mul(simd_float4x4 __x, simd_float3x4 __y);
347static simd_float4x4 SIMD_CFUNC simd_mul(simd_float4x4 __x, simd_float4x4 __y);
348static simd_double2x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double2x4 __y);
349static simd_double3x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double3x4 __y);
350static simd_double4x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double4x4 __y);
351static simd_double2x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double2x4 __y);
352static simd_double3x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double3x4 __y);
353static simd_double4x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double4x4 __y);
354static simd_double2x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double2x4 __y);
355static simd_double3x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double3x4 __y);
356static simd_double4x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double4x4 __y);
357
358static simd_bool SIMD_CFUNC simd_equal(simd_float2x2 __x, simd_float2x2 __y);
359static simd_bool SIMD_CFUNC simd_equal(simd_float2x3 __x, simd_float2x3 __y);
360static simd_bool SIMD_CFUNC simd_equal(simd_float2x4 __x, simd_float2x4 __y);
361static simd_bool SIMD_CFUNC simd_equal(simd_float3x2 __x, simd_float3x2 __y);
362static simd_bool SIMD_CFUNC simd_equal(simd_float3x3 __x, simd_float3x3 __y);
363static simd_bool SIMD_CFUNC simd_equal(simd_float3x4 __x, simd_float3x4 __y);
364static simd_bool SIMD_CFUNC simd_equal(simd_float4x2 __x, simd_float4x2 __y);
365static simd_bool SIMD_CFUNC simd_equal(simd_float4x3 __x, simd_float4x3 __y);
366static simd_bool SIMD_CFUNC simd_equal(simd_float4x4 __x, simd_float4x4 __y);
367static simd_bool SIMD_CFUNC simd_equal(simd_double2x2 __x, simd_double2x2 __y);
368static simd_bool SIMD_CFUNC simd_equal(simd_double2x3 __x, simd_double2x3 __y);
369static simd_bool SIMD_CFUNC simd_equal(simd_double2x4 __x, simd_double2x4 __y);
370static simd_bool SIMD_CFUNC simd_equal(simd_double3x2 __x, simd_double3x2 __y);
371static simd_bool SIMD_CFUNC simd_equal(simd_double3x3 __x, simd_double3x3 __y);
372static simd_bool SIMD_CFUNC simd_equal(simd_double3x4 __x, simd_double3x4 __y);
373static simd_bool SIMD_CFUNC simd_equal(simd_double4x2 __x, simd_double4x2 __y);
374static simd_bool SIMD_CFUNC simd_equal(simd_double4x3 __x, simd_double4x3 __y);
375static simd_bool SIMD_CFUNC simd_equal(simd_double4x4 __x, simd_double4x4 __y);
376#define matrix_equal simd_equal
377
378static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x2 __x, simd_float2x2 __y, float __tol);
379static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x3 __x, simd_float2x3 __y, float __tol);
380static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x4 __x, simd_float2x4 __y, float __tol);
381static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x2 __x, simd_float3x2 __y, float __tol);
382static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x3 __x, simd_float3x3 __y, float __tol);
383static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x4 __x, simd_float3x4 __y, float __tol);
384static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x2 __x, simd_float4x2 __y, float __tol);
385static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x3 __x, simd_float4x3 __y, float __tol);
386static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x4 __x, simd_float4x4 __y, float __tol);
387static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x2 __x, simd_double2x2 __y, double __tol);
388static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x3 __x, simd_double2x3 __y, double __tol);
389static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x4 __x, simd_double2x4 __y, double __tol);
390static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x2 __x, simd_double3x2 __y, double __tol);
391static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x3 __x, simd_double3x3 __y, double __tol);
392static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x4 __x, simd_double3x4 __y, double __tol);
393static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x2 __x, simd_double4x2 __y, double __tol);
394static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x3 __x, simd_double4x3 __y, double __tol);
395static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x4 __x, simd_double4x4 __y, double __tol);
396#define matrix_almost_equal_elements simd_almost_equal_elements
397
398static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x2 __x, simd_float2x2 __y, float __tol);
399static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x3 __x, simd_float2x3 __y, float __tol);
400static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x4 __x, simd_float2x4 __y, float __tol);
401static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x2 __x, simd_float3x2 __y, float __tol);
402static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x3 __x, simd_float3x3 __y, float __tol);
403static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x4 __x, simd_float3x4 __y, float __tol);
404static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x2 __x, simd_float4x2 __y, float __tol);
405static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x3 __x, simd_float4x3 __y, float __tol);
406static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x4 __x, simd_float4x4 __y, float __tol);
407static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x2 __x, simd_double2x2 __y, double __tol);
408static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x3 __x, simd_double2x3 __y, double __tol);
409static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x4 __x, simd_double2x4 __y, double __tol);
410static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x2 __x, simd_double3x2 __y, double __tol);
411static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x3 __x, simd_double3x3 __y, double __tol);
412static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x4 __x, simd_double3x4 __y, double __tol);
413static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x2 __x, simd_double4x2 __y, double __tol);
414static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x3 __x, simd_double4x3 __y, double __tol);
415static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x4 __x, simd_double4x4 __y, double __tol);
416#define matrix_almost_equal_elements_relative simd_almost_equal_elements_relative
417
418#ifdef __cplusplus
419} /* extern "C" */
420
421namespace simd {
422 static SIMD_CPPFUNC float2x2 operator+(const float2x2 x, const float2x2 y) { return float2x2(::simd_linear_combination(1, x, 1, y)); }
423 static SIMD_CPPFUNC float2x3 operator+(const float2x3 x, const float2x3 y) { return float2x3(::simd_linear_combination(1, x, 1, y)); }
424 static SIMD_CPPFUNC float2x4 operator+(const float2x4 x, const float2x4 y) { return float2x4(::simd_linear_combination(1, x, 1, y)); }
425 static SIMD_CPPFUNC float3x2 operator+(const float3x2 x, const float3x2 y) { return float3x2(::simd_linear_combination(1, x, 1, y)); }
426 static SIMD_CPPFUNC float3x3 operator+(const float3x3 x, const float3x3 y) { return float3x3(::simd_linear_combination(1, x, 1, y)); }
427 static SIMD_CPPFUNC float3x4 operator+(const float3x4 x, const float3x4 y) { return float3x4(::simd_linear_combination(1, x, 1, y)); }
428 static SIMD_CPPFUNC float4x2 operator+(const float4x2 x, const float4x2 y) { return float4x2(::simd_linear_combination(1, x, 1, y)); }
429 static SIMD_CPPFUNC float4x3 operator+(const float4x3 x, const float4x3 y) { return float4x3(::simd_linear_combination(1, x, 1, y)); }
430 static SIMD_CPPFUNC float4x4 operator+(const float4x4 x, const float4x4 y) { return float4x4(::simd_linear_combination(1, x, 1, y)); }
431
432 static SIMD_CPPFUNC float2x2 operator-(const float2x2 x, const float2x2 y) { return float2x2(::simd_linear_combination(1, x, -1, y)); }
433 static SIMD_CPPFUNC float2x3 operator-(const float2x3 x, const float2x3 y) { return float2x3(::simd_linear_combination(1, x, -1, y)); }
434 static SIMD_CPPFUNC float2x4 operator-(const float2x4 x, const float2x4 y) { return float2x4(::simd_linear_combination(1, x, -1, y)); }
435 static SIMD_CPPFUNC float3x2 operator-(const float3x2 x, const float3x2 y) { return float3x2(::simd_linear_combination(1, x, -1, y)); }
436 static SIMD_CPPFUNC float3x3 operator-(const float3x3 x, const float3x3 y) { return float3x3(::simd_linear_combination(1, x, -1, y)); }
437 static SIMD_CPPFUNC float3x4 operator-(const float3x4 x, const float3x4 y) { return float3x4(::simd_linear_combination(1, x, -1, y)); }
438 static SIMD_CPPFUNC float4x2 operator-(const float4x2 x, const float4x2 y) { return float4x2(::simd_linear_combination(1, x, -1, y)); }
439 static SIMD_CPPFUNC float4x3 operator-(const float4x3 x, const float4x3 y) { return float4x3(::simd_linear_combination(1, x, -1, y)); }
440 static SIMD_CPPFUNC float4x4 operator-(const float4x4 x, const float4x4 y) { return float4x4(::simd_linear_combination(1, x, -1, y)); }
441
442 static SIMD_CPPFUNC float2x2& operator+=(float2x2& x, const float2x2 y) { x = x + y; return x; }
443 static SIMD_CPPFUNC float2x3& operator+=(float2x3& x, const float2x3 y) { x = x + y; return x; }
444 static SIMD_CPPFUNC float2x4& operator+=(float2x4& x, const float2x4 y) { x = x + y; return x; }
445 static SIMD_CPPFUNC float3x2& operator+=(float3x2& x, const float3x2 y) { x = x + y; return x; }
446 static SIMD_CPPFUNC float3x3& operator+=(float3x3& x, const float3x3 y) { x = x + y; return x; }
447 static SIMD_CPPFUNC float3x4& operator+=(float3x4& x, const float3x4 y) { x = x + y; return x; }
448 static SIMD_CPPFUNC float4x2& operator+=(float4x2& x, const float4x2 y) { x = x + y; return x; }
449 static SIMD_CPPFUNC float4x3& operator+=(float4x3& x, const float4x3 y) { x = x + y; return x; }
450 static SIMD_CPPFUNC float4x4& operator+=(float4x4& x, const float4x4 y) { x = x + y; return x; }
451
452 static SIMD_CPPFUNC float2x2& operator-=(float2x2& x, const float2x2 y) { x = x - y; return x; }
453 static SIMD_CPPFUNC float2x3& operator-=(float2x3& x, const float2x3 y) { x = x - y; return x; }
454 static SIMD_CPPFUNC float2x4& operator-=(float2x4& x, const float2x4 y) { x = x - y; return x; }
455 static SIMD_CPPFUNC float3x2& operator-=(float3x2& x, const float3x2 y) { x = x - y; return x; }
456 static SIMD_CPPFUNC float3x3& operator-=(float3x3& x, const float3x3 y) { x = x - y; return x; }
457 static SIMD_CPPFUNC float3x4& operator-=(float3x4& x, const float3x4 y) { x = x - y; return x; }
458 static SIMD_CPPFUNC float4x2& operator-=(float4x2& x, const float4x2 y) { x = x - y; return x; }
459 static SIMD_CPPFUNC float4x3& operator-=(float4x3& x, const float4x3 y) { x = x - y; return x; }
460 static SIMD_CPPFUNC float4x4& operator-=(float4x4& x, const float4x4 y) { x = x - y; return x; }
461
462 static SIMD_CPPFUNC float2x2 transpose(const float2x2 x) { return ::simd_transpose(x); }
463 static SIMD_CPPFUNC float2x3 transpose(const float3x2 x) { return ::simd_transpose(x); }
464 static SIMD_CPPFUNC float2x4 transpose(const float4x2 x) { return ::simd_transpose(x); }
465 static SIMD_CPPFUNC float3x2 transpose(const float2x3 x) { return ::simd_transpose(x); }
466 static SIMD_CPPFUNC float3x3 transpose(const float3x3 x) { return ::simd_transpose(x); }
467 static SIMD_CPPFUNC float3x4 transpose(const float4x3 x) { return ::simd_transpose(x); }
468 static SIMD_CPPFUNC float4x2 transpose(const float2x4 x) { return ::simd_transpose(x); }
469 static SIMD_CPPFUNC float4x3 transpose(const float3x4 x) { return ::simd_transpose(x); }
470 static SIMD_CPPFUNC float4x4 transpose(const float4x4 x) { return ::simd_transpose(x); }
471
472 static SIMD_CPPFUNC float determinant(const float2x2 x) { return ::simd_determinant(x); }
473 static SIMD_CPPFUNC float determinant(const float3x3 x) { return ::simd_determinant(x); }
474 static SIMD_CPPFUNC float determinant(const float4x4 x) { return ::simd_determinant(x); }
475
476#pragma clang diagnostic push
477#pragma clang diagnostic ignored "-Wgcc-compat"
478 static SIMD_CPPFUNC float2x2 inverse(const float2x2 x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)) { return ::simd_inverse(x); }
479 static SIMD_CPPFUNC float3x3 inverse(const float3x3 x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)) { return ::simd_inverse(x); }
480 static SIMD_CPPFUNC float4x4 inverse(const float4x4 x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)) { return ::simd_inverse(x); }
481#pragma clang diagnostic pop
482
483 static SIMD_CPPFUNC float2x2 operator*(const float a, const float2x2 x) { return ::simd_mul(a, x); }
484 static SIMD_CPPFUNC float2x3 operator*(const float a, const float2x3 x) { return ::simd_mul(a, x); }
485 static SIMD_CPPFUNC float2x4 operator*(const float a, const float2x4 x) { return ::simd_mul(a, x); }
486 static SIMD_CPPFUNC float3x2 operator*(const float a, const float3x2 x) { return ::simd_mul(a, x); }
487 static SIMD_CPPFUNC float3x3 operator*(const float a, const float3x3 x) { return ::simd_mul(a, x); }
488 static SIMD_CPPFUNC float3x4 operator*(const float a, const float3x4 x) { return ::simd_mul(a, x); }
489 static SIMD_CPPFUNC float4x2 operator*(const float a, const float4x2 x) { return ::simd_mul(a, x); }
490 static SIMD_CPPFUNC float4x3 operator*(const float a, const float4x3 x) { return ::simd_mul(a, x); }
491 static SIMD_CPPFUNC float4x4 operator*(const float a, const float4x4 x) { return ::simd_mul(a, x); }
492 static SIMD_CPPFUNC float2x2 operator*(const float2x2 x, const float a) { return ::simd_mul(a, x); }
493 static SIMD_CPPFUNC float2x3 operator*(const float2x3 x, const float a) { return ::simd_mul(a, x); }
494 static SIMD_CPPFUNC float2x4 operator*(const float2x4 x, const float a) { return ::simd_mul(a, x); }
495 static SIMD_CPPFUNC float3x2 operator*(const float3x2 x, const float a) { return ::simd_mul(a, x); }
496 static SIMD_CPPFUNC float3x3 operator*(const float3x3 x, const float a) { return ::simd_mul(a, x); }
497 static SIMD_CPPFUNC float3x4 operator*(const float3x4 x, const float a) { return ::simd_mul(a, x); }
498 static SIMD_CPPFUNC float4x2 operator*(const float4x2 x, const float a) { return ::simd_mul(a, x); }
499 static SIMD_CPPFUNC float4x3 operator*(const float4x3 x, const float a) { return ::simd_mul(a, x); }
500 static SIMD_CPPFUNC float4x4 operator*(const float4x4 x, const float a) { return ::simd_mul(a, x); }
501 static SIMD_CPPFUNC float2x2& operator*=(float2x2& x, const float a) { x = ::simd_mul(a, x); return x; }
502 static SIMD_CPPFUNC float2x3& operator*=(float2x3& x, const float a) { x = ::simd_mul(a, x); return x; }
503 static SIMD_CPPFUNC float2x4& operator*=(float2x4& x, const float a) { x = ::simd_mul(a, x); return x; }
504 static SIMD_CPPFUNC float3x2& operator*=(float3x2& x, const float a) { x = ::simd_mul(a, x); return x; }
505 static SIMD_CPPFUNC float3x3& operator*=(float3x3& x, const float a) { x = ::simd_mul(a, x); return x; }
506 static SIMD_CPPFUNC float3x4& operator*=(float3x4& x, const float a) { x = ::simd_mul(a, x); return x; }
507 static SIMD_CPPFUNC float4x2& operator*=(float4x2& x, const float a) { x = ::simd_mul(a, x); return x; }
508 static SIMD_CPPFUNC float4x3& operator*=(float4x3& x, const float a) { x = ::simd_mul(a, x); return x; }
509 static SIMD_CPPFUNC float4x4& operator*=(float4x4& x, const float a) { x = ::simd_mul(a, x); return x; }
510
511 static SIMD_CPPFUNC float2 operator*(const float2 x, const float2x2 y) { return ::simd_mul(x, y); }
512 static SIMD_CPPFUNC float3 operator*(const float2 x, const float3x2 y) { return ::simd_mul(x, y); }
513 static SIMD_CPPFUNC float4 operator*(const float2 x, const float4x2 y) { return ::simd_mul(x, y); }
514 static SIMD_CPPFUNC float2 operator*(const float3 x, const float2x3 y) { return ::simd_mul(x, y); }
515 static SIMD_CPPFUNC float3 operator*(const float3 x, const float3x3 y) { return ::simd_mul(x, y); }
516 static SIMD_CPPFUNC float4 operator*(const float3 x, const float4x3 y) { return ::simd_mul(x, y); }
517 static SIMD_CPPFUNC float2 operator*(const float4 x, const float2x4 y) { return ::simd_mul(x, y); }
518 static SIMD_CPPFUNC float3 operator*(const float4 x, const float3x4 y) { return ::simd_mul(x, y); }
519 static SIMD_CPPFUNC float4 operator*(const float4 x, const float4x4 y) { return ::simd_mul(x, y); }
520 static SIMD_CPPFUNC float2 operator*(const float2x2 x, const float2 y) { return ::simd_mul(x, y); }
521 static SIMD_CPPFUNC float2 operator*(const float3x2 x, const float3 y) { return ::simd_mul(x, y); }
522 static SIMD_CPPFUNC float2 operator*(const float4x2 x, const float4 y) { return ::simd_mul(x, y); }
523 static SIMD_CPPFUNC float3 operator*(const float2x3 x, const float2 y) { return ::simd_mul(x, y); }
524 static SIMD_CPPFUNC float3 operator*(const float3x3 x, const float3 y) { return ::simd_mul(x, y); }
525 static SIMD_CPPFUNC float3 operator*(const float4x3 x, const float4 y) { return ::simd_mul(x, y); }
526 static SIMD_CPPFUNC float4 operator*(const float2x4 x, const float2 y) { return ::simd_mul(x, y); }
527 static SIMD_CPPFUNC float4 operator*(const float3x4 x, const float3 y) { return ::simd_mul(x, y); }
528 static SIMD_CPPFUNC float4 operator*(const float4x4 x, const float4 y) { return ::simd_mul(x, y); }
529 static SIMD_CPPFUNC float2& operator*=(float2& x, const float2x2 y) { x = ::simd_mul(x, y); return x; }
530 static SIMD_CPPFUNC float3& operator*=(float3& x, const float3x3 y) { x = ::simd_mul(x, y); return x; }
531 static SIMD_CPPFUNC float4& operator*=(float4& x, const float4x4 y) { x = ::simd_mul(x, y); return x; }
532
533 static SIMD_CPPFUNC float2x2 operator*(const float2x2 x, const float2x2 y) { return ::simd_mul(x, y); }
534 static SIMD_CPPFUNC float3x2 operator*(const float2x2 x, const float3x2 y) { return ::simd_mul(x, y); }
535 static SIMD_CPPFUNC float4x2 operator*(const float2x2 x, const float4x2 y) { return ::simd_mul(x, y); }
536 static SIMD_CPPFUNC float2x3 operator*(const float2x3 x, const float2x2 y) { return ::simd_mul(x, y); }
537 static SIMD_CPPFUNC float3x3 operator*(const float2x3 x, const float3x2 y) { return ::simd_mul(x, y); }
538 static SIMD_CPPFUNC float4x3 operator*(const float2x3 x, const float4x2 y) { return ::simd_mul(x, y); }
539 static SIMD_CPPFUNC float2x4 operator*(const float2x4 x, const float2x2 y) { return ::simd_mul(x, y); }
540 static SIMD_CPPFUNC float3x4 operator*(const float2x4 x, const float3x2 y) { return ::simd_mul(x, y); }
541 static SIMD_CPPFUNC float4x4 operator*(const float2x4 x, const float4x2 y) { return ::simd_mul(x, y); }
542 static SIMD_CPPFUNC float2x2 operator*(const float3x2 x, const float2x3 y) { return ::simd_mul(x, y); }
543 static SIMD_CPPFUNC float3x2 operator*(const float3x2 x, const float3x3 y) { return ::simd_mul(x, y); }
544 static SIMD_CPPFUNC float4x2 operator*(const float3x2 x, const float4x3 y) { return ::simd_mul(x, y); }
545 static SIMD_CPPFUNC float2x3 operator*(const float3x3 x, const float2x3 y) { return ::simd_mul(x, y); }
546 static SIMD_CPPFUNC float3x3 operator*(const float3x3 x, const float3x3 y) { return ::simd_mul(x, y); }
547 static SIMD_CPPFUNC float4x3 operator*(const float3x3 x, const float4x3 y) { return ::simd_mul(x, y); }
548 static SIMD_CPPFUNC float2x4 operator*(const float3x4 x, const float2x3 y) { return ::simd_mul(x, y); }
549 static SIMD_CPPFUNC float3x4 operator*(const float3x4 x, const float3x3 y) { return ::simd_mul(x, y); }
550 static SIMD_CPPFUNC float4x4 operator*(const float3x4 x, const float4x3 y) { return ::simd_mul(x, y); }
551 static SIMD_CPPFUNC float2x2 operator*(const float4x2 x, const float2x4 y) { return ::simd_mul(x, y); }
552 static SIMD_CPPFUNC float3x2 operator*(const float4x2 x, const float3x4 y) { return ::simd_mul(x, y); }
553 static SIMD_CPPFUNC float4x2 operator*(const float4x2 x, const float4x4 y) { return ::simd_mul(x, y); }
554 static SIMD_CPPFUNC float2x3 operator*(const float4x3 x, const float2x4 y) { return ::simd_mul(x, y); }
555 static SIMD_CPPFUNC float3x3 operator*(const float4x3 x, const float3x4 y) { return ::simd_mul(x, y); }
556 static SIMD_CPPFUNC float4x3 operator*(const float4x3 x, const float4x4 y) { return ::simd_mul(x, y); }
557 static SIMD_CPPFUNC float2x4 operator*(const float4x4 x, const float2x4 y) { return ::simd_mul(x, y); }
558 static SIMD_CPPFUNC float3x4 operator*(const float4x4 x, const float3x4 y) { return ::simd_mul(x, y); }
559 static SIMD_CPPFUNC float4x4 operator*(const float4x4 x, const float4x4 y) { return ::simd_mul(x, y); }
560 static SIMD_CPPFUNC float2x2& operator*=(float2x2& x, const float2x2 y) { x = ::simd_mul(x, y); return x; }
561 static SIMD_CPPFUNC float2x3& operator*=(float2x3& x, const float2x2 y) { x = ::simd_mul(x, y); return x; }
562 static SIMD_CPPFUNC float2x4& operator*=(float2x4& x, const float2x2 y) { x = ::simd_mul(x, y); return x; }
563 static SIMD_CPPFUNC float3x2& operator*=(float3x2& x, const float3x3 y) { x = ::simd_mul(x, y); return x; }
564 static SIMD_CPPFUNC float3x3& operator*=(float3x3& x, const float3x3 y) { x = ::simd_mul(x, y); return x; }
565 static SIMD_CPPFUNC float3x4& operator*=(float3x4& x, const float3x3 y) { x = ::simd_mul(x, y); return x; }
566 static SIMD_CPPFUNC float4x2& operator*=(float4x2& x, const float4x4 y) { x = ::simd_mul(x, y); return x; }
567 static SIMD_CPPFUNC float4x3& operator*=(float4x3& x, const float4x4 y) { x = ::simd_mul(x, y); return x; }
568 static SIMD_CPPFUNC float4x4& operator*=(float4x4& x, const float4x4 y) { x = ::simd_mul(x, y); return x; }
569
570 static SIMD_CPPFUNC bool operator==(const float2x2& x, const float2x2& y) { return ::simd_equal(x, y); }
571 static SIMD_CPPFUNC bool operator==(const float2x3& x, const float2x3& y) { return ::simd_equal(x, y); }
572 static SIMD_CPPFUNC bool operator==(const float2x4& x, const float2x4& y) { return ::simd_equal(x, y); }
573 static SIMD_CPPFUNC bool operator==(const float3x2& x, const float3x2& y) { return ::simd_equal(x, y); }
574 static SIMD_CPPFUNC bool operator==(const float3x3& x, const float3x3& y) { return ::simd_equal(x, y); }
575 static SIMD_CPPFUNC bool operator==(const float3x4& x, const float3x4& y) { return ::simd_equal(x, y); }
576 static SIMD_CPPFUNC bool operator==(const float4x2& x, const float4x2& y) { return ::simd_equal(x, y); }
577 static SIMD_CPPFUNC bool operator==(const float4x3& x, const float4x3& y) { return ::simd_equal(x, y); }
578 static SIMD_CPPFUNC bool operator==(const float4x4& x, const float4x4& y) { return ::simd_equal(x, y); }
579
580 static SIMD_CPPFUNC bool operator!=(const float2x2& x, const float2x2& y) { return !(x == y); }
581 static SIMD_CPPFUNC bool operator!=(const float2x3& x, const float2x3& y) { return !(x == y); }
582 static SIMD_CPPFUNC bool operator!=(const float2x4& x, const float2x4& y) { return !(x == y); }
583 static SIMD_CPPFUNC bool operator!=(const float3x2& x, const float3x2& y) { return !(x == y); }
584 static SIMD_CPPFUNC bool operator!=(const float3x3& x, const float3x3& y) { return !(x == y); }
585 static SIMD_CPPFUNC bool operator!=(const float3x4& x, const float3x4& y) { return !(x == y); }
586 static SIMD_CPPFUNC bool operator!=(const float4x2& x, const float4x2& y) { return !(x == y); }
587 static SIMD_CPPFUNC bool operator!=(const float4x3& x, const float4x3& y) { return !(x == y); }
588 static SIMD_CPPFUNC bool operator!=(const float4x4& x, const float4x4& y) { return !(x == y); }
589
590 static SIMD_CPPFUNC bool almost_equal_elements(const float2x2 x, const float2x2 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
591 static SIMD_CPPFUNC bool almost_equal_elements(const float2x3 x, const float2x3 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
592 static SIMD_CPPFUNC bool almost_equal_elements(const float2x4 x, const float2x4 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
593 static SIMD_CPPFUNC bool almost_equal_elements(const float3x2 x, const float3x2 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
594 static SIMD_CPPFUNC bool almost_equal_elements(const float3x3 x, const float3x3 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
595 static SIMD_CPPFUNC bool almost_equal_elements(const float3x4 x, const float3x4 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
596 static SIMD_CPPFUNC bool almost_equal_elements(const float4x2 x, const float4x2 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
597 static SIMD_CPPFUNC bool almost_equal_elements(const float4x3 x, const float4x3 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
598 static SIMD_CPPFUNC bool almost_equal_elements(const float4x4 x, const float4x4 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); }
599
600 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float2x2 x, const float2x2 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
601 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float2x3 x, const float2x3 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
602 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float2x4 x, const float2x4 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
603 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float3x2 x, const float3x2 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
604 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float3x3 x, const float3x3 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
605 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float3x4 x, const float3x4 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
606 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float4x2 x, const float4x2 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
607 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float4x3 x, const float4x3 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
608 static SIMD_CPPFUNC bool almost_equal_elements_relative(const float4x4 x, const float4x4 y, const float tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
609
610 static SIMD_CPPFUNC double2x2 operator+(const double2x2 x, const double2x2 y) { return double2x2(::simd_linear_combination(1, x, 1, y)); }
611 static SIMD_CPPFUNC double2x3 operator+(const double2x3 x, const double2x3 y) { return double2x3(::simd_linear_combination(1, x, 1, y)); }
612 static SIMD_CPPFUNC double2x4 operator+(const double2x4 x, const double2x4 y) { return double2x4(::simd_linear_combination(1, x, 1, y)); }
613 static SIMD_CPPFUNC double3x2 operator+(const double3x2 x, const double3x2 y) { return double3x2(::simd_linear_combination(1, x, 1, y)); }
614 static SIMD_CPPFUNC double3x3 operator+(const double3x3 x, const double3x3 y) { return double3x3(::simd_linear_combination(1, x, 1, y)); }
615 static SIMD_CPPFUNC double3x4 operator+(const double3x4 x, const double3x4 y) { return double3x4(::simd_linear_combination(1, x, 1, y)); }
616 static SIMD_CPPFUNC double4x2 operator+(const double4x2 x, const double4x2 y) { return double4x2(::simd_linear_combination(1, x, 1, y)); }
617 static SIMD_CPPFUNC double4x3 operator+(const double4x3 x, const double4x3 y) { return double4x3(::simd_linear_combination(1, x, 1, y)); }
618 static SIMD_CPPFUNC double4x4 operator+(const double4x4 x, const double4x4 y) { return double4x4(::simd_linear_combination(1, x, 1, y)); }
619
620 static SIMD_CPPFUNC double2x2 operator-(const double2x2 x, const double2x2 y) { return double2x2(::simd_linear_combination(1, x, -1, y)); }
621 static SIMD_CPPFUNC double2x3 operator-(const double2x3 x, const double2x3 y) { return double2x3(::simd_linear_combination(1, x, -1, y)); }
622 static SIMD_CPPFUNC double2x4 operator-(const double2x4 x, const double2x4 y) { return double2x4(::simd_linear_combination(1, x, -1, y)); }
623 static SIMD_CPPFUNC double3x2 operator-(const double3x2 x, const double3x2 y) { return double3x2(::simd_linear_combination(1, x, -1, y)); }
624 static SIMD_CPPFUNC double3x3 operator-(const double3x3 x, const double3x3 y) { return double3x3(::simd_linear_combination(1, x, -1, y)); }
625 static SIMD_CPPFUNC double3x4 operator-(const double3x4 x, const double3x4 y) { return double3x4(::simd_linear_combination(1, x, -1, y)); }
626 static SIMD_CPPFUNC double4x2 operator-(const double4x2 x, const double4x2 y) { return double4x2(::simd_linear_combination(1, x, -1, y)); }
627 static SIMD_CPPFUNC double4x3 operator-(const double4x3 x, const double4x3 y) { return double4x3(::simd_linear_combination(1, x, -1, y)); }
628 static SIMD_CPPFUNC double4x4 operator-(const double4x4 x, const double4x4 y) { return double4x4(::simd_linear_combination(1, x, -1, y)); }
629
630 static SIMD_CPPFUNC double2x2& operator+=(double2x2& x, const double2x2 y) { x = x + y; return x; }
631 static SIMD_CPPFUNC double2x3& operator+=(double2x3& x, const double2x3 y) { x = x + y; return x; }
632 static SIMD_CPPFUNC double2x4& operator+=(double2x4& x, const double2x4 y) { x = x + y; return x; }
633 static SIMD_CPPFUNC double3x2& operator+=(double3x2& x, const double3x2 y) { x = x + y; return x; }
634 static SIMD_CPPFUNC double3x3& operator+=(double3x3& x, const double3x3 y) { x = x + y; return x; }
635 static SIMD_CPPFUNC double3x4& operator+=(double3x4& x, const double3x4 y) { x = x + y; return x; }
636 static SIMD_CPPFUNC double4x2& operator+=(double4x2& x, const double4x2 y) { x = x + y; return x; }
637 static SIMD_CPPFUNC double4x3& operator+=(double4x3& x, const double4x3 y) { x = x + y; return x; }
638 static SIMD_CPPFUNC double4x4& operator+=(double4x4& x, const double4x4 y) { x = x + y; return x; }
639
640 static SIMD_CPPFUNC double2x2& operator-=(double2x2& x, const double2x2 y) { x = x - y; return x; }
641 static SIMD_CPPFUNC double2x3& operator-=(double2x3& x, const double2x3 y) { x = x - y; return x; }
642 static SIMD_CPPFUNC double2x4& operator-=(double2x4& x, const double2x4 y) { x = x - y; return x; }
643 static SIMD_CPPFUNC double3x2& operator-=(double3x2& x, const double3x2 y) { x = x - y; return x; }
644 static SIMD_CPPFUNC double3x3& operator-=(double3x3& x, const double3x3 y) { x = x - y; return x; }
645 static SIMD_CPPFUNC double3x4& operator-=(double3x4& x, const double3x4 y) { x = x - y; return x; }
646 static SIMD_CPPFUNC double4x2& operator-=(double4x2& x, const double4x2 y) { x = x - y; return x; }
647 static SIMD_CPPFUNC double4x3& operator-=(double4x3& x, const double4x3 y) { x = x - y; return x; }
648 static SIMD_CPPFUNC double4x4& operator-=(double4x4& x, const double4x4 y) { x = x - y; return x; }
649
650 static SIMD_CPPFUNC double2x2 transpose(const double2x2 x) { return ::simd_transpose(x); }
651 static SIMD_CPPFUNC double2x3 transpose(const double3x2 x) { return ::simd_transpose(x); }
652 static SIMD_CPPFUNC double2x4 transpose(const double4x2 x) { return ::simd_transpose(x); }
653 static SIMD_CPPFUNC double3x2 transpose(const double2x3 x) { return ::simd_transpose(x); }
654 static SIMD_CPPFUNC double3x3 transpose(const double3x3 x) { return ::simd_transpose(x); }
655 static SIMD_CPPFUNC double3x4 transpose(const double4x3 x) { return ::simd_transpose(x); }
656 static SIMD_CPPFUNC double4x2 transpose(const double2x4 x) { return ::simd_transpose(x); }
657 static SIMD_CPPFUNC double4x3 transpose(const double3x4 x) { return ::simd_transpose(x); }
658 static SIMD_CPPFUNC double4x4 transpose(const double4x4 x) { return ::simd_transpose(x); }
659
660 static SIMD_CPPFUNC double determinant(const double2x2 x) { return ::simd_determinant(x); }
661 static SIMD_CPPFUNC double determinant(const double3x3 x) { return ::simd_determinant(x); }
662 static SIMD_CPPFUNC double determinant(const double4x4 x) { return ::simd_determinant(x); }
663
664#pragma clang diagnostic push
665#pragma clang diagnostic ignored "-Wgcc-compat"
666 static SIMD_CPPFUNC double2x2 inverse(const double2x2 x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)) { return ::simd_inverse(x); }
667 static SIMD_CPPFUNC double3x3 inverse(const double3x3 x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)) { return ::simd_inverse(x); }
668 static SIMD_CPPFUNC double4x4 inverse(const double4x4 x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)) { return ::simd_inverse(x); }
669#pragma clang diagnostic pop
670
671 static SIMD_CPPFUNC double2x2 operator*(const double a, const double2x2 x) { return ::simd_mul(a, x); }
672 static SIMD_CPPFUNC double2x3 operator*(const double a, const double2x3 x) { return ::simd_mul(a, x); }
673 static SIMD_CPPFUNC double2x4 operator*(const double a, const double2x4 x) { return ::simd_mul(a, x); }
674 static SIMD_CPPFUNC double3x2 operator*(const double a, const double3x2 x) { return ::simd_mul(a, x); }
675 static SIMD_CPPFUNC double3x3 operator*(const double a, const double3x3 x) { return ::simd_mul(a, x); }
676 static SIMD_CPPFUNC double3x4 operator*(const double a, const double3x4 x) { return ::simd_mul(a, x); }
677 static SIMD_CPPFUNC double4x2 operator*(const double a, const double4x2 x) { return ::simd_mul(a, x); }
678 static SIMD_CPPFUNC double4x3 operator*(const double a, const double4x3 x) { return ::simd_mul(a, x); }
679 static SIMD_CPPFUNC double4x4 operator*(const double a, const double4x4 x) { return ::simd_mul(a, x); }
680 static SIMD_CPPFUNC double2x2 operator*(const double2x2 x, const double a) { return ::simd_mul(a, x); }
681 static SIMD_CPPFUNC double2x3 operator*(const double2x3 x, const double a) { return ::simd_mul(a, x); }
682 static SIMD_CPPFUNC double2x4 operator*(const double2x4 x, const double a) { return ::simd_mul(a, x); }
683 static SIMD_CPPFUNC double3x2 operator*(const double3x2 x, const double a) { return ::simd_mul(a, x); }
684 static SIMD_CPPFUNC double3x3 operator*(const double3x3 x, const double a) { return ::simd_mul(a, x); }
685 static SIMD_CPPFUNC double3x4 operator*(const double3x4 x, const double a) { return ::simd_mul(a, x); }
686 static SIMD_CPPFUNC double4x2 operator*(const double4x2 x, const double a) { return ::simd_mul(a, x); }
687 static SIMD_CPPFUNC double4x3 operator*(const double4x3 x, const double a) { return ::simd_mul(a, x); }
688 static SIMD_CPPFUNC double4x4 operator*(const double4x4 x, const double a) { return ::simd_mul(a, x); }
689 static SIMD_CPPFUNC double2x2& operator*=(double2x2& x, const double a) { x = ::simd_mul(a, x); return x; }
690 static SIMD_CPPFUNC double2x3& operator*=(double2x3& x, const double a) { x = ::simd_mul(a, x); return x; }
691 static SIMD_CPPFUNC double2x4& operator*=(double2x4& x, const double a) { x = ::simd_mul(a, x); return x; }
692 static SIMD_CPPFUNC double3x2& operator*=(double3x2& x, const double a) { x = ::simd_mul(a, x); return x; }
693 static SIMD_CPPFUNC double3x3& operator*=(double3x3& x, const double a) { x = ::simd_mul(a, x); return x; }
694 static SIMD_CPPFUNC double3x4& operator*=(double3x4& x, const double a) { x = ::simd_mul(a, x); return x; }
695 static SIMD_CPPFUNC double4x2& operator*=(double4x2& x, const double a) { x = ::simd_mul(a, x); return x; }
696 static SIMD_CPPFUNC double4x3& operator*=(double4x3& x, const double a) { x = ::simd_mul(a, x); return x; }
697 static SIMD_CPPFUNC double4x4& operator*=(double4x4& x, const double a) { x = ::simd_mul(a, x); return x; }
698
699 static SIMD_CPPFUNC double2 operator*(const double2 x, const double2x2 y) { return ::simd_mul(x, y); }
700 static SIMD_CPPFUNC double3 operator*(const double2 x, const double3x2 y) { return ::simd_mul(x, y); }
701 static SIMD_CPPFUNC double4 operator*(const double2 x, const double4x2 y) { return ::simd_mul(x, y); }
702 static SIMD_CPPFUNC double2 operator*(const double3 x, const double2x3 y) { return ::simd_mul(x, y); }
703 static SIMD_CPPFUNC double3 operator*(const double3 x, const double3x3 y) { return ::simd_mul(x, y); }
704 static SIMD_CPPFUNC double4 operator*(const double3 x, const double4x3 y) { return ::simd_mul(x, y); }
705 static SIMD_CPPFUNC double2 operator*(const double4 x, const double2x4 y) { return ::simd_mul(x, y); }
706 static SIMD_CPPFUNC double3 operator*(const double4 x, const double3x4 y) { return ::simd_mul(x, y); }
707 static SIMD_CPPFUNC double4 operator*(const double4 x, const double4x4 y) { return ::simd_mul(x, y); }
708 static SIMD_CPPFUNC double2 operator*(const double2x2 x, const double2 y) { return ::simd_mul(x, y); }
709 static SIMD_CPPFUNC double2 operator*(const double3x2 x, const double3 y) { return ::simd_mul(x, y); }
710 static SIMD_CPPFUNC double2 operator*(const double4x2 x, const double4 y) { return ::simd_mul(x, y); }
711 static SIMD_CPPFUNC double3 operator*(const double2x3 x, const double2 y) { return ::simd_mul(x, y); }
712 static SIMD_CPPFUNC double3 operator*(const double3x3 x, const double3 y) { return ::simd_mul(x, y); }
713 static SIMD_CPPFUNC double3 operator*(const double4x3 x, const double4 y) { return ::simd_mul(x, y); }
714 static SIMD_CPPFUNC double4 operator*(const double2x4 x, const double2 y) { return ::simd_mul(x, y); }
715 static SIMD_CPPFUNC double4 operator*(const double3x4 x, const double3 y) { return ::simd_mul(x, y); }
716 static SIMD_CPPFUNC double4 operator*(const double4x4 x, const double4 y) { return ::simd_mul(x, y); }
717 static SIMD_CPPFUNC double2& operator*=(double2& x, const double2x2 y) { x = ::simd_mul(x, y); return x; }
718 static SIMD_CPPFUNC double3& operator*=(double3& x, const double3x3 y) { x = ::simd_mul(x, y); return x; }
719 static SIMD_CPPFUNC double4& operator*=(double4& x, const double4x4 y) { x = ::simd_mul(x, y); return x; }
720
721 static SIMD_CPPFUNC double2x2 operator*(const double2x2 x, const double2x2 y) { return ::simd_mul(x, y); }
722 static SIMD_CPPFUNC double3x2 operator*(const double2x2 x, const double3x2 y) { return ::simd_mul(x, y); }
723 static SIMD_CPPFUNC double4x2 operator*(const double2x2 x, const double4x2 y) { return ::simd_mul(x, y); }
724 static SIMD_CPPFUNC double2x3 operator*(const double2x3 x, const double2x2 y) { return ::simd_mul(x, y); }
725 static SIMD_CPPFUNC double3x3 operator*(const double2x3 x, const double3x2 y) { return ::simd_mul(x, y); }
726 static SIMD_CPPFUNC double4x3 operator*(const double2x3 x, const double4x2 y) { return ::simd_mul(x, y); }
727 static SIMD_CPPFUNC double2x4 operator*(const double2x4 x, const double2x2 y) { return ::simd_mul(x, y); }
728 static SIMD_CPPFUNC double3x4 operator*(const double2x4 x, const double3x2 y) { return ::simd_mul(x, y); }
729 static SIMD_CPPFUNC double4x4 operator*(const double2x4 x, const double4x2 y) { return ::simd_mul(x, y); }
730 static SIMD_CPPFUNC double2x2 operator*(const double3x2 x, const double2x3 y) { return ::simd_mul(x, y); }
731 static SIMD_CPPFUNC double3x2 operator*(const double3x2 x, const double3x3 y) { return ::simd_mul(x, y); }
732 static SIMD_CPPFUNC double4x2 operator*(const double3x2 x, const double4x3 y) { return ::simd_mul(x, y); }
733 static SIMD_CPPFUNC double2x3 operator*(const double3x3 x, const double2x3 y) { return ::simd_mul(x, y); }
734 static SIMD_CPPFUNC double3x3 operator*(const double3x3 x, const double3x3 y) { return ::simd_mul(x, y); }
735 static SIMD_CPPFUNC double4x3 operator*(const double3x3 x, const double4x3 y) { return ::simd_mul(x, y); }
736 static SIMD_CPPFUNC double2x4 operator*(const double3x4 x, const double2x3 y) { return ::simd_mul(x, y); }
737 static SIMD_CPPFUNC double3x4 operator*(const double3x4 x, const double3x3 y) { return ::simd_mul(x, y); }
738 static SIMD_CPPFUNC double4x4 operator*(const double3x4 x, const double4x3 y) { return ::simd_mul(x, y); }
739 static SIMD_CPPFUNC double2x2 operator*(const double4x2 x, const double2x4 y) { return ::simd_mul(x, y); }
740 static SIMD_CPPFUNC double3x2 operator*(const double4x2 x, const double3x4 y) { return ::simd_mul(x, y); }
741 static SIMD_CPPFUNC double4x2 operator*(const double4x2 x, const double4x4 y) { return ::simd_mul(x, y); }
742 static SIMD_CPPFUNC double2x3 operator*(const double4x3 x, const double2x4 y) { return ::simd_mul(x, y); }
743 static SIMD_CPPFUNC double3x3 operator*(const double4x3 x, const double3x4 y) { return ::simd_mul(x, y); }
744 static SIMD_CPPFUNC double4x3 operator*(const double4x3 x, const double4x4 y) { return ::simd_mul(x, y); }
745 static SIMD_CPPFUNC double2x4 operator*(const double4x4 x, const double2x4 y) { return ::simd_mul(x, y); }
746 static SIMD_CPPFUNC double3x4 operator*(const double4x4 x, const double3x4 y) { return ::simd_mul(x, y); }
747 static SIMD_CPPFUNC double4x4 operator*(const double4x4 x, const double4x4 y) { return ::simd_mul(x, y); }
748 static SIMD_CPPFUNC double2x2& operator*=(double2x2& x, const double2x2 y) { x = ::simd_mul(x, y); return x; }
749 static SIMD_CPPFUNC double2x3& operator*=(double2x3& x, const double2x2 y) { x = ::simd_mul(x, y); return x; }
750 static SIMD_CPPFUNC double2x4& operator*=(double2x4& x, const double2x2 y) { x = ::simd_mul(x, y); return x; }
751 static SIMD_CPPFUNC double3x2& operator*=(double3x2& x, const double3x3 y) { x = ::simd_mul(x, y); return x; }
752 static SIMD_CPPFUNC double3x3& operator*=(double3x3& x, const double3x3 y) { x = ::simd_mul(x, y); return x; }
753 static SIMD_CPPFUNC double3x4& operator*=(double3x4& x, const double3x3 y) { x = ::simd_mul(x, y); return x; }
754 static SIMD_CPPFUNC double4x2& operator*=(double4x2& x, const double4x4 y) { x = ::simd_mul(x, y); return x; }
755 static SIMD_CPPFUNC double4x3& operator*=(double4x3& x, const double4x4 y) { x = ::simd_mul(x, y); return x; }
756 static SIMD_CPPFUNC double4x4& operator*=(double4x4& x, const double4x4 y) { x = ::simd_mul(x, y); return x; }
757
758 static SIMD_CPPFUNC bool operator==(const double2x2& x, const double2x2& y) { return ::simd_equal(x, y); }
759 static SIMD_CPPFUNC bool operator==(const double2x3& x, const double2x3& y) { return ::simd_equal(x, y); }
760 static SIMD_CPPFUNC bool operator==(const double2x4& x, const double2x4& y) { return ::simd_equal(x, y); }
761 static SIMD_CPPFUNC bool operator==(const double3x2& x, const double3x2& y) { return ::simd_equal(x, y); }
762 static SIMD_CPPFUNC bool operator==(const double3x3& x, const double3x3& y) { return ::simd_equal(x, y); }
763 static SIMD_CPPFUNC bool operator==(const double3x4& x, const double3x4& y) { return ::simd_equal(x, y); }
764 static SIMD_CPPFUNC bool operator==(const double4x2& x, const double4x2& y) { return ::simd_equal(x, y); }
765 static SIMD_CPPFUNC bool operator==(const double4x3& x, const double4x3& y) { return ::simd_equal(x, y); }
766 static SIMD_CPPFUNC bool operator==(const double4x4& x, const double4x4& y) { return ::simd_equal(x, y); }
767
768 static SIMD_CPPFUNC bool operator!=(const double2x2& x, const double2x2& y) { return !(x == y); }
769 static SIMD_CPPFUNC bool operator!=(const double2x3& x, const double2x3& y) { return !(x == y); }
770 static SIMD_CPPFUNC bool operator!=(const double2x4& x, const double2x4& y) { return !(x == y); }
771 static SIMD_CPPFUNC bool operator!=(const double3x2& x, const double3x2& y) { return !(x == y); }
772 static SIMD_CPPFUNC bool operator!=(const double3x3& x, const double3x3& y) { return !(x == y); }
773 static SIMD_CPPFUNC bool operator!=(const double3x4& x, const double3x4& y) { return !(x == y); }
774 static SIMD_CPPFUNC bool operator!=(const double4x2& x, const double4x2& y) { return !(x == y); }
775 static SIMD_CPPFUNC bool operator!=(const double4x3& x, const double4x3& y) { return !(x == y); }
776 static SIMD_CPPFUNC bool operator!=(const double4x4& x, const double4x4& y) { return !(x == y); }
777
778 static SIMD_CPPFUNC bool almost_equal_elements(const double2x2 x, const double2x2 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
779 static SIMD_CPPFUNC bool almost_equal_elements(const double2x3 x, const double2x3 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
780 static SIMD_CPPFUNC bool almost_equal_elements(const double2x4 x, const double2x4 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
781 static SIMD_CPPFUNC bool almost_equal_elements(const double3x2 x, const double3x2 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
782 static SIMD_CPPFUNC bool almost_equal_elements(const double3x3 x, const double3x3 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
783 static SIMD_CPPFUNC bool almost_equal_elements(const double3x4 x, const double3x4 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
784 static SIMD_CPPFUNC bool almost_equal_elements(const double4x2 x, const double4x2 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
785 static SIMD_CPPFUNC bool almost_equal_elements(const double4x3 x, const double4x3 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
786 static SIMD_CPPFUNC bool almost_equal_elements(const double4x4 x, const double4x4 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); }
787
788 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double2x2 x, const double2x2 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
789 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double2x3 x, const double2x3 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
790 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double2x4 x, const double2x4 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
791 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double3x2 x, const double3x2 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
792 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double3x3 x, const double3x3 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
793 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double3x4 x, const double3x4 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
794 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double4x2 x, const double4x2 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
795 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double4x3 x, const double4x3 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
796 static SIMD_CPPFUNC bool almost_equal_elements_relative(const double4x4 x, const double4x4 y, const double tol) { return ::simd_almost_equal_elements_relative(x, y, tol); }
797}
798
799extern "C" {
800#endif /* __cplusplus */
801
802#pragma mark - Implementation
803
804static simd_float2x2 SIMD_CFUNC simd_diagonal_matrix(simd_float2 __x) { simd_float2x2 __r = { .columns[0] = {__x.x,0}, .columns[1] = {0,__x.y} }; return __r; }
805static simd_double2x2 SIMD_CFUNC simd_diagonal_matrix(simd_double2 __x) { simd_double2x2 __r = { .columns[0] = {__x.x,0}, .columns[1] = {0,__x.y} }; return __r; }
806static simd_float3x3 SIMD_CFUNC simd_diagonal_matrix(simd_float3 __x) { simd_float3x3 __r = { .columns[0] = {__x.x,0,0}, .columns[1] = {0,__x.y,0}, .columns[2] = {0,0,__x.z} }; return __r; }
807static simd_double3x3 SIMD_CFUNC simd_diagonal_matrix(simd_double3 __x) { simd_double3x3 __r = { .columns[0] = {__x.x,0,0}, .columns[1] = {0,__x.y,0}, .columns[2] = {0,0,__x.z} }; return __r; }
808static simd_float4x4 SIMD_CFUNC simd_diagonal_matrix(simd_float4 __x) { simd_float4x4 __r = { .columns[0] = {__x.x,0,0,0}, .columns[1] = {0,__x.y,0,0}, .columns[2] = {0,0,__x.z,0}, .columns[3] = {0,0,0,__x.w} }; return __r; }
809static simd_double4x4 SIMD_CFUNC simd_diagonal_matrix(simd_double4 __x) { simd_double4x4 __r = { .columns[0] = {__x.x,0,0,0}, .columns[1] = {0,__x.y,0,0}, .columns[2] = {0,0,__x.z,0}, .columns[3] = {0,0,0,__x.w} }; return __r; }
810
811static simd_float2x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1) { simd_float2x2 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; }
812static simd_float2x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1) { simd_float2x3 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; }
813static simd_float2x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1) { simd_float2x4 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; }
814static simd_double2x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1) { simd_double2x2 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; }
815static simd_double2x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1) { simd_double2x3 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; }
816static simd_double2x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1) { simd_double2x4 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; }
817static simd_float3x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1, simd_float2 col2) { simd_float3x2 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2 }; return __r; }
818static simd_float3x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1, simd_float3 col2) { simd_float3x3 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2 }; return __r; }
819static simd_float3x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1, simd_float4 col2) { simd_float3x4 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2 }; return __r; }
820static simd_double3x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1, simd_double2 col2) { simd_double3x2 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2 }; return __r; }
821static simd_double3x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1, simd_double3 col2) { simd_double3x3 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2 }; return __r; }
822static simd_double3x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1, simd_double4 col2) { simd_double3x4 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2 }; return __r; }
823static simd_float4x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1, simd_float2 col2, simd_float2 col3) { simd_float4x2 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2, .columns[3] = col3 }; return __r; }
824static simd_float4x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1, simd_float3 col2, simd_float3 col3) { simd_float4x3 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2, .columns[3] = col3 }; return __r; }
825static simd_float4x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1, simd_float4 col2, simd_float4 col3) { simd_float4x4 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2, .columns[3] = col3 }; return __r; }
826static simd_double4x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1, simd_double2 col2, simd_double2 col3) { simd_double4x2 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2, .columns[3] = col3 }; return __r; }
827static simd_double4x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1, simd_double3 col2, simd_double3 col3) { simd_double4x3 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2, .columns[3] = col3 }; return __r; }
828static simd_double4x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1, simd_double4 col2, simd_double4 col3) { simd_double4x4 __r = { .columns[0] = col0, .columns[1] = col1, .columns[2] = col2, .columns[3] = col3 }; return __r; }
829
830static simd_float2x2 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1) { return simd_transpose(simd_matrix(row0, row1)); }
831static simd_float3x2 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1) { return simd_transpose(simd_matrix(row0, row1)); }
832static simd_float4x2 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1) { return simd_transpose(simd_matrix(row0, row1)); }
833static simd_double2x2 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1) { return simd_transpose(simd_matrix(row0, row1)); }
834static simd_double3x2 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1) { return simd_transpose(simd_matrix(row0, row1)); }
835static simd_double4x2 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1) { return simd_transpose(simd_matrix(row0, row1)); }
836static simd_float2x3 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1, simd_float2 row2) { return simd_transpose(simd_matrix(row0, row1, row2)); }
837static simd_float3x3 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1, simd_float3 row2) { return simd_transpose(simd_matrix(row0, row1, row2)); }
838static simd_float4x3 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1, simd_float4 row2) { return simd_transpose(simd_matrix(row0, row1, row2)); }
839static simd_double2x3 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1, simd_double2 row2) { return simd_transpose(simd_matrix(row0, row1, row2)); }
840static simd_double3x3 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1, simd_double3 row2) { return simd_transpose(simd_matrix(row0, row1, row2)); }
841static simd_double4x3 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1, simd_double4 row2) { return simd_transpose(simd_matrix(row0, row1, row2)); }
842static simd_float2x4 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1, simd_float2 row2, simd_float2 row3) { return simd_transpose(simd_matrix(row0, row1, row2, row3)); }
843static simd_float3x4 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1, simd_float3 row2, simd_float3 row3) { return simd_transpose(simd_matrix(row0, row1, row2, row3)); }
844static simd_float4x4 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1, simd_float4 row2, simd_float4 row3) { return simd_transpose(simd_matrix(row0, row1, row2, row3)); }
845static simd_double2x4 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1, simd_double2 row2, simd_double2 row3) { return simd_transpose(simd_matrix(row0, row1, row2, row3)); }
846static simd_double3x4 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1, simd_double3 row2, simd_double3 row3) { return simd_transpose(simd_matrix(row0, row1, row2, row3)); }
847static simd_double4x4 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1, simd_double4 row2, simd_double4 row3) { return simd_transpose(simd_matrix(row0, row1, row2, row3)); }
848
849static simd_float3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatf q) {
850 simd_float4x4 r = simd_matrix4x4(q);
851 return (simd_float3x3){ r.columns[0].xyz, r.columns[1].xyz, r.columns[2].xyz };
852}
853
854static simd_float4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatf q) {
855 simd_float4 v = q.vector;
856 simd_float4x4 r = {
857 .columns[0] = { 1 - 2*(v.y*v.y + v.z*v.z),
858 2*(v.x*v.y + v.z*v.w),
859 2*(v.x*v.z - v.y*v.w), 0 },
860 .columns[1] = { 2*(v.x*v.y - v.z*v.w),
861 1 - 2*(v.z*v.z + v.x*v.x),
862 2*(v.y*v.z + v.x*v.w), 0 },
863 .columns[2] = { 2*(v.z*v.x + v.y*v.w),
864 2*(v.y*v.z - v.x*v.w),
865 1 - 2*(v.y*v.y + v.x*v.x), 0 },
866 .columns[3] = { 0, 0, 0, 1 }
867 };
868 return r;
869}
870
871static simd_double3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatd q) {
872 simd_double4x4 r = simd_matrix4x4(q);
873 return (simd_double3x3){ r.columns[0].xyz, r.columns[1].xyz, r.columns[2].xyz };
874}
875
876static simd_double4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatd q) {
877 simd_double4 v = q.vector;
878 simd_double4x4 r = {
879 .columns[0] = { 1 - 2*(v.y*v.y + v.z*v.z),
880 2*(v.x*v.y + v.z*v.w),
881 2*(v.x*v.z - v.y*v.w), 0 },
882 .columns[1] = { 2*(v.x*v.y - v.z*v.w),
883 1 - 2*(v.z*v.z + v.x*v.x),
884 2*(v.y*v.z + v.x*v.w), 0 },
885 .columns[2] = { 2*(v.z*v.x + v.y*v.w),
886 2*(v.y*v.z - v.x*v.w),
887 1 - 2*(v.y*v.y + v.x*v.x), 0 },
888 .columns[3] = { 0, 0, 0, 1 }
889 };
890 return r;
891}
892
893static simd_float2x2 SIMD_CFUNC matrix_scale(float __a, simd_float2x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
894static simd_float3x2 SIMD_CFUNC matrix_scale(float __a, simd_float3x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
895static simd_float4x2 SIMD_CFUNC matrix_scale(float __a, simd_float4x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
896static simd_float2x3 SIMD_CFUNC matrix_scale(float __a, simd_float2x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
897static simd_float3x3 SIMD_CFUNC matrix_scale(float __a, simd_float3x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
898static simd_float4x3 SIMD_CFUNC matrix_scale(float __a, simd_float4x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
899static simd_float2x4 SIMD_CFUNC matrix_scale(float __a, simd_float2x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
900static simd_float3x4 SIMD_CFUNC matrix_scale(float __a, simd_float3x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
901static simd_float4x4 SIMD_CFUNC matrix_scale(float __a, simd_float4x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
902static simd_double2x2 SIMD_CFUNC matrix_scale(double __a, simd_double2x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
903static simd_double3x2 SIMD_CFUNC matrix_scale(double __a, simd_double3x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
904static simd_double4x2 SIMD_CFUNC matrix_scale(double __a, simd_double4x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
905static simd_double2x3 SIMD_CFUNC matrix_scale(double __a, simd_double2x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
906static simd_double3x3 SIMD_CFUNC matrix_scale(double __a, simd_double3x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
907static simd_double4x3 SIMD_CFUNC matrix_scale(double __a, simd_double4x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
908static simd_double2x4 SIMD_CFUNC matrix_scale(double __a, simd_double2x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
909static simd_double3x4 SIMD_CFUNC matrix_scale(double __a, simd_double3x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
910static simd_double4x4 SIMD_CFUNC matrix_scale(double __a, simd_double4x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
911
912static simd_float2x2 SIMD_CFUNC simd_mul(float __a, simd_float2x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
913static simd_float3x2 SIMD_CFUNC simd_mul(float __a, simd_float3x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
914static simd_float4x2 SIMD_CFUNC simd_mul(float __a, simd_float4x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
915static simd_float2x3 SIMD_CFUNC simd_mul(float __a, simd_float2x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
916static simd_float3x3 SIMD_CFUNC simd_mul(float __a, simd_float3x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
917static simd_float4x3 SIMD_CFUNC simd_mul(float __a, simd_float4x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
918static simd_float2x4 SIMD_CFUNC simd_mul(float __a, simd_float2x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
919static simd_float3x4 SIMD_CFUNC simd_mul(float __a, simd_float3x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
920static simd_float4x4 SIMD_CFUNC simd_mul(float __a, simd_float4x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
921static simd_double2x2 SIMD_CFUNC simd_mul(double __a, simd_double2x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
922static simd_double3x2 SIMD_CFUNC simd_mul(double __a, simd_double3x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
923static simd_double4x2 SIMD_CFUNC simd_mul(double __a, simd_double4x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
924static simd_double2x3 SIMD_CFUNC simd_mul(double __a, simd_double2x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
925static simd_double3x3 SIMD_CFUNC simd_mul(double __a, simd_double3x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
926static simd_double4x3 SIMD_CFUNC simd_mul(double __a, simd_double4x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
927static simd_double2x4 SIMD_CFUNC simd_mul(double __a, simd_double2x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; }
928static simd_double3x4 SIMD_CFUNC simd_mul(double __a, simd_double3x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; return __x; }
929static simd_double4x4 SIMD_CFUNC simd_mul(double __a, simd_double4x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; __x.columns[2] *= __a; __x.columns[3] *= __a; return __x; }
930
931static simd_float2x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x2 __x, float __b, simd_float2x2 __y) {
932 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
933 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
934 return __x;
935}
936static simd_float3x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x2 __x, float __b, simd_float3x2 __y) {
937 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
938 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
939 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
940 return __x;
941}
942static simd_float4x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x2 __x, float __b, simd_float4x2 __y) {
943 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
944 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
945 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
946 __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3];
947 return __x;
948}
949static simd_float2x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x3 __x, float __b, simd_float2x3 __y) {
950 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
951 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
952 return __x;
953}
954static simd_float3x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x3 __x, float __b, simd_float3x3 __y) {
955 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
956 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
957 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
958 return __x;
959}
960static simd_float4x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x3 __x, float __b, simd_float4x3 __y) {
961 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
962 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
963 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
964 __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3];
965 return __x;
966}
967static simd_float2x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x4 __x, float __b, simd_float2x4 __y) {
968 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
969 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
970 return __x;
971}
972static simd_float3x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x4 __x, float __b, simd_float3x4 __y) {
973 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
974 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
975 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
976 return __x;
977}
978static simd_float4x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x4 __x, float __b, simd_float4x4 __y) {
979 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
980 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
981 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
982 __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3];
983 return __x;
984}
985static simd_double2x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x2 __x, double __b, simd_double2x2 __y) {
986 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
987 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
988 return __x;
989}
990static simd_double3x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x2 __x, double __b, simd_double3x2 __y) {
991 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
992 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
993 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
994 return __x;
995}
996static simd_double4x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x2 __x, double __b, simd_double4x2 __y) {
997 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
998 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
999 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
1000 __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3];
1001 return __x;
1002}
1003static simd_double2x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x3 __x, double __b, simd_double2x3 __y) {
1004 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
1005 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
1006 return __x;
1007}
1008static simd_double3x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x3 __x, double __b, simd_double3x3 __y) {
1009 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
1010 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
1011 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
1012 return __x;
1013}
1014static simd_double4x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x3 __x, double __b, simd_double4x3 __y) {
1015 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
1016 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
1017 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
1018 __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3];
1019 return __x;
1020}
1021static simd_double2x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x4 __x, double __b, simd_double2x4 __y) {
1022 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
1023 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
1024 return __x;
1025}
1026static simd_double3x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x4 __x, double __b, simd_double3x4 __y) {
1027 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
1028 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
1029 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
1030 return __x;
1031}
1032static simd_double4x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x4 __x, double __b, simd_double4x4 __y) {
1033 __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0];
1034 __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1];
1035 __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2];
1036 __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3];
1037 return __x;
1038}
1039
1040static simd_float2x2 SIMD_CFUNC simd_add(simd_float2x2 __x, simd_float2x2 __y) { return simd_linear_combination(1, __x, 1, __y); }
1041static simd_float3x2 SIMD_CFUNC simd_add(simd_float3x2 __x, simd_float3x2 __y) { return simd_linear_combination(1, __x, 1, __y); }
1042static simd_float4x2 SIMD_CFUNC simd_add(simd_float4x2 __x, simd_float4x2 __y) { return simd_linear_combination(1, __x, 1, __y); }
1043static simd_float2x3 SIMD_CFUNC simd_add(simd_float2x3 __x, simd_float2x3 __y) { return simd_linear_combination(1, __x, 1, __y); }
1044static simd_float3x3 SIMD_CFUNC simd_add(simd_float3x3 __x, simd_float3x3 __y) { return simd_linear_combination(1, __x, 1, __y); }
1045static simd_float4x3 SIMD_CFUNC simd_add(simd_float4x3 __x, simd_float4x3 __y) { return simd_linear_combination(1, __x, 1, __y); }
1046static simd_float2x4 SIMD_CFUNC simd_add(simd_float2x4 __x, simd_float2x4 __y) { return simd_linear_combination(1, __x, 1, __y); }
1047static simd_float3x4 SIMD_CFUNC simd_add(simd_float3x4 __x, simd_float3x4 __y) { return simd_linear_combination(1, __x, 1, __y); }
1048static simd_float4x4 SIMD_CFUNC simd_add(simd_float4x4 __x, simd_float4x4 __y) { return simd_linear_combination(1, __x, 1, __y); }
1049static simd_double2x2 SIMD_CFUNC simd_add(simd_double2x2 __x, simd_double2x2 __y) { return simd_linear_combination(1, __x, 1, __y); }
1050static simd_double3x2 SIMD_CFUNC simd_add(simd_double3x2 __x, simd_double3x2 __y) { return simd_linear_combination(1, __x, 1, __y); }
1051static simd_double4x2 SIMD_CFUNC simd_add(simd_double4x2 __x, simd_double4x2 __y) { return simd_linear_combination(1, __x, 1, __y); }
1052static simd_double2x3 SIMD_CFUNC simd_add(simd_double2x3 __x, simd_double2x3 __y) { return simd_linear_combination(1, __x, 1, __y); }
1053static simd_double3x3 SIMD_CFUNC simd_add(simd_double3x3 __x, simd_double3x3 __y) { return simd_linear_combination(1, __x, 1, __y); }
1054static simd_double4x3 SIMD_CFUNC simd_add(simd_double4x3 __x, simd_double4x3 __y) { return simd_linear_combination(1, __x, 1, __y); }
1055static simd_double2x4 SIMD_CFUNC simd_add(simd_double2x4 __x, simd_double2x4 __y) { return simd_linear_combination(1, __x, 1, __y); }
1056static simd_double3x4 SIMD_CFUNC simd_add(simd_double3x4 __x, simd_double3x4 __y) { return simd_linear_combination(1, __x, 1, __y); }
1057static simd_double4x4 SIMD_CFUNC simd_add(simd_double4x4 __x, simd_double4x4 __y) { return simd_linear_combination(1, __x, 1, __y); }
1058
1059static simd_float2x2 SIMD_CFUNC simd_sub(simd_float2x2 __x, simd_float2x2 __y) { return simd_linear_combination(1, __x, -1, __y); }
1060static simd_float3x2 SIMD_CFUNC simd_sub(simd_float3x2 __x, simd_float3x2 __y) { return simd_linear_combination(1, __x, -1, __y); }
1061static simd_float4x2 SIMD_CFUNC simd_sub(simd_float4x2 __x, simd_float4x2 __y) { return simd_linear_combination(1, __x, -1, __y); }
1062static simd_float2x3 SIMD_CFUNC simd_sub(simd_float2x3 __x, simd_float2x3 __y) { return simd_linear_combination(1, __x, -1, __y); }
1063static simd_float3x3 SIMD_CFUNC simd_sub(simd_float3x3 __x, simd_float3x3 __y) { return simd_linear_combination(1, __x, -1, __y); }
1064static simd_float4x3 SIMD_CFUNC simd_sub(simd_float4x3 __x, simd_float4x3 __y) { return simd_linear_combination(1, __x, -1, __y); }
1065static simd_float2x4 SIMD_CFUNC simd_sub(simd_float2x4 __x, simd_float2x4 __y) { return simd_linear_combination(1, __x, -1, __y); }
1066static simd_float3x4 SIMD_CFUNC simd_sub(simd_float3x4 __x, simd_float3x4 __y) { return simd_linear_combination(1, __x, -1, __y); }
1067static simd_float4x4 SIMD_CFUNC simd_sub(simd_float4x4 __x, simd_float4x4 __y) { return simd_linear_combination(1, __x, -1, __y); }
1068static simd_double2x2 SIMD_CFUNC simd_sub(simd_double2x2 __x, simd_double2x2 __y) { return simd_linear_combination(1, __x, -1, __y); }
1069static simd_double3x2 SIMD_CFUNC simd_sub(simd_double3x2 __x, simd_double3x2 __y) { return simd_linear_combination(1, __x, -1, __y); }
1070static simd_double4x2 SIMD_CFUNC simd_sub(simd_double4x2 __x, simd_double4x2 __y) { return simd_linear_combination(1, __x, -1, __y); }
1071static simd_double2x3 SIMD_CFUNC simd_sub(simd_double2x3 __x, simd_double2x3 __y) { return simd_linear_combination(1, __x, -1, __y); }
1072static simd_double3x3 SIMD_CFUNC simd_sub(simd_double3x3 __x, simd_double3x3 __y) { return simd_linear_combination(1, __x, -1, __y); }
1073static simd_double4x3 SIMD_CFUNC simd_sub(simd_double4x3 __x, simd_double4x3 __y) { return simd_linear_combination(1, __x, -1, __y); }
1074static simd_double2x4 SIMD_CFUNC simd_sub(simd_double2x4 __x, simd_double2x4 __y) { return simd_linear_combination(1, __x, -1, __y); }
1075static simd_double3x4 SIMD_CFUNC simd_sub(simd_double3x4 __x, simd_double3x4 __y) { return simd_linear_combination(1, __x, -1, __y); }
1076static simd_double4x4 SIMD_CFUNC simd_sub(simd_double4x4 __x, simd_double4x4 __y) { return simd_linear_combination(1, __x, -1, __y); }
1077
1078static simd_float2x2 SIMD_CFUNC simd_transpose(simd_float2x2 __x) {
1079#if defined __SSE__
1080 simd_float4 __x0, __x1;
1081 __x0.xy = __x.columns[0];
1082 __x1.xy = __x.columns[1];
1083 simd_float4 __r01 = _mm_unpacklo_ps(__x0, __x1);
1084 return simd_matrix(__r01.lo, __r01.hi);
1085#else
1086 return simd_matrix((simd_float2){__x.columns[0][0], __x.columns[1][0]},
1087 (simd_float2){__x.columns[0][1], __x.columns[1][1]});
1088#endif
1089}
1090
1091static simd_float3x2 SIMD_CFUNC simd_transpose(simd_float2x3 __x) {
1092#if defined __SSE__
1093 simd_float4 __x0, __x1;
1094 __x0.xyz = __x.columns[0];
1095 __x1.xyz = __x.columns[1];
1096 simd_float4 __r01 = _mm_unpacklo_ps(__x0, __x1);
1097 simd_float4 __r2x = _mm_unpackhi_ps(__x0, __x1);
1098 return simd_matrix(__r01.lo, __r01.hi, __r2x.lo);
1099#else
1100 return simd_matrix((simd_float2){__x.columns[0][0], __x.columns[1][0]},
1101 (simd_float2){__x.columns[0][1], __x.columns[1][1]},
1102 (simd_float2){__x.columns[0][2], __x.columns[1][2]});
1103#endif
1104}
1105
1106static simd_float4x2 SIMD_CFUNC simd_transpose(simd_float2x4 __x) {
1107#if defined __SSE__
1108 simd_float4 __r01 = _mm_unpacklo_ps(__x.columns[0], __x.columns[1]);
1109 simd_float4 __r23 = _mm_unpackhi_ps(__x.columns[0], __x.columns[1]);
1110 return simd_matrix(__r01.lo, __r01.hi, __r23.lo, __r23.hi);
1111#else
1112 return simd_matrix((simd_float2){__x.columns[0][0], __x.columns[1][0]},
1113 (simd_float2){__x.columns[0][1], __x.columns[1][1]},
1114 (simd_float2){__x.columns[0][2], __x.columns[1][2]},
1115 (simd_float2){__x.columns[0][3], __x.columns[1][3]});
1116#endif
1117}
1118
1119static simd_float2x3 SIMD_CFUNC simd_transpose(simd_float3x2 __x) {
1120#if defined __SSE__
1121 simd_float4 __x0, __x1, __x2;
1122 __x0.xy = __x.columns[0];
1123 __x1.xy = __x.columns[1];
1124 __x2.xy = __x.columns[2];
1125 simd_float4 __t = _mm_unpacklo_ps(__x0, __x1);
1126 simd_float4 __r0 = _mm_shuffle_ps(__t,__x2,0xc4);
1127 simd_float4 __r1 = _mm_shuffle_ps(__t,__x2,0xde);
1128 return simd_matrix(__r0.xyz, __r1.xyz);
1129#else
1130 return simd_matrix((simd_float3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]},
1131 (simd_float3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]});
1132#endif
1133}
1134
1135static simd_float3x3 SIMD_CFUNC simd_transpose(simd_float3x3 __x) {
1136#if defined __SSE__
1137 simd_float4 __x0, __x1, __x2;
1138 __x0.xyz = __x.columns[0];
1139 __x1.xyz = __x.columns[1];
1140 __x2.xyz = __x.columns[2];
1141 simd_float4 __t0 = _mm_unpacklo_ps(__x0, __x1);
1142 simd_float4 __t1 = _mm_unpackhi_ps(__x0, __x1);
1143 simd_float4 __r0 = __t0; __r0.hi = __x2.lo;
1144 simd_float4 __r1 = _mm_shuffle_ps(__t0, __x2, 0xde);
1145 simd_float4 __r2 = __x2; __r2.lo = __t1.lo;
1146 return simd_matrix(__r0.xyz, __r1.xyz, __r2.xyz);
1147#else
1148 return simd_matrix((simd_float3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]},
1149 (simd_float3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]},
1150 (simd_float3){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2]});
1151#endif
1152}
1153
1154static simd_float4x3 SIMD_CFUNC simd_transpose(simd_float3x4 __x) {
1155#if defined __SSE__
1156 simd_float4 __t0 = _mm_unpacklo_ps(__x.columns[0],__x.columns[1]); /* 00 10 01 11 */
1157 simd_float4 __t1 = _mm_unpackhi_ps(__x.columns[0],__x.columns[1]); /* 02 12 03 13 */
1158 simd_float4 __r0 = __t0; __r0.hi = __x.columns[2].lo;
1159 simd_float4 __r1 = _mm_shuffle_ps(__t0, __x.columns[2], 0xde);
1160 simd_float4 __r2 = __x.columns[2]; __r2.lo = __t1.lo;
1161 simd_float4 __r3 = _mm_shuffle_ps(__t1, __x.columns[2], 0xfe);
1162 return simd_matrix(__r0.xyz, __r1.xyz, __r2.xyz, __r3.xyz);
1163#else
1164 return simd_matrix((simd_float3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]},
1165 (simd_float3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]},
1166 (simd_float3){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2]},
1167 (simd_float3){__x.columns[0][3], __x.columns[1][3], __x.columns[2][3]});
1168#endif
1169}
1170
1171static simd_float2x4 SIMD_CFUNC simd_transpose(simd_float4x2 __x) {
1172#if defined __SSE__
1173 simd_float4 __x0, __x1, __x2, __x3;
1174 __x0.xy = __x.columns[0];
1175 __x1.xy = __x.columns[1];
1176 __x2.xy = __x.columns[2];
1177 __x3.xy = __x.columns[3];
1178 simd_float4 __t0 = _mm_unpacklo_ps(__x0,__x2);
1179 simd_float4 __t1 = _mm_unpacklo_ps(__x1,__x3);
1180 simd_float4 __r0 = _mm_unpacklo_ps(__t0,__t1);
1181 simd_float4 __r1 = _mm_unpackhi_ps(__t0,__t1);
1182 return simd_matrix(__r0,__r1);
1183#else
1184 return simd_matrix((simd_float4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]},
1185 (simd_float4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]});
1186#endif
1187}
1188
1189static simd_float3x4 SIMD_CFUNC simd_transpose(simd_float4x3 __x) {
1190#if defined __SSE__
1191 simd_float4 __x0, __x1, __x2, __x3;
1192 __x0.xyz = __x.columns[0];
1193 __x1.xyz = __x.columns[1];
1194 __x2.xyz = __x.columns[2];
1195 __x3.xyz = __x.columns[3];
1196 simd_float4 __t0 = _mm_unpacklo_ps(__x0,__x2);
1197 simd_float4 __t1 = _mm_unpackhi_ps(__x0,__x2);
1198 simd_float4 __t2 = _mm_unpacklo_ps(__x1,__x3);
1199 simd_float4 __t3 = _mm_unpackhi_ps(__x1,__x3);
1200 simd_float4 __r0 = _mm_unpacklo_ps(__t0,__t2);
1201 simd_float4 __r1 = _mm_unpackhi_ps(__t0,__t2);
1202 simd_float4 __r2 = _mm_unpacklo_ps(__t1,__t3);
1203 return simd_matrix(__r0,__r1,__r2);
1204#else
1205 return simd_matrix((simd_float4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]},
1206 (simd_float4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]},
1207 (simd_float4){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2], __x.columns[3][2]});
1208#endif
1209}
1210
1211static simd_float4x4 SIMD_CFUNC simd_transpose(simd_float4x4 __x) {
1212#if defined __SSE__
1213 simd_float4 __t0 = _mm_unpacklo_ps(__x.columns[0],__x.columns[2]);
1214 simd_float4 __t1 = _mm_unpackhi_ps(__x.columns[0],__x.columns[2]);
1215 simd_float4 __t2 = _mm_unpacklo_ps(__x.columns[1],__x.columns[3]);
1216 simd_float4 __t3 = _mm_unpackhi_ps(__x.columns[1],__x.columns[3]);
1217 simd_float4 __r0 = _mm_unpacklo_ps(__t0,__t2);
1218 simd_float4 __r1 = _mm_unpackhi_ps(__t0,__t2);
1219 simd_float4 __r2 = _mm_unpacklo_ps(__t1,__t3);
1220 simd_float4 __r3 = _mm_unpackhi_ps(__t1,__t3);
1221 return simd_matrix(__r0,__r1,__r2,__r3);
1222#else
1223 return simd_matrix((simd_float4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]},
1224 (simd_float4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]},
1225 (simd_float4){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2], __x.columns[3][2]},
1226 (simd_float4){__x.columns[0][3], __x.columns[1][3], __x.columns[2][3], __x.columns[3][3]});
1227#endif
1228}
1229
1230static simd_double2x2 SIMD_CFUNC simd_transpose(simd_double2x2 __x) {
1231 return simd_matrix((simd_double2){__x.columns[0][0], __x.columns[1][0]},
1232 (simd_double2){__x.columns[0][1], __x.columns[1][1]});
1233}
1234
1235static simd_double3x2 SIMD_CFUNC simd_transpose(simd_double2x3 __x) {
1236 return simd_matrix((simd_double2){__x.columns[0][0], __x.columns[1][0]},
1237 (simd_double2){__x.columns[0][1], __x.columns[1][1]},
1238 (simd_double2){__x.columns[0][2], __x.columns[1][2]});
1239}
1240
1241static simd_double4x2 SIMD_CFUNC simd_transpose(simd_double2x4 __x) {
1242 return simd_matrix((simd_double2){__x.columns[0][0], __x.columns[1][0]},
1243 (simd_double2){__x.columns[0][1], __x.columns[1][1]},
1244 (simd_double2){__x.columns[0][2], __x.columns[1][2]},
1245 (simd_double2){__x.columns[0][3], __x.columns[1][3]});
1246}
1247
1248static simd_double2x3 SIMD_CFUNC simd_transpose(simd_double3x2 __x) {
1249 return simd_matrix((simd_double3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]},
1250 (simd_double3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]});
1251}
1252
1253static simd_double3x3 SIMD_CFUNC simd_transpose(simd_double3x3 __x) {
1254 return simd_matrix((simd_double3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]},
1255 (simd_double3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]},
1256 (simd_double3){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2]});
1257}
1258
1259static simd_double4x3 SIMD_CFUNC simd_transpose(simd_double3x4 __x) {
1260 return simd_matrix((simd_double3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]},
1261 (simd_double3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]},
1262 (simd_double3){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2]},
1263 (simd_double3){__x.columns[0][3], __x.columns[1][3], __x.columns[2][3]});
1264}
1265
1266static simd_double2x4 SIMD_CFUNC simd_transpose(simd_double4x2 __x) {
1267 return simd_matrix((simd_double4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]},
1268 (simd_double4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]});
1269}
1270
1271static simd_double3x4 SIMD_CFUNC simd_transpose(simd_double4x3 __x) {
1272 return simd_matrix((simd_double4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]},
1273 (simd_double4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]},
1274 (simd_double4){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2], __x.columns[3][2]});
1275}
1276
1277static simd_double4x4 SIMD_CFUNC simd_transpose(simd_double4x4 __x) {
1278 return simd_matrix((simd_double4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]},
1279 (simd_double4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]},
1280 (simd_double4){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2], __x.columns[3][2]},
1281 (simd_double4){__x.columns[0][3], __x.columns[1][3], __x.columns[2][3], __x.columns[3][3]});
1282}
1283
1284static simd_float3 SIMD_CFUNC __rotate1( simd_float3 __x) { return __builtin_shufflevector(__x,__x,1,2,0); }
1285static simd_float3 SIMD_CFUNC __rotate2( simd_float3 __x) { return __builtin_shufflevector(__x,__x,2,0,1); }
1286static simd_float4 SIMD_CFUNC __rotate1( simd_float4 __x) { return __builtin_shufflevector(__x,__x,1,2,3,0); }
1287static simd_float4 SIMD_CFUNC __rotate2( simd_float4 __x) { return __builtin_shufflevector(__x,__x,2,3,0,1); }
1288static simd_float4 SIMD_CFUNC __rotate3( simd_float4 __x) { return __builtin_shufflevector(__x,__x,3,0,1,2); }
1289static simd_double3 SIMD_CFUNC __rotate1(simd_double3 __x) { return __builtin_shufflevector(__x,__x,1,2,0); }
1290static simd_double3 SIMD_CFUNC __rotate2(simd_double3 __x) { return __builtin_shufflevector(__x,__x,2,0,1); }
1291static simd_double4 SIMD_CFUNC __rotate1(simd_double4 __x) { return __builtin_shufflevector(__x,__x,1,2,3,0); }
1292static simd_double4 SIMD_CFUNC __rotate2(simd_double4 __x) { return __builtin_shufflevector(__x,__x,2,3,0,1); }
1293static simd_double4 SIMD_CFUNC __rotate3(simd_double4 __x) { return __builtin_shufflevector(__x,__x,3,0,1,2); }
1294
1295static float SIMD_CFUNC simd_determinant( simd_float2x2 __x) { return __x.columns[0][0]*__x.columns[1][1] - __x.columns[0][1]*__x.columns[1][0]; }
1296static double SIMD_CFUNC simd_determinant(simd_double2x2 __x) { return __x.columns[0][0]*__x.columns[1][1] - __x.columns[0][1]*__x.columns[1][0]; }
1297static float SIMD_CFUNC simd_determinant( simd_float3x3 __x) { return simd_reduce_add(__x.columns[0]*(__rotate1(__x.columns[1])*__rotate2(__x.columns[2]) - __rotate2(__x.columns[1])*__rotate1(__x.columns[2]))); }
1298static double SIMD_CFUNC simd_determinant(simd_double3x3 __x) { return simd_reduce_add(__x.columns[0]*(__rotate1(__x.columns[1])*__rotate2(__x.columns[2]) - __rotate2(__x.columns[1])*__rotate1(__x.columns[2]))); }
1299static float SIMD_CFUNC simd_determinant( simd_float4x4 __x) {
1300 simd_float4 codet = __x.columns[0]*(__rotate1(__x.columns[1])*(__rotate2(__x.columns[2])*__rotate3(__x.columns[3])-__rotate3(__x.columns[2])*__rotate2(__x.columns[3])) +
1301 __rotate2(__x.columns[1])*(__rotate3(__x.columns[2])*__rotate1(__x.columns[3])-__rotate1(__x.columns[2])*__rotate3(__x.columns[3])) +
1302 __rotate3(__x.columns[1])*(__rotate1(__x.columns[2])*__rotate2(__x.columns[3])-__rotate2(__x.columns[2])*__rotate1(__x.columns[3])));
1303 return simd_reduce_add(codet.even - codet.odd);
1304}
1305static double SIMD_CFUNC simd_determinant(simd_double4x4 __x) {
1306 simd_double4 codet = __x.columns[0]*(__rotate1(__x.columns[1])*(__rotate2(__x.columns[2])*__rotate3(__x.columns[3])-__rotate3(__x.columns[2])*__rotate2(__x.columns[3])) +
1307 __rotate2(__x.columns[1])*(__rotate3(__x.columns[2])*__rotate1(__x.columns[3])-__rotate1(__x.columns[2])*__rotate3(__x.columns[3])) +
1308 __rotate3(__x.columns[1])*(__rotate1(__x.columns[2])*__rotate2(__x.columns[3])-__rotate2(__x.columns[2])*__rotate1(__x.columns[3])));
1309 return simd_reduce_add(codet.even - codet.odd);
1310}
1311
1312static simd_float2x2 SIMD_CFUNC simd_inverse( simd_float2x2 __x) { return __invert_f2(__x); }
1313static simd_float3x3 SIMD_CFUNC simd_inverse( simd_float3x3 __x) { return __invert_f3(__x); }
1314static simd_float4x4 SIMD_CFUNC simd_inverse( simd_float4x4 __x) { return __invert_f4(__x); }
1315static simd_double2x2 SIMD_CFUNC simd_inverse(simd_double2x2 __x) { return __invert_d2(__x); }
1316static simd_double3x3 SIMD_CFUNC simd_inverse(simd_double3x3 __x) { return __invert_d3(__x); }
1317static simd_double4x4 SIMD_CFUNC simd_inverse(simd_double4x4 __x) { return __invert_d4(__x); }
1318
1319static simd_float2 SIMD_CFUNC simd_mul( simd_float2x2 __x, simd_float2 __y) { simd_float2 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); return __r; }
1320static simd_float3 SIMD_CFUNC simd_mul( simd_float2x3 __x, simd_float2 __y) { simd_float3 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); return __r; }
1321static simd_float4 SIMD_CFUNC simd_mul( simd_float2x4 __x, simd_float2 __y) { simd_float4 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); return __r; }
1322static simd_float2 SIMD_CFUNC simd_mul( simd_float3x2 __x, simd_float3 __y) { simd_float2 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); return __r; }
1323static simd_float3 SIMD_CFUNC simd_mul( simd_float3x3 __x, simd_float3 __y) { simd_float3 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); return __r; }
1324static simd_float4 SIMD_CFUNC simd_mul( simd_float3x4 __x, simd_float3 __y) { simd_float4 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); return __r; }
1325static simd_float2 SIMD_CFUNC simd_mul( simd_float4x2 __x, simd_float4 __y) { simd_float2 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); __r = simd_muladd( __x.columns[3], __y[3],__r); return __r; }
1326static simd_float3 SIMD_CFUNC simd_mul( simd_float4x3 __x, simd_float4 __y) { simd_float3 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); __r = simd_muladd( __x.columns[3], __y[3],__r); return __r; }
1327static simd_float4 SIMD_CFUNC simd_mul( simd_float4x4 __x, simd_float4 __y) { simd_float4 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); __r = simd_muladd( __x.columns[3], __y[3],__r); return __r; }
1328static simd_double2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double2 __y) { simd_double2 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); return __r; }
1329static simd_double3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double2 __y) { simd_double3 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); return __r; }
1330static simd_double4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double2 __y) { simd_double4 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); return __r; }
1331static simd_double2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double3 __y) { simd_double2 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); return __r; }
1332static simd_double3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double3 __y) { simd_double3 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); return __r; }
1333static simd_double4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double3 __y) { simd_double4 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); return __r; }
1334static simd_double2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double4 __y) { simd_double2 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); __r = simd_muladd( __x.columns[3], __y[3],__r); return __r; }
1335static simd_double3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double4 __y) { simd_double3 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); __r = simd_muladd( __x.columns[3], __y[3],__r); return __r; }
1336static simd_double4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double4 __y) { simd_double4 __r = __x.columns[0]*__y[0]; __r = simd_muladd( __x.columns[1], __y[1],__r); __r = simd_muladd( __x.columns[2], __y[2],__r); __r = simd_muladd( __x.columns[3], __y[3],__r); return __r; }
1337
1338static simd_float2 SIMD_CFUNC simd_mul( simd_float2 __x, simd_float2x2 __y) { return simd_mul(simd_transpose(__y), __x); }
1339static simd_float3 SIMD_CFUNC simd_mul( simd_float2 __x, simd_float3x2 __y) { return simd_mul(simd_transpose(__y), __x); }
1340static simd_float4 SIMD_CFUNC simd_mul( simd_float2 __x, simd_float4x2 __y) { return simd_mul(simd_transpose(__y), __x); }
1341static simd_float2 SIMD_CFUNC simd_mul( simd_float3 __x, simd_float2x3 __y) { return simd_mul(simd_transpose(__y), __x); }
1342static simd_float3 SIMD_CFUNC simd_mul( simd_float3 __x, simd_float3x3 __y) { return simd_mul(simd_transpose(__y), __x); }
1343static simd_float4 SIMD_CFUNC simd_mul( simd_float3 __x, simd_float4x3 __y) { return simd_mul(simd_transpose(__y), __x); }
1344static simd_float2 SIMD_CFUNC simd_mul( simd_float4 __x, simd_float2x4 __y) { return simd_mul(simd_transpose(__y), __x); }
1345static simd_float3 SIMD_CFUNC simd_mul( simd_float4 __x, simd_float3x4 __y) { return simd_mul(simd_transpose(__y), __x); }
1346static simd_float4 SIMD_CFUNC simd_mul( simd_float4 __x, simd_float4x4 __y) { return simd_mul(simd_transpose(__y), __x); }
1347static simd_double2 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double2x2 __y) { return simd_mul(simd_transpose(__y), __x); }
1348static simd_double3 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double3x2 __y) { return simd_mul(simd_transpose(__y), __x); }
1349static simd_double4 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double4x2 __y) { return simd_mul(simd_transpose(__y), __x); }
1350static simd_double2 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double2x3 __y) { return simd_mul(simd_transpose(__y), __x); }
1351static simd_double3 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double3x3 __y) { return simd_mul(simd_transpose(__y), __x); }
1352static simd_double4 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double4x3 __y) { return simd_mul(simd_transpose(__y), __x); }
1353static simd_double2 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double2x4 __y) { return simd_mul(simd_transpose(__y), __x); }
1354static simd_double3 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double3x4 __y) { return simd_mul(simd_transpose(__y), __x); }
1355static simd_double4 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double4x4 __y) { return simd_mul(simd_transpose(__y), __x); }
1356
1357static simd_float2x2 SIMD_CFUNC simd_mul( simd_float2x2 __x, simd_float2x2 __y) { simd_float2x2 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1358static simd_double2x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double2x2 __y) { simd_double2x2 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1359static simd_float2x3 SIMD_CFUNC simd_mul( simd_float2x3 __x, simd_float2x2 __y) { simd_float2x3 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1360static simd_double2x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double2x2 __y) { simd_double2x3 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1361static simd_float2x4 SIMD_CFUNC simd_mul( simd_float2x4 __x, simd_float2x2 __y) { simd_float2x4 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1362static simd_double2x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double2x2 __y) { simd_double2x4 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1363static simd_float2x2 SIMD_CFUNC simd_mul( simd_float3x2 __x, simd_float2x3 __y) { simd_float2x2 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1364static simd_double2x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double2x3 __y) { simd_double2x2 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1365static simd_float2x3 SIMD_CFUNC simd_mul( simd_float3x3 __x, simd_float2x3 __y) { simd_float2x3 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1366static simd_double2x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double2x3 __y) { simd_double2x3 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1367static simd_float2x4 SIMD_CFUNC simd_mul( simd_float3x4 __x, simd_float2x3 __y) { simd_float2x4 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1368static simd_double2x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double2x3 __y) { simd_double2x4 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1369static simd_float2x2 SIMD_CFUNC simd_mul( simd_float4x2 __x, simd_float2x4 __y) { simd_float2x2 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1370static simd_double2x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double2x4 __y) { simd_double2x2 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1371static simd_float2x3 SIMD_CFUNC simd_mul( simd_float4x3 __x, simd_float2x4 __y) { simd_float2x3 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1372static simd_double2x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double2x4 __y) { simd_double2x3 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1373static simd_float2x4 SIMD_CFUNC simd_mul( simd_float4x4 __x, simd_float2x4 __y) { simd_float2x4 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1374static simd_double2x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double2x4 __y) { simd_double2x4 __r; for (int i=0; i<2; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1375
1376static simd_float3x2 SIMD_CFUNC simd_mul( simd_float2x2 __x, simd_float3x2 __y) { simd_float3x2 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1377static simd_double3x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double3x2 __y) { simd_double3x2 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1378static simd_float3x3 SIMD_CFUNC simd_mul( simd_float2x3 __x, simd_float3x2 __y) { simd_float3x3 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1379static simd_double3x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double3x2 __y) { simd_double3x3 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1380static simd_float3x4 SIMD_CFUNC simd_mul( simd_float2x4 __x, simd_float3x2 __y) { simd_float3x4 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1381static simd_double3x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double3x2 __y) { simd_double3x4 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1382static simd_float3x2 SIMD_CFUNC simd_mul( simd_float3x2 __x, simd_float3x3 __y) { simd_float3x2 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1383static simd_double3x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double3x3 __y) { simd_double3x2 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1384static simd_float3x3 SIMD_CFUNC simd_mul( simd_float3x3 __x, simd_float3x3 __y) { simd_float3x3 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1385static simd_double3x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double3x3 __y) { simd_double3x3 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1386static simd_float3x4 SIMD_CFUNC simd_mul( simd_float3x4 __x, simd_float3x3 __y) { simd_float3x4 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1387static simd_double3x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double3x3 __y) { simd_double3x4 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1388static simd_float3x2 SIMD_CFUNC simd_mul( simd_float4x2 __x, simd_float3x4 __y) { simd_float3x2 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1389static simd_double3x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double3x4 __y) { simd_double3x2 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1390static simd_float3x3 SIMD_CFUNC simd_mul( simd_float4x3 __x, simd_float3x4 __y) { simd_float3x3 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1391static simd_double3x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double3x4 __y) { simd_double3x3 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1392static simd_float3x4 SIMD_CFUNC simd_mul( simd_float4x4 __x, simd_float3x4 __y) { simd_float3x4 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1393static simd_double3x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double3x4 __y) { simd_double3x4 __r; for (int i=0; i<3; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1394
1395static simd_float4x2 SIMD_CFUNC simd_mul( simd_float2x2 __x, simd_float4x2 __y) { simd_float4x2 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1396static simd_double4x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double4x2 __y) { simd_double4x2 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1397static simd_float4x3 SIMD_CFUNC simd_mul( simd_float2x3 __x, simd_float4x2 __y) { simd_float4x3 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1398static simd_double4x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double4x2 __y) { simd_double4x3 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1399static simd_float4x4 SIMD_CFUNC simd_mul( simd_float2x4 __x, simd_float4x2 __y) { simd_float4x4 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1400static simd_double4x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double4x2 __y) { simd_double4x4 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1401static simd_float4x2 SIMD_CFUNC simd_mul( simd_float3x2 __x, simd_float4x3 __y) { simd_float4x2 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1402static simd_double4x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double4x3 __y) { simd_double4x2 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1403static simd_float4x3 SIMD_CFUNC simd_mul( simd_float3x3 __x, simd_float4x3 __y) { simd_float4x3 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1404static simd_double4x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double4x3 __y) { simd_double4x3 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1405static simd_float4x4 SIMD_CFUNC simd_mul( simd_float3x4 __x, simd_float4x3 __y) { simd_float4x4 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1406static simd_double4x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double4x3 __y) { simd_double4x4 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1407static simd_float4x2 SIMD_CFUNC simd_mul( simd_float4x2 __x, simd_float4x4 __y) { simd_float4x2 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1408static simd_double4x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double4x4 __y) { simd_double4x2 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1409static simd_float4x3 SIMD_CFUNC simd_mul( simd_float4x3 __x, simd_float4x4 __y) { simd_float4x3 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1410static simd_double4x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double4x4 __y) { simd_double4x3 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1411static simd_float4x4 SIMD_CFUNC simd_mul( simd_float4x4 __x, simd_float4x4 __y) { simd_float4x4 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1412static simd_double4x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double4x4 __y) { simd_double4x4 __r; for (int i=0; i<4; ++i) __r.columns[i] = simd_mul(__x, __y.columns[i]); return __r; }
1413
1414static simd_float2 SIMD_CFUNC matrix_multiply( simd_float2x2 __x, simd_float2 __y) { return simd_mul(__x, __y); }
1415static simd_float3 SIMD_CFUNC matrix_multiply( simd_float2x3 __x, simd_float2 __y) { return simd_mul(__x, __y); }
1416static simd_float4 SIMD_CFUNC matrix_multiply( simd_float2x4 __x, simd_float2 __y) { return simd_mul(__x, __y); }
1417static simd_float2 SIMD_CFUNC matrix_multiply( simd_float3x2 __x, simd_float3 __y) { return simd_mul(__x, __y); }
1418static simd_float3 SIMD_CFUNC matrix_multiply( simd_float3x3 __x, simd_float3 __y) { return simd_mul(__x, __y); }
1419static simd_float4 SIMD_CFUNC matrix_multiply( simd_float3x4 __x, simd_float3 __y) { return simd_mul(__x, __y); }
1420static simd_float2 SIMD_CFUNC matrix_multiply( simd_float4x2 __x, simd_float4 __y) { return simd_mul(__x, __y); }
1421static simd_float3 SIMD_CFUNC matrix_multiply( simd_float4x3 __x, simd_float4 __y) { return simd_mul(__x, __y); }
1422static simd_float4 SIMD_CFUNC matrix_multiply( simd_float4x4 __x, simd_float4 __y) { return simd_mul(__x, __y); }
1423static simd_double2 SIMD_CFUNC matrix_multiply(simd_double2x2 __x, simd_double2 __y) { return simd_mul(__x, __y); }
1424static simd_double3 SIMD_CFUNC matrix_multiply(simd_double2x3 __x, simd_double2 __y) { return simd_mul(__x, __y); }
1425static simd_double4 SIMD_CFUNC matrix_multiply(simd_double2x4 __x, simd_double2 __y) { return simd_mul(__x, __y); }
1426static simd_double2 SIMD_CFUNC matrix_multiply(simd_double3x2 __x, simd_double3 __y) { return simd_mul(__x, __y); }
1427static simd_double3 SIMD_CFUNC matrix_multiply(simd_double3x3 __x, simd_double3 __y) { return simd_mul(__x, __y); }
1428static simd_double4 SIMD_CFUNC matrix_multiply(simd_double3x4 __x, simd_double3 __y) { return simd_mul(__x, __y); }
1429static simd_double2 SIMD_CFUNC matrix_multiply(simd_double4x2 __x, simd_double4 __y) { return simd_mul(__x, __y); }
1430static simd_double3 SIMD_CFUNC matrix_multiply(simd_double4x3 __x, simd_double4 __y) { return simd_mul(__x, __y); }
1431static simd_double4 SIMD_CFUNC matrix_multiply(simd_double4x4 __x, simd_double4 __y) { return simd_mul(__x, __y); }
1432
1433static simd_float2 SIMD_CFUNC matrix_multiply( simd_float2 __x, simd_float2x2 __y) { return simd_mul(__x, __y); }
1434static simd_float3 SIMD_CFUNC matrix_multiply( simd_float2 __x, simd_float3x2 __y) { return simd_mul(__x, __y); }
1435static simd_float4 SIMD_CFUNC matrix_multiply( simd_float2 __x, simd_float4x2 __y) { return simd_mul(__x, __y); }
1436static simd_float2 SIMD_CFUNC matrix_multiply( simd_float3 __x, simd_float2x3 __y) { return simd_mul(__x, __y); }
1437static simd_float3 SIMD_CFUNC matrix_multiply( simd_float3 __x, simd_float3x3 __y) { return simd_mul(__x, __y); }
1438static simd_float4 SIMD_CFUNC matrix_multiply( simd_float3 __x, simd_float4x3 __y) { return simd_mul(__x, __y); }
1439static simd_float2 SIMD_CFUNC matrix_multiply( simd_float4 __x, simd_float2x4 __y) { return simd_mul(__x, __y); }
1440static simd_float3 SIMD_CFUNC matrix_multiply( simd_float4 __x, simd_float3x4 __y) { return simd_mul(__x, __y); }
1441static simd_float4 SIMD_CFUNC matrix_multiply( simd_float4 __x, simd_float4x4 __y) { return simd_mul(__x, __y); }
1442static simd_double2 SIMD_CFUNC matrix_multiply(simd_double2 __x, simd_double2x2 __y) { return simd_mul(__x, __y); }
1443static simd_double3 SIMD_CFUNC matrix_multiply(simd_double2 __x, simd_double3x2 __y) { return simd_mul(__x, __y); }
1444static simd_double4 SIMD_CFUNC matrix_multiply(simd_double2 __x, simd_double4x2 __y) { return simd_mul(__x, __y); }
1445static simd_double2 SIMD_CFUNC matrix_multiply(simd_double3 __x, simd_double2x3 __y) { return simd_mul(__x, __y); }
1446static simd_double3 SIMD_CFUNC matrix_multiply(simd_double3 __x, simd_double3x3 __y) { return simd_mul(__x, __y); }
1447static simd_double4 SIMD_CFUNC matrix_multiply(simd_double3 __x, simd_double4x3 __y) { return simd_mul(__x, __y); }
1448static simd_double2 SIMD_CFUNC matrix_multiply(simd_double4 __x, simd_double2x4 __y) { return simd_mul(__x, __y); }
1449static simd_double3 SIMD_CFUNC matrix_multiply(simd_double4 __x, simd_double3x4 __y) { return simd_mul(__x, __y); }
1450static simd_double4 SIMD_CFUNC matrix_multiply(simd_double4 __x, simd_double4x4 __y) { return simd_mul(__x, __y); }
1451
1452static simd_float2x2 SIMD_CFUNC matrix_multiply( simd_float2x2 __x, simd_float2x2 __y) { return simd_mul(__x, __y); }
1453static simd_double2x2 SIMD_CFUNC matrix_multiply(simd_double2x2 __x, simd_double2x2 __y) { return simd_mul(__x, __y); }
1454static simd_float2x3 SIMD_CFUNC matrix_multiply( simd_float2x3 __x, simd_float2x2 __y) { return simd_mul(__x, __y); }
1455static simd_double2x3 SIMD_CFUNC matrix_multiply(simd_double2x3 __x, simd_double2x2 __y) { return simd_mul(__x, __y); }
1456static simd_float2x4 SIMD_CFUNC matrix_multiply( simd_float2x4 __x, simd_float2x2 __y) { return simd_mul(__x, __y); }
1457static simd_double2x4 SIMD_CFUNC matrix_multiply(simd_double2x4 __x, simd_double2x2 __y) { return simd_mul(__x, __y); }
1458static simd_float2x2 SIMD_CFUNC matrix_multiply( simd_float3x2 __x, simd_float2x3 __y) { return simd_mul(__x, __y); }
1459static simd_double2x2 SIMD_CFUNC matrix_multiply(simd_double3x2 __x, simd_double2x3 __y) { return simd_mul(__x, __y); }
1460static simd_float2x3 SIMD_CFUNC matrix_multiply( simd_float3x3 __x, simd_float2x3 __y) { return simd_mul(__x, __y); }
1461static simd_double2x3 SIMD_CFUNC matrix_multiply(simd_double3x3 __x, simd_double2x3 __y) { return simd_mul(__x, __y); }
1462static simd_float2x4 SIMD_CFUNC matrix_multiply( simd_float3x4 __x, simd_float2x3 __y) { return simd_mul(__x, __y); }
1463static simd_double2x4 SIMD_CFUNC matrix_multiply(simd_double3x4 __x, simd_double2x3 __y) { return simd_mul(__x, __y); }
1464static simd_float2x2 SIMD_CFUNC matrix_multiply( simd_float4x2 __x, simd_float2x4 __y) { return simd_mul(__x, __y); }
1465static simd_double2x2 SIMD_CFUNC matrix_multiply(simd_double4x2 __x, simd_double2x4 __y) { return simd_mul(__x, __y); }
1466static simd_float2x3 SIMD_CFUNC matrix_multiply( simd_float4x3 __x, simd_float2x4 __y) { return simd_mul(__x, __y); }
1467static simd_double2x3 SIMD_CFUNC matrix_multiply(simd_double4x3 __x, simd_double2x4 __y) { return simd_mul(__x, __y); }
1468static simd_float2x4 SIMD_CFUNC matrix_multiply( simd_float4x4 __x, simd_float2x4 __y) { return simd_mul(__x, __y); }
1469static simd_double2x4 SIMD_CFUNC matrix_multiply(simd_double4x4 __x, simd_double2x4 __y) { return simd_mul(__x, __y); }
1470
1471static simd_float3x2 SIMD_CFUNC matrix_multiply( simd_float2x2 __x, simd_float3x2 __y) { return simd_mul(__x, __y); }
1472static simd_double3x2 SIMD_CFUNC matrix_multiply(simd_double2x2 __x, simd_double3x2 __y) { return simd_mul(__x, __y); }
1473static simd_float3x3 SIMD_CFUNC matrix_multiply( simd_float2x3 __x, simd_float3x2 __y) { return simd_mul(__x, __y); }
1474static simd_double3x3 SIMD_CFUNC matrix_multiply(simd_double2x3 __x, simd_double3x2 __y) { return simd_mul(__x, __y); }
1475static simd_float3x4 SIMD_CFUNC matrix_multiply( simd_float2x4 __x, simd_float3x2 __y) { return simd_mul(__x, __y); }
1476static simd_double3x4 SIMD_CFUNC matrix_multiply(simd_double2x4 __x, simd_double3x2 __y) { return simd_mul(__x, __y); }
1477static simd_float3x2 SIMD_CFUNC matrix_multiply( simd_float3x2 __x, simd_float3x3 __y) { return simd_mul(__x, __y); }
1478static simd_double3x2 SIMD_CFUNC matrix_multiply(simd_double3x2 __x, simd_double3x3 __y) { return simd_mul(__x, __y); }
1479static simd_float3x3 SIMD_CFUNC matrix_multiply( simd_float3x3 __x, simd_float3x3 __y) { return simd_mul(__x, __y); }
1480static simd_double3x3 SIMD_CFUNC matrix_multiply(simd_double3x3 __x, simd_double3x3 __y) { return simd_mul(__x, __y); }
1481static simd_float3x4 SIMD_CFUNC matrix_multiply( simd_float3x4 __x, simd_float3x3 __y) { return simd_mul(__x, __y); }
1482static simd_double3x4 SIMD_CFUNC matrix_multiply(simd_double3x4 __x, simd_double3x3 __y) { return simd_mul(__x, __y); }
1483static simd_float3x2 SIMD_CFUNC matrix_multiply( simd_float4x2 __x, simd_float3x4 __y) { return simd_mul(__x, __y); }
1484static simd_double3x2 SIMD_CFUNC matrix_multiply(simd_double4x2 __x, simd_double3x4 __y) { return simd_mul(__x, __y); }
1485static simd_float3x3 SIMD_CFUNC matrix_multiply( simd_float4x3 __x, simd_float3x4 __y) { return simd_mul(__x, __y); }
1486static simd_double3x3 SIMD_CFUNC matrix_multiply(simd_double4x3 __x, simd_double3x4 __y) { return simd_mul(__x, __y); }
1487static simd_float3x4 SIMD_CFUNC matrix_multiply( simd_float4x4 __x, simd_float3x4 __y) { return simd_mul(__x, __y); }
1488static simd_double3x4 SIMD_CFUNC matrix_multiply(simd_double4x4 __x, simd_double3x4 __y) { return simd_mul(__x, __y); }
1489
1490static simd_float4x2 SIMD_CFUNC matrix_multiply( simd_float2x2 __x, simd_float4x2 __y) { return simd_mul(__x, __y); }
1491static simd_double4x2 SIMD_CFUNC matrix_multiply(simd_double2x2 __x, simd_double4x2 __y) { return simd_mul(__x, __y); }
1492static simd_float4x3 SIMD_CFUNC matrix_multiply( simd_float2x3 __x, simd_float4x2 __y) { return simd_mul(__x, __y); }
1493static simd_double4x3 SIMD_CFUNC matrix_multiply(simd_double2x3 __x, simd_double4x2 __y) { return simd_mul(__x, __y); }
1494static simd_float4x4 SIMD_CFUNC matrix_multiply( simd_float2x4 __x, simd_float4x2 __y) { return simd_mul(__x, __y); }
1495static simd_double4x4 SIMD_CFUNC matrix_multiply(simd_double2x4 __x, simd_double4x2 __y) { return simd_mul(__x, __y); }
1496static simd_float4x2 SIMD_CFUNC matrix_multiply( simd_float3x2 __x, simd_float4x3 __y) { return simd_mul(__x, __y); }
1497static simd_double4x2 SIMD_CFUNC matrix_multiply(simd_double3x2 __x, simd_double4x3 __y) { return simd_mul(__x, __y); }
1498static simd_float4x3 SIMD_CFUNC matrix_multiply( simd_float3x3 __x, simd_float4x3 __y) { return simd_mul(__x, __y); }
1499static simd_double4x3 SIMD_CFUNC matrix_multiply(simd_double3x3 __x, simd_double4x3 __y) { return simd_mul(__x, __y); }
1500static simd_float4x4 SIMD_CFUNC matrix_multiply( simd_float3x4 __x, simd_float4x3 __y) { return simd_mul(__x, __y); }
1501static simd_double4x4 SIMD_CFUNC matrix_multiply(simd_double3x4 __x, simd_double4x3 __y) { return simd_mul(__x, __y); }
1502static simd_float4x2 SIMD_CFUNC matrix_multiply( simd_float4x2 __x, simd_float4x4 __y) { return simd_mul(__x, __y); }
1503static simd_double4x2 SIMD_CFUNC matrix_multiply(simd_double4x2 __x, simd_double4x4 __y) { return simd_mul(__x, __y); }
1504static simd_float4x3 SIMD_CFUNC matrix_multiply( simd_float4x3 __x, simd_float4x4 __y) { return simd_mul(__x, __y); }
1505static simd_double4x3 SIMD_CFUNC matrix_multiply(simd_double4x3 __x, simd_double4x4 __y) { return simd_mul(__x, __y); }
1506static simd_float4x4 SIMD_CFUNC matrix_multiply( simd_float4x4 __x, simd_float4x4 __y) { return simd_mul(__x, __y); }
1507static simd_double4x4 SIMD_CFUNC matrix_multiply(simd_double4x4 __x, simd_double4x4 __y) { return simd_mul(__x, __y); }
1508
1509static simd_bool SIMD_CFUNC simd_equal(simd_float2x2 __x, simd_float2x2 __y) {
1510 return simd_all((__x.columns[0] == __y.columns[0]) &
1511 (__x.columns[1] == __y.columns[1]));
1512}
1513static simd_bool SIMD_CFUNC simd_equal(simd_float2x3 __x, simd_float2x3 __y) {
1514 return simd_all((__x.columns[0] == __y.columns[0]) &
1515 (__x.columns[1] == __y.columns[1]));
1516}
1517static simd_bool SIMD_CFUNC simd_equal(simd_float2x4 __x, simd_float2x4 __y) {
1518 return simd_all((__x.columns[0] == __y.columns[0]) &
1519 (__x.columns[1] == __y.columns[1]));
1520}
1521static simd_bool SIMD_CFUNC simd_equal(simd_float3x2 __x, simd_float3x2 __y) {
1522 return simd_all((__x.columns[0] == __y.columns[0]) &
1523 (__x.columns[1] == __y.columns[1]) &
1524 (__x.columns[2] == __y.columns[2]));
1525}
1526static simd_bool SIMD_CFUNC simd_equal(simd_float3x3 __x, simd_float3x3 __y) {
1527 return simd_all((__x.columns[0] == __y.columns[0]) &
1528 (__x.columns[1] == __y.columns[1]) &
1529 (__x.columns[2] == __y.columns[2]));
1530}
1531static simd_bool SIMD_CFUNC simd_equal(simd_float3x4 __x, simd_float3x4 __y) {
1532 return simd_all((__x.columns[0] == __y.columns[0]) &
1533 (__x.columns[1] == __y.columns[1]) &
1534 (__x.columns[2] == __y.columns[2]));
1535}
1536static simd_bool SIMD_CFUNC simd_equal(simd_float4x2 __x, simd_float4x2 __y) {
1537 return simd_all((__x.columns[0] == __y.columns[0]) &
1538 (__x.columns[1] == __y.columns[1]) &
1539 (__x.columns[2] == __y.columns[2]) &
1540 (__x.columns[3] == __y.columns[3]));
1541}
1542static simd_bool SIMD_CFUNC simd_equal(simd_float4x3 __x, simd_float4x3 __y) {
1543 return simd_all((__x.columns[0] == __y.columns[0]) &
1544 (__x.columns[1] == __y.columns[1]) &
1545 (__x.columns[2] == __y.columns[2]) &
1546 (__x.columns[3] == __y.columns[3]));
1547}
1548static simd_bool SIMD_CFUNC simd_equal(simd_float4x4 __x, simd_float4x4 __y) {
1549 return simd_all((__x.columns[0] == __y.columns[0]) &
1550 (__x.columns[1] == __y.columns[1]) &
1551 (__x.columns[2] == __y.columns[2]) &
1552 (__x.columns[3] == __y.columns[3]));
1553}
1554static simd_bool SIMD_CFUNC simd_equal(simd_double2x2 __x, simd_double2x2 __y) {
1555 return simd_all((__x.columns[0] == __y.columns[0]) &
1556 (__x.columns[1] == __y.columns[1]));
1557}
1558static simd_bool SIMD_CFUNC simd_equal(simd_double2x3 __x, simd_double2x3 __y) {
1559 return simd_all((__x.columns[0] == __y.columns[0]) &
1560 (__x.columns[1] == __y.columns[1]));
1561}
1562static simd_bool SIMD_CFUNC simd_equal(simd_double2x4 __x, simd_double2x4 __y) {
1563 return simd_all((__x.columns[0] == __y.columns[0]) &
1564 (__x.columns[1] == __y.columns[1]));
1565}
1566static simd_bool SIMD_CFUNC simd_equal(simd_double3x2 __x, simd_double3x2 __y) {
1567 return simd_all((__x.columns[0] == __y.columns[0]) &
1568 (__x.columns[1] == __y.columns[1]) &
1569 (__x.columns[2] == __y.columns[2]));
1570}
1571static simd_bool SIMD_CFUNC simd_equal(simd_double3x3 __x, simd_double3x3 __y) {
1572 return simd_all((__x.columns[0] == __y.columns[0]) &
1573 (__x.columns[1] == __y.columns[1]) &
1574 (__x.columns[2] == __y.columns[2]));
1575}
1576static simd_bool SIMD_CFUNC simd_equal(simd_double3x4 __x, simd_double3x4 __y) {
1577 return simd_all((__x.columns[0] == __y.columns[0]) &
1578 (__x.columns[1] == __y.columns[1]) &
1579 (__x.columns[2] == __y.columns[2]));
1580}
1581static simd_bool SIMD_CFUNC simd_equal(simd_double4x2 __x, simd_double4x2 __y) {
1582 return simd_all((__x.columns[0] == __y.columns[0]) &
1583 (__x.columns[1] == __y.columns[1]) &
1584 (__x.columns[2] == __y.columns[2]) &
1585 (__x.columns[3] == __y.columns[3]));
1586}
1587static simd_bool SIMD_CFUNC simd_equal(simd_double4x3 __x, simd_double4x3 __y) {
1588 return simd_all((__x.columns[0] == __y.columns[0]) &
1589 (__x.columns[1] == __y.columns[1]) &
1590 (__x.columns[2] == __y.columns[2]) &
1591 (__x.columns[3] == __y.columns[3]));
1592}
1593static simd_bool SIMD_CFUNC simd_equal(simd_double4x4 __x, simd_double4x4 __y) {
1594 return simd_all((__x.columns[0] == __y.columns[0]) &
1595 (__x.columns[1] == __y.columns[1]) &
1596 (__x.columns[2] == __y.columns[2]) &
1597 (__x.columns[3] == __y.columns[3]));
1598}
1599
1600static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x2 __x, simd_float2x2 __y, float __tol) {
1601 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1602 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol));
1603}
1604static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x3 __x, simd_float2x3 __y, float __tol) {
1605 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1606 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol));
1607}
1608static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x4 __x, simd_float2x4 __y, float __tol) {
1609 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1610 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol));
1611}
1612static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x2 __x, simd_float3x2 __y, float __tol) {
1613 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1614 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1615 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol));
1616}
1617static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x3 __x, simd_float3x3 __y, float __tol) {
1618 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1619 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1620 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol));
1621}
1622static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x4 __x, simd_float3x4 __y, float __tol) {
1623 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1624 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1625 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol));
1626}
1627static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x2 __x, simd_float4x2 __y, float __tol) {
1628 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1629 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1630 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) &
1631 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol));
1632}
1633static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x3 __x, simd_float4x3 __y, float __tol) {
1634 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1635 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1636 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) &
1637 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol));
1638}
1639static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x4 __x, simd_float4x4 __y, float __tol) {
1640 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1641 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1642 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) &
1643 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol));
1644}
1645static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x2 __x, simd_double2x2 __y, double __tol) {
1646 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1647 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol));
1648}
1649static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x3 __x, simd_double2x3 __y, double __tol) {
1650 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1651 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol));
1652}
1653static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x4 __x, simd_double2x4 __y, double __tol) {
1654 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1655 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol));
1656}
1657static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x2 __x, simd_double3x2 __y, double __tol) {
1658 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1659 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1660 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol));
1661}
1662static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x3 __x, simd_double3x3 __y, double __tol) {
1663 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1664 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1665 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol));
1666}
1667static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x4 __x, simd_double3x4 __y, double __tol) {
1668 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1669 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1670 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol));
1671}
1672static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x2 __x, simd_double4x2 __y, double __tol) {
1673 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1674 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1675 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) &
1676 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol));
1677}
1678static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x3 __x, simd_double4x3 __y, double __tol) {
1679 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1680 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1681 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) &
1682 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol));
1683}
1684static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x4 __x, simd_double4x4 __y, double __tol) {
1685 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) &
1686 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) &
1687 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) &
1688 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol));
1689}
1690
1691static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x2 __x, simd_float2x2 __y, float __tol) {
1692 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1693 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])));
1694}
1695static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x3 __x, simd_float2x3 __y, float __tol) {
1696 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1697 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])));
1698}
1699static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x4 __x, simd_float2x4 __y, float __tol) {
1700 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1701 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])));
1702}
1703static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x2 __x, simd_float3x2 __y, float __tol) {
1704 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1705 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1706 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])));
1707}
1708static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x3 __x, simd_float3x3 __y, float __tol) {
1709 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1710 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1711 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])));
1712}
1713static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x4 __x, simd_float3x4 __y, float __tol) {
1714 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1715 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1716 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])));
1717}
1718static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x2 __x, simd_float4x2 __y, float __tol) {
1719 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1720 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1721 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) &
1722 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3])));
1723}
1724static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x3 __x, simd_float4x3 __y, float __tol) {
1725 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1726 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1727 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) &
1728 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3])));
1729}
1730static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x4 __x, simd_float4x4 __y, float __tol) {
1731 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1732 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1733 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) &
1734 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3])));
1735}
1736static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x2 __x, simd_double2x2 __y, double __tol) {
1737 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1738 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])));
1739}
1740static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x3 __x, simd_double2x3 __y, double __tol) {
1741 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1742 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])));
1743}
1744static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x4 __x, simd_double2x4 __y, double __tol) {
1745 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1746 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])));
1747}
1748static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x2 __x, simd_double3x2 __y, double __tol) {
1749 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1750 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1751 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])));
1752}
1753static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x3 __x, simd_double3x3 __y, double __tol) {
1754 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1755 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1756 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])));
1757}
1758static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x4 __x, simd_double3x4 __y, double __tol) {
1759 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1760 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1761 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])));
1762}
1763static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x2 __x, simd_double4x2 __y, double __tol) {
1764 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1765 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1766 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) &
1767 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3])));
1768}
1769static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x3 __x, simd_double4x3 __y, double __tol) {
1770 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1771 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1772 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) &
1773 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3])));
1774}
1775static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x4 __x, simd_double4x4 __y, double __tol) {
1776 return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) &
1777 (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) &
1778 (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) &
1779 (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3])));
1780}
1781
1782#ifdef __cplusplus
1783}
1784#endif
1785#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
1786#endif /* __SIMD_HEADER__ */
lib/libc/include/x86_64-macos-gnu/simd/matrix_types.h created+264
......@@ -0,0 +1,264 @@
1/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved.
2 *
3 * This header defines nine matrix types for each of float and double, which
4 * are intended for use together with the vector types defined in
5 * <simd/vector_types.h>.
6 *
7 * For compatibility with common graphics libraries, these matrices are stored
8 * in column-major order, and implemented as arrays of column vectors.
9 * Column-major storage order may seem a little strange if you aren't used to
10 * it, but for most usage the memory layout of the matrices shouldn't matter
11 * at all; instead you should think of matrices as abstract mathematical
12 * objects that you use to perform arithmetic without worrying about the
13 * details of the underlying representation.
14 *
15 * WARNING: vectors of length three are internally represented as length four
16 * vectors with one element of padding (for alignment purposes). This means
17 * that when a floatNx3 or doubleNx3 is viewed as a vector, it appears to
18 * have 4*N elements instead of the expected 3*N (with one padding element
19 * at the end of each column). The matrix elements are laid out in memory
20 * as follows:
21 *
22 * { 0, 1, 2, x, 3, 4, 5, x, ... }
23 *
24 * (where the scalar indices used above indicate the conceptual column-
25 * major storage order). If you aren't monkeying around with the internal
26 * storage details of matrices, you don't need to worry about this at all.
27 * Consider this yet another good reason to avoid doing so. */
28
29#ifndef SIMD_MATRIX_TYPES_HEADER
30#define SIMD_MATRIX_TYPES_HEADER
31
32#include <simd/types.h>
33#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
34
35/* Matrix types available in C, Objective-C, and C++ */
36typedef simd_float2x2 matrix_float2x2;
37typedef simd_float3x2 matrix_float3x2;
38typedef simd_float4x2 matrix_float4x2;
39
40typedef simd_float2x3 matrix_float2x3;
41typedef simd_float3x3 matrix_float3x3;
42typedef simd_float4x3 matrix_float4x3;
43
44typedef simd_float2x4 matrix_float2x4;
45typedef simd_float3x4 matrix_float3x4;
46typedef simd_float4x4 matrix_float4x4;
47
48typedef simd_double2x2 matrix_double2x2;
49typedef simd_double3x2 matrix_double3x2;
50typedef simd_double4x2 matrix_double4x2;
51
52typedef simd_double2x3 matrix_double2x3;
53typedef simd_double3x3 matrix_double3x3;
54typedef simd_double4x3 matrix_double4x3;
55
56typedef simd_double2x4 matrix_double2x4;
57typedef simd_double3x4 matrix_double3x4;
58typedef simd_double4x4 matrix_double4x4;
59
60#ifdef __cplusplus
61#if defined SIMD_MATRIX_HEADER
62static simd_float3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatf q);
63static simd_float4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatf q);
64static simd_double3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatd q);
65static simd_double4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatd q);
66#endif
67
68namespace simd {
69
70 struct float2x2 : ::simd_float2x2 {
71 float2x2() { columns[0] = 0; columns[1] = 0; }
72#if __has_feature(cxx_delegating_constructors)
73 float2x2(float diagonal) : float2x2((float2)diagonal) { }
74#endif
75 float2x2(float2 v) { columns[0] = (float2){v.x,0}; columns[1] = (float2){0,v.y}; }
76 float2x2(float2 c0, float2 c1) { columns[0] = c0; columns[1] = c1; }
77 float2x2(::simd_float2x2 m) : ::simd_float2x2(m) { }
78 };
79
80 struct float3x2 : ::simd_float3x2 {
81 float3x2() { columns[0] = 0; columns[1] = 0; columns[2] = 0; }
82#if __has_feature(cxx_delegating_constructors)
83 float3x2(float diagonal) : float3x2((float2)diagonal) { }
84#endif
85 float3x2(float2 v) { columns[0] = (float2){v.x,0}; columns[1] = (float2){0,v.y}; columns[2] = 0; }
86 float3x2(float2 c0, float2 c1, float2 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; }
87 float3x2(::simd_float3x2 m) : ::simd_float3x2(m) { }
88 };
89
90 struct float4x2 : ::simd_float4x2 {
91 float4x2() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; }
92#if __has_feature(cxx_delegating_constructors)
93 float4x2(float diagonal) : float4x2((float2)diagonal) { }
94#endif
95 float4x2(float2 v) { columns[0] = (float2){v.x,0}; columns[1] = (float2){0,v.y}; columns[2] = 0; columns[3] = 0; }
96 float4x2(float2 c0, float2 c1, float2 c2, float2 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; }
97 float4x2(::simd_float4x2 m) : ::simd_float4x2(m) { }
98 };
99
100 struct float2x3 : ::simd_float2x3 {
101 float2x3() { columns[0] = 0; columns[1] = 0; }
102#if __has_feature(cxx_delegating_constructors)
103 float2x3(float diagonal) : float2x3((float2)diagonal) { }
104#endif
105 float2x3(float2 v) { columns[0] = (float3){v.x,0,0}; columns[1] = (float3){0,v.y,0}; }
106 float2x3(float3 c0, float3 c1) { columns[0] = c0; columns[1] = c1; }
107 float2x3(::simd_float2x3 m) : ::simd_float2x3(m) { }
108 };
109
110 struct float3x3 : ::simd_float3x3 {
111 float3x3() { columns[0] = 0; columns[1] = 0; columns[2] = 0; }
112#if __has_feature(cxx_delegating_constructors)
113 float3x3(float diagonal) : float3x3((float3)diagonal) { }
114#endif
115 float3x3(float3 v) { columns[0] = (float3){v.x,0,0}; columns[1] = (float3){0,v.y,0}; columns[2] = (float3){0,0,v.z}; }
116 float3x3(float3 c0, float3 c1, float3 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; }
117 float3x3(::simd_float3x3 m) : ::simd_float3x3(m) { }
118#if defined SIMD_MATRIX_HEADER
119 float3x3(::simd_quatf q) : ::simd_float3x3(::simd_matrix3x3(q)) { }
120#endif
121 };
122
123 struct float4x3 : ::simd_float4x3 {
124 float4x3() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; }
125#if __has_feature(cxx_delegating_constructors)
126 float4x3(float diagonal) : float4x3((float3)diagonal) { }
127#endif
128 float4x3(float3 v) { columns[0] = (float3){v.x,0,0}; columns[1] = (float3){0,v.y,0}; columns[2] = (float3){0,0,v.z}; columns[3] = 0; }
129 float4x3(float3 c0, float3 c1, float3 c2, float3 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; }
130 float4x3(::simd_float4x3 m) : ::simd_float4x3(m) { }
131 };
132
133 struct float2x4 : ::simd_float2x4 {
134 float2x4() { columns[0] = 0; columns[1] = 0; }
135#if __has_feature(cxx_delegating_constructors)
136 float2x4(float diagonal) : float2x4((float2)diagonal) { }
137#endif
138 float2x4(float2 v) { columns[0] = (float4){v.x,0,0,0}; columns[1] = (float4){0,v.y,0,0}; }
139 float2x4(float4 c0, float4 c1) { columns[0] = c0; columns[1] = c1; }
140 float2x4(::simd_float2x4 m) : ::simd_float2x4(m) { }
141 };
142
143 struct float3x4 : ::simd_float3x4 {
144 float3x4() { columns[0] = 0; columns[1] = 0; columns[2] = 0; }
145#if __has_feature(cxx_delegating_constructors)
146 float3x4(float diagonal) : float3x4((float3)diagonal) { }
147#endif
148 float3x4(float3 v) { columns[0] = (float4){v.x,0,0,0}; columns[1] = (float4){0,v.y,0,0}; columns[2] = (float4){0,0,v.z,0}; }
149 float3x4(float4 c0, float4 c1, float4 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; }
150 float3x4(::simd_float3x4 m) : ::simd_float3x4(m) { }
151 };
152
153 struct float4x4 : ::simd_float4x4 {
154 float4x4() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; }
155#if __has_feature(cxx_delegating_constructors)
156 float4x4(float diagonal) : float4x4((float4)diagonal) { }
157#endif
158 float4x4(float4 v) { columns[0] = (float4){v.x,0,0,0}; columns[1] = (float4){0,v.y,0,0}; columns[2] = (float4){0,0,v.z,0}; columns[3] = (float4){0,0,0,v.w}; }
159 float4x4(float4 c0, float4 c1, float4 c2, float4 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; }
160 float4x4(::simd_float4x4 m) : ::simd_float4x4(m) { }
161#if defined SIMD_MATRIX_HEADER
162 float4x4(::simd_quatf q) : ::simd_float4x4(::simd_matrix4x4(q)) { }
163#endif
164 };
165
166 struct double2x2 : ::simd_double2x2 {
167 double2x2() { columns[0] = 0; columns[1] = 0; }
168#if __has_feature(cxx_delegating_constructors)
169 double2x2(double diagonal) : double2x2((double2)diagonal) { }
170#endif
171 double2x2(double2 v) { columns[0] = (double2){v.x,0}; columns[1] = (double2){0,v.y}; }
172 double2x2(double2 c0, double2 c1) { columns[0] = c0; columns[1] = c1; }
173 double2x2(::simd_double2x2 m) : ::simd_double2x2(m) { }
174 };
175
176 struct double3x2 : ::simd_double3x2 {
177 double3x2() { columns[0] = 0; columns[1] = 0; columns[2] = 0; }
178#if __has_feature(cxx_delegating_constructors)
179 double3x2(double diagonal) : double3x2((double2)diagonal) { }
180#endif
181 double3x2(double2 v) { columns[0] = (double2){v.x,0}; columns[1] = (double2){0,v.y}; columns[2] = 0; }
182 double3x2(double2 c0, double2 c1, double2 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; }
183 double3x2(::simd_double3x2 m) : ::simd_double3x2(m) { }
184 };
185
186 struct double4x2 : ::simd_double4x2 {
187 double4x2() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; }
188#if __has_feature(cxx_delegating_constructors)
189 double4x2(double diagonal) : double4x2((double2)diagonal) { }
190#endif
191 double4x2(double2 v) { columns[0] = (double2){v.x,0}; columns[1] = (double2){0,v.y}; columns[2] = 0; columns[3] = 0; }
192 double4x2(double2 c0, double2 c1, double2 c2, double2 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; }
193 double4x2(::simd_double4x2 m) : ::simd_double4x2(m) { }
194 };
195
196 struct double2x3 : ::simd_double2x3 {
197 double2x3() { columns[0] = 0; columns[1] = 0; }
198#if __has_feature(cxx_delegating_constructors)
199 double2x3(double diagonal) : double2x3((double2)diagonal) { }
200#endif
201 double2x3(double2 v) { columns[0] = (double3){v.x,0,0}; columns[1] = (double3){0,v.y,0}; }
202 double2x3(double3 c0, double3 c1) { columns[0] = c0; columns[1] = c1; }
203 double2x3(::simd_double2x3 m) : ::simd_double2x3(m) { }
204 };
205
206 struct double3x3 : ::simd_double3x3 {
207 double3x3() { columns[0] = 0; columns[1] = 0; columns[2] = 0; }
208#if __has_feature(cxx_delegating_constructors)
209 double3x3(double diagonal) : double3x3((double3)diagonal) { }
210#endif
211 double3x3(double3 v) { columns[0] = (double3){v.x,0,0}; columns[1] = (double3){0,v.y,0}; columns[2] = (double3){0,0,v.z}; }
212 double3x3(double3 c0, double3 c1, double3 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; }
213 double3x3(::simd_double3x3 m) : ::simd_double3x3(m) { }
214#if defined SIMD_MATRIX_HEADER
215 double3x3(::simd_quatd q) : ::simd_double3x3(::simd_matrix3x3(q)) { }
216#endif
217 };
218
219 struct double4x3 : ::simd_double4x3 {
220 double4x3() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; }
221#if __has_feature(cxx_delegating_constructors)
222 double4x3(double diagonal) : double4x3((double3)diagonal) { }
223#endif
224 double4x3(double3 v) { columns[0] = (double3){v.x,0,0}; columns[1] = (double3){0,v.y,0}; columns[2] = (double3){0,0,v.z}; columns[3] = 0; }
225 double4x3(double3 c0, double3 c1, double3 c2, double3 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; }
226 double4x3(::simd_double4x3 m) : ::simd_double4x3(m) { }
227 };
228
229 struct double2x4 : ::simd_double2x4 {
230 double2x4() { columns[0] = 0; columns[1] = 0; }
231#if __has_feature(cxx_delegating_constructors)
232 double2x4(double diagonal) : double2x4((double2)diagonal) { }
233#endif
234 double2x4(double2 v) { columns[0] = (double4){v.x,0,0,0}; columns[1] = (double4){0,v.y,0,0}; }
235 double2x4(double4 c0, double4 c1) { columns[0] = c0; columns[1] = c1; }
236 double2x4(::simd_double2x4 m) : ::simd_double2x4(m) { }
237 };
238
239 struct double3x4 : ::simd_double3x4 {
240 double3x4() { columns[0] = 0; columns[1] = 0; columns[2] = 0; }
241#if __has_feature(cxx_delegating_constructors)
242 double3x4(double diagonal) : double3x4((double3)diagonal) { }
243#endif
244 double3x4(double3 v) { columns[0] = (double4){v.x,0,0,0}; columns[1] = (double4){0,v.y,0,0}; columns[2] = (double4){0,0,v.z,0}; }
245 double3x4(double4 c0, double4 c1, double4 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; }
246 double3x4(::simd_double3x4 m) : ::simd_double3x4(m) { }
247 };
248
249 struct double4x4 : ::simd_double4x4 {
250 double4x4() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; }
251#if __has_feature(cxx_delegating_constructors)
252 double4x4(double diagonal) : double4x4((double4)diagonal) { }
253#endif
254 double4x4(double4 v) { columns[0] = (double4){v.x,0,0,0}; columns[1] = (double4){0,v.y,0,0}; columns[2] = (double4){0,0,v.z,0}; columns[3] = (double4){0,0,0,v.w}; }
255 double4x4(double4 c0, double4 c1, double4 c2, double4 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; }
256 double4x4(::simd_double4x4 m) : ::simd_double4x4(m) { }
257#if defined SIMD_MATRIX_HEADER
258 double4x4(::simd_quatd q) : ::simd_double4x4(::simd_matrix4x4(q)) { }
259#endif
260 };
261}
262#endif /* __cplusplus */
263#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
264#endif /* SIMD_MATRIX_TYPES_HEADER */
lib/libc/include/x86_64-macos-gnu/simd/packed.h created+1031
......@@ -0,0 +1,1031 @@
1/*! @header
2 * This header defines fixed size vector types with relaxed alignment. For
3 * each vector type defined by <simd/vector_types.h> that is not a 1- or 3-
4 * element vector, there is a corresponding type defined by this header that
5 * requires only the alignment matching that of the underlying scalar type.
6 *
7 * These types should be used to access buffers that may not be sufficiently
8 * aligned to allow them to be accessed using the "normal" simd vector types.
9 * As an example of this usage, suppose that you want to load a vector of
10 * four floats from an array of floats. The type simd_float4 has sixteen byte
11 * alignment, whereas an array of floats has only four byte alignment.
12 * Thus, naively casting a pointer into the array to (simd_float4 *) would
13 * invoke undefined behavior, and likely produce an alignment fault at
14 * runtime. Instead, use the corresponding packed type to load from the array:
15 *
16 * <pre>
17 * @textblock
18 * simd_float4 vector = *(packed_simd_float4 *)&array[i];
19 * // do something with vector ...
20 * @/textblock
21 * </pre>
22 *
23 * It's important to note that the packed_ types are only needed to work with
24 * memory; once the data is loaded, we simply operate on it as usual using
25 * the simd_float4 type, as illustrated above.
26 *
27 * @copyright 2014-2017 Apple, Inc. All rights reserved.
28 * @unsorted */
29
30#ifndef SIMD_PACKED_TYPES
31#define SIMD_PACKED_TYPES
32
33# include <simd/vector_types.h>
34# if SIMD_COMPILER_HAS_REQUIRED_FEATURES
35/*! @abstract A vector of two 8-bit signed (twos-complement) integers with
36 * relaxed alignment.
37 * @description In C++ and Metal, this type is also available as
38 * simd::packed::char2. The alignment of this type is that of the
39 * underlying scalar element type, so you can use it to load or store from
40 * an array of that type. */
41typedef __attribute__((__ext_vector_type__(2),__aligned__(1))) char simd_packed_char2;
42
43/*! @abstract A vector of four 8-bit signed (twos-complement) integers with
44 * relaxed alignment.
45 * @description In C++ and Metal, this type is also available as
46 * simd::packed::char4. The alignment of this type is that of the
47 * underlying scalar element type, so you can use it to load or store from
48 * an array of that type. */
49typedef __attribute__((__ext_vector_type__(4),__aligned__(1))) char simd_packed_char4;
50
51/*! @abstract A vector of eight 8-bit signed (twos-complement) integers with
52 * relaxed alignment.
53 * @description In C++ this type is also available as simd::packed::char8.
54 * This type is not available in Metal. The alignment of this type is only
55 * that of the underlying scalar element type, so you can use it to load or
56 * store from an array of that type. */
57typedef __attribute__((__ext_vector_type__(8),__aligned__(1))) char simd_packed_char8;
58
59/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers
60 * with relaxed alignment.
61 * @description In C++ this type is also available as simd::packed::char16.
62 * This type is not available in Metal. The alignment of this type is only
63 * that of the underlying scalar element type, so you can use it to load or
64 * store from an array of that type. */
65typedef __attribute__((__ext_vector_type__(16),__aligned__(1))) char simd_packed_char16;
66
67/*! @abstract A vector of thirty-two 8-bit signed (twos-complement) integers
68 * with relaxed alignment.
69 * @description In C++ this type is also available as simd::packed::char32.
70 * This type is not available in Metal. The alignment of this type is only
71 * that of the underlying scalar element type, so you can use it to load or
72 * store from an array of that type. */
73typedef __attribute__((__ext_vector_type__(32),__aligned__(1))) char simd_packed_char32;
74
75/*! @abstract A vector of sixty-four 8-bit signed (twos-complement) integers
76 * with relaxed alignment.
77 * @description In C++ this type is also available as simd::packed::char64.
78 * This type is not available in Metal. The alignment of this type is only
79 * that of the underlying scalar element type, so you can use it to load or
80 * store from an array of that type. */
81typedef __attribute__((__ext_vector_type__(64),__aligned__(1))) char simd_packed_char64;
82
83/*! @abstract A vector of two 8-bit unsigned integers with relaxed
84 * alignment.
85 * @description In C++ and Metal, this type is also available as
86 * simd::packed::uchar2. The alignment of this type is that of the
87 * underlying scalar element type, so you can use it to load or store from
88 * an array of that type. */
89typedef __attribute__((__ext_vector_type__(2),__aligned__(1))) unsigned char simd_packed_uchar2;
90
91/*! @abstract A vector of four 8-bit unsigned integers with relaxed
92 * alignment.
93 * @description In C++ and Metal, this type is also available as
94 * simd::packed::uchar4. The alignment of this type is that of the
95 * underlying scalar element type, so you can use it to load or store from
96 * an array of that type. */
97typedef __attribute__((__ext_vector_type__(4),__aligned__(1))) unsigned char simd_packed_uchar4;
98
99/*! @abstract A vector of eight 8-bit unsigned integers with relaxed
100 * alignment.
101 * @description In C++ this type is also available as simd::packed::uchar8.
102 * This type is not available in Metal. The alignment of this type is only
103 * that of the underlying scalar element type, so you can use it to load or
104 * store from an array of that type. */
105typedef __attribute__((__ext_vector_type__(8),__aligned__(1))) unsigned char simd_packed_uchar8;
106
107/*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed
108 * alignment.
109 * @description In C++ this type is also available as
110 * simd::packed::uchar16. This type is not available in Metal. The
111 * alignment of this type is only that of the underlying scalar element
112 * type, so you can use it to load or store from an array of that type. */
113typedef __attribute__((__ext_vector_type__(16),__aligned__(1))) unsigned char simd_packed_uchar16;
114
115/*! @abstract A vector of thirty-two 8-bit unsigned integers with relaxed
116 * alignment.
117 * @description In C++ this type is also available as
118 * simd::packed::uchar32. This type is not available in Metal. The
119 * alignment of this type is only that of the underlying scalar element
120 * type, so you can use it to load or store from an array of that type. */
121typedef __attribute__((__ext_vector_type__(32),__aligned__(1))) unsigned char simd_packed_uchar32;
122
123/*! @abstract A vector of sixty-four 8-bit unsigned integers with relaxed
124 * alignment.
125 * @description In C++ this type is also available as
126 * simd::packed::uchar64. This type is not available in Metal. The
127 * alignment of this type is only that of the underlying scalar element
128 * type, so you can use it to load or store from an array of that type. */
129typedef __attribute__((__ext_vector_type__(64),__aligned__(1))) unsigned char simd_packed_uchar64;
130
131/*! @abstract A vector of two 16-bit signed (twos-complement) integers with
132 * relaxed alignment.
133 * @description In C++ and Metal, this type is also available as
134 * simd::packed::short2. The alignment of this type is that of the
135 * underlying scalar element type, so you can use it to load or store from
136 * an array of that type. */
137typedef __attribute__((__ext_vector_type__(2),__aligned__(2))) short simd_packed_short2;
138
139/*! @abstract A vector of four 16-bit signed (twos-complement) integers with
140 * relaxed alignment.
141 * @description In C++ and Metal, this type is also available as
142 * simd::packed::short4. The alignment of this type is that of the
143 * underlying scalar element type, so you can use it to load or store from
144 * an array of that type. */
145typedef __attribute__((__ext_vector_type__(4),__aligned__(2))) short simd_packed_short4;
146
147/*! @abstract A vector of eight 16-bit signed (twos-complement) integers
148 * with relaxed alignment.
149 * @description In C++ this type is also available as simd::packed::short8.
150 * This type is not available in Metal. The alignment of this type is only
151 * that of the underlying scalar element type, so you can use it to load or
152 * store from an array of that type. */
153typedef __attribute__((__ext_vector_type__(8),__aligned__(2))) short simd_packed_short8;
154
155/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers
156 * with relaxed alignment.
157 * @description In C++ this type is also available as
158 * simd::packed::short16. This type is not available in Metal. The
159 * alignment of this type is only that of the underlying scalar element
160 * type, so you can use it to load or store from an array of that type. */
161typedef __attribute__((__ext_vector_type__(16),__aligned__(2))) short simd_packed_short16;
162
163/*! @abstract A vector of thirty-two 16-bit signed (twos-complement)
164 * integers with relaxed alignment.
165 * @description In C++ this type is also available as
166 * simd::packed::short32. This type is not available in Metal. The
167 * alignment of this type is only that of the underlying scalar element
168 * type, so you can use it to load or store from an array of that type. */
169typedef __attribute__((__ext_vector_type__(32),__aligned__(2))) short simd_packed_short32;
170
171/*! @abstract A vector of two 16-bit unsigned integers with relaxed
172 * alignment.
173 * @description In C++ and Metal, this type is also available as
174 * simd::packed::ushort2. The alignment of this type is that of the
175 * underlying scalar element type, so you can use it to load or store from
176 * an array of that type. */
177typedef __attribute__((__ext_vector_type__(2),__aligned__(2))) unsigned short simd_packed_ushort2;
178
179/*! @abstract A vector of four 16-bit unsigned integers with relaxed
180 * alignment.
181 * @description In C++ and Metal, this type is also available as
182 * simd::packed::ushort4. The alignment of this type is that of the
183 * underlying scalar element type, so you can use it to load or store from
184 * an array of that type. */
185typedef __attribute__((__ext_vector_type__(4),__aligned__(2))) unsigned short simd_packed_ushort4;
186
187/*! @abstract A vector of eight 16-bit unsigned integers with relaxed
188 * alignment.
189 * @description In C++ this type is also available as
190 * simd::packed::ushort8. This type is not available in Metal. The
191 * alignment of this type is only that of the underlying scalar element
192 * type, so you can use it to load or store from an array of that type. */
193typedef __attribute__((__ext_vector_type__(8),__aligned__(2))) unsigned short simd_packed_ushort8;
194
195/*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed
196 * alignment.
197 * @description In C++ this type is also available as
198 * simd::packed::ushort16. This type is not available in Metal. The
199 * alignment of this type is only that of the underlying scalar element
200 * type, so you can use it to load or store from an array of that type. */
201typedef __attribute__((__ext_vector_type__(16),__aligned__(2))) unsigned short simd_packed_ushort16;
202
203/*! @abstract A vector of thirty-two 16-bit unsigned integers with relaxed
204 * alignment.
205 * @description In C++ this type is also available as
206 * simd::packed::ushort32. This type is not available in Metal. The
207 * alignment of this type is only that of the underlying scalar element
208 * type, so you can use it to load or store from an array of that type. */
209typedef __attribute__((__ext_vector_type__(32),__aligned__(2))) unsigned short simd_packed_ushort32;
210
211/*! @abstract A vector of two 32-bit signed (twos-complement) integers with
212 * relaxed alignment.
213 * @description In C++ and Metal, this type is also available as
214 * simd::packed::int2. The alignment of this type is that of the underlying
215 * scalar element type, so you can use it to load or store from an array of
216 * that type. */
217typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) int simd_packed_int2;
218
219/*! @abstract A vector of four 32-bit signed (twos-complement) integers with
220 * relaxed alignment.
221 * @description In C++ and Metal, this type is also available as
222 * simd::packed::int4. The alignment of this type is that of the underlying
223 * scalar element type, so you can use it to load or store from an array of
224 * that type. */
225typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) int simd_packed_int4;
226
227/*! @abstract A vector of eight 32-bit signed (twos-complement) integers
228 * with relaxed alignment.
229 * @description In C++ this type is also available as simd::packed::int8.
230 * This type is not available in Metal. The alignment of this type is only
231 * that of the underlying scalar element type, so you can use it to load or
232 * store from an array of that type. */
233typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) int simd_packed_int8;
234
235/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers
236 * with relaxed alignment.
237 * @description In C++ this type is also available as simd::packed::int16.
238 * This type is not available in Metal. The alignment of this type is only
239 * that of the underlying scalar element type, so you can use it to load or
240 * store from an array of that type. */
241typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) int simd_packed_int16;
242
243/*! @abstract A vector of two 32-bit unsigned integers with relaxed
244 * alignment.
245 * @description In C++ and Metal, this type is also available as
246 * simd::packed::uint2. The alignment of this type is that of the
247 * underlying scalar element type, so you can use it to load or store from
248 * an array of that type. */
249typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) unsigned int simd_packed_uint2;
250
251/*! @abstract A vector of four 32-bit unsigned integers with relaxed
252 * alignment.
253 * @description In C++ and Metal, this type is also available as
254 * simd::packed::uint4. The alignment of this type is that of the
255 * underlying scalar element type, so you can use it to load or store from
256 * an array of that type. */
257typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) unsigned int simd_packed_uint4;
258
259/*! @abstract A vector of eight 32-bit unsigned integers with relaxed
260 * alignment.
261 * @description In C++ this type is also available as simd::packed::uint8.
262 * This type is not available in Metal. The alignment of this type is only
263 * that of the underlying scalar element type, so you can use it to load or
264 * store from an array of that type. */
265typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) unsigned int simd_packed_uint8;
266
267/*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed
268 * alignment.
269 * @description In C++ this type is also available as simd::packed::uint16.
270 * This type is not available in Metal. The alignment of this type is only
271 * that of the underlying scalar element type, so you can use it to load or
272 * store from an array of that type. */
273typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) unsigned int simd_packed_uint16;
274
275/*! @abstract A vector of two 32-bit floating-point numbers with relaxed
276 * alignment.
277 * @description In C++ and Metal, this type is also available as
278 * simd::packed::float2. The alignment of this type is that of the
279 * underlying scalar element type, so you can use it to load or store from
280 * an array of that type. */
281typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) float simd_packed_float2;
282
283/*! @abstract A vector of four 32-bit floating-point numbers with relaxed
284 * alignment.
285 * @description In C++ and Metal, this type is also available as
286 * simd::packed::float4. The alignment of this type is that of the
287 * underlying scalar element type, so you can use it to load or store from
288 * an array of that type. */
289typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) float simd_packed_float4;
290
291/*! @abstract A vector of eight 32-bit floating-point numbers with relaxed
292 * alignment.
293 * @description In C++ this type is also available as simd::packed::float8.
294 * This type is not available in Metal. The alignment of this type is only
295 * that of the underlying scalar element type, so you can use it to load or
296 * store from an array of that type. */
297typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) float simd_packed_float8;
298
299/*! @abstract A vector of sixteen 32-bit floating-point numbers with relaxed
300 * alignment.
301 * @description In C++ this type is also available as
302 * simd::packed::float16. This type is not available in Metal. The
303 * alignment of this type is only that of the underlying scalar element
304 * type, so you can use it to load or store from an array of that type. */
305typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) float simd_packed_float16;
306
307/*! @abstract A vector of two 64-bit signed (twos-complement) integers with
308 * relaxed alignment.
309 * @description In C++ and Metal, this type is also available as
310 * simd::packed::long2. The alignment of this type is that of the
311 * underlying scalar element type, so you can use it to load or store from
312 * an array of that type. */
313#if defined __LP64__
314typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) simd_long1 simd_packed_long2;
315#else
316typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) simd_long1 simd_packed_long2;
317#endif
318
319/*! @abstract A vector of four 64-bit signed (twos-complement) integers with
320 * relaxed alignment.
321 * @description In C++ and Metal, this type is also available as
322 * simd::packed::long4. The alignment of this type is that of the
323 * underlying scalar element type, so you can use it to load or store from
324 * an array of that type. */
325#if defined __LP64__
326typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) simd_long1 simd_packed_long4;
327#else
328typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) simd_long1 simd_packed_long4;
329#endif
330
331/*! @abstract A vector of eight 64-bit signed (twos-complement) integers
332 * with relaxed alignment.
333 * @description In C++ this type is also available as simd::packed::long8.
334 * This type is not available in Metal. The alignment of this type is only
335 * that of the underlying scalar element type, so you can use it to load or
336 * store from an array of that type. */
337#if defined __LP64__
338typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) simd_long1 simd_packed_long8;
339#else
340typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) simd_long1 simd_packed_long8;
341#endif
342
343/*! @abstract A vector of two 64-bit unsigned integers with relaxed
344 * alignment.
345 * @description In C++ and Metal, this type is also available as
346 * simd::packed::ulong2. The alignment of this type is that of the
347 * underlying scalar element type, so you can use it to load or store from
348 * an array of that type. */
349#if defined __LP64__
350typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) simd_ulong1 simd_packed_ulong2;
351#else
352typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) simd_ulong1 simd_packed_ulong2;
353#endif
354
355/*! @abstract A vector of four 64-bit unsigned integers with relaxed
356 * alignment.
357 * @description In C++ and Metal, this type is also available as
358 * simd::packed::ulong4. The alignment of this type is that of the
359 * underlying scalar element type, so you can use it to load or store from
360 * an array of that type. */
361#if defined __LP64__
362typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) simd_ulong1 simd_packed_ulong4;
363#else
364typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) simd_ulong1 simd_packed_ulong4;
365#endif
366
367/*! @abstract A vector of eight 64-bit unsigned integers with relaxed
368 * alignment.
369 * @description In C++ this type is also available as simd::packed::ulong8.
370 * This type is not available in Metal. The alignment of this type is only
371 * that of the underlying scalar element type, so you can use it to load or
372 * store from an array of that type. */
373#if defined __LP64__
374typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) simd_ulong1 simd_packed_ulong8;
375#else
376typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) simd_ulong1 simd_packed_ulong8;
377#endif
378
379/*! @abstract A vector of two 64-bit floating-point numbers with relaxed
380 * alignment.
381 * @description In C++ and Metal, this type is also available as
382 * simd::packed::double2. The alignment of this type is that of the
383 * underlying scalar element type, so you can use it to load or store from
384 * an array of that type. */
385#if defined __LP64__
386typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) double simd_packed_double2;
387#else
388typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) double simd_packed_double2;
389#endif
390
391/*! @abstract A vector of four 64-bit floating-point numbers with relaxed
392 * alignment.
393 * @description In C++ and Metal, this type is also available as
394 * simd::packed::double4. The alignment of this type is that of the
395 * underlying scalar element type, so you can use it to load or store from
396 * an array of that type. */
397#if defined __LP64__
398typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) double simd_packed_double4;
399#else
400typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) double simd_packed_double4;
401#endif
402
403/*! @abstract A vector of eight 64-bit floating-point numbers with relaxed
404 * alignment.
405 * @description In C++ this type is also available as
406 * simd::packed::double8. This type is not available in Metal. The
407 * alignment of this type is only that of the underlying scalar element
408 * type, so you can use it to load or store from an array of that type. */
409#if defined __LP64__
410typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) double simd_packed_double8;
411#else
412typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) double simd_packed_double8;
413#endif
414
415/* MARK: C++ vector types */
416#if defined __cplusplus
417namespace simd {
418 namespace packed {
419 /*! @abstract A vector of two 8-bit signed (twos-complement) integers
420 * with relaxed alignment.
421 * @description In C or Objective-C, this type is available as
422 * simd_packed_char2. The alignment of this type is only that of the
423 * underlying scalar element type, so you can use it to load or store
424 * from an array of that type. */
425typedef ::simd_packed_char2 char2;
426
427 /*! @abstract A vector of four 8-bit signed (twos-complement) integers
428 * with relaxed alignment.
429 * @description In C or Objective-C, this type is available as
430 * simd_packed_char4. The alignment of this type is only that of the
431 * underlying scalar element type, so you can use it to load or store
432 * from an array of that type. */
433typedef ::simd_packed_char4 char4;
434
435 /*! @abstract A vector of eight 8-bit signed (twos-complement) integers
436 * with relaxed alignment.
437 * @description This type is not available in Metal. In C or
438 * Objective-C, this type is available as simd_packed_char8. The
439 * alignment of this type is only that of the underlying scalar element
440 * type, so you can use it to load or store from an array of that type. */
441typedef ::simd_packed_char8 char8;
442
443 /*! @abstract A vector of sixteen 8-bit signed (twos-complement)
444 * integers with relaxed alignment.
445 * @description This type is not available in Metal. In C or
446 * Objective-C, this type is available as simd_packed_char16. The
447 * alignment of this type is only that of the underlying scalar element
448 * type, so you can use it to load or store from an array of that type. */
449typedef ::simd_packed_char16 char16;
450
451 /*! @abstract A vector of thirty-two 8-bit signed (twos-complement)
452 * integers with relaxed alignment.
453 * @description This type is not available in Metal. In C or
454 * Objective-C, this type is available as simd_packed_char32. The
455 * alignment of this type is only that of the underlying scalar element
456 * type, so you can use it to load or store from an array of that type. */
457typedef ::simd_packed_char32 char32;
458
459 /*! @abstract A vector of sixty-four 8-bit signed (twos-complement)
460 * integers with relaxed alignment.
461 * @description This type is not available in Metal. In C or
462 * Objective-C, this type is available as simd_packed_char64. The
463 * alignment of this type is only that of the underlying scalar element
464 * type, so you can use it to load or store from an array of that type. */
465typedef ::simd_packed_char64 char64;
466
467 /*! @abstract A vector of two 8-bit unsigned integers with relaxed
468 * alignment.
469 * @description In C or Objective-C, this type is available as
470 * simd_packed_uchar2. The alignment of this type is only that of the
471 * underlying scalar element type, so you can use it to load or store
472 * from an array of that type. */
473typedef ::simd_packed_uchar2 uchar2;
474
475 /*! @abstract A vector of four 8-bit unsigned integers with relaxed
476 * alignment.
477 * @description In C or Objective-C, this type is available as
478 * simd_packed_uchar4. The alignment of this type is only that of the
479 * underlying scalar element type, so you can use it to load or store
480 * from an array of that type. */
481typedef ::simd_packed_uchar4 uchar4;
482
483 /*! @abstract A vector of eight 8-bit unsigned integers with relaxed
484 * alignment.
485 * @description This type is not available in Metal. In C or
486 * Objective-C, this type is available as simd_packed_uchar8. The
487 * alignment of this type is only that of the underlying scalar element
488 * type, so you can use it to load or store from an array of that type. */
489typedef ::simd_packed_uchar8 uchar8;
490
491 /*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed
492 * alignment.
493 * @description This type is not available in Metal. In C or
494 * Objective-C, this type is available as simd_packed_uchar16. The
495 * alignment of this type is only that of the underlying scalar element
496 * type, so you can use it to load or store from an array of that type. */
497typedef ::simd_packed_uchar16 uchar16;
498
499 /*! @abstract A vector of thirty-two 8-bit unsigned integers with
500 * relaxed alignment.
501 * @description This type is not available in Metal. In C or
502 * Objective-C, this type is available as simd_packed_uchar32. The
503 * alignment of this type is only that of the underlying scalar element
504 * type, so you can use it to load or store from an array of that type. */
505typedef ::simd_packed_uchar32 uchar32;
506
507 /*! @abstract A vector of sixty-four 8-bit unsigned integers with
508 * relaxed alignment.
509 * @description This type is not available in Metal. In C or
510 * Objective-C, this type is available as simd_packed_uchar64. The
511 * alignment of this type is only that of the underlying scalar element
512 * type, so you can use it to load or store from an array of that type. */
513typedef ::simd_packed_uchar64 uchar64;
514
515 /*! @abstract A vector of two 16-bit signed (twos-complement) integers
516 * with relaxed alignment.
517 * @description In C or Objective-C, this type is available as
518 * simd_packed_short2. The alignment of this type is only that of the
519 * underlying scalar element type, so you can use it to load or store
520 * from an array of that type. */
521typedef ::simd_packed_short2 short2;
522
523 /*! @abstract A vector of four 16-bit signed (twos-complement) integers
524 * with relaxed alignment.
525 * @description In C or Objective-C, this type is available as
526 * simd_packed_short4. The alignment of this type is only that of the
527 * underlying scalar element type, so you can use it to load or store
528 * from an array of that type. */
529typedef ::simd_packed_short4 short4;
530
531 /*! @abstract A vector of eight 16-bit signed (twos-complement) integers
532 * with relaxed alignment.
533 * @description This type is not available in Metal. In C or
534 * Objective-C, this type is available as simd_packed_short8. The
535 * alignment of this type is only that of the underlying scalar element
536 * type, so you can use it to load or store from an array of that type. */
537typedef ::simd_packed_short8 short8;
538
539 /*! @abstract A vector of sixteen 16-bit signed (twos-complement)
540 * integers with relaxed alignment.
541 * @description This type is not available in Metal. In C or
542 * Objective-C, this type is available as simd_packed_short16. The
543 * alignment of this type is only that of the underlying scalar element
544 * type, so you can use it to load or store from an array of that type. */
545typedef ::simd_packed_short16 short16;
546
547 /*! @abstract A vector of thirty-two 16-bit signed (twos-complement)
548 * integers with relaxed alignment.
549 * @description This type is not available in Metal. In C or
550 * Objective-C, this type is available as simd_packed_short32. The
551 * alignment of this type is only that of the underlying scalar element
552 * type, so you can use it to load or store from an array of that type. */
553typedef ::simd_packed_short32 short32;
554
555 /*! @abstract A vector of two 16-bit unsigned integers with relaxed
556 * alignment.
557 * @description In C or Objective-C, this type is available as
558 * simd_packed_ushort2. The alignment of this type is only that of the
559 * underlying scalar element type, so you can use it to load or store
560 * from an array of that type. */
561typedef ::simd_packed_ushort2 ushort2;
562
563 /*! @abstract A vector of four 16-bit unsigned integers with relaxed
564 * alignment.
565 * @description In C or Objective-C, this type is available as
566 * simd_packed_ushort4. The alignment of this type is only that of the
567 * underlying scalar element type, so you can use it to load or store
568 * from an array of that type. */
569typedef ::simd_packed_ushort4 ushort4;
570
571 /*! @abstract A vector of eight 16-bit unsigned integers with relaxed
572 * alignment.
573 * @description This type is not available in Metal. In C or
574 * Objective-C, this type is available as simd_packed_ushort8. The
575 * alignment of this type is only that of the underlying scalar element
576 * type, so you can use it to load or store from an array of that type. */
577typedef ::simd_packed_ushort8 ushort8;
578
579 /*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed
580 * alignment.
581 * @description This type is not available in Metal. In C or
582 * Objective-C, this type is available as simd_packed_ushort16. The
583 * alignment of this type is only that of the underlying scalar element
584 * type, so you can use it to load or store from an array of that type. */
585typedef ::simd_packed_ushort16 ushort16;
586
587 /*! @abstract A vector of thirty-two 16-bit unsigned integers with
588 * relaxed alignment.
589 * @description This type is not available in Metal. In C or
590 * Objective-C, this type is available as simd_packed_ushort32. The
591 * alignment of this type is only that of the underlying scalar element
592 * type, so you can use it to load or store from an array of that type. */
593typedef ::simd_packed_ushort32 ushort32;
594
595 /*! @abstract A vector of two 32-bit signed (twos-complement) integers
596 * with relaxed alignment.
597 * @description In C or Objective-C, this type is available as
598 * simd_packed_int2. The alignment of this type is only that of the
599 * underlying scalar element type, so you can use it to load or store
600 * from an array of that type. */
601typedef ::simd_packed_int2 int2;
602
603 /*! @abstract A vector of four 32-bit signed (twos-complement) integers
604 * with relaxed alignment.
605 * @description In C or Objective-C, this type is available as
606 * simd_packed_int4. The alignment of this type is only that of the
607 * underlying scalar element type, so you can use it to load or store
608 * from an array of that type. */
609typedef ::simd_packed_int4 int4;
610
611 /*! @abstract A vector of eight 32-bit signed (twos-complement) integers
612 * with relaxed alignment.
613 * @description This type is not available in Metal. In C or
614 * Objective-C, this type is available as simd_packed_int8. The
615 * alignment of this type is only that of the underlying scalar element
616 * type, so you can use it to load or store from an array of that type. */
617typedef ::simd_packed_int8 int8;
618
619 /*! @abstract A vector of sixteen 32-bit signed (twos-complement)
620 * integers with relaxed alignment.
621 * @description This type is not available in Metal. In C or
622 * Objective-C, this type is available as simd_packed_int16. The
623 * alignment of this type is only that of the underlying scalar element
624 * type, so you can use it to load or store from an array of that type. */
625typedef ::simd_packed_int16 int16;
626
627 /*! @abstract A vector of two 32-bit unsigned integers with relaxed
628 * alignment.
629 * @description In C or Objective-C, this type is available as
630 * simd_packed_uint2. The alignment of this type is only that of the
631 * underlying scalar element type, so you can use it to load or store
632 * from an array of that type. */
633typedef ::simd_packed_uint2 uint2;
634
635 /*! @abstract A vector of four 32-bit unsigned integers with relaxed
636 * alignment.
637 * @description In C or Objective-C, this type is available as
638 * simd_packed_uint4. The alignment of this type is only that of the
639 * underlying scalar element type, so you can use it to load or store
640 * from an array of that type. */
641typedef ::simd_packed_uint4 uint4;
642
643 /*! @abstract A vector of eight 32-bit unsigned integers with relaxed
644 * alignment.
645 * @description This type is not available in Metal. In C or
646 * Objective-C, this type is available as simd_packed_uint8. The
647 * alignment of this type is only that of the underlying scalar element
648 * type, so you can use it to load or store from an array of that type. */
649typedef ::simd_packed_uint8 uint8;
650
651 /*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed
652 * alignment.
653 * @description This type is not available in Metal. In C or
654 * Objective-C, this type is available as simd_packed_uint16. The
655 * alignment of this type is only that of the underlying scalar element
656 * type, so you can use it to load or store from an array of that type. */
657typedef ::simd_packed_uint16 uint16;
658
659 /*! @abstract A vector of two 32-bit floating-point numbers with relaxed
660 * alignment.
661 * @description In C or Objective-C, this type is available as
662 * simd_packed_float2. The alignment of this type is only that of the
663 * underlying scalar element type, so you can use it to load or store
664 * from an array of that type. */
665typedef ::simd_packed_float2 float2;
666
667 /*! @abstract A vector of four 32-bit floating-point numbers with
668 * relaxed alignment.
669 * @description In C or Objective-C, this type is available as
670 * simd_packed_float4. The alignment of this type is only that of the
671 * underlying scalar element type, so you can use it to load or store
672 * from an array of that type. */
673typedef ::simd_packed_float4 float4;
674
675 /*! @abstract A vector of eight 32-bit floating-point numbers with
676 * relaxed alignment.
677 * @description This type is not available in Metal. In C or
678 * Objective-C, this type is available as simd_packed_float8. The
679 * alignment of this type is only that of the underlying scalar element
680 * type, so you can use it to load or store from an array of that type. */
681typedef ::simd_packed_float8 float8;
682
683 /*! @abstract A vector of sixteen 32-bit floating-point numbers with
684 * relaxed alignment.
685 * @description This type is not available in Metal. In C or
686 * Objective-C, this type is available as simd_packed_float16. The
687 * alignment of this type is only that of the underlying scalar element
688 * type, so you can use it to load or store from an array of that type. */
689typedef ::simd_packed_float16 float16;
690
691 /*! @abstract A vector of two 64-bit signed (twos-complement) integers
692 * with relaxed alignment.
693 * @description In C or Objective-C, this type is available as
694 * simd_packed_long2. The alignment of this type is only that of the
695 * underlying scalar element type, so you can use it to load or store
696 * from an array of that type. */
697typedef ::simd_packed_long2 long2;
698
699 /*! @abstract A vector of four 64-bit signed (twos-complement) integers
700 * with relaxed alignment.
701 * @description In C or Objective-C, this type is available as
702 * simd_packed_long4. The alignment of this type is only that of the
703 * underlying scalar element type, so you can use it to load or store
704 * from an array of that type. */
705typedef ::simd_packed_long4 long4;
706
707 /*! @abstract A vector of eight 64-bit signed (twos-complement) integers
708 * with relaxed alignment.
709 * @description This type is not available in Metal. In C or
710 * Objective-C, this type is available as simd_packed_long8. The
711 * alignment of this type is only that of the underlying scalar element
712 * type, so you can use it to load or store from an array of that type. */
713typedef ::simd_packed_long8 long8;
714
715 /*! @abstract A vector of two 64-bit unsigned integers with relaxed
716 * alignment.
717 * @description In C or Objective-C, this type is available as
718 * simd_packed_ulong2. The alignment of this type is only that of the
719 * underlying scalar element type, so you can use it to load or store
720 * from an array of that type. */
721typedef ::simd_packed_ulong2 ulong2;
722
723 /*! @abstract A vector of four 64-bit unsigned integers with relaxed
724 * alignment.
725 * @description In C or Objective-C, this type is available as
726 * simd_packed_ulong4. The alignment of this type is only that of the
727 * underlying scalar element type, so you can use it to load or store
728 * from an array of that type. */
729typedef ::simd_packed_ulong4 ulong4;
730
731 /*! @abstract A vector of eight 64-bit unsigned integers with relaxed
732 * alignment.
733 * @description This type is not available in Metal. In C or
734 * Objective-C, this type is available as simd_packed_ulong8. The
735 * alignment of this type is only that of the underlying scalar element
736 * type, so you can use it to load or store from an array of that type. */
737typedef ::simd_packed_ulong8 ulong8;
738
739 /*! @abstract A vector of two 64-bit floating-point numbers with relaxed
740 * alignment.
741 * @description In C or Objective-C, this type is available as
742 * simd_packed_double2. The alignment of this type is only that of the
743 * underlying scalar element type, so you can use it to load or store
744 * from an array of that type. */
745typedef ::simd_packed_double2 double2;
746
747 /*! @abstract A vector of four 64-bit floating-point numbers with
748 * relaxed alignment.
749 * @description In C or Objective-C, this type is available as
750 * simd_packed_double4. The alignment of this type is only that of the
751 * underlying scalar element type, so you can use it to load or store
752 * from an array of that type. */
753typedef ::simd_packed_double4 double4;
754
755 /*! @abstract A vector of eight 64-bit floating-point numbers with
756 * relaxed alignment.
757 * @description This type is not available in Metal. In C or
758 * Objective-C, this type is available as simd_packed_double8. The
759 * alignment of this type is only that of the underlying scalar element
760 * type, so you can use it to load or store from an array of that type. */
761typedef ::simd_packed_double8 double8;
762
763 } /* namespace simd::packed:: */
764} /* namespace simd:: */
765#endif /* __cplusplus */
766
767/* MARK: Deprecated vector types */
768/*! @group Deprecated vector types
769 * @discussion These are the original types used by earlier versions of the
770 * simd library; they are provided here for compatability with existing source
771 * files. Use the new ("simd_"-prefixed) types for future development. */
772/*! @abstract A vector of two 8-bit signed (twos-complement) integers with
773 * relaxed alignment.
774 * @description This type is deprecated; you should use simd_packed_char2
775 * or simd::packed::char2 instead. */
776typedef simd_packed_char2 packed_char2;
777
778/*! @abstract A vector of four 8-bit signed (twos-complement) integers with
779 * relaxed alignment.
780 * @description This type is deprecated; you should use simd_packed_char4
781 * or simd::packed::char4 instead. */
782typedef simd_packed_char4 packed_char4;
783
784/*! @abstract A vector of eight 8-bit signed (twos-complement) integers with
785 * relaxed alignment.
786 * @description This type is deprecated; you should use simd_packed_char8
787 * or simd::packed::char8 instead. */
788typedef simd_packed_char8 packed_char8;
789
790/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers
791 * with relaxed alignment.
792 * @description This type is deprecated; you should use simd_packed_char16
793 * or simd::packed::char16 instead. */
794typedef simd_packed_char16 packed_char16;
795
796/*! @abstract A vector of thirty-two 8-bit signed (twos-complement) integers
797 * with relaxed alignment.
798 * @description This type is deprecated; you should use simd_packed_char32
799 * or simd::packed::char32 instead. */
800typedef simd_packed_char32 packed_char32;
801
802/*! @abstract A vector of sixty-four 8-bit signed (twos-complement) integers
803 * with relaxed alignment.
804 * @description This type is deprecated; you should use simd_packed_char64
805 * or simd::packed::char64 instead. */
806typedef simd_packed_char64 packed_char64;
807
808/*! @abstract A vector of two 8-bit unsigned integers with relaxed
809 * alignment.
810 * @description This type is deprecated; you should use simd_packed_uchar2
811 * or simd::packed::uchar2 instead. */
812typedef simd_packed_uchar2 packed_uchar2;
813
814/*! @abstract A vector of four 8-bit unsigned integers with relaxed
815 * alignment.
816 * @description This type is deprecated; you should use simd_packed_uchar4
817 * or simd::packed::uchar4 instead. */
818typedef simd_packed_uchar4 packed_uchar4;
819
820/*! @abstract A vector of eight 8-bit unsigned integers with relaxed
821 * alignment.
822 * @description This type is deprecated; you should use simd_packed_uchar8
823 * or simd::packed::uchar8 instead. */
824typedef simd_packed_uchar8 packed_uchar8;
825
826/*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed
827 * alignment.
828 * @description This type is deprecated; you should use simd_packed_uchar16
829 * or simd::packed::uchar16 instead. */
830typedef simd_packed_uchar16 packed_uchar16;
831
832/*! @abstract A vector of thirty-two 8-bit unsigned integers with relaxed
833 * alignment.
834 * @description This type is deprecated; you should use simd_packed_uchar32
835 * or simd::packed::uchar32 instead. */
836typedef simd_packed_uchar32 packed_uchar32;
837
838/*! @abstract A vector of sixty-four 8-bit unsigned integers with relaxed
839 * alignment.
840 * @description This type is deprecated; you should use simd_packed_uchar64
841 * or simd::packed::uchar64 instead. */
842typedef simd_packed_uchar64 packed_uchar64;
843
844/*! @abstract A vector of two 16-bit signed (twos-complement) integers with
845 * relaxed alignment.
846 * @description This type is deprecated; you should use simd_packed_short2
847 * or simd::packed::short2 instead. */
848typedef simd_packed_short2 packed_short2;
849
850/*! @abstract A vector of four 16-bit signed (twos-complement) integers with
851 * relaxed alignment.
852 * @description This type is deprecated; you should use simd_packed_short4
853 * or simd::packed::short4 instead. */
854typedef simd_packed_short4 packed_short4;
855
856/*! @abstract A vector of eight 16-bit signed (twos-complement) integers
857 * with relaxed alignment.
858 * @description This type is deprecated; you should use simd_packed_short8
859 * or simd::packed::short8 instead. */
860typedef simd_packed_short8 packed_short8;
861
862/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers
863 * with relaxed alignment.
864 * @description This type is deprecated; you should use simd_packed_short16
865 * or simd::packed::short16 instead. */
866typedef simd_packed_short16 packed_short16;
867
868/*! @abstract A vector of thirty-two 16-bit signed (twos-complement)
869 * integers with relaxed alignment.
870 * @description This type is deprecated; you should use simd_packed_short32
871 * or simd::packed::short32 instead. */
872typedef simd_packed_short32 packed_short32;
873
874/*! @abstract A vector of two 16-bit unsigned integers with relaxed
875 * alignment.
876 * @description This type is deprecated; you should use simd_packed_ushort2
877 * or simd::packed::ushort2 instead. */
878typedef simd_packed_ushort2 packed_ushort2;
879
880/*! @abstract A vector of four 16-bit unsigned integers with relaxed
881 * alignment.
882 * @description This type is deprecated; you should use simd_packed_ushort4
883 * or simd::packed::ushort4 instead. */
884typedef simd_packed_ushort4 packed_ushort4;
885
886/*! @abstract A vector of eight 16-bit unsigned integers with relaxed
887 * alignment.
888 * @description This type is deprecated; you should use simd_packed_ushort8
889 * or simd::packed::ushort8 instead. */
890typedef simd_packed_ushort8 packed_ushort8;
891
892/*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed
893 * alignment.
894 * @description This type is deprecated; you should use
895 * simd_packed_ushort16 or simd::packed::ushort16 instead. */
896typedef simd_packed_ushort16 packed_ushort16;
897
898/*! @abstract A vector of thirty-two 16-bit unsigned integers with relaxed
899 * alignment.
900 * @description This type is deprecated; you should use
901 * simd_packed_ushort32 or simd::packed::ushort32 instead. */
902typedef simd_packed_ushort32 packed_ushort32;
903
904/*! @abstract A vector of two 32-bit signed (twos-complement) integers with
905 * relaxed alignment.
906 * @description This type is deprecated; you should use simd_packed_int2 or
907 * simd::packed::int2 instead. */
908typedef simd_packed_int2 packed_int2;
909
910/*! @abstract A vector of four 32-bit signed (twos-complement) integers with
911 * relaxed alignment.
912 * @description This type is deprecated; you should use simd_packed_int4 or
913 * simd::packed::int4 instead. */
914typedef simd_packed_int4 packed_int4;
915
916/*! @abstract A vector of eight 32-bit signed (twos-complement) integers
917 * with relaxed alignment.
918 * @description This type is deprecated; you should use simd_packed_int8 or
919 * simd::packed::int8 instead. */
920typedef simd_packed_int8 packed_int8;
921
922/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers
923 * with relaxed alignment.
924 * @description This type is deprecated; you should use simd_packed_int16
925 * or simd::packed::int16 instead. */
926typedef simd_packed_int16 packed_int16;
927
928/*! @abstract A vector of two 32-bit unsigned integers with relaxed
929 * alignment.
930 * @description This type is deprecated; you should use simd_packed_uint2
931 * or simd::packed::uint2 instead. */
932typedef simd_packed_uint2 packed_uint2;
933
934/*! @abstract A vector of four 32-bit unsigned integers with relaxed
935 * alignment.
936 * @description This type is deprecated; you should use simd_packed_uint4
937 * or simd::packed::uint4 instead. */
938typedef simd_packed_uint4 packed_uint4;
939
940/*! @abstract A vector of eight 32-bit unsigned integers with relaxed
941 * alignment.
942 * @description This type is deprecated; you should use simd_packed_uint8
943 * or simd::packed::uint8 instead. */
944typedef simd_packed_uint8 packed_uint8;
945
946/*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed
947 * alignment.
948 * @description This type is deprecated; you should use simd_packed_uint16
949 * or simd::packed::uint16 instead. */
950typedef simd_packed_uint16 packed_uint16;
951
952/*! @abstract A vector of two 32-bit floating-point numbers with relaxed
953 * alignment.
954 * @description This type is deprecated; you should use simd_packed_float2
955 * or simd::packed::float2 instead. */
956typedef simd_packed_float2 packed_float2;
957
958/*! @abstract A vector of four 32-bit floating-point numbers with relaxed
959 * alignment.
960 * @description This type is deprecated; you should use simd_packed_float4
961 * or simd::packed::float4 instead. */
962typedef simd_packed_float4 packed_float4;
963
964/*! @abstract A vector of eight 32-bit floating-point numbers with relaxed
965 * alignment.
966 * @description This type is deprecated; you should use simd_packed_float8
967 * or simd::packed::float8 instead. */
968typedef simd_packed_float8 packed_float8;
969
970/*! @abstract A vector of sixteen 32-bit floating-point numbers with relaxed
971 * alignment.
972 * @description This type is deprecated; you should use simd_packed_float16
973 * or simd::packed::float16 instead. */
974typedef simd_packed_float16 packed_float16;
975
976/*! @abstract A vector of two 64-bit signed (twos-complement) integers with
977 * relaxed alignment.
978 * @description This type is deprecated; you should use simd_packed_long2
979 * or simd::packed::long2 instead. */
980typedef simd_packed_long2 packed_long2;
981
982/*! @abstract A vector of four 64-bit signed (twos-complement) integers with
983 * relaxed alignment.
984 * @description This type is deprecated; you should use simd_packed_long4
985 * or simd::packed::long4 instead. */
986typedef simd_packed_long4 packed_long4;
987
988/*! @abstract A vector of eight 64-bit signed (twos-complement) integers
989 * with relaxed alignment.
990 * @description This type is deprecated; you should use simd_packed_long8
991 * or simd::packed::long8 instead. */
992typedef simd_packed_long8 packed_long8;
993
994/*! @abstract A vector of two 64-bit unsigned integers with relaxed
995 * alignment.
996 * @description This type is deprecated; you should use simd_packed_ulong2
997 * or simd::packed::ulong2 instead. */
998typedef simd_packed_ulong2 packed_ulong2;
999
1000/*! @abstract A vector of four 64-bit unsigned integers with relaxed
1001 * alignment.
1002 * @description This type is deprecated; you should use simd_packed_ulong4
1003 * or simd::packed::ulong4 instead. */
1004typedef simd_packed_ulong4 packed_ulong4;
1005
1006/*! @abstract A vector of eight 64-bit unsigned integers with relaxed
1007 * alignment.
1008 * @description This type is deprecated; you should use simd_packed_ulong8
1009 * or simd::packed::ulong8 instead. */
1010typedef simd_packed_ulong8 packed_ulong8;
1011
1012/*! @abstract A vector of two 64-bit floating-point numbers with relaxed
1013 * alignment.
1014 * @description This type is deprecated; you should use simd_packed_double2
1015 * or simd::packed::double2 instead. */
1016typedef simd_packed_double2 packed_double2;
1017
1018/*! @abstract A vector of four 64-bit floating-point numbers with relaxed
1019 * alignment.
1020 * @description This type is deprecated; you should use simd_packed_double4
1021 * or simd::packed::double4 instead. */
1022typedef simd_packed_double4 packed_double4;
1023
1024/*! @abstract A vector of eight 64-bit floating-point numbers with relaxed
1025 * alignment.
1026 * @description This type is deprecated; you should use simd_packed_double8
1027 * or simd::packed::double8 instead. */
1028typedef simd_packed_double8 packed_double8;
1029
1030# endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
1031#endif
lib/libc/include/x86_64-macos-gnu/simd/quaternion.h created+1194
......@@ -0,0 +1,1194 @@
1/*! @header
2 * This header defines functions for constructing and using quaternions.
3 * @copyright 2015-2016 Apple, Inc. All rights reserved.
4 * @unsorted */
5
6#ifndef SIMD_QUATERNIONS
7#define SIMD_QUATERNIONS
8
9#include <simd/base.h>
10#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
11#include <simd/vector.h>
12#include <simd/types.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/* MARK: - C and Objective-C float interfaces */
19
20/*! @abstract Constructs a quaternion from four scalar values.
21 *
22 * @param ix The first component of the imaginary (vector) part.
23 * @param iy The second component of the imaginary (vector) part.
24 * @param iz The third component of the imaginary (vector) part.
25 *
26 * @param r The real (scalar) part. */
27static inline SIMD_CFUNC simd_quatf simd_quaternion(float ix, float iy, float iz, float r) {
28 return (simd_quatf){ { ix, iy, iz, r } };
29}
30
31/*! @abstract Constructs a quaternion from an array of four scalars.
32 *
33 * @discussion Note that the imaginary part of the quaternion comes from
34 * array elements 0, 1, and 2, and the real part comes from element 3. */
35static inline SIMD_NONCONST simd_quatf simd_quaternion(const float xyzr[4]) {
36 return (simd_quatf){ *(const simd_packed_float4 *)xyzr };
37}
38
39/*! @abstract Constructs a quaternion from a four-element vector.
40 *
41 * @discussion Note that the imaginary (vector) part of the quaternion comes
42 * from lanes 0, 1, and 2 of the vector, and the real (scalar) part comes from
43 * lane 3. */
44static inline SIMD_CFUNC simd_quatf simd_quaternion(simd_float4 xyzr) {
45 return (simd_quatf){ xyzr };
46}
47
48/*! @abstract Constructs a quaternion that rotates by `angle` radians about
49 * `axis`. */
50static inline SIMD_CFUNC simd_quatf simd_quaternion(float angle, simd_float3 axis);
51
52/*! @abstract Construct a quaternion that rotates from one vector to another.
53 *
54 * @param from A normalized three-element vector.
55 * @param to A normalized three-element vector.
56 *
57 * @discussion The rotation axis is `simd_cross(from, to)`. If `from` and
58 * `to` point in opposite directions (to within machine precision), an
59 * arbitrary rotation axis is chosen, and the angle is pi radians. */
60static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3 from, simd_float3 to);
61
62/*! @abstract Construct a quaternion from a 3x3 rotation `matrix`.
63 *
64 * @discussion If `matrix` is not orthogonal with determinant 1, the result
65 * is undefined. */
66static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3x3 matrix);
67
68/*! @abstract Construct a quaternion from a 4x4 rotation `matrix`.
69 *
70 * @discussion The last row and column of the matrix are ignored. This
71 * function is equivalent to calling simd_quaternion with the upper-left 3x3
72 * submatrix . */
73static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float4x4 matrix);
74
75/*! @abstract The real (scalar) part of the quaternion `q`. */
76static inline SIMD_CFUNC float simd_real(simd_quatf q) {
77 return q.vector.w;
78}
79
80/*! @abstract The imaginary (vector) part of the quaternion `q`. */
81static inline SIMD_CFUNC simd_float3 simd_imag(simd_quatf q) {
82 return q.vector.xyz;
83}
84
85/*! @abstract The angle (in radians) of rotation represented by `q`. */
86static inline SIMD_CFUNC float simd_angle(simd_quatf q);
87
88/*! @abstract The normalized axis (a 3-element vector) around which the
89 * action of the quaternion `q` rotates. */
90static inline SIMD_CFUNC simd_float3 simd_axis(simd_quatf q);
91
92/*! @abstract The sum of the quaternions `p` and `q`. */
93static inline SIMD_CFUNC simd_quatf simd_add(simd_quatf p, simd_quatf q);
94
95/*! @abstract The difference of the quaternions `p` and `q`. */
96static inline SIMD_CFUNC simd_quatf simd_sub(simd_quatf p, simd_quatf q);
97
98/*! @abstract The product of the quaternions `p` and `q`. */
99static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf p, simd_quatf q);
100
101/*! @abstract The quaternion `q` scaled by the real value `a`. */
102static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf q, float a);
103
104/*! @abstract The quaternion `q` scaled by the real value `a`. */
105static inline SIMD_CFUNC simd_quatf simd_mul(float a, simd_quatf q);
106
107/*! @abstract The conjugate of the quaternion `q`. */
108static inline SIMD_CFUNC simd_quatf simd_conjugate(simd_quatf q);
109
110/*! @abstract The (multiplicative) inverse of the quaternion `q`. */
111static inline SIMD_CFUNC simd_quatf simd_inverse(simd_quatf q);
112
113/*! @abstract The negation (additive inverse) of the quaternion `q`. */
114static inline SIMD_CFUNC simd_quatf simd_negate(simd_quatf q);
115
116/*! @abstract The dot product of the quaternions `p` and `q` interpreted as
117 * four-dimensional vectors. */
118static inline SIMD_CFUNC float simd_dot(simd_quatf p, simd_quatf q);
119
120/*! @abstract The length of the quaternion `q`. */
121static inline SIMD_CFUNC float simd_length(simd_quatf q);
122
123/*! @abstract The unit quaternion obtained by normalizing `q`. */
124static inline SIMD_CFUNC simd_quatf simd_normalize(simd_quatf q);
125
126/*! @abstract Rotates the vector `v` by the quaternion `q`. */
127static inline SIMD_CFUNC simd_float3 simd_act(simd_quatf q, simd_float3 v);
128
129/*! @abstract Logarithm of the quaternion `q`.
130 * @discussion Do not call this function directly; use `log(q)` instead.
131 *
132 * We can write a quaternion `q` in the form: `r(cos(t) + sin(t)v)` where
133 * `r` is the length of `q`, `t` is an angle, and `v` is a unit 3-vector.
134 * The logarithm of `q` is `log(r) + tv`, just like the logarithm of the
135 * complex number `r*(cos(t) + i sin(t))` is `log(r) + it`.
136 *
137 * Note that this function is not robust against poorly-scaled non-unit
138 * quaternions, because it is primarily used for spline interpolation of
139 * unit quaternions. If you need to compute a robust logarithm of general
140 * quaternions, you can use the following approach:
141 *
142 * scale = simd_reduce_max(simd_abs(q.vector));
143 * logq = log(simd_recip(scale)*q);
144 * logq.real += log(scale);
145 * return logq; */
146static SIMD_NOINLINE simd_quatf __tg_log(simd_quatf q);
147
148/*! @abstract Inverse of `log( )`; the exponential map on quaternions.
149 * @discussion Do not call this function directly; use `exp(q)` instead. */
150static SIMD_NOINLINE simd_quatf __tg_exp(simd_quatf q);
151
152/*! @abstract Spherical linear interpolation along the shortest arc between
153 * quaternions `q0` and `q1`. */
154static SIMD_NOINLINE simd_quatf simd_slerp(simd_quatf q0, simd_quatf q1, float t);
155
156/*! @abstract Spherical linear interpolation along the longest arc between
157 * quaternions `q0` and `q1`. */
158static SIMD_NOINLINE simd_quatf simd_slerp_longest(simd_quatf q0, simd_quatf q1, float t);
159
160/*! @abstract Interpolate between quaternions along a spherical cubic spline.
161 *
162 * @discussion The function interpolates between q1 and q2. q0 is the left
163 * endpoint of the previous interval, and q3 is the right endpoint of the next
164 * interval. Use this function to smoothly interpolate between a sequence of
165 * rotations. */
166static SIMD_NOINLINE simd_quatf simd_spline(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t);
167
168/*! @abstract Spherical cubic Bezier interpolation between quaternions.
169 *
170 * @discussion The function treats q0 ... q3 as control points and uses slerp
171 * in place of lerp in the De Castlejeau algorithm. The endpoints of
172 * interpolation are thus q0 and q3, and the curve will not generally pass
173 * through q1 or q2. Note that the convex hull property of "standard" Bezier
174 * curve does not hold on the sphere. */
175static SIMD_NOINLINE simd_quatf simd_bezier(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t);
176
177#ifdef __cplusplus
178} /* extern "C" */
179/* MARK: - C++ float interfaces */
180
181namespace simd {
182 struct quatf : ::simd_quatf {
183 /*! @abstract The identity quaternion. */
184 quatf( ) : ::simd_quatf(::simd_quaternion((float4){0,0,0,1})) { }
185
186 /*! @abstract Constructs a C++ quaternion from a C quaternion. */
187 quatf(::simd_quatf q) : ::simd_quatf(q) { }
188
189 /*! @abstract Constructs a quaternion from components. */
190 quatf(float ix, float iy, float iz, float r) : ::simd_quatf(::simd_quaternion(ix, iy, iz, r)) { }
191
192 /*! @abstract Constructs a quaternion from an array of scalars. */
193 quatf(const float xyzr[4]) : ::simd_quatf(::simd_quaternion(xyzr)) { }
194
195 /*! @abstract Constructs a quaternion from a vector. */
196 quatf(float4 xyzr) : ::simd_quatf(::simd_quaternion(xyzr)) { }
197
198 /*! @abstract Quaternion representing rotation about `axis` by `angle`
199 * radians. */
200 quatf(float angle, float3 axis) : ::simd_quatf(::simd_quaternion(angle, axis)) { }
201
202 /*! @abstract Quaternion that rotates `from` into `to`. */
203 quatf(float3 from, float3 to) : ::simd_quatf(::simd_quaternion(from, to)) { }
204
205 /*! @abstract Constructs a quaternion from a rotation matrix. */
206 quatf(::simd_float3x3 matrix) : ::simd_quatf(::simd_quaternion(matrix)) { }
207
208 /*! @abstract Constructs a quaternion from a rotation matrix. */
209 quatf(::simd_float4x4 matrix) : ::simd_quatf(::simd_quaternion(matrix)) { }
210
211 /*! @abstract The real (scalar) part of the quaternion. */
212 float real(void) const { return ::simd_real(*this); }
213
214 /*! @abstract The imaginary (vector) part of the quaternion. */
215 float3 imag(void) const { return ::simd_imag(*this); }
216
217 /*! @abstract The angle the quaternion rotates by. */
218 float angle(void) const { return ::simd_angle(*this); }
219
220 /*! @abstract The axis the quaternion rotates about. */
221 float3 axis(void) const { return ::simd_axis(*this); }
222
223 /*! @abstract The length of the quaternion. */
224 float length(void) const { return ::simd_length(*this); }
225
226 /*! @abstract Act on the vector `v` by rotation. */
227 float3 operator()(const ::simd_float3 v) const { return ::simd_act(*this, v); }
228 };
229
230 static SIMD_CPPFUNC quatf operator+(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_add(p, q); }
231 static SIMD_CPPFUNC quatf operator-(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_sub(p, q); }
232 static SIMD_CPPFUNC quatf operator-(const ::simd_quatf p) { return ::simd_negate(p); }
233 static SIMD_CPPFUNC quatf operator*(const float r, const ::simd_quatf p) { return ::simd_mul(r, p); }
234 static SIMD_CPPFUNC quatf operator*(const ::simd_quatf p, const float r) { return ::simd_mul(p, r); }
235 static SIMD_CPPFUNC quatf operator*(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_mul(p, q); }
236 static SIMD_CPPFUNC quatf operator/(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_mul(p, ::simd_inverse(q)); }
237 static SIMD_CPPFUNC quatf operator+=(quatf &p, const ::simd_quatf q) { return p = p+q; }
238 static SIMD_CPPFUNC quatf operator-=(quatf &p, const ::simd_quatf q) { return p = p-q; }
239 static SIMD_CPPFUNC quatf operator*=(quatf &p, const float r) { return p = p*r; }
240 static SIMD_CPPFUNC quatf operator*=(quatf &p, const ::simd_quatf q) { return p = p*q; }
241 static SIMD_CPPFUNC quatf operator/=(quatf &p, const ::simd_quatf q) { return p = p/q; }
242
243 /*! @abstract The conjugate of the quaternion `q`. */
244 static SIMD_CPPFUNC quatf conjugate(const ::simd_quatf p) { return ::simd_conjugate(p); }
245
246 /*! @abstract The (multiplicative) inverse of the quaternion `q`. */
247 static SIMD_CPPFUNC quatf inverse(const ::simd_quatf p) { return ::simd_inverse(p); }
248
249 /*! @abstract The dot product of the quaternions `p` and `q` interpreted as
250 * four-dimensional vectors. */
251 static SIMD_CPPFUNC float dot(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_dot(p, q); }
252
253 /*! @abstract The unit quaternion obtained by normalizing `q`. */
254 static SIMD_CPPFUNC quatf normalize(const ::simd_quatf p) { return ::simd_normalize(p); }
255
256 /*! @abstract logarithm of the quaternion `q`. */
257 static SIMD_CPPFUNC quatf log(const ::simd_quatf q) { return ::__tg_log(q); }
258
259 /*! @abstract exponential map of quaterion `q`. */
260 static SIMD_CPPFUNC quatf exp(const ::simd_quatf q) { return ::__tg_exp(q); }
261
262 /*! @abstract Spherical linear interpolation along the shortest arc between
263 * quaternions `q0` and `q1`. */
264 static SIMD_CPPFUNC quatf slerp(const ::simd_quatf p0, const ::simd_quatf p1, float t) { return ::simd_slerp(p0, p1, t); }
265
266 /*! @abstract Spherical linear interpolation along the longest arc between
267 * quaternions `q0` and `q1`. */
268 static SIMD_CPPFUNC quatf slerp_longest(const ::simd_quatf p0, const ::simd_quatf p1, float t) { return ::simd_slerp_longest(p0, p1, t); }
269
270 /*! @abstract Interpolate between quaternions along a spherical cubic spline.
271 *
272 * @discussion The function interpolates between q1 and q2. q0 is the left
273 * endpoint of the previous interval, and q3 is the right endpoint of the next
274 * interval. Use this function to smoothly interpolate between a sequence of
275 * rotations. */
276 static SIMD_CPPFUNC quatf spline(const ::simd_quatf p0, const ::simd_quatf p1, const ::simd_quatf p2, const ::simd_quatf p3, float t) { return ::simd_spline(p0, p1, p2, p3, t); }
277
278 /*! @abstract Spherical cubic Bezier interpolation between quaternions.
279 *
280 * @discussion The function treats q0 ... q3 as control points and uses slerp
281 * in place of lerp in the De Castlejeau algorithm. The endpoints of
282 * interpolation are thus q0 and q3, and the curve will not generally pass
283 * through q1 or q2. Note that the convex hull property of "standard" Bezier
284 * curve does not hold on the sphere. */
285 static SIMD_CPPFUNC quatf bezier(const ::simd_quatf p0, const ::simd_quatf p1, const ::simd_quatf p2, const ::simd_quatf p3, float t) { return ::simd_bezier(p0, p1, p2, p3, t); }
286}
287
288extern "C" {
289#endif /* __cplusplus */
290
291/* MARK: - float implementations */
292
293#include <simd/math.h>
294#include <simd/geometry.h>
295
296/* tg_promote is implementation gobbledygook that enables the compile-time
297 * dispatching in tgmath.h to work its magic. */
298static simd_quatf __attribute__((__overloadable__)) __tg_promote(simd_quatf);
299
300/*! @abstract Constructs a quaternion from imaginary and real parts.
301 * @discussion This function is hidden behind an underscore to avoid confusion
302 * with the angle-axis constructor. */
303static inline SIMD_CFUNC simd_quatf _simd_quaternion(simd_float3 imag, float real) {
304 return simd_quaternion(simd_make_float4(imag, real));
305}
306
307static inline SIMD_CFUNC simd_quatf simd_quaternion(float angle, simd_float3 axis) {
308 return _simd_quaternion(sin(angle/2) * axis, cos(angle/2));
309}
310
311static inline SIMD_CFUNC float simd_angle(simd_quatf q) {
312 return 2*atan2(simd_length(q.vector.xyz), q.vector.w);
313}
314
315static inline SIMD_CFUNC simd_float3 simd_axis(simd_quatf q) {
316 return simd_normalize(q.vector.xyz);
317}
318
319static inline SIMD_CFUNC simd_quatf simd_add(simd_quatf p, simd_quatf q) {
320 return simd_quaternion(p.vector + q.vector);
321}
322
323static inline SIMD_CFUNC simd_quatf simd_sub(simd_quatf p, simd_quatf q) {
324 return simd_quaternion(p.vector - q.vector);
325}
326
327static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf p, simd_quatf q) {
328 #pragma STDC FP_CONTRACT ON
329 return simd_quaternion((p.vector.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) +
330 p.vector.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5)) +
331 (p.vector.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6) +
332 p.vector.w * q.vector));
333}
334
335static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf q, float a) {
336 return simd_quaternion(a * q.vector);
337}
338
339static inline SIMD_CFUNC simd_quatf simd_mul(float a, simd_quatf q) {
340 return simd_mul(q,a);
341}
342
343static inline SIMD_CFUNC simd_quatf simd_conjugate(simd_quatf q) {
344 return simd_quaternion(q.vector * (simd_float4){-1,-1,-1, 1});
345}
346
347static inline SIMD_CFUNC simd_quatf simd_inverse(simd_quatf q) {
348 return simd_quaternion(simd_conjugate(q).vector * simd_recip(simd_length_squared(q.vector)));
349}
350
351static inline SIMD_CFUNC simd_quatf simd_negate(simd_quatf q) {
352 return simd_quaternion(-q.vector);
353}
354
355static inline SIMD_CFUNC float simd_dot(simd_quatf p, simd_quatf q) {
356 return simd_dot(p.vector, q.vector);
357}
358
359static inline SIMD_CFUNC float simd_length(simd_quatf q) {
360 return simd_length(q.vector);
361}
362
363static inline SIMD_CFUNC simd_quatf simd_normalize(simd_quatf q) {
364 float length_squared = simd_length_squared(q.vector);
365 if (length_squared == 0) {
366 return simd_quaternion((simd_float4){0,0,0,1});
367 }
368 return simd_quaternion(q.vector * simd_rsqrt(length_squared));
369}
370
371#if defined __arm__ || defined __arm64__
372/*! @abstract Multiplies the vector `v` by the quaternion `q`.
373 *
374 * @discussion This IS NOT the action of `q` on `v` (i.e. this is not rotation
375 * by `q`. That operation is provided by `simd_act(q, v)`. This function is an
376 * implementation detail and you should not call it directly. It may be
377 * removed or modified in future versions of the simd module. */
378static inline SIMD_CFUNC simd_quatf _simd_mul_vq(simd_float3 v, simd_quatf q) {
379 #pragma STDC FP_CONTRACT ON
380 return simd_quaternion(v.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) +
381 v.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5) +
382 v.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6));
383}
384#endif
385
386static inline SIMD_CFUNC simd_float3 simd_act(simd_quatf q, simd_float3 v) {
387#if defined __arm__ || defined __arm64__
388 return simd_mul(q, _simd_mul_vq(v, simd_conjugate(q))).vector.xyz;
389#else
390 #pragma STDC FP_CONTRACT ON
391 simd_float3 t = 2*simd_cross(simd_imag(q),v);
392 return v + simd_real(q)*t + simd_cross(simd_imag(q), t);
393#endif
394}
395
396static SIMD_NOINLINE simd_quatf __tg_log(simd_quatf q) {
397 float real = __tg_log(simd_length_squared(q.vector))/2;
398 if (simd_equal(simd_imag(q), 0)) return _simd_quaternion(0, real);
399 simd_float3 imag = __tg_acos(simd_real(q)/simd_length(q)) * simd_normalize(simd_imag(q));
400 return _simd_quaternion(imag, real);
401}
402
403static SIMD_NOINLINE simd_quatf __tg_exp(simd_quatf q) {
404 // angle is actually *twice* the angle of the rotation corresponding to
405 // the resulting quaternion, which is why we don't simply use the (angle,
406 // axis) constructor to generate `unit`.
407 float angle = simd_length(simd_imag(q));
408 if (angle == 0) return _simd_quaternion(0, exp(simd_real(q)));
409 simd_float3 axis = simd_normalize(simd_imag(q));
410 simd_quatf unit = _simd_quaternion(sin(angle)*axis, cosf(angle));
411 return simd_mul(exp(simd_real(q)), unit);
412}
413
414/*! @abstract Implementation detail of the `simd_quaternion(from, to)`
415 * initializer.
416 *
417 * @discussion Computes the quaternion rotation `from` to `to` if they are
418 * separated by less than 90 degrees. Not numerically stable for larger
419 * angles. This function is an implementation detail and you should not
420 * call it directly. It may be removed or modified in future versions of the
421 * simd module. */
422static inline SIMD_CFUNC simd_quatf _simd_quaternion_reduced(simd_float3 from, simd_float3 to) {
423 simd_float3 half = simd_normalize(from + to);
424 return _simd_quaternion(simd_cross(from, half), simd_dot(from, half));
425}
426
427static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3 from, simd_float3 to) {
428
429 // If the angle between from and to is not too big, we can compute the
430 // rotation accurately using a simple implementation.
431 if (simd_dot(from, to) >= 0) {
432 return _simd_quaternion_reduced(from, to);
433 }
434
435 // Because from and to are more than 90 degrees apart, we compute the
436 // rotation in two stages (from -> half), (half -> to) to preserve numerical
437 // accuracy.
438 simd_float3 half = from + to;
439
440 if (simd_length_squared(half) == 0) {
441 // half is nearly zero, so from and to point in nearly opposite directions
442 // and the rotation is numerically underspecified. Pick an axis orthogonal
443 // to the vectors, and use an angle of pi radians.
444 simd_float3 abs_from = simd_abs(from);
445 if (abs_from.x <= abs_from.y && abs_from.x <= abs_from.z)
446 return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){1,0,0})), 0.f);
447 else if (abs_from.y <= abs_from.z)
448 return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){0,1,0})), 0.f);
449 else
450 return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){0,0,1})), 0.f);
451 }
452
453 // Compute the two-step rotation. */
454 half = simd_normalize(half);
455 return simd_mul(_simd_quaternion_reduced(from, half),
456 _simd_quaternion_reduced(half, to));
457}
458
459static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3x3 matrix) {
460 const simd_float3 *mat = matrix.columns;
461 float trace = mat[0][0] + mat[1][1] + mat[2][2];
462 if (trace >= 0.0) {
463 float r = 2*sqrt(1 + trace);
464 float rinv = simd_recip(r);
465 return simd_quaternion(rinv*(mat[1][2] - mat[2][1]),
466 rinv*(mat[2][0] - mat[0][2]),
467 rinv*(mat[0][1] - mat[1][0]),
468 r/4);
469 } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) {
470 float r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]);
471 float rinv = simd_recip(r);
472 return simd_quaternion(r/4,
473 rinv*(mat[0][1] + mat[1][0]),
474 rinv*(mat[0][2] + mat[2][0]),
475 rinv*(mat[1][2] - mat[2][1]));
476 } else if (mat[1][1] >= mat[2][2]) {
477 float r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]);
478 float rinv = simd_recip(r);
479 return simd_quaternion(rinv*(mat[0][1] + mat[1][0]),
480 r/4,
481 rinv*(mat[1][2] + mat[2][1]),
482 rinv*(mat[2][0] - mat[0][2]));
483 } else {
484 float r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]);
485 float rinv = simd_recip(r);
486 return simd_quaternion(rinv*(mat[0][2] + mat[2][0]),
487 rinv*(mat[1][2] + mat[2][1]),
488 r/4,
489 rinv*(mat[0][1] - mat[1][0]));
490 }
491}
492
493static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float4x4 matrix) {
494 const simd_float4 *mat = matrix.columns;
495 float trace = mat[0][0] + mat[1][1] + mat[2][2];
496 if (trace >= 0.0) {
497 float r = 2*sqrt(1 + trace);
498 float rinv = simd_recip(r);
499 return simd_quaternion(rinv*(mat[1][2] - mat[2][1]),
500 rinv*(mat[2][0] - mat[0][2]),
501 rinv*(mat[0][1] - mat[1][0]),
502 r/4);
503 } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) {
504 float r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]);
505 float rinv = simd_recip(r);
506 return simd_quaternion(r/4,
507 rinv*(mat[0][1] + mat[1][0]),
508 rinv*(mat[0][2] + mat[2][0]),
509 rinv*(mat[1][2] - mat[2][1]));
510 } else if (mat[1][1] >= mat[2][2]) {
511 float r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]);
512 float rinv = simd_recip(r);
513 return simd_quaternion(rinv*(mat[0][1] + mat[1][0]),
514 r/4,
515 rinv*(mat[1][2] + mat[2][1]),
516 rinv*(mat[2][0] - mat[0][2]));
517 } else {
518 float r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]);
519 float rinv = simd_recip(r);
520 return simd_quaternion(rinv*(mat[0][2] + mat[2][0]),
521 rinv*(mat[1][2] + mat[2][1]),
522 r/4,
523 rinv*(mat[0][1] - mat[1][0]));
524 }
525}
526
527/*! @abstract The angle between p and q interpreted as 4-dimensional vectors.
528 *
529 * @discussion This function is an implementation detail and you should not
530 * call it directly. It may be removed or modified in future versions of the
531 * simd module. */
532static SIMD_NOINLINE float _simd_angle(simd_quatf p, simd_quatf q) {
533 return 2*atan2(simd_length(p.vector - q.vector), simd_length(p.vector + q.vector));
534}
535
536/*! @abstract sin(x)/x.
537 *
538 * @discussion This function is an implementation detail and you should not
539 * call it directly. It may be removed or modified in future versions of the
540 * simd module. */
541static SIMD_CFUNC float _simd_sinc(float x) {
542 if (x == 0) return 1;
543 return sin(x)/x;
544}
545
546/*! @abstract Spherical lerp between q0 and q1.
547 *
548 * @discussion This function may interpolate along either the longer or
549 * shorter path between q0 and q1; it is used as an implementation detail
550 * in `simd_slerp` and `simd_slerp_longest`; you should use those functions
551 * instead of calling this directly. */
552static SIMD_NOINLINE simd_quatf _simd_slerp_internal(simd_quatf q0, simd_quatf q1, float t) {
553 float s = 1 - t;
554 float a = _simd_angle(q0, q1);
555 float r = simd_recip(_simd_sinc(a));
556 return simd_normalize(simd_quaternion(_simd_sinc(s*a)*r*s*q0.vector + _simd_sinc(t*a)*r*t*q1.vector));
557}
558
559static SIMD_NOINLINE simd_quatf simd_slerp(simd_quatf q0, simd_quatf q1, float t) {
560 if (simd_dot(q0, q1) >= 0)
561 return _simd_slerp_internal(q0, q1, t);
562 return _simd_slerp_internal(q0, simd_negate(q1), t);
563}
564
565static SIMD_NOINLINE simd_quatf simd_slerp_longest(simd_quatf q0, simd_quatf q1, float t) {
566 if (simd_dot(q0, q1) >= 0)
567 return _simd_slerp_internal(q0, simd_negate(q1), t);
568 return _simd_slerp_internal(q0, q1, t);
569}
570
571/*! @discussion This function is an implementation detail and you should not
572 * call it directly. It may be removed or modified in future versions of the
573 * simd module. */
574static SIMD_NOINLINE simd_quatf _simd_intermediate(simd_quatf q0, simd_quatf q1, simd_quatf q2) {
575 simd_quatf p0 = __tg_log(simd_mul(q0, simd_inverse(q1)));
576 simd_quatf p2 = __tg_log(simd_mul(q2, simd_inverse(q1)));
577 return simd_normalize(simd_mul(q1, __tg_exp(simd_mul(-0.25, simd_add(p0,p2)))));
578}
579
580/*! @discussion This function is an implementation detail and you should not
581 * call it directly. It may be removed or modified in future versions of the
582 * simd module. */
583static SIMD_NOINLINE simd_quatf _simd_squad(simd_quatf q0, simd_quatf qa, simd_quatf qb, simd_quatf q1, float t) {
584 simd_quatf r0 = _simd_slerp_internal(q0, q1, t);
585 simd_quatf r1 = _simd_slerp_internal(qa, qb, t);
586 return _simd_slerp_internal(r0, r1, 2*t*(1 - t));
587}
588
589static SIMD_NOINLINE simd_quatf simd_spline(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t) {
590 simd_quatf qa = _simd_intermediate(q0, q1, q2);
591 simd_quatf qb = _simd_intermediate(q1, q2, q3);
592 return _simd_squad(q1, qa, qb, q2, t);
593}
594
595static SIMD_NOINLINE simd_quatf simd_bezier(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t) {
596 simd_quatf q01 = _simd_slerp_internal(q0, q1, t);
597 simd_quatf q12 = _simd_slerp_internal(q1, q2, t);
598 simd_quatf q23 = _simd_slerp_internal(q2, q3, t);
599 simd_quatf q012 = _simd_slerp_internal(q01, q12, t);
600 simd_quatf q123 = _simd_slerp_internal(q12, q23, t);
601 return _simd_slerp_internal(q012, q123, t);
602}
603
604/* MARK: - C and Objective-C double interfaces */
605
606/*! @abstract Constructs a quaternion from four scalar values.
607 *
608 * @param ix The first component of the imaginary (vector) part.
609 * @param iy The second component of the imaginary (vector) part.
610 * @param iz The third component of the imaginary (vector) part.
611 *
612 * @param r The real (scalar) part. */
613static inline SIMD_CFUNC simd_quatd simd_quaternion(double ix, double iy, double iz, double r) {
614 return (simd_quatd){ { ix, iy, iz, r } };
615}
616
617/*! @abstract Constructs a quaternion from an array of four scalars.
618 *
619 * @discussion Note that the imaginary part of the quaternion comes from
620 * array elements 0, 1, and 2, and the real part comes from element 3. */
621static inline SIMD_NONCONST simd_quatd simd_quaternion(const double xyzr[4]) {
622 return (simd_quatd){ *(const simd_packed_double4 *)xyzr };
623}
624
625/*! @abstract Constructs a quaternion from a four-element vector.
626 *
627 * @discussion Note that the imaginary (vector) part of the quaternion comes
628 * from lanes 0, 1, and 2 of the vector, and the real (scalar) part comes from
629 * lane 3. */
630static inline SIMD_CFUNC simd_quatd simd_quaternion(simd_double4 xyzr) {
631 return (simd_quatd){ xyzr };
632}
633
634/*! @abstract Constructs a quaternion that rotates by `angle` radians about
635 * `axis`. */
636static inline SIMD_CFUNC simd_quatd simd_quaternion(double angle, simd_double3 axis);
637
638/*! @abstract Construct a quaternion that rotates from one vector to another.
639 *
640 * @param from A normalized three-element vector.
641 * @param to A normalized three-element vector.
642 *
643 * @discussion The rotation axis is `simd_cross(from, to)`. If `from` and
644 * `to` point in opposite directions (to within machine precision), an
645 * arbitrary rotation axis is chosen, and the angle is pi radians. */
646static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3 from, simd_double3 to);
647
648/*! @abstract Construct a quaternion from a 3x3 rotation `matrix`.
649 *
650 * @discussion If `matrix` is not orthogonal with determinant 1, the result
651 * is undefined. */
652static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3x3 matrix);
653
654/*! @abstract Construct a quaternion from a 4x4 rotation `matrix`.
655 *
656 * @discussion The last row and column of the matrix are ignored. This
657 * function is equivalent to calling simd_quaternion with the upper-left 3x3
658 * submatrix . */
659static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double4x4 matrix);
660
661/*! @abstract The real (scalar) part of the quaternion `q`. */
662static inline SIMD_CFUNC double simd_real(simd_quatd q) {
663 return q.vector.w;
664}
665
666/*! @abstract The imaginary (vector) part of the quaternion `q`. */
667static inline SIMD_CFUNC simd_double3 simd_imag(simd_quatd q) {
668 return q.vector.xyz;
669}
670
671/*! @abstract The angle (in radians) of rotation represented by `q`. */
672static inline SIMD_CFUNC double simd_angle(simd_quatd q);
673
674/*! @abstract The normalized axis (a 3-element vector) around which the
675 * action of the quaternion `q` rotates. */
676static inline SIMD_CFUNC simd_double3 simd_axis(simd_quatd q);
677
678/*! @abstract The sum of the quaternions `p` and `q`. */
679static inline SIMD_CFUNC simd_quatd simd_add(simd_quatd p, simd_quatd q);
680
681/*! @abstract The difference of the quaternions `p` and `q`. */
682static inline SIMD_CFUNC simd_quatd simd_sub(simd_quatd p, simd_quatd q);
683
684/*! @abstract The product of the quaternions `p` and `q`. */
685static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd p, simd_quatd q);
686
687/*! @abstract The quaternion `q` scaled by the real value `a`. */
688static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd q, double a);
689
690/*! @abstract The quaternion `q` scaled by the real value `a`. */
691static inline SIMD_CFUNC simd_quatd simd_mul(double a, simd_quatd q);
692
693/*! @abstract The conjugate of the quaternion `q`. */
694static inline SIMD_CFUNC simd_quatd simd_conjugate(simd_quatd q);
695
696/*! @abstract The (multiplicative) inverse of the quaternion `q`. */
697static inline SIMD_CFUNC simd_quatd simd_inverse(simd_quatd q);
698
699/*! @abstract The negation (additive inverse) of the quaternion `q`. */
700static inline SIMD_CFUNC simd_quatd simd_negate(simd_quatd q);
701
702/*! @abstract The dot product of the quaternions `p` and `q` interpreted as
703 * four-dimensional vectors. */
704static inline SIMD_CFUNC double simd_dot(simd_quatd p, simd_quatd q);
705
706/*! @abstract The length of the quaternion `q`. */
707static inline SIMD_CFUNC double simd_length(simd_quatd q);
708
709/*! @abstract The unit quaternion obtained by normalizing `q`. */
710static inline SIMD_CFUNC simd_quatd simd_normalize(simd_quatd q);
711
712/*! @abstract Rotates the vector `v` by the quaternion `q`. */
713static inline SIMD_CFUNC simd_double3 simd_act(simd_quatd q, simd_double3 v);
714
715/*! @abstract Logarithm of the quaternion `q`.
716 * @discussion Do not call this function directly; use `log(q)` instead.
717 *
718 * We can write a quaternion `q` in the form: `r(cos(t) + sin(t)v)` where
719 * `r` is the length of `q`, `t` is an angle, and `v` is a unit 3-vector.
720 * The logarithm of `q` is `log(r) + tv`, just like the logarithm of the
721 * complex number `r*(cos(t) + i sin(t))` is `log(r) + it`.
722 *
723 * Note that this function is not robust against poorly-scaled non-unit
724 * quaternions, because it is primarily used for spline interpolation of
725 * unit quaternions. If you need to compute a robust logarithm of general
726 * quaternions, you can use the following approach:
727 *
728 * scale = simd_reduce_max(simd_abs(q.vector));
729 * logq = log(simd_recip(scale)*q);
730 * logq.real += log(scale);
731 * return logq; */
732static SIMD_NOINLINE simd_quatd __tg_log(simd_quatd q);
733
734/*! @abstract Inverse of `log( )`; the exponential map on quaternions.
735 * @discussion Do not call this function directly; use `exp(q)` instead. */
736static SIMD_NOINLINE simd_quatd __tg_exp(simd_quatd q);
737
738/*! @abstract Spherical linear interpolation along the shortest arc between
739 * quaternions `q0` and `q1`. */
740static SIMD_NOINLINE simd_quatd simd_slerp(simd_quatd q0, simd_quatd q1, double t);
741
742/*! @abstract Spherical linear interpolation along the longest arc between
743 * quaternions `q0` and `q1`. */
744static SIMD_NOINLINE simd_quatd simd_slerp_longest(simd_quatd q0, simd_quatd q1, double t);
745
746/*! @abstract Interpolate between quaternions along a spherical cubic spline.
747 *
748 * @discussion The function interpolates between q1 and q2. q0 is the left
749 * endpoint of the previous interval, and q3 is the right endpoint of the next
750 * interval. Use this function to smoothly interpolate between a sequence of
751 * rotations. */
752static SIMD_NOINLINE simd_quatd simd_spline(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t);
753
754/*! @abstract Spherical cubic Bezier interpolation between quaternions.
755 *
756 * @discussion The function treats q0 ... q3 as control points and uses slerp
757 * in place of lerp in the De Castlejeau algorithm. The endpoints of
758 * interpolation are thus q0 and q3, and the curve will not generally pass
759 * through q1 or q2. Note that the convex hull property of "standard" Bezier
760 * curve does not hold on the sphere. */
761static SIMD_NOINLINE simd_quatd simd_bezier(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t);
762
763#ifdef __cplusplus
764} /* extern "C" */
765/* MARK: - C++ double interfaces */
766
767namespace simd {
768 struct quatd : ::simd_quatd {
769 /*! @abstract The identity quaternion. */
770 quatd( ) : ::simd_quatd(::simd_quaternion((double4){0,0,0,1})) { }
771
772 /*! @abstract Constructs a C++ quaternion from a C quaternion. */
773 quatd(::simd_quatd q) : ::simd_quatd(q) { }
774
775 /*! @abstract Constructs a quaternion from components. */
776 quatd(double ix, double iy, double iz, double r) : ::simd_quatd(::simd_quaternion(ix, iy, iz, r)) { }
777
778 /*! @abstract Constructs a quaternion from an array of scalars. */
779 quatd(const double xyzr[4]) : ::simd_quatd(::simd_quaternion(xyzr)) { }
780
781 /*! @abstract Constructs a quaternion from a vector. */
782 quatd(double4 xyzr) : ::simd_quatd(::simd_quaternion(xyzr)) { }
783
784 /*! @abstract Quaternion representing rotation about `axis` by `angle`
785 * radians. */
786 quatd(double angle, double3 axis) : ::simd_quatd(::simd_quaternion(angle, axis)) { }
787
788 /*! @abstract Quaternion that rotates `from` into `to`. */
789 quatd(double3 from, double3 to) : ::simd_quatd(::simd_quaternion(from, to)) { }
790
791 /*! @abstract Constructs a quaternion from a rotation matrix. */
792 quatd(::simd_double3x3 matrix) : ::simd_quatd(::simd_quaternion(matrix)) { }
793
794 /*! @abstract Constructs a quaternion from a rotation matrix. */
795 quatd(::simd_double4x4 matrix) : ::simd_quatd(::simd_quaternion(matrix)) { }
796
797 /*! @abstract The real (scalar) part of the quaternion. */
798 double real(void) const { return ::simd_real(*this); }
799
800 /*! @abstract The imaginary (vector) part of the quaternion. */
801 double3 imag(void) const { return ::simd_imag(*this); }
802
803 /*! @abstract The angle the quaternion rotates by. */
804 double angle(void) const { return ::simd_angle(*this); }
805
806 /*! @abstract The axis the quaternion rotates about. */
807 double3 axis(void) const { return ::simd_axis(*this); }
808
809 /*! @abstract The length of the quaternion. */
810 double length(void) const { return ::simd_length(*this); }
811
812 /*! @abstract Act on the vector `v` by rotation. */
813 double3 operator()(const ::simd_double3 v) const { return ::simd_act(*this, v); }
814 };
815
816 static SIMD_CPPFUNC quatd operator+(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_add(p, q); }
817 static SIMD_CPPFUNC quatd operator-(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_sub(p, q); }
818 static SIMD_CPPFUNC quatd operator-(const ::simd_quatd p) { return ::simd_negate(p); }
819 static SIMD_CPPFUNC quatd operator*(const double r, const ::simd_quatd p) { return ::simd_mul(r, p); }
820 static SIMD_CPPFUNC quatd operator*(const ::simd_quatd p, const double r) { return ::simd_mul(p, r); }
821 static SIMD_CPPFUNC quatd operator*(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_mul(p, q); }
822 static SIMD_CPPFUNC quatd operator/(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_mul(p, ::simd_inverse(q)); }
823 static SIMD_CPPFUNC quatd operator+=(quatd &p, const ::simd_quatd q) { return p = p+q; }
824 static SIMD_CPPFUNC quatd operator-=(quatd &p, const ::simd_quatd q) { return p = p-q; }
825 static SIMD_CPPFUNC quatd operator*=(quatd &p, const double r) { return p = p*r; }
826 static SIMD_CPPFUNC quatd operator*=(quatd &p, const ::simd_quatd q) { return p = p*q; }
827 static SIMD_CPPFUNC quatd operator/=(quatd &p, const ::simd_quatd q) { return p = p/q; }
828
829 /*! @abstract The conjugate of the quaternion `q`. */
830 static SIMD_CPPFUNC quatd conjugate(const ::simd_quatd p) { return ::simd_conjugate(p); }
831
832 /*! @abstract The (multiplicative) inverse of the quaternion `q`. */
833 static SIMD_CPPFUNC quatd inverse(const ::simd_quatd p) { return ::simd_inverse(p); }
834
835 /*! @abstract The dot product of the quaternions `p` and `q` interpreted as
836 * four-dimensional vectors. */
837 static SIMD_CPPFUNC double dot(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_dot(p, q); }
838
839 /*! @abstract The unit quaternion obtained by normalizing `q`. */
840 static SIMD_CPPFUNC quatd normalize(const ::simd_quatd p) { return ::simd_normalize(p); }
841
842 /*! @abstract logarithm of the quaternion `q`. */
843 static SIMD_CPPFUNC quatd log(const ::simd_quatd q) { return ::__tg_log(q); }
844
845 /*! @abstract exponential map of quaterion `q`. */
846 static SIMD_CPPFUNC quatd exp(const ::simd_quatd q) { return ::__tg_exp(q); }
847
848 /*! @abstract Spherical linear interpolation along the shortest arc between
849 * quaternions `q0` and `q1`. */
850 static SIMD_CPPFUNC quatd slerp(const ::simd_quatd p0, const ::simd_quatd p1, double t) { return ::simd_slerp(p0, p1, t); }
851
852 /*! @abstract Spherical linear interpolation along the longest arc between
853 * quaternions `q0` and `q1`. */
854 static SIMD_CPPFUNC quatd slerp_longest(const ::simd_quatd p0, const ::simd_quatd p1, double t) { return ::simd_slerp_longest(p0, p1, t); }
855
856 /*! @abstract Interpolate between quaternions along a spherical cubic spline.
857 *
858 * @discussion The function interpolates between q1 and q2. q0 is the left
859 * endpoint of the previous interval, and q3 is the right endpoint of the next
860 * interval. Use this function to smoothly interpolate between a sequence of
861 * rotations. */
862 static SIMD_CPPFUNC quatd spline(const ::simd_quatd p0, const ::simd_quatd p1, const ::simd_quatd p2, const ::simd_quatd p3, double t) { return ::simd_spline(p0, p1, p2, p3, t); }
863
864 /*! @abstract Spherical cubic Bezier interpolation between quaternions.
865 *
866 * @discussion The function treats q0 ... q3 as control points and uses slerp
867 * in place of lerp in the De Castlejeau algorithm. The endpoints of
868 * interpolation are thus q0 and q3, and the curve will not generally pass
869 * through q1 or q2. Note that the convex hull property of "standard" Bezier
870 * curve does not hold on the sphere. */
871 static SIMD_CPPFUNC quatd bezier(const ::simd_quatd p0, const ::simd_quatd p1, const ::simd_quatd p2, const ::simd_quatd p3, double t) { return ::simd_bezier(p0, p1, p2, p3, t); }
872}
873
874extern "C" {
875#endif /* __cplusplus */
876
877/* MARK: - double implementations */
878
879#include <simd/math.h>
880#include <simd/geometry.h>
881
882/* tg_promote is implementation gobbledygook that enables the compile-time
883 * dispatching in tgmath.h to work its magic. */
884static simd_quatd __attribute__((__overloadable__)) __tg_promote(simd_quatd);
885
886/*! @abstract Constructs a quaternion from imaginary and real parts.
887 * @discussion This function is hidden behind an underscore to avoid confusion
888 * with the angle-axis constructor. */
889static inline SIMD_CFUNC simd_quatd _simd_quaternion(simd_double3 imag, double real) {
890 return simd_quaternion(simd_make_double4(imag, real));
891}
892
893static inline SIMD_CFUNC simd_quatd simd_quaternion(double angle, simd_double3 axis) {
894 return _simd_quaternion(sin(angle/2) * axis, cos(angle/2));
895}
896
897static inline SIMD_CFUNC double simd_angle(simd_quatd q) {
898 return 2*atan2(simd_length(q.vector.xyz), q.vector.w);
899}
900
901static inline SIMD_CFUNC simd_double3 simd_axis(simd_quatd q) {
902 return simd_normalize(q.vector.xyz);
903}
904
905static inline SIMD_CFUNC simd_quatd simd_add(simd_quatd p, simd_quatd q) {
906 return simd_quaternion(p.vector + q.vector);
907}
908
909static inline SIMD_CFUNC simd_quatd simd_sub(simd_quatd p, simd_quatd q) {
910 return simd_quaternion(p.vector - q.vector);
911}
912
913static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd p, simd_quatd q) {
914 #pragma STDC FP_CONTRACT ON
915 return simd_quaternion((p.vector.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) +
916 p.vector.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5)) +
917 (p.vector.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6) +
918 p.vector.w * q.vector));
919}
920
921static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd q, double a) {
922 return simd_quaternion(a * q.vector);
923}
924
925static inline SIMD_CFUNC simd_quatd simd_mul(double a, simd_quatd q) {
926 return simd_mul(q,a);
927}
928
929static inline SIMD_CFUNC simd_quatd simd_conjugate(simd_quatd q) {
930 return simd_quaternion(q.vector * (simd_double4){-1,-1,-1, 1});
931}
932
933static inline SIMD_CFUNC simd_quatd simd_inverse(simd_quatd q) {
934 return simd_quaternion(simd_conjugate(q).vector * simd_recip(simd_length_squared(q.vector)));
935}
936
937static inline SIMD_CFUNC simd_quatd simd_negate(simd_quatd q) {
938 return simd_quaternion(-q.vector);
939}
940
941static inline SIMD_CFUNC double simd_dot(simd_quatd p, simd_quatd q) {
942 return simd_dot(p.vector, q.vector);
943}
944
945static inline SIMD_CFUNC double simd_length(simd_quatd q) {
946 return simd_length(q.vector);
947}
948
949static inline SIMD_CFUNC simd_quatd simd_normalize(simd_quatd q) {
950 double length_squared = simd_length_squared(q.vector);
951 if (length_squared == 0) {
952 return simd_quaternion((simd_double4){0,0,0,1});
953 }
954 return simd_quaternion(q.vector * simd_rsqrt(length_squared));
955}
956
957#if defined __arm__ || defined __arm64__
958/*! @abstract Multiplies the vector `v` by the quaternion `q`.
959 *
960 * @discussion This IS NOT the action of `q` on `v` (i.e. this is not rotation
961 * by `q`. That operation is provided by `simd_act(q, v)`. This function is an
962 * implementation detail and you should not call it directly. It may be
963 * removed or modified in future versions of the simd module. */
964static inline SIMD_CFUNC simd_quatd _simd_mul_vq(simd_double3 v, simd_quatd q) {
965 #pragma STDC FP_CONTRACT ON
966 return simd_quaternion(v.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) +
967 v.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5) +
968 v.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6));
969}
970#endif
971
972static inline SIMD_CFUNC simd_double3 simd_act(simd_quatd q, simd_double3 v) {
973#if defined __arm__ || defined __arm64__
974 return simd_mul(q, _simd_mul_vq(v, simd_conjugate(q))).vector.xyz;
975#else
976 #pragma STDC FP_CONTRACT ON
977 simd_double3 t = 2*simd_cross(simd_imag(q),v);
978 return v + simd_real(q)*t + simd_cross(simd_imag(q), t);
979#endif
980}
981
982static SIMD_NOINLINE simd_quatd __tg_log(simd_quatd q) {
983 double real = __tg_log(simd_length_squared(q.vector))/2;
984 if (simd_equal(simd_imag(q), 0)) return _simd_quaternion(0, real);
985 simd_double3 imag = __tg_acos(simd_real(q)/simd_length(q)) * simd_normalize(simd_imag(q));
986 return _simd_quaternion(imag, real);
987}
988
989static SIMD_NOINLINE simd_quatd __tg_exp(simd_quatd q) {
990 // angle is actually *twice* the angle of the rotation corresponding to
991 // the resulting quaternion, which is why we don't simply use the (angle,
992 // axis) constructor to generate `unit`.
993 double angle = simd_length(simd_imag(q));
994 if (angle == 0) return _simd_quaternion(0, exp(simd_real(q)));
995 simd_double3 axis = simd_normalize(simd_imag(q));
996 simd_quatd unit = _simd_quaternion(sin(angle)*axis, cosf(angle));
997 return simd_mul(exp(simd_real(q)), unit);
998}
999
1000/*! @abstract Implementation detail of the `simd_quaternion(from, to)`
1001 * initializer.
1002 *
1003 * @discussion Computes the quaternion rotation `from` to `to` if they are
1004 * separated by less than 90 degrees. Not numerically stable for larger
1005 * angles. This function is an implementation detail and you should not
1006 * call it directly. It may be removed or modified in future versions of the
1007 * simd module. */
1008static inline SIMD_CFUNC simd_quatd _simd_quaternion_reduced(simd_double3 from, simd_double3 to) {
1009 simd_double3 half = simd_normalize(from + to);
1010 return _simd_quaternion(simd_cross(from, half), simd_dot(from, half));
1011}
1012
1013static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3 from, simd_double3 to) {
1014
1015 // If the angle between from and to is not too big, we can compute the
1016 // rotation accurately using a simple implementation.
1017 if (simd_dot(from, to) >= 0) {
1018 return _simd_quaternion_reduced(from, to);
1019 }
1020
1021 // Because from and to are more than 90 degrees apart, we compute the
1022 // rotation in two stages (from -> half), (half -> to) to preserve numerical
1023 // accuracy.
1024 simd_double3 half = from + to;
1025
1026 if (simd_length_squared(half) == 0) {
1027 // half is nearly zero, so from and to point in nearly opposite directions
1028 // and the rotation is numerically underspecified. Pick an axis orthogonal
1029 // to the vectors, and use an angle of pi radians.
1030 simd_double3 abs_from = simd_abs(from);
1031 if (abs_from.x <= abs_from.y && abs_from.x <= abs_from.z)
1032 return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){1,0,0})), 0.f);
1033 else if (abs_from.y <= abs_from.z)
1034 return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){0,1,0})), 0.f);
1035 else
1036 return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){0,0,1})), 0.f);
1037 }
1038
1039 // Compute the two-step rotation. */
1040 half = simd_normalize(half);
1041 return simd_mul(_simd_quaternion_reduced(from, half),
1042 _simd_quaternion_reduced(half, to));
1043}
1044
1045static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3x3 matrix) {
1046 const simd_double3 *mat = matrix.columns;
1047 double trace = mat[0][0] + mat[1][1] + mat[2][2];
1048 if (trace >= 0.0) {
1049 double r = 2*sqrt(1 + trace);
1050 double rinv = simd_recip(r);
1051 return simd_quaternion(rinv*(mat[1][2] - mat[2][1]),
1052 rinv*(mat[2][0] - mat[0][2]),
1053 rinv*(mat[0][1] - mat[1][0]),
1054 r/4);
1055 } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) {
1056 double r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]);
1057 double rinv = simd_recip(r);
1058 return simd_quaternion(r/4,
1059 rinv*(mat[0][1] + mat[1][0]),
1060 rinv*(mat[0][2] + mat[2][0]),
1061 rinv*(mat[1][2] - mat[2][1]));
1062 } else if (mat[1][1] >= mat[2][2]) {
1063 double r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]);
1064 double rinv = simd_recip(r);
1065 return simd_quaternion(rinv*(mat[0][1] + mat[1][0]),
1066 r/4,
1067 rinv*(mat[1][2] + mat[2][1]),
1068 rinv*(mat[2][0] - mat[0][2]));
1069 } else {
1070 double r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]);
1071 double rinv = simd_recip(r);
1072 return simd_quaternion(rinv*(mat[0][2] + mat[2][0]),
1073 rinv*(mat[1][2] + mat[2][1]),
1074 r/4,
1075 rinv*(mat[0][1] - mat[1][0]));
1076 }
1077}
1078
1079static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double4x4 matrix) {
1080 const simd_double4 *mat = matrix.columns;
1081 double trace = mat[0][0] + mat[1][1] + mat[2][2];
1082 if (trace >= 0.0) {
1083 double r = 2*sqrt(1 + trace);
1084 double rinv = simd_recip(r);
1085 return simd_quaternion(rinv*(mat[1][2] - mat[2][1]),
1086 rinv*(mat[2][0] - mat[0][2]),
1087 rinv*(mat[0][1] - mat[1][0]),
1088 r/4);
1089 } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) {
1090 double r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]);
1091 double rinv = simd_recip(r);
1092 return simd_quaternion(r/4,
1093 rinv*(mat[0][1] + mat[1][0]),
1094 rinv*(mat[0][2] + mat[2][0]),
1095 rinv*(mat[1][2] - mat[2][1]));
1096 } else if (mat[1][1] >= mat[2][2]) {
1097 double r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]);
1098 double rinv = simd_recip(r);
1099 return simd_quaternion(rinv*(mat[0][1] + mat[1][0]),
1100 r/4,
1101 rinv*(mat[1][2] + mat[2][1]),
1102 rinv*(mat[2][0] - mat[0][2]));
1103 } else {
1104 double r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]);
1105 double rinv = simd_recip(r);
1106 return simd_quaternion(rinv*(mat[0][2] + mat[2][0]),
1107 rinv*(mat[1][2] + mat[2][1]),
1108 r/4,
1109 rinv*(mat[0][1] - mat[1][0]));
1110 }
1111}
1112
1113/*! @abstract The angle between p and q interpreted as 4-dimensional vectors.
1114 *
1115 * @discussion This function is an implementation detail and you should not
1116 * call it directly. It may be removed or modified in future versions of the
1117 * simd module. */
1118static SIMD_NOINLINE double _simd_angle(simd_quatd p, simd_quatd q) {
1119 return 2*atan2(simd_length(p.vector - q.vector), simd_length(p.vector + q.vector));
1120}
1121
1122/*! @abstract sin(x)/x.
1123 *
1124 * @discussion This function is an implementation detail and you should not
1125 * call it directly. It may be removed or modified in future versions of the
1126 * simd module. */
1127static SIMD_CFUNC double _simd_sinc(double x) {
1128 if (x == 0) return 1;
1129 return sin(x)/x;
1130}
1131
1132/*! @abstract Spherical lerp between q0 and q1.
1133 *
1134 * @discussion This function may interpolate along either the longer or
1135 * shorter path between q0 and q1; it is used as an implementation detail
1136 * in `simd_slerp` and `simd_slerp_longest`; you should use those functions
1137 * instead of calling this directly. */
1138static SIMD_NOINLINE simd_quatd _simd_slerp_internal(simd_quatd q0, simd_quatd q1, double t) {
1139 double s = 1 - t;
1140 double a = _simd_angle(q0, q1);
1141 double r = simd_recip(_simd_sinc(a));
1142 return simd_normalize(simd_quaternion(_simd_sinc(s*a)*r*s*q0.vector + _simd_sinc(t*a)*r*t*q1.vector));
1143}
1144
1145static SIMD_NOINLINE simd_quatd simd_slerp(simd_quatd q0, simd_quatd q1, double t) {
1146 if (simd_dot(q0, q1) >= 0)
1147 return _simd_slerp_internal(q0, q1, t);
1148 return _simd_slerp_internal(q0, simd_negate(q1), t);
1149}
1150
1151static SIMD_NOINLINE simd_quatd simd_slerp_longest(simd_quatd q0, simd_quatd q1, double t) {
1152 if (simd_dot(q0, q1) >= 0)
1153 return _simd_slerp_internal(q0, simd_negate(q1), t);
1154 return _simd_slerp_internal(q0, q1, t);
1155}
1156
1157/*! @discussion This function is an implementation detail and you should not
1158 * call it directly. It may be removed or modified in future versions of the
1159 * simd module. */
1160static SIMD_NOINLINE simd_quatd _simd_intermediate(simd_quatd q0, simd_quatd q1, simd_quatd q2) {
1161 simd_quatd p0 = __tg_log(simd_mul(q0, simd_inverse(q1)));
1162 simd_quatd p2 = __tg_log(simd_mul(q2, simd_inverse(q1)));
1163 return simd_normalize(simd_mul(q1, __tg_exp(simd_mul(-0.25, simd_add(p0,p2)))));
1164}
1165
1166/*! @discussion This function is an implementation detail and you should not
1167 * call it directly. It may be removed or modified in future versions of the
1168 * simd module. */
1169static SIMD_NOINLINE simd_quatd _simd_squad(simd_quatd q0, simd_quatd qa, simd_quatd qb, simd_quatd q1, double t) {
1170 simd_quatd r0 = _simd_slerp_internal(q0, q1, t);
1171 simd_quatd r1 = _simd_slerp_internal(qa, qb, t);
1172 return _simd_slerp_internal(r0, r1, 2*t*(1 - t));
1173}
1174
1175static SIMD_NOINLINE simd_quatd simd_spline(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t) {
1176 simd_quatd qa = _simd_intermediate(q0, q1, q2);
1177 simd_quatd qb = _simd_intermediate(q1, q2, q3);
1178 return _simd_squad(q1, qa, qb, q2, t);
1179}
1180
1181static SIMD_NOINLINE simd_quatd simd_bezier(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t) {
1182 simd_quatd q01 = _simd_slerp_internal(q0, q1, t);
1183 simd_quatd q12 = _simd_slerp_internal(q1, q2, t);
1184 simd_quatd q23 = _simd_slerp_internal(q2, q3, t);
1185 simd_quatd q012 = _simd_slerp_internal(q01, q12, t);
1186 simd_quatd q123 = _simd_slerp_internal(q12, q23, t);
1187 return _simd_slerp_internal(q012, q123, t);
1188}
1189
1190#ifdef __cplusplus
1191} /* extern "C" */
1192#endif /* __cplusplus */
1193#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
1194#endif /* SIMD_QUATERNIONS */
lib/libc/include/x86_64-macos-gnu/simd/simd.h created+21
......@@ -0,0 +1,21 @@
1/* Copyright (c) 2014 Apple, Inc. All rights reserved.
2 *
3 * This header provides small vector (simd) and matrix types, and basic
4 * arithmetic and mathematical functions for them. The vast majority of these
5 * operations are implemented as header inlines, as they can be performed
6 * using just a few instructions on most processors.
7 *
8 * These functions are broken into two groups; vector and matrix. This header
9 * includes all of them, but these may also be included separately. Consult
10 * these two headers for detailed documentation of what types and operations
11 * are available.
12 */
13
14#ifndef __SIMD_HEADER__
15#define __SIMD_HEADER__
16
17#include <simd/vector.h>
18#include <simd/matrix.h>
19#include <simd/quaternion.h>
20
21#endif
lib/libc/include/x86_64-macos-gnu/simd/types.h created+128
......@@ -0,0 +1,128 @@
1/*! @header
2 * @copyright 2015-2016 Apple, Inc. All rights reserved.
3 * @unsorted */
4
5#ifndef SIMD_TYPES
6#define SIMD_TYPES
7
8#include <simd/vector_types.h>
9#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
10
11/*! @group Matrices
12 * @discussion
13 * This header defines nine matrix types for each of float and double, which
14 * are intended for use together with the vector types defined in
15 * <simd/vector_types.h>.
16 *
17 * For compatibility with common graphics libraries, these matrices are stored
18 * in column-major order, and implemented as arrays of column vectors.
19 * Column-major storage order may seem a little strange if you aren't used to
20 * it, but for most usage the memory layout of the matrices shouldn't matter
21 * at all; instead you should think of matrices as abstract mathematical
22 * objects that you use to perform arithmetic without worrying about the
23 * details of the underlying representation.
24 *
25 * WARNING: vectors of length three are internally represented as length four
26 * vectors with one element of padding (for alignment purposes). This means
27 * that when a floatNx3 or doubleNx3 is viewed as a vector, it appears to
28 * have 4*N elements instead of the expected 3*N (with one padding element
29 * at the end of each column). The matrix elements are laid out in memory
30 * as follows:
31 *
32 * { 0, 1, 2, x, 3, 4, 5, x, ... }
33 *
34 * (where the scalar indices used above indicate the conceptual column-
35 * major storage order). If you aren't monkeying around with the internal
36 * storage details of matrices, you don't need to worry about this at all.
37 * Consider this yet another good reason to avoid doing so. */
38
39/*! @abstract A matrix with 2 rows and 2 columns. */
40typedef struct { simd_float2 columns[2]; } simd_float2x2;
41
42/*! @abstract A matrix with 2 rows and 3 columns. */
43typedef struct { simd_float2 columns[3]; } simd_float3x2;
44
45/*! @abstract A matrix with 2 rows and 4 columns. */
46typedef struct { simd_float2 columns[4]; } simd_float4x2;
47
48/*! @abstract A matrix with 3 rows and 2 columns. */
49typedef struct { simd_float3 columns[2]; } simd_float2x3;
50
51/*! @abstract A matrix with 3 rows and 3 columns. */
52typedef struct { simd_float3 columns[3]; } simd_float3x3;
53
54/*! @abstract A matrix with 3 rows and 4 columns. */
55typedef struct { simd_float3 columns[4]; } simd_float4x3;
56
57/*! @abstract A matrix with 4 rows and 2 columns. */
58typedef struct { simd_float4 columns[2]; } simd_float2x4;
59
60/*! @abstract A matrix with 4 rows and 3 columns. */
61typedef struct { simd_float4 columns[3]; } simd_float3x4;
62
63/*! @abstract A matrix with 4 rows and 4 columns. */
64typedef struct { simd_float4 columns[4]; } simd_float4x4;
65
66/*! @abstract A matrix with 2 rows and 2 columns. */
67typedef struct { simd_double2 columns[2]; } simd_double2x2;
68
69/*! @abstract A matrix with 2 rows and 3 columns. */
70typedef struct { simd_double2 columns[3]; } simd_double3x2;
71
72/*! @abstract A matrix with 2 rows and 4 columns. */
73typedef struct { simd_double2 columns[4]; } simd_double4x2;
74
75/*! @abstract A matrix with 3 rows and 2 columns. */
76typedef struct { simd_double3 columns[2]; } simd_double2x3;
77
78/*! @abstract A matrix with 3 rows and 3 columns. */
79typedef struct { simd_double3 columns[3]; } simd_double3x3;
80
81/*! @abstract A matrix with 3 rows and 4 columns. */
82typedef struct { simd_double3 columns[4]; } simd_double4x3;
83
84/*! @abstract A matrix with 4 rows and 2 columns. */
85typedef struct { simd_double4 columns[2]; } simd_double2x4;
86
87/*! @abstract A matrix with 4 rows and 3 columns. */
88typedef struct { simd_double4 columns[3]; } simd_double3x4;
89
90/*! @abstract A matrix with 4 rows and 4 columns. */
91typedef struct { simd_double4 columns[4]; } simd_double4x4;
92
93
94/*! @group Quaternions
95 * @discussion Unlike vectors, quaternions are not raw clang extended-vector
96 * types, because if they were you'd be able to intermix them with vectors
97 * in arithmetic operations freely, but the arithmetic would not do what you
98 * want it to do (it would simply perform the arithmetic operation
99 * componentwise on the quaternion and vector).
100 *
101 * Quaternions aren't unions in C/Obj-C, because then the C++ types couldn't
102 * inherit from the C types, which would make intermixing rather painful (you
103 * can't inherit from a union). This means that we can't provide nice member
104 * access like .real and .imag; you need to use functions to access the pieces
105 * of a quaternion instead.
106 *
107 * This also means that you need to use functions instead of operators to do
108 * arithmetic with quaternions in C and Obj-C. In C++, we are able to provide
109 * operator overloads for arithmetic.
110 *
111 * Internally, a quaternion is represented as a vector of four elements. The
112 * first three elements are the "imaginary" (or "vector") part of the
113 * quaternion, and the last element is the "real" (or "scalar") part. As with
114 * everything simd, you will generally get better performance if you avoid
115 * using the internal storage details of the type, and instead treat these
116 * quaternions as abstract mathematical objects once they are created.
117 *
118 * While the C types are defined here, the operations on quaternions and the
119 * C++ quaternion types are defined in <simd/quaternion.h> */
120
121/*! @abstract A single-precision quaternion. */
122typedef struct { simd_float4 vector; } simd_quatf;
123
124/*! @abstract A double-precision quaternion. */
125typedef struct { simd_double4 vector; } simd_quatd;
126
127#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
128#endif /* SIMD_TYPES */
lib/libc/include/x86_64-macos-gnu/simd/vector.h created+52
......@@ -0,0 +1,52 @@
1/* Copyright (c) 2014 Apple, Inc. All rights reserved.
2 *
3 * This header provides small vector (simd) types and basic arithmetic and
4 * math functions that operate on them.
5 *
6 * A wide assortment of vector types are provided in <simd/vector_types.h>,
7 * which is included by this header. The most important (as far as the rest
8 * of this library is concerned) are vector_floatN (where N is 2, 3, 4, 8, or
9 * 16), and vector_doubleN (where N is 2, 3, 4, or 8).
10 *
11 * All of the vector types are based on what clang call "OpenCL vectors",
12 * defined with the __ext_vector_type__ attribute. Many C operators "just
13 * work" with these types, so it is not necessary to make function calls
14 * to do basic arithmetic:
15 *
16 * simd_float4 x, y;
17 * x = x + y; // vector sum of x and y.
18 *
19 * scalar values are implicitly promoted to vectors (with a "splat"), so it
20 * is possible to easily write expressions involving scalars as well:
21 *
22 * simd_float4 x;
23 * x = 2*x; // scale x by 2.
24 *
25 * Besides the basic operations provided by the compiler, this header provides
26 * a set of mathematical and geometric primitives for use with these types.
27 * In C and Objective-C, these functions are prefixed with vector_; in C++,
28 * unprefixed names are available within the simd:: namespace.
29 *
30 * simd_float3 x, y;
31 * vector_max(x,y) // elementwise maximum of x and y
32 * fabs(x) // same as vector_abs(x)
33 * vector_clamp(x,0,1) // x clamped to the range [0,1]. This has no
34 * // standard-library analogue, so there is no
35 * // alternate name.
36 *
37 * Matrix and matrix-vector operations are also available in <simd/matrix.h>.
38 */
39
40#ifndef __SIMD_VECTOR_HEADER__
41#define __SIMD_VECTOR_HEADER__
42
43#include <simd/vector_types.h>
44#include <simd/packed.h>
45#include <simd/vector_make.h>
46#include <simd/logic.h>
47#include <simd/math.h>
48#include <simd/common.h>
49#include <simd/geometry.h>
50#include <simd/conversion.h>
51
52#endif
lib/libc/include/x86_64-macos-gnu/simd/vector_make.h created+6768
......@@ -0,0 +1,6768 @@
1/*! @header
2 * This header defines functions for constructing, extending, and truncating
3 * simd vector types.
4 *
5 * For each vector type `simd_typeN` supported by <simd/simd.h>, the following
6 * constructors are provided:
7 *
8 * ~~~
9 * simd_typeN simd_make_typeN(type other);
10 * simd_typeN simd_make_typeN(simd_typeM other);
11 * ~~~
12 * For the scalar-input version, or if M < N, these functions zero-extend
13 * `other` to produce a wider vector. If M == N, `other` is passed through
14 * unmodified. If `M > N`, `other` is truncated to form the result.
15 *
16 * ~~~
17 * simd_typeN simd_make_typeN_undef(type other);
18 * simd_typeN simd_make_typeN_undef(simd_typeM other);
19 * ~~~
20 * These functions are only available for M < N and for scalar inputs. They
21 * extend `other` to produce a wider vector where the contents of the newly-
22 * formed lanes are undefined.
23 *
24 * In addition, if N is 2, 3, or 4, the following constructors are available:
25 * ~~~
26 * simd_make_typeN(parts ...)
27 * ~~~
28 * where parts is a list of scalars and smaller vectors such that the sum of
29 * the number of lanes in the arguments is equal to N. For example, a
30 * `simd_float3` can be constructed from three `floats`, or a `float` and a
31 * `simd_float2` in any order:
32 * ~~~
33 * simd_float2 ab = { 1, 2 };
34 * simd_float3 vector = simd_make_float3(ab, 3);
35 * ~~~
36 *
37 * @copyright 2014-2016 Apple, Inc. All rights reserved.
38 * @unsorted */
39
40#ifndef SIMD_VECTOR_CONSTRUCTORS
41#define SIMD_VECTOR_CONSTRUCTORS
42
43#include <simd/vector_types.h>
44#if SIMD_COMPILER_HAS_REQUIRED_FEATURES
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/*! @abstract Concatenates `x` and `y` to form a vector of two 8-bit signed
51 * (twos-complement) integers. */
52static inline SIMD_CFUNC simd_char2 simd_make_char2(char x, char y) {
53 simd_char2 result;
54 result.x = x;
55 result.y = y;
56 return result;
57}
58
59/*! @abstract Zero-extends `other` to form a vector of two 8-bit signed
60 * (twos-complement) integers. */
61static inline SIMD_CFUNC simd_char2 simd_make_char2(char other) {
62 simd_char2 result = 0;
63 result.x = other;
64 return result;
65}
66
67/*! @abstract Extends `other` to form a vector of two 8-bit signed (twos-
68 * complement) integers. The contents of the newly-created vector lanes are
69 * unspecified. */
70static inline SIMD_CFUNC simd_char2 simd_make_char2_undef(char other) {
71 simd_char2 result;
72 result.x = other;
73 return result;
74}
75
76/*! @abstract Returns `other` unmodified. This function is a convenience for
77 * templated and autogenerated code. */
78static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char2 other) {
79 return other;
80}
81
82/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos-
83 * complement) integers. */
84static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char3 other) {
85 return other.xy;
86}
87
88/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos-
89 * complement) integers. */
90static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char4 other) {
91 return other.xy;
92}
93
94/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos-
95 * complement) integers. */
96static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char8 other) {
97 return other.xy;
98}
99
100/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos-
101 * complement) integers. */
102static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char16 other) {
103 return other.xy;
104}
105
106/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos-
107 * complement) integers. */
108static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char32 other) {
109 return other.xy;
110}
111
112/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos-
113 * complement) integers. */
114static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char64 other) {
115 return other.xy;
116}
117
118/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 8-bit
119 * signed (twos-complement) integers. */
120static inline SIMD_CFUNC simd_char3 simd_make_char3(char x, char y, char z) {
121 simd_char3 result;
122 result.x = x;
123 result.y = y;
124 result.z = z;
125 return result;
126}
127
128/*! @abstract Concatenates `x` and `yz` to form a vector of three 8-bit
129 * signed (twos-complement) integers. */
130static inline SIMD_CFUNC simd_char3 simd_make_char3(char x, simd_char2 yz) {
131 simd_char3 result;
132 result.x = x;
133 result.yz = yz;
134 return result;
135}
136
137/*! @abstract Concatenates `xy` and `z` to form a vector of three 8-bit
138 * signed (twos-complement) integers. */
139static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char2 xy, char z) {
140 simd_char3 result;
141 result.xy = xy;
142 result.z = z;
143 return result;
144}
145
146/*! @abstract Zero-extends `other` to form a vector of three 8-bit signed
147 * (twos-complement) integers. */
148static inline SIMD_CFUNC simd_char3 simd_make_char3(char other) {
149 simd_char3 result = 0;
150 result.x = other;
151 return result;
152}
153
154/*! @abstract Extends `other` to form a vector of three 8-bit signed (twos-
155 * complement) integers. The contents of the newly-created vector lanes are
156 * unspecified. */
157static inline SIMD_CFUNC simd_char3 simd_make_char3_undef(char other) {
158 simd_char3 result;
159 result.x = other;
160 return result;
161}
162
163/*! @abstract Zero-extends `other` to form a vector of three 8-bit signed
164 * (twos-complement) integers. */
165static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char2 other) {
166 simd_char3 result = 0;
167 result.xy = other;
168 return result;
169}
170
171/*! @abstract Extends `other` to form a vector of three 8-bit signed (twos-
172 * complement) integers. The contents of the newly-created vector lanes are
173 * unspecified. */
174static inline SIMD_CFUNC simd_char3 simd_make_char3_undef(simd_char2 other) {
175 simd_char3 result;
176 result.xy = other;
177 return result;
178}
179
180/*! @abstract Returns `other` unmodified. This function is a convenience for
181 * templated and autogenerated code. */
182static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char3 other) {
183 return other;
184}
185
186/*! @abstract Truncates `other` to form a vector of three 8-bit signed
187 * (twos-complement) integers. */
188static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char4 other) {
189 return other.xyz;
190}
191
192/*! @abstract Truncates `other` to form a vector of three 8-bit signed
193 * (twos-complement) integers. */
194static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char8 other) {
195 return other.xyz;
196}
197
198/*! @abstract Truncates `other` to form a vector of three 8-bit signed
199 * (twos-complement) integers. */
200static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char16 other) {
201 return other.xyz;
202}
203
204/*! @abstract Truncates `other` to form a vector of three 8-bit signed
205 * (twos-complement) integers. */
206static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char32 other) {
207 return other.xyz;
208}
209
210/*! @abstract Truncates `other` to form a vector of three 8-bit signed
211 * (twos-complement) integers. */
212static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char64 other) {
213 return other.xyz;
214}
215
216/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
217 * 8-bit signed (twos-complement) integers. */
218static inline SIMD_CFUNC simd_char4 simd_make_char4(char x, char y, char z, char w) {
219 simd_char4 result;
220 result.x = x;
221 result.y = y;
222 result.z = z;
223 result.w = w;
224 return result;
225}
226
227/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 8-bit
228 * signed (twos-complement) integers. */
229static inline SIMD_CFUNC simd_char4 simd_make_char4(char x, char y, simd_char2 zw) {
230 simd_char4 result;
231 result.x = x;
232 result.y = y;
233 result.zw = zw;
234 return result;
235}
236
237/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 8-bit
238 * signed (twos-complement) integers. */
239static inline SIMD_CFUNC simd_char4 simd_make_char4(char x, simd_char2 yz, char w) {
240 simd_char4 result;
241 result.x = x;
242 result.yz = yz;
243 result.w = w;
244 return result;
245}
246
247/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 8-bit
248 * signed (twos-complement) integers. */
249static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char2 xy, char z, char w) {
250 simd_char4 result;
251 result.xy = xy;
252 result.z = z;
253 result.w = w;
254 return result;
255}
256
257/*! @abstract Concatenates `x` and `yzw` to form a vector of four 8-bit
258 * signed (twos-complement) integers. */
259static inline SIMD_CFUNC simd_char4 simd_make_char4(char x, simd_char3 yzw) {
260 simd_char4 result;
261 result.x = x;
262 result.yzw = yzw;
263 return result;
264}
265
266/*! @abstract Concatenates `xy` and `zw` to form a vector of four 8-bit
267 * signed (twos-complement) integers. */
268static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char2 xy, simd_char2 zw) {
269 simd_char4 result;
270 result.xy = xy;
271 result.zw = zw;
272 return result;
273}
274
275/*! @abstract Concatenates `xyz` and `w` to form a vector of four 8-bit
276 * signed (twos-complement) integers. */
277static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char3 xyz, char w) {
278 simd_char4 result;
279 result.xyz = xyz;
280 result.w = w;
281 return result;
282}
283
284/*! @abstract Zero-extends `other` to form a vector of four 8-bit signed
285 * (twos-complement) integers. */
286static inline SIMD_CFUNC simd_char4 simd_make_char4(char other) {
287 simd_char4 result = 0;
288 result.x = other;
289 return result;
290}
291
292/*! @abstract Extends `other` to form a vector of four 8-bit signed (twos-
293 * complement) integers. The contents of the newly-created vector lanes are
294 * unspecified. */
295static inline SIMD_CFUNC simd_char4 simd_make_char4_undef(char other) {
296 simd_char4 result;
297 result.x = other;
298 return result;
299}
300
301/*! @abstract Zero-extends `other` to form a vector of four 8-bit signed
302 * (twos-complement) integers. */
303static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char2 other) {
304 simd_char4 result = 0;
305 result.xy = other;
306 return result;
307}
308
309/*! @abstract Extends `other` to form a vector of four 8-bit signed (twos-
310 * complement) integers. The contents of the newly-created vector lanes are
311 * unspecified. */
312static inline SIMD_CFUNC simd_char4 simd_make_char4_undef(simd_char2 other) {
313 simd_char4 result;
314 result.xy = other;
315 return result;
316}
317
318/*! @abstract Zero-extends `other` to form a vector of four 8-bit signed
319 * (twos-complement) integers. */
320static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char3 other) {
321 simd_char4 result = 0;
322 result.xyz = other;
323 return result;
324}
325
326/*! @abstract Extends `other` to form a vector of four 8-bit signed (twos-
327 * complement) integers. The contents of the newly-created vector lanes are
328 * unspecified. */
329static inline SIMD_CFUNC simd_char4 simd_make_char4_undef(simd_char3 other) {
330 simd_char4 result;
331 result.xyz = other;
332 return result;
333}
334
335/*! @abstract Returns `other` unmodified. This function is a convenience for
336 * templated and autogenerated code. */
337static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char4 other) {
338 return other;
339}
340
341/*! @abstract Truncates `other` to form a vector of four 8-bit signed (twos-
342 * complement) integers. */
343static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char8 other) {
344 return other.xyzw;
345}
346
347/*! @abstract Truncates `other` to form a vector of four 8-bit signed (twos-
348 * complement) integers. */
349static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char16 other) {
350 return other.xyzw;
351}
352
353/*! @abstract Truncates `other` to form a vector of four 8-bit signed (twos-
354 * complement) integers. */
355static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char32 other) {
356 return other.xyzw;
357}
358
359/*! @abstract Truncates `other` to form a vector of four 8-bit signed (twos-
360 * complement) integers. */
361static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char64 other) {
362 return other.xyzw;
363}
364
365/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 8-bit
366 * signed (twos-complement) integers. */
367static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char4 lo, simd_char4 hi) {
368 simd_char8 result;
369 result.lo = lo;
370 result.hi = hi;
371 return result;
372}
373
374/*! @abstract Zero-extends `other` to form a vector of eight 8-bit signed
375 * (twos-complement) integers. */
376static inline SIMD_CFUNC simd_char8 simd_make_char8(char other) {
377 simd_char8 result = 0;
378 result.x = other;
379 return result;
380}
381
382/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos-
383 * complement) integers. The contents of the newly-created vector lanes are
384 * unspecified. */
385static inline SIMD_CFUNC simd_char8 simd_make_char8_undef(char other) {
386 simd_char8 result;
387 result.x = other;
388 return result;
389}
390
391/*! @abstract Zero-extends `other` to form a vector of eight 8-bit signed
392 * (twos-complement) integers. */
393static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char2 other) {
394 simd_char8 result = 0;
395 result.xy = other;
396 return result;
397}
398
399/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos-
400 * complement) integers. The contents of the newly-created vector lanes are
401 * unspecified. */
402static inline SIMD_CFUNC simd_char8 simd_make_char8_undef(simd_char2 other) {
403 simd_char8 result;
404 result.xy = other;
405 return result;
406}
407
408/*! @abstract Zero-extends `other` to form a vector of eight 8-bit signed
409 * (twos-complement) integers. */
410static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char3 other) {
411 simd_char8 result = 0;
412 result.xyz = other;
413 return result;
414}
415
416/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos-
417 * complement) integers. The contents of the newly-created vector lanes are
418 * unspecified. */
419static inline SIMD_CFUNC simd_char8 simd_make_char8_undef(simd_char3 other) {
420 simd_char8 result;
421 result.xyz = other;
422 return result;
423}
424
425/*! @abstract Zero-extends `other` to form a vector of eight 8-bit signed
426 * (twos-complement) integers. */
427static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char4 other) {
428 simd_char8 result = 0;
429 result.xyzw = other;
430 return result;
431}
432
433/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos-
434 * complement) integers. The contents of the newly-created vector lanes are
435 * unspecified. */
436static inline SIMD_CFUNC simd_char8 simd_make_char8_undef(simd_char4 other) {
437 simd_char8 result;
438 result.xyzw = other;
439 return result;
440}
441
442/*! @abstract Returns `other` unmodified. This function is a convenience for
443 * templated and autogenerated code. */
444static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char8 other) {
445 return other;
446}
447
448/*! @abstract Truncates `other` to form a vector of eight 8-bit signed
449 * (twos-complement) integers. */
450static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char16 other) {
451 return simd_make_char8(other.lo);
452}
453
454/*! @abstract Truncates `other` to form a vector of eight 8-bit signed
455 * (twos-complement) integers. */
456static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char32 other) {
457 return simd_make_char8(other.lo);
458}
459
460/*! @abstract Truncates `other` to form a vector of eight 8-bit signed
461 * (twos-complement) integers. */
462static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char64 other) {
463 return simd_make_char8(other.lo);
464}
465
466/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 8-bit
467 * signed (twos-complement) integers. */
468static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char8 lo, simd_char8 hi) {
469 simd_char16 result;
470 result.lo = lo;
471 result.hi = hi;
472 return result;
473}
474
475/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed
476 * (twos-complement) integers. */
477static inline SIMD_CFUNC simd_char16 simd_make_char16(char other) {
478 simd_char16 result = 0;
479 result.x = other;
480 return result;
481}
482
483/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed
484 * (twos-complement) integers. The contents of the newly-created vector
485 * lanes are unspecified. */
486static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(char other) {
487 simd_char16 result;
488 result.x = other;
489 return result;
490}
491
492/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed
493 * (twos-complement) integers. */
494static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char2 other) {
495 simd_char16 result = 0;
496 result.xy = other;
497 return result;
498}
499
500/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed
501 * (twos-complement) integers. The contents of the newly-created vector
502 * lanes are unspecified. */
503static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(simd_char2 other) {
504 simd_char16 result;
505 result.xy = other;
506 return result;
507}
508
509/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed
510 * (twos-complement) integers. */
511static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char3 other) {
512 simd_char16 result = 0;
513 result.xyz = other;
514 return result;
515}
516
517/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed
518 * (twos-complement) integers. The contents of the newly-created vector
519 * lanes are unspecified. */
520static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(simd_char3 other) {
521 simd_char16 result;
522 result.xyz = other;
523 return result;
524}
525
526/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed
527 * (twos-complement) integers. */
528static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char4 other) {
529 simd_char16 result = 0;
530 result.xyzw = other;
531 return result;
532}
533
534/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed
535 * (twos-complement) integers. The contents of the newly-created vector
536 * lanes are unspecified. */
537static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(simd_char4 other) {
538 simd_char16 result;
539 result.xyzw = other;
540 return result;
541}
542
543/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed
544 * (twos-complement) integers. */
545static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char8 other) {
546 simd_char16 result = 0;
547 result.lo = simd_make_char8(other);
548 return result;
549}
550
551/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed
552 * (twos-complement) integers. The contents of the newly-created vector
553 * lanes are unspecified. */
554static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(simd_char8 other) {
555 simd_char16 result;
556 result.lo = simd_make_char8(other);
557 return result;
558}
559
560/*! @abstract Returns `other` unmodified. This function is a convenience for
561 * templated and autogenerated code. */
562static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char16 other) {
563 return other;
564}
565
566/*! @abstract Truncates `other` to form a vector of sixteen 8-bit signed
567 * (twos-complement) integers. */
568static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char32 other) {
569 return simd_make_char16(other.lo);
570}
571
572/*! @abstract Truncates `other` to form a vector of sixteen 8-bit signed
573 * (twos-complement) integers. */
574static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char64 other) {
575 return simd_make_char16(other.lo);
576}
577
578/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two
579 * 8-bit signed (twos-complement) integers. */
580static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char16 lo, simd_char16 hi) {
581 simd_char32 result;
582 result.lo = lo;
583 result.hi = hi;
584 return result;
585}
586
587/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
588 * signed (twos-complement) integers. */
589static inline SIMD_CFUNC simd_char32 simd_make_char32(char other) {
590 simd_char32 result = 0;
591 result.x = other;
592 return result;
593}
594
595/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed
596 * (twos-complement) integers. The contents of the newly-created vector
597 * lanes are unspecified. */
598static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(char other) {
599 simd_char32 result;
600 result.x = other;
601 return result;
602}
603
604/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
605 * signed (twos-complement) integers. */
606static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char2 other) {
607 simd_char32 result = 0;
608 result.xy = other;
609 return result;
610}
611
612/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed
613 * (twos-complement) integers. The contents of the newly-created vector
614 * lanes are unspecified. */
615static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char2 other) {
616 simd_char32 result;
617 result.xy = other;
618 return result;
619}
620
621/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
622 * signed (twos-complement) integers. */
623static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char3 other) {
624 simd_char32 result = 0;
625 result.xyz = other;
626 return result;
627}
628
629/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed
630 * (twos-complement) integers. The contents of the newly-created vector
631 * lanes are unspecified. */
632static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char3 other) {
633 simd_char32 result;
634 result.xyz = other;
635 return result;
636}
637
638/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
639 * signed (twos-complement) integers. */
640static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char4 other) {
641 simd_char32 result = 0;
642 result.xyzw = other;
643 return result;
644}
645
646/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed
647 * (twos-complement) integers. The contents of the newly-created vector
648 * lanes are unspecified. */
649static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char4 other) {
650 simd_char32 result;
651 result.xyzw = other;
652 return result;
653}
654
655/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
656 * signed (twos-complement) integers. */
657static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char8 other) {
658 simd_char32 result = 0;
659 result.lo = simd_make_char16(other);
660 return result;
661}
662
663/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed
664 * (twos-complement) integers. The contents of the newly-created vector
665 * lanes are unspecified. */
666static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char8 other) {
667 simd_char32 result;
668 result.lo = simd_make_char16(other);
669 return result;
670}
671
672/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
673 * signed (twos-complement) integers. */
674static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char16 other) {
675 simd_char32 result = 0;
676 result.lo = simd_make_char16(other);
677 return result;
678}
679
680/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed
681 * (twos-complement) integers. The contents of the newly-created vector
682 * lanes are unspecified. */
683static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char16 other) {
684 simd_char32 result;
685 result.lo = simd_make_char16(other);
686 return result;
687}
688
689/*! @abstract Returns `other` unmodified. This function is a convenience for
690 * templated and autogenerated code. */
691static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char32 other) {
692 return other;
693}
694
695/*! @abstract Truncates `other` to form a vector of thirty-two 8-bit signed
696 * (twos-complement) integers. */
697static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char64 other) {
698 return simd_make_char32(other.lo);
699}
700
701/*! @abstract Concatenates `lo` and `hi` to form a vector of sixty-four
702 * 8-bit signed (twos-complement) integers. */
703static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char32 lo, simd_char32 hi) {
704 simd_char64 result;
705 result.lo = lo;
706 result.hi = hi;
707 return result;
708}
709
710/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
711 * signed (twos-complement) integers. */
712static inline SIMD_CFUNC simd_char64 simd_make_char64(char other) {
713 simd_char64 result = 0;
714 result.x = other;
715 return result;
716}
717
718/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed
719 * (twos-complement) integers. The contents of the newly-created vector
720 * lanes are unspecified. */
721static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(char other) {
722 simd_char64 result;
723 result.x = other;
724 return result;
725}
726
727/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
728 * signed (twos-complement) integers. */
729static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char2 other) {
730 simd_char64 result = 0;
731 result.xy = other;
732 return result;
733}
734
735/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed
736 * (twos-complement) integers. The contents of the newly-created vector
737 * lanes are unspecified. */
738static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char2 other) {
739 simd_char64 result;
740 result.xy = other;
741 return result;
742}
743
744/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
745 * signed (twos-complement) integers. */
746static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char3 other) {
747 simd_char64 result = 0;
748 result.xyz = other;
749 return result;
750}
751
752/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed
753 * (twos-complement) integers. The contents of the newly-created vector
754 * lanes are unspecified. */
755static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char3 other) {
756 simd_char64 result;
757 result.xyz = other;
758 return result;
759}
760
761/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
762 * signed (twos-complement) integers. */
763static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char4 other) {
764 simd_char64 result = 0;
765 result.xyzw = other;
766 return result;
767}
768
769/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed
770 * (twos-complement) integers. The contents of the newly-created vector
771 * lanes are unspecified. */
772static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char4 other) {
773 simd_char64 result;
774 result.xyzw = other;
775 return result;
776}
777
778/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
779 * signed (twos-complement) integers. */
780static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char8 other) {
781 simd_char64 result = 0;
782 result.lo = simd_make_char32(other);
783 return result;
784}
785
786/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed
787 * (twos-complement) integers. The contents of the newly-created vector
788 * lanes are unspecified. */
789static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char8 other) {
790 simd_char64 result;
791 result.lo = simd_make_char32(other);
792 return result;
793}
794
795/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
796 * signed (twos-complement) integers. */
797static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char16 other) {
798 simd_char64 result = 0;
799 result.lo = simd_make_char32(other);
800 return result;
801}
802
803/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed
804 * (twos-complement) integers. The contents of the newly-created vector
805 * lanes are unspecified. */
806static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char16 other) {
807 simd_char64 result;
808 result.lo = simd_make_char32(other);
809 return result;
810}
811
812/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
813 * signed (twos-complement) integers. */
814static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char32 other) {
815 simd_char64 result = 0;
816 result.lo = simd_make_char32(other);
817 return result;
818}
819
820/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed
821 * (twos-complement) integers. The contents of the newly-created vector
822 * lanes are unspecified. */
823static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char32 other) {
824 simd_char64 result;
825 result.lo = simd_make_char32(other);
826 return result;
827}
828
829/*! @abstract Returns `other` unmodified. This function is a convenience for
830 * templated and autogenerated code. */
831static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char64 other) {
832 return other;
833}
834
835/*! @abstract Concatenates `x` and `y` to form a vector of two 8-bit
836 * unsigned integers. */
837static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(unsigned char x, unsigned char y) {
838 simd_uchar2 result;
839 result.x = x;
840 result.y = y;
841 return result;
842}
843
844/*! @abstract Zero-extends `other` to form a vector of two 8-bit unsigned
845 * integers. */
846static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(unsigned char other) {
847 simd_uchar2 result = 0;
848 result.x = other;
849 return result;
850}
851
852/*! @abstract Extends `other` to form a vector of two 8-bit unsigned
853 * integers. The contents of the newly-created vector lanes are
854 * unspecified. */
855static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2_undef(unsigned char other) {
856 simd_uchar2 result;
857 result.x = other;
858 return result;
859}
860
861/*! @abstract Returns `other` unmodified. This function is a convenience for
862 * templated and autogenerated code. */
863static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar2 other) {
864 return other;
865}
866
867/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned
868 * integers. */
869static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar3 other) {
870 return other.xy;
871}
872
873/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned
874 * integers. */
875static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar4 other) {
876 return other.xy;
877}
878
879/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned
880 * integers. */
881static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar8 other) {
882 return other.xy;
883}
884
885/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned
886 * integers. */
887static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar16 other) {
888 return other.xy;
889}
890
891/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned
892 * integers. */
893static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar32 other) {
894 return other.xy;
895}
896
897/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned
898 * integers. */
899static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar64 other) {
900 return other.xy;
901}
902
903/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 8-bit
904 * unsigned integers. */
905static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(unsigned char x, unsigned char y, unsigned char z) {
906 simd_uchar3 result;
907 result.x = x;
908 result.y = y;
909 result.z = z;
910 return result;
911}
912
913/*! @abstract Concatenates `x` and `yz` to form a vector of three 8-bit
914 * unsigned integers. */
915static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(unsigned char x, simd_uchar2 yz) {
916 simd_uchar3 result;
917 result.x = x;
918 result.yz = yz;
919 return result;
920}
921
922/*! @abstract Concatenates `xy` and `z` to form a vector of three 8-bit
923 * unsigned integers. */
924static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar2 xy, unsigned char z) {
925 simd_uchar3 result;
926 result.xy = xy;
927 result.z = z;
928 return result;
929}
930
931/*! @abstract Zero-extends `other` to form a vector of three 8-bit unsigned
932 * integers. */
933static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(unsigned char other) {
934 simd_uchar3 result = 0;
935 result.x = other;
936 return result;
937}
938
939/*! @abstract Extends `other` to form a vector of three 8-bit unsigned
940 * integers. The contents of the newly-created vector lanes are
941 * unspecified. */
942static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3_undef(unsigned char other) {
943 simd_uchar3 result;
944 result.x = other;
945 return result;
946}
947
948/*! @abstract Zero-extends `other` to form a vector of three 8-bit unsigned
949 * integers. */
950static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar2 other) {
951 simd_uchar3 result = 0;
952 result.xy = other;
953 return result;
954}
955
956/*! @abstract Extends `other` to form a vector of three 8-bit unsigned
957 * integers. The contents of the newly-created vector lanes are
958 * unspecified. */
959static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3_undef(simd_uchar2 other) {
960 simd_uchar3 result;
961 result.xy = other;
962 return result;
963}
964
965/*! @abstract Returns `other` unmodified. This function is a convenience for
966 * templated and autogenerated code. */
967static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar3 other) {
968 return other;
969}
970
971/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned
972 * integers. */
973static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar4 other) {
974 return other.xyz;
975}
976
977/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned
978 * integers. */
979static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar8 other) {
980 return other.xyz;
981}
982
983/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned
984 * integers. */
985static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar16 other) {
986 return other.xyz;
987}
988
989/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned
990 * integers. */
991static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar32 other) {
992 return other.xyz;
993}
994
995/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned
996 * integers. */
997static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar64 other) {
998 return other.xyz;
999}
1000
1001/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
1002 * 8-bit unsigned integers. */
1003static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char x, unsigned char y, unsigned char z, unsigned char w) {
1004 simd_uchar4 result;
1005 result.x = x;
1006 result.y = y;
1007 result.z = z;
1008 result.w = w;
1009 return result;
1010}
1011
1012/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 8-bit
1013 * unsigned integers. */
1014static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char x, unsigned char y, simd_uchar2 zw) {
1015 simd_uchar4 result;
1016 result.x = x;
1017 result.y = y;
1018 result.zw = zw;
1019 return result;
1020}
1021
1022/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 8-bit
1023 * unsigned integers. */
1024static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char x, simd_uchar2 yz, unsigned char w) {
1025 simd_uchar4 result;
1026 result.x = x;
1027 result.yz = yz;
1028 result.w = w;
1029 return result;
1030}
1031
1032/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 8-bit
1033 * unsigned integers. */
1034static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar2 xy, unsigned char z, unsigned char w) {
1035 simd_uchar4 result;
1036 result.xy = xy;
1037 result.z = z;
1038 result.w = w;
1039 return result;
1040}
1041
1042/*! @abstract Concatenates `x` and `yzw` to form a vector of four 8-bit
1043 * unsigned integers. */
1044static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char x, simd_uchar3 yzw) {
1045 simd_uchar4 result;
1046 result.x = x;
1047 result.yzw = yzw;
1048 return result;
1049}
1050
1051/*! @abstract Concatenates `xy` and `zw` to form a vector of four 8-bit
1052 * unsigned integers. */
1053static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar2 xy, simd_uchar2 zw) {
1054 simd_uchar4 result;
1055 result.xy = xy;
1056 result.zw = zw;
1057 return result;
1058}
1059
1060/*! @abstract Concatenates `xyz` and `w` to form a vector of four 8-bit
1061 * unsigned integers. */
1062static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar3 xyz, unsigned char w) {
1063 simd_uchar4 result;
1064 result.xyz = xyz;
1065 result.w = w;
1066 return result;
1067}
1068
1069/*! @abstract Zero-extends `other` to form a vector of four 8-bit unsigned
1070 * integers. */
1071static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char other) {
1072 simd_uchar4 result = 0;
1073 result.x = other;
1074 return result;
1075}
1076
1077/*! @abstract Extends `other` to form a vector of four 8-bit unsigned
1078 * integers. The contents of the newly-created vector lanes are
1079 * unspecified. */
1080static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4_undef(unsigned char other) {
1081 simd_uchar4 result;
1082 result.x = other;
1083 return result;
1084}
1085
1086/*! @abstract Zero-extends `other` to form a vector of four 8-bit unsigned
1087 * integers. */
1088static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar2 other) {
1089 simd_uchar4 result = 0;
1090 result.xy = other;
1091 return result;
1092}
1093
1094/*! @abstract Extends `other` to form a vector of four 8-bit unsigned
1095 * integers. The contents of the newly-created vector lanes are
1096 * unspecified. */
1097static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4_undef(simd_uchar2 other) {
1098 simd_uchar4 result;
1099 result.xy = other;
1100 return result;
1101}
1102
1103/*! @abstract Zero-extends `other` to form a vector of four 8-bit unsigned
1104 * integers. */
1105static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar3 other) {
1106 simd_uchar4 result = 0;
1107 result.xyz = other;
1108 return result;
1109}
1110
1111/*! @abstract Extends `other` to form a vector of four 8-bit unsigned
1112 * integers. The contents of the newly-created vector lanes are
1113 * unspecified. */
1114static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4_undef(simd_uchar3 other) {
1115 simd_uchar4 result;
1116 result.xyz = other;
1117 return result;
1118}
1119
1120/*! @abstract Returns `other` unmodified. This function is a convenience for
1121 * templated and autogenerated code. */
1122static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar4 other) {
1123 return other;
1124}
1125
1126/*! @abstract Truncates `other` to form a vector of four 8-bit unsigned
1127 * integers. */
1128static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar8 other) {
1129 return other.xyzw;
1130}
1131
1132/*! @abstract Truncates `other` to form a vector of four 8-bit unsigned
1133 * integers. */
1134static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar16 other) {
1135 return other.xyzw;
1136}
1137
1138/*! @abstract Truncates `other` to form a vector of four 8-bit unsigned
1139 * integers. */
1140static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar32 other) {
1141 return other.xyzw;
1142}
1143
1144/*! @abstract Truncates `other` to form a vector of four 8-bit unsigned
1145 * integers. */
1146static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar64 other) {
1147 return other.xyzw;
1148}
1149
1150/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 8-bit
1151 * unsigned integers. */
1152static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar4 lo, simd_uchar4 hi) {
1153 simd_uchar8 result;
1154 result.lo = lo;
1155 result.hi = hi;
1156 return result;
1157}
1158
1159/*! @abstract Zero-extends `other` to form a vector of eight 8-bit unsigned
1160 * integers. */
1161static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(unsigned char other) {
1162 simd_uchar8 result = 0;
1163 result.x = other;
1164 return result;
1165}
1166
1167/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned
1168 * integers. The contents of the newly-created vector lanes are
1169 * unspecified. */
1170static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8_undef(unsigned char other) {
1171 simd_uchar8 result;
1172 result.x = other;
1173 return result;
1174}
1175
1176/*! @abstract Zero-extends `other` to form a vector of eight 8-bit unsigned
1177 * integers. */
1178static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar2 other) {
1179 simd_uchar8 result = 0;
1180 result.xy = other;
1181 return result;
1182}
1183
1184/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned
1185 * integers. The contents of the newly-created vector lanes are
1186 * unspecified. */
1187static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8_undef(simd_uchar2 other) {
1188 simd_uchar8 result;
1189 result.xy = other;
1190 return result;
1191}
1192
1193/*! @abstract Zero-extends `other` to form a vector of eight 8-bit unsigned
1194 * integers. */
1195static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar3 other) {
1196 simd_uchar8 result = 0;
1197 result.xyz = other;
1198 return result;
1199}
1200
1201/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned
1202 * integers. The contents of the newly-created vector lanes are
1203 * unspecified. */
1204static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8_undef(simd_uchar3 other) {
1205 simd_uchar8 result;
1206 result.xyz = other;
1207 return result;
1208}
1209
1210/*! @abstract Zero-extends `other` to form a vector of eight 8-bit unsigned
1211 * integers. */
1212static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar4 other) {
1213 simd_uchar8 result = 0;
1214 result.xyzw = other;
1215 return result;
1216}
1217
1218/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned
1219 * integers. The contents of the newly-created vector lanes are
1220 * unspecified. */
1221static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8_undef(simd_uchar4 other) {
1222 simd_uchar8 result;
1223 result.xyzw = other;
1224 return result;
1225}
1226
1227/*! @abstract Returns `other` unmodified. This function is a convenience for
1228 * templated and autogenerated code. */
1229static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar8 other) {
1230 return other;
1231}
1232
1233/*! @abstract Truncates `other` to form a vector of eight 8-bit unsigned
1234 * integers. */
1235static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar16 other) {
1236 return simd_make_uchar8(other.lo);
1237}
1238
1239/*! @abstract Truncates `other` to form a vector of eight 8-bit unsigned
1240 * integers. */
1241static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar32 other) {
1242 return simd_make_uchar8(other.lo);
1243}
1244
1245/*! @abstract Truncates `other` to form a vector of eight 8-bit unsigned
1246 * integers. */
1247static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar64 other) {
1248 return simd_make_uchar8(other.lo);
1249}
1250
1251/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 8-bit
1252 * unsigned integers. */
1253static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar8 lo, simd_uchar8 hi) {
1254 simd_uchar16 result;
1255 result.lo = lo;
1256 result.hi = hi;
1257 return result;
1258}
1259
1260/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit
1261 * unsigned integers. */
1262static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(unsigned char other) {
1263 simd_uchar16 result = 0;
1264 result.x = other;
1265 return result;
1266}
1267
1268/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned
1269 * integers. The contents of the newly-created vector lanes are
1270 * unspecified. */
1271static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(unsigned char other) {
1272 simd_uchar16 result;
1273 result.x = other;
1274 return result;
1275}
1276
1277/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit
1278 * unsigned integers. */
1279static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar2 other) {
1280 simd_uchar16 result = 0;
1281 result.xy = other;
1282 return result;
1283}
1284
1285/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned
1286 * integers. The contents of the newly-created vector lanes are
1287 * unspecified. */
1288static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(simd_uchar2 other) {
1289 simd_uchar16 result;
1290 result.xy = other;
1291 return result;
1292}
1293
1294/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit
1295 * unsigned integers. */
1296static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar3 other) {
1297 simd_uchar16 result = 0;
1298 result.xyz = other;
1299 return result;
1300}
1301
1302/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned
1303 * integers. The contents of the newly-created vector lanes are
1304 * unspecified. */
1305static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(simd_uchar3 other) {
1306 simd_uchar16 result;
1307 result.xyz = other;
1308 return result;
1309}
1310
1311/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit
1312 * unsigned integers. */
1313static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar4 other) {
1314 simd_uchar16 result = 0;
1315 result.xyzw = other;
1316 return result;
1317}
1318
1319/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned
1320 * integers. The contents of the newly-created vector lanes are
1321 * unspecified. */
1322static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(simd_uchar4 other) {
1323 simd_uchar16 result;
1324 result.xyzw = other;
1325 return result;
1326}
1327
1328/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit
1329 * unsigned integers. */
1330static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar8 other) {
1331 simd_uchar16 result = 0;
1332 result.lo = simd_make_uchar8(other);
1333 return result;
1334}
1335
1336/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned
1337 * integers. The contents of the newly-created vector lanes are
1338 * unspecified. */
1339static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(simd_uchar8 other) {
1340 simd_uchar16 result;
1341 result.lo = simd_make_uchar8(other);
1342 return result;
1343}
1344
1345/*! @abstract Returns `other` unmodified. This function is a convenience for
1346 * templated and autogenerated code. */
1347static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar16 other) {
1348 return other;
1349}
1350
1351/*! @abstract Truncates `other` to form a vector of sixteen 8-bit unsigned
1352 * integers. */
1353static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar32 other) {
1354 return simd_make_uchar16(other.lo);
1355}
1356
1357/*! @abstract Truncates `other` to form a vector of sixteen 8-bit unsigned
1358 * integers. */
1359static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar64 other) {
1360 return simd_make_uchar16(other.lo);
1361}
1362
1363/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two
1364 * 8-bit unsigned integers. */
1365static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar16 lo, simd_uchar16 hi) {
1366 simd_uchar32 result;
1367 result.lo = lo;
1368 result.hi = hi;
1369 return result;
1370}
1371
1372/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
1373 * unsigned integers. */
1374static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(unsigned char other) {
1375 simd_uchar32 result = 0;
1376 result.x = other;
1377 return result;
1378}
1379
1380/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned
1381 * integers. The contents of the newly-created vector lanes are
1382 * unspecified. */
1383static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(unsigned char other) {
1384 simd_uchar32 result;
1385 result.x = other;
1386 return result;
1387}
1388
1389/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
1390 * unsigned integers. */
1391static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar2 other) {
1392 simd_uchar32 result = 0;
1393 result.xy = other;
1394 return result;
1395}
1396
1397/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned
1398 * integers. The contents of the newly-created vector lanes are
1399 * unspecified. */
1400static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar2 other) {
1401 simd_uchar32 result;
1402 result.xy = other;
1403 return result;
1404}
1405
1406/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
1407 * unsigned integers. */
1408static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar3 other) {
1409 simd_uchar32 result = 0;
1410 result.xyz = other;
1411 return result;
1412}
1413
1414/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned
1415 * integers. The contents of the newly-created vector lanes are
1416 * unspecified. */
1417static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar3 other) {
1418 simd_uchar32 result;
1419 result.xyz = other;
1420 return result;
1421}
1422
1423/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
1424 * unsigned integers. */
1425static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar4 other) {
1426 simd_uchar32 result = 0;
1427 result.xyzw = other;
1428 return result;
1429}
1430
1431/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned
1432 * integers. The contents of the newly-created vector lanes are
1433 * unspecified. */
1434static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar4 other) {
1435 simd_uchar32 result;
1436 result.xyzw = other;
1437 return result;
1438}
1439
1440/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
1441 * unsigned integers. */
1442static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar8 other) {
1443 simd_uchar32 result = 0;
1444 result.lo = simd_make_uchar16(other);
1445 return result;
1446}
1447
1448/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned
1449 * integers. The contents of the newly-created vector lanes are
1450 * unspecified. */
1451static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar8 other) {
1452 simd_uchar32 result;
1453 result.lo = simd_make_uchar16(other);
1454 return result;
1455}
1456
1457/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit
1458 * unsigned integers. */
1459static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar16 other) {
1460 simd_uchar32 result = 0;
1461 result.lo = simd_make_uchar16(other);
1462 return result;
1463}
1464
1465/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned
1466 * integers. The contents of the newly-created vector lanes are
1467 * unspecified. */
1468static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar16 other) {
1469 simd_uchar32 result;
1470 result.lo = simd_make_uchar16(other);
1471 return result;
1472}
1473
1474/*! @abstract Returns `other` unmodified. This function is a convenience for
1475 * templated and autogenerated code. */
1476static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar32 other) {
1477 return other;
1478}
1479
1480/*! @abstract Truncates `other` to form a vector of thirty-two 8-bit
1481 * unsigned integers. */
1482static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar64 other) {
1483 return simd_make_uchar32(other.lo);
1484}
1485
1486/*! @abstract Concatenates `lo` and `hi` to form a vector of sixty-four
1487 * 8-bit unsigned integers. */
1488static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar32 lo, simd_uchar32 hi) {
1489 simd_uchar64 result;
1490 result.lo = lo;
1491 result.hi = hi;
1492 return result;
1493}
1494
1495/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
1496 * unsigned integers. */
1497static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(unsigned char other) {
1498 simd_uchar64 result = 0;
1499 result.x = other;
1500 return result;
1501}
1502
1503/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned
1504 * integers. The contents of the newly-created vector lanes are
1505 * unspecified. */
1506static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(unsigned char other) {
1507 simd_uchar64 result;
1508 result.x = other;
1509 return result;
1510}
1511
1512/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
1513 * unsigned integers. */
1514static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar2 other) {
1515 simd_uchar64 result = 0;
1516 result.xy = other;
1517 return result;
1518}
1519
1520/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned
1521 * integers. The contents of the newly-created vector lanes are
1522 * unspecified. */
1523static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar2 other) {
1524 simd_uchar64 result;
1525 result.xy = other;
1526 return result;
1527}
1528
1529/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
1530 * unsigned integers. */
1531static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar3 other) {
1532 simd_uchar64 result = 0;
1533 result.xyz = other;
1534 return result;
1535}
1536
1537/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned
1538 * integers. The contents of the newly-created vector lanes are
1539 * unspecified. */
1540static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar3 other) {
1541 simd_uchar64 result;
1542 result.xyz = other;
1543 return result;
1544}
1545
1546/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
1547 * unsigned integers. */
1548static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar4 other) {
1549 simd_uchar64 result = 0;
1550 result.xyzw = other;
1551 return result;
1552}
1553
1554/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned
1555 * integers. The contents of the newly-created vector lanes are
1556 * unspecified. */
1557static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar4 other) {
1558 simd_uchar64 result;
1559 result.xyzw = other;
1560 return result;
1561}
1562
1563/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
1564 * unsigned integers. */
1565static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar8 other) {
1566 simd_uchar64 result = 0;
1567 result.lo = simd_make_uchar32(other);
1568 return result;
1569}
1570
1571/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned
1572 * integers. The contents of the newly-created vector lanes are
1573 * unspecified. */
1574static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar8 other) {
1575 simd_uchar64 result;
1576 result.lo = simd_make_uchar32(other);
1577 return result;
1578}
1579
1580/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
1581 * unsigned integers. */
1582static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar16 other) {
1583 simd_uchar64 result = 0;
1584 result.lo = simd_make_uchar32(other);
1585 return result;
1586}
1587
1588/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned
1589 * integers. The contents of the newly-created vector lanes are
1590 * unspecified. */
1591static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar16 other) {
1592 simd_uchar64 result;
1593 result.lo = simd_make_uchar32(other);
1594 return result;
1595}
1596
1597/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit
1598 * unsigned integers. */
1599static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar32 other) {
1600 simd_uchar64 result = 0;
1601 result.lo = simd_make_uchar32(other);
1602 return result;
1603}
1604
1605/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned
1606 * integers. The contents of the newly-created vector lanes are
1607 * unspecified. */
1608static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar32 other) {
1609 simd_uchar64 result;
1610 result.lo = simd_make_uchar32(other);
1611 return result;
1612}
1613
1614/*! @abstract Returns `other` unmodified. This function is a convenience for
1615 * templated and autogenerated code. */
1616static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar64 other) {
1617 return other;
1618}
1619
1620/*! @abstract Concatenates `x` and `y` to form a vector of two 16-bit signed
1621 * (twos-complement) integers. */
1622static inline SIMD_CFUNC simd_short2 simd_make_short2(short x, short y) {
1623 simd_short2 result;
1624 result.x = x;
1625 result.y = y;
1626 return result;
1627}
1628
1629/*! @abstract Zero-extends `other` to form a vector of two 16-bit signed
1630 * (twos-complement) integers. */
1631static inline SIMD_CFUNC simd_short2 simd_make_short2(short other) {
1632 simd_short2 result = 0;
1633 result.x = other;
1634 return result;
1635}
1636
1637/*! @abstract Extends `other` to form a vector of two 16-bit signed (twos-
1638 * complement) integers. The contents of the newly-created vector lanes are
1639 * unspecified. */
1640static inline SIMD_CFUNC simd_short2 simd_make_short2_undef(short other) {
1641 simd_short2 result;
1642 result.x = other;
1643 return result;
1644}
1645
1646/*! @abstract Returns `other` unmodified. This function is a convenience for
1647 * templated and autogenerated code. */
1648static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short2 other) {
1649 return other;
1650}
1651
1652/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos-
1653 * complement) integers. */
1654static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short3 other) {
1655 return other.xy;
1656}
1657
1658/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos-
1659 * complement) integers. */
1660static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short4 other) {
1661 return other.xy;
1662}
1663
1664/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos-
1665 * complement) integers. */
1666static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short8 other) {
1667 return other.xy;
1668}
1669
1670/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos-
1671 * complement) integers. */
1672static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short16 other) {
1673 return other.xy;
1674}
1675
1676/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos-
1677 * complement) integers. */
1678static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short32 other) {
1679 return other.xy;
1680}
1681
1682/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 16-bit
1683 * signed (twos-complement) integers. */
1684static inline SIMD_CFUNC simd_short3 simd_make_short3(short x, short y, short z) {
1685 simd_short3 result;
1686 result.x = x;
1687 result.y = y;
1688 result.z = z;
1689 return result;
1690}
1691
1692/*! @abstract Concatenates `x` and `yz` to form a vector of three 16-bit
1693 * signed (twos-complement) integers. */
1694static inline SIMD_CFUNC simd_short3 simd_make_short3(short x, simd_short2 yz) {
1695 simd_short3 result;
1696 result.x = x;
1697 result.yz = yz;
1698 return result;
1699}
1700
1701/*! @abstract Concatenates `xy` and `z` to form a vector of three 16-bit
1702 * signed (twos-complement) integers. */
1703static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short2 xy, short z) {
1704 simd_short3 result;
1705 result.xy = xy;
1706 result.z = z;
1707 return result;
1708}
1709
1710/*! @abstract Zero-extends `other` to form a vector of three 16-bit signed
1711 * (twos-complement) integers. */
1712static inline SIMD_CFUNC simd_short3 simd_make_short3(short other) {
1713 simd_short3 result = 0;
1714 result.x = other;
1715 return result;
1716}
1717
1718/*! @abstract Extends `other` to form a vector of three 16-bit signed (twos-
1719 * complement) integers. The contents of the newly-created vector lanes are
1720 * unspecified. */
1721static inline SIMD_CFUNC simd_short3 simd_make_short3_undef(short other) {
1722 simd_short3 result;
1723 result.x = other;
1724 return result;
1725}
1726
1727/*! @abstract Zero-extends `other` to form a vector of three 16-bit signed
1728 * (twos-complement) integers. */
1729static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short2 other) {
1730 simd_short3 result = 0;
1731 result.xy = other;
1732 return result;
1733}
1734
1735/*! @abstract Extends `other` to form a vector of three 16-bit signed (twos-
1736 * complement) integers. The contents of the newly-created vector lanes are
1737 * unspecified. */
1738static inline SIMD_CFUNC simd_short3 simd_make_short3_undef(simd_short2 other) {
1739 simd_short3 result;
1740 result.xy = other;
1741 return result;
1742}
1743
1744/*! @abstract Returns `other` unmodified. This function is a convenience for
1745 * templated and autogenerated code. */
1746static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short3 other) {
1747 return other;
1748}
1749
1750/*! @abstract Truncates `other` to form a vector of three 16-bit signed
1751 * (twos-complement) integers. */
1752static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short4 other) {
1753 return other.xyz;
1754}
1755
1756/*! @abstract Truncates `other` to form a vector of three 16-bit signed
1757 * (twos-complement) integers. */
1758static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short8 other) {
1759 return other.xyz;
1760}
1761
1762/*! @abstract Truncates `other` to form a vector of three 16-bit signed
1763 * (twos-complement) integers. */
1764static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short16 other) {
1765 return other.xyz;
1766}
1767
1768/*! @abstract Truncates `other` to form a vector of three 16-bit signed
1769 * (twos-complement) integers. */
1770static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short32 other) {
1771 return other.xyz;
1772}
1773
1774/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
1775 * 16-bit signed (twos-complement) integers. */
1776static inline SIMD_CFUNC simd_short4 simd_make_short4(short x, short y, short z, short w) {
1777 simd_short4 result;
1778 result.x = x;
1779 result.y = y;
1780 result.z = z;
1781 result.w = w;
1782 return result;
1783}
1784
1785/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 16-bit
1786 * signed (twos-complement) integers. */
1787static inline SIMD_CFUNC simd_short4 simd_make_short4(short x, short y, simd_short2 zw) {
1788 simd_short4 result;
1789 result.x = x;
1790 result.y = y;
1791 result.zw = zw;
1792 return result;
1793}
1794
1795/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 16-bit
1796 * signed (twos-complement) integers. */
1797static inline SIMD_CFUNC simd_short4 simd_make_short4(short x, simd_short2 yz, short w) {
1798 simd_short4 result;
1799 result.x = x;
1800 result.yz = yz;
1801 result.w = w;
1802 return result;
1803}
1804
1805/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 16-bit
1806 * signed (twos-complement) integers. */
1807static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short2 xy, short z, short w) {
1808 simd_short4 result;
1809 result.xy = xy;
1810 result.z = z;
1811 result.w = w;
1812 return result;
1813}
1814
1815/*! @abstract Concatenates `x` and `yzw` to form a vector of four 16-bit
1816 * signed (twos-complement) integers. */
1817static inline SIMD_CFUNC simd_short4 simd_make_short4(short x, simd_short3 yzw) {
1818 simd_short4 result;
1819 result.x = x;
1820 result.yzw = yzw;
1821 return result;
1822}
1823
1824/*! @abstract Concatenates `xy` and `zw` to form a vector of four 16-bit
1825 * signed (twos-complement) integers. */
1826static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short2 xy, simd_short2 zw) {
1827 simd_short4 result;
1828 result.xy = xy;
1829 result.zw = zw;
1830 return result;
1831}
1832
1833/*! @abstract Concatenates `xyz` and `w` to form a vector of four 16-bit
1834 * signed (twos-complement) integers. */
1835static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short3 xyz, short w) {
1836 simd_short4 result;
1837 result.xyz = xyz;
1838 result.w = w;
1839 return result;
1840}
1841
1842/*! @abstract Zero-extends `other` to form a vector of four 16-bit signed
1843 * (twos-complement) integers. */
1844static inline SIMD_CFUNC simd_short4 simd_make_short4(short other) {
1845 simd_short4 result = 0;
1846 result.x = other;
1847 return result;
1848}
1849
1850/*! @abstract Extends `other` to form a vector of four 16-bit signed (twos-
1851 * complement) integers. The contents of the newly-created vector lanes are
1852 * unspecified. */
1853static inline SIMD_CFUNC simd_short4 simd_make_short4_undef(short other) {
1854 simd_short4 result;
1855 result.x = other;
1856 return result;
1857}
1858
1859/*! @abstract Zero-extends `other` to form a vector of four 16-bit signed
1860 * (twos-complement) integers. */
1861static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short2 other) {
1862 simd_short4 result = 0;
1863 result.xy = other;
1864 return result;
1865}
1866
1867/*! @abstract Extends `other` to form a vector of four 16-bit signed (twos-
1868 * complement) integers. The contents of the newly-created vector lanes are
1869 * unspecified. */
1870static inline SIMD_CFUNC simd_short4 simd_make_short4_undef(simd_short2 other) {
1871 simd_short4 result;
1872 result.xy = other;
1873 return result;
1874}
1875
1876/*! @abstract Zero-extends `other` to form a vector of four 16-bit signed
1877 * (twos-complement) integers. */
1878static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short3 other) {
1879 simd_short4 result = 0;
1880 result.xyz = other;
1881 return result;
1882}
1883
1884/*! @abstract Extends `other` to form a vector of four 16-bit signed (twos-
1885 * complement) integers. The contents of the newly-created vector lanes are
1886 * unspecified. */
1887static inline SIMD_CFUNC simd_short4 simd_make_short4_undef(simd_short3 other) {
1888 simd_short4 result;
1889 result.xyz = other;
1890 return result;
1891}
1892
1893/*! @abstract Returns `other` unmodified. This function is a convenience for
1894 * templated and autogenerated code. */
1895static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short4 other) {
1896 return other;
1897}
1898
1899/*! @abstract Truncates `other` to form a vector of four 16-bit signed
1900 * (twos-complement) integers. */
1901static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short8 other) {
1902 return other.xyzw;
1903}
1904
1905/*! @abstract Truncates `other` to form a vector of four 16-bit signed
1906 * (twos-complement) integers. */
1907static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short16 other) {
1908 return other.xyzw;
1909}
1910
1911/*! @abstract Truncates `other` to form a vector of four 16-bit signed
1912 * (twos-complement) integers. */
1913static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short32 other) {
1914 return other.xyzw;
1915}
1916
1917/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 16-bit
1918 * signed (twos-complement) integers. */
1919static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short4 lo, simd_short4 hi) {
1920 simd_short8 result;
1921 result.lo = lo;
1922 result.hi = hi;
1923 return result;
1924}
1925
1926/*! @abstract Zero-extends `other` to form a vector of eight 16-bit signed
1927 * (twos-complement) integers. */
1928static inline SIMD_CFUNC simd_short8 simd_make_short8(short other) {
1929 simd_short8 result = 0;
1930 result.x = other;
1931 return result;
1932}
1933
1934/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos-
1935 * complement) integers. The contents of the newly-created vector lanes are
1936 * unspecified. */
1937static inline SIMD_CFUNC simd_short8 simd_make_short8_undef(short other) {
1938 simd_short8 result;
1939 result.x = other;
1940 return result;
1941}
1942
1943/*! @abstract Zero-extends `other` to form a vector of eight 16-bit signed
1944 * (twos-complement) integers. */
1945static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short2 other) {
1946 simd_short8 result = 0;
1947 result.xy = other;
1948 return result;
1949}
1950
1951/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos-
1952 * complement) integers. The contents of the newly-created vector lanes are
1953 * unspecified. */
1954static inline SIMD_CFUNC simd_short8 simd_make_short8_undef(simd_short2 other) {
1955 simd_short8 result;
1956 result.xy = other;
1957 return result;
1958}
1959
1960/*! @abstract Zero-extends `other` to form a vector of eight 16-bit signed
1961 * (twos-complement) integers. */
1962static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short3 other) {
1963 simd_short8 result = 0;
1964 result.xyz = other;
1965 return result;
1966}
1967
1968/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos-
1969 * complement) integers. The contents of the newly-created vector lanes are
1970 * unspecified. */
1971static inline SIMD_CFUNC simd_short8 simd_make_short8_undef(simd_short3 other) {
1972 simd_short8 result;
1973 result.xyz = other;
1974 return result;
1975}
1976
1977/*! @abstract Zero-extends `other` to form a vector of eight 16-bit signed
1978 * (twos-complement) integers. */
1979static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short4 other) {
1980 simd_short8 result = 0;
1981 result.xyzw = other;
1982 return result;
1983}
1984
1985/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos-
1986 * complement) integers. The contents of the newly-created vector lanes are
1987 * unspecified. */
1988static inline SIMD_CFUNC simd_short8 simd_make_short8_undef(simd_short4 other) {
1989 simd_short8 result;
1990 result.xyzw = other;
1991 return result;
1992}
1993
1994/*! @abstract Returns `other` unmodified. This function is a convenience for
1995 * templated and autogenerated code. */
1996static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short8 other) {
1997 return other;
1998}
1999
2000/*! @abstract Truncates `other` to form a vector of eight 16-bit signed
2001 * (twos-complement) integers. */
2002static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short16 other) {
2003 return simd_make_short8(other.lo);
2004}
2005
2006/*! @abstract Truncates `other` to form a vector of eight 16-bit signed
2007 * (twos-complement) integers. */
2008static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short32 other) {
2009 return simd_make_short8(other.lo);
2010}
2011
2012/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 16-bit
2013 * signed (twos-complement) integers. */
2014static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short8 lo, simd_short8 hi) {
2015 simd_short16 result;
2016 result.lo = lo;
2017 result.hi = hi;
2018 return result;
2019}
2020
2021/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed
2022 * (twos-complement) integers. */
2023static inline SIMD_CFUNC simd_short16 simd_make_short16(short other) {
2024 simd_short16 result = 0;
2025 result.x = other;
2026 return result;
2027}
2028
2029/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed
2030 * (twos-complement) integers. The contents of the newly-created vector
2031 * lanes are unspecified. */
2032static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(short other) {
2033 simd_short16 result;
2034 result.x = other;
2035 return result;
2036}
2037
2038/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed
2039 * (twos-complement) integers. */
2040static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short2 other) {
2041 simd_short16 result = 0;
2042 result.xy = other;
2043 return result;
2044}
2045
2046/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed
2047 * (twos-complement) integers. The contents of the newly-created vector
2048 * lanes are unspecified. */
2049static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(simd_short2 other) {
2050 simd_short16 result;
2051 result.xy = other;
2052 return result;
2053}
2054
2055/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed
2056 * (twos-complement) integers. */
2057static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short3 other) {
2058 simd_short16 result = 0;
2059 result.xyz = other;
2060 return result;
2061}
2062
2063/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed
2064 * (twos-complement) integers. The contents of the newly-created vector
2065 * lanes are unspecified. */
2066static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(simd_short3 other) {
2067 simd_short16 result;
2068 result.xyz = other;
2069 return result;
2070}
2071
2072/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed
2073 * (twos-complement) integers. */
2074static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short4 other) {
2075 simd_short16 result = 0;
2076 result.xyzw = other;
2077 return result;
2078}
2079
2080/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed
2081 * (twos-complement) integers. The contents of the newly-created vector
2082 * lanes are unspecified. */
2083static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(simd_short4 other) {
2084 simd_short16 result;
2085 result.xyzw = other;
2086 return result;
2087}
2088
2089/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed
2090 * (twos-complement) integers. */
2091static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short8 other) {
2092 simd_short16 result = 0;
2093 result.lo = simd_make_short8(other);
2094 return result;
2095}
2096
2097/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed
2098 * (twos-complement) integers. The contents of the newly-created vector
2099 * lanes are unspecified. */
2100static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(simd_short8 other) {
2101 simd_short16 result;
2102 result.lo = simd_make_short8(other);
2103 return result;
2104}
2105
2106/*! @abstract Returns `other` unmodified. This function is a convenience for
2107 * templated and autogenerated code. */
2108static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short16 other) {
2109 return other;
2110}
2111
2112/*! @abstract Truncates `other` to form a vector of sixteen 16-bit signed
2113 * (twos-complement) integers. */
2114static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short32 other) {
2115 return simd_make_short16(other.lo);
2116}
2117
2118/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two
2119 * 16-bit signed (twos-complement) integers. */
2120static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short16 lo, simd_short16 hi) {
2121 simd_short32 result;
2122 result.lo = lo;
2123 result.hi = hi;
2124 return result;
2125}
2126
2127/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2128 * signed (twos-complement) integers. */
2129static inline SIMD_CFUNC simd_short32 simd_make_short32(short other) {
2130 simd_short32 result = 0;
2131 result.x = other;
2132 return result;
2133}
2134
2135/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed
2136 * (twos-complement) integers. The contents of the newly-created vector
2137 * lanes are unspecified. */
2138static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(short other) {
2139 simd_short32 result;
2140 result.x = other;
2141 return result;
2142}
2143
2144/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2145 * signed (twos-complement) integers. */
2146static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short2 other) {
2147 simd_short32 result = 0;
2148 result.xy = other;
2149 return result;
2150}
2151
2152/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed
2153 * (twos-complement) integers. The contents of the newly-created vector
2154 * lanes are unspecified. */
2155static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short2 other) {
2156 simd_short32 result;
2157 result.xy = other;
2158 return result;
2159}
2160
2161/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2162 * signed (twos-complement) integers. */
2163static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short3 other) {
2164 simd_short32 result = 0;
2165 result.xyz = other;
2166 return result;
2167}
2168
2169/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed
2170 * (twos-complement) integers. The contents of the newly-created vector
2171 * lanes are unspecified. */
2172static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short3 other) {
2173 simd_short32 result;
2174 result.xyz = other;
2175 return result;
2176}
2177
2178/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2179 * signed (twos-complement) integers. */
2180static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short4 other) {
2181 simd_short32 result = 0;
2182 result.xyzw = other;
2183 return result;
2184}
2185
2186/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed
2187 * (twos-complement) integers. The contents of the newly-created vector
2188 * lanes are unspecified. */
2189static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short4 other) {
2190 simd_short32 result;
2191 result.xyzw = other;
2192 return result;
2193}
2194
2195/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2196 * signed (twos-complement) integers. */
2197static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short8 other) {
2198 simd_short32 result = 0;
2199 result.lo = simd_make_short16(other);
2200 return result;
2201}
2202
2203/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed
2204 * (twos-complement) integers. The contents of the newly-created vector
2205 * lanes are unspecified. */
2206static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short8 other) {
2207 simd_short32 result;
2208 result.lo = simd_make_short16(other);
2209 return result;
2210}
2211
2212/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2213 * signed (twos-complement) integers. */
2214static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short16 other) {
2215 simd_short32 result = 0;
2216 result.lo = simd_make_short16(other);
2217 return result;
2218}
2219
2220/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed
2221 * (twos-complement) integers. The contents of the newly-created vector
2222 * lanes are unspecified. */
2223static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short16 other) {
2224 simd_short32 result;
2225 result.lo = simd_make_short16(other);
2226 return result;
2227}
2228
2229/*! @abstract Returns `other` unmodified. This function is a convenience for
2230 * templated and autogenerated code. */
2231static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short32 other) {
2232 return other;
2233}
2234
2235/*! @abstract Concatenates `x` and `y` to form a vector of two 16-bit
2236 * unsigned integers. */
2237static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(unsigned short x, unsigned short y) {
2238 simd_ushort2 result;
2239 result.x = x;
2240 result.y = y;
2241 return result;
2242}
2243
2244/*! @abstract Zero-extends `other` to form a vector of two 16-bit unsigned
2245 * integers. */
2246static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(unsigned short other) {
2247 simd_ushort2 result = 0;
2248 result.x = other;
2249 return result;
2250}
2251
2252/*! @abstract Extends `other` to form a vector of two 16-bit unsigned
2253 * integers. The contents of the newly-created vector lanes are
2254 * unspecified. */
2255static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2_undef(unsigned short other) {
2256 simd_ushort2 result;
2257 result.x = other;
2258 return result;
2259}
2260
2261/*! @abstract Returns `other` unmodified. This function is a convenience for
2262 * templated and autogenerated code. */
2263static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort2 other) {
2264 return other;
2265}
2266
2267/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned
2268 * integers. */
2269static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort3 other) {
2270 return other.xy;
2271}
2272
2273/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned
2274 * integers. */
2275static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort4 other) {
2276 return other.xy;
2277}
2278
2279/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned
2280 * integers. */
2281static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort8 other) {
2282 return other.xy;
2283}
2284
2285/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned
2286 * integers. */
2287static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort16 other) {
2288 return other.xy;
2289}
2290
2291/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned
2292 * integers. */
2293static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort32 other) {
2294 return other.xy;
2295}
2296
2297/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 16-bit
2298 * unsigned integers. */
2299static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(unsigned short x, unsigned short y, unsigned short z) {
2300 simd_ushort3 result;
2301 result.x = x;
2302 result.y = y;
2303 result.z = z;
2304 return result;
2305}
2306
2307/*! @abstract Concatenates `x` and `yz` to form a vector of three 16-bit
2308 * unsigned integers. */
2309static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(unsigned short x, simd_ushort2 yz) {
2310 simd_ushort3 result;
2311 result.x = x;
2312 result.yz = yz;
2313 return result;
2314}
2315
2316/*! @abstract Concatenates `xy` and `z` to form a vector of three 16-bit
2317 * unsigned integers. */
2318static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort2 xy, unsigned short z) {
2319 simd_ushort3 result;
2320 result.xy = xy;
2321 result.z = z;
2322 return result;
2323}
2324
2325/*! @abstract Zero-extends `other` to form a vector of three 16-bit unsigned
2326 * integers. */
2327static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(unsigned short other) {
2328 simd_ushort3 result = 0;
2329 result.x = other;
2330 return result;
2331}
2332
2333/*! @abstract Extends `other` to form a vector of three 16-bit unsigned
2334 * integers. The contents of the newly-created vector lanes are
2335 * unspecified. */
2336static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3_undef(unsigned short other) {
2337 simd_ushort3 result;
2338 result.x = other;
2339 return result;
2340}
2341
2342/*! @abstract Zero-extends `other` to form a vector of three 16-bit unsigned
2343 * integers. */
2344static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort2 other) {
2345 simd_ushort3 result = 0;
2346 result.xy = other;
2347 return result;
2348}
2349
2350/*! @abstract Extends `other` to form a vector of three 16-bit unsigned
2351 * integers. The contents of the newly-created vector lanes are
2352 * unspecified. */
2353static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3_undef(simd_ushort2 other) {
2354 simd_ushort3 result;
2355 result.xy = other;
2356 return result;
2357}
2358
2359/*! @abstract Returns `other` unmodified. This function is a convenience for
2360 * templated and autogenerated code. */
2361static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort3 other) {
2362 return other;
2363}
2364
2365/*! @abstract Truncates `other` to form a vector of three 16-bit unsigned
2366 * integers. */
2367static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort4 other) {
2368 return other.xyz;
2369}
2370
2371/*! @abstract Truncates `other` to form a vector of three 16-bit unsigned
2372 * integers. */
2373static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort8 other) {
2374 return other.xyz;
2375}
2376
2377/*! @abstract Truncates `other` to form a vector of three 16-bit unsigned
2378 * integers. */
2379static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort16 other) {
2380 return other.xyz;
2381}
2382
2383/*! @abstract Truncates `other` to form a vector of three 16-bit unsigned
2384 * integers. */
2385static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort32 other) {
2386 return other.xyz;
2387}
2388
2389/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
2390 * 16-bit unsigned integers. */
2391static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) {
2392 simd_ushort4 result;
2393 result.x = x;
2394 result.y = y;
2395 result.z = z;
2396 result.w = w;
2397 return result;
2398}
2399
2400/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 16-bit
2401 * unsigned integers. */
2402static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short x, unsigned short y, simd_ushort2 zw) {
2403 simd_ushort4 result;
2404 result.x = x;
2405 result.y = y;
2406 result.zw = zw;
2407 return result;
2408}
2409
2410/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 16-bit
2411 * unsigned integers. */
2412static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short x, simd_ushort2 yz, unsigned short w) {
2413 simd_ushort4 result;
2414 result.x = x;
2415 result.yz = yz;
2416 result.w = w;
2417 return result;
2418}
2419
2420/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 16-bit
2421 * unsigned integers. */
2422static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort2 xy, unsigned short z, unsigned short w) {
2423 simd_ushort4 result;
2424 result.xy = xy;
2425 result.z = z;
2426 result.w = w;
2427 return result;
2428}
2429
2430/*! @abstract Concatenates `x` and `yzw` to form a vector of four 16-bit
2431 * unsigned integers. */
2432static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short x, simd_ushort3 yzw) {
2433 simd_ushort4 result;
2434 result.x = x;
2435 result.yzw = yzw;
2436 return result;
2437}
2438
2439/*! @abstract Concatenates `xy` and `zw` to form a vector of four 16-bit
2440 * unsigned integers. */
2441static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort2 xy, simd_ushort2 zw) {
2442 simd_ushort4 result;
2443 result.xy = xy;
2444 result.zw = zw;
2445 return result;
2446}
2447
2448/*! @abstract Concatenates `xyz` and `w` to form a vector of four 16-bit
2449 * unsigned integers. */
2450static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort3 xyz, unsigned short w) {
2451 simd_ushort4 result;
2452 result.xyz = xyz;
2453 result.w = w;
2454 return result;
2455}
2456
2457/*! @abstract Zero-extends `other` to form a vector of four 16-bit unsigned
2458 * integers. */
2459static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short other) {
2460 simd_ushort4 result = 0;
2461 result.x = other;
2462 return result;
2463}
2464
2465/*! @abstract Extends `other` to form a vector of four 16-bit unsigned
2466 * integers. The contents of the newly-created vector lanes are
2467 * unspecified. */
2468static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4_undef(unsigned short other) {
2469 simd_ushort4 result;
2470 result.x = other;
2471 return result;
2472}
2473
2474/*! @abstract Zero-extends `other` to form a vector of four 16-bit unsigned
2475 * integers. */
2476static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort2 other) {
2477 simd_ushort4 result = 0;
2478 result.xy = other;
2479 return result;
2480}
2481
2482/*! @abstract Extends `other` to form a vector of four 16-bit unsigned
2483 * integers. The contents of the newly-created vector lanes are
2484 * unspecified. */
2485static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4_undef(simd_ushort2 other) {
2486 simd_ushort4 result;
2487 result.xy = other;
2488 return result;
2489}
2490
2491/*! @abstract Zero-extends `other` to form a vector of four 16-bit unsigned
2492 * integers. */
2493static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort3 other) {
2494 simd_ushort4 result = 0;
2495 result.xyz = other;
2496 return result;
2497}
2498
2499/*! @abstract Extends `other` to form a vector of four 16-bit unsigned
2500 * integers. The contents of the newly-created vector lanes are
2501 * unspecified. */
2502static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4_undef(simd_ushort3 other) {
2503 simd_ushort4 result;
2504 result.xyz = other;
2505 return result;
2506}
2507
2508/*! @abstract Returns `other` unmodified. This function is a convenience for
2509 * templated and autogenerated code. */
2510static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort4 other) {
2511 return other;
2512}
2513
2514/*! @abstract Truncates `other` to form a vector of four 16-bit unsigned
2515 * integers. */
2516static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort8 other) {
2517 return other.xyzw;
2518}
2519
2520/*! @abstract Truncates `other` to form a vector of four 16-bit unsigned
2521 * integers. */
2522static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort16 other) {
2523 return other.xyzw;
2524}
2525
2526/*! @abstract Truncates `other` to form a vector of four 16-bit unsigned
2527 * integers. */
2528static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort32 other) {
2529 return other.xyzw;
2530}
2531
2532/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 16-bit
2533 * unsigned integers. */
2534static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort4 lo, simd_ushort4 hi) {
2535 simd_ushort8 result;
2536 result.lo = lo;
2537 result.hi = hi;
2538 return result;
2539}
2540
2541/*! @abstract Zero-extends `other` to form a vector of eight 16-bit unsigned
2542 * integers. */
2543static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(unsigned short other) {
2544 simd_ushort8 result = 0;
2545 result.x = other;
2546 return result;
2547}
2548
2549/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned
2550 * integers. The contents of the newly-created vector lanes are
2551 * unspecified. */
2552static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8_undef(unsigned short other) {
2553 simd_ushort8 result;
2554 result.x = other;
2555 return result;
2556}
2557
2558/*! @abstract Zero-extends `other` to form a vector of eight 16-bit unsigned
2559 * integers. */
2560static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort2 other) {
2561 simd_ushort8 result = 0;
2562 result.xy = other;
2563 return result;
2564}
2565
2566/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned
2567 * integers. The contents of the newly-created vector lanes are
2568 * unspecified. */
2569static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8_undef(simd_ushort2 other) {
2570 simd_ushort8 result;
2571 result.xy = other;
2572 return result;
2573}
2574
2575/*! @abstract Zero-extends `other` to form a vector of eight 16-bit unsigned
2576 * integers. */
2577static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort3 other) {
2578 simd_ushort8 result = 0;
2579 result.xyz = other;
2580 return result;
2581}
2582
2583/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned
2584 * integers. The contents of the newly-created vector lanes are
2585 * unspecified. */
2586static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8_undef(simd_ushort3 other) {
2587 simd_ushort8 result;
2588 result.xyz = other;
2589 return result;
2590}
2591
2592/*! @abstract Zero-extends `other` to form a vector of eight 16-bit unsigned
2593 * integers. */
2594static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort4 other) {
2595 simd_ushort8 result = 0;
2596 result.xyzw = other;
2597 return result;
2598}
2599
2600/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned
2601 * integers. The contents of the newly-created vector lanes are
2602 * unspecified. */
2603static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8_undef(simd_ushort4 other) {
2604 simd_ushort8 result;
2605 result.xyzw = other;
2606 return result;
2607}
2608
2609/*! @abstract Returns `other` unmodified. This function is a convenience for
2610 * templated and autogenerated code. */
2611static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort8 other) {
2612 return other;
2613}
2614
2615/*! @abstract Truncates `other` to form a vector of eight 16-bit unsigned
2616 * integers. */
2617static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort16 other) {
2618 return simd_make_ushort8(other.lo);
2619}
2620
2621/*! @abstract Truncates `other` to form a vector of eight 16-bit unsigned
2622 * integers. */
2623static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort32 other) {
2624 return simd_make_ushort8(other.lo);
2625}
2626
2627/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 16-bit
2628 * unsigned integers. */
2629static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort8 lo, simd_ushort8 hi) {
2630 simd_ushort16 result;
2631 result.lo = lo;
2632 result.hi = hi;
2633 return result;
2634}
2635
2636/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit
2637 * unsigned integers. */
2638static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(unsigned short other) {
2639 simd_ushort16 result = 0;
2640 result.x = other;
2641 return result;
2642}
2643
2644/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned
2645 * integers. The contents of the newly-created vector lanes are
2646 * unspecified. */
2647static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(unsigned short other) {
2648 simd_ushort16 result;
2649 result.x = other;
2650 return result;
2651}
2652
2653/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit
2654 * unsigned integers. */
2655static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort2 other) {
2656 simd_ushort16 result = 0;
2657 result.xy = other;
2658 return result;
2659}
2660
2661/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned
2662 * integers. The contents of the newly-created vector lanes are
2663 * unspecified. */
2664static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(simd_ushort2 other) {
2665 simd_ushort16 result;
2666 result.xy = other;
2667 return result;
2668}
2669
2670/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit
2671 * unsigned integers. */
2672static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort3 other) {
2673 simd_ushort16 result = 0;
2674 result.xyz = other;
2675 return result;
2676}
2677
2678/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned
2679 * integers. The contents of the newly-created vector lanes are
2680 * unspecified. */
2681static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(simd_ushort3 other) {
2682 simd_ushort16 result;
2683 result.xyz = other;
2684 return result;
2685}
2686
2687/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit
2688 * unsigned integers. */
2689static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort4 other) {
2690 simd_ushort16 result = 0;
2691 result.xyzw = other;
2692 return result;
2693}
2694
2695/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned
2696 * integers. The contents of the newly-created vector lanes are
2697 * unspecified. */
2698static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(simd_ushort4 other) {
2699 simd_ushort16 result;
2700 result.xyzw = other;
2701 return result;
2702}
2703
2704/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit
2705 * unsigned integers. */
2706static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort8 other) {
2707 simd_ushort16 result = 0;
2708 result.lo = simd_make_ushort8(other);
2709 return result;
2710}
2711
2712/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned
2713 * integers. The contents of the newly-created vector lanes are
2714 * unspecified. */
2715static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(simd_ushort8 other) {
2716 simd_ushort16 result;
2717 result.lo = simd_make_ushort8(other);
2718 return result;
2719}
2720
2721/*! @abstract Returns `other` unmodified. This function is a convenience for
2722 * templated and autogenerated code. */
2723static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort16 other) {
2724 return other;
2725}
2726
2727/*! @abstract Truncates `other` to form a vector of sixteen 16-bit unsigned
2728 * integers. */
2729static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort32 other) {
2730 return simd_make_ushort16(other.lo);
2731}
2732
2733/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two
2734 * 16-bit unsigned integers. */
2735static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort16 lo, simd_ushort16 hi) {
2736 simd_ushort32 result;
2737 result.lo = lo;
2738 result.hi = hi;
2739 return result;
2740}
2741
2742/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2743 * unsigned integers. */
2744static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(unsigned short other) {
2745 simd_ushort32 result = 0;
2746 result.x = other;
2747 return result;
2748}
2749
2750/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned
2751 * integers. The contents of the newly-created vector lanes are
2752 * unspecified. */
2753static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(unsigned short other) {
2754 simd_ushort32 result;
2755 result.x = other;
2756 return result;
2757}
2758
2759/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2760 * unsigned integers. */
2761static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort2 other) {
2762 simd_ushort32 result = 0;
2763 result.xy = other;
2764 return result;
2765}
2766
2767/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned
2768 * integers. The contents of the newly-created vector lanes are
2769 * unspecified. */
2770static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort2 other) {
2771 simd_ushort32 result;
2772 result.xy = other;
2773 return result;
2774}
2775
2776/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2777 * unsigned integers. */
2778static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort3 other) {
2779 simd_ushort32 result = 0;
2780 result.xyz = other;
2781 return result;
2782}
2783
2784/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned
2785 * integers. The contents of the newly-created vector lanes are
2786 * unspecified. */
2787static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort3 other) {
2788 simd_ushort32 result;
2789 result.xyz = other;
2790 return result;
2791}
2792
2793/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2794 * unsigned integers. */
2795static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort4 other) {
2796 simd_ushort32 result = 0;
2797 result.xyzw = other;
2798 return result;
2799}
2800
2801/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned
2802 * integers. The contents of the newly-created vector lanes are
2803 * unspecified. */
2804static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort4 other) {
2805 simd_ushort32 result;
2806 result.xyzw = other;
2807 return result;
2808}
2809
2810/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2811 * unsigned integers. */
2812static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort8 other) {
2813 simd_ushort32 result = 0;
2814 result.lo = simd_make_ushort16(other);
2815 return result;
2816}
2817
2818/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned
2819 * integers. The contents of the newly-created vector lanes are
2820 * unspecified. */
2821static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort8 other) {
2822 simd_ushort32 result;
2823 result.lo = simd_make_ushort16(other);
2824 return result;
2825}
2826
2827/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit
2828 * unsigned integers. */
2829static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort16 other) {
2830 simd_ushort32 result = 0;
2831 result.lo = simd_make_ushort16(other);
2832 return result;
2833}
2834
2835/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned
2836 * integers. The contents of the newly-created vector lanes are
2837 * unspecified. */
2838static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort16 other) {
2839 simd_ushort32 result;
2840 result.lo = simd_make_ushort16(other);
2841 return result;
2842}
2843
2844/*! @abstract Returns `other` unmodified. This function is a convenience for
2845 * templated and autogenerated code. */
2846static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort32 other) {
2847 return other;
2848}
2849
2850/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit signed
2851 * (twos-complement) integers. */
2852static inline SIMD_CFUNC simd_int2 simd_make_int2(int x, int y) {
2853 simd_int2 result;
2854 result.x = x;
2855 result.y = y;
2856 return result;
2857}
2858
2859/*! @abstract Zero-extends `other` to form a vector of two 32-bit signed
2860 * (twos-complement) integers. */
2861static inline SIMD_CFUNC simd_int2 simd_make_int2(int other) {
2862 simd_int2 result = 0;
2863 result.x = other;
2864 return result;
2865}
2866
2867/*! @abstract Extends `other` to form a vector of two 32-bit signed (twos-
2868 * complement) integers. The contents of the newly-created vector lanes are
2869 * unspecified. */
2870static inline SIMD_CFUNC simd_int2 simd_make_int2_undef(int other) {
2871 simd_int2 result;
2872 result.x = other;
2873 return result;
2874}
2875
2876/*! @abstract Returns `other` unmodified. This function is a convenience for
2877 * templated and autogenerated code. */
2878static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int2 other) {
2879 return other;
2880}
2881
2882/*! @abstract Truncates `other` to form a vector of two 32-bit signed (twos-
2883 * complement) integers. */
2884static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int3 other) {
2885 return other.xy;
2886}
2887
2888/*! @abstract Truncates `other` to form a vector of two 32-bit signed (twos-
2889 * complement) integers. */
2890static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int4 other) {
2891 return other.xy;
2892}
2893
2894/*! @abstract Truncates `other` to form a vector of two 32-bit signed (twos-
2895 * complement) integers. */
2896static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int8 other) {
2897 return other.xy;
2898}
2899
2900/*! @abstract Truncates `other` to form a vector of two 32-bit signed (twos-
2901 * complement) integers. */
2902static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int16 other) {
2903 return other.xy;
2904}
2905
2906/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit
2907 * signed (twos-complement) integers. */
2908static inline SIMD_CFUNC simd_int3 simd_make_int3(int x, int y, int z) {
2909 simd_int3 result;
2910 result.x = x;
2911 result.y = y;
2912 result.z = z;
2913 return result;
2914}
2915
2916/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit
2917 * signed (twos-complement) integers. */
2918static inline SIMD_CFUNC simd_int3 simd_make_int3(int x, simd_int2 yz) {
2919 simd_int3 result;
2920 result.x = x;
2921 result.yz = yz;
2922 return result;
2923}
2924
2925/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit
2926 * signed (twos-complement) integers. */
2927static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int2 xy, int z) {
2928 simd_int3 result;
2929 result.xy = xy;
2930 result.z = z;
2931 return result;
2932}
2933
2934/*! @abstract Zero-extends `other` to form a vector of three 32-bit signed
2935 * (twos-complement) integers. */
2936static inline SIMD_CFUNC simd_int3 simd_make_int3(int other) {
2937 simd_int3 result = 0;
2938 result.x = other;
2939 return result;
2940}
2941
2942/*! @abstract Extends `other` to form a vector of three 32-bit signed (twos-
2943 * complement) integers. The contents of the newly-created vector lanes are
2944 * unspecified. */
2945static inline SIMD_CFUNC simd_int3 simd_make_int3_undef(int other) {
2946 simd_int3 result;
2947 result.x = other;
2948 return result;
2949}
2950
2951/*! @abstract Zero-extends `other` to form a vector of three 32-bit signed
2952 * (twos-complement) integers. */
2953static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int2 other) {
2954 simd_int3 result = 0;
2955 result.xy = other;
2956 return result;
2957}
2958
2959/*! @abstract Extends `other` to form a vector of three 32-bit signed (twos-
2960 * complement) integers. The contents of the newly-created vector lanes are
2961 * unspecified. */
2962static inline SIMD_CFUNC simd_int3 simd_make_int3_undef(simd_int2 other) {
2963 simd_int3 result;
2964 result.xy = other;
2965 return result;
2966}
2967
2968/*! @abstract Returns `other` unmodified. This function is a convenience for
2969 * templated and autogenerated code. */
2970static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int3 other) {
2971 return other;
2972}
2973
2974/*! @abstract Truncates `other` to form a vector of three 32-bit signed
2975 * (twos-complement) integers. */
2976static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int4 other) {
2977 return other.xyz;
2978}
2979
2980/*! @abstract Truncates `other` to form a vector of three 32-bit signed
2981 * (twos-complement) integers. */
2982static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int8 other) {
2983 return other.xyz;
2984}
2985
2986/*! @abstract Truncates `other` to form a vector of three 32-bit signed
2987 * (twos-complement) integers. */
2988static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int16 other) {
2989 return other.xyz;
2990}
2991
2992/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
2993 * 32-bit signed (twos-complement) integers. */
2994static inline SIMD_CFUNC simd_int4 simd_make_int4(int x, int y, int z, int w) {
2995 simd_int4 result;
2996 result.x = x;
2997 result.y = y;
2998 result.z = z;
2999 result.w = w;
3000 return result;
3001}
3002
3003/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit
3004 * signed (twos-complement) integers. */
3005static inline SIMD_CFUNC simd_int4 simd_make_int4(int x, int y, simd_int2 zw) {
3006 simd_int4 result;
3007 result.x = x;
3008 result.y = y;
3009 result.zw = zw;
3010 return result;
3011}
3012
3013/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit
3014 * signed (twos-complement) integers. */
3015static inline SIMD_CFUNC simd_int4 simd_make_int4(int x, simd_int2 yz, int w) {
3016 simd_int4 result;
3017 result.x = x;
3018 result.yz = yz;
3019 result.w = w;
3020 return result;
3021}
3022
3023/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit
3024 * signed (twos-complement) integers. */
3025static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int2 xy, int z, int w) {
3026 simd_int4 result;
3027 result.xy = xy;
3028 result.z = z;
3029 result.w = w;
3030 return result;
3031}
3032
3033/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit
3034 * signed (twos-complement) integers. */
3035static inline SIMD_CFUNC simd_int4 simd_make_int4(int x, simd_int3 yzw) {
3036 simd_int4 result;
3037 result.x = x;
3038 result.yzw = yzw;
3039 return result;
3040}
3041
3042/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit
3043 * signed (twos-complement) integers. */
3044static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int2 xy, simd_int2 zw) {
3045 simd_int4 result;
3046 result.xy = xy;
3047 result.zw = zw;
3048 return result;
3049}
3050
3051/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit
3052 * signed (twos-complement) integers. */
3053static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int3 xyz, int w) {
3054 simd_int4 result;
3055 result.xyz = xyz;
3056 result.w = w;
3057 return result;
3058}
3059
3060/*! @abstract Zero-extends `other` to form a vector of four 32-bit signed
3061 * (twos-complement) integers. */
3062static inline SIMD_CFUNC simd_int4 simd_make_int4(int other) {
3063 simd_int4 result = 0;
3064 result.x = other;
3065 return result;
3066}
3067
3068/*! @abstract Extends `other` to form a vector of four 32-bit signed (twos-
3069 * complement) integers. The contents of the newly-created vector lanes are
3070 * unspecified. */
3071static inline SIMD_CFUNC simd_int4 simd_make_int4_undef(int other) {
3072 simd_int4 result;
3073 result.x = other;
3074 return result;
3075}
3076
3077/*! @abstract Zero-extends `other` to form a vector of four 32-bit signed
3078 * (twos-complement) integers. */
3079static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int2 other) {
3080 simd_int4 result = 0;
3081 result.xy = other;
3082 return result;
3083}
3084
3085/*! @abstract Extends `other` to form a vector of four 32-bit signed (twos-
3086 * complement) integers. The contents of the newly-created vector lanes are
3087 * unspecified. */
3088static inline SIMD_CFUNC simd_int4 simd_make_int4_undef(simd_int2 other) {
3089 simd_int4 result;
3090 result.xy = other;
3091 return result;
3092}
3093
3094/*! @abstract Zero-extends `other` to form a vector of four 32-bit signed
3095 * (twos-complement) integers. */
3096static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int3 other) {
3097 simd_int4 result = 0;
3098 result.xyz = other;
3099 return result;
3100}
3101
3102/*! @abstract Extends `other` to form a vector of four 32-bit signed (twos-
3103 * complement) integers. The contents of the newly-created vector lanes are
3104 * unspecified. */
3105static inline SIMD_CFUNC simd_int4 simd_make_int4_undef(simd_int3 other) {
3106 simd_int4 result;
3107 result.xyz = other;
3108 return result;
3109}
3110
3111/*! @abstract Returns `other` unmodified. This function is a convenience for
3112 * templated and autogenerated code. */
3113static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int4 other) {
3114 return other;
3115}
3116
3117/*! @abstract Truncates `other` to form a vector of four 32-bit signed
3118 * (twos-complement) integers. */
3119static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int8 other) {
3120 return other.xyzw;
3121}
3122
3123/*! @abstract Truncates `other` to form a vector of four 32-bit signed
3124 * (twos-complement) integers. */
3125static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int16 other) {
3126 return other.xyzw;
3127}
3128
3129/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit
3130 * signed (twos-complement) integers. */
3131static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int4 lo, simd_int4 hi) {
3132 simd_int8 result;
3133 result.lo = lo;
3134 result.hi = hi;
3135 return result;
3136}
3137
3138/*! @abstract Zero-extends `other` to form a vector of eight 32-bit signed
3139 * (twos-complement) integers. */
3140static inline SIMD_CFUNC simd_int8 simd_make_int8(int other) {
3141 simd_int8 result = 0;
3142 result.x = other;
3143 return result;
3144}
3145
3146/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos-
3147 * complement) integers. The contents of the newly-created vector lanes are
3148 * unspecified. */
3149static inline SIMD_CFUNC simd_int8 simd_make_int8_undef(int other) {
3150 simd_int8 result;
3151 result.x = other;
3152 return result;
3153}
3154
3155/*! @abstract Zero-extends `other` to form a vector of eight 32-bit signed
3156 * (twos-complement) integers. */
3157static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int2 other) {
3158 simd_int8 result = 0;
3159 result.xy = other;
3160 return result;
3161}
3162
3163/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos-
3164 * complement) integers. The contents of the newly-created vector lanes are
3165 * unspecified. */
3166static inline SIMD_CFUNC simd_int8 simd_make_int8_undef(simd_int2 other) {
3167 simd_int8 result;
3168 result.xy = other;
3169 return result;
3170}
3171
3172/*! @abstract Zero-extends `other` to form a vector of eight 32-bit signed
3173 * (twos-complement) integers. */
3174static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int3 other) {
3175 simd_int8 result = 0;
3176 result.xyz = other;
3177 return result;
3178}
3179
3180/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos-
3181 * complement) integers. The contents of the newly-created vector lanes are
3182 * unspecified. */
3183static inline SIMD_CFUNC simd_int8 simd_make_int8_undef(simd_int3 other) {
3184 simd_int8 result;
3185 result.xyz = other;
3186 return result;
3187}
3188
3189/*! @abstract Zero-extends `other` to form a vector of eight 32-bit signed
3190 * (twos-complement) integers. */
3191static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int4 other) {
3192 simd_int8 result = 0;
3193 result.xyzw = other;
3194 return result;
3195}
3196
3197/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos-
3198 * complement) integers. The contents of the newly-created vector lanes are
3199 * unspecified. */
3200static inline SIMD_CFUNC simd_int8 simd_make_int8_undef(simd_int4 other) {
3201 simd_int8 result;
3202 result.xyzw = other;
3203 return result;
3204}
3205
3206/*! @abstract Returns `other` unmodified. This function is a convenience for
3207 * templated and autogenerated code. */
3208static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int8 other) {
3209 return other;
3210}
3211
3212/*! @abstract Truncates `other` to form a vector of eight 32-bit signed
3213 * (twos-complement) integers. */
3214static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int16 other) {
3215 return simd_make_int8(other.lo);
3216}
3217
3218/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit
3219 * signed (twos-complement) integers. */
3220static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int8 lo, simd_int8 hi) {
3221 simd_int16 result;
3222 result.lo = lo;
3223 result.hi = hi;
3224 return result;
3225}
3226
3227/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed
3228 * (twos-complement) integers. */
3229static inline SIMD_CFUNC simd_int16 simd_make_int16(int other) {
3230 simd_int16 result = 0;
3231 result.x = other;
3232 return result;
3233}
3234
3235/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed
3236 * (twos-complement) integers. The contents of the newly-created vector
3237 * lanes are unspecified. */
3238static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(int other) {
3239 simd_int16 result;
3240 result.x = other;
3241 return result;
3242}
3243
3244/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed
3245 * (twos-complement) integers. */
3246static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int2 other) {
3247 simd_int16 result = 0;
3248 result.xy = other;
3249 return result;
3250}
3251
3252/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed
3253 * (twos-complement) integers. The contents of the newly-created vector
3254 * lanes are unspecified. */
3255static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(simd_int2 other) {
3256 simd_int16 result;
3257 result.xy = other;
3258 return result;
3259}
3260
3261/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed
3262 * (twos-complement) integers. */
3263static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int3 other) {
3264 simd_int16 result = 0;
3265 result.xyz = other;
3266 return result;
3267}
3268
3269/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed
3270 * (twos-complement) integers. The contents of the newly-created vector
3271 * lanes are unspecified. */
3272static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(simd_int3 other) {
3273 simd_int16 result;
3274 result.xyz = other;
3275 return result;
3276}
3277
3278/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed
3279 * (twos-complement) integers. */
3280static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int4 other) {
3281 simd_int16 result = 0;
3282 result.xyzw = other;
3283 return result;
3284}
3285
3286/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed
3287 * (twos-complement) integers. The contents of the newly-created vector
3288 * lanes are unspecified. */
3289static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(simd_int4 other) {
3290 simd_int16 result;
3291 result.xyzw = other;
3292 return result;
3293}
3294
3295/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed
3296 * (twos-complement) integers. */
3297static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int8 other) {
3298 simd_int16 result = 0;
3299 result.lo = simd_make_int8(other);
3300 return result;
3301}
3302
3303/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed
3304 * (twos-complement) integers. The contents of the newly-created vector
3305 * lanes are unspecified. */
3306static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(simd_int8 other) {
3307 simd_int16 result;
3308 result.lo = simd_make_int8(other);
3309 return result;
3310}
3311
3312/*! @abstract Returns `other` unmodified. This function is a convenience for
3313 * templated and autogenerated code. */
3314static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int16 other) {
3315 return other;
3316}
3317
3318/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit
3319 * unsigned integers. */
3320static inline SIMD_CFUNC simd_uint2 simd_make_uint2(unsigned int x, unsigned int y) {
3321 simd_uint2 result;
3322 result.x = x;
3323 result.y = y;
3324 return result;
3325}
3326
3327/*! @abstract Zero-extends `other` to form a vector of two 32-bit unsigned
3328 * integers. */
3329static inline SIMD_CFUNC simd_uint2 simd_make_uint2(unsigned int other) {
3330 simd_uint2 result = 0;
3331 result.x = other;
3332 return result;
3333}
3334
3335/*! @abstract Extends `other` to form a vector of two 32-bit unsigned
3336 * integers. The contents of the newly-created vector lanes are
3337 * unspecified. */
3338static inline SIMD_CFUNC simd_uint2 simd_make_uint2_undef(unsigned int other) {
3339 simd_uint2 result;
3340 result.x = other;
3341 return result;
3342}
3343
3344/*! @abstract Returns `other` unmodified. This function is a convenience for
3345 * templated and autogenerated code. */
3346static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint2 other) {
3347 return other;
3348}
3349
3350/*! @abstract Truncates `other` to form a vector of two 32-bit unsigned
3351 * integers. */
3352static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint3 other) {
3353 return other.xy;
3354}
3355
3356/*! @abstract Truncates `other` to form a vector of two 32-bit unsigned
3357 * integers. */
3358static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint4 other) {
3359 return other.xy;
3360}
3361
3362/*! @abstract Truncates `other` to form a vector of two 32-bit unsigned
3363 * integers. */
3364static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint8 other) {
3365 return other.xy;
3366}
3367
3368/*! @abstract Truncates `other` to form a vector of two 32-bit unsigned
3369 * integers. */
3370static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint16 other) {
3371 return other.xy;
3372}
3373
3374/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit
3375 * unsigned integers. */
3376static inline SIMD_CFUNC simd_uint3 simd_make_uint3(unsigned int x, unsigned int y, unsigned int z) {
3377 simd_uint3 result;
3378 result.x = x;
3379 result.y = y;
3380 result.z = z;
3381 return result;
3382}
3383
3384/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit
3385 * unsigned integers. */
3386static inline SIMD_CFUNC simd_uint3 simd_make_uint3(unsigned int x, simd_uint2 yz) {
3387 simd_uint3 result;
3388 result.x = x;
3389 result.yz = yz;
3390 return result;
3391}
3392
3393/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit
3394 * unsigned integers. */
3395static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint2 xy, unsigned int z) {
3396 simd_uint3 result;
3397 result.xy = xy;
3398 result.z = z;
3399 return result;
3400}
3401
3402/*! @abstract Zero-extends `other` to form a vector of three 32-bit unsigned
3403 * integers. */
3404static inline SIMD_CFUNC simd_uint3 simd_make_uint3(unsigned int other) {
3405 simd_uint3 result = 0;
3406 result.x = other;
3407 return result;
3408}
3409
3410/*! @abstract Extends `other` to form a vector of three 32-bit unsigned
3411 * integers. The contents of the newly-created vector lanes are
3412 * unspecified. */
3413static inline SIMD_CFUNC simd_uint3 simd_make_uint3_undef(unsigned int other) {
3414 simd_uint3 result;
3415 result.x = other;
3416 return result;
3417}
3418
3419/*! @abstract Zero-extends `other` to form a vector of three 32-bit unsigned
3420 * integers. */
3421static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint2 other) {
3422 simd_uint3 result = 0;
3423 result.xy = other;
3424 return result;
3425}
3426
3427/*! @abstract Extends `other` to form a vector of three 32-bit unsigned
3428 * integers. The contents of the newly-created vector lanes are
3429 * unspecified. */
3430static inline SIMD_CFUNC simd_uint3 simd_make_uint3_undef(simd_uint2 other) {
3431 simd_uint3 result;
3432 result.xy = other;
3433 return result;
3434}
3435
3436/*! @abstract Returns `other` unmodified. This function is a convenience for
3437 * templated and autogenerated code. */
3438static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint3 other) {
3439 return other;
3440}
3441
3442/*! @abstract Truncates `other` to form a vector of three 32-bit unsigned
3443 * integers. */
3444static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint4 other) {
3445 return other.xyz;
3446}
3447
3448/*! @abstract Truncates `other` to form a vector of three 32-bit unsigned
3449 * integers. */
3450static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint8 other) {
3451 return other.xyz;
3452}
3453
3454/*! @abstract Truncates `other` to form a vector of three 32-bit unsigned
3455 * integers. */
3456static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint16 other) {
3457 return other.xyz;
3458}
3459
3460/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
3461 * 32-bit unsigned integers. */
3462static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int x, unsigned int y, unsigned int z, unsigned int w) {
3463 simd_uint4 result;
3464 result.x = x;
3465 result.y = y;
3466 result.z = z;
3467 result.w = w;
3468 return result;
3469}
3470
3471/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit
3472 * unsigned integers. */
3473static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int x, unsigned int y, simd_uint2 zw) {
3474 simd_uint4 result;
3475 result.x = x;
3476 result.y = y;
3477 result.zw = zw;
3478 return result;
3479}
3480
3481/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit
3482 * unsigned integers. */
3483static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int x, simd_uint2 yz, unsigned int w) {
3484 simd_uint4 result;
3485 result.x = x;
3486 result.yz = yz;
3487 result.w = w;
3488 return result;
3489}
3490
3491/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit
3492 * unsigned integers. */
3493static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint2 xy, unsigned int z, unsigned int w) {
3494 simd_uint4 result;
3495 result.xy = xy;
3496 result.z = z;
3497 result.w = w;
3498 return result;
3499}
3500
3501/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit
3502 * unsigned integers. */
3503static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int x, simd_uint3 yzw) {
3504 simd_uint4 result;
3505 result.x = x;
3506 result.yzw = yzw;
3507 return result;
3508}
3509
3510/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit
3511 * unsigned integers. */
3512static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint2 xy, simd_uint2 zw) {
3513 simd_uint4 result;
3514 result.xy = xy;
3515 result.zw = zw;
3516 return result;
3517}
3518
3519/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit
3520 * unsigned integers. */
3521static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint3 xyz, unsigned int w) {
3522 simd_uint4 result;
3523 result.xyz = xyz;
3524 result.w = w;
3525 return result;
3526}
3527
3528/*! @abstract Zero-extends `other` to form a vector of four 32-bit unsigned
3529 * integers. */
3530static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int other) {
3531 simd_uint4 result = 0;
3532 result.x = other;
3533 return result;
3534}
3535
3536/*! @abstract Extends `other` to form a vector of four 32-bit unsigned
3537 * integers. The contents of the newly-created vector lanes are
3538 * unspecified. */
3539static inline SIMD_CFUNC simd_uint4 simd_make_uint4_undef(unsigned int other) {
3540 simd_uint4 result;
3541 result.x = other;
3542 return result;
3543}
3544
3545/*! @abstract Zero-extends `other` to form a vector of four 32-bit unsigned
3546 * integers. */
3547static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint2 other) {
3548 simd_uint4 result = 0;
3549 result.xy = other;
3550 return result;
3551}
3552
3553/*! @abstract Extends `other` to form a vector of four 32-bit unsigned
3554 * integers. The contents of the newly-created vector lanes are
3555 * unspecified. */
3556static inline SIMD_CFUNC simd_uint4 simd_make_uint4_undef(simd_uint2 other) {
3557 simd_uint4 result;
3558 result.xy = other;
3559 return result;
3560}
3561
3562/*! @abstract Zero-extends `other` to form a vector of four 32-bit unsigned
3563 * integers. */
3564static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint3 other) {
3565 simd_uint4 result = 0;
3566 result.xyz = other;
3567 return result;
3568}
3569
3570/*! @abstract Extends `other` to form a vector of four 32-bit unsigned
3571 * integers. The contents of the newly-created vector lanes are
3572 * unspecified. */
3573static inline SIMD_CFUNC simd_uint4 simd_make_uint4_undef(simd_uint3 other) {
3574 simd_uint4 result;
3575 result.xyz = other;
3576 return result;
3577}
3578
3579/*! @abstract Returns `other` unmodified. This function is a convenience for
3580 * templated and autogenerated code. */
3581static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint4 other) {
3582 return other;
3583}
3584
3585/*! @abstract Truncates `other` to form a vector of four 32-bit unsigned
3586 * integers. */
3587static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint8 other) {
3588 return other.xyzw;
3589}
3590
3591/*! @abstract Truncates `other` to form a vector of four 32-bit unsigned
3592 * integers. */
3593static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint16 other) {
3594 return other.xyzw;
3595}
3596
3597/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit
3598 * unsigned integers. */
3599static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint4 lo, simd_uint4 hi) {
3600 simd_uint8 result;
3601 result.lo = lo;
3602 result.hi = hi;
3603 return result;
3604}
3605
3606/*! @abstract Zero-extends `other` to form a vector of eight 32-bit unsigned
3607 * integers. */
3608static inline SIMD_CFUNC simd_uint8 simd_make_uint8(unsigned int other) {
3609 simd_uint8 result = 0;
3610 result.x = other;
3611 return result;
3612}
3613
3614/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned
3615 * integers. The contents of the newly-created vector lanes are
3616 * unspecified. */
3617static inline SIMD_CFUNC simd_uint8 simd_make_uint8_undef(unsigned int other) {
3618 simd_uint8 result;
3619 result.x = other;
3620 return result;
3621}
3622
3623/*! @abstract Zero-extends `other` to form a vector of eight 32-bit unsigned
3624 * integers. */
3625static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint2 other) {
3626 simd_uint8 result = 0;
3627 result.xy = other;
3628 return result;
3629}
3630
3631/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned
3632 * integers. The contents of the newly-created vector lanes are
3633 * unspecified. */
3634static inline SIMD_CFUNC simd_uint8 simd_make_uint8_undef(simd_uint2 other) {
3635 simd_uint8 result;
3636 result.xy = other;
3637 return result;
3638}
3639
3640/*! @abstract Zero-extends `other` to form a vector of eight 32-bit unsigned
3641 * integers. */
3642static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint3 other) {
3643 simd_uint8 result = 0;
3644 result.xyz = other;
3645 return result;
3646}
3647
3648/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned
3649 * integers. The contents of the newly-created vector lanes are
3650 * unspecified. */
3651static inline SIMD_CFUNC simd_uint8 simd_make_uint8_undef(simd_uint3 other) {
3652 simd_uint8 result;
3653 result.xyz = other;
3654 return result;
3655}
3656
3657/*! @abstract Zero-extends `other` to form a vector of eight 32-bit unsigned
3658 * integers. */
3659static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint4 other) {
3660 simd_uint8 result = 0;
3661 result.xyzw = other;
3662 return result;
3663}
3664
3665/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned
3666 * integers. The contents of the newly-created vector lanes are
3667 * unspecified. */
3668static inline SIMD_CFUNC simd_uint8 simd_make_uint8_undef(simd_uint4 other) {
3669 simd_uint8 result;
3670 result.xyzw = other;
3671 return result;
3672}
3673
3674/*! @abstract Returns `other` unmodified. This function is a convenience for
3675 * templated and autogenerated code. */
3676static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint8 other) {
3677 return other;
3678}
3679
3680/*! @abstract Truncates `other` to form a vector of eight 32-bit unsigned
3681 * integers. */
3682static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint16 other) {
3683 return simd_make_uint8(other.lo);
3684}
3685
3686/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit
3687 * unsigned integers. */
3688static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint8 lo, simd_uint8 hi) {
3689 simd_uint16 result;
3690 result.lo = lo;
3691 result.hi = hi;
3692 return result;
3693}
3694
3695/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
3696 * unsigned integers. */
3697static inline SIMD_CFUNC simd_uint16 simd_make_uint16(unsigned int other) {
3698 simd_uint16 result = 0;
3699 result.x = other;
3700 return result;
3701}
3702
3703/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned
3704 * integers. The contents of the newly-created vector lanes are
3705 * unspecified. */
3706static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(unsigned int other) {
3707 simd_uint16 result;
3708 result.x = other;
3709 return result;
3710}
3711
3712/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
3713 * unsigned integers. */
3714static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint2 other) {
3715 simd_uint16 result = 0;
3716 result.xy = other;
3717 return result;
3718}
3719
3720/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned
3721 * integers. The contents of the newly-created vector lanes are
3722 * unspecified. */
3723static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(simd_uint2 other) {
3724 simd_uint16 result;
3725 result.xy = other;
3726 return result;
3727}
3728
3729/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
3730 * unsigned integers. */
3731static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint3 other) {
3732 simd_uint16 result = 0;
3733 result.xyz = other;
3734 return result;
3735}
3736
3737/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned
3738 * integers. The contents of the newly-created vector lanes are
3739 * unspecified. */
3740static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(simd_uint3 other) {
3741 simd_uint16 result;
3742 result.xyz = other;
3743 return result;
3744}
3745
3746/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
3747 * unsigned integers. */
3748static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint4 other) {
3749 simd_uint16 result = 0;
3750 result.xyzw = other;
3751 return result;
3752}
3753
3754/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned
3755 * integers. The contents of the newly-created vector lanes are
3756 * unspecified. */
3757static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(simd_uint4 other) {
3758 simd_uint16 result;
3759 result.xyzw = other;
3760 return result;
3761}
3762
3763/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
3764 * unsigned integers. */
3765static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint8 other) {
3766 simd_uint16 result = 0;
3767 result.lo = simd_make_uint8(other);
3768 return result;
3769}
3770
3771/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned
3772 * integers. The contents of the newly-created vector lanes are
3773 * unspecified. */
3774static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(simd_uint8 other) {
3775 simd_uint16 result;
3776 result.lo = simd_make_uint8(other);
3777 return result;
3778}
3779
3780/*! @abstract Returns `other` unmodified. This function is a convenience for
3781 * templated and autogenerated code. */
3782static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint16 other) {
3783 return other;
3784}
3785
3786/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit
3787 * floating-point numbers. */
3788static inline SIMD_CFUNC simd_float2 simd_make_float2(float x, float y) {
3789 simd_float2 result;
3790 result.x = x;
3791 result.y = y;
3792 return result;
3793}
3794
3795/*! @abstract Zero-extends `other` to form a vector of two 32-bit floating-
3796 * point numbers. */
3797static inline SIMD_CFUNC simd_float2 simd_make_float2(float other) {
3798 simd_float2 result = 0;
3799 result.x = other;
3800 return result;
3801}
3802
3803/*! @abstract Extends `other` to form a vector of two 32-bit floating-point
3804 * numbers. The contents of the newly-created vector lanes are unspecified. */
3805static inline SIMD_CFUNC simd_float2 simd_make_float2_undef(float other) {
3806 simd_float2 result;
3807 result.x = other;
3808 return result;
3809}
3810
3811/*! @abstract Returns `other` unmodified. This function is a convenience for
3812 * templated and autogenerated code. */
3813static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float2 other) {
3814 return other;
3815}
3816
3817/*! @abstract Truncates `other` to form a vector of two 32-bit floating-
3818 * point numbers. */
3819static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float3 other) {
3820 return other.xy;
3821}
3822
3823/*! @abstract Truncates `other` to form a vector of two 32-bit floating-
3824 * point numbers. */
3825static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float4 other) {
3826 return other.xy;
3827}
3828
3829/*! @abstract Truncates `other` to form a vector of two 32-bit floating-
3830 * point numbers. */
3831static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float8 other) {
3832 return other.xy;
3833}
3834
3835/*! @abstract Truncates `other` to form a vector of two 32-bit floating-
3836 * point numbers. */
3837static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float16 other) {
3838 return other.xy;
3839}
3840
3841/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit
3842 * floating-point numbers. */
3843static inline SIMD_CFUNC simd_float3 simd_make_float3(float x, float y, float z) {
3844 simd_float3 result;
3845 result.x = x;
3846 result.y = y;
3847 result.z = z;
3848 return result;
3849}
3850
3851/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit
3852 * floating-point numbers. */
3853static inline SIMD_CFUNC simd_float3 simd_make_float3(float x, simd_float2 yz) {
3854 simd_float3 result;
3855 result.x = x;
3856 result.yz = yz;
3857 return result;
3858}
3859
3860/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit
3861 * floating-point numbers. */
3862static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float2 xy, float z) {
3863 simd_float3 result;
3864 result.xy = xy;
3865 result.z = z;
3866 return result;
3867}
3868
3869/*! @abstract Zero-extends `other` to form a vector of three 32-bit
3870 * floating-point numbers. */
3871static inline SIMD_CFUNC simd_float3 simd_make_float3(float other) {
3872 simd_float3 result = 0;
3873 result.x = other;
3874 return result;
3875}
3876
3877/*! @abstract Extends `other` to form a vector of three 32-bit floating-
3878 * point numbers. The contents of the newly-created vector lanes are
3879 * unspecified. */
3880static inline SIMD_CFUNC simd_float3 simd_make_float3_undef(float other) {
3881 simd_float3 result;
3882 result.x = other;
3883 return result;
3884}
3885
3886/*! @abstract Zero-extends `other` to form a vector of three 32-bit
3887 * floating-point numbers. */
3888static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float2 other) {
3889 simd_float3 result = 0;
3890 result.xy = other;
3891 return result;
3892}
3893
3894/*! @abstract Extends `other` to form a vector of three 32-bit floating-
3895 * point numbers. The contents of the newly-created vector lanes are
3896 * unspecified. */
3897static inline SIMD_CFUNC simd_float3 simd_make_float3_undef(simd_float2 other) {
3898 simd_float3 result;
3899 result.xy = other;
3900 return result;
3901}
3902
3903/*! @abstract Returns `other` unmodified. This function is a convenience for
3904 * templated and autogenerated code. */
3905static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float3 other) {
3906 return other;
3907}
3908
3909/*! @abstract Truncates `other` to form a vector of three 32-bit floating-
3910 * point numbers. */
3911static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float4 other) {
3912 return other.xyz;
3913}
3914
3915/*! @abstract Truncates `other` to form a vector of three 32-bit floating-
3916 * point numbers. */
3917static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float8 other) {
3918 return other.xyz;
3919}
3920
3921/*! @abstract Truncates `other` to form a vector of three 32-bit floating-
3922 * point numbers. */
3923static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float16 other) {
3924 return other.xyz;
3925}
3926
3927/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
3928 * 32-bit floating-point numbers. */
3929static inline SIMD_CFUNC simd_float4 simd_make_float4(float x, float y, float z, float w) {
3930 simd_float4 result;
3931 result.x = x;
3932 result.y = y;
3933 result.z = z;
3934 result.w = w;
3935 return result;
3936}
3937
3938/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit
3939 * floating-point numbers. */
3940static inline SIMD_CFUNC simd_float4 simd_make_float4(float x, float y, simd_float2 zw) {
3941 simd_float4 result;
3942 result.x = x;
3943 result.y = y;
3944 result.zw = zw;
3945 return result;
3946}
3947
3948/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit
3949 * floating-point numbers. */
3950static inline SIMD_CFUNC simd_float4 simd_make_float4(float x, simd_float2 yz, float w) {
3951 simd_float4 result;
3952 result.x = x;
3953 result.yz = yz;
3954 result.w = w;
3955 return result;
3956}
3957
3958/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit
3959 * floating-point numbers. */
3960static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float2 xy, float z, float w) {
3961 simd_float4 result;
3962 result.xy = xy;
3963 result.z = z;
3964 result.w = w;
3965 return result;
3966}
3967
3968/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit
3969 * floating-point numbers. */
3970static inline SIMD_CFUNC simd_float4 simd_make_float4(float x, simd_float3 yzw) {
3971 simd_float4 result;
3972 result.x = x;
3973 result.yzw = yzw;
3974 return result;
3975}
3976
3977/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit
3978 * floating-point numbers. */
3979static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float2 xy, simd_float2 zw) {
3980 simd_float4 result;
3981 result.xy = xy;
3982 result.zw = zw;
3983 return result;
3984}
3985
3986/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit
3987 * floating-point numbers. */
3988static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float3 xyz, float w) {
3989 simd_float4 result;
3990 result.xyz = xyz;
3991 result.w = w;
3992 return result;
3993}
3994
3995/*! @abstract Zero-extends `other` to form a vector of four 32-bit floating-
3996 * point numbers. */
3997static inline SIMD_CFUNC simd_float4 simd_make_float4(float other) {
3998 simd_float4 result = 0;
3999 result.x = other;
4000 return result;
4001}
4002
4003/*! @abstract Extends `other` to form a vector of four 32-bit floating-point
4004 * numbers. The contents of the newly-created vector lanes are unspecified. */
4005static inline SIMD_CFUNC simd_float4 simd_make_float4_undef(float other) {
4006 simd_float4 result;
4007 result.x = other;
4008 return result;
4009}
4010
4011/*! @abstract Zero-extends `other` to form a vector of four 32-bit floating-
4012 * point numbers. */
4013static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float2 other) {
4014 simd_float4 result = 0;
4015 result.xy = other;
4016 return result;
4017}
4018
4019/*! @abstract Extends `other` to form a vector of four 32-bit floating-point
4020 * numbers. The contents of the newly-created vector lanes are unspecified. */
4021static inline SIMD_CFUNC simd_float4 simd_make_float4_undef(simd_float2 other) {
4022 simd_float4 result;
4023 result.xy = other;
4024 return result;
4025}
4026
4027/*! @abstract Zero-extends `other` to form a vector of four 32-bit floating-
4028 * point numbers. */
4029static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float3 other) {
4030 simd_float4 result = 0;
4031 result.xyz = other;
4032 return result;
4033}
4034
4035/*! @abstract Extends `other` to form a vector of four 32-bit floating-point
4036 * numbers. The contents of the newly-created vector lanes are unspecified. */
4037static inline SIMD_CFUNC simd_float4 simd_make_float4_undef(simd_float3 other) {
4038 simd_float4 result;
4039 result.xyz = other;
4040 return result;
4041}
4042
4043/*! @abstract Returns `other` unmodified. This function is a convenience for
4044 * templated and autogenerated code. */
4045static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float4 other) {
4046 return other;
4047}
4048
4049/*! @abstract Truncates `other` to form a vector of four 32-bit floating-
4050 * point numbers. */
4051static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float8 other) {
4052 return other.xyzw;
4053}
4054
4055/*! @abstract Truncates `other` to form a vector of four 32-bit floating-
4056 * point numbers. */
4057static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float16 other) {
4058 return other.xyzw;
4059}
4060
4061/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit
4062 * floating-point numbers. */
4063static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float4 lo, simd_float4 hi) {
4064 simd_float8 result;
4065 result.lo = lo;
4066 result.hi = hi;
4067 return result;
4068}
4069
4070/*! @abstract Zero-extends `other` to form a vector of eight 32-bit
4071 * floating-point numbers. */
4072static inline SIMD_CFUNC simd_float8 simd_make_float8(float other) {
4073 simd_float8 result = 0;
4074 result.x = other;
4075 return result;
4076}
4077
4078/*! @abstract Extends `other` to form a vector of eight 32-bit floating-
4079 * point numbers. The contents of the newly-created vector lanes are
4080 * unspecified. */
4081static inline SIMD_CFUNC simd_float8 simd_make_float8_undef(float other) {
4082 simd_float8 result;
4083 result.x = other;
4084 return result;
4085}
4086
4087/*! @abstract Zero-extends `other` to form a vector of eight 32-bit
4088 * floating-point numbers. */
4089static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float2 other) {
4090 simd_float8 result = 0;
4091 result.xy = other;
4092 return result;
4093}
4094
4095/*! @abstract Extends `other` to form a vector of eight 32-bit floating-
4096 * point numbers. The contents of the newly-created vector lanes are
4097 * unspecified. */
4098static inline SIMD_CFUNC simd_float8 simd_make_float8_undef(simd_float2 other) {
4099 simd_float8 result;
4100 result.xy = other;
4101 return result;
4102}
4103
4104/*! @abstract Zero-extends `other` to form a vector of eight 32-bit
4105 * floating-point numbers. */
4106static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float3 other) {
4107 simd_float8 result = 0;
4108 result.xyz = other;
4109 return result;
4110}
4111
4112/*! @abstract Extends `other` to form a vector of eight 32-bit floating-
4113 * point numbers. The contents of the newly-created vector lanes are
4114 * unspecified. */
4115static inline SIMD_CFUNC simd_float8 simd_make_float8_undef(simd_float3 other) {
4116 simd_float8 result;
4117 result.xyz = other;
4118 return result;
4119}
4120
4121/*! @abstract Zero-extends `other` to form a vector of eight 32-bit
4122 * floating-point numbers. */
4123static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float4 other) {
4124 simd_float8 result = 0;
4125 result.xyzw = other;
4126 return result;
4127}
4128
4129/*! @abstract Extends `other` to form a vector of eight 32-bit floating-
4130 * point numbers. The contents of the newly-created vector lanes are
4131 * unspecified. */
4132static inline SIMD_CFUNC simd_float8 simd_make_float8_undef(simd_float4 other) {
4133 simd_float8 result;
4134 result.xyzw = other;
4135 return result;
4136}
4137
4138/*! @abstract Returns `other` unmodified. This function is a convenience for
4139 * templated and autogenerated code. */
4140static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float8 other) {
4141 return other;
4142}
4143
4144/*! @abstract Truncates `other` to form a vector of eight 32-bit floating-
4145 * point numbers. */
4146static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float16 other) {
4147 return simd_make_float8(other.lo);
4148}
4149
4150/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit
4151 * floating-point numbers. */
4152static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float8 lo, simd_float8 hi) {
4153 simd_float16 result;
4154 result.lo = lo;
4155 result.hi = hi;
4156 return result;
4157}
4158
4159/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
4160 * floating-point numbers. */
4161static inline SIMD_CFUNC simd_float16 simd_make_float16(float other) {
4162 simd_float16 result = 0;
4163 result.x = other;
4164 return result;
4165}
4166
4167/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating-
4168 * point numbers. The contents of the newly-created vector lanes are
4169 * unspecified. */
4170static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(float other) {
4171 simd_float16 result;
4172 result.x = other;
4173 return result;
4174}
4175
4176/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
4177 * floating-point numbers. */
4178static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float2 other) {
4179 simd_float16 result = 0;
4180 result.xy = other;
4181 return result;
4182}
4183
4184/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating-
4185 * point numbers. The contents of the newly-created vector lanes are
4186 * unspecified. */
4187static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(simd_float2 other) {
4188 simd_float16 result;
4189 result.xy = other;
4190 return result;
4191}
4192
4193/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
4194 * floating-point numbers. */
4195static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float3 other) {
4196 simd_float16 result = 0;
4197 result.xyz = other;
4198 return result;
4199}
4200
4201/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating-
4202 * point numbers. The contents of the newly-created vector lanes are
4203 * unspecified. */
4204static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(simd_float3 other) {
4205 simd_float16 result;
4206 result.xyz = other;
4207 return result;
4208}
4209
4210/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
4211 * floating-point numbers. */
4212static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float4 other) {
4213 simd_float16 result = 0;
4214 result.xyzw = other;
4215 return result;
4216}
4217
4218/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating-
4219 * point numbers. The contents of the newly-created vector lanes are
4220 * unspecified. */
4221static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(simd_float4 other) {
4222 simd_float16 result;
4223 result.xyzw = other;
4224 return result;
4225}
4226
4227/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit
4228 * floating-point numbers. */
4229static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float8 other) {
4230 simd_float16 result = 0;
4231 result.lo = simd_make_float8(other);
4232 return result;
4233}
4234
4235/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating-
4236 * point numbers. The contents of the newly-created vector lanes are
4237 * unspecified. */
4238static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(simd_float8 other) {
4239 simd_float16 result;
4240 result.lo = simd_make_float8(other);
4241 return result;
4242}
4243
4244/*! @abstract Returns `other` unmodified. This function is a convenience for
4245 * templated and autogenerated code. */
4246static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float16 other) {
4247 return other;
4248}
4249
4250/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit signed
4251 * (twos-complement) integers. */
4252static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long1 x, simd_long1 y) {
4253 simd_long2 result;
4254 result.x = x;
4255 result.y = y;
4256 return result;
4257}
4258
4259/*! @abstract Zero-extends `other` to form a vector of two 64-bit signed
4260 * (twos-complement) integers. */
4261static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long1 other) {
4262 simd_long2 result = 0;
4263 result.x = other;
4264 return result;
4265}
4266
4267/*! @abstract Extends `other` to form a vector of two 64-bit signed (twos-
4268 * complement) integers. The contents of the newly-created vector lanes are
4269 * unspecified. */
4270static inline SIMD_CFUNC simd_long2 simd_make_long2_undef(simd_long1 other) {
4271 simd_long2 result;
4272 result.x = other;
4273 return result;
4274}
4275
4276/*! @abstract Returns `other` unmodified. This function is a convenience for
4277 * templated and autogenerated code. */
4278static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long2 other) {
4279 return other;
4280}
4281
4282/*! @abstract Truncates `other` to form a vector of two 64-bit signed (twos-
4283 * complement) integers. */
4284static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long3 other) {
4285 return other.xy;
4286}
4287
4288/*! @abstract Truncates `other` to form a vector of two 64-bit signed (twos-
4289 * complement) integers. */
4290static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long4 other) {
4291 return other.xy;
4292}
4293
4294/*! @abstract Truncates `other` to form a vector of two 64-bit signed (twos-
4295 * complement) integers. */
4296static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long8 other) {
4297 return other.xy;
4298}
4299
4300/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit
4301 * signed (twos-complement) integers. */
4302static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long1 x, simd_long1 y, simd_long1 z) {
4303 simd_long3 result;
4304 result.x = x;
4305 result.y = y;
4306 result.z = z;
4307 return result;
4308}
4309
4310/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit
4311 * signed (twos-complement) integers. */
4312static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long1 x, simd_long2 yz) {
4313 simd_long3 result;
4314 result.x = x;
4315 result.yz = yz;
4316 return result;
4317}
4318
4319/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit
4320 * signed (twos-complement) integers. */
4321static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long2 xy, simd_long1 z) {
4322 simd_long3 result;
4323 result.xy = xy;
4324 result.z = z;
4325 return result;
4326}
4327
4328/*! @abstract Zero-extends `other` to form a vector of three 64-bit signed
4329 * (twos-complement) integers. */
4330static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long1 other) {
4331 simd_long3 result = 0;
4332 result.x = other;
4333 return result;
4334}
4335
4336/*! @abstract Extends `other` to form a vector of three 64-bit signed (twos-
4337 * complement) integers. The contents of the newly-created vector lanes are
4338 * unspecified. */
4339static inline SIMD_CFUNC simd_long3 simd_make_long3_undef(simd_long1 other) {
4340 simd_long3 result;
4341 result.x = other;
4342 return result;
4343}
4344
4345/*! @abstract Zero-extends `other` to form a vector of three 64-bit signed
4346 * (twos-complement) integers. */
4347static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long2 other) {
4348 simd_long3 result = 0;
4349 result.xy = other;
4350 return result;
4351}
4352
4353/*! @abstract Extends `other` to form a vector of three 64-bit signed (twos-
4354 * complement) integers. The contents of the newly-created vector lanes are
4355 * unspecified. */
4356static inline SIMD_CFUNC simd_long3 simd_make_long3_undef(simd_long2 other) {
4357 simd_long3 result;
4358 result.xy = other;
4359 return result;
4360}
4361
4362/*! @abstract Returns `other` unmodified. This function is a convenience for
4363 * templated and autogenerated code. */
4364static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long3 other) {
4365 return other;
4366}
4367
4368/*! @abstract Truncates `other` to form a vector of three 64-bit signed
4369 * (twos-complement) integers. */
4370static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long4 other) {
4371 return other.xyz;
4372}
4373
4374/*! @abstract Truncates `other` to form a vector of three 64-bit signed
4375 * (twos-complement) integers. */
4376static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long8 other) {
4377 return other.xyz;
4378}
4379
4380/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
4381 * 64-bit signed (twos-complement) integers. */
4382static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 x, simd_long1 y, simd_long1 z, simd_long1 w) {
4383 simd_long4 result;
4384 result.x = x;
4385 result.y = y;
4386 result.z = z;
4387 result.w = w;
4388 return result;
4389}
4390
4391/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit
4392 * signed (twos-complement) integers. */
4393static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 x, simd_long1 y, simd_long2 zw) {
4394 simd_long4 result;
4395 result.x = x;
4396 result.y = y;
4397 result.zw = zw;
4398 return result;
4399}
4400
4401/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit
4402 * signed (twos-complement) integers. */
4403static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 x, simd_long2 yz, simd_long1 w) {
4404 simd_long4 result;
4405 result.x = x;
4406 result.yz = yz;
4407 result.w = w;
4408 return result;
4409}
4410
4411/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit
4412 * signed (twos-complement) integers. */
4413static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long2 xy, simd_long1 z, simd_long1 w) {
4414 simd_long4 result;
4415 result.xy = xy;
4416 result.z = z;
4417 result.w = w;
4418 return result;
4419}
4420
4421/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit
4422 * signed (twos-complement) integers. */
4423static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 x, simd_long3 yzw) {
4424 simd_long4 result;
4425 result.x = x;
4426 result.yzw = yzw;
4427 return result;
4428}
4429
4430/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit
4431 * signed (twos-complement) integers. */
4432static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long2 xy, simd_long2 zw) {
4433 simd_long4 result;
4434 result.xy = xy;
4435 result.zw = zw;
4436 return result;
4437}
4438
4439/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit
4440 * signed (twos-complement) integers. */
4441static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long3 xyz, simd_long1 w) {
4442 simd_long4 result;
4443 result.xyz = xyz;
4444 result.w = w;
4445 return result;
4446}
4447
4448/*! @abstract Zero-extends `other` to form a vector of four 64-bit signed
4449 * (twos-complement) integers. */
4450static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 other) {
4451 simd_long4 result = 0;
4452 result.x = other;
4453 return result;
4454}
4455
4456/*! @abstract Extends `other` to form a vector of four 64-bit signed (twos-
4457 * complement) integers. The contents of the newly-created vector lanes are
4458 * unspecified. */
4459static inline SIMD_CFUNC simd_long4 simd_make_long4_undef(simd_long1 other) {
4460 simd_long4 result;
4461 result.x = other;
4462 return result;
4463}
4464
4465/*! @abstract Zero-extends `other` to form a vector of four 64-bit signed
4466 * (twos-complement) integers. */
4467static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long2 other) {
4468 simd_long4 result = 0;
4469 result.xy = other;
4470 return result;
4471}
4472
4473/*! @abstract Extends `other` to form a vector of four 64-bit signed (twos-
4474 * complement) integers. The contents of the newly-created vector lanes are
4475 * unspecified. */
4476static inline SIMD_CFUNC simd_long4 simd_make_long4_undef(simd_long2 other) {
4477 simd_long4 result;
4478 result.xy = other;
4479 return result;
4480}
4481
4482/*! @abstract Zero-extends `other` to form a vector of four 64-bit signed
4483 * (twos-complement) integers. */
4484static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long3 other) {
4485 simd_long4 result = 0;
4486 result.xyz = other;
4487 return result;
4488}
4489
4490/*! @abstract Extends `other` to form a vector of four 64-bit signed (twos-
4491 * complement) integers. The contents of the newly-created vector lanes are
4492 * unspecified. */
4493static inline SIMD_CFUNC simd_long4 simd_make_long4_undef(simd_long3 other) {
4494 simd_long4 result;
4495 result.xyz = other;
4496 return result;
4497}
4498
4499/*! @abstract Returns `other` unmodified. This function is a convenience for
4500 * templated and autogenerated code. */
4501static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long4 other) {
4502 return other;
4503}
4504
4505/*! @abstract Truncates `other` to form a vector of four 64-bit signed
4506 * (twos-complement) integers. */
4507static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long8 other) {
4508 return other.xyzw;
4509}
4510
4511/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit
4512 * signed (twos-complement) integers. */
4513static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long4 lo, simd_long4 hi) {
4514 simd_long8 result;
4515 result.lo = lo;
4516 result.hi = hi;
4517 return result;
4518}
4519
4520/*! @abstract Zero-extends `other` to form a vector of eight 64-bit signed
4521 * (twos-complement) integers. */
4522static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long1 other) {
4523 simd_long8 result = 0;
4524 result.x = other;
4525 return result;
4526}
4527
4528/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos-
4529 * complement) integers. The contents of the newly-created vector lanes are
4530 * unspecified. */
4531static inline SIMD_CFUNC simd_long8 simd_make_long8_undef(simd_long1 other) {
4532 simd_long8 result;
4533 result.x = other;
4534 return result;
4535}
4536
4537/*! @abstract Zero-extends `other` to form a vector of eight 64-bit signed
4538 * (twos-complement) integers. */
4539static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long2 other) {
4540 simd_long8 result = 0;
4541 result.xy = other;
4542 return result;
4543}
4544
4545/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos-
4546 * complement) integers. The contents of the newly-created vector lanes are
4547 * unspecified. */
4548static inline SIMD_CFUNC simd_long8 simd_make_long8_undef(simd_long2 other) {
4549 simd_long8 result;
4550 result.xy = other;
4551 return result;
4552}
4553
4554/*! @abstract Zero-extends `other` to form a vector of eight 64-bit signed
4555 * (twos-complement) integers. */
4556static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long3 other) {
4557 simd_long8 result = 0;
4558 result.xyz = other;
4559 return result;
4560}
4561
4562/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos-
4563 * complement) integers. The contents of the newly-created vector lanes are
4564 * unspecified. */
4565static inline SIMD_CFUNC simd_long8 simd_make_long8_undef(simd_long3 other) {
4566 simd_long8 result;
4567 result.xyz = other;
4568 return result;
4569}
4570
4571/*! @abstract Zero-extends `other` to form a vector of eight 64-bit signed
4572 * (twos-complement) integers. */
4573static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long4 other) {
4574 simd_long8 result = 0;
4575 result.xyzw = other;
4576 return result;
4577}
4578
4579/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos-
4580 * complement) integers. The contents of the newly-created vector lanes are
4581 * unspecified. */
4582static inline SIMD_CFUNC simd_long8 simd_make_long8_undef(simd_long4 other) {
4583 simd_long8 result;
4584 result.xyzw = other;
4585 return result;
4586}
4587
4588/*! @abstract Returns `other` unmodified. This function is a convenience for
4589 * templated and autogenerated code. */
4590static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long8 other) {
4591 return other;
4592}
4593
4594/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit
4595 * unsigned integers. */
4596static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong1 x, simd_ulong1 y) {
4597 simd_ulong2 result;
4598 result.x = x;
4599 result.y = y;
4600 return result;
4601}
4602
4603/*! @abstract Zero-extends `other` to form a vector of two 64-bit unsigned
4604 * integers. */
4605static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong1 other) {
4606 simd_ulong2 result = 0;
4607 result.x = other;
4608 return result;
4609}
4610
4611/*! @abstract Extends `other` to form a vector of two 64-bit unsigned
4612 * integers. The contents of the newly-created vector lanes are
4613 * unspecified. */
4614static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2_undef(simd_ulong1 other) {
4615 simd_ulong2 result;
4616 result.x = other;
4617 return result;
4618}
4619
4620/*! @abstract Returns `other` unmodified. This function is a convenience for
4621 * templated and autogenerated code. */
4622static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong2 other) {
4623 return other;
4624}
4625
4626/*! @abstract Truncates `other` to form a vector of two 64-bit unsigned
4627 * integers. */
4628static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong3 other) {
4629 return other.xy;
4630}
4631
4632/*! @abstract Truncates `other` to form a vector of two 64-bit unsigned
4633 * integers. */
4634static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong4 other) {
4635 return other.xy;
4636}
4637
4638/*! @abstract Truncates `other` to form a vector of two 64-bit unsigned
4639 * integers. */
4640static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong8 other) {
4641 return other.xy;
4642}
4643
4644/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit
4645 * unsigned integers. */
4646static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong1 x, simd_ulong1 y, simd_ulong1 z) {
4647 simd_ulong3 result;
4648 result.x = x;
4649 result.y = y;
4650 result.z = z;
4651 return result;
4652}
4653
4654/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit
4655 * unsigned integers. */
4656static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong1 x, simd_ulong2 yz) {
4657 simd_ulong3 result;
4658 result.x = x;
4659 result.yz = yz;
4660 return result;
4661}
4662
4663/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit
4664 * unsigned integers. */
4665static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong2 xy, simd_ulong1 z) {
4666 simd_ulong3 result;
4667 result.xy = xy;
4668 result.z = z;
4669 return result;
4670}
4671
4672/*! @abstract Zero-extends `other` to form a vector of three 64-bit unsigned
4673 * integers. */
4674static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong1 other) {
4675 simd_ulong3 result = 0;
4676 result.x = other;
4677 return result;
4678}
4679
4680/*! @abstract Extends `other` to form a vector of three 64-bit unsigned
4681 * integers. The contents of the newly-created vector lanes are
4682 * unspecified. */
4683static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3_undef(simd_ulong1 other) {
4684 simd_ulong3 result;
4685 result.x = other;
4686 return result;
4687}
4688
4689/*! @abstract Zero-extends `other` to form a vector of three 64-bit unsigned
4690 * integers. */
4691static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong2 other) {
4692 simd_ulong3 result = 0;
4693 result.xy = other;
4694 return result;
4695}
4696
4697/*! @abstract Extends `other` to form a vector of three 64-bit unsigned
4698 * integers. The contents of the newly-created vector lanes are
4699 * unspecified. */
4700static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3_undef(simd_ulong2 other) {
4701 simd_ulong3 result;
4702 result.xy = other;
4703 return result;
4704}
4705
4706/*! @abstract Returns `other` unmodified. This function is a convenience for
4707 * templated and autogenerated code. */
4708static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong3 other) {
4709 return other;
4710}
4711
4712/*! @abstract Truncates `other` to form a vector of three 64-bit unsigned
4713 * integers. */
4714static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong4 other) {
4715 return other.xyz;
4716}
4717
4718/*! @abstract Truncates `other` to form a vector of three 64-bit unsigned
4719 * integers. */
4720static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong8 other) {
4721 return other.xyz;
4722}
4723
4724/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
4725 * 64-bit unsigned integers. */
4726static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 x, simd_ulong1 y, simd_ulong1 z, simd_ulong1 w) {
4727 simd_ulong4 result;
4728 result.x = x;
4729 result.y = y;
4730 result.z = z;
4731 result.w = w;
4732 return result;
4733}
4734
4735/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit
4736 * unsigned integers. */
4737static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 x, simd_ulong1 y, simd_ulong2 zw) {
4738 simd_ulong4 result;
4739 result.x = x;
4740 result.y = y;
4741 result.zw = zw;
4742 return result;
4743}
4744
4745/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit
4746 * unsigned integers. */
4747static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 x, simd_ulong2 yz, simd_ulong1 w) {
4748 simd_ulong4 result;
4749 result.x = x;
4750 result.yz = yz;
4751 result.w = w;
4752 return result;
4753}
4754
4755/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit
4756 * unsigned integers. */
4757static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong2 xy, simd_ulong1 z, simd_ulong1 w) {
4758 simd_ulong4 result;
4759 result.xy = xy;
4760 result.z = z;
4761 result.w = w;
4762 return result;
4763}
4764
4765/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit
4766 * unsigned integers. */
4767static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 x, simd_ulong3 yzw) {
4768 simd_ulong4 result;
4769 result.x = x;
4770 result.yzw = yzw;
4771 return result;
4772}
4773
4774/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit
4775 * unsigned integers. */
4776static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong2 xy, simd_ulong2 zw) {
4777 simd_ulong4 result;
4778 result.xy = xy;
4779 result.zw = zw;
4780 return result;
4781}
4782
4783/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit
4784 * unsigned integers. */
4785static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong3 xyz, simd_ulong1 w) {
4786 simd_ulong4 result;
4787 result.xyz = xyz;
4788 result.w = w;
4789 return result;
4790}
4791
4792/*! @abstract Zero-extends `other` to form a vector of four 64-bit unsigned
4793 * integers. */
4794static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 other) {
4795 simd_ulong4 result = 0;
4796 result.x = other;
4797 return result;
4798}
4799
4800/*! @abstract Extends `other` to form a vector of four 64-bit unsigned
4801 * integers. The contents of the newly-created vector lanes are
4802 * unspecified. */
4803static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4_undef(simd_ulong1 other) {
4804 simd_ulong4 result;
4805 result.x = other;
4806 return result;
4807}
4808
4809/*! @abstract Zero-extends `other` to form a vector of four 64-bit unsigned
4810 * integers. */
4811static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong2 other) {
4812 simd_ulong4 result = 0;
4813 result.xy = other;
4814 return result;
4815}
4816
4817/*! @abstract Extends `other` to form a vector of four 64-bit unsigned
4818 * integers. The contents of the newly-created vector lanes are
4819 * unspecified. */
4820static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4_undef(simd_ulong2 other) {
4821 simd_ulong4 result;
4822 result.xy = other;
4823 return result;
4824}
4825
4826/*! @abstract Zero-extends `other` to form a vector of four 64-bit unsigned
4827 * integers. */
4828static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong3 other) {
4829 simd_ulong4 result = 0;
4830 result.xyz = other;
4831 return result;
4832}
4833
4834/*! @abstract Extends `other` to form a vector of four 64-bit unsigned
4835 * integers. The contents of the newly-created vector lanes are
4836 * unspecified. */
4837static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4_undef(simd_ulong3 other) {
4838 simd_ulong4 result;
4839 result.xyz = other;
4840 return result;
4841}
4842
4843/*! @abstract Returns `other` unmodified. This function is a convenience for
4844 * templated and autogenerated code. */
4845static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong4 other) {
4846 return other;
4847}
4848
4849/*! @abstract Truncates `other` to form a vector of four 64-bit unsigned
4850 * integers. */
4851static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong8 other) {
4852 return other.xyzw;
4853}
4854
4855/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit
4856 * unsigned integers. */
4857static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong4 lo, simd_ulong4 hi) {
4858 simd_ulong8 result;
4859 result.lo = lo;
4860 result.hi = hi;
4861 return result;
4862}
4863
4864/*! @abstract Zero-extends `other` to form a vector of eight 64-bit unsigned
4865 * integers. */
4866static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong1 other) {
4867 simd_ulong8 result = 0;
4868 result.x = other;
4869 return result;
4870}
4871
4872/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned
4873 * integers. The contents of the newly-created vector lanes are
4874 * unspecified. */
4875static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8_undef(simd_ulong1 other) {
4876 simd_ulong8 result;
4877 result.x = other;
4878 return result;
4879}
4880
4881/*! @abstract Zero-extends `other` to form a vector of eight 64-bit unsigned
4882 * integers. */
4883static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong2 other) {
4884 simd_ulong8 result = 0;
4885 result.xy = other;
4886 return result;
4887}
4888
4889/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned
4890 * integers. The contents of the newly-created vector lanes are
4891 * unspecified. */
4892static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8_undef(simd_ulong2 other) {
4893 simd_ulong8 result;
4894 result.xy = other;
4895 return result;
4896}
4897
4898/*! @abstract Zero-extends `other` to form a vector of eight 64-bit unsigned
4899 * integers. */
4900static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong3 other) {
4901 simd_ulong8 result = 0;
4902 result.xyz = other;
4903 return result;
4904}
4905
4906/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned
4907 * integers. The contents of the newly-created vector lanes are
4908 * unspecified. */
4909static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8_undef(simd_ulong3 other) {
4910 simd_ulong8 result;
4911 result.xyz = other;
4912 return result;
4913}
4914
4915/*! @abstract Zero-extends `other` to form a vector of eight 64-bit unsigned
4916 * integers. */
4917static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong4 other) {
4918 simd_ulong8 result = 0;
4919 result.xyzw = other;
4920 return result;
4921}
4922
4923/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned
4924 * integers. The contents of the newly-created vector lanes are
4925 * unspecified. */
4926static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8_undef(simd_ulong4 other) {
4927 simd_ulong8 result;
4928 result.xyzw = other;
4929 return result;
4930}
4931
4932/*! @abstract Returns `other` unmodified. This function is a convenience for
4933 * templated and autogenerated code. */
4934static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong8 other) {
4935 return other;
4936}
4937
4938/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit
4939 * floating-point numbers. */
4940static inline SIMD_CFUNC simd_double2 simd_make_double2(double x, double y) {
4941 simd_double2 result;
4942 result.x = x;
4943 result.y = y;
4944 return result;
4945}
4946
4947/*! @abstract Zero-extends `other` to form a vector of two 64-bit floating-
4948 * point numbers. */
4949static inline SIMD_CFUNC simd_double2 simd_make_double2(double other) {
4950 simd_double2 result = 0;
4951 result.x = other;
4952 return result;
4953}
4954
4955/*! @abstract Extends `other` to form a vector of two 64-bit floating-point
4956 * numbers. The contents of the newly-created vector lanes are unspecified. */
4957static inline SIMD_CFUNC simd_double2 simd_make_double2_undef(double other) {
4958 simd_double2 result;
4959 result.x = other;
4960 return result;
4961}
4962
4963/*! @abstract Returns `other` unmodified. This function is a convenience for
4964 * templated and autogenerated code. */
4965static inline SIMD_CFUNC simd_double2 simd_make_double2(simd_double2 other) {
4966 return other;
4967}
4968
4969/*! @abstract Truncates `other` to form a vector of two 64-bit floating-
4970 * point numbers. */
4971static inline SIMD_CFUNC simd_double2 simd_make_double2(simd_double3 other) {
4972 return other.xy;
4973}
4974
4975/*! @abstract Truncates `other` to form a vector of two 64-bit floating-
4976 * point numbers. */
4977static inline SIMD_CFUNC simd_double2 simd_make_double2(simd_double4 other) {
4978 return other.xy;
4979}
4980
4981/*! @abstract Truncates `other` to form a vector of two 64-bit floating-
4982 * point numbers. */
4983static inline SIMD_CFUNC simd_double2 simd_make_double2(simd_double8 other) {
4984 return other.xy;
4985}
4986
4987/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit
4988 * floating-point numbers. */
4989static inline SIMD_CFUNC simd_double3 simd_make_double3(double x, double y, double z) {
4990 simd_double3 result;
4991 result.x = x;
4992 result.y = y;
4993 result.z = z;
4994 return result;
4995}
4996
4997/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit
4998 * floating-point numbers. */
4999static inline SIMD_CFUNC simd_double3 simd_make_double3(double x, simd_double2 yz) {
5000 simd_double3 result;
5001 result.x = x;
5002 result.yz = yz;
5003 return result;
5004}
5005
5006/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit
5007 * floating-point numbers. */
5008static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double2 xy, double z) {
5009 simd_double3 result;
5010 result.xy = xy;
5011 result.z = z;
5012 return result;
5013}
5014
5015/*! @abstract Zero-extends `other` to form a vector of three 64-bit
5016 * floating-point numbers. */
5017static inline SIMD_CFUNC simd_double3 simd_make_double3(double other) {
5018 simd_double3 result = 0;
5019 result.x = other;
5020 return result;
5021}
5022
5023/*! @abstract Extends `other` to form a vector of three 64-bit floating-
5024 * point numbers. The contents of the newly-created vector lanes are
5025 * unspecified. */
5026static inline SIMD_CFUNC simd_double3 simd_make_double3_undef(double other) {
5027 simd_double3 result;
5028 result.x = other;
5029 return result;
5030}
5031
5032/*! @abstract Zero-extends `other` to form a vector of three 64-bit
5033 * floating-point numbers. */
5034static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double2 other) {
5035 simd_double3 result = 0;
5036 result.xy = other;
5037 return result;
5038}
5039
5040/*! @abstract Extends `other` to form a vector of three 64-bit floating-
5041 * point numbers. The contents of the newly-created vector lanes are
5042 * unspecified. */
5043static inline SIMD_CFUNC simd_double3 simd_make_double3_undef(simd_double2 other) {
5044 simd_double3 result;
5045 result.xy = other;
5046 return result;
5047}
5048
5049/*! @abstract Returns `other` unmodified. This function is a convenience for
5050 * templated and autogenerated code. */
5051static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double3 other) {
5052 return other;
5053}
5054
5055/*! @abstract Truncates `other` to form a vector of three 64-bit floating-
5056 * point numbers. */
5057static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double4 other) {
5058 return other.xyz;
5059}
5060
5061/*! @abstract Truncates `other` to form a vector of three 64-bit floating-
5062 * point numbers. */
5063static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double8 other) {
5064 return other.xyz;
5065}
5066
5067/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
5068 * 64-bit floating-point numbers. */
5069static inline SIMD_CFUNC simd_double4 simd_make_double4(double x, double y, double z, double w) {
5070 simd_double4 result;
5071 result.x = x;
5072 result.y = y;
5073 result.z = z;
5074 result.w = w;
5075 return result;
5076}
5077
5078/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit
5079 * floating-point numbers. */
5080static inline SIMD_CFUNC simd_double4 simd_make_double4(double x, double y, simd_double2 zw) {
5081 simd_double4 result;
5082 result.x = x;
5083 result.y = y;
5084 result.zw = zw;
5085 return result;
5086}
5087
5088/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit
5089 * floating-point numbers. */
5090static inline SIMD_CFUNC simd_double4 simd_make_double4(double x, simd_double2 yz, double w) {
5091 simd_double4 result;
5092 result.x = x;
5093 result.yz = yz;
5094 result.w = w;
5095 return result;
5096}
5097
5098/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit
5099 * floating-point numbers. */
5100static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double2 xy, double z, double w) {
5101 simd_double4 result;
5102 result.xy = xy;
5103 result.z = z;
5104 result.w = w;
5105 return result;
5106}
5107
5108/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit
5109 * floating-point numbers. */
5110static inline SIMD_CFUNC simd_double4 simd_make_double4(double x, simd_double3 yzw) {
5111 simd_double4 result;
5112 result.x = x;
5113 result.yzw = yzw;
5114 return result;
5115}
5116
5117/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit
5118 * floating-point numbers. */
5119static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double2 xy, simd_double2 zw) {
5120 simd_double4 result;
5121 result.xy = xy;
5122 result.zw = zw;
5123 return result;
5124}
5125
5126/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit
5127 * floating-point numbers. */
5128static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double3 xyz, double w) {
5129 simd_double4 result;
5130 result.xyz = xyz;
5131 result.w = w;
5132 return result;
5133}
5134
5135/*! @abstract Zero-extends `other` to form a vector of four 64-bit floating-
5136 * point numbers. */
5137static inline SIMD_CFUNC simd_double4 simd_make_double4(double other) {
5138 simd_double4 result = 0;
5139 result.x = other;
5140 return result;
5141}
5142
5143/*! @abstract Extends `other` to form a vector of four 64-bit floating-point
5144 * numbers. The contents of the newly-created vector lanes are unspecified. */
5145static inline SIMD_CFUNC simd_double4 simd_make_double4_undef(double other) {
5146 simd_double4 result;
5147 result.x = other;
5148 return result;
5149}
5150
5151/*! @abstract Zero-extends `other` to form a vector of four 64-bit floating-
5152 * point numbers. */
5153static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double2 other) {
5154 simd_double4 result = 0;
5155 result.xy = other;
5156 return result;
5157}
5158
5159/*! @abstract Extends `other` to form a vector of four 64-bit floating-point
5160 * numbers. The contents of the newly-created vector lanes are unspecified. */
5161static inline SIMD_CFUNC simd_double4 simd_make_double4_undef(simd_double2 other) {
5162 simd_double4 result;
5163 result.xy = other;
5164 return result;
5165}
5166
5167/*! @abstract Zero-extends `other` to form a vector of four 64-bit floating-
5168 * point numbers. */
5169static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double3 other) {
5170 simd_double4 result = 0;
5171 result.xyz = other;
5172 return result;
5173}
5174
5175/*! @abstract Extends `other` to form a vector of four 64-bit floating-point
5176 * numbers. The contents of the newly-created vector lanes are unspecified. */
5177static inline SIMD_CFUNC simd_double4 simd_make_double4_undef(simd_double3 other) {
5178 simd_double4 result;
5179 result.xyz = other;
5180 return result;
5181}
5182
5183/*! @abstract Returns `other` unmodified. This function is a convenience for
5184 * templated and autogenerated code. */
5185static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double4 other) {
5186 return other;
5187}
5188
5189/*! @abstract Truncates `other` to form a vector of four 64-bit floating-
5190 * point numbers. */
5191static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double8 other) {
5192 return other.xyzw;
5193}
5194
5195/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit
5196 * floating-point numbers. */
5197static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double4 lo, simd_double4 hi) {
5198 simd_double8 result;
5199 result.lo = lo;
5200 result.hi = hi;
5201 return result;
5202}
5203
5204/*! @abstract Zero-extends `other` to form a vector of eight 64-bit
5205 * floating-point numbers. */
5206static inline SIMD_CFUNC simd_double8 simd_make_double8(double other) {
5207 simd_double8 result = 0;
5208 result.x = other;
5209 return result;
5210}
5211
5212/*! @abstract Extends `other` to form a vector of eight 64-bit floating-
5213 * point numbers. The contents of the newly-created vector lanes are
5214 * unspecified. */
5215static inline SIMD_CFUNC simd_double8 simd_make_double8_undef(double other) {
5216 simd_double8 result;
5217 result.x = other;
5218 return result;
5219}
5220
5221/*! @abstract Zero-extends `other` to form a vector of eight 64-bit
5222 * floating-point numbers. */
5223static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double2 other) {
5224 simd_double8 result = 0;
5225 result.xy = other;
5226 return result;
5227}
5228
5229/*! @abstract Extends `other` to form a vector of eight 64-bit floating-
5230 * point numbers. The contents of the newly-created vector lanes are
5231 * unspecified. */
5232static inline SIMD_CFUNC simd_double8 simd_make_double8_undef(simd_double2 other) {
5233 simd_double8 result;
5234 result.xy = other;
5235 return result;
5236}
5237
5238/*! @abstract Zero-extends `other` to form a vector of eight 64-bit
5239 * floating-point numbers. */
5240static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double3 other) {
5241 simd_double8 result = 0;
5242 result.xyz = other;
5243 return result;
5244}
5245
5246/*! @abstract Extends `other` to form a vector of eight 64-bit floating-
5247 * point numbers. The contents of the newly-created vector lanes are
5248 * unspecified. */
5249static inline SIMD_CFUNC simd_double8 simd_make_double8_undef(simd_double3 other) {
5250 simd_double8 result;
5251 result.xyz = other;
5252 return result;
5253}
5254
5255/*! @abstract Zero-extends `other` to form a vector of eight 64-bit
5256 * floating-point numbers. */
5257static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double4 other) {
5258 simd_double8 result = 0;
5259 result.xyzw = other;
5260 return result;
5261}
5262
5263/*! @abstract Extends `other` to form a vector of eight 64-bit floating-
5264 * point numbers. The contents of the newly-created vector lanes are
5265 * unspecified. */
5266static inline SIMD_CFUNC simd_double8 simd_make_double8_undef(simd_double4 other) {
5267 simd_double8 result;
5268 result.xyzw = other;
5269 return result;
5270}
5271
5272/*! @abstract Returns `other` unmodified. This function is a convenience for
5273 * templated and autogenerated code. */
5274static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double8 other) {
5275 return other;
5276}
5277
5278#ifdef __cplusplus
5279} /* extern "C" */
5280
5281namespace simd {
5282/*! @abstract Concatenates `x` and `y` to form a vector of two 8-bit signed
5283 * (twos-complement) integers. */
5284static inline SIMD_CPPFUNC char2 make_char2(char x, char y) {
5285 return ::simd_make_char2(x, y);
5286}
5287
5288/*! @abstract Truncates or zero-extends `other` to form a vector of two
5289 * 8-bit signed (twos-complement) integers. */
5290template <typename typeN> static SIMD_CPPFUNC char2 make_char2(typeN other) {
5291 return ::simd_make_char2(other);
5292}
5293
5294/*! @abstract Extends `other` to form a vector of two 8-bit signed (twos-
5295 * complement) integers. The contents of the newly-created vector lanes are
5296 * unspecified. */
5297template <typename typeN> static SIMD_CPPFUNC char2 make_char2_undef(typeN other) {
5298 return ::simd_make_char2_undef(other);
5299}
5300
5301/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 8-bit
5302 * signed (twos-complement) integers. */
5303static inline SIMD_CPPFUNC char3 make_char3(char x, char y, char z) {
5304 return ::simd_make_char3(x, y, z);
5305}
5306
5307/*! @abstract Concatenates `x` and `yz` to form a vector of three 8-bit
5308 * signed (twos-complement) integers. */
5309static inline SIMD_CPPFUNC char3 make_char3(char x, char2 yz) {
5310 return ::simd_make_char3(x, yz);
5311}
5312
5313/*! @abstract Concatenates `xy` and `z` to form a vector of three 8-bit
5314 * signed (twos-complement) integers. */
5315static inline SIMD_CPPFUNC char3 make_char3(char2 xy, char z) {
5316 return ::simd_make_char3(xy, z);
5317}
5318
5319/*! @abstract Truncates or zero-extends `other` to form a vector of three
5320 * 8-bit signed (twos-complement) integers. */
5321template <typename typeN> static SIMD_CPPFUNC char3 make_char3(typeN other) {
5322 return ::simd_make_char3(other);
5323}
5324
5325/*! @abstract Extends `other` to form a vector of three 8-bit signed (twos-
5326 * complement) integers. The contents of the newly-created vector lanes are
5327 * unspecified. */
5328template <typename typeN> static SIMD_CPPFUNC char3 make_char3_undef(typeN other) {
5329 return ::simd_make_char3_undef(other);
5330}
5331
5332/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
5333 * 8-bit signed (twos-complement) integers. */
5334static inline SIMD_CPPFUNC char4 make_char4(char x, char y, char z, char w) {
5335 return ::simd_make_char4(x, y, z, w);
5336}
5337
5338/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 8-bit
5339 * signed (twos-complement) integers. */
5340static inline SIMD_CPPFUNC char4 make_char4(char x, char y, char2 zw) {
5341 return ::simd_make_char4(x, y, zw);
5342}
5343
5344/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 8-bit
5345 * signed (twos-complement) integers. */
5346static inline SIMD_CPPFUNC char4 make_char4(char x, char2 yz, char w) {
5347 return ::simd_make_char4(x, yz, w);
5348}
5349
5350/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 8-bit
5351 * signed (twos-complement) integers. */
5352static inline SIMD_CPPFUNC char4 make_char4(char2 xy, char z, char w) {
5353 return ::simd_make_char4(xy, z, w);
5354}
5355
5356/*! @abstract Concatenates `x` and `yzw` to form a vector of four 8-bit
5357 * signed (twos-complement) integers. */
5358static inline SIMD_CPPFUNC char4 make_char4(char x, char3 yzw) {
5359 return ::simd_make_char4(x, yzw);
5360}
5361
5362/*! @abstract Concatenates `xy` and `zw` to form a vector of four 8-bit
5363 * signed (twos-complement) integers. */
5364static inline SIMD_CPPFUNC char4 make_char4(char2 xy, char2 zw) {
5365 return ::simd_make_char4(xy, zw);
5366}
5367
5368/*! @abstract Concatenates `xyz` and `w` to form a vector of four 8-bit
5369 * signed (twos-complement) integers. */
5370static inline SIMD_CPPFUNC char4 make_char4(char3 xyz, char w) {
5371 return ::simd_make_char4(xyz, w);
5372}
5373
5374/*! @abstract Truncates or zero-extends `other` to form a vector of four
5375 * 8-bit signed (twos-complement) integers. */
5376template <typename typeN> static SIMD_CPPFUNC char4 make_char4(typeN other) {
5377 return ::simd_make_char4(other);
5378}
5379
5380/*! @abstract Extends `other` to form a vector of four 8-bit signed (twos-
5381 * complement) integers. The contents of the newly-created vector lanes are
5382 * unspecified. */
5383template <typename typeN> static SIMD_CPPFUNC char4 make_char4_undef(typeN other) {
5384 return ::simd_make_char4_undef(other);
5385}
5386
5387/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 8-bit
5388 * signed (twos-complement) integers. */
5389static inline SIMD_CPPFUNC char8 make_char8(char4 lo, char4 hi) {
5390 return ::simd_make_char8(lo, hi);
5391}
5392
5393/*! @abstract Truncates or zero-extends `other` to form a vector of eight
5394 * 8-bit signed (twos-complement) integers. */
5395template <typename typeN> static SIMD_CPPFUNC char8 make_char8(typeN other) {
5396 return ::simd_make_char8(other);
5397}
5398
5399/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos-
5400 * complement) integers. The contents of the newly-created vector lanes are
5401 * unspecified. */
5402template <typename typeN> static SIMD_CPPFUNC char8 make_char8_undef(typeN other) {
5403 return ::simd_make_char8_undef(other);
5404}
5405
5406/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 8-bit
5407 * signed (twos-complement) integers. */
5408static inline SIMD_CPPFUNC char16 make_char16(char8 lo, char8 hi) {
5409 return ::simd_make_char16(lo, hi);
5410}
5411
5412/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen
5413 * 8-bit signed (twos-complement) integers. */
5414template <typename typeN> static SIMD_CPPFUNC char16 make_char16(typeN other) {
5415 return ::simd_make_char16(other);
5416}
5417
5418/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed
5419 * (twos-complement) integers. The contents of the newly-created vector
5420 * lanes are unspecified. */
5421template <typename typeN> static SIMD_CPPFUNC char16 make_char16_undef(typeN other) {
5422 return ::simd_make_char16_undef(other);
5423}
5424
5425/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two
5426 * 8-bit signed (twos-complement) integers. */
5427static inline SIMD_CPPFUNC char32 make_char32(char16 lo, char16 hi) {
5428 return ::simd_make_char32(lo, hi);
5429}
5430
5431/*! @abstract Truncates or zero-extends `other` to form a vector of thirty-
5432 * two 8-bit signed (twos-complement) integers. */
5433template <typename typeN> static SIMD_CPPFUNC char32 make_char32(typeN other) {
5434 return ::simd_make_char32(other);
5435}
5436
5437/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed
5438 * (twos-complement) integers. The contents of the newly-created vector
5439 * lanes are unspecified. */
5440template <typename typeN> static SIMD_CPPFUNC char32 make_char32_undef(typeN other) {
5441 return ::simd_make_char32_undef(other);
5442}
5443
5444/*! @abstract Concatenates `lo` and `hi` to form a vector of sixty-four
5445 * 8-bit signed (twos-complement) integers. */
5446static inline SIMD_CPPFUNC char64 make_char64(char32 lo, char32 hi) {
5447 return ::simd_make_char64(lo, hi);
5448}
5449
5450/*! @abstract Truncates or zero-extends `other` to form a vector of sixty-
5451 * four 8-bit signed (twos-complement) integers. */
5452template <typename typeN> static SIMD_CPPFUNC char64 make_char64(typeN other) {
5453 return ::simd_make_char64(other);
5454}
5455
5456/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed
5457 * (twos-complement) integers. The contents of the newly-created vector
5458 * lanes are unspecified. */
5459template <typename typeN> static SIMD_CPPFUNC char64 make_char64_undef(typeN other) {
5460 return ::simd_make_char64_undef(other);
5461}
5462
5463/*! @abstract Concatenates `x` and `y` to form a vector of two 8-bit
5464 * unsigned integers. */
5465static inline SIMD_CPPFUNC uchar2 make_uchar2(unsigned char x, unsigned char y) {
5466 return ::simd_make_uchar2(x, y);
5467}
5468
5469/*! @abstract Truncates or zero-extends `other` to form a vector of two
5470 * 8-bit unsigned integers. */
5471template <typename typeN> static SIMD_CPPFUNC uchar2 make_uchar2(typeN other) {
5472 return ::simd_make_uchar2(other);
5473}
5474
5475/*! @abstract Extends `other` to form a vector of two 8-bit unsigned
5476 * integers. The contents of the newly-created vector lanes are
5477 * unspecified. */
5478template <typename typeN> static SIMD_CPPFUNC uchar2 make_uchar2_undef(typeN other) {
5479 return ::simd_make_uchar2_undef(other);
5480}
5481
5482/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 8-bit
5483 * unsigned integers. */
5484static inline SIMD_CPPFUNC uchar3 make_uchar3(unsigned char x, unsigned char y, unsigned char z) {
5485 return ::simd_make_uchar3(x, y, z);
5486}
5487
5488/*! @abstract Concatenates `x` and `yz` to form a vector of three 8-bit
5489 * unsigned integers. */
5490static inline SIMD_CPPFUNC uchar3 make_uchar3(unsigned char x, uchar2 yz) {
5491 return ::simd_make_uchar3(x, yz);
5492}
5493
5494/*! @abstract Concatenates `xy` and `z` to form a vector of three 8-bit
5495 * unsigned integers. */
5496static inline SIMD_CPPFUNC uchar3 make_uchar3(uchar2 xy, unsigned char z) {
5497 return ::simd_make_uchar3(xy, z);
5498}
5499
5500/*! @abstract Truncates or zero-extends `other` to form a vector of three
5501 * 8-bit unsigned integers. */
5502template <typename typeN> static SIMD_CPPFUNC uchar3 make_uchar3(typeN other) {
5503 return ::simd_make_uchar3(other);
5504}
5505
5506/*! @abstract Extends `other` to form a vector of three 8-bit unsigned
5507 * integers. The contents of the newly-created vector lanes are
5508 * unspecified. */
5509template <typename typeN> static SIMD_CPPFUNC uchar3 make_uchar3_undef(typeN other) {
5510 return ::simd_make_uchar3_undef(other);
5511}
5512
5513/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
5514 * 8-bit unsigned integers. */
5515static inline SIMD_CPPFUNC uchar4 make_uchar4(unsigned char x, unsigned char y, unsigned char z, unsigned char w) {
5516 return ::simd_make_uchar4(x, y, z, w);
5517}
5518
5519/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 8-bit
5520 * unsigned integers. */
5521static inline SIMD_CPPFUNC uchar4 make_uchar4(unsigned char x, unsigned char y, uchar2 zw) {
5522 return ::simd_make_uchar4(x, y, zw);
5523}
5524
5525/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 8-bit
5526 * unsigned integers. */
5527static inline SIMD_CPPFUNC uchar4 make_uchar4(unsigned char x, uchar2 yz, unsigned char w) {
5528 return ::simd_make_uchar4(x, yz, w);
5529}
5530
5531/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 8-bit
5532 * unsigned integers. */
5533static inline SIMD_CPPFUNC uchar4 make_uchar4(uchar2 xy, unsigned char z, unsigned char w) {
5534 return ::simd_make_uchar4(xy, z, w);
5535}
5536
5537/*! @abstract Concatenates `x` and `yzw` to form a vector of four 8-bit
5538 * unsigned integers. */
5539static inline SIMD_CPPFUNC uchar4 make_uchar4(unsigned char x, uchar3 yzw) {
5540 return ::simd_make_uchar4(x, yzw);
5541}
5542
5543/*! @abstract Concatenates `xy` and `zw` to form a vector of four 8-bit
5544 * unsigned integers. */
5545static inline SIMD_CPPFUNC uchar4 make_uchar4(uchar2 xy, uchar2 zw) {
5546 return ::simd_make_uchar4(xy, zw);
5547}
5548
5549/*! @abstract Concatenates `xyz` and `w` to form a vector of four 8-bit
5550 * unsigned integers. */
5551static inline SIMD_CPPFUNC uchar4 make_uchar4(uchar3 xyz, unsigned char w) {
5552 return ::simd_make_uchar4(xyz, w);
5553}
5554
5555/*! @abstract Truncates or zero-extends `other` to form a vector of four
5556 * 8-bit unsigned integers. */
5557template <typename typeN> static SIMD_CPPFUNC uchar4 make_uchar4(typeN other) {
5558 return ::simd_make_uchar4(other);
5559}
5560
5561/*! @abstract Extends `other` to form a vector of four 8-bit unsigned
5562 * integers. The contents of the newly-created vector lanes are
5563 * unspecified. */
5564template <typename typeN> static SIMD_CPPFUNC uchar4 make_uchar4_undef(typeN other) {
5565 return ::simd_make_uchar4_undef(other);
5566}
5567
5568/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 8-bit
5569 * unsigned integers. */
5570static inline SIMD_CPPFUNC uchar8 make_uchar8(uchar4 lo, uchar4 hi) {
5571 return ::simd_make_uchar8(lo, hi);
5572}
5573
5574/*! @abstract Truncates or zero-extends `other` to form a vector of eight
5575 * 8-bit unsigned integers. */
5576template <typename typeN> static SIMD_CPPFUNC uchar8 make_uchar8(typeN other) {
5577 return ::simd_make_uchar8(other);
5578}
5579
5580/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned
5581 * integers. The contents of the newly-created vector lanes are
5582 * unspecified. */
5583template <typename typeN> static SIMD_CPPFUNC uchar8 make_uchar8_undef(typeN other) {
5584 return ::simd_make_uchar8_undef(other);
5585}
5586
5587/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 8-bit
5588 * unsigned integers. */
5589static inline SIMD_CPPFUNC uchar16 make_uchar16(uchar8 lo, uchar8 hi) {
5590 return ::simd_make_uchar16(lo, hi);
5591}
5592
5593/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen
5594 * 8-bit unsigned integers. */
5595template <typename typeN> static SIMD_CPPFUNC uchar16 make_uchar16(typeN other) {
5596 return ::simd_make_uchar16(other);
5597}
5598
5599/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned
5600 * integers. The contents of the newly-created vector lanes are
5601 * unspecified. */
5602template <typename typeN> static SIMD_CPPFUNC uchar16 make_uchar16_undef(typeN other) {
5603 return ::simd_make_uchar16_undef(other);
5604}
5605
5606/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two
5607 * 8-bit unsigned integers. */
5608static inline SIMD_CPPFUNC uchar32 make_uchar32(uchar16 lo, uchar16 hi) {
5609 return ::simd_make_uchar32(lo, hi);
5610}
5611
5612/*! @abstract Truncates or zero-extends `other` to form a vector of thirty-
5613 * two 8-bit unsigned integers. */
5614template <typename typeN> static SIMD_CPPFUNC uchar32 make_uchar32(typeN other) {
5615 return ::simd_make_uchar32(other);
5616}
5617
5618/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned
5619 * integers. The contents of the newly-created vector lanes are
5620 * unspecified. */
5621template <typename typeN> static SIMD_CPPFUNC uchar32 make_uchar32_undef(typeN other) {
5622 return ::simd_make_uchar32_undef(other);
5623}
5624
5625/*! @abstract Concatenates `lo` and `hi` to form a vector of sixty-four
5626 * 8-bit unsigned integers. */
5627static inline SIMD_CPPFUNC uchar64 make_uchar64(uchar32 lo, uchar32 hi) {
5628 return ::simd_make_uchar64(lo, hi);
5629}
5630
5631/*! @abstract Truncates or zero-extends `other` to form a vector of sixty-
5632 * four 8-bit unsigned integers. */
5633template <typename typeN> static SIMD_CPPFUNC uchar64 make_uchar64(typeN other) {
5634 return ::simd_make_uchar64(other);
5635}
5636
5637/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned
5638 * integers. The contents of the newly-created vector lanes are
5639 * unspecified. */
5640template <typename typeN> static SIMD_CPPFUNC uchar64 make_uchar64_undef(typeN other) {
5641 return ::simd_make_uchar64_undef(other);
5642}
5643
5644/*! @abstract Concatenates `x` and `y` to form a vector of two 16-bit signed
5645 * (twos-complement) integers. */
5646static inline SIMD_CPPFUNC short2 make_short2(short x, short y) {
5647 return ::simd_make_short2(x, y);
5648}
5649
5650/*! @abstract Truncates or zero-extends `other` to form a vector of two
5651 * 16-bit signed (twos-complement) integers. */
5652template <typename typeN> static SIMD_CPPFUNC short2 make_short2(typeN other) {
5653 return ::simd_make_short2(other);
5654}
5655
5656/*! @abstract Extends `other` to form a vector of two 16-bit signed (twos-
5657 * complement) integers. The contents of the newly-created vector lanes are
5658 * unspecified. */
5659template <typename typeN> static SIMD_CPPFUNC short2 make_short2_undef(typeN other) {
5660 return ::simd_make_short2_undef(other);
5661}
5662
5663/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 16-bit
5664 * signed (twos-complement) integers. */
5665static inline SIMD_CPPFUNC short3 make_short3(short x, short y, short z) {
5666 return ::simd_make_short3(x, y, z);
5667}
5668
5669/*! @abstract Concatenates `x` and `yz` to form a vector of three 16-bit
5670 * signed (twos-complement) integers. */
5671static inline SIMD_CPPFUNC short3 make_short3(short x, short2 yz) {
5672 return ::simd_make_short3(x, yz);
5673}
5674
5675/*! @abstract Concatenates `xy` and `z` to form a vector of three 16-bit
5676 * signed (twos-complement) integers. */
5677static inline SIMD_CPPFUNC short3 make_short3(short2 xy, short z) {
5678 return ::simd_make_short3(xy, z);
5679}
5680
5681/*! @abstract Truncates or zero-extends `other` to form a vector of three
5682 * 16-bit signed (twos-complement) integers. */
5683template <typename typeN> static SIMD_CPPFUNC short3 make_short3(typeN other) {
5684 return ::simd_make_short3(other);
5685}
5686
5687/*! @abstract Extends `other` to form a vector of three 16-bit signed (twos-
5688 * complement) integers. The contents of the newly-created vector lanes are
5689 * unspecified. */
5690template <typename typeN> static SIMD_CPPFUNC short3 make_short3_undef(typeN other) {
5691 return ::simd_make_short3_undef(other);
5692}
5693
5694/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
5695 * 16-bit signed (twos-complement) integers. */
5696static inline SIMD_CPPFUNC short4 make_short4(short x, short y, short z, short w) {
5697 return ::simd_make_short4(x, y, z, w);
5698}
5699
5700/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 16-bit
5701 * signed (twos-complement) integers. */
5702static inline SIMD_CPPFUNC short4 make_short4(short x, short y, short2 zw) {
5703 return ::simd_make_short4(x, y, zw);
5704}
5705
5706/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 16-bit
5707 * signed (twos-complement) integers. */
5708static inline SIMD_CPPFUNC short4 make_short4(short x, short2 yz, short w) {
5709 return ::simd_make_short4(x, yz, w);
5710}
5711
5712/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 16-bit
5713 * signed (twos-complement) integers. */
5714static inline SIMD_CPPFUNC short4 make_short4(short2 xy, short z, short w) {
5715 return ::simd_make_short4(xy, z, w);
5716}
5717
5718/*! @abstract Concatenates `x` and `yzw` to form a vector of four 16-bit
5719 * signed (twos-complement) integers. */
5720static inline SIMD_CPPFUNC short4 make_short4(short x, short3 yzw) {
5721 return ::simd_make_short4(x, yzw);
5722}
5723
5724/*! @abstract Concatenates `xy` and `zw` to form a vector of four 16-bit
5725 * signed (twos-complement) integers. */
5726static inline SIMD_CPPFUNC short4 make_short4(short2 xy, short2 zw) {
5727 return ::simd_make_short4(xy, zw);
5728}
5729
5730/*! @abstract Concatenates `xyz` and `w` to form a vector of four 16-bit
5731 * signed (twos-complement) integers. */
5732static inline SIMD_CPPFUNC short4 make_short4(short3 xyz, short w) {
5733 return ::simd_make_short4(xyz, w);
5734}
5735
5736/*! @abstract Truncates or zero-extends `other` to form a vector of four
5737 * 16-bit signed (twos-complement) integers. */
5738template <typename typeN> static SIMD_CPPFUNC short4 make_short4(typeN other) {
5739 return ::simd_make_short4(other);
5740}
5741
5742/*! @abstract Extends `other` to form a vector of four 16-bit signed (twos-
5743 * complement) integers. The contents of the newly-created vector lanes are
5744 * unspecified. */
5745template <typename typeN> static SIMD_CPPFUNC short4 make_short4_undef(typeN other) {
5746 return ::simd_make_short4_undef(other);
5747}
5748
5749/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 16-bit
5750 * signed (twos-complement) integers. */
5751static inline SIMD_CPPFUNC short8 make_short8(short4 lo, short4 hi) {
5752 return ::simd_make_short8(lo, hi);
5753}
5754
5755/*! @abstract Truncates or zero-extends `other` to form a vector of eight
5756 * 16-bit signed (twos-complement) integers. */
5757template <typename typeN> static SIMD_CPPFUNC short8 make_short8(typeN other) {
5758 return ::simd_make_short8(other);
5759}
5760
5761/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos-
5762 * complement) integers. The contents of the newly-created vector lanes are
5763 * unspecified. */
5764template <typename typeN> static SIMD_CPPFUNC short8 make_short8_undef(typeN other) {
5765 return ::simd_make_short8_undef(other);
5766}
5767
5768/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 16-bit
5769 * signed (twos-complement) integers. */
5770static inline SIMD_CPPFUNC short16 make_short16(short8 lo, short8 hi) {
5771 return ::simd_make_short16(lo, hi);
5772}
5773
5774/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen
5775 * 16-bit signed (twos-complement) integers. */
5776template <typename typeN> static SIMD_CPPFUNC short16 make_short16(typeN other) {
5777 return ::simd_make_short16(other);
5778}
5779
5780/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed
5781 * (twos-complement) integers. The contents of the newly-created vector
5782 * lanes are unspecified. */
5783template <typename typeN> static SIMD_CPPFUNC short16 make_short16_undef(typeN other) {
5784 return ::simd_make_short16_undef(other);
5785}
5786
5787/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two
5788 * 16-bit signed (twos-complement) integers. */
5789static inline SIMD_CPPFUNC short32 make_short32(short16 lo, short16 hi) {
5790 return ::simd_make_short32(lo, hi);
5791}
5792
5793/*! @abstract Truncates or zero-extends `other` to form a vector of thirty-
5794 * two 16-bit signed (twos-complement) integers. */
5795template <typename typeN> static SIMD_CPPFUNC short32 make_short32(typeN other) {
5796 return ::simd_make_short32(other);
5797}
5798
5799/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed
5800 * (twos-complement) integers. The contents of the newly-created vector
5801 * lanes are unspecified. */
5802template <typename typeN> static SIMD_CPPFUNC short32 make_short32_undef(typeN other) {
5803 return ::simd_make_short32_undef(other);
5804}
5805
5806/*! @abstract Concatenates `x` and `y` to form a vector of two 16-bit
5807 * unsigned integers. */
5808static inline SIMD_CPPFUNC ushort2 make_ushort2(unsigned short x, unsigned short y) {
5809 return ::simd_make_ushort2(x, y);
5810}
5811
5812/*! @abstract Truncates or zero-extends `other` to form a vector of two
5813 * 16-bit unsigned integers. */
5814template <typename typeN> static SIMD_CPPFUNC ushort2 make_ushort2(typeN other) {
5815 return ::simd_make_ushort2(other);
5816}
5817
5818/*! @abstract Extends `other` to form a vector of two 16-bit unsigned
5819 * integers. The contents of the newly-created vector lanes are
5820 * unspecified. */
5821template <typename typeN> static SIMD_CPPFUNC ushort2 make_ushort2_undef(typeN other) {
5822 return ::simd_make_ushort2_undef(other);
5823}
5824
5825/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 16-bit
5826 * unsigned integers. */
5827static inline SIMD_CPPFUNC ushort3 make_ushort3(unsigned short x, unsigned short y, unsigned short z) {
5828 return ::simd_make_ushort3(x, y, z);
5829}
5830
5831/*! @abstract Concatenates `x` and `yz` to form a vector of three 16-bit
5832 * unsigned integers. */
5833static inline SIMD_CPPFUNC ushort3 make_ushort3(unsigned short x, ushort2 yz) {
5834 return ::simd_make_ushort3(x, yz);
5835}
5836
5837/*! @abstract Concatenates `xy` and `z` to form a vector of three 16-bit
5838 * unsigned integers. */
5839static inline SIMD_CPPFUNC ushort3 make_ushort3(ushort2 xy, unsigned short z) {
5840 return ::simd_make_ushort3(xy, z);
5841}
5842
5843/*! @abstract Truncates or zero-extends `other` to form a vector of three
5844 * 16-bit unsigned integers. */
5845template <typename typeN> static SIMD_CPPFUNC ushort3 make_ushort3(typeN other) {
5846 return ::simd_make_ushort3(other);
5847}
5848
5849/*! @abstract Extends `other` to form a vector of three 16-bit unsigned
5850 * integers. The contents of the newly-created vector lanes are
5851 * unspecified. */
5852template <typename typeN> static SIMD_CPPFUNC ushort3 make_ushort3_undef(typeN other) {
5853 return ::simd_make_ushort3_undef(other);
5854}
5855
5856/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
5857 * 16-bit unsigned integers. */
5858static inline SIMD_CPPFUNC ushort4 make_ushort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) {
5859 return ::simd_make_ushort4(x, y, z, w);
5860}
5861
5862/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 16-bit
5863 * unsigned integers. */
5864static inline SIMD_CPPFUNC ushort4 make_ushort4(unsigned short x, unsigned short y, ushort2 zw) {
5865 return ::simd_make_ushort4(x, y, zw);
5866}
5867
5868/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 16-bit
5869 * unsigned integers. */
5870static inline SIMD_CPPFUNC ushort4 make_ushort4(unsigned short x, ushort2 yz, unsigned short w) {
5871 return ::simd_make_ushort4(x, yz, w);
5872}
5873
5874/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 16-bit
5875 * unsigned integers. */
5876static inline SIMD_CPPFUNC ushort4 make_ushort4(ushort2 xy, unsigned short z, unsigned short w) {
5877 return ::simd_make_ushort4(xy, z, w);
5878}
5879
5880/*! @abstract Concatenates `x` and `yzw` to form a vector of four 16-bit
5881 * unsigned integers. */
5882static inline SIMD_CPPFUNC ushort4 make_ushort4(unsigned short x, ushort3 yzw) {
5883 return ::simd_make_ushort4(x, yzw);
5884}
5885
5886/*! @abstract Concatenates `xy` and `zw` to form a vector of four 16-bit
5887 * unsigned integers. */
5888static inline SIMD_CPPFUNC ushort4 make_ushort4(ushort2 xy, ushort2 zw) {
5889 return ::simd_make_ushort4(xy, zw);
5890}
5891
5892/*! @abstract Concatenates `xyz` and `w` to form a vector of four 16-bit
5893 * unsigned integers. */
5894static inline SIMD_CPPFUNC ushort4 make_ushort4(ushort3 xyz, unsigned short w) {
5895 return ::simd_make_ushort4(xyz, w);
5896}
5897
5898/*! @abstract Truncates or zero-extends `other` to form a vector of four
5899 * 16-bit unsigned integers. */
5900template <typename typeN> static SIMD_CPPFUNC ushort4 make_ushort4(typeN other) {
5901 return ::simd_make_ushort4(other);
5902}
5903
5904/*! @abstract Extends `other` to form a vector of four 16-bit unsigned
5905 * integers. The contents of the newly-created vector lanes are
5906 * unspecified. */
5907template <typename typeN> static SIMD_CPPFUNC ushort4 make_ushort4_undef(typeN other) {
5908 return ::simd_make_ushort4_undef(other);
5909}
5910
5911/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 16-bit
5912 * unsigned integers. */
5913static inline SIMD_CPPFUNC ushort8 make_ushort8(ushort4 lo, ushort4 hi) {
5914 return ::simd_make_ushort8(lo, hi);
5915}
5916
5917/*! @abstract Truncates or zero-extends `other` to form a vector of eight
5918 * 16-bit unsigned integers. */
5919template <typename typeN> static SIMD_CPPFUNC ushort8 make_ushort8(typeN other) {
5920 return ::simd_make_ushort8(other);
5921}
5922
5923/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned
5924 * integers. The contents of the newly-created vector lanes are
5925 * unspecified. */
5926template <typename typeN> static SIMD_CPPFUNC ushort8 make_ushort8_undef(typeN other) {
5927 return ::simd_make_ushort8_undef(other);
5928}
5929
5930/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 16-bit
5931 * unsigned integers. */
5932static inline SIMD_CPPFUNC ushort16 make_ushort16(ushort8 lo, ushort8 hi) {
5933 return ::simd_make_ushort16(lo, hi);
5934}
5935
5936/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen
5937 * 16-bit unsigned integers. */
5938template <typename typeN> static SIMD_CPPFUNC ushort16 make_ushort16(typeN other) {
5939 return ::simd_make_ushort16(other);
5940}
5941
5942/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned
5943 * integers. The contents of the newly-created vector lanes are
5944 * unspecified. */
5945template <typename typeN> static SIMD_CPPFUNC ushort16 make_ushort16_undef(typeN other) {
5946 return ::simd_make_ushort16_undef(other);
5947}
5948
5949/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two
5950 * 16-bit unsigned integers. */
5951static inline SIMD_CPPFUNC ushort32 make_ushort32(ushort16 lo, ushort16 hi) {
5952 return ::simd_make_ushort32(lo, hi);
5953}
5954
5955/*! @abstract Truncates or zero-extends `other` to form a vector of thirty-
5956 * two 16-bit unsigned integers. */
5957template <typename typeN> static SIMD_CPPFUNC ushort32 make_ushort32(typeN other) {
5958 return ::simd_make_ushort32(other);
5959}
5960
5961/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned
5962 * integers. The contents of the newly-created vector lanes are
5963 * unspecified. */
5964template <typename typeN> static SIMD_CPPFUNC ushort32 make_ushort32_undef(typeN other) {
5965 return ::simd_make_ushort32_undef(other);
5966}
5967
5968/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit signed
5969 * (twos-complement) integers. */
5970static inline SIMD_CPPFUNC int2 make_int2(int x, int y) {
5971 return ::simd_make_int2(x, y);
5972}
5973
5974/*! @abstract Truncates or zero-extends `other` to form a vector of two
5975 * 32-bit signed (twos-complement) integers. */
5976template <typename typeN> static SIMD_CPPFUNC int2 make_int2(typeN other) {
5977 return ::simd_make_int2(other);
5978}
5979
5980/*! @abstract Extends `other` to form a vector of two 32-bit signed (twos-
5981 * complement) integers. The contents of the newly-created vector lanes are
5982 * unspecified. */
5983template <typename typeN> static SIMD_CPPFUNC int2 make_int2_undef(typeN other) {
5984 return ::simd_make_int2_undef(other);
5985}
5986
5987/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit
5988 * signed (twos-complement) integers. */
5989static inline SIMD_CPPFUNC int3 make_int3(int x, int y, int z) {
5990 return ::simd_make_int3(x, y, z);
5991}
5992
5993/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit
5994 * signed (twos-complement) integers. */
5995static inline SIMD_CPPFUNC int3 make_int3(int x, int2 yz) {
5996 return ::simd_make_int3(x, yz);
5997}
5998
5999/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit
6000 * signed (twos-complement) integers. */
6001static inline SIMD_CPPFUNC int3 make_int3(int2 xy, int z) {
6002 return ::simd_make_int3(xy, z);
6003}
6004
6005/*! @abstract Truncates or zero-extends `other` to form a vector of three
6006 * 32-bit signed (twos-complement) integers. */
6007template <typename typeN> static SIMD_CPPFUNC int3 make_int3(typeN other) {
6008 return ::simd_make_int3(other);
6009}
6010
6011/*! @abstract Extends `other` to form a vector of three 32-bit signed (twos-
6012 * complement) integers. The contents of the newly-created vector lanes are
6013 * unspecified. */
6014template <typename typeN> static SIMD_CPPFUNC int3 make_int3_undef(typeN other) {
6015 return ::simd_make_int3_undef(other);
6016}
6017
6018/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
6019 * 32-bit signed (twos-complement) integers. */
6020static inline SIMD_CPPFUNC int4 make_int4(int x, int y, int z, int w) {
6021 return ::simd_make_int4(x, y, z, w);
6022}
6023
6024/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit
6025 * signed (twos-complement) integers. */
6026static inline SIMD_CPPFUNC int4 make_int4(int x, int y, int2 zw) {
6027 return ::simd_make_int4(x, y, zw);
6028}
6029
6030/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit
6031 * signed (twos-complement) integers. */
6032static inline SIMD_CPPFUNC int4 make_int4(int x, int2 yz, int w) {
6033 return ::simd_make_int4(x, yz, w);
6034}
6035
6036/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit
6037 * signed (twos-complement) integers. */
6038static inline SIMD_CPPFUNC int4 make_int4(int2 xy, int z, int w) {
6039 return ::simd_make_int4(xy, z, w);
6040}
6041
6042/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit
6043 * signed (twos-complement) integers. */
6044static inline SIMD_CPPFUNC int4 make_int4(int x, int3 yzw) {
6045 return ::simd_make_int4(x, yzw);
6046}
6047
6048/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit
6049 * signed (twos-complement) integers. */
6050static inline SIMD_CPPFUNC int4 make_int4(int2 xy, int2 zw) {
6051 return ::simd_make_int4(xy, zw);
6052}
6053
6054/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit
6055 * signed (twos-complement) integers. */
6056static inline SIMD_CPPFUNC int4 make_int4(int3 xyz, int w) {
6057 return ::simd_make_int4(xyz, w);
6058}
6059
6060/*! @abstract Truncates or zero-extends `other` to form a vector of four
6061 * 32-bit signed (twos-complement) integers. */
6062template <typename typeN> static SIMD_CPPFUNC int4 make_int4(typeN other) {
6063 return ::simd_make_int4(other);
6064}
6065
6066/*! @abstract Extends `other` to form a vector of four 32-bit signed (twos-
6067 * complement) integers. The contents of the newly-created vector lanes are
6068 * unspecified. */
6069template <typename typeN> static SIMD_CPPFUNC int4 make_int4_undef(typeN other) {
6070 return ::simd_make_int4_undef(other);
6071}
6072
6073/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit
6074 * signed (twos-complement) integers. */
6075static inline SIMD_CPPFUNC int8 make_int8(int4 lo, int4 hi) {
6076 return ::simd_make_int8(lo, hi);
6077}
6078
6079/*! @abstract Truncates or zero-extends `other` to form a vector of eight
6080 * 32-bit signed (twos-complement) integers. */
6081template <typename typeN> static SIMD_CPPFUNC int8 make_int8(typeN other) {
6082 return ::simd_make_int8(other);
6083}
6084
6085/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos-
6086 * complement) integers. The contents of the newly-created vector lanes are
6087 * unspecified. */
6088template <typename typeN> static SIMD_CPPFUNC int8 make_int8_undef(typeN other) {
6089 return ::simd_make_int8_undef(other);
6090}
6091
6092/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit
6093 * signed (twos-complement) integers. */
6094static inline SIMD_CPPFUNC int16 make_int16(int8 lo, int8 hi) {
6095 return ::simd_make_int16(lo, hi);
6096}
6097
6098/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen
6099 * 32-bit signed (twos-complement) integers. */
6100template <typename typeN> static SIMD_CPPFUNC int16 make_int16(typeN other) {
6101 return ::simd_make_int16(other);
6102}
6103
6104/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed
6105 * (twos-complement) integers. The contents of the newly-created vector
6106 * lanes are unspecified. */
6107template <typename typeN> static SIMD_CPPFUNC int16 make_int16_undef(typeN other) {
6108 return ::simd_make_int16_undef(other);
6109}
6110
6111/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit
6112 * unsigned integers. */
6113static inline SIMD_CPPFUNC uint2 make_uint2(unsigned int x, unsigned int y) {
6114 return ::simd_make_uint2(x, y);
6115}
6116
6117/*! @abstract Truncates or zero-extends `other` to form a vector of two
6118 * 32-bit unsigned integers. */
6119template <typename typeN> static SIMD_CPPFUNC uint2 make_uint2(typeN other) {
6120 return ::simd_make_uint2(other);
6121}
6122
6123/*! @abstract Extends `other` to form a vector of two 32-bit unsigned
6124 * integers. The contents of the newly-created vector lanes are
6125 * unspecified. */
6126template <typename typeN> static SIMD_CPPFUNC uint2 make_uint2_undef(typeN other) {
6127 return ::simd_make_uint2_undef(other);
6128}
6129
6130/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit
6131 * unsigned integers. */
6132static inline SIMD_CPPFUNC uint3 make_uint3(unsigned int x, unsigned int y, unsigned int z) {
6133 return ::simd_make_uint3(x, y, z);
6134}
6135
6136/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit
6137 * unsigned integers. */
6138static inline SIMD_CPPFUNC uint3 make_uint3(unsigned int x, uint2 yz) {
6139 return ::simd_make_uint3(x, yz);
6140}
6141
6142/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit
6143 * unsigned integers. */
6144static inline SIMD_CPPFUNC uint3 make_uint3(uint2 xy, unsigned int z) {
6145 return ::simd_make_uint3(xy, z);
6146}
6147
6148/*! @abstract Truncates or zero-extends `other` to form a vector of three
6149 * 32-bit unsigned integers. */
6150template <typename typeN> static SIMD_CPPFUNC uint3 make_uint3(typeN other) {
6151 return ::simd_make_uint3(other);
6152}
6153
6154/*! @abstract Extends `other` to form a vector of three 32-bit unsigned
6155 * integers. The contents of the newly-created vector lanes are
6156 * unspecified. */
6157template <typename typeN> static SIMD_CPPFUNC uint3 make_uint3_undef(typeN other) {
6158 return ::simd_make_uint3_undef(other);
6159}
6160
6161/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
6162 * 32-bit unsigned integers. */
6163static inline SIMD_CPPFUNC uint4 make_uint4(unsigned int x, unsigned int y, unsigned int z, unsigned int w) {
6164 return ::simd_make_uint4(x, y, z, w);
6165}
6166
6167/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit
6168 * unsigned integers. */
6169static inline SIMD_CPPFUNC uint4 make_uint4(unsigned int x, unsigned int y, uint2 zw) {
6170 return ::simd_make_uint4(x, y, zw);
6171}
6172
6173/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit
6174 * unsigned integers. */
6175static inline SIMD_CPPFUNC uint4 make_uint4(unsigned int x, uint2 yz, unsigned int w) {
6176 return ::simd_make_uint4(x, yz, w);
6177}
6178
6179/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit
6180 * unsigned integers. */
6181static inline SIMD_CPPFUNC uint4 make_uint4(uint2 xy, unsigned int z, unsigned int w) {
6182 return ::simd_make_uint4(xy, z, w);
6183}
6184
6185/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit
6186 * unsigned integers. */
6187static inline SIMD_CPPFUNC uint4 make_uint4(unsigned int x, uint3 yzw) {
6188 return ::simd_make_uint4(x, yzw);
6189}
6190
6191/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit
6192 * unsigned integers. */
6193static inline SIMD_CPPFUNC uint4 make_uint4(uint2 xy, uint2 zw) {
6194 return ::simd_make_uint4(xy, zw);
6195}
6196
6197/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit
6198 * unsigned integers. */
6199static inline SIMD_CPPFUNC uint4 make_uint4(uint3 xyz, unsigned int w) {
6200 return ::simd_make_uint4(xyz, w);
6201}
6202
6203/*! @abstract Truncates or zero-extends `other` to form a vector of four
6204 * 32-bit unsigned integers. */
6205template <typename typeN> static SIMD_CPPFUNC uint4 make_uint4(typeN other) {
6206 return ::simd_make_uint4(other);
6207}
6208
6209/*! @abstract Extends `other` to form a vector of four 32-bit unsigned
6210 * integers. The contents of the newly-created vector lanes are
6211 * unspecified. */
6212template <typename typeN> static SIMD_CPPFUNC uint4 make_uint4_undef(typeN other) {
6213 return ::simd_make_uint4_undef(other);
6214}
6215
6216/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit
6217 * unsigned integers. */
6218static inline SIMD_CPPFUNC uint8 make_uint8(uint4 lo, uint4 hi) {
6219 return ::simd_make_uint8(lo, hi);
6220}
6221
6222/*! @abstract Truncates or zero-extends `other` to form a vector of eight
6223 * 32-bit unsigned integers. */
6224template <typename typeN> static SIMD_CPPFUNC uint8 make_uint8(typeN other) {
6225 return ::simd_make_uint8(other);
6226}
6227
6228/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned
6229 * integers. The contents of the newly-created vector lanes are
6230 * unspecified. */
6231template <typename typeN> static SIMD_CPPFUNC uint8 make_uint8_undef(typeN other) {
6232 return ::simd_make_uint8_undef(other);
6233}
6234
6235/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit
6236 * unsigned integers. */
6237static inline SIMD_CPPFUNC uint16 make_uint16(uint8 lo, uint8 hi) {
6238 return ::simd_make_uint16(lo, hi);
6239}
6240
6241/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen
6242 * 32-bit unsigned integers. */
6243template <typename typeN> static SIMD_CPPFUNC uint16 make_uint16(typeN other) {
6244 return ::simd_make_uint16(other);
6245}
6246
6247/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned
6248 * integers. The contents of the newly-created vector lanes are
6249 * unspecified. */
6250template <typename typeN> static SIMD_CPPFUNC uint16 make_uint16_undef(typeN other) {
6251 return ::simd_make_uint16_undef(other);
6252}
6253
6254/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit
6255 * floating-point numbers. */
6256static inline SIMD_CPPFUNC float2 make_float2(float x, float y) {
6257 return ::simd_make_float2(x, y);
6258}
6259
6260/*! @abstract Truncates or zero-extends `other` to form a vector of two
6261 * 32-bit floating-point numbers. */
6262template <typename typeN> static SIMD_CPPFUNC float2 make_float2(typeN other) {
6263 return ::simd_make_float2(other);
6264}
6265
6266/*! @abstract Extends `other` to form a vector of two 32-bit floating-point
6267 * numbers. The contents of the newly-created vector lanes are unspecified. */
6268template <typename typeN> static SIMD_CPPFUNC float2 make_float2_undef(typeN other) {
6269 return ::simd_make_float2_undef(other);
6270}
6271
6272/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit
6273 * floating-point numbers. */
6274static inline SIMD_CPPFUNC float3 make_float3(float x, float y, float z) {
6275 return ::simd_make_float3(x, y, z);
6276}
6277
6278/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit
6279 * floating-point numbers. */
6280static inline SIMD_CPPFUNC float3 make_float3(float x, float2 yz) {
6281 return ::simd_make_float3(x, yz);
6282}
6283
6284/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit
6285 * floating-point numbers. */
6286static inline SIMD_CPPFUNC float3 make_float3(float2 xy, float z) {
6287 return ::simd_make_float3(xy, z);
6288}
6289
6290/*! @abstract Truncates or zero-extends `other` to form a vector of three
6291 * 32-bit floating-point numbers. */
6292template <typename typeN> static SIMD_CPPFUNC float3 make_float3(typeN other) {
6293 return ::simd_make_float3(other);
6294}
6295
6296/*! @abstract Extends `other` to form a vector of three 32-bit floating-
6297 * point numbers. The contents of the newly-created vector lanes are
6298 * unspecified. */
6299template <typename typeN> static SIMD_CPPFUNC float3 make_float3_undef(typeN other) {
6300 return ::simd_make_float3_undef(other);
6301}
6302
6303/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
6304 * 32-bit floating-point numbers. */
6305static inline SIMD_CPPFUNC float4 make_float4(float x, float y, float z, float w) {
6306 return ::simd_make_float4(x, y, z, w);
6307}
6308
6309/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit
6310 * floating-point numbers. */
6311static inline SIMD_CPPFUNC float4 make_float4(float x, float y, float2 zw) {
6312 return ::simd_make_float4(x, y, zw);
6313}
6314
6315/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit
6316 * floating-point numbers. */
6317static inline SIMD_CPPFUNC float4 make_float4(float x, float2 yz, float w) {
6318 return ::simd_make_float4(x, yz, w);
6319}
6320
6321/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit
6322 * floating-point numbers. */
6323static inline SIMD_CPPFUNC float4 make_float4(float2 xy, float z, float w) {
6324 return ::simd_make_float4(xy, z, w);
6325}
6326
6327/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit
6328 * floating-point numbers. */
6329static inline SIMD_CPPFUNC float4 make_float4(float x, float3 yzw) {
6330 return ::simd_make_float4(x, yzw);
6331}
6332
6333/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit
6334 * floating-point numbers. */
6335static inline SIMD_CPPFUNC float4 make_float4(float2 xy, float2 zw) {
6336 return ::simd_make_float4(xy, zw);
6337}
6338
6339/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit
6340 * floating-point numbers. */
6341static inline SIMD_CPPFUNC float4 make_float4(float3 xyz, float w) {
6342 return ::simd_make_float4(xyz, w);
6343}
6344
6345/*! @abstract Truncates or zero-extends `other` to form a vector of four
6346 * 32-bit floating-point numbers. */
6347template <typename typeN> static SIMD_CPPFUNC float4 make_float4(typeN other) {
6348 return ::simd_make_float4(other);
6349}
6350
6351/*! @abstract Extends `other` to form a vector of four 32-bit floating-point
6352 * numbers. The contents of the newly-created vector lanes are unspecified. */
6353template <typename typeN> static SIMD_CPPFUNC float4 make_float4_undef(typeN other) {
6354 return ::simd_make_float4_undef(other);
6355}
6356
6357/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit
6358 * floating-point numbers. */
6359static inline SIMD_CPPFUNC float8 make_float8(float4 lo, float4 hi) {
6360 return ::simd_make_float8(lo, hi);
6361}
6362
6363/*! @abstract Truncates or zero-extends `other` to form a vector of eight
6364 * 32-bit floating-point numbers. */
6365template <typename typeN> static SIMD_CPPFUNC float8 make_float8(typeN other) {
6366 return ::simd_make_float8(other);
6367}
6368
6369/*! @abstract Extends `other` to form a vector of eight 32-bit floating-
6370 * point numbers. The contents of the newly-created vector lanes are
6371 * unspecified. */
6372template <typename typeN> static SIMD_CPPFUNC float8 make_float8_undef(typeN other) {
6373 return ::simd_make_float8_undef(other);
6374}
6375
6376/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit
6377 * floating-point numbers. */
6378static inline SIMD_CPPFUNC float16 make_float16(float8 lo, float8 hi) {
6379 return ::simd_make_float16(lo, hi);
6380}
6381
6382/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen
6383 * 32-bit floating-point numbers. */
6384template <typename typeN> static SIMD_CPPFUNC float16 make_float16(typeN other) {
6385 return ::simd_make_float16(other);
6386}
6387
6388/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating-
6389 * point numbers. The contents of the newly-created vector lanes are
6390 * unspecified. */
6391template <typename typeN> static SIMD_CPPFUNC float16 make_float16_undef(typeN other) {
6392 return ::simd_make_float16_undef(other);
6393}
6394
6395/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit signed
6396 * (twos-complement) integers. */
6397static inline SIMD_CPPFUNC long2 make_long2(long1 x, long1 y) {
6398 return ::simd_make_long2(x, y);
6399}
6400
6401/*! @abstract Truncates or zero-extends `other` to form a vector of two
6402 * 64-bit signed (twos-complement) integers. */
6403template <typename typeN> static SIMD_CPPFUNC long2 make_long2(typeN other) {
6404 return ::simd_make_long2(other);
6405}
6406
6407/*! @abstract Extends `other` to form a vector of two 64-bit signed (twos-
6408 * complement) integers. The contents of the newly-created vector lanes are
6409 * unspecified. */
6410template <typename typeN> static SIMD_CPPFUNC long2 make_long2_undef(typeN other) {
6411 return ::simd_make_long2_undef(other);
6412}
6413
6414/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit
6415 * signed (twos-complement) integers. */
6416static inline SIMD_CPPFUNC long3 make_long3(long1 x, long1 y, long1 z) {
6417 return ::simd_make_long3(x, y, z);
6418}
6419
6420/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit
6421 * signed (twos-complement) integers. */
6422static inline SIMD_CPPFUNC long3 make_long3(long1 x, long2 yz) {
6423 return ::simd_make_long3(x, yz);
6424}
6425
6426/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit
6427 * signed (twos-complement) integers. */
6428static inline SIMD_CPPFUNC long3 make_long3(long2 xy, long1 z) {
6429 return ::simd_make_long3(xy, z);
6430}
6431
6432/*! @abstract Truncates or zero-extends `other` to form a vector of three
6433 * 64-bit signed (twos-complement) integers. */
6434template <typename typeN> static SIMD_CPPFUNC long3 make_long3(typeN other) {
6435 return ::simd_make_long3(other);
6436}
6437
6438/*! @abstract Extends `other` to form a vector of three 64-bit signed (twos-
6439 * complement) integers. The contents of the newly-created vector lanes are
6440 * unspecified. */
6441template <typename typeN> static SIMD_CPPFUNC long3 make_long3_undef(typeN other) {
6442 return ::simd_make_long3_undef(other);
6443}
6444
6445/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
6446 * 64-bit signed (twos-complement) integers. */
6447static inline SIMD_CPPFUNC long4 make_long4(long1 x, long1 y, long1 z, long1 w) {
6448 return ::simd_make_long4(x, y, z, w);
6449}
6450
6451/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit
6452 * signed (twos-complement) integers. */
6453static inline SIMD_CPPFUNC long4 make_long4(long1 x, long1 y, long2 zw) {
6454 return ::simd_make_long4(x, y, zw);
6455}
6456
6457/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit
6458 * signed (twos-complement) integers. */
6459static inline SIMD_CPPFUNC long4 make_long4(long1 x, long2 yz, long1 w) {
6460 return ::simd_make_long4(x, yz, w);
6461}
6462
6463/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit
6464 * signed (twos-complement) integers. */
6465static inline SIMD_CPPFUNC long4 make_long4(long2 xy, long1 z, long1 w) {
6466 return ::simd_make_long4(xy, z, w);
6467}
6468
6469/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit
6470 * signed (twos-complement) integers. */
6471static inline SIMD_CPPFUNC long4 make_long4(long1 x, long3 yzw) {
6472 return ::simd_make_long4(x, yzw);
6473}
6474
6475/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit
6476 * signed (twos-complement) integers. */
6477static inline SIMD_CPPFUNC long4 make_long4(long2 xy, long2 zw) {
6478 return ::simd_make_long4(xy, zw);
6479}
6480
6481/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit
6482 * signed (twos-complement) integers. */
6483static inline SIMD_CPPFUNC long4 make_long4(long3 xyz, long1 w) {
6484 return ::simd_make_long4(xyz, w);
6485}
6486
6487/*! @abstract Truncates or zero-extends `other` to form a vector of four
6488 * 64-bit signed (twos-complement) integers. */
6489template <typename typeN> static SIMD_CPPFUNC long4 make_long4(typeN other) {
6490 return ::simd_make_long4(other);
6491}
6492
6493/*! @abstract Extends `other` to form a vector of four 64-bit signed (twos-
6494 * complement) integers. The contents of the newly-created vector lanes are
6495 * unspecified. */
6496template <typename typeN> static SIMD_CPPFUNC long4 make_long4_undef(typeN other) {
6497 return ::simd_make_long4_undef(other);
6498}
6499
6500/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit
6501 * signed (twos-complement) integers. */
6502static inline SIMD_CPPFUNC long8 make_long8(long4 lo, long4 hi) {
6503 return ::simd_make_long8(lo, hi);
6504}
6505
6506/*! @abstract Truncates or zero-extends `other` to form a vector of eight
6507 * 64-bit signed (twos-complement) integers. */
6508template <typename typeN> static SIMD_CPPFUNC long8 make_long8(typeN other) {
6509 return ::simd_make_long8(other);
6510}
6511
6512/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos-
6513 * complement) integers. The contents of the newly-created vector lanes are
6514 * unspecified. */
6515template <typename typeN> static SIMD_CPPFUNC long8 make_long8_undef(typeN other) {
6516 return ::simd_make_long8_undef(other);
6517}
6518
6519/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit
6520 * unsigned integers. */
6521static inline SIMD_CPPFUNC ulong2 make_ulong2(ulong1 x, ulong1 y) {
6522 return ::simd_make_ulong2(x, y);
6523}
6524
6525/*! @abstract Truncates or zero-extends `other` to form a vector of two
6526 * 64-bit unsigned integers. */
6527template <typename typeN> static SIMD_CPPFUNC ulong2 make_ulong2(typeN other) {
6528 return ::simd_make_ulong2(other);
6529}
6530
6531/*! @abstract Extends `other` to form a vector of two 64-bit unsigned
6532 * integers. The contents of the newly-created vector lanes are
6533 * unspecified. */
6534template <typename typeN> static SIMD_CPPFUNC ulong2 make_ulong2_undef(typeN other) {
6535 return ::simd_make_ulong2_undef(other);
6536}
6537
6538/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit
6539 * unsigned integers. */
6540static inline SIMD_CPPFUNC ulong3 make_ulong3(ulong1 x, ulong1 y, ulong1 z) {
6541 return ::simd_make_ulong3(x, y, z);
6542}
6543
6544/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit
6545 * unsigned integers. */
6546static inline SIMD_CPPFUNC ulong3 make_ulong3(ulong1 x, ulong2 yz) {
6547 return ::simd_make_ulong3(x, yz);
6548}
6549
6550/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit
6551 * unsigned integers. */
6552static inline SIMD_CPPFUNC ulong3 make_ulong3(ulong2 xy, ulong1 z) {
6553 return ::simd_make_ulong3(xy, z);
6554}
6555
6556/*! @abstract Truncates or zero-extends `other` to form a vector of three
6557 * 64-bit unsigned integers. */
6558template <typename typeN> static SIMD_CPPFUNC ulong3 make_ulong3(typeN other) {
6559 return ::simd_make_ulong3(other);
6560}
6561
6562/*! @abstract Extends `other` to form a vector of three 64-bit unsigned
6563 * integers. The contents of the newly-created vector lanes are
6564 * unspecified. */
6565template <typename typeN> static SIMD_CPPFUNC ulong3 make_ulong3_undef(typeN other) {
6566 return ::simd_make_ulong3_undef(other);
6567}
6568
6569/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
6570 * 64-bit unsigned integers. */
6571static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong1 x, ulong1 y, ulong1 z, ulong1 w) {
6572 return ::simd_make_ulong4(x, y, z, w);
6573}
6574
6575/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit
6576 * unsigned integers. */
6577static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong1 x, ulong1 y, ulong2 zw) {
6578 return ::simd_make_ulong4(x, y, zw);
6579}
6580
6581/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit
6582 * unsigned integers. */
6583static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong1 x, ulong2 yz, ulong1 w) {
6584 return ::simd_make_ulong4(x, yz, w);
6585}
6586
6587/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit
6588 * unsigned integers. */
6589static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong2 xy, ulong1 z, ulong1 w) {
6590 return ::simd_make_ulong4(xy, z, w);
6591}
6592
6593/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit
6594 * unsigned integers. */
6595static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong1 x, ulong3 yzw) {
6596 return ::simd_make_ulong4(x, yzw);
6597}
6598
6599/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit
6600 * unsigned integers. */
6601static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong2 xy, ulong2 zw) {
6602 return ::simd_make_ulong4(xy, zw);
6603}
6604
6605/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit
6606 * unsigned integers. */
6607static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong3 xyz, ulong1 w) {
6608 return ::simd_make_ulong4(xyz, w);
6609}
6610
6611/*! @abstract Truncates or zero-extends `other` to form a vector of four
6612 * 64-bit unsigned integers. */
6613template <typename typeN> static SIMD_CPPFUNC ulong4 make_ulong4(typeN other) {
6614 return ::simd_make_ulong4(other);
6615}
6616
6617/*! @abstract Extends `other` to form a vector of four 64-bit unsigned
6618 * integers. The contents of the newly-created vector lanes are
6619 * unspecified. */
6620template <typename typeN> static SIMD_CPPFUNC ulong4 make_ulong4_undef(typeN other) {
6621 return ::simd_make_ulong4_undef(other);
6622}
6623
6624/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit
6625 * unsigned integers. */
6626static inline SIMD_CPPFUNC ulong8 make_ulong8(ulong4 lo, ulong4 hi) {
6627 return ::simd_make_ulong8(lo, hi);
6628}
6629
6630/*! @abstract Truncates or zero-extends `other` to form a vector of eight
6631 * 64-bit unsigned integers. */
6632template <typename typeN> static SIMD_CPPFUNC ulong8 make_ulong8(typeN other) {
6633 return ::simd_make_ulong8(other);
6634}
6635
6636/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned
6637 * integers. The contents of the newly-created vector lanes are
6638 * unspecified. */
6639template <typename typeN> static SIMD_CPPFUNC ulong8 make_ulong8_undef(typeN other) {
6640 return ::simd_make_ulong8_undef(other);
6641}
6642
6643/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit
6644 * floating-point numbers. */
6645static inline SIMD_CPPFUNC double2 make_double2(double x, double y) {
6646 return ::simd_make_double2(x, y);
6647}
6648
6649/*! @abstract Truncates or zero-extends `other` to form a vector of two
6650 * 64-bit floating-point numbers. */
6651template <typename typeN> static SIMD_CPPFUNC double2 make_double2(typeN other) {
6652 return ::simd_make_double2(other);
6653}
6654
6655/*! @abstract Extends `other` to form a vector of two 64-bit floating-point
6656 * numbers. The contents of the newly-created vector lanes are unspecified. */
6657template <typename typeN> static SIMD_CPPFUNC double2 make_double2_undef(typeN other) {
6658 return ::simd_make_double2_undef(other);
6659}
6660
6661/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit
6662 * floating-point numbers. */
6663static inline SIMD_CPPFUNC double3 make_double3(double x, double y, double z) {
6664 return ::simd_make_double3(x, y, z);
6665}
6666
6667/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit
6668 * floating-point numbers. */
6669static inline SIMD_CPPFUNC double3 make_double3(double x, double2 yz) {
6670 return ::simd_make_double3(x, yz);
6671}
6672
6673/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit
6674 * floating-point numbers. */
6675static inline SIMD_CPPFUNC double3 make_double3(double2 xy, double z) {
6676 return ::simd_make_double3(xy, z);
6677}
6678
6679/*! @abstract Truncates or zero-extends `other` to form a vector of three
6680 * 64-bit floating-point numbers. */
6681template <typename typeN> static SIMD_CPPFUNC double3 make_double3(typeN other) {
6682 return ::simd_make_double3(other);
6683}
6684
6685/*! @abstract Extends `other` to form a vector of three 64-bit floating-
6686 * point numbers. The contents of the newly-created vector lanes are
6687 * unspecified. */
6688template <typename typeN> static SIMD_CPPFUNC double3 make_double3_undef(typeN other) {
6689 return ::simd_make_double3_undef(other);
6690}
6691
6692/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four
6693 * 64-bit floating-point numbers. */
6694static inline SIMD_CPPFUNC double4 make_double4(double x, double y, double z, double w) {
6695 return ::simd_make_double4(x, y, z, w);
6696}
6697
6698/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit
6699 * floating-point numbers. */
6700static inline SIMD_CPPFUNC double4 make_double4(double x, double y, double2 zw) {
6701 return ::simd_make_double4(x, y, zw);
6702}
6703
6704/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit
6705 * floating-point numbers. */
6706static inline SIMD_CPPFUNC double4 make_double4(double x, double2 yz, double w) {
6707 return ::simd_make_double4(x, yz, w);
6708}
6709
6710/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit
6711 * floating-point numbers. */
6712static inline SIMD_CPPFUNC double4 make_double4(double2 xy, double z, double w) {
6713 return ::simd_make_double4(xy, z, w);
6714}
6715
6716/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit
6717 * floating-point numbers. */
6718static inline SIMD_CPPFUNC double4 make_double4(double x, double3 yzw) {
6719 return ::simd_make_double4(x, yzw);
6720}
6721
6722/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit
6723 * floating-point numbers. */
6724static inline SIMD_CPPFUNC double4 make_double4(double2 xy, double2 zw) {
6725 return ::simd_make_double4(xy, zw);
6726}
6727
6728/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit
6729 * floating-point numbers. */
6730static inline SIMD_CPPFUNC double4 make_double4(double3 xyz, double w) {
6731 return ::simd_make_double4(xyz, w);
6732}
6733
6734/*! @abstract Truncates or zero-extends `other` to form a vector of four
6735 * 64-bit floating-point numbers. */
6736template <typename typeN> static SIMD_CPPFUNC double4 make_double4(typeN other) {
6737 return ::simd_make_double4(other);
6738}
6739
6740/*! @abstract Extends `other` to form a vector of four 64-bit floating-point
6741 * numbers. The contents of the newly-created vector lanes are unspecified. */
6742template <typename typeN> static SIMD_CPPFUNC double4 make_double4_undef(typeN other) {
6743 return ::simd_make_double4_undef(other);
6744}
6745
6746/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit
6747 * floating-point numbers. */
6748static inline SIMD_CPPFUNC double8 make_double8(double4 lo, double4 hi) {
6749 return ::simd_make_double8(lo, hi);
6750}
6751
6752/*! @abstract Truncates or zero-extends `other` to form a vector of eight
6753 * 64-bit floating-point numbers. */
6754template <typename typeN> static SIMD_CPPFUNC double8 make_double8(typeN other) {
6755 return ::simd_make_double8(other);
6756}
6757
6758/*! @abstract Extends `other` to form a vector of eight 64-bit floating-
6759 * point numbers. The contents of the newly-created vector lanes are
6760 * unspecified. */
6761template <typename typeN> static SIMD_CPPFUNC double8 make_double8_undef(typeN other) {
6762 return ::simd_make_double8_undef(other);
6763}
6764
6765} /* namespace simd */
6766#endif /* __cplusplus */
6767#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
6768#endif /* SIMD_VECTOR_CONSTRUCTORS */
lib/libc/include/x86_64-macos-gnu/simd/vector_types.h created+1281
......@@ -0,0 +1,1281 @@
1/*! @header
2 * This header defines fixed size vector types that are useful both for
3 * graphics and geometry, and for software vectorization without
4 * architecture-specific intrinsics.
5 *
6 * These types are based on a clang feature called "Extended vector types"
7 * or "OpenCL vector types" (despite the name, these types work just fine
8 * in C, Objective-C, and C++). There are a few tricks that make these
9 * types nicer to work with than traditional simd intrinsic types:
10 *
11 * - Basic arithmetic operators are overloaded to perform lanewise
12 * operations with these types, including both vector-vector and
13 * vector-scalar operations.
14 *
15 * - It is possible to access vector components both via array-style
16 * subscripting and by using the "." operator with component names
17 * "x", "y", "z", "w", and permutations thereof.
18 *
19 * - There are also some named subvectors: .lo and .hi are the first
20 * and second halves of a vector, and .even and .odd are the even-
21 * and odd-indexed elements of a vector.
22 *
23 * - Clang provides some useful builtins that operate on these vector
24 * types: __builtin_shufflevector and __builtin_convertvector.
25 *
26 * - The <simd/simd.h> headers define a large assortment of vector and
27 * matrix operations that work on these types.
28 *
29 * - You can also use the simd types with the architecture-specific
30 * intrinsics defined in <immintrin.h> and <arm_neon.h>.
31 *
32 * The following vector types are defined by this header:
33 *
34 * simd_charN where N is 1, 2, 3, 4, 8, 16, 32, or 64.
35 * simd_ucharN where N is 1, 2, 3, 4, 8, 16, 32, or 64.
36 * simd_shortN where N is 1, 2, 3, 4, 8, 16, or 32.
37 * simd_ushortN where N is 1, 2, 3, 4, 8, 16, or 32.
38 * simd_intN where N is 1, 2, 3, 4, 8, or 16.
39 * simd_uintN where N is 1, 2, 3, 4, 8, or 16.
40 * simd_floatN where N is 1, 2, 3, 4, 8, or 16.
41 * simd_longN where N is 1, 2, 3, 4, or 8.
42 * simd_ulongN where N is 1, 2, 3, 4, or 8.
43 * simd_doubleN where N is 1, 2, 3, 4, or 8.
44 *
45 * These types generally have greater alignment than the underlying scalar
46 * type; they are aligned to either the size of the vector[1] or 16 bytes,
47 * whichever is smaller.
48 *
49 * [1] Note that sizeof a three-element vector is the same as sizeof the
50 * corresponding four-element vector, because three-element vectors have
51 * a hidden lane of padding.
52 *
53 * In earlier versions of the simd library, the alignment of vectors could
54 * be larger than 16B, up to the "architectural vector size" of 16, 32, or
55 * 64B, depending on what options were passed on the command line when
56 * compiling. This super-alignment does not interact well with malloc, and
57 * makes it difficult for libraries to provide a stable API, while conferring
58 * relatively little performance benefit, so it has been relaxed.
59 *
60 * For each simd_typeN type where N is not 1 or 3, there is also a
61 * corresponding simd_packed_typeN type that requires only the alignment
62 * matching that of the underlying scalar type. Use this if you need to
63 * work with pointers-to or arrays-of scalar values:
64 *
65 * void myFunction(float *pointerToFourFloats) {
66 * // This is a bug, because `pointerToFourFloats` does not satisfy
67 * // the alignment requirements of the `simd_float4` type; attempting
68 * // to dereference (load from) `vecptr` is likely to crash at runtime.
69 * simd_float4 *vecptr = (simd_float4 *)pointerToFourFloats;
70 *
71 * // Instead, convert to `simd_packed_float4`:
72 * simd_packed_float4 *vecptr = (simd_packed_float4 *)pointerToFourFloats;
73 * // The `simd_packed_float4` type has the same alignment requirements
74 * // as `float`, so this conversion is safe, and lets us load a vector.
75 * // Note that `simd_packed_float4` can be assigned to `simd_float4`
76 * // without any conversion; they types only behave differently as
77 * // pointers or arrays.
78 * simd_float4 vector = vecptr[0];
79 * }
80 *
81 * All of the simd_-prefixed types are also available in the C++ simd::
82 * namespace; simd_char4 can be used as simd::char4, for example. These types
83 * largely match the Metal shader language vector types, except that there
84 * are no vector types larger than 4 elements in Metal.
85 *
86 * @copyright 2014-2017 Apple, Inc. All rights reserved.
87 * @unsorted */
88
89#ifndef SIMD_VECTOR_TYPES
90#define SIMD_VECTOR_TYPES
91
92# include <simd/base.h>
93# if SIMD_COMPILER_HAS_REQUIRED_FEATURES
94
95/* MARK: Basic vector types */
96
97/*! @group C and Objective-C vector types
98 * @discussion These are the basic types that underpin the simd library. */
99
100/*! @abstract A scalar 8-bit signed (twos-complement) integer. */
101typedef char simd_char1;
102
103/*! @abstract A vector of two 8-bit signed (twos-complement) integers.
104 * @description In C++ and Metal, this type is also available as
105 * simd::char2. The alignment of this type is greater than the alignment of
106 * char; if you need to operate on data buffers that may not be suitably
107 * aligned, you should access them using simd_packed_char2 instead. */
108typedef __attribute__((__ext_vector_type__(2))) char simd_char2;
109
110/*! @abstract A vector of three 8-bit signed (twos-complement) integers.
111 * @description In C++ and Metal, this type is also available as
112 * simd::char3. Note that vectors of this type are padded to have the same
113 * size and alignment as simd_char4. */
114typedef __attribute__((__ext_vector_type__(3))) char simd_char3;
115
116/*! @abstract A vector of four 8-bit signed (twos-complement) integers.
117 * @description In C++ and Metal, this type is also available as
118 * simd::char4. The alignment of this type is greater than the alignment of
119 * char; if you need to operate on data buffers that may not be suitably
120 * aligned, you should access them using simd_packed_char4 instead. */
121typedef __attribute__((__ext_vector_type__(4))) char simd_char4;
122
123/*! @abstract A vector of eight 8-bit signed (twos-complement) integers.
124 * @description In C++ this type is also available as simd::char8. This
125 * type is not available in Metal. The alignment of this type is greater
126 * than the alignment of char; if you need to operate on data buffers that
127 * may not be suitably aligned, you should access them using
128 * simd_packed_char8 instead. */
129typedef __attribute__((__ext_vector_type__(8))) char simd_char8;
130
131/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers.
132 * @description In C++ this type is also available as simd::char16. This
133 * type is not available in Metal. The alignment of this type is greater
134 * than the alignment of char; if you need to operate on data buffers that
135 * may not be suitably aligned, you should access them using
136 * simd_packed_char16 instead. */
137typedef __attribute__((__ext_vector_type__(16))) char simd_char16;
138
139/*! @abstract A vector of thirty-two 8-bit signed (twos-complement)
140 * integers.
141 * @description In C++ this type is also available as simd::char32. This
142 * type is not available in Metal. The alignment of this type is greater
143 * than the alignment of char; if you need to operate on data buffers that
144 * may not be suitably aligned, you should access them using
145 * simd_packed_char32 instead. */
146typedef __attribute__((__ext_vector_type__(32),__aligned__(16))) char simd_char32;
147
148/*! @abstract A vector of sixty-four 8-bit signed (twos-complement)
149 * integers.
150 * @description In C++ this type is also available as simd::char64. This
151 * type is not available in Metal. The alignment of this type is greater
152 * than the alignment of char; if you need to operate on data buffers that
153 * may not be suitably aligned, you should access them using
154 * simd_packed_char64 instead. */
155typedef __attribute__((__ext_vector_type__(64),__aligned__(16))) char simd_char64;
156
157/*! @abstract A scalar 8-bit unsigned integer. */
158typedef unsigned char simd_uchar1;
159
160/*! @abstract A vector of two 8-bit unsigned integers.
161 * @description In C++ and Metal, this type is also available as
162 * simd::uchar2. The alignment of this type is greater than the alignment
163 * of unsigned char; if you need to operate on data buffers that may not be
164 * suitably aligned, you should access them using simd_packed_uchar2
165 * instead. */
166typedef __attribute__((__ext_vector_type__(2))) unsigned char simd_uchar2;
167
168/*! @abstract A vector of three 8-bit unsigned integers.
169 * @description In C++ and Metal, this type is also available as
170 * simd::uchar3. Note that vectors of this type are padded to have the same
171 * size and alignment as simd_uchar4. */
172typedef __attribute__((__ext_vector_type__(3))) unsigned char simd_uchar3;
173
174/*! @abstract A vector of four 8-bit unsigned integers.
175 * @description In C++ and Metal, this type is also available as
176 * simd::uchar4. The alignment of this type is greater than the alignment
177 * of unsigned char; if you need to operate on data buffers that may not be
178 * suitably aligned, you should access them using simd_packed_uchar4
179 * instead. */
180typedef __attribute__((__ext_vector_type__(4))) unsigned char simd_uchar4;
181
182/*! @abstract A vector of eight 8-bit unsigned integers.
183 * @description In C++ this type is also available as simd::uchar8. This
184 * type is not available in Metal. The alignment of this type is greater
185 * than the alignment of unsigned char; if you need to operate on data
186 * buffers that may not be suitably aligned, you should access them using
187 * simd_packed_uchar8 instead. */
188typedef __attribute__((__ext_vector_type__(8))) unsigned char simd_uchar8;
189
190/*! @abstract A vector of sixteen 8-bit unsigned integers.
191 * @description In C++ this type is also available as simd::uchar16. This
192 * type is not available in Metal. The alignment of this type is greater
193 * than the alignment of unsigned char; if you need to operate on data
194 * buffers that may not be suitably aligned, you should access them using
195 * simd_packed_uchar16 instead. */
196typedef __attribute__((__ext_vector_type__(16))) unsigned char simd_uchar16;
197
198/*! @abstract A vector of thirty-two 8-bit unsigned integers.
199 * @description In C++ this type is also available as simd::uchar32. This
200 * type is not available in Metal. The alignment of this type is greater
201 * than the alignment of unsigned char; if you need to operate on data
202 * buffers that may not be suitably aligned, you should access them using
203 * simd_packed_uchar32 instead. */
204typedef __attribute__((__ext_vector_type__(32),__aligned__(16))) unsigned char simd_uchar32;
205
206/*! @abstract A vector of sixty-four 8-bit unsigned integers.
207 * @description In C++ this type is also available as simd::uchar64. This
208 * type is not available in Metal. The alignment of this type is greater
209 * than the alignment of unsigned char; if you need to operate on data
210 * buffers that may not be suitably aligned, you should access them using
211 * simd_packed_uchar64 instead. */
212typedef __attribute__((__ext_vector_type__(64),__aligned__(16))) unsigned char simd_uchar64;
213
214/*! @abstract A scalar 16-bit signed (twos-complement) integer. */
215typedef short simd_short1;
216
217/*! @abstract A vector of two 16-bit signed (twos-complement) integers.
218 * @description In C++ and Metal, this type is also available as
219 * simd::short2. The alignment of this type is greater than the alignment
220 * of short; if you need to operate on data buffers that may not be
221 * suitably aligned, you should access them using simd_packed_short2
222 * instead. */
223typedef __attribute__((__ext_vector_type__(2))) short simd_short2;
224
225/*! @abstract A vector of three 16-bit signed (twos-complement) integers.
226 * @description In C++ and Metal, this type is also available as
227 * simd::short3. Note that vectors of this type are padded to have the same
228 * size and alignment as simd_short4. */
229typedef __attribute__((__ext_vector_type__(3))) short simd_short3;
230
231/*! @abstract A vector of four 16-bit signed (twos-complement) integers.
232 * @description In C++ and Metal, this type is also available as
233 * simd::short4. The alignment of this type is greater than the alignment
234 * of short; if you need to operate on data buffers that may not be
235 * suitably aligned, you should access them using simd_packed_short4
236 * instead. */
237typedef __attribute__((__ext_vector_type__(4))) short simd_short4;
238
239/*! @abstract A vector of eight 16-bit signed (twos-complement) integers.
240 * @description In C++ this type is also available as simd::short8. This
241 * type is not available in Metal. The alignment of this type is greater
242 * than the alignment of short; if you need to operate on data buffers that
243 * may not be suitably aligned, you should access them using
244 * simd_packed_short8 instead. */
245typedef __attribute__((__ext_vector_type__(8))) short simd_short8;
246
247/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers.
248 * @description In C++ this type is also available as simd::short16. This
249 * type is not available in Metal. The alignment of this type is greater
250 * than the alignment of short; if you need to operate on data buffers that
251 * may not be suitably aligned, you should access them using
252 * simd_packed_short16 instead. */
253typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) short simd_short16;
254
255/*! @abstract A vector of thirty-two 16-bit signed (twos-complement)
256 * integers.
257 * @description In C++ this type is also available as simd::short32. This
258 * type is not available in Metal. The alignment of this type is greater
259 * than the alignment of short; if you need to operate on data buffers that
260 * may not be suitably aligned, you should access them using
261 * simd_packed_short32 instead. */
262typedef __attribute__((__ext_vector_type__(32),__aligned__(16))) short simd_short32;
263
264/*! @abstract A scalar 16-bit unsigned integer. */
265typedef unsigned short simd_ushort1;
266
267/*! @abstract A vector of two 16-bit unsigned integers.
268 * @description In C++ and Metal, this type is also available as
269 * simd::ushort2. The alignment of this type is greater than the alignment
270 * of unsigned short; if you need to operate on data buffers that may not
271 * be suitably aligned, you should access them using simd_packed_ushort2
272 * instead. */
273typedef __attribute__((__ext_vector_type__(2))) unsigned short simd_ushort2;
274
275/*! @abstract A vector of three 16-bit unsigned integers.
276 * @description In C++ and Metal, this type is also available as
277 * simd::ushort3. Note that vectors of this type are padded to have the
278 * same size and alignment as simd_ushort4. */
279typedef __attribute__((__ext_vector_type__(3))) unsigned short simd_ushort3;
280
281/*! @abstract A vector of four 16-bit unsigned integers.
282 * @description In C++ and Metal, this type is also available as
283 * simd::ushort4. The alignment of this type is greater than the alignment
284 * of unsigned short; if you need to operate on data buffers that may not
285 * be suitably aligned, you should access them using simd_packed_ushort4
286 * instead. */
287typedef __attribute__((__ext_vector_type__(4))) unsigned short simd_ushort4;
288
289/*! @abstract A vector of eight 16-bit unsigned integers.
290 * @description In C++ this type is also available as simd::ushort8. This
291 * type is not available in Metal. The alignment of this type is greater
292 * than the alignment of unsigned short; if you need to operate on data
293 * buffers that may not be suitably aligned, you should access them using
294 * simd_packed_ushort8 instead. */
295typedef __attribute__((__ext_vector_type__(8))) unsigned short simd_ushort8;
296
297/*! @abstract A vector of sixteen 16-bit unsigned integers.
298 * @description In C++ this type is also available as simd::ushort16. This
299 * type is not available in Metal. The alignment of this type is greater
300 * than the alignment of unsigned short; if you need to operate on data
301 * buffers that may not be suitably aligned, you should access them using
302 * simd_packed_ushort16 instead. */
303typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) unsigned short simd_ushort16;
304
305/*! @abstract A vector of thirty-two 16-bit unsigned integers.
306 * @description In C++ this type is also available as simd::ushort32. This
307 * type is not available in Metal. The alignment of this type is greater
308 * than the alignment of unsigned short; if you need to operate on data
309 * buffers that may not be suitably aligned, you should access them using
310 * simd_packed_ushort32 instead. */
311typedef __attribute__((__ext_vector_type__(32),__aligned__(16))) unsigned short simd_ushort32;
312
313/*! @abstract A scalar 32-bit signed (twos-complement) integer. */
314typedef int simd_int1;
315
316/*! @abstract A vector of two 32-bit signed (twos-complement) integers.
317 * @description In C++ and Metal, this type is also available as
318 * simd::int2. The alignment of this type is greater than the alignment of
319 * int; if you need to operate on data buffers that may not be suitably
320 * aligned, you should access them using simd_packed_int2 instead. */
321typedef __attribute__((__ext_vector_type__(2))) int simd_int2;
322
323/*! @abstract A vector of three 32-bit signed (twos-complement) integers.
324 * @description In C++ and Metal, this type is also available as
325 * simd::int3. Note that vectors of this type are padded to have the same
326 * size and alignment as simd_int4. */
327typedef __attribute__((__ext_vector_type__(3))) int simd_int3;
328
329/*! @abstract A vector of four 32-bit signed (twos-complement) integers.
330 * @description In C++ and Metal, this type is also available as
331 * simd::int4. The alignment of this type is greater than the alignment of
332 * int; if you need to operate on data buffers that may not be suitably
333 * aligned, you should access them using simd_packed_int4 instead. */
334typedef __attribute__((__ext_vector_type__(4))) int simd_int4;
335
336/*! @abstract A vector of eight 32-bit signed (twos-complement) integers.
337 * @description In C++ this type is also available as simd::int8. This type
338 * is not available in Metal. The alignment of this type is greater than
339 * the alignment of int; if you need to operate on data buffers that may
340 * not be suitably aligned, you should access them using simd_packed_int8
341 * instead. */
342typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) int simd_int8;
343
344/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers.
345 * @description In C++ this type is also available as simd::int16. This
346 * type is not available in Metal. The alignment of this type is greater
347 * than the alignment of int; if you need to operate on data buffers that
348 * may not be suitably aligned, you should access them using
349 * simd_packed_int16 instead. */
350typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) int simd_int16;
351
352/*! @abstract A scalar 32-bit unsigned integer. */
353typedef unsigned int simd_uint1;
354
355/*! @abstract A vector of two 32-bit unsigned integers.
356 * @description In C++ and Metal, this type is also available as
357 * simd::uint2. The alignment of this type is greater than the alignment of
358 * unsigned int; if you need to operate on data buffers that may not be
359 * suitably aligned, you should access them using simd_packed_uint2
360 * instead. */
361typedef __attribute__((__ext_vector_type__(2))) unsigned int simd_uint2;
362
363/*! @abstract A vector of three 32-bit unsigned integers.
364 * @description In C++ and Metal, this type is also available as
365 * simd::uint3. Note that vectors of this type are padded to have the same
366 * size and alignment as simd_uint4. */
367typedef __attribute__((__ext_vector_type__(3))) unsigned int simd_uint3;
368
369/*! @abstract A vector of four 32-bit unsigned integers.
370 * @description In C++ and Metal, this type is also available as
371 * simd::uint4. The alignment of this type is greater than the alignment of
372 * unsigned int; if you need to operate on data buffers that may not be
373 * suitably aligned, you should access them using simd_packed_uint4
374 * instead. */
375typedef __attribute__((__ext_vector_type__(4))) unsigned int simd_uint4;
376
377/*! @abstract A vector of eight 32-bit unsigned integers.
378 * @description In C++ this type is also available as simd::uint8. This
379 * type is not available in Metal. The alignment of this type is greater
380 * than the alignment of unsigned int; if you need to operate on data
381 * buffers that may not be suitably aligned, you should access them using
382 * simd_packed_uint8 instead. */
383typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) unsigned int simd_uint8;
384
385/*! @abstract A vector of sixteen 32-bit unsigned integers.
386 * @description In C++ this type is also available as simd::uint16. This
387 * type is not available in Metal. The alignment of this type is greater
388 * than the alignment of unsigned int; if you need to operate on data
389 * buffers that may not be suitably aligned, you should access them using
390 * simd_packed_uint16 instead. */
391typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) unsigned int simd_uint16;
392
393/*! @abstract A scalar 32-bit floating-point number. */
394typedef float simd_float1;
395
396/*! @abstract A vector of two 32-bit floating-point numbers.
397 * @description In C++ and Metal, this type is also available as
398 * simd::float2. The alignment of this type is greater than the alignment
399 * of float; if you need to operate on data buffers that may not be
400 * suitably aligned, you should access them using simd_packed_float2
401 * instead. */
402typedef __attribute__((__ext_vector_type__(2))) float simd_float2;
403
404/*! @abstract A vector of three 32-bit floating-point numbers.
405 * @description In C++ and Metal, this type is also available as
406 * simd::float3. Note that vectors of this type are padded to have the same
407 * size and alignment as simd_float4. */
408typedef __attribute__((__ext_vector_type__(3))) float simd_float3;
409
410/*! @abstract A vector of four 32-bit floating-point numbers.
411 * @description In C++ and Metal, this type is also available as
412 * simd::float4. The alignment of this type is greater than the alignment
413 * of float; if you need to operate on data buffers that may not be
414 * suitably aligned, you should access them using simd_packed_float4
415 * instead. */
416typedef __attribute__((__ext_vector_type__(4))) float simd_float4;
417
418/*! @abstract A vector of eight 32-bit floating-point numbers.
419 * @description In C++ this type is also available as simd::float8. This
420 * type is not available in Metal. The alignment of this type is greater
421 * than the alignment of float; if you need to operate on data buffers that
422 * may not be suitably aligned, you should access them using
423 * simd_packed_float8 instead. */
424typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) float simd_float8;
425
426/*! @abstract A vector of sixteen 32-bit floating-point numbers.
427 * @description In C++ this type is also available as simd::float16. This
428 * type is not available in Metal. The alignment of this type is greater
429 * than the alignment of float; if you need to operate on data buffers that
430 * may not be suitably aligned, you should access them using
431 * simd_packed_float16 instead. */
432typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) float simd_float16;
433
434/*! @abstract A scalar 64-bit signed (twos-complement) integer. */
435#if defined __LP64__
436typedef long simd_long1;
437#else
438typedef long long simd_long1;
439#endif
440
441/*! @abstract A vector of two 64-bit signed (twos-complement) integers.
442 * @description In C++ and Metal, this type is also available as
443 * simd::long2. The alignment of this type is greater than the alignment of
444 * simd_long1; if you need to operate on data buffers that may not be
445 * suitably aligned, you should access them using simd_packed_long2
446 * instead. */
447typedef __attribute__((__ext_vector_type__(2))) simd_long1 simd_long2;
448
449/*! @abstract A vector of three 64-bit signed (twos-complement) integers.
450 * @description In C++ and Metal, this type is also available as
451 * simd::long3. Note that vectors of this type are padded to have the same
452 * size and alignment as simd_long4. */
453typedef __attribute__((__ext_vector_type__(3),__aligned__(16))) simd_long1 simd_long3;
454
455/*! @abstract A vector of four 64-bit signed (twos-complement) integers.
456 * @description In C++ and Metal, this type is also available as
457 * simd::long4. The alignment of this type is greater than the alignment of
458 * simd_long1; if you need to operate on data buffers that may not be
459 * suitably aligned, you should access them using simd_packed_long4
460 * instead. */
461typedef __attribute__((__ext_vector_type__(4),__aligned__(16))) simd_long1 simd_long4;
462
463/*! @abstract A vector of eight 64-bit signed (twos-complement) integers.
464 * @description In C++ this type is also available as simd::long8. This
465 * type is not available in Metal. The alignment of this type is greater
466 * than the alignment of simd_long1; if you need to operate on data buffers
467 * that may not be suitably aligned, you should access them using
468 * simd_packed_long8 instead. */
469typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) simd_long1 simd_long8;
470
471/*! @abstract A scalar 64-bit unsigned integer. */
472#if defined __LP64__
473typedef unsigned long simd_ulong1;
474#else
475typedef unsigned long long simd_ulong1;
476#endif
477
478/*! @abstract A vector of two 64-bit unsigned integers.
479 * @description In C++ and Metal, this type is also available as
480 * simd::ulong2. The alignment of this type is greater than the alignment
481 * of simd_ulong1; if you need to operate on data buffers that may not be
482 * suitably aligned, you should access them using simd_packed_ulong2
483 * instead. */
484typedef __attribute__((__ext_vector_type__(2))) simd_ulong1 simd_ulong2;
485
486/*! @abstract A vector of three 64-bit unsigned integers.
487 * @description In C++ and Metal, this type is also available as
488 * simd::ulong3. Note that vectors of this type are padded to have the same
489 * size and alignment as simd_ulong4. */
490typedef __attribute__((__ext_vector_type__(3),__aligned__(16))) simd_ulong1 simd_ulong3;
491
492/*! @abstract A vector of four 64-bit unsigned integers.
493 * @description In C++ and Metal, this type is also available as
494 * simd::ulong4. The alignment of this type is greater than the alignment
495 * of simd_ulong1; if you need to operate on data buffers that may not be
496 * suitably aligned, you should access them using simd_packed_ulong4
497 * instead. */
498typedef __attribute__((__ext_vector_type__(4),__aligned__(16))) simd_ulong1 simd_ulong4;
499
500/*! @abstract A vector of eight 64-bit unsigned integers.
501 * @description In C++ this type is also available as simd::ulong8. This
502 * type is not available in Metal. The alignment of this type is greater
503 * than the alignment of simd_ulong1; if you need to operate on data
504 * buffers that may not be suitably aligned, you should access them using
505 * simd_packed_ulong8 instead. */
506typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) simd_ulong1 simd_ulong8;
507
508/*! @abstract A scalar 64-bit floating-point number. */
509typedef double simd_double1;
510
511/*! @abstract A vector of two 64-bit floating-point numbers.
512 * @description In C++ and Metal, this type is also available as
513 * simd::double2. The alignment of this type is greater than the alignment
514 * of double; if you need to operate on data buffers that may not be
515 * suitably aligned, you should access them using simd_packed_double2
516 * instead. */
517typedef __attribute__((__ext_vector_type__(2))) double simd_double2;
518
519/*! @abstract A vector of three 64-bit floating-point numbers.
520 * @description In C++ and Metal, this type is also available as
521 * simd::double3. Note that vectors of this type are padded to have the
522 * same size and alignment as simd_double4. */
523typedef __attribute__((__ext_vector_type__(3),__aligned__(16))) double simd_double3;
524
525/*! @abstract A vector of four 64-bit floating-point numbers.
526 * @description In C++ and Metal, this type is also available as
527 * simd::double4. The alignment of this type is greater than the alignment
528 * of double; if you need to operate on data buffers that may not be
529 * suitably aligned, you should access them using simd_packed_double4
530 * instead. */
531typedef __attribute__((__ext_vector_type__(4),__aligned__(16))) double simd_double4;
532
533/*! @abstract A vector of eight 64-bit floating-point numbers.
534 * @description In C++ this type is also available as simd::double8. This
535 * type is not available in Metal. The alignment of this type is greater
536 * than the alignment of double; if you need to operate on data buffers
537 * that may not be suitably aligned, you should access them using
538 * simd_packed_double8 instead. */
539typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) double simd_double8;
540
541/* MARK: C++ vector types */
542#if defined __cplusplus
543/*! @group C++ and Metal vector types
544 * @discussion Shorter type names available within the simd:: namespace.
545 * Each of these types is interchangable with the corresponding C type
546 * with the `simd_` prefix. */
547namespace simd {
548 /*! @abstract A scalar 8-bit signed (twos-complement) integer.
549 * @discussion In C and Objective-C, this type is available as
550 * simd_char1. */
551typedef ::simd_char1 char1;
552
553 /*! @abstract A vector of two 8-bit signed (twos-complement) integers.
554 * @description In C or Objective-C, this type is available as
555 * simd_char2. The alignment of this type is greater than the alignment
556 * of char; if you need to operate on data buffers that may not be
557 * suitably aligned, you should access them using simd::packed_char2
558 * instead. */
559typedef ::simd_char2 char2;
560
561 /*! @abstract A vector of three 8-bit signed (twos-complement) integers.
562 * @description In C or Objective-C, this type is available as
563 * simd_char3. Vectors of this type are padded to have the same size and
564 * alignment as simd_char4. */
565typedef ::simd_char3 char3;
566
567 /*! @abstract A vector of four 8-bit signed (twos-complement) integers.
568 * @description In C or Objective-C, this type is available as
569 * simd_char4. The alignment of this type is greater than the alignment
570 * of char; if you need to operate on data buffers that may not be
571 * suitably aligned, you should access them using simd::packed_char4
572 * instead. */
573typedef ::simd_char4 char4;
574
575 /*! @abstract A vector of eight 8-bit signed (twos-complement) integers.
576 * @description This type is not available in Metal. In C or Objective-C,
577 * this type is available as simd_char8. The alignment of this type is
578 * greater than the alignment of char; if you need to operate on data
579 * buffers that may not be suitably aligned, you should access them using
580 * simd::packed_char8 instead. */
581typedef ::simd_char8 char8;
582
583 /*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers.
584 * @description This type is not available in Metal. In C or Objective-C,
585 * this type is available as simd_char16. The alignment of this type is
586 * greater than the alignment of char; if you need to operate on data
587 * buffers that may not be suitably aligned, you should access them using
588 * simd::packed_char16 instead. */
589typedef ::simd_char16 char16;
590
591 /*! @abstract A vector of thirty-two 8-bit signed (twos-complement)
592 * integers.
593 * @description This type is not available in Metal. In C or Objective-C,
594 * this type is available as simd_char32. The alignment of this type is
595 * greater than the alignment of char; if you need to operate on data
596 * buffers that may not be suitably aligned, you should access them using
597 * simd::packed_char32 instead. */
598typedef ::simd_char32 char32;
599
600 /*! @abstract A vector of sixty-four 8-bit signed (twos-complement)
601 * integers.
602 * @description This type is not available in Metal. In C or Objective-C,
603 * this type is available as simd_char64. The alignment of this type is
604 * greater than the alignment of char; if you need to operate on data
605 * buffers that may not be suitably aligned, you should access them using
606 * simd::packed_char64 instead. */
607typedef ::simd_char64 char64;
608
609 /*! @abstract A scalar 8-bit unsigned integer.
610 * @discussion In C and Objective-C, this type is available as
611 * simd_uchar1. */
612typedef ::simd_uchar1 uchar1;
613
614 /*! @abstract A vector of two 8-bit unsigned integers.
615 * @description In C or Objective-C, this type is available as
616 * simd_uchar2. The alignment of this type is greater than the alignment
617 * of unsigned char; if you need to operate on data buffers that may not
618 * be suitably aligned, you should access them using simd::packed_uchar2
619 * instead. */
620typedef ::simd_uchar2 uchar2;
621
622 /*! @abstract A vector of three 8-bit unsigned integers.
623 * @description In C or Objective-C, this type is available as
624 * simd_uchar3. Vectors of this type are padded to have the same size and
625 * alignment as simd_uchar4. */
626typedef ::simd_uchar3 uchar3;
627
628 /*! @abstract A vector of four 8-bit unsigned integers.
629 * @description In C or Objective-C, this type is available as
630 * simd_uchar4. The alignment of this type is greater than the alignment
631 * of unsigned char; if you need to operate on data buffers that may not
632 * be suitably aligned, you should access them using simd::packed_uchar4
633 * instead. */
634typedef ::simd_uchar4 uchar4;
635
636 /*! @abstract A vector of eight 8-bit unsigned integers.
637 * @description This type is not available in Metal. In C or Objective-C,
638 * this type is available as simd_uchar8. The alignment of this type is
639 * greater than the alignment of unsigned char; if you need to operate on
640 * data buffers that may not be suitably aligned, you should access them
641 * using simd::packed_uchar8 instead. */
642typedef ::simd_uchar8 uchar8;
643
644 /*! @abstract A vector of sixteen 8-bit unsigned integers.
645 * @description This type is not available in Metal. In C or Objective-C,
646 * this type is available as simd_uchar16. The alignment of this type is
647 * greater than the alignment of unsigned char; if you need to operate on
648 * data buffers that may not be suitably aligned, you should access them
649 * using simd::packed_uchar16 instead. */
650typedef ::simd_uchar16 uchar16;
651
652 /*! @abstract A vector of thirty-two 8-bit unsigned integers.
653 * @description This type is not available in Metal. In C or Objective-C,
654 * this type is available as simd_uchar32. The alignment of this type is
655 * greater than the alignment of unsigned char; if you need to operate on
656 * data buffers that may not be suitably aligned, you should access them
657 * using simd::packed_uchar32 instead. */
658typedef ::simd_uchar32 uchar32;
659
660 /*! @abstract A vector of sixty-four 8-bit unsigned integers.
661 * @description This type is not available in Metal. In C or Objective-C,
662 * this type is available as simd_uchar64. The alignment of this type is
663 * greater than the alignment of unsigned char; if you need to operate on
664 * data buffers that may not be suitably aligned, you should access them
665 * using simd::packed_uchar64 instead. */
666typedef ::simd_uchar64 uchar64;
667
668 /*! @abstract A scalar 16-bit signed (twos-complement) integer.
669 * @discussion In C and Objective-C, this type is available as
670 * simd_short1. */
671typedef ::simd_short1 short1;
672
673 /*! @abstract A vector of two 16-bit signed (twos-complement) integers.
674 * @description In C or Objective-C, this type is available as
675 * simd_short2. The alignment of this type is greater than the alignment
676 * of short; if you need to operate on data buffers that may not be
677 * suitably aligned, you should access them using simd::packed_short2
678 * instead. */
679typedef ::simd_short2 short2;
680
681 /*! @abstract A vector of three 16-bit signed (twos-complement) integers.
682 * @description In C or Objective-C, this type is available as
683 * simd_short3. Vectors of this type are padded to have the same size and
684 * alignment as simd_short4. */
685typedef ::simd_short3 short3;
686
687 /*! @abstract A vector of four 16-bit signed (twos-complement) integers.
688 * @description In C or Objective-C, this type is available as
689 * simd_short4. The alignment of this type is greater than the alignment
690 * of short; if you need to operate on data buffers that may not be
691 * suitably aligned, you should access them using simd::packed_short4
692 * instead. */
693typedef ::simd_short4 short4;
694
695 /*! @abstract A vector of eight 16-bit signed (twos-complement) integers.
696 * @description This type is not available in Metal. In C or Objective-C,
697 * this type is available as simd_short8. The alignment of this type is
698 * greater than the alignment of short; if you need to operate on data
699 * buffers that may not be suitably aligned, you should access them using
700 * simd::packed_short8 instead. */
701typedef ::simd_short8 short8;
702
703 /*! @abstract A vector of sixteen 16-bit signed (twos-complement)
704 * integers.
705 * @description This type is not available in Metal. In C or Objective-C,
706 * this type is available as simd_short16. The alignment of this type is
707 * greater than the alignment of short; if you need to operate on data
708 * buffers that may not be suitably aligned, you should access them using
709 * simd::packed_short16 instead. */
710typedef ::simd_short16 short16;
711
712 /*! @abstract A vector of thirty-two 16-bit signed (twos-complement)
713 * integers.
714 * @description This type is not available in Metal. In C or Objective-C,
715 * this type is available as simd_short32. The alignment of this type is
716 * greater than the alignment of short; if you need to operate on data
717 * buffers that may not be suitably aligned, you should access them using
718 * simd::packed_short32 instead. */
719typedef ::simd_short32 short32;
720
721 /*! @abstract A scalar 16-bit unsigned integer.
722 * @discussion In C and Objective-C, this type is available as
723 * simd_ushort1. */
724typedef ::simd_ushort1 ushort1;
725
726 /*! @abstract A vector of two 16-bit unsigned integers.
727 * @description In C or Objective-C, this type is available as
728 * simd_ushort2. The alignment of this type is greater than the alignment
729 * of unsigned short; if you need to operate on data buffers that may not
730 * be suitably aligned, you should access them using simd::packed_ushort2
731 * instead. */
732typedef ::simd_ushort2 ushort2;
733
734 /*! @abstract A vector of three 16-bit unsigned integers.
735 * @description In C or Objective-C, this type is available as
736 * simd_ushort3. Vectors of this type are padded to have the same size
737 * and alignment as simd_ushort4. */
738typedef ::simd_ushort3 ushort3;
739
740 /*! @abstract A vector of four 16-bit unsigned integers.
741 * @description In C or Objective-C, this type is available as
742 * simd_ushort4. The alignment of this type is greater than the alignment
743 * of unsigned short; if you need to operate on data buffers that may not
744 * be suitably aligned, you should access them using simd::packed_ushort4
745 * instead. */
746typedef ::simd_ushort4 ushort4;
747
748 /*! @abstract A vector of eight 16-bit unsigned integers.
749 * @description This type is not available in Metal. In C or Objective-C,
750 * this type is available as simd_ushort8. The alignment of this type is
751 * greater than the alignment of unsigned short; if you need to operate
752 * on data buffers that may not be suitably aligned, you should access
753 * them using simd::packed_ushort8 instead. */
754typedef ::simd_ushort8 ushort8;
755
756 /*! @abstract A vector of sixteen 16-bit unsigned integers.
757 * @description This type is not available in Metal. In C or Objective-C,
758 * this type is available as simd_ushort16. The alignment of this type is
759 * greater than the alignment of unsigned short; if you need to operate
760 * on data buffers that may not be suitably aligned, you should access
761 * them using simd::packed_ushort16 instead. */
762typedef ::simd_ushort16 ushort16;
763
764 /*! @abstract A vector of thirty-two 16-bit unsigned integers.
765 * @description This type is not available in Metal. In C or Objective-C,
766 * this type is available as simd_ushort32. The alignment of this type is
767 * greater than the alignment of unsigned short; if you need to operate
768 * on data buffers that may not be suitably aligned, you should access
769 * them using simd::packed_ushort32 instead. */
770typedef ::simd_ushort32 ushort32;
771
772 /*! @abstract A scalar 32-bit signed (twos-complement) integer.
773 * @discussion In C and Objective-C, this type is available as simd_int1. */
774typedef ::simd_int1 int1;
775
776 /*! @abstract A vector of two 32-bit signed (twos-complement) integers.
777 * @description In C or Objective-C, this type is available as simd_int2.
778 * The alignment of this type is greater than the alignment of int; if
779 * you need to operate on data buffers that may not be suitably aligned,
780 * you should access them using simd::packed_int2 instead. */
781typedef ::simd_int2 int2;
782
783 /*! @abstract A vector of three 32-bit signed (twos-complement) integers.
784 * @description In C or Objective-C, this type is available as simd_int3.
785 * Vectors of this type are padded to have the same size and alignment as
786 * simd_int4. */
787typedef ::simd_int3 int3;
788
789 /*! @abstract A vector of four 32-bit signed (twos-complement) integers.
790 * @description In C or Objective-C, this type is available as simd_int4.
791 * The alignment of this type is greater than the alignment of int; if
792 * you need to operate on data buffers that may not be suitably aligned,
793 * you should access them using simd::packed_int4 instead. */
794typedef ::simd_int4 int4;
795
796 /*! @abstract A vector of eight 32-bit signed (twos-complement) integers.
797 * @description This type is not available in Metal. In C or Objective-C,
798 * this type is available as simd_int8. The alignment of this type is
799 * greater than the alignment of int; if you need to operate on data
800 * buffers that may not be suitably aligned, you should access them using
801 * simd::packed_int8 instead. */
802typedef ::simd_int8 int8;
803
804 /*! @abstract A vector of sixteen 32-bit signed (twos-complement)
805 * integers.
806 * @description This type is not available in Metal. In C or Objective-C,
807 * this type is available as simd_int16. The alignment of this type is
808 * greater than the alignment of int; if you need to operate on data
809 * buffers that may not be suitably aligned, you should access them using
810 * simd::packed_int16 instead. */
811typedef ::simd_int16 int16;
812
813 /*! @abstract A scalar 32-bit unsigned integer.
814 * @discussion In C and Objective-C, this type is available as
815 * simd_uint1. */
816typedef ::simd_uint1 uint1;
817
818 /*! @abstract A vector of two 32-bit unsigned integers.
819 * @description In C or Objective-C, this type is available as
820 * simd_uint2. The alignment of this type is greater than the alignment
821 * of unsigned int; if you need to operate on data buffers that may not
822 * be suitably aligned, you should access them using simd::packed_uint2
823 * instead. */
824typedef ::simd_uint2 uint2;
825
826 /*! @abstract A vector of three 32-bit unsigned integers.
827 * @description In C or Objective-C, this type is available as
828 * simd_uint3. Vectors of this type are padded to have the same size and
829 * alignment as simd_uint4. */
830typedef ::simd_uint3 uint3;
831
832 /*! @abstract A vector of four 32-bit unsigned integers.
833 * @description In C or Objective-C, this type is available as
834 * simd_uint4. The alignment of this type is greater than the alignment
835 * of unsigned int; if you need to operate on data buffers that may not
836 * be suitably aligned, you should access them using simd::packed_uint4
837 * instead. */
838typedef ::simd_uint4 uint4;
839
840 /*! @abstract A vector of eight 32-bit unsigned integers.
841 * @description This type is not available in Metal. In C or Objective-C,
842 * this type is available as simd_uint8. The alignment of this type is
843 * greater than the alignment of unsigned int; if you need to operate on
844 * data buffers that may not be suitably aligned, you should access them
845 * using simd::packed_uint8 instead. */
846typedef ::simd_uint8 uint8;
847
848 /*! @abstract A vector of sixteen 32-bit unsigned integers.
849 * @description This type is not available in Metal. In C or Objective-C,
850 * this type is available as simd_uint16. The alignment of this type is
851 * greater than the alignment of unsigned int; if you need to operate on
852 * data buffers that may not be suitably aligned, you should access them
853 * using simd::packed_uint16 instead. */
854typedef ::simd_uint16 uint16;
855
856 /*! @abstract A scalar 32-bit floating-point number.
857 * @discussion In C and Objective-C, this type is available as
858 * simd_float1. */
859typedef ::simd_float1 float1;
860
861 /*! @abstract A vector of two 32-bit floating-point numbers.
862 * @description In C or Objective-C, this type is available as
863 * simd_float2. The alignment of this type is greater than the alignment
864 * of float; if you need to operate on data buffers that may not be
865 * suitably aligned, you should access them using simd::packed_float2
866 * instead. */
867typedef ::simd_float2 float2;
868
869 /*! @abstract A vector of three 32-bit floating-point numbers.
870 * @description In C or Objective-C, this type is available as
871 * simd_float3. Vectors of this type are padded to have the same size and
872 * alignment as simd_float4. */
873typedef ::simd_float3 float3;
874
875 /*! @abstract A vector of four 32-bit floating-point numbers.
876 * @description In C or Objective-C, this type is available as
877 * simd_float4. The alignment of this type is greater than the alignment
878 * of float; if you need to operate on data buffers that may not be
879 * suitably aligned, you should access them using simd::packed_float4
880 * instead. */
881typedef ::simd_float4 float4;
882
883 /*! @abstract A vector of eight 32-bit floating-point numbers.
884 * @description This type is not available in Metal. In C or Objective-C,
885 * this type is available as simd_float8. The alignment of this type is
886 * greater than the alignment of float; if you need to operate on data
887 * buffers that may not be suitably aligned, you should access them using
888 * simd::packed_float8 instead. */
889typedef ::simd_float8 float8;
890
891 /*! @abstract A vector of sixteen 32-bit floating-point numbers.
892 * @description This type is not available in Metal. In C or Objective-C,
893 * this type is available as simd_float16. The alignment of this type is
894 * greater than the alignment of float; if you need to operate on data
895 * buffers that may not be suitably aligned, you should access them using
896 * simd::packed_float16 instead. */
897typedef ::simd_float16 float16;
898
899 /*! @abstract A scalar 64-bit signed (twos-complement) integer.
900 * @discussion In C and Objective-C, this type is available as
901 * simd_long1. */
902typedef ::simd_long1 long1;
903
904 /*! @abstract A vector of two 64-bit signed (twos-complement) integers.
905 * @description In C or Objective-C, this type is available as
906 * simd_long2. The alignment of this type is greater than the alignment
907 * of simd_long1; if you need to operate on data buffers that may not be
908 * suitably aligned, you should access them using simd::packed_long2
909 * instead. */
910typedef ::simd_long2 long2;
911
912 /*! @abstract A vector of three 64-bit signed (twos-complement) integers.
913 * @description In C or Objective-C, this type is available as
914 * simd_long3. Vectors of this type are padded to have the same size and
915 * alignment as simd_long4. */
916typedef ::simd_long3 long3;
917
918 /*! @abstract A vector of four 64-bit signed (twos-complement) integers.
919 * @description In C or Objective-C, this type is available as
920 * simd_long4. The alignment of this type is greater than the alignment
921 * of simd_long1; if you need to operate on data buffers that may not be
922 * suitably aligned, you should access them using simd::packed_long4
923 * instead. */
924typedef ::simd_long4 long4;
925
926 /*! @abstract A vector of eight 64-bit signed (twos-complement) integers.
927 * @description This type is not available in Metal. In C or Objective-C,
928 * this type is available as simd_long8. The alignment of this type is
929 * greater than the alignment of simd_long1; if you need to operate on
930 * data buffers that may not be suitably aligned, you should access them
931 * using simd::packed_long8 instead. */
932typedef ::simd_long8 long8;
933
934 /*! @abstract A scalar 64-bit unsigned integer.
935 * @discussion In C and Objective-C, this type is available as
936 * simd_ulong1. */
937typedef ::simd_ulong1 ulong1;
938
939 /*! @abstract A vector of two 64-bit unsigned integers.
940 * @description In C or Objective-C, this type is available as
941 * simd_ulong2. The alignment of this type is greater than the alignment
942 * of simd_ulong1; if you need to operate on data buffers that may not be
943 * suitably aligned, you should access them using simd::packed_ulong2
944 * instead. */
945typedef ::simd_ulong2 ulong2;
946
947 /*! @abstract A vector of three 64-bit unsigned integers.
948 * @description In C or Objective-C, this type is available as
949 * simd_ulong3. Vectors of this type are padded to have the same size and
950 * alignment as simd_ulong4. */
951typedef ::simd_ulong3 ulong3;
952
953 /*! @abstract A vector of four 64-bit unsigned integers.
954 * @description In C or Objective-C, this type is available as
955 * simd_ulong4. The alignment of this type is greater than the alignment
956 * of simd_ulong1; if you need to operate on data buffers that may not be
957 * suitably aligned, you should access them using simd::packed_ulong4
958 * instead. */
959typedef ::simd_ulong4 ulong4;
960
961 /*! @abstract A vector of eight 64-bit unsigned integers.
962 * @description This type is not available in Metal. In C or Objective-C,
963 * this type is available as simd_ulong8. The alignment of this type is
964 * greater than the alignment of simd_ulong1; if you need to operate on
965 * data buffers that may not be suitably aligned, you should access them
966 * using simd::packed_ulong8 instead. */
967typedef ::simd_ulong8 ulong8;
968
969 /*! @abstract A scalar 64-bit floating-point number.
970 * @discussion In C and Objective-C, this type is available as
971 * simd_double1. */
972typedef ::simd_double1 double1;
973
974 /*! @abstract A vector of two 64-bit floating-point numbers.
975 * @description In C or Objective-C, this type is available as
976 * simd_double2. The alignment of this type is greater than the alignment
977 * of double; if you need to operate on data buffers that may not be
978 * suitably aligned, you should access them using simd::packed_double2
979 * instead. */
980typedef ::simd_double2 double2;
981
982 /*! @abstract A vector of three 64-bit floating-point numbers.
983 * @description In C or Objective-C, this type is available as
984 * simd_double3. Vectors of this type are padded to have the same size
985 * and alignment as simd_double4. */
986typedef ::simd_double3 double3;
987
988 /*! @abstract A vector of four 64-bit floating-point numbers.
989 * @description In C or Objective-C, this type is available as
990 * simd_double4. The alignment of this type is greater than the alignment
991 * of double; if you need to operate on data buffers that may not be
992 * suitably aligned, you should access them using simd::packed_double4
993 * instead. */
994typedef ::simd_double4 double4;
995
996 /*! @abstract A vector of eight 64-bit floating-point numbers.
997 * @description This type is not available in Metal. In C or Objective-C,
998 * this type is available as simd_double8. The alignment of this type is
999 * greater than the alignment of double; if you need to operate on data
1000 * buffers that may not be suitably aligned, you should access them using
1001 * simd::packed_double8 instead. */
1002typedef ::simd_double8 double8;
1003
1004} /* namespace simd:: */
1005#endif /* __cplusplus */
1006
1007/* MARK: Deprecated vector types */
1008/*! @group Deprecated vector types
1009 * @discussion These are the original types used by earlier versions of the
1010 * simd library; they are provided here for compatability with existing source
1011 * files. Use the new ("simd_"-prefixed) types for future development. */
1012
1013/*! @abstract A vector of two 8-bit signed (twos-complement) integers.
1014 * @description This type is deprecated; you should use simd_char2 or
1015 * simd::char2 instead. */
1016typedef simd_char2 vector_char2;
1017
1018/*! @abstract A vector of three 8-bit signed (twos-complement) integers.
1019 * @description This type is deprecated; you should use simd_char3 or
1020 * simd::char3 instead. */
1021typedef simd_char3 vector_char3;
1022
1023/*! @abstract A vector of four 8-bit signed (twos-complement) integers.
1024 * @description This type is deprecated; you should use simd_char4 or
1025 * simd::char4 instead. */
1026typedef simd_char4 vector_char4;
1027
1028/*! @abstract A vector of eight 8-bit signed (twos-complement) integers.
1029 * @description This type is deprecated; you should use simd_char8 or
1030 * simd::char8 instead. */
1031typedef simd_char8 vector_char8;
1032
1033/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers.
1034 * @description This type is deprecated; you should use simd_char16 or
1035 * simd::char16 instead. */
1036typedef simd_char16 vector_char16;
1037
1038/*! @abstract A vector of thirty-two 8-bit signed (twos-complement)
1039 * integers.
1040 * @description This type is deprecated; you should use simd_char32 or
1041 * simd::char32 instead. */
1042typedef simd_char32 vector_char32;
1043
1044/*! @abstract A vector of two 8-bit unsigned integers.
1045 * @description This type is deprecated; you should use simd_uchar2 or
1046 * simd::uchar2 instead. */
1047typedef simd_uchar2 vector_uchar2;
1048
1049/*! @abstract A vector of three 8-bit unsigned integers.
1050 * @description This type is deprecated; you should use simd_uchar3 or
1051 * simd::uchar3 instead. */
1052typedef simd_uchar3 vector_uchar3;
1053
1054/*! @abstract A vector of four 8-bit unsigned integers.
1055 * @description This type is deprecated; you should use simd_uchar4 or
1056 * simd::uchar4 instead. */
1057typedef simd_uchar4 vector_uchar4;
1058
1059/*! @abstract A vector of eight 8-bit unsigned integers.
1060 * @description This type is deprecated; you should use simd_uchar8 or
1061 * simd::uchar8 instead. */
1062typedef simd_uchar8 vector_uchar8;
1063
1064/*! @abstract A vector of sixteen 8-bit unsigned integers.
1065 * @description This type is deprecated; you should use simd_uchar16 or
1066 * simd::uchar16 instead. */
1067typedef simd_uchar16 vector_uchar16;
1068
1069/*! @abstract A vector of thirty-two 8-bit unsigned integers.
1070 * @description This type is deprecated; you should use simd_uchar32 or
1071 * simd::uchar32 instead. */
1072typedef simd_uchar32 vector_uchar32;
1073
1074/*! @abstract A vector of two 16-bit signed (twos-complement) integers.
1075 * @description This type is deprecated; you should use simd_short2 or
1076 * simd::short2 instead. */
1077typedef simd_short2 vector_short2;
1078
1079/*! @abstract A vector of three 16-bit signed (twos-complement) integers.
1080 * @description This type is deprecated; you should use simd_short3 or
1081 * simd::short3 instead. */
1082typedef simd_short3 vector_short3;
1083
1084/*! @abstract A vector of four 16-bit signed (twos-complement) integers.
1085 * @description This type is deprecated; you should use simd_short4 or
1086 * simd::short4 instead. */
1087typedef simd_short4 vector_short4;
1088
1089/*! @abstract A vector of eight 16-bit signed (twos-complement) integers.
1090 * @description This type is deprecated; you should use simd_short8 or
1091 * simd::short8 instead. */
1092typedef simd_short8 vector_short8;
1093
1094/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers.
1095 * @description This type is deprecated; you should use simd_short16 or
1096 * simd::short16 instead. */
1097typedef simd_short16 vector_short16;
1098
1099/*! @abstract A vector of thirty-two 16-bit signed (twos-complement)
1100 * integers.
1101 * @description This type is deprecated; you should use simd_short32 or
1102 * simd::short32 instead. */
1103typedef simd_short32 vector_short32;
1104
1105/*! @abstract A vector of two 16-bit unsigned integers.
1106 * @description This type is deprecated; you should use simd_ushort2 or
1107 * simd::ushort2 instead. */
1108typedef simd_ushort2 vector_ushort2;
1109
1110/*! @abstract A vector of three 16-bit unsigned integers.
1111 * @description This type is deprecated; you should use simd_ushort3 or
1112 * simd::ushort3 instead. */
1113typedef simd_ushort3 vector_ushort3;
1114
1115/*! @abstract A vector of four 16-bit unsigned integers.
1116 * @description This type is deprecated; you should use simd_ushort4 or
1117 * simd::ushort4 instead. */
1118typedef simd_ushort4 vector_ushort4;
1119
1120/*! @abstract A vector of eight 16-bit unsigned integers.
1121 * @description This type is deprecated; you should use simd_ushort8 or
1122 * simd::ushort8 instead. */
1123typedef simd_ushort8 vector_ushort8;
1124
1125/*! @abstract A vector of sixteen 16-bit unsigned integers.
1126 * @description This type is deprecated; you should use simd_ushort16 or
1127 * simd::ushort16 instead. */
1128typedef simd_ushort16 vector_ushort16;
1129
1130/*! @abstract A vector of thirty-two 16-bit unsigned integers.
1131 * @description This type is deprecated; you should use simd_ushort32 or
1132 * simd::ushort32 instead. */
1133typedef simd_ushort32 vector_ushort32;
1134
1135/*! @abstract A vector of two 32-bit signed (twos-complement) integers.
1136 * @description This type is deprecated; you should use simd_int2 or
1137 * simd::int2 instead. */
1138typedef simd_int2 vector_int2;
1139
1140/*! @abstract A vector of three 32-bit signed (twos-complement) integers.
1141 * @description This type is deprecated; you should use simd_int3 or
1142 * simd::int3 instead. */
1143typedef simd_int3 vector_int3;
1144
1145/*! @abstract A vector of four 32-bit signed (twos-complement) integers.
1146 * @description This type is deprecated; you should use simd_int4 or
1147 * simd::int4 instead. */
1148typedef simd_int4 vector_int4;
1149
1150/*! @abstract A vector of eight 32-bit signed (twos-complement) integers.
1151 * @description This type is deprecated; you should use simd_int8 or
1152 * simd::int8 instead. */
1153typedef simd_int8 vector_int8;
1154
1155/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers.
1156 * @description This type is deprecated; you should use simd_int16 or
1157 * simd::int16 instead. */
1158typedef simd_int16 vector_int16;
1159
1160/*! @abstract A vector of two 32-bit unsigned integers.
1161 * @description This type is deprecated; you should use simd_uint2 or
1162 * simd::uint2 instead. */
1163typedef simd_uint2 vector_uint2;
1164
1165/*! @abstract A vector of three 32-bit unsigned integers.
1166 * @description This type is deprecated; you should use simd_uint3 or
1167 * simd::uint3 instead. */
1168typedef simd_uint3 vector_uint3;
1169
1170/*! @abstract A vector of four 32-bit unsigned integers.
1171 * @description This type is deprecated; you should use simd_uint4 or
1172 * simd::uint4 instead. */
1173typedef simd_uint4 vector_uint4;
1174
1175/*! @abstract A vector of eight 32-bit unsigned integers.
1176 * @description This type is deprecated; you should use simd_uint8 or
1177 * simd::uint8 instead. */
1178typedef simd_uint8 vector_uint8;
1179
1180/*! @abstract A vector of sixteen 32-bit unsigned integers.
1181 * @description This type is deprecated; you should use simd_uint16 or
1182 * simd::uint16 instead. */
1183typedef simd_uint16 vector_uint16;
1184
1185/*! @abstract A vector of two 32-bit floating-point numbers.
1186 * @description This type is deprecated; you should use simd_float2 or
1187 * simd::float2 instead. */
1188typedef simd_float2 vector_float2;
1189
1190/*! @abstract A vector of three 32-bit floating-point numbers.
1191 * @description This type is deprecated; you should use simd_float3 or
1192 * simd::float3 instead. */
1193typedef simd_float3 vector_float3;
1194
1195/*! @abstract A vector of four 32-bit floating-point numbers.
1196 * @description This type is deprecated; you should use simd_float4 or
1197 * simd::float4 instead. */
1198typedef simd_float4 vector_float4;
1199
1200/*! @abstract A vector of eight 32-bit floating-point numbers.
1201 * @description This type is deprecated; you should use simd_float8 or
1202 * simd::float8 instead. */
1203typedef simd_float8 vector_float8;
1204
1205/*! @abstract A vector of sixteen 32-bit floating-point numbers.
1206 * @description This type is deprecated; you should use simd_float16 or
1207 * simd::float16 instead. */
1208typedef simd_float16 vector_float16;
1209
1210/*! @abstract A scalar 64-bit signed (twos-complement) integer.
1211 * @description This type is deprecated; you should use simd_long1 or
1212 * simd::long1 instead. */
1213typedef simd_long1 vector_long1;
1214
1215/*! @abstract A vector of two 64-bit signed (twos-complement) integers.
1216 * @description This type is deprecated; you should use simd_long2 or
1217 * simd::long2 instead. */
1218typedef simd_long2 vector_long2;
1219
1220/*! @abstract A vector of three 64-bit signed (twos-complement) integers.
1221 * @description This type is deprecated; you should use simd_long3 or
1222 * simd::long3 instead. */
1223typedef simd_long3 vector_long3;
1224
1225/*! @abstract A vector of four 64-bit signed (twos-complement) integers.
1226 * @description This type is deprecated; you should use simd_long4 or
1227 * simd::long4 instead. */
1228typedef simd_long4 vector_long4;
1229
1230/*! @abstract A vector of eight 64-bit signed (twos-complement) integers.
1231 * @description This type is deprecated; you should use simd_long8 or
1232 * simd::long8 instead. */
1233typedef simd_long8 vector_long8;
1234
1235/*! @abstract A scalar 64-bit unsigned integer.
1236 * @description This type is deprecated; you should use simd_ulong1 or
1237 * simd::ulong1 instead. */
1238typedef simd_ulong1 vector_ulong1;
1239
1240/*! @abstract A vector of two 64-bit unsigned integers.
1241 * @description This type is deprecated; you should use simd_ulong2 or
1242 * simd::ulong2 instead. */
1243typedef simd_ulong2 vector_ulong2;
1244
1245/*! @abstract A vector of three 64-bit unsigned integers.
1246 * @description This type is deprecated; you should use simd_ulong3 or
1247 * simd::ulong3 instead. */
1248typedef simd_ulong3 vector_ulong3;
1249
1250/*! @abstract A vector of four 64-bit unsigned integers.
1251 * @description This type is deprecated; you should use simd_ulong4 or
1252 * simd::ulong4 instead. */
1253typedef simd_ulong4 vector_ulong4;
1254
1255/*! @abstract A vector of eight 64-bit unsigned integers.
1256 * @description This type is deprecated; you should use simd_ulong8 or
1257 * simd::ulong8 instead. */
1258typedef simd_ulong8 vector_ulong8;
1259
1260/*! @abstract A vector of two 64-bit floating-point numbers.
1261 * @description This type is deprecated; you should use simd_double2 or
1262 * simd::double2 instead. */
1263typedef simd_double2 vector_double2;
1264
1265/*! @abstract A vector of three 64-bit floating-point numbers.
1266 * @description This type is deprecated; you should use simd_double3 or
1267 * simd::double3 instead. */
1268typedef simd_double3 vector_double3;
1269
1270/*! @abstract A vector of four 64-bit floating-point numbers.
1271 * @description This type is deprecated; you should use simd_double4 or
1272 * simd::double4 instead. */
1273typedef simd_double4 vector_double4;
1274
1275/*! @abstract A vector of eight 64-bit floating-point numbers.
1276 * @description This type is deprecated; you should use simd_double8 or
1277 * simd::double8 instead. */
1278typedef simd_double8 vector_double8;
1279
1280# endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
1281#endif
lib/libc/include/x86_64-macos-gnu/spawn.h+22
......@@ -135,12 +135,18 @@ __BEGIN_DECLS
135135int posix_spawnattr_getbinpref_np(const posix_spawnattr_t * __restrict,
136136 size_t, cpu_type_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
137137
138int posix_spawnattr_getarchpref_np(const posix_spawnattr_t * __restrict,
139 size_t, cpu_type_t *__restrict, cpu_subtype_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(11.0), ios(14.0)) __API_UNAVAILABLE(watchos, tvos);
140
138141int posix_spawnattr_setauditsessionport_np(posix_spawnattr_t * __restrict,
139142 mach_port_t) __API_AVAILABLE(macos(10.6), ios(3.2));
140143
141144int posix_spawnattr_setbinpref_np(posix_spawnattr_t * __restrict,
142145 size_t, cpu_type_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
143146
147int posix_spawnattr_setarchpref_np(posix_spawnattr_t * __restrict,
148 size_t, cpu_type_t *__restrict, cpu_subtype_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(11.0), ios(14.0)) __API_UNAVAILABLE(watchos, tvos);
149
144150int posix_spawnattr_setexceptionports_np(posix_spawnattr_t * __restrict,
145151 exception_mask_t, mach_port_t,
146152 exception_behavior_t, thread_state_flavor_t) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
......@@ -150,6 +156,22 @@ int posix_spawnattr_setspecialport_np(posix_spawnattr_t * __restrict,
150156
151157int posix_spawnattr_setsuidcredport_np(posix_spawnattr_t * __restrict, mach_port_t) __API_UNAVAILABLE(ios, macos);
152158
159int posix_spawnattr_setnosmt_np(const posix_spawnattr_t * __restrict attr) __API_AVAILABLE(macos(11.0));
160
161/*
162 * Set CPU Security Mitigation on the spawned process
163 * This attribute affects all threads and is inherited on fork and exec
164 */
165int posix_spawnattr_set_csm_np(const posix_spawnattr_t * __restrict attr, uint32_t flags) __API_AVAILABLE(macos(11.0));
166/*
167 * flags for CPU Security Mitigation attribute
168 * POSIX_SPAWN_NP_CSM_ALL should be used in most cases,
169 * the individual flags are provided only for performance evaluation etc
170 */
171#define POSIX_SPAWN_NP_CSM_ALL 0x0001
172#define POSIX_SPAWN_NP_CSM_NOSMT 0x0002
173#define POSIX_SPAWN_NP_CSM_TECS 0x0004
174
153175int posix_spawn_file_actions_addinherit_np(posix_spawn_file_actions_t *,
154176 int) __API_AVAILABLE(macos(10.7), ios(4.3)) __API_UNAVAILABLE(watchos, tvos);
155177
lib/libc/include/x86_64-macos-gnu/stdint.h-9
......@@ -3,15 +3,6 @@
33 * All rights reserved.
44 */
55
6/*
7 * Note from the Zig project:
8 *
9 * Apple released their libc as a whole under the APSL 2.0 license [1], which
10 * includes this file. Therefore, this file is governed by the APSL 2.0 license.
11 *
12 * [1]: https://opensource.apple.com/source/Libc/Libc-1353.100.2/
13 */
14
156#ifndef _STDINT_H_
167#define _STDINT_H_
178
lib/libc/include/x86_64-macos-gnu/stdio.h+1-1
......@@ -217,7 +217,7 @@ __END_DECLS
217217/* Additional functionality provided by:
218218 * POSIX.2-1992 C Language Binding Option
219219 */
220#if TARGET_OS_EMBEDDED
220#if TARGET_OS_IPHONE
221221#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
222222#else
223223#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg)
lib/libc/include/x86_64-macos-gnu/stdlib.h+4-1
......@@ -178,7 +178,7 @@ unsigned long long
178178 strtoull(const char *__str, char **__endptr, int __base);
179179#endif /* !__DARWIN_NO_LONG_LONG */
180180
181#if TARGET_OS_EMBEDDED
181#if TARGET_OS_IPHONE
182182#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
183183#else
184184#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg)
......@@ -347,6 +347,9 @@ int sradixsort(const unsigned char **__base, int __nel, const unsigned char *__
347347void sranddev(void);
348348void srandomdev(void);
349349void *reallocf(void *__ptr, size_t __size) __alloc_size(2);
350long long
351 strtonum(const char *__numstr, long long __minval, long long __maxval, const char **__errstrp)
352 __API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0));
350353#if !__DARWIN_NO_LONG_LONG
351354long long
352355 strtoq(const char *__str, char **__endptr, int __base);
lib/libc/include/x86_64-macos-gnu/string.h+4
......@@ -170,6 +170,10 @@ void swab(const void * __restrict, void * __restrict, ssize_t);
170170__OSX_AVAILABLE(10.12.1) __IOS_AVAILABLE(10.1)
171171__TVOS_AVAILABLE(10.0.1) __WATCHOS_AVAILABLE(3.1)
172172int timingsafe_bcmp(const void *__b1, const void *__b2, size_t __len);
173
174__OSX_AVAILABLE(11.0) __IOS_AVAILABLE(14.0)
175__TVOS_AVAILABLE(14.0) __WATCHOS_AVAILABLE(7.0)
176int strsignal_r(int __sig, char *__strsignalbuf, size_t __buflen);
173177__END_DECLS
174178
175179/* Some functions historically defined in string.h were placed in strings.h
lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h+6-6
......@@ -2,7 +2,7 @@
22 * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
5 *
66 * This file contains Original Code and/or Modifications of Original Code
77 * as defined in and that are subject to the Apple Public Source License
88 * Version 2.0 (the 'License'). You may not use this file except in
......@@ -11,10 +11,10 @@
1111 * unlawful or unlicensed copies of an Apple operating system, or to
1212 * circumvent, violate, or enable the circumvention or violation of, any
1313 * terms of an Apple operating system software license agreement.
14 *
14 *
1515 * Please obtain a copy of the License at
1616 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
17 *
1818 * The Original Code and all software distributed under the License are
1919 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
......@@ -22,11 +22,11 @@
2222 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323 * Please see the License for the specific language governing rights and
2424 * limitations under the License.
25 *
25 *
2626 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727 */
28#ifndef _PTHREAD_ATTR_T
29#define _PTHREAD_ATTR_T
28#ifndef _PTHREAD_ATTR_T
29#define _PTHREAD_ATTR_T
3030#include <sys/_pthread/_pthread_types.h> /* __darwin_pthread_attr_t */
3131typedef __darwin_pthread_attr_t pthread_attr_t;
3232#endif /* _PTHREAD_ATTR_T */
lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h+4-4
......@@ -2,7 +2,7 @@
22 * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
5 *
66 * This file contains Original Code and/or Modifications of Original Code
77 * as defined in and that are subject to the Apple Public Source License
88 * Version 2.0 (the 'License'). You may not use this file except in
......@@ -11,10 +11,10 @@
1111 * unlawful or unlicensed copies of an Apple operating system, or to
1212 * circumvent, violate, or enable the circumvention or violation of, any
1313 * terms of an Apple operating system software license agreement.
14 *
14 *
1515 * Please obtain a copy of the License at
1616 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
17 *
1818 * The Original Code and all software distributed under the License are
1919 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
......@@ -22,7 +22,7 @@
2222 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323 * Please see the License for the specific language governing rights and
2424 * limitations under the License.
25 *
25 *
2626 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727 */
2828#ifndef _PTHREAD_COND_T
lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h+4-4
......@@ -2,7 +2,7 @@
22 * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
5 *
66 * This file contains Original Code and/or Modifications of Original Code
77 * as defined in and that are subject to the Apple Public Source License
88 * Version 2.0 (the 'License'). You may not use this file except in
......@@ -11,10 +11,10 @@
1111 * unlawful or unlicensed copies of an Apple operating system, or to
1212 * circumvent, violate, or enable the circumvention or violation of, any
1313 * terms of an Apple operating system software license agreement.
14 *
14 *
1515 * Please obtain a copy of the License at
1616 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
17 *
1818 * The Original Code and all software distributed under the License are
1919 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
......@@ -22,7 +22,7 @@
2222 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323 * Please see the License for the specific language governing rights and
2424 * limitations under the License.
25 *
25 *
2626 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727 */
2828#ifndef _PTHREAD_CONDATTR_T
lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h+4-4
......@@ -2,7 +2,7 @@
22 * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
5 *
66 * This file contains Original Code and/or Modifications of Original Code
77 * as defined in and that are subject to the Apple Public Source License
88 * Version 2.0 (the 'License'). You may not use this file except in
......@@ -11,10 +11,10 @@
1111 * unlawful or unlicensed copies of an Apple operating system, or to
1212 * circumvent, violate, or enable the circumvention or violation of, any
1313 * terms of an Apple operating system software license agreement.
14 *
14 *
1515 * Please obtain a copy of the License at
1616 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
17 *
1818 * The Original Code and all software distributed under the License are
1919 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
......@@ -22,7 +22,7 @@
2222 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323 * Please see the License for the specific language governing rights and
2424 * limitations under the License.
25 *
25 *
2626 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727 */
2828#ifndef _PTHREAD_RWLOCK_T
lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h+4-4
......@@ -2,7 +2,7 @@
22 * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
5 *
66 * This file contains Original Code and/or Modifications of Original Code
77 * as defined in and that are subject to the Apple Public Source License
88 * Version 2.0 (the 'License'). You may not use this file except in
......@@ -11,10 +11,10 @@
1111 * unlawful or unlicensed copies of an Apple operating system, or to
1212 * circumvent, violate, or enable the circumvention or violation of, any
1313 * terms of an Apple operating system software license agreement.
14 *
14 *
1515 * Please obtain a copy of the License at
1616 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
17 *
1818 * The Original Code and all software distributed under the License are
1919 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
......@@ -22,7 +22,7 @@
2222 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323 * Please see the License for the specific language governing rights and
2424 * limitations under the License.
25 *
25 *
2626 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727 */
2828#ifndef _PTHREAD_RWLOCKATTR_T
lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h+4-4
......@@ -2,7 +2,7 @@
22 * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
5 *
66 * This file contains Original Code and/or Modifications of Original Code
77 * as defined in and that are subject to the Apple Public Source License
88 * Version 2.0 (the 'License'). You may not use this file except in
......@@ -11,10 +11,10 @@
1111 * unlawful or unlicensed copies of an Apple operating system, or to
1212 * circumvent, violate, or enable the circumvention or violation of, any
1313 * terms of an Apple operating system software license agreement.
14 *
14 *
1515 * Please obtain a copy of the License at
1616 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
17 *
1818 * The Original Code and all software distributed under the License are
1919 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
......@@ -22,7 +22,7 @@
2222 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323 * Please see the License for the specific language governing rights and
2424 * limitations under the License.
25 *
25 *
2626 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727 */
2828#ifndef _PTHREAD_T
lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h+4-4
......@@ -2,7 +2,7 @@
22 * Copyright (c) 2003-2013 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
5 *
66 * This file contains Original Code and/or Modifications of Original Code
77 * as defined in and that are subject to the Apple Public Source License
88 * Version 2.0 (the 'License'). You may not use this file except in
......@@ -11,10 +11,10 @@
1111 * unlawful or unlicensed copies of an Apple operating system, or to
1212 * circumvent, violate, or enable the circumvention or violation of, any
1313 * terms of an Apple operating system software license agreement.
14 *
14 *
1515 * Please obtain a copy of the License at
1616 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
17 *
1818 * The Original Code and all software distributed under the License are
1919 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
......@@ -22,7 +22,7 @@
2222 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323 * Please see the License for the specific language governing rights and
2424 * limitations under the License.
25 *
25 *
2626 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727 */
2828
lib/libc/include/x86_64-macos-gnu/sys/_select.h+5
......@@ -36,8 +36,13 @@
3636#ifndef _SYS__SELECT_H_
3737#define _SYS__SELECT_H_
3838
39#include <sys/cdefs.h> /* __DARWIN_EXTSN_C, __DARWIN_1050, __DARWIN_ALIAS_C */
40#include <sys/_types/_fd_def.h> /* fd_set */
41#include <sys/_types/_timeval.h> /* struct timeval */
42
3943int select(int, fd_set * __restrict, fd_set * __restrict,
4044 fd_set * __restrict, struct timeval * __restrict)
45
4146#if defined(_DARWIN_C_SOURCE) || defined(_DARWIN_UNLIMITED_SELECT)
4247__DARWIN_EXTSN_C(select)
4348#else /* !_DARWIN_C_SOURCE && !_DARWIN_UNLIMITED_SELECT */
lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h+36
......@@ -305,6 +305,30 @@
305305#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_6(x)
306306#endif
307307
308#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130700
309#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_7(x) x
310#else
311#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_7(x)
312#endif
313
314#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140000
315#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_0(x) x
316#else
317#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_0(x)
318#endif
319
320#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140100
321#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_1(x) x
322#else
323#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_1(x)
324#endif
325
326#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140200
327#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_2(x) x
328#else
329#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_2(x)
330#endif
331
308332#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1000
309333#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_0(x) x
310334#else
......@@ -497,3 +521,15 @@
497521#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_15_1(x)
498522#endif
499523
524#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101600
525#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_16(x) x
526#else
527#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_16(x)
528#endif
529
530#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000
531#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_0(x) x
532#else
533#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_0(x)
534#endif
535
lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h+8-1
......@@ -51,12 +51,16 @@ typedef struct fd_set {
5151 __int32_t fds_bits[__DARWIN_howmany(__DARWIN_FD_SETSIZE, __DARWIN_NFDBITS)];
5252} fd_set;
5353
54int __darwin_check_fd_set_overflow(int, const void *, int) __attribute__((__weak_import__));
54int __darwin_check_fd_set_overflow(int, const void *, int) __API_AVAILABLE(macosx(11.0), ios(14.0), tvos(14.0), watchos(7.0));
5555__END_DECLS
5656
5757__header_always_inline int
5858__darwin_check_fd_set(int _a, const void *_b)
5959{
60#ifdef __clang__
61#pragma clang diagnostic push
62#pragma clang diagnostic ignored "-Wunguarded-availability-new"
63#endif
6064 if ((uintptr_t)&__darwin_check_fd_set_overflow != (uintptr_t) 0) {
6165#if defined(_DARWIN_UNLIMITED_SELECT) || defined(_DARWIN_C_SOURCE)
6266 return __darwin_check_fd_set_overflow(_a, _b, 1);
......@@ -66,6 +70,9 @@ __darwin_check_fd_set(int _a, const void *_b)
6670 } else {
6771 return 1;
6872 }
73#ifdef __clang__
74#pragma clang diagnostic pop
75#endif
6976}
7077
7178/* This inline avoids argument side-effect issues with FD_ISSET() */
lib/libc/include/x86_64-macos-gnu/sys/_types/_guid_t.h created+37
......@@ -0,0 +1,37 @@
1/*
2 * Copyright (c) 2003-2012 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#ifndef _KAUTH_GUID
29#define _KAUTH_GUID
30/* Apple-style globally unique identifier */
31typedef union {
32#define KAUTH_GUID_SIZE 16 /* 128-bit identifier */
33 unsigned char g_guid[KAUTH_GUID_SIZE];
34 unsigned int g_guid_asint[KAUTH_GUID_SIZE / sizeof(unsigned int)];
35} guid_t;
36#define _GUID_T
37#endif /* _KAUTH_GUID */
lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h+1-1
......@@ -27,5 +27,5 @@
2727 */
2828#ifndef _INT8_T
2929#define _INT8_T
30typedef __signed char int8_t;
30typedef signed char int8_t;
3131#endif /* _INT8_T */
lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h+1
......@@ -38,6 +38,7 @@
3838#include <machine/types.h> /* __darwin_size_t */
3939#include <machine/_mcontext.h> /* _STRUCT_MCONTEXT */
4040#include <sys/_types.h> /* __darwin_sigset_t */
41#include <sys/_types/_sigaltstack.h> /* _STRUCT_SIGALTSTACK */
4142
4243_STRUCT_UCONTEXT
4344{
lib/libc/include/x86_64-macos-gnu/sys/acl.h created+212
......@@ -0,0 +1,212 @@
1/*
2 * Copyright (c) 2004, 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#ifndef _SYS_ACL_H
24#define _SYS_ACL_H
25
26#include <Availability.h>
27#include <sys/kauth.h>
28#include <sys/_types/_ssize_t.h>
29
30#define __DARWIN_ACL_READ_DATA (1<<1)
31#define __DARWIN_ACL_LIST_DIRECTORY __DARWIN_ACL_READ_DATA
32#define __DARWIN_ACL_WRITE_DATA (1<<2)
33#define __DARWIN_ACL_ADD_FILE __DARWIN_ACL_WRITE_DATA
34#define __DARWIN_ACL_EXECUTE (1<<3)
35#define __DARWIN_ACL_SEARCH __DARWIN_ACL_EXECUTE
36#define __DARWIN_ACL_DELETE (1<<4)
37#define __DARWIN_ACL_APPEND_DATA (1<<5)
38#define __DARWIN_ACL_ADD_SUBDIRECTORY __DARWIN_ACL_APPEND_DATA
39#define __DARWIN_ACL_DELETE_CHILD (1<<6)
40#define __DARWIN_ACL_READ_ATTRIBUTES (1<<7)
41#define __DARWIN_ACL_WRITE_ATTRIBUTES (1<<8)
42#define __DARWIN_ACL_READ_EXTATTRIBUTES (1<<9)
43#define __DARWIN_ACL_WRITE_EXTATTRIBUTES (1<<10)
44#define __DARWIN_ACL_READ_SECURITY (1<<11)
45#define __DARWIN_ACL_WRITE_SECURITY (1<<12)
46#define __DARWIN_ACL_CHANGE_OWNER (1<<13)
47#define __DARWIN_ACL_SYNCHRONIZE (1<<20)
48
49#define __DARWIN_ACL_EXTENDED_ALLOW 1
50#define __DARWIN_ACL_EXTENDED_DENY 2
51
52#define __DARWIN_ACL_ENTRY_INHERITED (1<<4)
53#define __DARWIN_ACL_ENTRY_FILE_INHERIT (1<<5)
54#define __DARWIN_ACL_ENTRY_DIRECTORY_INHERIT (1<<6)
55#define __DARWIN_ACL_ENTRY_LIMIT_INHERIT (1<<7)
56#define __DARWIN_ACL_ENTRY_ONLY_INHERIT (1<<8)
57#define __DARWIN_ACL_FLAG_NO_INHERIT (1<<17)
58
59/*
60 * Implementation constants.
61 *
62 * The ACL_TYPE_EXTENDED binary format permits 169 entries plus
63 * the ACL header in a page. Give ourselves some room to grow;
64 * this limit is arbitrary.
65 */
66#define ACL_MAX_ENTRIES 128
67
68/* 23.2.2 Individual object access permissions - nonstandard */
69typedef enum {
70 ACL_READ_DATA = __DARWIN_ACL_READ_DATA,
71 ACL_LIST_DIRECTORY = __DARWIN_ACL_LIST_DIRECTORY,
72 ACL_WRITE_DATA = __DARWIN_ACL_WRITE_DATA,
73 ACL_ADD_FILE = __DARWIN_ACL_ADD_FILE,
74 ACL_EXECUTE = __DARWIN_ACL_EXECUTE,
75 ACL_SEARCH = __DARWIN_ACL_SEARCH,
76 ACL_DELETE = __DARWIN_ACL_DELETE,
77 ACL_APPEND_DATA = __DARWIN_ACL_APPEND_DATA,
78 ACL_ADD_SUBDIRECTORY = __DARWIN_ACL_ADD_SUBDIRECTORY,
79 ACL_DELETE_CHILD = __DARWIN_ACL_DELETE_CHILD,
80 ACL_READ_ATTRIBUTES = __DARWIN_ACL_READ_ATTRIBUTES,
81 ACL_WRITE_ATTRIBUTES = __DARWIN_ACL_WRITE_ATTRIBUTES,
82 ACL_READ_EXTATTRIBUTES = __DARWIN_ACL_READ_EXTATTRIBUTES,
83 ACL_WRITE_EXTATTRIBUTES = __DARWIN_ACL_WRITE_EXTATTRIBUTES,
84 ACL_READ_SECURITY = __DARWIN_ACL_READ_SECURITY,
85 ACL_WRITE_SECURITY = __DARWIN_ACL_WRITE_SECURITY,
86 ACL_CHANGE_OWNER = __DARWIN_ACL_CHANGE_OWNER,
87 ACL_SYNCHRONIZE = __DARWIN_ACL_SYNCHRONIZE,
88} acl_perm_t;
89
90/* 23.2.5 ACL entry tag type bits - nonstandard */
91typedef enum {
92 ACL_UNDEFINED_TAG = 0,
93 ACL_EXTENDED_ALLOW = __DARWIN_ACL_EXTENDED_ALLOW,
94 ACL_EXTENDED_DENY = __DARWIN_ACL_EXTENDED_DENY
95} acl_tag_t;
96
97/* 23.2.6 Individual ACL types */
98typedef enum {
99 ACL_TYPE_EXTENDED = 0x00000100,
100/* Posix 1003.1e types - not supported */
101 ACL_TYPE_ACCESS = 0x00000000,
102 ACL_TYPE_DEFAULT = 0x00000001,
103/* The following types are defined on FreeBSD/Linux - not supported */
104 ACL_TYPE_AFS = 0x00000002,
105 ACL_TYPE_CODA = 0x00000003,
106 ACL_TYPE_NTFS = 0x00000004,
107 ACL_TYPE_NWFS = 0x00000005
108} acl_type_t;
109
110/* 23.2.7 ACL qualifier constants */
111
112#define ACL_UNDEFINED_ID NULL /* XXX ? */
113
114/* 23.2.8 ACL Entry Constants */
115typedef enum {
116 ACL_FIRST_ENTRY = 0,
117 ACL_NEXT_ENTRY = -1,
118 ACL_LAST_ENTRY = -2
119} acl_entry_id_t;
120
121/* nonstandard ACL / entry flags */
122typedef enum {
123 ACL_FLAG_DEFER_INHERIT = (1 << 0), /* tentative */
124 ACL_FLAG_NO_INHERIT = __DARWIN_ACL_FLAG_NO_INHERIT,
125 ACL_ENTRY_INHERITED = __DARWIN_ACL_ENTRY_INHERITED,
126 ACL_ENTRY_FILE_INHERIT = __DARWIN_ACL_ENTRY_FILE_INHERIT,
127 ACL_ENTRY_DIRECTORY_INHERIT = __DARWIN_ACL_ENTRY_DIRECTORY_INHERIT,
128 ACL_ENTRY_LIMIT_INHERIT = __DARWIN_ACL_ENTRY_LIMIT_INHERIT,
129 ACL_ENTRY_ONLY_INHERIT = __DARWIN_ACL_ENTRY_ONLY_INHERIT
130} acl_flag_t;
131
132/* "External" ACL types */
133
134struct _acl;
135struct _acl_entry;
136struct _acl_permset;
137struct _acl_flagset;
138
139typedef struct _acl *acl_t;
140typedef struct _acl_entry *acl_entry_t;
141typedef struct _acl_permset *acl_permset_t;
142typedef struct _acl_flagset *acl_flagset_t;
143
144typedef u_int64_t acl_permset_mask_t;
145
146__BEGIN_DECLS
147/* 23.1.6.1 ACL Storage Management */
148extern acl_t acl_dup(acl_t acl);
149extern int acl_free(void *obj_p);
150extern acl_t acl_init(int count);
151
152/* 23.1.6.2 (1) ACL Entry manipulation */
153extern int acl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d);
154extern int acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p);
155extern int acl_create_entry_np(acl_t *acl_p, acl_entry_t *entry_p, int entry_index);
156extern int acl_delete_entry(acl_t acl, acl_entry_t entry_d);
157extern int acl_get_entry(acl_t acl, int entry_id, acl_entry_t *entry_p);
158extern int acl_valid(acl_t acl);
159extern int acl_valid_fd_np(int fd, acl_type_t type, acl_t acl);
160extern int acl_valid_file_np(const char *path, acl_type_t type, acl_t acl);
161extern int acl_valid_link_np(const char *path, acl_type_t type, acl_t acl);
162
163/* 23.1.6.2 (2) Manipulate permissions within an ACL entry */
164extern int acl_add_perm(acl_permset_t permset_d, acl_perm_t perm);
165extern int acl_calc_mask(acl_t *acl_p); /* not supported */
166extern int acl_clear_perms(acl_permset_t permset_d);
167extern int acl_delete_perm(acl_permset_t permset_d, acl_perm_t perm);
168extern int acl_get_perm_np(acl_permset_t permset_d, acl_perm_t perm);
169extern int acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p);
170extern int acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d);
171
172/* nonstandard - manipulate permissions within an ACL entry using bitmasks */
173extern int acl_maximal_permset_mask_np(acl_permset_mask_t * mask_p) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
174extern int acl_get_permset_mask_np(acl_entry_t entry_d, acl_permset_mask_t * mask_p) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
175extern int acl_set_permset_mask_np(acl_entry_t entry_d, acl_permset_mask_t mask) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
176
177/* nonstandard - manipulate flags on ACLs and entries */
178extern int acl_add_flag_np(acl_flagset_t flagset_d, acl_flag_t flag);
179extern int acl_clear_flags_np(acl_flagset_t flagset_d);
180extern int acl_delete_flag_np(acl_flagset_t flagset_d, acl_flag_t flag);
181extern int acl_get_flag_np(acl_flagset_t flagset_d, acl_flag_t flag);
182extern int acl_get_flagset_np(void *obj_p, acl_flagset_t *flagset_p);
183extern int acl_set_flagset_np(void *obj_p, acl_flagset_t flagset_d);
184
185/* 23.1.6.2 (3) Manipulate ACL entry tag type and qualifier */
186extern void *acl_get_qualifier(acl_entry_t entry_d);
187extern int acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p);
188extern int acl_set_qualifier(acl_entry_t entry_d, const void *tag_qualifier_p);
189extern int acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type);
190
191/* 23.1.6.3 ACL manipulation on an Object */
192extern int acl_delete_def_file(const char *path_p); /* not supported */
193extern acl_t acl_get_fd(int fd);
194extern acl_t acl_get_fd_np(int fd, acl_type_t type);
195extern acl_t acl_get_file(const char *path_p, acl_type_t type);
196extern acl_t acl_get_link_np(const char *path_p, acl_type_t type);
197extern int acl_set_fd(int fd, acl_t acl);
198extern int acl_set_fd_np(int fd, acl_t acl, acl_type_t acl_type);
199extern int acl_set_file(const char *path_p, acl_type_t type, acl_t acl);
200extern int acl_set_link_np(const char *path_p, acl_type_t type, acl_t acl);
201
202/* 23.1.6.4 ACL Format translation */
203extern ssize_t acl_copy_ext(void *buf_p, acl_t acl, ssize_t size);
204extern ssize_t acl_copy_ext_native(void *buf_p, acl_t acl, ssize_t size);
205extern acl_t acl_copy_int(const void *buf_p);
206extern acl_t acl_copy_int_native(const void *buf_p);
207extern acl_t acl_from_text(const char *buf_p);
208extern ssize_t acl_size(acl_t acl);
209extern char *acl_to_text(acl_t acl, ssize_t *len_p);
210__END_DECLS
211
212#endif /* _SYS_ACL_H */
lib/libc/include/x86_64-macos-gnu/sys/attr.h+8-1
......@@ -51,6 +51,7 @@
5151
5252
5353#define FSOPT_ATTR_CMN_EXTENDED 0x00000020
54#define FSOPT_RETURN_REALDEV 0x00000200
5455
5556/* we currently aren't anywhere near this amount for a valid
5657 * fssearchblock.sizeofsearchparams1 or fssearchblock.sizeofsearchparams2
......@@ -239,6 +240,10 @@ typedef struct vol_capabilities_attr {
239240 * that implies multiple volumes must be mounted in order to boot and root the
240241 * operating system. Typically, this means a read-only system volume and a
241242 * writable data volume.
243 *
244 * VOL_CAP_FMT_SEALED: When set, this volume is cryptographically sealed.
245 * Any modifications to volume data or metadata will be detected and may
246 * render the volume unusable.
242247 */
243248#define VOL_CAP_FMT_PERSISTENTOBJECTIDS 0x00000001
244249#define VOL_CAP_FMT_SYMBOLICLINKS 0x00000002
......@@ -265,6 +270,7 @@ typedef struct vol_capabilities_attr {
265270#define VOL_CAP_FMT_NO_PERMISSIONS 0x00400000
266271#define VOL_CAP_FMT_SHARED_SPACE 0x00800000
267272#define VOL_CAP_FMT_VOL_GROUPS 0x01000000
273#define VOL_CAP_FMT_SEALED 0x02000000
268274
269275/*
270276 * VOL_CAP_INT_SEARCHFS: When set, the volume implements the
......@@ -515,8 +521,9 @@ typedef struct vol_attributes_attr {
515521#define ATTR_CMNEXT_REALFSID 0x00000080
516522#define ATTR_CMNEXT_CLONEID 0x00000100
517523#define ATTR_CMNEXT_EXT_FLAGS 0x00000200
524#define ATTR_CMNEXT_RECURSIVE_GENCOUNT 0x00000400
518525
519#define ATTR_CMNEXT_VALIDMASK 0x000003fc
526#define ATTR_CMNEXT_VALIDMASK 0x000007fc
520527#define ATTR_CMNEXT_SETMASK 0x00000000
521528
522529/* Deprecated fork attributes */
lib/libc/include/x86_64-macos-gnu/sys/cdefs.h+32-11
......@@ -174,6 +174,15 @@
174174#define __cold
175175#endif
176176
177/* __exported denotes symbols that should be exported even when symbols
178 * are hidden by default.
179 * __exported_push/_exported_pop are pragmas used to delimit a range of
180 * symbols that should be exported even when symbols are hidden by default.
181 */
182#define __exported __attribute__((__visibility__("default")))
183#define __exported_push _Pragma("GCC visibility push(default)")
184#define __exported_pop _Pragma("GCC visibility pop")
185
177186/* __deprecated causes the compiler to produce a warning when encountering
178187 * code using the deprecated functionality.
179188 * __deprecated_msg() does the same, and compilers that support it will print
......@@ -202,9 +211,17 @@
202211#define __kpi_deprecated(_msg)
203212
204213/* __unavailable causes the compiler to error out when encountering
205 * code using the tagged function of variable.
214 * code using the tagged function
206215 */
207#define __unavailable __attribute__((__unavailable__))
216#if __has_attribute(unavailable)
217#define __unavailable __attribute__((__unavailable__))
218#else
219#define __unavailable
220#endif
221
222#define __kpi_unavailable
223
224#define __kpi_deprecated_arm64_macos_unavailable
208225
209226/* Delete pseudo-keywords wherever they are not available or needed. */
210227#ifndef __dead
......@@ -471,9 +488,19 @@
471488
472489/* These settings are particular to each product. */
473490/* Platform: MacOSX */
491#if defined(__i386__)
474492#define __DARWIN_ONLY_64_BIT_INO_T 0
475/* #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) */
493#define __DARWIN_ONLY_UNIX_CONFORMANCE 0
476494#define __DARWIN_ONLY_VERS_1050 0
495#elif defined(__x86_64__)
496#define __DARWIN_ONLY_64_BIT_INO_T 0
497#define __DARWIN_ONLY_UNIX_CONFORMANCE 1
498#define __DARWIN_ONLY_VERS_1050 0
499#else
500#define __DARWIN_ONLY_64_BIT_INO_T 1
501#define __DARWIN_ONLY_UNIX_CONFORMANCE 1
502#define __DARWIN_ONLY_VERS_1050 1
503#endif
477504
478505/*
479506 * The __DARWIN_ALIAS macros are used to do symbol renaming; they allow
......@@ -493,14 +520,6 @@
493520 * pre-10.5, and it is the default compilation environment, revert the
494521 * compilation environment to pre-__DARWIN_UNIX03.
495522 */
496#if !defined(__DARWIN_ONLY_UNIX_CONFORMANCE)
497# if defined(__LP64__)
498# define __DARWIN_ONLY_UNIX_CONFORMANCE 1
499# else /* !__LP64__ */
500# define __DARWIN_ONLY_UNIX_CONFORMANCE 0
501# endif /* __LP64__ */
502#endif /* !__DARWIN_ONLY_UNIX_CONFORMANCE */
503
504523#if !defined(__DARWIN_UNIX03)
505524# if __DARWIN_ONLY_UNIX_CONFORMANCE
506525# if defined(_NONSTD_SOURCE)
......@@ -803,6 +822,8 @@
803822 */
804823#if !defined(__sys_cdefs_arch_unknown__) && defined(__i386__)
805824#elif !defined(__sys_cdefs_arch_unknown__) && defined(__x86_64__)
825#elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm__)
826#elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm64__)
806827#else
807828#error Unsupported architecture
808829#endif
lib/libc/include/x86_64-macos-gnu/sys/event.h+1-1
......@@ -262,7 +262,7 @@ enum {
262262#define NOTE_EXEC 0x20000000 /* process exec'd */
263263#define NOTE_REAP ((unsigned int)eNoteReapDeprecated /* 0x10000000 */ ) /* process reaped */
264264#define NOTE_SIGNAL 0x08000000 /* shared with EVFILT_SIGNAL */
265#define NOTE_EXITSTATUS 0x04000000 /* exit status to be returned, valid for child process only */
265#define NOTE_EXITSTATUS 0x04000000 /* exit status to be returned, valid for child process or when allowed to signal target pid */
266266#define NOTE_EXIT_DETAIL 0x02000000 /* provide details on reasons for exit */
267267
268268#define NOTE_PDATAMASK 0x000fffff /* mask for signal & exit status */
lib/libc/include/x86_64-macos-gnu/sys/fcntl.h+72-48
......@@ -107,67 +107,70 @@
107107 * which was documented to use FREAD/FWRITE, continues to work.
108108 */
109109#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
110#define FREAD 0x0001
111#define FWRITE 0x0002
110#define FREAD 0x00000001
111#define FWRITE 0x00000002
112112#endif
113#define O_NONBLOCK 0x0004 /* no delay */
114#define O_APPEND 0x0008 /* set append mode */
113#define O_NONBLOCK 0x00000004 /* no delay */
114#define O_APPEND 0x00000008 /* set append mode */
115115
116116#include <sys/_types/_o_sync.h>
117117
118118#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
119#define O_SHLOCK 0x0010 /* open with shared file lock */
120#define O_EXLOCK 0x0020 /* open with exclusive file lock */
121#define O_ASYNC 0x0040 /* signal pgrp when data ready */
119#define O_SHLOCK 0x00000010 /* open with shared file lock */
120#define O_EXLOCK 0x00000020 /* open with exclusive file lock */
121#define O_ASYNC 0x00000040 /* signal pgrp when data ready */
122122#define O_FSYNC O_SYNC /* source compatibility: do not use */
123#define O_NOFOLLOW 0x0100 /* don't follow symlinks */
123#define O_NOFOLLOW 0x00000100 /* don't follow symlinks */
124124#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
125#define O_CREAT 0x0200 /* create if nonexistant */
126#define O_TRUNC 0x0400 /* truncate to zero length */
127#define O_EXCL 0x0800 /* error if already exists */
128
129#if __DARWIN_C_LEVEL >= 200809L
130/*
131 * Descriptor value for the current working directory
132 */
133#define AT_FDCWD -2
134
135/*
136 * Flags for the at functions
137 */
138#define AT_EACCESS 0x0010 /* Use effective ids in access check */
139#define AT_SYMLINK_NOFOLLOW 0x0020 /* Act on the symlink itself not the target */
140#define AT_SYMLINK_FOLLOW 0x0040 /* Act on target of symlink */
141#define AT_REMOVEDIR 0x0080 /* Path refers to directory */
142#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
143#define AT_REALDEV 0x0200 /* Return real device inodes resides on for fstatat(2) */
144#define AT_FDONLY 0x0400 /* Use only the fd and Ignore the path for fstatat(2) */
145#endif
146#endif
125#define O_CREAT 0x00000200 /* create if nonexistant */
126#define O_TRUNC 0x00000400 /* truncate to zero length */
127#define O_EXCL 0x00000800 /* error if already exists */
147128
148129#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
149#define O_EVTONLY 0x8000 /* descriptor requested for event notifications only */
130#define O_EVTONLY 0x00008000 /* descriptor requested for event notifications only */
150131#endif
151132
152133
153#define O_NOCTTY 0x20000 /* don't assign controlling terminal */
134#define O_NOCTTY 0x00020000 /* don't assign controlling terminal */
154135
155136
156137#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
157#define O_DIRECTORY 0x100000
158#define O_SYMLINK 0x200000 /* allow open of a symlink */
138#define O_DIRECTORY 0x00100000
139#define O_SYMLINK 0x00200000 /* allow open of a symlink */
159140#endif
160141
142// O_DSYNC 0x00400000 /* synch I/O data integrity */
161143#include <sys/_types/_o_dsync.h>
162144
163145
164146#if __DARWIN_C_LEVEL >= 200809L
165#define O_CLOEXEC 0x1000000 /* implicitly set FD_CLOEXEC */
147#define O_CLOEXEC 0x01000000 /* implicitly set FD_CLOEXEC */
166148#endif
167149
168150
151#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
152#define O_NOFOLLOW_ANY 0x20000000 /* no symlinks allowed in path */
153#endif
154
169155
156#if __DARWIN_C_LEVEL >= 200809L
157/*
158 * Descriptor value for the current working directory
159 */
160#define AT_FDCWD -2
170161
162/*
163 * Flags for the at functions
164 */
165#define AT_EACCESS 0x0010 /* Use effective ids in access check */
166#define AT_SYMLINK_NOFOLLOW 0x0020 /* Act on the symlink itself not the target */
167#define AT_SYMLINK_FOLLOW 0x0040 /* Act on target of symlink */
168#define AT_REMOVEDIR 0x0080 /* Path refers to directory */
169#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
170#define AT_REALDEV 0x0200 /* Return real device inodes resides on for fstatat(2) */
171#define AT_FDONLY 0x0400 /* Use only the fd and Ignore the path for fstatat(2) */
172#endif
173#endif
171174
172175/* Data Protection Flags */
173176#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
......@@ -224,7 +227,7 @@
224227#define F_FLUSH_DATA 40
225228#define F_CHKCLEAN 41 /* Used for regression test */
226229#define F_PREALLOCATE 42 /* Preallocate storage */
227#define F_SETSIZE 43 /* Truncate a file without zeroing space */
230#define F_SETSIZE 43 /* Truncate a file. Equivalent to calling truncate(2) */
228231#define F_RDADVISE 44 /* Issue an advisory read async with no copy to user */
229232#define F_RDAHEAD 45 /* turn read ahead off/on for this fd */
230233/*
......@@ -293,6 +296,10 @@
293296
294297#define F_GETPATH_NOFIRMLINK 102 /* return the full path without firmlinks of the fd */
295298
299#define F_ADDFILESIGS_INFO 103 /* Add signature from same file, return information */
300#define F_ADDFILESUPPL 104 /* Add supplemental signature from same file with fd reference to original */
301#define F_GETSIGSINFO 105 /* Look up code signature information attached to a file or slice */
302
296303// FS-specific fcntl()'s numbers begin at 0x00010000 and go up
297304#define FCNTL_FS_SPECIFIC_BASE 0x00010000
298305
......@@ -374,30 +381,34 @@ struct radvisory {
374381};
375382
376383
377/** Information the user passes in to get the codeblobs out of the kernel */
378typedef struct fcodeblobs {
379 void *f_cd_hash;
380 size_t f_hash_size;
381 void *f_cd_buffer;
382 size_t f_cd_size;
383 unsigned int *f_out_size;
384 int f_arch;
385 int __padding;
386} fcodeblobs_t;
387
388
389384/*
390385 * detached code signatures data type -
391386 * information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS.
392387 * F_ADDFILESIGS is a shortcut for files that contain their own signature and
393388 * doesn't require mapping of the file in order to load the signature.
394389 */
390#define USER_FSIGNATURES_CDHASH_LEN 20
395391typedef struct fsignatures {
396392 off_t fs_file_start;
397393 void *fs_blob_start;
398394 size_t fs_blob_size;
395
396 /* The following fields are only applicable to F_ADDFILESIGS_INFO (64bit only). */
397 /* Prior to F_ADDFILESIGS_INFO, this struct ended after fs_blob_size. */
398 size_t fs_fsignatures_size;// input: size of this struct (for compatibility)
399 char fs_cdhash[USER_FSIGNATURES_CDHASH_LEN]; // output: cdhash
400 int fs_hash_type;// output: hash algorithm type for cdhash
399401} fsignatures_t;
400402
403typedef struct fsupplement {
404 off_t fs_file_start; /* offset of Mach-O image in FAT file */
405 off_t fs_blob_start; /* offset of signature in Mach-O image */
406 size_t fs_blob_size; /* signature blob size */
407 int fs_orig_fd; /* address of original image */
408} fsupplement_t;
409
410
411
401412/*
402413 * DYLD needs to check if the object is allowed to be combined
403414 * into the main binary. This is done between the code signature
......@@ -415,6 +426,19 @@ typedef struct fchecklv {
415426} fchecklv_t;
416427
417428
429/* At this time F_GETSIGSINFO can only indicate platformness.
430 * As additional requestable information is defined, new keys will be added and the
431 * fgetsigsinfo_t structure will be lengthened to add space for the additional information
432 */
433#define GETSIGSINFO_PLATFORM_BINARY 1
434
435/* fgetsigsinfo_t used by F_GETSIGSINFO command */
436typedef struct fgetsigsinfo {
437 off_t fg_file_start; /* IN: Offset in the file to look for a signature, -1 for any signature */
438 int fg_info_request; /* IN: Key indicating the info requested */
439 int fg_sig_is_platform; /* OUT: 1 if the signature is a plat form binary, 0 if not */
440} fgetsigsinfo_t;
441
418442
419443/* lock operations for flock(2) */
420444#define LOCK_SH 0x01 /* shared file lock */
lib/libc/include/x86_64-macos-gnu/sys/ioccom.h+1-1
......@@ -83,7 +83,7 @@
8383#define IOC_OUT (__uint32_t)0x40000000
8484/* copy parameters in */
8585#define IOC_IN (__uint32_t)0x80000000
86/* copy paramters in and out */
86/* copy parameters in and out */
8787#define IOC_INOUT (IOC_IN|IOC_OUT)
8888/* mask for IN/OUT/VOID */
8989#define IOC_DIRMASK (__uint32_t)0xe0000000
lib/libc/include/x86_64-macos-gnu/sys/kauth.h created+410
......@@ -0,0 +1,410 @@
1/*
2 * Copyright (c) 2004-2010 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 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
30 * support for mandatory and extensible security protections. This notice
31 * is included in support of clause 2.2 (b) of the Apple Public License,
32 * Version 2.0.
33 */
34
35#ifndef _SYS_KAUTH_H
36#define _SYS_KAUTH_H
37
38#include <sys/appleapiopts.h>
39#include <sys/cdefs.h>
40#include <mach/boolean.h>
41#include <machine/types.h> /* u_int8_t, etc. */
42#include <sys/_types.h> /* __offsetof() */
43#include <sys/_types/_uid_t.h> /* uid_t */
44#include <sys/_types/_gid_t.h> /* gid_t */
45#include <sys/syslimits.h> /* NGROUPS_MAX */
46
47#ifdef __APPLE_API_EVOLVING
48
49/*
50 * Identities.
51 */
52
53#define KAUTH_UID_NONE (~(uid_t)0 - 100) /* not a valid UID */
54#define KAUTH_GID_NONE (~(gid_t)0 - 100) /* not a valid GID */
55
56#include <sys/_types/_guid_t.h>
57
58/* NT Security Identifier, structure as defined by Microsoft */
59#pragma pack(1) /* push packing of 1 byte */
60typedef struct {
61 u_int8_t sid_kind;
62 u_int8_t sid_authcount;
63 u_int8_t sid_authority[6];
64#define KAUTH_NTSID_MAX_AUTHORITIES 16
65 u_int32_t sid_authorities[KAUTH_NTSID_MAX_AUTHORITIES];
66} ntsid_t;
67#pragma pack() /* pop packing to previous packing level */
68#define _NTSID_T
69
70/* valid byte count inside a SID structure */
71#define KAUTH_NTSID_HDRSIZE (8)
72#define KAUTH_NTSID_SIZE(_s) (KAUTH_NTSID_HDRSIZE + ((_s)->sid_authcount * sizeof(u_int32_t)))
73
74/*
75 * External lookup message payload; this structure is shared between the
76 * kernel group membership resolver, and the user space group membership
77 * resolver daemon, and is use to communicate resolution requests from the
78 * kernel to user space, and the result of that request from user space to
79 * the kernel.
80 */
81struct kauth_identity_extlookup {
82 u_int32_t el_seqno; /* request sequence number */
83 u_int32_t el_result; /* lookup result */
84#define KAUTH_EXTLOOKUP_SUCCESS 0 /* results here are good */
85#define KAUTH_EXTLOOKUP_BADRQ 1 /* request badly formatted */
86#define KAUTH_EXTLOOKUP_FAILURE 2 /* transient failure during lookup */
87#define KAUTH_EXTLOOKUP_FATAL 3 /* permanent failure during lookup */
88#define KAUTH_EXTLOOKUP_INPROG 100 /* request in progress */
89 u_int32_t el_flags;
90#define KAUTH_EXTLOOKUP_VALID_UID (1<<0)
91#define KAUTH_EXTLOOKUP_VALID_UGUID (1<<1)
92#define KAUTH_EXTLOOKUP_VALID_USID (1<<2)
93#define KAUTH_EXTLOOKUP_VALID_GID (1<<3)
94#define KAUTH_EXTLOOKUP_VALID_GGUID (1<<4)
95#define KAUTH_EXTLOOKUP_VALID_GSID (1<<5)
96#define KAUTH_EXTLOOKUP_WANT_UID (1<<6)
97#define KAUTH_EXTLOOKUP_WANT_UGUID (1<<7)
98#define KAUTH_EXTLOOKUP_WANT_USID (1<<8)
99#define KAUTH_EXTLOOKUP_WANT_GID (1<<9)
100#define KAUTH_EXTLOOKUP_WANT_GGUID (1<<10)
101#define KAUTH_EXTLOOKUP_WANT_GSID (1<<11)
102#define KAUTH_EXTLOOKUP_WANT_MEMBERSHIP (1<<12)
103#define KAUTH_EXTLOOKUP_VALID_MEMBERSHIP (1<<13)
104#define KAUTH_EXTLOOKUP_ISMEMBER (1<<14)
105#define KAUTH_EXTLOOKUP_VALID_PWNAM (1<<15)
106#define KAUTH_EXTLOOKUP_WANT_PWNAM (1<<16)
107#define KAUTH_EXTLOOKUP_VALID_GRNAM (1<<17)
108#define KAUTH_EXTLOOKUP_WANT_GRNAM (1<<18)
109#define KAUTH_EXTLOOKUP_VALID_SUPGRPS (1<<19)
110#define KAUTH_EXTLOOKUP_WANT_SUPGRPS (1<<20)
111
112 __darwin_pid_t el_info_pid; /* request on behalf of PID */
113 u_int64_t el_extend; /* extension field */
114 u_int32_t el_info_reserved_1; /* reserved (APPLE) */
115
116 uid_t el_uid; /* user ID */
117 guid_t el_uguid; /* user GUID */
118 u_int32_t el_uguid_valid; /* TTL on translation result (seconds) */
119 ntsid_t el_usid; /* user NT SID */
120 u_int32_t el_usid_valid; /* TTL on translation result (seconds) */
121 gid_t el_gid; /* group ID */
122 guid_t el_gguid; /* group GUID */
123 u_int32_t el_gguid_valid; /* TTL on translation result (seconds) */
124 ntsid_t el_gsid; /* group SID */
125 u_int32_t el_gsid_valid; /* TTL on translation result (seconds) */
126 u_int32_t el_member_valid; /* TTL on group lookup result */
127 u_int32_t el_sup_grp_cnt; /* count of supplemental groups up to NGROUPS */
128 gid_t el_sup_groups[NGROUPS_MAX]; /* supplemental group list */
129};
130
131struct kauth_cache_sizes {
132 u_int32_t kcs_group_size;
133 u_int32_t kcs_id_size;
134};
135
136#define KAUTH_EXTLOOKUP_REGISTER (0)
137#define KAUTH_EXTLOOKUP_RESULT (1<<0)
138#define KAUTH_EXTLOOKUP_WORKER (1<<1)
139#define KAUTH_EXTLOOKUP_DEREGISTER (1<<2)
140#define KAUTH_GET_CACHE_SIZES (1<<3)
141#define KAUTH_SET_CACHE_SIZES (1<<4)
142#define KAUTH_CLEAR_CACHES (1<<5)
143
144#define IDENTITYSVC_ENTITLEMENT "com.apple.private.identitysvc"
145
146
147
148/*
149 * Generic Access Control Lists.
150 */
151#if defined(KERNEL) || defined (_SYS_ACL_H)
152
153typedef u_int32_t kauth_ace_rights_t;
154
155/* Access Control List Entry (ACE) */
156struct kauth_ace {
157 guid_t ace_applicable;
158 u_int32_t ace_flags;
159#define KAUTH_ACE_KINDMASK 0xf
160#define KAUTH_ACE_PERMIT 1
161#define KAUTH_ACE_DENY 2
162#define KAUTH_ACE_AUDIT 3 /* not implemented */
163#define KAUTH_ACE_ALARM 4 /* not implemented */
164#define KAUTH_ACE_INHERITED (1<<4)
165#define KAUTH_ACE_FILE_INHERIT (1<<5)
166#define KAUTH_ACE_DIRECTORY_INHERIT (1<<6)
167#define KAUTH_ACE_LIMIT_INHERIT (1<<7)
168#define KAUTH_ACE_ONLY_INHERIT (1<<8)
169#define KAUTH_ACE_SUCCESS (1<<9) /* not implemented (AUDIT/ALARM) */
170#define KAUTH_ACE_FAILURE (1<<10) /* not implemented (AUDIT/ALARM) */
171/* All flag bits controlling ACE inheritance */
172#define KAUTH_ACE_INHERIT_CONTROL_FLAGS \
173 (KAUTH_ACE_FILE_INHERIT | \
174 KAUTH_ACE_DIRECTORY_INHERIT | \
175 KAUTH_ACE_LIMIT_INHERIT | \
176 KAUTH_ACE_ONLY_INHERIT)
177 kauth_ace_rights_t ace_rights; /* scope specific */
178 /* These rights are never tested, but may be present in an ACL */
179#define KAUTH_ACE_GENERIC_ALL (1<<21)
180#define KAUTH_ACE_GENERIC_EXECUTE (1<<22)
181#define KAUTH_ACE_GENERIC_WRITE (1<<23)
182#define KAUTH_ACE_GENERIC_READ (1<<24)
183};
184
185#ifndef _KAUTH_ACE
186#define _KAUTH_ACE
187typedef struct kauth_ace *kauth_ace_t;
188#endif
189
190
191/* Access Control List */
192struct kauth_acl {
193 u_int32_t acl_entrycount;
194 u_int32_t acl_flags;
195
196 struct kauth_ace acl_ace[1];
197};
198
199/*
200 * XXX this value needs to be raised - 3893388
201 */
202#define KAUTH_ACL_MAX_ENTRIES 128
203
204/*
205 * The low 16 bits of the flags field are reserved for filesystem
206 * internal use and must be preserved by all APIs. This includes
207 * round-tripping flags through user-space interfaces.
208 */
209#define KAUTH_ACL_FLAGS_PRIVATE (0xffff)
210
211/*
212 * The high 16 bits of the flags are used to store attributes and
213 * to request specific handling of the ACL.
214 */
215
216/* inheritance will be deferred until the first rename operation */
217#define KAUTH_ACL_DEFER_INHERIT (1<<16)
218/* this ACL must not be overwritten as part of an inheritance operation */
219#define KAUTH_ACL_NO_INHERIT (1<<17)
220
221/* acl_entrycount that tells us the ACL is not valid */
222#define KAUTH_FILESEC_NOACL ((u_int32_t)(-1))
223
224/*
225 * If the acl_entrycount field is KAUTH_FILESEC_NOACL, then the size is the
226 * same as a kauth_acl structure; the intent is to put an actual entrycount of
227 * KAUTH_FILESEC_NOACL on disk to distinguish a kauth_filesec_t with an empty
228 * entry (Windows treats this as "deny all") from one that merely indicates a
229 * file group and/or owner guid values.
230 */
231#define KAUTH_ACL_SIZE(c) (__offsetof(struct kauth_acl, acl_ace) + ((u_int32_t)(c) != KAUTH_FILESEC_NOACL ? ((c) * sizeof(struct kauth_ace)) : 0))
232#define KAUTH_ACL_COPYSIZE(p) KAUTH_ACL_SIZE((p)->acl_entrycount)
233
234
235#ifndef _KAUTH_ACL
236#define _KAUTH_ACL
237typedef struct kauth_acl *kauth_acl_t;
238#endif
239
240
241
242/*
243 * Extended File Security.
244 */
245
246/* File Security information */
247struct kauth_filesec {
248 u_int32_t fsec_magic;
249#define KAUTH_FILESEC_MAGIC 0x012cc16d
250 guid_t fsec_owner;
251 guid_t fsec_group;
252
253 struct kauth_acl fsec_acl;
254};
255
256/* backwards compatibility */
257#define fsec_entrycount fsec_acl.acl_entrycount
258#define fsec_flags fsec_acl.acl_flags
259#define fsec_ace fsec_acl.acl_ace
260#define KAUTH_FILESEC_FLAGS_PRIVATE KAUTH_ACL_FLAGS_PRIVATE
261#define KAUTH_FILESEC_DEFER_INHERIT KAUTH_ACL_DEFER_INHERIT
262#define KAUTH_FILESEC_NO_INHERIT KAUTH_ACL_NO_INHERIT
263#define KAUTH_FILESEC_NONE ((kauth_filesec_t)0)
264#define KAUTH_FILESEC_WANTED ((kauth_filesec_t)1)
265
266#ifndef _KAUTH_FILESEC
267#define _KAUTH_FILESEC
268typedef struct kauth_filesec *kauth_filesec_t;
269#endif
270
271#define KAUTH_FILESEC_SIZE(c) (__offsetof(struct kauth_filesec, fsec_acl) + __offsetof(struct kauth_acl, acl_ace) + (c) * sizeof(struct kauth_ace))
272#define KAUTH_FILESEC_COPYSIZE(p) KAUTH_FILESEC_SIZE(((p)->fsec_entrycount == KAUTH_FILESEC_NOACL) ? 0 : (p)->fsec_entrycount)
273#define KAUTH_FILESEC_COUNT(s) (((s) - KAUTH_FILESEC_SIZE(0)) / sizeof(struct kauth_ace))
274#define KAUTH_FILESEC_VALID(s) ((s) >= KAUTH_FILESEC_SIZE(0) && (((s) - KAUTH_FILESEC_SIZE(0)) % sizeof(struct kauth_ace)) == 0)
275
276#define KAUTH_FILESEC_XATTR "com.apple.system.Security"
277
278/* Allowable first arguments to kauth_filesec_acl_setendian() */
279#define KAUTH_ENDIAN_HOST 0x00000001 /* set host endianness */
280#define KAUTH_ENDIAN_DISK 0x00000002 /* set disk endianness */
281
282#endif /* KERNEL || <sys/acl.h> */
283
284
285
286/* Actions, also rights bits in an ACE */
287
288#if defined(KERNEL) || defined (_SYS_ACL_H)
289#define KAUTH_VNODE_READ_DATA (1U<<1)
290#define KAUTH_VNODE_LIST_DIRECTORY KAUTH_VNODE_READ_DATA
291#define KAUTH_VNODE_WRITE_DATA (1U<<2)
292#define KAUTH_VNODE_ADD_FILE KAUTH_VNODE_WRITE_DATA
293#define KAUTH_VNODE_EXECUTE (1U<<3)
294#define KAUTH_VNODE_SEARCH KAUTH_VNODE_EXECUTE
295#define KAUTH_VNODE_DELETE (1U<<4)
296#define KAUTH_VNODE_APPEND_DATA (1U<<5)
297#define KAUTH_VNODE_ADD_SUBDIRECTORY KAUTH_VNODE_APPEND_DATA
298#define KAUTH_VNODE_DELETE_CHILD (1U<<6)
299#define KAUTH_VNODE_READ_ATTRIBUTES (1U<<7)
300#define KAUTH_VNODE_WRITE_ATTRIBUTES (1U<<8)
301#define KAUTH_VNODE_READ_EXTATTRIBUTES (1U<<9)
302#define KAUTH_VNODE_WRITE_EXTATTRIBUTES (1U<<10)
303#define KAUTH_VNODE_READ_SECURITY (1U<<11)
304#define KAUTH_VNODE_WRITE_SECURITY (1U<<12)
305#define KAUTH_VNODE_TAKE_OWNERSHIP (1U<<13)
306
307/* backwards compatibility only */
308#define KAUTH_VNODE_CHANGE_OWNER KAUTH_VNODE_TAKE_OWNERSHIP
309
310/* For Windows interoperability only */
311#define KAUTH_VNODE_SYNCHRONIZE (1U<<20)
312
313/* (1<<21) - (1<<24) are reserved for generic rights bits */
314
315/* Actions not expressed as rights bits */
316/*
317 * Authorizes the vnode as the target of a hard link.
318 */
319#define KAUTH_VNODE_LINKTARGET (1U<<25)
320
321/*
322 * Indicates that other steps have been taken to authorise the action,
323 * but authorisation should be denied for immutable objects.
324 */
325#define KAUTH_VNODE_CHECKIMMUTABLE (1U<<26)
326
327/* Action modifiers */
328/*
329 * The KAUTH_VNODE_ACCESS bit is passed to the callback if the authorisation
330 * request in progress is advisory, rather than authoritative. Listeners
331 * performing consequential work (i.e. not strictly checking authorisation)
332 * may test this flag to avoid performing unnecessary work.
333 *
334 * This bit will never be present in an ACE.
335 */
336#define KAUTH_VNODE_ACCESS (1U<<31)
337
338/*
339 * The KAUTH_VNODE_NOIMMUTABLE bit is passed to the callback along with the
340 * KAUTH_VNODE_WRITE_SECURITY bit (and no others) to indicate that the
341 * caller wishes to change one or more of the immutable flags, and the
342 * state of these flags should not be considered when authorizing the request.
343 * The system immutable flags are only ignored when the system securelevel
344 * is low enough to allow their removal.
345 */
346#define KAUTH_VNODE_NOIMMUTABLE (1U<<30)
347
348
349/*
350 * fake right that is composed by the following...
351 * vnode must have search for owner, group and world allowed
352 * plus there must be no deny modes present for SEARCH... this fake
353 * right is used by the fast lookup path to avoid checking
354 * for an exact match on the last credential to lookup
355 * the component being acted on
356 */
357#define KAUTH_VNODE_SEARCHBYANYONE (1U<<29)
358
359
360/*
361 * when passed as an 'action' to "vnode_uncache_authorized_actions"
362 * it indicates that all of the cached authorizations for that
363 * vnode should be invalidated
364 */
365#define KAUTH_INVALIDATE_CACHED_RIGHTS ((kauth_action_t)~0)
366
367
368
369/* The expansions of the GENERIC bits at evaluation time */
370#define KAUTH_VNODE_GENERIC_READ_BITS (KAUTH_VNODE_READ_DATA | \
371 KAUTH_VNODE_READ_ATTRIBUTES | \
372 KAUTH_VNODE_READ_EXTATTRIBUTES | \
373 KAUTH_VNODE_READ_SECURITY)
374
375#define KAUTH_VNODE_GENERIC_WRITE_BITS (KAUTH_VNODE_WRITE_DATA | \
376 KAUTH_VNODE_APPEND_DATA | \
377 KAUTH_VNODE_DELETE | \
378 KAUTH_VNODE_DELETE_CHILD | \
379 KAUTH_VNODE_WRITE_ATTRIBUTES | \
380 KAUTH_VNODE_WRITE_EXTATTRIBUTES | \
381 KAUTH_VNODE_WRITE_SECURITY)
382
383#define KAUTH_VNODE_GENERIC_EXECUTE_BITS (KAUTH_VNODE_EXECUTE)
384
385#define KAUTH_VNODE_GENERIC_ALL_BITS (KAUTH_VNODE_GENERIC_READ_BITS | \
386 KAUTH_VNODE_GENERIC_WRITE_BITS | \
387 KAUTH_VNODE_GENERIC_EXECUTE_BITS)
388
389/*
390 * Some sets of bits, defined here for convenience.
391 */
392#define KAUTH_VNODE_WRITE_RIGHTS (KAUTH_VNODE_ADD_FILE | \
393 KAUTH_VNODE_ADD_SUBDIRECTORY | \
394 KAUTH_VNODE_DELETE_CHILD | \
395 KAUTH_VNODE_WRITE_DATA | \
396 KAUTH_VNODE_APPEND_DATA | \
397 KAUTH_VNODE_DELETE | \
398 KAUTH_VNODE_WRITE_ATTRIBUTES | \
399 KAUTH_VNODE_WRITE_EXTATTRIBUTES | \
400 KAUTH_VNODE_WRITE_SECURITY | \
401 KAUTH_VNODE_TAKE_OWNERSHIP | \
402 KAUTH_VNODE_LINKTARGET | \
403 KAUTH_VNODE_CHECKIMMUTABLE)
404
405
406#endif /* KERNEL || <sys/acl.h> */
407
408
409#endif /* __APPLE_API_EVOLVING */
410#endif /* _SYS_KAUTH_H */
lib/libc/include/x86_64-macos-gnu/sys/mman.h+17-4
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2000-2019 Apple Computer, Inc. All rights reserved.
2 * Copyright (c) 2000-2020 Apple Computer, Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55 *
......@@ -89,6 +89,10 @@
8989#include <sys/_types/_off_t.h>
9090#include <sys/_types/_size_t.h>
9191
92#if __DARWIN_C_LEVEL >= 200809L
93#include <Availability.h>
94#endif /* __DARWIN_C_LEVEL */
95
9296/*
9397 * Protections are chosen from these bits, or-ed together
9498 */
......@@ -145,9 +149,17 @@
145149#define MAP_RESILIENT_CODESIGN 0x2000 /* no code-signing failures */
146150#define MAP_RESILIENT_MEDIA 0x4000 /* no backing-store failures */
147151
148#if !defined(CONFIG_EMBEDDED)
149#define MAP_32BIT 0x8000 /* Return virtual addresses <4G only: Requires entitlement */
150#endif /* !defined(CONFIG_EMBEDDED) */
152#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
153#define MAP_32BIT 0x8000 /* Return virtual addresses <4G only */
154#endif /* defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 */
155
156
157/*
158 * Flags used to support translated processes.
159 */
160#define MAP_TRANSLATED_ALLOW_EXECUTE 0x20000 /* allow execute in translated processes */
161
162#define MAP_UNIX03 0x40000 /* UNIX03 compliance */
151163
152164#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
153165
......@@ -213,6 +225,7 @@
213225
214226
215227
228
216229__BEGIN_DECLS
217230/* [ML] */
218231int mlockall(int);
lib/libc/include/x86_64-macos-gnu/sys/mount.h+12-1
......@@ -324,7 +324,7 @@ struct vfsidctl {
324324 * New style VFS sysctls, do not reuse/conflict with the namespace for
325325 * private sysctls.
326326 */
327#define VFS_CTL_STATFS 0x00010001 /* statfs */
327#define VFS_CTL_OSTATFS 0x00010001 /* old legacy statfs */
328328#define VFS_CTL_UMOUNT 0x00010002 /* unmount */
329329#define VFS_CTL_QUERY 0x00010003 /* anything wrong? (vfsquery) */
330330#define VFS_CTL_NEWADDR 0x00010004 /* reconnect to new address */
......@@ -334,6 +334,17 @@ struct vfsidctl {
334334#define VFS_CTL_DISC 0x00010008 /* server disconnected */
335335#define VFS_CTL_SERVERINFO 0x00010009 /* information about fs server */
336336#define VFS_CTL_NSTATUS 0x0001000A /* netfs mount status */
337#define VFS_CTL_STATFS64 0x0001000B /* statfs64 */
338
339/*
340 * Automatically select the correct VFS_CTL_*STATFS* flavor based
341 * on what "struct statfs" layout the client will use.
342 */
343#if __DARWIN_64_BIT_INO_T
344#define VFS_CTL_STATFS VFS_CTL_STATFS64
345#else
346#define VFS_CTL_STATFS VFS_CTL_OSTATFS
347#endif
337348
338349struct vfsquery {
339350 u_int32_t vq_flags;
lib/libc/include/x86_64-macos-gnu/sys/param.h+4-22
......@@ -197,10 +197,10 @@
197197#define MAXSYMLINKS 32
198198
199199/* Bit map related macros. */
200#define setbit(a, i) (((char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
201#define clrbit(a, i) (((char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
202#define isset(a, i) (((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY)))
203#define isclr(a, i) ((((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
200#define setbit(a, i) (((unsigned char *)(a))[(i)/NBBY] |= 1u<<((i)%NBBY))
201#define clrbit(a, i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1u<<((i)%NBBY)))
202#define isset(a, i) (((unsigned char *)(a))[(i)/NBBY] & (1u<<((i)%NBBY)))
203#define isclr(a, i) ((((unsigned char *)(a))[(i)/NBBY] & (1u<<((i)%NBBY))) == 0)
204204
205205/* Macros for counting and rounding. */
206206#ifndef howmany
......@@ -218,24 +218,6 @@
218218#define MAX(a, b) (((a)>(b))?(a):(b))
219219#endif /* MAX */
220220
221/*
222 * Constants for setting the parameters of the kernel memory allocator.
223 *
224 * 2 ** MINBUCKET is the smallest unit of memory that will be
225 * allocated. It must be at least large enough to hold a pointer.
226 *
227 * Units of memory less or equal to MAXALLOCSAVE will permanently
228 * allocate physical memory; requests for these size pieces of
229 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
230 * always allocate and free physical memory; requests for these
231 * size allocations should be done infrequently as they will be slow.
232 *
233 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
234 * MAXALLOCSIZE must be a power of two.
235 */
236#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
237#define MAXALLOCSAVE (2 * CLBYTES)
238
239221/*
240222 * Scale factor for scaled integers used to count %cpu time and load avgs.
241223 *
lib/libc/include/x86_64-macos-gnu/sys/proc.h+1
......@@ -84,6 +84,7 @@
8484struct session;
8585struct pgrp;
8686struct proc;
87struct proc_ident;
8788
8889/* Exported fields for kern sysctls */
8990struct extern_proc {
lib/libc/include/x86_64-macos-gnu/sys/resource.h+56-2
......@@ -188,7 +188,13 @@ struct rusage {
188188#define RUSAGE_INFO_V2 2
189189#define RUSAGE_INFO_V3 3
190190#define RUSAGE_INFO_V4 4
191#define RUSAGE_INFO_CURRENT RUSAGE_INFO_V4
191#define RUSAGE_INFO_V5 5
192#define RUSAGE_INFO_CURRENT RUSAGE_INFO_V5
193
194/*
195 * Flags for RUSAGE_INFO_V5
196 */
197#define RU_PROC_RUNS_RESLIDE 0x00000001 /* proc has reslid shared cache */
192198
193199typedef void *rusage_info_t;
194200
......@@ -318,7 +324,47 @@ struct rusage_info_v4 {
318324 uint64_t ri_runnable_time;
319325};
320326
321typedef struct rusage_info_v4 rusage_info_current;
327struct rusage_info_v5 {
328 uint8_t ri_uuid[16];
329 uint64_t ri_user_time;
330 uint64_t ri_system_time;
331 uint64_t ri_pkg_idle_wkups;
332 uint64_t ri_interrupt_wkups;
333 uint64_t ri_pageins;
334 uint64_t ri_wired_size;
335 uint64_t ri_resident_size;
336 uint64_t ri_phys_footprint;
337 uint64_t ri_proc_start_abstime;
338 uint64_t ri_proc_exit_abstime;
339 uint64_t ri_child_user_time;
340 uint64_t ri_child_system_time;
341 uint64_t ri_child_pkg_idle_wkups;
342 uint64_t ri_child_interrupt_wkups;
343 uint64_t ri_child_pageins;
344 uint64_t ri_child_elapsed_abstime;
345 uint64_t ri_diskio_bytesread;
346 uint64_t ri_diskio_byteswritten;
347 uint64_t ri_cpu_time_qos_default;
348 uint64_t ri_cpu_time_qos_maintenance;
349 uint64_t ri_cpu_time_qos_background;
350 uint64_t ri_cpu_time_qos_utility;
351 uint64_t ri_cpu_time_qos_legacy;
352 uint64_t ri_cpu_time_qos_user_initiated;
353 uint64_t ri_cpu_time_qos_user_interactive;
354 uint64_t ri_billed_system_time;
355 uint64_t ri_serviced_system_time;
356 uint64_t ri_logical_writes;
357 uint64_t ri_lifetime_max_phys_footprint;
358 uint64_t ri_instructions;
359 uint64_t ri_cycles;
360 uint64_t ri_billed_energy;
361 uint64_t ri_serviced_energy;
362 uint64_t ri_interval_max_phys_footprint;
363 uint64_t ri_runnable_time;
364 uint64_t ri_flags;
365};
366
367typedef struct rusage_info_v5 rusage_info_current;
322368
323369#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
324370
......@@ -409,6 +455,8 @@ struct proc_rlimit_control_wakeupmon {
409455#define IOPOL_TYPE_VFS_ATIME_UPDATES 2
410456#define IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES 3
411457#define IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME 4
458#define IOPOL_TYPE_VFS_TRIGGER_RESOLVE 5
459#define IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION 6
412460
413461/* scope */
414462#define IOPOL_SCOPE_PROCESS 0
......@@ -438,6 +486,12 @@ struct proc_rlimit_control_wakeupmon {
438486#define IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT 0
439487#define IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME 1
440488
489#define IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT 0
490#define IOPOL_VFS_TRIGGER_RESOLVE_OFF 1
491
492#define IOPOL_VFS_CONTENT_PROTECTION_DEFAULT 0
493#define IOPOL_VFS_CONTENT_PROTECTION_IGNORE 1
494
441495#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
442496
443497
lib/libc/include/x86_64-macos-gnu/sys/shm.h+4
......@@ -109,7 +109,11 @@ typedef unsigned short shmatt_t;
109109 * headers at this time, to avoid the resulting namespace
110110 * pollution, which is why we discourages its use.
111111 */
112#if __arm64__
113#define SHMLBA (16*1024) /* [XSI] Segment low boundary address multiple*/
114#else /* __arm64__ */
112115#define SHMLBA 4096 /* [XSI] Segment low boundary address multiple*/
116#endif /* __arm64__ */
113117
114118/* "official" access mode definitions; somewhat braindead since you have
115119 * to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
lib/libc/include/x86_64-macos-gnu/sys/socket.h+15-6
......@@ -160,8 +160,8 @@
160160#define SO_ERROR 0x1007 /* get error status and clear */
161161#define SO_TYPE 0x1008 /* get socket type */
162162#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
163#define SO_LABEL 0x1010 /* socket's MAC label */
164#define SO_PEERLABEL 0x1011 /* socket's peer MAC label */
163#define SO_LABEL 0x1010 /* deprecated */
164#define SO_PEERLABEL 0x1011 /* deprecated */
165165#ifdef __APPLE__
166166#define SO_NREAD 0x1020 /* APPLE: get 1st-packet byte count */
167167#define SO_NKE 0x1021 /* APPLE: Install socket-level NKE */
......@@ -182,7 +182,7 @@
182182#define SO_NET_SERVICE_TYPE 0x1116 /* Network service type */
183183
184184
185#define SO_NETSVC_MARKING_LEVEL 0x1119 /* Get QoS marking in effect for socket */
185#define SO_NETSVC_MARKING_LEVEL 0x1119 /* Get QoS marking in effect for socket */
186186
187187/*
188188 * Network Service Type for option SO_NET_SERVICE_TYPE
......@@ -398,7 +398,8 @@ struct so_np_extensions {
398398#define AF_RESERVED_36 36 /* Reserved for internal usage */
399399#define AF_IEEE80211 37 /* IEEE 802.11 protocol */
400400#define AF_UTUN 38
401#define AF_MAX 40
401#define AF_VSOCK 40 /* VM Sockets */
402#define AF_MAX 41
402403#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
403404
404405/*
......@@ -486,6 +487,7 @@ struct sockaddr_storage {
486487#define PF_PPP AF_PPP
487488#define PF_RESERVED_36 AF_RESERVED_36
488489#define PF_UTUN AF_UTUN
490#define PF_VSOCK AF_VSOCK
489491#define PF_MAX AF_MAX
490492
491493/*
......@@ -578,6 +580,13 @@ struct msghdr {
578580#define MSG_NEEDSA 0x10000 /* Fail receive if socket address cannot be allocated */
579581#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
580582
583#if __DARWIN_C_LEVEL >= 200809L
584#define MSG_NOSIGNAL 0x80000 /* do not generate SIGPIPE on EOF */
585#endif /* __DARWIN_C_LEVEL */
586
587#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
588#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
589
581590/*
582591 * Header for ancillary data objects in msg_control buffer.
583592 * Used for additional information with/about a datagram
......@@ -671,7 +680,7 @@ struct cmsgcred {
671680#define SHUT_WR 1 /* shut down the writing side */
672681#define SHUT_RDWR 2 /* shut down both sides */
673682
674#if !defined(_POSIX_C_SOURCE)
683#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
675684/*
676685 * sendfile(2) header/trailer struct
677686 */
......@@ -683,7 +692,7 @@ struct sf_hdtr {
683692};
684693
685694
686#endif /* !_POSIX_C_SOURCE */
695#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
687696
688697
689698__BEGIN_DECLS
lib/libc/include/x86_64-macos-gnu/sys/spawn.h+3-1
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
2 * Copyright (c) 2006-2020 Apple Computer, Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55 *
......@@ -61,6 +61,8 @@
6161#define POSIX_SPAWN_SETSID 0x0400
6262#define POSIX_SPAWN_CLOEXEC_DEFAULT 0x4000
6363
64#define _POSIX_SPAWN_RESLIDE 0x0800
65
6466/*
6567 * Possible values to be set for the process control actions on resource starvation.
6668 * POSIX_SPAWN_PCONTROL_THROTTLE indicates that the process is to be throttled on starvation.
lib/libc/include/x86_64-macos-gnu/sys/stat.h+3-1
......@@ -361,6 +361,7 @@ struct stat64 __DARWIN_STRUCT_STAT64;
361361
362362#endif
363363
364#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
364365/*
365366 * Extended flags ("EF") returned by ATTR_CMNEXT_EXT_FLAGS from getattrlist/getattrlistbulk
366367 */
......@@ -369,7 +370,8 @@ struct stat64 __DARWIN_STRUCT_STAT64;
369370#define EF_IS_SYNC_ROOT 0x00000004 /* file is a sync root for iCloud */
370371#define EF_IS_PURGEABLE 0x00000008 /* file is purgeable */
371372#define EF_IS_SPARSE 0x00000010 /* file has at least one sparse region */
372
373#define EF_IS_SYNTHETIC 0x00000020 /* a synthetic directory/symlink */
374#endif
373375
374376
375377
lib/libc/include/x86_64-macos-gnu/sys/sysctl.h+11-7
......@@ -553,8 +553,8 @@ extern struct loadavg averunnable;
553553/*
554554 * CTL_HW identifiers
555555 */
556#define HW_MACHINE 1 /* string: machine class */
557#define HW_MODEL 2 /* string: specific machine model */
556#define HW_MACHINE 1 /* string: machine class (deprecated: use HW_PRODUCT) */
557#define HW_MODEL 2 /* string: specific machine model (deprecated: use HW_TARGET) */
558558#define HW_NCPU 3 /* int: number of cpus */
559559#define HW_BYTEORDER 4 /* int: machine byte order */
560560#define HW_PHYSMEM 5 /* int: total memory */
......@@ -578,12 +578,14 @@ extern struct loadavg averunnable;
578578#define HW_TB_FREQ 23 /* int: Bus Frequency */
579579#define HW_MEMSIZE 24 /* uint64_t: physical ram size */
580580#define HW_AVAILCPU 25 /* int: number of available CPUs */
581#define HW_MAXID 26 /* number of valid hw ids */
581#define HW_TARGET 26 /* string: model identifier */
582#define HW_PRODUCT 27 /* string: product identifier */
583#define HW_MAXID 28 /* number of valid hw ids */
582584
583585#define CTL_HW_NAMES { \
584586 { 0, 0 }, \
585 { "machine", CTLTYPE_STRING }, \
586 { "model", CTLTYPE_STRING }, \
587 { "machine", CTLTYPE_STRING }, /* Deprecated: use hw.product */ \
588 { "model", CTLTYPE_STRING }, /* Deprecated: use hw.target */ \
587589 { "ncpu", CTLTYPE_INT }, \
588590 { "byteorder", CTLTYPE_INT }, \
589591 { "physmem", CTLTYPE_INT }, \
......@@ -606,7 +608,9 @@ extern struct loadavg averunnable;
606608 { "l3cachesize", CTLTYPE_INT }, \
607609 { "tbfrequency", CTLTYPE_INT }, \
608610 { "memsize", CTLTYPE_QUAD }, \
609 { "availcpu", CTLTYPE_INT } \
611 { "availcpu", CTLTYPE_INT }, \
612 { "target", CTLTYPE_STRING }, \
613 { "product", CTLTYPE_STRING }, \
610614}
611615
612616/*
......@@ -755,7 +759,7 @@ extern struct loadavg averunnable;
755759#define CTL_DEBUG_MAXID 20
756760
757761
758#if (CTL_MAXID != 9) || (KERN_MAXID != 72) || (VM_MAXID != 6) || (HW_MAXID != 26) || (USER_MAXID != 21) || (CTL_DEBUG_MAXID != 20)
762#if (CTL_MAXID != 9) || (KERN_MAXID != 72) || (VM_MAXID != 6) || (HW_MAXID != 28) || (USER_MAXID != 21) || (CTL_DEBUG_MAXID != 20)
759763#error Use the SYSCTL_*() macros and OID_AUTO instead!
760764#endif
761765
lib/libc/include/x86_64-macos-gnu/sys/syslimits.h+9-1
......@@ -68,11 +68,19 @@
6868#include <sys/cdefs.h>
6969
7070#if !defined(_ANSI_SOURCE)
71
72/* max bytes for an exec function */
73#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
74#define ARG_MAX (1024 * 1024)
75#else
76#define ARG_MAX (256 * 1024)
77#endif
78
7179/*
7280 * Note: CHILD_MAX *must* be less than hard_maxproc, which is set at
7381 * compile time; you *cannot* set it higher than the hard limit!!
7482 */
75#define ARG_MAX (256 * 1024) /* max bytes for an exec function */
83
7684#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
7785#define CHILD_MAX 266 /* max simultaneous processes */
7886#define GID_MAX 2147483647U /* max value for a gid_t (2^31-2) */
lib/libc/include/x86_64-macos-gnu/sys/uio.h+13-2
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
2 * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
33 *
44 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55 *
......@@ -64,8 +64,10 @@
6464#ifndef _SYS_UIO_H_
6565#define _SYS_UIO_H_
6666
67#include <Availability.h>
6768#include <sys/cdefs.h>
6869#include <sys/_types.h>
70#include <sys/_types/_off_t.h>
6971
7072/*
7173 * [XSI] The ssize_t and size_t types shall be defined as described
......@@ -76,7 +78,7 @@
7678
7779/*
7880 * [XSI] Structure whose address is passed as the second parameter to the
79 * readv() and writev() functions.
81 * readv(), preadv(), writev() and pwritev() functions.
8082 */
8183#include <sys/_types/_iovec_t.h>
8284
......@@ -95,6 +97,15 @@ enum uio_rw { UIO_READ, UIO_WRITE };
9597__BEGIN_DECLS
9698ssize_t readv(int, const struct iovec *, int) __DARWIN_ALIAS_C(readv);
9799ssize_t writev(int, const struct iovec *, int) __DARWIN_ALIAS_C(writev);
100
101#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
102
103ssize_t preadv(int, const struct iovec *, int, off_t) __DARWIN_NOCANCEL(preadv) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0));
104ssize_t pwritev(int, const struct iovec *, int, off_t) __DARWIN_NOCANCEL(pwritev) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0));
105
106#endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */
107
98108__END_DECLS
99109
110
100111#endif /* !_SYS_UIO_H_ */
lib/libc/include/x86_64-macos-gnu/sys/un.h+1
......@@ -90,6 +90,7 @@ struct sockaddr_un {
9090#define LOCAL_PEEREPID 0x003 /* retrieve eff. peer pid */
9191#define LOCAL_PEERUUID 0x004 /* retrieve peer UUID */
9292#define LOCAL_PEEREUUID 0x005 /* retrieve eff. peer UUID */
93#define LOCAL_PEERTOKEN 0x006 /* retrieve peer audit token */
9394
9495#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
9596
lib/libc/include/x86_64-macos-gnu/xlocale/_inttypes.h+1
......@@ -26,6 +26,7 @@
2626
2727#include <sys/cdefs.h>
2828#include <stdint.h>
29#include <stddef.h> /* wchar_t */
2930#include <_xlocale.h>
3031
3132__BEGIN_DECLS
lib/libc/include/x86_64-macos-gnu/xlocale/_wchar.h+2
......@@ -27,6 +27,8 @@
2727#include <_stdio.h>
2828#include <_xlocale.h>
2929#include <sys/_types/_mbstate_t.h>
30#include <sys/_types/_wint_t.h>
31#include <stddef.h> /* wchar_t */
3032
3133/* Initially added in Issue 4 */
3234__BEGIN_DECLS
lib/libc/include/x86_64-macos-gnu/xpc/activity.h created+447
......@@ -0,0 +1,447 @@
1#ifndef __XPC_ACTIVITY_H__
2#define __XPC_ACTIVITY_H__
3
4#ifndef __XPC_INDIRECT__
5#error "Please #include <xpc/xpc.h> instead of this file directly."
6// For HeaderDoc.
7#include <xpc/base.h>
8#endif // __XPC_INDIRECT__
9
10#ifdef __BLOCKS__
11
12XPC_ASSUME_NONNULL_BEGIN
13__BEGIN_DECLS
14
15/*
16 * The following are a collection of keys and values used to set an activity's
17 * execution criteria.
18 */
19
20/*!
21 * @constant XPC_ACTIVITY_INTERVAL
22 * An integer property indicating the desired time interval (in seconds) of the
23 * activity. The activity will not be run more than once per time interval.
24 * Due to the nature of XPC Activity finding an opportune time to run
25 * the activity, any two occurrences may be more or less than 'interval'
26 * seconds apart, but on average will be 'interval' seconds apart.
27 * The presence of this key implies the following, unless overridden:
28 * - XPC_ACTIVITY_REPEATING with a value of true
29 * - XPC_ACTIVITY_DELAY with a value of half the 'interval'
30 * The delay enforces a minimum distance between any two occurrences.
31 * - XPC_ACTIVITY_GRACE_PERIOD with a value of half the 'interval'.
32 * The grace period is the amount of time allowed to pass after the end of
33 * the interval before more aggressive scheduling occurs. The grace period
34 * does not increase the size of the interval.
35 */
36__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
37XPC_EXPORT
38const char * const XPC_ACTIVITY_INTERVAL;
39
40/*!
41 * @constant XPC_ACTIVITY_REPEATING
42 * A boolean property indicating whether this is a repeating activity.
43 */
44__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
45XPC_EXPORT
46const char * const XPC_ACTIVITY_REPEATING;
47
48/*!
49 * @constant XPC_ACTIVITY_DELAY
50 * An integer property indicating the number of seconds to delay before
51 * beginning the activity.
52 */
53__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
54XPC_EXPORT
55const char * const XPC_ACTIVITY_DELAY;
56
57/*!
58 * @constant XPC_ACTIVITY_GRACE_PERIOD
59 * An integer property indicating the number of seconds to allow as a grace
60 * period before the scheduling of the activity becomes more aggressive.
61 */
62__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
63XPC_EXPORT
64const char * const XPC_ACTIVITY_GRACE_PERIOD;
65
66
67__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
68XPC_EXPORT
69const int64_t XPC_ACTIVITY_INTERVAL_1_MIN;
70
71__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
72XPC_EXPORT
73const int64_t XPC_ACTIVITY_INTERVAL_5_MIN;
74
75__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
76XPC_EXPORT
77const int64_t XPC_ACTIVITY_INTERVAL_15_MIN;
78
79__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
80XPC_EXPORT
81const int64_t XPC_ACTIVITY_INTERVAL_30_MIN;
82
83__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
84XPC_EXPORT
85const int64_t XPC_ACTIVITY_INTERVAL_1_HOUR;
86
87__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
88XPC_EXPORT
89const int64_t XPC_ACTIVITY_INTERVAL_4_HOURS;
90
91__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
92XPC_EXPORT
93const int64_t XPC_ACTIVITY_INTERVAL_8_HOURS;
94
95__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
96XPC_EXPORT
97const int64_t XPC_ACTIVITY_INTERVAL_1_DAY;
98
99__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
100XPC_EXPORT
101const int64_t XPC_ACTIVITY_INTERVAL_7_DAYS;
102
103/*!
104 * @constant XPC_ACTIVITY_PRIORITY
105 * A string property indicating the priority of the activity.
106 */
107__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
108XPC_EXPORT
109const char * const XPC_ACTIVITY_PRIORITY;
110
111/*!
112 * @constant XPC_ACTIVITY_PRIORITY_MAINTENANCE
113 * A string indicating activity is maintenance priority.
114 *
115 * Maintenance priority is intended for user-invisible maintenance tasks
116 * such as garbage collection or optimization.
117 *
118 * Maintenance activities are not permitted to run if the device thermal
119 * condition exceeds a nominal level or if the battery level is lower than 20%.
120 * In Low Power Mode (on supported devices), maintenance activities are not
121 * permitted to run while the device is on battery, or plugged in and the
122 * battery level is lower than 30%.
123 */
124__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
125XPC_EXPORT
126const char * const XPC_ACTIVITY_PRIORITY_MAINTENANCE;
127
128/*!
129 * @constant XPC_ACTIVITY_PRIORITY_UTILITY
130 * A string indicating activity is utility priority.
131 *
132 * Utility priority is intended for user-visible tasks such as fetching data
133 * from the network, copying files, or importing data.
134 *
135 * Utility activities are not permitted to run if the device thermal condition
136 * exceeds a moderate level or if the battery level is less than 10%. In Low
137 * Power Mode (on supported devices) when on battery power, utility activities
138 * are only permitted when they are close to their deadline (90% of their time
139 * window has elapsed).
140 */
141__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
142XPC_EXPORT
143const char * const XPC_ACTIVITY_PRIORITY_UTILITY;
144
145/*!
146 * @constant XPC_ACTIVITY_ALLOW_BATTERY
147 * A Boolean value indicating whether the activity should be allowed to run
148 * while the computer is on battery power. The default value is false for
149 * maintenance priority activity and true for utility priority activity.
150 */
151__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
152XPC_EXPORT
153const char * const XPC_ACTIVITY_ALLOW_BATTERY;
154
155/*!
156 * @constant XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP
157 * A Boolean value indicating whether the activity should only be performed
158 * while device appears to be asleep. Note that the definition of screen sleep
159 * may vary by platform and may include states where the device is known to be
160 * idle despite the fact that the display itself is still powered. Defaults to
161 * false.
162 */
163__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
164XPC_EXPORT
165const char * const XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP; // bool
166
167/*!
168 * @constant XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL
169 * An integer percentage of minimum battery charge required to allow the
170 * activity to run. A default minimum battery level is determined by the
171 * system.
172 */
173__OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_9, __MAC_10_9, __IPHONE_7_0, __IPHONE_7_0,
174 "REQUIRE_BATTERY_LEVEL is not implemented")
175XPC_EXPORT
176const char * const XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL; // int (%)
177
178/*!
179 * @constant XPC_ACTIVITY_REQUIRE_HDD_SPINNING
180 * A Boolean value indicating whether the activity should only be performed
181 * while the hard disk drive (HDD) is spinning. Computers with flash storage
182 * are considered to be equivalent to HDD spinning. Defaults to false.
183 */
184__OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_9, __MAC_10_9, __IPHONE_7_0, __IPHONE_7_0,
185 "REQUIRE_HDD_SPINNING is not implemented")
186XPC_EXPORT
187const char * const XPC_ACTIVITY_REQUIRE_HDD_SPINNING; // bool
188
189/*!
190 * @define XPC_TYPE_ACTIVITY
191 * A type representing the XPC activity object.
192 */
193#define XPC_TYPE_ACTIVITY (&_xpc_type_activity)
194__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
195XPC_EXPORT
196XPC_TYPE(_xpc_type_activity);
197
198/*!
199 * @typedef xpc_activity_t
200 *
201 * @abstract
202 * An XPC activity object.
203 *
204 * @discussion
205 * This object represents a set of execution criteria and a current execution
206 * state for background activity on the system. Once an activity is registered,
207 * the system will evaluate its criteria to determine whether the activity is
208 * eligible to run under current system conditions. When an activity becomes
209 * eligible to run, its execution state will be updated and an invocation of
210 * its handler block will be made.
211 */
212XPC_DECL(xpc_activity);
213
214/*!
215 * @typedef xpc_activity_handler_t
216 *
217 * @abstract
218 * A block that is called when an XPC activity becomes eligible to run.
219 */
220XPC_NONNULL1
221typedef void (^xpc_activity_handler_t)(xpc_activity_t activity);
222
223/*!
224 * @constant XPC_ACTIVITY_CHECK_IN
225 * This constant may be passed to xpc_activity_register() as the criteria
226 * dictionary in order to check in with the system for previously registered
227 * activity using the same identifier (for example, an activity taken from a
228 * launchd property list).
229 */
230__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
231XPC_EXPORT
232const xpc_object_t XPC_ACTIVITY_CHECK_IN;
233
234/*!
235 * @function xpc_activity_register
236 *
237 * @abstract
238 * Registers an activity with the system.
239 *
240 * @discussion
241 * Registers a new activity with the system. The criteria of the activity are
242 * described by the dictionary passed to this function. If an activity with the
243 * same identifier already exists, the criteria provided override the existing
244 * criteria unless the special dictionary XPC_ACTIVITY_CHECK_IN is used. The
245 * XPC_ACTIVITY_CHECK_IN dictionary instructs the system to first look up an
246 * existing activity without modifying its criteria. Once the existing activity
247 * is found (or a new one is created with an empty set of criteria) the handler
248 * will be called with an activity object in the XPC_ACTIVITY_STATE_CHECK_IN
249 * state.
250 *
251 * @param identifier
252 * A unique identifier for the activity. Each application has its own namespace.
253 * The identifier should remain constant across registrations, relaunches of
254 * the application, and reboots. It should identify the kind of work being done,
255 * not a particular invocation of the work.
256 *
257 * @param criteria
258 * A dictionary of criteria for the activity.
259 *
260 * @param handler
261 * The handler block to be called when the activity changes state to one of the
262 * following states:
263 * - XPC_ACTIVITY_STATE_CHECK_IN (optional)
264 * - XPC_ACTIVITY_STATE_RUN
265 *
266 * The handler block is never invoked reentrantly. It will be invoked on a
267 * dispatch queue with an appropriate priority to perform the activity.
268 */
269__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
270XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
271void
272xpc_activity_register(const char *identifier, xpc_object_t criteria,
273 xpc_activity_handler_t handler);
274
275/*!
276 * @function xpc_activity_copy_criteria
277 *
278 * @abstract
279 * Returns an XPC dictionary describing the execution criteria of an activity.
280 * This will return NULL in cases where the activity has already completed, e.g.
281 * when checking in to an event that finished and was not rescheduled.
282 */
283__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
284XPC_EXPORT XPC_WARN_RESULT XPC_RETURNS_RETAINED XPC_NONNULL1
285xpc_object_t _Nullable
286xpc_activity_copy_criteria(xpc_activity_t activity);
287
288/*!
289 * @function xpc_activity_set_criteria
290 *
291 * @abstract
292 * Modifies the execution criteria of an activity.
293 */
294__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
295XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
296void
297xpc_activity_set_criteria(xpc_activity_t activity, xpc_object_t criteria);
298
299/*!
300 * @enum xpc_activity_state_t
301 * An activity is defined to be in one of the following states. Applications
302 * may check the current state of the activity using xpc_activity_get_state()
303 * in the handler block provided to xpc_activity_register().
304 *
305 * The application can modify the state of the activity by calling
306 * xpc_activity_set_state() with one of the following:
307 * - XPC_ACTIVITY_STATE_DEFER
308 * - XPC_ACTIVITY_STATE_CONTINUE
309 * - XPC_ACTIVITY_STATE_DONE
310 *
311 * @constant XPC_ACTIVITY_STATE_CHECK_IN
312 * An activity in this state has just completed a checkin with the system after
313 * XPC_ACTIVITY_CHECK_IN was provided as the criteria dictionary to
314 * xpc_activity_register. The state gives the application an opportunity to
315 * inspect and modify the activity's criteria.
316 *
317 * @constant XPC_ACTIVITY_STATE_WAIT
318 * An activity in this state is waiting for an opportunity to run. This value
319 * is never returned within the activity's handler block, as the block is
320 * invoked in response to XPC_ACTIVITY_STATE_CHECK_IN or XPC_ACTIVITY_STATE_RUN.
321 *
322 * Note:
323 * A launchd job may idle exit while an activity is in the wait state and be
324 * relaunched in response to the activity becoming runnable. The launchd job
325 * simply needs to re-register for the activity on its next launch by passing
326 * XPC_ACTIVITY_STATE_CHECK_IN to xpc_activity_register().
327 *
328 * @constant XPC_ACTIVITY_STATE_RUN
329 * An activity in this state is eligible to run based on its criteria.
330 *
331 * @constant XPC_ACTIVITY_STATE_DEFER
332 * An application may pass this value to xpc_activity_set_state() to indicate
333 * that the activity should be deferred (placed back into the WAIT state) until
334 * a time when its criteria are met again. Deferring an activity does not reset
335 * any of its time-based criteria (in other words, it will remain past due).
336 *
337 * IMPORTANT:
338 * This should be done in response to observing xpc_activity_should_defer().
339 * It should not be done unilaterally. If you determine that conditions are bad
340 * to do your activity's work for reasons you can't express in a criteria
341 * dictionary, you should set the activity's state to XPC_ACTIVITY_STATE_DONE.
342 *
343 *
344 * @constant XPC_ACTIVITY_STATE_CONTINUE
345 * An application may pass this value to xpc_activity_set_state() to indicate
346 * that the activity will continue its operation beyond the return of its
347 * handler block. This can be used to extend an activity to include asynchronous
348 * operations. The activity's handler block will not be invoked again until the
349 * state has been updated to either XPC_ACTIVITY_STATE_DEFER or, in the case
350 * of repeating activity, XPC_ACTIVITY_STATE_DONE.
351 *
352 * @constant XPC_ACTIVITY_STATE_DONE
353 * An application may pass this value to xpc_activity_set_state() to indicate
354 * that the activity has completed. For non-repeating activity, the resources
355 * associated with the activity will be automatically released upon return from
356 * the handler block. For repeating activity, timers present in the activity's
357 * criteria will be reset.
358 */
359enum {
360 XPC_ACTIVITY_STATE_CHECK_IN,
361 XPC_ACTIVITY_STATE_WAIT,
362 XPC_ACTIVITY_STATE_RUN,
363 XPC_ACTIVITY_STATE_DEFER,
364 XPC_ACTIVITY_STATE_CONTINUE,
365 XPC_ACTIVITY_STATE_DONE,
366};
367typedef long xpc_activity_state_t;
368
369/*!
370 * @function xpc_activity_get_state
371 *
372 * @abstract
373 * Returns the current state of an activity.
374 */
375__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
376XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
377xpc_activity_state_t
378xpc_activity_get_state(xpc_activity_t activity);
379
380/*!
381 * @function xpc_activity_set_state
382 *
383 * @abstract
384 * Updates the current state of an activity.
385 *
386 * @return
387 * Returns true if the state was successfully updated; otherwise, returns
388 * false if the requested state transition is not valid.
389 */
390__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
391XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
392bool
393xpc_activity_set_state(xpc_activity_t activity, xpc_activity_state_t state);
394
395/*!
396 * @function xpc_activity_should_defer
397 *
398 * @abstract
399 * Test whether an activity should be deferred.
400 *
401 * @discussion
402 * This function may be used to test whether the criteria of a long-running
403 * activity are still satisfied. If not, the system indicates that the
404 * application should defer the activity. The application may acknowledge the
405 * deferral by calling xpc_activity_set_state() with XPC_ACTIVITY_STATE_DEFER.
406 * Once deferred, the system will place the activity back into the WAIT state
407 * and re-invoke the handler block at the earliest opportunity when the criteria
408 * are once again satisfied.
409 *
410 * @return
411 * Returns true if the activity should be deferred.
412 */
413__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
414XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
415bool
416xpc_activity_should_defer(xpc_activity_t activity);
417
418/*!
419 * @function xpc_activity_unregister
420 *
421 * @abstract
422 * Unregisters an activity found by its identifier.
423 *
424 * @discussion
425 * A dynamically registered activity will be deleted in response to this call.
426 * Statically registered activity (from a launchd property list) will be
427 * deleted until the job is next loaded (e.g. at next boot).
428 *
429 * Unregistering an activity has no effect on any outstanding xpc_activity_t
430 * objects or any currently executing xpc_activity_handler_t blocks; however,
431 * no new handler block invocations will be made after it is unregistered.
432 *
433 * @param identifier
434 * The identifier of the activity to unregister.
435 */
436__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
437XPC_EXPORT XPC_NONNULL1
438void
439xpc_activity_unregister(const char *identifier);
440
441__END_DECLS
442XPC_ASSUME_NONNULL_END
443
444#endif // __BLOCKS__
445
446#endif // __XPC_ACTIVITY_H__
447
lib/libc/include/x86_64-macos-gnu/xpc/availability.h created+124
......@@ -0,0 +1,124 @@
1#ifndef __XPC_AVAILABILITY_H__
2#define __XPC_AVAILABILITY_H__
3
4#include <Availability.h>
5
6// Certain parts of the project use all the project's headers but have to build
7// against newer OSX SDKs than ebuild uses -- liblaunch_host being the example.
8// So we need to define these.
9#ifndef __MAC_10_16
10#define __MAC_10_16 101600
11#endif // __MAC_10_16
12
13#ifndef __MAC_10_15
14#define __MAC_10_15 101500
15#define __AVAILABILITY_INTERNAL__MAC_10_15 \
16__attribute__((availability(macosx, introduced=10.15)))
17#endif // __MAC_10_15
18
19#ifndef __MAC_10_14
20#define __MAC_10_14 101400
21#define __AVAILABILITY_INTERNAL__MAC_10_14 \
22__attribute__((availability(macosx, introduced=10.14)))
23#endif // __MAC_10_14
24
25#ifndef __MAC_10_13
26#define __MAC_10_13 101300
27#define __AVAILABILITY_INTERNAL__MAC_10_13 \
28 __attribute__((availability(macosx, introduced=10.13)))
29#endif // __MAC_10_13
30
31#ifndef __MAC_10_12
32#define __MAC_10_12 101200
33#define __AVAILABILITY_INTERNAL__MAC_10_12 \
34 __attribute__((availability(macosx, introduced=10.12)))
35#endif // __MAC_10_12
36
37#ifndef __MAC_10_11
38#define __MAC_10_11 101100
39#define __AVAILABILITY_INTERNAL__MAC_10_11 \
40 __attribute__((availability(macosx, introduced=10.11)))
41#endif // __MAC_10_11
42
43#ifndef __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11
44#define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11
45#endif // __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11
46
47#ifndef __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11
48#define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11
49#endif // __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11
50
51#ifndef __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11
52#define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11
53#endif // __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11
54
55#ifndef __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11
56#define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11
57#endif // __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11
58
59#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11
60#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11
61#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11
62
63#ifndef __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11
64#define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11
65#endif // __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11
66
67#ifndef __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11
68#define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11
69#endif // __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11
70
71#ifndef __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11
72#define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11
73#endif // __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11
74
75#ifndef __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11
76#define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11
77#endif // __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11
78
79#ifndef __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11
80#define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11
81#endif // __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11
82
83#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13
84#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13
85#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13
86
87#if __has_include(<simulator_host.h>)
88#include <simulator_host.h>
89#else // __has_include(<simulator_host.h>)
90#ifndef IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED
91#define IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED 999999
92#endif // IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED
93#endif // __has_include(<simulator_host.h>)
94
95#ifndef __WATCHOS_UNAVAILABLE
96#define __WATCHOS_UNAVAILABLE
97#endif
98
99#ifndef __TVOS_UNAVAILABLE
100#define __TVOS_UNAVAILABLE
101#endif
102
103// simulator host-side bits build against SDKs not having __*_AVAILABLE() yet
104#ifndef __OSX_AVAILABLE
105#define __OSX_AVAILABLE(...)
106#endif
107
108#ifndef __IOS_AVAILABLE
109#define __IOS_AVAILABLE(...)
110#endif
111
112#ifndef __TVOS_AVAILABLE
113#define __TVOS_AVAILABLE(...)
114#endif
115
116#ifndef __WATCHOS_AVAILABLE
117#define __WATCHOS_AVAILABLE(...)
118#endif
119
120#ifndef __API_AVAILABLE
121#define __API_AVAILABLE(...)
122#endif
123
124#endif // __XPC_AVAILABILITY_H__
lib/libc/include/x86_64-macos-gnu/xpc/base.h created+213
......@@ -0,0 +1,213 @@
1// Copyright (c) 2009-2011 Apple Inc. All rights reserved.
2
3#ifndef __XPC_BASE_H__
4#define __XPC_BASE_H__
5
6#include <sys/cdefs.h>
7
8__BEGIN_DECLS
9
10#if !defined(__has_include)
11#define __has_include(x) 0
12#endif // !defined(__has_include)
13
14#if !defined(__has_attribute)
15#define __has_attribute(x) 0
16#endif // !defined(__has_attribute)
17
18#if !defined(__has_feature)
19#define __has_feature(x) 0
20#endif // !defined(__has_feature)
21
22#if !defined(__has_extension)
23#define __has_extension(x) 0
24#endif // !defined(__has_extension)
25
26#if __has_include(<xpc/availability.h>)
27#include <xpc/availability.h>
28#else // __has_include(<xpc/availability.h>)
29#include <Availability.h>
30#endif // __has_include(<xpc/availability.h>)
31
32#include <os/availability.h>
33
34#ifndef __XPC_INDIRECT__
35#error "Please #include <xpc/xpc.h> instead of this file directly."
36#endif // __XPC_INDIRECT__
37
38#pragma mark Attribute Shims
39#ifdef __GNUC__
40#define XPC_CONSTRUCTOR __attribute__((constructor))
41#define XPC_NORETURN __attribute__((__noreturn__))
42#define XPC_NOTHROW __attribute__((__nothrow__))
43#define XPC_NONNULL1 __attribute__((__nonnull__(1)))
44#define XPC_NONNULL2 __attribute__((__nonnull__(2)))
45#define XPC_NONNULL3 __attribute__((__nonnull__(3)))
46#define XPC_NONNULL4 __attribute__((__nonnull__(4)))
47#define XPC_NONNULL5 __attribute__((__nonnull__(5)))
48#define XPC_NONNULL6 __attribute__((__nonnull__(6)))
49#define XPC_NONNULL7 __attribute__((__nonnull__(7)))
50#define XPC_NONNULL8 __attribute__((__nonnull__(8)))
51#define XPC_NONNULL9 __attribute__((__nonnull__(9)))
52#define XPC_NONNULL10 __attribute__((__nonnull__(10)))
53#define XPC_NONNULL11 __attribute__((__nonnull__(11)))
54#define XPC_NONNULL_ALL __attribute__((__nonnull__))
55#define XPC_SENTINEL __attribute__((__sentinel__))
56#define XPC_PURE __attribute__((__pure__))
57#define XPC_WARN_RESULT __attribute__((__warn_unused_result__))
58#define XPC_MALLOC __attribute__((__malloc__))
59#define XPC_UNUSED __attribute__((__unused__))
60#define XPC_USED __attribute__((__used__))
61#define XPC_PACKED __attribute__((__packed__))
62#define XPC_PRINTF(m, n) __attribute__((format(printf, m, n)))
63#define XPC_INLINE static __inline__ __attribute__((__always_inline__))
64#define XPC_NOINLINE __attribute__((noinline))
65#define XPC_NOIMPL __attribute__((unavailable))
66
67#if __has_attribute(noescape)
68#define XPC_NOESCAPE __attribute__((__noescape__))
69#else
70#define XPC_NOESCAPE
71#endif
72
73#if __has_extension(attribute_unavailable_with_message)
74#define XPC_UNAVAILABLE(m) __attribute__((unavailable(m)))
75#else // __has_extension(attribute_unavailable_with_message)
76#define XPC_UNAVAILABLE(m) XPC_NOIMPL
77#endif // __has_extension(attribute_unavailable_with_message)
78
79#define XPC_EXPORT extern __attribute__((visibility("default")))
80#define XPC_NOEXPORT __attribute__((visibility("hidden")))
81#define XPC_WEAKIMPORT extern __attribute__((weak_import))
82#define XPC_DEBUGGER_EXCL XPC_NOEXPORT XPC_USED
83#define XPC_TRANSPARENT_UNION __attribute__((transparent_union))
84#if __clang__
85#define XPC_DEPRECATED(m) __attribute__((deprecated(m)))
86#else // __clang__
87#define XPC_DEPRECATED(m) __attribute__((deprecated))
88#endif // __clang
89
90#if defined(__XPC_TEST__) && __XPC_TEST__
91#define XPC_TESTSTATIC
92#define XPC_TESTEXTERN extern
93#else // defined(__XPC_TEST__) && __XPC_TEST__
94#define XPC_TESTSTATIC static
95#endif // defined(__XPC_TEST__) && __XPC_TEST__
96
97#if __has_feature(objc_arc)
98#define XPC_GIVES_REFERENCE __strong
99#define XPC_UNRETAINED __unsafe_unretained
100#define XPC_BRIDGE(xo) ((__bridge void *)(xo))
101#define XPC_BRIDGEREF_BEGIN(xo) ((__bridge_retained void *)(xo))
102#define XPC_BRIDGEREF_BEGIN_WITH_REF(xo) ((__bridge void *)(xo))
103#define XPC_BRIDGEREF_MIDDLE(xo) ((__bridge id)(xo))
104#define XPC_BRIDGEREF_END(xo) ((__bridge_transfer id)(xo))
105#else // __has_feature(objc_arc)
106#define XPC_GIVES_REFERENCE
107#define XPC_UNRETAINED
108#define XPC_BRIDGE(xo) (xo)
109#define XPC_BRIDGEREF_BEGIN(xo) (xo)
110#define XPC_BRIDGEREF_BEGIN_WITH_REF(xo) (xo)
111#define XPC_BRIDGEREF_MIDDLE(xo) (xo)
112#define XPC_BRIDGEREF_END(xo) (xo)
113#endif // __has_feature(objc_arc)
114
115#define _xpc_unreachable() __builtin_unreachable()
116#else // __GNUC__
117/*! @parseOnly */
118#define XPC_CONSTRUCTOR
119/*! @parseOnly */
120#define XPC_NORETURN
121/*! @parseOnly */
122#define XPC_NOTHROW
123/*! @parseOnly */
124#define XPC_NONNULL1
125/*! @parseOnly */
126#define XPC_NONNULL2
127/*! @parseOnly */
128#define XPC_NONNULL3
129/*! @parseOnly */
130#define XPC_NONNULL4
131/*! @parseOnly */
132#define XPC_NONNULL5
133/*! @parseOnly */
134#define XPC_NONNULL6
135/*! @parseOnly */
136#define XPC_NONNULL7
137/*! @parseOnly */
138#define XPC_NONNULL8
139/*! @parseOnly */
140#define XPC_NONNULL9
141/*! @parseOnly */
142#define XPC_NONNULL10
143/*! @parseOnly */
144#define XPC_NONNULL11
145/*! @parseOnly */
146#define XPC_NONNULL(n)
147/*! @parseOnly */
148#define XPC_NONNULL_ALL
149/*! @parseOnly */
150#define XPC_SENTINEL
151/*! @parseOnly */
152#define XPC_PURE
153/*! @parseOnly */
154#define XPC_WARN_RESULT
155/*! @parseOnly */
156#define XPC_MALLOC
157/*! @parseOnly */
158#define XPC_UNUSED
159/*! @parseOnly */
160#define XPC_PACKED
161/*! @parseOnly */
162#define XPC_PRINTF(m, n)
163/*! @parseOnly */
164#define XPC_INLINE static inline
165/*! @parseOnly */
166#define XPC_NOINLINE
167/*! @parseOnly */
168#define XPC_NOIMPL
169/*! @parseOnly */
170#define XPC_EXPORT extern
171/*! @parseOnly */
172#define XPC_WEAKIMPORT
173/*! @parseOnly */
174#define XPC_DEPRECATED
175/*! @parseOnly */
176#define XPC_UNAVAILABLE(m)
177/*! @parseOnly */
178#define XPC_NOESCAPE
179#endif // __GNUC__
180
181#if __has_feature(assume_nonnull)
182#define XPC_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
183#define XPC_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
184#else
185#define XPC_ASSUME_NONNULL_BEGIN
186#define XPC_ASSUME_NONNULL_END
187#endif
188
189#if __has_feature(nullability_on_arrays)
190#define XPC_NONNULL_ARRAY _Nonnull
191#else
192#define XPC_NONNULL_ARRAY
193#endif
194
195#ifdef OS_CLOSED_OPTIONS
196#define XPC_FLAGS_ENUM(_name, _type, ...) \
197 OS_CLOSED_OPTIONS(_name, _type, __VA_ARGS__)
198#else // OS_CLOSED_ENUM
199#define XPC_FLAGS_ENUM(_name, _type, ...) \
200 OS_ENUM(_name, _type, __VA_ARGS__)
201#endif // OS_CLOSED_ENUM
202
203#ifdef OS_CLOSED_ENUM
204#define XPC_ENUM(_name, _type, ...) \
205 OS_CLOSED_ENUM(_name, _type, __VA_ARGS__)
206#else // OS_CLOSED_ENUM
207#define XPC_ENUM(_name, _type, ...) \
208 OS_ENUM(_name, _type, __VA_ARGS__)
209#endif // OS_CLOSED_ENUM
210
211__END_DECLS
212
213#endif // __XPC_BASE_H__
lib/libc/include/x86_64-macos-gnu/xpc/connection.h created+748
......@@ -0,0 +1,748 @@
1#ifndef __XPC_CONNECTION_H__
2#define __XPC_CONNECTION_H__
3
4#ifndef __XPC_INDIRECT__
5#error "Please #include <xpc/xpc.h> instead of this file directly."
6// For HeaderDoc.
7#include <xpc/base.h>
8#endif // __XPC_INDIRECT__
9
10#ifndef __BLOCKS__
11#error "XPC connections require Blocks support."
12#endif // __BLOCKS__
13
14XPC_ASSUME_NONNULL_BEGIN
15__BEGIN_DECLS
16
17/*!
18 * @constant XPC_ERROR_CONNECTION_INTERRUPTED
19 * Will be delivered to the connection's event handler if the remote service
20 * exited. The connection is still live even in this case, and resending a
21 * message will cause the service to be launched on-demand. This error serves
22 * as a client's indication that it should resynchronize any state that it had
23 * given the service.
24 *
25 * Any messages in the queue to be sent will be unwound and canceled when this
26 * error occurs. In the case where a message waiting to be sent has a reply
27 * handler, that handler will be invoked with this error. In the context of the
28 * reply handler, this error indicates that a reply to the message will never
29 * arrive.
30 *
31 * Messages that do not have reply handlers associated with them will be
32 * silently disposed of. This error will only be given to peer connections.
33 */
34#define XPC_ERROR_CONNECTION_INTERRUPTED \
35 XPC_GLOBAL_OBJECT(_xpc_error_connection_interrupted)
36__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
37XPC_EXPORT
38const struct _xpc_dictionary_s _xpc_error_connection_interrupted;
39
40/*!
41 * @constant XPC_ERROR_CONNECTION_INVALID
42 * Will be delivered to the connection's event handler if the named service
43 * provided to xpc_connection_create() could not be found in the XPC service
44 * namespace. The connection is useless and should be disposed of.
45 *
46 * Any messages in the queue to be sent will be unwound and canceled when this
47 * error occurs, similarly to the behavior when XPC_ERROR_CONNECTION_INTERRUPTED
48 * occurs. The only difference is that the XPC_ERROR_CONNECTION_INVALID will be
49 * given to outstanding reply handlers and the connection's event handler.
50 *
51 * This error may be given to any type of connection.
52 */
53#define XPC_ERROR_CONNECTION_INVALID \
54 XPC_GLOBAL_OBJECT(_xpc_error_connection_invalid)
55__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
56XPC_EXPORT
57const struct _xpc_dictionary_s _xpc_error_connection_invalid;
58
59/*!
60 * @constant XPC_ERROR_TERMINATION_IMMINENT
61 * On macOS, this error will be delivered to a peer connection's event handler
62 * when the XPC runtime has determined that the program should exit and that
63 * all outstanding transactions must be wound down, and no new transactions can
64 * be opened.
65 *
66 * After this error has been delivered to the event handler, no more messages
67 * will be received by the connection. The runtime will still attempt to deliver
68 * outgoing messages, but this error should be treated as an indication that
69 * the program will exit very soon, and any outstanding business over the
70 * connection should be wrapped up as quickly as possible and the connection
71 * canceled shortly thereafter.
72 *
73 * This error will only be delivered to peer connections received through a
74 * listener or the xpc_main() event handler.
75 */
76#define XPC_ERROR_TERMINATION_IMMINENT \
77 XPC_GLOBAL_OBJECT(_xpc_error_termination_imminent)
78__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
79XPC_EXPORT
80const struct _xpc_dictionary_s _xpc_error_termination_imminent;
81
82/*!
83 * @constant XPC_CONNECTION_MACH_SERVICE_LISTENER
84 * Passed to xpc_connection_create_mach_service(). This flag indicates that the
85 * caller is the listener for the named service. This flag may only be passed
86 * for services which are advertised in the process' launchd.plist(5). You may
87 * not use this flag to dynamically add services to the Mach bootstrap
88 * namespace.
89 */
90#define XPC_CONNECTION_MACH_SERVICE_LISTENER (1 << 0)
91
92/*!
93 * @constant XPC_CONNECTION_MACH_SERVICE_PRIVILEGED
94 * Passed to xpc_connection_create_mach_service(). This flag indicates that the
95 * job advertising the service name in its launchd.plist(5) should be in the
96 * privileged Mach bootstrap. This is typically accomplished by placing your
97 * launchd.plist(5) in /Library/LaunchDaemons. If specified alongside the
98 * XPC_CONNECTION_MACH_SERVICE_LISTENER flag, this flag is a no-op.
99 */
100#define XPC_CONNECTION_MACH_SERVICE_PRIVILEGED (1 << 1)
101
102/*!
103 * @typedef xpc_finalizer_f
104 * A function that is invoked when a connection is being torn down and its
105 * context needs to be freed. The sole argument is the value that was given to
106 * {@link xpc_connection_set_context} or NULL if no context has been set. It is
107 * not safe to reference the connection from within this function.
108 *
109 * @param value
110 * The context object that is to be disposed of.
111 */
112typedef void (*xpc_finalizer_t)(void * _Nullable value);
113
114/*!
115 * @function xpc_connection_create
116 * Creates a new connection object.
117 *
118 * @param name
119 * If non-NULL, the name of the service with which to connect. The returned
120 * connection will be a peer.
121 *
122 * If NULL, an anonymous listener connection will be created. You can embed the
123 * ability to create new peer connections in an endpoint, which can be inserted
124 * into a message and sent to another process .
125 *
126 * @param targetq
127 * The GCD queue to which the event handler block will be submitted. This
128 * parameter may be NULL, in which case the connection's target queue will be
129 * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT.
130 * The target queue may be changed later with a call to
131 * xpc_connection_set_target_queue().
132 *
133 * @result
134 * A new connection object. The caller is responsible for disposing of the
135 * returned object with {@link xpc_release} when it is no longer needed.
136 *
137 * @discussion
138 * This method will succeed even if the named service does not exist. This is
139 * because the XPC namespace is not queried for the service name until the
140 * connection has been activated. See {@link xpc_connection_activate()}.
141 *
142 * XPC connections, like dispatch sources, are returned in an inactive state, so
143 * you must call {@link xpc_connection_activate()} in order to begin receiving
144 * events from the connection. Also like dispatch sources, connections must be
145 * activated and not suspended in order to be safely released. It is
146 * a programming error to release an inactive or suspended connection.
147 */
148__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
149XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
150xpc_connection_t
151xpc_connection_create(const char * _Nullable name,
152 dispatch_queue_t _Nullable targetq);
153
154/*!
155 * @function xpc_connection_create_mach_service
156 * Creates a new connection object representing a Mach service.
157 *
158 * @param name
159 * The name of the remote service with which to connect. The service name must
160 * exist in a Mach bootstrap that is accessible to the process and be advertised
161 * in a launchd.plist.
162 *
163 * @param targetq
164 * The GCD queue to which the event handler block will be submitted. This
165 * parameter may be NULL, in which case the connection's target queue will be
166 * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT.
167 * The target queue may be changed later with a call to
168 * xpc_connection_set_target_queue().
169 *
170 * @param flags
171 * Additional attributes with which to create the connection.
172 *
173 * @result
174 * A new connection object.
175 *
176 * @discussion
177 * If the XPC_CONNECTION_MACH_SERVICE_LISTENER flag is given to this method,
178 * then the connection returned will be a listener connection. Otherwise, a peer
179 * connection will be returned. See the documentation for
180 * {@link xpc_connection_set_event_handler()} for the semantics of listener
181 * connections versus peer connections.
182 *
183 * This method will succeed even if the named service does not exist. This is
184 * because the Mach namespace is not queried for the service name until the
185 * connection has been activated. See {@link xpc_connection_activate()}.
186 */
187__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
188XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
189xpc_connection_t
190xpc_connection_create_mach_service(const char *name,
191 dispatch_queue_t _Nullable targetq, uint64_t flags);
192
193/*!
194 * @function xpc_connection_create_from_endpoint
195 * Creates a new connection from the given endpoint.
196 *
197 * @param endpoint
198 * The endpoint from which to create the new connection.
199 *
200 * @result
201 * A new peer connection to the listener represented by the given endpoint.
202 *
203 * The same responsibilities of setting an event handler and activating the
204 * connection after calling xpc_connection_create() apply to the connection
205 * returned by this API. Since the connection yielded by this API is not
206 * associated with a name (and therefore is not rediscoverable), this connection
207 * will receive XPC_ERROR_CONNECTION_INVALID if the listening side crashes,
208 * exits or cancels the listener connection.
209 */
210__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
211XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL
212xpc_connection_t
213xpc_connection_create_from_endpoint(xpc_endpoint_t endpoint);
214
215/*!
216 * @function xpc_connection_set_target_queue
217 * Sets the target queue of the given connection.
218 *
219 * @param connection
220 * The connection object which is to be manipulated.
221 *
222 * @param targetq
223 * The GCD queue to which the event handler block will be submitted. This
224 * parameter may be NULL, in which case the connection's target queue will be
225 * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT.
226 *
227 * @discussion
228 * Setting the target queue is asynchronous and non-preemptive and therefore
229 * this method will not interrupt the execution of an already-running event
230 * handler block. Setting the target queue may be likened to issuing a barrier
231 * to the connection which does the actual work of changing the target queue.
232 *
233 * The XPC runtime guarantees this non-preemptiveness even for concurrent target
234 * queues. If the target queue is a concurrent queue, then XPC still guarantees
235 * that there will never be more than one invocation of the connection's event
236 * handler block executing concurrently. If you wish to process events
237 * concurrently, you can dispatch_async(3) to a concurrent queue from within
238 * the event handler.
239 *
240 * IMPORTANT: When called from within the event handler block,
241 * dispatch_get_current_queue(3) is NOT guaranteed to return a pointer to the
242 * queue set with this method.
243 *
244 * Despite this seeming inconsistency, the XPC runtime guarantees that, when the
245 * target queue is a serial queue, the event handler block will execute
246 * synchonously with respect to other blocks submitted to that same queue. When
247 * the target queue is a concurrent queue, the event handler block may run
248 * concurrently with other blocks submitted to that queue, but it will never run
249 * concurrently with other invocations of itself for the same connection, as
250 * discussed previously.
251 */
252__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
253XPC_EXPORT XPC_NONNULL1
254void
255xpc_connection_set_target_queue(xpc_connection_t connection,
256 dispatch_queue_t _Nullable targetq);
257
258/*!
259 * @function xpc_connection_set_event_handler
260 * Sets the event handler block for the connection.
261 *
262 * @param connection
263 * The connection object which is to be manipulated.
264 *
265 * @param handler
266 * The event handler block.
267 *
268 * @discussion
269 * Setting the event handler is asynchronous and non-preemptive, and therefore
270 * this method will not interrupt the execution of an already-running event
271 * handler block. If the event handler is executing at the time of this call, it
272 * will finish, and then the connection's event handler will be changed before
273 * the next invocation of the event handler. The XPC runtime guarantees this
274 * non-preemptiveness even for concurrent target queues.
275 *
276 * Connection event handlers are non-reentrant, so it is safe to call
277 * xpc_connection_set_event_handler() from within the event handler block.
278 *
279 * The event handler's execution should be treated as a barrier to all
280 * connection activity. When it is executing, the connection will not attempt to
281 * send or receive messages, including reply messages. Thus, it is not safe to
282 * call xpc_connection_send_message_with_reply_sync() on the connection from
283 * within the event handler.
284 *
285 * You do not hold a reference on the object received as the event handler's
286 * only argument. Regardless of the type of object received, it is safe to call
287 * xpc_retain() on the object to obtain a reference to it.
288 *
289 * A connection may receive different events depending upon whether it is a
290 * listener or not. Any connection may receive an error in its event handler.
291 * But while normal connections may receive messages in addition to errors,
292 * listener connections will receive connections and and not messages.
293 *
294 * Connections received by listeners are equivalent to those returned by
295 * xpc_connection_create() with a non-NULL name argument and a NULL targetq
296 * argument with the exception that you do not hold a reference on them.
297 * You must set an event handler and activate the connection. If you do not wish
298 * to accept the connection, you may simply call xpc_connection_cancel() on it
299 * and return. The runtime will dispose of it for you.
300 *
301 * If there is an error in the connection, this handler will be invoked with the
302 * error dictionary as its argument. This dictionary will be one of the well-
303 * known XPC_ERROR_* dictionaries.
304 *
305 * Regardless of the type of event, ownership of the event object is NOT
306 * implicitly transferred. Thus, the object will be released and deallocated at
307 * some point in the future after the event handler returns. If you wish the
308 * event's lifetime to persist, you must retain it with xpc_retain().
309 *
310 * Connections received through the event handler will be released and
311 * deallocated after the connection has gone invalid and delivered that event to
312 * its event handler.
313 */
314__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
315XPC_EXPORT XPC_NONNULL_ALL
316void
317xpc_connection_set_event_handler(xpc_connection_t connection,
318 xpc_handler_t handler);
319
320/*!
321 * @function xpc_connection_activate
322 * Activates the connection. Connections start in an inactive state, so you must
323 * call xpc_connection_activate() on a connection before it will send or receive
324 * any messages.
325 *
326 * @param connection
327 * The connection object which is to be manipulated.
328 *
329 * @discussion
330 * Calling xpc_connection_activate() on an active connection has no effect.
331 * Releasing the last reference on an inactive connection that was created with
332 * an xpc_connection_create*() call is undefined.
333 *
334 * For backward compatibility reasons, xpc_connection_resume() on an inactive
335 * and not otherwise suspended xpc connection has the same effect as calling
336 * xpc_connection_activate(). For new code, using xpc_connection_activate()
337 * is preferred.
338 */
339__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
340__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
341XPC_EXPORT XPC_NONNULL_ALL
342void
343xpc_connection_activate(xpc_connection_t connection);
344
345/*!
346 * @function xpc_connection_suspend
347 * Suspends the connection so that the event handler block will not fire and
348 * that the connection will not attempt to send any messages it has in its
349 * queue. All calls to xpc_connection_suspend() must be balanced with calls to
350 * xpc_connection_resume() before releasing the last reference to the
351 * connection.
352 *
353 * @param connection
354 * The connection object which is to be manipulated.
355 *
356 * @discussion
357 * Suspension is asynchronous and non-preemptive, and therefore this method will
358 * not interrupt the execution of an already-running event handler block. If
359 * the event handler is executing at the time of this call, it will finish, and
360 * then the connection will be suspended before the next scheduled invocation
361 * of the event handler. The XPC runtime guarantees this non-preemptiveness even
362 * for concurrent target queues.
363 *
364 * Connection event handlers are non-reentrant, so it is safe to call
365 * xpc_connection_suspend() from within the event handler block.
366 */
367__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
368XPC_EXPORT XPC_NONNULL_ALL
369void
370xpc_connection_suspend(xpc_connection_t connection);
371
372/*!
373 * @function xpc_connection_resume
374 * Resumes the connection.
375 *
376 * @param connection
377 * The connection object which is to be manipulated.
378 *
379 * @discussion
380 * In order for a connection to become live, every call to
381 * xpc_connection_suspend() must be balanced with a call to
382 * xpc_connection_resume().
383 *
384 * For backward compatibility reasons, xpc_connection_resume() on an inactive
385 * and not otherwise suspended xpc connection has the same effect as calling
386 * xpc_connection_activate(). For new code, using xpc_connection_activate()
387 * is preferred.
388 *
389 * Calling xpc_connection_resume() more times than xpc_connection_suspend()
390 * has been called is otherwise considered an error.
391 */
392__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
393XPC_EXPORT XPC_NONNULL_ALL
394void
395xpc_connection_resume(xpc_connection_t connection);
396
397/*!
398 * @function xpc_connection_send_message
399 * Sends a message over the connection to the destination service.
400 *
401 * @param connection
402 * The connection over which the message shall be sent.
403 *
404 * @param message
405 * The message to send. This must be a dictionary object. This dictionary is
406 * logically copied by the connection, so it is safe to modify the dictionary
407 * after this call.
408 *
409 * @discussion
410 * Messages are delivered in FIFO order. This API is safe to call from multiple
411 * GCD queues. There is no indication that a message was delivered successfully.
412 * This is because even once the message has been successfully enqueued on the
413 * remote end, there are no guarantees about when the runtime will dequeue the
414 * message and invoke the other connection's event handler block.
415 *
416 * If this API is used to send a message that is in reply to another message,
417 * there is no guarantee of ordering between the invocations of the connection's
418 * event handler and the reply handler for that message, even if they are
419 * targeted to the same queue.
420 *
421 * After extensive study, we have found that clients who are interested in
422 * the state of the message on the server end are typically holding open
423 * transactions related to that message. And the only reliable way to track the
424 * lifetime of that transaction is at the protocol layer. So the server should
425 * send a reply message, which upon receiving, will cause the client to close
426 * its transaction.
427 */
428__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
429XPC_EXPORT XPC_NONNULL_ALL
430void
431xpc_connection_send_message(xpc_connection_t connection, xpc_object_t message);
432
433/*!
434 * @function xpc_connection_send_barrier
435 * Issues a barrier against the connection's message-send activity.
436 *
437 * @param connection
438 * The connection against which the barrier is to be issued.
439 *
440 * @param barrier
441 * The barrier block to issue. This barrier prevents concurrent message-send
442 * activity on the connection. No messages will be sent while the barrier block
443 * is executing.
444 *
445 * @discussion
446 * XPC guarantees that, even if the connection's target queue is a concurrent
447 * queue, there are no other messages being sent concurrently while the barrier
448 * block is executing. XPC does not guarantee that the receipt of messages
449 * (either through the connection's event handler or through reply handlers)
450 * will be suspended while the barrier is executing.
451 *
452 * A barrier is issued relative to the message-send queue. Thus, if you call
453 * xpc_connection_send_message() five times and then call
454 * xpc_connection_send_barrier(), the barrier will be invoked after the fifth
455 * message has been sent and its memory disposed of. You may safely cancel a
456 * connection from within a barrier block.
457 *
458 * If a barrier is issued after sending a message which expects a reply, the
459 * behavior is the same as described above. The receipt of a reply message will
460 * not influence when the barrier runs.
461 *
462 * A barrier block can be useful for throttling resource consumption on the
463 * connected side of a connection. For example, if your connection sends many
464 * large messages, you can use a barrier to limit the number of messages that
465 * are inflight at any given time. This can be particularly useful for messages
466 * that contain kernel resources (like file descriptors) which have a system-
467 * wide limit.
468 *
469 * If a barrier is issued on a canceled connection, it will be invoked
470 * immediately. If a connection has been canceled and still has outstanding
471 * barriers, those barriers will be invoked as part of the connection's
472 * unwinding process.
473 *
474 * It is important to note that a barrier block's execution order is not
475 * guaranteed with respect to other blocks that have been scheduled on the
476 * target queue of the connection. Or said differently,
477 * xpc_connection_send_barrier(3) is not equivalent to dispatch_async(3).
478 */
479__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
480XPC_EXPORT XPC_NONNULL_ALL
481void
482xpc_connection_send_barrier(xpc_connection_t connection,
483 dispatch_block_t barrier);
484
485/*!
486 * @function xpc_connection_send_message_with_reply
487 * Sends a message over the connection to the destination service and associates
488 * a handler to be invoked when the remote service sends a reply message.
489 *
490 * @param connection
491 * The connection over which the message shall be sent.
492 *
493 * @param message
494 * The message to send. This must be a dictionary object.
495 *
496 * @param replyq
497 * The GCD queue to which the reply handler will be submitted. This may be a
498 * concurrent queue.
499 *
500 * @param handler
501 * The handler block to invoke when a reply to the message is received from
502 * the connection. If the remote service exits prematurely before the reply was
503 * received, the XPC_ERROR_CONNECTION_INTERRUPTED error will be returned.
504 * If the connection went invalid before the message could be sent, the
505 * XPC_ERROR_CONNECTION_INVALID error will be returned.
506 *
507 * @discussion
508 * If the given GCD queue is a concurrent queue, XPC cannot guarantee that there
509 * will not be multiple reply handlers being invoked concurrently. XPC does not
510 * guarantee any ordering for the invocation of reply handers. So if multiple
511 * messages are waiting for replies and the connection goes invalid, there is no
512 * guarantee that the reply handlers will be invoked in FIFO order. Similarly,
513 * XPC does not guarantee that reply handlers will not run concurrently with
514 * the connection's event handler in the case that the reply queue and the
515 * connection's target queue are the same concurrent queue.
516 */
517__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
518XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL4
519void
520xpc_connection_send_message_with_reply(xpc_connection_t connection,
521 xpc_object_t message, dispatch_queue_t _Nullable replyq,
522 xpc_handler_t handler);
523
524/*!
525 * @function xpc_connection_send_message_with_reply_sync
526 * Sends a message over the connection and blocks the caller until a reply is
527 * received.
528 *
529 * @param connection
530 * The connection over which the message shall be sent.
531 *
532 * @param message
533 * The message to send. This must be a dictionary object.
534 *
535 * @result
536 * The message that the remote service sent in reply to the original message.
537 * If the remote service exits prematurely before the reply was received, the
538 * XPC_ERROR_CONNECTION_INTERRUPTED error will be returned. If the connection
539 * went invalid before the message could be sent, the
540 * XPC_ERROR_CONNECTION_INVALID error will be returned.
541 *
542 * You are responsible for releasing the returned object.
543 *
544 * @discussion
545 * This API supports priority inversion avoidance, and should be used instead of
546 * combining xpc_connection_send_message_with_reply() with a semaphore.
547 *
548 * Invoking this API from a queue that is a part of the target queue hierarchy
549 * results in deadlocks under certain conditions.
550 *
551 * Be judicious about your use of this API. It can block indefinitely, so if you
552 * are using it to implement an API that can be called from the main thread, you
553 * may wish to consider allowing the API to take a queue and callback block so
554 * that results may be delivered asynchronously if possible.
555 */
556__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
557XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT XPC_RETURNS_RETAINED
558xpc_object_t
559xpc_connection_send_message_with_reply_sync(xpc_connection_t connection,
560 xpc_object_t message);
561
562/*!
563 * @function xpc_connection_cancel
564 * Cancels the connection and ensures that its event handler will not fire
565 * again. After this call, any messages that have not yet been sent will be
566 * discarded, and the connection will be unwound. If there are messages that are
567 * awaiting replies, they will have their reply handlers invoked with the
568 * XPC_ERROR_CONNECTION_INVALID error.
569 *
570 * @param connection
571 * The connection object which is to be manipulated.
572 *
573 * @discussion
574 * Cancellation is asynchronous and non-preemptive and therefore this method
575 * will not interrupt the execution of an already-running event handler block.
576 * If the event handler is executing at the time of this call, it will finish,
577 * and then the connection will be canceled, causing a final invocation of the
578 * event handler to be scheduled with the XPC_ERROR_CONNECTION_INVALID error.
579 * After that invocation, there will be no further invocations of the event
580 * handler.
581 *
582 * The XPC runtime guarantees this non-preemptiveness even for concurrent target
583 * queues.
584 */
585__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
586XPC_EXPORT XPC_NONNULL_ALL
587void
588xpc_connection_cancel(xpc_connection_t connection);
589
590/*!
591 * @function xpc_connection_get_name
592 * Returns the name of the service with which the connections was created.
593 *
594 * @param connection
595 * The connection object which is to be examined.
596 *
597 * @result
598 * The name of the remote service. If you obtained the connection through an
599 * invocation of another connection's event handler, NULL is returned.
600 */
601__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
602XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
603const char * _Nullable
604xpc_connection_get_name(xpc_connection_t connection);
605
606/*!
607 * @function xpc_connection_get_euid
608 * Returns the EUID of the remote peer.
609 *
610 * @param connection
611 * The connection object which is to be examined.
612 *
613 * @result
614 * The EUID of the remote peer at the time the connection was made.
615 */
616__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
617XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
618uid_t
619xpc_connection_get_euid(xpc_connection_t connection);
620
621/*!
622 * @function xpc_connection_get_egid
623 * Returns the EGID of the remote peer.
624 *
625 * @param connection
626 * The connection object which is to be examined.
627 *
628 * @result
629 * The EGID of the remote peer at the time the connection was made.
630 */
631__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
632XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
633gid_t
634xpc_connection_get_egid(xpc_connection_t connection);
635
636/*!
637 * @function xpc_connection_get_pid
638 * Returns the PID of the remote peer.
639 *
640 * @param connection
641 * The connection object which is to be examined.
642 *
643 * @result
644 * The PID of the remote peer.
645 *
646 * @discussion
647 * A given PID is not guaranteed to be unique across an entire boot cycle.
648 * Great care should be taken when dealing with this information, as it can go
649 * stale after the connection is established. OS X recycles PIDs, and therefore
650 * another process could spawn and claim the PID before a message is actually
651 * received from the connection.
652 *
653 * XPC will deliver an error to your event handler if the remote process goes
654 * away, but there are no guarantees as to the timing of this notification's
655 * delivery either at the kernel layer or at the XPC layer.
656 */
657__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
658XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
659pid_t
660xpc_connection_get_pid(xpc_connection_t connection);
661
662/*!
663 * @function xpc_connection_get_asid
664 * Returns the audit session identifier of the remote peer.
665 *
666 * @param connection
667 * The connection object which is to be examined.
668 *
669 * @result
670 * The audit session ID of the remote peer at the time the connection was made.
671 */
672__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
673XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
674au_asid_t
675xpc_connection_get_asid(xpc_connection_t connection);
676
677/*!
678 * @function xpc_connection_set_context
679 * Sets context on an connection.
680 *
681 * @param connection
682 * The connection which is to be manipulated.
683 *
684 * @param context
685 * The context to associate with the connection.
686 *
687 * @discussion
688 * If you must manage the memory of the context object, you must set a finalizer
689 * to dispose of it. If this method is called on a connection which already has
690 * context associated with it, the finalizer will NOT be invoked. The finalizer
691 * is only invoked when the connection is being deallocated.
692 *
693 * It is recommended that, instead of changing the actual context pointer
694 * associated with the object, you instead change the state of the context
695 * object itself.
696 */
697__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
698XPC_EXPORT XPC_NONNULL1
699void
700xpc_connection_set_context(xpc_connection_t connection,
701 void * _Nullable context);
702
703/*!
704 * @function xpc_connection_get_context
705 * Returns the context associated with the connection.
706 *
707 * @param connection
708 * The connection which is to be examined.
709 *
710 * @result
711 * The context associated with the connection. NULL if there has been no context
712 * associated with the object.
713 */
714__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
715XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
716void * _Nullable
717xpc_connection_get_context(xpc_connection_t connection);
718
719/*!
720 * @function xpc_connection_set_finalizer_f
721 * Sets the finalizer for the given connection.
722 *
723 * @param connection
724 * The connection on which to set the finalizer.
725 *
726 * @param finalizer
727 * The function that will be invoked when the connection's retain count has
728 * dropped to zero and is being torn down.
729 *
730 * @discussion
731 * This method disposes of the context value associated with a connection, as
732 * set by {@link xpc_connection_set_context}.
733 *
734 * For many uses of context objects, this API allows for a convenient shorthand
735 * for freeing them. For example, for a context object allocated with malloc(3):
736 *
737 * xpc_connection_set_finalizer_f(object, free);
738 */
739__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
740XPC_EXPORT XPC_NONNULL1
741void
742xpc_connection_set_finalizer_f(xpc_connection_t connection,
743 xpc_finalizer_t _Nullable finalizer);
744
745__END_DECLS
746XPC_ASSUME_NONNULL_END
747
748#endif // __XPC_CONNECTION_H__
lib/libc/include/x86_64-macos-gnu/xpc/debug.h created+23
......@@ -0,0 +1,23 @@
1#ifndef __XPC_DEBUG_H__
2#define __XPC_DEBUG_H__
3
4/*!
5 * @function xpc_debugger_api_misuse_info
6 * Returns a pointer to a string describing the reason XPC aborted the calling
7 * process. On OS X, this will be the same string present in the "Application
8 * Specific Information" section of the crash report.
9 *
10 * @result
11 * A pointer to the human-readable string describing the reason the caller was
12 * aborted. If XPC was not responsible for the program's termination, NULL will
13 * be returned.
14 *
15 * @discussion
16 * This function is only callable from within a debugger. It is not meant to be
17 * called by the program directly.
18 */
19XPC_DEBUGGER_EXCL
20const char *
21xpc_debugger_api_misuse_info(void);
22
23#endif // __XPC_DEBUG_H__
lib/libc/include/x86_64-macos-gnu/xpc/endpoint.h created+22
......@@ -0,0 +1,22 @@
1#ifndef __XPC_ENDPOINT_H__
2#define __XPC_ENDPOINT_H__
3
4/*!
5 * @function xpc_endpoint_create
6 * Creates a new endpoint from a connection that is suitable for embedding into
7 * messages.
8 *
9 * @param connection
10 * Only connections obtained through calls to xpc_connection_create*() may be
11 * given to this API. Passing any other type of connection is not supported and
12 * will result in undefined behavior.
13 *
14 * @result
15 * A new endpoint object.
16 */
17__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
18XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
19xpc_endpoint_t _Nonnull
20xpc_endpoint_create(xpc_connection_t _Nonnull connection);
21
22#endif // __XPC_ENDPOINT_H__
lib/libc/include/x86_64-macos-gnu/xpc/xpc.h created+2701
......@@ -0,0 +1,2701 @@
1// Copyright (c) 2009-2020 Apple Inc. All rights reserved.
2
3#ifndef __XPC_H__
4#define __XPC_H__
5
6#include <os/object.h>
7#include <dispatch/dispatch.h>
8
9#include <sys/mman.h>
10#include <uuid/uuid.h>
11#include <bsm/audit.h>
12#include <stdarg.h>
13#include <stdbool.h>
14#include <stdint.h>
15#include <stdlib.h>
16#include <stdio.h>
17#include <string.h>
18#include <unistd.h>
19#include <fcntl.h>
20
21#ifndef __XPC_INDIRECT__
22#define __XPC_INDIRECT__
23#endif // __XPC_INDIRECT__
24
25#include <xpc/base.h>
26
27#if __has_include(<xpc/xpc_transaction_deprecate.h>)
28#include <xpc/xpc_transaction_deprecate.h>
29#else // __has_include(<xpc/transaction_deprecate.h>)
30#define XPC_TRANSACTION_DEPRECATED
31#endif // __has_include(<xpc/transaction_deprecate.h>)
32
33XPC_ASSUME_NONNULL_BEGIN
34__BEGIN_DECLS
35
36#ifndef __OSX_AVAILABLE_STARTING
37#define __OSX_AVAILABLE_STARTING(x, y)
38#endif // __OSX_AVAILABLE_STARTING
39
40#define XPC_API_VERSION 20200610
41
42/*!
43 * @typedef xpc_type_t
44 * A type that describes XPC object types.
45 */
46typedef const struct _xpc_type_s * xpc_type_t;
47#ifndef XPC_TYPE
48#define XPC_TYPE(type) const struct _xpc_type_s type
49#endif // XPC_TYPE
50
51/*!
52 * @typedef xpc_object_t
53 * A type that can describe all XPC objects. Dictionaries, arrays, strings, etc.
54 * are all described by this type.
55 *
56 * XPC objects are created with a retain count of 1, and therefore it is the
57 * caller's responsibility to call xpc_release() on them when they are no longer
58 * needed.
59 */
60
61#if OS_OBJECT_USE_OBJC
62/* By default, XPC objects are declared as Objective-C types when building with
63 * an Objective-C compiler. This allows them to participate in ARC, in RR
64 * management by the Blocks runtime and in leaks checking by the static
65 * analyzer, and enables them to be added to Cocoa collections.
66 *
67 * See <os/object.h> for details.
68 */
69OS_OBJECT_DECL(xpc_object);
70#ifndef XPC_DECL
71#define XPC_DECL(name) typedef xpc_object_t name##_t
72#endif // XPC_DECL
73
74#define XPC_GLOBAL_OBJECT(object) ((OS_OBJECT_BRIDGE xpc_object_t)&(object))
75#define XPC_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
76XPC_INLINE XPC_NONNULL_ALL
77void
78_xpc_object_validate(xpc_object_t object) {
79 (void)*(unsigned long volatile *)(OS_OBJECT_BRIDGE void *)object;
80}
81#else // OS_OBJECT_USE_OBJC
82typedef void * xpc_object_t;
83#define XPC_DECL(name) typedef struct _##name##_s * name##_t
84#define XPC_GLOBAL_OBJECT(object) (&(object))
85#define XPC_RETURNS_RETAINED
86#endif // OS_OBJECT_USE_OBJC
87
88/*!
89 * @typedef xpc_handler_t
90 * The type of block that is accepted by the XPC connection APIs.
91 *
92 * @param object
93 * An XPC object that is to be handled. If there was an error, this object will
94 * be equal to one of the well-known XPC_ERROR_* dictionaries and can be
95 * compared with the equality operator.
96 *
97 * @discussion
98 * You are not responsible for releasing the event object.
99 */
100#if __BLOCKS__
101typedef void (^xpc_handler_t)(xpc_object_t object);
102#endif // __BLOCKS__
103
104/*!
105 * @define XPC_TYPE_CONNECTION
106 * A type representing a connection to a named service. This connection is
107 * bidirectional and can be used to both send and receive messages. A
108 * connection carries the credentials of the remote service provider.
109 */
110#define XPC_TYPE_CONNECTION (&_xpc_type_connection)
111__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
112XPC_EXPORT
113XPC_TYPE(_xpc_type_connection);
114XPC_DECL(xpc_connection);
115
116/*!
117 * @typedef xpc_connection_handler_t
118 * The type of the function that will be invoked for a bundled XPC service when
119 * there is a new connection on the service.
120 *
121 * @param connection
122 * A new connection that is equivalent to one received by a listener connection.
123 * See the documentation for {@link xpc_connection_set_event_handler} for the
124 * semantics associated with the received connection.
125 */
126typedef void (*xpc_connection_handler_t)(xpc_connection_t connection);
127
128/*!
129 * @define XPC_TYPE_ENDPOINT
130 * A type representing a connection in serialized form. Unlike a connection, an
131 * endpoint is an inert object that does not have any runtime activity
132 * associated with it. Thus, it is safe to pass an endpoint in a message. Upon
133 * receiving an endpoint, the recipient can use
134 * xpc_connection_create_from_endpoint() to create as many distinct connections
135 * as desired.
136 */
137#define XPC_TYPE_ENDPOINT (&_xpc_type_endpoint)
138__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
139XPC_EXPORT
140XPC_TYPE(_xpc_type_endpoint);
141XPC_DECL(xpc_endpoint);
142
143/*!
144 * @define XPC_TYPE_NULL
145 * A type representing a null object. This type is useful for disambiguating
146 * an unset key in a dictionary and one which has been reserved but set empty.
147 * Also, this type is a way to represent a "null" value in dictionaries, which
148 * do not accept NULL.
149 */
150#define XPC_TYPE_NULL (&_xpc_type_null)
151__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
152XPC_EXPORT
153XPC_TYPE(_xpc_type_null);
154
155/*!
156 * @define XPC_TYPE_BOOL
157 * A type representing a Boolean value.
158 */
159#define XPC_TYPE_BOOL (&_xpc_type_bool)
160__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
161XPC_EXPORT
162XPC_TYPE(_xpc_type_bool);
163
164/*!
165 * @define XPC_BOOL_TRUE
166 * A constant representing a Boolean value of true. You may compare a Boolean
167 * object against this constant to determine its value.
168 */
169#define XPC_BOOL_TRUE XPC_GLOBAL_OBJECT(_xpc_bool_true)
170__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
171XPC_EXPORT
172const struct _xpc_bool_s _xpc_bool_true;
173
174/*!
175 * @define XPC_BOOL_FALSE
176 * A constant representing a Boolean value of false. You may compare a Boolean
177 * object against this constant to determine its value.
178 */
179#define XPC_BOOL_FALSE XPC_GLOBAL_OBJECT(_xpc_bool_false)
180__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
181XPC_EXPORT
182const struct _xpc_bool_s _xpc_bool_false;
183
184/*!
185 * @define XPC_TYPE_INT64
186 * A type representing a signed, 64-bit integer value.
187 */
188#define XPC_TYPE_INT64 (&_xpc_type_int64)
189__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
190XPC_EXPORT
191XPC_TYPE(_xpc_type_int64);
192
193/*!
194 * @define XPC_TYPE_UINT64
195 * A type representing an unsigned, 64-bit integer value.
196 */
197#define XPC_TYPE_UINT64 (&_xpc_type_uint64)
198__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
199XPC_EXPORT
200XPC_TYPE(_xpc_type_uint64);
201
202/*!
203 * @define XPC_TYPE_DOUBLE
204 * A type representing an IEEE-compliant, double-precision floating point value.
205 */
206#define XPC_TYPE_DOUBLE (&_xpc_type_double)
207__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
208XPC_EXPORT
209XPC_TYPE(_xpc_type_double);
210
211/*!
212 * @define XPC_TYPE_DATE
213* A type representing a date interval. The interval is with respect to the
214 * Unix epoch. XPC dates are in Unix time and are thus unaware of local time
215 * or leap seconds.
216 */
217#define XPC_TYPE_DATE (&_xpc_type_date)
218__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
219XPC_EXPORT
220XPC_TYPE(_xpc_type_date);
221
222/*!
223 * @define XPC_TYPE_DATA
224 * A type representing a an arbitrary buffer of bytes.
225 */
226#define XPC_TYPE_DATA (&_xpc_type_data)
227__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
228XPC_EXPORT
229XPC_TYPE(_xpc_type_data);
230
231/*!
232 * @define XPC_TYPE_STRING
233 * A type representing a NUL-terminated C-string.
234 */
235#define XPC_TYPE_STRING (&_xpc_type_string)
236__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
237XPC_EXPORT
238XPC_TYPE(_xpc_type_string);
239
240/*!
241 * @define XPC_TYPE_UUID
242 * A type representing a Universally Unique Identifier as defined by uuid(3).
243 */
244#define XPC_TYPE_UUID (&_xpc_type_uuid)
245__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
246XPC_EXPORT
247XPC_TYPE(_xpc_type_uuid);
248
249/*!
250 * @define XPC_TYPE_FD
251 * A type representing a POSIX file descriptor.
252 */
253#define XPC_TYPE_FD (&_xpc_type_fd)
254__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
255XPC_EXPORT
256XPC_TYPE(_xpc_type_fd);
257
258/*!
259 * @define XPC_TYPE_SHMEM
260 * A type representing a region of shared memory.
261 */
262#define XPC_TYPE_SHMEM (&_xpc_type_shmem)
263__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
264XPC_EXPORT
265XPC_TYPE(_xpc_type_shmem);
266
267/*!
268 * @define XPC_TYPE_ARRAY
269 * A type representing an array of XPC objects. This array must be contiguous,
270 * i.e. it cannot contain NULL values. If you wish to indicate that a slot
271 * is empty, you can insert a null object. The array will grow as needed to
272 * accommodate more objects.
273 */
274#define XPC_TYPE_ARRAY (&_xpc_type_array)
275__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
276XPC_EXPORT
277XPC_TYPE(_xpc_type_array);
278
279/*!
280 * @define XPC_TYPE_DICTIONARY
281 * A type representing a dictionary of XPC objects, keyed off of C-strings.
282 * You may insert NULL values into this collection. The dictionary will grow
283 * as needed to accommodate more key/value pairs.
284 */
285#define XPC_TYPE_DICTIONARY (&_xpc_type_dictionary)
286__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
287XPC_EXPORT
288XPC_TYPE(_xpc_type_dictionary);
289
290/*!
291 * @define XPC_TYPE_ERROR
292 * A type representing an error object. Errors in XPC are dictionaries, but
293 * xpc_get_type() will return this type when given an error object. You
294 * cannot create an error object directly; XPC will only give them to handlers.
295 * These error objects have pointer values that are constant across the lifetime
296 * of your process and can be safely compared.
297 *
298 * These constants are enumerated in the header for the connection object. Error
299 * dictionaries may reserve keys so that they can be queried to obtain more
300 * detailed information about the error. Currently, the only reserved key is
301 * XPC_ERROR_KEY_DESCRIPTION.
302 */
303#define XPC_TYPE_ERROR (&_xpc_type_error)
304__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
305XPC_EXPORT
306XPC_TYPE(_xpc_type_error);
307
308/*!
309 * @define XPC_ERROR_KEY_DESCRIPTION
310 * In an error dictionary, querying for this key will return a string object
311 * that describes the error in a human-readable way.
312 */
313#define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description
314__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
315XPC_EXPORT
316const char * const _xpc_error_key_description;
317
318/*!
319 * @define XPC_EVENT_KEY_NAME
320 * In an event dictionary, this querying for this key will return a string
321 * object that describes the event.
322 */
323#define XPC_EVENT_KEY_NAME _xpc_event_key_name
324__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
325XPC_EXPORT
326const char * const _xpc_event_key_name;
327
328XPC_ASSUME_NONNULL_END
329#if !defined(__XPC_BUILDING_XPC__) || !__XPC_BUILDING_XPC__
330#include <xpc/endpoint.h>
331#include <xpc/debug.h>
332#if __BLOCKS__
333#include <xpc/connection.h>
334#include <xpc/activity.h>
335#endif // __BLOCKS__
336#undef __XPC_INDIRECT__
337#include <launch.h>
338#endif // !defined(__XPC_BUILDING_XPC__) || !__XPC_BUILDING_XPC__
339XPC_ASSUME_NONNULL_BEGIN
340
341#pragma mark XPC Object Protocol
342/*!
343 * @function xpc_retain
344 *
345 * @abstract
346 * Increments the reference count of an object.
347 *
348 * @param object
349 * The object which is to be manipulated.
350 *
351 * @result
352 * The object which was given.
353 *
354 * @discussion
355 * Calls to xpc_retain() must be balanced with calls to xpc_release()
356 * to avoid leaking memory.
357 */
358__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
359XPC_EXPORT XPC_NONNULL1
360xpc_object_t
361xpc_retain(xpc_object_t object);
362#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
363#undef xpc_retain
364#define xpc_retain(object) ({ xpc_object_t _o = (object); \
365 _xpc_object_validate(_o); [_o retain]; })
366#endif // OS_OBJECT_USE_OBJC_RETAIN_RELEASE
367
368/*!
369 * @function xpc_release
370 *
371 * @abstract
372 * Decrements the reference count of an object.
373 *
374 * @param object
375 * The object which is to be manipulated.
376 *
377 * @discussion
378 * The caller must take care to balance retains and releases. When creating or
379 * retaining XPC objects, the creator obtains a reference on the object. Thus,
380 * it is the caller's responsibility to call xpc_release() on those objects when
381 * they are no longer needed.
382 */
383__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
384XPC_EXPORT XPC_NONNULL1
385void
386xpc_release(xpc_object_t object);
387#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
388#undef xpc_release
389#define xpc_release(object) ({ xpc_object_t _o = (object); \
390 _xpc_object_validate(_o); [_o release]; })
391#endif // OS_OBJECT_USE_OBJC_RETAIN_RELEASE
392
393/*!
394 * @function xpc_get_type
395 *
396 * @abstract
397 * Returns the type of an object.
398 *
399 * @param object
400 * The object to examine.
401 *
402 * @result
403 * An opaque pointer describing the type of the object. This pointer is suitable
404 * direct comparison to exported type constants with the equality operator.
405 */
406__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
407XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
408xpc_type_t
409xpc_get_type(xpc_object_t object);
410
411/*!
412 * @function xpc_type_get_name
413 *
414 * @abstract
415 * Returns a string describing an XPC object type.
416 *
417 * @param type
418 * The type to describe.
419 *
420 * @result
421 * A string describing the type of an object, like "string" or "int64".
422 * This string should not be freed or modified.
423 */
424__OSX_AVAILABLE_STARTING(__MAC_10_15, __IPHONE_13_0)
425XPC_EXPORT XPC_NONNULL1
426const char *
427xpc_type_get_name(xpc_type_t type);
428
429/*!
430 * @function xpc_copy
431 *
432 * @abstract
433 * Creates a copy of the object.
434 *
435 * @param object
436 * The object to copy.
437 *
438 * @result
439 * The new object. NULL if the object type does not support copying or if
440 * sufficient memory for the copy could not be allocated. Service objects do
441 * not support copying.
442 *
443 * @discussion
444 * When called on an array or dictionary, xpc_copy() will perform a deep copy.
445 *
446 * The object returned is not necessarily guaranteed to be a new object, and
447 * whether it is will depend on the implementation of the object being copied.
448 */
449__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
450XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT XPC_RETURNS_RETAINED
451xpc_object_t _Nullable
452xpc_copy(xpc_object_t object);
453
454/*!
455 * @function xpc_equal
456 *
457 * @abstract
458 * Compares two objects for equality.
459 *
460 * @param object1
461 * The first object to compare.
462 *
463 * @param object2
464 * The second object to compare.
465 *
466 * @result
467 * Returns true if the objects are equal, otherwise false. Two objects must be
468 * of the same type in order to be equal.
469 *
470 * For two arrays to be equal, they must contain the same values at the
471 * same indexes. For two dictionaries to be equal, they must contain the same
472 * values for the same keys.
473 *
474 * Two objects being equal implies that their hashes (as returned by xpc_hash())
475 * are also equal.
476 */
477__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
478XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_WARN_RESULT
479bool
480xpc_equal(xpc_object_t object1, xpc_object_t object2);
481
482/*!
483 * @function xpc_hash
484 *
485 * @abstract
486 * Calculates a hash value for the given object.
487 *
488 * @param object
489 * The object for which to calculate a hash value. This value may be modded
490 * with a table size for insertion into a dictionary-like data structure.
491 *
492 * @result
493 * The calculated hash value.
494 *
495 * @discussion
496 * Note that the computed hash values for any particular type and value of an
497 * object can change from across releases and platforms and should not be
498 * assumed to be constant across all time and space or stored persistently.
499 */
500__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
501XPC_EXPORT XPC_NONNULL1 XPC_WARN_RESULT
502size_t
503xpc_hash(xpc_object_t object);
504
505/*!
506 * @function xpc_copy_description
507 *
508 * @abstract
509 * Copies a debug string describing the object.
510 *
511 * @param object
512 * The object which is to be examined.
513 *
514 * @result
515 * A string describing object which contains information useful for debugging.
516 * This string should be disposed of with free(3) when done.
517 */
518__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
519XPC_EXPORT XPC_MALLOC XPC_WARN_RESULT XPC_NONNULL1
520char *
521xpc_copy_description(xpc_object_t object);
522
523#pragma mark XPC Object Types
524#pragma mark Null
525/*!
526 * @function xpc_null_create
527 *
528 * @abstract
529 * Creates an XPC object representing the null object.
530 *
531 * @result
532 * A new null object.
533 */
534__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
535XPC_EXPORT XPC_RETURNS_RETAINED XPC_WARN_RESULT
536xpc_object_t
537xpc_null_create(void);
538
539#pragma mark Boolean
540/*!
541 * @function xpc_bool_create
542 *
543 * @abstract
544 * Creates an XPC Boolean object.
545 *
546 * @param value
547 * The Boolean primitive value which is to be boxed.
548 *
549 * @result
550 * A new Boolean object.
551 */
552__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
553XPC_EXPORT XPC_RETURNS_RETAINED XPC_WARN_RESULT
554xpc_object_t
555xpc_bool_create(bool value);
556
557/*!
558 * @function xpc_bool_get_value
559 *
560 * @abstract
561 * Returns the underlying Boolean value from the object.
562 *
563 * @param xbool
564 * The Boolean object which is to be examined.
565 *
566 * @result
567 * The underlying Boolean value or false if the given object was not an XPC
568 * Boolean object.
569 */
570__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
571XPC_EXPORT
572bool
573xpc_bool_get_value(xpc_object_t xbool);
574
575#pragma mark Signed Integer
576/*!
577 * @function xpc_int64_create
578 *
579 * @abstract
580 * Creates an XPC signed integer object.
581 *
582 * @param value
583 * The signed integer value which is to be boxed.
584 *
585 * @result
586 * A new signed integer object.
587 */
588__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
589XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
590xpc_object_t
591xpc_int64_create(int64_t value);
592
593/*!
594 * @function xpc_int64_get_value
595 *
596 * @abstract
597 * Returns the underlying signed 64-bit integer value from an object.
598 *
599 * @param xint
600 * The signed integer object which is to be examined.
601 *
602 * @result
603 * The underlying signed 64-bit value or 0 if the given object was not an XPC
604 * integer object.
605 */
606__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
607XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
608int64_t
609xpc_int64_get_value(xpc_object_t xint);
610
611#pragma mark Unsigned Integer
612/*!
613 * @function xpc_uint64_create
614 *
615 * @abstract
616 * Creates an XPC unsigned integer object.
617 *
618 * @param value
619 * The unsigned integer value which is to be boxed.
620 *
621 * @result
622 * A new unsigned integer object.
623 */
624__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
625XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
626xpc_object_t
627xpc_uint64_create(uint64_t value);
628
629/*!
630 * @function xpc_uint64_get_value
631 *
632 * @abstract
633 * Returns the underlying unsigned 64-bit integer value from an object.
634 *
635 * @param xuint
636 * The unsigned integer object which is to be examined.
637 *
638 * @result
639 * The underlying unsigned integer value or 0 if the given object was not an XPC
640 * unsigned integer object.
641 */
642__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
643XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
644uint64_t
645xpc_uint64_get_value(xpc_object_t xuint);
646
647#pragma mark Double
648/*!
649 * @function xpc_double_create
650 *
651 * @abstract
652 * Creates an XPC double object.
653 *
654 * @param value
655 * The floating point quantity which is to be boxed.
656 *
657 * @result
658 * A new floating point object.
659 */
660__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
661XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
662xpc_object_t
663xpc_double_create(double value);
664
665/*!
666 * @function xpc_double_get_value
667 *
668 * @abstract
669 * Returns the underlying double-precision floating point value from an object.
670 *
671 * @param xdouble
672 * The floating point object which is to be examined.
673 *
674 * @result
675 * The underlying floating point value or NAN if the given object was not an XPC
676 * floating point object.
677 */
678__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
679XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
680double
681xpc_double_get_value(xpc_object_t xdouble);
682
683#pragma mark Date
684/*!
685 * @function xpc_date_create
686 *
687 * @abstract
688 * Creates an XPC date object.
689 *
690 * @param interval
691 * The date interval which is to be boxed. Negative values indicate the number
692 * of nanoseconds before the epoch. Positive values indicate the number of
693 * nanoseconds after the epoch.
694 *
695 * @result
696 * A new date object.
697 */
698__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
699XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
700xpc_object_t
701xpc_date_create(int64_t interval);
702
703/*!
704 * @function xpc_date_create_from_current
705 *
706 * @abstract
707 * Creates an XPC date object representing the current date.
708 *
709 * @result
710 * A new date object representing the current date.
711 */
712__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
713XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
714xpc_object_t
715xpc_date_create_from_current(void);
716
717/*!
718 * @function xpc_date_get_value
719 *
720 * @abstract
721 * Returns the underlying date interval from an object.
722 *
723 * @param xdate
724 * The date object which is to be examined.
725 *
726 * @result
727 * The underlying date interval or 0 if the given object was not an XPC date
728 * object.
729 */
730__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
731XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
732int64_t
733xpc_date_get_value(xpc_object_t xdate);
734
735#pragma mark Data
736/*!
737 * @function xpc_data_create
738 *
739 * @abstract
740 * Creates an XPC object representing buffer of bytes.
741 *
742 * @param bytes
743 * The buffer of bytes which is to be boxed. You may create an empty data object
744 * by passing NULL for this parameter and 0 for the length. Passing NULL with
745 * any other length will result in undefined behavior.
746 *
747 * @param length
748 * The number of bytes which are to be boxed.
749 *
750 * @result
751 * A new data object.
752 *
753 * @discussion
754 * This method will copy the buffer given into internal storage. After calling
755 * this method, it is safe to dispose of the given buffer.
756 */
757__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
758XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
759xpc_object_t
760xpc_data_create(const void * _Nullable bytes, size_t length);
761
762/*!
763 * @function xpc_data_create_with_dispatch_data
764 *
765 * @abstract
766 * Creates an XPC object representing buffer of bytes described by the given GCD
767 * data object.
768 *
769 * @param ddata
770 * The GCD data object containing the bytes which are to be boxed. This object
771 * is retained by the data object.
772 *
773 * @result
774 * A new data object.
775 *
776 * @discussion
777 * The object returned by this method will refer to the buffer returned by
778 * dispatch_data_create_map(). The point where XPC will make the call to
779 * dispatch_data_create_map() is undefined.
780 */
781__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
782XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
783xpc_object_t
784xpc_data_create_with_dispatch_data(dispatch_data_t ddata);
785
786/*!
787 * @function xpc_data_get_length
788 *
789 * @abstract
790 * Returns the length of the data encapsulated by an XPC data object.
791 *
792 * @param xdata
793 * The data object which is to be examined.
794 *
795 * @result
796 * The length of the underlying boxed data or 0 if the given object was not an
797 * XPC data object.
798 */
799__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
800XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
801size_t
802xpc_data_get_length(xpc_object_t xdata);
803
804/*!
805 * @function xpc_data_get_bytes_ptr
806 *
807 * @abstract
808 * Returns a pointer to the internal storage of a data object.
809 *
810 * @param xdata
811 * The data object which is to be examined.
812 *
813 * @result
814 * A pointer to the underlying boxed data or NULL if the given object was not an
815 * XPC data object.
816 */
817__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
818XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
819const void * _Nullable
820xpc_data_get_bytes_ptr(xpc_object_t xdata);
821
822/*!
823 * @function xpc_data_get_bytes
824 *
825 * @abstract
826 * Copies the bytes stored in an data objects into the specified buffer.
827 *
828 * @param xdata
829 * The data object which is to be examined.
830 *
831 * @param buffer
832 * The buffer in which to copy the data object's bytes.
833 *
834 * @param off
835 * The offset at which to begin the copy. If this offset is greater than the
836 * length of the data element, nothing is copied. Pass 0 to start the copy
837 * at the beginning of the buffer.
838 *
839 * @param length
840 * The length of the destination buffer.
841 *
842 * @result
843 * The number of bytes that were copied into the buffer or 0 if the given object
844 * was not an XPC data object.
845 */
846__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
847XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2
848size_t
849xpc_data_get_bytes(xpc_object_t xdata,
850 void *buffer, size_t off, size_t length);
851
852#pragma mark String
853/*!
854 * @function xpc_string_create
855 *
856 * @abstract
857 * Creates an XPC object representing a NUL-terminated C-string.
858 *
859 * @param string
860 * The C-string which is to be boxed.
861 *
862 * @result
863 * A new string object.
864 */
865__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
866XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
867xpc_object_t
868xpc_string_create(const char *string);
869
870/*!
871 * @function xpc_string_create_with_format
872 *
873 * @abstract
874 * Creates an XPC object representing a C-string that is generated from the
875 * given format string and arguments.
876 *
877 * @param fmt
878 * The printf(3)-style format string from which to construct the final C-string
879 * to be boxed.
880 *
881 * @param ...
882 * The arguments which correspond to those specified in the format string.
883 *
884 * @result
885 * A new string object.
886 */
887__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
888XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
889XPC_PRINTF(1, 2)
890xpc_object_t
891xpc_string_create_with_format(const char *fmt, ...);
892
893/*!
894 * @function xpc_string_create_with_format_and_arguments
895 *
896 * @abstract
897 * Creates an XPC object representing a C-string that is generated from the
898 * given format string and argument list pointer.
899 *
900 * @param fmt
901 * The printf(3)-style format string from which to construct the final C-string
902 * to be boxed.
903 *
904 * @param ap
905 * A pointer to the arguments which correspond to those specified in the format
906 * string.
907 *
908 * @result
909 * A new string object.
910 */
911__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
912XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
913XPC_PRINTF(1, 0)
914xpc_object_t
915xpc_string_create_with_format_and_arguments(const char *fmt, va_list ap);
916
917/*!
918 * @function xpc_string_get_length
919 *
920 * @abstract
921 * Returns the length of the underlying string.
922 *
923 * @param xstring
924 * The string object which is to be examined.
925 *
926 * @result
927 * The length of the underlying string, not including the NUL-terminator, or 0
928 * if the given object was not an XPC string object.
929 */
930__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
931XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
932size_t
933xpc_string_get_length(xpc_object_t xstring);
934
935/*!
936 * @function xpc_string_get_string_ptr
937 *
938 * @abstract
939 * Returns a pointer to the internal storage of a string object.
940 *
941 * @param xstring
942 * The string object which is to be examined.
943 *
944 * @result
945 * A pointer to the string object's internal storage or NULL if the given object
946 * was not an XPC string object.
947 */
948__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
949XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
950const char * _Nullable
951xpc_string_get_string_ptr(xpc_object_t xstring);
952
953#pragma mark UUID
954/*!
955 * @function xpc_uuid_create
956 *
957 * @abstract
958 * Creates an XPC object representing a universally-unique identifier (UUID) as
959 * described by uuid(3).
960 *
961 * @param uuid
962 * The UUID which is to be boxed.
963 *
964 * @result
965 * A new UUID object.
966 */
967__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
968XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
969xpc_object_t
970xpc_uuid_create(const uuid_t XPC_NONNULL_ARRAY uuid);
971
972/*!
973 * @function xpc_uuid_get_bytes
974 *
975 * @abstract
976 * Returns a pointer to the the boxed UUID bytes in an XPC UUID object.
977 *
978 * @param xuuid
979 * The UUID object which is to be examined.
980 *
981 * @result
982 * The underlying <code>uuid_t</code> bytes or NULL if the given object was not
983 * an XPC UUID object. The returned pointer may be safely passed to the uuid(3)
984 * APIs.
985 */
986__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
987XPC_EXPORT XPC_NONNULL1
988const uint8_t * _Nullable
989xpc_uuid_get_bytes(xpc_object_t xuuid);
990
991#pragma mark File Descriptors
992/*!
993 * @function xpc_fd_create
994 *
995 * @abstract
996 * Creates an XPC object representing a POSIX file descriptor.
997 *
998 * @param fd
999 * The file descriptor which is to be boxed.
1000 *
1001 * @result
1002 * A new file descriptor object. NULL if sufficient memory could not be
1003 * allocated or if the given file descriptor was not valid.
1004 *
1005 * @discussion
1006 * This method performs the equivalent of a dup(2) on the descriptor, and thus
1007 * it is safe to call close(2) on the descriptor after boxing it with a file
1008 * descriptor object.
1009 *
1010 * IMPORTANT: Pointer equality is the ONLY valid test for equality between two
1011 * file descriptor objects. There is no reliable way to determine whether two
1012 * file descriptors refer to the same inode with the same capabilities, so two
1013 * file descriptor objects created from the same underlying file descriptor
1014 * number will not compare equally with xpc_equal(). This is also true of a
1015 * file descriptor object created using xpc_copy() and the original.
1016 *
1017 * This also implies that two collections containing file descriptor objects
1018 * cannot be equal unless the exact same object was inserted into both.
1019 */
1020__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1021XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
1022xpc_object_t _Nullable
1023xpc_fd_create(int fd);
1024
1025/*!
1026 * @function xpc_fd_dup
1027 *
1028 * @abstract
1029 * Returns a file descriptor that is equivalent to the one boxed by the file
1030 * file descriptor object.
1031 *
1032 * @param xfd
1033 * The file descriptor object which is to be examined.
1034 *
1035 * @result
1036 * A file descriptor that is equivalent to the one originally given to
1037 * xpc_fd_create(). If the descriptor could not be created or if the given
1038 * object was not an XPC file descriptor, -1 is returned.
1039 *
1040 * @discussion
1041 * Multiple invocations of xpc_fd_dup() will not return the same file descriptor
1042 * number, but they will return descriptors that are equivalent, as though they
1043 * had been created by dup(2).
1044 *
1045 * The caller is responsible for calling close(2) on the returned descriptor.
1046 */
1047__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1048XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1049int
1050xpc_fd_dup(xpc_object_t xfd);
1051
1052#pragma mark Shared Memory
1053/*!
1054 * @function xpc_shmem_create
1055 *
1056 * @abstract
1057 * Creates an XPC object representing the given shared memory region.
1058 *
1059 * @param region
1060 * A pointer to a region of shared memory, created through a call to mmap(2)
1061 * with the MAP_SHARED flag, which is to be boxed.
1062 *
1063 * @param length
1064 * The length of the region.
1065 *
1066 * @result
1067 * A new shared memory object.
1068 *
1069 * @discussion
1070 * Only memory regions whose exact characteristics are known to the caller
1071 * should be boxed using this API. Memory returned from malloc(3) may not be
1072 * safely shared on either OS X or iOS because the underlying virtual memory
1073 * objects for malloc(3)ed allocations are owned by the malloc(3) subsystem and
1074 * not the caller of malloc(3).
1075 *
1076 * If you wish to share a memory region that you receive from another subsystem,
1077 * part of the interface contract with that other subsystem must include how to
1078 * create the region of memory, or sharing it may be unsafe.
1079 *
1080 * Certain operations may internally fragment a region of memory in a way that
1081 * would truncate the range detected by the shared memory object. vm_copy(), for
1082 * example, may split the region into multiple parts to avoid copying certain
1083 * page ranges. For this reason, it is recommended that you delay all VM
1084 * operations until the shared memory object has been created so that the VM
1085 * system knows that the entire range is intended for sharing.
1086 */
1087__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1088XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
1089xpc_object_t
1090xpc_shmem_create(void *region, size_t length);
1091
1092/*!
1093 * @function xpc_shmem_map
1094 *
1095 * @abstract
1096 * Maps the region boxed by the XPC shared memory object into the caller's
1097 * address space.
1098 *
1099 * @param xshmem
1100 * The shared memory object to be examined.
1101 *
1102 * @param region
1103 * On return, this will point to the region at which the shared memory was
1104 * mapped.
1105 *
1106 * @result
1107 * The length of the region that was mapped. If the mapping failed or if the
1108 * given object was not an XPC shared memory object, 0 is returned. The length
1109 * of the mapped region will always be an integral page size, even if the
1110 * creator of the region specified a non-integral page size.
1111 *
1112 * @discussion
1113 * The resulting region must be disposed of with munmap(2).
1114 *
1115 * It is the responsibility of the caller to manage protections on the new
1116 * region accordingly.
1117 */
1118__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1119XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
1120size_t
1121xpc_shmem_map(xpc_object_t xshmem, void * _Nullable * _Nonnull region);
1122
1123#pragma mark Array
1124/*!
1125 * @typedef xpc_array_applier_t
1126 * A block to be invoked for every value in the array.
1127 *
1128 * @param index
1129 * The current index in the iteration.
1130 *
1131 * @param value
1132 * The current value in the iteration.
1133 *
1134 * @result
1135 * A Boolean indicating whether iteration should continue.
1136 */
1137#ifdef __BLOCKS__
1138typedef bool (^xpc_array_applier_t)(size_t index, xpc_object_t _Nonnull value);
1139#endif // __BLOCKS__
1140
1141/*!
1142 * @function xpc_array_create
1143 *
1144 * @abstract
1145 * Creates an XPC object representing an array of XPC objects.
1146 *
1147 * @discussion
1148 * This array must be contiguous and cannot contain any NULL values. If you
1149 * wish to insert the equivalent of a NULL value, you may use the result of
1150 * {@link xpc_null_create}.
1151 *
1152 * @param objects
1153 * An array of XPC objects which is to be boxed. The order of this array is
1154 * preserved in the object. If this array contains a NULL value, the behavior
1155 * is undefined. This parameter may be NULL only if the count is 0.
1156 *
1157 * @param count
1158 * The number of objects in the given array. If the number passed is less than
1159 * the actual number of values in the array, only the specified number of items
1160 * are inserted into the resulting array. If the number passed is more than
1161 * the the actual number of values, the behavior is undefined.
1162 *
1163 * @result
1164 * A new array object.
1165 */
1166__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1167XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
1168xpc_object_t
1169xpc_array_create(const xpc_object_t _Nonnull * _Nullable objects, size_t count);
1170
1171/*!
1172 * @function xpc_array_create_empty
1173 *
1174 * @abstract
1175 * Creates an XPC object representing an array of XPC objects.
1176 *
1177 * @result
1178 * A new array object.
1179 *
1180 * @see
1181 * xpc_array_create
1182 */
1183API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
1184XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
1185xpc_object_t
1186xpc_array_create_empty(void);
1187
1188/*!
1189 * @function xpc_array_set_value
1190 *
1191 * @abstract
1192 * Inserts the specified object into the array at the specified index.
1193 *
1194 * @param xarray
1195 * The array object which is to be manipulated.
1196 *
1197 * @param index
1198 * The index at which to insert the value. This value must lie within the index
1199 * space of the array (0 to N-1 inclusive, where N is the count of the array).
1200 * If the index is outside that range, the behavior is undefined.
1201 *
1202 * @param value
1203 * The object to insert. This value is retained by the array and cannot be
1204 * NULL. If there is already a value at the specified index, it is released,
1205 * and the new value is inserted in its place.
1206 */
1207__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1208XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
1209void
1210xpc_array_set_value(xpc_object_t xarray, size_t index, xpc_object_t value);
1211
1212/*!
1213 * @function xpc_array_append_value
1214 *
1215 * @abstract
1216 * Appends an object to an XPC array.
1217 *
1218 * @param xarray
1219 * The array object which is to be manipulated.
1220 *
1221 * @param value
1222 * The object to append. This object is retained by the array.
1223 */
1224__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1225XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
1226void
1227xpc_array_append_value(xpc_object_t xarray, xpc_object_t value);
1228
1229/*!
1230 * @function xpc_array_get_count
1231 *
1232 * @abstract
1233 * Returns the count of values currently in the array.
1234 *
1235 * @param xarray
1236 * The array object which is to be examined.
1237 *
1238 * @result
1239 * The count of values in the array or 0 if the given object was not an XPC
1240 * array.
1241 */
1242__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1243XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1244size_t
1245xpc_array_get_count(xpc_object_t xarray);
1246
1247/*!
1248 * @function xpc_array_get_value
1249 *
1250 * @abstract
1251 * Returns the value at the specified index in the array.
1252 *
1253 * @param xarray
1254 * The array object which is to be examined.
1255 *
1256 * @param index
1257 * The index of the value to obtain. This value must lie within the range of
1258 * indexes as specified in xpc_array_set_value().
1259 *
1260 * @result
1261 * The object at the specified index within the array or NULL if the given
1262 * object was not an XPC array.
1263 *
1264 * @discussion
1265 * This method does not grant the caller a reference to the underlying object,
1266 * and thus the caller is not responsible for releasing the object.
1267 */
1268__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1269XPC_EXPORT XPC_NONNULL_ALL
1270xpc_object_t
1271xpc_array_get_value(xpc_object_t xarray, size_t index);
1272
1273/*!
1274 * @function xpc_array_apply
1275 *
1276 * @abstract
1277 * Invokes the given block for every value in the array.
1278 *
1279 * @param xarray
1280 * The array object which is to be examined.
1281 *
1282 * @param applier
1283 * The block which this function applies to every element in the array.
1284 *
1285 * @result
1286 * A Boolean indicating whether iteration of the array completed successfully.
1287 * Iteration will only fail if the applier block returns false.
1288 *
1289 * @discussion
1290 * You should not modify an array's contents during iteration. The array indexes
1291 * are iterated in order.
1292 */
1293#ifdef __BLOCKS__
1294__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1295XPC_EXPORT XPC_NONNULL_ALL
1296bool
1297xpc_array_apply(xpc_object_t xarray, XPC_NOESCAPE xpc_array_applier_t applier);
1298#endif // __BLOCKS__
1299
1300#pragma mark Array Primitive Setters
1301/*!
1302 * @define XPC_ARRAY_APPEND
1303 * A constant that may be passed as the destination index to the class of
1304 * primitive XPC array setters indicating that the given primitive should be
1305 * appended to the array.
1306 */
1307#define XPC_ARRAY_APPEND ((size_t)(-1))
1308
1309/*!
1310 * @function xpc_array_set_bool
1311 *
1312 * @abstract
1313 * Inserts a <code>bool</code> (primitive) value into an array.
1314 *
1315 * @param xarray
1316 * The array object which is to be manipulated.
1317 *
1318 * @param index
1319 * The index at which to insert the value. This value must lie within the index
1320 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1321 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1322 * undefined.
1323 *
1324 * @param value
1325 * The <code>bool</code> value to insert. After calling this method, the XPC
1326 * object corresponding to the primitive value inserted may be safely retrieved
1327 * with {@link xpc_array_get_value()}.
1328 */
1329__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1330XPC_EXPORT XPC_NONNULL1
1331void
1332xpc_array_set_bool(xpc_object_t xarray, size_t index, bool value);
1333
1334/*!
1335 * @function xpc_array_set_int64
1336 *
1337 * @abstract
1338 * Inserts an <code>int64_t</code> (primitive) value into an array.
1339 *
1340 * @param xarray
1341 * The array object which is to be manipulated.
1342 *
1343 * @param index
1344 * The index at which to insert the value. This value must lie within the index
1345 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1346 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1347 * undefined.
1348 *
1349 * @param value
1350 * The <code>int64_t</code> value to insert. After calling this method, the XPC
1351 * object corresponding to the primitive value inserted may be safely retrieved
1352 * with {@link xpc_array_get_value()}.
1353 */
1354__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1355XPC_EXPORT XPC_NONNULL1
1356void
1357xpc_array_set_int64(xpc_object_t xarray, size_t index, int64_t value);
1358
1359/*!
1360 * @function xpc_array_set_uint64
1361 *
1362 * @abstract
1363 * Inserts a <code>uint64_t</code> (primitive) value into an array.
1364 *
1365 * @param xarray
1366 * The array object which is to be manipulated.
1367 *
1368 * @param index
1369 * The index at which to insert the value. This value must lie within the index
1370 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1371 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1372 * undefined.
1373 *
1374 * @param value
1375 * The <code>uint64_t</code> value to insert. After calling this method, the XPC
1376 * object corresponding to the primitive value inserted may be safely retrieved
1377 * with {@link xpc_array_get_value()}.
1378 */
1379__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1380XPC_EXPORT XPC_NONNULL1
1381void
1382xpc_array_set_uint64(xpc_object_t xarray, size_t index, uint64_t value);
1383
1384/*!
1385 * @function xpc_array_set_double
1386 *
1387 * @abstract
1388 * Inserts a <code>double</code> (primitive) value into an array.
1389 *
1390 * @param xarray
1391 * The array object which is to be manipulated.
1392 *
1393 * @param index
1394 * The index at which to insert the value. This value must lie within the index
1395 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1396 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1397 * undefined.
1398 *
1399 * @param value
1400 * The <code>double</code> value to insert. After calling this method, the XPC
1401 * object corresponding to the primitive value inserted may be safely retrieved
1402 * with {@link xpc_array_get_value()}.
1403 */
1404__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1405XPC_EXPORT XPC_NONNULL1
1406void
1407xpc_array_set_double(xpc_object_t xarray, size_t index, double value);
1408
1409/*!
1410 * @function xpc_array_set_date
1411 *
1412 * @abstract
1413 * Inserts a date value into an array.
1414 *
1415 * @param xarray
1416 * The array object which is to be manipulated.
1417 *
1418 * @param index
1419 * The index at which to insert the value. This value must lie within the index
1420 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1421 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1422 * undefined.
1423 *
1424 * @param value
1425 * The date value to insert, represented as an <code>int64_t</code>. After
1426 * calling this method, the XPC object corresponding to the primitive value
1427 * inserted may be safely retrieved with {@link xpc_array_get_value()}.
1428 */
1429__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1430XPC_EXPORT XPC_NONNULL1
1431void
1432xpc_array_set_date(xpc_object_t xarray, size_t index, int64_t value);
1433
1434/*!
1435 * @function xpc_array_set_data
1436 *
1437 * @abstract
1438 * Inserts a raw data value into an array.
1439 *
1440 * @param xarray
1441 * The array object which is to be manipulated.
1442 *
1443 * @param index
1444 * The index at which to insert the value. This value must lie within the index
1445 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1446 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1447 * undefined.
1448 *
1449 * @param bytes
1450 * The raw data to insert. After calling this method, the XPC object
1451 * corresponding to the primitive value inserted may be safely retrieved with
1452 * {@link xpc_array_get_value()}.
1453 *
1454 * @param length
1455 * The length of the data.
1456 */
1457__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1458XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
1459void
1460xpc_array_set_data(xpc_object_t xarray, size_t index, const void *bytes,
1461 size_t length);
1462
1463/*!
1464 * @function xpc_array_set_string
1465 *
1466 * @abstract
1467 * Inserts a C string into an array.
1468 *
1469 * @param xarray
1470 * The array object which is to be manipulated.
1471 *
1472 * @param index
1473 * The index at which to insert the value. This value must lie within the index
1474 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1475 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1476 * undefined.
1477 *
1478 * @param string
1479 * The C string to insert. After calling this method, the XPC object
1480 * corresponding to the primitive value inserted may be safely retrieved with
1481 * {@link xpc_array_get_value()}.
1482 */
1483__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1484XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
1485void
1486xpc_array_set_string(xpc_object_t xarray, size_t index, const char *string);
1487
1488/*!
1489 * @function xpc_array_set_uuid
1490 *
1491 * @abstract
1492 * Inserts a <code>uuid_t</code> (primitive) value into an array.
1493 *
1494 * @param xarray
1495 * The array object which is to be manipulated.
1496 *
1497 * @param index
1498 * The index at which to insert the value. This value must lie within the index
1499 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1500 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1501 * undefined.
1502 *
1503 * @param uuid
1504 * The UUID primitive to insert. After calling this method, the XPC object
1505 * corresponding to the primitive value inserted may be safely retrieved with
1506 * {@link xpc_array_get_value()}.
1507 */
1508__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1509XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
1510void
1511xpc_array_set_uuid(xpc_object_t xarray, size_t index,
1512 const uuid_t XPC_NONNULL_ARRAY uuid);
1513
1514/*!
1515 * @function xpc_array_set_fd
1516 *
1517 * @abstract
1518 * Inserts a file descriptor into an array.
1519 *
1520 * @param xarray
1521 * The array object which is to be manipulated.
1522 *
1523 * @param index
1524 * The index at which to insert the value. This value must lie within the index
1525 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1526 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1527 * undefined.
1528 *
1529 * @param fd
1530 * The file descriptor to insert. After calling this method, the XPC object
1531 * corresponding to the primitive value inserted may be safely retrieved with
1532 * {@link xpc_array_get_value()}.
1533 */
1534__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1535XPC_EXPORT XPC_NONNULL1
1536void
1537xpc_array_set_fd(xpc_object_t xarray, size_t index, int fd);
1538
1539/*!
1540 * @function xpc_array_set_connection
1541 *
1542 * @abstract
1543 * Inserts a connection into an array.
1544 *
1545 * @param xarray
1546 * The array object which is to be manipulated.
1547 *
1548 * @param index
1549 * The index at which to insert the value. This value must lie within the index
1550 * space of the array (0 to N-1 inclusive, where N is the count of the array) or
1551 * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
1552 * undefined.
1553 *
1554 * @param connection
1555 * The connection to insert. After calling this method, the XPC object
1556 * corresponding to the primitive value inserted may be safely retrieved with
1557 * {@link xpc_array_get_value()}. The connection is NOT retained by the array.
1558 */
1559__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1560XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
1561void
1562xpc_array_set_connection(xpc_object_t xarray, size_t index,
1563 xpc_connection_t connection);
1564
1565#pragma mark Array Primitive Getters
1566/*!
1567 * @function xpc_array_get_bool
1568 *
1569 * @abstract
1570 * Gets a <code>bool</code> primitive value from an array directly.
1571 *
1572 * @param xarray
1573 * The array which is to be examined.
1574 *
1575 * @param index
1576 * The index of the value to obtain. This value must lie within the index space
1577 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1578 * index is outside that range, the behavior is undefined.
1579 *
1580 * @result
1581 * The underlying <code>bool</code> value at the specified index. false if the
1582 * value at the specified index is not a Boolean value.
1583 */
1584__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1585XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1586bool
1587xpc_array_get_bool(xpc_object_t xarray, size_t index);
1588
1589/*!
1590 * @function xpc_array_get_int64
1591 *
1592 * @abstract
1593 * Gets an <code>int64_t</code> primitive value from an array directly.
1594 *
1595 * @param xarray
1596 * The array which is to be examined.
1597 *
1598 * @param index
1599 * The index of the value to obtain. This value must lie within the index space
1600 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1601 * index is outside that range, the behavior is undefined.
1602 *
1603 * @result
1604 * The underlying <code>int64_t</code> value at the specified index. 0 if the
1605 * value at the specified index is not a signed integer value.
1606 */
1607__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1608XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1609int64_t
1610xpc_array_get_int64(xpc_object_t xarray, size_t index);
1611
1612/*!
1613 * @function xpc_array_get_uint64
1614 *
1615 * @abstract
1616 * Gets a <code>uint64_t</code> primitive value from an array directly.
1617 *
1618 * @param xarray
1619 * The array which is to be examined.
1620 *
1621 * @param index
1622 * The index of the value to obtain. This value must lie within the index space
1623 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1624 * index is outside that range, the behavior is undefined.
1625 *
1626 * @result
1627 * The underlying <code>uint64_t</code> value at the specified index. 0 if the
1628 * value at the specified index is not an unsigned integer value.
1629 */
1630__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1631XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1632uint64_t
1633xpc_array_get_uint64(xpc_object_t xarray, size_t index);
1634
1635/*!
1636 * @function xpc_array_get_double
1637 *
1638 * @abstract
1639 * Gets a <code>double</code> primitive value from an array directly.
1640 *
1641 * @param xarray
1642 * The array which is to be examined.
1643 *
1644 * @param index
1645 * The index of the value to obtain. This value must lie within the index space
1646 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1647 * index is outside that range, the behavior is undefined.
1648 *
1649 * @result
1650 * The underlying <code>double</code> value at the specified index. NAN if the
1651 * value at the specified index is not a floating point value.
1652 */
1653__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1654XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1655double
1656xpc_array_get_double(xpc_object_t xarray, size_t index);
1657
1658/*!
1659 * @function xpc_array_get_date
1660 *
1661 * @abstract
1662 * Gets a date interval from an array directly.
1663 *
1664 * @param xarray
1665 * The array which is to be examined.
1666 *
1667 * @param index
1668 * The index of the value to obtain. This value must lie within the index space
1669 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1670 * index is outside that range, the behavior is undefined.
1671 *
1672 * @result
1673 * The underlying date interval at the specified index. 0 if the value at the
1674 * specified index is not a date value.
1675 */
1676__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1677XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1678int64_t
1679xpc_array_get_date(xpc_object_t xarray, size_t index);
1680
1681/*!
1682 * @function xpc_array_get_data
1683 *
1684 * @abstract
1685 * Gets a pointer to the raw bytes of a data object from an array directly.
1686 *
1687 * @param xarray
1688 * The array which is to be examined.
1689 *
1690 * @param index
1691 * The index of the value to obtain. This value must lie within the index space
1692 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1693 * index is outside that range, the behavior is undefined.
1694 *
1695 * @param length
1696 * Upon return output, will contain the length of the data corresponding to the
1697 * specified key.
1698 *
1699 * @result
1700 * The underlying bytes at the specified index. NULL if the value at the
1701 * specified index is not a data value.
1702 */
1703__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1704XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1705const void * _Nullable
1706xpc_array_get_data(xpc_object_t xarray, size_t index,
1707 size_t * _Nullable length);
1708
1709/*!
1710 * @function xpc_array_get_string
1711 *
1712 * @abstract
1713 * Gets a C string value from an array directly.
1714 *
1715 * @param xarray
1716 * The array which is to be examined.
1717 *
1718 * @param index
1719 * The index of the value to obtain. This value must lie within the index space
1720 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1721 * index is outside that range, the behavior is undefined.
1722 *
1723 * @result
1724 * The underlying C string at the specified index. NULL if the value at the
1725 * specified index is not a C string value.
1726 */
1727__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1728XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1729const char * _Nullable
1730xpc_array_get_string(xpc_object_t xarray, size_t index);
1731
1732/*!
1733 * @function xpc_array_get_uuid
1734 *
1735 * @abstract
1736 * Gets a <code>uuid_t</code> value from an array directly.
1737 *
1738 * @param xarray
1739 * The array which is to be examined.
1740 *
1741 * @param index
1742 * The index of the value to obtain. This value must lie within the index space
1743 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1744 * index is outside that range, the behavior is undefined.
1745 *
1746 * @result
1747 * The underlying <code>uuid_t</code> value at the specified index. The null
1748 * UUID if the value at the specified index is not a UUID value. The returned
1749 * pointer may be safely passed to the uuid(3) APIs.
1750 */
1751__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1752XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1753const uint8_t * _Nullable
1754xpc_array_get_uuid(xpc_object_t xarray, size_t index);
1755
1756/*!
1757 * @function xpc_array_dup_fd
1758 *
1759 * @abstract
1760 * Gets a file descriptor from an array directly.
1761 *
1762 * @param xarray
1763 * The array which is to be examined.
1764 *
1765 * @param index
1766 * The index of the value to obtain. This value must lie within the index space
1767 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1768 * index is outside that range, the behavior is undefined.
1769 *
1770 * @result
1771 * A new file descriptor created from the value at the specified index. You are
1772 * responsible for close(2)ing this descriptor. -1 if the value at the specified
1773 * index is not a file descriptor value.
1774 */
1775__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1776XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
1777int
1778xpc_array_dup_fd(xpc_object_t xarray, size_t index);
1779
1780/*!
1781 * @function xpc_array_create_connection
1782 *
1783 * @abstract
1784 * Creates a connection object from an array directly.
1785 *
1786 * @param xarray
1787 * The array which is to be examined.
1788 *
1789 * @param index
1790 * The index of the value to obtain. This value must lie within the index space
1791 * of the array (0 to N-1 inclusive, where N is the count of the array). If the
1792 * index is outside that range, the behavior is undefined.
1793 *
1794 * @result
1795 * A new connection created from the value at the specified index. You are
1796 * responsible for calling xpc_release() on the returned connection. NULL if the
1797 * value at the specified index is not an endpoint containing a connection. Each
1798 * call to this method for the same index in the same array will yield a
1799 * different connection. See {@link xpc_connection_create_from_endpoint()} for
1800 * discussion as to the responsibilities when dealing with the returned
1801 * connection.
1802 */
1803__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1804XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
1805xpc_connection_t _Nullable
1806xpc_array_create_connection(xpc_object_t xarray, size_t index);
1807
1808/*!
1809 * @function xpc_array_get_dictionary
1810 *
1811 * @abstract
1812 * Returns the dictionary at the specified index in the array.
1813 *
1814 * @param xarray
1815 * The array object which is to be examined.
1816 *
1817 * @param index
1818 * The index of the value to obtain. This value must lie within the range of
1819 * indexes as specified in xpc_array_set_value().
1820 *
1821 * @result
1822 * The object at the specified index within the array or NULL if the given
1823 * object was not an XPC array or if the the value at the specified index was
1824 * not a dictionary.
1825 *
1826 * @discussion
1827 * This method does not grant the caller a reference to the underlying object,
1828 * and thus the caller is not responsible for releasing the object.
1829 */
1830__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
1831XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
1832xpc_object_t _Nullable
1833xpc_array_get_dictionary(xpc_object_t xarray, size_t index);
1834
1835/*!
1836 * @function xpc_array_get_array
1837 *
1838 * @abstract
1839 * Returns the array at the specified index in the array.
1840 *
1841 * @param xarray
1842 * The array object which is to be examined.
1843 *
1844 * @param index
1845 * The index of the value to obtain. This value must lie within the range of
1846 * indexes as specified in xpc_array_set_value().
1847 *
1848 * @result
1849 * The object at the specified index within the array or NULL if the given
1850 * object was not an XPC array or if the the value at the specified index was
1851 * not an array.
1852 *
1853 * @discussion
1854 * This method does not grant the caller a reference to the underlying object,
1855 * and thus the caller is not responsible for releasing the object.
1856 */
1857__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
1858XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
1859xpc_object_t _Nullable
1860xpc_array_get_array(xpc_object_t xarray, size_t index);
1861
1862#pragma mark Dictionary
1863/*!
1864 * @typedef xpc_dictionary_applier_t
1865 * A block to be invoked for every key/value pair in the dictionary.
1866 *
1867 * @param key
1868 * The current key in the iteration.
1869 *
1870 * @param value
1871 * The current value in the iteration.
1872 *
1873 * @result
1874 * A Boolean indicating whether iteration should continue.
1875 */
1876#ifdef __BLOCKS__
1877typedef bool (^xpc_dictionary_applier_t)(const char * _Nonnull key,
1878 xpc_object_t _Nonnull value);
1879#endif // __BLOCKS__
1880
1881/*!
1882 * @function xpc_dictionary_create
1883 *
1884 * @abstract
1885 * Creates an XPC object representing a dictionary of XPC objects keyed to
1886 * C-strings.
1887 *
1888 * @param keys
1889 * An array of C-strings that are to be the keys for the values to be inserted.
1890 * Each element of this array is copied into the dictionary's internal storage.
1891 * Elements of this array may NOT be NULL.
1892 *
1893 * @param values
1894 * A C-array that is parallel to the array of keys, consisting of objects that
1895 * are to be inserted. Each element in this array is retained. Elements in this
1896 * array may be NULL.
1897 *
1898 * @param count
1899 * The number of key/value pairs in the given arrays. If the count is less than
1900 * the actual count of values, only that many key/value pairs will be inserted
1901 * into the dictionary.
1902 *
1903 * If the count is more than the the actual count of key/value pairs, the
1904 * behavior is undefined. If one array is NULL and the other is not, the
1905 * behavior is undefined. If both arrays are NULL and the count is non-0, the
1906 * behavior is undefined.
1907 *
1908 * @result
1909 * The new dictionary object.
1910 */
1911__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1912XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
1913xpc_object_t
1914xpc_dictionary_create(const char * _Nonnull const * _Nullable keys,
1915 const xpc_object_t _Nullable * _Nullable values, size_t count);
1916
1917/*!
1918 * @function xpc_dictionary_create_empty
1919 *
1920 * @abstract
1921 * Creates an XPC object representing a dictionary of XPC objects keyed to
1922 * C-strings.
1923 *
1924 * @result
1925 * The new dictionary object.
1926 *
1927 * @see
1928 * xpc_dictionary_create
1929 */
1930API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
1931XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
1932xpc_object_t
1933xpc_dictionary_create_empty(void);
1934
1935/*!
1936 * @function xpc_dictionary_create_reply
1937 *
1938 * @abstract
1939 * Creates a dictionary that is in reply to the given dictionary.
1940 *
1941 * @param original
1942 * The original dictionary that is to be replied to.
1943 *
1944 * @result
1945 * The new dictionary object. NULL if the object was not a dictionary with a
1946 * reply context.
1947 *
1948 * @discussion
1949 * After completing successfully on a dictionary, this method may not be called
1950 * again on that same dictionary. Attempts to do so will return NULL.
1951 *
1952 * When this dictionary is sent across the reply connection, the remote end's
1953 * reply handler is invoked.
1954 */
1955__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1956XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL
1957xpc_object_t _Nullable
1958xpc_dictionary_create_reply(xpc_object_t original);
1959
1960/*!
1961 * @function xpc_dictionary_set_value
1962 *
1963 * @abstract
1964 * Sets the value for the specified key to the specified object.
1965 *
1966 * @param xdict
1967 * The dictionary object which is to be manipulated.
1968 *
1969 * @param key
1970 * The key for which the value shall be set.
1971 *
1972 * @param value
1973 * The object to insert. The object is retained by the dictionary. If there
1974 * already exists a value for the specified key, the old value is released
1975 * and overwritten by the new value. This parameter may be NULL, in which case
1976 * the value corresponding to the specified key is deleted if present.
1977 */
1978__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
1979XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
1980void
1981xpc_dictionary_set_value(xpc_object_t xdict, const char *key,
1982 xpc_object_t _Nullable value);
1983
1984/*!
1985 * @function xpc_dictionary_get_value
1986 *
1987 * @abstract
1988 * Returns the value for the specified key.
1989 *
1990 * @param xdict
1991 * The dictionary object which is to be examined.
1992 *
1993 * @param key
1994 * The key whose value is to be obtained.
1995 *
1996 * @result
1997 * The object for the specified key within the dictionary. NULL if there is no
1998 * value associated with the specified key or if the given object was not an
1999 * XPC dictionary.
2000 *
2001 * @discussion
2002 * This method does not grant the caller a reference to the underlying object,
2003 * and thus the caller is not responsible for releasing the object.
2004 */
2005__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2006XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2
2007xpc_object_t _Nullable
2008xpc_dictionary_get_value(xpc_object_t xdict, const char *key);
2009
2010/*!
2011 * @function xpc_dictionary_get_count
2012 *
2013 * @abstract
2014 * Returns the number of values stored in the dictionary.
2015 *
2016 * @param xdict
2017 * The dictionary object which is to be examined.
2018 *
2019 * @result
2020 * The number of values stored in the dictionary or 0 if the given object was
2021 * not an XPC dictionary. Calling xpc_dictionary_set_value() with a non-NULL
2022 * value will increment the count. Calling xpc_dictionary_set_value() with a
2023 * NULL value will decrement the count.
2024 */
2025__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2026XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
2027size_t
2028xpc_dictionary_get_count(xpc_object_t xdict);
2029
2030/*!
2031 * @function xpc_dictionary_apply
2032 *
2033 * @abstract
2034 * Invokes the given block for every key/value pair in the dictionary.
2035 *
2036 * @param xdict
2037 * The dictionary object which is to be examined.
2038 *
2039 * @param applier
2040 * The block which this function applies to every key/value pair in the
2041 * dictionary.
2042 *
2043 * @result
2044 * A Boolean indicating whether iteration of the dictionary completed
2045 * successfully. Iteration will only fail if the applier block returns false.
2046 *
2047 * @discussion
2048 * You should not modify a dictionary's contents during iteration. There is no
2049 * guaranteed order of iteration over dictionaries.
2050 */
2051#ifdef __BLOCKS__
2052__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2053XPC_EXPORT XPC_NONNULL_ALL
2054bool
2055xpc_dictionary_apply(xpc_object_t xdict,
2056 XPC_NOESCAPE xpc_dictionary_applier_t applier);
2057#endif // __BLOCKS__
2058
2059/*!
2060 * @function xpc_dictionary_get_remote_connection
2061 *
2062 * @abstract
2063 * Returns the connection from which the dictionary was received.
2064 *
2065 * @param xdict
2066 * The dictionary object which is to be examined.
2067 *
2068 * @result
2069 * If the dictionary was received by a connection event handler or a dictionary
2070 * created through xpc_dictionary_create_reply(), a connection object over which
2071 * a reply message can be sent is returned. For any other dictionary, NULL is
2072 * returned.
2073 */
2074__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2075XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2076xpc_connection_t _Nullable
2077xpc_dictionary_get_remote_connection(xpc_object_t xdict);
2078
2079#pragma mark Dictionary Primitive Setters
2080/*!
2081 * @function xpc_dictionary_set_bool
2082 *
2083 * @abstract
2084 * Inserts a <code>bool</code> (primitive) value into a dictionary.
2085 *
2086 * @param xdict
2087 * The dictionary which is to be manipulated.
2088 *
2089 * @param key
2090 * The key for which the primitive value shall be set.
2091 *
2092 * @param value
2093 * The <code>bool</code> value to insert. After calling this method, the XPC
2094 * object corresponding to the primitive value inserted may be safely retrieved
2095 * with {@link xpc_dictionary_get_value()}.
2096 */
2097__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2098XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
2099void
2100xpc_dictionary_set_bool(xpc_object_t xdict, const char *key, bool value);
2101
2102/*!
2103 * @function xpc_dictionary_set_int64
2104 *
2105 * @abstract
2106 * Inserts an <code>int64_t</code> (primitive) value into a dictionary.
2107 *
2108 * @param xdict
2109 * The dictionary which is to be manipulated.
2110 *
2111 * @param key
2112 * The key for which the primitive value shall be set.
2113 *
2114 * @param value
2115 * The <code>int64_t</code> value to insert. After calling this method, the XPC
2116 * object corresponding to the primitive value inserted may be safely retrieved
2117 * with {@link xpc_dictionary_get_value()}.
2118 */
2119__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2120XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
2121void
2122xpc_dictionary_set_int64(xpc_object_t xdict, const char *key, int64_t value);
2123
2124/*!
2125 * @function xpc_dictionary_set_uint64
2126 *
2127 * @abstract
2128 * Inserts a <code>uint64_t</code> (primitive) value into a dictionary.
2129 *
2130 * @param xdict
2131 * The dictionary which is to be manipulated.
2132 *
2133 * @param key
2134 * The key for which the primitive value shall be set.
2135 *
2136 * @param value
2137 * The <code>uint64_t</code> value to insert. After calling this method, the XPC
2138 * object corresponding to the primitive value inserted may be safely retrieved
2139 * with {@link xpc_dictionary_get_value()}.
2140 */
2141__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2142XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
2143void
2144xpc_dictionary_set_uint64(xpc_object_t xdict, const char *key, uint64_t value);
2145
2146/*!
2147 * @function xpc_dictionary_set_double
2148 *
2149 * @abstract
2150 * Inserts a <code>double</code> (primitive) value into a dictionary.
2151 *
2152 * @param xdict
2153 * The dictionary which is to be manipulated.
2154 *
2155 * @param key
2156 * The key for which the primitive value shall be set.
2157 *
2158 * @param value
2159 * The <code>double</code> value to insert. After calling this method, the XPC
2160 * object corresponding to the primitive value inserted may be safely retrieved
2161 * with {@link xpc_dictionary_get_value()}.
2162 */
2163__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2164XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
2165void
2166xpc_dictionary_set_double(xpc_object_t xdict, const char *key, double value);
2167
2168/*!
2169 * @function xpc_dictionary_set_date
2170 *
2171 * @abstract
2172 * Inserts a date (primitive) value into a dictionary.
2173 *
2174 * @param xdict
2175 * The dictionary which is to be manipulated.
2176 *
2177 * @param key
2178 * The key for which the primitive value shall be set.
2179 *
2180 * @param value
2181 * The date value to insert. After calling this method, the XPC object
2182 * corresponding to the primitive value inserted may be safely retrieved with
2183 * {@link xpc_dictionary_get_value()}.
2184 */
2185__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2186XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
2187void
2188xpc_dictionary_set_date(xpc_object_t xdict, const char *key, int64_t value);
2189
2190/*!
2191 * @function xpc_dictionary_set_data
2192 *
2193 * @abstract
2194 * Inserts a raw data value into a dictionary.
2195 *
2196 * @param xdict
2197 * The dictionary which is to be manipulated.
2198 *
2199 * @param key
2200 * The key for which the primitive value shall be set.
2201 *
2202 * @param bytes
2203 * The bytes to insert. After calling this method, the XPC object corresponding
2204 * to the primitive value inserted may be safely retrieved with
2205 * {@link xpc_dictionary_get_value()}.
2206 *
2207 * @param length
2208 * The length of the data.
2209 */
2210__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2211XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
2212void
2213xpc_dictionary_set_data(xpc_object_t xdict, const char *key, const void *bytes,
2214 size_t length);
2215
2216/*!
2217 * @function xpc_dictionary_set_string
2218 *
2219 * @abstract
2220 * Inserts a C string value into a dictionary.
2221 *
2222 * @param xdict
2223 * The dictionary which is to be manipulated.
2224 *
2225 * @param key
2226 * The key for which the primitive value shall be set.
2227 *
2228 * @param string
2229 * The C string to insert. After calling this method, the XPC object
2230 * corresponding to the primitive value inserted may be safely retrieved with
2231 * {@link xpc_dictionary_get_value()}.
2232 */
2233__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2234XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
2235void
2236xpc_dictionary_set_string(xpc_object_t xdict, const char *key,
2237 const char *string);
2238
2239/*!
2240 * @function xpc_dictionary_set_uuid
2241 *
2242 * @abstract
2243 * Inserts a uuid (primitive) value into an array.
2244 *
2245 * @param xdict
2246 * The dictionary which is to be manipulated.
2247 *
2248 * @param key
2249 * The key for which the primitive value shall be set.
2250 *
2251 * @param uuid
2252 * The <code>uuid_t</code> value to insert. After calling this method, the XPC
2253 * object corresponding to the primitive value inserted may be safely retrieved
2254 * with {@link xpc_dictionary_get_value()}.
2255 */
2256__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2257XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
2258void
2259xpc_dictionary_set_uuid(xpc_object_t xdict, const char *key,
2260 const uuid_t XPC_NONNULL_ARRAY uuid);
2261
2262/*!
2263 * @function xpc_dictionary_set_fd
2264 *
2265 * @abstract
2266 * Inserts a file descriptor into a dictionary.
2267 *
2268 * @param xdict
2269 * The dictionary which is to be manipulated.
2270 *
2271 * @param key
2272 * The key for which the primitive value shall be set.
2273 *
2274 * @param fd
2275 * The file descriptor to insert. After calling this method, the XPC object
2276 * corresponding to the primitive value inserted may be safely retrieved
2277 * with {@link xpc_dictionary_get_value()}.
2278 */
2279__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2280XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
2281void
2282xpc_dictionary_set_fd(xpc_object_t xdict, const char *key, int fd);
2283
2284/*!
2285 * @function xpc_dictionary_set_connection
2286 *
2287 * @abstract
2288 * Inserts a connection into a dictionary.
2289 *
2290 * @param xdict
2291 * The dictionary which is to be manipulated.
2292 *
2293 * @param key
2294 * The key for which the primitive value shall be set.
2295 *
2296 * @param connection
2297 * The connection to insert. After calling this method, the XPC object
2298 * corresponding to the primitive value inserted may be safely retrieved
2299 * with {@link xpc_dictionary_get_value()}. The connection is NOT retained by
2300 * the dictionary.
2301 */
2302__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2303XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
2304void
2305xpc_dictionary_set_connection(xpc_object_t xdict, const char *key,
2306 xpc_connection_t connection);
2307
2308#pragma mark Dictionary Primitive Getters
2309/*!
2310 * @function xpc_dictionary_get_bool
2311 *
2312 * @abstract
2313 * Gets a <code>bool</code> primitive value from a dictionary directly.
2314 *
2315 * @param xdict
2316 * The dictionary object which is to be examined.
2317 *
2318 * @param key
2319 * The key whose value is to be obtained.
2320 *
2321 * @result
2322 * The underlying <code>bool</code> value for the specified key. false if the
2323 * the value for the specified key is not a Boolean value or if there is no
2324 * value for the specified key.
2325 */
2326__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2327XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2328bool
2329xpc_dictionary_get_bool(xpc_object_t xdict, const char *key);
2330
2331/*!
2332 * @function xpc_dictionary_get_int64
2333 *
2334 * @abstract
2335 * Gets an <code>int64</code> primitive value from a dictionary directly.
2336 *
2337 * @param xdict
2338 * The dictionary object which is to be examined.
2339 *
2340 * @param key
2341 * The key whose value is to be obtained.
2342 *
2343 * @result
2344 * The underlying <code>int64_t</code> value for the specified key. 0 if the
2345 * value for the specified key is not a signed integer value or if there is no
2346 * value for the specified key.
2347 */
2348__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2349XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2350int64_t
2351xpc_dictionary_get_int64(xpc_object_t xdict, const char *key);
2352
2353/*!
2354 * @function xpc_dictionary_get_uint64
2355 *
2356 * @abstract
2357 * Gets a <code>uint64</code> primitive value from a dictionary directly.
2358 *
2359 * @param xdict
2360 * The dictionary object which is to be examined.
2361 *
2362 * @param key
2363 * The key whose value is to be obtained.
2364 *
2365 * @result
2366 * The underlying <code>uint64_t</code> value for the specified key. 0 if the
2367 * value for the specified key is not an unsigned integer value or if there is
2368 * no value for the specified key.
2369 */
2370__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2371XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2372uint64_t
2373xpc_dictionary_get_uint64(xpc_object_t xdict, const char *key);
2374
2375/*!
2376 * @function xpc_dictionary_get_double
2377 *
2378 * @abstract
2379 * Gets a <code>double</code> primitive value from a dictionary directly.
2380 *
2381 * @param xdict
2382 * The dictionary object which is to be examined.
2383 *
2384 * @param key
2385 * The key whose value is to be obtained.
2386 *
2387 * @result
2388 * The underlying <code>double</code> value for the specified key. NAN if the
2389 * value for the specified key is not a floating point value or if there is no
2390 * value for the specified key.
2391 */
2392__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2393XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2394double
2395xpc_dictionary_get_double(xpc_object_t xdict, const char *key);
2396
2397/*!
2398 * @function xpc_dictionary_get_date
2399 *
2400 * @abstract
2401 * Gets a date value from a dictionary directly.
2402 *
2403 * @param xdict
2404 * The dictionary object which is to be examined.
2405 *
2406 * @param key
2407 * The key whose value is to be obtained.
2408 *
2409 * @result
2410 * The underlying date interval for the specified key. 0 if the value for the
2411 * specified key is not a date value or if there is no value for the specified
2412 * key.
2413 */
2414__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2415XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2416int64_t
2417xpc_dictionary_get_date(xpc_object_t xdict, const char *key);
2418
2419/*!
2420 * @function xpc_dictionary_get_data
2421 *
2422 * @abstract
2423 * Gets a raw data value from a dictionary directly.
2424 *
2425 * @param xdict
2426 * The dictionary object which is to be examined.
2427 *
2428 * @param key
2429 * The key whose value is to be obtained.
2430 *
2431 * @param length
2432 * For the data type, the third parameter, upon output, will contain the length
2433 * of the data corresponding to the specified key. May be NULL.
2434 *
2435 * @result
2436 * The underlying raw data for the specified key. NULL if the value for the
2437 * specified key is not a data value or if there is no value for the specified
2438 * key.
2439 */
2440__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2441XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
2442const void * _Nullable
2443xpc_dictionary_get_data(xpc_object_t xdict, const char *key,
2444 size_t * _Nullable length);
2445
2446/*!
2447 * @function xpc_dictionary_get_string
2448 *
2449 * @abstract
2450 * Gets a C string value from a dictionary directly.
2451 *
2452 * @param xdict
2453 * The dictionary object which is to be examined.
2454 *
2455 * @param key
2456 * The key whose value is to be obtained.
2457 *
2458 * @result
2459 * The underlying C string for the specified key. NULL if the value for the
2460 * specified key is not a C string value or if there is no value for the
2461 * specified key.
2462 */
2463__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2464XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2465const char * _Nullable
2466xpc_dictionary_get_string(xpc_object_t xdict, const char *key);
2467
2468/*!
2469 * @function xpc_dictionary_get_uuid
2470 *
2471 * @abstract
2472 * Gets a uuid value from a dictionary directly.
2473 *
2474 * @param xdict
2475 * The dictionary object which is to be examined.
2476 *
2477 * @param key
2478 * The key whose value is to be obtained.
2479 *
2480 * @result
2481 * The underlying <code>uuid_t</code> value for the specified key. NULL is the
2482 * value at the specified index is not a UUID value. The returned pointer may be
2483 * safely passed to the uuid(3) APIs.
2484 */
2485__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2486XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2
2487const uint8_t * _Nullable
2488xpc_dictionary_get_uuid(xpc_object_t xdict, const char *key);
2489
2490/*!
2491 * @function xpc_dictionary_dup_fd
2492 *
2493 * @abstract
2494 * Creates a file descriptor from a dictionary directly.
2495 *
2496 * @param xdict
2497 * The dictionary object which is to be examined.
2498 *
2499 * @param key
2500 * The key whose value is to be obtained.
2501 *
2502 * @result
2503 * A new file descriptor created from the value for the specified key. You are
2504 * responsible for close(2)ing this descriptor. -1 if the value for the
2505 * specified key is not a file descriptor value or if there is no value for the
2506 * specified key.
2507 */
2508__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2509XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2510int
2511xpc_dictionary_dup_fd(xpc_object_t xdict, const char *key);
2512
2513/*!
2514 * @function xpc_dictionary_create_connection
2515 *
2516 * @abstract
2517 * Creates a connection from a dictionary directly.
2518 *
2519 * @param xdict
2520 * The dictionary object which is to be examined.
2521 *
2522 * @param key
2523 * The key whose value is to be obtained.
2524 *
2525 * @result
2526 * A new connection created from the value for the specified key. You are
2527 * responsible for calling xpc_release() on the returned connection. NULL if the
2528 * value for the specified key is not an endpoint containing a connection or if
2529 * there is no value for the specified key. Each call to this method for the
2530 * same key in the same dictionary will yield a different connection. See
2531 * {@link xpc_connection_create_from_endpoint()} for discussion as to the
2532 * responsibilities when dealing with the returned connection.
2533 */
2534__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2535XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL
2536xpc_connection_t _Nullable
2537xpc_dictionary_create_connection(xpc_object_t xdict, const char *key);
2538
2539/*!
2540 * @function xpc_dictionary_get_dictionary
2541 *
2542 * @abstract
2543 * Returns the dictionary value for the specified key.
2544 *
2545 * @param xdict
2546 * The dictionary object which is to be examined.
2547 *
2548 * @param key
2549 * The key whose value is to be obtained.
2550 *
2551 * @result
2552 * The object for the specified key within the dictionary. NULL if there is no
2553 * value associated with the specified key, if the given object was not an
2554 * XPC dictionary, or if the object for the specified key is not a dictionary.
2555 *
2556 * @discussion
2557 * This method does not grant the caller a reference to the underlying object,
2558 * and thus the caller is not responsible for releasing the object.
2559 */
2560__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
2561XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2562xpc_object_t _Nullable
2563xpc_dictionary_get_dictionary(xpc_object_t xdict, const char *key);
2564
2565/*!
2566 * @function xpc_dictionary_get_array
2567 *
2568 * @abstract
2569 * Returns the array value for the specified key.
2570 *
2571 * @param xdict
2572 * The dictionary object which is to be examined.
2573 *
2574 * @param key
2575 * The key whose value is to be obtained.
2576 *
2577 * @result
2578 * The object for the specified key within the dictionary. NULL if there is no
2579 * value associated with the specified key, if the given object was not an
2580 * XPC dictionary, or if the object for the specified key is not an array.
2581 *
2582 * @discussion
2583 * This method does not grant the caller a reference to the underlying object,
2584 * and thus the caller is not responsible for releasing the object.
2585 */
2586__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
2587XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
2588xpc_object_t _Nullable
2589xpc_dictionary_get_array(xpc_object_t xdict, const char *key);
2590
2591#pragma mark Runtime
2592/*!
2593 * @function xpc_main
2594 * The springboard into the XPCService runtime. This function will set up your
2595 * service bundle's listener connection and manage it automatically. After this
2596 * initial setup, this function will, by default, call dispatch_main(). You may
2597 * override this behavior by setting the RunLoopType key in your XPC service
2598 * bundle's Info.plist under the XPCService dictionary.
2599 *
2600 * @param handler
2601 * The handler with which to accept new connections.
2602 */
2603__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2604XPC_EXPORT XPC_NORETURN XPC_NONNULL1
2605void
2606xpc_main(xpc_connection_handler_t handler);
2607
2608#pragma mark Transactions
2609/*!
2610 * @function xpc_transaction_begin
2611 * Informs the XPC runtime that a transaction has begun and that the service
2612 * should not exit due to inactivity.
2613 *
2614 * @discussion
2615 * A service with no outstanding transactions may automatically exit due to
2616 * inactivity as determined by the system.
2617 *
2618 * This function may be used to manually manage transactions in cases where
2619 * their automatic management (as described below) does not meet the needs of an
2620 * XPC service. This function also updates the transaction count used for sudden
2621 * termination, i.e. vproc_transaction_begin(), and these two interfaces may be
2622 * used in combination.
2623 *
2624 * The XPC runtime will automatically begin a transaction on behalf of a service
2625 * when a new message is received. If no reply message is expected, the
2626 * transaction is automatically ended when the connection event handler returns.
2627 * If a reply message is created, the transaction will end when the reply
2628 * message is sent or released. An XPC service may use xpc_transaction_begin()
2629 * and xpc_transaction_end() to inform the XPC runtime about activity that
2630 * occurs outside of this common pattern.
2631 *
2632 * On macOS, when the XPC runtime has determined that the service should exit,
2633 * the event handlers for all active peer connections will receive
2634 * {@link XPC_ERROR_TERMINATION_IMMINENT} as an indication that they should
2635 * unwind their existing transactions. After this error is delivered to a
2636 * connection's event handler, no more messages will be delivered to the
2637 * connection.
2638 */
2639__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2640XPC_TRANSACTION_DEPRECATED
2641XPC_EXPORT
2642void
2643xpc_transaction_begin(void);
2644
2645/*!
2646 * @function xpc_transaction_end
2647 * Informs the XPC runtime that a transaction has ended.
2648 *
2649 * @discussion
2650 * As described in {@link xpc_transaction_begin()}, this API may be used
2651 * interchangeably with vproc_transaction_end().
2652 *
2653 * See the discussion for {@link xpc_transaction_begin()} for details regarding
2654 * the XPC runtime's idle-exit policy.
2655 */
2656__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2657XPC_TRANSACTION_DEPRECATED
2658XPC_EXPORT
2659void
2660xpc_transaction_end(void);
2661
2662#pragma mark XPC Event Stream
2663/*!
2664 * @function xpc_set_event_stream_handler
2665 * Sets the event handler to invoke when streamed events are received.
2666 *
2667 * @param stream
2668 * The name of the event stream for which this handler will be invoked.
2669 *
2670 * @param targetq
2671 * The GCD queue to which the event handler block will be submitted. This
2672 * parameter may be NULL, in which case the connection's target queue will be
2673 * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT.
2674 *
2675 * @param handler
2676 * The event handler block. The event which this block receives as its first
2677 * parameter will always be a dictionary which contains the XPC_EVENT_KEY_NAME
2678 * key. The value for this key will be a string whose value is the name assigned
2679 * to the XPC event specified in the launchd.plist. Future keys may be added to
2680 * this dictionary.
2681 *
2682 * @discussion
2683 * Multiple calls to this function for the same event stream will result in
2684 * undefined behavior.
2685 *
2686 * There is no API to pause delivery of XPC events. If a process that
2687 * has set an XPC event handler exits, events may be dropped due to races
2688 * between the event handler running and the process exiting.
2689 */
2690#if __BLOCKS__
2691__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
2692XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
2693void
2694xpc_set_event_stream_handler(const char *stream,
2695 dispatch_queue_t _Nullable targetq, xpc_handler_t handler);
2696#endif // __BLOCKS__
2697
2698__END_DECLS
2699XPC_ASSUME_NONNULL_END
2700
2701#endif // __XPC_H__