diff --git a/lib/libc/include/x86_64-macos-gnu/AssertMacros.h b/lib/libc/include/x86_64-macos-gnu/AssertMacros.h new file mode 100644 index 0000000000..c338a0f9e4 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/AssertMacros.h @@ -0,0 +1,1441 @@ +/* + * Copyright (c) 2002-2017 by Apple Inc.. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + + +/* + File: AssertMacros.h + + Contains: This file defines structured error handling and assertion macros for + programming in C. Originally used in QuickDraw GX and later enhanced. + These macros are used throughout Apple's software. + + New code may not want to begin adopting these macros and instead use + existing language functionality. + + See "Living In an Exceptional World" by Sean Parent + (develop, The Apple Technical Journal, Issue 11, August/September 1992) + or + + for the methodology behind these error handling and assertion macros. + + Bugs?: For bug reports, consult the following page on + the World Wide Web: + + http://developer.apple.com/bugreporter/ +*/ +#ifndef __ASSERTMACROS__ +#define __ASSERTMACROS__ + +#ifdef DEBUG_ASSERT_CONFIG_INCLUDE + #include DEBUG_ASSERT_CONFIG_INCLUDE +#endif + +/* + * Macro overview: + * + * check(assertion) + * In production builds, pre-processed away + * In debug builds, if assertion evaluates to false, calls DEBUG_ASSERT_MESSAGE + * + * verify(assertion) + * In production builds, evaluates assertion and does nothing + * In debug builds, if assertion evaluates to false, calls DEBUG_ASSERT_MESSAGE + * + * require(assertion, exceptionLabel) + * In production builds, if the assertion expression evaluates to false, goto exceptionLabel + * In debug builds, if the assertion expression evaluates to false, calls DEBUG_ASSERT_MESSAGE + * and jumps to exceptionLabel + * + * In addition the following suffixes are available: + * + * _noerr Adds "!= 0" to assertion. Useful for asserting and OSStatus or OSErr is noErr (zero) + * _action Adds statement to be executued if assertion fails + * _quiet Suppress call to DEBUG_ASSERT_MESSAGE + * _string Allows you to add explanitory message to DEBUG_ASSERT_MESSAGE + * + * For instance, require_noerr_string(resultCode, label, msg) will do nothing if + * resultCode is zero, otherwise it will call DEBUG_ASSERT_MESSAGE with msg + * and jump to label. + * + * Configuration: + * + * By default all macros generate "production code" (i.e non-debug). If + * DEBUG_ASSERT_PRODUCTION_CODE is defined to zero or DEBUG is defined to non-zero + * while this header is included, the macros will generated debug code. + * + * If DEBUG_ASSERT_COMPONENT_NAME_STRING is defined, all debug messages will + * be prefixed with it. + * + * By default, all messages write to stderr. If you would like to write a custom + * error message formater, defined DEBUG_ASSERT_MESSAGE to your function name. + * + * Each individual macro will only be defined if it is not already defined, so + * you can redefine their behavior singly by providing your own definition before + * this file is included. + * + * If you define __ASSERTMACROS__ before this file is included, then nothing in + * this file will take effect. + * + * Prior to Mac OS X 10.6 the macro names used in this file conflicted with some + * user code, including libraries in boost and the proposed C++ standards efforts, + * and there was no way for a client of this header to resolve this conflict. Because + * of this, most of the macros have been changed so that they are prefixed with + * __ and contain at least one capital letter, which should alleviate the current + * and future conflicts. However, to allow current sources to continue to compile, + * compatibility macros are defined at the end with the old names. A tops script + * at the end of this file will convert all of the old macro names used in a directory + * to the new names. Clients are recommended to migrate over to these new macros as + * they update their sources because a future release of Mac OS X will remove the + * old macro definitions ( without the double-underscore prefix ). Clients who + * want to compile without the old macro definitions can define the macro + * __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES to 0 before this file is + * included. + */ + + +/* + * Before including this file, #define DEBUG_ASSERT_COMPONENT_NAME_STRING to + * a C-string containing the name of your client. This string will be passed to + * the DEBUG_ASSERT_MESSAGE macro for inclusion in any assertion messages. + * + * If you do not define DEBUG_ASSERT_COMPONENT_NAME_STRING, the default + * DEBUG_ASSERT_COMPONENT_NAME_STRING value, an empty string, will be used by + * the assertion macros. + */ +#ifndef DEBUG_ASSERT_COMPONENT_NAME_STRING + #define DEBUG_ASSERT_COMPONENT_NAME_STRING "" +#endif + + +/* + * To activate the additional assertion code and messages for non-production builds, + * #define DEBUG_ASSERT_PRODUCTION_CODE to zero before including this file. + * + * If you do not define DEBUG_ASSERT_PRODUCTION_CODE, the default value 1 will be used + * (production code = no assertion code and no messages). + */ +#ifndef DEBUG_ASSERT_PRODUCTION_CODE + #define DEBUG_ASSERT_PRODUCTION_CODE !DEBUG +#endif + + +/* + * DEBUG_ASSERT_MESSAGE(component, assertion, label, error, file, line, errorCode) + * + * Summary: + * All assertion messages are routed through this macro. If you wish to use your + * own routine to display assertion messages, you can override DEBUG_ASSERT_MESSAGE + * by #defining DEBUG_ASSERT_MESSAGE before including this file. + * + * Parameters: + * + * componentNameString: + * A pointer to a string constant containing the name of the + * component this code is part of. This must be a string constant + * (and not a string variable or NULL) because the preprocessor + * concatenates it with other string constants. + * + * assertionString: + * A pointer to a string constant containing the assertion. + * This must be a string constant (and not a string variable or + * NULL) because the Preprocessor concatenates it with other + * string constants. + * + * exceptionLabelString: + * A pointer to a string containing the exceptionLabel, or NULL. + * + * errorString: + * A pointer to the error string, or NULL. DEBUG_ASSERT_MESSAGE macros + * must not attempt to concatenate this string with constant + * character strings. + * + * fileName: + * A pointer to the fileName or pathname (generated by the + * preprocessor __FILE__ identifier), or NULL. + * + * lineNumber: + * The line number in the file (generated by the preprocessor + * __LINE__ identifier), or 0 (zero). + * + * errorCode: + * A value associated with the assertion, or 0. + * + * Here is an example of a DEBUG_ASSERT_MESSAGE macro and a routine which displays + * assertion messsages: + * + * #define DEBUG_ASSERT_COMPONENT_NAME_STRING "MyCoolProgram" + * + * #define DEBUG_ASSERT_MESSAGE(componentNameString, assertionString, \ + * exceptionLabelString, errorString, fileName, lineNumber, errorCode) \ + * MyProgramDebugAssert(componentNameString, assertionString, \ + * exceptionLabelString, errorString, fileName, lineNumber, errorCode) + * + * static void + * MyProgramDebugAssert(const char *componentNameString, const char *assertionString, + * const char *exceptionLabelString, const char *errorString, + * const char *fileName, long lineNumber, int errorCode) + * { + * if ( (assertionString != NULL) && (*assertionString != '\0') ) + * fprintf(stderr, "Assertion failed: %s: %s\n", componentNameString, assertionString); + * else + * fprintf(stderr, "Check failed: %s:\n", componentNameString); + * if ( exceptionLabelString != NULL ) + * fprintf(stderr, " %s\n", exceptionLabelString); + * if ( errorString != NULL ) + * fprintf(stderr, " %s\n", errorString); + * if ( fileName != NULL ) + * fprintf(stderr, " file: %s\n", fileName); + * if ( lineNumber != 0 ) + * fprintf(stderr, " line: %ld\n", lineNumber); + * if ( errorCode != 0 ) + * fprintf(stderr, " error: %d\n", errorCode); + * } + * + * If you do not define DEBUG_ASSERT_MESSAGE, a simple printf to stderr will be used. + */ +#ifndef DEBUG_ASSERT_MESSAGE + #ifdef KERNEL + #include + #define DEBUG_ASSERT_MESSAGE(name, assertion, label, message, file, line, value) \ + printf( "AssertMacros: %s, %s file: %s, line: %d, value: %ld\n", assertion, (message!=0) ? message : "", file, line, (long) (value)); + #else + #include + #define DEBUG_ASSERT_MESSAGE(name, assertion, label, message, file, line, value) \ + fprintf(stderr, "AssertMacros: %s, %s file: %s, line: %d, value: %ld\n", assertion, (message!=0) ? message : "", file, line, (long) (value)); + #endif +#endif + + + + + +/* + * __Debug_String(message) + * + * Summary: + * Production builds: does nothing and produces no code. + * + * Non-production builds: call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * message: + * The C string to display. + * + */ +#ifndef __Debug_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Debug_String(message) + #else + #define __Debug_String(message) \ + do \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + "", \ + 0, \ + message, \ + __FILE__, \ + __LINE__, \ + 0); \ + } while ( 0 ) + #endif +#endif + +/* + * __Check(assertion) + * + * Summary: + * Production builds: does nothing and produces no code. + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * assertion: + * The assertion expression. + */ +#ifndef __Check + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Check(assertion) + #else + #define __Check(assertion) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, 0, 0, __FILE__, __LINE__, 0 ); \ + } \ + } while ( 0 ) + #endif +#endif + +#ifndef __nCheck + #define __nCheck(assertion) __Check(!(assertion)) +#endif + +/* + * __Check_String(assertion, message) + * + * Summary: + * Production builds: does nothing and produces no code. + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * message: + * The C string to display. + */ +#ifndef __Check_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Check_String(assertion, message) + #else + #define __Check_String(assertion, message) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, 0, message, __FILE__, __LINE__, 0 ); \ + } \ + } while ( 0 ) + #endif +#endif + +#ifndef __nCheck_String + #define __nCheck_String(assertion, message) __Check_String(!(assertion), message) +#endif + +/* + * __Check_noErr(errorCode) + * + * Summary: + * Production builds: does nothing and produces no code. + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * errorCode: + * The errorCode expression to compare with 0. + */ +#ifndef __Check_noErr + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Check_noErr(errorCode) + #else + #define __Check_noErr(errorCode) \ + do \ + { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \ + } \ + } while ( 0 ) + #endif +#endif + +/* + * __Check_noErr_String(errorCode, message) + * + * Summary: + * Production builds: check_noerr_string() does nothing and produces + * no code. + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * errorCode: + * The errorCode expression to compare to 0. + * + * message: + * The C string to display. + */ +#ifndef __Check_noErr_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Check_noErr_String(errorCode, message) + #else + #define __Check_noErr_String(errorCode, message) \ + do \ + { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", 0, message, __FILE__, __LINE__, evalOnceErrorCode ); \ + } \ + } while ( 0 ) + #endif +#endif + +/* + * __Verify(assertion) + * + * Summary: + * Production builds: evaluate the assertion expression, but ignore + * the result. + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * assertion: + * The assertion expression. + */ +#ifndef __Verify + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Verify(assertion) \ + do \ + { \ + if ( !(assertion) ) \ + { \ + } \ + } while ( 0 ) + #else + #define __Verify(assertion) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, 0, 0, __FILE__, __LINE__, 0 ); \ + } \ + } while ( 0 ) + #endif +#endif + +#ifndef __nVerify + #define __nVerify(assertion) __Verify(!(assertion)) +#endif + +/* + * __Verify_String(assertion, message) + * + * Summary: + * Production builds: evaluate the assertion expression, but ignore + * the result. + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * message: + * The C string to display. + */ +#ifndef __Verify_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Verify_String(assertion, message) \ + do \ + { \ + if ( !(assertion) ) \ + { \ + } \ + } while ( 0 ) + #else + #define __Verify_String(assertion, message) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, 0, message, __FILE__, __LINE__, 0 ); \ + } \ + } while ( 0 ) + #endif +#endif + +#ifndef __nVerify_String + #define __nVerify_String(assertion, message) __Verify_String(!(assertion), message) +#endif + +/* + * __Verify_noErr(errorCode) + * + * Summary: + * Production builds: evaluate the errorCode expression, but ignore + * the result. + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + */ +#ifndef __Verify_noErr + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Verify_noErr(errorCode) \ + do \ + { \ + if ( 0 != (errorCode) ) \ + { \ + } \ + } while ( 0 ) + #else + #define __Verify_noErr(errorCode) \ + do \ + { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \ + } \ + } while ( 0 ) + #endif +#endif + +/* + * __Verify_noErr_String(errorCode, message) + * + * Summary: + * Production builds: evaluate the errorCode expression, but ignore + * the result. + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE. + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + * + * message: + * The C string to display. + */ +#ifndef __Verify_noErr_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Verify_noErr_String(errorCode, message) \ + do \ + { \ + if ( 0 != (errorCode) ) \ + { \ + } \ + } while ( 0 ) + #else + #define __Verify_noErr_String(errorCode, message) \ + do \ + { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", 0, message, __FILE__, __LINE__, evalOnceErrorCode ); \ + } \ + } while ( 0 ) + #endif +#endif + +/* + * __Verify_noErr_Action(errorCode, action) + * + * Summary: + * Production builds: if the errorCode expression does not equal 0 (noErr), + * execute the action statement or compound statement (block). + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE and then execute the action statement or compound + * statement (block). + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + * + * action: + * The statement or compound statement (block). + */ +#ifndef __Verify_noErr_Action + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Verify_noErr_Action(errorCode, action) \ + if ( 0 != (errorCode) ) { \ + action; \ + } \ + else do {} while (0) + #else + #define __Verify_noErr_Action(errorCode, action) \ + do { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \ + action; \ + } \ + } while (0) + #endif +#endif + +/* + * __Verify_Action(assertion, action) + * + * Summary: + * Production builds: if the assertion expression evaluates to false, + * then execute the action statement or compound statement (block). + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE and then execute the action statement or compound + * statement (block). + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * action: + * The statement or compound statement (block). + */ +#ifndef __Verify_Action + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Verify_Action(assertion, action) \ + if ( __builtin_expect(!(assertion), 0) ) { \ + action; \ + } \ + else do {} while (0) + #else + #define __Verify_Action(assertion, action) \ + if ( __builtin_expect(!(assertion), 0) ) { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, 0, 0, __FILE__, __LINE__, 0 ); \ + action; \ + } \ + else do {} while (0) + #endif +#endif + +/* + * __Require(assertion, exceptionLabel) + * + * Summary: + * Production builds: if the assertion expression evaluates to false, + * goto exceptionLabel. + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE and then goto exceptionLabel. + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * exceptionLabel: + * The label. + */ +#ifndef __Require + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Require(assertion, exceptionLabel) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #else + #define __Require(assertion, exceptionLabel) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, #exceptionLabel, 0, __FILE__, __LINE__, 0); \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #endif +#endif + +#ifndef __nRequire + #define __nRequire(assertion, exceptionLabel) __Require(!(assertion), exceptionLabel) +#endif + +/* + * __Require_Action(assertion, exceptionLabel, action) + * + * Summary: + * Production builds: if the assertion expression evaluates to false, + * execute the action statement or compound statement (block) and then + * goto exceptionLabel. + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE, execute the action statement or compound + * statement (block), and then goto exceptionLabel. + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * exceptionLabel: + * The label. + * + * action: + * The statement or compound statement (block). + */ +#ifndef __Require_Action + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Require_Action(assertion, exceptionLabel, action) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #else + #define __Require_Action(assertion, exceptionLabel, action) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, #exceptionLabel, 0, __FILE__, __LINE__, 0); \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #endif +#endif + +#ifndef __nRequire_Action + #define __nRequire_Action(assertion, exceptionLabel, action) \ + __Require_Action(!(assertion), exceptionLabel, action) +#endif + +/* + * __Require_Quiet(assertion, exceptionLabel) + * + * Summary: + * If the assertion expression evaluates to false, goto exceptionLabel. + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * exceptionLabel: + * The label. + */ +#ifndef __Require_Quiet + #define __Require_Quiet(assertion, exceptionLabel) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + goto exceptionLabel; \ + } \ + } while ( 0 ) +#endif + +#ifndef __nRequire_Quiet + #define __nRequire_Quiet(assertion, exceptionLabel) __Require_Quiet(!(assertion), exceptionLabel) +#endif + +/* + * __Require_Action_Quiet(assertion, exceptionLabel, action) + * + * Summary: + * If the assertion expression evaluates to false, execute the action + * statement or compound statement (block), and goto exceptionLabel. + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * exceptionLabel: + * The label. + * + * action: + * The statement or compound statement (block). + */ +#ifndef __Require_Action_Quiet + #define __Require_Action_Quiet(assertion, exceptionLabel, action) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) +#endif + +#ifndef __nRequire_Action_Quiet + #define __nRequire_Action_Quiet(assertion, exceptionLabel, action) \ + __Require_Action_Quiet(!(assertion), exceptionLabel, action) +#endif + +/* + * __Require_String(assertion, exceptionLabel, message) + * + * Summary: + * Production builds: if the assertion expression evaluates to false, + * goto exceptionLabel. + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE, and then goto exceptionLabel. + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * exceptionLabel: + * The label. + * + * message: + * The C string to display. + */ +#ifndef __Require_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Require_String(assertion, exceptionLabel, message) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #else + #define __Require_String(assertion, exceptionLabel, message) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, #exceptionLabel, message, __FILE__, __LINE__, 0); \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #endif +#endif + +#ifndef __nRequire_String + #define __nRequire_String(assertion, exceptionLabel, string) \ + __Require_String(!(assertion), exceptionLabel, string) +#endif + +/* + * __Require_Action_String(assertion, exceptionLabel, action, message) + * + * Summary: + * Production builds: if the assertion expression evaluates to false, + * execute the action statement or compound statement (block), and then + * goto exceptionLabel. + * + * Non-production builds: if the assertion expression evaluates to false, + * call DEBUG_ASSERT_MESSAGE, execute the action statement or compound + * statement (block), and then goto exceptionLabel. + * + * Parameters: + * + * assertion: + * The assertion expression. + * + * exceptionLabel: + * The label. + * + * action: + * The statement or compound statement (block). + * + * message: + * The C string to display. + */ +#ifndef __Require_Action_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Require_Action_String(assertion, exceptionLabel, action, message) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #else + #define __Require_Action_String(assertion, exceptionLabel, action, message) \ + do \ + { \ + if ( __builtin_expect(!(assertion), 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #assertion, #exceptionLabel, message, __FILE__, __LINE__, 0); \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #endif +#endif + +#ifndef __nRequire_Action_String + #define __nRequire_Action_String(assertion, exceptionLabel, action, message) \ + __Require_Action_String(!(assertion), exceptionLabel, action, message) +#endif + +/* + * __Require_noErr(errorCode, exceptionLabel) + * + * Summary: + * Production builds: if the errorCode expression does not equal 0 (noErr), + * goto exceptionLabel. + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE and then goto exceptionLabel. + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + * + * exceptionLabel: + * The label. + */ +#ifndef __Require_noErr + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Require_noErr(errorCode, exceptionLabel) \ + do \ + { \ + if ( __builtin_expect(0 != (errorCode), 0) ) \ + { \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #else + #define __Require_noErr(errorCode, exceptionLabel) \ + do \ + { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", #exceptionLabel, 0, __FILE__, __LINE__, evalOnceErrorCode); \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #endif +#endif + +/* + * __Require_noErr_Action(errorCode, exceptionLabel, action) + * + * Summary: + * Production builds: if the errorCode expression does not equal 0 (noErr), + * execute the action statement or compound statement (block) and + * goto exceptionLabel. + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE, execute the action statement or + * compound statement (block), and then goto exceptionLabel. + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + * + * exceptionLabel: + * The label. + * + * action: + * The statement or compound statement (block). + */ +#ifndef __Require_noErr_Action + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Require_noErr_Action(errorCode, exceptionLabel, action) \ + do \ + { \ + if ( __builtin_expect(0 != (errorCode), 0) ) \ + { \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #else + #define __Require_noErr_Action(errorCode, exceptionLabel, action) \ + do \ + { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", #exceptionLabel, 0, __FILE__, __LINE__, evalOnceErrorCode); \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #endif +#endif + +/* + * __Require_noErr_Quiet(errorCode, exceptionLabel) + * + * Summary: + * If the errorCode expression does not equal 0 (noErr), + * goto exceptionLabel. + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + * + * exceptionLabel: + * The label. + */ +#ifndef __Require_noErr_Quiet + #define __Require_noErr_Quiet(errorCode, exceptionLabel) \ + do \ + { \ + if ( __builtin_expect(0 != (errorCode), 0) ) \ + { \ + goto exceptionLabel; \ + } \ + } while ( 0 ) +#endif + +/* + * __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action) + * + * Summary: + * If the errorCode expression does not equal 0 (noErr), + * execute the action statement or compound statement (block) and + * goto exceptionLabel. + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + * + * exceptionLabel: + * The label. + * + * action: + * The statement or compound statement (block). + */ +#ifndef __Require_noErr_Action_Quiet + #define __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action) \ + do \ + { \ + if ( __builtin_expect(0 != (errorCode), 0) ) \ + { \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) +#endif + +/* + * __Require_noErr_String(errorCode, exceptionLabel, message) + * + * Summary: + * Production builds: if the errorCode expression does not equal 0 (noErr), + * goto exceptionLabel. + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE, and then goto exceptionLabel. + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + * + * exceptionLabel: + * The label. + * + * message: + * The C string to display. + */ +#ifndef __Require_noErr_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Require_noErr_String(errorCode, exceptionLabel, message) \ + do \ + { \ + if ( __builtin_expect(0 != (errorCode), 0) ) \ + { \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #else + #define __Require_noErr_String(errorCode, exceptionLabel, message) \ + do \ + { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", #exceptionLabel, message, __FILE__, __LINE__, evalOnceErrorCode); \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #endif +#endif + +/* + * __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) + * + * Summary: + * Production builds: if the errorCode expression does not equal 0 (noErr), + * execute the action statement or compound statement (block) and + * goto exceptionLabel. + * + * Non-production builds: if the errorCode expression does not equal 0 (noErr), + * call DEBUG_ASSERT_MESSAGE, execute the action statement or compound + * statement (block), and then goto exceptionLabel. + * + * Parameters: + * + * errorCode: + * The expression to compare to 0. + * + * exceptionLabel: + * The label. + * + * action: + * The statement or compound statement (block). + * + * message: + * The C string to display. + */ +#ifndef __Require_noErr_Action_String + #if DEBUG_ASSERT_PRODUCTION_CODE + #define __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) \ + do \ + { \ + if ( __builtin_expect(0 != (errorCode), 0) ) \ + { \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #else + #define __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) \ + do \ + { \ + long evalOnceErrorCode = (errorCode); \ + if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) \ + { \ + DEBUG_ASSERT_MESSAGE( \ + DEBUG_ASSERT_COMPONENT_NAME_STRING, \ + #errorCode " == 0 ", #exceptionLabel, message, __FILE__, __LINE__, evalOnceErrorCode); \ + { \ + action; \ + } \ + goto exceptionLabel; \ + } \ + } while ( 0 ) + #endif +#endif + +/* + * __Check_Compile_Time(expr) + * + * Summary: + * any build: if the expression is not true, generated a compile time error. + * + * Parameters: + * + * expr: + * The compile time expression that should evaluate to non-zero. + * + * Discussion: + * This declares an array with a size that is determined by a compile-time expression. + * If false, it declares a negatively sized array, which generates a compile-time error. + * + * Examples: + * __Check_Compile_Time( sizeof( int ) == 4 ); + * __Check_Compile_Time( offsetof( MyStruct, myField ) == 4 ); + * __Check_Compile_Time( ( kMyBufferSize % 512 ) == 0 ); + * + * Note: This only works with compile-time expressions. + * Note: This only works in places where extern declarations are allowed (e.g. global scope). + */ +#ifndef __Check_Compile_Time + #ifdef __GNUC__ + #if (__cplusplus >= 201103L) + #define __Check_Compile_Time( expr ) static_assert( expr , "__Check_Compile_Time") + #elif (__STDC_VERSION__ >= 201112L) + #define __Check_Compile_Time( expr ) _Static_assert( expr , "__Check_Compile_Time") + #else + #define __Check_Compile_Time( expr ) \ + extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ] __attribute__( ( unused ) ) + #endif + #else + #define __Check_Compile_Time( expr ) \ + extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ] + #endif +#endif + +/* + * For time immemorial, Mac OS X has defined version of most of these macros without the __ prefix, which + * could collide with similarly named functions or macros in user code, including new functionality in + * Boost and the C++ standard library. + * + * macOS High Sierra and iOS 11 will now require that clients move to the new macros as defined above. + * + * If you would like to enable the macros for use within your own project, you can define the + * __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES macro via an Xcode Build Configuration. + * See "Add a build configuration (xcconfig) file" in Xcode Help. + * + * To aid users of these macros in converting their sources, the following tops script will convert usages + * of the old macros into the new equivalents. To do so, in Terminal go into the directory containing the + * sources to be converted and run this command. + * + find -E . -regex '.*\.(c|cc|cp|cpp|m|mm|h)' -print0 | xargs -0 tops -verbose \ + replace "check()" with "__Check()" \ + replace "check_noerr()" with "__Check_noErr()" \ + replace "check_noerr_string()" with "__Check_noErr_String()" \ + replace "check_string()" with "__Check_String()" \ + replace "require()" with "__Require()" \ + replace "require_action()" with "__Require_Action()" \ + replace "require_action_string()" with "__Require_Action_String()" \ + replace "require_noerr()" with "__Require_noErr()" \ + replace "require_noerr_action()" with "__Require_noErr_Action()" \ + replace "require_noerr_action_string()" with "__Require_noErr_Action_String()" \ + replace "require_noerr_string()" with "__Require_noErr_String()" \ + replace "require_string()" with "__Require_String()" \ + replace "verify()" with "__Verify()" \ + replace "verify_action()" with "__Verify_Action()" \ + replace "verify_noerr()" with "__Verify_noErr()" \ + replace "verify_noerr_action()" with "__Verify_noErr_Action()" \ + replace "verify_noerr_string()" with "__Verify_noErr_String()" \ + replace "verify_string()" with "__Verify_String()" \ + replace "ncheck()" with "__nCheck()" \ + replace "ncheck_string()" with "__nCheck_String()" \ + replace "nrequire()" with "__nRequire()" \ + replace "nrequire_action()" with "__nRequire_Action()" \ + replace "nrequire_action_quiet()" with "__nRequire_Action_Quiet()" \ + replace "nrequire_action_string()" with "__nRequire_Action_String()" \ + replace "nrequire_quiet()" with "__nRequire_Quiet()" \ + replace "nrequire_string()" with "__nRequire_String()" \ + replace "nverify()" with "__nVerify()" \ + replace "nverify_string()" with "__nVerify_String()" \ + replace "require_action_quiet()" with "__Require_Action_Quiet()" \ + replace "require_noerr_action_quiet()" with "__Require_noErr_Action_Quiet()" \ + replace "require_noerr_quiet()" with "__Require_noErr_Quiet()" \ + replace "require_quiet()" with "__Require_Quiet()" \ + replace "check_compile_time()" with "__Check_Compile_Time()" \ + replace "debug_string()" with "__Debug_String()" + * + */ + +#ifndef __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES + #if __has_include() + #include + #else + /* In macOS High Sierra and iOS 11, if we haven't set this yet, it now defaults to off. */ + #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 + #endif +#endif + +#if __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES + + #ifndef check + #define check(assertion) __Check(assertion) + #endif + + #ifndef check_noerr + #define check_noerr(errorCode) __Check_noErr(errorCode) + #endif + + #ifndef check_noerr_string + #define check_noerr_string(errorCode, message) __Check_noErr_String(errorCode, message) + #endif + + #ifndef check_string + #define check_string(assertion, message) __Check_String(assertion, message) + #endif + + #ifndef require + #define require(assertion, exceptionLabel) __Require(assertion, exceptionLabel) + #endif + + #ifndef require_action + #define require_action(assertion, exceptionLabel, action) __Require_Action(assertion, exceptionLabel, action) + #endif + + #ifndef require_action_string + #define require_action_string(assertion, exceptionLabel, action, message) __Require_Action_String(assertion, exceptionLabel, action, message) + #endif + + #ifndef require_noerr + #define require_noerr(errorCode, exceptionLabel) __Require_noErr(errorCode, exceptionLabel) + #endif + + #ifndef require_noerr_action + #define require_noerr_action(errorCode, exceptionLabel, action) __Require_noErr_Action(errorCode, exceptionLabel, action) + #endif + + #ifndef require_noerr_action_string + #define require_noerr_action_string(errorCode, exceptionLabel, action, message) __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) + #endif + + #ifndef require_noerr_string + #define require_noerr_string(errorCode, exceptionLabel, message) __Require_noErr_String(errorCode, exceptionLabel, message) + #endif + + #ifndef require_string + #define require_string(assertion, exceptionLabel, message) __Require_String(assertion, exceptionLabel, message) + #endif + + #ifndef verify + #define verify(assertion) __Verify(assertion) + #endif + + #ifndef verify_action + #define verify_action(assertion, action) __Verify_Action(assertion, action) + #endif + + #ifndef verify_noerr + #define verify_noerr(errorCode) __Verify_noErr(errorCode) + #endif + + #ifndef verify_noerr_action + #define verify_noerr_action(errorCode, action) __Verify_noErr_Action(errorCode, action) + #endif + + #ifndef verify_noerr_string + #define verify_noerr_string(errorCode, message) __Verify_noErr_String(errorCode, message) + #endif + + #ifndef verify_string + #define verify_string(assertion, message) __Verify_String(assertion, message) + #endif + + #ifndef ncheck + #define ncheck(assertion) __nCheck(assertion) + #endif + + #ifndef ncheck_string + #define ncheck_string(assertion, message) __nCheck_String(assertion, message) + #endif + + #ifndef nrequire + #define nrequire(assertion, exceptionLabel) __nRequire(assertion, exceptionLabel) + #endif + + #ifndef nrequire_action + #define nrequire_action(assertion, exceptionLabel, action) __nRequire_Action(assertion, exceptionLabel, action) + #endif + + #ifndef nrequire_action_quiet + #define nrequire_action_quiet(assertion, exceptionLabel, action) __nRequire_Action_Quiet(assertion, exceptionLabel, action) + #endif + + #ifndef nrequire_action_string + #define nrequire_action_string(assertion, exceptionLabel, action, message) __nRequire_Action_String(assertion, exceptionLabel, action, message) + #endif + + #ifndef nrequire_quiet + #define nrequire_quiet(assertion, exceptionLabel) __nRequire_Quiet(assertion, exceptionLabel) + #endif + + #ifndef nrequire_string + #define nrequire_string(assertion, exceptionLabel, string) __nRequire_String(assertion, exceptionLabel, string) + #endif + + #ifndef nverify + #define nverify(assertion) __nVerify(assertion) + #endif + + #ifndef nverify_string + #define nverify_string(assertion, message) __nVerify_String(assertion, message) + #endif + + #ifndef require_action_quiet + #define require_action_quiet(assertion, exceptionLabel, action) __Require_Action_Quiet(assertion, exceptionLabel, action) + #endif + + #ifndef require_noerr_action_quiet + #define require_noerr_action_quiet(errorCode, exceptionLabel, action) __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action) + #endif + + #ifndef require_noerr_quiet + #define require_noerr_quiet(errorCode, exceptionLabel) __Require_noErr_Quiet(errorCode, exceptionLabel) + #endif + + #ifndef require_quiet + #define require_quiet(assertion, exceptionLabel) __Require_Quiet(assertion, exceptionLabel) + #endif + + #ifndef check_compile_time + #define check_compile_time( expr ) __Check_Compile_Time( expr ) + #endif + + #ifndef debug_string + #define debug_string(message) __Debug_String(message) + #endif + +#endif /* ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES */ + + +#endif /* __ASSERTMACROS__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/Availability.h b/lib/libc/include/x86_64-macos-gnu/Availability.h index c81a1940fa..d57c1ce942 100644 --- a/lib/libc/include/x86_64-macos-gnu/Availability.h +++ b/lib/libc/include/x86_64-macos-gnu/Availability.h @@ -132,130 +132,7 @@ #define __API_TO_BE_DEPRECATED 100000 #endif -#ifndef __MAC_10_0 -#define __MAC_10_0 1000 -#define __MAC_10_1 1010 -#define __MAC_10_2 1020 -#define __MAC_10_3 1030 -#define __MAC_10_4 1040 -#define __MAC_10_5 1050 -#define __MAC_10_6 1060 -#define __MAC_10_7 1070 -#define __MAC_10_8 1080 -#define __MAC_10_9 1090 -#define __MAC_10_10 101000 -#define __MAC_10_10_2 101002 -#define __MAC_10_10_3 101003 -#define __MAC_10_11 101100 -#define __MAC_10_11_2 101102 -#define __MAC_10_11_3 101103 -#define __MAC_10_11_4 101104 -#define __MAC_10_12 101200 -#define __MAC_10_12_1 101201 -#define __MAC_10_12_2 101202 -#define __MAC_10_12_4 101204 -#define __MAC_10_13 101300 -#define __MAC_10_13_1 101301 -#define __MAC_10_13_2 101302 -#define __MAC_10_13_4 101304 -#define __MAC_10_14 101400 -#define __MAC_10_14_1 101401 -#define __MAC_10_14_4 101404 -#define __MAC_10_15 101500 -#define __MAC_10_15_1 101501 -#define __MAC_10_15_4 101504 -/* __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */ - -#define __IPHONE_2_0 20000 -#define __IPHONE_2_1 20100 -#define __IPHONE_2_2 20200 -#define __IPHONE_3_0 30000 -#define __IPHONE_3_1 30100 -#define __IPHONE_3_2 30200 -#define __IPHONE_4_0 40000 -#define __IPHONE_4_1 40100 -#define __IPHONE_4_2 40200 -#define __IPHONE_4_3 40300 -#define __IPHONE_5_0 50000 -#define __IPHONE_5_1 50100 -#define __IPHONE_6_0 60000 -#define __IPHONE_6_1 60100 -#define __IPHONE_7_0 70000 -#define __IPHONE_7_1 70100 -#define __IPHONE_8_0 80000 -#define __IPHONE_8_1 80100 -#define __IPHONE_8_2 80200 -#define __IPHONE_8_3 80300 -#define __IPHONE_8_4 80400 -#define __IPHONE_9_0 90000 -#define __IPHONE_9_1 90100 -#define __IPHONE_9_2 90200 -#define __IPHONE_9_3 90300 -#define __IPHONE_10_0 100000 -#define __IPHONE_10_1 100100 -#define __IPHONE_10_2 100200 -#define __IPHONE_10_3 100300 -#define __IPHONE_11_0 110000 -#define __IPHONE_11_1 110100 -#define __IPHONE_11_2 110200 -#define __IPHONE_11_3 110300 -#define __IPHONE_11_4 110400 -#define __IPHONE_12_0 120000 -#define __IPHONE_12_1 120100 -#define __IPHONE_12_2 120200 -#define __IPHONE_12_3 120300 -#define __IPHONE_13_0 130000 -#define __IPHONE_13_1 130100 -#define __IPHONE_13_2 130200 -#define __IPHONE_13_3 130300 -#define __IPHONE_13_4 130400 -#define __IPHONE_13_5 130500 -#define __IPHONE_13_6 130600 -/* __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */ - -#define __TVOS_9_0 90000 -#define __TVOS_9_1 90100 -#define __TVOS_9_2 90200 -#define __TVOS_10_0 100000 -#define __TVOS_10_0_1 100001 -#define __TVOS_10_1 100100 -#define __TVOS_10_2 100200 -#define __TVOS_11_0 110000 -#define __TVOS_11_1 110100 -#define __TVOS_11_2 110200 -#define __TVOS_11_3 110300 -#define __TVOS_11_4 110400 -#define __TVOS_12_0 120000 -#define __TVOS_12_1 120100 -#define __TVOS_12_2 120200 -#define __TVOS_12_3 120300 -#define __TVOS_13_0 130000 -#define __TVOS_13_2 130200 -#define __TVOS_13_3 130300 -#define __TVOS_13_4 130400 - -#define __WATCHOS_1_0 10000 -#define __WATCHOS_2_0 20000 -#define __WATCHOS_2_1 20100 -#define __WATCHOS_2_2 20200 -#define __WATCHOS_3_0 30000 -#define __WATCHOS_3_1 30100 -#define __WATCHOS_3_1_1 30101 -#define __WATCHOS_3_2 30200 -#define __WATCHOS_4_0 40000 -#define __WATCHOS_4_1 40100 -#define __WATCHOS_4_2 40200 -#define __WATCHOS_4_3 40300 -#define __WATCHOS_5_0 50000 -#define __WATCHOS_5_1 50100 -#define __WATCHOS_5_2 50200 -#define __WATCHOS_6_0 60000 -#define __WATCHOS_6_1 60100 -#define __WATCHOS_6_2 60200 - -#define __DRIVERKIT_19_0 190000 -#endif /* __MAC_10_0 */ - +#include #include #ifdef __IPHONE_OS_VERSION_MIN_REQUIRED diff --git a/lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h b/lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h index 92bbd4b36f..7356564c61 100644 --- a/lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h +++ b/lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h @@ -45,6 +45,9 @@ #ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ /* compiler sets __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ when -miphoneos-version-min is used */ #define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ + /* set to 1 when RC_FALLBACK_PLATFORM=iphoneos */ + #elif 0 + #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_14_0 #endif #endif /* __IPHONE_OS_VERSION_MIN_REQUIRED */ @@ -52,7 +55,7 @@ #ifdef __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ /* compiler sets __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ when -mtvos-version-min is used */ #define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ - #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_13_0 + #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_14_2 /* for compatibility with existing code. New code should use platform specific checks */ #define __IPHONE_OS_VERSION_MIN_REQUIRED 90000 #endif @@ -62,7 +65,7 @@ #ifdef __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ /* compiler sets __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ when -mwatchos-version-min is used */ #define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ - #define __WATCH_OS_VERSION_MAX_ALLOWED 60000 + #define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_7_1 /* for compatibility with existing code. New code should use platform specific checks */ #define __IPHONE_OS_VERSION_MIN_REQUIRED 90000 #endif @@ -72,7 +75,7 @@ #ifdef __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ #define __BRIDGE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ - #define __BRIDGE_OS_VERSION_MAX_ALLOWED 20000 + #define __BRIDGE_OS_VERSION_MAX_ALLOWED 50000 /* for compatibility with existing code. New code should use platform specific checks */ #define __IPHONE_OS_VERSION_MIN_REQUIRED 110000 #endif @@ -87,14 +90,14 @@ #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED /* make sure a default max version is set */ #ifndef __MAC_OS_X_VERSION_MAX_ALLOWED - #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_10_15 + #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_11_0 #endif #endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */ #ifdef __IPHONE_OS_VERSION_MIN_REQUIRED /* make sure a default max version is set */ #ifndef __IPHONE_OS_VERSION_MAX_ALLOWED - #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_13_0 + #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_14_2 #endif /* make sure a valid min is set */ #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_2_0 @@ -2887,7 +2890,7 @@ #if __has_builtin(__is_target_environment) #if __has_builtin(__is_target_variant_os) #if __has_builtin(__is_target_variant_environment) - #if (__is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi)) + #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)) #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION __attribute__((availability(ios,introduced=4.0))) #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION __attribute__((availability(ios,unavailable))) #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION_MSG(_msg) __attribute__((availability(ios,unavailable))) diff --git a/lib/libc/include/x86_64-macos-gnu/AvailabilityMacros.h b/lib/libc/include/x86_64-macos-gnu/AvailabilityMacros.h new file mode 100644 index 0000000000..4fa40fcb36 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/AvailabilityMacros.h @@ -0,0 +1,4015 @@ +/* + * Copyright (c) 2001-2010 by Apple Inc.. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + File: AvailabilityMacros.h + + More Info: See the SDK Compatibility Guide + + Contains: Autoconfiguration of AVAILABLE_ macros for Mac OS X + + This header enables a developer to specify build time + constraints on what Mac OS X versions the resulting + application will be run. There are two bounds a developer + can specify: + + MAC_OS_X_VERSION_MIN_REQUIRED + MAC_OS_X_VERSION_MAX_ALLOWED + + The lower bound controls which calls to OS functions will + be weak-importing (allowed to be unresolved at launch time). + The upper bound controls which OS functionality, if used, + will result in a compiler error because that functionality is + not available on any OS in the specifed range. + + For example, suppose an application is compiled with: + + MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_2 + MAC_OS_X_VERSION_MAX_ALLOWED = MAC_OS_X_VERSION_10_3 + + and an OS header contains: + + extern void funcA(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; + extern void funcB(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2; + extern void funcC(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3; + extern void funcD(void) AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER; + extern void funcE(void) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER; + extern void funcF(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; + extern void funcG(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; + + typedef long TypeA DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER; + typedef long TypeB DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER; + typedef long TypeC DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER; + typedef long TypeD DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER; + typedef long TypeE DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER; + + Any application code which uses these declarations will get the following: + + compile link run + ------- ------ ------- + funcA: normal normal normal + funcB: warning normal normal + funcC: normal normal normal + funcD: normal normal normal + funcE: normal normal normal + funcF: normal weak on 10.3 normal, on 10.2 (&funcF == NULL) + funcG: error error n/a + typeA: warning + typeB: warning + typeC: warning + typeD: normal + typeE: normal + + +*/ +#ifndef __AVAILABILITYMACROS__ +#define __AVAILABILITYMACROS__ + +/* + * Set up standard Mac OS X versions + */ +#define MAC_OS_X_VERSION_10_0 1000 +#define MAC_OS_X_VERSION_10_1 1010 +#define MAC_OS_X_VERSION_10_2 1020 +#define MAC_OS_X_VERSION_10_3 1030 +#define MAC_OS_X_VERSION_10_4 1040 +#define MAC_OS_X_VERSION_10_5 1050 +#define MAC_OS_X_VERSION_10_6 1060 +#define MAC_OS_X_VERSION_10_7 1070 +#define MAC_OS_X_VERSION_10_8 1080 +#define MAC_OS_X_VERSION_10_9 1090 +#define MAC_OS_X_VERSION_10_10 101000 +#define MAC_OS_X_VERSION_10_10_2 101002 +#define MAC_OS_X_VERSION_10_10_3 101003 +#define MAC_OS_X_VERSION_10_11 101100 +#define MAC_OS_X_VERSION_10_11_2 101102 +#define MAC_OS_X_VERSION_10_11_3 101103 +#define MAC_OS_X_VERSION_10_11_4 101104 +#define MAC_OS_X_VERSION_10_12 101200 +#define MAC_OS_X_VERSION_10_12_1 101201 +#define MAC_OS_X_VERSION_10_12_2 101202 +#define MAC_OS_X_VERSION_10_12_4 101204 +#define MAC_OS_X_VERSION_10_13 101300 +#define MAC_OS_X_VERSION_10_13_1 101301 +#define MAC_OS_X_VERSION_10_13_2 101302 +#define MAC_OS_X_VERSION_10_13_4 101304 +#define MAC_OS_X_VERSION_10_14 101400 +#define MAC_OS_X_VERSION_10_14_1 101401 +#define MAC_OS_X_VERSION_10_14_4 101404 +#define MAC_OS_X_VERSION_10_15 101500 +#define MAC_OS_VERSION_11_0 110000 + +/* + * If min OS not specified, assume 10.4 for intel + * Note: compiler driver may set _ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED_ based on MACOSX_DEPLOYMENT_TARGET environment variable + */ +#ifndef MAC_OS_X_VERSION_MIN_REQUIRED + #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + #if (__i386__ || __x86_64__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < MAC_OS_X_VERSION_10_4) + #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid. + #endif + #define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + #else + #if __i386__ || __x86_64__ + #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 + #elif __arm__ || __arm64__ + #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_5 + #else + #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_1 + #endif + #endif +#endif + +/* + * if max OS not specified, assume larger of (10.15, min) + */ +#ifndef MAC_OS_X_VERSION_MAX_ALLOWED + #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_VERSION_11_0 + #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_MIN_REQUIRED + #else + #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_VERSION_11_0 + #endif +#endif + +/* + * Error on bad values + */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_MIN_REQUIRED + #error MAC_OS_X_VERSION_MAX_ALLOWED must be >= MAC_OS_X_VERSION_MIN_REQUIRED +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_0 + #error MAC_OS_X_VERSION_MIN_REQUIRED must be >= MAC_OS_X_VERSION_10_0 +#endif + +/* + * only certain compilers support __attribute__((weak_import)) + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1020) + #define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import)) +#elif defined(__MWERKS__) && (__MWERKS__ >= 0x3205) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1020) && !defined(__INTEL__) + #define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import)) +#else + #define WEAK_IMPORT_ATTRIBUTE +#endif + +/* + * only certain compilers support __attribute__((deprecated)) + */ +#if defined(__has_feature) && defined(__has_attribute) + #if __has_attribute(deprecated) + #define DEPRECATED_ATTRIBUTE __attribute__((deprecated)) + #if __has_feature(attribute_deprecated_with_message) + #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s))) + #else + #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated)) + #endif + #else + #define DEPRECATED_ATTRIBUTE + #define DEPRECATED_MSG_ATTRIBUTE(s) + #endif +#elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #define DEPRECATED_ATTRIBUTE __attribute__((deprecated)) + #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) + #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s))) + #else + #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated)) + #endif +#else + #define DEPRECATED_ATTRIBUTE + #define DEPRECATED_MSG_ATTRIBUTE(s) +#endif + +/* + * only certain compilers support __attribute__((unavailable)) + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable)) +#else + #define UNAVAILABLE_ATTRIBUTE +#endif + + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER + * + * Used on functions introduced in Mac OS X 10.0 + */ +#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED + * + * Used on functions introduced in Mac OS X 10.0, + * and deprecated in Mac OS X 10.0 + */ +#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER + * + * Used on types deprecated in Mac OS X 10.0 + */ +#define DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER DEPRECATED_ATTRIBUTE + +#ifndef __AVAILABILITY_MACROS_USES_AVAILABILITY + #ifdef __has_attribute + #if __has_attribute(availability) + #include + #define __AVAILABILITY_MACROS_USES_AVAILABILITY 1 + #endif + #endif +#endif + +#if TARGET_OS_OSX +#define __IPHONE_COMPAT_VERSION __IPHONE_NA +#elif TARGET_OS_MACCATALYST +#define __IPHONE_COMPAT_VERSION __IPHONE_NA +#else +#define __IPHONE_COMPAT_VERSION __IPHONE_4_0 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.1, + * and deprecated in Mac OS X 10.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.2, + * and deprecated in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.3, + * and deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.4, + * and deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.5, + * and deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.6, + * and deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.7, + * and deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.13 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY +#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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 DEPRECATED_ATTRIBUTE +#else +#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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.8, + * and deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.9, + * and deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.10, + * and deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10_2, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.10.2, + * and deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10_3, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.10.3, + * and deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.11, + * and deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_2, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.11.2, + * and deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_3, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.11.3, + * and deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_4, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.11.4, + * and deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.12, + * and deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.11.4, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.12.1, + * and deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.11.4, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.12, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_2, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.12.2, + * and deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.11.4, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.12, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.12.1, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_4, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.12.4, + * and deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.11.4, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.12, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.12.1, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.12.2, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #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 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.13 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_13, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13 + #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13 + #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.14 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_14, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_14 + #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14 + #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.15 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_15, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_15 + #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 + #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER + * + * Used on types deprecated in Mac OS X 10.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER + * + * Used on types deprecated in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER + * + * Used on types deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER + * + * Used on types deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER + * + * Used on types deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER + * + * Used on types deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER + * + * Used on types deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER + * + * Used on types deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER + * + * Used on types deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER + * + * Used on types deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER + * + * Used on types deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER + * + * Used on types deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER + * + * Used on types deprecated in Mac OS X 10.13 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER + * + * Used on types deprecated in Mac OS X 10.14.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #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) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_14_4 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER +#endif + +#endif /* __AVAILABILITYMACROS__ */ + + diff --git a/lib/libc/include/x86_64-macos-gnu/AvailabilityVersions.h b/lib/libc/include/x86_64-macos-gnu/AvailabilityVersions.h new file mode 100644 index 0000000000..5b2c2cce30 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/AvailabilityVersions.h @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2019 by Apple Inc.. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef __AVAILABILITY_VERSIONS__ +#define __AVAILABILITY_VERSIONS__ + +#define __MAC_10_0 1000 +#define __MAC_10_1 1010 +#define __MAC_10_2 1020 +#define __MAC_10_3 1030 +#define __MAC_10_4 1040 +#define __MAC_10_5 1050 +#define __MAC_10_6 1060 +#define __MAC_10_7 1070 +#define __MAC_10_8 1080 +#define __MAC_10_9 1090 +#define __MAC_10_10 101000 +#define __MAC_10_10_2 101002 +#define __MAC_10_10_3 101003 +#define __MAC_10_11 101100 +#define __MAC_10_11_2 101102 +#define __MAC_10_11_3 101103 +#define __MAC_10_11_4 101104 +#define __MAC_10_12 101200 +#define __MAC_10_12_1 101201 +#define __MAC_10_12_2 101202 +#define __MAC_10_12_4 101204 +#define __MAC_10_13 101300 +#define __MAC_10_13_1 101301 +#define __MAC_10_13_2 101302 +#define __MAC_10_13_4 101304 +#define __MAC_10_14 101400 +#define __MAC_10_14_1 101401 +#define __MAC_10_14_4 101404 +#define __MAC_10_14_6 101406 +#define __MAC_10_15 101500 +#define __MAC_10_15_1 101501 +#define __MAC_10_15_4 101504 +#define __MAC_10_16 101600 +#define __MAC_11_0 110000 +/* __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ + +#define __IPHONE_2_0 20000 +#define __IPHONE_2_1 20100 +#define __IPHONE_2_2 20200 +#define __IPHONE_3_0 30000 +#define __IPHONE_3_1 30100 +#define __IPHONE_3_2 30200 +#define __IPHONE_4_0 40000 +#define __IPHONE_4_1 40100 +#define __IPHONE_4_2 40200 +#define __IPHONE_4_3 40300 +#define __IPHONE_5_0 50000 +#define __IPHONE_5_1 50100 +#define __IPHONE_6_0 60000 +#define __IPHONE_6_1 60100 +#define __IPHONE_7_0 70000 +#define __IPHONE_7_1 70100 +#define __IPHONE_8_0 80000 +#define __IPHONE_8_1 80100 +#define __IPHONE_8_2 80200 +#define __IPHONE_8_3 80300 +#define __IPHONE_8_4 80400 +#define __IPHONE_9_0 90000 +#define __IPHONE_9_1 90100 +#define __IPHONE_9_2 90200 +#define __IPHONE_9_3 90300 +#define __IPHONE_10_0 100000 +#define __IPHONE_10_1 100100 +#define __IPHONE_10_2 100200 +#define __IPHONE_10_3 100300 +#define __IPHONE_11_0 110000 +#define __IPHONE_11_1 110100 +#define __IPHONE_11_2 110200 +#define __IPHONE_11_3 110300 +#define __IPHONE_11_4 110400 +#define __IPHONE_12_0 120000 +#define __IPHONE_12_1 120100 +#define __IPHONE_12_2 120200 +#define __IPHONE_12_3 120300 +#define __IPHONE_12_4 120400 +#define __IPHONE_13_0 130000 +#define __IPHONE_13_1 130100 +#define __IPHONE_13_2 130200 +#define __IPHONE_13_3 130300 +#define __IPHONE_13_4 130400 +#define __IPHONE_13_5 130500 +#define __IPHONE_13_6 130600 +#define __IPHONE_13_7 130700 +#define __IPHONE_14_0 140000 +#define __IPHONE_14_1 140100 +#define __IPHONE_14_2 140200 +/* __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ + +#define __TVOS_9_0 90000 +#define __TVOS_9_1 90100 +#define __TVOS_9_2 90200 +#define __TVOS_10_0 100000 +#define __TVOS_10_0_1 100001 +#define __TVOS_10_1 100100 +#define __TVOS_10_2 100200 +#define __TVOS_11_0 110000 +#define __TVOS_11_1 110100 +#define __TVOS_11_2 110200 +#define __TVOS_11_3 110300 +#define __TVOS_11_4 110400 +#define __TVOS_12_0 120000 +#define __TVOS_12_1 120100 +#define __TVOS_12_2 120200 +#define __TVOS_12_3 120300 +#define __TVOS_12_4 120400 +#define __TVOS_13_0 130000 +#define __TVOS_13_2 130200 +#define __TVOS_13_3 130300 +#define __TVOS_13_4 130400 +#define __TVOS_14_0 140000 +#define __TVOS_14_1 140100 +#define __TVOS_14_2 140200 + +#define __WATCHOS_1_0 10000 +#define __WATCHOS_2_0 20000 +#define __WATCHOS_2_1 20100 +#define __WATCHOS_2_2 20200 +#define __WATCHOS_3_0 30000 +#define __WATCHOS_3_1 30100 +#define __WATCHOS_3_1_1 30101 +#define __WATCHOS_3_2 30200 +#define __WATCHOS_4_0 40000 +#define __WATCHOS_4_1 40100 +#define __WATCHOS_4_2 40200 +#define __WATCHOS_4_3 40300 +#define __WATCHOS_5_0 50000 +#define __WATCHOS_5_1 50100 +#define __WATCHOS_5_2 50200 +#define __WATCHOS_5_3 50300 +#define __WATCHOS_6_0 60000 +#define __WATCHOS_6_1 60100 +#define __WATCHOS_6_2 60200 +#define __WATCHOS_7_0 70000 +#define __WATCHOS_7_1 70100 + +/* + * Set up standard Mac OS X versions + */ + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) + +#define MAC_OS_X_VERSION_10_0 1000 +#define MAC_OS_X_VERSION_10_1 1010 +#define MAC_OS_X_VERSION_10_2 1020 +#define MAC_OS_X_VERSION_10_3 1030 +#define MAC_OS_X_VERSION_10_4 1040 +#define MAC_OS_X_VERSION_10_5 1050 +#define MAC_OS_X_VERSION_10_6 1060 +#define MAC_OS_X_VERSION_10_7 1070 +#define MAC_OS_X_VERSION_10_8 1080 +#define MAC_OS_X_VERSION_10_9 1090 +#define MAC_OS_X_VERSION_10_10 101000 +#define MAC_OS_X_VERSION_10_10_2 101002 +#define MAC_OS_X_VERSION_10_10_3 101003 +#define MAC_OS_X_VERSION_10_11 101100 +#define MAC_OS_X_VERSION_10_11_2 101102 +#define MAC_OS_X_VERSION_10_11_3 101103 +#define MAC_OS_X_VERSION_10_11_4 101104 +#define MAC_OS_X_VERSION_10_12 101200 +#define MAC_OS_X_VERSION_10_12_1 101201 +#define MAC_OS_X_VERSION_10_12_2 101202 +#define MAC_OS_X_VERSION_10_12_4 101204 +#define MAC_OS_X_VERSION_10_13 101300 +#define MAC_OS_X_VERSION_10_13_1 101301 +#define MAC_OS_X_VERSION_10_13_2 101302 +#define MAC_OS_X_VERSION_10_13_4 101304 +#define MAC_OS_X_VERSION_10_14 101400 +#define MAC_OS_X_VERSION_10_14_1 101401 +#define MAC_OS_X_VERSION_10_14_4 101404 +#define MAC_OS_X_VERSION_10_14_6 101406 +#define MAC_OS_X_VERSION_10_15 101500 +#define MAC_OS_X_VERSION_10_15_1 101501 +#define MAC_OS_X_VERSION_10_16 101600 +#define MAC_OS_VERSION_11_0 110000 + +#endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */ + +#define __DRIVERKIT_19_0 190000 +#define __DRIVERKIT_20_0 200000 + +#endif /* __AVAILABILITY_VERSIONS__ */ + diff --git a/lib/libc/include/x86_64-macos-gnu/ConditionalMacros.h b/lib/libc/include/x86_64-macos-gnu/ConditionalMacros.h new file mode 100644 index 0000000000..5344fb985f --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/ConditionalMacros.h @@ -0,0 +1,619 @@ +/* + * Copyright (c) 1993-2011 by Apple Inc.. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + File: ConditionalMacros.h + + Contains: Set up for compiler independent conditionals + + Version: CarbonCore-769~1 + + Bugs?: For bug reports, consult the following page on + the World Wide Web: + + http://developer.apple.com/bugreporter/ + +*/ +#ifndef __CONDITIONALMACROS__ +#define __CONDITIONALMACROS__ + +#include +/**************************************************************************************************** + UNIVERSAL_INTERFACES_VERSION + + 0x0400 --> version 4.0 (Mac OS X only) + 0x0335 --> version 3.4 + 0x0331 --> version 3.3.1 + 0x0330 --> version 3.3 + 0x0320 --> version 3.2 + 0x0310 --> version 3.1 + 0x0301 --> version 3.0.1 + 0x0300 --> version 3.0 + 0x0210 --> version 2.1 + This conditional did not exist prior to version 2.1 +****************************************************************************************************/ +#define UNIVERSAL_INTERFACES_VERSION 0x0400 +/**************************************************************************************************** + + All TARGET_* condtionals are set up by TargetConditionals.h + +****************************************************************************************************/ +#include + + + + +/**************************************************************************************************** + + PRAGMA_* + These conditionals specify whether the compiler supports particular #pragma's + + PRAGMA_IMPORT - Compiler supports: #pragma import on/off/reset + PRAGMA_ONCE - Compiler supports: #pragma once + PRAGMA_STRUCT_ALIGN - Compiler supports: #pragma options align=mac68k/power/reset + PRAGMA_STRUCT_PACK - Compiler supports: #pragma pack(n) + PRAGMA_STRUCT_PACKPUSH - Compiler supports: #pragma pack(push, n)/pack(pop) + PRAGMA_ENUM_PACK - Compiler supports: #pragma options(!pack_enums) + PRAGMA_ENUM_ALWAYSINT - Compiler supports: #pragma enumsalwaysint on/off/reset + PRAGMA_ENUM_OPTIONS - Compiler supports: #pragma options enum=int/small/reset + + + FOUR_CHAR_CODE + 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. + It was never intended for endian swapping. + + FOUR_CHAR_CODE('abcd') - Convert a four-char-code to the correct 32-bit value + + + TYPE_* + These conditionals specify whether the compiler supports particular types. + + TYPE_LONGLONG - Compiler supports "long long" 64-bit integers + TYPE_EXTENDED - Compiler supports "extended" 80/96 bit floating point + TYPE_LONGDOUBLE_IS_DOUBLE - Compiler implements "long double" same as "double" + + + FUNCTION_* + These conditionals specify whether the compiler supports particular language extensions + to function prototypes and definitions. + + FUNCTION_PASCAL - Compiler supports "pascal void Foo()" + FUNCTION_DECLSPEC - Compiler supports "__declspec(xxx) void Foo()" + FUNCTION_WIN32CC - Compiler supports "void __cdecl Foo()" and "void __stdcall Foo()" + +****************************************************************************************************/ + +#if defined(__GNUC__) && (defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__NEXT_CPP__) || defined(__MACOS_CLASSIC__)) + /* + gcc based compilers used on Mac OS X + */ + #define PRAGMA_IMPORT 0 + #define PRAGMA_ONCE 0 + + #if __GNUC__ >= 4 + #define PRAGMA_STRUCT_PACK 1 + #define PRAGMA_STRUCT_PACKPUSH 1 + #else + #define PRAGMA_STRUCT_PACK 0 + #define PRAGMA_STRUCT_PACKPUSH 0 + #endif + + #if __LP64__ || __arm64__ || __ARM_ARCH_7K + #define PRAGMA_STRUCT_ALIGN 0 + #else + #define PRAGMA_STRUCT_ALIGN 1 + #endif + + #define PRAGMA_ENUM_PACK 0 + #define PRAGMA_ENUM_ALWAYSINT 0 + #define PRAGMA_ENUM_OPTIONS 0 + #define FOUR_CHAR_CODE(x) (x) + + #define TYPE_EXTENDED 0 + + #ifdef __ppc__ + #ifdef __LONG_DOUBLE_128__ + #define TYPE_LONGDOUBLE_IS_DOUBLE 0 + #else + #define TYPE_LONGDOUBLE_IS_DOUBLE 1 + #endif + #else + #define TYPE_LONGDOUBLE_IS_DOUBLE 0 + #endif + + #define TYPE_LONGLONG 1 + + #define FUNCTION_PASCAL 0 + #define FUNCTION_DECLSPEC 0 + #define FUNCTION_WIN32CC 0 + + #ifdef __MACOS_CLASSIC__ + #ifndef TARGET_API_MAC_CARBON /* gcc cfm cross compiler assumes you're building Carbon code */ + #define TARGET_API_MAC_CARBON 1 + #endif + #endif + + + +#elif defined(__MWERKS__) + /* + CodeWarrior compiler from Metrowerks/Motorola + */ + #define PRAGMA_ONCE 1 + #define PRAGMA_IMPORT 0 + #define PRAGMA_STRUCT_ALIGN 1 + #define PRAGMA_STRUCT_PACK 1 + #define PRAGMA_STRUCT_PACKPUSH 0 + #define PRAGMA_ENUM_PACK 0 + #define PRAGMA_ENUM_ALWAYSINT 1 + #define PRAGMA_ENUM_OPTIONS 0 + #if __option(enumsalwaysint) && __option(ANSI_strict) + #define FOUR_CHAR_CODE(x) ((long)(x)) /* otherwise compiler will complain about values with high bit set */ + #else + #define FOUR_CHAR_CODE(x) (x) + #endif + #define FUNCTION_PASCAL 1 + #define FUNCTION_DECLSPEC 1 + #define FUNCTION_WIN32CC 0 + + #if __option(longlong) + #define TYPE_LONGLONG 1 + #else + #define TYPE_LONGLONG 0 + #endif + #define TYPE_EXTENDED 0 + #define TYPE_LONGDOUBLE_IS_DOUBLE 1 + + + +#else + /* + Unknown compiler, perhaps set up from the command line + */ + #error unknown compiler + #ifndef PRAGMA_IMPORT + #define PRAGMA_IMPORT 0 + #endif + #ifndef PRAGMA_STRUCT_ALIGN + #define PRAGMA_STRUCT_ALIGN 0 + #endif + #ifndef PRAGMA_ONCE + #define PRAGMA_ONCE 0 + #endif + #ifndef PRAGMA_STRUCT_PACK + #define PRAGMA_STRUCT_PACK 0 + #endif + #ifndef PRAGMA_STRUCT_PACKPUSH + #define PRAGMA_STRUCT_PACKPUSH 0 + #endif + #ifndef PRAGMA_ENUM_PACK + #define PRAGMA_ENUM_PACK 0 + #endif + #ifndef PRAGMA_ENUM_ALWAYSINT + #define PRAGMA_ENUM_ALWAYSINT 0 + #endif + #ifndef PRAGMA_ENUM_OPTIONS + #define PRAGMA_ENUM_OPTIONS 0 + #endif + #ifndef FOUR_CHAR_CODE + #define FOUR_CHAR_CODE(x) (x) + #endif + + #ifndef TYPE_LONGDOUBLE_IS_DOUBLE + #define TYPE_LONGDOUBLE_IS_DOUBLE 1 + #endif + #ifndef TYPE_EXTENDED + #define TYPE_EXTENDED 0 + #endif + #ifndef TYPE_LONGLONG + #define TYPE_LONGLONG 0 + #endif + #ifndef FUNCTION_PASCAL + #define FUNCTION_PASCAL 0 + #endif + #ifndef FUNCTION_DECLSPEC + #define FUNCTION_DECLSPEC 0 + #endif + #ifndef FUNCTION_WIN32CC + #define FUNCTION_WIN32CC 0 + #endif +#endif + + + + +/**************************************************************************************************** + + Under MacOS, the classic 68k runtime has two calling conventions: pascal or C + Under Win32, there are two calling conventions: __cdecl or __stdcall + Headers and implementation files can use the following macros to make their + source more portable by hiding the calling convention details: + + EXTERN_API* + These macros are used to specify the calling convention on a function prototype. + + EXTERN_API - Classic 68k: pascal, Win32: __cdecl + EXTERN_API_C - Classic 68k: C, Win32: __cdecl + EXTERN_API_STDCALL - Classic 68k: pascal, Win32: __stdcall + EXTERN_API_C_STDCALL - Classic 68k: C, Win32: __stdcall + + + DEFINE_API* + These macros are used to specify the calling convention on a function definition. + + DEFINE_API - Classic 68k: pascal, Win32: __cdecl + DEFINE_API_C - Classic 68k: C, Win32: __cdecl + DEFINE_API_STDCALL - Classic 68k: pascal, Win32: __stdcall + DEFINE_API_C_STDCALL - Classic 68k: C, Win32: __stdcall + + + CALLBACK_API* + These macros are used to specify the calling convention of a function pointer. + + CALLBACK_API - Classic 68k: pascal, Win32: __stdcall + CALLBACK_API_C - Classic 68k: C, Win32: __stdcall + CALLBACK_API_STDCALL - Classic 68k: pascal, Win32: __cdecl + CALLBACK_API_C_STDCALL - Classic 68k: C, Win32: __cdecl + +****************************************************************************************************/ + +#if FUNCTION_PASCAL && !FUNCTION_DECLSPEC && !FUNCTION_WIN32CC + /* compiler supports pascal keyword only */ + #define EXTERN_API(_type) extern pascal _type + #define EXTERN_API_C(_type) extern _type + #define EXTERN_API_STDCALL(_type) extern pascal _type + #define EXTERN_API_C_STDCALL(_type) extern _type + + #define DEFINE_API(_type) pascal _type + #define DEFINE_API_C(_type) _type + #define DEFINE_API_STDCALL(_type) pascal _type + #define DEFINE_API_C_STDCALL(_type) _type + + #define CALLBACK_API(_type, _name) pascal _type (*_name) + #define CALLBACK_API_C(_type, _name) _type (*_name) + #define CALLBACK_API_STDCALL(_type, _name) pascal _type (*_name) + #define CALLBACK_API_C_STDCALL(_type, _name) _type (*_name) + +#elif FUNCTION_PASCAL && FUNCTION_DECLSPEC && !FUNCTION_WIN32CC + /* compiler supports pascal and __declspec() */ + #define EXTERN_API(_type) extern pascal __declspec(dllimport) _type + #define EXTERN_API_C(_type) extern __declspec(dllimport) _type + #define EXTERN_API_STDCALL(_type) extern pascal __declspec(dllimport) _type + #define EXTERN_API_C_STDCALL(_type) extern __declspec(dllimport) _type + + #define DEFINE_API(_type) pascal __declspec(dllexport) _type + #define DEFINE_API_C(_type) __declspec(dllexport) _type + #define DEFINE_API_STDCALL(_type) pascal __declspec(dllexport) _type + #define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type + + #define CALLBACK_API(_type, _name) pascal _type (*_name) + #define CALLBACK_API_C(_type, _name) _type (*_name) + #define CALLBACK_API_STDCALL(_type, _name) pascal _type (*_name) + #define CALLBACK_API_C_STDCALL(_type, _name) _type (*_name) + +#elif !FUNCTION_PASCAL && FUNCTION_DECLSPEC && !FUNCTION_WIN32CC + /* compiler supports __declspec() */ + #define EXTERN_API(_type) extern __declspec(dllimport) _type + #define EXTERN_API_C(_type) extern __declspec(dllimport) _type + #define EXTERN_API_STDCALL(_type) extern __declspec(dllimport) _type + #define EXTERN_API_C_STDCALL(_type) extern __declspec(dllimport) _type + + #define DEFINE_API(_type) __declspec(dllexport) _type + #define DEFINE_API_C(_type) __declspec(dllexport) _type + #define DEFINE_API_STDCALL(_type) __declspec(dllexport) _type + #define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type + + #define CALLBACK_API(_type, _name) _type ( * _name) + #define CALLBACK_API_C(_type, _name) _type ( * _name) + #define CALLBACK_API_STDCALL(_type, _name) _type ( * _name) + #define CALLBACK_API_C_STDCALL(_type, _name) _type ( * _name) + +#elif !FUNCTION_PASCAL && FUNCTION_DECLSPEC && FUNCTION_WIN32CC + /* compiler supports __declspec() and __cdecl */ + #define EXTERN_API(_type) __declspec(dllimport) _type __cdecl + #define EXTERN_API_C(_type) __declspec(dllimport) _type __cdecl + #define EXTERN_API_STDCALL(_type) __declspec(dllimport) _type __stdcall + #define EXTERN_API_C_STDCALL(_type) __declspec(dllimport) _type __stdcall + + #define DEFINE_API(_type) __declspec(dllexport) _type __cdecl + #define DEFINE_API_C(_type) __declspec(dllexport) _type __cdecl + #define DEFINE_API_STDCALL(_type) __declspec(dllexport) _type __stdcall + #define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type __stdcall + + #define CALLBACK_API(_type, _name) _type (__cdecl * _name) + #define CALLBACK_API_C(_type, _name) _type (__cdecl * _name) + #define CALLBACK_API_STDCALL(_type, _name) _type (__stdcall * _name) + #define CALLBACK_API_C_STDCALL(_type, _name) _type (__stdcall * _name) + +#elif !FUNCTION_PASCAL && !FUNCTION_DECLSPEC && FUNCTION_WIN32CC + /* compiler supports __cdecl */ + #define EXTERN_API(_type) _type __cdecl + #define EXTERN_API_C(_type) _type __cdecl + #define EXTERN_API_STDCALL(_type) _type __stdcall + #define EXTERN_API_C_STDCALL(_type) _type __stdcall + + #define DEFINE_API(_type) _type __cdecl + #define DEFINE_API_C(_type) _type __cdecl + #define DEFINE_API_STDCALL(_type) _type __stdcall + #define DEFINE_API_C_STDCALL(_type) _type __stdcall + + #define CALLBACK_API(_type, _name) _type (__cdecl * _name) + #define CALLBACK_API_C(_type, _name) _type (__cdecl * _name) + #define CALLBACK_API_STDCALL(_type, _name) _type (__stdcall * _name) + #define CALLBACK_API_C_STDCALL(_type, _name) _type (__stdcall * _name) + +#else + /* compiler supports no extensions */ + #define EXTERN_API(_type) extern _type + #define EXTERN_API_C(_type) extern _type + #define EXTERN_API_STDCALL(_type) extern _type + #define EXTERN_API_C_STDCALL(_type) extern _type + + #define DEFINE_API(_type) _type + #define DEFINE_API_C(_type) _type + #define DEFINE_API_STDCALL(_type) _type + #define DEFINE_API_C_STDCALL(_type) _type + + #define CALLBACK_API(_type, _name) _type ( * _name) + #define CALLBACK_API_C(_type, _name) _type ( * _name) + #define CALLBACK_API_STDCALL(_type, _name) _type ( * _name) + #define CALLBACK_API_C_STDCALL(_type, _name) _type ( * _name) + #undef pascal + #define pascal +#endif + +/**************************************************************************************************** + + Set up TARGET_API_*_* values + +****************************************************************************************************/ +#if !defined(TARGET_API_MAC_OS8) && !defined(TARGET_API_MAC_OSX) && !defined(TARGET_API_MAC_CARBON) +/* No TARGET_API_MAC_* predefined on command line */ +#if TARGET_RT_MAC_MACHO +/* Looks like MachO style compiler */ +#define TARGET_API_MAC_OS8 0 +#define TARGET_API_MAC_CARBON 1 +#define TARGET_API_MAC_OSX 1 +#elif defined(TARGET_CARBON) && TARGET_CARBON +/* grandfather in use of TARGET_CARBON */ +#define TARGET_API_MAC_OS8 0 +#define TARGET_API_MAC_CARBON 1 +#define TARGET_API_MAC_OSX 0 +#elif TARGET_CPU_PPC && TARGET_RT_MAC_CFM +/* Looks like CFM style PPC compiler */ +#define TARGET_API_MAC_OS8 1 +#define TARGET_API_MAC_CARBON 0 +#define TARGET_API_MAC_OSX 0 +#else +/* 68k or some other compiler */ +#define TARGET_API_MAC_OS8 1 +#define TARGET_API_MAC_CARBON 0 +#define TARGET_API_MAC_OSX 0 +#endif /* */ + +#else +#ifndef TARGET_API_MAC_OS8 +#define TARGET_API_MAC_OS8 0 +#endif /* !defined(TARGET_API_MAC_OS8) */ + +#ifndef TARGET_API_MAC_OSX +#define TARGET_API_MAC_OSX TARGET_RT_MAC_MACHO +#endif /* !defined(TARGET_API_MAC_OSX) */ + +#ifndef TARGET_API_MAC_CARBON +#define TARGET_API_MAC_CARBON TARGET_API_MAC_OSX +#endif /* !defined(TARGET_API_MAC_CARBON) */ + +#endif /* !defined(TARGET_API_MAC_OS8) && !defined(TARGET_API_MAC_OSX) && !defined(TARGET_API_MAC_CARBON) */ + +#if TARGET_API_MAC_OS8 && TARGET_API_MAC_OSX +#error TARGET_API_MAC_OS8 and TARGET_API_MAC_OSX are mutually exclusive +#endif /* TARGET_API_MAC_OS8 && TARGET_API_MAC_OSX */ + +#if !TARGET_API_MAC_OS8 && !TARGET_API_MAC_CARBON && !TARGET_API_MAC_OSX +#error At least one of TARGET_API_MAC_* must be true +#endif /* !TARGET_API_MAC_OS8 && !TARGET_API_MAC_CARBON && !TARGET_API_MAC_OSX */ + +/* Support source code still using TARGET_CARBON */ +#ifndef TARGET_CARBON +#if TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8 +#define TARGET_CARBON 1 +#else +#define TARGET_CARBON 0 +#endif /* TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8 */ + +#endif /* !defined(TARGET_CARBON) */ + +/**************************************************************************************************** + Backward compatibility for clients expecting 2.x version on ConditionalMacros.h + + GENERATINGPOWERPC - Compiler is generating PowerPC instructions + GENERATING68K - Compiler is generating 68k family instructions + GENERATING68881 - Compiler is generating mc68881 floating point instructions + GENERATINGCFM - Code being generated assumes CFM calling conventions + CFMSYSTEMCALLS - No A-traps. Systems calls are made using CFM and UPP's + PRAGMA_ALIGN_SUPPORTED - Compiler supports: #pragma options align=mac68k/power/reset + PRAGMA_IMPORT_SUPPORTED - Compiler supports: #pragma import on/off/reset + CGLUESUPPORTED - Clients can use all lowercase toolbox functions that take C strings instead of pascal strings + +****************************************************************************************************/ +#if !TARGET_API_MAC_CARBON +#define GENERATINGPOWERPC TARGET_CPU_PPC +#define GENERATING68K 0 +#define GENERATING68881 TARGET_RT_MAC_68881 +#define GENERATINGCFM TARGET_RT_MAC_CFM +#define CFMSYSTEMCALLS TARGET_RT_MAC_CFM +#ifndef CGLUESUPPORTED +#define CGLUESUPPORTED 0 +#endif /* !defined(CGLUESUPPORTED) */ + +#ifndef OLDROUTINELOCATIONS +#define OLDROUTINELOCATIONS 0 +#endif /* !defined(OLDROUTINELOCATIONS) */ + +#define PRAGMA_ALIGN_SUPPORTED PRAGMA_STRUCT_ALIGN +#define PRAGMA_IMPORT_SUPPORTED PRAGMA_IMPORT +#else +/* Carbon code should not use old conditionals */ +#define PRAGMA_ALIGN_SUPPORTED ..PRAGMA_ALIGN_SUPPORTED_is_obsolete.. +#define GENERATINGPOWERPC ..GENERATINGPOWERPC_is_obsolete.. +#define GENERATING68K ..GENERATING68K_is_obsolete.. +#define GENERATING68881 ..GENERATING68881_is_obsolete.. +#define GENERATINGCFM ..GENERATINGCFM_is_obsolete.. +#define CFMSYSTEMCALLS ..CFMSYSTEMCALLS_is_obsolete.. +#endif /* !TARGET_API_MAC_CARBON */ + + + +/**************************************************************************************************** + + OLDROUTINENAMES - "Old" names for Macintosh system calls are allowed in source code. + (e.g. DisposPtr instead of DisposePtr). The names of system routine + are now more sensitive to change because CFM binds by name. In the + past, system routine names were compiled out to just an A-Trap. + Macros have been added that each map an old name to its new name. + This allows old routine names to be used in existing source files, + but the macros only work if OLDROUTINENAMES is true. This support + will be removed in the near future. Thus, all source code should + be changed to use the new names! You can set OLDROUTINENAMES to false + to see if your code has any old names left in it. + +****************************************************************************************************/ +#ifndef OLDROUTINENAMES +#define OLDROUTINENAMES 0 +#endif /* !defined(OLDROUTINENAMES) */ + + + +/**************************************************************************************************** + The following macros isolate the use of 68K inlines in function prototypes. + On the Mac OS under the Classic 68K runtime, function prototypes were followed + by a list of 68K opcodes which the compiler inserted in the generated code instead + of a JSR. Under Classic 68K on the Mac OS, this macro will put the opcodes + in the right syntax. For all other OS's and runtimes the macro suppress the opcodes. + Example: + + EXTERN_P void DrawPicture(PicHandle myPicture, const Rect *dstRect) + ONEWORDINLINE(0xA8F6); + +****************************************************************************************************/ + +#if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM + #define ONEWORDINLINE(w1) = w1 + #define TWOWORDINLINE(w1,w2) = {w1,w2} + #define THREEWORDINLINE(w1,w2,w3) = {w1,w2,w3} + #define FOURWORDINLINE(w1,w2,w3,w4) = {w1,w2,w3,w4} + #define FIVEWORDINLINE(w1,w2,w3,w4,w5) = {w1,w2,w3,w4,w5} + #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6) = {w1,w2,w3,w4,w5,w6} + #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7) = {w1,w2,w3,w4,w5,w6,w7} + #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8) = {w1,w2,w3,w4,w5,w6,w7,w8} + #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9) = {w1,w2,w3,w4,w5,w6,w7,w8,w9} + #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10) = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10} + #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11) = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11} + #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} +#else + #define ONEWORDINLINE(w1) + #define TWOWORDINLINE(w1,w2) + #define THREEWORDINLINE(w1,w2,w3) + #define FOURWORDINLINE(w1,w2,w3,w4) + #define FIVEWORDINLINE(w1,w2,w3,w4,w5) + #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6) + #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7) + #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8) + #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9) + #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10) + #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11) + #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12) +#endif + + +/**************************************************************************************************** + + TARGET_CARBON - default: false. Switches all of the above as described. Overrides all others + - NOTE: If you set TARGET_CARBON to 1, then the other switches will be setup by + ConditionalMacros, and should not be set manually. + + If you wish to do development for pre-Carbon Systems, you can set the following: + + OPAQUE_TOOLBOX_STRUCTS - default: false. True for Carbon builds, hides struct fields. + OPAQUE_UPP_TYPES - default: false. True for Carbon builds, UPP types are unique and opaque. + ACCESSOR_CALLS_ARE_FUNCTIONS - default: false. True for Carbon builds, enables accessor functions. + CALL_NOT_IN_CARBON - default: true. False for Carbon builds, hides calls not supported in Carbon. + + Specifically, if you are building a non-Carbon application (one that links against InterfaceLib) + but you wish to use some of the accessor functions, you can set ACCESSOR_CALLS_ARE_FUNCTIONS to 1 + and link with CarbonAccessors.o, which implements just the accessor functions. This will help you + preserve source compatibility between your Carbon and non-Carbon application targets. + + MIXEDMODE_CALLS_ARE_FUNCTIONS - deprecated. + +****************************************************************************************************/ +#if TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8 +#ifndef OPAQUE_TOOLBOX_STRUCTS +#define OPAQUE_TOOLBOX_STRUCTS 1 +#endif /* !defined(OPAQUE_TOOLBOX_STRUCTS) */ + +#ifndef OPAQUE_UPP_TYPES +#define OPAQUE_UPP_TYPES 1 +#endif /* !defined(OPAQUE_UPP_TYPES) */ + +#ifndef ACCESSOR_CALLS_ARE_FUNCTIONS +#define ACCESSOR_CALLS_ARE_FUNCTIONS 1 +#endif /* !defined(ACCESSOR_CALLS_ARE_FUNCTIONS) */ + +#ifndef CALL_NOT_IN_CARBON +#define CALL_NOT_IN_CARBON 0 +#endif /* !defined(CALL_NOT_IN_CARBON) */ + +#ifndef MIXEDMODE_CALLS_ARE_FUNCTIONS +#define MIXEDMODE_CALLS_ARE_FUNCTIONS 1 +#endif /* !defined(MIXEDMODE_CALLS_ARE_FUNCTIONS) */ + +#else +#ifndef OPAQUE_TOOLBOX_STRUCTS +#define OPAQUE_TOOLBOX_STRUCTS 0 +#endif /* !defined(OPAQUE_TOOLBOX_STRUCTS) */ + +#ifndef ACCESSOR_CALLS_ARE_FUNCTIONS +#define ACCESSOR_CALLS_ARE_FUNCTIONS 0 +#endif /* !defined(ACCESSOR_CALLS_ARE_FUNCTIONS) */ + +/* + * It's possible to have ACCESSOR_CALLS_ARE_FUNCTIONS set to true and OPAQUE_TOOLBOX_STRUCTS + * set to false, but not the other way around, so make sure the defines are not set this way. + */ +#ifndef CALL_NOT_IN_CARBON +#define CALL_NOT_IN_CARBON 1 +#endif /* !defined(CALL_NOT_IN_CARBON) */ + +#ifndef MIXEDMODE_CALLS_ARE_FUNCTIONS +#define MIXEDMODE_CALLS_ARE_FUNCTIONS 0 +#endif /* !defined(MIXEDMODE_CALLS_ARE_FUNCTIONS) */ + +#endif /* TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8 */ + + + + +#endif /* __CONDITIONALMACROS__ */ + diff --git a/lib/libc/include/x86_64-macos-gnu/MacTypes.h b/lib/libc/include/x86_64-macos-gnu/MacTypes.h new file mode 100644 index 0000000000..135fad0fd2 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/MacTypes.h @@ -0,0 +1,808 @@ +/* + * Copyright (c) 1985-2011 by Apple Inc.. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + File: MacTypes.h + + Contains: Basic Macintosh data types. + + Version: CarbonCore-769~1 + + Bugs?: For bug reports, consult the following page on + the World Wide Web: + + http://developer.apple.com/bugreporter/ + +*/ +#ifndef __MACTYPES__ +#define __MACTYPES__ + +#ifndef __CONDITIONALMACROS__ +#include +#endif + +#include + +#include + +#include + +#if PRAGMA_ONCE +#pragma once +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma pack(push, 2) + + +/* + CarbonCore Deprecation flags. + + Certain Carbon API functions are deprecated in 10.3 and later + systems. These will produce a warning when compiling on 10.3. + + Other functions and constants do not produce meaningful + results when building Carbon for Mac OS X. For these + functions, no-op macros are provided, but only when the + ALLOW_OBSOLETE_CARBON flag is defined to be 0: eg + -DALLOW_OBSOLETE_CARBON=0. +*/ + +#if ! defined(ALLOW_OBSOLETE_CARBON) || ! ALLOW_OBSOLETE_CARBON + +#define ALLOW_OBSOLETE_CARBON_MACMEMORY 0 +#define ALLOW_OBSOLETE_CARBON_OSUTILS 0 + +#else + +#define ALLOW_OBSOLETE_CARBON_MACMEMORY 1 /* Removes obsolete constants; turns HLock/HUnlock into no-op macros */ +#define ALLOW_OBSOLETE_CARBON_OSUTILS 1 /* Removes obsolete structures */ + +#endif + +#ifndef NULL +#define NULL __DARWIN_NULL +#endif /* ! NULL */ +#ifndef nil + #if defined(__has_feature) + #if __has_feature(cxx_nullptr) + #define nil nullptr + #else + #define nil __DARWIN_NULL + #endif + #else + #define nil __DARWIN_NULL + #endif +#endif + +/******************************************************************************** + + Base integer types for all target OS's and CPU's + + UInt8 8-bit unsigned integer + SInt8 8-bit signed integer + UInt16 16-bit unsigned integer + SInt16 16-bit signed integer + UInt32 32-bit unsigned integer + SInt32 32-bit signed integer + UInt64 64-bit unsigned integer + SInt64 64-bit signed integer + +*********************************************************************************/ +typedef unsigned char UInt8; +typedef signed char SInt8; +typedef unsigned short UInt16; +typedef signed short SInt16; + +#if __LP64__ +typedef unsigned int UInt32; +typedef signed int SInt32; +#else +typedef unsigned long UInt32; +typedef signed long SInt32; +#endif + +/* avoid redeclaration if libkern/OSTypes.h */ +#ifndef _OS_OSTYPES_H +#if TARGET_RT_BIG_ENDIAN +struct wide { + SInt32 hi; + UInt32 lo; +}; +typedef struct wide wide; +struct UnsignedWide { + UInt32 hi; + UInt32 lo; +}; +typedef struct UnsignedWide UnsignedWide; +#else +struct wide { + UInt32 lo; + SInt32 hi; +}; +typedef struct wide wide; +struct UnsignedWide { + UInt32 lo; + UInt32 hi; +}; +typedef struct UnsignedWide UnsignedWide; +#endif /* TARGET_RT_BIG_ENDIAN */ + +#endif + +#if TYPE_LONGLONG +/* + Note: wide and UnsignedWide must always be structs for source code + compatibility. On the other hand UInt64 and SInt64 can be + either a struct or a long long, depending on the compiler. + + If you use UInt64 and SInt64 you should do all operations on + those data types through the functions/macros in Math64.h. + This will assure that your code compiles with compilers that + support long long and those that don't. + + The MS Visual C/C++ compiler uses __int64 instead of long long. +*/ + #if defined(_MSC_VER) && !defined(__MWERKS__) && defined(_M_IX86) + typedef signed __int64 SInt64; + typedef unsigned __int64 UInt64; + #else + typedef signed long long SInt64; + typedef unsigned long long UInt64; + #endif +#else + + +typedef wide SInt64; +typedef UnsignedWide UInt64; +#endif /* TYPE_LONGLONG */ + +/******************************************************************************** + + Base fixed point types + + Fixed 16-bit signed integer plus 16-bit fraction + UnsignedFixed 16-bit unsigned integer plus 16-bit fraction + Fract 2-bit signed integer plus 30-bit fraction + ShortFixed 8-bit signed integer plus 8-bit fraction + +*********************************************************************************/ +typedef SInt32 Fixed; +typedef Fixed * FixedPtr; +typedef SInt32 Fract; +typedef Fract * FractPtr; +typedef UInt32 UnsignedFixed; +typedef UnsignedFixed * UnsignedFixedPtr; +typedef short ShortFixed; +typedef ShortFixed * ShortFixedPtr; + + +/******************************************************************************** + + Base floating point types + + Float32 32 bit IEEE float: 1 sign bit, 8 exponent bits, 23 fraction bits + Float64 64 bit IEEE float: 1 sign bit, 11 exponent bits, 52 fraction bits + Float80 80 bit MacOS float: 1 sign bit, 15 exponent bits, 1 integer bit, 63 fraction bits + Float96 96 bit 68881 float: 1 sign bit, 15 exponent bits, 16 pad bits, 1 integer bit, 63 fraction bits + + Note: These are fixed size floating point types, useful when writing a floating + point value to disk. If your compiler does not support a particular size + float, a struct is used instead. + Use one of the NCEG types (e.g. double_t) or an ANSI C type (e.g. double) if + you want a floating point representation that is natural for any given + compiler, but might be a different size on different compilers. + +*********************************************************************************/ +typedef float Float32; +typedef double Float64; +struct Float80 { + SInt16 exp; + UInt16 man[4]; +}; +typedef struct Float80 Float80; + +struct Float96 { + SInt16 exp[2]; /* the second 16-bits are undefined */ + UInt16 man[4]; +}; +typedef struct Float96 Float96; +struct Float32Point { + Float32 x; + Float32 y; +}; +typedef struct Float32Point Float32Point; + +/******************************************************************************** + + MacOS Memory Manager types + + Ptr Pointer to a non-relocatable block + Handle Pointer to a master pointer to a relocatable block + Size The number of bytes in a block (signed for historical reasons) + +*********************************************************************************/ +typedef char * Ptr; +typedef Ptr * Handle; +typedef long Size; + +/******************************************************************************** + + Higher level basic types + + OSErr 16-bit result error code + OSStatus 32-bit result error code + LogicalAddress Address in the clients virtual address space + ConstLogicalAddress Address in the clients virtual address space that will only be read + PhysicalAddress Real address as used on the hardware bus + BytePtr Pointer to an array of bytes + ByteCount The size of an array of bytes + ByteOffset An offset into an array of bytes + ItemCount 32-bit iteration count + OptionBits Standard 32-bit set of bit flags + PBVersion ? + Duration 32-bit millisecond timer for drivers + AbsoluteTime 64-bit clock + ScriptCode A particular set of written characters (e.g. Roman vs Cyrillic) and their encoding + LangCode A particular language (e.g. English), as represented using a particular ScriptCode + RegionCode Designates a language as used in a particular region (e.g. British vs American + English) together with other region-dependent characteristics (e.g. date format) + FourCharCode A 32-bit value made by packing four 1 byte characters together + OSType A FourCharCode used in the OS and file system (e.g. creator) + ResType A FourCharCode used to tag resources (e.g. 'DLOG') + +*********************************************************************************/ +typedef SInt16 OSErr; +typedef SInt32 OSStatus; +typedef void * LogicalAddress; +typedef const void * ConstLogicalAddress; +typedef void * PhysicalAddress; +typedef UInt8 * BytePtr; +typedef unsigned long ByteCount; +typedef unsigned long ByteOffset; +typedef SInt32 Duration; +typedef UnsignedWide AbsoluteTime; +typedef UInt32 OptionBits; +typedef unsigned long ItemCount; +typedef UInt32 PBVersion; +typedef SInt16 ScriptCode; +typedef SInt16 LangCode; +typedef SInt16 RegionCode; +typedef UInt32 FourCharCode; +typedef FourCharCode OSType; +typedef FourCharCode ResType; +typedef OSType * OSTypePtr; +typedef ResType * ResTypePtr; +/******************************************************************************** + + Boolean types and values + + Boolean Mac OS historic type, sizeof(Boolean)==1 + bool Defined in stdbool.h, ISO C/C++ standard type + false Now defined in stdbool.h + true Now defined in stdbool.h + +*********************************************************************************/ +typedef unsigned char Boolean; +/******************************************************************************** + + Function Pointer Types + + ProcPtr Generic pointer to a function + Register68kProcPtr Pointer to a 68K function that expects parameters in registers + UniversalProcPtr Pointer to classic 68K code or a RoutineDescriptor + + ProcHandle Pointer to a ProcPtr + UniversalProcHandle Pointer to a UniversalProcPtr + +*********************************************************************************/ +typedef CALLBACK_API_C( long , ProcPtr )(void); +typedef CALLBACK_API( void , Register68kProcPtr )(void); +#if TARGET_RT_MAC_CFM +/* The RoutineDescriptor structure is defined in MixedMode.h */ +typedef struct RoutineDescriptor *UniversalProcPtr; +#else +typedef ProcPtr UniversalProcPtr; +#endif /* TARGET_RT_MAC_CFM */ + +typedef ProcPtr * ProcHandle; +typedef UniversalProcPtr * UniversalProcHandle; +/******************************************************************************** + + RefCon Types + + For access to private data in callbacks, etc.; refcons are generally + used as a pointer to something, but in the 32-bit world refcons in + different APIs have had various types: pointer, unsigned scalar, and + signed scalar. The RefCon types defined here support the current 32-bit + usage but provide normalization to pointer types for 64-bit. + + PRefCon is preferred for new APIs; URefCon and SRefCon are primarily + for compatibility with existing APIs. + +*********************************************************************************/ +typedef void * PRefCon; +#if __LP64__ +typedef void * URefCon; +typedef void * SRefCon; +#else +typedef UInt32 URefCon; +typedef SInt32 SRefCon; +#endif /* __LP64__ */ + +/******************************************************************************** + + Common Constants + + noErr OSErr: function performed properly - no error + kNilOptions OptionBits: all flags false + kInvalidID KernelID: NULL is for pointers as kInvalidID is for ID's + kVariableLengthArray array bounds: variable length array + + Note: kVariableLengthArray was used in array bounds to specify a variable length array, + usually the last field in a struct. Now that the C language supports + the concept of flexible array members, you can instead use: + + struct BarList + { + short listLength; + Bar elements[]; + }; + + However, this changes the semantics somewhat, as sizeof( BarList ) contains + no space for any of the elements, so to allocate a list with space for + the count elements + + struct BarList* l = (struct BarList*) malloc( sizeof(BarList) + count * sizeof(Bar) ); + +*********************************************************************************/ +enum { + noErr = 0 +}; + +enum { + kNilOptions = 0 +}; + +#define kInvalidID 0 +enum { + kVariableLengthArray +#ifdef __has_extension + #if __has_extension(enumerator_attributes) + __attribute__((deprecated)) + #endif +#endif + = 1 +}; + +enum { + kUnknownType = 0x3F3F3F3F /* "????" QuickTime 3.0: default unknown ResType or OSType */ +}; + + + +/******************************************************************************** + + String Types and Unicode Types + + UnicodeScalarValue, A complete Unicode character in UTF-32 format, with + UTF32Char values from 0 through 0x10FFFF (excluding the surrogate + range 0xD800-0xDFFF and certain disallowed values). + + UniChar, A 16-bit Unicode code value in the default UTF-16 format. + UTF16Char UnicodeScalarValues 0-0xFFFF are expressed in UTF-16 + format using a single UTF16Char with the same value. + UnicodeScalarValues 0x10000-0x10FFFF are expressed in + UTF-16 format using a pair of UTF16Chars - one in the + high surrogate range (0xD800-0xDBFF) followed by one in + the low surrogate range (0xDC00-0xDFFF). All of the + characters defined in Unicode versions through 3.0 are + in the range 0-0xFFFF and can be expressed using a single + UTF16Char, thus the term "Unicode character" generally + refers to a UniChar = UTF16Char. + + UTF8Char An 8-bit code value in UTF-8 format. UnicodeScalarValues + 0-0x7F are expressed in UTF-8 format using one UTF8Char + with the same value. UnicodeScalarValues above 0x7F are + expressed in UTF-8 format using 2-4 UTF8Chars, all with + values in the range 0x80-0xF4 (UnicodeScalarValues + 0x100-0xFFFF use two or three UTF8Chars, + UnicodeScalarValues 0x10000-0x10FFFF use four UTF8Chars). + + UniCharCount A count of UTF-16 code values in an array or buffer. + + StrNNN Pascal string holding up to NNN bytes + StringPtr Pointer to a pascal string + StringHandle Pointer to a StringPtr + ConstStringPtr Pointer to a read-only pascal string + ConstStrNNNParam For function parameters only - means string is const + + CStringPtr Pointer to a C string (in C: char*) + ConstCStringPtr Pointer to a read-only C string (in C: const char*) + + Note: The length of a pascal string is stored as the first byte. + A pascal string does not have a termination byte. + A pascal string can hold at most 255 bytes of data. + The first character in a pascal string is offset one byte from the start of the string. + + A C string is terminated with a byte of value zero. + A C string has no length limitation. + The first character in a C string is the zeroth byte of the string. + + +*********************************************************************************/ +typedef UInt32 UnicodeScalarValue; +typedef UInt32 UTF32Char; +typedef UInt16 UniChar; +typedef UInt16 UTF16Char; +typedef UInt8 UTF8Char; +typedef UniChar * UniCharPtr; +typedef unsigned long UniCharCount; +typedef UniCharCount * UniCharCountPtr; +typedef unsigned char Str255[256]; +typedef unsigned char Str63[64]; +typedef unsigned char Str32[33]; +typedef unsigned char Str31[32]; +typedef unsigned char Str27[28]; +typedef unsigned char Str15[16]; +/* + The type Str32 is used in many AppleTalk based data structures. + It holds up to 32 one byte chars. The problem is that with the + length byte it is 33 bytes long. This can cause weird alignment + problems in structures. To fix this the type "Str32Field" has + been created. It should only be used to hold 32 chars, but + it is 34 bytes long so that there are no alignment problems. +*/ +typedef unsigned char Str32Field[34]; +/* + QuickTime 3.0: + The type StrFileName is used to make MacOS structs work + cross-platform. For example FSSpec or SFReply previously + contained a Str63 field. They now contain a StrFileName + field which is the same when targeting the MacOS but is + a 256 char buffer for Win32 and unix, allowing them to + contain long file names. +*/ +typedef Str63 StrFileName; +typedef unsigned char * StringPtr; +typedef StringPtr * StringHandle; +typedef const unsigned char * ConstStringPtr; +typedef const unsigned char * ConstStr255Param; +typedef const unsigned char * ConstStr63Param; +typedef const unsigned char * ConstStr32Param; +typedef const unsigned char * ConstStr31Param; +typedef const unsigned char * ConstStr27Param; +typedef const unsigned char * ConstStr15Param; +typedef ConstStr63Param ConstStrFileNameParam; +#ifdef __cplusplus +inline unsigned char StrLength(ConstStr255Param string) { return (*string); } +#else +#define StrLength(string) (*(const unsigned char *)(string)) +#endif /* defined(__cplusplus) */ + +#if OLDROUTINENAMES +#define Length(string) StrLength(string) +#endif /* OLDROUTINENAMES */ + +/******************************************************************************** + + Process Manager type ProcessSerialNumber (previously in Processes.h) + +*********************************************************************************/ +/* type for unique process identifier */ +struct ProcessSerialNumber { + UInt32 highLongOfPSN; + UInt32 lowLongOfPSN; +}; +typedef struct ProcessSerialNumber ProcessSerialNumber; +typedef ProcessSerialNumber * ProcessSerialNumberPtr; +/******************************************************************************** + + Quickdraw Types + + Point 2D Quickdraw coordinate, range: -32K to +32K + Rect Rectangular Quickdraw area + Style Quickdraw font rendering styles + StyleParameter Style when used as a parameter (historical 68K convention) + StyleField Style when used as a field (historical 68K convention) + CharParameter Char when used as a parameter (historical 68K convention) + + Note: The original Macintosh toolbox in 68K Pascal defined Style as a SET. + Both Style and CHAR occupy 8-bits in packed records or 16-bits when + used as fields in non-packed records or as parameters. + +*********************************************************************************/ +struct Point { + short v; + short h; +}; +typedef struct Point Point; +typedef Point * PointPtr; +struct Rect { + short top; + short left; + short bottom; + short right; +}; +typedef struct Rect Rect; +typedef Rect * RectPtr; +struct FixedPoint { + Fixed x; + Fixed y; +}; +typedef struct FixedPoint FixedPoint; +struct FixedRect { + Fixed left; + Fixed top; + Fixed right; + Fixed bottom; +}; +typedef struct FixedRect FixedRect; + +typedef short CharParameter; +enum { + normal = 0, + bold = 1, + italic = 2, + underline = 4, + outline = 8, + shadow = 0x10, + condense = 0x20, + extend = 0x40 +}; + +typedef unsigned char Style; +typedef short StyleParameter; +typedef Style StyleField; + + +/******************************************************************************** + + QuickTime TimeBase types (previously in Movies.h) + + TimeValue Count of units + TimeScale Units per second + CompTimeValue 64-bit count of units (always a struct) + TimeValue64 64-bit count of units (long long or struct) + TimeBase An opaque reference to a time base + TimeRecord Package of TimeBase, duration, and scale + +*********************************************************************************/ +typedef SInt32 TimeValue; +typedef SInt32 TimeScale; +typedef wide CompTimeValue; +typedef SInt64 TimeValue64; +typedef struct TimeBaseRecord* TimeBase; +struct TimeRecord { + CompTimeValue value; /* units (duration or absolute) */ + TimeScale scale; /* units per second */ + TimeBase base; /* refernce to the time base */ +}; +typedef struct TimeRecord TimeRecord; + +/******************************************************************************** + + THINK C base objects + + HandleObject Root class for handle based THINK C++ objects + PascalObject Root class for pascal style objects in THINK C++ + +*********************************************************************************/ +#if defined(__SC__) && !defined(__STDC__) && defined(__cplusplus) + class __machdl HandleObject {}; + #if TARGET_CPU_68K + class __pasobj PascalObject {}; + #endif +#endif + + +/******************************************************************************** + + MacOS versioning structures + + VersRec Contents of a 'vers' resource + VersRecPtr Pointer to a VersRecPtr + VersRecHndl Resource Handle containing a VersRec + NumVersion Packed BCD version representation (e.g. "4.2.1a3" is 0x04214003) + UniversalProcPtr Pointer to classic 68K code or a RoutineDescriptor + + ProcHandle Pointer to a ProcPtr + UniversalProcHandle Pointer to a UniversalProcPtr + +*********************************************************************************/ +#if TARGET_RT_BIG_ENDIAN +struct NumVersion { + /* Numeric version part of 'vers' resource */ + UInt8 majorRev; /*1st part of version number in BCD*/ + UInt8 minorAndBugRev; /*2nd & 3rd part of version number share a byte*/ + UInt8 stage; /*stage code: dev, alpha, beta, final*/ + UInt8 nonRelRev; /*revision level of non-released version*/ +}; +typedef struct NumVersion NumVersion; +#else +struct NumVersion { + /* Numeric version part of 'vers' resource accessable in little endian format */ + UInt8 nonRelRev; /*revision level of non-released version*/ + UInt8 stage; /*stage code: dev, alpha, beta, final*/ + UInt8 minorAndBugRev; /*2nd & 3rd part of version number share a byte*/ + UInt8 majorRev; /*1st part of version number in BCD*/ +}; +typedef struct NumVersion NumVersion; +#endif /* TARGET_RT_BIG_ENDIAN */ + +enum { + /* Version Release Stage Codes */ + developStage = 0x20, + alphaStage = 0x40, + betaStage = 0x60, + finalStage = 0x80 +}; + +union NumVersionVariant { + /* NumVersionVariant is a wrapper so NumVersion can be accessed as a 32-bit value */ + NumVersion parts; + UInt32 whole; +}; +typedef union NumVersionVariant NumVersionVariant; +typedef NumVersionVariant * NumVersionVariantPtr; +typedef NumVersionVariantPtr * NumVersionVariantHandle; +struct VersRec { + /* 'vers' resource format */ + NumVersion numericVersion; /*encoded version number*/ + short countryCode; /*country code from intl utilities*/ + Str255 shortVersion; /*version number string - worst case*/ + Str255 reserved; /*longMessage string packed after shortVersion*/ +}; +typedef struct VersRec VersRec; +typedef VersRec * VersRecPtr; +typedef VersRecPtr * VersRecHndl; +/********************************************************************************* + + Old names for types + +*********************************************************************************/ +typedef UInt8 Byte; +typedef SInt8 SignedByte; +typedef wide * WidePtr; +typedef UnsignedWide * UnsignedWidePtr; +typedef Float80 extended80; +typedef Float96 extended96; +typedef SInt8 VHSelect; +/********************************************************************************* + + Debugger functions + +*********************************************************************************/ +/* + * Debugger() + * + * Availability: + * Mac OS X: in version 10.0 and later in CoreServices.framework + * CarbonLib: in CarbonLib 1.0 and later + * Non-Carbon CFM: in InterfaceLib 7.1 and later + */ +extern void +Debugger(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA); + + +/* + * DebugStr() + * + * Availability: + * Mac OS X: in version 10.0 and later in CoreServices.framework + * CarbonLib: in CarbonLib 1.0 and later + * Non-Carbon CFM: in InterfaceLib 7.1 and later + */ +extern void +DebugStr(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA); + + +/* + * debugstr() + * + * Availability: + * Mac OS X: not available + * CarbonLib: not available + * Non-Carbon CFM: in InterfaceLib 7.1 and later + */ + + +#if TARGET_CPU_PPC +/* Only for Mac OS native drivers */ +/* + * SysDebug() + * + * Availability: + * Mac OS X: not available + * CarbonLib: not available + * Non-Carbon CFM: in DriverServicesLib 1.0 and later + */ + + +/* + * SysDebugStr() + * + * Availability: + * Mac OS X: not available + * CarbonLib: not available + * Non-Carbon CFM: in DriverServicesLib 1.0 and later + */ + + +#endif /* TARGET_CPU_PPC */ + +/* SADE break points */ +/* + * SysBreak() + * + * Availability: + * Mac OS X: in version 10.0 and later in CoreServices.framework + * CarbonLib: in CarbonLib 1.0 and later + * Non-Carbon CFM: in InterfaceLib 7.1 and later + */ +extern void +SysBreak(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA); + + +/* + * SysBreakStr() + * + * Availability: + * Mac OS X: in version 10.0 and later in CoreServices.framework + * CarbonLib: in CarbonLib 1.0 and later + * Non-Carbon CFM: in InterfaceLib 7.1 and later + */ +extern void +SysBreakStr(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA); + + +/* + * SysBreakFunc() + * + * Availability: + * Mac OS X: in version 10.0 and later in CoreServices.framework + * CarbonLib: in CarbonLib 1.0 and later + * Non-Carbon CFM: in InterfaceLib 7.1 and later + */ +extern void +SysBreakFunc(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA); + + +/* old names for Debugger and DebugStr */ +#if OLDROUTINENAMES && TARGET_CPU_68K + #define Debugger68k() Debugger() + #define DebugStr68k(s) DebugStr(s) +#endif + + +#pragma pack(pop) + +#ifdef __cplusplus +} +#endif + +#endif /* __MACTYPES__ */ + diff --git a/lib/libc/include/x86_64-macos-gnu/TargetConditionals.h b/lib/libc/include/x86_64-macos-gnu/TargetConditionals.h index ca021fd11b..11880f6fe2 100644 --- a/lib/libc/include/x86_64-macos-gnu/TargetConditionals.h +++ b/lib/libc/include/x86_64-macos-gnu/TargetConditionals.h @@ -35,71 +35,72 @@ #ifndef __TARGETCONDITIONALS__ #define __TARGETCONDITIONALS__ -/**************************************************************************************************** - - TARGET_CPU_* - These conditionals specify which microprocessor instruction set is being - generated. At most one of these is true, the rest are false. - - TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode - TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode - TARGET_CPU_68K - Compiler is generating 680x0 instructions - TARGET_CPU_X86 - Compiler is generating x86 instructions for 32-bit mode - TARGET_CPU_X86_64 - Compiler is generating x86 instructions for 64-bit mode - TARGET_CPU_ARM - Compiler is generating ARM instructions for 32-bit mode - TARGET_CPU_ARM64 - Compiler is generating ARM instructions for 64-bit mode - TARGET_CPU_MIPS - Compiler is generating MIPS instructions - TARGET_CPU_SPARC - Compiler is generating Sparc instructions - TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions - - - TARGET_OS_* - These conditionals specify in which Operating System the generated code will - run. Indention is used to show which conditionals are evolutionary subclasses. - - The MAC/WIN32/UNIX conditionals are mutually exclusive. - The IOS/TV/WATCH conditionals are mutually exclusive. - - - TARGET_OS_WIN32 - Generated code will run under 32-bit Windows - TARGET_OS_UNIX - Generated code will run under some Unix (not OSX) - TARGET_OS_MAC - Generated code will run under Mac OS X variant - TARGET_OS_OSX - Generated code will run under OS X devices - TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator - TARGET_OS_IOS - Generated code will run under iOS - TARGET_OS_TV - Generated code will run under Apple TV OS - TARGET_OS_WATCH - Generated code will run under Apple Watch OS - TARGET_OS_BRIDGE - Generated code will run under Bridge devices - TARGET_OS_MACCATALYST - Generated code will run under macOS - TARGET_OS_SIMULATOR - Generated code will run under a simulator - - TARGET_OS_EMBEDDED - DEPRECATED: Use TARGET_OS_IPHONE and/or TARGET_OS_SIMULATOR instead - TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR - TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH - - +----------------------------------------------------------------+ - | TARGET_OS_MAC | - | +---+ +-----------------------------------------------------+ | - | | | | TARGET_OS_IPHONE | | - | |OSX| | +-----+ +----+ +-------+ +--------+ +-------------+ | | - | | | | | IOS | | TV | | WATCH | | BRIDGE | | MACCATALYST | | | - | | | | +-----+ +----+ +-------+ +--------+ +-------------+ | | - | +---+ +-----------------------------------------------------+ | - +----------------------------------------------------------------+ - - TARGET_RT_* - These conditionals specify in which runtime the generated code will - run. This is needed when the OS and CPU support more than one runtime - (e.g. Mac OS X supports CFM and mach-o). - - TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers - TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers - TARGET_RT_64_BIT - Generated code uses 64-bit pointers - TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used - TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used - - -****************************************************************************************************/ +/* + * + * TARGET_CPU_* + * These conditionals specify which microprocessor instruction set is being + * generated. At most one of these is true, the rest are false. + * + * TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode + * TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode + * TARGET_CPU_68K - Compiler is generating 680x0 instructions + * TARGET_CPU_X86 - Compiler is generating x86 instructions for 32-bit mode + * TARGET_CPU_X86_64 - Compiler is generating x86 instructions for 64-bit mode + * TARGET_CPU_ARM - Compiler is generating ARM instructions for 32-bit mode + * TARGET_CPU_ARM64 - Compiler is generating ARM instructions for 64-bit mode + * TARGET_CPU_MIPS - Compiler is generating MIPS instructions + * TARGET_CPU_SPARC - Compiler is generating Sparc instructions + * TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions + * + * + * TARGET_OS_* + * These conditionals specify in which Operating System the generated code will + * run. Indention is used to show which conditionals are evolutionary subclasses. + * + * The MAC/WIN32/UNIX conditionals are mutually exclusive. + * The IOS/TV/WATCH conditionals are mutually exclusive. + * + * + * TARGET_OS_WIN32 - Generated code will run under 32-bit Windows + * TARGET_OS_UNIX - Generated code will run under some Unix (not OSX) + * TARGET_OS_MAC - Generated code will run under Mac OS X variant + * TARGET_OS_OSX - Generated code will run under OS X devices + * TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator + * TARGET_OS_IOS - Generated code will run under iOS + * TARGET_OS_TV - Generated code will run under Apple TV OS + * TARGET_OS_WATCH - Generated code will run under Apple Watch OS + * TARGET_OS_BRIDGE - Generated code will run under Bridge devices + * TARGET_OS_MACCATALYST - Generated code will run under macOS + * TARGET_OS_SIMULATOR - Generated code will run under a simulator + * + * TARGET_OS_EMBEDDED - DEPRECATED: Use TARGET_OS_IPHONE and/or TARGET_OS_SIMULATOR instead + * TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR + * TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH + * + * +---------------------------------------------------------------------+ + * | TARGET_OS_MAC | + * | +---+ +-----------------------------------------------+ +---------+ | + * | | | | TARGET_OS_IPHONE | | | | + * | | | | +---------------+ +----+ +-------+ +--------+ | | | | + * | | | | | IOS | | | | | | | | | | | + * | |OSX| | |+-------------+| | TV | | WATCH | | BRIDGE | | |DRIVERKIT| | + * | | | | || MACCATALYST || | | | | | | | | | | + * | | | | |+-------------+| | | | | | | | | | | + * | | | | +---------------+ +----+ +-------+ +--------+ | | | | + * | +---+ +-----------------------------------------------+ +---------+ | + * +---------------------------------------------------------------------+ + * + * TARGET_RT_* + * These conditionals specify in which runtime the generated code will + * run. This is needed when the OS and CPU support more than one runtime + * (e.g. Mac OS X supports CFM and mach-o). + * + * TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers + * TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers + * TARGET_RT_64_BIT - Generated code uses 64-bit pointers + * TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used + * TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used + */ /* * TARGET_OS conditionals can be enabled via clang preprocessor extensions: @@ -133,7 +134,9 @@ #if __has_builtin(__is_target_environment) /* “-target=x86_64-apple-ios12-macabi” */ - #if __is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi) + /* “-target=arm64-apple-ios12-macabi” */ + /* “-target=arm64e-apple-ios12-macabi” */ + #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) #define TARGET_OS_OSX 0 #define TARGET_OS_IPHONE 1 #define TARGET_OS_IOS 1 @@ -173,7 +176,9 @@ #endif /* -target=x86_64-apple-driverkit19.0 */ - #if __is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(driverkit) + /* -target=arm64-apple-driverkit19.0 */ + /* -target=arm64e-apple-driverkit19.0 */ + #if (__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(driverkit) #define TARGET_OS_OSX 0 #define TARGET_OS_IPHONE 0 #define TARGET_OS_IOS 0 @@ -231,7 +236,8 @@ #define TARGET_IPHONE_SIMULATOR TARGET_OS_SIMULATOR /* deprecated */ #define TARGET_OS_NANO TARGET_OS_WATCH /* deprecated */ - #define TARGET_ABI_USES_IOS_VALUES (TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST) + + #define TARGET_ABI_USES_IOS_VALUES (!TARGET_CPU_X86_64 || (TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST)) #if defined(__ppc__) #define TARGET_CPU_PPC 1 #define TARGET_CPU_PPC64 0 diff --git a/lib/libc/include/x86_64-macos-gnu/_ctermid.h b/lib/libc/include/x86_64-macos-gnu/_ctermid.h index 540b117622..5bbd721a0d 100644 --- a/lib/libc/include/x86_64-macos-gnu/_ctermid.h +++ b/lib/libc/include/x86_64-macos-gnu/_ctermid.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2002-2006, 2008-2010, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2002-2006, 2008-2010, 2012, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -23,5 +23,13 @@ #ifndef _CTERMID_H_ #define _CTERMID_H_ + +#include + +__BEGIN_DECLS + char *ctermid(char *); + +__END_DECLS + #endif diff --git a/lib/libc/include/x86_64-macos-gnu/bsm/audit.h b/lib/libc/include/x86_64-macos-gnu/bsm/audit.h index 2bac16e91a..2a77601093 100644 --- a/lib/libc/include/x86_64-macos-gnu/bsm/audit.h +++ b/lib/libc/include/x86_64-macos-gnu/bsm/audit.h @@ -332,13 +332,24 @@ struct au_evclass_map { }; typedef struct au_evclass_map au_evclass_map_t; + +#if !defined(_KERNEL) && !defined(KERNEL) +#include +#define __AUDIT_API_DEPRECATED __API_DEPRECATED("audit is deprecated", macos(10.4, 11.0)) +#else +#define __AUDIT_API_DEPRECATED +#endif + /* * Audit system calls. */ #if !defined(_KERNEL) && !defined(KERNEL) -int audit(const void *, int); -int auditon(int, void *, int); -int auditctl(const char *); +int audit(const void *, int) +__AUDIT_API_DEPRECATED; +int auditon(int, void *, int) +__AUDIT_API_DEPRECATED; +int auditctl(const char *) +__AUDIT_API_DEPRECATED; int getauid(au_id_t *); int setauid(const au_id_t *); int getaudit_addr(struct auditinfo_addr *, int); @@ -360,8 +371,10 @@ __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_2_0, __IPHONE_6_0); #else -int getaudit(struct auditinfo *); -int setaudit(const struct auditinfo *); +int getaudit(struct auditinfo *) +__AUDIT_API_DEPRECATED; +int setaudit(const struct auditinfo *) +__AUDIT_API_DEPRECATED; #endif /* !__APPLE__ */ #ifdef __APPLE_API_PRIVATE diff --git a/lib/libc/include/x86_64-macos-gnu/device/device_types.h b/lib/libc/include/x86_64-macos-gnu/device/device_types.h new file mode 100644 index 0000000000..2125026e9b --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/device/device_types.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * Author: David B. Golub, Carnegie Mellon University + * Date: 3/89 + */ + +#ifndef DEVICE_TYPES_H +#define DEVICE_TYPES_H + +/* + * Types for device interface. + */ +#include +#include +#include +#include + + + +/* + * IO buffer - out-of-line array of characters. + */ +typedef char * io_buf_ptr_t; + +/* + * Some types for IOKit. + */ + +#ifdef IOKIT + +/* must match device_types.defs */ +typedef char io_name_t[128]; +typedef char io_string_t[512]; +typedef char io_string_inband_t[4096]; +typedef char io_struct_inband_t[4096]; + +#if __LP64__ +typedef uint64_t io_user_scalar_t; +typedef uint64_t io_user_reference_t; +typedef io_user_scalar_t io_scalar_inband_t[16]; +typedef io_user_reference_t io_async_ref_t[8]; +typedef io_user_scalar_t io_scalar_inband64_t[16]; +typedef io_user_reference_t io_async_ref64_t[8]; +#else +typedef int io_user_scalar_t; +typedef natural_t io_user_reference_t; +typedef io_user_scalar_t io_scalar_inband_t[16]; +typedef io_user_reference_t io_async_ref_t[8]; +typedef uint64_t io_scalar_inband64_t[16]; +typedef uint64_t io_async_ref64_t[8]; +#endif // __LP64__ + + +#ifndef __IOKIT_PORTS_DEFINED__ +#define __IOKIT_PORTS_DEFINED__ +typedef mach_port_t io_object_t; +#endif /* __IOKIT_PORTS_DEFINED__ */ + + +#endif /* IOKIT */ + +#endif /* DEVICE_TYPES_H */ diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/base.h b/lib/libc/include/x86_64-macos-gnu/dispatch/base.h new file mode 100644 index 0000000000..8ede9615bc --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/base.h @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2008-2012 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_BASE__ +#define __DISPATCH_BASE__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#endif + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif +#ifndef __has_include +#define __has_include(x) 0 +#endif +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#ifndef __has_extension +#define __has_extension(x) 0 +#endif + +#if __GNUC__ +#define DISPATCH_NORETURN __attribute__((__noreturn__)) +#define DISPATCH_NOTHROW __attribute__((__nothrow__)) +#define DISPATCH_NONNULL1 __attribute__((__nonnull__(1))) +#define DISPATCH_NONNULL2 __attribute__((__nonnull__(2))) +#define DISPATCH_NONNULL3 __attribute__((__nonnull__(3))) +#define DISPATCH_NONNULL4 __attribute__((__nonnull__(4))) +#define DISPATCH_NONNULL5 __attribute__((__nonnull__(5))) +#define DISPATCH_NONNULL6 __attribute__((__nonnull__(6))) +#define DISPATCH_NONNULL7 __attribute__((__nonnull__(7))) +#if __clang__ && __clang_major__ < 3 +// rdar://problem/6857843 +#define DISPATCH_NONNULL_ALL +#else +#define DISPATCH_NONNULL_ALL __attribute__((__nonnull__)) +#endif +#define DISPATCH_SENTINEL __attribute__((__sentinel__)) +#define DISPATCH_PURE __attribute__((__pure__)) +#define DISPATCH_CONST __attribute__((__const__)) +#define DISPATCH_WARN_RESULT __attribute__((__warn_unused_result__)) +#define DISPATCH_MALLOC __attribute__((__malloc__)) +#define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__)) +#define DISPATCH_UNAVAILABLE __attribute__((__unavailable__)) +#define DISPATCH_UNAVAILABLE_MSG(msg) __attribute__((__unavailable__(msg))) +#elif defined(_MSC_VER) +#define DISPATCH_NORETURN __declspec(noreturn) +#define DISPATCH_NOTHROW __declspec(nothrow) +#define DISPATCH_NONNULL1 +#define DISPATCH_NONNULL2 +#define DISPATCH_NONNULL3 +#define DISPATCH_NONNULL4 +#define DISPATCH_NONNULL5 +#define DISPATCH_NONNULL6 +#define DISPATCH_NONNULL7 +#define DISPATCH_NONNULL_ALL +#define DISPATCH_SENTINEL +#define DISPATCH_PURE +#define DISPATCH_CONST +#if (_MSC_VER >= 1700) +#define DISPATCH_WARN_RESULT _Check_return_ +#else +#define DISPATCH_WARN_RESULT +#endif +#define DISPATCH_MALLOC +#define DISPATCH_ALWAYS_INLINE __forceinline +#define DISPATCH_UNAVAILABLE +#define DISPATCH_UNAVAILABLE_MSG(msg) +#else +/*! @parseOnly */ +#define DISPATCH_NORETURN +/*! @parseOnly */ +#define DISPATCH_NOTHROW +/*! @parseOnly */ +#define DISPATCH_NONNULL1 +/*! @parseOnly */ +#define DISPATCH_NONNULL2 +/*! @parseOnly */ +#define DISPATCH_NONNULL3 +/*! @parseOnly */ +#define DISPATCH_NONNULL4 +/*! @parseOnly */ +#define DISPATCH_NONNULL5 +/*! @parseOnly */ +#define DISPATCH_NONNULL6 +/*! @parseOnly */ +#define DISPATCH_NONNULL7 +/*! @parseOnly */ +#define DISPATCH_NONNULL_ALL +/*! @parseOnly */ +#define DISPATCH_SENTINEL +/*! @parseOnly */ +#define DISPATCH_PURE +/*! @parseOnly */ +#define DISPATCH_CONST +/*! @parseOnly */ +#define DISPATCH_WARN_RESULT +/*! @parseOnly */ +#define DISPATCH_MALLOC +/*! @parseOnly */ +#define DISPATCH_ALWAYS_INLINE +/*! @parseOnly */ +#define DISPATCH_UNAVAILABLE +/*! @parseOnly */ +#define DISPATCH_UNAVAILABLE_MSG(msg) +#endif + +#define DISPATCH_LINUX_UNAVAILABLE() + +#ifdef __FreeBSD__ +#define DISPATCH_FREEBSD_UNAVAILABLE() \ + DISPATCH_UNAVAILABLE_MSG( \ + "This interface is unavailable on FreeBSD systems") +#else +#define DISPATCH_FREEBSD_UNAVAILABLE() +#endif + +#ifndef DISPATCH_ALIAS_V2 +#if TARGET_OS_MAC +#define DISPATCH_ALIAS_V2(sym) __asm__("_" #sym "$V2") +#else +#define DISPATCH_ALIAS_V2(sym) +#endif +#endif + +#if defined(_WIN32) +#if defined(__cplusplus) +#define DISPATCH_EXPORT extern "C" __declspec(dllimport) +#else +#define DISPATCH_EXPORT extern __declspec(dllimport) +#endif +#elif __GNUC__ +#define DISPATCH_EXPORT extern __attribute__((visibility("default"))) +#else +#define DISPATCH_EXPORT extern +#endif + +#if __GNUC__ +#define DISPATCH_INLINE static __inline__ +#else +#define DISPATCH_INLINE static inline +#endif + +#if __GNUC__ +#define DISPATCH_EXPECT(x, v) __builtin_expect((x), (v)) +#define dispatch_compiler_barrier() __asm__ __volatile__("" ::: "memory") +#else +#define DISPATCH_EXPECT(x, v) (x) +#define dispatch_compiler_barrier() do { } while (0) +#endif + +#if __has_attribute(not_tail_called) +#define DISPATCH_NOT_TAIL_CALLED __attribute__((__not_tail_called__)) +#else +#define DISPATCH_NOT_TAIL_CALLED +#endif + +#if __has_builtin(__builtin_assume) +#define DISPATCH_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr) +#else +#define DISPATCH_COMPILER_CAN_ASSUME(expr) ((void)(expr)) +#endif + +#if __has_attribute(noescape) +#define DISPATCH_NOESCAPE __attribute__((__noescape__)) +#else +#define DISPATCH_NOESCAPE +#endif + +#if __has_attribute(cold) +#define DISPATCH_COLD __attribute__((__cold__)) +#else +#define DISPATCH_COLD +#endif + +#if __has_feature(assume_nonnull) +#define DISPATCH_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +#define DISPATCH_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +#define DISPATCH_ASSUME_NONNULL_BEGIN +#define DISPATCH_ASSUME_NONNULL_END +#endif + +#if !__has_feature(nullability) +#ifndef _Nullable +#define _Nullable +#endif +#ifndef _Nonnull +#define _Nonnull +#endif +#ifndef _Null_unspecified +#define _Null_unspecified +#endif +#endif + +#ifndef DISPATCH_RETURNS_RETAINED_BLOCK +#if __has_attribute(ns_returns_retained) +#define DISPATCH_RETURNS_RETAINED_BLOCK __attribute__((__ns_returns_retained__)) +#else +#define DISPATCH_RETURNS_RETAINED_BLOCK +#endif +#endif + +#if __has_attribute(enum_extensibility) +#define __DISPATCH_ENUM_ATTR __attribute__((__enum_extensibility__(open))) +#define __DISPATCH_ENUM_ATTR_CLOSED __attribute__((__enum_extensibility__(closed))) +#else +#define __DISPATCH_ENUM_ATTR +#define __DISPATCH_ENUM_ATTR_CLOSED +#endif // __has_attribute(enum_extensibility) + +#if __has_attribute(flag_enum) +#define __DISPATCH_OPTIONS_ATTR __attribute__((__flag_enum__)) +#else +#define __DISPATCH_OPTIONS_ATTR +#endif // __has_attribute(flag_enum) + + +#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums) || \ + __has_extension(cxx_fixed_enum) || defined(_WIN32) +#define DISPATCH_ENUM(name, type, ...) \ + typedef enum : type { __VA_ARGS__ } __DISPATCH_ENUM_ATTR name##_t +#define DISPATCH_OPTIONS(name, type, ...) \ + typedef enum : type { __VA_ARGS__ } __DISPATCH_OPTIONS_ATTR __DISPATCH_ENUM_ATTR name##_t +#else +#define DISPATCH_ENUM(name, type, ...) \ + enum { __VA_ARGS__ } __DISPATCH_ENUM_ATTR; typedef type name##_t +#define DISPATCH_OPTIONS(name, type, ...) \ + enum { __VA_ARGS__ } __DISPATCH_OPTIONS_ATTR __DISPATCH_ENUM_ATTR; typedef type name##_t +#endif // __has_feature(objc_fixed_enum) ... + + + +#if __has_feature(enumerator_attributes) +#define DISPATCH_ENUM_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__) +#define DISPATCH_ENUM_API_DEPRECATED(...) API_DEPRECATED(__VA_ARGS__) +#define DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...) \ + API_DEPRECATED_WITH_REPLACEMENT(__VA_ARGS__) +#else +#define DISPATCH_ENUM_API_AVAILABLE(...) +#define DISPATCH_ENUM_API_DEPRECATED(...) +#define DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...) +#endif + +#ifdef __swift__ +#define DISPATCH_SWIFT3_OVERLAY 1 +#else // __swift__ +#define DISPATCH_SWIFT3_OVERLAY 0 +#endif // __swift__ + +#if __has_feature(attribute_availability_swift) +#define DISPATCH_SWIFT_UNAVAILABLE(_msg) \ + __attribute__((__availability__(swift, unavailable, message=_msg))) +#else +#define DISPATCH_SWIFT_UNAVAILABLE(_msg) +#endif + +#if DISPATCH_SWIFT3_OVERLAY +#define DISPATCH_SWIFT3_UNAVAILABLE(_msg) DISPATCH_SWIFT_UNAVAILABLE(_msg) +#else +#define DISPATCH_SWIFT3_UNAVAILABLE(_msg) +#endif + +#if __has_attribute(swift_private) +#define DISPATCH_REFINED_FOR_SWIFT __attribute__((__swift_private__)) +#else +#define DISPATCH_REFINED_FOR_SWIFT +#endif + +#if __has_attribute(swift_name) +#define DISPATCH_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name))) +#else +#define DISPATCH_SWIFT_NAME(_name) +#endif + +#ifndef __cplusplus +#define DISPATCH_TRANSPARENT_UNION __attribute__((__transparent_union__)) +#else +#define DISPATCH_TRANSPARENT_UNION +#endif + +typedef void (*dispatch_function_t)(void *_Nullable); + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/block.h b/lib/libc/include/x86_64-macos-gnu/dispatch/block.h new file mode 100644 index 0000000000..6aa3c8f2d1 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/block.h @@ -0,0 +1,428 @@ +/* + * Copyright (c) 2014 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_BLOCK__ +#define __DISPATCH_BLOCK__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +#ifdef __BLOCKS__ + +/*! + * @group Dispatch block objects + */ + +DISPATCH_ASSUME_NONNULL_BEGIN + +__BEGIN_DECLS + +/*! + * @typedef dispatch_block_flags_t + * Flags to pass to the dispatch_block_create* functions. + * + * @const DISPATCH_BLOCK_BARRIER + * Flag indicating that a dispatch block object should act as a barrier block + * when submitted to a DISPATCH_QUEUE_CONCURRENT queue. + * See dispatch_barrier_async() for details. + * This flag has no effect when the dispatch block object is invoked directly. + * + * @const DISPATCH_BLOCK_DETACHED + * Flag indicating that a dispatch block object should execute disassociated + * from current execution context attributes such as os_activity_t + * and properties of the current IPC request (if any). With regard to QoS class, + * the behavior is the same as for DISPATCH_BLOCK_NO_QOS. If invoked directly, + * the block object will remove the other attributes from the calling thread for + * the duration of the block body (before applying attributes assigned to the + * block object, if any). If submitted to a queue, the block object will be + * executed with the attributes of the queue (or any attributes specifically + * assigned to the block object). + * + * @const DISPATCH_BLOCK_ASSIGN_CURRENT + * Flag indicating that a dispatch block object should be assigned the execution + * context attributes that are current at the time the block object is created. + * This applies to attributes such as QOS class, os_activity_t and properties of + * the current IPC request (if any). If invoked directly, the block object will + * apply these attributes to the calling thread for the duration of the block + * body. If the block object is submitted to a queue, this flag replaces the + * default behavior of associating the submitted block instance with the + * execution context attributes that are current at the time of submission. + * If a specific QOS class is assigned with DISPATCH_BLOCK_NO_QOS_CLASS or + * dispatch_block_create_with_qos_class(), that QOS class takes precedence over + * the QOS class assignment indicated by this flag. + * + * @const DISPATCH_BLOCK_NO_QOS_CLASS + * Flag indicating that a dispatch block object should be not be assigned a QOS + * class. If invoked directly, the block object will be executed with the QOS + * class of the calling thread. If the block object is submitted to a queue, + * this replaces the default behavior of associating the submitted block + * instance with the QOS class current at the time of submission. + * This flag is ignored if a specific QOS class is assigned with + * dispatch_block_create_with_qos_class(). + * + * @const DISPATCH_BLOCK_INHERIT_QOS_CLASS + * Flag indicating that execution of a dispatch block object submitted to a + * queue should prefer the QOS class assigned to the queue over the QOS class + * assigned to the block (resp. associated with the block at the time of + * submission). The latter will only be used if the queue in question does not + * have an assigned QOS class, as long as doing so does not result in a QOS + * class lower than the QOS class inherited from the queue's target queue. + * This flag is the default when a dispatch block object is submitted to a queue + * for asynchronous execution and has no effect when the dispatch block object + * is invoked directly. It is ignored if DISPATCH_BLOCK_ENFORCE_QOS_CLASS is + * also passed. + * + * @const DISPATCH_BLOCK_ENFORCE_QOS_CLASS + * Flag indicating that execution of a dispatch block object submitted to a + * queue should prefer the QOS class assigned to the block (resp. associated + * with the block at the time of submission) over the QOS class assigned to the + * queue, as long as doing so will not result in a lower QOS class. + * This flag is the default when a dispatch block object is submitted to a queue + * for synchronous execution or when the dispatch block object is invoked + * directly. + */ +DISPATCH_OPTIONS(dispatch_block_flags, unsigned long, + DISPATCH_BLOCK_BARRIER + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x1, + DISPATCH_BLOCK_DETACHED + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x2, + DISPATCH_BLOCK_ASSIGN_CURRENT + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x4, + DISPATCH_BLOCK_NO_QOS_CLASS + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x8, + DISPATCH_BLOCK_INHERIT_QOS_CLASS + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x10, + DISPATCH_BLOCK_ENFORCE_QOS_CLASS + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x20, +); + +/*! + * @function dispatch_block_create + * + * @abstract + * Create a new dispatch block object on the heap from an existing block and + * the given flags. + * + * @discussion + * The provided block is Block_copy'ed to the heap and retained by the newly + * created dispatch block object. + * + * The returned dispatch block object is intended to be submitted to a dispatch + * queue with dispatch_async() and related functions, but may also be invoked + * directly. Both operations can be performed an arbitrary number of times but + * only the first completed execution of a dispatch block object can be waited + * on with dispatch_block_wait() or observed with dispatch_block_notify(). + * + * If the returned dispatch block object is submitted to a dispatch queue, the + * submitted block instance will be associated with the QOS class current at the + * time of submission, unless one of the following flags assigned a specific QOS + * class (or no QOS class) at the time of block creation: + * - DISPATCH_BLOCK_ASSIGN_CURRENT + * - DISPATCH_BLOCK_NO_QOS_CLASS + * - DISPATCH_BLOCK_DETACHED + * The QOS class the block object will be executed with also depends on the QOS + * class assigned to the queue and which of the following flags was specified or + * defaulted to: + * - DISPATCH_BLOCK_INHERIT_QOS_CLASS (default for asynchronous execution) + * - DISPATCH_BLOCK_ENFORCE_QOS_CLASS (default for synchronous execution) + * See description of dispatch_block_flags_t for details. + * + * If the returned dispatch block object is submitted directly to a serial queue + * and is configured to execute with a specific QOS class, the system will make + * a best effort to apply the necessary QOS overrides to ensure that blocks + * submitted earlier to the serial queue are executed at that same QOS class or + * higher. + * + * @param flags + * Configuration flags for the block object. + * Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t + * results in NULL being returned. + * + * @param block + * The block to create the dispatch block object from. + * + * @result + * The newly created dispatch block object, or NULL. + * When not building with Objective-C ARC, must be released with a -[release] + * message or the Block_release() function. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_RETURNS_RETAINED_BLOCK +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_block_t +dispatch_block_create(dispatch_block_flags_t flags, dispatch_block_t block); + +/*! + * @function dispatch_block_create_with_qos_class + * + * @abstract + * Create a new dispatch block object on the heap from an existing block and + * the given flags, and assign it the specified QOS class and relative priority. + * + * @discussion + * The provided block is Block_copy'ed to the heap and retained by the newly + * created dispatch block object. + * + * The returned dispatch block object is intended to be submitted to a dispatch + * queue with dispatch_async() and related functions, but may also be invoked + * directly. Both operations can be performed an arbitrary number of times but + * only the first completed execution of a dispatch block object can be waited + * on with dispatch_block_wait() or observed with dispatch_block_notify(). + * + * If invoked directly, the returned dispatch block object will be executed with + * the assigned QOS class as long as that does not result in a lower QOS class + * than what is current on the calling thread. + * + * If the returned dispatch block object is submitted to a dispatch queue, the + * QOS class it will be executed with depends on the QOS class assigned to the + * block, the QOS class assigned to the queue and which of the following flags + * was specified or defaulted to: + * - DISPATCH_BLOCK_INHERIT_QOS_CLASS: default for asynchronous execution + * - DISPATCH_BLOCK_ENFORCE_QOS_CLASS: default for synchronous execution + * See description of dispatch_block_flags_t for details. + * + * If the returned dispatch block object is submitted directly to a serial queue + * and is configured to execute with a specific QOS class, the system will make + * a best effort to apply the necessary QOS overrides to ensure that blocks + * submitted earlier to the serial queue are executed at that same QOS class or + * higher. + * + * @param flags + * Configuration flags for the new block object. + * Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t + * results in NULL being returned. + * + * @param qos_class + * A QOS class value: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * - QOS_CLASS_UNSPECIFIED + * Passing QOS_CLASS_UNSPECIFIED is equivalent to specifying the + * DISPATCH_BLOCK_NO_QOS_CLASS flag. Passing any other value results in NULL + * being returned. + * + * @param relative_priority + * A relative priority within the QOS class. This value is a negative + * offset from the maximum supported scheduler priority for the given class. + * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY + * results in NULL being returned. + * + * @param block + * The block to create the dispatch block object from. + * + * @result + * The newly created dispatch block object, or NULL. + * When not building with Objective-C ARC, must be released with a -[release] + * message or the Block_release() function. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_RETURNS_RETAINED_BLOCK +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_block_t +dispatch_block_create_with_qos_class(dispatch_block_flags_t flags, + dispatch_qos_class_t qos_class, int relative_priority, + dispatch_block_t block); + +/*! + * @function dispatch_block_perform + * + * @abstract + * Create, synchronously execute and release a dispatch block object from the + * specified block and flags. + * + * @discussion + * Behaves identically to the sequence + * + * dispatch_block_t b = dispatch_block_create(flags, block); + * b(); + * Block_release(b); + * + * but may be implemented more efficiently internally by not requiring a copy + * to the heap of the specified block or the allocation of a new block object. + * + * @param flags + * Configuration flags for the temporary block object. + * The result of passing a value that is not a bitwise OR of flags from + * dispatch_block_flags_t is undefined. + * + * @param block + * The block to create the temporary block object from. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW +void +dispatch_block_perform(dispatch_block_flags_t flags, + DISPATCH_NOESCAPE dispatch_block_t block); + +/*! + * @function dispatch_block_wait + * + * @abstract + * Wait synchronously until execution of the specified dispatch block object has + * completed or until the specified timeout has elapsed. + * + * @discussion + * This function will return immediately if execution of the block object has + * already completed. + * + * It is not possible to wait for multiple executions of the same block object + * with this interface; use dispatch_group_wait() for that purpose. A single + * dispatch block object may either be waited on once and executed once, + * or it may be executed any number of times. The behavior of any other + * combination is undefined. Submission to a dispatch queue counts as an + * execution, even if cancellation (dispatch_block_cancel) means the block's + * code never runs. + * + * The result of calling this function from multiple threads simultaneously + * with the same dispatch block object is undefined, but note that doing so + * would violate the rules described in the previous paragraph. + * + * If this function returns indicating that the specified timeout has elapsed, + * then that invocation does not count as the one allowed wait. + * + * If at the time this function is called, the specified dispatch block object + * has been submitted directly to a serial queue, the system will make a best + * effort to apply the necessary QOS overrides to ensure that the block and any + * blocks submitted earlier to that serial queue are executed at the QOS class + * (or higher) of the thread calling dispatch_block_wait(). + * + * @param block + * The dispatch block object to wait on. + * The result of passing NULL or a block object not returned by one of the + * dispatch_block_create* functions is undefined. + * + * @param timeout + * When to timeout (see dispatch_time). As a convenience, there are the + * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants. + * + * @result + * Returns zero on success (the dispatch block object completed within the + * specified timeout) or non-zero on error (i.e. timed out). + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +intptr_t +dispatch_block_wait(dispatch_block_t block, dispatch_time_t timeout); + +/*! + * @function dispatch_block_notify + * + * @abstract + * Schedule a notification block to be submitted to a queue when the execution + * of a specified dispatch block object has completed. + * + * @discussion + * This function will submit the notification block immediately if execution of + * the observed block object has already completed. + * + * It is not possible to be notified of multiple executions of the same block + * object with this interface, use dispatch_group_notify() for that purpose. + * + * A single dispatch block object may either be observed one or more times + * and executed once, or it may be executed any number of times. The behavior + * of any other combination is undefined. Submission to a dispatch queue + * counts as an execution, even if cancellation (dispatch_block_cancel) means + * the block's code never runs. + * + * If multiple notification blocks are scheduled for a single block object, + * there is no defined order in which the notification blocks will be submitted + * to their associated queues. + * + * @param block + * The dispatch block object to observe. + * The result of passing NULL or a block object not returned by one of the + * dispatch_block_create* functions is undefined. + * + * @param queue + * The queue to which the supplied notification block will be submitted when + * the observed block completes. + * + * @param notification_block + * The notification block to submit when the observed block object completes. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_block_notify(dispatch_block_t block, dispatch_queue_t queue, + dispatch_block_t notification_block); + +/*! + * @function dispatch_block_cancel + * + * @abstract + * Asynchronously cancel the specified dispatch block object. + * + * @discussion + * Cancellation causes any future execution of the dispatch block object to + * return immediately, but does not affect any execution of the block object + * that is already in progress. + * + * Release of any resources associated with the block object will be delayed + * until execution of the block object is next attempted (or any execution + * already in progress completes). + * + * NOTE: care needs to be taken to ensure that a block object that may be + * canceled does not capture any resources that require execution of the + * block body in order to be released (e.g. memory allocated with + * malloc(3) that the block body calls free(3) on). Such resources will + * be leaked if the block body is never executed due to cancellation. + * + * @param block + * The dispatch block object to cancel. + * The result of passing NULL or a block object not returned by one of the + * dispatch_block_create* functions is undefined. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_block_cancel(dispatch_block_t block); + +/*! + * @function dispatch_block_testcancel + * + * @abstract + * Tests whether the given dispatch block object has been canceled. + * + * @param block + * The dispatch block object to test. + * The result of passing NULL or a block object not returned by one of the + * dispatch_block_create* functions is undefined. + * + * @result + * Non-zero if canceled and zero if not canceled. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +intptr_t +dispatch_block_testcancel(dispatch_block_t block); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif // __BLOCKS__ + +#endif // __DISPATCH_BLOCK__ diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/data.h b/lib/libc/include/x86_64-macos-gnu/dispatch/data.h new file mode 100644 index 0000000000..8250669183 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/data.h @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2009-2013 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_DATA__ +#define __DISPATCH_DATA__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +__BEGIN_DECLS + +/*! @header + * Dispatch data objects describe contiguous or sparse regions of memory that + * may be managed by the system or by the application. + * Dispatch data objects are immutable, any direct access to memory regions + * represented by dispatch objects must not modify that memory. + */ + +/*! + * @typedef dispatch_data_t + * A dispatch object representing memory regions. + */ +DISPATCH_DATA_DECL(dispatch_data); + +/*! + * @var dispatch_data_empty + * @discussion The singleton dispatch data object representing a zero-length + * memory region. + */ +#define dispatch_data_empty \ + DISPATCH_GLOBAL_OBJECT(dispatch_data_t, _dispatch_data_empty) +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT struct dispatch_data_s _dispatch_data_empty; + +/*! + * @const DISPATCH_DATA_DESTRUCTOR_DEFAULT + * @discussion The default destructor for dispatch data objects. + * Used at data object creation to indicate that the supplied buffer should + * be copied into internal storage managed by the system. + */ +#define DISPATCH_DATA_DESTRUCTOR_DEFAULT NULL + +#ifdef __BLOCKS__ +/*! @parseOnly */ +#define DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(name) \ + DISPATCH_EXPORT const dispatch_block_t _dispatch_data_destructor_##name +#else +#define DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(name) \ + DISPATCH_EXPORT const dispatch_function_t \ + _dispatch_data_destructor_##name +#endif /* __BLOCKS__ */ + +/*! + * @const DISPATCH_DATA_DESTRUCTOR_FREE + * @discussion The destructor for dispatch data objects created from a malloc'd + * buffer. Used at data object creation to indicate that the supplied buffer + * was allocated by the malloc() family and should be destroyed with free(3). + */ +#define DISPATCH_DATA_DESTRUCTOR_FREE (_dispatch_data_destructor_free) +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(free); + +/*! + * @const DISPATCH_DATA_DESTRUCTOR_MUNMAP + * @discussion The destructor for dispatch data objects that have been created + * from buffers that require deallocation with munmap(2). + */ +#define DISPATCH_DATA_DESTRUCTOR_MUNMAP (_dispatch_data_destructor_munmap) +API_AVAILABLE(macos(10.9), ios(7.0)) +DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(munmap); + +#ifdef __BLOCKS__ +/*! + * @function dispatch_data_create + * Creates a dispatch data object from the given contiguous buffer of memory. If + * a non-default destructor is provided, ownership of the buffer remains with + * the caller (i.e. the bytes will not be copied). The last release of the data + * object will result in the invocation of the specified destructor on the + * specified queue to free the buffer. + * + * If the DISPATCH_DATA_DESTRUCTOR_FREE destructor is provided the buffer will + * be freed via free(3) and the queue argument ignored. + * + * If the DISPATCH_DATA_DESTRUCTOR_DEFAULT destructor is provided, data object + * creation will copy the buffer into internal memory managed by the system. + * + * @param buffer A contiguous buffer of data. + * @param size The size of the contiguous buffer of data. + * @param queue The queue to which the destructor should be submitted. + * @param destructor The destructor responsible for freeing the data when it + * is no longer needed. + * @result A newly created dispatch data object. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_data_t +dispatch_data_create(const void *buffer, + size_t size, + dispatch_queue_t _Nullable queue, + dispatch_block_t _Nullable destructor); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_data_get_size + * Returns the logical size of the memory region(s) represented by the specified + * dispatch data object. + * + * @param data The dispatch data object to query. + * @result The number of bytes represented by the data object. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_PURE DISPATCH_NONNULL1 DISPATCH_NOTHROW +size_t +dispatch_data_get_size(dispatch_data_t data); + +/*! + * @function dispatch_data_create_map + * Maps the memory represented by the specified dispatch data object as a single + * contiguous memory region and returns a new data object representing it. + * If non-NULL references to a pointer and a size variable are provided, they + * are filled with the location and extent of that region. These allow direct + * read access to the represented memory, but are only valid until the returned + * object is released. Under ARC, if that object is held in a variable with + * automatic storage, care needs to be taken to ensure that it is not released + * by the compiler before memory access via the pointer has been completed. + * + * @param data The dispatch data object to map. + * @param buffer_ptr A pointer to a pointer variable to be filled with the + * location of the mapped contiguous memory region, or + * NULL. + * @param size_ptr A pointer to a size_t variable to be filled with the + * size of the mapped contiguous memory region, or NULL. + * @result A newly created dispatch data object. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_RETURNS_RETAINED +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_data_t +dispatch_data_create_map(dispatch_data_t data, + const void *_Nullable *_Nullable buffer_ptr, + size_t *_Nullable size_ptr); + +/*! + * @function dispatch_data_create_concat + * Returns a new dispatch data object representing the concatenation of the + * specified data objects. Those objects may be released by the application + * after the call returns (however, the system might not deallocate the memory + * region(s) described by them until the newly created object has also been + * released). + * + * @param data1 The data object representing the region(s) of memory to place + * at the beginning of the newly created object. + * @param data2 The data object representing the region(s) of memory to place + * at the end of the newly created object. + * @result A newly created object representing the concatenation of the + * data1 and data2 objects. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_RETURNS_RETAINED +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_data_t +dispatch_data_create_concat(dispatch_data_t data1, dispatch_data_t data2); + +/*! + * @function dispatch_data_create_subrange + * Returns a new dispatch data object representing a subrange of the specified + * data object, which may be released by the application after the call returns + * (however, the system might not deallocate the memory region(s) described by + * that object until the newly created object has also been released). + * + * @param data The data object representing the region(s) of memory to + * create a subrange of. + * @param offset The offset into the data object where the subrange + * starts. + * @param length The length of the range. + * @result A newly created object representing the specified + * subrange of the data object. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_RETURNS_RETAINED +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_data_t +dispatch_data_create_subrange(dispatch_data_t data, + size_t offset, + size_t length); + +#ifdef __BLOCKS__ +/*! + * @typedef dispatch_data_applier_t + * A block to be invoked for every contiguous memory region in a data object. + * + * @param region A data object representing the current region. + * @param offset The logical offset of the current region to the start + * of the data object. + * @param buffer The location of the memory for the current region. + * @param size The size of the memory for the current region. + * @result A Boolean indicating whether traversal should continue. + */ +typedef bool (^dispatch_data_applier_t)(dispatch_data_t region, + size_t offset, + const void *buffer, + size_t size); + +/*! + * @function dispatch_data_apply + * Traverse the memory regions represented by the specified dispatch data object + * in logical order and invoke the specified block once for every contiguous + * memory region encountered. + * + * Each invocation of the block is passed a data object representing the current + * region and its logical offset, along with the memory location and extent of + * the region. These allow direct read access to the memory region, but are only + * valid until the passed-in region object is released. Note that the region + * object is released by the system when the block returns, it is the + * responsibility of the application to retain it if the region object or the + * associated memory location are needed after the block returns. + * + * @param data The data object to traverse. + * @param applier The block to be invoked for every contiguous memory + * region in the data object. + * @result A Boolean indicating whether traversal completed + * successfully. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +bool +dispatch_data_apply(dispatch_data_t data, + DISPATCH_NOESCAPE dispatch_data_applier_t applier); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_data_copy_region + * Finds the contiguous memory region containing the specified location among + * the regions represented by the specified object and returns a copy of the + * internal dispatch data object representing that region along with its logical + * offset in the specified object. + * + * @param data The dispatch data object to query. + * @param location The logical position in the data object to query. + * @param offset_ptr A pointer to a size_t variable to be filled with the + * logical offset of the returned region object to the + * start of the queried data object. + * @result A newly created dispatch data object. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_RETURNS_RETAINED +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_data_t +dispatch_data_copy_region(dispatch_data_t data, + size_t location, + size_t *offset_ptr); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif /* __DISPATCH_DATA__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/dispatch.h b/lib/libc/include/x86_64-macos-gnu/dispatch/dispatch.h new file mode 100644 index 0000000000..8a22e488c0 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/dispatch.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2008-2013 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_PUBLIC__ +#define __DISPATCH_PUBLIC__ + +#ifdef __APPLE__ +#include +#include +#include +#include +#elif defined(_WIN32) +#include +#elif defined(__unix__) +#include +#endif + +#include +#include +#include +#include +#include +#include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#include +#endif +#include +#if defined(_WIN32) +#include +#endif + +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__has_feature) +#if __has_feature(modules) +#if !defined(__arm__) +#include // for off_t (to match Glibc.modulemap) +#endif +#endif +#endif + +#define DISPATCH_API_VERSION 20181008 + +#ifndef __DISPATCH_INDIRECT__ +#define __DISPATCH_INDIRECT__ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#undef __DISPATCH_INDIRECT__ + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/group.h b/lib/libc/include/x86_64-macos-gnu/dispatch/group.h new file mode 100644 index 0000000000..6b30b26c6e --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/group.h @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2008-2013 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_GROUP__ +#define __DISPATCH_GROUP__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @typedef dispatch_group_t + * @abstract + * A group of blocks submitted to queues for asynchronous invocation. + */ +DISPATCH_DECL(dispatch_group); + +__BEGIN_DECLS + +/*! + * @function dispatch_group_create + * + * @abstract + * Creates new group with which blocks may be associated. + * + * @discussion + * This function creates a new group with which blocks may be associated. + * The dispatch group may be used to wait for the completion of the blocks it + * references. The group object memory is freed with dispatch_release(). + * + * @result + * The newly created group, or NULL on failure. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_group_t +dispatch_group_create(void); + +/*! + * @function dispatch_group_async + * + * @abstract + * Submits a block to a dispatch queue and associates the block with the given + * dispatch group. + * + * @discussion + * Submits a block to a dispatch queue and associates the block with the given + * dispatch group. The dispatch group may be used to wait for the completion + * of the blocks it references. + * + * @param group + * A dispatch group to associate with the submitted block. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The dispatch queue to which the block will be submitted for asynchronous + * invocation. + * + * @param block + * The block to perform asynchronously. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_group_async(dispatch_group_t group, + dispatch_queue_t queue, + dispatch_block_t block); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_group_async_f + * + * @abstract + * Submits a function to a dispatch queue and associates the block with the + * given dispatch group. + * + * @discussion + * See dispatch_group_async() for details. + * + * @param group + * A dispatch group to associate with the submitted function. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The dispatch queue to which the function will be submitted for asynchronous + * invocation. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_group_async_f(). + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_NONNULL4 +DISPATCH_NOTHROW +void +dispatch_group_async_f(dispatch_group_t group, + dispatch_queue_t queue, + void *_Nullable context, + dispatch_function_t work); + +/*! + * @function dispatch_group_wait + * + * @abstract + * Wait synchronously until all the blocks associated with a group have + * completed or until the specified timeout has elapsed. + * + * @discussion + * This function waits for the completion of the blocks associated with the + * given dispatch group, and returns after all blocks have completed or when + * the specified timeout has elapsed. + * + * This function will return immediately if there are no blocks associated + * with the dispatch group (i.e. the group is empty). + * + * The result of calling this function from multiple threads simultaneously + * with the same dispatch group is undefined. + * + * After the successful return of this function, the dispatch group is empty. + * It may either be released with dispatch_release() or re-used for additional + * blocks. See dispatch_group_async() for more information. + * + * @param group + * The dispatch group to wait on. + * The result of passing NULL in this parameter is undefined. + * + * @param timeout + * When to timeout (see dispatch_time). As a convenience, there are the + * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants. + * + * @result + * Returns zero on success (all blocks associated with the group completed + * within the specified timeout) or non-zero on error (i.e. timed out). + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +intptr_t +dispatch_group_wait(dispatch_group_t group, dispatch_time_t timeout); + +/*! + * @function dispatch_group_notify + * + * @abstract + * Schedule a block to be submitted to a queue when all the blocks associated + * with a group have completed. + * + * @discussion + * This function schedules a notification block to be submitted to the specified + * queue once all blocks associated with the dispatch group have completed. + * + * If no blocks are associated with the dispatch group (i.e. the group is empty) + * then the notification block will be submitted immediately. + * + * The group will be empty at the time the notification block is submitted to + * the target queue. The group may either be released with dispatch_release() + * or reused for additional operations. + * See dispatch_group_async() for more information. + * + * @param group + * The dispatch group to observe. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The queue to which the supplied block will be submitted when the group + * completes. + * + * @param block + * The block to submit when the group completes. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_group_notify(dispatch_group_t group, + dispatch_queue_t queue, + dispatch_block_t block); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_group_notify_f + * + * @abstract + * Schedule a function to be submitted to a queue when all the blocks + * associated with a group have completed. + * + * @discussion + * See dispatch_group_notify() for details. + * + * @param group + * The dispatch group to observe. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_group_notify_f(). + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_NONNULL4 +DISPATCH_NOTHROW +void +dispatch_group_notify_f(dispatch_group_t group, + dispatch_queue_t queue, + void *_Nullable context, + dispatch_function_t work); + +/*! + * @function dispatch_group_enter + * + * @abstract + * Manually indicate a block has entered the group + * + * @discussion + * Calling this function indicates another block has joined the group through + * a means other than dispatch_group_async(). Calls to this function must be + * balanced with dispatch_group_leave(). + * + * @param group + * The dispatch group to update. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_group_enter(dispatch_group_t group); + +/*! + * @function dispatch_group_leave + * + * @abstract + * Manually indicate a block in the group has completed + * + * @discussion + * Calling this function indicates block has completed and left the dispatch + * group by a means other than dispatch_group_async(). + * + * @param group + * The dispatch group to update. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_group_leave(dispatch_group_t group); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/io.h b/lib/libc/include/x86_64-macos-gnu/dispatch/io.h new file mode 100644 index 0000000000..db9733d829 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/io.h @@ -0,0 +1,597 @@ +/* + * Copyright (c) 2009-2013 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_IO__ +#define __DISPATCH_IO__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +__BEGIN_DECLS + +/*! @header + * Dispatch I/O provides both stream and random access asynchronous read and + * write operations on file descriptors. One or more dispatch I/O channels may + * be created from a file descriptor as either the DISPATCH_IO_STREAM type or + * DISPATCH_IO_RANDOM type. Once a channel has been created the application may + * schedule asynchronous read and write operations. + * + * The application may set policies on the dispatch I/O channel to indicate the + * desired frequency of I/O handlers for long-running operations. + * + * Dispatch I/O also provides a memory management model for I/O buffers that + * avoids unnecessary copying of data when pipelined between channels. Dispatch + * I/O monitors the overall memory pressure and I/O access patterns for the + * application to optimize resource utilization. + */ + +/*! + * @typedef dispatch_fd_t + * Native file descriptor type for the platform. + */ +#if defined(_WIN32) +typedef intptr_t dispatch_fd_t; +#else +typedef int dispatch_fd_t; +#endif + +/*! + * @functiongroup Dispatch I/O Convenience API + * Convenience wrappers around the dispatch I/O channel API, with simpler + * callback handler semantics and no explicit management of channel objects. + * File descriptors passed to the convenience API are treated as streams, and + * scheduling multiple operations on one file descriptor via the convenience API + * may incur more overhead than by using the dispatch I/O channel API directly. + */ + +#ifdef __BLOCKS__ +/*! + * @function dispatch_read + * Schedule a read operation for asynchronous execution on the specified file + * descriptor. The specified handler is enqueued with the data read from the + * file descriptor when the operation has completed or an error occurs. + * + * The data object passed to the handler will be automatically released by the + * system when the handler returns. It is the responsibility of the application + * to retain, concatenate or copy the data object if it is needed after the + * handler returns. + * + * The data object passed to the handler will only contain as much data as is + * currently available from the file descriptor (up to the specified length). + * + * If an unrecoverable error occurs on the file descriptor, the handler will be + * enqueued with the appropriate error code along with a data object of any data + * that could be read successfully. + * + * An invocation of the handler with an error code of zero and an empty data + * object indicates that EOF was reached. + * + * The system takes control of the file descriptor until the handler is + * enqueued, and during this time file descriptor flags such as O_NONBLOCK will + * be modified by the system on behalf of the application. It is an error for + * the application to modify a file descriptor directly while it is under the + * control of the system, but it may create additional dispatch I/O convenience + * operations or dispatch I/O channels associated with that file descriptor. + * + * @param fd The file descriptor from which to read the data. + * @param length The length of data to read from the file descriptor, + * or SIZE_MAX to indicate that all of the data currently + * available from the file descriptor should be read. + * @param queue The dispatch queue to which the handler should be + * submitted. + * @param handler The handler to enqueue when data is ready to be + * delivered. + * param data The data read from the file descriptor. + * param error An errno condition for the read operation or + * zero if the read was successful. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW +void +dispatch_read(dispatch_fd_t fd, + size_t length, + dispatch_queue_t queue, + void (^handler)(dispatch_data_t data, int error)); + +/*! + * @function dispatch_write + * Schedule a write operation for asynchronous execution on the specified file + * descriptor. The specified handler is enqueued when the operation has + * completed or an error occurs. + * + * If an unrecoverable error occurs on the file descriptor, the handler will be + * enqueued with the appropriate error code along with the data that could not + * be successfully written. + * + * An invocation of the handler with an error code of zero indicates that the + * data was fully written to the channel. + * + * The system takes control of the file descriptor until the handler is + * enqueued, and during this time file descriptor flags such as O_NONBLOCK will + * be modified by the system on behalf of the application. It is an error for + * the application to modify a file descriptor directly while it is under the + * control of the system, but it may create additional dispatch I/O convenience + * operations or dispatch I/O channels associated with that file descriptor. + * + * @param fd The file descriptor to which to write the data. + * @param data The data object to write to the file descriptor. + * @param queue The dispatch queue to which the handler should be + * submitted. + * @param handler The handler to enqueue when the data has been written. + * param data The data that could not be written to the I/O + * channel, or NULL. + * param error An errno condition for the write operation or + * zero if the write was successful. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NONNULL4 +DISPATCH_NOTHROW +void +dispatch_write(dispatch_fd_t fd, + dispatch_data_t data, + dispatch_queue_t queue, + void (^handler)(dispatch_data_t _Nullable data, int error)); +#endif /* __BLOCKS__ */ + +/*! + * @functiongroup Dispatch I/O Channel API + */ + +/*! + * @typedef dispatch_io_t + * A dispatch I/O channel represents the asynchronous I/O policy applied to a + * file descriptor. I/O channels are first class dispatch objects and may be + * retained and released, suspended and resumed, etc. + */ +DISPATCH_DECL(dispatch_io); + +/*! + * @typedef dispatch_io_type_t + * The type of a dispatch I/O channel: + * + * @const DISPATCH_IO_STREAM A dispatch I/O channel representing a stream of + * bytes. Read and write operations on a channel of this type are performed + * serially (in order of creation) and read/write data at the file pointer + * position that is current at the time the operation starts executing. + * Operations of different type (read vs. write) may be performed simultaneously. + * Offsets passed to operations on a channel of this type are ignored. + * + * @const DISPATCH_IO_RANDOM A dispatch I/O channel representing a random + * access file. Read and write operations on a channel of this type may be + * performed concurrently and read/write data at the specified offset. Offsets + * are interpreted relative to the file pointer position current at the time the + * I/O channel is created. Attempting to create a channel of this type for a + * file descriptor that is not seekable will result in an error. + */ +#define DISPATCH_IO_STREAM 0 +#define DISPATCH_IO_RANDOM 1 + +typedef unsigned long dispatch_io_type_t; + +#ifdef __BLOCKS__ +/*! + * @function dispatch_io_create + * Create a dispatch I/O channel associated with a file descriptor. The system + * takes control of the file descriptor until the channel is closed, an error + * occurs on the file descriptor or all references to the channel are released. + * At that time the specified cleanup handler will be enqueued and control over + * the file descriptor relinquished. + * + * While a file descriptor is under the control of a dispatch I/O channel, file + * descriptor flags such as O_NONBLOCK will be modified by the system on behalf + * of the application. It is an error for the application to modify a file + * descriptor directly while it is under the control of a dispatch I/O channel, + * but it may create additional channels associated with that file descriptor. + * + * @param type The desired type of I/O channel (DISPATCH_IO_STREAM + * or DISPATCH_IO_RANDOM). + * @param fd The file descriptor to associate with the I/O channel. + * @param queue The dispatch queue to which the handler should be submitted. + * @param cleanup_handler The handler to enqueue when the system + * relinquishes control over the file descriptor. + * param error An errno condition if control is relinquished + * because channel creation failed, zero otherwise. + * @result The newly created dispatch I/O channel or NULL if an error + * occurred (invalid type specified). + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_io_t +dispatch_io_create(dispatch_io_type_t type, + dispatch_fd_t fd, + dispatch_queue_t queue, + void (^cleanup_handler)(int error)); + +/*! + * @function dispatch_io_create_with_path + * Create a dispatch I/O channel associated with a path name. The specified + * path, oflag and mode parameters will be passed to open(2) when the first I/O + * operation on the channel is ready to execute and the resulting file + * descriptor will remain open and under the control of the system until the + * channel is closed, an error occurs on the file descriptor or all references + * to the channel are released. At that time the file descriptor will be closed + * and the specified cleanup handler will be enqueued. + * + * @param type The desired type of I/O channel (DISPATCH_IO_STREAM + * or DISPATCH_IO_RANDOM). + * @param path The absolute path to associate with the I/O channel. + * @param oflag The flags to pass to open(2) when opening the file at + * path. + * @param mode The mode to pass to open(2) when creating the file at + * path (i.e. with flag O_CREAT), zero otherwise. + * @param queue The dispatch queue to which the handler should be + * submitted. + * @param cleanup_handler The handler to enqueue when the system + * has closed the file at path. + * param error An errno condition if control is relinquished + * because channel creation or opening of the + * specified file failed, zero otherwise. + * @result The newly created dispatch I/O channel or NULL if an error + * occurred (invalid type or non-absolute path specified). + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_io_t +dispatch_io_create_with_path(dispatch_io_type_t type, + const char *path, int oflag, mode_t mode, + dispatch_queue_t queue, + void (^cleanup_handler)(int error)); + +/*! + * @function dispatch_io_create_with_io + * Create a new dispatch I/O channel from an existing dispatch I/O channel. + * The new channel inherits the file descriptor or path name associated with + * the existing channel, but not its channel type or policies. + * + * If the existing channel is associated with a file descriptor, control by the + * system over that file descriptor is extended until the new channel is also + * closed, an error occurs on the file descriptor, or all references to both + * channels are released. At that time the specified cleanup handler will be + * enqueued and control over the file descriptor relinquished. + * + * While a file descriptor is under the control of a dispatch I/O channel, file + * descriptor flags such as O_NONBLOCK will be modified by the system on behalf + * of the application. It is an error for the application to modify a file + * descriptor directly while it is under the control of a dispatch I/O channel, + * but it may create additional channels associated with that file descriptor. + * + * @param type The desired type of I/O channel (DISPATCH_IO_STREAM + * or DISPATCH_IO_RANDOM). + * @param io The existing channel to create the new I/O channel from. + * @param queue The dispatch queue to which the handler should be submitted. + * @param cleanup_handler The handler to enqueue when the system + * relinquishes control over the file descriptor + * (resp. closes the file at path) associated with + * the existing channel. + * param error An errno condition if control is relinquished + * because channel creation failed, zero otherwise. + * @result The newly created dispatch I/O channel or NULL if an error + * occurred (invalid type specified). + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_io_t +dispatch_io_create_with_io(dispatch_io_type_t type, + dispatch_io_t io, + dispatch_queue_t queue, + void (^cleanup_handler)(int error)); + +/*! + * @typedef dispatch_io_handler_t + * The prototype of I/O handler blocks for dispatch I/O operations. + * + * @param done A flag indicating whether the operation is complete. + * @param data The data object to be handled. + * @param error An errno condition for the operation. + */ +typedef void (^dispatch_io_handler_t)(bool done, dispatch_data_t _Nullable data, + int error); + +/*! + * @function dispatch_io_read + * Schedule a read operation for asynchronous execution on the specified I/O + * channel. The I/O handler is enqueued one or more times depending on the + * general load of the system and the policy specified on the I/O channel. + * + * Any data read from the channel is described by the dispatch data object + * passed to the I/O handler. This object will be automatically released by the + * system when the I/O handler returns. It is the responsibility of the + * application to retain, concatenate or copy the data object if it is needed + * after the I/O handler returns. + * + * Dispatch I/O handlers are not reentrant. The system will ensure that no new + * I/O handler instance is invoked until the previously enqueued handler block + * has returned. + * + * An invocation of the I/O handler with the done flag set indicates that the + * read operation is complete and that the handler will not be enqueued again. + * + * If an unrecoverable error occurs on the I/O channel's underlying file + * descriptor, the I/O handler will be enqueued with the done flag set, the + * appropriate error code and a NULL data object. + * + * An invocation of the I/O handler with the done flag set, an error code of + * zero and an empty data object indicates that EOF was reached. + * + * @param channel The dispatch I/O channel from which to read the data. + * @param offset The offset relative to the channel position from which + * to start reading (only for DISPATCH_IO_RANDOM). + * @param length The length of data to read from the I/O channel, or + * SIZE_MAX to indicate that data should be read until EOF + * is reached. + * @param queue The dispatch queue to which the I/O handler should be + * submitted. + * @param io_handler The I/O handler to enqueue when data is ready to be + * delivered. + * param done A flag indicating whether the operation is complete. + * param data An object with the data most recently read from the + * I/O channel as part of this read operation, or NULL. + * param error An errno condition for the read operation or zero if + * the read was successful. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL4 DISPATCH_NONNULL5 +DISPATCH_NOTHROW +void +dispatch_io_read(dispatch_io_t channel, + off_t offset, + size_t length, + dispatch_queue_t queue, + dispatch_io_handler_t io_handler); + +/*! + * @function dispatch_io_write + * Schedule a write operation for asynchronous execution on the specified I/O + * channel. The I/O handler is enqueued one or more times depending on the + * general load of the system and the policy specified on the I/O channel. + * + * Any data remaining to be written to the I/O channel is described by the + * dispatch data object passed to the I/O handler. This object will be + * automatically released by the system when the I/O handler returns. It is the + * responsibility of the application to retain, concatenate or copy the data + * object if it is needed after the I/O handler returns. + * + * Dispatch I/O handlers are not reentrant. The system will ensure that no new + * I/O handler instance is invoked until the previously enqueued handler block + * has returned. + * + * An invocation of the I/O handler with the done flag set indicates that the + * write operation is complete and that the handler will not be enqueued again. + * + * If an unrecoverable error occurs on the I/O channel's underlying file + * descriptor, the I/O handler will be enqueued with the done flag set, the + * appropriate error code and an object containing the data that could not be + * written. + * + * An invocation of the I/O handler with the done flag set and an error code of + * zero indicates that the data was fully written to the channel. + * + * @param channel The dispatch I/O channel on which to write the data. + * @param offset The offset relative to the channel position from which + * to start writing (only for DISPATCH_IO_RANDOM). + * @param data The data to write to the I/O channel. The data object + * will be retained by the system until the write operation + * is complete. + * @param queue The dispatch queue to which the I/O handler should be + * submitted. + * @param io_handler The I/O handler to enqueue when data has been delivered. + * param done A flag indicating whether the operation is complete. + * param data An object of the data remaining to be + * written to the I/O channel as part of this write + * operation, or NULL. + * param error An errno condition for the write operation or zero + * if the write was successful. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NONNULL4 +DISPATCH_NONNULL5 DISPATCH_NOTHROW +void +dispatch_io_write(dispatch_io_t channel, + off_t offset, + dispatch_data_t data, + dispatch_queue_t queue, + dispatch_io_handler_t io_handler); +#endif /* __BLOCKS__ */ + +/*! + * @typedef dispatch_io_close_flags_t + * The type of flags you can set on a dispatch_io_close() call + * + * @const DISPATCH_IO_STOP Stop outstanding operations on a channel when + * the channel is closed. + */ +#define DISPATCH_IO_STOP 0x1 + +typedef unsigned long dispatch_io_close_flags_t; + +/*! + * @function dispatch_io_close + * Close the specified I/O channel to new read or write operations; scheduling + * operations on a closed channel results in their handler returning an error. + * + * If the DISPATCH_IO_STOP flag is provided, the system will make a best effort + * to interrupt any outstanding read and write operations on the I/O channel, + * otherwise those operations will run to completion normally. + * Partial results of read and write operations may be returned even after a + * channel is closed with the DISPATCH_IO_STOP flag. + * The final invocation of an I/O handler of an interrupted operation will be + * passed an ECANCELED error code, as will the I/O handler of an operation + * scheduled on a closed channel. + * + * @param channel The dispatch I/O channel to close. + * @param flags The flags for the close operation. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_io_close(dispatch_io_t channel, dispatch_io_close_flags_t flags); + +#ifdef __BLOCKS__ +/*! + * @function dispatch_io_barrier + * Schedule a barrier operation on the specified I/O channel; all previously + * scheduled operations on the channel will complete before the provided + * barrier block is enqueued onto the global queue determined by the channel's + * target queue, and no subsequently scheduled operations will start until the + * barrier block has returned. + * + * If multiple channels are associated with the same file descriptor, a barrier + * operation scheduled on any of these channels will act as a barrier across all + * channels in question, i.e. all previously scheduled operations on any of the + * channels will complete before the barrier block is enqueued, and no + * operations subsequently scheduled on any of the channels will start until the + * barrier block has returned. + * + * While the barrier block is running, it may safely operate on the channel's + * underlying file descriptor with fsync(2), lseek(2) etc. (but not close(2)). + * + * @param channel The dispatch I/O channel to schedule the barrier on. + * @param barrier The barrier block. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_io_barrier(dispatch_io_t channel, dispatch_block_t barrier); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_io_get_descriptor + * Returns the file descriptor underlying a dispatch I/O channel. + * + * Will return -1 for a channel closed with dispatch_io_close() and for a + * channel associated with a path name that has not yet been open(2)ed. + * + * If called from a barrier block scheduled on a channel associated with a path + * name that has not yet been open(2)ed, this will trigger the channel open(2) + * operation and return the resulting file descriptor. + * + * @param channel The dispatch I/O channel to query. + * @result The file descriptor underlying the channel, or -1. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_fd_t +dispatch_io_get_descriptor(dispatch_io_t channel); + +/*! + * @function dispatch_io_set_high_water + * Set a high water mark on the I/O channel for all operations. + * + * The system will make a best effort to enqueue I/O handlers with partial + * results as soon the number of bytes processed by an operation (i.e. read or + * written) reaches the high water mark. + * + * The size of data objects passed to I/O handlers for this channel will never + * exceed the specified high water mark. + * + * The default value for the high water mark is unlimited (i.e. SIZE_MAX). + * + * @param channel The dispatch I/O channel on which to set the policy. + * @param high_water The number of bytes to use as a high water mark. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_io_set_high_water(dispatch_io_t channel, size_t high_water); + +/*! + * @function dispatch_io_set_low_water + * Set a low water mark on the I/O channel for all operations. + * + * The system will process (i.e. read or write) at least the low water mark + * number of bytes for an operation before enqueueing I/O handlers with partial + * results. + * + * The size of data objects passed to intermediate I/O handler invocations for + * this channel (i.e. excluding the final invocation) will never be smaller than + * the specified low water mark, except if the channel has an interval with the + * DISPATCH_IO_STRICT_INTERVAL flag set or if EOF or an error was encountered. + * + * I/O handlers should be prepared to receive amounts of data significantly + * larger than the low water mark in general. If an I/O handler requires + * intermediate results of fixed size, set both the low and and the high water + * mark to that size. + * + * The default value for the low water mark is unspecified, but must be assumed + * to be such that intermediate handler invocations may occur. + * If I/O handler invocations with partial results are not desired, set the + * low water mark to SIZE_MAX. + * + * @param channel The dispatch I/O channel on which to set the policy. + * @param low_water The number of bytes to use as a low water mark. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_io_set_low_water(dispatch_io_t channel, size_t low_water); + +/*! + * @typedef dispatch_io_interval_flags_t + * Type of flags to set on dispatch_io_set_interval() + * + * @const DISPATCH_IO_STRICT_INTERVAL Enqueue I/O handlers at a channel's + * interval setting even if the amount of data ready to be delivered is inferior + * to the low water mark (or zero). + */ +#define DISPATCH_IO_STRICT_INTERVAL 0x1 + +typedef unsigned long dispatch_io_interval_flags_t; + +/*! + * @function dispatch_io_set_interval + * Set a nanosecond interval at which I/O handlers are to be enqueued on the + * I/O channel for all operations. + * + * This allows an application to receive periodic feedback on the progress of + * read and write operations, e.g. for the purposes of displaying progress bars. + * + * If the amount of data ready to be delivered to an I/O handler at the interval + * is inferior to the channel low water mark, the handler will only be enqueued + * if the DISPATCH_IO_STRICT_INTERVAL flag is set. + * + * Note that the system may defer enqueueing interval I/O handlers by a small + * unspecified amount of leeway in order to align with other system activity for + * improved system performance or power consumption. + * + * @param channel The dispatch I/O channel on which to set the policy. + * @param interval The interval in nanoseconds at which delivery of the I/O + * handler is desired. + * @param flags Flags indicating desired data delivery behavior at + * interval time. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_io_set_interval(dispatch_io_t channel, + uint64_t interval, + dispatch_io_interval_flags_t flags); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif /* __DISPATCH_IO__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/object.h b/lib/libc/include/x86_64-macos-gnu/dispatch/object.h new file mode 100644 index 0000000000..3f95f90025 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/object.h @@ -0,0 +1,606 @@ +/* + * Copyright (c) 2008-2012 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_OBJECT__ +#define __DISPATCH_OBJECT__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +#if __has_include() +#include +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @typedef dispatch_object_t + * + * @abstract + * Abstract base type for all dispatch objects. + * The details of the type definition are language-specific. + * + * @discussion + * Dispatch objects are reference counted via calls to dispatch_retain() and + * dispatch_release(). + */ + +#if OS_OBJECT_USE_OBJC +/* + * By default, dispatch objects are declared as Objective-C types when building + * with an Objective-C compiler. This allows them to participate in ARC, in RR + * management by the Blocks runtime and in leaks checking by the static + * analyzer, and enables them to be added to Cocoa collections. + * See for details. + */ +OS_OBJECT_DECL_CLASS(dispatch_object); + +#if OS_OBJECT_SWIFT3 +#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS_SWIFT(name, dispatch_object) +#define DISPATCH_DECL_SUBCLASS(name, base) OS_OBJECT_DECL_SUBCLASS_SWIFT(name, base) +#else // OS_OBJECT_SWIFT3 +#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS(name, dispatch_object) +#define DISPATCH_DECL_SUBCLASS(name, base) OS_OBJECT_DECL_SUBCLASS(name, base) + +DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +_dispatch_object_validate(dispatch_object_t object) +{ + void *isa = *(void *volatile*)(OS_OBJECT_BRIDGE void*)object; + (void)isa; +} +#endif // OS_OBJECT_SWIFT3 + +#define DISPATCH_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object)) +#define DISPATCH_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED +#elif defined(__cplusplus) && !defined(__DISPATCH_BUILDING_DISPATCH__) +/* + * Dispatch objects are NOT C++ objects. Nevertheless, we can at least keep C++ + * aware of type compatibility. + */ +typedef struct dispatch_object_s { +private: + dispatch_object_s(); + ~dispatch_object_s(); + dispatch_object_s(const dispatch_object_s &); + void operator=(const dispatch_object_s &); +} *dispatch_object_t; +#define DISPATCH_DECL(name) \ + typedef struct name##_s : public dispatch_object_s {} *name##_t +#define DISPATCH_DECL_SUBCLASS(name, base) \ + typedef struct name##_s : public base##_s {} *name##_t +#define DISPATCH_GLOBAL_OBJECT(type, object) (static_cast(&(object))) +#define DISPATCH_RETURNS_RETAINED +#else /* Plain C */ +typedef union { + struct _os_object_s *_os_obj; + struct dispatch_object_s *_do; + struct dispatch_queue_s *_dq; + struct dispatch_queue_attr_s *_dqa; + struct dispatch_group_s *_dg; + struct dispatch_source_s *_ds; + struct dispatch_channel_s *_dch; + struct dispatch_mach_s *_dm; + struct dispatch_mach_msg_s *_dmsg; + struct dispatch_semaphore_s *_dsema; + struct dispatch_data_s *_ddata; + struct dispatch_io_s *_dchannel; +} dispatch_object_t DISPATCH_TRANSPARENT_UNION; +#define DISPATCH_DECL(name) typedef struct name##_s *name##_t +#define DISPATCH_DECL_SUBCLASS(name, base) typedef base##_t name##_t +#define DISPATCH_GLOBAL_OBJECT(type, object) ((type)&(object)) +#define DISPATCH_RETURNS_RETAINED +#endif + +#if OS_OBJECT_SWIFT3 && OS_OBJECT_USE_OBJC +#define DISPATCH_SOURCE_TYPE_DECL(name) \ + DISPATCH_EXPORT struct dispatch_source_type_s \ + _dispatch_source_type_##name; \ + OS_OBJECT_DECL_PROTOCOL(dispatch_source_##name, ); \ + OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL( \ + dispatch_source, dispatch_source_##name) +#define DISPATCH_SOURCE_DECL(name) \ + DISPATCH_DECL(name); \ + OS_OBJECT_DECL_PROTOCOL(name, ); \ + OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, name) +#ifndef DISPATCH_DATA_DECL +#define DISPATCH_DATA_DECL(name) OS_OBJECT_DECL_SWIFT(name) +#endif // DISPATCH_DATA_DECL +#else +#define DISPATCH_SOURCE_DECL(name) \ + DISPATCH_DECL(name); +#define DISPATCH_DATA_DECL(name) DISPATCH_DECL(name) +#define DISPATCH_SOURCE_TYPE_DECL(name) \ + DISPATCH_EXPORT const struct dispatch_source_type_s \ + _dispatch_source_type_##name +#endif + +#ifdef __BLOCKS__ +/*! + * @typedef dispatch_block_t + * + * @abstract + * The type of blocks submitted to dispatch queues, which take no arguments + * and have no return value. + * + * @discussion + * When not building with Objective-C ARC, a block object allocated on or + * copied to the heap must be released with a -[release] message or the + * Block_release() function. + * + * The declaration of a block literal allocates storage on the stack. + * Therefore, this is an invalid construct: + * + * dispatch_block_t block; + * if (x) { + * block = ^{ printf("true\n"); }; + * } else { + * block = ^{ printf("false\n"); }; + * } + * block(); // unsafe!!! + * + * + * What is happening behind the scenes: + * + * if (x) { + * struct Block __tmp_1 = ...; // setup details + * block = &__tmp_1; + * } else { + * struct Block __tmp_2 = ...; // setup details + * block = &__tmp_2; + * } + * + * + * As the example demonstrates, the address of a stack variable is escaping the + * scope in which it is allocated. That is a classic C bug. + * + * Instead, the block literal must be copied to the heap with the Block_copy() + * function or by sending it a -[copy] message. + */ +typedef void (^dispatch_block_t)(void); +#endif // __BLOCKS__ + +__BEGIN_DECLS + +/*! + * @typedef dispatch_qos_class_t + * Alias for qos_class_t type. + */ +#if __has_include() +typedef qos_class_t dispatch_qos_class_t; +#else +typedef unsigned int dispatch_qos_class_t; +#endif + +/*! + * @function dispatch_retain + * + * @abstract + * Increment the reference count of a dispatch object. + * + * @discussion + * Calls to dispatch_retain() must be balanced with calls to + * dispatch_release(). + * + * @param object + * The object to retain. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +DISPATCH_SWIFT_UNAVAILABLE("Can't be used with ARC") +void +dispatch_retain(dispatch_object_t object); +#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#undef dispatch_retain +#define dispatch_retain(object) \ + __extension__({ dispatch_object_t _o = (object); \ + _dispatch_object_validate(_o); (void)[_o retain]; }) +#endif + +/*! + * @function dispatch_release + * + * @abstract + * Decrement the reference count of a dispatch object. + * + * @discussion + * A dispatch object is asynchronously deallocated once all references are + * released (i.e. the reference count becomes zero). The system does not + * guarantee that a given client is the last or only reference to a given + * object. + * + * @param object + * The object to release. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +DISPATCH_SWIFT_UNAVAILABLE("Can't be used with ARC") +void +dispatch_release(dispatch_object_t object); +#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#undef dispatch_release +#define dispatch_release(object) \ + __extension__({ dispatch_object_t _o = (object); \ + _dispatch_object_validate(_o); [_o release]; }) +#endif + +/*! + * @function dispatch_get_context + * + * @abstract + * Returns the application defined context of the object. + * + * @param object + * The result of passing NULL in this parameter is undefined. + * + * @result + * The context of the object; may be NULL. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_PURE DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +void *_Nullable +dispatch_get_context(dispatch_object_t object); + +/*! + * @function dispatch_set_context + * + * @abstract + * Associates an application defined context with the object. + * + * @param object + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The new client defined context for the object. This may be NULL. + * + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW +void +dispatch_set_context(dispatch_object_t object, void *_Nullable context); + +/*! + * @function dispatch_set_finalizer_f + * + * @abstract + * Set the finalizer function for a dispatch object. + * + * @param object + * The dispatch object to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param finalizer + * The finalizer function pointer. + * + * @discussion + * A dispatch object's finalizer will be invoked on the object's target queue + * after all references to the object have been released. This finalizer may be + * used by the application to release any resources associated with the object, + * such as freeing the object's context. + * The context parameter passed to the finalizer function is the current + * context of the dispatch object at the time the finalizer call is made. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW +void +dispatch_set_finalizer_f(dispatch_object_t object, + dispatch_function_t _Nullable finalizer); + +/*! + * @function dispatch_activate + * + * @abstract + * Activates the specified dispatch object. + * + * @discussion + * Dispatch objects such as queues and sources may be created in an inactive + * state. Objects in this state have to be activated before any blocks + * associated with them will be invoked. + * + * The target queue of inactive objects can be changed using + * dispatch_set_target_queue(). Change of target queue is no longer permitted + * once an initially inactive object has been activated. + * + * Calling dispatch_activate() on an active object has no effect. + * Releasing the last reference count on an inactive object is undefined. + * + * @param object + * The object to be activated. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_activate(dispatch_object_t object); + +/*! + * @function dispatch_suspend + * + * @abstract + * Suspends the invocation of blocks on a dispatch object. + * + * @discussion + * A suspended object will not invoke any blocks associated with it. The + * suspension of an object will occur after any running block associated with + * the object completes. + * + * Calls to dispatch_suspend() must be balanced with calls + * to dispatch_resume(). + * + * @param object + * The object to be suspended. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_suspend(dispatch_object_t object); + +/*! + * @function dispatch_resume + * + * @abstract + * Resumes the invocation of blocks on a dispatch object. + * + * @discussion + * Dispatch objects can be suspended with dispatch_suspend(), which increments + * an internal suspension count. dispatch_resume() is the inverse operation, + * and consumes suspension counts. When the last suspension count is consumed, + * blocks associated with the object will be invoked again. + * + * For backward compatibility reasons, dispatch_resume() on an inactive and not + * otherwise suspended dispatch source object has the same effect as calling + * dispatch_activate(). For new code, using dispatch_activate() is preferred. + * + * If the specified object has zero suspension count and is not an inactive + * source, this function will result in an assertion and the process being + * terminated. + * + * @param object + * The object to be resumed. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_resume(dispatch_object_t object); + +/*! + * @function dispatch_set_qos_class_floor + * + * @abstract + * Sets the QOS class floor on a dispatch queue, source or workloop. + * + * @discussion + * The QOS class of workitems submitted to this object asynchronously will be + * elevated to at least the specified QOS class floor. The QOS of the workitem + * will be used if higher than the floor even when the workitem has been created + * without "ENFORCE" semantics. + * + * Setting the QOS class floor is equivalent to the QOS effects of configuring + * a queue whose target queue has a QoS class set to the same value. + * + * @param object + * A dispatch queue, workloop, or source to configure. + * The object must be inactive. + * + * Passing another object type or an object that has been activated is undefined + * and will cause the process to be terminated. + * + * @param qos_class + * A QOS class value: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * Passing any other value is undefined. + * + * @param relative_priority + * A relative priority within the QOS class. This value is a negative + * offset from the maximum supported scheduler priority for the given class. + * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY + * is undefined. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW +void +dispatch_set_qos_class_floor(dispatch_object_t object, + dispatch_qos_class_t qos_class, int relative_priority); + +#ifdef __BLOCKS__ +/*! + * @function dispatch_wait + * + * @abstract + * Wait synchronously for an object or until the specified timeout has elapsed. + * + * @discussion + * Type-generic macro that maps to dispatch_block_wait, dispatch_group_wait or + * dispatch_semaphore_wait, depending on the type of the first argument. + * See documentation for these functions for more details. + * This function is unavailable for any other object type. + * + * @param object + * The object to wait on. + * The result of passing NULL in this parameter is undefined. + * + * @param timeout + * When to timeout (see dispatch_time). As a convenience, there are the + * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants. + * + * @result + * Returns zero on success or non-zero on error (i.e. timed out). + */ +DISPATCH_UNAVAILABLE +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +intptr_t +dispatch_wait(void *object, dispatch_time_t timeout); +#if __has_extension(c_generic_selections) +#define dispatch_wait(object, timeout) \ + _Generic((object), \ + dispatch_block_t:dispatch_block_wait, \ + dispatch_group_t:dispatch_group_wait, \ + dispatch_semaphore_t:dispatch_semaphore_wait \ + )((object),(timeout)) +#endif + +/*! + * @function dispatch_notify + * + * @abstract + * Schedule a notification block to be submitted to a queue when the execution + * of a specified object has completed. + * + * @discussion + * Type-generic macro that maps to dispatch_block_notify or + * dispatch_group_notify, depending on the type of the first argument. + * See documentation for these functions for more details. + * This function is unavailable for any other object type. + * + * @param object + * The object to observe. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The queue to which the supplied notification block will be submitted when + * the observed object completes. + * + * @param notification_block + * The block to submit when the observed object completes. + */ +DISPATCH_UNAVAILABLE +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_notify(void *object, dispatch_object_t queue, + dispatch_block_t notification_block); +#if __has_extension(c_generic_selections) +#define dispatch_notify(object, queue, notification_block) \ + _Generic((object), \ + dispatch_block_t:dispatch_block_notify, \ + dispatch_group_t:dispatch_group_notify \ + )((object),(queue), (notification_block)) +#endif + +/*! + * @function dispatch_cancel + * + * @abstract + * Cancel the specified object. + * + * @discussion + * Type-generic macro that maps to dispatch_block_cancel or + * dispatch_source_cancel, depending on the type of the first argument. + * See documentation for these functions for more details. + * This function is unavailable for any other object type. + * + * @param object + * The object to cancel. + * The result of passing NULL in this parameter is undefined. + */ +DISPATCH_UNAVAILABLE +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_cancel(void *object); +#if __has_extension(c_generic_selections) +#define dispatch_cancel(object) \ + _Generic((object), \ + dispatch_block_t:dispatch_block_cancel, \ + dispatch_source_t:dispatch_source_cancel \ + )((object)) +#endif + +/*! + * @function dispatch_testcancel + * + * @abstract + * Test whether the specified object has been canceled + * + * @discussion + * Type-generic macro that maps to dispatch_block_testcancel or + * dispatch_source_testcancel, depending on the type of the first argument. + * See documentation for these functions for more details. + * This function is unavailable for any other object type. + * + * @param object + * The object to test. + * The result of passing NULL in this parameter is undefined. + * + * @result + * Non-zero if canceled and zero if not canceled. + */ +DISPATCH_UNAVAILABLE +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +intptr_t +dispatch_testcancel(void *object); +#if __has_extension(c_generic_selections) +#define dispatch_testcancel(object) \ + _Generic((object), \ + dispatch_block_t:dispatch_block_testcancel, \ + dispatch_source_t:dispatch_source_testcancel \ + )((object)) +#endif +#endif // __BLOCKS__ + +/*! + * @function dispatch_debug + * + * @abstract + * Programmatically log debug information about a dispatch object. + * + * @discussion + * Programmatically log debug information about a dispatch object. By default, + * the log output is sent to syslog at notice level. In the debug version of + * the library, the log output is sent to a file in /var/tmp. + * The log output destination can be configured via the LIBDISPATCH_LOG + * environment variable, valid values are: YES, NO, syslog, stderr, file. + * + * This function is deprecated and will be removed in a future release. + * Objective-C callers may use -debugDescription instead. + * + * @param object + * The object to introspect. + * + * @param message + * The message to log above and beyond the introspection. + */ +API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW DISPATCH_COLD +__attribute__((__format__(printf,2,3))) +void +dispatch_debug(dispatch_object_t object, const char *message, ...); + +API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW DISPATCH_COLD +__attribute__((__format__(printf,2,0))) +void +dispatch_debugv(dispatch_object_t object, const char *message, va_list ap); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/once.h b/lib/libc/include/x86_64-macos-gnu/dispatch/once.h new file mode 100644 index 0000000000..fbce4b111e --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/once.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2008-2010 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_ONCE__ +#define __DISPATCH_ONCE__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +__BEGIN_DECLS + +/*! + * @typedef dispatch_once_t + * + * @abstract + * A predicate for use with dispatch_once(). It must be initialized to zero. + * Note: static and global variables default to zero. + */ +DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead") +typedef intptr_t dispatch_once_t; + +#if defined(__x86_64__) || defined(__i386__) || defined(__s390x__) +#define DISPATCH_ONCE_INLINE_FASTPATH 1 +#elif defined(__APPLE__) +#define DISPATCH_ONCE_INLINE_FASTPATH 1 +#else +#define DISPATCH_ONCE_INLINE_FASTPATH 0 +#endif + +/*! + * @function dispatch_once + * + * @abstract + * Execute a block once and only once. + * + * @param predicate + * A pointer to a dispatch_once_t that is used to test whether the block has + * completed or not. + * + * @param block + * The block to execute once. + * + * @discussion + * Always call dispatch_once() before using or testing any variables that are + * initialized by the block. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead") +void +dispatch_once(dispatch_once_t *predicate, + DISPATCH_NOESCAPE dispatch_block_t block); + +#if DISPATCH_ONCE_INLINE_FASTPATH +DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead") +void +_dispatch_once(dispatch_once_t *predicate, + DISPATCH_NOESCAPE dispatch_block_t block) +{ + if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) { + dispatch_once(predicate, block); + } else { + dispatch_compiler_barrier(); + } + DISPATCH_COMPILER_CAN_ASSUME(*predicate == ~0l); +} +#undef dispatch_once +#define dispatch_once _dispatch_once +#endif +#endif // DISPATCH_ONCE_INLINE_FASTPATH + +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead") +void +dispatch_once_f(dispatch_once_t *predicate, void *_Nullable context, + dispatch_function_t function); + +#if DISPATCH_ONCE_INLINE_FASTPATH +DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL1 DISPATCH_NONNULL3 +DISPATCH_NOTHROW +DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead") +void +_dispatch_once_f(dispatch_once_t *predicate, void *_Nullable context, + dispatch_function_t function) +{ + if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) { + dispatch_once_f(predicate, context, function); + } else { + dispatch_compiler_barrier(); + } + DISPATCH_COMPILER_CAN_ASSUME(*predicate == ~0l); +} +#undef dispatch_once_f +#define dispatch_once_f _dispatch_once_f +#endif // DISPATCH_ONCE_INLINE_FASTPATH + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/queue.h b/lib/libc/include/x86_64-macos-gnu/dispatch/queue.h new file mode 100644 index 0000000000..e4251fa74d --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/queue.h @@ -0,0 +1,1674 @@ +/* + * Copyright (c) 2008-2014 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_QUEUE__ +#define __DISPATCH_QUEUE__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @header + * + * Dispatch is an abstract model for expressing concurrency via simple but + * powerful API. + * + * At the core, dispatch provides serial FIFO queues to which blocks may be + * submitted. Blocks submitted to these dispatch queues are invoked on a pool + * of threads fully managed by the system. No guarantee is made regarding + * which thread a block will be invoked on; however, it is guaranteed that only + * one block submitted to the FIFO dispatch queue will be invoked at a time. + * + * When multiple queues have blocks to be processed, the system is free to + * allocate additional threads to invoke the blocks concurrently. When the + * queues become empty, these threads are automatically released. + */ + +/*! + * @typedef dispatch_queue_t + * + * @abstract + * Dispatch queues invoke workitems submitted to them. + * + * @discussion + * Dispatch queues come in many flavors, the most common one being the dispatch + * serial queue (See dispatch_queue_serial_t). + * + * The system manages a pool of threads which process dispatch queues and invoke + * workitems submitted to them. + * + * Conceptually a dispatch queue may have its own thread of execution, and + * interaction between queues is highly asynchronous. + * + * Dispatch queues are reference counted via calls to dispatch_retain() and + * dispatch_release(). Pending workitems submitted to a queue also hold a + * reference to the queue until they have finished. Once all references to a + * queue have been released, the queue will be deallocated by the system. + */ +DISPATCH_DECL(dispatch_queue); + +/*! + * @typedef dispatch_queue_global_t + * + * @abstract + * Dispatch global concurrent queues are an abstraction around the system thread + * pool which invokes workitems that are submitted to dispatch queues. + * + * @discussion + * Dispatch global concurrent queues provide buckets of priorities on top of the + * thread pool the system manages. The system will decide how many threads + * to allocate to this pool depending on demand and system load. In particular, + * the system tries to maintain a good level of concurrency for this resource, + * and will create new threads when too many existing worker threads block in + * system calls. + * + * The global concurrent queues are a shared resource and as such it is the + * responsiblity of every user of this resource to not submit an unbounded + * amount of work to this pool, especially work that may block, as this can + * cause the system to spawn very large numbers of threads (aka. thread + * explosion). + * + * Work items submitted to the global concurrent queues have no ordering + * guarantee with respect to the order of submission, and workitems submitted + * to these queues may be invoked concurrently. + * + * Dispatch global concurrent queues are well-known global objects that are + * returned by dispatch_get_global_queue(). These objects cannot be modified. + * Calls to dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc., + * will have no effect when used with queues of this type. + */ +DISPATCH_DECL_SUBCLASS(dispatch_queue_global, dispatch_queue); + +/*! + * @typedef dispatch_queue_serial_t + * + * @abstract + * Dispatch serial queues invoke workitems submitted to them serially in FIFO + * order. + * + * @discussion + * Dispatch serial queues are lightweight objects to which workitems may be + * submitted to be invoked in FIFO order. A serial queue will only invoke one + * workitem at a time, but independent serial queues may each invoke their work + * items concurrently with respect to each other. + * + * Serial queues can target each other (See dispatch_set_target_queue()). The + * serial queue at the bottom of a queue hierarchy provides an exclusion + * context: at most one workitem submitted to any of the queues in such + * a hiearchy will run at any given time. + * + * Such hierarchies provide a natural construct to organize an application + * subsystem around. + * + * Serial queues are created by passing a dispatch queue attribute derived from + * DISPATCH_QUEUE_SERIAL to dispatch_queue_create_with_target(). + */ +DISPATCH_DECL_SUBCLASS(dispatch_queue_serial, dispatch_queue); + +/*! + * @typedef dispatch_queue_main_t + * + * @abstract + * The type of the default queue that is bound to the main thread. + * + * @discussion + * The main queue is a serial queue (See dispatch_queue_serial_t) which is bound + * to the main thread of an application. + * + * In order to invoke workitems submitted to the main queue, the application + * must call dispatch_main(), NSApplicationMain(), or use a CFRunLoop on the + * main thread. + * + * The main queue is a well known global object that is made automatically on + * behalf of the main thread during process initialization and is returned by + * dispatch_get_main_queue(). This object cannot be modified. Calls to + * dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc., will + * have no effect when used on the main queue. + */ +DISPATCH_DECL_SUBCLASS(dispatch_queue_main, dispatch_queue_serial); + +/*! + * @typedef dispatch_queue_concurrent_t + * + * @abstract + * Dispatch concurrent queues invoke workitems submitted to them concurrently, + * and admit a notion of barrier workitems. + * + * @discussion + * Dispatch concurrent queues are lightweight objects to which regular and + * barrier workitems may be submited. Barrier workitems are invoked in + * exclusion of any other kind of workitem in FIFO order. + * + * Regular workitems can be invoked concurrently for the same concurrent queue, + * in any order. However, regular workitems will not be invoked before any + * barrier workitem submited ahead of them has been invoked. + * + * In other words, if a serial queue is equivalent to a mutex in the Dispatch + * world, a concurrent queue is equivalent to a reader-writer lock, where + * regular items are readers and barriers are writers. + * + * Concurrent queues are created by passing a dispatch queue attribute derived + * from DISPATCH_QUEUE_CONCURRENT to dispatch_queue_create_with_target(). + * + * Caveat: + * Dispatch concurrent queues at this time do not implement priority inversion + * avoidance when lower priority regular workitems (readers) are being invoked + * and are preventing a higher priority barrier (writer) from being invoked. + */ +DISPATCH_DECL_SUBCLASS(dispatch_queue_concurrent, dispatch_queue); + +__BEGIN_DECLS + +/*! + * @function dispatch_async + * + * @abstract + * Submits a block for asynchronous execution on a dispatch queue. + * + * @discussion + * The dispatch_async() function is the fundamental mechanism for submitting + * blocks to a dispatch queue. + * + * Calls to dispatch_async() always return immediately after the block has + * been submitted, and never wait for the block to be invoked. + * + * The target queue determines whether the block will be invoked serially or + * concurrently with respect to other blocks submitted to that same queue. + * Serial queues are processed concurrently with respect to each other. + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The system will hold a reference on the target queue until the block + * has finished. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to submit to the target dispatch queue. This function performs + * Block_copy() and Block_release() on behalf of callers. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_async(dispatch_queue_t queue, dispatch_block_t block); +#endif + +/*! + * @function dispatch_async_f + * + * @abstract + * Submits a function for asynchronous execution on a dispatch queue. + * + * @discussion + * See dispatch_async() for details. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The system will hold a reference on the target queue until the function + * has returned. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_async_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_async_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @function dispatch_sync + * + * @abstract + * Submits a block for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a workitem to a dispatch queue like dispatch_async(), however + * dispatch_sync() will not return until the workitem has finished. + * + * Work items submitted to a queue with dispatch_sync() do not observe certain + * queue attributes of that queue when invoked (such as autorelease frequency + * and QOS class). + * + * Calls to dispatch_sync() targeting the current queue will result + * in dead-lock. Use of dispatch_sync() is also subject to the same + * multi-party dead-lock problems that may result from the use of a mutex. + * Use of dispatch_async() is preferred. + * + * Unlike dispatch_async(), no retain is performed on the target queue. Because + * calls to this function are synchronous, the dispatch_sync() "borrows" the + * reference of the caller. + * + * As an optimization, dispatch_sync() invokes the workitem on the thread which + * submitted the workitem, except when the passed queue is the main queue or + * a queue targetting it (See dispatch_queue_main_t, + * dispatch_set_target_queue()). + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to be invoked on the target dispatch queue. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_sync(dispatch_queue_t queue, DISPATCH_NOESCAPE dispatch_block_t block); +#endif + +/*! + * @function dispatch_sync_f + * + * @abstract + * Submits a function for synchronous execution on a dispatch queue. + * + * @discussion + * See dispatch_sync() for details. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_sync_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_sync_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @function dispatch_async_and_wait + * + * @abstract + * Submits a block for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a workitem to a dispatch queue like dispatch_async(), however + * dispatch_async_and_wait() will not return until the workitem has finished. + * + * Like functions of the dispatch_sync family, dispatch_async_and_wait() is + * subject to dead-lock (See dispatch_sync() for details). + * + * However, dispatch_async_and_wait() differs from functions of the + * dispatch_sync family in two fundamental ways: how it respects queue + * attributes and how it chooses the execution context invoking the workitem. + * + * Differences with dispatch_sync() + * + * Work items submitted to a queue with dispatch_async_and_wait() observe all + * queue attributes of that queue when invoked (inluding autorelease frequency + * or QOS class). + * + * When the runtime has brought up a thread to invoke the asynchronous workitems + * already submitted to the specified queue, that servicing thread will also be + * used to execute synchronous work submitted to the queue with + * dispatch_async_and_wait(). + * + * However, if the runtime has not brought up a thread to service the specified + * queue (because it has no workitems enqueued, or only synchronous workitems), + * then dispatch_async_and_wait() will invoke the workitem on the calling thread, + * similar to the behaviour of functions in the dispatch_sync family. + * + * As an exception, if the queue the work is submitted to doesn't target + * a global concurrent queue (for example because it targets the main queue), + * then the workitem will never be invoked by the thread calling + * dispatch_async_and_wait(). + * + * In other words, dispatch_async_and_wait() is similar to submitting + * a dispatch_block_create()d workitem to a queue and then waiting on it, as + * shown in the code example below. However, dispatch_async_and_wait() is + * significantly more efficient when a new thread is not required to execute + * the workitem (as it will use the stack of the submitting thread instead of + * requiring heap allocations). + * + * + * dispatch_block_t b = dispatch_block_create(0, block); + * dispatch_async(queue, b); + * dispatch_block_wait(b, DISPATCH_TIME_FOREVER); + * Block_release(b); + * + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to be invoked on the target dispatch queue. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_async_and_wait(dispatch_queue_t queue, + DISPATCH_NOESCAPE dispatch_block_t block); +#endif + +/*! + * @function dispatch_async_and_wait_f + * + * @abstract + * Submits a function for synchronous execution on a dispatch queue. + * + * @discussion + * See dispatch_async_and_wait() for details. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_async_and_wait_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_async_and_wait_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + + +#if defined(__APPLE__) && \ + (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \ + __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ + __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9) +#define DISPATCH_APPLY_AUTO_AVAILABLE 0 +#define DISPATCH_APPLY_QUEUE_ARG_NULLABILITY _Nonnull +#else +#define DISPATCH_APPLY_AUTO_AVAILABLE 1 +#define DISPATCH_APPLY_QUEUE_ARG_NULLABILITY _Nullable +#endif + +/*! + * @constant DISPATCH_APPLY_AUTO + * + * @abstract + * Constant to pass to dispatch_apply() or dispatch_apply_f() to request that + * the system automatically use worker threads that match the configuration of + * the current thread as closely as possible. + * + * @discussion + * When submitting a block for parallel invocation, passing this constant as the + * queue argument will automatically use the global concurrent queue that + * matches the Quality of Service of the caller most closely. + * + * No assumptions should be made about which global concurrent queue will + * actually be used. + * + * Using this constant deploys backward to macOS 10.9, iOS 7.0 and any tvOS or + * watchOS version. + */ +#if DISPATCH_APPLY_AUTO_AVAILABLE +#define DISPATCH_APPLY_AUTO ((dispatch_queue_t _Nonnull)0) +#endif + +/*! + * @function dispatch_apply + * + * @abstract + * Submits a block to a dispatch queue for parallel invocation. + * + * @discussion + * Submits a block to a dispatch queue for parallel invocation. This function + * waits for the task block to complete before returning. If the specified queue + * is concurrent, the block may be invoked concurrently, and it must therefore + * be reentrant safe. + * + * Each invocation of the block will be passed the current index of iteration. + * + * @param iterations + * The number of iterations to perform. + * + * @param queue + * The dispatch queue to which the block is submitted. + * The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use + * a queue appropriate for the calling thread. + * + * @param block + * The block to be invoked the specified number of iterations. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_apply(size_t iterations, + dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue, + DISPATCH_NOESCAPE void (^block)(size_t)); +#endif + +/*! + * @function dispatch_apply_f + * + * @abstract + * Submits a function to a dispatch queue for parallel invocation. + * + * @discussion + * See dispatch_apply() for details. + * + * @param iterations + * The number of iterations to perform. + * + * @param queue + * The dispatch queue to which the function is submitted. + * The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use + * a queue appropriate for the calling thread. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the specified queue. The first + * parameter passed to this function is the context provided to + * dispatch_apply_f(). The second parameter passed to this function is the + * current index of iteration. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_NOTHROW +void +dispatch_apply_f(size_t iterations, + dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue, + void *_Nullable context, void (*work)(void *_Nullable, size_t)); + +/*! + * @function dispatch_get_current_queue + * + * @abstract + * Returns the queue on which the currently executing block is running. + * + * @discussion + * Returns the queue on which the currently executing block is running. + * + * When dispatch_get_current_queue() is called outside of the context of a + * submitted block, it will return the default concurrent queue. + * + * Recommended for debugging and logging purposes only: + * The code must not make any assumptions about the queue returned, unless it + * is one of the global queues or a queue the code has itself created. + * The code must not assume that synchronous execution onto a queue is safe + * from deadlock if that queue is not the one returned by + * dispatch_get_current_queue(). + * + * When dispatch_get_current_queue() is called on the main thread, it may + * or may not return the same value as dispatch_get_main_queue(). Comparing + * the two is not a valid way to test whether code is executing on the + * main thread (see dispatch_assert_queue() and dispatch_assert_queue_not()). + * + * This function is deprecated and will be removed in a future release. + * + * @result + * Returns the current queue. + */ +API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0)) +DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_queue_t +dispatch_get_current_queue(void); + +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT +struct dispatch_queue_s _dispatch_main_q; + +/*! + * @function dispatch_get_main_queue + * + * @abstract + * Returns the default queue that is bound to the main thread. + * + * @discussion + * In order to invoke blocks submitted to the main queue, the application must + * call dispatch_main(), NSApplicationMain(), or use a CFRunLoop on the main + * thread. + * + * The main queue is meant to be used in application context to interact with + * the main thread and the main runloop. + * + * Because the main queue doesn't behave entirely like a regular serial queue, + * it may have unwanted side-effects when used in processes that are not UI apps + * (daemons). For such processes, the main queue should be avoided. + * + * @see dispatch_queue_main_t + * + * @result + * Returns the main queue. This queue is created automatically on behalf of + * the main thread before main() is called. + */ +DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_CONST DISPATCH_NOTHROW +dispatch_queue_main_t +dispatch_get_main_queue(void) +{ + return DISPATCH_GLOBAL_OBJECT(dispatch_queue_main_t, _dispatch_main_q); +} + +/*! + * @typedef dispatch_queue_priority_t + * Type of dispatch_queue_priority + * + * @constant DISPATCH_QUEUE_PRIORITY_HIGH + * Items dispatched to the queue will run at high priority, + * i.e. the queue will be scheduled for execution before + * any default priority or low priority queue. + * + * @constant DISPATCH_QUEUE_PRIORITY_DEFAULT + * Items dispatched to the queue will run at the default + * priority, i.e. the queue will be scheduled for execution + * after all high priority queues have been scheduled, but + * before any low priority queues have been scheduled. + * + * @constant DISPATCH_QUEUE_PRIORITY_LOW + * Items dispatched to the queue will run at low priority, + * i.e. the queue will be scheduled for execution after all + * default priority and high priority queues have been + * scheduled. + * + * @constant DISPATCH_QUEUE_PRIORITY_BACKGROUND + * Items dispatched to the queue will run at background priority, i.e. the queue + * will be scheduled for execution after all higher priority queues have been + * scheduled and the system will run items on this queue on a thread with + * background status as per setpriority(2) (i.e. disk I/O is throttled and the + * thread's scheduling priority is set to lowest value). + */ +#define DISPATCH_QUEUE_PRIORITY_HIGH 2 +#define DISPATCH_QUEUE_PRIORITY_DEFAULT 0 +#define DISPATCH_QUEUE_PRIORITY_LOW (-2) +#define DISPATCH_QUEUE_PRIORITY_BACKGROUND INT16_MIN + +typedef long dispatch_queue_priority_t; + +/*! + * @function dispatch_get_global_queue + * + * @abstract + * Returns a well-known global concurrent queue of a given quality of service + * class. + * + * @discussion + * See dispatch_queue_global_t. + * + * @param identifier + * A quality of service class defined in qos_class_t or a priority defined in + * dispatch_queue_priority_t. + * + * It is recommended to use quality of service class values to identify the + * well-known global concurrent queues: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * + * The global concurrent queues may still be identified by their priority, + * which map to the following QOS classes: + * - DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED + * - DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT + * - DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY + * - DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND + * + * @param flags + * Reserved for future use. Passing any value other than zero may result in + * a NULL return value. + * + * @result + * Returns the requested global queue or NULL if the requested global queue + * does not exist. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_queue_global_t +dispatch_get_global_queue(intptr_t identifier, uintptr_t flags); + +/*! + * @typedef dispatch_queue_attr_t + * + * @abstract + * Attribute for dispatch queues. + */ +DISPATCH_DECL(dispatch_queue_attr); + +/*! + * @const DISPATCH_QUEUE_SERIAL + * + * @discussion + * An attribute that can be used to create a dispatch queue that invokes blocks + * serially in FIFO order. + * + * See dispatch_queue_serial_t. + */ +#define DISPATCH_QUEUE_SERIAL NULL + +/*! + * @const DISPATCH_QUEUE_SERIAL_INACTIVE + * + * @discussion + * An attribute that can be used to create a dispatch queue that invokes blocks + * serially in FIFO order, and that is initially inactive. + * + * See dispatch_queue_attr_make_initially_inactive(). + */ +#define DISPATCH_QUEUE_SERIAL_INACTIVE \ + dispatch_queue_attr_make_initially_inactive(DISPATCH_QUEUE_SERIAL) + +/*! + * @const DISPATCH_QUEUE_CONCURRENT + * + * @discussion + * An attribute that can be used to create a dispatch queue that may invoke + * blocks concurrently and supports barrier blocks submitted with the dispatch + * barrier API. + * + * See dispatch_queue_concurrent_t. + */ +#define DISPATCH_QUEUE_CONCURRENT \ + DISPATCH_GLOBAL_OBJECT(dispatch_queue_attr_t, \ + _dispatch_queue_attr_concurrent) +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT +struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent; + +/*! + * @const DISPATCH_QUEUE_CONCURRENT_INACTIVE + * + * @discussion + * An attribute that can be used to create a dispatch queue that may invoke + * blocks concurrently and supports barrier blocks submitted with the dispatch + * barrier API, and that is initially inactive. + * + * See dispatch_queue_attr_make_initially_inactive(). + */ +#define DISPATCH_QUEUE_CONCURRENT_INACTIVE \ + dispatch_queue_attr_make_initially_inactive(DISPATCH_QUEUE_CONCURRENT) + +/*! + * @function dispatch_queue_attr_make_initially_inactive + * + * @abstract + * Returns an attribute value which may be provided to dispatch_queue_create() + * or dispatch_queue_create_with_target(), in order to make the created queue + * initially inactive. + * + * @discussion + * Dispatch queues may be created in an inactive state. Queues in this state + * have to be activated before any blocks associated with them will be invoked. + * + * A queue in inactive state cannot be deallocated, dispatch_activate() must be + * called before the last reference to a queue created with this attribute is + * released. + * + * The target queue of a queue in inactive state can be changed using + * dispatch_set_target_queue(). Change of target queue is no longer permitted + * once an initially inactive queue has been activated. + * + * @param attr + * A queue attribute value to be combined with the initially inactive attribute. + * + * @return + * Returns an attribute value which may be provided to dispatch_queue_create() + * and dispatch_queue_create_with_target(). + * The new value combines the attributes specified by the 'attr' parameter with + * the initially inactive attribute. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW +dispatch_queue_attr_t +dispatch_queue_attr_make_initially_inactive( + dispatch_queue_attr_t _Nullable attr); + +/*! + * @const DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL + * + * @discussion + * A dispatch queue created with this attribute invokes blocks serially in FIFO + * order, and surrounds execution of any block submitted asynchronously to it + * with the equivalent of a individual Objective-C @autoreleasepool + * scope. + * + * See dispatch_queue_attr_make_with_autorelease_frequency(). + */ +#define DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL \ + dispatch_queue_attr_make_with_autorelease_frequency(\ + DISPATCH_QUEUE_SERIAL, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM) + +/*! + * @const DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL + * + * @discussion + * A dispatch queue created with this attribute may invokes blocks concurrently + * and supports barrier blocks submitted with the dispatch barrier API. It also + * surrounds execution of any block submitted asynchronously to it with the + * equivalent of a individual Objective-C @autoreleasepool + * + * See dispatch_queue_attr_make_with_autorelease_frequency(). + */ +#define DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL \ + dispatch_queue_attr_make_with_autorelease_frequency(\ + DISPATCH_QUEUE_CONCURRENT, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM) + +/*! + * @typedef dispatch_autorelease_frequency_t + * Values to pass to the dispatch_queue_attr_make_with_autorelease_frequency() + * function. + * + * @const DISPATCH_AUTORELEASE_FREQUENCY_INHERIT + * Dispatch queues with this autorelease frequency inherit the behavior from + * their target queue. This is the default behavior for manually created queues. + * + * @const DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM + * Dispatch queues with this autorelease frequency push and pop an autorelease + * pool around the execution of every block that was submitted to it + * asynchronously. + * @see dispatch_queue_attr_make_with_autorelease_frequency(). + * + * @const DISPATCH_AUTORELEASE_FREQUENCY_NEVER + * Dispatch queues with this autorelease frequency never set up an individual + * autorelease pool around the execution of a block that is submitted to it + * asynchronously. This is the behavior of the global concurrent queues. + */ +DISPATCH_ENUM(dispatch_autorelease_frequency, unsigned long, + DISPATCH_AUTORELEASE_FREQUENCY_INHERIT DISPATCH_ENUM_API_AVAILABLE( + macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 0, + DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM DISPATCH_ENUM_API_AVAILABLE( + macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 1, + DISPATCH_AUTORELEASE_FREQUENCY_NEVER DISPATCH_ENUM_API_AVAILABLE( + macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 2, +); + +/*! + * @function dispatch_queue_attr_make_with_autorelease_frequency + * + * @abstract + * Returns a dispatch queue attribute value with the autorelease frequency + * set to the specified value. + * + * @discussion + * When a queue uses the per-workitem autorelease frequency (either directly + * or inherithed from its target queue), any block submitted asynchronously to + * this queue (via dispatch_async(), dispatch_barrier_async(), + * dispatch_group_notify(), etc...) is executed as if surrounded by a individual + * Objective-C @autoreleasepool scope. + * + * Autorelease frequency has no effect on blocks that are submitted + * synchronously to a queue (via dispatch_sync(), dispatch_barrier_sync()). + * + * The global concurrent queues have the DISPATCH_AUTORELEASE_FREQUENCY_NEVER + * behavior. Manually created dispatch queues use + * DISPATCH_AUTORELEASE_FREQUENCY_INHERIT by default. + * + * Queues created with this attribute cannot change target queues after having + * been activated. See dispatch_set_target_queue() and dispatch_activate(). + * + * @param attr + * A queue attribute value to be combined with the specified autorelease + * frequency or NULL. + * + * @param frequency + * The requested autorelease frequency. + * + * @return + * Returns an attribute value which may be provided to dispatch_queue_create() + * or NULL if an invalid autorelease frequency was requested. + * This new value combines the attributes specified by the 'attr' parameter and + * the chosen autorelease frequency. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW +dispatch_queue_attr_t +dispatch_queue_attr_make_with_autorelease_frequency( + dispatch_queue_attr_t _Nullable attr, + dispatch_autorelease_frequency_t frequency); + +/*! + * @function dispatch_queue_attr_make_with_qos_class + * + * @abstract + * Returns an attribute value which may be provided to dispatch_queue_create() + * or dispatch_queue_create_with_target(), in order to assign a QOS class and + * relative priority to the queue. + * + * @discussion + * When specified in this manner, the QOS class and relative priority take + * precedence over those inherited from the dispatch queue's target queue (if + * any) as long that does not result in a lower QOS class and relative priority. + * + * The global queue priorities map to the following QOS classes: + * - DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED + * - DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT + * - DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY + * - DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND + * + * Example: + * + * dispatch_queue_t queue; + * dispatch_queue_attr_t attr; + * attr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, + * QOS_CLASS_UTILITY, 0); + * queue = dispatch_queue_create("com.example.myqueue", attr); + * + * + * The QOS class and relative priority set this way on a queue have no effect on + * blocks that are submitted synchronously to a queue (via dispatch_sync(), + * dispatch_barrier_sync()). + * + * @param attr + * A queue attribute value to be combined with the QOS class, or NULL. + * + * @param qos_class + * A QOS class value: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * Passing any other value results in NULL being returned. + * + * @param relative_priority + * A relative priority within the QOS class. This value is a negative + * offset from the maximum supported scheduler priority for the given class. + * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY + * results in NULL being returned. + * + * @return + * Returns an attribute value which may be provided to dispatch_queue_create() + * and dispatch_queue_create_with_target(), or NULL if an invalid QOS class was + * requested. + * The new value combines the attributes specified by the 'attr' parameter and + * the new QOS class and relative priority. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW +dispatch_queue_attr_t +dispatch_queue_attr_make_with_qos_class(dispatch_queue_attr_t _Nullable attr, + dispatch_qos_class_t qos_class, int relative_priority); + +/*! + * @const DISPATCH_TARGET_QUEUE_DEFAULT + * @discussion Constant to pass to the dispatch_queue_create_with_target(), + * dispatch_set_target_queue() and dispatch_source_create() functions to + * indicate that the default target queue for the object type in question + * should be used. + */ +#define DISPATCH_TARGET_QUEUE_DEFAULT NULL + +/*! + * @function dispatch_queue_create_with_target + * + * @abstract + * Creates a new dispatch queue with a specified target queue. + * + * @discussion + * Dispatch queues created with the DISPATCH_QUEUE_SERIAL or a NULL attribute + * invoke blocks serially in FIFO order. + * + * Dispatch queues created with the DISPATCH_QUEUE_CONCURRENT attribute may + * invoke blocks concurrently (similarly to the global concurrent queues, but + * potentially with more overhead), and support barrier blocks submitted with + * the dispatch barrier API, which e.g. enables the implementation of efficient + * reader-writer schemes. + * + * When a dispatch queue is no longer needed, it should be released with + * dispatch_release(). Note that any pending blocks submitted asynchronously to + * a queue will hold a reference to that queue. Therefore a queue will not be + * deallocated until all pending blocks have finished. + * + * When using a dispatch queue attribute @a attr specifying a QoS class (derived + * from the result of dispatch_queue_attr_make_with_qos_class()), passing the + * result of dispatch_get_global_queue() in @a target will ignore the QoS class + * of that global queue and will use the global queue with the QoS class + * specified by attr instead. + * + * Queues created with dispatch_queue_create_with_target() cannot have their + * target queue changed, unless created inactive (See + * dispatch_queue_attr_make_initially_inactive()), in which case the target + * queue can be changed until the newly created queue is activated with + * dispatch_activate(). + * + * @param label + * A string label to attach to the queue. + * This parameter is optional and may be NULL. + * + * @param attr + * A predefined attribute such as DISPATCH_QUEUE_SERIAL, + * DISPATCH_QUEUE_CONCURRENT, or the result of a call to + * a dispatch_queue_attr_make_with_* function. + * + * @param target + * The target queue for the newly created queue. The target queue is retained. + * If this parameter is DISPATCH_TARGET_QUEUE_DEFAULT, sets the queue's target + * queue to the default target queue for the given queue type. + * + * @result + * The newly created dispatch queue. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_queue_t +dispatch_queue_create_with_target(const char *_Nullable label, + dispatch_queue_attr_t _Nullable attr, dispatch_queue_t _Nullable target) + DISPATCH_ALIAS_V2(dispatch_queue_create_with_target); + +/*! + * @function dispatch_queue_create + * + * @abstract + * Creates a new dispatch queue to which blocks may be submitted. + * + * @discussion + * Dispatch queues created with the DISPATCH_QUEUE_SERIAL or a NULL attribute + * invoke blocks serially in FIFO order. + * + * Dispatch queues created with the DISPATCH_QUEUE_CONCURRENT attribute may + * invoke blocks concurrently (similarly to the global concurrent queues, but + * potentially with more overhead), and support barrier blocks submitted with + * the dispatch barrier API, which e.g. enables the implementation of efficient + * reader-writer schemes. + * + * When a dispatch queue is no longer needed, it should be released with + * dispatch_release(). Note that any pending blocks submitted asynchronously to + * a queue will hold a reference to that queue. Therefore a queue will not be + * deallocated until all pending blocks have finished. + * + * Passing the result of the dispatch_queue_attr_make_with_qos_class() function + * to the attr parameter of this function allows a quality of service class and + * relative priority to be specified for the newly created queue. + * The quality of service class so specified takes precedence over the quality + * of service class of the newly created dispatch queue's target queue (if any) + * as long that does not result in a lower QOS class and relative priority. + * + * When no quality of service class is specified, the target queue of a newly + * created dispatch queue is the default priority global concurrent queue. + * + * @param label + * A string label to attach to the queue. + * This parameter is optional and may be NULL. + * + * @param attr + * A predefined attribute such as DISPATCH_QUEUE_SERIAL, + * DISPATCH_QUEUE_CONCURRENT, or the result of a call to + * a dispatch_queue_attr_make_with_* function. + * + * @result + * The newly created dispatch queue. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_queue_t +dispatch_queue_create(const char *_Nullable label, + dispatch_queue_attr_t _Nullable attr); + +/*! + * @const DISPATCH_CURRENT_QUEUE_LABEL + * @discussion Constant to pass to the dispatch_queue_get_label() function to + * retrieve the label of the current queue. + */ +#define DISPATCH_CURRENT_QUEUE_LABEL NULL + +/*! + * @function dispatch_queue_get_label + * + * @abstract + * Returns the label of the given queue, as specified when the queue was + * created, or the empty string if a NULL label was specified. + * + * Passing DISPATCH_CURRENT_QUEUE_LABEL will return the label of the current + * queue. + * + * @param queue + * The queue to query, or DISPATCH_CURRENT_QUEUE_LABEL. + * + * @result + * The label of the queue. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW +const char * +dispatch_queue_get_label(dispatch_queue_t _Nullable queue); + +/*! + * @function dispatch_queue_get_qos_class + * + * @abstract + * Returns the QOS class and relative priority of the given queue. + * + * @discussion + * If the given queue was created with an attribute value returned from + * dispatch_queue_attr_make_with_qos_class(), this function returns the QOS + * class and relative priority specified at that time; for any other attribute + * value it returns a QOS class of QOS_CLASS_UNSPECIFIED and a relative + * priority of 0. + * + * If the given queue is one of the global queues, this function returns its + * assigned QOS class value as documented under dispatch_get_global_queue() and + * a relative priority of 0; in the case of the main queue it returns the QOS + * value provided by qos_class_main() and a relative priority of 0. + * + * @param queue + * The queue to query. + * + * @param relative_priority_ptr + * A pointer to an int variable to be filled with the relative priority offset + * within the QOS class, or NULL. + * + * @return + * A QOS class value: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * - QOS_CLASS_UNSPECIFIED + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NONNULL1 DISPATCH_NOTHROW +dispatch_qos_class_t +dispatch_queue_get_qos_class(dispatch_queue_t queue, + int *_Nullable relative_priority_ptr); + +/*! + * @function dispatch_set_target_queue + * + * @abstract + * Sets the target queue for the given object. + * + * @discussion + * An object's target queue is responsible for processing the object. + * + * When no quality of service class and relative priority is specified for a + * dispatch queue at the time of creation, a dispatch queue's quality of service + * class is inherited from its target queue. The dispatch_get_global_queue() + * function may be used to obtain a target queue of a specific quality of + * service class, however the use of dispatch_queue_attr_make_with_qos_class() + * is recommended instead. + * + * Blocks submitted to a serial queue whose target queue is another serial + * queue will not be invoked concurrently with blocks submitted to the target + * queue or to any other queue with that same target queue. + * + * The result of introducing a cycle into the hierarchy of target queues is + * undefined. + * + * A dispatch source's target queue specifies where its event handler and + * cancellation handler blocks will be submitted. + * + * A dispatch I/O channel's target queue specifies where where its I/O + * operations are executed. If the channel's target queue's priority is set to + * DISPATCH_QUEUE_PRIORITY_BACKGROUND, then the I/O operations performed by + * dispatch_io_read() or dispatch_io_write() on that queue will be + * throttled when there is I/O contention. + * + * For all other dispatch object types, the only function of the target queue + * is to determine where an object's finalizer function is invoked. + * + * In general, changing the target queue of an object is an asynchronous + * operation that doesn't take effect immediately, and doesn't affect blocks + * already associated with the specified object. + * + * However, if an object is inactive at the time dispatch_set_target_queue() is + * called, then the target queue change takes effect immediately, and will + * affect blocks already associated with the specified object. After an + * initially inactive object has been activated, calling + * dispatch_set_target_queue() results in an assertion and the process being + * terminated. + * + * If a dispatch queue is active and targeted by other dispatch objects, + * changing its target queue results in undefined behavior. + * + * @param object + * The object to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The new target queue for the object. The queue is retained, and the + * previous target queue, if any, is released. + * If queue is DISPATCH_TARGET_QUEUE_DEFAULT, set the object's target queue + * to the default target queue for the given object type. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW +void +dispatch_set_target_queue(dispatch_object_t object, + dispatch_queue_t _Nullable queue); + +/*! + * @function dispatch_main + * + * @abstract + * Execute blocks submitted to the main queue. + * + * @discussion + * This function "parks" the main thread and waits for blocks to be submitted + * to the main queue. This function never returns. + * + * Applications that call NSApplicationMain() or CFRunLoopRun() on the + * main thread do not need to call dispatch_main(). + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW DISPATCH_NORETURN +void +dispatch_main(void); + +/*! + * @function dispatch_after + * + * @abstract + * Schedule a block for execution on a given queue at a specified time. + * + * @discussion + * Passing DISPATCH_TIME_NOW as the "when" parameter is supported, but not as + * optimal as calling dispatch_async() instead. Passing DISPATCH_TIME_FOREVER + * is undefined. + * + * @param when + * A temporal milestone returned by dispatch_time() or dispatch_walltime(). + * + * @param queue + * A queue to which the given block will be submitted at the specified time. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block of code to execute. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_after(dispatch_time_t when, dispatch_queue_t queue, + dispatch_block_t block); +#endif + +/*! + * @function dispatch_after_f + * + * @abstract + * Schedule a function for execution on a given queue at a specified time. + * + * @discussion + * See dispatch_after() for details. + * + * @param when + * A temporal milestone returned by dispatch_time() or dispatch_walltime(). + * + * @param queue + * A queue to which the given function will be submitted at the specified time. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_after_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL4 DISPATCH_NOTHROW +void +dispatch_after_f(dispatch_time_t when, dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @functiongroup Dispatch Barrier API + * The dispatch barrier API is a mechanism for submitting barrier blocks to a + * dispatch queue, analogous to the dispatch_async()/dispatch_sync() API. + * It enables the implementation of efficient reader/writer schemes. + * Barrier blocks only behave specially when submitted to queues created with + * the DISPATCH_QUEUE_CONCURRENT attribute; on such a queue, a barrier block + * will not run until all blocks submitted to the queue earlier have completed, + * and any blocks submitted to the queue after a barrier block will not run + * until the barrier block has completed. + * When submitted to a a global queue or to a queue not created with the + * DISPATCH_QUEUE_CONCURRENT attribute, barrier blocks behave identically to + * blocks submitted with the dispatch_async()/dispatch_sync() API. + */ + +/*! + * @function dispatch_barrier_async + * + * @abstract + * Submits a barrier block for asynchronous execution on a dispatch queue. + * + * @discussion + * Submits a block to a dispatch queue like dispatch_async(), but marks that + * block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues). + * + * See dispatch_async() for details and "Dispatch Barrier API" for a description + * of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The system will hold a reference on the target queue until the block + * has finished. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to submit to the target dispatch queue. This function performs + * Block_copy() and Block_release() on behalf of callers. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_barrier_async(dispatch_queue_t queue, dispatch_block_t block); +#endif + +/*! + * @function dispatch_barrier_async_f + * + * @abstract + * Submits a barrier function for asynchronous execution on a dispatch queue. + * + * @discussion + * Submits a function to a dispatch queue like dispatch_async_f(), but marks + * that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT + * queues). + * + * See dispatch_async_f() for details and "Dispatch Barrier API" for a + * description of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The system will hold a reference on the target queue until the function + * has returned. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_barrier_async_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_barrier_async_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @function dispatch_barrier_sync + * + * @abstract + * Submits a barrier block for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a block to a dispatch queue like dispatch_sync(), but marks that + * block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues). + * + * See dispatch_sync() for details and "Dispatch Barrier API" for a description + * of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to be invoked on the target dispatch queue. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_barrier_sync(dispatch_queue_t queue, + DISPATCH_NOESCAPE dispatch_block_t block); +#endif + +/*! + * @function dispatch_barrier_sync_f + * + * @abstract + * Submits a barrier function for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a function to a dispatch queue like dispatch_sync_f(), but marks that + * fuction as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues). + * + * See dispatch_sync_f() for details. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_barrier_sync_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_barrier_sync_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @function dispatch_barrier_async_and_wait + * + * @abstract + * Submits a block for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a block to a dispatch queue like dispatch_async_and_wait(), but marks + * that block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT + * queues). + * + * See "Dispatch Barrier API" for a description of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param work + * The application-defined block to invoke on the target queue. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_barrier_async_and_wait(dispatch_queue_t queue, + DISPATCH_NOESCAPE dispatch_block_t block); +#endif + +/*! + * @function dispatch_barrier_async_and_wait_f + * + * @abstract + * Submits a function for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a function to a dispatch queue like dispatch_async_and_wait_f(), but + * marks that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT + * queues). + * + * See "Dispatch Barrier API" for a description of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_barrier_async_and_wait_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_barrier_async_and_wait_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @functiongroup Dispatch queue-specific contexts + * This API allows different subsystems to associate context to a shared queue + * without risk of collision and to retrieve that context from blocks executing + * on that queue or any of its child queues in the target queue hierarchy. + */ + +/*! + * @function dispatch_queue_set_specific + * + * @abstract + * Associates a subsystem-specific context with a dispatch queue, for a key + * unique to the subsystem. + * + * @discussion + * The specified destructor will be invoked with the context on the default + * priority global concurrent queue when a new context is set for the same key, + * or after all references to the queue have been released. + * + * @param queue + * The dispatch queue to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param key + * The key to set the context for, typically a pointer to a static variable + * specific to the subsystem. Keys are only compared as pointers and never + * dereferenced. Passing a string constant directly is not recommended. + * The NULL key is reserved and attempts to set a context for it are ignored. + * + * @param context + * The new subsystem-specific context for the object. This may be NULL. + * + * @param destructor + * The destructor function pointer. This may be NULL and is ignored if context + * is NULL. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_queue_set_specific(dispatch_queue_t queue, const void *key, + void *_Nullable context, dispatch_function_t _Nullable destructor); + +/*! + * @function dispatch_queue_get_specific + * + * @abstract + * Returns the subsystem-specific context associated with a dispatch queue, for + * a key unique to the subsystem. + * + * @discussion + * Returns the context for the specified key if it has been set on the specified + * queue. + * + * @param queue + * The dispatch queue to query. + * The result of passing NULL in this parameter is undefined. + * + * @param key + * The key to get the context for, typically a pointer to a static variable + * specific to the subsystem. Keys are only compared as pointers and never + * dereferenced. Passing a string constant directly is not recommended. + * + * @result + * The context for the specified key or NULL if no context was found. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_PURE DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +void *_Nullable +dispatch_queue_get_specific(dispatch_queue_t queue, const void *key); + +/*! + * @function dispatch_get_specific + * + * @abstract + * Returns the current subsystem-specific context for a key unique to the + * subsystem. + * + * @discussion + * When called from a block executing on a queue, returns the context for the + * specified key if it has been set on the queue, otherwise returns the result + * of dispatch_get_specific() executed on the queue's target queue or NULL + * if the current queue is a global concurrent queue. + * + * @param key + * The key to get the context for, typically a pointer to a static variable + * specific to the subsystem. Keys are only compared as pointers and never + * dereferenced. Passing a string constant directly is not recommended. + * + * @result + * The context for the specified key or NULL if no context was found. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW +void *_Nullable +dispatch_get_specific(const void *key); + +/*! + * @functiongroup Dispatch assertion API + * + * This API asserts at runtime that code is executing in (or out of) the context + * of a given queue. It can be used to check that a block accessing a resource + * does so from the proper queue protecting the resource. It also can be used + * to verify that a block that could cause a deadlock if run on a given queue + * never executes on that queue. + */ + +/*! + * @function dispatch_assert_queue + * + * @abstract + * Verifies that the current block is executing on a given dispatch queue. + * + * @discussion + * Some code expects to be run on a specific dispatch queue. This function + * verifies that that expectation is true. + * + * If the currently executing block was submitted to the specified queue or to + * any queue targeting it (see dispatch_set_target_queue()), this function + * returns. + * + * If the currently executing block was submitted with a synchronous API + * (dispatch_sync(), dispatch_barrier_sync(), ...), the context of the + * submitting block is also evaluated (recursively). + * If a synchronously submitting block is found that was itself submitted to + * the specified queue or to any queue targeting it, this function returns. + * + * Otherwise this function asserts: it logs an explanation to the system log and + * terminates the application. + * + * Passing the result of dispatch_get_main_queue() to this function verifies + * that the current block was submitted to the main queue, or to a queue + * targeting it, or is running on the main thread (in any context). + * + * When dispatch_assert_queue() is called outside of the context of a + * submitted block (for example from the context of a thread created manually + * with pthread_create()) then this function will also assert and terminate + * the application. + * + * The variant dispatch_assert_queue_debug() is compiled out when the + * preprocessor macro NDEBUG is defined. (See also assert(3)). + * + * @param queue + * The dispatch queue that the current block is expected to run on. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 +void +dispatch_assert_queue(dispatch_queue_t queue) + DISPATCH_ALIAS_V2(dispatch_assert_queue); + +/*! + * @function dispatch_assert_queue_barrier + * + * @abstract + * Verifies that the current block is executing on a given dispatch queue, + * and that the block acts as a barrier on that queue. + * + * @discussion + * This behaves exactly like dispatch_assert_queue(), with the additional check + * that the current block acts as a barrier on the specified queue, which is + * always true if the specified queue is serial (see DISPATCH_BLOCK_BARRIER or + * dispatch_barrier_async() for details). + * + * The variant dispatch_assert_queue_barrier_debug() is compiled out when the + * preprocessor macro NDEBUG is defined. (See also assert()). + * + * @param queue + * The dispatch queue that the current block is expected to run as a barrier on. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 +void +dispatch_assert_queue_barrier(dispatch_queue_t queue); + +/*! + * @function dispatch_assert_queue_not + * + * @abstract + * Verifies that the current block is not executing on a given dispatch queue. + * + * @discussion + * This function is the equivalent of dispatch_assert_queue() with the test for + * equality inverted. That means that it will terminate the application when + * dispatch_assert_queue() would return, and vice-versa. See discussion there. + * + * The variant dispatch_assert_queue_not_debug() is compiled out when the + * preprocessor macro NDEBUG is defined. (See also assert(3)). + * + * @param queue + * The dispatch queue that the current block is expected not to run on. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 +void +dispatch_assert_queue_not(dispatch_queue_t queue) + DISPATCH_ALIAS_V2(dispatch_assert_queue_not); + +#ifdef NDEBUG +#define dispatch_assert_queue_debug(q) ((void)(0 && (q))) +#define dispatch_assert_queue_barrier_debug(q) ((void)(0 && (q))) +#define dispatch_assert_queue_not_debug(q) ((void)(0 && (q))) +#else +#define dispatch_assert_queue_debug(q) dispatch_assert_queue(q) +#define dispatch_assert_queue_barrier_debug(q) dispatch_assert_queue_barrier(q) +#define dispatch_assert_queue_not_debug(q) dispatch_assert_queue_not(q) +#endif + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/semaphore.h b/lib/libc/include/x86_64-macos-gnu/dispatch/semaphore.h new file mode 100644 index 0000000000..a6f9394f95 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/semaphore.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2008-2013 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_SEMAPHORE__ +#define __DISPATCH_SEMAPHORE__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @typedef dispatch_semaphore_t + * + * @abstract + * A counting semaphore. + */ +DISPATCH_DECL(dispatch_semaphore); + +__BEGIN_DECLS + +/*! + * @function dispatch_semaphore_create + * + * @abstract + * Creates new counting semaphore with an initial value. + * + * @discussion + * Passing zero for the value is useful for when two threads need to reconcile + * the completion of a particular event. Passing a value greater than zero is + * useful for managing a finite pool of resources, where the pool size is equal + * to the value. + * + * @param value + * The starting value for the semaphore. Passing a value less than zero will + * cause NULL to be returned. + * + * @result + * The newly created semaphore, or NULL on failure. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_semaphore_t +dispatch_semaphore_create(intptr_t value); + +/*! + * @function dispatch_semaphore_wait + * + * @abstract + * Wait (decrement) for a semaphore. + * + * @discussion + * Decrement the counting semaphore. If the resulting value is less than zero, + * this function waits for a signal to occur before returning. + * + * @param dsema + * The semaphore. The result of passing NULL in this parameter is undefined. + * + * @param timeout + * When to timeout (see dispatch_time). As a convenience, there are the + * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants. + * + * @result + * Returns zero on success, or non-zero if the timeout occurred. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +intptr_t +dispatch_semaphore_wait(dispatch_semaphore_t dsema, dispatch_time_t timeout); + +/*! + * @function dispatch_semaphore_signal + * + * @abstract + * Signal (increment) a semaphore. + * + * @discussion + * Increment the counting semaphore. If the previous value was less than zero, + * this function wakes a waiting thread before returning. + * + * @param dsema The counting semaphore. + * The result of passing NULL in this parameter is undefined. + * + * @result + * This function returns non-zero if a thread is woken. Otherwise, zero is + * returned. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +intptr_t +dispatch_semaphore_signal(dispatch_semaphore_t dsema); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif /* __DISPATCH_SEMAPHORE__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/source.h b/lib/libc/include/x86_64-macos-gnu/dispatch/source.h new file mode 100644 index 0000000000..5ce8260223 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/source.h @@ -0,0 +1,780 @@ +/* + * Copyright (c) 2008-2013 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_SOURCE__ +#define __DISPATCH_SOURCE__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +#if TARGET_OS_MAC +#include +#include +#endif + +#if !defined(_WIN32) +#include +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @header + * The dispatch framework provides a suite of interfaces for monitoring low- + * level system objects (file descriptors, Mach ports, signals, VFS nodes, etc.) + * for activity and automatically submitting event handler blocks to dispatch + * queues when such activity occurs. + * + * This suite of interfaces is known as the Dispatch Source API. + */ + +/*! + * @typedef dispatch_source_t + * + * @abstract + * Dispatch sources are used to automatically submit event handler blocks to + * dispatch queues in response to external events. + */ +DISPATCH_SOURCE_DECL(dispatch_source); + +__BEGIN_DECLS + +/*! + * @typedef dispatch_source_type_t + * + * @abstract + * Constants of this type represent the class of low-level system object that + * is being monitored by the dispatch source. Constants of this type are + * passed as a parameter to dispatch_source_create() and determine how the + * handle argument is interpreted (i.e. as a file descriptor, mach port, + * signal number, process identifier, etc.), and how the mask argument is + * interpreted. + */ +typedef const struct dispatch_source_type_s *dispatch_source_type_t; + +/*! + * @const DISPATCH_SOURCE_TYPE_DATA_ADD + * @discussion A dispatch source that coalesces data obtained via calls to + * dispatch_source_merge_data(). An ADD is used to coalesce the data. + * The handle is unused (pass zero for now). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_DATA_ADD (&_dispatch_source_type_data_add) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(data_add); + +/*! + * @const DISPATCH_SOURCE_TYPE_DATA_OR + * @discussion A dispatch source that coalesces data obtained via calls to + * dispatch_source_merge_data(). A bitwise OR is used to coalesce the data. + * The handle is unused (pass zero for now). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_DATA_OR (&_dispatch_source_type_data_or) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(data_or); + +/*! + * @const DISPATCH_SOURCE_TYPE_DATA_REPLACE + * @discussion A dispatch source that tracks data obtained via calls to + * dispatch_source_merge_data(). Newly obtained data values replace existing + * data values not yet delivered to the source handler + * + * A data value of zero will cause the source handler to not be invoked. + * + * The handle is unused (pass zero for now). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_DATA_REPLACE (&_dispatch_source_type_data_replace) +API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)) +DISPATCH_SOURCE_TYPE_DECL(data_replace); + +/*! + * @const DISPATCH_SOURCE_TYPE_MACH_SEND + * @discussion A dispatch source that monitors a Mach port for dead name + * notifications (send right no longer has any corresponding receive right). + * The handle is a Mach port with a send or send-once right (mach_port_t). + * The mask is a mask of desired events from dispatch_source_mach_send_flags_t. + */ +#define DISPATCH_SOURCE_TYPE_MACH_SEND (&_dispatch_source_type_mach_send) +API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(mach_send); + +/*! + * @const DISPATCH_SOURCE_TYPE_MACH_RECV + * @discussion A dispatch source that monitors a Mach port for pending messages. + * The handle is a Mach port with a receive right (mach_port_t). + * The mask is a mask of desired events from dispatch_source_mach_recv_flags_t, + * but no flags are currently defined (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_MACH_RECV (&_dispatch_source_type_mach_recv) +API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(mach_recv); + +/*! + * @const DISPATCH_SOURCE_TYPE_MEMORYPRESSURE + * @discussion A dispatch source that monitors the system for changes in + * memory pressure condition. + * The handle is unused (pass zero for now). + * The mask is a mask of desired events from + * dispatch_source_memorypressure_flags_t. + */ +#define DISPATCH_SOURCE_TYPE_MEMORYPRESSURE \ + (&_dispatch_source_type_memorypressure) +API_AVAILABLE(macos(10.9), ios(8.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(memorypressure); + +/*! + * @const DISPATCH_SOURCE_TYPE_PROC + * @discussion A dispatch source that monitors an external process for events + * defined by dispatch_source_proc_flags_t. + * The handle is a process identifier (pid_t). + * The mask is a mask of desired events from dispatch_source_proc_flags_t. + */ +#define DISPATCH_SOURCE_TYPE_PROC (&_dispatch_source_type_proc) +API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(proc); + +/*! + * @const DISPATCH_SOURCE_TYPE_READ + * @discussion A dispatch source that monitors a file descriptor for pending + * bytes available to be read. + * The handle is a file descriptor (int). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(read); + +/*! + * @const DISPATCH_SOURCE_TYPE_SIGNAL + * @discussion A dispatch source that monitors the current process for signals. + * The handle is a signal number (int). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_SIGNAL (&_dispatch_source_type_signal) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(signal); + +/*! + * @const DISPATCH_SOURCE_TYPE_TIMER + * @discussion A dispatch source that submits the event handler block based + * on a timer. + * The handle is unused (pass zero for now). + * The mask specifies which flags from dispatch_source_timer_flags_t to apply. + */ +#define DISPATCH_SOURCE_TYPE_TIMER (&_dispatch_source_type_timer) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(timer); + +/*! + * @const DISPATCH_SOURCE_TYPE_VNODE + * @discussion A dispatch source that monitors a file descriptor for events + * defined by dispatch_source_vnode_flags_t. + * The handle is a file descriptor (int). + * The mask is a mask of desired events from dispatch_source_vnode_flags_t. + */ +#define DISPATCH_SOURCE_TYPE_VNODE (&_dispatch_source_type_vnode) +API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(vnode); + +/*! + * @const DISPATCH_SOURCE_TYPE_WRITE + * @discussion A dispatch source that monitors a file descriptor for available + * buffer space to write bytes. + * The handle is a file descriptor (int). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_WRITE (&_dispatch_source_type_write) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(write); + +/*! + * @typedef dispatch_source_mach_send_flags_t + * Type of dispatch_source_mach_send flags + * + * @constant DISPATCH_MACH_SEND_DEAD + * The receive right corresponding to the given send right was destroyed. + */ +#define DISPATCH_MACH_SEND_DEAD 0x1 + +typedef unsigned long dispatch_source_mach_send_flags_t; + +/*! + * @typedef dispatch_source_mach_recv_flags_t + * Type of dispatch_source_mach_recv flags + */ +typedef unsigned long dispatch_source_mach_recv_flags_t; + +/*! + * @typedef dispatch_source_memorypressure_flags_t + * Type of dispatch_source_memorypressure flags + * + * @constant DISPATCH_MEMORYPRESSURE_NORMAL + * The system memory pressure condition has returned to normal. + * + * @constant DISPATCH_MEMORYPRESSURE_WARN + * The system memory pressure condition has changed to warning. + * + * @constant DISPATCH_MEMORYPRESSURE_CRITICAL + * The system memory pressure condition has changed to critical. + * + * @discussion + * Elevated memory pressure is a system-wide condition that applications + * registered for this source should react to by changing their future memory + * use behavior, e.g. by reducing cache sizes of newly initiated operations + * until memory pressure returns back to normal. + * NOTE: applications should NOT traverse and discard existing caches for past + * operations when the system memory pressure enters an elevated state, as that + * is likely to trigger VM operations that will further aggravate system memory + * pressure. + */ + +#define DISPATCH_MEMORYPRESSURE_NORMAL 0x01 +#define DISPATCH_MEMORYPRESSURE_WARN 0x02 +#define DISPATCH_MEMORYPRESSURE_CRITICAL 0x04 + +typedef unsigned long dispatch_source_memorypressure_flags_t; + +/*! + * @typedef dispatch_source_proc_flags_t + * Type of dispatch_source_proc flags + * + * @constant DISPATCH_PROC_EXIT + * The process has exited (perhaps cleanly, perhaps not). + * + * @constant DISPATCH_PROC_FORK + * The process has created one or more child processes. + * + * @constant DISPATCH_PROC_EXEC + * The process has become another executable image via + * exec*() or posix_spawn*(). + * + * @constant DISPATCH_PROC_SIGNAL + * A Unix signal was delivered to the process. + */ +#define DISPATCH_PROC_EXIT 0x80000000 +#define DISPATCH_PROC_FORK 0x40000000 +#define DISPATCH_PROC_EXEC 0x20000000 +#define DISPATCH_PROC_SIGNAL 0x08000000 + +typedef unsigned long dispatch_source_proc_flags_t; + +/*! + * @typedef dispatch_source_vnode_flags_t + * Type of dispatch_source_vnode flags + * + * @constant DISPATCH_VNODE_DELETE + * The filesystem object was deleted from the namespace. + * + * @constant DISPATCH_VNODE_WRITE + * The filesystem object data changed. + * + * @constant DISPATCH_VNODE_EXTEND + * The filesystem object changed in size. + * + * @constant DISPATCH_VNODE_ATTRIB + * The filesystem object metadata changed. + * + * @constant DISPATCH_VNODE_LINK + * The filesystem object link count changed. + * + * @constant DISPATCH_VNODE_RENAME + * The filesystem object was renamed in the namespace. + * + * @constant DISPATCH_VNODE_REVOKE + * The filesystem object was revoked. + * + * @constant DISPATCH_VNODE_FUNLOCK + * The filesystem object was unlocked. + */ + +#define DISPATCH_VNODE_DELETE 0x1 +#define DISPATCH_VNODE_WRITE 0x2 +#define DISPATCH_VNODE_EXTEND 0x4 +#define DISPATCH_VNODE_ATTRIB 0x8 +#define DISPATCH_VNODE_LINK 0x10 +#define DISPATCH_VNODE_RENAME 0x20 +#define DISPATCH_VNODE_REVOKE 0x40 +#define DISPATCH_VNODE_FUNLOCK 0x100 + +typedef unsigned long dispatch_source_vnode_flags_t; + +/*! + * @typedef dispatch_source_timer_flags_t + * Type of dispatch_source_timer flags + * + * @constant DISPATCH_TIMER_STRICT + * Specifies that the system should make a best effort to strictly observe the + * leeway value specified for the timer via dispatch_source_set_timer(), even + * if that value is smaller than the default leeway value that would be applied + * to the timer otherwise. A minimal amount of leeway will be applied to the + * timer even if this flag is specified. + * + * CAUTION: Use of this flag may override power-saving techniques employed by + * the system and cause higher power consumption, so it must be used with care + * and only when absolutely necessary. + */ + +#define DISPATCH_TIMER_STRICT 0x1 + +typedef unsigned long dispatch_source_timer_flags_t; + +/*! + * @function dispatch_source_create + * + * @abstract + * Creates a new dispatch source to monitor low-level system objects and auto- + * matically submit a handler block to a dispatch queue in response to events. + * + * @discussion + * Dispatch sources are not reentrant. Any events received while the dispatch + * source is suspended or while the event handler block is currently executing + * will be coalesced and delivered after the dispatch source is resumed or the + * event handler block has returned. + * + * Dispatch sources are created in an inactive state. After creating the + * source and setting any desired attributes (i.e. the handler, context, etc.), + * a call must be made to dispatch_activate() in order to begin event delivery. + * + * Calling dispatch_set_target_queue() on a source once it has been activated + * is not allowed (see dispatch_activate() and dispatch_set_target_queue()). + * + * For backward compatibility reasons, dispatch_resume() on an inactive, + * and not otherwise suspended source has the same effect as calling + * dispatch_activate(). For new code, using dispatch_activate() is preferred. + * + * @param type + * Declares the type of the dispatch source. Must be one of the defined + * dispatch_source_type_t constants. + * + * @param handle + * The underlying system handle to monitor. The interpretation of this argument + * is determined by the constant provided in the type parameter. + * + * @param mask + * A mask of flags specifying which events are desired. The interpretation of + * this argument is determined by the constant provided in the type parameter. + * + * @param queue + * The dispatch queue to which the event handler block will be submitted. + * If queue is DISPATCH_TARGET_QUEUE_DEFAULT, the source will submit the event + * handler block to the default priority global queue. + * + * @result + * The newly created dispatch source. Or NULL if invalid arguments are passed. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_source_t +dispatch_source_create(dispatch_source_type_t type, + uintptr_t handle, + uintptr_t mask, + dispatch_queue_t _Nullable queue); + +/*! + * @function dispatch_source_set_event_handler + * + * @abstract + * Sets the event handler block for the given dispatch source. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The event handler block to submit to the source's target queue. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_event_handler(dispatch_source_t source, + dispatch_block_t _Nullable handler); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_source_set_event_handler_f + * + * @abstract + * Sets the event handler function for the given dispatch source. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The event handler function to submit to the source's target queue. + * The context parameter passed to the event handler function is the context of + * the dispatch source current at the time the event handler was set. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_event_handler_f(dispatch_source_t source, + dispatch_function_t _Nullable handler); + +/*! + * @function dispatch_source_set_cancel_handler + * + * @abstract + * Sets the cancellation handler block for the given dispatch source. + * + * @discussion + * The cancellation handler (if specified) will be submitted to the source's + * target queue in response to a call to dispatch_source_cancel() once the + * system has released all references to the source's underlying handle and + * the source's event handler block has returned. + * + * IMPORTANT: + * Source cancellation and a cancellation handler are required for file + * descriptor and mach port based sources in order to safely close the + * descriptor or destroy the port. + * Closing the descriptor or port before the cancellation handler is invoked may + * result in a race condition. If a new descriptor is allocated with the same + * value as the recently closed descriptor while the source's event handler is + * still running, the event handler may read/write data to the wrong descriptor. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The cancellation handler block to submit to the source's target queue. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_cancel_handler(dispatch_source_t source, + dispatch_block_t _Nullable handler); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_source_set_cancel_handler_f + * + * @abstract + * Sets the cancellation handler function for the given dispatch source. + * + * @discussion + * See dispatch_source_set_cancel_handler() for more details. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The cancellation handler function to submit to the source's target queue. + * The context parameter passed to the event handler function is the current + * context of the dispatch source at the time the handler call is made. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_cancel_handler_f(dispatch_source_t source, + dispatch_function_t _Nullable handler); + +/*! + * @function dispatch_source_cancel + * + * @abstract + * Asynchronously cancel the dispatch source, preventing any further invocation + * of its event handler block. + * + * @discussion + * Cancellation prevents any further invocation of the event handler block for + * the specified dispatch source, but does not interrupt an event handler + * block that is already in progress. + * + * The cancellation handler is submitted to the source's target queue once the + * the source's event handler has finished, indicating it is now safe to close + * the source's handle (i.e. file descriptor or mach port). + * + * See dispatch_source_set_cancel_handler() for more information. + * + * @param source + * The dispatch source to be canceled. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_source_cancel(dispatch_source_t source); + +/*! + * @function dispatch_source_testcancel + * + * @abstract + * Tests whether the given dispatch source has been canceled. + * + * @param source + * The dispatch source to be tested. + * The result of passing NULL in this parameter is undefined. + * + * @result + * Non-zero if canceled and zero if not canceled. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +intptr_t +dispatch_source_testcancel(dispatch_source_t source); + +/*! + * @function dispatch_source_get_handle + * + * @abstract + * Returns the underlying system handle associated with this dispatch source. + * + * @param source + * The result of passing NULL in this parameter is undefined. + * + * @result + * The return value should be interpreted according to the type of the dispatch + * source, and may be one of the following handles: + * + * DISPATCH_SOURCE_TYPE_DATA_ADD: n/a + * DISPATCH_SOURCE_TYPE_DATA_OR: n/a + * DISPATCH_SOURCE_TYPE_DATA_REPLACE: n/a + * DISPATCH_SOURCE_TYPE_MACH_SEND: mach port (mach_port_t) + * DISPATCH_SOURCE_TYPE_MACH_RECV: mach port (mach_port_t) + * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE n/a + * DISPATCH_SOURCE_TYPE_PROC: process identifier (pid_t) + * DISPATCH_SOURCE_TYPE_READ: file descriptor (int) + * DISPATCH_SOURCE_TYPE_SIGNAL: signal number (int) + * DISPATCH_SOURCE_TYPE_TIMER: n/a + * DISPATCH_SOURCE_TYPE_VNODE: file descriptor (int) + * DISPATCH_SOURCE_TYPE_WRITE: file descriptor (int) + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +uintptr_t +dispatch_source_get_handle(dispatch_source_t source); + +/*! + * @function dispatch_source_get_mask + * + * @abstract + * Returns the mask of events monitored by the dispatch source. + * + * @param source + * The result of passing NULL in this parameter is undefined. + * + * @result + * The return value should be interpreted according to the type of the dispatch + * source, and may be one of the following flag sets: + * + * DISPATCH_SOURCE_TYPE_DATA_ADD: n/a + * DISPATCH_SOURCE_TYPE_DATA_OR: n/a + * DISPATCH_SOURCE_TYPE_DATA_REPLACE: n/a + * DISPATCH_SOURCE_TYPE_MACH_SEND: dispatch_source_mach_send_flags_t + * DISPATCH_SOURCE_TYPE_MACH_RECV: dispatch_source_mach_recv_flags_t + * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE dispatch_source_memorypressure_flags_t + * DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_flags_t + * DISPATCH_SOURCE_TYPE_READ: n/a + * DISPATCH_SOURCE_TYPE_SIGNAL: n/a + * DISPATCH_SOURCE_TYPE_TIMER: dispatch_source_timer_flags_t + * DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_vnode_flags_t + * DISPATCH_SOURCE_TYPE_WRITE: n/a + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +uintptr_t +dispatch_source_get_mask(dispatch_source_t source); + +/*! + * @function dispatch_source_get_data + * + * @abstract + * Returns pending data for the dispatch source. + * + * @discussion + * This function is intended to be called from within the event handler block. + * The result of calling this function outside of the event handler callback is + * undefined. + * + * @param source + * The result of passing NULL in this parameter is undefined. + * + * @result + * The return value should be interpreted according to the type of the dispatch + * source, and may be one of the following: + * + * DISPATCH_SOURCE_TYPE_DATA_ADD: application defined data + * DISPATCH_SOURCE_TYPE_DATA_OR: application defined data + * DISPATCH_SOURCE_TYPE_DATA_REPLACE: application defined data + * DISPATCH_SOURCE_TYPE_MACH_SEND: dispatch_source_mach_send_flags_t + * DISPATCH_SOURCE_TYPE_MACH_RECV: dispatch_source_mach_recv_flags_t + * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE dispatch_source_memorypressure_flags_t + * DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_flags_t + * DISPATCH_SOURCE_TYPE_READ: estimated bytes available to read + * DISPATCH_SOURCE_TYPE_SIGNAL: number of signals delivered since + * the last handler invocation + * DISPATCH_SOURCE_TYPE_TIMER: number of times the timer has fired + * since the last handler invocation + * DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_vnode_flags_t + * DISPATCH_SOURCE_TYPE_WRITE: estimated buffer space available + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +uintptr_t +dispatch_source_get_data(dispatch_source_t source); + +/*! + * @function dispatch_source_merge_data + * + * @abstract + * Merges data into a dispatch source of type DISPATCH_SOURCE_TYPE_DATA_ADD, + * DISPATCH_SOURCE_TYPE_DATA_OR or DISPATCH_SOURCE_TYPE_DATA_REPLACE, + * and submits its event handler block to its target queue. + * + * @param source + * The result of passing NULL in this parameter is undefined. + * + * @param value + * The value to coalesce with the pending data using a logical OR or an ADD + * as specified by the dispatch source type. A value of zero has no effect + * and will not result in the submission of the event handler block. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_source_merge_data(dispatch_source_t source, uintptr_t value); + +/*! + * @function dispatch_source_set_timer + * + * @abstract + * Sets a start time, interval, and leeway value for a timer source. + * + * @discussion + * Once this function returns, any pending source data accumulated for the + * previous timer values has been cleared; the next fire of the timer will + * occur at 'start', and every 'interval' nanoseconds thereafter until the + * timer source is canceled. + * + * Any fire of the timer may be delayed by the system in order to improve power + * consumption and system performance. The upper limit to the allowable delay + * may be configured with the 'leeway' argument, the lower limit is under the + * control of the system. + * + * For the initial timer fire at 'start', the upper limit to the allowable + * delay is set to 'leeway' nanoseconds. For the subsequent timer fires at + * 'start' + N * 'interval', the upper limit is MIN('leeway','interval'/2). + * + * The lower limit to the allowable delay may vary with process state such as + * visibility of application UI. If the specified timer source was created with + * a mask of DISPATCH_TIMER_STRICT, the system will make a best effort to + * strictly observe the provided 'leeway' value even if it is smaller than the + * current lower limit. Note that a minimal amount of delay is to be expected + * even if this flag is specified. + * + * The 'start' argument also determines which clock will be used for the timer: + * If 'start' is DISPATCH_TIME_NOW or was created with dispatch_time(3), the + * timer is based on up time (which is obtained from mach_absolute_time() on + * Apple platforms). If 'start' was created with dispatch_walltime(3), the + * timer is based on gettimeofday(3). + * + * Calling this function has no effect if the timer source has already been + * canceled. + * + * @param start + * The start time of the timer. See dispatch_time() and dispatch_walltime() + * for more information. + * + * @param interval + * The nanosecond interval for the timer. Use DISPATCH_TIME_FOREVER for a + * one-shot timer. + * + * @param leeway + * The nanosecond leeway for the timer. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_source_set_timer(dispatch_source_t source, + dispatch_time_t start, + uint64_t interval, + uint64_t leeway); + +/*! + * @function dispatch_source_set_registration_handler + * + * @abstract + * Sets the registration handler block for the given dispatch source. + * + * @discussion + * The registration handler (if specified) will be submitted to the source's + * target queue once the corresponding kevent() has been registered with the + * system, following the initial dispatch_resume() of the source. + * + * If a source is already registered when the registration handler is set, the + * registration handler will be invoked immediately. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The registration handler block to submit to the source's target queue. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_registration_handler(dispatch_source_t source, + dispatch_block_t _Nullable handler); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_source_set_registration_handler_f + * + * @abstract + * Sets the registration handler function for the given dispatch source. + * + * @discussion + * See dispatch_source_set_registration_handler() for more details. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The registration handler function to submit to the source's target queue. + * The context parameter passed to the registration handler function is the + * current context of the dispatch source at the time the handler call is made. + */ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_registration_handler_f(dispatch_source_t source, + dispatch_function_t _Nullable handler); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/time.h b/lib/libc/include/x86_64-macos-gnu/dispatch/time.h new file mode 100644 index 0000000000..a1cd2006ef --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/time.h @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2008-2011 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_TIME__ +#define __DISPATCH_TIME__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +#include + +// +#if TARGET_OS_MAC +#include +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +#ifdef NSEC_PER_SEC +#undef NSEC_PER_SEC +#endif +#ifdef USEC_PER_SEC +#undef USEC_PER_SEC +#endif +#ifdef NSEC_PER_USEC +#undef NSEC_PER_USEC +#endif +#ifdef NSEC_PER_MSEC +#undef NSEC_PER_MSEC +#endif +#define NSEC_PER_SEC 1000000000ull +#define NSEC_PER_MSEC 1000000ull +#define USEC_PER_SEC 1000000ull +#define NSEC_PER_USEC 1000ull + +__BEGIN_DECLS + +struct timespec; + +/*! + * @typedef dispatch_time_t + * + * @abstract + * A somewhat abstract representation of time; where zero means "now" and + * DISPATCH_TIME_FOREVER means "infinity" and every value in between is an + * opaque encoding. + */ +typedef uint64_t dispatch_time_t; + +enum { + DISPATCH_WALLTIME_NOW DISPATCH_ENUM_API_AVAILABLE + (macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = ~1ull, +}; + +#define DISPATCH_TIME_NOW (0ull) +#define DISPATCH_TIME_FOREVER (~0ull) + +/*! + * @function dispatch_time + * + * @abstract + * Create a dispatch_time_t relative to the current value of the default or + * wall time clock, or modify an existing dispatch_time_t. + * + * @discussion + * On Apple platforms, the default clock is based on mach_absolute_time(). + * + * @param when + * An optional dispatch_time_t to add nanoseconds to. If DISPATCH_TIME_NOW is + * passed, then dispatch_time() will use the default clock (which is based on + * mach_absolute_time() on Apple platforms). If DISPATCH_WALLTIME_NOW is used, + * dispatch_time() will use the value returned by gettimeofday(3). + * dispatch_time(DISPATCH_WALLTIME_NOW, delta) is equivalent to + * dispatch_walltime(NULL, delta). + * + * @param delta + * Nanoseconds to add. + * + * @result + * A new dispatch_time_t. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_time_t +dispatch_time(dispatch_time_t when, int64_t delta); + +/*! + * @function dispatch_walltime + * + * @abstract + * Create a dispatch_time_t using the wall clock. + * + * @discussion + * On Mac OS X the wall clock is based on gettimeofday(3). + * + * @param when + * A struct timespec to add time to. If NULL is passed, then + * dispatch_walltime() will use the result of gettimeofday(3). + * dispatch_walltime(NULL, delta) returns the same value as + * dispatch_time(DISPATCH_WALLTIME_NOW, delta). + * + * @param delta + * Nanoseconds to add. + * + * @result + * A new dispatch_time_t. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_time_t +dispatch_walltime(const struct timespec *_Nullable when, int64_t delta); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/workloop.h b/lib/libc/include/x86_64-macos-gnu/dispatch/workloop.h new file mode 100644 index 0000000000..58e494fd1c --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/workloop.h @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2017-2019 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __DISPATCH_WORKLOOP__ +#define __DISPATCH_WORKLOOP__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +__BEGIN_DECLS + +/*! + * @typedef dispatch_workloop_t + * + * @abstract + * Dispatch workloops invoke workitems submitted to them in priority order. + * + * @discussion + * A dispatch workloop is a flavor of dispatch_queue_t that is a priority + * ordered queue (using the QOS class of the submitted workitems as the + * ordering). + * + * Between each workitem invocation, the workloop will evaluate whether higher + * priority workitems have since been submitted, either directly to the + * workloop or to any queues that target the workloop, and execute these first. + * + * Serial queues targeting a workloop maintain FIFO execution of their + * workitems. However, the workloop may reorder workitems submitted to + * independent serial queues targeting it with respect to each other, + * based on their priorities, while preserving FIFO execution with respect to + * each serial queue. + * + * A dispatch workloop is a "subclass" of dispatch_queue_t which can be passed + * to all APIs accepting a dispatch queue, except for functions from the + * dispatch_sync() family. dispatch_async_and_wait() must be used for workloop + * objects. Functions from the dispatch_sync() family on queues targeting + * a workloop are still permitted but discouraged for performance reasons. + */ +DISPATCH_DECL_SUBCLASS(dispatch_workloop, dispatch_queue); + +/*! + * @function dispatch_workloop_create + * + * @abstract + * Creates a new dispatch workloop to which workitems may be submitted. + * + * @param label + * A string label to attach to the workloop. + * + * @result + * The newly created dispatch workloop. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_workloop_t +dispatch_workloop_create(const char *_Nullable label); + +/*! + * @function dispatch_workloop_create_inactive + * + * @abstract + * Creates a new inactive dispatch workloop that can be setup and then + * activated. + * + * @discussion + * Creating an inactive workloop allows for it to receive further configuration + * before it is activated, and workitems can be submitted to it. + * + * Submitting workitems to an inactive workloop is undefined and will cause the + * process to be terminated. + * + * @param label + * A string label to attach to the workloop. + * + * @result + * The newly created dispatch workloop. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_workloop_t +dispatch_workloop_create_inactive(const char *_Nullable label); + +/*! + * @function dispatch_workloop_set_autorelease_frequency + * + * @abstract + * Sets the autorelease frequency of the workloop. + * + * @discussion + * See dispatch_queue_attr_make_with_autorelease_frequency(). + * The default policy for a workloop is + * DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM. + * + * @param workloop + * The dispatch workloop to modify. + * + * This workloop must be inactive, passing an activated object is undefined + * and will cause the process to be terminated. + * + * @param frequency + * The requested autorelease frequency. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_workloop_set_autorelease_frequency(dispatch_workloop_t workloop, + dispatch_autorelease_frequency_t frequency); + +/*! + * @function dispatch_workloop_set_os_workgroup + * + * @abstract + * Associates an os_workgroup_t with the specified dispatch workloop. + * + * The worker thread will be a member of the specified os_workgroup_t while executing + * work items submitted to the workloop. + * + * @param workloop + * The dispatch workloop to modify. + * + * This workloop must be inactive, passing an activated object is undefined + * and will cause the process to be terminated. + * + * @param workgroup + * The workgroup to associate with this workloop. + * + * The workgroup specified is retained and the previously associated workgroup + * (if any) is released. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_workloop_set_os_workgroup(dispatch_workloop_t workloop, + os_workgroup_t workgroup); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/hfs/hfs_format.h b/lib/libc/include/x86_64-macos-gnu/hfs/hfs_format.h new file mode 100644 index 0000000000..89df0dc69b --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/hfs/hfs_format.h @@ -0,0 +1,818 @@ +/* + * Copyright (c) 2000-2015 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef __HFS_FORMAT__ +#define __HFS_FORMAT__ + +#include +#include +#include "hfs_unistr.h" + +/* + * hfs_format.h + * + * This file describes the on-disk format for HFS and HFS Plus volumes. + * + * Note: Starting 10.9, definition of struct HFSUniStr255 exists in hfs_unitstr.h + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* some on-disk hfs structures have 68K alignment (misaligned) */ + +/* Signatures used to differentiate between HFS and HFS Plus volumes */ +enum { + kHFSSigWord = 0x4244, /* 'BD' in ASCII */ + kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */ + kHFSXSigWord = 0x4858, /* 'HX' in ASCII */ + + kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */ + kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */ + + kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */ + kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */ + kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */ +}; + + +#ifdef __APPLE_API_PRIVATE +/* + * Mac OS X has two special directories on HFS+ volumes for hardlinked files + * and hardlinked directories as well as for open-unlinked files. + * + * These directories and their contents are not exported from the filesystem + * under Mac OS X. + */ +#define HFSPLUSMETADATAFOLDER "\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80HFS+ Private Data" +#define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd" + +/* + * Files in the "HFS+ Private Data" folder have one of the following prefixes + * followed by a decimal number (no leading zeros) for the file ID. + * + * Note: Earlier version of Mac OS X used a 32 bit random number for the link + * ref number instead of the file id. + * + * e.g. iNode7182000 and temp3296 + */ +#define HFS_INODE_PREFIX "iNode" +#define HFS_DELETE_PREFIX "temp" + +/* + * Files in the ".HFS+ Private Directory Data" folder have the following + * prefix followed by a decimal number (no leading zeros) for the file ID. + * + * e.g. dir_555 + */ +#define HFS_DIRINODE_PREFIX "dir_" + +/* + * Hardlink inodes save the head of the link chain in + * an extended attribute named FIRST_LINK_XATTR_NAME. + * The attribute data is the decimal value in ASCII + * of the cnid for the first link in the chain. + * + * This extended attribute is private (i.e. its not + * exported in the getxattr/listxattr POSIX APIs). + */ +#define FIRST_LINK_XATTR_NAME "com.apple.system.hfs.firstlink" +#define FIRST_LINK_XATTR_REC_SIZE (sizeof(HFSPlusAttrData) - 2 + 12) + +/* + * The name space ID for generating an HFS volume UUID + * + * B3E20F39-F292-11D6-97A4-00306543ECAC + */ +#define HFS_UUID_NAMESPACE_ID "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC" + +#endif /* __APPLE_API_PRIVATE */ + +/* + * Indirect link files (hard links) have the following type/creator. + */ +enum { + kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */ + kHFSPlusCreator = 0x6866732B /* 'hfs+' */ +}; + + +/* + * File type and creator for symbolic links + */ +enum { + kSymLinkFileType = 0x736C6E6B, /* 'slnk' */ + kSymLinkCreator = 0x72686170 /* 'rhap' */ +}; + + +enum { + kHFSMaxVolumeNameChars = 27, + kHFSMaxFileNameChars = 31, + kHFSPlusMaxFileNameChars = 255 +}; + + +/* Extent overflow file data structures */ + +/* HFS Extent key */ +struct HFSExtentKey { + u_int8_t keyLength; /* length of key, excluding this field */ + u_int8_t forkType; /* 0 = data fork, FF = resource fork */ + u_int32_t fileID; /* file ID */ + u_int16_t startBlock; /* first file allocation block number in this extent */ +} __attribute__((aligned(2), packed)); +typedef struct HFSExtentKey HFSExtentKey; + +/* HFS Plus Extent key */ +struct HFSPlusExtentKey { + u_int16_t keyLength; /* length of key, excluding this field */ + u_int8_t forkType; /* 0 = data fork, FF = resource fork */ + u_int8_t pad; /* make the other fields align on 32-bit boundary */ + u_int32_t fileID; /* file ID */ + u_int32_t startBlock; /* first file allocation block number in this extent */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusExtentKey HFSPlusExtentKey; + +/* Number of extent descriptors per extent record */ +enum { + kHFSExtentDensity = 3, + kHFSPlusExtentDensity = 8 +}; + +/* HFS extent descriptor */ +struct HFSExtentDescriptor { + u_int16_t startBlock; /* first allocation block */ + u_int16_t blockCount; /* number of allocation blocks */ +} __attribute__((aligned(2), packed)); +typedef struct HFSExtentDescriptor HFSExtentDescriptor; + +/* HFS Plus extent descriptor */ +struct HFSPlusExtentDescriptor { + u_int32_t startBlock; /* first allocation block */ + u_int32_t blockCount; /* number of allocation blocks */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor; + +/* HFS extent record */ +typedef HFSExtentDescriptor HFSExtentRecord[3]; + +/* HFS Plus extent record */ +typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8]; + + +/* Finder information */ +struct FndrFileInfo { + u_int32_t fdType; /* file type */ + u_int32_t fdCreator; /* file creator */ + u_int16_t fdFlags; /* Finder flags */ + struct { + int16_t v; /* file's location */ + int16_t h; + } fdLocation; + int16_t opaque; +} __attribute__((aligned(2), packed)); +typedef struct FndrFileInfo FndrFileInfo; + +struct FndrDirInfo { + struct { /* folder's window rectangle */ + int16_t top; + int16_t left; + int16_t bottom; + int16_t right; + } frRect; + unsigned short frFlags; /* Finder flags */ + struct { + u_int16_t v; /* folder's location */ + u_int16_t h; + } frLocation; + int16_t opaque; +} __attribute__((aligned(2), packed)); +typedef struct FndrDirInfo FndrDirInfo; + +struct FndrOpaqueInfo { + int8_t opaque[16]; +} __attribute__((aligned(2), packed)); +typedef struct FndrOpaqueInfo FndrOpaqueInfo; + +struct FndrExtendedDirInfo { + u_int32_t document_id; + u_int32_t date_added; + u_int16_t extended_flags; + u_int16_t reserved3; + u_int32_t write_gen_counter; +} __attribute__((aligned(2), packed)); + +struct FndrExtendedFileInfo { + u_int32_t document_id; + u_int32_t date_added; + u_int16_t extended_flags; + u_int16_t reserved2; + u_int32_t write_gen_counter; +} __attribute__((aligned(2), packed)); + +/* HFS Plus Fork data info - 80 bytes */ +struct HFSPlusForkData { + u_int64_t logicalSize; /* fork's logical size in bytes */ + u_int32_t clumpSize; /* fork's clump size in bytes */ + u_int32_t totalBlocks; /* total blocks used by this fork */ + HFSPlusExtentRecord extents; /* initial set of extents */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusForkData HFSPlusForkData; + + +/* Mac OS X has 16 bytes worth of "BSD" info. + * + * Note: Mac OS 9 implementations and applications + * should preserve, but not change, this information. + */ +struct HFSPlusBSDInfo { + u_int32_t ownerID; /* user-id of owner or hard link chain previous link */ + u_int32_t groupID; /* group-id of owner or hard link chain next link */ + u_int8_t adminFlags; /* super-user changeable flags */ + u_int8_t ownerFlags; /* owner changeable flags */ + u_int16_t fileMode; /* file type and permission bits */ + union { + u_int32_t iNodeNum; /* indirect node number (hard links only) */ + u_int32_t linkCount; /* links that refer to this indirect node */ + u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */ + } special; +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusBSDInfo HFSPlusBSDInfo; + +/* + * Hardlink "links" resolve to an inode + * and the actual uid/gid comes from that + * inode. + * + * We repurpose the links's uid/gid fields + * for the hardlink link chain. The chain + * consists of a doubly linked list of file + * ids. + */ + +#define hl_firstLinkID reserved1 /* Valid only if HasLinkChain flag is set (indirect nodes only) */ + +#define hl_prevLinkID bsdInfo.ownerID /* Valid only if HasLinkChain flag is set */ +#define hl_nextLinkID bsdInfo.groupID /* Valid only if HasLinkChain flag is set */ + +#define hl_linkReference bsdInfo.special.iNodeNum +#define hl_linkCount bsdInfo.special.linkCount + + +/* Catalog file data structures */ + +enum { + kHFSRootParentID = 1, /* Parent ID of the root folder */ + kHFSRootFolderID = 2, /* Folder ID of the root folder */ + kHFSExtentsFileID = 3, /* File ID of the extents file */ + kHFSCatalogFileID = 4, /* File ID of the catalog file */ + kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */ + kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */ + kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */ + kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */ + kHFSAttributeDataFileID = 13, /* Used in Mac OS X runtime for extent based attributes */ + /* kHFSAttributeDataFileID is never stored on disk. */ + kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */ + kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */ + kHFSFirstUserCatalogNodeID = 16 +}; + +/* HFS catalog key */ +struct HFSCatalogKey { + u_int8_t keyLength; /* key length (in bytes) */ + u_int8_t reserved; /* reserved (set to zero) */ + u_int32_t parentID; /* parent folder ID */ + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */ +} __attribute__((aligned(2), packed)); +typedef struct HFSCatalogKey HFSCatalogKey; + +/* HFS Plus catalog key */ +struct HFSPlusCatalogKey { + u_int16_t keyLength; /* key length (in bytes) */ + u_int32_t parentID; /* parent folder ID */ + HFSUniStr255 nodeName; /* catalog node name */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusCatalogKey HFSPlusCatalogKey; + +/* Catalog record types */ +enum { + /* HFS Catalog Records */ + kHFSFolderRecord = 0x0100, /* Folder record */ + kHFSFileRecord = 0x0200, /* File record */ + kHFSFolderThreadRecord = 0x0300, /* Folder thread record */ + kHFSFileThreadRecord = 0x0400, /* File thread record */ + + /* HFS Plus Catalog Records */ + kHFSPlusFolderRecord = 1, /* Folder record */ + kHFSPlusFileRecord = 2, /* File record */ + kHFSPlusFolderThreadRecord = 3, /* Folder thread record */ + kHFSPlusFileThreadRecord = 4 /* File thread record */ +}; + + +/* Catalog file record flags */ +enum { + kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */ + kHFSFileLockedMask = 0x0001, + + kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */ + kHFSThreadExistsMask = 0x0002, + + kHFSHasAttributesBit = 0x0002, /* object has extended attributes */ + kHFSHasAttributesMask = 0x0004, + + kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */ + kHFSHasSecurityMask = 0x0008, + + kHFSHasFolderCountBit = 0x0004, /* only for HFSX, folder maintains a separate sub-folder count */ + kHFSHasFolderCountMask = 0x0010, /* (sum of folder records and directory hard links) */ + + kHFSHasLinkChainBit = 0x0005, /* has hardlink chain (inode or link) */ + kHFSHasLinkChainMask = 0x0020, + + kHFSHasChildLinkBit = 0x0006, /* folder has a child that's a dir link */ + kHFSHasChildLinkMask = 0x0040, + + kHFSHasDateAddedBit = 0x0007, /* File/Folder has the date-added stored in the finder info. */ + kHFSHasDateAddedMask = 0x0080, + + kHFSFastDevPinnedBit = 0x0008, /* this file has been pinned to the fast-device by the hot-file code on cooperative fusion */ + kHFSFastDevPinnedMask = 0x0100, + + kHFSDoNotFastDevPinBit = 0x0009, /* this file can not be pinned to the fast-device */ + kHFSDoNotFastDevPinMask = 0x0200, + + kHFSFastDevCandidateBit = 0x000a, /* this item is a potential candidate for fast-dev pinning (as are any of its descendents */ + kHFSFastDevCandidateMask = 0x0400, + + kHFSAutoCandidateBit = 0x000b, /* this item was automatically marked as a fast-dev candidate by the kernel */ + kHFSAutoCandidateMask = 0x0800 + + // There are only 4 flag bits remaining: 0x1000, 0x2000, 0x4000, 0x8000 + +}; + + +/* HFS catalog folder record - 70 bytes */ +struct HFSCatalogFolder { + int16_t recordType; /* == kHFSFolderRecord */ + u_int16_t flags; /* folder flags */ + u_int16_t valence; /* folder valence */ + u_int32_t folderID; /* folder ID */ + u_int32_t createDate; /* date and time of creation */ + u_int32_t modifyDate; /* date and time of last modification */ + u_int32_t backupDate; /* date and time of last backup */ + FndrDirInfo userInfo; /* Finder information */ + FndrOpaqueInfo finderInfo; /* additional Finder information */ + u_int32_t reserved[4]; /* reserved - initialized as zero */ +} __attribute__((aligned(2), packed)); +typedef struct HFSCatalogFolder HFSCatalogFolder; + +/* HFS Plus catalog folder record - 88 bytes */ +struct HFSPlusCatalogFolder { + int16_t recordType; /* == kHFSPlusFolderRecord */ + u_int16_t flags; /* file flags */ + u_int32_t valence; /* folder's item count */ + u_int32_t folderID; /* folder ID */ + u_int32_t createDate; /* date and time of creation */ + u_int32_t contentModDate; /* date and time of last content modification */ + u_int32_t attributeModDate; /* date and time of last attribute modification */ + u_int32_t accessDate; /* date and time of last access (MacOS X only) */ + u_int32_t backupDate; /* date and time of last backup */ + HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */ + FndrDirInfo userInfo; /* Finder information */ + FndrOpaqueInfo finderInfo; /* additional Finder information */ + u_int32_t textEncoding; /* hint for name conversions */ + u_int32_t folderCount; /* number of enclosed folders, active when HasFolderCount is set */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder; + +/* HFS catalog file record - 102 bytes */ +struct HFSCatalogFile { + int16_t recordType; /* == kHFSFileRecord */ + u_int8_t flags; /* file flags */ + int8_t fileType; /* file type (unused ?) */ + FndrFileInfo userInfo; /* Finder information */ + u_int32_t fileID; /* file ID */ + u_int16_t dataStartBlock; /* not used - set to zero */ + int32_t dataLogicalSize; /* logical EOF of data fork */ + int32_t dataPhysicalSize; /* physical EOF of data fork */ + u_int16_t rsrcStartBlock; /* not used - set to zero */ + int32_t rsrcLogicalSize; /* logical EOF of resource fork */ + int32_t rsrcPhysicalSize; /* physical EOF of resource fork */ + u_int32_t createDate; /* date and time of creation */ + u_int32_t modifyDate; /* date and time of last modification */ + u_int32_t backupDate; /* date and time of last backup */ + FndrOpaqueInfo finderInfo; /* additional Finder information */ + u_int16_t clumpSize; /* file clump size (not used) */ + HFSExtentRecord dataExtents; /* first data fork extent record */ + HFSExtentRecord rsrcExtents; /* first resource fork extent record */ + u_int32_t reserved; /* reserved - initialized as zero */ +} __attribute__((aligned(2), packed)); +typedef struct HFSCatalogFile HFSCatalogFile; + +/* HFS Plus catalog file record - 248 bytes */ +struct HFSPlusCatalogFile { + int16_t recordType; /* == kHFSPlusFileRecord */ + u_int16_t flags; /* file flags */ + u_int32_t reserved1; /* reserved - initialized as zero */ + u_int32_t fileID; /* file ID */ + u_int32_t createDate; /* date and time of creation */ + u_int32_t contentModDate; /* date and time of last content modification */ + u_int32_t attributeModDate; /* date and time of last attribute modification */ + u_int32_t accessDate; /* date and time of last access (MacOS X only) */ + u_int32_t backupDate; /* date and time of last backup */ + HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */ + FndrFileInfo userInfo; /* Finder information */ + FndrOpaqueInfo finderInfo; /* additional Finder information */ + u_int32_t textEncoding; /* hint for name conversions */ + u_int32_t reserved2; /* reserved - initialized as zero */ + + /* Note: these start on double long (64 bit) boundary */ + HFSPlusForkData dataFork; /* size and block data for data fork */ + HFSPlusForkData resourceFork; /* size and block data for resource fork */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusCatalogFile HFSPlusCatalogFile; + +/* HFS catalog thread record - 46 bytes */ +struct HFSCatalogThread { + int16_t recordType; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */ + int32_t reserved[2]; /* reserved - initialized as zero */ + u_int32_t parentID; /* parent ID for this catalog node */ + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */ +} __attribute__((aligned(2), packed)); +typedef struct HFSCatalogThread HFSCatalogThread; + +/* HFS Plus catalog thread record -- 264 bytes */ +struct HFSPlusCatalogThread { + int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */ + int16_t reserved; /* reserved - initialized as zero */ + u_int32_t parentID; /* parent ID for this catalog node */ + HFSUniStr255 nodeName; /* name of this catalog node (variable length) */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusCatalogThread HFSPlusCatalogThread; + +#ifdef __APPLE_API_UNSTABLE +/* + * These are the types of records in the attribute B-tree. The values were + * chosen so that they wouldn't conflict with the catalog record types. + */ +enum { + kHFSPlusAttrInlineData = 0x10, /* attributes whose data fits in a b-tree node */ + kHFSPlusAttrForkData = 0x20, /* extent based attributes (data lives in extents) */ + kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */ +}; + + +/* + * HFSPlusAttrForkData + * For larger attributes, whose value is stored in allocation blocks. + * If the attribute has more than 8 extents, there will be additional + * records (of type HFSPlusAttrExtents) for this attribute. + */ +struct HFSPlusAttrForkData { + u_int32_t recordType; /* == kHFSPlusAttrForkData*/ + u_int32_t reserved; + HFSPlusForkData theFork; /* size and first extents of value*/ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrForkData HFSPlusAttrForkData; + +/* + * HFSPlusAttrExtents + * This record contains information about overflow extents for large, + * fragmented attributes. + */ +struct HFSPlusAttrExtents { + u_int32_t recordType; /* == kHFSPlusAttrExtents*/ + u_int32_t reserved; + HFSPlusExtentRecord extents; /* additional extents*/ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrExtents HFSPlusAttrExtents; + +/* + * Atrributes B-tree Data Record + * + * For small attributes, whose entire value is stored + * within a single B-tree record. + */ +struct HFSPlusAttrData { + u_int32_t recordType; /* == kHFSPlusAttrInlineData */ + u_int32_t reserved[2]; + u_int32_t attrSize; /* size of attribute data in bytes */ + u_int8_t attrData[2]; /* variable length */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrData HFSPlusAttrData; + + +/* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */ +struct HFSPlusAttrInlineData { + u_int32_t recordType; + u_int32_t reserved; + u_int32_t logicalSize; + u_int8_t userData[2]; +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData; + + +/* A generic Attribute Record */ +union HFSPlusAttrRecord { + u_int32_t recordType; + HFSPlusAttrInlineData inlineData; /* NOT USED */ + HFSPlusAttrData attrData; + HFSPlusAttrForkData forkData; + HFSPlusAttrExtents overflowExtents; +}; +typedef union HFSPlusAttrRecord HFSPlusAttrRecord; + +/* Attribute key */ +enum { kHFSMaxAttrNameLen = 127 }; +struct HFSPlusAttrKey { + u_int16_t keyLength; /* key length (in bytes) */ + u_int16_t pad; /* set to zero */ + u_int32_t fileID; /* file associated with attribute */ + u_int32_t startBlock; /* first allocation block number for extents */ + u_int16_t attrNameLen; /* number of unicode characters */ + u_int16_t attrName[kHFSMaxAttrNameLen]; /* attribute name (Unicode) */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusAttrKey HFSPlusAttrKey; + +#define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t)) +#define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - kHFSMaxAttrNameLen*sizeof(u_int16_t)) + +#endif /* __APPLE_API_UNSTABLE */ + + +/* Key and node lengths */ +enum { + kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t), + kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t), + kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t), + kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t), + kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(u_int8_t), + kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t), + kHFSPlusCatalogMinNodeSize = 4096, + kHFSPlusExtentMinNodeSize = 512, + kHFSPlusAttrMinNodeSize = 4096 +}; + +/* HFS and HFS Plus volume attribute bits */ +enum { + /* Bits 0-6 are reserved (always cleared by MountVol call) */ + kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */ + kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */ + kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */ + kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */ + kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */ + kHFSCatalogNodeIDsReusedBit = 12, + kHFSVolumeJournaledBit = 13, /* this volume has a journal on it */ + kHFSVolumeInconsistentBit = 14, /* serious inconsistencies detected at runtime */ + kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */ + /* + * HFS only has 16 bits of attributes in the MDB, but HFS Plus has 32 bits. + * Therefore, bits 16-31 can only be used on HFS Plus. + */ + kHFSUnusedNodeFixBit = 31, /* Unused nodes in the Catalog B-tree have been zero-filled. See Radar #6947811. */ + kHFSContentProtectionBit = 30, /* Volume has per-file content protection */ + + /*** Keep these in sync with the bits above ! ****/ + kHFSVolumeHardwareLockMask = 0x00000080, + kHFSVolumeUnmountedMask = 0x00000100, + kHFSVolumeSparedBlocksMask = 0x00000200, + kHFSVolumeNoCacheRequiredMask = 0x00000400, + kHFSBootVolumeInconsistentMask = 0x00000800, + kHFSCatalogNodeIDsReusedMask = 0x00001000, + kHFSVolumeJournaledMask = 0x00002000, + kHFSVolumeInconsistentMask = 0x00004000, + kHFSVolumeSoftwareLockMask = 0x00008000, + + /* Bits 16-31 are allocated from high to low */ + + kHFSContentProtectionMask = 0x40000000, + kHFSUnusedNodeFixMask = 0x80000000, + + kHFSMDBAttributesMask = 0x8380 +}; + +enum { + kHFSUnusedNodesFixDate = 0xc5ef2480 /* March 25, 2009 */ +}; + +/* HFS Master Directory Block - 162 bytes */ +/* Stored at sector #2 (3rd sector) and second-to-last sector. */ +struct HFSMasterDirectoryBlock { + u_int16_t drSigWord; /* == kHFSSigWord */ + u_int32_t drCrDate; /* date and time of volume creation */ + u_int32_t drLsMod; /* date and time of last modification */ + u_int16_t drAtrb; /* volume attributes */ + u_int16_t drNmFls; /* number of files in root folder */ + u_int16_t drVBMSt; /* first block of volume bitmap */ + u_int16_t drAllocPtr; /* start of next allocation search */ + u_int16_t drNmAlBlks; /* number of allocation blocks in volume */ + u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */ + u_int32_t drClpSiz; /* default clump size */ + u_int16_t drAlBlSt; /* first allocation block in volume */ + u_int32_t drNxtCNID; /* next unused catalog node ID */ + u_int16_t drFreeBks; /* number of unused allocation blocks */ + u_int8_t drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */ + u_int32_t drVolBkUp; /* date and time of last backup */ + u_int16_t drVSeqNum; /* volume backup sequence number */ + u_int32_t drWrCnt; /* volume write count */ + u_int32_t drXTClpSiz; /* clump size for extents overflow file */ + u_int32_t drCTClpSiz; /* clump size for catalog file */ + u_int16_t drNmRtDirs; /* number of directories in root folder */ + u_int32_t drFilCnt; /* number of files in volume */ + u_int32_t drDirCnt; /* number of directories in volume */ + u_int32_t drFndrInfo[8]; /* information used by the Finder */ + u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */ + HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */ + u_int32_t drXTFlSize; /* size of extents overflow file */ + HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */ + u_int32_t drCTFlSize; /* size of catalog file */ + HFSExtentRecord drCTExtRec; /* extent record for catalog file */ +} __attribute__((aligned(2), packed)); +typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock; + + +#ifdef __APPLE_API_UNSTABLE +#define SET_HFS_TEXT_ENCODING(hint) \ + (0x656e6300 | ((hint) & 0xff)) +#define GET_HFS_TEXT_ENCODING(hint) \ + (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU) +#endif /* __APPLE_API_UNSTABLE */ + + +/* HFS Plus Volume Header - 512 bytes */ +/* Stored at sector #2 (3rd sector) and second-to-last sector. */ +struct HFSPlusVolumeHeader { + u_int16_t signature; /* == kHFSPlusSigWord */ + u_int16_t version; /* == kHFSPlusVersion */ + u_int32_t attributes; /* volume attributes */ + u_int32_t lastMountedVersion; /* implementation version which last mounted volume */ + u_int32_t journalInfoBlock; /* block addr of journal info (if volume is journaled, zero otherwise) */ + + u_int32_t createDate; /* date and time of volume creation */ + u_int32_t modifyDate; /* date and time of last modification */ + u_int32_t backupDate; /* date and time of last backup */ + u_int32_t checkedDate; /* date and time of last disk check */ + + u_int32_t fileCount; /* number of files in volume */ + u_int32_t folderCount; /* number of directories in volume */ + + u_int32_t blockSize; /* size (in bytes) of allocation blocks */ + u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/ + u_int32_t freeBlocks; /* number of unused allocation blocks */ + + u_int32_t nextAllocation; /* start of next allocation search */ + u_int32_t rsrcClumpSize; /* default resource fork clump size */ + u_int32_t dataClumpSize; /* default data fork clump size */ + u_int32_t nextCatalogID; /* next unused catalog node ID */ + + u_int32_t writeCount; /* volume write count */ + u_int64_t encodingsBitmap; /* which encodings have been use on this volume */ + + u_int8_t finderInfo[32]; /* information used by the Finder */ + + HFSPlusForkData allocationFile; /* allocation bitmap file */ + HFSPlusForkData extentsFile; /* extents B-tree file */ + HFSPlusForkData catalogFile; /* catalog B-tree file */ + HFSPlusForkData attributesFile; /* extended attributes B-tree file */ + HFSPlusForkData startupFile; /* boot file (secondary loader) */ +} __attribute__((aligned(2), packed)); +typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader; + + +/* B-tree structures */ + +enum BTreeKeyLimits{ + kMaxKeyLength = 520 +}; + +union BTreeKey{ + u_int8_t length8; + u_int16_t length16; + u_int8_t rawData [kMaxKeyLength+2]; +}; +typedef union BTreeKey BTreeKey; + +/* BTNodeDescriptor -- Every B-tree node starts with these fields. */ +struct BTNodeDescriptor { + u_int32_t fLink; /* next node at this level*/ + u_int32_t bLink; /* previous node at this level*/ + int8_t kind; /* kind of node (leaf, index, header, map)*/ + u_int8_t height; /* zero for header, map; child is one more than parent*/ + u_int16_t numRecords; /* number of records in this node*/ + u_int16_t reserved; /* reserved - initialized as zero */ +} __attribute__((aligned(2), packed)); +typedef struct BTNodeDescriptor BTNodeDescriptor; + +/* Constants for BTNodeDescriptor kind */ +enum { + kBTLeafNode = -1, + kBTIndexNode = 0, + kBTHeaderNode = 1, + kBTMapNode = 2 +}; + +/* BTHeaderRec -- The first record of a B-tree header node */ +struct BTHeaderRec { + u_int16_t treeDepth; /* maximum height (usually leaf nodes) */ + u_int32_t rootNode; /* node number of root node */ + u_int32_t leafRecords; /* number of leaf records in all leaf nodes */ + u_int32_t firstLeafNode; /* node number of first leaf node */ + u_int32_t lastLeafNode; /* node number of last leaf node */ + u_int16_t nodeSize; /* size of a node, in bytes */ + u_int16_t maxKeyLength; /* reserved */ + u_int32_t totalNodes; /* total number of nodes in tree */ + u_int32_t freeNodes; /* number of unused (free) nodes in tree */ + u_int16_t reserved1; /* unused */ + u_int32_t clumpSize; /* reserved */ + u_int8_t btreeType; /* reserved */ + u_int8_t keyCompareType; /* Key string Comparison Type */ + u_int32_t attributes; /* persistent attributes about the tree */ + u_int32_t reserved3[16]; /* reserved */ +} __attribute__((aligned(2), packed)); +typedef struct BTHeaderRec BTHeaderRec; + +/* Constants for BTHeaderRec attributes */ +enum { + kBTBadCloseMask = 0x00000001, /* reserved */ + kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */ + kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */ +}; + + +/* Catalog Key Name Comparison Type */ +enum { + kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */ + kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */ +}; + +#include + +/* JournalInfoBlock - Structure that describes where our journal lives */ + +// the original size of the reserved field in the JournalInfoBlock was +// 32*sizeof(u_int32_t). To keep the total size of the structure the +// same we subtract the size of new fields (currently: ext_jnl_uuid and +// machine_uuid). If you add additional fields, place them before the +// reserved field and subtract their size in this macro. +// +#define JIB_RESERVED_SIZE ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48) + +struct JournalInfoBlock { + u_int32_t flags; + u_int32_t device_signature[8]; // signature used to locate our device. + u_int64_t offset; // byte offset to the journal on the device + u_int64_t size; // size in bytes of the journal + uuid_string_t ext_jnl_uuid; + char machine_serial_num[48]; + char reserved[JIB_RESERVED_SIZE]; +} __attribute__((aligned(2), packed)); +typedef struct JournalInfoBlock JournalInfoBlock; + +enum { + kJIJournalInFSMask = 0x00000001, + kJIJournalOnOtherDeviceMask = 0x00000002, + kJIJournalNeedInitMask = 0x00000004 +}; + +// +// This the content type uuid for "external journal" GPT +// partitions. Each instance of a partition also has a +// uuid that uniquely identifies that instance. +// +#define EXTJNL_CONTENT_TYPE_UUID "4A6F7572-6E61-11AA-AA11-00306543ECAC" + + +#ifdef __cplusplus +} +#endif + +#endif /* __HFS_FORMAT__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/hfs/hfs_unistr.h b/lib/libc/include/x86_64-macos-gnu/hfs/hfs_unistr.h new file mode 100644 index 0000000000..5b300a28d1 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/hfs/hfs_unistr.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2013 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef __HFS_UNISTR__ +#define __HFS_UNISTR__ + +#include + +/* + * hfs_unitstr.h + * + * This file contains definition of the unicode string used for HFS Plus + * files and folder names, as described by the on-disk format. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef _HFSUNISTR255_DEFINED_ +#define _HFSUNISTR255_DEFINED_ +/* Unicode strings are used for HFS Plus file and folder names */ +struct HFSUniStr255 { + u_int16_t length; /* number of unicode characters */ + u_int16_t unicode[255]; /* unicode characters */ +} __attribute__((aligned(2), packed)); +typedef struct HFSUniStr255 HFSUniStr255; +typedef const HFSUniStr255 *ConstHFSUniStr255Param; +#endif /* _HFSUNISTR255_DEFINED_ */ + + +#ifdef __cplusplus +} +#endif + + +#endif /* __HFS_UNISTR__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/i386/_param.h b/lib/libc/include/x86_64-macos-gnu/i386/_param.h index 3a0ac8bba7..1ab450d5d4 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/_param.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/_param.h @@ -37,10 +37,10 @@ * cast to any desired pointer type. */ #define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1) -#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES) +#define __DARWIN_ALIGN(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES) #define __DARWIN_ALIGNBYTES32 (sizeof(__uint32_t) - 1) -#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32) +#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32) #endif /* _I386__PARAM_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/launch.h b/lib/libc/include/x86_64-macos-gnu/launch.h new file mode 100644 index 0000000000..905b9ef931 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/launch.h @@ -0,0 +1,409 @@ +#ifndef __XPC_LAUNCH_H__ +#define __XPC_LAUNCH_H__ + +/*! + * @header + * These interfaces were only ever documented for the purpose of allowing a + * launchd job to obtain file descriptors associated with the sockets it + * advertised in its launchd.plist(5). That functionality is now available in a + * much more straightforward fashion through the {@link launch_activate_socket} + * API. + * + * There are currently no replacements for other uses of the {@link launch_msg} + * API, including submitting, removing, starting, stopping and listing jobs. + */ + +#include +#include + +#include +#include +#include +#include + +#if __has_feature(assume_nonnull) +_Pragma("clang assume_nonnull begin") +#endif +__BEGIN_DECLS + +#define LAUNCH_KEY_SUBMITJOB "SubmitJob" +#define LAUNCH_KEY_REMOVEJOB "RemoveJob" +#define LAUNCH_KEY_STARTJOB "StartJob" +#define LAUNCH_KEY_STOPJOB "StopJob" +#define LAUNCH_KEY_GETJOB "GetJob" +#define LAUNCH_KEY_GETJOBS "GetJobs" +#define LAUNCH_KEY_CHECKIN "CheckIn" + +#define LAUNCH_JOBKEY_LABEL "Label" +#define LAUNCH_JOBKEY_DISABLED "Disabled" +#define LAUNCH_JOBKEY_USERNAME "UserName" +#define LAUNCH_JOBKEY_GROUPNAME "GroupName" +#define LAUNCH_JOBKEY_TIMEOUT "TimeOut" +#define LAUNCH_JOBKEY_EXITTIMEOUT "ExitTimeOut" +#define LAUNCH_JOBKEY_INITGROUPS "InitGroups" +#define LAUNCH_JOBKEY_SOCKETS "Sockets" +#define LAUNCH_JOBKEY_MACHSERVICES "MachServices" +#define LAUNCH_JOBKEY_MACHSERVICELOOKUPPOLICIES "MachServiceLookupPolicies" +#define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility" +#define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing" +#define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments" +#define LAUNCH_JOBKEY_PROGRAM "Program" +#define LAUNCH_JOBKEY_ONDEMAND "OnDemand" +#define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive" +#define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts" +#define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts" +#define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType" +#define LAUNCH_JOBKEY_LIMITLOADTOHARDWARE "LimitLoadToHardware" +#define LAUNCH_JOBKEY_LIMITLOADFROMHARDWARE "LimitLoadFromHardware" +#define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad" +#define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory" +#define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory" +#define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables" +#define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables" +#define LAUNCH_JOBKEY_UMASK "Umask" +#define LAUNCH_JOBKEY_NICE "Nice" +#define LAUNCH_JOBKEY_HOPEFULLYEXITSFIRST "HopefullyExitsFirst" +#define LAUNCH_JOBKEY_HOPEFULLYEXITSLAST "HopefullyExitsLast" +#define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO" +#define LAUNCH_JOBKEY_LOWPRIORITYBACKGROUNDIO "LowPriorityBackgroundIO" +#define LAUNCH_JOBKEY_MATERIALIZEDATALESSFILES "MaterializeDatalessFiles" +#define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate" +#define LAUNCH_JOBKEY_STARTONMOUNT "StartOnMount" +#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits" +#define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits" +#define LAUNCH_JOBKEY_STANDARDINPATH "StandardInPath" +#define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath" +#define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath" +#define LAUNCH_JOBKEY_DEBUG "Debug" +#define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger" +#define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories" +#define LAUNCH_JOBKEY_HOMERELATIVEQUEUEDIRECTORIES "HomeRelativeQueueDirectories" +#define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths" +#define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval" +#define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval" +#define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs" +#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus" +#define LAUNCH_JOBKEY_PID "PID" +#define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" +#define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" +#define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup" +#define LAUNCH_JOBKEY_IGNOREPROCESSGROUPATSHUTDOWN \ + "IgnoreProcessGroupAtShutdown" +#define LAUNCH_JOBKEY_LEGACYTIMERS "LegacyTimers" +#define LAUNCH_JOBKEY_ENABLEPRESSUREDEXIT "EnablePressuredExit" +#define LAUNCH_JOBKEY_ENABLETRANSACTIONS "EnableTransactions" +#define LAUNCH_JOBKEY_DRAINMESSAGESONFAILEDINIT "DrainMessagesOnFailedInit" +#define LAUNCH_JOBKEY_POLICIES "Policies" + +#define LAUNCH_JOBKEY_PUBLISHESEVENTS "PublishesEvents" +#define LAUNCH_KEY_PUBLISHESEVENTS_DOMAININTERNAL "DomainInternal" + +#define LAUNCH_JOBPOLICY_DENYCREATINGOTHERJOBS "DenyCreatingOtherJobs" + +#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" +#define LAUNCH_JOBINETDCOMPATIBILITY_INSTANCES "Instances" + +#define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose" +#define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn" + +#define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit" +#define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState" +#define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState" +#define LAUNCH_JOBKEY_KEEPALIVE_HOMERELATIVEPATHSTATE "HomeRelativePathState" +#define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBACTIVE "OtherJobActive" +#define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBENABLED "OtherJobEnabled" +#define LAUNCH_JOBKEY_KEEPALIVE_AFTERINITIALDEMAND "AfterInitialDemand" +#define LAUNCH_JOBKEY_KEEPALIVE_CRASHED "Crashed" + +#define LAUNCH_JOBKEY_LAUNCHEVENTS "LaunchEvents" + +#define LAUNCH_JOBKEY_CAL_MINUTE "Minute" +#define LAUNCH_JOBKEY_CAL_HOUR "Hour" +#define LAUNCH_JOBKEY_CAL_DAY "Day" +#define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday" +#define LAUNCH_JOBKEY_CAL_MONTH "Month" + +#define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core" +#define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU" +#define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data" +#define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize" +#define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock" +#define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles" +#define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses" +#define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize" +#define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack" + +#define LAUNCH_JOBKEY_DISABLED_MACHINETYPE "MachineType" +#define LAUNCH_JOBKEY_DISABLED_MODELNAME "ModelName" + +#define LAUNCH_JOBKEY_DATASTORES "Datastores" +#define LAUNCH_JOBKEY_DATASTORES_SIZELIMIT "SizeLimit" + +#define LAUNCH_JOBSOCKETKEY_TYPE "SockType" +#define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive" +#define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour" +#define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey" +#define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName" +#define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode" +#define LAUNCH_JOBSOCKETKEY_PATHOWNER "SockPathOwner" +#define LAUNCH_JOBSOCKETKEY_PATHGROUP "SockPathGroup" +#define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName" +#define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName" +#define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily" +#define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol" +#define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup" + +#define LAUNCH_JOBKEY_PROCESSTYPE "ProcessType" +#define LAUNCH_KEY_PROCESSTYPE_APP "App" +#define LAUNCH_KEY_PROCESSTYPE_STANDARD "Standard" +#define LAUNCH_KEY_PROCESSTYPE_BACKGROUND "Background" +#define LAUNCH_KEY_PROCESSTYPE_INTERACTIVE "Interactive" +#define LAUNCH_KEY_PROCESSTYPE_ADAPTIVE "Adaptive" + +/*! + * @function launch_activate_socket + * + * @abstract + * Retrieves the file descriptors for sockets specified in the process' + * launchd.plist(5). + * + * @param name + * The name of the socket entry in the service's Sockets dictionary. + * + * @param fds + * On return, this parameter will be populated with an array of file + * descriptors. One socket can have many descriptors associated with it + * depending on the characteristics of the network interfaces on the system. + * The descriptors in this array are the results of calling getaddrinfo(3) with + * the parameters described in launchd.plist(5). + * + * The caller is responsible for calling free(3) on the returned pointer. + * + * @param cnt + * The number of file descriptor entries in the returned array. + * + * @result + * On success, zero is returned. Otherwise, an appropriate POSIX-domain is + * returned. Possible error codes are: + * + * ENOENT -> There was no socket of the specified name owned by the caller. + * ESRCH -> The caller is not a process managed by launchd. + * EALREADY -> The socket has already been activated by the caller. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3 +int +launch_activate_socket(const char *name, + int * _Nonnull * _Nullable fds, size_t *cnt); + +typedef struct _launch_data *launch_data_t; +typedef void (*launch_data_dict_iterator_t)(const launch_data_t lval, + const char *key, void * _Nullable ctx); + +typedef enum { + LAUNCH_DATA_DICTIONARY = 1, + LAUNCH_DATA_ARRAY, + LAUNCH_DATA_FD, + LAUNCH_DATA_INTEGER, + LAUNCH_DATA_REAL, + LAUNCH_DATA_BOOL, + LAUNCH_DATA_STRING, + LAUNCH_DATA_OPAQUE, + LAUNCH_DATA_ERRNO, + LAUNCH_DATA_MACHPORT, +} launch_data_type_t; + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT +launch_data_t +launch_data_alloc(launch_data_type_t type); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT OS_NONNULL1 +launch_data_t +launch_data_copy(launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +launch_data_type_t +launch_data_get_type(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 +void +launch_data_free(launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3 +bool +launch_data_dict_insert(launch_data_t ldict, const launch_data_t lval, + const char *key); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2 +launch_data_t _Nullable +launch_data_dict_lookup(const launch_data_t ldict, const char *key); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 OS_NONNULL2 +bool +launch_data_dict_remove(launch_data_t ldict, const char *key); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 OS_NONNULL2 +void +launch_data_dict_iterate(const launch_data_t ldict, + launch_data_dict_iterator_t iterator, void * _Nullable ctx); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +size_t +launch_data_dict_get_count(const launch_data_t ldict); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 OS_NONNULL2 +bool +launch_data_array_set_index(launch_data_t larray, const launch_data_t lval, + size_t idx); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +launch_data_t +launch_data_array_get_index(const launch_data_t larray, size_t idx); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +size_t +launch_data_array_get_count(const launch_data_t larray); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT +launch_data_t +launch_data_new_fd(int fd); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT +launch_data_t +launch_data_new_machport(mach_port_t val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT +launch_data_t +launch_data_new_integer(long long val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT +launch_data_t +launch_data_new_bool(bool val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT +launch_data_t +launch_data_new_real(double val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT +launch_data_t +launch_data_new_string(const char *val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT +launch_data_t +launch_data_new_opaque(const void *bytes, size_t sz); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 +bool +launch_data_set_fd(launch_data_t ld, int fd); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 +bool +launch_data_set_machport(launch_data_t ld, mach_port_t mp); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 +bool +launch_data_set_integer(launch_data_t ld, long long val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 +bool +launch_data_set_bool(launch_data_t ld, bool val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 +bool +launch_data_set_real(launch_data_t ld, double val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 +bool +launch_data_set_string(launch_data_t ld, const char *val); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_NONNULL1 +bool +launch_data_set_opaque(launch_data_t ld, const void *bytes, size_t sz); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +int +launch_data_get_fd(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +mach_port_t +launch_data_get_machport(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +long long +launch_data_get_integer(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +bool +launch_data_get_bool(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +double +launch_data_get_real(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +const char * +launch_data_get_string(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +void * +launch_data_get_opaque(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +size_t +launch_data_get_opaque_size(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT OS_NONNULL1 +int +launch_data_get_errno(const launch_data_t ld); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_WARN_RESULT +int +launch_get_fd(void); + +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0) +OS_EXPORT OS_MALLOC OS_WARN_RESULT OS_NONNULL1 +launch_data_t +launch_msg(const launch_data_t request); + +__END_DECLS +#if __has_feature(assume_nonnull) +_Pragma("clang assume_nonnull end") +#endif + +#endif // __XPC_LAUNCH_H__ diff --git a/lib/libc/include/x86_64-macos-gnu/libDER/DERItem.h b/lib/libc/include/x86_64-macos-gnu/libDER/DERItem.h new file mode 100644 index 0000000000..99d38e8d65 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/libDER/DERItem.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 Apple Inc. All Rights Reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _DER_ITEM_H_ +#define _DER_ITEM_H_ + +#if __has_include() + #include +#else + #include +#endif + +__BEGIN_DECLS + +/* + * Primary representation of a block of memory. + */ +typedef struct { + DERByte *data; + DERSize length; +} DERItem; + +__END_DECLS + +#endif /* _DER_ITEM_H_ */ + + diff --git a/lib/libc/include/x86_64-macos-gnu/libDER/libDER_config.h b/lib/libc/include/x86_64-macos-gnu/libDER/libDER_config.h new file mode 100644 index 0000000000..8743f4303d --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/libDER/libDER_config.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2005-2007,2011-2012,2014 Apple Inc. All Rights Reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + + +/* + * libDER_config.h - platform dependent #defines and typedefs for libDER + * + */ + +#ifndef _LIB_DER_CONFIG_H_ +#define _LIB_DER_CONFIG_H_ + +#include +#include +#include + +#if defined(WIN32) && defined(__cplusplus) + +#if !defined(__BEGIN_DECLS) || !defined(__END_DECLS) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#endif // __BEGIN_DECLS || __END_DECLS + +#else +#include +#endif // defined(WIN32) && defined(__cplusplus) + +__BEGIN_DECLS + +/* + * Basic data types: unsigned 8-bit integer, unsigned 32-bit integer + */ +typedef uint8_t DERByte; +typedef uint16_t DERShort; +typedef size_t DERSize; + + +/* + * Use these #defines of you have memset, memmove, and memcmp; else + * write your own equivalents. + */ + +#define DERMemset(ptr, c, len) memset(ptr, c, len) +#define DERMemmove(dst, src, len) memmove(dst, src, len) +#define DERMemcmp(b1, b2, len) memcmp(b1, b2, len) + + +/*** + *** Compile time options to trim size of the library. + ***/ + +/* enable general DER encode */ +#define DER_ENCODE_ENABLE 1 + +/* enable general DER decode */ +#define DER_DECODE_ENABLE 1 + +#ifndef DER_MULTIBYTE_TAGS +/* enable multibyte tag support. */ +#define DER_MULTIBYTE_TAGS 1 +#endif + +#ifndef DER_TAG_SIZE +/* Iff DER_MULTIBYTE_TAGS is 1 this is the sizeof(DERTag) in bytes. Note that + tags are still encoded and decoded from a minimally encoded DER + represantation. This value maintains compatibility with libImg4Decode/Encode. */ +#define DER_TAG_SIZE 8 +#endif + + +/* ---------------------- Do not edit below this line ---------------------- */ + +/* + * Logical representation of a tag (the encoded representation is always in + * the minimal number of bytes). The top 3 bits encode class and method + * The remaining bits encode the tag value. To obtain smaller DERItemSpecs + * sizes, choose the smallest type that fits your needs. Most standard ASN.1 + * usage only needs single byte tags, but ocasionally custom applications + * require a larger tag namespace. + */ +#if DER_MULTIBYTE_TAGS + +#if DER_TAG_SIZE == 1 +typedef uint8_t DERTag; +#elif DER_TAG_SIZE == 2 +typedef uint16_t DERTag; +#elif DER_TAG_SIZE == 4 +typedef uint32_t DERTag; +#elif DER_TAG_SIZE == 8 +typedef uint64_t DERTag; +#else +#error DER_TAG_SIZE invalid +#endif + +#else /* DER_MULTIBYTE_TAGS */ +typedef DERByte DERTag; +#endif /* !DER_MULTIBYTE_TAGS */ + +__END_DECLS + +#endif /* _LIB_DER_CONFIG_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h new file mode 100644 index 0000000000..ac38f94409 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2004-2016 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _OSATOMIC_H_ +#define _OSATOMIC_H_ + +/*! @header + * These are deprecated legacy interfaces for atomic and synchronization + * operations. + * + * Define OSATOMIC_USE_INLINED=1 to get inline implementations of the + * OSAtomic interfaces in terms of the primitives. + * + * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of the + * OSSpinLock interfaces in terms of the primitives. + * + * These are intended as a transition convenience, direct use of those + * primitives should be preferred. + */ + +#include + +#include "OSAtomicDeprecated.h" +#include "OSSpinLockDeprecated.h" +#include "OSAtomicQueue.h" + +#endif /* _OSATOMIC_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicDeprecated.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicDeprecated.h new file mode 100644 index 0000000000..f838a29587 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicDeprecated.h @@ -0,0 +1,1266 @@ +/* + * Copyright (c) 2004-2016 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _OSATOMIC_DEPRECATED_H_ +#define _OSATOMIC_DEPRECATED_H_ + +/*! @header + * These are deprecated legacy interfaces for atomic operations. + * The C11 interfaces in resp. C++11 interfaces in + * should be used instead. + * + * Define OSATOMIC_USE_INLINED=1 to get inline implementations of these + * interfaces in terms of the resp. primitives. + * This is intended as a transition convenience, direct use of those primitives + * is preferred. + */ + +#include + +#if !(defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED) + +#include +#include +#include +#include + +#ifndef OSATOMIC_DEPRECATED +#define OSATOMIC_DEPRECATED 1 +#ifndef __cplusplus +#define OSATOMIC_BARRIER_DEPRECATED_MSG(_r) \ + "Use " #_r "() from instead" +#define OSATOMIC_DEPRECATED_MSG(_r) \ + "Use " #_r "_explicit(memory_order_relaxed) from instead" +#else +#define OSATOMIC_BARRIER_DEPRECATED_MSG(_r) \ + "Use std::" #_r "() from instead" +#define OSATOMIC_DEPRECATED_MSG(_r) \ + "Use std::" #_r "_explicit(std::memory_order_relaxed) from instead" +#endif +#define OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(_r) \ + __OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) +#define OSATOMIC_DEPRECATED_REPLACE_WITH(_r) \ + __OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSATOMIC_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSATOMIC_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSATOMIC_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSATOMIC_DEPRECATED_MSG(_r)) +#else +#undef OSATOMIC_DEPRECATED +#define OSATOMIC_DEPRECATED 0 +#define OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(_r) +#define OSATOMIC_DEPRECATED_REPLACE_WITH(_r) +#endif + +/* + * WARNING: all addresses passed to these functions must be "naturally aligned", + * i.e. int32_t pointers must be 32-bit aligned (low 2 bits of + * address are zeroes), and int64_t pointers must be 64-bit + * aligned (low 3 bits of address are zeroes.). + * Note that this is not the default alignment of the int64_t type + * in the iOS ARMv7 ABI, see + * {@link //apple_ref/doc/uid/TP40009021-SW8 iPhoneOSABIReference} + * + * Note that some versions of the atomic functions incorporate memory barriers + * and some do not. Barriers strictly order memory access on weakly-ordered + * architectures such as ARM. All loads and stores that appear (in sequential + * program order) before the barrier are guaranteed to complete before any + * load or store that appears after the barrier. + * + * The barrier operation is typically a no-op on uniprocessor systems and + * fully enabled on multiprocessor systems. On some platforms, such as ARM, + * the barrier can be quite expensive. + * + * Most code should use the barrier functions to ensure that memory shared + * between threads is properly synchronized. For example, if you want to + * initialize a shared data structure and then atomically increment a variable + * to indicate that the initialization is complete, you must use + * {@link OSAtomicIncrement32Barrier} to ensure that the stores to your data + * structure complete before the atomic increment. + * + * Likewise, the consumer of that data structure must use + * {@link OSAtomicDecrement32Barrier}, + * in order to ensure that their loads of the structure are not executed before + * the atomic decrement. On the other hand, if you are simply incrementing a + * global counter, then it is safe and potentially faster to use + * {@link OSAtomicIncrement32}. + * + * If you are unsure which version to use, prefer the barrier variants as they + * are safer. + * + * For the kernel-space version of this header, see + * {@link //apple_ref/doc/header/OSAtomic.h OSAtomic.h (Kernel Framework)} + * + * @apiuid //apple_ref/doc/header/user_space_OSAtomic.h + */ + +__BEGIN_DECLS + +/*! @typedef OSAtomic_int64_aligned64_t + * 64-bit aligned int64_t type. + * Use for variables whose addresses are passed to OSAtomic*64() functions to + * get the compiler to generate the required alignment. + */ + +#if __has_attribute(aligned) +typedef int64_t __attribute__((__aligned__((sizeof(int64_t))))) + OSAtomic_int64_aligned64_t; +#else +typedef int64_t OSAtomic_int64_aligned64_t; +#endif + +/*! @group Arithmetic functions + All functions in this group return the new value. + */ + +/*! @abstract Atomically adds two 32-bit values. + @discussion + This function adds the value given by __theAmount to the + value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int32_t OSAtomicAdd32( int32_t __theAmount, volatile int32_t *__theValue ); + + +/*! @abstract Atomically adds two 32-bit values. + @discussion + This function adds the value given by __theAmount to the + value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + + This function is equivalent to {@link OSAtomicAdd32} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int32_t OSAtomicAdd32Barrier( int32_t __theAmount, volatile int32_t *__theValue ); + + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1 || TARGET_OS_DRIVERKIT + +/*! @abstract Atomically increments a 32-bit value. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add) +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1) +int32_t OSAtomicIncrement32( volatile int32_t *__theValue ); + + +/*! @abstract Atomically increments a 32-bit value with a barrier. + @discussion + This function is equivalent to {@link OSAtomicIncrement32} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add) +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1) +int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue ); + + +/*! @abstract Atomically decrements a 32-bit value. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_sub) +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1) +int32_t OSAtomicDecrement32( volatile int32_t *__theValue ); + + +/*! @abstract Atomically decrements a 32-bit value with a barrier. + @discussion + This function is equivalent to {@link OSAtomicDecrement32} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_sub) +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1) +int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue ); + +#else +__inline static +int32_t OSAtomicIncrement32( volatile int32_t *__theValue ) + { return OSAtomicAdd32( 1, __theValue); } + +__inline static +int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue ) + { return OSAtomicAdd32Barrier( 1, __theValue); } + +__inline static +int32_t OSAtomicDecrement32( volatile int32_t *__theValue ) + { return OSAtomicAdd32( -1, __theValue); } + +__inline static +int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue ) + { return OSAtomicAdd32Barrier( -1, __theValue); } +#endif + + +/*! @abstract Atomically adds two 64-bit values. + @discussion + This function adds the value given by __theAmount to the + value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int64_t OSAtomicAdd64( int64_t __theAmount, + volatile OSAtomic_int64_aligned64_t *__theValue ); + + +/*! @abstract Atomically adds two 64-bit values with a barrier. + @discussion + This function adds the value given by __theAmount to the + value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + + This function is equivalent to {@link OSAtomicAdd64} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_3_2) +int64_t OSAtomicAdd64Barrier( int64_t __theAmount, + volatile OSAtomic_int64_aligned64_t *__theValue ); + + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1 || TARGET_OS_DRIVERKIT + +/*! @abstract Atomically increments a 64-bit value. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add) +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1) +int64_t OSAtomicIncrement64( volatile OSAtomic_int64_aligned64_t *__theValue ); + + +/*! @abstract Atomically increments a 64-bit value with a barrier. + @discussion + This function is equivalent to {@link OSAtomicIncrement64} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add) +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1) +int64_t OSAtomicIncrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue ); + + +/*! @abstract Atomically decrements a 64-bit value. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_sub) +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1) +int64_t OSAtomicDecrement64( volatile OSAtomic_int64_aligned64_t *__theValue ); + + +/*! @abstract Atomically decrements a 64-bit value with a barrier. + @discussion + This function is equivalent to {@link OSAtomicDecrement64} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_sub) +__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1) +int64_t OSAtomicDecrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue ); + +#else +__inline static +int64_t OSAtomicIncrement64( volatile OSAtomic_int64_aligned64_t *__theValue ) + { return OSAtomicAdd64( 1, __theValue); } + +__inline static +int64_t OSAtomicIncrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue ) + { return OSAtomicAdd64Barrier( 1, __theValue); } + +__inline static +int64_t OSAtomicDecrement64( volatile OSAtomic_int64_aligned64_t *__theValue ) + { return OSAtomicAdd64( -1, __theValue); } + +__inline static +int64_t OSAtomicDecrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue ) + { return OSAtomicAdd64Barrier( -1, __theValue); } +#endif + + +/*! @group Boolean functions (AND, OR, XOR) + * + * @discussion Functions in this group come in four variants for each operation: + * with and without barriers, and functions that return the original value or + * the result value of the operation. + * + * The "Orig" versions return the original value, (before the operation); the non-Orig + * versions return the value after the operation. All are layered on top of + * {@link OSAtomicCompareAndSwap32} and similar. + */ + +/*! @abstract Atomic bitwise OR of two 32-bit values. + @discussion + This function performs the bitwise OR of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int32_t OSAtomicOr32( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise OR of two 32-bit values with barrier. + @discussion + This function performs the bitwise OR of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + + This function is equivalent to {@link OSAtomicOr32} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int32_t OSAtomicOr32Barrier( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise OR of two 32-bit values returning original. + @discussion + This function performs the bitwise OR of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + @result Returns the original value referenced by __theValue. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2) +int32_t OSAtomicOr32Orig( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise OR of two 32-bit values returning original with barrier. + @discussion + This function performs the bitwise OR of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + + This function is equivalent to {@link OSAtomicOr32Orig} + except that it also introduces a barrier. + @result Returns the original value referenced by __theValue. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2) +int32_t OSAtomicOr32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue ); + + + + +/*! @abstract Atomic bitwise AND of two 32-bit values. + @discussion + This function performs the bitwise AND of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int32_t OSAtomicAnd32( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise AND of two 32-bit values with barrier. + @discussion + This function performs the bitwise AND of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + + This function is equivalent to {@link OSAtomicAnd32} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int32_t OSAtomicAnd32Barrier( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise AND of two 32-bit values returning original. + @discussion + This function performs the bitwise AND of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + @result Returns the original value referenced by __theValue. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2) +int32_t OSAtomicAnd32Orig( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise AND of two 32-bit values returning original with barrier. + @discussion + This function performs the bitwise AND of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + + This function is equivalent to {@link OSAtomicAnd32Orig} + except that it also introduces a barrier. + @result Returns the original value referenced by __theValue. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2) +int32_t OSAtomicAnd32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue ); + + + + +/*! @abstract Atomic bitwise XOR of two 32-bit values. + @discussion + This function performs the bitwise XOR of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + @result Returns the new value. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_xor) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int32_t OSAtomicXor32( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise XOR of two 32-bit values with barrier. + @discussion + This function performs the bitwise XOR of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + + This function is equivalent to {@link OSAtomicXor32} + except that it also introduces a barrier. + @result Returns the new value. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_xor) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +int32_t OSAtomicXor32Barrier( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise XOR of two 32-bit values returning original. + @discussion + This function performs the bitwise XOR of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + @result Returns the original value referenced by __theValue. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_xor) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2) +int32_t OSAtomicXor32Orig( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @abstract Atomic bitwise XOR of two 32-bit values returning original with barrier. + @discussion + This function performs the bitwise XOR of the value given by __theMask + with the value in the memory location referenced by __theValue, + storing the result back to that memory location atomically. + + This function is equivalent to {@link OSAtomicXor32Orig} + except that it also introduces a barrier. + @result Returns the original value referenced by __theValue. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_xor) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2) +int32_t OSAtomicXor32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue ); + + +/*! @group Compare and swap + * Functions in this group return true if the swap occured. There are several versions, + * depending on data type and on whether or not a barrier is used. + */ + + +/*! @abstract Compare and swap for 32-bit values. + @discussion + This function compares the value in __oldValue to the value + in the memory location referenced by __theValue. If the values + match, this function stores the value from __newValue into + that memory location atomically. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +bool OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue ); + + +/*! @abstract Compare and swap for 32-bit values with barrier. + @discussion + This function compares the value in __oldValue to the value + in the memory location referenced by __theValue. If the values + match, this function stores the value from __newValue into + that memory location atomically. + + This function is equivalent to {@link OSAtomicCompareAndSwap32} + except that it also introduces a barrier. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue ); + + +/*! @abstract Compare and swap pointers. + @discussion + This function compares the pointer stored in __oldValue to the pointer + in the memory location referenced by __theValue. If the pointers + match, this function stores the pointer from __newValue into + that memory location atomically. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) +bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ); + + +/*! @abstract Compare and swap pointers with barrier. + @discussion + This function compares the pointer stored in __oldValue to the pointer + in the memory location referenced by __theValue. If the pointers + match, this function stores the pointer from __newValue into + that memory location atomically. + + This function is equivalent to {@link OSAtomicCompareAndSwapPtr} + except that it also introduces a barrier. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) +bool OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue ); + + +/*! @abstract Compare and swap for int values. + @discussion + This function compares the value in __oldValue to the value + in the memory location referenced by __theValue. If the values + match, this function stores the value from __newValue into + that memory location atomically. + + This function is equivalent to {@link OSAtomicCompareAndSwap32}. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) +bool OSAtomicCompareAndSwapInt( int __oldValue, int __newValue, volatile int *__theValue ); + + +/*! @abstract Compare and swap for int values. + @discussion + This function compares the value in __oldValue to the value + in the memory location referenced by __theValue. If the values + match, this function stores the value from __newValue into + that memory location atomically. + + This function is equivalent to {@link OSAtomicCompareAndSwapInt} + except that it also introduces a barrier. + + This function is equivalent to {@link OSAtomicCompareAndSwap32Barrier}. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) +bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue ); + + +/*! @abstract Compare and swap for long values. + @discussion + This function compares the value in __oldValue to the value + in the memory location referenced by __theValue. If the values + match, this function stores the value from __newValue into + that memory location atomically. + + This function is equivalent to {@link OSAtomicCompareAndSwap32} on 32-bit architectures, + or {@link OSAtomicCompareAndSwap64} on 64-bit architectures. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) +bool OSAtomicCompareAndSwapLong( long __oldValue, long __newValue, volatile long *__theValue ); + + +/*! @abstract Compare and swap for long values. + @discussion + This function compares the value in __oldValue to the value + in the memory location referenced by __theValue. If the values + match, this function stores the value from __newValue into + that memory location atomically. + + This function is equivalent to {@link OSAtomicCompareAndSwapLong} + except that it also introduces a barrier. + + This function is equivalent to {@link OSAtomicCompareAndSwap32} on 32-bit architectures, + or {@link OSAtomicCompareAndSwap64} on 64-bit architectures. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) +bool OSAtomicCompareAndSwapLongBarrier( long __oldValue, long __newValue, volatile long *__theValue ); + + +/*! @abstract Compare and swap for uint64_t values. + @discussion + This function compares the value in __oldValue to the value + in the memory location referenced by __theValue. If the values + match, this function stores the value from __newValue into + that memory location atomically. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, + volatile OSAtomic_int64_aligned64_t *__theValue ); + + +/*! @abstract Compare and swap for uint64_t values. + @discussion + This function compares the value in __oldValue to the value + in the memory location referenced by __theValue. If the values + match, this function stores the value from __newValue into + that memory location atomically. + + This function is equivalent to {@link OSAtomicCompareAndSwap64} + except that it also introduces a barrier. + @result Returns TRUE on a match, FALSE otherwise. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_3_2) +bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, + volatile OSAtomic_int64_aligned64_t *__theValue ); + + +/* Test and set. + * They return the original value of the bit, and operate on bit (0x80>>(n&7)) + * in byte ((char*)theAddress + (n>>3)). + */ +/*! @abstract Atomic test and set + @discussion + This function tests a bit in the value referenced by + __theAddress and if it is not set, sets it. + + The bit is chosen by the value of __n such that the + operation will be performed on bit (0x80 >> (__n & 7)) + of byte ((char *)__theAddress + (n >> 3)). + + For example, if __theAddress points to a 64-bit value, + to compare the value of the most significant bit, you would specify + 56 for __n. + @result + Returns the original value of the bit being tested. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +bool OSAtomicTestAndSet( uint32_t __n, volatile void *__theAddress ); + + +/*! @abstract Atomic test and set with barrier + @discussion + This function tests a bit in the value referenced by __theAddress + and if it is not set, sets it. + + The bit is chosen by the value of __n such that the + operation will be performed on bit (0x80 >> (__n & 7)) + of byte ((char *)__theAddress + (n >> 3)). + + For example, if __theAddress points to a 64-bit value, + to compare the value of the most significant bit, you would specify + 56 for __n. + + This function is equivalent to {@link OSAtomicTestAndSet} + except that it also introduces a barrier. + @result + Returns the original value of the bit being tested. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +bool OSAtomicTestAndSetBarrier( uint32_t __n, volatile void *__theAddress ); + + + +/*! @abstract Atomic test and clear + @discussion + This function tests a bit in the value referenced by __theAddress + and if it is not cleared, clears it. + + The bit is chosen by the value of __n such that the + operation will be performed on bit (0x80 >> (__n & 7)) + of byte ((char *)__theAddress + (n >> 3)). + + For example, if __theAddress points to a 64-bit value, + to compare the value of the most significant bit, you would specify + 56 for __n. + + @result + Returns the original value of the bit being tested. + */ +OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +bool OSAtomicTestAndClear( uint32_t __n, volatile void *__theAddress ); + + +/*! @abstract Atomic test and clear + @discussion + This function tests a bit in the value referenced by __theAddress + and if it is not cleared, clears it. + + The bit is chosen by the value of __n such that the + operation will be performed on bit (0x80 >> (__n & 7)) + of byte ((char *)__theAddress + (n >> 3)). + + For example, if __theAddress points to a 64-bit value, + to compare the value of the most significant bit, you would specify + 56 for __n. + + This function is equivalent to {@link OSAtomicTestAndSet} + except that it also introduces a barrier. + @result + Returns the original value of the bit being tested. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +bool OSAtomicTestAndClearBarrier( uint32_t __n, volatile void *__theAddress ); + + +/*! @group Memory barriers */ + +/*! @abstract Memory barrier. + @discussion + This function serves as both a read and write barrier. + */ +OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_thread_fence) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +void OSMemoryBarrier( void ); + +__END_DECLS + +#else // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED + +/* + * Inline implementations of the legacy OSAtomic interfaces in terms of + * C11 resp. C++11 primitives. + * Direct use of those primitives is preferred. + */ + +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C++" { +#if !(__has_include() && __has_extension(cxx_atomic)) +#error Cannot use inlined OSAtomic without and C++11 atomics +#endif +#include +typedef std::atomic _OSAtomic_uint8_t; +typedef std::atomic _OSAtomic_int32_t; +typedef std::atomic _OSAtomic_uint32_t; +typedef std::atomic _OSAtomic_int64_t; +typedef std::atomic _OSAtomic_void_ptr_t; +#define OSATOMIC_STD(_a) std::_a +__BEGIN_DECLS +#else +#if !(__has_include() && __has_extension(c_atomic)) +#error Cannot use inlined OSAtomic without and C11 atomics +#endif +#include +typedef _Atomic(uint8_t) _OSAtomic_uint8_t; +typedef _Atomic(int32_t) _OSAtomic_int32_t; +typedef _Atomic(uint32_t) _OSAtomic_uint32_t; +typedef _Atomic(int64_t) _OSAtomic_int64_t; +typedef _Atomic(void*) _OSAtomic_void_ptr_t; +#define OSATOMIC_STD(_a) _a +#endif + +#if __has_extension(c_alignof) && __has_attribute(aligned) +typedef int64_t __attribute__((__aligned__(_Alignof(_OSAtomic_int64_t)))) + OSAtomic_int64_aligned64_t; +#elif __has_attribute(aligned) +typedef int64_t __attribute__((__aligned__((sizeof(_OSAtomic_int64_t))))) + OSAtomic_int64_aligned64_t; +#else +typedef int64_t OSAtomic_int64_aligned64_t; +#endif + +#if __has_attribute(always_inline) +#define OSATOMIC_INLINE static __inline __attribute__((__always_inline__)) +#else +#define OSATOMIC_INLINE static __inline +#endif + +OSATOMIC_INLINE +int32_t +OSAtomicAdd32(int32_t __theAmount, volatile int32_t *__theValue) +{ + return (OSATOMIC_STD(atomic_fetch_add_explicit)( + (volatile _OSAtomic_int32_t*) __theValue, __theAmount, + OSATOMIC_STD(memory_order_relaxed)) + __theAmount); +} + +OSATOMIC_INLINE +int32_t +OSAtomicAdd32Barrier(int32_t __theAmount, volatile int32_t *__theValue) +{ + return (OSATOMIC_STD(atomic_fetch_add_explicit)( + (volatile _OSAtomic_int32_t*) __theValue, __theAmount, + OSATOMIC_STD(memory_order_seq_cst)) + __theAmount); +} + +OSATOMIC_INLINE +int32_t +OSAtomicIncrement32(volatile int32_t *__theValue) +{ + return OSAtomicAdd32(1, __theValue); +} + +OSATOMIC_INLINE +int32_t +OSAtomicIncrement32Barrier(volatile int32_t *__theValue) +{ + return OSAtomicAdd32Barrier(1, __theValue); +} + +OSATOMIC_INLINE +int32_t +OSAtomicDecrement32(volatile int32_t *__theValue) +{ + return OSAtomicAdd32(-1, __theValue); +} + +OSATOMIC_INLINE +int32_t +OSAtomicDecrement32Barrier(volatile int32_t *__theValue) +{ + return OSAtomicAdd32Barrier(-1, __theValue); +} + +OSATOMIC_INLINE +int64_t +OSAtomicAdd64(int64_t __theAmount, + volatile OSAtomic_int64_aligned64_t *__theValue) +{ + return (OSATOMIC_STD(atomic_fetch_add_explicit)( + (volatile _OSAtomic_int64_t*) __theValue, __theAmount, + OSATOMIC_STD(memory_order_relaxed)) + __theAmount); +} + +OSATOMIC_INLINE +int64_t +OSAtomicAdd64Barrier(int64_t __theAmount, + volatile OSAtomic_int64_aligned64_t *__theValue) +{ + return (OSATOMIC_STD(atomic_fetch_add_explicit)( + (volatile _OSAtomic_int64_t*) __theValue, __theAmount, + OSATOMIC_STD(memory_order_seq_cst)) + __theAmount); +} + +OSATOMIC_INLINE +int64_t +OSAtomicIncrement64(volatile OSAtomic_int64_aligned64_t *__theValue) +{ + return OSAtomicAdd64(1, __theValue); +} + +OSATOMIC_INLINE +int64_t +OSAtomicIncrement64Barrier(volatile OSAtomic_int64_aligned64_t *__theValue) +{ + return OSAtomicAdd64Barrier(1, __theValue); +} + +OSATOMIC_INLINE +int64_t +OSAtomicDecrement64(volatile OSAtomic_int64_aligned64_t *__theValue) +{ + return OSAtomicAdd64(-1, __theValue); +} + +OSATOMIC_INLINE +int64_t +OSAtomicDecrement64Barrier(volatile OSAtomic_int64_aligned64_t *__theValue) +{ + return OSAtomicAdd64Barrier(-1, __theValue); +} + +OSATOMIC_INLINE +int32_t +OSAtomicOr32(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_relaxed)) | __theMask); +} + +OSATOMIC_INLINE +int32_t +OSAtomicOr32Barrier(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_seq_cst)) | __theMask); +} + +OSATOMIC_INLINE +int32_t +OSAtomicOr32Orig(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +int32_t +OSAtomicOr32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_seq_cst))); +} + +OSATOMIC_INLINE +int32_t +OSAtomicAnd32(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_relaxed)) & __theMask); +} + +OSATOMIC_INLINE +int32_t +OSAtomicAnd32Barrier(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_seq_cst)) & __theMask); +} + +OSATOMIC_INLINE +int32_t +OSAtomicAnd32Orig(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +int32_t +OSAtomicAnd32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_seq_cst))); +} + +OSATOMIC_INLINE +int32_t +OSAtomicXor32(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_relaxed)) ^ __theMask); +} + +OSATOMIC_INLINE +int32_t +OSAtomicXor32Barrier(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_seq_cst)) ^ __theMask); +} + +OSATOMIC_INLINE +int32_t +OSAtomicXor32Orig(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +int32_t +OSAtomicXor32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue) +{ + return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)( + (volatile _OSAtomic_uint32_t*)__theValue, __theMask, + OSATOMIC_STD(memory_order_seq_cst))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwap32(int32_t __oldValue, int32_t __newValue, + volatile int32_t *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile _OSAtomic_int32_t*)__theValue, &__oldValue, __newValue, + OSATOMIC_STD(memory_order_relaxed), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwap32Barrier(int32_t __oldValue, int32_t __newValue, + volatile int32_t *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile _OSAtomic_int32_t*)__theValue, &__oldValue, __newValue, + OSATOMIC_STD(memory_order_seq_cst), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwapPtr(void *__oldValue, void *__newValue, + void * volatile *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile _OSAtomic_void_ptr_t*)__theValue, &__oldValue, __newValue, + OSATOMIC_STD(memory_order_relaxed), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwapPtrBarrier(void *__oldValue, void *__newValue, + void * volatile *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile _OSAtomic_void_ptr_t*)__theValue, &__oldValue, __newValue, + OSATOMIC_STD(memory_order_seq_cst), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwapInt(int __oldValue, int __newValue, + volatile int *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile OSATOMIC_STD(atomic_int)*)__theValue, &__oldValue, + __newValue, OSATOMIC_STD(memory_order_relaxed), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwapIntBarrier(int __oldValue, int __newValue, + volatile int *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile OSATOMIC_STD(atomic_int)*)__theValue, &__oldValue, + __newValue, OSATOMIC_STD(memory_order_seq_cst), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwapLong(long __oldValue, long __newValue, + volatile long *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile OSATOMIC_STD(atomic_long)*)__theValue, &__oldValue, + __newValue, OSATOMIC_STD(memory_order_relaxed), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwapLongBarrier(long __oldValue, long __newValue, + volatile long *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile OSATOMIC_STD(atomic_long)*)__theValue, &__oldValue, + __newValue, OSATOMIC_STD(memory_order_seq_cst), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwap64(int64_t __oldValue, int64_t __newValue, + volatile OSAtomic_int64_aligned64_t *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile _OSAtomic_int64_t*)__theValue, &__oldValue, __newValue, + OSATOMIC_STD(memory_order_relaxed), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicCompareAndSwap64Barrier(int64_t __oldValue, int64_t __newValue, + volatile OSAtomic_int64_aligned64_t *__theValue) +{ + return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)( + (volatile _OSAtomic_int64_t*)__theValue, &__oldValue, __newValue, + OSATOMIC_STD(memory_order_seq_cst), + OSATOMIC_STD(memory_order_relaxed))); +} + +OSATOMIC_INLINE +bool +OSAtomicTestAndSet(uint32_t __n, volatile void *__theAddress) +{ + uintptr_t a = (uintptr_t)__theAddress + (__n >> 3); + uint8_t v = (0x80u >> (__n & 7)); + return (OSATOMIC_STD(atomic_fetch_or_explicit)((_OSAtomic_uint8_t*)a, v, + OSATOMIC_STD(memory_order_relaxed)) & v); +} + +OSATOMIC_INLINE +bool +OSAtomicTestAndSetBarrier(uint32_t __n, volatile void *__theAddress) +{ + uintptr_t a = (uintptr_t)__theAddress + (__n >> 3); + uint8_t v = (0x80u >> (__n & 7)); + return (OSATOMIC_STD(atomic_fetch_or_explicit)((_OSAtomic_uint8_t*)a, v, + OSATOMIC_STD(memory_order_seq_cst)) & v); +} + +OSATOMIC_INLINE +bool +OSAtomicTestAndClear(uint32_t __n, volatile void *__theAddress) +{ + uintptr_t a = (uintptr_t)__theAddress + (__n >> 3); + uint8_t v = (0x80u >> (__n & 7)); + return (OSATOMIC_STD(atomic_fetch_and_explicit)((_OSAtomic_uint8_t*)a, + (uint8_t)~v, OSATOMIC_STD(memory_order_relaxed)) & v); +} + +OSATOMIC_INLINE +bool +OSAtomicTestAndClearBarrier(uint32_t __n, volatile void *__theAddress) +{ + uintptr_t a = (uintptr_t)__theAddress + (__n >> 3); + uint8_t v = (0x80u >> (__n & 7)); + return (OSATOMIC_STD(atomic_fetch_and_explicit)((_OSAtomic_uint8_t*)a, + (uint8_t)~v, OSATOMIC_STD(memory_order_seq_cst)) & v); +} + +OSATOMIC_INLINE +void +OSMemoryBarrier(void) +{ + OSATOMIC_STD(atomic_thread_fence)(OSATOMIC_STD(memory_order_seq_cst)); +} + +#undef OSATOMIC_INLINE +#undef OSATOMIC_STD +#ifdef __cplusplus +__END_DECLS +} // extern "C++" +#endif + +#endif // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED + +#if TARGET_OS_OSX || TARGET_OS_DRIVERKIT + +__BEGIN_DECLS + +/*! @group Lockless atomic fifo enqueue and dequeue + * These routines manipulate singly-linked FIFO lists. + * + * This API is deprecated and no longer recommended + */ + +/*! @abstract The data structure for a fifo queue head. + @discussion + You should always initialize a fifo queue head structure with the + initialization vector {@link OS_ATOMIC_FIFO_QUEUE_INIT} before use. + */ +#if defined(__LP64__) + +typedef volatile struct { + void *opaque1; + void *opaque2; + int opaque3; +} __attribute__ ((aligned (16))) OSFifoQueueHead; + +#else + +typedef volatile struct { + void *opaque1; + void *opaque2; + int opaque3; +} OSFifoQueueHead; + +#endif +/*! @abstract The initialization vector for a fifo queue head. */ +#define OS_ATOMIC_FIFO_QUEUE_INIT { NULL, NULL, 0 } + +/*! @abstract Enqueue an element onto a list. + @discussion + Memory barriers are incorporated as needed to permit thread-safe access + to the queue element. + @param __list + The list on which you want to enqueue the element. + @param __new + The element to add. + @param __offset + The "offset" parameter is the offset (in bytes) of the link field + from the beginning of the data structure being queued (__new). + The link field should be a pointer type. + The __offset value needs to be same for all enqueuing and + dequeuing operations on the same list, even if different structure types + are enqueued on that list. The use of offsetset(), defined in + stddef.h is the common way to specify the __offset + value. + + @note + This API is deprecated and no longer recommended + */ +__API_DEPRECATED("No longer supported", macos(10.7, 11.0)) +void OSAtomicFifoEnqueue( OSFifoQueueHead *__list, void *__new, size_t __offset); + +/*! @abstract Dequeue an element from a list. + @discussion + Memory barriers are incorporated as needed to permit thread-safe access + to the queue element. + @param __list + The list from which you want to dequeue an element. + @param __offset + The "offset" parameter is the offset (in bytes) of the link field + from the beginning of the data structure being dequeued (__new). + The link field should be a pointer type. + The __offset value needs to be same for all enqueuing and + dequeuing operations on the same list, even if different structure types + are enqueued on that list. The use of offsetset(), defined in + stddef.h is the common way to specify the __offset + value. + @result + Returns the oldest enqueued element, or NULL if the + list is empty. + + @note + This API is deprecated and no longer recommended + */ +__API_DEPRECATED("No longer supported", macos(10.7, 11.0)) +void* OSAtomicFifoDequeue( OSFifoQueueHead *__list, size_t __offset); + +__END_DECLS + +#endif /* TARGET_OS_OSX || TARGET_OS_DRIVERKIT */ + +#endif /* _OSATOMIC_DEPRECATED_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicQueue.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicQueue.h new file mode 100644 index 0000000000..0ca841ceb3 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicQueue.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2004-2016 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _OSATOMICQUEUE_H_ +#define _OSATOMICQUEUE_H_ + +#include +#include +#include +#include +#include "OSAtomicDeprecated.h" + +#include + +/*! @header Lockless atomic enqueue and dequeue + * These routines manipulate singly-linked LIFO lists. + */ + +__BEGIN_DECLS + +/*! @abstract The data structure for a queue head. + @discussion + You should always initialize a queue head structure with the + initialization vector {@link OS_ATOMIC_QUEUE_INIT} before use. + */ +#if defined(__LP64__) + +typedef volatile struct { + void *opaque1; + long opaque2; +} __attribute__ ((aligned (16))) OSQueueHead; + +#else + +typedef volatile struct { + void *opaque1; + long opaque2; +} OSQueueHead; + +#endif + +/*! @abstract The initialization vector for a queue head. */ +#define OS_ATOMIC_QUEUE_INIT { NULL, 0 } + +/*! @abstract Enqueue an element onto a list. + @discussion + Memory barriers are incorporated as needed to permit thread-safe access + to the queue element. + @param __list + The list on which you want to enqueue the element. + @param __new + The element to add. + @param __offset + The "offset" parameter is the offset (in bytes) of the link field + from the beginning of the data structure being queued (__new). + The link field should be a pointer type. + The __offset value needs to be same for all enqueuing and + dequeuing operations on the same list, even if different structure types + are enqueued on that list. The use of offsetset(), defined in + stddef.h is the common way to specify the __offset + value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0) +void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset); + + +/*! @abstract Dequeue an element from a list. + @discussion + Memory barriers are incorporated as needed to permit thread-safe access + to the queue element. + @param __list + The list from which you want to dequeue an element. + @param __offset + The "offset" parameter is the offset (in bytes) of the link field + from the beginning of the data structure being dequeued (__new). + The link field should be a pointer type. + The __offset value needs to be same for all enqueuing and + dequeuing operations on the same list, even if different structure types + are enqueued on that list. The use of offsetset(), defined in + stddef.h is the common way to specify the __offset + value. + IMPORTANT: the memory backing the link field of a queue element must not be + unmapped after OSAtomicDequeue() returns until all concurrent calls to + OSAtomicDequeue() for the same list on other threads have also returned, + as they may still be accessing that memory location. + @result + Returns the most recently enqueued element, or NULL if the + list is empty. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0) +void* OSAtomicDequeue( OSQueueHead *__list, size_t __offset); + +__END_DECLS + +#endif /* _OSATOMICQUEUE_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h index d9712031e5..63d67d4496 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h @@ -37,10 +37,22 @@ #define OSSwapConstInt32(x) __DARWIN_OSSwapConstInt32(x) #define OSSwapConstInt64(x) __DARWIN_OSSwapConstInt64(x) +#if !defined(__DARWIN_OS_INLINE) +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define __DARWIN_OS_INLINE static inline +# elif defined(__MWERKS__) || defined(__cplusplus) +# define __DARWIN_OS_INLINE static inline +# else +# define __DARWIN_OS_INLINE static __inline__ +# endif +#endif + #if defined(__GNUC__) #if (defined(__i386__) || defined(__x86_64__)) #include +#elif defined (__arm__) || defined(__arm64__) +#include #else #include #endif @@ -61,7 +73,7 @@ enum { OSBigEndian }; -OS_INLINE +__DARWIN_OS_INLINE int32_t OSHostByteOrder(void) { @@ -85,7 +97,7 @@ OSHostByteOrder(void) /* Functions for loading native endian values. */ -OS_INLINE +__DARWIN_OS_INLINE uint16_t _OSReadInt16( const volatile void * base, @@ -95,7 +107,7 @@ _OSReadInt16( return *(volatile uint16_t *)((uintptr_t)base + byteOffset); } -OS_INLINE +__DARWIN_OS_INLINE uint32_t _OSReadInt32( const volatile void * base, @@ -105,7 +117,7 @@ _OSReadInt32( return *(volatile uint32_t *)((uintptr_t)base + byteOffset); } -OS_INLINE +__DARWIN_OS_INLINE uint64_t _OSReadInt64( const volatile void * base, @@ -117,7 +129,7 @@ _OSReadInt64( /* Functions for storing native endian values. */ -OS_INLINE +__DARWIN_OS_INLINE void _OSWriteInt16( volatile void * base, @@ -128,7 +140,7 @@ _OSWriteInt16( *(volatile uint16_t *)((uintptr_t)base + byteOffset) = data; } -OS_INLINE +__DARWIN_OS_INLINE void _OSWriteInt32( volatile void * base, @@ -139,7 +151,7 @@ _OSWriteInt32( *(volatile uint32_t *)((uintptr_t)base + byteOffset) = data; } -OS_INLINE +__DARWIN_OS_INLINE void _OSWriteInt64( volatile void * base, diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h new file mode 100644 index 0000000000..f22b14199d --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2004-2016 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _OSSPINLOCK_DEPRECATED_H_ +#define _OSSPINLOCK_DEPRECATED_H_ + +/*! @header + * These are deprecated legacy interfaces for userspace spinlocks. + * + * These interfaces should no longer be used, particularily in situations where + * threads of differing priorities may contend on the same spinlock. + * + * The interfaces in should be used instead in cases where a very + * low-level lock primitive is required. In general however, using higher level + * synchronization primitives such as those provided by the pthread or dispatch + * subsystems should be preferred. + * + * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of these + * interfaces in terms of the primitives. This is intended as a + * transition convenience, direct use of those primitives is preferred. + */ + +#ifndef OSSPINLOCK_DEPRECATED +#define OSSPINLOCK_DEPRECATED 1 +#define OSSPINLOCK_DEPRECATED_MSG(_r) "Use " #_r "() from instead" +#define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) \ + __OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSSPINLOCK_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \ + __OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSSPINLOCK_DEPRECATED_MSG(_r)) +#else +#undef OSSPINLOCK_DEPRECATED +#define OSSPINLOCK_DEPRECATED 0 +#define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) +#endif + +#if !(defined(OSSPINLOCK_USE_INLINED) && OSSPINLOCK_USE_INLINED) + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +/*! @abstract The default value for an OSSpinLock. + @discussion + The convention is that unlocked is zero, locked is nonzero. + */ +#define OS_SPINLOCK_INIT 0 + + +/*! @abstract Data type for a spinlock. + @discussion + You should always initialize a spinlock to {@link OS_SPINLOCK_INIT} before + using it. + */ +typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock); + + +/*! @abstract Locks a spinlock if it would not block + @result + Returns false if the lock was already held by another thread, + true if it took the lock successfully. + */ +OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +bool OSSpinLockTry( volatile OSSpinLock *__lock ); + + +/*! @abstract Locks a spinlock + @discussion + Although the lock operation spins, it employs various strategies to back + off if the lock is held. + */ +OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +void OSSpinLockLock( volatile OSSpinLock *__lock ); + + +/*! @abstract Unlocks a spinlock */ +OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock) +__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) +void OSSpinLockUnlock( volatile OSSpinLock *__lock ); + +__END_DECLS + +#else /* OSSPINLOCK_USE_INLINED */ + +/* + * Inline implementations of the legacy OSSpinLock interfaces in terms of the + * of the primitives. Direct use of those primitives is preferred. + * + * NOTE: the locked value of os_unfair_lock is implementation defined and + * subject to change, code that relies on the specific locked value used by the + * legacy OSSpinLock interface WILL break when using these inline + * implementations in terms of os_unfair_lock. + */ + +#if !OSSPINLOCK_USE_INLINED_TRANSPARENT + +#include + +__BEGIN_DECLS + +#if __has_attribute(always_inline) +#define OSSPINLOCK_INLINE static __inline +#else +#define OSSPINLOCK_INLINE static __inline __attribute__((__always_inline__)) +#endif + +#define OS_SPINLOCK_INIT 0 +typedef int32_t OSSpinLock; + +#if __has_extension(c_static_assert) +_Static_assert(sizeof(OSSpinLock) == sizeof(os_unfair_lock), + "Incompatible os_unfair_lock type"); +#endif + +OSSPINLOCK_INLINE +void +OSSpinLockLock(volatile OSSpinLock *__lock) +{ + os_unfair_lock_t lock = (os_unfair_lock_t)__lock; + return os_unfair_lock_lock(lock); +} + +OSSPINLOCK_INLINE +bool +OSSpinLockTry(volatile OSSpinLock *__lock) +{ + os_unfair_lock_t lock = (os_unfair_lock_t)__lock; + return os_unfair_lock_trylock(lock); +} + +OSSPINLOCK_INLINE +void +OSSpinLockUnlock(volatile OSSpinLock *__lock) +{ + os_unfair_lock_t lock = (os_unfair_lock_t)__lock; + return os_unfair_lock_unlock(lock); +} + +#undef OSSPINLOCK_INLINE + +__END_DECLS + +#else /* OSSPINLOCK_USE_INLINED_TRANSPARENT */ + +#include +#include +#include +#include +#include + +#define OS_NOSPIN_LOCK_AVAILABILITY \ + __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) \ + __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0) + +__BEGIN_DECLS + +#define OS_SPINLOCK_INIT 0 +typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock); +typedef volatile OSSpinLock *_os_nospin_lock_t + OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t); + +OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock) +OS_NOSPIN_LOCK_AVAILABILITY +void _os_nospin_lock_lock(_os_nospin_lock_t lock); +#undef OSSpinLockLock +#define OSSpinLockLock(lock) _os_nospin_lock_lock(lock) + +OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock) +OS_NOSPIN_LOCK_AVAILABILITY +bool _os_nospin_lock_trylock(_os_nospin_lock_t lock); +#undef OSSpinLockTry +#define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock) + +OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock) +OS_NOSPIN_LOCK_AVAILABILITY +void _os_nospin_lock_unlock(_os_nospin_lock_t lock); +#undef OSSpinLockUnlock +#define OSSpinLockUnlock(lock) _os_nospin_lock_unlock(lock) + +__END_DECLS + +#endif /* OSSPINLOCK_USE_INLINED_TRANSPARENT */ + +#endif /* OSSPINLOCK_USE_INLINED */ + +#endif /* _OSSPINLOCK_DEPRECATED_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSTypes.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSTypes.h new file mode 100644 index 0000000000..451ef763c8 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSTypes.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 1999-2012 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#include + +#ifndef _OS_OSTYPES_H +#define _OS_OSTYPES_H + +#define OSTYPES_K64_REV 2 + +typedef unsigned int UInt; +typedef signed int SInt; + + +#include + +#endif /* _OS_OSTYPES_H */ diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h b/lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h index 89c2714b3b..db7419df0b 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h @@ -41,14 +41,14 @@ /* Macros for swapping constant values in the preprocessing stage. */ #define __DARWIN_OSSwapConstInt16(x) \ - ((__uint16_t)((((__uint16_t)(x) & 0xff00) >> 8) | \ - (((__uint16_t)(x) & 0x00ff) << 8))) + ((__uint16_t)((((__uint16_t)(x) & 0xff00U) >> 8) | \ + (((__uint16_t)(x) & 0x00ffU) << 8))) #define __DARWIN_OSSwapConstInt32(x) \ - ((__uint32_t)((((__uint32_t)(x) & 0xff000000) >> 24) | \ - (((__uint32_t)(x) & 0x00ff0000) >> 8) | \ - (((__uint32_t)(x) & 0x0000ff00) << 8) | \ - (((__uint32_t)(x) & 0x000000ff) << 24))) + ((__uint32_t)((((__uint32_t)(x) & 0xff000000U) >> 24) | \ + (((__uint32_t)(x) & 0x00ff0000U) >> 8) | \ + (((__uint32_t)(x) & 0x0000ff00U) << 8) | \ + (((__uint32_t)(x) & 0x000000ffU) << 24))) #define __DARWIN_OSSwapConstInt64(x) \ ((__uint64_t)((((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \ @@ -62,10 +62,23 @@ #if defined(__GNUC__) +#if !defined(__DARWIN_OS_INLINE) +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define __DARWIN_OS_INLINE static inline +# elif defined(__MWERKS__) || defined(__cplusplus) +# define __DARWIN_OS_INLINE static inline +# else +# define __DARWIN_OS_INLINE static __inline__ +# endif +#endif + #if defined(__i386__) || defined(__x86_64__) #include #endif +#if defined (__arm__) || defined(__arm64__) +#include +#endif #define __DARWIN_OSSwapInt16(x) \ @@ -81,16 +94,6 @@ #if defined(__i386__) || defined(__x86_64__) -#if !defined(__DARWIN_OS_INLINE) -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -# define __DARWIN_OS_INLINE static inline -# elif defined(__MWERKS__) || defined(__cplusplus) -# define __DARWIN_OS_INLINE static inline -# else -# define __DARWIN_OS_INLINE static __inline__ -# endif -#endif - __DARWIN_OS_INLINE uint16_t _OSSwapInt16( diff --git a/lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h b/lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h index 4e8f31f57a..7745cc61b0 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h +++ b/lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h @@ -112,6 +112,15 @@ extern void _tlv_atexit(void (*termFunc)(void* objAddr), void* objAddr) __O */ extern void _tlv_bootstrap(void) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) DYLD_DRIVERKIT_UNAVAILABLE ; + +/* + * Dylibs that are incorporated into the dyld cache are removed from disk. That means code + * cannot stat() the file to see if it "exists". This function is like a stat() call that checks if a + * path is to a dylib that was removed from disk and is incorporated into the active dyld cache. + */ +extern 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; + + /* * The following dyld API's are deprecated as of Mac OS X 10.5. They are either * no longer necessary or are superceeded by dlopen and friends in . diff --git a/lib/libc/include/x86_64-macos-gnu/mach-o/loader.h b/lib/libc/include/x86_64-macos-gnu/mach-o/loader.h index a6bdbcbde3..e4b1455917 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach-o/loader.h +++ b/lib/libc/include/x86_64-macos-gnu/mach-o/loader.h @@ -115,11 +115,14 @@ struct mach_header_64 { #define MH_DYLIB 0x6 /* dynamically bound shared library */ #define MH_DYLINKER 0x7 /* dynamic link editor */ #define MH_BUNDLE 0x8 /* dynamically bound bundle file */ -#define MH_DYLIB_STUB 0x9 /* shared library stub for static */ - /* linking only, no section contents */ -#define MH_DSYM 0xa /* companion file with only debug */ - /* sections */ +#define MH_DYLIB_STUB 0x9 /* shared library stub for static + linking only, no section contents */ +#define MH_DSYM 0xa /* companion file with only debug + sections */ #define MH_KEXT_BUNDLE 0xb /* x86_64 kexts */ +#define MH_FILESET 0xc /* a file composed of other Mach-Os to + be run in the same userspace sharing + a single linkedit. */ /* Constants for the flags field of the mach_header */ #define MH_NOUNDEFS 0x1 /* the object file has no undefined @@ -322,6 +325,7 @@ struct load_command { #define LC_BUILD_VERSION 0x32 /* build for platform min OS version */ #define LC_DYLD_EXPORTS_TRIE (0x33 | LC_REQ_DYLD) /* used with linkedit_data_command, payload is trie */ #define LC_DYLD_CHAINED_FIXUPS (0x34 | LC_REQ_DYLD) /* used with linkedit_data_command */ +#define LC_FILESET_ENTRY (0x35 | LC_REQ_DYLD) /* used with fileset_entry_command */ /* * A variable length string in a load command is represented by an lc_str @@ -1265,9 +1269,6 @@ struct build_tool_version { #define PLATFORM_WATCHOS 4 #define PLATFORM_BRIDGEOS 5 #define PLATFORM_MACCATALYST 6 -#if (!defined(PLATFORM_MACCATALYST)) -#define PLATFORM_MACCATALYST 6 -#endif #define PLATFORM_IOSSIMULATOR 7 #define PLATFORM_TVOSSIMULATOR 8 #define PLATFORM_WATCHOSSIMULATOR 9 @@ -1574,4 +1575,27 @@ struct note_command { uint64_t size; /* length of data region */ }; +/* + * LC_FILESET_ENTRY commands describe constituent Mach-O files that are part + * of a fileset. In one implementation, entries are dylibs with individual + * mach headers and repositionable text and data segments. Each entry is + * further described by its own mach header. + */ +struct fileset_entry_command { + uint32_t cmd; /* LC_FILESET_ENTRY */ + uint32_t cmdsize; /* includes entry_id string */ + uint64_t vmaddr; /* memory address of the entry */ + uint64_t fileoff; /* file offset of the entry */ + union lc_str entry_id; /* contained entry id */ + uint32_t reserved; /* reserved */ +}; + +/* + * These deprecated values may still be used within Apple but are mechanically + * removed from public API. The mechanical process may produce unusual results. + */ +#if (!defined(PLATFORM_MACCATALYST)) +#define PLATFORM_MACCATALYST PLATFORM_MACCATALYST +#endif + #endif /* _MACHO_LOADER_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h index c9cc8992cf..2c79050b6d 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h @@ -603,7 +603,48 @@ _STRUCT_X86_DEBUG_STATE32 unsigned int __dr6; unsigned int __dr7; }; + +#define _STRUCT_X86_INSTRUCTION_STATE struct __x86_instruction_state +_STRUCT_X86_INSTRUCTION_STATE +{ + int __insn_stream_valid_bytes; + int __insn_offset; + int __out_of_synch; /* + * non-zero when the cacheline that includes the insn_offset + * is replaced in the insn_bytes array due to a mismatch + * detected when comparing it with the same cacheline in memory + */ +#define _X86_INSTRUCTION_STATE_MAX_INSN_BYTES (2448 - 64 - 4) + __uint8_t __insn_bytes[_X86_INSTRUCTION_STATE_MAX_INSN_BYTES]; +#define _X86_INSTRUCTION_STATE_CACHELINE_SIZE 64 + __uint8_t __insn_cacheline[_X86_INSTRUCTION_STATE_CACHELINE_SIZE]; +}; + +#define _STRUCT_LAST_BRANCH_RECORD struct __last_branch_record +_STRUCT_LAST_BRANCH_RECORD +{ + __uint64_t __from_ip; + __uint64_t __to_ip; + __uint32_t __mispredict : 1, + __tsx_abort : 1, + __in_tsx : 1, + __cycle_count: 16, + __reserved : 13; +}; + +#define _STRUCT_LAST_BRANCH_STATE struct __last_branch_state +_STRUCT_LAST_BRANCH_STATE +{ + int __lbr_count; + __uint32_t __lbr_supported_tsx : 1, + __lbr_supported_cycle_count : 1, + __reserved : 30; +#define __LASTBRANCH_MAX 32 + _STRUCT_LAST_BRANCH_RECORD __lbrs[__LASTBRANCH_MAX]; +}; + #else /* !__DARWIN_UNIX03 */ + #define _STRUCT_X86_DEBUG_STATE32 struct x86_debug_state32 _STRUCT_X86_DEBUG_STATE32 { @@ -616,6 +657,45 @@ _STRUCT_X86_DEBUG_STATE32 unsigned int dr6; unsigned int dr7; }; + +#define _STRUCT_X86_INSTRUCTION_STATE struct __x86_instruction_state +_STRUCT_X86_INSTRUCTION_STATE +{ + int insn_stream_valid_bytes; + int insn_offset; + int out_of_synch; /* + * non-zero when the cacheline that includes the insn_offset + * is replaced in the insn_bytes array due to a mismatch + * detected when comparing it with the same cacheline in memory + */ +#define x86_INSTRUCTION_STATE_MAX_INSN_BYTES (2448 - 64 - 4) + __uint8_t insn_bytes[x86_INSTRUCTION_STATE_MAX_INSN_BYTES]; +#define x86_INSTRUCTION_STATE_CACHELINE_SIZE 64 + __uint8_t insn_cacheline[x86_INSTRUCTION_STATE_CACHELINE_SIZE]; +}; + +#define _STRUCT_LAST_BRANCH_RECORD struct __last_branch_record +_STRUCT_LAST_BRANCH_RECORD +{ + __uint64_t from_ip; + __uint64_t to_ip; + __uint32_t mispredict : 1, + tsx_abort : 1, + in_tsx : 1, + cycle_count: 16, + reserved : 13; +}; + +#define _STRUCT_LAST_BRANCH_STATE struct __last_branch_state +_STRUCT_LAST_BRANCH_STATE +{ + int lbr_count; + __uint32_t lbr_supported_tsx : 1, + lbr_supported_cycle_count : 1, + reserved : 30; +#define __LASTBRANCH_MAX 32 + _STRUCT_LAST_BRANCH_RECORD lbrs[__LASTBRANCH_MAX]; +}; #endif /* !__DARWIN_UNIX03 */ #define _STRUCT_X86_PAGEIN_STATE struct __x86_pagein_state diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h index 759489dcf7..4cd90fa08f 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h @@ -32,7 +32,7 @@ #ifndef _MACH_I386_THREAD_STATE_H_ #define _MACH_I386_THREAD_STATE_H_ -/* Size of maximum exported thread state in words */ +/* Size of maximum exported thread state in 32-bit words */ #define I386_THREAD_STATE_MAX (614) /* Size of biggest state possible */ #if defined (__i386__) || defined(__x86_64__) diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h index 105fe352df..ecb4bcae20 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2020 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -121,6 +121,8 @@ #define x86_AVX512_STATE (x86_AVX512_STATE32 + 2) #define x86_PAGEIN_STATE 22 #define x86_THREAD_FULL_STATE64 23 +#define x86_INSTRUCTION_STATE 24 +#define x86_LAST_BRANCH_STATE 25 /* * Largest state on this machine: @@ -155,6 +157,8 @@ (x == x86_AVX512_STATE64) || \ (x == x86_AVX512_STATE) || \ (x == x86_PAGEIN_STATE) || \ + (x == x86_INSTRUCTION_STATE) || \ + (x == x86_LAST_BRANCH_STATE) || \ (x == THREAD_STATE_NONE)) struct x86_state_hdr { @@ -259,6 +263,19 @@ typedef _STRUCT_X86_PAGEIN_STATE x86_pagein_state_t; #define X86_PAGEIN_STATE_COUNT x86_PAGEIN_STATE_COUNT +typedef _STRUCT_X86_INSTRUCTION_STATE x86_instruction_state_t; +#define x86_INSTRUCTION_STATE_COUNT \ + ((mach_msg_type_number_t)(sizeof(x86_instruction_state_t) / sizeof(int))) + +#define X86_INSTRUCTION_STATE_COUNT x86_INSTRUCTION_STATE_COUNT + +typedef _STRUCT_LAST_BRANCH_STATE last_branch_state_t; +#define x86_LAST_BRANCH_STATE_COUNT \ + ((mach_msg_type_number_t)(sizeof(last_branch_state_t) / sizeof(int))) + +#define X86_LAST_BRANCH_STATE_COUNT x86_LAST_BRANCH_STATE_COUNT + + /* * Combined thread, float and exception states */ diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h index fc37cd1d80..7834a85024 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h @@ -90,47 +90,34 @@ #ifndef _MACH_I386_VM_PARAM_H_ #define _MACH_I386_VM_PARAM_H_ +#if !defined(KERNEL) && !defined(__ASSEMBLER__) + +#include +#endif + #define BYTE_SIZE 8 /* byte size in bits */ #define I386_PGBYTES 4096 /* bytes per 80386 page */ #define I386_PGSHIFT 12 /* bitshift for pages */ -#define PAGE_SIZE I386_PGBYTES + +#if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) #define PAGE_SHIFT I386_PGSHIFT -#define PAGE_MASK (PAGE_SIZE - 1) +#define PAGE_SIZE I386_PGBYTES +#define PAGE_MASK (PAGE_SIZE-1) +#else /* !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) */ +#define PAGE_SHIFT vm_page_shift +#define PAGE_SIZE vm_page_size +#define PAGE_MASK vm_page_mask +#endif /* !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) */ -#define PAGE_MAX_SHIFT PAGE_SHIFT -#define PAGE_MAX_SIZE PAGE_SIZE -#define PAGE_MAX_MASK PAGE_MASK - -#define PAGE_MIN_SHIFT PAGE_SHIFT -#define PAGE_MIN_SIZE PAGE_SIZE -#define PAGE_MIN_MASK PAGE_MASK - -#define I386_LPGBYTES 2*1024*1024 /* bytes per large page */ -#define I386_LPGSHIFT 21 /* bitshift for large pages */ -#define I386_LPGMASK (I386_LPGBYTES-1) - -/* - * Convert bytes to pages and convert pages to bytes. - * No rounding is used. - */ - -#define i386_btop(x) ((ppnum_t)((x) >> I386_PGSHIFT)) -#define machine_btop(x) i386_btop(x) -#define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT) -#define machine_ptob(x) i386_ptob(x) - -/* - * Round off or truncate to the nearest page. These will work - * for either addresses or counts. (i.e. 1 byte rounds to 1 page - * bytes. - */ - -#define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \ - ~(I386_PGBYTES-1)) -#define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1)) +#define PAGE_MAX_SHIFT 14 +#define PAGE_MAX_SIZE (1 << PAGE_MAX_SHIFT) +#define PAGE_MAX_MASK (PAGE_MAX_SIZE-1) +#define PAGE_MIN_SHIFT 12 +#define PAGE_MIN_SIZE (1 << PAGE_MIN_SHIFT) +#define PAGE_MIN_MASK (PAGE_MIN_SIZE-1) #define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL) diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h index f75fd05a91..acf56e0435 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h @@ -70,7 +70,6 @@ #ifndef ASSEMBLER #include -#include #include /* diff --git a/lib/libc/include/x86_64-macos-gnu/mach/kern_return.h b/lib/libc/include/x86_64-macos-gnu/mach/kern_return.h index cbc29d9374..d321826008 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/kern_return.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/kern_return.h @@ -323,6 +323,10 @@ /* The provided buffer is of insufficient size for the requested data. */ +#define KERN_DENIED 53 +/* Denied by security policy + */ + #define KERN_RETURN_MAX 0x100 /* Maximum return value allowable */ diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_port.h b/lib/libc/include/x86_64-macos-gnu/mach/mach_port.h index 8f587e3bfa..f300e8164b 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_port.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/mach_port.h @@ -226,7 +226,7 @@ extern #endif /* mig_external */ kern_return_t mach_port_get_set_status ( - ipc_space_inspect_t task, + ipc_space_read_t task, mach_port_name_t name, mach_port_name_array_t *members, mach_msg_type_number_t *membersCnt @@ -312,7 +312,7 @@ extern #endif /* mig_external */ kern_return_t mach_port_get_attributes ( - ipc_space_inspect_t task, + ipc_space_read_t task, mach_port_name_t name, mach_port_flavor_t flavor, mach_port_info_t port_info_out, @@ -398,7 +398,7 @@ extern #endif /* mig_external */ kern_return_t mach_port_space_info ( - ipc_space_inspect_t task, + ipc_space_read_t space, ipc_info_space_t *space_info, ipc_info_name_array_t *table_info, mach_msg_type_number_t *table_infoCnt, @@ -428,7 +428,7 @@ extern #endif /* mig_external */ kern_return_t mach_port_kernel_object ( - ipc_space_inspect_t task, + ipc_space_read_t task, mach_port_name_t name, unsigned *object_type, unsigned *object_addr @@ -468,7 +468,7 @@ extern #endif /* mig_external */ kern_return_t mach_port_get_context ( - ipc_space_inspect_t task, + ipc_space_read_t task, mach_port_name_t name, mach_port_context_t *context ); @@ -494,7 +494,7 @@ extern #endif /* mig_external */ kern_return_t mach_port_kobject ( - ipc_space_inspect_t task, + ipc_space_read_t task, mach_port_name_t name, natural_t *object_type, mach_vm_address_t *object_addr @@ -603,7 +603,7 @@ extern #endif /* mig_external */ kern_return_t mach_port_kobject_description ( - ipc_space_inspect_t task, + ipc_space_read_t task, mach_port_name_t name, natural_t *object_type, mach_vm_address_t *object_addr, diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h b/lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h index e38647c7a6..8be7b8968a 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h @@ -131,12 +131,6 @@ extern kern_return_t _kernelrpc_mach_port_allocate_trap( mach_port_name_t *name ); - -extern kern_return_t _kernelrpc_mach_port_destroy_trap( - mach_port_name_t target, - mach_port_name_t name - ); - extern kern_return_t _kernelrpc_mach_port_deallocate_trap( mach_port_name_t target, mach_port_name_t name diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_types.h b/lib/libc/include/x86_64-macos-gnu/mach/mach_types.h index bd4bc3424c..103a659070 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_types.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/mach_types.h @@ -117,12 +117,17 @@ */ typedef mach_port_t task_t; typedef mach_port_t task_name_t; +typedef mach_port_t task_policy_set_t; +typedef mach_port_t task_policy_get_t; typedef mach_port_t task_inspect_t; +typedef mach_port_t task_read_t; typedef mach_port_t task_suspension_token_t; typedef mach_port_t thread_t; typedef mach_port_t thread_act_t; typedef mach_port_t thread_inspect_t; +typedef mach_port_t thread_read_t; typedef mach_port_t ipc_space_t; +typedef mach_port_t ipc_space_read_t; typedef mach_port_t ipc_space_inspect_t; typedef mach_port_t coalition_t; typedef mach_port_t host_t; @@ -138,6 +143,8 @@ typedef mach_port_t alarm_t; typedef mach_port_t clock_serv_t; typedef mach_port_t clock_ctrl_t; typedef mach_port_t arcade_register_t; +typedef mach_port_t ipc_eventlink_t; +typedef mach_port_t eventlink_port_pair_t[2]; typedef mach_port_t suid_cred_t; @@ -159,6 +166,7 @@ typedef exception_handler_t *exception_handler_array_t; typedef mach_port_t vm_task_entry_t; typedef mach_port_t io_master_t; typedef mach_port_t UNDServerRef; +typedef mach_port_t mach_eventlink_t; /* * Mig doesn't translate the components of an array. @@ -212,12 +220,15 @@ typedef uint32_t suid_cred_uid_t; #define TASK_NULL ((task_t) 0) #define TASK_NAME_NULL ((task_name_t) 0) -#define TASK_INSPECT_NULL ((task_inspect_t) 0) +#define TASK_INSPECT_NULL ((task_inspect_t) 0) +#define TASK_READ_NULL ((task_read_t) 0) #define THREAD_NULL ((thread_t) 0) #define THREAD_INSPECT_NULL ((thread_inspect_t) 0) +#define THREAD_READ_NULL ((thread_read_t) 0) #define TID_NULL ((uint64_t) 0) #define THR_ACT_NULL ((thread_act_t) 0) #define IPC_SPACE_NULL ((ipc_space_t) 0) +#define IPC_SPACE_READ_NULL ((ipc_space_read_t) 0) #define IPC_SPACE_INSPECT_NULL ((ipc_space_inspect_t) 0) #define COALITION_NULL ((coalition_t) 0) #define HOST_NULL ((host_t) 0) @@ -232,7 +243,25 @@ typedef uint32_t suid_cred_uid_t; #define CLOCK_NULL ((clock_t) 0) #define UND_SERVER_NULL ((UNDServerRef) 0) #define ARCADE_REG_NULL ((arcade_register_t) 0) -#define SUID_CRED_NULL ((suid_cred_t) 0) +#define MACH_EVENTLINK_NULL ((mach_eventlink_t) 0) +#define IPC_EVENTLINK_NULL ((ipc_eventlink_t) 0) +#define SUID_CRED_NULL ((suid_cred_t) 0) + +/* capability strictly _DECREASING_. + * not ordered the other way around because we want TASK_FLAVOR_CONTROL + * to be closest to the itk_lock. see task.h. + */ +typedef unsigned int mach_task_flavor_t; +#define TASK_FLAVOR_CONTROL 0 /* a task_t */ +#define TASK_FLAVOR_READ 1 /* a task_read_t */ +#define TASK_FLAVOR_INSPECT 2 /* a task_inspect_t */ +#define TASK_FLAVOR_NAME 3 /* a task_name_t */ + +/* capability strictly _DECREASING_ */ +typedef unsigned int mach_thread_flavor_t; +#define THREAD_FLAVOR_CONTROL 0 /* a thread_t */ +#define THREAD_FLAVOR_READ 1 /* a thread_read_t */ +#define THREAD_FLAVOR_INSPECT 2 /* a thread_inspect_t */ /* DEPRECATED */ typedef natural_t ledger_item_t; diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine.h b/lib/libc/include/x86_64-macos-gnu/mach/machine.h index a209623264..53e12fe99a 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine.h @@ -118,6 +118,9 @@ typedef integer_t cpu_threadtype_t; #define CPU_TYPE_POWERPC ((cpu_type_t) 18) #define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64) /* skip ((cpu_type_t) 19) */ +/* skip ((cpu_type_t) 20 */ +/* skip ((cpu_type_t) 21 */ +/* skip ((cpu_type_t) 22 */ /* * Machine subtypes (these are defined here, instead of in a machine @@ -130,7 +133,14 @@ typedef integer_t cpu_threadtype_t; */ #define CPU_SUBTYPE_MASK 0xff000000 /* mask for feature flags */ #define CPU_SUBTYPE_LIB64 0x80000000 /* 64 bit libraries */ +#define CPU_SUBTYPE_PTRAUTH_ABI 0x80000000 /* pointer authentication with versioned ABI */ +/* + * When selecting a slice, ANY will pick the slice with the best + * grading for the selected cpu_type_t, unlike the "ALL" subtypes, + * which are the slices that can run on any hardware for that cpu type. + */ +#define CPU_SUBTYPE_ANY ((cpu_subtype_t) -1) /* * Object files that are hand-crafted to run on any @@ -365,9 +375,7 @@ typedef integer_t cpu_threadtype_t; #define CPUFAMILY_INTEL_BROADWELL 0x582ed09c #define CPUFAMILY_INTEL_SKYLAKE 0x37fc219f #define CPUFAMILY_INTEL_KABYLAKE 0x0f817246 -#if !defined(RC_HIDE_XNU_ICELAKE) #define CPUFAMILY_INTEL_ICELAKE 0x38435547 -#endif /* not RC_HIDE_XNU_ICELAKE */ #if !defined(RC_HIDE_XNU_COMETLAKE) #define CPUFAMILY_INTEL_COMETLAKE 0x1cf8a03e #endif /* not RC_HIDE_XNU_COMETLAKE */ @@ -386,6 +394,14 @@ typedef integer_t cpu_threadtype_t; #define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6 #define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f #define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2 +#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3 + +#define CPUSUBFAMILY_UNKNOWN 0 +#define CPUSUBFAMILY_ARM_HP 1 +#define CPUSUBFAMILY_ARM_HG 2 +#define CPUSUBFAMILY_ARM_M 3 +#define CPUSUBFAMILY_ARM_HS 4 +#define CPUSUBFAMILY_ARM_HC_HD 5 /* The following synonyms are deprecated: */ #define CPUFAMILY_INTEL_6_23 CPUFAMILY_INTEL_PENRYN diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h index e0bdc10828..858368fc5d 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/_structs.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/_structs.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h index 6423078b8b..dcc5d133f9 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/boolean.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/boolean.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h index 5a85bd37f3..b98d4b0ef7 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/exception.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/exception.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h index 276656cbc5..adae6e8bcb 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/kern_return.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/kern_return.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h index da865d7fc5..8150d716ac 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/processor_info.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/processor_info.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h index 196a1546d6..37f9024726 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/rpc.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/rpc.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h index 7dbfecefc3..06f38104cc 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/thread_state.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/thread_state.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h index 1c389658b0..3e319e8cef 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/thread_status.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/thread_status.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h index 08f4ac5fc9..dcc0ec5398 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/vm_param.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/vm_param.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h index 66cbebfda9..7f1605a277 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h @@ -31,6 +31,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "mach/i386/vm_types.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/vm_types.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/mach/message.h b/lib/libc/include/x86_64-macos-gnu/mach/message.h index 59e9fa07fb..7959fc7f26 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/message.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/message.h @@ -228,6 +228,7 @@ typedef unsigned int mach_msg_priority_t; #define MACH_MSG_PRIORITY_UNSPECIFIED (mach_msg_priority_t) 0 + typedef unsigned int mach_msg_type_name_t; #define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */ @@ -499,6 +500,9 @@ typedef struct{ mach_port_name_t sender; } msg_labels_t; +typedef int mach_msg_filter_id; +#define MACH_MSG_FILTER_POLICY_ALLOW (mach_msg_filter_id)0 + /* * Trailer type to pass MAC policy label info as a mach message trailer. * @@ -511,7 +515,7 @@ typedef struct{ security_token_t msgh_sender; audit_token_t msgh_audit; mach_port_context_t msgh_context; - int msgh_ad; + mach_msg_filter_id msgh_ad; msg_labels_t msgh_labels; } mach_msg_mac_trailer_t; @@ -799,6 +803,8 @@ typedef kern_return_t mach_msg_return_t; /* compatibility: no longer a returned error */ #define MACH_SEND_NO_GRANT_DEST 0x10000016 /* The destination port doesn't accept ports in body */ +#define MACH_SEND_MSG_FILTERED 0x10000017 +/* Message send was rejected by message filter */ #define MACH_RCV_IN_PROGRESS 0x10004001 /* Thread is waiting for receive. (Internal use only.) */ diff --git a/lib/libc/include/x86_64-macos-gnu/mach/port.h b/lib/libc/include/x86_64-macos-gnu/mach/port.h index bd1fc19fd4..2865602b0c 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/port.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/port.h @@ -339,6 +339,9 @@ typedef struct mach_port_qos { #define MPO_STRICT 0x20 /* Apply strict guarding for port */ #define MPO_DENAP_RECEIVER 0x40 /* Mark the port as App de-nap receiver */ #define MPO_IMMOVABLE_RECEIVE 0x80 /* Mark the port as immovable; protected by the guard context */ +#define MPO_FILTER_MSG 0x100 /* Allow message filtering */ +#define MPO_TG_BLOCK_TRACKING 0x200 /* Track blocking relationship for thread group during sync IPC */ + /* * Structure to define optional attributes for a newly * constructed port. @@ -346,7 +349,10 @@ typedef struct mach_port_qos { typedef struct mach_port_options { uint32_t flags; /* Flags defining attributes for port */ mach_port_limits_t mpl; /* Message queue limit for port */ - uint64_t reserved[2]; /* Reserved */ + union { + uint64_t reserved[2]; /* Reserved */ + mach_port_name_t work_interval_port; /* Work interval port */ + }; }mach_port_options_t; typedef mach_port_options_t *mach_port_options_ptr_t; @@ -367,6 +373,7 @@ enum mach_port_guard_exception_codes { kGUARD_EXC_INCORRECT_GUARD = 1u << 4, kGUARD_EXC_IMMOVABLE = 1u << 5, kGUARD_EXC_STRICT_REPLY = 1u << 6, + kGUARD_EXC_MSG_FILTERED = 1u << 7, /* start of [optionally] non-fatal guards */ kGUARD_EXC_INVALID_RIGHT = 1u << 8, kGUARD_EXC_INVALID_NAME = 1u << 9, diff --git a/lib/libc/include/x86_64-macos-gnu/mach/processor_set.h b/lib/libc/include/x86_64-macos-gnu/mach/processor_set.h index c306155ff2..c840a73fc5 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/processor_set.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/processor_set.h @@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t; #endif /* AUTOTEST */ #ifndef processor_set_MSG_COUNT -#define processor_set_MSG_COUNT 10 +#define processor_set_MSG_COUNT 11 #endif /* processor_set_MSG_COUNT */ #include @@ -200,6 +200,20 @@ kern_return_t processor_set_info mach_msg_type_number_t *info_outCnt ); +/* Routine processor_set_tasks_with_flavor */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_tasks_with_flavor +( + processor_set_t processor_set, + mach_task_flavor_t flavor, + task_array_t *task_list, + mach_msg_type_number_t *task_listCnt +); + __END_DECLS /********************** Caution **************************/ @@ -336,6 +350,18 @@ __END_DECLS #ifdef __MigPackStructs #pragma pack(pop) #endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_task_flavor_t flavor; + } __Request__processor_set_tasks_with_flavor_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif #endif /* !__Request__processor_set_subsystem__defined */ /* union of all requests */ @@ -353,6 +379,7 @@ union __RequestUnion__processor_set_subsystem { __Request__processor_set_policy_control_t Request_processor_set_policy_control; __Request__processor_set_stack_usage_t Request_processor_set_stack_usage; __Request__processor_set_info_t Request_processor_set_info; + __Request__processor_set_tasks_with_flavor_t Request_processor_set_tasks_with_flavor; }; #endif /* !__RequestUnion__processor_set_subsystem__defined */ /* typedefs for all replies */ @@ -499,6 +526,22 @@ union __RequestUnion__processor_set_subsystem { #ifdef __MigPackStructs #pragma pack(pop) #endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t task_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t task_listCnt; + } __Reply__processor_set_tasks_with_flavor_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif #endif /* !__Reply__processor_set_subsystem__defined */ /* union of all replies */ @@ -516,6 +559,7 @@ union __ReplyUnion__processor_set_subsystem { __Reply__processor_set_policy_control_t Reply_processor_set_policy_control; __Reply__processor_set_stack_usage_t Reply_processor_set_stack_usage; __Reply__processor_set_info_t Reply_processor_set_info; + __Reply__processor_set_tasks_with_flavor_t Reply_processor_set_tasks_with_flavor; }; #endif /* !__RequestUnion__processor_set_subsystem__defined */ @@ -530,7 +574,8 @@ union __ReplyUnion__processor_set_subsystem { { "processor_set_threads", 4006 },\ { "processor_set_policy_control", 4007 },\ { "processor_set_stack_usage", 4008 },\ - { "processor_set_info", 4009 } + { "processor_set_info", 4009 },\ + { "processor_set_tasks_with_flavor", 4010 } #endif #ifdef __AfterMigUserHeader diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task.h b/lib/libc/include/x86_64-macos-gnu/mach/task.h index 20019654bb..0065500c12 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/task.h @@ -279,7 +279,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t task_get_exception_ports ( - task_inspect_t task, + task_t task, exception_mask_t exception_mask, exception_mask_array_t masks, mach_msg_type_number_t *masksCnt, @@ -372,7 +372,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t task_policy_set ( - task_t task, + task_policy_set_t task, task_policy_flavor_t flavor, task_policy_t policy_info, mach_msg_type_number_t policy_infoCnt @@ -388,7 +388,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t task_policy_get ( - task_t task, + task_policy_get_t task, task_policy_flavor_t flavor, task_policy_t policy_info, mach_msg_type_number_t *policy_infoCnt, @@ -487,7 +487,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t task_zone_info ( - task_t target_task, + task_inspect_t target_task, mach_zone_name_array_t *names, mach_msg_type_number_t *namesCnt, task_zone_info_array_t *info, @@ -527,7 +527,7 @@ extern #endif /* mig_external */ kern_return_t task_get_assignment ( - task_t task, + task_inspect_t task, processor_set_name_t *assigned_set ); @@ -559,7 +559,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t task_get_state ( - task_t task, + task_read_t task, thread_state_flavor_t flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt @@ -631,7 +631,7 @@ extern #endif /* mig_external */ kern_return_t task_purgable_info ( - task_t task, + task_inspect_t task, task_purgable_info_t *stats ); @@ -645,7 +645,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t task_get_mach_voucher ( - task_t task, + task_read_t task, mach_voucher_selector_t which, ipc_voucher_t *voucher ); @@ -700,7 +700,7 @@ extern kern_return_t task_map_corpse_info ( task_t task, - task_t corspe_task, + task_read_t corspe_task, vm_address_t *kcd_addr_begin, uint32_t *kcd_size ); @@ -739,7 +739,7 @@ extern #endif /* mig_external */ kern_return_t task_get_dyld_image_infos ( - task_inspect_t task, + task_read_t task, dyld_kernel_image_info_array_t *dyld_images, mach_msg_type_number_t *dyld_imagesCnt ); @@ -791,7 +791,7 @@ extern kern_return_t task_map_corpse_info_64 ( task_t task, - task_t corspe_task, + task_read_t corspe_task, mach_vm_address_t *kcd_addr_begin, mach_vm_size_t *kcd_size ); @@ -1022,7 +1022,7 @@ __END_DECLS NDR_record_t NDR; thread_state_flavor_t flavor; mach_msg_type_number_t new_stateCnt; - natural_t new_state[614]; + natural_t new_state[1296]; } __Request__thread_create_running_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) @@ -1331,7 +1331,7 @@ __END_DECLS NDR_record_t NDR; thread_state_flavor_t flavor; mach_msg_type_number_t new_stateCnt; - natural_t new_state[614]; + natural_t new_state[1296]; } __Request__task_set_state_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) @@ -2111,7 +2111,7 @@ union __RequestUnion__task_subsystem { NDR_record_t NDR; kern_return_t RetCode; mach_msg_type_number_t old_stateCnt; - natural_t old_state[614]; + natural_t old_state[1296]; } __Reply__task_get_state_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task_info.h b/lib/libc/include/x86_64-macos-gnu/mach/task_info.h index 86cfdb3492..d243343f5f 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task_info.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/task_info.h @@ -112,8 +112,13 @@ typedef struct task_basic_info_32 *task_basic_info_32_t; /* Don't use this, use MACH_TASK_BASIC_INFO instead */ struct task_basic_info_64 { integer_t suspend_count; /* suspend count for task */ +#if defined(__arm__) || defined(__arm64__) mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ mach_vm_size_t resident_size; /* resident memory size (bytes) */ +#else /* defined(__arm__) || defined(__arm64__) */ + mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ + mach_vm_size_t resident_size; /* resident memory size (bytes) */ +#endif /* defined(__arm__) || defined(__arm64__) */ time_value_t user_time; /* total user run time for * terminated threads */ time_value_t system_time; /* total system run time for @@ -123,9 +128,26 @@ struct task_basic_info_64 { typedef struct task_basic_info_64 task_basic_info_64_data_t; typedef struct task_basic_info_64 *task_basic_info_64_t; +#if defined(__arm__) || defined(__arm64__) + #if defined(__arm__) && defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0) +/* + * Note: arm64 can't use the old flavor. If you somehow manage to, + * you can cope with the nonsense data yourself. + */ + #define TASK_BASIC_INFO_64 5 + #define TASK_BASIC_INFO_64_COUNT \ + (sizeof(task_basic_info_64_data_t) / sizeof(natural_t)) + + #else + + #define TASK_BASIC_INFO_64 TASK_BASIC_INFO_64_2 + #define TASK_BASIC_INFO_64_COUNT TASK_BASIC_INFO_64_2_COUNT + #endif +#else /* defined(__arm__) || defined(__arm64__) */ #define TASK_BASIC_INFO_64 5 /* 64-bit capable basic info */ #define TASK_BASIC_INFO_64_COUNT \ (sizeof(task_basic_info_64_data_t) / sizeof(natural_t)) +#endif /* localized structure - cannot be safely passed between tasks of differing sizes */ @@ -249,6 +271,27 @@ typedef struct task_dyld_info *task_dyld_info_t; #define TASK_DYLD_ALL_IMAGE_INFO_32 0 /* format value */ #define TASK_DYLD_ALL_IMAGE_INFO_64 1 /* format value */ +#if defined(__arm__) || defined(__arm64__) + +/* Don't use this, use MACH_TASK_BASIC_INFO instead */ +/* Compatibility for old 32-bit mach_vm_*_t */ +#define TASK_BASIC_INFO_64_2 18 /* 64-bit capable basic info */ + +struct task_basic_info_64_2 { + integer_t suspend_count; /* suspend count for task */ + mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ + mach_vm_size_t resident_size; /* resident memory size (bytes) */ + time_value_t user_time; /* total user run time for + * terminated threads */ + time_value_t system_time; /* total system run time for + * terminated threads */ + policy_t policy; /* default policy for new threads */ +}; +typedef struct task_basic_info_64_2 task_basic_info_64_2_data_t; +typedef struct task_basic_info_64_2 *task_basic_info_64_2_t; +#define TASK_BASIC_INFO_64_2_COUNT \ + (sizeof(task_basic_info_64_2_data_t) / sizeof(natural_t)) +#endif #define TASK_EXTMOD_INFO 19 @@ -377,7 +420,7 @@ typedef struct task_vm_info *task_vm_info_t; typedef struct vm_purgeable_info task_purgable_info_t; -#define TASK_TRACE_MEMORY_INFO 24 +#define TASK_TRACE_MEMORY_INFO 24 /* no longer supported */ struct task_trace_memory_info { uint64_t user_memory_address; /* address of start of trace memory buffer */ uint64_t buffer_size; /* size of buffer in bytes */ @@ -412,6 +455,9 @@ typedef gpu_energy_data *gpu_energy_data_t; struct task_power_info_v2 { task_power_info_data_t cpu_energy; gpu_energy_data gpu_energy; +#if defined(__arm__) || defined(__arm64__) + uint64_t task_energy; +#endif /* defined(__arm__) || defined(__arm64__) */ uint64_t task_ptime; uint64_t task_pset_switches; }; diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task_policy.h b/lib/libc/include/x86_64-macos-gnu/mach/task_policy.h index 04970a5b63..9e2cb4e7da 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task_policy.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/task_policy.h @@ -110,8 +110,7 @@ typedef integer_t *task_policy_t; #define TASK_BASE_LATENCY_QOS_POLICY 10 #define TASK_BASE_THROUGHPUT_QOS_POLICY 11 - -enum task_role { +typedef enum task_role { TASK_RENICED = -1, TASK_UNSPECIFIED = 0, TASK_FOREGROUND_APPLICATION = 1, @@ -122,9 +121,7 @@ enum task_role { TASK_NONUI_APPLICATION = 6, TASK_DEFAULT_APPLICATION = 7, TASK_DARWINBG_APPLICATION = 8, -}; - -typedef integer_t task_role_t; +} task_role_t; struct task_category_policy { task_role_t role; diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h b/lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h index ded90941a4..dea0f9d6dc 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h @@ -69,18 +69,19 @@ typedef int task_special_port_t; -#define TASK_KERNEL_PORT 1 /* Represents task to the outside - * world.*/ +#define TASK_KERNEL_PORT 1 /* The full task port for task. */ #define TASK_HOST_PORT 2 /* The host (priv) port for task. */ -#define TASK_NAME_PORT 3 /* the name (unpriv) port for task */ +#define TASK_NAME_PORT 3 /* The name port for task. */ #define TASK_BOOTSTRAP_PORT 4 /* Bootstrap environment for task. */ -/* - * Evolving and likely to change. - */ +#define TASK_INSPECT_PORT 5 /* The inspect port for task. */ + +#define TASK_READ_PORT 6 /* The read port for task. */ + + #define TASK_SEATBELT_PORT 7 /* Seatbelt compiler/DEM port for task. */ diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_act.h b/lib/libc/include/x86_64-macos-gnu/mach/thread_act.h index 5a21aa7e81..7f7608476b 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_act.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/thread_act.h @@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t; #endif /* AUTOTEST */ #ifndef thread_act_MSG_COUNT -#define thread_act_MSG_COUNT 28 +#define thread_act_MSG_COUNT 29 #endif /* thread_act_MSG_COUNT */ #include @@ -88,7 +88,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t act_get_state ( - thread_act_t target_act, + thread_read_t target_act, int flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt @@ -119,7 +119,7 @@ extern __WATCHOS_PROHIBITED kern_return_t thread_get_state ( - thread_act_t target_act, + thread_read_t target_act, thread_state_flavor_t flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt @@ -211,7 +211,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t thread_get_special_port ( - thread_act_t thr_act, + thread_inspect_t thr_act, int which_port, mach_port_t *special_port ); @@ -272,7 +272,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t thread_get_exception_ports ( - thread_inspect_t thread, + thread_act_t thread, exception_mask_t exception_mask, exception_mask_array_t masks, mach_msg_type_number_t *masksCnt, @@ -402,7 +402,7 @@ extern #endif /* mig_external */ kern_return_t thread_get_assignment ( - thread_act_t thread, + thread_inspect_t thread, processor_set_name_t *assigned_set ); @@ -433,7 +433,7 @@ __WATCHOS_PROHIBITED __TVOS_PROHIBITED kern_return_t thread_get_mach_voucher ( - thread_act_t thr_act, + thread_read_t thr_act, mach_voucher_selector_t which, ipc_voucher_t *voucher ); @@ -467,6 +467,23 @@ kern_return_t thread_swap_mach_voucher ipc_voucher_t *old_voucher ); +/* Routine thread_convert_thread_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_convert_thread_state +( + thread_act_t thread, + int direction, + thread_state_flavor_t flavor, + thread_state_t in_state, + mach_msg_type_number_t in_stateCnt, + thread_state_t out_state, + mach_msg_type_number_t *out_stateCnt +); + __END_DECLS /********************** Caution **************************/ @@ -516,7 +533,7 @@ __END_DECLS NDR_record_t NDR; int flavor; mach_msg_type_number_t new_stateCnt; - natural_t new_state[614]; + natural_t new_state[1296]; } __Request__act_set_state_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) @@ -543,7 +560,7 @@ __END_DECLS NDR_record_t NDR; thread_state_flavor_t flavor; mach_msg_type_number_t new_stateCnt; - natural_t new_state[614]; + natural_t new_state[1296]; } __Request__thread_set_state_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) @@ -851,6 +868,22 @@ __END_DECLS #ifdef __MigPackStructs #pragma pack(pop) #endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int direction; + thread_state_flavor_t flavor; + mach_msg_type_number_t in_stateCnt; + natural_t in_state[1296]; + mach_msg_type_number_t out_stateCnt; + } __Request__thread_convert_thread_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif #endif /* !__Request__thread_act_subsystem__defined */ /* union of all requests */ @@ -886,6 +919,7 @@ union __RequestUnion__thread_act_subsystem { __Request__thread_get_mach_voucher_t Request_thread_get_mach_voucher; __Request__thread_set_mach_voucher_t Request_thread_set_mach_voucher; __Request__thread_swap_mach_voucher_t Request_thread_swap_mach_voucher; + __Request__thread_convert_thread_state_t Request_thread_convert_thread_state; }; #endif /* !__RequestUnion__thread_act_subsystem__defined */ /* typedefs for all replies */ @@ -913,7 +947,7 @@ union __RequestUnion__thread_act_subsystem { NDR_record_t NDR; kern_return_t RetCode; mach_msg_type_number_t old_stateCnt; - natural_t old_state[614]; + natural_t old_state[1296]; } __Reply__act_get_state_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) @@ -939,7 +973,7 @@ union __RequestUnion__thread_act_subsystem { NDR_record_t NDR; kern_return_t RetCode; mach_msg_type_number_t old_stateCnt; - natural_t old_state[614]; + natural_t old_state[1296]; } __Reply__thread_get_state_t __attribute__((unused)); #ifdef __MigPackStructs #pragma pack(pop) @@ -1259,6 +1293,20 @@ union __RequestUnion__thread_act_subsystem { #ifdef __MigPackStructs #pragma pack(pop) #endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t out_stateCnt; + natural_t out_state[1296]; + } __Reply__thread_convert_thread_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif #endif /* !__Reply__thread_act_subsystem__defined */ /* union of all replies */ @@ -1294,6 +1342,7 @@ union __ReplyUnion__thread_act_subsystem { __Reply__thread_get_mach_voucher_t Reply_thread_get_mach_voucher; __Reply__thread_set_mach_voucher_t Reply_thread_set_mach_voucher; __Reply__thread_swap_mach_voucher_t Reply_thread_swap_mach_voucher; + __Reply__thread_convert_thread_state_t Reply_thread_convert_thread_state; }; #endif /* !__RequestUnion__thread_act_subsystem__defined */ @@ -1326,7 +1375,8 @@ union __ReplyUnion__thread_act_subsystem { { "thread_set_policy", 3624 },\ { "thread_get_mach_voucher", 3625 },\ { "thread_set_mach_voucher", 3626 },\ - { "thread_swap_mach_voucher", 3627 } + { "thread_swap_mach_voucher", 3627 },\ + { "thread_convert_thread_state", 3628 } #endif #ifdef __AfterMigUserHeader diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h b/lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h index 02199835a4..7bb1bea5ae 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h @@ -67,8 +67,11 @@ #ifndef _MACH_THREAD_SPECIAL_PORTS_H_ #define _MACH_THREAD_SPECIAL_PORTS_H_ -#define THREAD_KERNEL_PORT 1 /* Represents the thread to the outside - * world.*/ +#define THREAD_KERNEL_PORT 1 /* The full thread port for thread. */ + +#define THREAD_INSPECT_PORT 2 /* The inspect port for thread. */ + +#define THREAD_READ_PORT 3 /* The read port for thread. */ /* * Definitions for ease of use diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_status.h b/lib/libc/include/x86_64-macos-gnu/mach/thread_status.h index a91b936eba..7ccb65d6a1 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_status.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/thread_status.h @@ -94,4 +94,7 @@ typedef natural_t thread_state_data_t[THREAD_STATE_MAX]; typedef int thread_state_flavor_t; typedef thread_state_flavor_t *thread_state_flavor_array_t; +#define THREAD_CONVERT_THREAD_STATE_TO_SELF 1 +#define THREAD_CONVERT_THREAD_STATE_FROM_SELF 2 + #endif /* _MACH_THREAD_STATUS_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h b/lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h index 8914da2372..5046c6bc7a 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h @@ -149,4 +149,5 @@ typedef int vm_prot_t; #define VM_PROT_STRIP_READ ((vm_prot_t) 0x80) #define VM_PROT_EXECUTE_ONLY (VM_PROT_EXECUTE|VM_PROT_STRIP_READ) + #endif /* _MACH_VM_PROT_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h b/lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h index 0a2ee5b74c..1d9ba2a4d1 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * Copyright (c) 2000-2020 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -66,8 +66,12 @@ #ifndef _MACH_VM_STATISTICS_H_ #define _MACH_VM_STATISTICS_H_ -#include +#ifdef __cplusplus +extern "C" { +#endif +#include +#include /* * vm_statistics @@ -167,6 +171,8 @@ struct vm_statistics64 { typedef struct vm_statistics64 *vm_statistics64_t; typedef struct vm_statistics64 vm_statistics64_data_t; +kern_return_t vm_stats(void *info, unsigned int *count); + /* * VM_STATISTICS_TRUNCATE_TO_32_BIT * @@ -352,6 +358,7 @@ enum virtual_memory_guard_exception_codes { #define VM_MEMORY_MALLOC_NANO 11 #define VM_MEMORY_MALLOC_MEDIUM 12 +#define VM_MEMORY_MALLOC_PGUARD 13 #define VM_MEMORY_MACH_MSG 20 #define VM_MEMORY_IOKIT 21 @@ -512,6 +519,22 @@ enum virtual_memory_guard_exception_codes { /* memory allocated by CoreMedia for global image registration of frames */ #define VM_MEMORY_CM_REGWARP 101 +/* memory allocated by EmbeddedAcousticRecognition for speech decoder */ +#define VM_MEMORY_EAR_DECODER 102 + +/* CoreUI cached image data */ +#define VM_MEMORY_COREUI_CACHED_IMAGE_DATA 103 + +/* Reserve 230-239 for Rosetta */ +#define VM_MEMORY_ROSETTA 230 +#define VM_MEMORY_ROSETTA_THREAD_CONTEXT 231 +#define VM_MEMORY_ROSETTA_INDIRECT_BRANCH_MAP 232 +#define VM_MEMORY_ROSETTA_RETURN_STACK 233 +#define VM_MEMORY_ROSETTA_EXECUTABLE_HEAP 234 +#define VM_MEMORY_ROSETTA_USER_LDT 235 +#define VM_MEMORY_ROSETTA_ARENA 236 +#define VM_MEMORY_ROSETTA_10 239 + /* Reserve 240-255 for application */ #define VM_MEMORY_APPLICATION_SPECIFIC_1 240 #define VM_MEMORY_APPLICATION_SPECIFIC_16 255 @@ -520,4 +543,8 @@ enum virtual_memory_guard_exception_codes { +#ifdef __cplusplus +} +#endif + #endif /* _MACH_VM_STATISTICS_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_types.h b/lib/libc/include/x86_64-macos-gnu/mach/vm_types.h index 1367f255b0..b65a36847b 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_types.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/vm_types.h @@ -70,10 +70,12 @@ typedef uint32_t ppnum_t; /* Physical page number */ -typedef mach_port_t vm_map_t; +typedef mach_port_t vm_map_t, vm_map_read_t, vm_map_inspect_t; #define VM_MAP_NULL ((vm_map_t) 0) +#define VM_MAP_INSPECT_NULL ((vm_map_inspect_t) 0) +#define VM_MAP_READ_NULL ((vm_map_read_t) 0) /* * Evolving definitions, likely to change. diff --git a/lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h b/lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h index 27ac45190e..dc98841eb9 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h @@ -27,6 +27,8 @@ */ #if defined (__i386__) || defined (__x86_64__) #include "i386/_mcontext.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/_mcontext.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/machine/_param.h b/lib/libc/include/x86_64-macos-gnu/machine/_param.h index c8e35a1c29..c6a6028b17 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/_param.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/_param.h @@ -26,7 +26,9 @@ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #if defined (__i386__) || defined (__x86_64__) -#include "i386/_param.h" +#include +#elif defined (__arm__) || defined (__arm64__) +#include #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/machine/_types.h b/lib/libc/include/x86_64-macos-gnu/machine/_types.h index 2873a84a85..47dbe8c188 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/_types.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/_types.h @@ -30,6 +30,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "i386/_types.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/_types.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/machine/endian.h b/lib/libc/include/x86_64-macos-gnu/machine/endian.h index 4bbc8c4df8..682a15155d 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/endian.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/endian.h @@ -33,6 +33,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "i386/endian.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/endian.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/machine/limits.h b/lib/libc/include/x86_64-macos-gnu/machine/limits.h index bfe42ba649..7ae09a12e0 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/limits.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/limits.h @@ -4,6 +4,8 @@ * This file is public domain. */ #if defined (__i386__) || defined(__x86_64__) #include +#elif defined (__arm__) || defined (__arm64__) +#include #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/machine/param.h b/lib/libc/include/x86_64-macos-gnu/machine/param.h index 10f8f6332e..5b69eeb337 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/param.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/param.h @@ -32,7 +32,9 @@ #define _BSD_MACHINE_PARAM_H_ #if defined (__i386__) || defined(__x86_64__) -#include "i386/param.h" +#include +#elif defined (__arm__) || defined (__arm64__) +#include #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/machine/signal.h b/lib/libc/include/x86_64-macos-gnu/machine/signal.h index def4d744b7..d8a6a2433e 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/signal.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/signal.h @@ -30,6 +30,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "i386/signal.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/signal.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/machine/types.h b/lib/libc/include/x86_64-macos-gnu/machine/types.h index a991f733e5..e2241c06c3 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/types.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/types.h @@ -33,6 +33,8 @@ #if defined (__i386__) || defined(__x86_64__) #include "i386/types.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/types.h" #else #error architecture not supported #endif diff --git a/lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h b/lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h index c0270235da..8c0d4cadd6 100644 --- a/lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h +++ b/lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h @@ -44,9 +44,9 @@ void *realloc(void *__ptr, size_t __size) __result_use_check __alloc_size(2); #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) void *valloc(size_t) __alloc_size(1); #endif // !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) -#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) && \ - ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ - (defined(__cplusplus) && __cplusplus >= 201703L)) +#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + (defined(__cplusplus) && __cplusplus >= 201703L) void *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); #endif int posix_memalign(void **__memptr, size_t __alignment, size_t __size) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0); diff --git a/lib/libc/include/x86_64-macos-gnu/math.h b/lib/libc/include/x86_64-macos-gnu/math.h index 535d7b5976..bb92c5ba15 100644 --- a/lib/libc/include/x86_64-macos-gnu/math.h +++ b/lib/libc/include/x86_64-macos-gnu/math.h @@ -547,6 +547,7 @@ extern long double fmal(long double, long double, long double); #define islessgreater(x, y) __builtin_islessgreater((x),(y)) #define isunordered(x, y) __builtin_isunordered((x),(y)) +#if defined __i386__ || defined __x86_64__ /* Deprecated functions; use the INFINITY and NAN macros instead. */ extern float __inff(void) __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) __API_DEPRECATED("use `(long double)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); extern float __nan(void) __API_DEPRECATED("use `NAN` instead", macos(10.0, 10.14)) __API_UNAVAILABLE(ios, watchos, tvos); +#endif /****************************************************************************** * Reentrant variants of lgamma[fl] * @@ -736,6 +738,7 @@ extern int signgam; #define TLOSS 5 #define PLOSS 6 +#if defined __i386__ || defined __x86_64__ /* Legacy BSD API; use the C99 `lrint( )` function instead. */ extern long int rinttol(double) __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 /* Legacy BSD API; use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead. */ extern double significand(double) __API_DEPRECATED("Use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead.", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +#endif #if !defined __cplusplus struct exception { diff --git a/lib/libc/include/x86_64-macos-gnu/net/if.h b/lib/libc/include/x86_64-macos-gnu/net/if.h index 946332ff00..d92581cf2f 100644 --- a/lib/libc/include/x86_64-macos-gnu/net/if.h +++ b/lib/libc/include/x86_64-macos-gnu/net/if.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * Copyright (c) 2000-2020 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * diff --git a/lib/libc/include/x86_64-macos-gnu/net/if_var.h b/lib/libc/include/x86_64-macos-gnu/net/if_var.h index 4787d9e145..3e3d801f1e 100644 --- a/lib/libc/include/x86_64-macos-gnu/net/if_var.h +++ b/lib/libc/include/x86_64-macos-gnu/net/if_var.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * Copyright (c) 2000-2020 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -70,6 +70,7 @@ #include #include /* get TAILQ macros */ #ifdef BSD_KERN_PRIVATE +#include #include #endif diff --git a/lib/libc/include/x86_64-macos-gnu/netinet/in.h b/lib/libc/include/x86_64-macos-gnu/netinet/in.h index 0fc452a587..bc41ef5563 100644 --- a/lib/libc/include/x86_64-macos-gnu/netinet/in.h +++ b/lib/libc/include/x86_64-macos-gnu/netinet/in.h @@ -63,14 +63,14 @@ #ifndef _NETINET_IN_H_ #define _NETINET_IN_H_ + #include -#include #include /* uint(8|16|32)_t */ #include -#include +#include #include /* @@ -435,6 +435,7 @@ struct ip_opts { #define IP_PKTINFO 26 /* get pktinfo on recv socket, set src on sent dgram */ #define IP_RECVPKTINFO IP_PKTINFO /* receive pktinfo w/dgram */ #define IP_RECVTOS 27 /* bool; receive IP TOS w/dgram */ +#define IP_DONTFRAG 28 /* don't fragment packet */ #define IP_FW_ADD 40 /* add a firewall rule to chain */ #define IP_FW_DEL 41 /* delete a firewall rule from chain */ diff --git a/lib/libc/include/x86_64-macos-gnu/netinet/tcp.h b/lib/libc/include/x86_64-macos-gnu/netinet/tcp.h index 4a716d498b..afd36ffd6f 100644 --- a/lib/libc/include/x86_64-macos-gnu/netinet/tcp.h +++ b/lib/libc/include/x86_64-macos-gnu/netinet/tcp.h @@ -63,11 +63,13 @@ #ifndef _NETINET_TCP_H_ #define _NETINET_TCP_H_ -#include #include + #include #include /* __uint32_t */ +#include + #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) typedef __uint32_t tcp_seq; typedef __uint32_t tcp_cc; /* connection count per rfc1644 */ diff --git a/lib/libc/include/x86_64-macos-gnu/netinet6/in6.h b/lib/libc/include/x86_64-macos-gnu/netinet6/in6.h index fc4550f3fc..7f7d3fc75b 100644 --- a/lib/libc/include/x86_64-macos-gnu/netinet6/in6.h +++ b/lib/libc/include/x86_64-macos-gnu/netinet6/in6.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2018 Apple Inc. All rights reserved. + * Copyright (c) 2008-2020 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -98,6 +98,7 @@ #ifndef _NETINET6_IN6_H_ #define _NETINET6_IN6_H_ #include + #include #include @@ -178,6 +179,7 @@ struct sockaddr_in6 { + /* * Definition of some useful macros to handle IP6 addresses */ @@ -206,6 +208,7 @@ struct sockaddr_in6 { #define IN6ADDR_V4MAPPED_INIT \ {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}} +#define IN6ADDR_MULTICAST_PREFIX IN6MASK8 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ extern const struct in6_addr in6addr_any; @@ -297,6 +300,16 @@ extern const struct in6_addr in6addr_linklocal_allv2routers; */ #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) +#define IPV6_ADDR_MC_FLAGS(a) ((a)->s6_addr[1] & 0xf0) + +#define IPV6_ADDR_MC_FLAGS_TRANSIENT 0x10 +#define IPV6_ADDR_MC_FLAGS_PREFIX 0x20 +#define IPV6_ADDR_MC_FLAGS_UNICAST_BASED (IPV6_ADDR_MC_FLAGS_TRANSIENT | IPV6_ADDR_MC_FLAGS_PREFIX) + +#define IN6_IS_ADDR_UNICAST_BASED_MULTICAST(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_FLAGS(a) == IPV6_ADDR_MC_FLAGS_UNICAST_BASED)) + /* * Unique Local IPv6 Unicast Addresses (per RFC 4193) */ @@ -311,8 +324,9 @@ extern const struct in6_addr in6addr_linklocal_allv2routers; #define IN6_IS_ADDR_MC_NODELOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && \ (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL)) -#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) && \ +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_FLAGS(a) != IPV6_ADDR_MC_FLAGS_UNICAST_BASED) && \ (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL)) #define IN6_IS_ADDR_MC_SITELOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && \ @@ -369,9 +383,9 @@ extern const struct in6_addr in6addr_linklocal_allv2routers; #define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */ #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ #define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */ -#define IPV6_MULTICAST_IF 9 /* __uint8_t; set/get IP6 multicast i/f */ -#define IPV6_MULTICAST_HOPS 10 /* __uint8_t; set/get IP6 multicast hops */ -#define IPV6_MULTICAST_LOOP 11 /* __uint8_t; set/get IP6 mcast loopback */ +#define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */ +#define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */ +#define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 mcast loopback */ #define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */ #define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */ @@ -663,5 +677,5 @@ extern int inet6_rth_segments(const void *); extern struct in6_addr *inet6_rth_getaddr(const void *, int); __END_DECLS -#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#endif /* PLATFORM_DriverKit */ #endif /* !_NETINET6_IN6_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/objc/NSObjCRuntime.h b/lib/libc/include/x86_64-macos-gnu/objc/NSObjCRuntime.h new file mode 100644 index 0000000000..ab0b6b9b75 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/objc/NSObjCRuntime.h @@ -0,0 +1,33 @@ +/* NSObjCRuntime.h + Copyright (c) 1994-2012, Apple Inc. All rights reserved. +*/ + +#ifndef _OBJC_NSOBJCRUNTIME_H_ +#define _OBJC_NSOBJCRUNTIME_H_ + +#include +#include + +#if __LP64__ || 0 || NS_BUILD_32_LIKE_64 +typedef long NSInteger; +typedef unsigned long NSUInteger; +#else +typedef int NSInteger; +typedef unsigned int NSUInteger; +#endif + +#define NSIntegerMax LONG_MAX +#define NSIntegerMin LONG_MIN +#define NSUIntegerMax ULONG_MAX + +#define NSINTEGER_DEFINED 1 + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/objc/NSObject.h b/lib/libc/include/x86_64-macos-gnu/objc/NSObject.h new file mode 100644 index 0000000000..2172abaf4e --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/objc/NSObject.h @@ -0,0 +1,112 @@ +/* NSObject.h + Copyright (c) 1994-2012, Apple Inc. All rights reserved. +*/ + +#ifndef _OBJC_NSOBJECT_H_ +#define _OBJC_NSOBJECT_H_ + +#if __OBJC__ + +#include +#include + +@class NSString, NSMethodSignature, NSInvocation; + +@protocol NSObject + +- (BOOL)isEqual:(id)object; +@property (readonly) NSUInteger hash; + +@property (readonly) Class superclass; +- (Class)class OBJC_SWIFT_UNAVAILABLE("use 'type(of: anObject)' instead"); +- (instancetype)self; + +- (id)performSelector:(SEL)aSelector; +- (id)performSelector:(SEL)aSelector withObject:(id)object; +- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2; + +- (BOOL)isProxy; + +- (BOOL)isKindOfClass:(Class)aClass; +- (BOOL)isMemberOfClass:(Class)aClass; +- (BOOL)conformsToProtocol:(Protocol *)aProtocol; + +- (BOOL)respondsToSelector:(SEL)aSelector; + +- (instancetype)retain OBJC_ARC_UNAVAILABLE; +- (oneway void)release OBJC_ARC_UNAVAILABLE; +- (instancetype)autorelease OBJC_ARC_UNAVAILABLE; +- (NSUInteger)retainCount OBJC_ARC_UNAVAILABLE; + +- (struct _NSZone *)zone OBJC_ARC_UNAVAILABLE; + +@property (readonly, copy) NSString *description; +@optional +@property (readonly, copy) NSString *debugDescription; + +@end + + +OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0) +OBJC_ROOT_CLASS +OBJC_EXPORT +@interface NSObject { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-interface-ivars" + Class isa OBJC_ISA_AVAILABILITY; +#pragma clang diagnostic pop +} + ++ (void)load; + ++ (void)initialize; +- (instancetype)init +#if NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER + NS_DESIGNATED_INITIALIZER +#endif + ; + ++ (instancetype)new OBJC_SWIFT_UNAVAILABLE("use object initializers instead"); ++ (instancetype)allocWithZone:(struct _NSZone *)zone OBJC_SWIFT_UNAVAILABLE("use object initializers instead"); ++ (instancetype)alloc OBJC_SWIFT_UNAVAILABLE("use object initializers instead"); +- (void)dealloc OBJC_SWIFT_UNAVAILABLE("use 'deinit' to define a de-initializer"); + +- (void)finalize OBJC_DEPRECATED("Objective-C garbage collection is no longer supported"); + +- (id)copy; +- (id)mutableCopy; + ++ (id)copyWithZone:(struct _NSZone *)zone OBJC_ARC_UNAVAILABLE; ++ (id)mutableCopyWithZone:(struct _NSZone *)zone OBJC_ARC_UNAVAILABLE; + ++ (BOOL)instancesRespondToSelector:(SEL)aSelector; ++ (BOOL)conformsToProtocol:(Protocol *)protocol; +- (IMP)methodForSelector:(SEL)aSelector; ++ (IMP)instanceMethodForSelector:(SEL)aSelector; +- (void)doesNotRecognizeSelector:(SEL)aSelector; + +- (id)forwardingTargetForSelector:(SEL)aSelector OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); +- (void)forwardInvocation:(NSInvocation *)anInvocation OBJC_SWIFT_UNAVAILABLE(""); +- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector OBJC_SWIFT_UNAVAILABLE(""); + ++ (NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)aSelector OBJC_SWIFT_UNAVAILABLE(""); + +- (BOOL)allowsWeakReference UNAVAILABLE_ATTRIBUTE; +- (BOOL)retainWeakReference UNAVAILABLE_ATTRIBUTE; + ++ (BOOL)isSubclassOfClass:(Class)aClass; + ++ (BOOL)resolveClassMethod:(SEL)sel OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); ++ (BOOL)resolveInstanceMethod:(SEL)sel OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + ++ (NSUInteger)hash; ++ (Class)superclass; ++ (Class)class OBJC_SWIFT_UNAVAILABLE("use 'aClass.self' instead"); ++ (NSString *)description; ++ (NSString *)debugDescription; + +@end + +#endif + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/objc/objc-api.h b/lib/libc/include/x86_64-macos-gnu/objc/objc-api.h new file mode 100644 index 0000000000..d6eb37353d --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/objc/objc-api.h @@ -0,0 +1,286 @@ +/* + * Copyright (c) 1999-2006 Apple Inc. All Rights Reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +// Copyright 1988-1996 NeXT Software, Inc. + +#ifndef _OBJC_OBJC_API_H_ +#define _OBJC_OBJC_API_H_ + +#include +#include +#include +#include + +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +#ifndef __has_extension +# define __has_extension __has_feature +#endif + +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +#if !__has_feature(nullability) +# ifndef _Nullable +# define _Nullable +# endif +# ifndef _Nonnull +# define _Nonnull +# endif +# ifndef _Null_unspecified +# define _Null_unspecified +# endif +#endif + + + +/* + * OBJC_API_VERSION 0 or undef: Tiger and earlier API only + * OBJC_API_VERSION 2: Leopard and later API available + */ +#if !defined(OBJC_API_VERSION) +# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5 +# define OBJC_API_VERSION 0 +# else +# define OBJC_API_VERSION 2 +# endif +#endif + + +/* + * OBJC_NO_GC 1: GC is not supported + * OBJC_NO_GC undef: GC is supported. This SDK no longer supports this mode. + * + * OBJC_NO_GC_API undef: Libraries must export any symbols that + * dual-mode code may links to. + * OBJC_NO_GC_API 1: Libraries need not export GC-related symbols. + */ +#if defined(__OBJC_GC__) +# error Objective-C garbage collection is not supported. +#elif TARGET_OS_OSX + /* GC is unsupported. GC API symbols are exported. */ +# define OBJC_NO_GC 1 +# undef OBJC_NO_GC_API +#else + /* GC is unsupported. GC API symbols are not exported. */ +# define OBJC_NO_GC 1 +# define OBJC_NO_GC_API 1 +#endif + + +/* NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER == 1 + * marks -[NSObject init] as a designated initializer. */ +#if !defined(NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER) +# define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1 +#endif + +/* The arm64 ABI requires proper casting to ensure arguments are passed + * * correctly. */ +#if defined(__arm64__) && !__swift__ +# undef OBJC_OLD_DISPATCH_PROTOTYPES +# define OBJC_OLD_DISPATCH_PROTOTYPES 0 +#endif + +/* OBJC_OLD_DISPATCH_PROTOTYPES == 0 enforces the rule that the dispatch + * functions must be cast to an appropriate function pointer type. */ +#if !defined(OBJC_OLD_DISPATCH_PROTOTYPES) +# if __swift__ + // Existing Swift code expects IMP to be Comparable. + // Variadic IMP is comparable via OpaquePointer; non-variadic IMP isn't. +# define OBJC_OLD_DISPATCH_PROTOTYPES 1 +# else +# define OBJC_OLD_DISPATCH_PROTOTYPES 0 +# endif +#endif + + +/* OBJC_AVAILABLE: shorthand for all-OS availability */ + +# if !defined(OBJC_AVAILABLE) +# define OBJC_AVAILABLE(x, i, t, w, b) \ + __OSX_AVAILABLE(x) __IOS_AVAILABLE(i) __TVOS_AVAILABLE(t) \ + __WATCHOS_AVAILABLE(w) +# endif + + + +/* OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE: Deprecated on OS X, + * unavailable everywhere else. */ + +# if !defined(OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE) +# define OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(_start, _dep, _msg) \ + __OSX_DEPRECATED(_start, _dep, _msg) \ + __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \ + __WATCHOS_UNAVAILABLE +# endif + + + +/* OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE: Available on OS X, + * unavailable everywhere else. */ + +# if !defined(OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE) +# define OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(vers) \ + __OSX_AVAILABLE(vers) \ + __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \ + __WATCHOS_UNAVAILABLE +# endif + + + +/* OBJC_ISA_AVAILABILITY: `isa` will be deprecated or unavailable + * in the future */ +#if !defined(OBJC_ISA_AVAILABILITY) +# if __OBJC2__ +# define OBJC_ISA_AVAILABILITY __attribute__((deprecated)) +# else +# define OBJC_ISA_AVAILABILITY /* still available */ +# endif +#endif + + +/* OBJC2_UNAVAILABLE: unavailable in objc 2.0, deprecated in Leopard */ +#if !defined(OBJC2_UNAVAILABLE) +# if __OBJC2__ +# define OBJC2_UNAVAILABLE UNAVAILABLE_ATTRIBUTE +# else + /* plain C code also falls here, but this is close enough */ +# define OBJC2_UNAVAILABLE \ + __OSX_DEPRECATED(10.5, 10.5, "not available in __OBJC2__") \ + __IOS_DEPRECATED(2.0, 2.0, "not available in __OBJC2__") \ + __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE +# endif +#endif + +/* OBJC_UNAVAILABLE: unavailable, with a message where supported */ +#if !defined(OBJC_UNAVAILABLE) +# if __has_extension(attribute_unavailable_with_message) +# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable(_msg))) +# else +# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable)) +# endif +#endif + +/* OBJC_DEPRECATED: deprecated, with a message where supported */ +#if !defined(OBJC_DEPRECATED) +# if __has_extension(attribute_deprecated_with_message) +# define OBJC_DEPRECATED(_msg) __attribute__((deprecated(_msg))) +# else +# define OBJC_DEPRECATED(_msg) __attribute__((deprecated)) +# endif +#endif + +/* OBJC_ARC_UNAVAILABLE: unavailable with -fobjc-arc */ +#if !defined(OBJC_ARC_UNAVAILABLE) +# if __has_feature(objc_arc) +# define OBJC_ARC_UNAVAILABLE OBJC_UNAVAILABLE("not available in automatic reference counting mode") +# else +# define OBJC_ARC_UNAVAILABLE +# endif +#endif + +/* OBJC_SWIFT_UNAVAILABLE: unavailable in Swift */ +#if !defined(OBJC_SWIFT_UNAVAILABLE) +# if __has_feature(attribute_availability_swift) +# define OBJC_SWIFT_UNAVAILABLE(_msg) __attribute__((availability(swift, unavailable, message=_msg))) +# else +# define OBJC_SWIFT_UNAVAILABLE(_msg) +# endif +#endif + +/* OBJC_ARM64_UNAVAILABLE: unavailable on arm64 (i.e. stret dispatch) */ +#if !defined(OBJC_ARM64_UNAVAILABLE) +# if defined(__arm64__) +# define OBJC_ARM64_UNAVAILABLE OBJC_UNAVAILABLE("not available in arm64") +# else +# define OBJC_ARM64_UNAVAILABLE +# endif +#endif + +/* OBJC_GC_UNAVAILABLE: unavailable with -fobjc-gc or -fobjc-gc-only */ +#if !defined(OBJC_GC_UNAVAILABLE) +# define OBJC_GC_UNAVAILABLE +#endif + +#if !defined(OBJC_EXTERN) +# if defined(__cplusplus) +# define OBJC_EXTERN extern "C" +# else +# define OBJC_EXTERN extern +# endif +#endif + +#if !defined(OBJC_VISIBLE) + +# define OBJC_VISIBLE __attribute__((visibility("default"))) + +#endif + +#if !defined(OBJC_EXPORT) +# define OBJC_EXPORT OBJC_EXTERN OBJC_VISIBLE +#endif + +#if !defined(OBJC_IMPORT) +# define OBJC_IMPORT extern +#endif + +#if !defined(OBJC_ROOT_CLASS) +# if __has_attribute(objc_root_class) +# define OBJC_ROOT_CLASS __attribute__((objc_root_class)) +# else +# define OBJC_ROOT_CLASS +# endif +#endif + +#ifndef __DARWIN_NULL +#define __DARWIN_NULL NULL +#endif + +#if !defined(OBJC_INLINE) +# define OBJC_INLINE __inline +#endif + +// Declares an enum type or option bits type as appropriate for each language. +#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum)) +#define OBJC_ENUM(_type, _name) enum _name : _type _name; enum _name : _type +#if (__cplusplus) +#define OBJC_OPTIONS(_type, _name) _type _name; enum : _type +#else +#define OBJC_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type +#endif +#else +#define OBJC_ENUM(_type, _name) _type _name; enum +#define OBJC_OPTIONS(_type, _name) _type _name; enum +#endif + +#if !defined(OBJC_RETURNS_RETAINED) +# if __OBJC__ && __has_attribute(ns_returns_retained) +# define OBJC_RETURNS_RETAINED __attribute__((ns_returns_retained)) +# else +# define OBJC_RETURNS_RETAINED +# endif +#endif + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/objc/objc.h b/lib/libc/include/x86_64-macos-gnu/objc/objc.h new file mode 100644 index 0000000000..4c68159452 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/objc/objc.h @@ -0,0 +1,259 @@ +/* + * Copyright (c) 1999-2007 Apple Inc. All Rights Reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * objc.h + * Copyright 1988-1996, NeXT Software, Inc. + */ + +#ifndef _OBJC_OBJC_H_ +#define _OBJC_OBJC_H_ + +#include // for __DARWIN_NULL +#include +#include +#include + +#if !OBJC_TYPES_DEFINED +/// An opaque type that represents an Objective-C class. +typedef struct objc_class *Class; + +/// Represents an instance of a class. +struct objc_object { + Class _Nonnull isa OBJC_ISA_AVAILABILITY; +}; + +/// A pointer to an instance of a class. +typedef struct objc_object *id; +#endif + +/// An opaque type that represents a method selector. +typedef struct objc_selector *SEL; + +/// A pointer to the function of a method implementation. +#if !OBJC_OLD_DISPATCH_PROTOTYPES +typedef void (*IMP)(void /* id, SEL, ... */ ); +#else +typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...); +#endif + +/// Type to represent a boolean value. + +#if defined(__OBJC_BOOL_IS_BOOL) + // Honor __OBJC_BOOL_IS_BOOL when available. +# if __OBJC_BOOL_IS_BOOL +# define OBJC_BOOL_IS_BOOL 1 +# else +# define OBJC_BOOL_IS_BOOL 0 +# endif +#else + // __OBJC_BOOL_IS_BOOL not set. +# if TARGET_OS_OSX || TARGET_OS_MACCATALYST || ((TARGET_OS_IOS || 0) && !__LP64__ && !__ARM_ARCH_7K) +# define OBJC_BOOL_IS_BOOL 0 +# else +# define OBJC_BOOL_IS_BOOL 1 +# endif +#endif + +#if OBJC_BOOL_IS_BOOL + typedef bool BOOL; +#else +# define OBJC_BOOL_IS_CHAR 1 + typedef signed char BOOL; + // BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C" + // even if -funsigned-char is used. +#endif + +#define OBJC_BOOL_DEFINED + +#if __has_feature(objc_bool) +#define YES __objc_yes +#define NO __objc_no +#else +#define YES ((BOOL)1) +#define NO ((BOOL)0) +#endif + +#ifndef Nil +# if __has_feature(cxx_nullptr) +# define Nil nullptr +# else +# define Nil __DARWIN_NULL +# endif +#endif + +#ifndef nil +# if __has_feature(cxx_nullptr) +# define nil nullptr +# else +# define nil __DARWIN_NULL +# endif +#endif + +#ifndef __strong +# if !__has_feature(objc_arc) +# define __strong /* empty */ +# endif +#endif + +#ifndef __unsafe_unretained +# if !__has_feature(objc_arc) +# define __unsafe_unretained /* empty */ +# endif +#endif + +#ifndef __autoreleasing +# if !__has_feature(objc_arc) +# define __autoreleasing /* empty */ +# endif +#endif + + +/** + * Returns the name of the method specified by a given selector. + * + * @param sel A pointer of type \c SEL. Pass the selector whose name you wish to determine. + * + * @return A C string indicating the name of the selector. + */ +OBJC_EXPORT const char * _Nonnull sel_getName(SEL _Nonnull sel) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Registers a method with the Objective-C runtime system, maps the method + * name to a selector, and returns the selector value. + * + * @param str A pointer to a C string. Pass the name of the method you wish to register. + * + * @return A pointer of type SEL specifying the selector for the named method. + * + * @note You must register a method name with the Objective-C runtime system to obtain the + * method’s selector before you can add the method to a class definition. If the method name + * has already been registered, this function simply returns the selector. + */ +OBJC_EXPORT SEL _Nonnull sel_registerName(const char * _Nonnull str) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the class name of a given object. + * + * @param obj An Objective-C object. + * + * @return The name of the class of which \e obj is an instance. + */ +OBJC_EXPORT const char * _Nonnull object_getClassName(id _Nullable obj) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a pointer to any extra bytes allocated with an instance given object. + * + * @param obj An Objective-C object. + * + * @return A pointer to any extra bytes allocated with \e obj. If \e obj was + * not allocated with any extra bytes, then dereferencing the returned pointer is undefined. + * + * @note This function returns a pointer to any extra bytes allocated with the instance + * (as specified by \c class_createInstance with extraBytes>0). This memory follows the + * object's ordinary ivars, but may not be adjacent to the last ivar. + * @note The returned pointer is guaranteed to be pointer-size aligned, even if the area following + * the object's last ivar is less aligned than that. Alignment greater than pointer-size is never + * guaranteed, even if the area following the object's last ivar is more aligned than that. + * @note In a garbage-collected environment, the memory is scanned conservatively. + */ +OBJC_EXPORT void * _Nullable object_getIndexedIvars(id _Nullable obj) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Identifies a selector as being valid or invalid. + * + * @param sel The selector you want to identify. + * + * @return YES if selector is valid and has a function implementation, NO otherwise. + * + * @warning On some platforms, an invalid reference (to invalid memory addresses) can cause + * a crash. + */ +OBJC_EXPORT BOOL sel_isMapped(SEL _Nonnull sel) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Registers a method name with the Objective-C runtime system. + * + * @param str A pointer to a C string. Pass the name of the method you wish to register. + * + * @return A pointer of type SEL specifying the selector for the named method. + * + * @note The implementation of this method is identical to the implementation of \c sel_registerName. + * @note Prior to OS X version 10.0, this method tried to find the selector mapped to the given name + * and returned \c NULL if the selector was not found. This was changed for safety, because it was + * observed that many of the callers of this function did not check the return value for \c NULL. + */ +OBJC_EXPORT SEL _Nonnull sel_getUid(const char * _Nonnull str) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +typedef const void* objc_objectptr_t; + + +// Obsolete ARC conversions. + +OBJC_EXPORT id _Nullable objc_retainedObject(objc_objectptr_t _Nullable obj) +#if !OBJC_DECLARE_SYMBOLS + OBJC_UNAVAILABLE("use CFBridgingRelease() or a (__bridge_transfer id) cast instead") +#endif + ; +OBJC_EXPORT id _Nullable objc_unretainedObject(objc_objectptr_t _Nullable obj) +#if !OBJC_DECLARE_SYMBOLS + OBJC_UNAVAILABLE("use a (__bridge id) cast instead") +#endif + ; +OBJC_EXPORT objc_objectptr_t _Nullable objc_unretainedPointer(id _Nullable obj) +#if !OBJC_DECLARE_SYMBOLS + OBJC_UNAVAILABLE("use a __bridge cast instead") +#endif + ; + + +#if !__OBJC2__ + +// The following declarations are provided here for source compatibility. + +#if defined(__LP64__) + typedef long arith_t; + typedef unsigned long uarith_t; +# define ARITH_SHIFT 32 +#else + typedef int arith_t; + typedef unsigned uarith_t; +# define ARITH_SHIFT 16 +#endif + +typedef char *STR; + +#define ISSELECTOR(sel) sel_isMapped(sel) +#define SELNAME(sel) sel_getName(sel) +#define SELUID(str) sel_getUid(str) +#define NAMEOF(obj) object_getClassName(obj) +#define IV(obj) object_getIndexedIvars(obj) + +#endif + +#endif /* _OBJC_OBJC_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/os/base.h b/lib/libc/include/x86_64-macos-gnu/os/base.h index e8e9059272..027bcc8d2b 100644 --- a/lib/libc/include/x86_64-macos-gnu/os/base.h +++ b/lib/libc/include/x86_64-macos-gnu/os/base.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2013 Apple Inc. All rights reserved. + * Copyright (c) 2008-2020 Apple Inc. All rights reserved. * * @APPLE_APACHE_LICENSE_HEADER_START@ * @@ -23,6 +23,7 @@ #include + #ifndef __has_builtin #define __has_builtin(x) 0 #endif @@ -73,7 +74,7 @@ #define OS_ALWAYS_INLINE __attribute__((__always_inline__)) #define OS_TRANSPARENT_UNION __attribute__((__transparent_union__)) #define OS_ALIGNED(n) __attribute__((__aligned__((n)))) -#define OS_FORMAT_PRINTF(x,y) __attribute__((__format__(printf,x,y))) +#define OS_FORMAT_PRINTF(x, y) __attribute__((__format__(printf,x,y))) #define OS_EXPORT extern __attribute__((__visibility__("default"))) #define OS_INLINE static __inline__ #define OS_EXPECT(x, v) __builtin_expect((x), (v)) @@ -110,7 +111,7 @@ #define OS_ALWAYS_INLINE #define OS_TRANSPARENT_UNION #define OS_ALIGNED(n) -#define OS_FORMAT_PRINTF(x,y) +#define OS_FORMAT_PRINTF(x, y) #define OS_EXPORT extern #define OS_INLINE static inline #define OS_EXPECT(x, v) (x) @@ -124,6 +125,8 @@ #if defined(__cplusplus) && defined(__clang__) #define OS_FALLTHROUGH [[clang::fallthrough]] +#elif __has_attribute(fallthrough) +#define OS_FALLTHROUGH __attribute__((__fallthrough__)) #else #define OS_FALLTHROUGH #endif @@ -164,30 +167,21 @@ * -Wassign-enum prevents you from assigning illegal values to a variable of the * enum type. */ -#ifndef __OPEN_SOURCE__ -/*! - * @internal - * - */ -#endif // __OPEN_SOURCE__ #define __OS_OPTIONS_ATTR __attribute__((flag_enum)) #else #define __OS_OPTIONS_ATTR #endif // __has_attribute(flag_enum) #if __has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum) || \ - __has_extension(cxx_strong_enums) + __has_extension(cxx_strong_enums) #define OS_ENUM(_name, _type, ...) \ - typedef enum : _type { __VA_ARGS__ } _name##_t + typedef enum : _type { __VA_ARGS__ } _name##_t #define OS_CLOSED_ENUM(_name, _type, ...) \ - typedef enum : _type { __VA_ARGS__ } \ - __OS_ENUM_ATTR_CLOSED _name##_t + typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR_CLOSED _name##_t #define OS_OPTIONS(_name, _type, ...) \ - typedef enum : _type { __VA_ARGS__ } \ - __OS_ENUM_ATTR __OS_OPTIONS_ATTR _name##_t + typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR __OS_OPTIONS_ATTR _name##_t #define OS_CLOSED_OPTIONS(_name, _type, ...) \ - typedef enum : _type { __VA_ARGS__ } \ - __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR _name##_t + typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR _name##_t #else /*! * There is unfortunately no good way in plain C to have both fixed-type enums @@ -220,25 +214,25 @@ * When compiling in ObjC or C++, both of the above assignments are illegal. */ #define __OS_ENUM_C_FALLBACK(_name, _type, ...) \ - typedef _type _name##_t; enum _name { __VA_ARGS__ } + typedef _type _name##_t; enum _name { __VA_ARGS__ } #define OS_ENUM(_name, _type, ...) \ - typedef _type _name##_t; enum { __VA_ARGS__ } + typedef _type _name##_t; enum { __VA_ARGS__ } #define OS_CLOSED_ENUM(_name, _type, ...) \ - __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \ - __OS_ENUM_ATTR_CLOSED + __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \ + __OS_ENUM_ATTR_CLOSED #define OS_OPTIONS(_name, _type, ...) \ - __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \ - __OS_ENUM_ATTR __OS_OPTIONS_ATTR + __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \ + __OS_ENUM_ATTR __OS_OPTIONS_ATTR #define OS_CLOSED_OPTIONS(_name, _type, ...) \ - __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \ - __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR + __OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \ + __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR #endif // __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums) #if __has_feature(attribute_availability_swift) // equivalent to __SWIFT_UNAVAILABLE from Availability.h #define OS_SWIFT_UNAVAILABLE(_msg) \ - __attribute__((__availability__(swift, unavailable, message=_msg))) + __attribute__((__availability__(swift, unavailable, message=_msg))) #else #define OS_SWIFT_UNAVAILABLE(_msg) #endif @@ -262,12 +256,12 @@ #ifdef __GNUC__ #define os_prevent_tail_call_optimization() __asm__("") -#define os_is_compile_time_constant(expr) __builtin_constant_p(expr) -#define os_compiler_barrier() __asm__ __volatile__("" ::: "memory") +#define os_is_compile_time_constant(expr) __builtin_constant_p(expr) +#define os_compiler_barrier() __asm__ __volatile__("" ::: "memory") #else #define os_prevent_tail_call_optimization() do { } while (0) -#define os_is_compile_time_constant(expr) 0 -#define os_compiler_barrier() do { } while (0) +#define os_is_compile_time_constant(expr) 0 +#define os_compiler_barrier() do { } while (0) #endif #if __has_attribute(not_tail_called) @@ -276,6 +270,7 @@ #define OS_NOT_TAIL_CALLED #endif + typedef void (*os_function_t)(void *_Nullable); #ifdef __BLOCKS__ @@ -322,4 +317,6 @@ typedef void (*os_function_t)(void *_Nullable); typedef void (^os_block_t)(void); #endif + + #endif // __OS_BASE__ diff --git a/lib/libc/include/x86_64-macos-gnu/os/clock.h b/lib/libc/include/x86_64-macos-gnu/os/clock.h new file mode 100644 index 0000000000..665e1d8716 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/os/clock.h @@ -0,0 +1,18 @@ +#ifndef __OS_CLOCK__ +#define __OS_CLOCK__ + +#include +#include + +/* + * @typedef os_clockid_t + * + * @abstract + * Describes the kind of clock that the workgroup timestamp parameters are + * specified in + */ +OS_ENUM(os_clockid, uint32_t, + OS_CLOCK_MACH_ABSOLUTE_TIME = 32, +); + +#endif /* __OS_CLOCK__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/os/lock.h b/lib/libc/include/x86_64-macos-gnu/os/lock.h new file mode 100644 index 0000000000..5c46f28e94 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/os/lock.h @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2016 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __OS_LOCK__ +#define __OS_LOCK__ + +#include +#include +#include +#include +#include +#include + +OS_ASSUME_NONNULL_BEGIN + +/*! @header + * Low-level lock API. + */ + +#define OS_LOCK_API_VERSION 20160309 + +__BEGIN_DECLS + +#define OS_UNFAIR_LOCK_AVAILABILITY \ + __API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) + +/*! + * @typedef os_unfair_lock + * + * @abstract + * Low-level lock that allows waiters to block efficiently on contention. + * + * In general, higher level synchronization primitives such as those provided by + * the pthread or dispatch subsystems should be preferred. + * + * The values stored in the lock should be considered opaque and implementation + * defined, they contain thread ownership information that the system may use + * to attempt to resolve priority inversions. + * + * This lock must be unlocked from the same thread that locked it, attempts to + * unlock from a different thread will cause an assertion aborting the process. + * + * This lock must not be accessed from multiple processes or threads via shared + * or multiply-mapped memory, the lock implementation relies on the address of + * the lock value and owning process. + * + * Must be initialized with OS_UNFAIR_LOCK_INIT + * + * @discussion + * Replacement for the deprecated OSSpinLock. Does not spin on contention but + * waits in the kernel to be woken up by an unlock. + * + * As with OSSpinLock there is no attempt at fairness or lock ordering, e.g. an + * unlocker can potentially immediately reacquire the lock before a woken up + * waiter gets an opportunity to attempt to acquire the lock. This may be + * advantageous for performance reasons, but also makes starvation of waiters a + * possibility. + */ +OS_UNFAIR_LOCK_AVAILABILITY +typedef struct os_unfair_lock_s { + uint32_t _os_unfair_lock_opaque; +} os_unfair_lock, *os_unfair_lock_t; + +#ifndef OS_UNFAIR_LOCK_INIT +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define OS_UNFAIR_LOCK_INIT ((os_unfair_lock){0}) +#elif defined(__cplusplus) && __cplusplus >= 201103L +#define OS_UNFAIR_LOCK_INIT (os_unfair_lock{}) +#elif defined(__cplusplus) +#define OS_UNFAIR_LOCK_INIT (os_unfair_lock()) +#else +#define OS_UNFAIR_LOCK_INIT {0} +#endif +#endif // OS_UNFAIR_LOCK_INIT + +/*! + * @function os_unfair_lock_lock + * + * @abstract + * Locks an os_unfair_lock. + * + * @param lock + * Pointer to an os_unfair_lock. + */ +OS_UNFAIR_LOCK_AVAILABILITY +OS_EXPORT OS_NOTHROW OS_NONNULL_ALL +void os_unfair_lock_lock(os_unfair_lock_t lock); + +/*! + * @function os_unfair_lock_trylock + * + * @abstract + * Locks an os_unfair_lock if it is not already locked. + * + * @discussion + * It is invalid to surround this function with a retry loop, if this function + * returns false, the program must be able to proceed without having acquired + * the lock, or it must call os_unfair_lock_lock() directly (a retry loop around + * os_unfair_lock_trylock() amounts to an inefficient implementation of + * os_unfair_lock_lock() that hides the lock waiter from the system and prevents + * resolution of priority inversions). + * + * @param lock + * Pointer to an os_unfair_lock. + * + * @result + * Returns true if the lock was succesfully locked and false if the lock was + * already locked. + */ +OS_UNFAIR_LOCK_AVAILABILITY +OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NONNULL_ALL +bool os_unfair_lock_trylock(os_unfair_lock_t lock); + +/*! + * @function os_unfair_lock_unlock + * + * @abstract + * Unlocks an os_unfair_lock. + * + * @param lock + * Pointer to an os_unfair_lock. + */ +OS_UNFAIR_LOCK_AVAILABILITY +OS_EXPORT OS_NOTHROW OS_NONNULL_ALL +void os_unfair_lock_unlock(os_unfair_lock_t lock); + +/*! + * @function os_unfair_lock_assert_owner + * + * @abstract + * Asserts that the calling thread is the current owner of the specified + * unfair lock. + * + * @discussion + * If the lock is currently owned by the calling thread, this function returns. + * + * If the lock is unlocked or owned by a different thread, this function + * asserts and terminates the process. + * + * @param lock + * Pointer to an os_unfair_lock. + */ +OS_UNFAIR_LOCK_AVAILABILITY +OS_EXPORT OS_NOTHROW OS_NONNULL_ALL +void os_unfair_lock_assert_owner(os_unfair_lock_t lock); + +/*! + * @function os_unfair_lock_assert_not_owner + * + * @abstract + * Asserts that the calling thread is not the current owner of the specified + * unfair lock. + * + * @discussion + * If the lock is unlocked or owned by a different thread, this function + * returns. + * + * If the lock is currently owned by the current thread, this function asserts + * and terminates the process. + * + * @param lock + * Pointer to an os_unfair_lock. + */ +OS_UNFAIR_LOCK_AVAILABILITY +OS_EXPORT OS_NOTHROW OS_NONNULL_ALL +void os_unfair_lock_assert_not_owner(os_unfair_lock_t lock); + +__END_DECLS + +OS_ASSUME_NONNULL_END + +#endif // __OS_LOCK__ diff --git a/lib/libc/include/x86_64-macos-gnu/os/object.h b/lib/libc/include/x86_64-macos-gnu/os/object.h new file mode 100644 index 0000000000..e2ce3f4677 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/os/object.h @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2011-2014 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __OS_OBJECT__ +#define __OS_OBJECT__ + +#ifdef __APPLE__ +#include +#include +#include +#include +#elif defined(_WIN32) +#include +#elif defined(__unix__) +#include +#endif + +/*! + * @header + * + * @preprocinfo + * By default, libSystem objects such as GCD and XPC objects are declared as + * Objective-C types when building with an Objective-C compiler. This allows + * them to participate in ARC, in RR management by the Blocks runtime and in + * leaks checking by the static analyzer, and enables them to be added to Cocoa + * collections. + * + * NOTE: this requires explicit cancellation of dispatch sources and xpc + * connections whose handler blocks capture the source/connection object, + * resp. ensuring that such captures do not form retain cycles (e.g. by + * declaring the source as __weak). + * + * To opt-out of this default behavior, add -DOS_OBJECT_USE_OBJC=0 to your + * compiler flags. + * + * This mode requires a platform with the modern Objective-C runtime, the + * Objective-C GC compiler option to be disabled, and at least a Mac OS X 10.8 + * or iOS 6.0 deployment target. + */ + +#ifndef OS_OBJECT_HAVE_OBJC_SUPPORT +#if !defined(__OBJC__) || defined(__OBJC_GC__) +# define OS_OBJECT_HAVE_OBJC_SUPPORT 0 +#elif !defined(TARGET_OS_MAC) || !TARGET_OS_MAC +# define OS_OBJECT_HAVE_OBJC_SUPPORT 0 +#elif TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0 +# define OS_OBJECT_HAVE_OBJC_SUPPORT 0 +#elif TARGET_OS_MAC && !TARGET_OS_IPHONE +# if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8 +# define OS_OBJECT_HAVE_OBJC_SUPPORT 0 +# elif defined(__i386__) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12 +# define OS_OBJECT_HAVE_OBJC_SUPPORT 0 +# else +# define OS_OBJECT_HAVE_OBJC_SUPPORT 1 +# endif +#else +# define OS_OBJECT_HAVE_OBJC_SUPPORT 1 +#endif +#endif // OS_OBJECT_HAVE_OBJC_SUPPORT + +#if OS_OBJECT_HAVE_OBJC_SUPPORT +#if defined(__swift__) && __swift__ && !OS_OBJECT_USE_OBJC +#define OS_OBJECT_USE_OBJC 1 +#endif +#ifndef OS_OBJECT_USE_OBJC +#define OS_OBJECT_USE_OBJC 1 +#endif +#elif defined(OS_OBJECT_USE_OBJC) && OS_OBJECT_USE_OBJC +/* Unsupported platform for OS_OBJECT_USE_OBJC=1 */ +#undef OS_OBJECT_USE_OBJC +#define OS_OBJECT_USE_OBJC 0 +#else +#define OS_OBJECT_USE_OBJC 0 +#endif + +#ifndef OS_OBJECT_SWIFT3 +#ifdef __swift__ +#define OS_OBJECT_SWIFT3 1 +#else // __swift__ +#define OS_OBJECT_SWIFT3 0 +#endif // __swift__ +#endif // OS_OBJECT_SWIFT3 + +#if __has_feature(assume_nonnull) +#define OS_OBJECT_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +#define OS_OBJECT_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +#define OS_OBJECT_ASSUME_NONNULL_BEGIN +#define OS_OBJECT_ASSUME_NONNULL_END +#endif +#define OS_OBJECT_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + +#if OS_OBJECT_USE_OBJC +#import +#if __has_attribute(objc_independent_class) +#define OS_OBJC_INDEPENDENT_CLASS __attribute__((objc_independent_class)) +#endif // __has_attribute(objc_independent_class) +#ifndef OS_OBJC_INDEPENDENT_CLASS +#define OS_OBJC_INDEPENDENT_CLASS +#endif +#define OS_OBJECT_CLASS(name) OS_##name +#define OS_OBJECT_DECL_PROTOCOL(name, ...) \ + @protocol OS_OBJECT_CLASS(name) __VA_ARGS__ \ + @end +#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL(name, proto) \ + @interface name () \ + @end +#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, proto) \ + OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL( \ + OS_OBJECT_CLASS(name), OS_OBJECT_CLASS(proto)) +#define OS_OBJECT_DECL_IMPL(name, adhere, ...) \ + OS_OBJECT_DECL_PROTOCOL(name, __VA_ARGS__) \ + typedef adhere \ + * OS_OBJC_INDEPENDENT_CLASS name##_t +#define OS_OBJECT_DECL_BASE(name, ...) \ + @interface OS_OBJECT_CLASS(name) : __VA_ARGS__ \ + - (instancetype)init OS_SWIFT_UNAVAILABLE("Unavailable in Swift"); \ + @end +#define OS_OBJECT_DECL_IMPL_CLASS(name, ...) \ + OS_OBJECT_DECL_BASE(name, ## __VA_ARGS__) \ + typedef OS_OBJECT_CLASS(name) \ + * OS_OBJC_INDEPENDENT_CLASS name##_t +#define OS_OBJECT_DECL(name, ...) \ + OS_OBJECT_DECL_IMPL(name, NSObject, ) +#define OS_OBJECT_DECL_SUBCLASS(name, super) \ + OS_OBJECT_DECL_IMPL(name, NSObject, ) +#if __has_attribute(ns_returns_retained) +#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__)) +#else +#define OS_OBJECT_RETURNS_RETAINED +#endif +#if __has_attribute(ns_consumed) +#define OS_OBJECT_CONSUMED __attribute__((__ns_consumed__)) +#else +#define OS_OBJECT_CONSUMED +#endif +#if __has_feature(objc_arc) +#define OS_OBJECT_BRIDGE __bridge +#define OS_WARN_RESULT_NEEDS_RELEASE +#else +#define OS_OBJECT_BRIDGE +#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT +#endif + + +#if __has_attribute(objc_runtime_visible) && \ + ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ + __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12) || \ + (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \ + !defined(__TV_OS_VERSION_MIN_REQUIRED) && \ + !defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \ + __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) || \ + (defined(__TV_OS_VERSION_MIN_REQUIRED) && \ + __TV_OS_VERSION_MIN_REQUIRED < __TVOS_10_0) || \ + (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \ + __WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_3_0)) +/* + * To provide backward deployment of ObjC objects in Swift on pre-10.12 + * SDKs, OS_object classes can be marked as OS_OBJECT_OBJC_RUNTIME_VISIBLE. + * When compiling with a deployment target earlier than OS X 10.12 (iOS 10.0, + * tvOS 10.0, watchOS 3.0) the Swift compiler will only refer to this type at + * runtime (using the ObjC runtime). + */ +#define OS_OBJECT_OBJC_RUNTIME_VISIBLE __attribute__((objc_runtime_visible)) +#else +#define OS_OBJECT_OBJC_RUNTIME_VISIBLE +#endif +#ifndef OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#if defined(__clang_analyzer__) +#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1 +#elif __has_feature(objc_arc) && !OS_OBJECT_SWIFT3 +#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1 +#else +#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0 +#endif +#endif +#if OS_OBJECT_SWIFT3 +#define OS_OBJECT_DECL_SWIFT(name) \ + OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \ + OS_OBJECT_DECL_IMPL_CLASS(name, NSObject) +#define OS_OBJECT_DECL_SUBCLASS_SWIFT(name, super) \ + OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \ + OS_OBJECT_DECL_IMPL_CLASS(name, OS_OBJECT_CLASS(super)) +#endif // OS_OBJECT_SWIFT3 +OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE +OS_OBJECT_DECL_BASE(object, NSObject); +#else +/*! @parseOnly */ +#define OS_OBJECT_RETURNS_RETAINED +/*! @parseOnly */ +#define OS_OBJECT_CONSUMED +/*! @parseOnly */ +#define OS_OBJECT_BRIDGE +/*! @parseOnly */ +#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT +/*! @parseOnly */ +#define OS_OBJECT_OBJC_RUNTIME_VISIBLE +#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0 +#endif + +#if OS_OBJECT_SWIFT3 +#define OS_OBJECT_DECL_CLASS(name) \ + OS_OBJECT_DECL_SUBCLASS_SWIFT(name, object) +#elif OS_OBJECT_USE_OBJC +#define OS_OBJECT_DECL_CLASS(name) \ + OS_OBJECT_DECL(name) +#else +#define OS_OBJECT_DECL_CLASS(name) \ + typedef struct name##_s *name##_t +#endif + +#if OS_OBJECT_USE_OBJC +/* Declares a class of the specific name and exposes the interface and typedefs + * name##_t to the pointer to the class */ +#define OS_OBJECT_SHOW_CLASS(name, ...) \ + OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \ + OS_OBJECT_DECL_IMPL_CLASS(name, ## __VA_ARGS__ ) +/* Declares a subclass of the same name, and + * subclass adheres to protocol specified. Typedefs baseclass * to subclass##_t */ +#define OS_OBJECT_SHOW_SUBCLASS(subclass_name, super, proto_name) \ + OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \ + OS_OBJECT_DECL_BASE(subclass_name, OS_OBJECT_CLASS(super)); \ + typedef OS_OBJECT_CLASS(super) \ + * OS_OBJC_INDEPENDENT_CLASS subclass_name##_t +#else /* Plain C */ +#define OS_OBJECT_DECL_PROTOCOL(name, ...) +#define OS_OBJECT_SHOW_CLASS(name, ...) \ + typedef struct name##_s *name##_t +#define OS_OBJECT_SHOW_SUBCLASS(name, super, ...) \ + typedef super##_t name##_t +#endif + +#define OS_OBJECT_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object)) + +__BEGIN_DECLS + +/*! + * @function os_retain + * + * @abstract + * Increment the reference count of an os_object. + * + * @discussion + * On a platform with the modern Objective-C runtime this is exactly equivalent + * to sending the object the -[retain] message. + * + * @param object + * The object to retain. + * + * @result + * The retained object. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +OS_EXPORT OS_SWIFT_UNAVAILABLE("Can't be used with ARC") +void* +os_retain(void *object); +#if OS_OBJECT_USE_OBJC +#undef os_retain +#define os_retain(object) [object retain] +#endif + +/*! + * @function os_release + * + * @abstract + * Decrement the reference count of a os_object. + * + * @discussion + * On a platform with the modern Objective-C runtime this is exactly equivalent + * to sending the object the -[release] message. + * + * @param object + * The object to release. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +OS_EXPORT +void OS_SWIFT_UNAVAILABLE("Can't be used with ARC") +os_release(void *object); +#if OS_OBJECT_USE_OBJC +#undef os_release +#define os_release(object) [object release] +#endif + +__END_DECLS + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/os/workgroup.h b/lib/libc/include/x86_64-macos-gnu/os/workgroup.h new file mode 100644 index 0000000000..96b870c10c --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/os/workgroup.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __OS_WORKGROUP__ +#define __OS_WORKGROUP__ + +#ifndef __DISPATCH_BUILDING_DISPATCH__ +#ifndef __OS_WORKGROUP_INDIRECT__ +#define __OS_WORKGROUP_INDIRECT__ +#endif /* __OS_WORKGROUP_INDIRECT__ */ + +#include +#include +#include +#include + +#undef __OS_WORKGROUP_INDIRECT__ +#endif /* __DISPATCH_BUILDING_DISPATCH__ */ + +#endif /* __OS_WORKGROUP__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/os/workgroup_base.h b/lib/libc/include/x86_64-macos-gnu/os/workgroup_base.h new file mode 100644 index 0000000000..3983f002ae --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/os/workgroup_base.h @@ -0,0 +1,78 @@ +#ifndef __OS_WORKGROUP_BASE__ +#define __OS_WORKGROUP_BASE__ + +#ifndef __OS_WORKGROUP_INDIRECT__ +#error "Please #include instead of this file directly." +#endif + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#if __has_feature(assume_nonnull) +#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +#define OS_WORKGROUP_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN +#define OS_WORKGROUP_ASSUME_NONNULL_END +#endif +#define OS_WORKGROUP_WARN_RESULT __attribute__((__warn_unused_result__)) +#define OS_WORKGROUP_EXPORT OS_EXPORT +#define OS_WORKGROUP_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED + +#define OS_WORKGROUP_DECL(name, swift_name) \ + OS_SWIFT_NAME(swift_name) \ + OS_OBJECT_SHOW_CLASS(name, OS_OBJECT_CLASS(object)) + +#if OS_OBJECT_USE_OBJC +#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...) \ + OS_SWIFT_NAME(swift_name) \ + OS_OBJECT_DECL_PROTOCOL(name ## __VA_ARGS__ ) +#else +#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...) +#endif + +#define OS_WORKGROUP_SUBCLASS_DECL(name, super, swift_name, ...) \ + OS_SWIFT_NAME(swift_name) \ + OS_OBJECT_SHOW_SUBCLASS(name, super, name, ## __VA_ARGS__) + +#if defined(__LP64__) +#define __OS_WORKGROUP_ATTR_SIZE__ 60 +#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56 +#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 36 +#else +#define __OS_WORKGROUP_ATTR_SIZE__ 60 +#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56 +#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 28 +#endif + +#define _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT 0x2FA863B4 +#define _OS_WORKGROUP_ATTR_SIG_EMPTY_INIT 0x2FA863C4 + +struct OS_REFINED_FOR_SWIFT os_workgroup_attr_opaque_s { + uint32_t sig; + char opaque[__OS_WORKGROUP_ATTR_SIZE__]; +}; + +#define _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT 0x52A74C4D +struct OS_REFINED_FOR_SWIFT os_workgroup_interval_data_opaque_s { + uint32_t sig; + char opaque[__OS_WORKGROUP_INTERVAL_DATA_SIZE__]; +}; + +struct OS_REFINED_FOR_SWIFT os_workgroup_join_token_opaque_s { + uint32_t sig; + char opaque[__OS_WORKGROUP_JOIN_TOKEN_SIZE__]; +}; + +#endif /* __OS_WORKGROUP_BASE__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/os/workgroup_interval.h b/lib/libc/include/x86_64-macos-gnu/os/workgroup_interval.h new file mode 100644 index 0000000000..8594aed529 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/os/workgroup_interval.h @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2020 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __OS_WORKGROUP_INTERVAL__ +#define __OS_WORKGROUP_INTERVAL__ + +#ifndef __OS_WORKGROUP_INDIRECT__ +#error "Please #include instead of this file directly." +#include // For header doc +#endif + +__BEGIN_DECLS + +OS_WORKGROUP_ASSUME_NONNULL_BEGIN + +/*! + * @typedef os_workgroup_interval_t + * + * @abstract + * A subclass of an os_workgroup_t for tracking work performed as part of + * a repeating interval-driven workload. + */ +OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_interval, Repeatable); +OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_interval, os_workgroup, WorkGroupInterval); + +/* During the first instance of this API, the only supported interval + * workgroups are for audio workloads. Please refer to the AudioToolbox + * framework for more information. + */ + +/* + * @typedef os_workgroup_interval_data, os_workgroup_interval_data_t + * + * @abstract + * An opaque structure containing additional configuration for the workgroup + * interval. + */ +typedef struct os_workgroup_interval_data_opaque_s os_workgroup_interval_data_s; +typedef struct os_workgroup_interval_data_opaque_s *os_workgroup_interval_data_t; +#define OS_WORKGROUP_INTERVAL_DATA_INITIALIZER \ + { .sig = _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT } + +/*! + * @function os_workgroup_interval_start + * + * @abstract + * Indicates to the system that the member threads of this + * os_workgroup_interval_t have begun working on an instance of the repeatable + * interval workload with the specified timestamps. This function is real time + * safe. + * + * This function will set and return an errno in the following cases: + * + * - The current thread is not a member of the os_workgroup_interval_t + * - The os_workgroup_interval_t has been cancelled + * - The timestamps passed in are malformed + * - os_workgroup_interval_start() was previously called on the + * os_workgroup_interval_t without an intervening os_workgroup_interval_finish() + * - A concurrent workgroup interval configuration operation is taking place. + * + * @param start + * Start timestamp specified in the os_clockid_t with which the + * os_workgroup_interval_t was created. This is generally a time in the past and + * indicates when the workgroup started working on an interval period + * + * @param deadline + * Deadline timestamp specified in the os_clockid_t with which the + * os_workgroup_interval_t was created. This specifies the deadline which the + * interval period would like to meet. + * + * @param data + * This field is currently unused and should be NULL + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_interval_start(os_workgroup_interval_t wg, uint64_t start, uint64_t + deadline, os_workgroup_interval_data_t _Nullable data); + +/*! + * @function os_workgroup_interval_update + * + * @abstract + * Updates an already started interval workgroup to have the new + * deadline specified. This function is real time safe. + * + * This function will return an error in the following cases: + * - The current thread is not a member of the os_workgroup_interval_t + * - The os_workgroup_interval_t has been cancelled + * - The timestamp passed in is malformed + * - os_workgroup_interval_start() was not previously called on the + * os_workgroup_interval_t or was already matched with an + * os_workgroup_interval_finish() + * - A concurrent workgroup interval configuration operation is taking place + * + * @param deadline + * Timestamp specified in the os_clockid_t with + * which the os_workgroup_interval_t was created. + * + * @param data + * This field is currently unused and should be NULL + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_interval_update(os_workgroup_interval_t wg, uint64_t deadline, + os_workgroup_interval_data_t _Nullable data); + +/*! + * @function os_workgroup_interval_finish + * + * @abstract + * Indicates to the system that the member threads of + * this os_workgroup_interval_t have finished working on the current instance + * of the interval workload. This function is real time safe. + * + * This function will return an error in the following cases: + * - The current thread is not a member of the os_workgroup_interval_t + * - os_workgroup_interval_start() was not previously called on the + * os_workgroup_interval_t or was already matched with an + * os_workgroup_interval_finish() + * - A concurrent workgroup interval configuration operation is taking place. + * + * @param data + * This field is currently unused and should be NULL + * + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_interval_finish(os_workgroup_interval_t wg, + os_workgroup_interval_data_t _Nullable data); + +OS_WORKGROUP_ASSUME_NONNULL_END + +__END_DECLS + +#endif /* __OS_WORKGROUP_INTERVAL__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/os/workgroup_object.h b/lib/libc/include/x86_64-macos-gnu/os/workgroup_object.h new file mode 100644 index 0000000000..984d3e2e80 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/os/workgroup_object.h @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2020 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __OS_WORKGROUP_OBJECT__ +#define __OS_WORKGROUP_OBJECT__ + +#ifndef __OS_WORKGROUP_INDIRECT__ +#error "Please #include instead of this file directly." +#include // For header doc +#endif + +__BEGIN_DECLS + +OS_WORKGROUP_ASSUME_NONNULL_BEGIN + +/*! + * @typedef os_workgroup_t + * + * @abstract + * A reference counted os object representing a workload that needs to + * be distinctly recognized and tracked by the system. The workgroup + * tracks a collection of threads all working cooperatively. An os_workgroup + * object - when not an instance of a specific os_workgroup_t subclass - + * represents a generic workload and makes no assumptions about the kind of + * work done. + * + * @discussion + * Threads can explicitly join an os_workgroup_t to mark themselves as + * participants in the workload. + */ +OS_WORKGROUP_DECL(os_workgroup, WorkGroup); + + +/* Attribute creation and specification */ + +/*! + * @typedef os_workgroup_attr_t + * + * @abstract + * Pointer to an opaque structure for describing attributes that can be + * configured on a workgroup at creation. + */ +typedef struct os_workgroup_attr_opaque_s os_workgroup_attr_s; +typedef struct os_workgroup_attr_opaque_s *os_workgroup_attr_t; + +/* os_workgroup_t attributes need to be initialized before use. This initializer + * allows you to create a workgroup with the system default attributes. */ +#define OS_WORKGROUP_ATTR_INITIALIZER_DEFAULT \ + { .sig = _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT } + + + +/* The main use of the workgroup API is through instantiations of the concrete + * subclasses - please refer to os/workgroup_interval.h and + * os/workgroup_parallel.h for more information on creating workgroups. + * + * The functions below operate on all subclasses of os_workgroup_t. + */ + +/*! + * @function os_workgroup_copy_port + * + * @abstract + * Returns a reference to a send right representing this workgroup that is to be + * sent to other processes. This port is to be passed to + * os_workgroup_create_with_port() to create a workgroup object. + * + * It is the client's responsibility to release the send right reference. + * + * If an error is encountered, errno is set and returned. + */ +API_AVAILABLE(macos(11.0)) +API_UNAVAILABLE(ios, tvos, watchos) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_copy_port(os_workgroup_t wg, mach_port_t *mach_port_out); + +/*! + * @function os_workgroup_create_with_port + * + * @abstract + * Create an os_workgroup_t object from a send right returned by a previous + * call to os_workgroup_copy_port, potentially in a different process. + * + * A newly created os_workgroup_t has no initial member threads - in particular + * the creating thread does not join the os_workgroup_t implicitly. + * + * @param name + * A client specified string for labelling the workgroup. This parameter is + * optional and can be NULL. + * + * @param mach_port + * The send right to create the workgroup from. No reference is consumed + * on the specified send right. + */ +API_AVAILABLE(macos(11.0)) +API_UNAVAILABLE(ios, tvos, watchos) +OS_SWIFT_NAME(WorkGroup.init(__name:port:)) OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED +os_workgroup_t _Nullable +os_workgroup_create_with_port(const char *_Nullable name, mach_port_t mach_port); + +/*! + * @function os_workgroup_create_with_workgroup + * + * @abstract + * Create a new os_workgroup object from an existing os_workgroup. + * + * The newly created os_workgroup has no initial member threads - in particular + * the creating threaad does not join the os_workgroup_t implicitly. + * + * @param name + * A client specified string for labelling the workgroup. This parameter is + * optional and can be NULL. + * + * @param wg + * The existing workgroup to create a new workgroup object from. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED +os_workgroup_t _Nullable +os_workgroup_create_with_workgroup(const char * _Nullable name, os_workgroup_t wg); + +/*! + * @typedef os_workgroup_join_token, os_workgroup_join_token_t + * + * @abstract + * An opaque join token which the client needs to pass to os_workgroup_join + * and os_workgroup_leave + */ +OS_REFINED_FOR_SWIFT +typedef struct os_workgroup_join_token_opaque_s os_workgroup_join_token_s; +OS_REFINED_FOR_SWIFT +typedef struct os_workgroup_join_token_opaque_s *os_workgroup_join_token_t; + + +/*! + * @function os_workgroup_join + * + * @abstract + * Joins the current thread to the specified workgroup and populates the join + * token that has been passed in. This API is real-time safe. + * + * @param wg + * The workgroup that the current thread would like to join + * + * @param token_out + * Pointer to a client allocated struct which the function will populate + * with the join token. This token must be passed in by the thread when it calls + * os_workgroup_leave(). + * + * Errors will be returned in the following cases: + * + * EALREADY The thread is already part of a workgroup that the specified + * workgroup does not nest with + * EINVAL The workgroup has been cancelled + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_join(os_workgroup_t wg, os_workgroup_join_token_t token_out); + +/*! + * @function os_workgroup_leave + * + * @abstract + * This removes the current thread from a workgroup it has previously + * joined. Threads must leave all workgroups in the reverse order that they + * have joined them. Failing to do so before exiting will result in undefined + * behavior. + * + * If the join token is malformed, the process will be aborted. + * + * This API is real time safe. + * + * @param wg + * The workgroup that the current thread would like to leave. + * + * @param token + * This is the join token populated by the most recent call to + * os_workgroup_join(). + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +void +os_workgroup_leave(os_workgroup_t wg, os_workgroup_join_token_t token); + +/* Working Arena index of a thread in a workgroup */ +typedef uint32_t os_workgroup_index; +/* Destructor for Working Arena */ +typedef void (*os_workgroup_working_arena_destructor_t)(void * _Nullable); + +/*! + * @function os_workgroup_set_working_arena + * + * @abstract + * Associates a client defined working arena with the workgroup. The arena + * is local to the workgroup object in the process. This is intended for + * distributing a manually managed memory allocation between member threads + * of the workgroup. + * + * This function can be called multiple times and the client specified + * destructor will be called on the previously assigned arena, if any. This + * function can only be called when no threads have currently joined the + * workgroup and all workloops associated with the workgroup are idle. + * + * @param wg + * The workgroup to associate the working arena with + * + * @param arena + * The client managed arena to associate with the workgroup. This value can + * be NULL. + * + * @param max_workers + * The maximum number of threads that will ever query the workgroup for the + * arena and request an index into it. If the arena is not used to partition + * work amongst member threads, then this field can be 0. + * + * @param destructor + * A destructor to call on the previously assigned working arena, if any + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_set_working_arena(os_workgroup_t wg, void * _Nullable arena, + uint32_t max_workers, os_workgroup_working_arena_destructor_t destructor); + +/*! + * @function os_workgroup_get_working_arena + * + * @abstract + * Returns the working arena associated with the workgroup and the current + * thread's index in the workgroup. This function can only be called by a member + * of the workgroup. Multiple calls to this API by a member thread will return + * the same arena and index until the thread leaves the workgroup. + * + * For workloops with an associated workgroup, every work item on the workloop + * will receive the same index in the arena. + * + * This method returns NULL if no arena is set on the workgroup. The index + * returned by this function is zero-based and is namespaced per workgroup + * object in the process. The indices provided are strictly monotonic and never + * reused until a future call to os_workgroup_set_working_arena. + * + * @param wg + * The workgroup to get the working arena from. + * + * @param index_out + * A pointer to a os_workgroup_index which will be populated by the caller's + * index in the workgroup. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +void * _Nullable +os_workgroup_get_working_arena(os_workgroup_t wg, + os_workgroup_index * _Nullable index_out); + +/*! + * @function os_workgroup_cancel + * + * @abstract + * This API invalidates a workgroup and indicates to the system that the + * workload is no longer relevant to the caller. + * + * No new work should be initiated for a cancelled workgroup and + * work that is already underway should periodically check for + * cancellation with os_workgroup_testcancel and initiate cleanup if needed. + * + * Threads currently in the workgroup continue to be tracked together but no + * new threads may join this workgroup - the only possible operation allowed is + * to leave the workgroup. Other actions may have undefined behavior or + * otherwise fail. + * + * This API is idempotent. Cancellation is local to the workgroup object + * it is called on and does not affect other workgroups. + * + * @param wg + * The workgroup that that the thread would like to cancel + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +void +os_workgroup_cancel(os_workgroup_t wg); + +/*! + * @function os_workgroup_testcancel + * + * @abstract + * Returns true if the workgroup object has been cancelled. See also + * os_workgroup_cancel + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +bool +os_workgroup_testcancel(os_workgroup_t wg); + +/*! + * @typedef os_workgroup_max_parallel_threads_attr_t + * + * @abstract + * A pointer to a structure describing the set of properties of a workgroup to + * override with the explicitly specified values in the structure. + * + * See also os_workgroup_max_parallel_threads. + */ +OS_REFINED_FOR_SWIFT +typedef struct os_workgroup_max_parallel_threads_attr_s os_workgroup_mpt_attr_s; +OS_REFINED_FOR_SWIFT +typedef struct os_workgroup_max_parallel_threads_attr_s *os_workgroup_mpt_attr_t; + +/*! + * @function os_workgroup_max_parallel_threads + * + * @abstract + * Returns the system's recommendation for maximum number of threads the client + * should make for a multi-threaded workload in a given workgroup. + * + * This API takes into consideration the current hardware the code is running on + * and the attributes of the workgroup. It does not take into consideration the + * current load of the system and therefore always provides the most optimal + * recommendation for the workload. + * + * @param wg + * The workgroup in which the multi-threaded workload will be performed in. The + * threads performing the multi-threaded workload are expected to join this + * workgroup. + * + * @param attr + * This value is currently unused and should be NULL. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +int +os_workgroup_max_parallel_threads(os_workgroup_t wg, os_workgroup_mpt_attr_t + _Nullable attr); + +OS_WORKGROUP_ASSUME_NONNULL_END + +__END_DECLS + +#endif /* __OS_WORKGROUP_OBJECT__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/os/workgroup_parallel.h b/lib/libc/include/x86_64-macos-gnu/os/workgroup_parallel.h new file mode 100644 index 0000000000..48d232e47a --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/os/workgroup_parallel.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2020 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __OS_WORKGROUP_PARALLEL__ +#define __OS_WORKGROUP_PARALLEL__ + +#ifndef __OS_WORKGROUP_INDIRECT__ +#error "Please #include instead of this file directly." +#include // For header doc +#endif + +#include + +__BEGIN_DECLS + +OS_WORKGROUP_ASSUME_NONNULL_BEGIN + +/*! + * @typedef os_workgroup_parallel_t + * + * @abstract + * A subclass of an os_workgroup_t for tracking parallel work. + */ +OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_parallel, Parallelizable); +OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_parallel, os_workgroup, WorkGroupParallel); + +/*! + * @function os_workgroup_parallel_create + * + * @abstract + * Creates an os_workgroup_t which tracks a parallel workload. + * A newly created os_workgroup_interval_t has no initial member threads - + * in particular the creating thread does not join the os_workgroup_parallel_t + * implicitly. + * + * See also os_workgroup_max_parallel_threads(). + * + * @param name + * A client specified string for labelling the workgroup. This parameter is + * optional and can be NULL. + * + * @param attr + * The requested set of workgroup attributes. NULL is to be specified for the + * default set of attributes. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED +OS_SWIFT_NAME(WorkGroupParallel.init(__name:attr:)) +os_workgroup_parallel_t _Nullable +os_workgroup_parallel_create(const char * _Nullable name, + os_workgroup_attr_t _Nullable attr); + +OS_WORKGROUP_ASSUME_NONNULL_END + +__END_DECLS + +#endif /* __OS_WORKGROUP_PARALLEL__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/pthread.h b/lib/libc/include/x86_64-macos-gnu/pthread.h index a042c82aed..c6490770be 100644 --- a/lib/libc/include/x86_64-macos-gnu/pthread.h +++ b/lib/libc/include/x86_64-macos-gnu/pthread.h @@ -53,9 +53,6 @@ #define _PTHREAD_H #include <_types.h> -#ifndef __POSIX_LIB__ -#include -#endif #include #include #include @@ -559,6 +556,33 @@ int pthread_sigmask(int, const sigset_t * _Nullable, sigset_t * _Nullable) __API_AVAILABLE(macos(10.4), ios(2.0)) void pthread_yield_np(void); +__API_AVAILABLE(macos(11.0)) +__API_UNAVAILABLE(ios, tvos, watchos) +void pthread_jit_write_protect_np(int enabled); + +__API_AVAILABLE(macos(11.0)) +__API_UNAVAILABLE(ios, tvos, watchos) +int pthread_jit_write_protect_supported_np(void); + +/*! + * @function pthread_cpu_number_np + * + * @param cpu_number_out + * The CPU number that the thread was running on at the time of query. + * This cpu number is in the interval [0, ncpus) (from sysctlbyname("hw.ncpu")) + * + * @result + * This function returns 0 or the value of errno if an error occurred. + * + * @note + * Optimizations of per-CPU datastructures based on the result of this function + * still require synchronization since it is not guaranteed that the thread will + * still be on the same CPU by the time the function returns. + */ +__API_AVAILABLE(macos(11.0), ios(14.2), tvos(14.2), watchos(7.1)) +int +pthread_cpu_number_np(size_t *cpu_number_out); + #endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE || __cplusplus */ __END_DECLS #if __has_feature(assume_nonnull) diff --git a/lib/libc/include/x86_64-macos-gnu/pthread/sched.h b/lib/libc/include/x86_64-macos-gnu/pthread/sched.h index 91efb4eae3..2ef6e2b8ab 100644 --- a/lib/libc/include/x86_64-macos-gnu/pthread/sched.h +++ b/lib/libc/include/x86_64-macos-gnu/pthread/sched.h @@ -25,7 +25,7 @@ #define _SCHED_H_ #include -#include +#include __BEGIN_DECLS /* @@ -33,6 +33,8 @@ __BEGIN_DECLS */ #ifndef __POSIX_LIB__ struct sched_param { int sched_priority; char __opaque[__SCHED_PARAM_SIZE__]; }; +#else +struct sched_param; #endif extern int sched_yield(void); diff --git a/lib/libc/include/x86_64-macos-gnu/pthread_impl.h b/lib/libc/include/x86_64-macos-gnu/pthread_impl.h deleted file mode 100644 index 35d32d3021..0000000000 --- a/lib/libc/include/x86_64-macos-gnu/pthread_impl.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#ifndef _PTHREAD_IMPL_H_ -#define _PTHREAD_IMPL_H_ -/* - * Internal implementation details - */ - -/* This whole header file will disappear, so don't depend on it... */ - -#if __has_feature(assume_nonnull) -_Pragma("clang assume_nonnull begin") -#endif - -#ifndef __POSIX_LIB__ - -/* - * [Internal] data structure signatures - */ -#define _PTHREAD_MUTEX_SIG_init 0x32AAABA7 - -#define _PTHREAD_ERRORCHECK_MUTEX_SIG_init 0x32AAABA1 -#define _PTHREAD_RECURSIVE_MUTEX_SIG_init 0x32AAABA2 -#define _PTHREAD_FIRSTFIT_MUTEX_SIG_init 0x32AAABA3 - -#define _PTHREAD_COND_SIG_init 0x3CB0B1BB -#define _PTHREAD_ONCE_SIG_init 0x30B1BCBA -#define _PTHREAD_RWLOCK_SIG_init 0x2DA8B3B4 - -/* - * POSIX scheduling policies - */ -#define SCHED_OTHER 1 -#define SCHED_FIFO 4 -#define SCHED_RR 2 - -#define __SCHED_PARAM_SIZE__ 4 - -#endif /* __POSIX_LIB__ */ - -#if __has_feature(assume_nonnull) -_Pragma("clang assume_nonnull end") -#endif - -#endif /* _PTHREAD_IMPL_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/sched.h b/lib/libc/include/x86_64-macos-gnu/sched.h index 91efb4eae3..2ef6e2b8ab 100644 --- a/lib/libc/include/x86_64-macos-gnu/sched.h +++ b/lib/libc/include/x86_64-macos-gnu/sched.h @@ -25,7 +25,7 @@ #define _SCHED_H_ #include -#include +#include __BEGIN_DECLS /* @@ -33,6 +33,8 @@ __BEGIN_DECLS */ #ifndef __POSIX_LIB__ struct sched_param { int sched_priority; char __opaque[__SCHED_PARAM_SIZE__]; }; +#else +struct sched_param; #endif extern int sched_yield(void); diff --git a/lib/libc/include/x86_64-macos-gnu/signal.h b/lib/libc/include/x86_64-macos-gnu/signal.h index 94c4c1bb4d..8727cefdba 100644 --- a/lib/libc/include/x86_64-macos-gnu/signal.h +++ b/lib/libc/include/x86_64-macos-gnu/signal.h @@ -108,16 +108,11 @@ int sigvec(int, struct sigvec *, struct sigvec *); __END_DECLS /* List definitions after function declarations, or Reiser cpp gets upset. */ -#if defined(__i386__) || defined(__x86_64__) -/* The left shift operator on intel is modulo 32 */ __header_always_inline int __sigbits(int __signo) { return __signo > __DARWIN_NSIG ? 0 : (1 << (__signo - 1)); } -#else /* !__i386__ && !__x86_64__ */ -#define __sigbits(signo) (1 << ((signo) - 1)) -#endif /* __i386__ || __x86_64__ */ #define sigaddset(set, signo) (*(set) |= __sigbits(signo), 0) #define sigdelset(set, signo) (*(set) &= ~__sigbits(signo), 0) diff --git a/lib/libc/include/x86_64-macos-gnu/simd/base.h b/lib/libc/include/x86_64-macos-gnu/simd/base.h new file mode 100644 index 0000000000..01371186dc --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/base.h @@ -0,0 +1,122 @@ +/*! @header + * This header defines macros used in the implementation of + * types and functions. Even though they are exposed in a public header, + * the macros defined in this header are implementation details, and you + * should not use or rely on them. They may be changed or removed entirely + * in a future release. + * + * @copyright 2016-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_BASE +#define SIMD_BASE + +/* Define __has_attribute and __has_include if they aren't available */ +# ifndef __has_attribute +# define __has_attribute(__x) 0 +# endif +# ifndef __has_include +# define __has_include(__x) 0 +# endif +# ifndef __has_feature +# define __has_feature(__x) 0 +# endif + +# if __has_attribute(__ext_vector_type__) && __has_attribute(__overloadable__) +# define SIMD_COMPILER_HAS_REQUIRED_FEATURES 1 +# else +/* Your compiler is missing one or more features that are hard requirements + * for any support. None of the types or functions defined by + * the simd headers will be available. */ +# define SIMD_COMPILER_HAS_REQUIRED_FEATURES 0 +# endif + +# if SIMD_COMPILER_HAS_REQUIRED_FEATURES +# if __has_include() +# include +/* A number of new features are added in newer releases; most of these are + * inline in the header, which makes them available even when targeting older + * OS versions. Those that make external calls, however, are only available + * when targeting the release in which they became available. Because of the + * way in which simd functions are overloaded, the usual weak-linking tricks + * do not work; these functions are simply unavailable when targeting older + * versions of the library. */ +# if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13 || \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_11_0 || \ + __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_4_0 || \ + __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_11_0 || \ + __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_19_0 +# define SIMD_LIBRARY_VERSION 3 +# elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12 || \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0 || \ + __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0 || \ + __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0 +# define SIMD_LIBRARY_VERSION 2 +# elif __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 +# define SIMD_LIBRARY_VERSION 1 +# else +# define SIMD_LIBRARY_VERSION 0 +# endif +# else /* !__has_include() */ +# define SIMD_LIBRARY_VERSION 3 +# define __API_AVAILABLE(...) /* Nothing */ +# endif + +/* The simd types interoperate with the native simd intrinsic types for each + * architecture; the headers that define those types and operations are + * automatically included with simd.h */ +# if defined __ARM_NEON__ +# include +# elif defined __i386__ || defined __x86_64__ +# include +# endif + +/* Define a number of function attributes used by the simd functions. */ +# if __has_attribute(__always_inline__) +# define SIMD_INLINE __attribute__((__always_inline__)) +# else +# define SIMD_INLINE inline +# endif + +# if __has_attribute(__const__) +# define SIMD_CONST __attribute__((__const__)) +# else +# define SIMD_CONST /* nothing */ +# endif + +# if __has_attribute(__nodebug__) +# define SIMD_NODEBUG __attribute__((__nodebug__)) +# else +# define SIMD_NODEBUG /* nothing */ +# endif + +# if __has_attribute(__deprecated__) +# define SIMD_DEPRECATED(message) __attribute__((__deprecated__(message))) +# else +# define SIMD_DEPRECATED(message) /* nothing */ +# endif + +#define SIMD_OVERLOAD __attribute__((__overloadable__)) +#define SIMD_CPPFUNC SIMD_INLINE SIMD_CONST SIMD_NODEBUG +#define SIMD_CFUNC SIMD_CPPFUNC SIMD_OVERLOAD +#define SIMD_NOINLINE SIMD_CONST SIMD_NODEBUG SIMD_OVERLOAD +#define SIMD_NONCONST SIMD_INLINE SIMD_NODEBUG SIMD_OVERLOAD +#define __SIMD_INLINE__ SIMD_CPPFUNC +#define __SIMD_ATTRIBUTES__ SIMD_CFUNC +#define __SIMD_OVERLOAD__ SIMD_OVERLOAD + +#if defined __cplusplus +/*! @abstract A boolean scalar. */ +typedef bool simd_bool; +#else +/*! @abstract A boolean scalar. */ +typedef _Bool simd_bool; +#endif +/*! @abstract A boolean scalar. + * @discussion This type is deprecated; In C or Objective-C sources, use + * `_Bool` instead. In C++ sources, use `bool`. */ +typedef simd_bool __SIMD_BOOLEAN_TYPE__; + +# endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* defined SIMD_BASE */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/common.h b/lib/libc/include/x86_64-macos-gnu/simd/common.h new file mode 100644 index 0000000000..c23c323590 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/common.h @@ -0,0 +1,4458 @@ +/*! @header + * The interfaces declared in this header provide "common" elementwise + * operations that are neither math nor logic functions. These are available + * only for floating-point vectors and scalars, except for min, max, abs, + * clamp, and the reduce operations, which also support integer vectors. + * + * simd_abs(x) Absolute value of x. Also available as fabs + * for floating-point vectors. If x is the + * smallest signed integer, x is returned. + * + * simd_max(x,y) Returns the maximum of x and y. Also available + * as fmax for floating-point vectors. + * + * simd_min(x,y) Returns the minimum of x and y. Also available + * as fmin for floating-point vectors. + * + * simd_clamp(x,min,max) x clamped to the range [min, max]. + * + * simd_sign(x) -1 if x is less than zero, 0 if x is zero or + * NaN, and +1 if x is greater than zero. + * + * simd_mix(x,y,t) If t is not in the range [0,1], the result is + * undefined. Otherwise the result is x+(y-x)*t, + * which linearly interpolates between x and y. + * + * simd_recip(x) An approximation to 1/x. If x is very near the + * limits of representable values, or is infinity + * or NaN, the result is undefined. There are + * two variants of this function: + * + * simd_precise_recip(x) + * + * and + * + * simd_fast_recip(x). + * + * The "precise" variant is accurate to a few ULPs, + * whereas the "fast" variant may have as little + * as 11 bits of accuracy in float and about 22 + * bits in double. + * + * The function simd_recip(x) resolves to + * simd_precise_recip(x) ordinarily, but to + * simd_fast_recip(x) when used in a translation + * unit compiled with -ffast-math (when + * -ffast-math is in effect, you may still use the + * precise version of this function by calling it + * explicitly by name). + * + * simd_rsqrt(x) An approximation to 1/sqrt(x). If x is + * infinity or NaN, the result is undefined. + * There are two variants of this function: + * + * simd_precise_rsqrt(x) + * + * and + * + * simd_fast_rsqrt(x). + * + * The "precise" variant is accurate to a few ULPs, + * whereas the "fast" variant may have as little + * as 11 bits of accuracy in float and about 22 + * bits in double. + * + * The function simd_rsqrt(x) resolves to + * simd_precise_rsqrt(x) ordinarily, but to + * simd_fast_rsqrt(x) when used in a translation + * unit compiled with -ffast-math (when + * -ffast-math is in effect, you may still use the + * precise version of this function by calling it + * explicitly by name). + * + * simd_fract(x) The "fractional part" of x, which lies strictly + * in the range [0, 0x1.fffffep-1]. + * + * simd_step(edge,x) 0 if x < edge, and 1 otherwise. + * + * simd_smoothstep(edge0,edge1,x) 0 if x <= edge0, 1 if x >= edge1, and + * a Hermite interpolation between 0 and 1 if + * edge0 < x < edge1. + * + * simd_reduce_add(x) Sum of the elements of x. + * + * simd_reduce_min(x) Minimum of the elements of x. + * + * simd_reduce_max(x) Maximum of the elements of x. + * + * simd_equal(x,y) True if and only if every lane of x is equal + * to the corresponding lane of y. + * + * The following common functions are available in the simd:: namespace: + * + * C++ Function Equivalent C Function + * -------------------------------------------------------------------- + * simd::abs(x) simd_abs(x) + * simd::max(x,y) simd_max(x,y) + * simd::min(x,y) simd_min(x,y) + * simd::clamp(x,min,max) simd_clamp(x,min,max) + * simd::sign(x) simd_sign(x) + * simd::mix(x,y,t) simd_mix(x,y,t) + * simd::recip(x) simd_recip(x) + * simd::rsqrt(x) simd_rsqrt(x) + * simd::fract(x) simd_fract(x) + * simd::step(edge,x) simd_step(edge,x) + * simd::smoothstep(e0,e1,x) simd_smoothstep(e0,e1,x) + * simd::reduce_add(x) simd_reduce_add(x) + * simd::reduce_max(x) simd_reduce_max(x) + * simd::reduce_min(x) simd_reduce_min(x) + * simd::equal(x,y) simd_equal(x,y) + * + * simd::precise::recip(x) simd_precise_recip(x) + * simd::precise::rsqrt(x) simd_precise_rsqrt(x) + * + * simd::fast::recip(x) simd_fast_recip(x) + * simd::fast::rsqrt(x) simd_fast_rsqrt(x) + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_COMMON_HEADER +#define SIMD_COMMON_HEADER + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char2 simd_abs(simd_char2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char3 simd_abs(simd_char3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char4 simd_abs(simd_char4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char8 simd_abs(simd_char8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char16 simd_abs(simd_char16 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char32 simd_abs(simd_char32 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char64 simd_abs(simd_char64 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short2 simd_abs(simd_short2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short3 simd_abs(simd_short3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short4 simd_abs(simd_short4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short8 simd_abs(simd_short8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short16 simd_abs(simd_short16 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short32 simd_abs(simd_short32 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int2 simd_abs(simd_int2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int3 simd_abs(simd_int3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int4 simd_abs(simd_int4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int8 simd_abs(simd_int8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int16 simd_abs(simd_int16 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float2 simd_abs(simd_float2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float3 simd_abs(simd_float3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float4 simd_abs(simd_float4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float8 simd_abs(simd_float8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float16 simd_abs(simd_float16 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_long2 simd_abs(simd_long2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_long3 simd_abs(simd_long3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_long4 simd_abs(simd_long4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_long8 simd_abs(simd_long8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_double2 simd_abs(simd_double2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_double3 simd_abs(simd_double3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_double4 simd_abs(simd_double4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_double8 simd_abs(simd_double8 x); +/*! @abstract The elementwise absolute value of x. + * @discussion Deprecated. Use simd_abs(x) instead. */ +#define vector_abs simd_abs + +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char2 simd_max(simd_char2 x, simd_char2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char3 simd_max(simd_char3 x, simd_char3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char4 simd_max(simd_char4 x, simd_char4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char8 simd_max(simd_char8 x, simd_char8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char16 simd_max(simd_char16 x, simd_char16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char32 simd_max(simd_char32 x, simd_char32 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char64 simd_max(simd_char64 x, simd_char64 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar2 simd_max(simd_uchar2 x, simd_uchar2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar3 simd_max(simd_uchar3 x, simd_uchar3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar4 simd_max(simd_uchar4 x, simd_uchar4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar8 simd_max(simd_uchar8 x, simd_uchar8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar16 simd_max(simd_uchar16 x, simd_uchar16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar32 simd_max(simd_uchar32 x, simd_uchar32 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar64 simd_max(simd_uchar64 x, simd_uchar64 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short2 simd_max(simd_short2 x, simd_short2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short3 simd_max(simd_short3 x, simd_short3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short4 simd_max(simd_short4 x, simd_short4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short8 simd_max(simd_short8 x, simd_short8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short16 simd_max(simd_short16 x, simd_short16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short32 simd_max(simd_short32 x, simd_short32 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort2 simd_max(simd_ushort2 x, simd_ushort2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort3 simd_max(simd_ushort3 x, simd_ushort3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort4 simd_max(simd_ushort4 x, simd_ushort4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort8 simd_max(simd_ushort8 x, simd_ushort8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort16 simd_max(simd_ushort16 x, simd_ushort16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort32 simd_max(simd_ushort32 x, simd_ushort32 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int2 simd_max(simd_int2 x, simd_int2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int3 simd_max(simd_int3 x, simd_int3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int4 simd_max(simd_int4 x, simd_int4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int8 simd_max(simd_int8 x, simd_int8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int16 simd_max(simd_int16 x, simd_int16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint2 simd_max(simd_uint2 x, simd_uint2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint3 simd_max(simd_uint3 x, simd_uint3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint4 simd_max(simd_uint4 x, simd_uint4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint8 simd_max(simd_uint8 x, simd_uint8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint16 simd_max(simd_uint16 x, simd_uint16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC float simd_max(float x, float y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float2 simd_max(simd_float2 x, simd_float2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float3 simd_max(simd_float3 x, simd_float3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float4 simd_max(simd_float4 x, simd_float4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float8 simd_max(simd_float8 x, simd_float8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float16 simd_max(simd_float16 x, simd_float16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_long2 simd_max(simd_long2 x, simd_long2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_long3 simd_max(simd_long3 x, simd_long3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_long4 simd_max(simd_long4 x, simd_long4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_long8 simd_max(simd_long8 x, simd_long8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ulong2 simd_max(simd_ulong2 x, simd_ulong2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ulong3 simd_max(simd_ulong3 x, simd_ulong3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ulong4 simd_max(simd_ulong4 x, simd_ulong4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ulong8 simd_max(simd_ulong8 x, simd_ulong8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC double simd_max(double x, double y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_double2 simd_max(simd_double2 x, simd_double2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_double3 simd_max(simd_double3 x, simd_double3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_double4 simd_max(simd_double4 x, simd_double4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_double8 simd_max(simd_double8 x, simd_double8 y); +/*! @abstract The elementwise maximum of x and y. + * @discussion Deprecated. Use simd_max(x,y) instead. */ +#define vector_max simd_max + +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char2 simd_min(simd_char2 x, simd_char2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char3 simd_min(simd_char3 x, simd_char3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char4 simd_min(simd_char4 x, simd_char4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char8 simd_min(simd_char8 x, simd_char8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char16 simd_min(simd_char16 x, simd_char16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char32 simd_min(simd_char32 x, simd_char32 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char64 simd_min(simd_char64 x, simd_char64 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar2 simd_min(simd_uchar2 x, simd_uchar2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar3 simd_min(simd_uchar3 x, simd_uchar3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar4 simd_min(simd_uchar4 x, simd_uchar4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar8 simd_min(simd_uchar8 x, simd_uchar8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar16 simd_min(simd_uchar16 x, simd_uchar16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar32 simd_min(simd_uchar32 x, simd_uchar32 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar64 simd_min(simd_uchar64 x, simd_uchar64 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short2 simd_min(simd_short2 x, simd_short2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short3 simd_min(simd_short3 x, simd_short3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short4 simd_min(simd_short4 x, simd_short4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short8 simd_min(simd_short8 x, simd_short8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short16 simd_min(simd_short16 x, simd_short16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short32 simd_min(simd_short32 x, simd_short32 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort2 simd_min(simd_ushort2 x, simd_ushort2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort3 simd_min(simd_ushort3 x, simd_ushort3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort4 simd_min(simd_ushort4 x, simd_ushort4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort8 simd_min(simd_ushort8 x, simd_ushort8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort16 simd_min(simd_ushort16 x, simd_ushort16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort32 simd_min(simd_ushort32 x, simd_ushort32 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int2 simd_min(simd_int2 x, simd_int2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int3 simd_min(simd_int3 x, simd_int3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int4 simd_min(simd_int4 x, simd_int4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int8 simd_min(simd_int8 x, simd_int8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int16 simd_min(simd_int16 x, simd_int16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint2 simd_min(simd_uint2 x, simd_uint2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint3 simd_min(simd_uint3 x, simd_uint3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint4 simd_min(simd_uint4 x, simd_uint4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint8 simd_min(simd_uint8 x, simd_uint8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint16 simd_min(simd_uint16 x, simd_uint16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC float simd_min(float x, float y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float2 simd_min(simd_float2 x, simd_float2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float3 simd_min(simd_float3 x, simd_float3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float4 simd_min(simd_float4 x, simd_float4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float8 simd_min(simd_float8 x, simd_float8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float16 simd_min(simd_float16 x, simd_float16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_long2 simd_min(simd_long2 x, simd_long2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_long3 simd_min(simd_long3 x, simd_long3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_long4 simd_min(simd_long4 x, simd_long4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_long8 simd_min(simd_long8 x, simd_long8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ulong2 simd_min(simd_ulong2 x, simd_ulong2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ulong3 simd_min(simd_ulong3 x, simd_ulong3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ulong4 simd_min(simd_ulong4 x, simd_ulong4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ulong8 simd_min(simd_ulong8 x, simd_ulong8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC double simd_min(double x, double y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_double2 simd_min(simd_double2 x, simd_double2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_double3 simd_min(simd_double3 x, simd_double3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_double4 simd_min(simd_double4 x, simd_double4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_double8 simd_min(simd_double8 x, simd_double8 y); +/*! @abstract The elementwise minimum of x and y. + * @discussion Deprecated. Use simd_min(x,y) instead. */ +#define vector_min simd_min + + +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char2 simd_clamp(simd_char2 x, simd_char2 min, simd_char2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char3 simd_clamp(simd_char3 x, simd_char3 min, simd_char3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char4 simd_clamp(simd_char4 x, simd_char4 min, simd_char4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char8 simd_clamp(simd_char8 x, simd_char8 min, simd_char8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char16 simd_clamp(simd_char16 x, simd_char16 min, simd_char16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char32 simd_clamp(simd_char32 x, simd_char32 min, simd_char32 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char64 simd_clamp(simd_char64 x, simd_char64 min, simd_char64 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar2 simd_clamp(simd_uchar2 x, simd_uchar2 min, simd_uchar2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar3 simd_clamp(simd_uchar3 x, simd_uchar3 min, simd_uchar3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar4 simd_clamp(simd_uchar4 x, simd_uchar4 min, simd_uchar4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar8 simd_clamp(simd_uchar8 x, simd_uchar8 min, simd_uchar8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar16 simd_clamp(simd_uchar16 x, simd_uchar16 min, simd_uchar16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar32 simd_clamp(simd_uchar32 x, simd_uchar32 min, simd_uchar32 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar64 simd_clamp(simd_uchar64 x, simd_uchar64 min, simd_uchar64 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short2 simd_clamp(simd_short2 x, simd_short2 min, simd_short2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short3 simd_clamp(simd_short3 x, simd_short3 min, simd_short3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short4 simd_clamp(simd_short4 x, simd_short4 min, simd_short4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short8 simd_clamp(simd_short8 x, simd_short8 min, simd_short8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short16 simd_clamp(simd_short16 x, simd_short16 min, simd_short16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short32 simd_clamp(simd_short32 x, simd_short32 min, simd_short32 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort2 simd_clamp(simd_ushort2 x, simd_ushort2 min, simd_ushort2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort3 simd_clamp(simd_ushort3 x, simd_ushort3 min, simd_ushort3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort4 simd_clamp(simd_ushort4 x, simd_ushort4 min, simd_ushort4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort8 simd_clamp(simd_ushort8 x, simd_ushort8 min, simd_ushort8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort16 simd_clamp(simd_ushort16 x, simd_ushort16 min, simd_ushort16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort32 simd_clamp(simd_ushort32 x, simd_ushort32 min, simd_ushort32 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int2 simd_clamp(simd_int2 x, simd_int2 min, simd_int2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int3 simd_clamp(simd_int3 x, simd_int3 min, simd_int3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int4 simd_clamp(simd_int4 x, simd_int4 min, simd_int4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int8 simd_clamp(simd_int8 x, simd_int8 min, simd_int8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int16 simd_clamp(simd_int16 x, simd_int16 min, simd_int16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint2 simd_clamp(simd_uint2 x, simd_uint2 min, simd_uint2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint3 simd_clamp(simd_uint3 x, simd_uint3 min, simd_uint3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint4 simd_clamp(simd_uint4 x, simd_uint4 min, simd_uint4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint8 simd_clamp(simd_uint8 x, simd_uint8 min, simd_uint8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint16 simd_clamp(simd_uint16 x, simd_uint16 min, simd_uint16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC float simd_clamp(float x, float min, float max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float2 simd_clamp(simd_float2 x, simd_float2 min, simd_float2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float3 simd_clamp(simd_float3 x, simd_float3 min, simd_float3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float4 simd_clamp(simd_float4 x, simd_float4 min, simd_float4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float8 simd_clamp(simd_float8 x, simd_float8 min, simd_float8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float16 simd_clamp(simd_float16 x, simd_float16 min, simd_float16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_long2 simd_clamp(simd_long2 x, simd_long2 min, simd_long2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_long3 simd_clamp(simd_long3 x, simd_long3 min, simd_long3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_long4 simd_clamp(simd_long4 x, simd_long4 min, simd_long4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_long8 simd_clamp(simd_long8 x, simd_long8 min, simd_long8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ulong2 simd_clamp(simd_ulong2 x, simd_ulong2 min, simd_ulong2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ulong3 simd_clamp(simd_ulong3 x, simd_ulong3 min, simd_ulong3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ulong4 simd_clamp(simd_ulong4 x, simd_ulong4 min, simd_ulong4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ulong8 simd_clamp(simd_ulong8 x, simd_ulong8 min, simd_ulong8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC double simd_clamp(double x, double min, double max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_double2 simd_clamp(simd_double2 x, simd_double2 min, simd_double2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_double3 simd_clamp(simd_double3 x, simd_double3 min, simd_double3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_double4 simd_clamp(simd_double4 x, simd_double4 min, simd_double4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_double8 simd_clamp(simd_double8 x, simd_double8 min, simd_double8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Deprecated. Use simd_clamp(x,min,max) instead. */ +#define vector_clamp simd_clamp + +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC float simd_sign(float x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float2 simd_sign(simd_float2 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float3 simd_sign(simd_float3 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float4 simd_sign(simd_float4 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float8 simd_sign(simd_float8 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float16 simd_sign(simd_float16 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC double simd_sign(double x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_double2 simd_sign(simd_double2 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_double3 simd_sign(simd_double3 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_double4 simd_sign(simd_double4 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_double8 simd_sign(simd_double8 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. + * @discussion Deprecated. Use simd_sign(x) instead. */ +#define vector_sign simd_sign + +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC float simd_mix(float x, float y, float t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float2 simd_mix(simd_float2 x, simd_float2 y, simd_float2 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float3 simd_mix(simd_float3 x, simd_float3 y, simd_float3 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float4 simd_mix(simd_float4 x, simd_float4 y, simd_float4 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float8 simd_mix(simd_float8 x, simd_float8 y, simd_float8 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float16 simd_mix(simd_float16 x, simd_float16 y, simd_float16 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC double simd_mix(double x, double y, double t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_double2 simd_mix(simd_double2 x, simd_double2 y, simd_double2 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_double3 simd_mix(simd_double3 x, simd_double3 y, simd_double3 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_double4 simd_mix(simd_double4 x, simd_double4 y, simd_double4 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_double8 simd_mix(simd_double8 x, simd_double8 y, simd_double8 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 + * @discussion Deprecated. Use simd_mix(x, y, t) instead. */ +#define vector_mix simd_mix + +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC float simd_precise_recip(float x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float2 simd_precise_recip(simd_float2 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float3 simd_precise_recip(simd_float3 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float4 simd_precise_recip(simd_float4 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float8 simd_precise_recip(simd_float8 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float16 simd_precise_recip(simd_float16 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC double simd_precise_recip(double x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_double2 simd_precise_recip(simd_double2 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_double3 simd_precise_recip(simd_double3 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_double4 simd_precise_recip(simd_double4 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_double8 simd_precise_recip(simd_double8 x); +/*! @abstract A good approximation to 1/x. + * @discussion Deprecated. Use simd_precise_recip(x) instead. */ +#define vector_precise_recip simd_precise_recip + +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC float simd_fast_recip(float x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float2 simd_fast_recip(simd_float2 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float3 simd_fast_recip(simd_float3 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float4 simd_fast_recip(simd_float4 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float8 simd_fast_recip(simd_float8 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float16 simd_fast_recip(simd_float16 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC double simd_fast_recip(double x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_double2 simd_fast_recip(simd_double2 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_double3 simd_fast_recip(simd_double3 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_double4 simd_fast_recip(simd_double4 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_double8 simd_fast_recip(simd_double8 x); +/*! @abstract A fast approximation to 1/x. + * @discussion Deprecated. Use simd_fast_recip(x) instead. */ +#define vector_fast_recip simd_fast_recip + +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC float simd_recip(float x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float2 simd_recip(simd_float2 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float3 simd_recip(simd_float3 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float4 simd_recip(simd_float4 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float8 simd_recip(simd_float8 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float16 simd_recip(simd_float16 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC double simd_recip(double x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double2 simd_recip(simd_double2 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double3 simd_recip(simd_double3 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double4 simd_recip(simd_double4 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double8 simd_recip(simd_double8 x); +/*! @abstract An approximation to 1/x. + * @discussion Deprecated. Use simd_recip(x) instead. */ +#define vector_recip simd_recip + +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC float simd_precise_rsqrt(float x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float2 simd_precise_rsqrt(simd_float2 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float3 simd_precise_rsqrt(simd_float3 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float4 simd_precise_rsqrt(simd_float4 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float8 simd_precise_rsqrt(simd_float8 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float16 simd_precise_rsqrt(simd_float16 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC double simd_precise_rsqrt(double x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_double2 simd_precise_rsqrt(simd_double2 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_double3 simd_precise_rsqrt(simd_double3 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_double4 simd_precise_rsqrt(simd_double4 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_double8 simd_precise_rsqrt(simd_double8 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion Deprecated. Use simd_precise_rsqrt(x) instead. */ +#define vector_precise_rsqrt simd_precise_rsqrt + +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC float simd_fast_rsqrt(float x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float2 simd_fast_rsqrt(simd_float2 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float3 simd_fast_rsqrt(simd_float3 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float4 simd_fast_rsqrt(simd_float4 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float8 simd_fast_rsqrt(simd_float8 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float16 simd_fast_rsqrt(simd_float16 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC double simd_fast_rsqrt(double x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_double2 simd_fast_rsqrt(simd_double2 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_double3 simd_fast_rsqrt(simd_double3 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_double4 simd_fast_rsqrt(simd_double4 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_double8 simd_fast_rsqrt(simd_double8 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion Deprecated. Use simd_fast_rsqrt(x) instead. */ +#define vector_fast_rsqrt simd_fast_rsqrt + +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC float simd_rsqrt(float x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float2 simd_rsqrt(simd_float2 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float3 simd_rsqrt(simd_float3 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float4 simd_rsqrt(simd_float4 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float8 simd_rsqrt(simd_float8 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float16 simd_rsqrt(simd_float16 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC double simd_rsqrt(double x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double2 simd_rsqrt(simd_double2 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double3 simd_rsqrt(simd_double3 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double4 simd_rsqrt(simd_double4 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double8 simd_rsqrt(simd_double8 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion Deprecated. Use simd_rsqrt(x) instead. */ +#define vector_rsqrt simd_rsqrt + +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC float simd_fract(float x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float2 simd_fract(simd_float2 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float3 simd_fract(simd_float3 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float4 simd_fract(simd_float4 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float8 simd_fract(simd_float8 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float16 simd_fract(simd_float16 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC double simd_fract(double x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_double2 simd_fract(simd_double2 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_double3 simd_fract(simd_double3 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_double4 simd_fract(simd_double4 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_double8 simd_fract(simd_double8 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion Deprecated. Use simd_fract(x) instead. */ +#define vector_fract simd_fract + +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC float simd_step(float edge, float x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float2 simd_step(simd_float2 edge, simd_float2 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float3 simd_step(simd_float3 edge, simd_float3 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float4 simd_step(simd_float4 edge, simd_float4 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float8 simd_step(simd_float8 edge, simd_float8 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float16 simd_step(simd_float16 edge, simd_float16 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC double simd_step(double edge, double x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_double2 simd_step(simd_double2 edge, simd_double2 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_double3 simd_step(simd_double3 edge, simd_double3 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_double4 simd_step(simd_double4 edge, simd_double4 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_double8 simd_step(simd_double8 edge, simd_double8 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Deprecated. Use simd_step(edge, x) instead. */ +#define vector_step simd_step + +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC float simd_smoothstep(float edge0, float edge1, float x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float2 simd_smoothstep(simd_float2 edge0, simd_float2 edge1, simd_float2 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float3 simd_smoothstep(simd_float3 edge0, simd_float3 edge1, simd_float3 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float4 simd_smoothstep(simd_float4 edge0, simd_float4 edge1, simd_float4 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float8 simd_smoothstep(simd_float8 edge0, simd_float8 edge1, simd_float8 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float16 simd_smoothstep(simd_float16 edge0, simd_float16 edge1, simd_float16 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC double simd_smoothstep(double edge0, double edge1, double x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_double2 simd_smoothstep(simd_double2 edge0, simd_double2 edge1, simd_double2 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_double3 simd_smoothstep(simd_double3 edge0, simd_double3 edge1, simd_double3 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_double4 simd_smoothstep(simd_double4 edge0, simd_double4 edge1, simd_double4 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_double8 simd_smoothstep(simd_double8 edge0, simd_double8 edge1, simd_double8 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion Deprecated. Use simd_smoothstep(edge0, edge1, x) instead. */ +#define vector_smoothstep simd_smoothstep + +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char32 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char64 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar32 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar64 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short32 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort32 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC double simd_reduce_add(simd_double2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC double simd_reduce_add(simd_double3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC double simd_reduce_add(simd_double4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC double simd_reduce_add(simd_double8 x); +/*! @abstract Sum of elements in x. + * @discussion Deprecated. Use simd_add(x) instead. */ +#define vector_reduce_add simd_reduce_add + +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char32 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char64 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar32 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar64 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short32 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort32 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_min(simd_double2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_min(simd_double3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_min(simd_double4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_min(simd_double8 x); +/*! @abstract Minimum of elements in x. + * @discussion Deprecated. Use simd_min(x) instead. */ +#define vector_reduce_min simd_reduce_min + +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char32 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char64 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar32 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar64 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short32 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort32 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_max(simd_double2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_max(simd_double3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_max(simd_double4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_max(simd_double8 x); +/*! @abstract Maximum of elements in x. + * @discussion Deprecated. Use simd_max(x) instead. */ +#define vector_reduce_max simd_reduce_max + +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char2 x, simd_char2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char3 x, simd_char3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char4 x, simd_char4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char8 x, simd_char8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char16 x, simd_char16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char32 x, simd_char32 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char64 x, simd_char64 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar2 x, simd_uchar2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar3 x, simd_uchar3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar4 x, simd_uchar4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar8 x, simd_uchar8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar16 x, simd_uchar16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar32 x, simd_uchar32 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar64 x, simd_uchar64 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short2 x, simd_short2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short3 x, simd_short3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short4 x, simd_short4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short8 x, simd_short8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short16 x, simd_short16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short32 x, simd_short32 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort2 x, simd_ushort2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort3 x, simd_ushort3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort4 x, simd_ushort4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort8 x, simd_ushort8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort16 x, simd_ushort16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort32 x, simd_ushort32 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int2 x, simd_int2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int3 x, simd_int3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int4 x, simd_int4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int8 x, simd_int8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int16 x, simd_int16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint2 x, simd_uint2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint3 x, simd_uint3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint4 x, simd_uint4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint8 x, simd_uint8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint16 x, simd_uint16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float2 x, simd_float2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float3 x, simd_float3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float4 x, simd_float4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float8 x, simd_float8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float16 x, simd_float16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_long2 x, simd_long2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_long3 x, simd_long3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_long4 x, simd_long4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_long8 x, simd_long8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong2 x, simd_ulong2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong3 x, simd_ulong3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong4 x, simd_ulong4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong8 x, simd_ulong8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_double2 x, simd_double2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_double3 x, simd_double3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_double4 x, simd_double4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_double8 x, simd_double8 y) { + return simd_all(x == y); +} + +#ifdef __cplusplus +} /* extern "C" */ + +namespace simd { + /*! @abstract The lanewise absolute value of x. */ + template static SIMD_CPPFUNC typeN abs(const typeN x) { return ::simd_abs(x); } + /*! @abstract The lanewise maximum of x and y. */ + template static SIMD_CPPFUNC typeN max(const typeN x, const typeN y) { return ::simd_max(x,y); } + /*! @abstract The lanewise minimum of x and y. */ + template static SIMD_CPPFUNC typeN min(const typeN x, const typeN y) { return ::simd_min(x,y); } + /*! @abstract x clamped to the interval [min, max]. */ + template static SIMD_CPPFUNC typeN clamp(const typeN x, const typeN min, const typeN max) { return ::simd_clamp(x,min,max); } + /*! @abstract -1 if x < 0, +1 if x > 0, and 0 otherwise. */ + template static SIMD_CPPFUNC fptypeN sign(const fptypeN x) { return ::simd_sign(x); } + /*! @abstract Linearly interpolates between x and y, taking the value x when t=0 and y when t=1 */ + template static SIMD_CPPFUNC fptypeN mix(const fptypeN x, const fptypeN y, const fptypeN t) { return ::simd_mix(x,y,t); } + /*! @abstract An approximation to 1/x. */ + template static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return simd_recip(x); } + /*! @abstract An approximation to 1/sqrt(x). */ + template static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return simd_rsqrt(x); } + /*! @abstract The "fracional part" of x, in the range [0,1). */ + template static SIMD_CPPFUNC fptypeN fract(const fptypeN x) { return ::simd_fract(x); } + /*! @abstract 0 if x < edge, 1 otherwise. */ + template static SIMD_CPPFUNC fptypeN step(const fptypeN edge, const fptypeN x) { return ::simd_step(edge,x); } + /*! @abstract smoothly interpolates from 0 at edge0 to 1 at edge1. */ + template static SIMD_CPPFUNC fptypeN smoothstep(const fptypeN edge0, const fptypeN edge1, const fptypeN x) { return ::simd_smoothstep(edge0,edge1,x); } + /*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. + * + * @discussion This isn't operator== because that's already defined by + * the compiler to return a lane mask. */ + template static SIMD_CPPFUNC simd_bool equal(const fptypeN x, const fptypeN y) { return ::simd_equal(x, y); } +#if __cpp_decltype_auto + /* If you are targeting an earlier version of the C++ standard that lacks + decltype_auto support, you may use the C-style simd_reduce_* functions + instead. */ + /*! @abstract The sum of the elements in x. May overflow. */ + template static SIMD_CPPFUNC auto reduce_add(typeN x) { return ::simd_reduce_add(x); } + /*! @abstract The least element in x. */ + template static SIMD_CPPFUNC auto reduce_min(typeN x) { return ::simd_reduce_min(x); } + /*! @abstract The greatest element in x. */ + template static SIMD_CPPFUNC auto reduce_max(typeN x) { return ::simd_reduce_max(x); } +#endif + namespace precise { + /*! @abstract An approximation to 1/x. */ + template static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return ::simd_precise_recip(x); } + /*! @abstract An approximation to 1/sqrt(x). */ + template static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return ::simd_precise_rsqrt(x); } + } + namespace fast { + /*! @abstract An approximation to 1/x. */ + template static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return ::simd_fast_recip(x); } + /*! @abstract An approximation to 1/sqrt(x). */ + template static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return ::simd_fast_rsqrt(x); } + } +} + +extern "C" { +#endif /* __cplusplus */ + +#pragma mark - Implementation + +static inline SIMD_CFUNC simd_char2 simd_abs(simd_char2 x) { + return simd_make_char2(simd_abs(simd_make_char8_undef(x))); +} + +static inline SIMD_CFUNC simd_char3 simd_abs(simd_char3 x) { + return simd_make_char3(simd_abs(simd_make_char8_undef(x))); +} + +static inline SIMD_CFUNC simd_char4 simd_abs(simd_char4 x) { + return simd_make_char4(simd_abs(simd_make_char8_undef(x))); +} + +static inline SIMD_CFUNC simd_char8 simd_abs(simd_char8 x) { +#if defined __arm__ || defined __arm64__ + return vabs_s8(x); +#else + return simd_make_char8(simd_abs(simd_make_char16_undef(x))); +#endif +} + +static inline SIMD_CFUNC simd_char16 simd_abs(simd_char16 x) { +#if defined __arm__ || defined __arm64__ + return vabsq_s8(x); +#elif defined __SSE4_1__ + return (simd_char16) _mm_abs_epi8((__m128i)x); +#else + simd_char16 mask = x >> 7; return (x ^ mask) - mask; +#endif +} + +static inline SIMD_CFUNC simd_char32 simd_abs(simd_char32 x) { +#if defined __AVX2__ + return _mm256_abs_epi8(x); +#else + return simd_make_char32(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_char64 simd_abs(simd_char64 x) { +#if defined __AVX512BW__ + return _mm512_abs_epi8(x); +#else + return simd_make_char64(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_short2 simd_abs(simd_short2 x) { + return simd_make_short2(simd_abs(simd_make_short4_undef(x))); +} + +static inline SIMD_CFUNC simd_short3 simd_abs(simd_short3 x) { + return simd_make_short3(simd_abs(simd_make_short4_undef(x))); +} + +static inline SIMD_CFUNC simd_short4 simd_abs(simd_short4 x) { +#if defined __arm__ || defined __arm64__ + return vabs_s16(x); +#else + return simd_make_short4(simd_abs(simd_make_short8_undef(x))); +#endif +} + +static inline SIMD_CFUNC simd_short8 simd_abs(simd_short8 x) { +#if defined __arm__ || defined __arm64__ + return vabsq_s16(x); +#elif defined __SSE4_1__ + return (simd_short8) _mm_abs_epi16((__m128i)x); +#else + simd_short8 mask = x >> 15; return (x ^ mask) - mask; +#endif +} + +static inline SIMD_CFUNC simd_short16 simd_abs(simd_short16 x) { +#if defined __AVX2__ + return _mm256_abs_epi16(x); +#else + return simd_make_short16(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_short32 simd_abs(simd_short32 x) { +#if defined __AVX512BW__ + return _mm512_abs_epi16(x); +#else + return simd_make_short32(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_int2 simd_abs(simd_int2 x) { +#if defined __arm__ || defined __arm64__ + return vabs_s32(x); +#else + return simd_make_int2(simd_abs(simd_make_int4_undef(x))); +#endif +} + +static inline SIMD_CFUNC simd_int3 simd_abs(simd_int3 x) { + return simd_make_int3(simd_abs(simd_make_int4_undef(x))); +} + +static inline SIMD_CFUNC simd_int4 simd_abs(simd_int4 x) { +#if defined __arm__ || defined __arm64__ + return vabsq_s32(x); +#elif defined __SSE4_1__ + return (simd_int4) _mm_abs_epi32((__m128i)x); +#else + simd_int4 mask = x >> 31; return (x ^ mask) - mask; +#endif +} + +static inline SIMD_CFUNC simd_int8 simd_abs(simd_int8 x) { +#if defined __AVX2__ + return _mm256_abs_epi32(x); +#else + return simd_make_int8(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_int16 simd_abs(simd_int16 x) { +#if defined __AVX512F__ + return _mm512_abs_epi32(x); +#else + return simd_make_int16(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_abs(simd_float2 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_float3 simd_abs(simd_float3 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_float4 simd_abs(simd_float4 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_float8 simd_abs(simd_float8 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_float16 simd_abs(simd_float16 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_long2 simd_abs(simd_long2 x) { +#if defined __arm64__ + return vabsq_s64(x); +#elif defined __SSE4_1__ + return (simd_long2) _mm_abs_epi64((__m128i)x); +#else + simd_long2 mask = x >> 63; return (x ^ mask) - mask; +#endif +} + +static inline SIMD_CFUNC simd_long3 simd_abs(simd_long3 x) { + return simd_make_long3(simd_abs(simd_make_long4_undef(x))); +} + +static inline SIMD_CFUNC simd_long4 simd_abs(simd_long4 x) { +#if defined __AVX2__ + return _mm256_abs_epi64(x); +#else + return simd_make_long4(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_long8 simd_abs(simd_long8 x) { +#if defined __AVX512F__ + return _mm512_abs_epi64(x); +#else + return simd_make_long8(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_double2 simd_abs(simd_double2 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_double3 simd_abs(simd_double3 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_double4 simd_abs(simd_double4 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_double8 simd_abs(simd_double8 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_char2 simd_min(simd_char2 x, simd_char2 y) { + return simd_make_char2(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char3 simd_min(simd_char3 x, simd_char3 y) { + return simd_make_char3(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char4 simd_min(simd_char4 x, simd_char4 y) { + return simd_make_char4(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char8 simd_min(simd_char8 x, simd_char8 y) { +#if defined __arm__ || defined __arm64__ + return vmin_s8(x, y); +#else + return simd_make_char8(simd_min(simd_make_char16_undef(x), simd_make_char16_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_char16 simd_min(simd_char16 x, simd_char16 y) { +#if defined __arm__ || defined __arm64__ + return vminq_s8(x, y); +#elif defined __SSE4_1__ + return (simd_char16) _mm_min_epi8((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_char32 simd_min(simd_char32 x, simd_char32 y) { +#if defined __AVX2__ + return _mm256_min_epi8(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_char64 simd_min(simd_char64 x, simd_char64 y) { +#if defined __AVX512BW__ + return _mm512_min_epi8(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uchar2 simd_min(simd_uchar2 x, simd_uchar2 y) { + return simd_make_uchar2(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar3 simd_min(simd_uchar3 x, simd_uchar3 y) { + return simd_make_uchar3(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar4 simd_min(simd_uchar4 x, simd_uchar4 y) { + return simd_make_uchar4(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar8 simd_min(simd_uchar8 x, simd_uchar8 y) { +#if defined __arm__ || defined __arm64__ + return vmin_u8(x, y); +#else + return simd_make_uchar8(simd_min(simd_make_uchar16_undef(x), simd_make_uchar16_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_uchar16 simd_min(simd_uchar16 x, simd_uchar16 y) { +#if defined __arm__ || defined __arm64__ + return vminq_u8(x, y); +#elif defined __SSE4_1__ + return (simd_uchar16) _mm_min_epu8((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uchar32 simd_min(simd_uchar32 x, simd_uchar32 y) { +#if defined __AVX2__ + return _mm256_min_epu8(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uchar64 simd_min(simd_uchar64 x, simd_uchar64 y) { +#if defined __AVX512BW__ + return _mm512_min_epu8(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_short2 simd_min(simd_short2 x, simd_short2 y) { + return simd_make_short2(simd_min(simd_make_short4_undef(x), simd_make_short4_undef(y))); +} + +static inline SIMD_CFUNC simd_short3 simd_min(simd_short3 x, simd_short3 y) { + return simd_make_short3(simd_min(simd_make_short4_undef(x), simd_make_short4_undef(y))); +} + +static inline SIMD_CFUNC simd_short4 simd_min(simd_short4 x, simd_short4 y) { +#if defined __arm__ || defined __arm64__ + return vmin_s16(x, y); +#else + return simd_make_short4(simd_min(simd_make_short8_undef(x), simd_make_short8_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_short8 simd_min(simd_short8 x, simd_short8 y) { +#if defined __arm__ || defined __arm64__ + return vminq_s16(x, y); +#elif defined __SSE4_1__ + return (simd_short8) _mm_min_epi16((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_short16 simd_min(simd_short16 x, simd_short16 y) { +#if defined __AVX2__ + return _mm256_min_epi16(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_short32 simd_min(simd_short32 x, simd_short32 y) { +#if defined __AVX512BW__ + return _mm512_min_epi16(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ushort2 simd_min(simd_ushort2 x, simd_ushort2 y) { + return simd_make_ushort2(simd_min(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y))); +} + +static inline SIMD_CFUNC simd_ushort3 simd_min(simd_ushort3 x, simd_ushort3 y) { + return simd_make_ushort3(simd_min(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y))); +} + +static inline SIMD_CFUNC simd_ushort4 simd_min(simd_ushort4 x, simd_ushort4 y) { +#if defined __arm__ || defined __arm64__ + return vmin_u16(x, y); +#else + return simd_make_ushort4(simd_min(simd_make_ushort8_undef(x), simd_make_ushort8_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_ushort8 simd_min(simd_ushort8 x, simd_ushort8 y) { +#if defined __arm__ || defined __arm64__ + return vminq_u16(x, y); +#elif defined __SSE4_1__ + return (simd_ushort8) _mm_min_epu16((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ushort16 simd_min(simd_ushort16 x, simd_ushort16 y) { +#if defined __AVX2__ + return _mm256_min_epu16(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ushort32 simd_min(simd_ushort32 x, simd_ushort32 y) { +#if defined __AVX512BW__ + return _mm512_min_epu16(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_int2 simd_min(simd_int2 x, simd_int2 y) { +#if defined __arm__ || defined __arm64__ + return vmin_s32(x, y); +#else + return simd_make_int2(simd_min(simd_make_int4_undef(x), simd_make_int4_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_int3 simd_min(simd_int3 x, simd_int3 y) { + return simd_make_int3(simd_min(simd_make_int4_undef(x), simd_make_int4_undef(y))); +} + +static inline SIMD_CFUNC simd_int4 simd_min(simd_int4 x, simd_int4 y) { +#if defined __arm__ || defined __arm64__ + return vminq_s32(x, y); +#elif defined __SSE4_1__ + return (simd_int4) _mm_min_epi32((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_int8 simd_min(simd_int8 x, simd_int8 y) { +#if defined __AVX2__ + return _mm256_min_epi32(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_int16 simd_min(simd_int16 x, simd_int16 y) { +#if defined __AVX512F__ + return _mm512_min_epi32(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uint2 simd_min(simd_uint2 x, simd_uint2 y) { +#if defined __arm__ || defined __arm64__ + return vmin_u32(x, y); +#else + return simd_make_uint2(simd_min(simd_make_uint4_undef(x), simd_make_uint4_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_uint3 simd_min(simd_uint3 x, simd_uint3 y) { + return simd_make_uint3(simd_min(simd_make_uint4_undef(x), simd_make_uint4_undef(y))); +} + +static inline SIMD_CFUNC simd_uint4 simd_min(simd_uint4 x, simd_uint4 y) { +#if defined __arm__ || defined __arm64__ + return vminq_u32(x, y); +#elif defined __SSE4_1__ + return (simd_uint4) _mm_min_epu32((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uint8 simd_min(simd_uint8 x, simd_uint8 y) { +#if defined __AVX2__ + return _mm256_min_epu32(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uint16 simd_min(simd_uint16 x, simd_uint16 y) { +#if defined __AVX512F__ + return _mm512_min_epu32(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC float simd_min(float x, float y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float2 simd_min(simd_float2 x, simd_float2 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float3 simd_min(simd_float3 x, simd_float3 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float4 simd_min(simd_float4 x, simd_float4 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float8 simd_min(simd_float8 x, simd_float8 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float16 simd_min(simd_float16 x, simd_float16 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_long2 simd_min(simd_long2 x, simd_long2 y) { +#if defined __AVX512VL__ + return _mm_min_epi64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_long3 simd_min(simd_long3 x, simd_long3 y) { + return simd_make_long3(simd_min(simd_make_long4_undef(x), simd_make_long4_undef(y))); +} + +static inline SIMD_CFUNC simd_long4 simd_min(simd_long4 x, simd_long4 y) { +#if defined __AVX512VL__ + return _mm256_min_epi64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_long8 simd_min(simd_long8 x, simd_long8 y) { +#if defined __AVX512F__ + return _mm512_min_epi64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ulong2 simd_min(simd_ulong2 x, simd_ulong2 y) { +#if defined __AVX512VL__ + return _mm_min_epu64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ulong3 simd_min(simd_ulong3 x, simd_ulong3 y) { + return simd_make_ulong3(simd_min(simd_make_ulong4_undef(x), simd_make_ulong4_undef(y))); +} + +static inline SIMD_CFUNC simd_ulong4 simd_min(simd_ulong4 x, simd_ulong4 y) { +#if defined __AVX512VL__ + return _mm256_min_epu64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ulong8 simd_min(simd_ulong8 x, simd_ulong8 y) { +#if defined __AVX512F__ + return _mm512_min_epu64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC double simd_min(double x, double y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_double2 simd_min(simd_double2 x, simd_double2 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_double3 simd_min(simd_double3 x, simd_double3 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_double4 simd_min(simd_double4 x, simd_double4 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_double8 simd_min(simd_double8 x, simd_double8 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_char2 simd_max(simd_char2 x, simd_char2 y) { + return simd_make_char2(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char3 simd_max(simd_char3 x, simd_char3 y) { + return simd_make_char3(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char4 simd_max(simd_char4 x, simd_char4 y) { + return simd_make_char4(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char8 simd_max(simd_char8 x, simd_char8 y) { +#if defined __arm__ || defined __arm64__ + return vmax_s8(x, y); +#else + return simd_make_char8(simd_max(simd_make_char16_undef(x), simd_make_char16_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_char16 simd_max(simd_char16 x, simd_char16 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_s8(x, y); +#elif defined __SSE4_1__ + return (simd_char16) _mm_max_epi8((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_char32 simd_max(simd_char32 x, simd_char32 y) { +#if defined __AVX2__ + return _mm256_max_epi8(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_char64 simd_max(simd_char64 x, simd_char64 y) { +#if defined __AVX512BW__ + return _mm512_max_epi8(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uchar2 simd_max(simd_uchar2 x, simd_uchar2 y) { + return simd_make_uchar2(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar3 simd_max(simd_uchar3 x, simd_uchar3 y) { + return simd_make_uchar3(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar4 simd_max(simd_uchar4 x, simd_uchar4 y) { + return simd_make_uchar4(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar8 simd_max(simd_uchar8 x, simd_uchar8 y) { +#if defined __arm__ || defined __arm64__ + return vmax_u8(x, y); +#else + return simd_make_uchar8(simd_max(simd_make_uchar16_undef(x), simd_make_uchar16_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_uchar16 simd_max(simd_uchar16 x, simd_uchar16 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_u8(x, y); +#elif defined __SSE4_1__ + return (simd_uchar16) _mm_max_epu8((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uchar32 simd_max(simd_uchar32 x, simd_uchar32 y) { +#if defined __AVX2__ + return _mm256_max_epu8(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uchar64 simd_max(simd_uchar64 x, simd_uchar64 y) { +#if defined __AVX512BW__ + return _mm512_max_epu8(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_short2 simd_max(simd_short2 x, simd_short2 y) { + return simd_make_short2(simd_max(simd_make_short4_undef(x), simd_make_short4_undef(y))); +} + +static inline SIMD_CFUNC simd_short3 simd_max(simd_short3 x, simd_short3 y) { + return simd_make_short3(simd_max(simd_make_short4_undef(x), simd_make_short4_undef(y))); +} + +static inline SIMD_CFUNC simd_short4 simd_max(simd_short4 x, simd_short4 y) { +#if defined __arm__ || defined __arm64__ + return vmax_s16(x, y); +#else + return simd_make_short4(simd_max(simd_make_short8_undef(x), simd_make_short8_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_short8 simd_max(simd_short8 x, simd_short8 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_s16(x, y); +#elif defined __SSE4_1__ + return (simd_short8) _mm_max_epi16((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_short16 simd_max(simd_short16 x, simd_short16 y) { +#if defined __AVX2__ + return _mm256_max_epi16(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_short32 simd_max(simd_short32 x, simd_short32 y) { +#if defined __AVX512BW__ + return _mm512_max_epi16(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ushort2 simd_max(simd_ushort2 x, simd_ushort2 y) { + return simd_make_ushort2(simd_max(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y))); +} + +static inline SIMD_CFUNC simd_ushort3 simd_max(simd_ushort3 x, simd_ushort3 y) { + return simd_make_ushort3(simd_max(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y))); +} + +static inline SIMD_CFUNC simd_ushort4 simd_max(simd_ushort4 x, simd_ushort4 y) { +#if defined __arm__ || defined __arm64__ + return vmax_u16(x, y); +#else + return simd_make_ushort4(simd_max(simd_make_ushort8_undef(x), simd_make_ushort8_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_ushort8 simd_max(simd_ushort8 x, simd_ushort8 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_u16(x, y); +#elif defined __SSE4_1__ + return (simd_ushort8) _mm_max_epu16((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ushort16 simd_max(simd_ushort16 x, simd_ushort16 y) { +#if defined __AVX2__ + return _mm256_max_epu16(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ushort32 simd_max(simd_ushort32 x, simd_ushort32 y) { +#if defined __AVX512BW__ + return _mm512_max_epu16(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_int2 simd_max(simd_int2 x, simd_int2 y) { +#if defined __arm__ || defined __arm64__ + return vmax_s32(x, y); +#else + return simd_make_int2(simd_max(simd_make_int4_undef(x), simd_make_int4_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_int3 simd_max(simd_int3 x, simd_int3 y) { + return simd_make_int3(simd_max(simd_make_int4_undef(x), simd_make_int4_undef(y))); +} + +static inline SIMD_CFUNC simd_int4 simd_max(simd_int4 x, simd_int4 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_s32(x, y); +#elif defined __SSE4_1__ + return (simd_int4) _mm_max_epi32((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_int8 simd_max(simd_int8 x, simd_int8 y) { +#if defined __AVX2__ + return _mm256_max_epi32(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_int16 simd_max(simd_int16 x, simd_int16 y) { +#if defined __AVX512F__ + return _mm512_max_epi32(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uint2 simd_max(simd_uint2 x, simd_uint2 y) { +#if defined __arm__ || defined __arm64__ + return vmax_u32(x, y); +#else + return simd_make_uint2(simd_max(simd_make_uint4_undef(x), simd_make_uint4_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_uint3 simd_max(simd_uint3 x, simd_uint3 y) { + return simd_make_uint3(simd_max(simd_make_uint4_undef(x), simd_make_uint4_undef(y))); +} + +static inline SIMD_CFUNC simd_uint4 simd_max(simd_uint4 x, simd_uint4 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_u32(x, y); +#elif defined __SSE4_1__ + return (simd_uint4) _mm_max_epu32((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uint8 simd_max(simd_uint8 x, simd_uint8 y) { +#if defined __AVX2__ + return _mm256_max_epu32(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uint16 simd_max(simd_uint16 x, simd_uint16 y) { +#if defined __AVX512F__ + return _mm512_max_epu32(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC float simd_max(float x, float y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float2 simd_max(simd_float2 x, simd_float2 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float3 simd_max(simd_float3 x, simd_float3 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float4 simd_max(simd_float4 x, simd_float4 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float8 simd_max(simd_float8 x, simd_float8 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float16 simd_max(simd_float16 x, simd_float16 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_long2 simd_max(simd_long2 x, simd_long2 y) { +#if defined __AVX512VL__ + return _mm_max_epi64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_long3 simd_max(simd_long3 x, simd_long3 y) { + return simd_make_long3(simd_max(simd_make_long4_undef(x), simd_make_long4_undef(y))); +} + +static inline SIMD_CFUNC simd_long4 simd_max(simd_long4 x, simd_long4 y) { +#if defined __AVX512VL__ + return _mm256_max_epi64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_long8 simd_max(simd_long8 x, simd_long8 y) { +#if defined __AVX512F__ + return _mm512_max_epi64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ulong2 simd_max(simd_ulong2 x, simd_ulong2 y) { +#if defined __AVX512VL__ + return _mm_max_epu64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ulong3 simd_max(simd_ulong3 x, simd_ulong3 y) { + return simd_make_ulong3(simd_max(simd_make_ulong4_undef(x), simd_make_ulong4_undef(y))); +} + +static inline SIMD_CFUNC simd_ulong4 simd_max(simd_ulong4 x, simd_ulong4 y) { +#if defined __AVX512VL__ + return _mm256_max_epu64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ulong8 simd_max(simd_ulong8 x, simd_ulong8 y) { +#if defined __AVX512F__ + return _mm512_max_epu64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC double simd_max(double x, double y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_double2 simd_max(simd_double2 x, simd_double2 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_double3 simd_max(simd_double3 x, simd_double3 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_double4 simd_max(simd_double4 x, simd_double4 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_double8 simd_max(simd_double8 x, simd_double8 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_char2 simd_clamp(simd_char2 x, simd_char2 min, simd_char2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char3 simd_clamp(simd_char3 x, simd_char3 min, simd_char3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char4 simd_clamp(simd_char4 x, simd_char4 min, simd_char4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char8 simd_clamp(simd_char8 x, simd_char8 min, simd_char8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char16 simd_clamp(simd_char16 x, simd_char16 min, simd_char16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char32 simd_clamp(simd_char32 x, simd_char32 min, simd_char32 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char64 simd_clamp(simd_char64 x, simd_char64 min, simd_char64 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar2 simd_clamp(simd_uchar2 x, simd_uchar2 min, simd_uchar2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar3 simd_clamp(simd_uchar3 x, simd_uchar3 min, simd_uchar3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar4 simd_clamp(simd_uchar4 x, simd_uchar4 min, simd_uchar4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar8 simd_clamp(simd_uchar8 x, simd_uchar8 min, simd_uchar8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar16 simd_clamp(simd_uchar16 x, simd_uchar16 min, simd_uchar16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar32 simd_clamp(simd_uchar32 x, simd_uchar32 min, simd_uchar32 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar64 simd_clamp(simd_uchar64 x, simd_uchar64 min, simd_uchar64 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short2 simd_clamp(simd_short2 x, simd_short2 min, simd_short2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short3 simd_clamp(simd_short3 x, simd_short3 min, simd_short3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short4 simd_clamp(simd_short4 x, simd_short4 min, simd_short4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short8 simd_clamp(simd_short8 x, simd_short8 min, simd_short8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short16 simd_clamp(simd_short16 x, simd_short16 min, simd_short16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short32 simd_clamp(simd_short32 x, simd_short32 min, simd_short32 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort2 simd_clamp(simd_ushort2 x, simd_ushort2 min, simd_ushort2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort3 simd_clamp(simd_ushort3 x, simd_ushort3 min, simd_ushort3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort4 simd_clamp(simd_ushort4 x, simd_ushort4 min, simd_ushort4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort8 simd_clamp(simd_ushort8 x, simd_ushort8 min, simd_ushort8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort16 simd_clamp(simd_ushort16 x, simd_ushort16 min, simd_ushort16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort32 simd_clamp(simd_ushort32 x, simd_ushort32 min, simd_ushort32 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int2 simd_clamp(simd_int2 x, simd_int2 min, simd_int2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int3 simd_clamp(simd_int3 x, simd_int3 min, simd_int3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int4 simd_clamp(simd_int4 x, simd_int4 min, simd_int4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int8 simd_clamp(simd_int8 x, simd_int8 min, simd_int8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int16 simd_clamp(simd_int16 x, simd_int16 min, simd_int16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint2 simd_clamp(simd_uint2 x, simd_uint2 min, simd_uint2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint3 simd_clamp(simd_uint3 x, simd_uint3 min, simd_uint3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint4 simd_clamp(simd_uint4 x, simd_uint4 min, simd_uint4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint8 simd_clamp(simd_uint8 x, simd_uint8 min, simd_uint8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint16 simd_clamp(simd_uint16 x, simd_uint16 min, simd_uint16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC float simd_clamp(float x, float min, float max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float2 simd_clamp(simd_float2 x, simd_float2 min, simd_float2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float3 simd_clamp(simd_float3 x, simd_float3 min, simd_float3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float4 simd_clamp(simd_float4 x, simd_float4 min, simd_float4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float8 simd_clamp(simd_float8 x, simd_float8 min, simd_float8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float16 simd_clamp(simd_float16 x, simd_float16 min, simd_float16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_long2 simd_clamp(simd_long2 x, simd_long2 min, simd_long2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_long3 simd_clamp(simd_long3 x, simd_long3 min, simd_long3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_long4 simd_clamp(simd_long4 x, simd_long4 min, simd_long4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_long8 simd_clamp(simd_long8 x, simd_long8 min, simd_long8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ulong2 simd_clamp(simd_ulong2 x, simd_ulong2 min, simd_ulong2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ulong3 simd_clamp(simd_ulong3 x, simd_ulong3 min, simd_ulong3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ulong4 simd_clamp(simd_ulong4 x, simd_ulong4 min, simd_ulong4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ulong8 simd_clamp(simd_ulong8 x, simd_ulong8 min, simd_ulong8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC double simd_clamp(double x, double min, double max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_double2 simd_clamp(simd_double2 x, simd_double2 min, simd_double2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_double3 simd_clamp(simd_double3 x, simd_double3 min, simd_double3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_double4 simd_clamp(simd_double4 x, simd_double4 min, simd_double4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_double8 simd_clamp(simd_double8 x, simd_double8 min, simd_double8 max) { + return simd_min(simd_max(x, min), max); +} + + +static inline SIMD_CFUNC float simd_sign(float x) { + return (x == 0 | x != x) ? 0 : copysign(1,x); +} + +static inline SIMD_CFUNC simd_float2 simd_sign(simd_float2 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_float3 simd_sign(simd_float3 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_float4 simd_sign(simd_float4 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_float8 simd_sign(simd_float8 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_float16 simd_sign(simd_float16 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC double simd_sign(double x) { + return (x == 0 | x != x) ? 0 : copysign(1,x); +} + +static inline SIMD_CFUNC simd_double2 simd_sign(simd_double2 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_double3 simd_sign(simd_double3 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_double4 simd_sign(simd_double4 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_double8 simd_sign(simd_double8 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC float simd_mix(float x, float y, float t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float2 simd_mix(simd_float2 x, simd_float2 y, simd_float2 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float3 simd_mix(simd_float3 x, simd_float3 y, simd_float3 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float4 simd_mix(simd_float4 x, simd_float4 y, simd_float4 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float8 simd_mix(simd_float8 x, simd_float8 y, simd_float8 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float16 simd_mix(simd_float16 x, simd_float16 y, simd_float16 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC double simd_mix(double x, double y, double t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_double2 simd_mix(simd_double2 x, simd_double2 y, simd_double2 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_double3 simd_mix(simd_double3 x, simd_double3 y, simd_double3 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_double4 simd_mix(simd_double4 x, simd_double4 y, simd_double4 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_double8 simd_mix(simd_double8 x, simd_double8 y, simd_double8 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC float simd_recip(float x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_recip(simd_float2 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_recip(simd_float3 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float4 simd_recip(simd_float4 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_recip(simd_float8 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_recip(simd_float16 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC double simd_recip(double x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_double2 simd_recip(simd_double2 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_double3 simd_recip(simd_double3 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_double4 simd_recip(simd_double4 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_double8 simd_recip(simd_double8 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC float simd_fast_recip(float x) { +#if defined __AVX512VL__ + simd_float4 x4 = simd_make_float4(x); + return ((simd_float4)_mm_rcp14_ss(x4, x4)).x; +#elif defined __SSE__ + return ((simd_float4)_mm_rcp_ss(simd_make_float4(x))).x; +#elif defined __ARM_NEON__ + return simd_fast_recip(simd_make_float2_undef(x)).x; +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_fast_recip(simd_float2 x) { +#if defined __SSE__ + return simd_make_float2(simd_fast_recip(simd_make_float4_undef(x))); +#elif defined __ARM_NEON__ + simd_float2 r = vrecpe_f32(x); + return r * vrecps_f32(x, r); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_fast_recip(simd_float3 x) { + return simd_make_float3(simd_fast_recip(simd_make_float4_undef(x))); +} + +static inline SIMD_CFUNC simd_float4 simd_fast_recip(simd_float4 x) { +#if defined __AVX512VL__ + return _mm_rcp14_ps(x); +#elif defined __SSE__ + return _mm_rcp_ps(x); +#elif defined __ARM_NEON__ + simd_float4 r = vrecpeq_f32(x); + return r * vrecpsq_f32(x, r); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_fast_recip(simd_float8 x) { +#if defined __AVX512VL__ + return _mm256_rcp14_ps(x); +#elif defined __AVX__ + return _mm256_rcp_ps(x); +#else + return simd_make_float8(simd_fast_recip(x.lo), simd_fast_recip(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_fast_recip(simd_float16 x) { +#if defined __AVX512F__ + return _mm512_rcp14_ps(x); +#else + return simd_make_float16(simd_fast_recip(x.lo), simd_fast_recip(x.hi)); +#endif +} + +static inline SIMD_CFUNC double simd_fast_recip(double x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC simd_double2 simd_fast_recip(simd_double2 x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC simd_double3 simd_fast_recip(simd_double3 x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC simd_double4 simd_fast_recip(simd_double4 x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC simd_double8 simd_fast_recip(simd_double8 x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC float simd_precise_recip(float x) { +#if defined __SSE__ + float r = simd_fast_recip(x); + return r*(2 - (x == 0 ? -INFINITY : x)*r); +#elif defined __ARM_NEON__ + return simd_precise_recip(simd_make_float2_undef(x)).x; +#else + return 1/x; +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_precise_recip(simd_float2 x) { +#if defined __SSE__ + return simd_make_float2(simd_precise_recip(simd_make_float4_undef(x))); +#elif defined __ARM_NEON__ + simd_float2 r = simd_fast_recip(x); + return r*vrecps_f32(x, r); +#else + return 1/x; +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_precise_recip(simd_float3 x) { + return simd_make_float3(simd_precise_recip(simd_make_float4_undef(x))); +} + +static inline SIMD_CFUNC simd_float4 simd_precise_recip(simd_float4 x) { +#if defined __SSE__ + simd_float4 r = simd_fast_recip(x); + return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r); +#elif defined __ARM_NEON__ + simd_float4 r = simd_fast_recip(x); + return r*vrecpsq_f32(x, r); +#else + return 1/x; +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_precise_recip(simd_float8 x) { +#if defined __AVX__ + simd_float8 r = simd_fast_recip(x); + return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r); +#else + return simd_make_float8(simd_precise_recip(x.lo), simd_precise_recip(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_precise_recip(simd_float16 x) { +#if defined __AVX512F__ + simd_float16 r = simd_fast_recip(x); + return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r); +#else + return simd_make_float16(simd_precise_recip(x.lo), simd_precise_recip(x.hi)); +#endif +} + +static inline SIMD_CFUNC double simd_precise_recip(double x) { + return 1/x; +} + +static inline SIMD_CFUNC simd_double2 simd_precise_recip(simd_double2 x) { + return 1/x; +} + +static inline SIMD_CFUNC simd_double3 simd_precise_recip(simd_double3 x) { + return 1/x; +} + +static inline SIMD_CFUNC simd_double4 simd_precise_recip(simd_double4 x) { + return 1/x; +} + +static inline SIMD_CFUNC simd_double8 simd_precise_recip(simd_double8 x) { + return 1/x; +} + +static inline SIMD_CFUNC float simd_rsqrt(float x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_rsqrt(simd_float2 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_rsqrt(simd_float3 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float4 simd_rsqrt(simd_float4 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_rsqrt(simd_float8 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_rsqrt(simd_float16 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC double simd_rsqrt(double x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_double2 simd_rsqrt(simd_double2 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_double3 simd_rsqrt(simd_double3 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_double4 simd_rsqrt(simd_double4 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_double8 simd_rsqrt(simd_double8 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC float simd_fast_rsqrt(float x) { +#if defined __AVX512VL__ + simd_float4 x4 = simd_make_float4(x); + return ((simd_float4)_mm_rsqrt14_ss(x4, x4)).x; +#elif defined __SSE__ + return ((simd_float4)_mm_rsqrt_ss(simd_make_float4(x))).x; +#elif defined __ARM_NEON__ + return simd_fast_rsqrt(simd_make_float2_undef(x)).x; +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_fast_rsqrt(simd_float2 x) { +#if defined __SSE__ + return simd_make_float2(simd_fast_rsqrt(simd_make_float4_undef(x))); +#elif defined __ARM_NEON__ + simd_float2 r = vrsqrte_f32(x); + return r * vrsqrts_f32(x, r*r); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_fast_rsqrt(simd_float3 x) { + return simd_make_float3(simd_fast_rsqrt(simd_make_float4_undef(x))); +} + +static inline SIMD_CFUNC simd_float4 simd_fast_rsqrt(simd_float4 x) { +#if defined __AVX512VL__ + return _mm_rsqrt14_ps(x); +#elif defined __SSE__ + return _mm_rsqrt_ps(x); +#elif defined __ARM_NEON__ + simd_float4 r = vrsqrteq_f32(x); + return r * vrsqrtsq_f32(x, r*r); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_fast_rsqrt(simd_float8 x) { +#if defined __AVX512VL__ + return _mm256_rsqrt14_ps(x); +#elif defined __AVX__ + return _mm256_rsqrt_ps(x); +#else + return simd_make_float8(simd_fast_rsqrt(x.lo), simd_fast_rsqrt(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_fast_rsqrt(simd_float16 x) { +#if defined __AVX512F__ + return _mm512_rsqrt14_ps(x); +#else + return simd_make_float16(simd_fast_rsqrt(x.lo), simd_fast_rsqrt(x.hi)); +#endif +} + +static inline SIMD_CFUNC double simd_fast_rsqrt(double x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC simd_double2 simd_fast_rsqrt(simd_double2 x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC simd_double3 simd_fast_rsqrt(simd_double3 x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC simd_double4 simd_fast_rsqrt(simd_double4 x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC simd_double8 simd_fast_rsqrt(simd_double8 x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC float simd_precise_rsqrt(float x) { +#if defined __SSE__ + float r = simd_fast_rsqrt(x); + return r*(1.5f - 0.5f*(r == INFINITY ? -INFINITY : x)*r*r); +#elif defined __ARM_NEON__ + return simd_precise_rsqrt(simd_make_float2_undef(x)).x; +#else + return 1/sqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_precise_rsqrt(simd_float2 x) { +#if defined __SSE__ + return simd_make_float2(simd_precise_rsqrt(simd_make_float4_undef(x))); +#elif defined __ARM_NEON__ + simd_float2 r = simd_fast_rsqrt(x); + return r*vrsqrts_f32(x, r*r); +#else + return 1/__tg_sqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_precise_rsqrt(simd_float3 x) { + return simd_make_float3(simd_precise_rsqrt(simd_make_float4_undef(x))); +} + +static inline SIMD_CFUNC simd_float4 simd_precise_rsqrt(simd_float4 x) { +#if defined __SSE__ + simd_float4 r = simd_fast_rsqrt(x); + return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r); +#elif defined __ARM_NEON__ + simd_float4 r = simd_fast_rsqrt(x); + return r*vrsqrtsq_f32(x, r*r); +#else + return 1/__tg_sqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_precise_rsqrt(simd_float8 x) { +#if defined __AVX__ + simd_float8 r = simd_fast_rsqrt(x); + return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r); +#else + return simd_make_float8(simd_precise_rsqrt(x.lo), simd_precise_rsqrt(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_precise_rsqrt(simd_float16 x) { +#if defined __AVX512F__ + simd_float16 r = simd_fast_rsqrt(x); + return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r); +#else + return simd_make_float16(simd_precise_rsqrt(x.lo), simd_precise_rsqrt(x.hi)); +#endif +} + +static inline SIMD_CFUNC double simd_precise_rsqrt(double x) { + return 1/sqrt(x); +} + +static inline SIMD_CFUNC simd_double2 simd_precise_rsqrt(simd_double2 x) { + return 1/__tg_sqrt(x); +} + +static inline SIMD_CFUNC simd_double3 simd_precise_rsqrt(simd_double3 x) { + return 1/__tg_sqrt(x); +} + +static inline SIMD_CFUNC simd_double4 simd_precise_rsqrt(simd_double4 x) { + return 1/__tg_sqrt(x); +} + +static inline SIMD_CFUNC simd_double8 simd_precise_rsqrt(simd_double8 x) { + return 1/__tg_sqrt(x); +} + +static inline SIMD_CFUNC float simd_fract(float x) { + return fmin(x - floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float2 simd_fract(simd_float2 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float3 simd_fract(simd_float3 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float4 simd_fract(simd_float4 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float8 simd_fract(simd_float8 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float16 simd_fract(simd_float16 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC double simd_fract(double x) { + return fmin(x - floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC simd_double2 simd_fract(simd_double2 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC simd_double3 simd_fract(simd_double3 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC simd_double4 simd_fract(simd_double4 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC simd_double8 simd_fract(simd_double8 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC float simd_step(float edge, float x) { + return !(x < edge); +} + +static inline SIMD_CFUNC simd_float2 simd_step(simd_float2 edge, simd_float2 x) { + return simd_bitselect((simd_float2)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_float3 simd_step(simd_float3 edge, simd_float3 x) { + return simd_bitselect((simd_float3)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_float4 simd_step(simd_float4 edge, simd_float4 x) { + return simd_bitselect((simd_float4)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_float8 simd_step(simd_float8 edge, simd_float8 x) { + return simd_bitselect((simd_float8)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_float16 simd_step(simd_float16 edge, simd_float16 x) { + return simd_bitselect((simd_float16)1, 0, x < edge); +} + +static inline SIMD_CFUNC double simd_step(double edge, double x) { + return !(x < edge); +} + +static inline SIMD_CFUNC simd_double2 simd_step(simd_double2 edge, simd_double2 x) { + return simd_bitselect((simd_double2)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_double3 simd_step(simd_double3 edge, simd_double3 x) { + return simd_bitselect((simd_double3)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_double4 simd_step(simd_double4 edge, simd_double4 x) { + return simd_bitselect((simd_double4)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_double8 simd_step(simd_double8 edge, simd_double8 x) { + return simd_bitselect((simd_double8)1, 0, x < edge); +} + +static inline SIMD_CFUNC float simd_smoothstep(float edge0, float edge1, float x) { + float t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float2 simd_smoothstep(simd_float2 edge0, simd_float2 edge1, simd_float2 x) { + simd_float2 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float3 simd_smoothstep(simd_float3 edge0, simd_float3 edge1, simd_float3 x) { + simd_float3 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float4 simd_smoothstep(simd_float4 edge0, simd_float4 edge1, simd_float4 x) { + simd_float4 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float8 simd_smoothstep(simd_float8 edge0, simd_float8 edge1, simd_float8 x) { + simd_float8 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float16 simd_smoothstep(simd_float16 edge0, simd_float16 edge1, simd_float16 x) { + simd_float16 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC double simd_smoothstep(double edge0, double edge1, double x) { + double t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_double2 simd_smoothstep(simd_double2 edge0, simd_double2 edge1, simd_double2 x) { + simd_double2 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_double3 simd_smoothstep(simd_double3 edge0, simd_double3 edge1, simd_double3 x) { + simd_double3 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_double4 simd_smoothstep(simd_double4 edge0, simd_double4 edge1, simd_double4 x) { + simd_double4 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_double8 simd_smoothstep(simd_double8 edge0, simd_double8 edge1, simd_double8 x) { + simd_double8 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char32 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char64 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar32 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar64 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short32 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort32 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC double simd_reduce_add(simd_double2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC double simd_reduce_add(simd_double3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC double simd_reduce_add(simd_double4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC double simd_reduce_add(simd_double8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char3 x) { + char t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char32 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char64 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar3 x) { + unsigned char t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar32 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar64 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short3 x) { + short t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short32 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort3 x) { + unsigned short t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort32 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int3 x) { + int t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint3 x) { + unsigned int t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float2 x) { + return fmin(x.x, x.y); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float3 x) { + return fmin(fmin(x.x, x.z), x.y); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long3 x) { + simd_long1 t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong3 x) { + simd_ulong1 t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC double simd_reduce_min(simd_double2 x) { + return fmin(x.x, x.y); +} + +static inline SIMD_CFUNC double simd_reduce_min(simd_double3 x) { + return fmin(fmin(x.x, x.z), x.y); +} + +static inline SIMD_CFUNC double simd_reduce_min(simd_double4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC double simd_reduce_min(simd_double8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char3 x) { + char t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char32 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char64 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar3 x) { + unsigned char t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar32 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar64 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short3 x) { + short t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short32 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort3 x) { + unsigned short t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort32 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int3 x) { + int t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint3 x) { + unsigned int t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float2 x) { + return fmax(x.x, x.y); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float3 x) { + return fmax(fmax(x.x, x.z), x.y); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long3 x) { + simd_long1 t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong3 x) { + simd_ulong1 t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC double simd_reduce_max(simd_double2 x) { + return fmax(x.x, x.y); +} + +static inline SIMD_CFUNC double simd_reduce_max(simd_double3 x) { + return fmax(fmax(x.x, x.z), x.y); +} + +static inline SIMD_CFUNC double simd_reduce_max(simd_double4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC double simd_reduce_max(simd_double8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +#ifdef __cplusplus +} +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_COMMON_HEADER */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/conversion.h b/lib/libc/include/x86_64-macos-gnu/simd/conversion.h new file mode 100644 index 0000000000..b4d2c20552 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/conversion.h @@ -0,0 +1,1967 @@ +/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved. + * + * The interfaces declared in this header provide conversions between vector + * types. The following functions are available: + * + * simd_char(x) simd_uchar(x) + * simd_short(x) simd_ushort(x) + * simd_int(x) simd_uint(x) + * simd_long(x) simd_ulong(x) + * simd_float(x) + * simd_double(x) + * + * Each of these functions converts x to a vector whose elements have the + * type named by the function, with the same number of elements as x. Unlike + * a vector cast, these functions convert the elements to the new element + * type. These conversions behave exactly as C scalar conversions, except + * that conversions from integer vector types to signed integer vector types + * are guaranteed to wrap modulo 2^N (where N is the number of bits in an + * element of the result type). + * + * For integer vector types, saturating conversions are also available: + * + * simd_char_sat(x) simd_uchar_sat(x) + * simd_short_sat(x) simd_ushort_sat(x) + * simd_int_sat(x) simd_uint_sat(x) + * simd_long_sat(x) simd_ulong_sat(x) + * + * These conversions clamp x to the representable range of the result type + * before converting. + * + * Unlike most vector operations in , there are no abbreviated C++ + * names for these functions in the simd:: namespace. + */ + +#ifndef __SIMD_CONVERSION_HEADER__ +#define __SIMD_CONVERSION_HEADER__ + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static simd_char2 SIMD_CFUNC simd_char(simd_char2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_char3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_char4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_char8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_char16 __x); +static simd_char32 SIMD_CFUNC simd_char(simd_char32 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_uchar2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_uchar3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_uchar4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_uchar8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_uchar16 __x); +static simd_char32 SIMD_CFUNC simd_char(simd_uchar32 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_short2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_short3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_short4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_short8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_short16 __x); +static simd_char32 SIMD_CFUNC simd_char(simd_short32 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_ushort2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_ushort3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_ushort4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_ushort8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_ushort16 __x); +static simd_char32 SIMD_CFUNC simd_char(simd_ushort32 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_int2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_int3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_int4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_int8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_int16 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_uint2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_uint3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_uint4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_uint8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_uint16 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_float2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_float3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_float4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_float8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_float16 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_long2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_long3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_long4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_long8 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_ulong2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_ulong3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_ulong4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_ulong8 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_double2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_double3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_double4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_double8 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_char2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_char3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_char4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_char8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_char16 __x); +static simd_char32 SIMD_CFUNC simd_char_sat(simd_char32 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_short2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_short3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_short4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_short8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_short16 __x); +static simd_char32 SIMD_CFUNC simd_char_sat(simd_short32 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_int2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_int3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_int4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_int8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_int16 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_float2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_float3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_float4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_float8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_float16 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_long2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_long3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_long4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_long8 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_double2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_double3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_double4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_double8 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_uchar2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_uchar3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_uchar4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_uchar8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_uchar16 __x); +static simd_char32 SIMD_CFUNC simd_char_sat(simd_uchar32 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_ushort2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_ushort3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_ushort4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_ushort8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_ushort16 __x); +static simd_char32 SIMD_CFUNC simd_char_sat(simd_ushort32 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_uint2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_uint3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_uint4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_uint8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_uint16 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_ulong2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_ulong3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_ulong4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_ulong8 __x); +#define vector_char simd_char +#define vector_char_sat simd_char_sat + +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_char2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_char3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_char4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_char8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_char16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_char32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uchar2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uchar3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uchar4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uchar8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uchar16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_uchar32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_short2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_short3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_short4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_short8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_short16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_short32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ushort2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ushort3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ushort4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ushort8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_ushort16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_ushort32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_int2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_int3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_int4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_int8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_int16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uint2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uint3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uint4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uint8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uint16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_float2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_float3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_float4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_float8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_float16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_long2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_long3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_long4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_long8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ulong2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ulong3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ulong4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ulong8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_double2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_double3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_double4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_double8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_char2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_char3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_char4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_char8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_char16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_char32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_short2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_short3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_short4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_short8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_short16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_short32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_int2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_int3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_int4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_int8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_int16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_float2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_float3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_float4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_float8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_float16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_long2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_long3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_long4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_long8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_double2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_double3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_double4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_double8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uchar2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uchar3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uchar4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uchar8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uchar16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_uchar32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ushort2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ushort3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ushort4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ushort8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_ushort16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_ushort32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uint2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uint3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uint4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uint8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uint16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ulong2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ulong3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ulong4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ulong8 __x); +#define vector_uchar simd_uchar +#define vector_uchar_sat simd_uchar_sat + +static simd_short2 SIMD_CFUNC simd_short(simd_char2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_char3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_char4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_char8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_char16 __x); +static simd_short32 SIMD_CFUNC simd_short(simd_char32 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_uchar2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_uchar3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_uchar4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_uchar8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_uchar16 __x); +static simd_short32 SIMD_CFUNC simd_short(simd_uchar32 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_short2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_short3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_short4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_short8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_short16 __x); +static simd_short32 SIMD_CFUNC simd_short(simd_short32 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_ushort2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_ushort3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_ushort4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_ushort8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_ushort16 __x); +static simd_short32 SIMD_CFUNC simd_short(simd_ushort32 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_int2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_int3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_int4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_int8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_int16 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_uint2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_uint3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_uint4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_uint8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_uint16 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_float2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_float3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_float4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_float8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_float16 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_long2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_long3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_long4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_long8 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_ulong2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_ulong3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_ulong4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_ulong8 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_double2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_double3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_double4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_double8 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_char2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_char3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_char4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_char8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_char16 __x); +static simd_short32 SIMD_CFUNC simd_short_sat(simd_char32 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_short2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_short3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_short4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_short8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_short16 __x); +static simd_short32 SIMD_CFUNC simd_short_sat(simd_short32 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_int2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_int3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_int4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_int8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_int16 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_float2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_float3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_float4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_float8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_float16 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_long2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_long3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_long4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_long8 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_double2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_double3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_double4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_double8 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_uchar2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_uchar3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_uchar4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_uchar8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_uchar16 __x); +static simd_short32 SIMD_CFUNC simd_short_sat(simd_uchar32 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_ushort2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_ushort3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_ushort4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_ushort8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_ushort16 __x); +static simd_short32 SIMD_CFUNC simd_short_sat(simd_ushort32 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_uint2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_uint3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_uint4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_uint8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_uint16 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_ulong2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_ulong3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_ulong4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_ulong8 __x); +#define vector_short simd_short +#define vector_short_sat simd_short_sat + +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_char2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_char3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_char4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_char8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_char16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_char32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uchar2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uchar3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uchar4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uchar8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uchar16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_uchar32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_short2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_short3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_short4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_short8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_short16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_short32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ushort2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ushort3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ushort4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ushort8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_ushort16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_ushort32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_int2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_int3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_int4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_int8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_int16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uint2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uint3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uint4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uint8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uint16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_float2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_float3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_float4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_float8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_float16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_long2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_long3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_long4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_long8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ulong2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ulong3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ulong4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ulong8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_double2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_double3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_double4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_double8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_char2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_char3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_char4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_char8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_char16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_char32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_short2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_short3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_short4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_short8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_short16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_short32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_int2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_int3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_int4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_int8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_int16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_float2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_float3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_float4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_float8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_float16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_long2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_long3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_long4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_long8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_double2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_double3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_double4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_double8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uchar2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uchar3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uchar4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uchar8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uchar16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_uchar32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ushort2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ushort3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ushort4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ushort8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_ushort16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_ushort32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uint2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uint3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uint4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uint8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uint16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ulong2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ulong3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ulong4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ulong8 __x); +#define vector_ushort simd_ushort +#define vector_ushort_sat simd_ushort_sat + +static simd_int2 SIMD_CFUNC simd_int(simd_char2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_char3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_char4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_char8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_char16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_uchar2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_uchar3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_uchar4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_uchar8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_uchar16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_short2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_short3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_short4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_short8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_short16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_ushort2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_ushort3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_ushort4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_ushort8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_ushort16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_int2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_int3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_int4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_int8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_int16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_uint2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_uint3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_uint4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_uint8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_uint16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_float2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_float3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_float4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_float8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_float16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_long2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_long3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_long4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_long8 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_ulong2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_ulong3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_ulong4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_ulong8 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_double2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_double3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_double4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_double8 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_char2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_char3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_char4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_char8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_char16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_short2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_short3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_short4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_short8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_short16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_int2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_int3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_int4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_int8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_int16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_float2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_float3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_float4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_float8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_float16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_long2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_long3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_long4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_long8 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_double2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_double3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_double4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_double8 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_uchar2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_uchar3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_uchar4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_uchar8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_uchar16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_ushort2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_ushort3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_ushort4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_ushort8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_ushort16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_uint2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_uint3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_uint4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_uint8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_uint16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_ulong2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_ulong3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_ulong4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_ulong8 __x); +static simd_int2 SIMD_CFUNC simd_int_rte(simd_float2 __x); +static simd_int3 SIMD_CFUNC simd_int_rte(simd_float3 __x); +static simd_int4 SIMD_CFUNC simd_int_rte(simd_float4 __x); +static simd_int8 SIMD_CFUNC simd_int_rte(simd_float8 __x); +static simd_int16 SIMD_CFUNC simd_int_rte(simd_float16 __x); +#define vector_int simd_int +#define vector_int_sat simd_int_sat + +static simd_uint2 SIMD_CFUNC simd_uint(simd_char2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_char3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_char4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_char8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_char16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_uchar2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_uchar3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_uchar4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_uchar8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_uchar16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_short2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_short3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_short4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_short8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_short16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_ushort2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_ushort3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_ushort4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_ushort8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_ushort16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_int2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_int3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_int4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_int8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_int16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_uint2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_uint3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_uint4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_uint8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_uint16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_float2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_float3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_float4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_float8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_float16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_long2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_long3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_long4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_long8 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_ulong2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_ulong3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_ulong4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_ulong8 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_double2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_double3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_double4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_double8 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_char2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_char3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_char4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_char8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_char16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_short2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_short3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_short4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_short8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_short16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_int2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_int3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_int4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_int8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_int16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_float2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_float3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_float4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_float8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_float16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_long2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_long3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_long4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_long8 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_double2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_double3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_double4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_double8 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uchar2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uchar3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uchar4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uchar8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uchar16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ushort2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ushort3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ushort4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ushort8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_ushort16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uint2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uint3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uint4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uint8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uint16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ulong2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ulong3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ulong4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ulong8 __x); +#define vector_uint simd_uint +#define vector_uint_sat simd_uint_sat + +static simd_float2 SIMD_CFUNC simd_float(simd_char2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_char3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_char4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_char8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_char16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_uchar2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_uchar3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_uchar4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_uchar8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_uchar16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_short2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_short3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_short4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_short8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_short16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_ushort2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_ushort3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_ushort4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_ushort8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_ushort16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_int2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_int3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_int4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_int8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_int16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_uint2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_uint3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_uint4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_uint8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_uint16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_float2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_float3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_float4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_float8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_float16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_long2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_long3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_long4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_long8 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_ulong2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_ulong3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_ulong4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_ulong8 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_double2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_double3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_double4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_double8 __x); +#define vector_float simd_float + +static simd_long2 SIMD_CFUNC simd_long(simd_char2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_char3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_char4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_char8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_uchar2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_uchar3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_uchar4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_uchar8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_short2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_short3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_short4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_short8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_ushort2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_ushort3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_ushort4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_ushort8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_int2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_int3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_int4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_int8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_uint2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_uint3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_uint4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_uint8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_float2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_float3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_float4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_float8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_long2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_long3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_long4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_long8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_ulong2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_ulong3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_ulong4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_ulong8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_double2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_double3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_double4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_double8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_char2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_char3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_char4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_char8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_short2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_short3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_short4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_short8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_int2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_int3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_int4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_int8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_float2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_float3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_float4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_float8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_long2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_long3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_long4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_long8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_double2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_double3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_double4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_double8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_uchar2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_uchar3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_uchar4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_uchar8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_ushort2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_ushort3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_ushort4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_ushort8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_uint2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_uint3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_uint4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_uint8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_ulong2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_ulong3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_ulong4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_ulong8 __x); +static simd_long2 SIMD_CFUNC simd_long_rte(simd_double2 __x); +static simd_long3 SIMD_CFUNC simd_long_rte(simd_double3 __x); +static simd_long4 SIMD_CFUNC simd_long_rte(simd_double4 __x); +static simd_long8 SIMD_CFUNC simd_long_rte(simd_double8 __x); +#define vector_long simd_long +#define vector_long_sat simd_long_sat + +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_char2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_char3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_char4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_char8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uchar2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uchar3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uchar4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uchar8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_short2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_short3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_short4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_short8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ushort2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ushort3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ushort4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ushort8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_int2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_int3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_int4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_int8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uint2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uint3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uint4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uint8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_float2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_float3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_float4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_float8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_long2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_long3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_long4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_long8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ulong2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ulong3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ulong4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ulong8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_double2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_double3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_double4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_double8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_char2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_char3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_char4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_char8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_short2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_short3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_short4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_short8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_int2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_int3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_int4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_int8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_float2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_float3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_float4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_float8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_long2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_long3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_long4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_long8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_double2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_double3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_double4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_double8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uchar2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uchar3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uchar4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uchar8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ushort2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ushort3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ushort4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ushort8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uint2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uint3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uint4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uint8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ulong2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ulong3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ulong4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ulong8 __x); +#define vector_ulong simd_ulong +#define vector_ulong_sat simd_ulong_sat + +static simd_double2 SIMD_CFUNC simd_double(simd_char2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_char3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_char4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_char8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_uchar2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_uchar3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_uchar4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_uchar8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_short2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_short3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_short4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_short8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_ushort2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_ushort3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_ushort4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_ushort8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_int2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_int3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_int4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_int8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_uint2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_uint3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_uint4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_uint8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_float2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_float3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_float4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_float8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_long2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_long3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_long4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_long8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_ulong2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_ulong3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_ulong4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_ulong8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_double2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_double3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_double4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_double8 __x); +#define vector_double simd_double + +static simd_char2 SIMD_CFUNC vector2(char __x, char __y) { return ( simd_char2){__x, __y}; } +static simd_uchar2 SIMD_CFUNC vector2(unsigned char __x, unsigned char __y) { return ( simd_uchar2){__x, __y}; } +static simd_short2 SIMD_CFUNC vector2(short __x, short __y) { return ( simd_short2){__x, __y}; } +static simd_ushort2 SIMD_CFUNC vector2(unsigned short __x, unsigned short __y) { return (simd_ushort2){__x, __y}; } +static simd_int2 SIMD_CFUNC vector2(int __x, int __y) { return ( simd_int2){__x, __y}; } +static simd_uint2 SIMD_CFUNC vector2(unsigned int __x, unsigned int __y) { return ( simd_uint2){__x, __y}; } +static simd_float2 SIMD_CFUNC vector2(float __x, float __y) { return ( simd_float2){__x, __y}; } +static simd_long2 SIMD_CFUNC vector2(simd_long1 __x, simd_long1 __y) { return ( simd_long2){__x, __y}; } +static simd_ulong2 SIMD_CFUNC vector2(simd_ulong1 __x, simd_ulong1 __y) { return ( simd_ulong2){__x, __y}; } +static simd_double2 SIMD_CFUNC vector2(double __x, double __y) { return (simd_double2){__x, __y}; } + +static simd_char3 SIMD_CFUNC vector3(char __x, char __y, char __z) { return ( simd_char3){__x, __y, __z}; } +static simd_uchar3 SIMD_CFUNC vector3(unsigned char __x, unsigned char __y, unsigned char __z) { return ( simd_uchar3){__x, __y, __z}; } +static simd_short3 SIMD_CFUNC vector3(short __x, short __y, short __z) { return ( simd_short3){__x, __y, __z}; } +static simd_ushort3 SIMD_CFUNC vector3(unsigned short __x, unsigned short __y, unsigned short __z) { return (simd_ushort3){__x, __y, __z}; } +static simd_int3 SIMD_CFUNC vector3(int __x, int __y, int __z) { return ( simd_int3){__x, __y, __z}; } +static simd_uint3 SIMD_CFUNC vector3(unsigned int __x, unsigned int __y, unsigned int __z) { return ( simd_uint3){__x, __y, __z}; } +static simd_float3 SIMD_CFUNC vector3(float __x, float __y, float __z) { return ( simd_float3){__x, __y, __z}; } +static simd_long3 SIMD_CFUNC vector3(simd_long1 __x, simd_long1 __y, simd_long1 __z) { return ( simd_long3){__x, __y, __z}; } +static simd_ulong3 SIMD_CFUNC vector3(simd_ulong1 __x, simd_ulong1 __y, simd_ulong1 __z) { return ( simd_ulong3){__x, __y, __z}; } +static simd_double3 SIMD_CFUNC vector3(double __x, double __y, double __z) { return (simd_double3){__x, __y, __z}; } + +static simd_char3 SIMD_CFUNC vector3(simd_char2 __xy, char __z) { simd_char3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_uchar3 SIMD_CFUNC vector3(simd_uchar2 __xy, unsigned char __z) { simd_uchar3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_short3 SIMD_CFUNC vector3(simd_short2 __xy, short __z) { simd_short3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_ushort3 SIMD_CFUNC vector3(simd_ushort2 __xy, unsigned short __z) { simd_ushort3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_int3 SIMD_CFUNC vector3(simd_int2 __xy, int __z) { simd_int3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_uint3 SIMD_CFUNC vector3(simd_uint2 __xy, unsigned int __z) { simd_uint3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_float3 SIMD_CFUNC vector3(simd_float2 __xy, float __z) { simd_float3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_long3 SIMD_CFUNC vector3(simd_long2 __xy, simd_long1 __z) { simd_long3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_ulong3 SIMD_CFUNC vector3(simd_ulong2 __xy, simd_ulong1 __z) { simd_ulong3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_double3 SIMD_CFUNC vector3(simd_double2 __xy, double __z) { simd_double3 __r; __r.xy = __xy; __r.z = __z; return __r; } + +static simd_char4 SIMD_CFUNC vector4(char __x, char __y, char __z, char __w) { return ( simd_char4){__x, __y, __z, __w}; } +static simd_uchar4 SIMD_CFUNC vector4(unsigned char __x, unsigned char __y, unsigned char __z, unsigned char __w) { return ( simd_uchar4){__x, __y, __z, __w}; } +static simd_short4 SIMD_CFUNC vector4(short __x, short __y, short __z, short __w) { return ( simd_short4){__x, __y, __z, __w}; } +static simd_ushort4 SIMD_CFUNC vector4(unsigned short __x, unsigned short __y, unsigned short __z, unsigned short __w) { return (simd_ushort4){__x, __y, __z, __w}; } +static simd_int4 SIMD_CFUNC vector4(int __x, int __y, int __z, int __w) { return ( simd_int4){__x, __y, __z, __w}; } +static simd_uint4 SIMD_CFUNC vector4(unsigned int __x, unsigned int __y, unsigned int __z, unsigned int __w) { return ( simd_uint4){__x, __y, __z, __w}; } +static simd_float4 SIMD_CFUNC vector4(float __x, float __y, float __z, float __w) { return ( simd_float4){__x, __y, __z, __w}; } +static simd_long4 SIMD_CFUNC vector4(simd_long1 __x, simd_long1 __y, simd_long1 __z, simd_long1 __w) { return ( simd_long4){__x, __y, __z, __w}; } +static simd_ulong4 SIMD_CFUNC vector4(simd_ulong1 __x, simd_ulong1 __y, simd_ulong1 __z, simd_ulong1 __w) { return ( simd_ulong4){__x, __y, __z, __w}; } +static simd_double4 SIMD_CFUNC vector4(double __x, double __y, double __z, double __w) { return (simd_double4){__x, __y, __z, __w}; } + +static simd_char4 SIMD_CFUNC vector4(simd_char2 __xy, simd_char2 __zw) { simd_char4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_uchar4 SIMD_CFUNC vector4(simd_uchar2 __xy, simd_uchar2 __zw) { simd_uchar4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_short4 SIMD_CFUNC vector4(simd_short2 __xy, simd_short2 __zw) { simd_short4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_ushort4 SIMD_CFUNC vector4(simd_ushort2 __xy, simd_ushort2 __zw) { simd_ushort4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_int4 SIMD_CFUNC vector4(simd_int2 __xy, simd_int2 __zw) { simd_int4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_uint4 SIMD_CFUNC vector4(simd_uint2 __xy, simd_uint2 __zw) { simd_uint4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_float4 SIMD_CFUNC vector4(simd_float2 __xy, simd_float2 __zw) { simd_float4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_long4 SIMD_CFUNC vector4(simd_long2 __xy, simd_long2 __zw) { simd_long4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_ulong4 SIMD_CFUNC vector4(simd_ulong2 __xy, simd_ulong2 __zw) { simd_ulong4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_double4 SIMD_CFUNC vector4(simd_double2 __xy, simd_double2 __zw) { simd_double4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } + +static simd_char4 SIMD_CFUNC vector4(simd_char3 __xyz, char __w) { simd_char4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_uchar4 SIMD_CFUNC vector4(simd_uchar3 __xyz, unsigned char __w) { simd_uchar4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_short4 SIMD_CFUNC vector4(simd_short3 __xyz, short __w) { simd_short4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_ushort4 SIMD_CFUNC vector4(simd_ushort3 __xyz, unsigned short __w) { simd_ushort4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_int4 SIMD_CFUNC vector4(simd_int3 __xyz, int __w) { simd_int4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_uint4 SIMD_CFUNC vector4(simd_uint3 __xyz, unsigned int __w) { simd_uint4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_float4 SIMD_CFUNC vector4(simd_float3 __xyz, float __w) { simd_float4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_long4 SIMD_CFUNC vector4(simd_long3 __xyz, simd_long1 __w) { simd_long4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_ulong4 SIMD_CFUNC vector4(simd_ulong3 __xyz, simd_ulong1 __w) { simd_ulong4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_double4 SIMD_CFUNC vector4(simd_double3 __xyz, double __w) { simd_double4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } + +static simd_char8 SIMD_CFUNC vector8(simd_char4 __lo, simd_char4 __hi) { simd_char8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uchar8 SIMD_CFUNC vector8(simd_uchar4 __lo, simd_uchar4 __hi) { simd_uchar8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_short8 SIMD_CFUNC vector8(simd_short4 __lo, simd_short4 __hi) { simd_short8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_ushort8 SIMD_CFUNC vector8(simd_ushort4 __lo, simd_ushort4 __hi) { simd_ushort8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_int8 SIMD_CFUNC vector8(simd_int4 __lo, simd_int4 __hi) { simd_int8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uint8 SIMD_CFUNC vector8(simd_uint4 __lo, simd_uint4 __hi) { simd_uint8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_float8 SIMD_CFUNC vector8(simd_float4 __lo, simd_float4 __hi) { simd_float8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_long8 SIMD_CFUNC vector8(simd_long4 __lo, simd_long4 __hi) { simd_long8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_ulong8 SIMD_CFUNC vector8(simd_ulong4 __lo, simd_ulong4 __hi) { simd_ulong8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_double8 SIMD_CFUNC vector8(simd_double4 __lo, simd_double4 __hi) { simd_double8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } + +static simd_char16 SIMD_CFUNC vector16(simd_char8 __lo, simd_char8 __hi) { simd_char16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uchar16 SIMD_CFUNC vector16(simd_uchar8 __lo, simd_uchar8 __hi) { simd_uchar16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_short16 SIMD_CFUNC vector16(simd_short8 __lo, simd_short8 __hi) { simd_short16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_ushort16 SIMD_CFUNC vector16(simd_ushort8 __lo, simd_ushort8 __hi) { simd_ushort16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_int16 SIMD_CFUNC vector16(simd_int8 __lo, simd_int8 __hi) { simd_int16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uint16 SIMD_CFUNC vector16(simd_uint8 __lo, simd_uint8 __hi) { simd_uint16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_float16 SIMD_CFUNC vector16(simd_float8 __lo, simd_float8 __hi) { simd_float16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } + +static simd_char32 SIMD_CFUNC vector32(simd_char16 __lo, simd_char16 __hi) { simd_char32 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uchar32 SIMD_CFUNC vector32(simd_uchar16 __lo, simd_uchar16 __hi) { simd_uchar32 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_short32 SIMD_CFUNC vector32(simd_short16 __lo, simd_short16 __hi) { simd_short32 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_ushort32 SIMD_CFUNC vector32(simd_ushort16 __lo, simd_ushort16 __hi) { simd_ushort32 __r; __r.lo = __lo; __r.hi = __hi; return __r; } + +#pragma mark - Implementation + +static simd_char2 SIMD_CFUNC simd_char(simd_char2 __x) { return __x; } +static simd_char3 SIMD_CFUNC simd_char(simd_char3 __x) { return __x; } +static simd_char4 SIMD_CFUNC simd_char(simd_char4 __x) { return __x; } +static simd_char8 SIMD_CFUNC simd_char(simd_char8 __x) { return __x; } +static simd_char16 SIMD_CFUNC simd_char(simd_char16 __x) { return __x; } +static simd_char32 SIMD_CFUNC simd_char(simd_char32 __x) { return __x; } +static simd_char2 SIMD_CFUNC simd_char(simd_uchar2 __x) { return (simd_char2)__x; } +static simd_char3 SIMD_CFUNC simd_char(simd_uchar3 __x) { return (simd_char3)__x; } +static simd_char4 SIMD_CFUNC simd_char(simd_uchar4 __x) { return (simd_char4)__x; } +static simd_char8 SIMD_CFUNC simd_char(simd_uchar8 __x) { return (simd_char8)__x; } +static simd_char16 SIMD_CFUNC simd_char(simd_uchar16 __x) { return (simd_char16)__x; } +static simd_char32 SIMD_CFUNC simd_char(simd_uchar32 __x) { return (simd_char32)__x; } +static simd_char2 SIMD_CFUNC simd_char(simd_short2 __x) { return __builtin_convertvector(__x & 0xff, simd_char2); } +static simd_char3 SIMD_CFUNC simd_char(simd_short3 __x) { return __builtin_convertvector(__x & 0xff, simd_char3); } +static simd_char4 SIMD_CFUNC simd_char(simd_short4 __x) { return __builtin_convertvector(__x & 0xff, simd_char4); } +static simd_char8 SIMD_CFUNC simd_char(simd_short8 __x) { return __builtin_convertvector(__x & 0xff, simd_char8); } +static simd_char16 SIMD_CFUNC simd_char(simd_short16 __x) { return __builtin_convertvector(__x & 0xff, simd_char16); } +static simd_char32 SIMD_CFUNC simd_char(simd_short32 __x) { return __builtin_convertvector(__x & 0xff, simd_char32); } +static simd_char2 SIMD_CFUNC simd_char(simd_ushort2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_ushort3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_ushort4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_ushort8 __x) { return simd_char(simd_short(__x)); } +static simd_char16 SIMD_CFUNC simd_char(simd_ushort16 __x) { return simd_char(simd_short(__x)); } +static simd_char32 SIMD_CFUNC simd_char(simd_ushort32 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_int2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_int3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_int4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_int8 __x) { return simd_char(simd_short(__x)); } +static simd_char16 SIMD_CFUNC simd_char(simd_int16 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_uint2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_uint3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_uint4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_uint8 __x) { return simd_char(simd_short(__x)); } +static simd_char16 SIMD_CFUNC simd_char(simd_uint16 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_float2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_float3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_float4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_float8 __x) { return simd_char(simd_short(__x)); } +static simd_char16 SIMD_CFUNC simd_char(simd_float16 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_long2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_long3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_long4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_long8 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_ulong2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_ulong3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_ulong4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_ulong8 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_double2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_double3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_double4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_double8 __x) { return simd_char(simd_short(__x)); } + +static simd_char2 SIMD_CFUNC simd_char_sat(simd_char2 __x) { return __x; } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_char3 __x) { return __x; } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_char4 __x) { return __x; } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_char8 __x) { return __x; } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_char16 __x) { return __x; } +static simd_char32 SIMD_CFUNC simd_char_sat(simd_char32 __x) { return __x; } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_short2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_short3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_short4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_short8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_short16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char32 SIMD_CFUNC simd_char_sat(simd_short32 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_int2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_int3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_int4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_int8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_int16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_float2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_float3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_float4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_float8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_float16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_long2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_long3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_long4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_long8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_double2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_double3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_double4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_double8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_uchar2 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_uchar3 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_uchar4 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_uchar8 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_uchar16 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char32 SIMD_CFUNC simd_char_sat(simd_uchar32 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_ushort2 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_ushort3 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_ushort4 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_ushort8 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_ushort16 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char32 SIMD_CFUNC simd_char_sat(simd_ushort32 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_uint2 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_uint3 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_uint4 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_uint8 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_uint16 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_ulong2 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_ulong3 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_ulong4 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_ulong8 __x) { return simd_char(simd_min(__x,0x7f)); } + + +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_char2 __x) { return (simd_uchar2)__x; } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_char3 __x) { return (simd_uchar3)__x; } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_char4 __x) { return (simd_uchar4)__x; } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_char8 __x) { return (simd_uchar8)__x; } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_char16 __x) { return (simd_uchar16)__x; } +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_char32 __x) { return (simd_uchar32)__x; } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uchar2 __x) { return __x; } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uchar3 __x) { return __x; } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uchar4 __x) { return __x; } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uchar8 __x) { return __x; } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uchar16 __x) { return __x; } +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_uchar32 __x) { return __x; } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_short2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_short3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_short4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_short8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_short16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_short32 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ushort2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ushort3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ushort4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ushort8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_ushort16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_ushort32 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_int2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_int3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_int4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_int8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_int16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uint2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uint3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uint4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uint8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uint16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_float2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_float3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_float4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_float8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_float16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_long2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_long3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_long4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_long8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ulong2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ulong3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ulong4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ulong8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_double2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_double3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_double4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_double8 __x) { return simd_uchar(simd_char(__x)); } + +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_char2 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_char3 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_char4 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_char8 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_char16 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_char32 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_short2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_short3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_short4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_short8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_short16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_short32 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_int2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_int3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_int4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_int8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_int16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_float2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_float3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_float4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_float8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_float16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_long2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_long3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_long4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_long8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_double2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_double3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_double4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_double8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uchar2 __x) { return __x; } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uchar3 __x) { return __x; } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uchar4 __x) { return __x; } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uchar8 __x) { return __x; } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uchar16 __x) { return __x; } +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_uchar32 __x) { return __x; } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ushort2 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ushort3 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ushort4 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ushort8 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_ushort16 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_ushort32 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uint2 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uint3 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uint4 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uint8 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uint16 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ulong2 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ulong3 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ulong4 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ulong8 __x) { return simd_uchar(simd_min(__x,0xff)); } + + +static simd_short2 SIMD_CFUNC simd_short(simd_char2 __x) { return __builtin_convertvector(__x, simd_short2); } +static simd_short3 SIMD_CFUNC simd_short(simd_char3 __x) { return __builtin_convertvector(__x, simd_short3); } +static simd_short4 SIMD_CFUNC simd_short(simd_char4 __x) { return __builtin_convertvector(__x, simd_short4); } +static simd_short8 SIMD_CFUNC simd_short(simd_char8 __x) { return __builtin_convertvector(__x, simd_short8); } +static simd_short16 SIMD_CFUNC simd_short(simd_char16 __x) { return __builtin_convertvector(__x, simd_short16); } +static simd_short32 SIMD_CFUNC simd_short(simd_char32 __x) { return __builtin_convertvector(__x, simd_short32); } +static simd_short2 SIMD_CFUNC simd_short(simd_uchar2 __x) { return __builtin_convertvector(__x, simd_short2); } +static simd_short3 SIMD_CFUNC simd_short(simd_uchar3 __x) { return __builtin_convertvector(__x, simd_short3); } +static simd_short4 SIMD_CFUNC simd_short(simd_uchar4 __x) { return __builtin_convertvector(__x, simd_short4); } +static simd_short8 SIMD_CFUNC simd_short(simd_uchar8 __x) { return __builtin_convertvector(__x, simd_short8); } +static simd_short16 SIMD_CFUNC simd_short(simd_uchar16 __x) { return __builtin_convertvector(__x, simd_short16); } +static simd_short32 SIMD_CFUNC simd_short(simd_uchar32 __x) { return __builtin_convertvector(__x, simd_short32); } +static simd_short2 SIMD_CFUNC simd_short(simd_short2 __x) { return __x; } +static simd_short3 SIMD_CFUNC simd_short(simd_short3 __x) { return __x; } +static simd_short4 SIMD_CFUNC simd_short(simd_short4 __x) { return __x; } +static simd_short8 SIMD_CFUNC simd_short(simd_short8 __x) { return __x; } +static simd_short16 SIMD_CFUNC simd_short(simd_short16 __x) { return __x; } +static simd_short32 SIMD_CFUNC simd_short(simd_short32 __x) { return __x; } +static simd_short2 SIMD_CFUNC simd_short(simd_ushort2 __x) { return (simd_short2)__x; } +static simd_short3 SIMD_CFUNC simd_short(simd_ushort3 __x) { return (simd_short3)__x; } +static simd_short4 SIMD_CFUNC simd_short(simd_ushort4 __x) { return (simd_short4)__x; } +static simd_short8 SIMD_CFUNC simd_short(simd_ushort8 __x) { return (simd_short8)__x; } +static simd_short16 SIMD_CFUNC simd_short(simd_ushort16 __x) { return (simd_short16)__x; } +static simd_short32 SIMD_CFUNC simd_short(simd_ushort32 __x) { return (simd_short32)__x; } +static simd_short2 SIMD_CFUNC simd_short(simd_int2 __x) { return __builtin_convertvector(__x & 0xffff, simd_short2); } +static simd_short3 SIMD_CFUNC simd_short(simd_int3 __x) { return __builtin_convertvector(__x & 0xffff, simd_short3); } +static simd_short4 SIMD_CFUNC simd_short(simd_int4 __x) { return __builtin_convertvector(__x & 0xffff, simd_short4); } +static simd_short8 SIMD_CFUNC simd_short(simd_int8 __x) { return __builtin_convertvector(__x & 0xffff, simd_short8); } +static simd_short16 SIMD_CFUNC simd_short(simd_int16 __x) { return __builtin_convertvector(__x & 0xffff, simd_short16); } +static simd_short2 SIMD_CFUNC simd_short(simd_uint2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_uint3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_uint4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_uint8 __x) { return simd_short(simd_int(__x)); } +static simd_short16 SIMD_CFUNC simd_short(simd_uint16 __x) { return simd_short(simd_int(__x)); } +static simd_short2 SIMD_CFUNC simd_short(simd_float2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_float3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_float4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_float8 __x) { return simd_short(simd_int(__x)); } +static simd_short16 SIMD_CFUNC simd_short(simd_float16 __x) { return simd_short(simd_int(__x)); } +static simd_short2 SIMD_CFUNC simd_short(simd_long2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_long3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_long4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_long8 __x) { return simd_short(simd_int(__x)); } +static simd_short2 SIMD_CFUNC simd_short(simd_ulong2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_ulong3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_ulong4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_ulong8 __x) { return simd_short(simd_int(__x)); } +static simd_short2 SIMD_CFUNC simd_short(simd_double2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_double3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_double4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_double8 __x) { return simd_short(simd_int(__x)); } + +static simd_short2 SIMD_CFUNC simd_short_sat(simd_char2 __x) { return simd_short(__x); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_char3 __x) { return simd_short(__x); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_char4 __x) { return simd_short(__x); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_char8 __x) { return simd_short(__x); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_char16 __x) { return simd_short(__x); } +static simd_short32 SIMD_CFUNC simd_short_sat(simd_char32 __x) { return simd_short(__x); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_short2 __x) { return __x; } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_short3 __x) { return __x; } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_short4 __x) { return __x; } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_short8 __x) { return __x; } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_short16 __x) { return __x; } +static simd_short32 SIMD_CFUNC simd_short_sat(simd_short32 __x) { return __x; } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_int2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_int3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_int4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_int8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_int16 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_float2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_float3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_float4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_float8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_float16 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_long2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_long3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_long4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_long8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_double2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_double3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_double4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_double8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_uchar2 __x) { return simd_short(__x); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_uchar3 __x) { return simd_short(__x); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_uchar4 __x) { return simd_short(__x); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_uchar8 __x) { return simd_short(__x); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_uchar16 __x) { return simd_short(__x); } +static simd_short32 SIMD_CFUNC simd_short_sat(simd_uchar32 __x) { return simd_short(__x); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_ushort2 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_ushort3 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_ushort4 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_ushort8 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_ushort16 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short32 SIMD_CFUNC simd_short_sat(simd_ushort32 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_uint2 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_uint3 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_uint4 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_uint8 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_uint16 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_ulong2 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_ulong3 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_ulong4 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_ulong8 __x) { return simd_short(simd_min(__x,0x7fff)); } + + +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_char2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_char3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_char4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_char8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_char16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_char32 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uchar2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uchar3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uchar4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uchar8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uchar16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_uchar32 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_short2 __x) { return (simd_ushort2)__x; } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_short3 __x) { return (simd_ushort3)__x; } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_short4 __x) { return (simd_ushort4)__x; } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_short8 __x) { return (simd_ushort8)__x; } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_short16 __x) { return (simd_ushort16)__x; } +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_short32 __x) { return (simd_ushort32)__x; } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ushort2 __x) { return __x; } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ushort3 __x) { return __x; } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ushort4 __x) { return __x; } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ushort8 __x) { return __x; } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_ushort16 __x) { return __x; } +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_ushort32 __x) { return __x; } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_int2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_int3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_int4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_int8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_int16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uint2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uint3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uint4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uint8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uint16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_float2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_float3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_float4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_float8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_float16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_long2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_long3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_long4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_long8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ulong2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ulong3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ulong4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ulong8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_double2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_double3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_double4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_double8 __x) { return simd_ushort(simd_short(__x)); } + +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_char2 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_char3 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_char4 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_char8 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_char16 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_char32 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_short2 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_short3 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_short4 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_short8 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_short16 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_short32 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_int2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_int3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_int4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_int8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_int16 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_float2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_float3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_float4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_float8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_float16 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_long2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_long3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_long4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_long8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_double2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_double3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_double4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_double8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uchar2 __x) { return simd_ushort(__x); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uchar3 __x) { return simd_ushort(__x); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uchar4 __x) { return simd_ushort(__x); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uchar8 __x) { return simd_ushort(__x); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uchar16 __x) { return simd_ushort(__x); } +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_uchar32 __x) { return simd_ushort(__x); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ushort2 __x) { return __x; } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ushort3 __x) { return __x; } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ushort4 __x) { return __x; } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ushort8 __x) { return __x; } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_ushort16 __x) { return __x; } +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_ushort32 __x) { return __x; } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uint2 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uint3 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uint4 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uint8 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uint16 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ulong2 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ulong3 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ulong4 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ulong8 __x) { return simd_ushort(simd_min(__x, 0xffff)); } + + +static simd_int2 SIMD_CFUNC simd_int(simd_char2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_char3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_char4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_char8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_char16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_uchar2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_uchar3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_uchar4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_uchar8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_uchar16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_short2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_short3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_short4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_short8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_short16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_ushort2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_ushort3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_ushort4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_ushort8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_ushort16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_int2 __x) { return __x; } +static simd_int3 SIMD_CFUNC simd_int(simd_int3 __x) { return __x; } +static simd_int4 SIMD_CFUNC simd_int(simd_int4 __x) { return __x; } +static simd_int8 SIMD_CFUNC simd_int(simd_int8 __x) { return __x; } +static simd_int16 SIMD_CFUNC simd_int(simd_int16 __x) { return __x; } +static simd_int2 SIMD_CFUNC simd_int(simd_uint2 __x) { return (simd_int2)__x; } +static simd_int3 SIMD_CFUNC simd_int(simd_uint3 __x) { return (simd_int3)__x; } +static simd_int4 SIMD_CFUNC simd_int(simd_uint4 __x) { return (simd_int4)__x; } +static simd_int8 SIMD_CFUNC simd_int(simd_uint8 __x) { return (simd_int8)__x; } +static simd_int16 SIMD_CFUNC simd_int(simd_uint16 __x) { return (simd_int16)__x; } +static simd_int2 SIMD_CFUNC simd_int(simd_float2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_float3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_float4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_float8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_float16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_long2 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_long3 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_long4 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_long8 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int8); } +static simd_int2 SIMD_CFUNC simd_int(simd_ulong2 __x) { return simd_int(simd_long(__x)); } +static simd_int3 SIMD_CFUNC simd_int(simd_ulong3 __x) { return simd_int(simd_long(__x)); } +static simd_int4 SIMD_CFUNC simd_int(simd_ulong4 __x) { return simd_int(simd_long(__x)); } +static simd_int8 SIMD_CFUNC simd_int(simd_ulong8 __x) { return simd_int(simd_long(__x)); } +static simd_int2 SIMD_CFUNC simd_int(simd_double2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_double3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_double4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_double8 __x) { return __builtin_convertvector(__x, simd_int8); } + +static simd_int2 SIMD_CFUNC simd_int_sat(simd_char2 __x) { return simd_int(__x); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_char3 __x) { return simd_int(__x); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_char4 __x) { return simd_int(__x); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_char8 __x) { return simd_int(__x); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_char16 __x) { return simd_int(__x); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_short2 __x) { return simd_int(__x); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_short3 __x) { return simd_int(__x); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_short4 __x) { return simd_int(__x); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_short8 __x) { return simd_int(__x); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_short16 __x) { return simd_int(__x); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_int2 __x) { return __x; } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_int3 __x) { return __x; } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_int4 __x) { return __x; } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_int8 __x) { return __x; } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_int16 __x) { return __x; } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_float2 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_float3 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_float4 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_float8 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_float16 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_long2 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_long3 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_long4 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_long8 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_double2 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_double3 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_double4 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_double8 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_uchar2 __x) { return simd_int(__x); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_uchar3 __x) { return simd_int(__x); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_uchar4 __x) { return simd_int(__x); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_uchar8 __x) { return simd_int(__x); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_uchar16 __x) { return simd_int(__x); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_ushort2 __x) { return simd_int(__x); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_ushort3 __x) { return simd_int(__x); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_ushort4 __x) { return simd_int(__x); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_ushort8 __x) { return simd_int(__x); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_ushort16 __x) { return simd_int(__x); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_uint2 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_uint3 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_uint4 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_uint8 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_uint16 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_ulong2 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_ulong3 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_ulong4 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_ulong8 __x) { return simd_int(simd_min(__x,0x7fffffff)); } + +static simd_int2 SIMD_CFUNC simd_int_rte(simd_float2 __x) { +#if defined __arm64__ + return vcvtn_s32_f32(__x); +#else + return simd_make_int2(simd_int_rte(simd_make_float4_undef(__x))); +#endif +} + +static simd_int3 SIMD_CFUNC simd_int_rte(simd_float3 __x) { + return simd_make_int3(simd_int_rte(simd_make_float4_undef(__x))); +} + +static simd_int4 SIMD_CFUNC simd_int_rte(simd_float4 __x) { +#if defined __SSE2__ + return _mm_cvtps_epi32(__x); +#elif defined __arm64__ + return vcvtnq_s32_f32(__x); +#else + simd_float4 magic = __tg_copysign(0x1.0p23, __x); + simd_int4 x_is_small = __tg_fabs(__x) < 0x1.0p23; + return __builtin_convertvector(simd_bitselect(__x, (__x + magic) - magic, x_is_small & 0x7fffffff), simd_int4); +#endif +} + +static simd_int8 SIMD_CFUNC simd_int_rte(simd_float8 __x) { +#if defined __AVX__ + return _mm256_cvtps_epi32(__x); +#else + return simd_make_int8(simd_int_rte(__x.lo), simd_int_rte(__x.hi)); +#endif +} + +static simd_int16 SIMD_CFUNC simd_int_rte(simd_float16 __x) { +#if defined __AVX512F__ + return _mm512_cvt_roundps_epi32(__x, _MM_FROUND_RINT); +#else + return simd_make_int16(simd_int_rte(__x.lo), simd_int_rte(__x.hi)); +#endif +} + +static simd_uint2 SIMD_CFUNC simd_uint(simd_char2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_char3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_char4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_char8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_char16 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_uchar2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_uchar3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_uchar4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_uchar8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_uchar16 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_short2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_short3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_short4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_short8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_short16 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_ushort2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_ushort3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_ushort4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_ushort8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_ushort16 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_int2 __x) { return (simd_uint2)__x; } +static simd_uint3 SIMD_CFUNC simd_uint(simd_int3 __x) { return (simd_uint3)__x; } +static simd_uint4 SIMD_CFUNC simd_uint(simd_int4 __x) { return (simd_uint4)__x; } +static simd_uint8 SIMD_CFUNC simd_uint(simd_int8 __x) { return (simd_uint8)__x; } +static simd_uint16 SIMD_CFUNC simd_uint(simd_int16 __x) { return (simd_uint16)__x; } +static simd_uint2 SIMD_CFUNC simd_uint(simd_uint2 __x) { return __x; } +static simd_uint3 SIMD_CFUNC simd_uint(simd_uint3 __x) { return __x; } +static simd_uint4 SIMD_CFUNC simd_uint(simd_uint4 __x) { return __x; } +static simd_uint8 SIMD_CFUNC simd_uint(simd_uint8 __x) { return __x; } +static simd_uint16 SIMD_CFUNC simd_uint(simd_uint16 __x) { return __x; } +static 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); } +static 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); } +static 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); } +static 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); } +static 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); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_long2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_long3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_long4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_long8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_ulong2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_ulong3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_ulong4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_ulong8 __x) { return simd_uint(simd_int(__x)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } + +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_char2 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_char3 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_char4 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_char8 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_char16 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_short2 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_short3 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_short4 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_short8 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_short16 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_int2 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_int3 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_int4 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_int8 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_int16 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_float2 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_float3 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_float4 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_float8 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_float16 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_long2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_long3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_long4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_long8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_double2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_double3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_double4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_double8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uchar2 __x) { return simd_uint(__x); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uchar3 __x) { return simd_uint(__x); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uchar4 __x) { return simd_uint(__x); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uchar8 __x) { return simd_uint(__x); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uchar16 __x) { return simd_uint(__x); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ushort2 __x) { return simd_uint(__x); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ushort3 __x) { return simd_uint(__x); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ushort4 __x) { return simd_uint(__x); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ushort8 __x) { return simd_uint(__x); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_ushort16 __x) { return simd_uint(__x); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uint2 __x) { return __x; } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uint3 __x) { return __x; } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uint4 __x) { return __x; } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uint8 __x) { return __x; } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uint16 __x) { return __x; } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ulong2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ulong3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ulong4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ulong8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } + + +static simd_float2 SIMD_CFUNC simd_float(simd_char2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float3 SIMD_CFUNC simd_float(simd_char3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float4 SIMD_CFUNC simd_float(simd_char4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float8 SIMD_CFUNC simd_float(simd_char8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float16 SIMD_CFUNC simd_float(simd_char16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float2 SIMD_CFUNC simd_float(simd_uchar2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float3 SIMD_CFUNC simd_float(simd_uchar3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float4 SIMD_CFUNC simd_float(simd_uchar4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float8 SIMD_CFUNC simd_float(simd_uchar8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float16 SIMD_CFUNC simd_float(simd_uchar16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float2 SIMD_CFUNC simd_float(simd_short2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float3 SIMD_CFUNC simd_float(simd_short3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float4 SIMD_CFUNC simd_float(simd_short4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float8 SIMD_CFUNC simd_float(simd_short8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float16 SIMD_CFUNC simd_float(simd_short16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float2 SIMD_CFUNC simd_float(simd_ushort2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float3 SIMD_CFUNC simd_float(simd_ushort3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float4 SIMD_CFUNC simd_float(simd_ushort4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float8 SIMD_CFUNC simd_float(simd_ushort8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float16 SIMD_CFUNC simd_float(simd_ushort16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float2 SIMD_CFUNC simd_float(simd_int2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_int3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_int4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_int8 __x) { return __builtin_convertvector(__x,simd_float8); } +static simd_float16 SIMD_CFUNC simd_float(simd_int16 __x) { return __builtin_convertvector(__x,simd_float16); } +static simd_float2 SIMD_CFUNC simd_float(simd_uint2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_uint3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_uint4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_uint8 __x) { return __builtin_convertvector(__x,simd_float8); } +static simd_float16 SIMD_CFUNC simd_float(simd_uint16 __x) { return __builtin_convertvector(__x,simd_float16); } +static simd_float2 SIMD_CFUNC simd_float(simd_float2 __x) { return __x; } +static simd_float3 SIMD_CFUNC simd_float(simd_float3 __x) { return __x; } +static simd_float4 SIMD_CFUNC simd_float(simd_float4 __x) { return __x; } +static simd_float8 SIMD_CFUNC simd_float(simd_float8 __x) { return __x; } +static simd_float16 SIMD_CFUNC simd_float(simd_float16 __x) { return __x; } +static simd_float2 SIMD_CFUNC simd_float(simd_long2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_long3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_long4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_long8 __x) { return __builtin_convertvector(__x,simd_float8); } +static simd_float2 SIMD_CFUNC simd_float(simd_ulong2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_ulong3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_ulong4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_ulong8 __x) { return __builtin_convertvector(__x,simd_float8); } +static simd_float2 SIMD_CFUNC simd_float(simd_double2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_double3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_double4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_double8 __x) { return __builtin_convertvector(__x,simd_float8); } + + +static simd_long2 SIMD_CFUNC simd_long(simd_char2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_char3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_char4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_char8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_uchar2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_uchar3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_uchar4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_uchar8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_short2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_short3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_short4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_short8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_ushort2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_ushort3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_ushort4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_ushort8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_int2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_int3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_int4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_int8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_uint2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_uint3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_uint4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_uint8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_float2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_float3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_float4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_float8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_long2 __x) { return __x; } +static simd_long3 SIMD_CFUNC simd_long(simd_long3 __x) { return __x; } +static simd_long4 SIMD_CFUNC simd_long(simd_long4 __x) { return __x; } +static simd_long8 SIMD_CFUNC simd_long(simd_long8 __x) { return __x; } +static simd_long2 SIMD_CFUNC simd_long(simd_ulong2 __x) { return (simd_long2)__x; } +static simd_long3 SIMD_CFUNC simd_long(simd_ulong3 __x) { return (simd_long3)__x; } +static simd_long4 SIMD_CFUNC simd_long(simd_ulong4 __x) { return (simd_long4)__x; } +static simd_long8 SIMD_CFUNC simd_long(simd_ulong8 __x) { return (simd_long8)__x; } +static simd_long2 SIMD_CFUNC simd_long(simd_double2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_double3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_double4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_double8 __x) { return __builtin_convertvector(__x,simd_long8); } + +static simd_long2 SIMD_CFUNC simd_long_sat(simd_char2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_char3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_char4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_char8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_short2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_short3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_short4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_short8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_int2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_int3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_int4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_int8 __x) { return simd_long(__x); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_long2 __x) { return __x; } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_long3 __x) { return __x; } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_long4 __x) { return __x; } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_long8 __x) { return __x; } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_double2 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_double3 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_double4 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_double8 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_uchar2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_uchar3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_uchar4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_uchar8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_ushort2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_ushort3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_ushort4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_ushort8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_uint2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_uint3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_uint4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_uint8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_ulong2 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_ulong3 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_ulong4 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_ulong8 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); } + +static simd_long2 SIMD_CFUNC simd_long_rte(simd_double2 __x) { +#if defined __AVX512F__ + return _mm_cvtpd_epi64(__x); +#elif defined __arm64__ + return vcvtnq_s64_f64(__x); +#else + simd_double2 magic = __tg_copysign(0x1.0p52, __x); + simd_long2 x_is_small = __tg_fabs(__x) < 0x1.0p52; + return __builtin_convertvector(simd_bitselect(__x, (__x + magic) - magic, x_is_small & 0x7fffffffffffffff), simd_long2); +#endif +} + +static simd_long3 SIMD_CFUNC simd_long_rte(simd_double3 __x) { + return simd_make_long3(simd_long_rte(simd_make_double4_undef(__x))); +} + +static simd_long4 SIMD_CFUNC simd_long_rte(simd_double4 __x) { +#if defined __AVX512F__ + return _mm256_cvtpd_epi64(__x); +#else + return simd_make_long4(simd_long_rte(__x.lo), simd_long_rte(__x.hi)); +#endif +} + +static simd_long8 SIMD_CFUNC simd_long_rte(simd_double8 __x) { +#if defined __AVX512F__ + return _mm512_cvt_roundpd_epi64(__x, _MM_FROUND_RINT); +#else + return simd_make_long8(simd_long_rte(__x.lo), simd_long_rte(__x.hi)); +#endif +} + + +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_char2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_char3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_char4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_char8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uchar2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uchar3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uchar4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uchar8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_short2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_short3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_short4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_short8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ushort2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ushort3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ushort4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ushort8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_int2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_int3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_int4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_int8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uint2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uint3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uint4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uint8 __x) { return simd_ulong(simd_long(__x)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_long2 __x) { return (simd_ulong2)__x; } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_long3 __x) { return (simd_ulong3)__x; } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_long4 __x) { return (simd_ulong4)__x; } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_long8 __x) { return (simd_ulong8)__x; } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ulong2 __x) { return __x; } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ulong3 __x) { return __x; } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ulong4 __x) { return __x; } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ulong8 __x) { return __x; } +static 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); } +static 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); } +static 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); } +static 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); } + +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_char2 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_char3 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_char4 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_char8 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_short2 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_short3 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_short4 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_short8 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_int2 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_int3 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_int4 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_int8 __x) { return simd_ulong(simd_max(__x,0)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_long2 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_long3 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_long4 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_long8 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_double2 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_double3 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_double4 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_double8 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uchar2 __x) { return simd_ulong(__x); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uchar3 __x) { return simd_ulong(__x); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uchar4 __x) { return simd_ulong(__x); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uchar8 __x) { return simd_ulong(__x); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ushort2 __x) { return simd_ulong(__x); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ushort3 __x) { return simd_ulong(__x); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ushort4 __x) { return simd_ulong(__x); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ushort8 __x) { return simd_ulong(__x); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uint2 __x) { return simd_ulong(__x); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uint3 __x) { return simd_ulong(__x); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uint4 __x) { return simd_ulong(__x); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uint8 __x) { return simd_ulong(__x); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ulong2 __x) { return __x; } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ulong3 __x) { return __x; } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ulong4 __x) { return __x; } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ulong8 __x) { return __x; } + + +static simd_double2 SIMD_CFUNC simd_double(simd_char2 __x) { return simd_double(simd_int(__x)); } +static simd_double3 SIMD_CFUNC simd_double(simd_char3 __x) { return simd_double(simd_int(__x)); } +static simd_double4 SIMD_CFUNC simd_double(simd_char4 __x) { return simd_double(simd_int(__x)); } +static simd_double8 SIMD_CFUNC simd_double(simd_char8 __x) { return simd_double(simd_int(__x)); } +static simd_double2 SIMD_CFUNC simd_double(simd_uchar2 __x) { return simd_double(simd_int(__x)); } +static simd_double3 SIMD_CFUNC simd_double(simd_uchar3 __x) { return simd_double(simd_int(__x)); } +static simd_double4 SIMD_CFUNC simd_double(simd_uchar4 __x) { return simd_double(simd_int(__x)); } +static simd_double8 SIMD_CFUNC simd_double(simd_uchar8 __x) { return simd_double(simd_int(__x)); } +static simd_double2 SIMD_CFUNC simd_double(simd_short2 __x) { return simd_double(simd_int(__x)); } +static simd_double3 SIMD_CFUNC simd_double(simd_short3 __x) { return simd_double(simd_int(__x)); } +static simd_double4 SIMD_CFUNC simd_double(simd_short4 __x) { return simd_double(simd_int(__x)); } +static simd_double8 SIMD_CFUNC simd_double(simd_short8 __x) { return simd_double(simd_int(__x)); } +static simd_double2 SIMD_CFUNC simd_double(simd_ushort2 __x) { return simd_double(simd_int(__x)); } +static simd_double3 SIMD_CFUNC simd_double(simd_ushort3 __x) { return simd_double(simd_int(__x)); } +static simd_double4 SIMD_CFUNC simd_double(simd_ushort4 __x) { return simd_double(simd_int(__x)); } +static simd_double8 SIMD_CFUNC simd_double(simd_ushort8 __x) { return simd_double(simd_int(__x)); } +static simd_double2 SIMD_CFUNC simd_double(simd_int2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_int3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_int4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_int8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_uint2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_uint3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_uint4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_uint8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_float2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_float3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_float4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_float8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_long2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_long3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_long4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_long8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_ulong2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_ulong3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_ulong4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_ulong8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_double2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_double3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_double4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_double8 __x) { return __builtin_convertvector(__x, simd_double8); } + + +#ifdef __cplusplus +} +#endif +#endif // SIMD_COMPILER_HAS_REQUIRED_FEATURES +#endif // __SIMD_CONVERSION_HEADER__ + diff --git a/lib/libc/include/x86_64-macos-gnu/simd/extern.h b/lib/libc/include/x86_64-macos-gnu/simd/extern.h new file mode 100644 index 0000000000..b4b6b8f53d --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/extern.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2014 Apple, Inc. All rights reserved. */ + +#ifndef __SIMD_EXTERN_HEADER__ +#define __SIMD_EXTERN_HEADER__ + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma mark - geometry +#if SIMD_LIBRARY_VERSION >= 2 +extern float _simd_orient_vf2(simd_float2, simd_float2); +extern float _simd_orient_pf2(simd_float2, simd_float2, simd_float2); +extern float _simd_incircle_pf2(simd_float2, simd_float2, simd_float2, simd_float2); + +extern float _simd_orient_vf3(simd_float3, simd_float3, simd_float3); +extern float _simd_orient_pf3(simd_float3, simd_float3, simd_float3, simd_float3); +extern float _simd_insphere_pf3(simd_float3, simd_float3, simd_float3, simd_float3, simd_float3); + +extern double _simd_orient_vd2(simd_double2, simd_double2); +extern double _simd_orient_pd2(simd_double2, simd_double2, simd_double2); +extern double _simd_incircle_pd2(simd_double2, simd_double2, simd_double2, simd_double2); + +/* The double3 variants of these functions take their arguments in a buffer + * to workaround the fact that double3 calling conventions are different + * depending on whether or not the executable has been compiled with AVX + * enabled. */ +extern double _simd_orient_vd3(const double *); +extern double _simd_orient_pd3(const double *); +extern double _simd_insphere_pd3(const double *); +#endif /* SIMD_LIBRARY_VERSION */ + +#pragma mark - matrix +extern simd_float2x2 __invert_f2(simd_float2x2); +extern simd_double2x2 __invert_d2(simd_double2x2); +extern simd_float3x3 __invert_f3(simd_float3x3); +extern simd_double3x3 __invert_d3(simd_double3x3); +extern simd_float4x4 __invert_f4(simd_float4x4); +extern simd_double4x4 __invert_d4(simd_double4x4); + +#ifdef __cplusplus +} +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* __SIMD_EXTERN_HEADER__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/geometry.h b/lib/libc/include/x86_64-macos-gnu/simd/geometry.h new file mode 100644 index 0000000000..80b2e5f0f6 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/geometry.h @@ -0,0 +1,1083 @@ +/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved. + * + * The interfaces declared in this header provide operations for mathematical + * vectors; these functions and macros operate on vectors of floating-point + * data only. + * + * Function Result + * ------------------------------------------------------------------ + * simd_dot(x,y) The dot product of x and y. + * + * simd_project(x,y) x projected onto y. There are two variants + * of this function, simd_precise_project + * and simd_fast_project. simd_project + * is equivalent to simd_precise_project + * unless you are compiling with -ffast-math + * specified, in which case it is equivalent + * to simd_fast_project. + * + * simd_length(x) The length (two-norm) of x. Undefined if + * x is poorly scaled such that an + * intermediate computation overflows or + * underflows. There are two variants + * of this function, simd_precise_length + * and simd_fast_length. simd_length + * is equivalent to simd_precise_length + * unless you are compiling with -ffast-math + * specified, in which case it is equivalent + * to simd_fast_length. + * + * simd_length_squared(x) The square of the length of x. If you + * simply need to compare relative magnitudes, + * use this instead of simd_length; it is + * faster than simd_fast_length and as + * accurate as simd_precise_length. + * + * simd_norm_one(x) The one-norm (sum of absolute values) of x. + * + * simd_norm_inf(x) The inf-norm (max absolute value) of x. + * + * simd_distance(x,y) The distance between x and y. Undefined if + * x and y are poorly scaled such that an + * intermediate computation overflows + * or underflows. There are two variants + * of this function, simd_precise_distance + * and simd_fast_distance. simd_distance + * is equivalent to simd_precise_distance + * unless you are compiling with -ffast-math + * specified, in which case it is equivalent + * to simd_fast_distance. + * + * simd_distance_squared(x,y) The square of the distance between x and y. + * + * simd_normalize(x) A vector pointing in the direction of x + * with length 1.0. Undefined if x is + * the zero vector, or if x is poorly scaled + * such that an intermediate computation + * overflows or underflows. There are two + * variants of this function, + * simd_precise_normalize and + * simd_fast_normalize. simd_normalize + * is equivalent to simd_precise_normalize + * unless you are compiling with -ffast-math + * specified, in which case it is equivalent + * to simd_fast_normalize. + * + * simd_cross(x,y) If x and y are vectors of dimension 3, + * the cross-product of x and y. + * + * If x and y are vectors of dimension 2, + * the cross-product of x and y interpreted as + * vectors in the z == 0 plane of a three- + * dimensional space. + * + * If x and y are vectors with a length that + * is neither 2 nor 3, this operation is not + * available. + * + * simd_reflect(x,n) Reflects x through the plane perpendicular + * to the normal vector n. Only available + * for vectors of length 2, 3, or 4. + * + * simd_refract(x,n,eta) Calculates the refraction direction given + * unit incident vector x, unit normal vector + * n, and index of refraction eta. If the + * angle between the incident vector and the + * surface normal is too great for the + * specified index of refraction, zero is + * returned. + * Available for vectors of length 2, 3, or 4. + * + * In C++ the following geometric functions are available in the simd:: + * namespace: + * + * C++ Function Equivalent C Function + * ----------------------------------------------------------- + * simd::dot(x,y) simd_dot(x,y) + * simd::project(x,y) simd_project(x,y) + * simd::length_squared(x) simd_length_squared(x) + * simd::length(x) simd_length(x) + * simd::distance_squared(x,y) simd_distance_squared(x,y) + * simd::norm_one(x) simd_norm_one(x) + * simd::norm_inf(x) simd_norm_inf(x) + * simd::distance(x,y) simd_distance(x,y) + * simd::normalize(x) simd_normalize(x) + * simd::cross(x,y) simd_cross(x,y) + * simd::reflect(x,n) simd_reflect(x,n) + * simd::refract(x,n,eta) simd_refract(x,n,eta) + * + * simd::precise::project(x,y) simd_precise_project(x,y) + * simd::precise::length(x) simd_precise_length(x) + * simd::precise::distance(x,y) simd_precise_distance(x,y) + * simd::precise::normalize(x) simd_precise_normalize(x) + * + * simd::fast::project(x,y) simd_fast_project(x,y) + * simd::fast::length(x) simd_fast_length(x) + * simd::fast::distance(x,y) simd_fast_distance(x,y) + * simd::fast::normalize(x) simd_fast_normalize(x) + */ + +#ifndef __SIMD_GEOMETRY_HEADER__ +#define __SIMD_GEOMETRY_HEADER__ + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static float SIMD_CFUNC simd_dot(simd_float2 __x, simd_float2 __y); +static float SIMD_CFUNC simd_dot(simd_float3 __x, simd_float3 __y); +static float SIMD_CFUNC simd_dot(simd_float4 __x, simd_float4 __y); +static float SIMD_CFUNC simd_dot(simd_float8 __x, simd_float8 __y); +static float SIMD_CFUNC simd_dot(simd_float16 __x, simd_float16 __y); +static double SIMD_CFUNC simd_dot(simd_double2 __x, simd_double2 __y); +static double SIMD_CFUNC simd_dot(simd_double3 __x, simd_double3 __y); +static double SIMD_CFUNC simd_dot(simd_double4 __x, simd_double4 __y); +static double SIMD_CFUNC simd_dot(simd_double8 __x, simd_double8 __y); +#define vector_dot simd_dot + +static simd_float2 SIMD_CFUNC simd_precise_project(simd_float2 __x, simd_float2 __y); +static simd_float3 SIMD_CFUNC simd_precise_project(simd_float3 __x, simd_float3 __y); +static simd_float4 SIMD_CFUNC simd_precise_project(simd_float4 __x, simd_float4 __y); +static simd_float8 SIMD_CFUNC simd_precise_project(simd_float8 __x, simd_float8 __y); +static simd_float16 SIMD_CFUNC simd_precise_project(simd_float16 __x, simd_float16 __y); +static simd_double2 SIMD_CFUNC simd_precise_project(simd_double2 __x, simd_double2 __y); +static simd_double3 SIMD_CFUNC simd_precise_project(simd_double3 __x, simd_double3 __y); +static simd_double4 SIMD_CFUNC simd_precise_project(simd_double4 __x, simd_double4 __y); +static simd_double8 SIMD_CFUNC simd_precise_project(simd_double8 __x, simd_double8 __y); +#define vector_precise_project simd_precise_project + +static simd_float2 SIMD_CFUNC simd_fast_project(simd_float2 __x, simd_float2 __y); +static simd_float3 SIMD_CFUNC simd_fast_project(simd_float3 __x, simd_float3 __y); +static simd_float4 SIMD_CFUNC simd_fast_project(simd_float4 __x, simd_float4 __y); +static simd_float8 SIMD_CFUNC simd_fast_project(simd_float8 __x, simd_float8 __y); +static simd_float16 SIMD_CFUNC simd_fast_project(simd_float16 __x, simd_float16 __y); +static simd_double2 SIMD_CFUNC simd_fast_project(simd_double2 __x, simd_double2 __y); +static simd_double3 SIMD_CFUNC simd_fast_project(simd_double3 __x, simd_double3 __y); +static simd_double4 SIMD_CFUNC simd_fast_project(simd_double4 __x, simd_double4 __y); +static simd_double8 SIMD_CFUNC simd_fast_project(simd_double8 __x, simd_double8 __y); +#define vector_fast_project simd_fast_project + +static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y); +static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y); +static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y); +static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y); +static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y); +static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y); +static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y); +static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y); +static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y); +#define vector_project simd_project + +static float SIMD_CFUNC simd_precise_length(simd_float2 __x); +static float SIMD_CFUNC simd_precise_length(simd_float3 __x); +static float SIMD_CFUNC simd_precise_length(simd_float4 __x); +static float SIMD_CFUNC simd_precise_length(simd_float8 __x); +static float SIMD_CFUNC simd_precise_length(simd_float16 __x); +static double SIMD_CFUNC simd_precise_length(simd_double2 __x); +static double SIMD_CFUNC simd_precise_length(simd_double3 __x); +static double SIMD_CFUNC simd_precise_length(simd_double4 __x); +static double SIMD_CFUNC simd_precise_length(simd_double8 __x); +#define vector_precise_length simd_precise_length + +static float SIMD_CFUNC simd_fast_length(simd_float2 __x); +static float SIMD_CFUNC simd_fast_length(simd_float3 __x); +static float SIMD_CFUNC simd_fast_length(simd_float4 __x); +static float SIMD_CFUNC simd_fast_length(simd_float8 __x); +static float SIMD_CFUNC simd_fast_length(simd_float16 __x); +static double SIMD_CFUNC simd_fast_length(simd_double2 __x); +static double SIMD_CFUNC simd_fast_length(simd_double3 __x); +static double SIMD_CFUNC simd_fast_length(simd_double4 __x); +static double SIMD_CFUNC simd_fast_length(simd_double8 __x); +#define vector_fast_length simd_fast_length + +static float SIMD_CFUNC simd_length(simd_float2 __x); +static float SIMD_CFUNC simd_length(simd_float3 __x); +static float SIMD_CFUNC simd_length(simd_float4 __x); +static float SIMD_CFUNC simd_length(simd_float8 __x); +static float SIMD_CFUNC simd_length(simd_float16 __x); +static double SIMD_CFUNC simd_length(simd_double2 __x); +static double SIMD_CFUNC simd_length(simd_double3 __x); +static double SIMD_CFUNC simd_length(simd_double4 __x); +static double SIMD_CFUNC simd_length(simd_double8 __x); +#define vector_length simd_length + +static float SIMD_CFUNC simd_length_squared(simd_float2 __x); +static float SIMD_CFUNC simd_length_squared(simd_float3 __x); +static float SIMD_CFUNC simd_length_squared(simd_float4 __x); +static float SIMD_CFUNC simd_length_squared(simd_float8 __x); +static float SIMD_CFUNC simd_length_squared(simd_float16 __x); +static double SIMD_CFUNC simd_length_squared(simd_double2 __x); +static double SIMD_CFUNC simd_length_squared(simd_double3 __x); +static double SIMD_CFUNC simd_length_squared(simd_double4 __x); +static double SIMD_CFUNC simd_length_squared(simd_double8 __x); +#define vector_length_squared simd_length_squared + +static float SIMD_CFUNC simd_norm_one(simd_float2 __x); +static float SIMD_CFUNC simd_norm_one(simd_float3 __x); +static float SIMD_CFUNC simd_norm_one(simd_float4 __x); +static float SIMD_CFUNC simd_norm_one(simd_float8 __x); +static float SIMD_CFUNC simd_norm_one(simd_float16 __x); +static double SIMD_CFUNC simd_norm_one(simd_double2 __x); +static double SIMD_CFUNC simd_norm_one(simd_double3 __x); +static double SIMD_CFUNC simd_norm_one(simd_double4 __x); +static double SIMD_CFUNC simd_norm_one(simd_double8 __x); +#define vector_norm_one simd_norm_one + +static float SIMD_CFUNC simd_norm_inf(simd_float2 __x); +static float SIMD_CFUNC simd_norm_inf(simd_float3 __x); +static float SIMD_CFUNC simd_norm_inf(simd_float4 __x); +static float SIMD_CFUNC simd_norm_inf(simd_float8 __x); +static float SIMD_CFUNC simd_norm_inf(simd_float16 __x); +static double SIMD_CFUNC simd_norm_inf(simd_double2 __x); +static double SIMD_CFUNC simd_norm_inf(simd_double3 __x); +static double SIMD_CFUNC simd_norm_inf(simd_double4 __x); +static double SIMD_CFUNC simd_norm_inf(simd_double8 __x); +#define vector_norm_inf simd_norm_inf + +static float SIMD_CFUNC simd_precise_distance(simd_float2 __x, simd_float2 __y); +static float SIMD_CFUNC simd_precise_distance(simd_float3 __x, simd_float3 __y); +static float SIMD_CFUNC simd_precise_distance(simd_float4 __x, simd_float4 __y); +static float SIMD_CFUNC simd_precise_distance(simd_float8 __x, simd_float8 __y); +static float SIMD_CFUNC simd_precise_distance(simd_float16 __x, simd_float16 __y); +static double SIMD_CFUNC simd_precise_distance(simd_double2 __x, simd_double2 __y); +static double SIMD_CFUNC simd_precise_distance(simd_double3 __x, simd_double3 __y); +static double SIMD_CFUNC simd_precise_distance(simd_double4 __x, simd_double4 __y); +static double SIMD_CFUNC simd_precise_distance(simd_double8 __x, simd_double8 __y); +#define vector_precise_distance simd_precise_distance + +static float SIMD_CFUNC simd_fast_distance(simd_float2 __x, simd_float2 __y); +static float SIMD_CFUNC simd_fast_distance(simd_float3 __x, simd_float3 __y); +static float SIMD_CFUNC simd_fast_distance(simd_float4 __x, simd_float4 __y); +static float SIMD_CFUNC simd_fast_distance(simd_float8 __x, simd_float8 __y); +static float SIMD_CFUNC simd_fast_distance(simd_float16 __x, simd_float16 __y); +static double SIMD_CFUNC simd_fast_distance(simd_double2 __x, simd_double2 __y); +static double SIMD_CFUNC simd_fast_distance(simd_double3 __x, simd_double3 __y); +static double SIMD_CFUNC simd_fast_distance(simd_double4 __x, simd_double4 __y); +static double SIMD_CFUNC simd_fast_distance(simd_double8 __x, simd_double8 __y); +#define vector_fast_distance simd_fast_distance + +static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y); +static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y); +static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y); +static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y); +static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y); +static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y); +static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y); +static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y); +static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y); +#define vector_distance simd_distance + +static float SIMD_CFUNC simd_distance_squared(simd_float2 __x, simd_float2 __y); +static float SIMD_CFUNC simd_distance_squared(simd_float3 __x, simd_float3 __y); +static float SIMD_CFUNC simd_distance_squared(simd_float4 __x, simd_float4 __y); +static float SIMD_CFUNC simd_distance_squared(simd_float8 __x, simd_float8 __y); +static float SIMD_CFUNC simd_distance_squared(simd_float16 __x, simd_float16 __y); +static double SIMD_CFUNC simd_distance_squared(simd_double2 __x, simd_double2 __y); +static double SIMD_CFUNC simd_distance_squared(simd_double3 __x, simd_double3 __y); +static double SIMD_CFUNC simd_distance_squared(simd_double4 __x, simd_double4 __y); +static double SIMD_CFUNC simd_distance_squared(simd_double8 __x, simd_double8 __y); +#define vector_distance_squared simd_distance_squared + +static simd_float2 SIMD_CFUNC simd_precise_normalize(simd_float2 __x); +static simd_float3 SIMD_CFUNC simd_precise_normalize(simd_float3 __x); +static simd_float4 SIMD_CFUNC simd_precise_normalize(simd_float4 __x); +static simd_float8 SIMD_CFUNC simd_precise_normalize(simd_float8 __x); +static simd_float16 SIMD_CFUNC simd_precise_normalize(simd_float16 __x); +static simd_double2 SIMD_CFUNC simd_precise_normalize(simd_double2 __x); +static simd_double3 SIMD_CFUNC simd_precise_normalize(simd_double3 __x); +static simd_double4 SIMD_CFUNC simd_precise_normalize(simd_double4 __x); +static simd_double8 SIMD_CFUNC simd_precise_normalize(simd_double8 __x); +#define vector_precise_normalize simd_precise_normalize + +static simd_float2 SIMD_CFUNC simd_fast_normalize(simd_float2 __x); +static simd_float3 SIMD_CFUNC simd_fast_normalize(simd_float3 __x); +static simd_float4 SIMD_CFUNC simd_fast_normalize(simd_float4 __x); +static simd_float8 SIMD_CFUNC simd_fast_normalize(simd_float8 __x); +static simd_float16 SIMD_CFUNC simd_fast_normalize(simd_float16 __x); +static simd_double2 SIMD_CFUNC simd_fast_normalize(simd_double2 __x); +static simd_double3 SIMD_CFUNC simd_fast_normalize(simd_double3 __x); +static simd_double4 SIMD_CFUNC simd_fast_normalize(simd_double4 __x); +static simd_double8 SIMD_CFUNC simd_fast_normalize(simd_double8 __x); +#define vector_fast_normalize simd_fast_normalize + +static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x); +static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x); +static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x); +static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x); +static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x); +static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x); +static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x); +static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x); +static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x); +#define vector_normalize simd_normalize + +static simd_float3 SIMD_CFUNC simd_cross(simd_float2 __x, simd_float2 __y); +static simd_float3 SIMD_CFUNC simd_cross(simd_float3 __x, simd_float3 __y); +static simd_double3 SIMD_CFUNC simd_cross(simd_double2 __x, simd_double2 __y); +static simd_double3 SIMD_CFUNC simd_cross(simd_double3 __x, simd_double3 __y); +#define vector_cross simd_cross + +static simd_float2 SIMD_CFUNC simd_reflect(simd_float2 __x, simd_float2 __n); +static simd_float3 SIMD_CFUNC simd_reflect(simd_float3 __x, simd_float3 __n); +static simd_float4 SIMD_CFUNC simd_reflect(simd_float4 __x, simd_float4 __n); +static simd_double2 SIMD_CFUNC simd_reflect(simd_double2 __x, simd_double2 __n); +static simd_double3 SIMD_CFUNC simd_reflect(simd_double3 __x, simd_double3 __n); +static simd_double4 SIMD_CFUNC simd_reflect(simd_double4 __x, simd_double4 __n); +#define vector_reflect simd_reflect + +static simd_float2 SIMD_CFUNC simd_refract(simd_float2 __x, simd_float2 __n, float __eta); +static simd_float3 SIMD_CFUNC simd_refract(simd_float3 __x, simd_float3 __n, float __eta); +static simd_float4 SIMD_CFUNC simd_refract(simd_float4 __x, simd_float4 __n, float __eta); +static simd_double2 SIMD_CFUNC simd_refract(simd_double2 __x, simd_double2 __n, double __eta); +static simd_double3 SIMD_CFUNC simd_refract(simd_double3 __x, simd_double3 __n, double __eta); +static simd_double4 SIMD_CFUNC simd_refract(simd_double4 __x, simd_double4 __n, double __eta); +#define vector_refract simd_refract + +#if SIMD_LIBRARY_VERSION >= 2 +/* These functions require that you are building for OS X 10.12 or later, + * iOS 10.0 or later, watchOS 3.0 or later, and tvOS 10.0 or later. On + * earlier OS versions, the library functions that implement these + * operations are not available. */ + +/*! @functiongroup vector orientation + * + * @discussion These functions return a positive value if the origin and + * their ordered arguments determine a positively oriented parallelepiped, + * zero if it is degenerate, and a negative value if it is negatively + * oriented. This is equivalent to saying that the matrix with rows equal + * to the vectors has a positive, zero, or negative determinant, + * respectively. + * + * Naive evaluation of the determinant is prone to producing incorrect + * results if the vectors are nearly degenerate (e.g. floating-point + * rounding might cause the determinant to be zero or negative when + * the points are very nearly coplanar but positively oriented). If + * the vectors are very large or small, computing the determininat is + * also prone to premature overflow, which may cause the result to be + * NaN even though the vectors contain normal floating-point numbers. + * + * These routines take care to avoid those issues and always return a + * result with correct sign, even when the problem is very ill- + * conditioned. */ + +/*! @abstract Test the orientation of two 2d vectors. + * + * @param __x The first vector. + * @param __y The second vector. + * + * @result Positive if (x, y) are positively oriented, zero if they are + * colinear, and negative if they are negatively oriented. + * + * @discussion For two-dimensional vectors, "positively oriented" is + * equivalent to the ordering (0, x, y) proceeding counter-clockwise + * when viewed down the z axis, or to the cross product of x and y + * extended to three-dimensions having positive z-component. */ +static float SIMD_CFUNC simd_orient(simd_float2 __x, simd_float2 __y); + +/*! @abstract Test the orientation of two 2d vectors. + * + * @param __x The first vector. + * @param __y The second vector. + * + * @result Positive if (x, y) are positively oriented, zero if they are + * colinear, and negative if they are negatively oriented. + * + * @discussion For two-dimensional vectors, "positively oriented" is + * equivalent to the ordering (0, x, y) proceeding counter- clockwise + * when viewed down the z axis, or to the cross product of x and y + * extended to three-dimensions having positive z-component. */ +static double SIMD_CFUNC simd_orient(simd_double2 __x, simd_double2 __y); + +/*! @abstract Test the orientation of three 3d vectors. + * + * @param __x The first vector. + * @param __y The second vector. + * @param __z The third vector. + * + * @result Positive if (x, y, z) are positively oriented, zero if they + * are coplanar, and negative if they are negatively oriented. + * + * @discussion For three-dimensional vectors, "positively oriented" is + * equivalent to the ordering (x, y, z) following the "right hand rule", + * or to the dot product of z with the cross product of x and y being + * positive. */ +static float SIMD_CFUNC simd_orient(simd_float3 __x, simd_float3 __y, simd_float3 __z); + +/*! @abstract Test the orientation of three 3d vectors. + * + * @param __x The first vector. + * @param __y The second vector. + * @param __z The third vector. + * + * @result Positive if (x, y, c) are positively oriented, zero if they + * are coplanar, and negative if they are negatively oriented. + * + * @discussion For three-dimensional vectors, "positively oriented" is + * equivalent to the ordering (x, y, z) following the "right hand rule", + * or to the dot product of z with the cross product of x and y being + * positive. */ +static double SIMD_CFUNC simd_orient(simd_double3 __x, simd_double3 __y, simd_double3 __z); + +/*! @functiongroup point (affine) orientation + * + * @discussion These functions return a positive value if their ordered + * arguments determine a positively oriented parallelepiped, zero if it + * is degenerate, and a negative value if it is negatively oriented. + * + * simd_orient(a, b, c) is formally equivalent to simd_orient(b-a, c-a), + * but it is not effected by rounding error from subtraction of points, + * as that implementation would be. Care is taken so that the sign of + * the result is always correct, even if the problem is ill-conditioned. */ + +/*! @abstract Test the orientation of a triangle in 2d. + * + * @param __a The first point of the triangle. + * @param __b The second point of the triangle. + * @param __c The third point of the triangle. + * + * @result Positive if the triangle is positively oriented, zero if it + * is degenerate (three points in a line), and negative if it is negatively + * oriented. + * + * @discussion "Positively oriented" is equivalent to the ordering + * (a, b, c) proceeding counter-clockwise when viewed down the z axis, + * or to the cross product of a-c and b-c extended to three-dimensions + * having positive z-component. */ +static float SIMD_CFUNC simd_orient(simd_float2 __a, simd_float2 __b, simd_float2 __c); + +/*! @abstract Test the orientation of a triangle in 2d. + * + * @param __a The first point of the triangle. + * @param __b The second point of the triangle. + * @param __c The third point of the triangle. + * + * @result Positive if the triangle is positively oriented, zero if it + * is degenerate (three points in a line), and negative if it is negatively + * oriented. + * + * @discussion "Positively oriented" is equivalent to the ordering + * (a, b, c) proceeding counter-clockwise when viewed down the z axis, + * or to the cross product of a-c and b-c extended to three-dimensions + * having positive z-component. */ +static double SIMD_CFUNC simd_orient(simd_double2 __a, simd_double2 __b, simd_double2 __c); + +/*! @abstract Test the orientation of a tetrahedron in 3d. + * + * @param __a The first point of the tetrahedron. + * @param __b The second point of the tetrahedron. + * @param __c The third point of the tetrahedron. + * @param __d The fourth point of the tetrahedron. + * + * @result Positive if the tetrahedron is positively oriented, zero if it + * is degenerate (four points in a plane), and negative if it is negatively + * oriented. + * + * @discussion "Positively oriented" is equivalent to the vectors + * (a-d, b-d, c-d) following the "right hand rule", or to the dot product + * of c-d with the the cross product of a-d and b-d being positive. */ +static float SIMD_CFUNC simd_orient(simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d); + +/*! @abstract Test the orientation of a tetrahedron in 3d. + * + * @param __a The first point of the tetrahedron. + * @param __b The second point of the tetrahedron. + * @param __c The third point of the tetrahedron. + * @param __d The fourth point of the tetrahedron. + * + * @result Positive if the tetrahedron is positively oriented, zero if it + * is degenerate (four points in a plane), and negative if it is negatively + * oriented. + * + * @discussion "Positively oriented" is equivalent to the vectors + * (a-d, b-d, c-d) following the "right hand rule", or to the dot product + * of c-d with the the cross product of a-d and b-d being positive. */ +static double SIMD_CFUNC simd_orient(simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d); + +/*! @functiongroup incircle (points) tests + * + * @discussion These functions determine whether the point x is inside, on, + * or outside the circle or sphere passing through a group of points. If + * x is inside the circle, the result is positive; if x is on the circle, + * the result is zero; if x is outside the circle the result is negative. + * + * These functions are always exact, even if the problem is ill- + * conditioned (meaning that the points are nearly co-linear or + * co-planar). + * + * If the points are negatively-oriented, the the notions of "inside" and + * "outside" are flipped. If the points are degenerate, then the result + * is undefined. */ + +/*! @abstract Test if x lies inside, on, or outside the circle passing + * through a, b, and c. + * + * @param __x The point being tested. + * @param __a The first point determining the circle. + * @param __b The second point determining the circle. + * @param __c The third point determining the circle. + * + * @result Assuming that (a,b,c) are positively-oriented, positive if x is + * inside the circle, zero if x is on the circle, and negative if x is + * outside the circle. The sign of the result is flipped if (a,b,c) are + * negatively-oriented. */ +static float SIMD_CFUNC simd_incircle(simd_float2 __x, simd_float2 __a, simd_float2 __b, simd_float2 __c); + +/*! @abstract Test if x lies inside, on, or outside the circle passing + * through a, b, and c. + * + * @param __x The point being tested. + * @param __a The first point determining the circle. + * @param __b The second point determining the circle. + * @param __c The third point determining the circle. + * + * @result Assuming that (a,b,c) are positively-oriented, positive if x is + * inside the circle, zero if x is on the circle, and negative if x is + * outside the circle. The sign of the result is flipped if (a,b,c) are + * negatively-oriented. */ +static double SIMD_CFUNC simd_incircle(simd_double2 __x, simd_double2 __a, simd_double2 __b, simd_double2 __c); + +/*! @abstract Test if x lies inside, on, or outside the sphere passing + * through a, b, c, and d. + * + * @param __x The point being tested. + * @param __a The first point determining the sphere. + * @param __b The second point determining the sphere. + * @param __c The third point determining the sphere. + * @param __d The fourth point determining the sphere. + * + * @result Assuming that the points are positively-oriented, positive if x + * is inside the sphere, zero if x is on the sphere, and negative if x is + * outside the sphere. The sign of the result is flipped if the points are + * negatively-oriented. */ +static float SIMD_CFUNC simd_insphere(simd_float3 __x, simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d); + +/*! @abstract Test if x lies inside, on, or outside the sphere passing + * through a, b, c, and d. + * + * @param __x The point being tested. + * @param __a The first point determining the sphere. + * @param __b The second point determining the sphere. + * @param __c The third point determining the sphere. + * @param __d The fourth point determining the sphere. + * + * @result Assuming that the points are positively-oriented, positive if x + * is inside the sphere, zero if x is on the sphere, and negative if x is + * outside the sphere. The sign of the result is flipped if the points are + * negatively-oriented. */ +static double SIMD_CFUNC simd_insphere(simd_double3 __x, simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d); +#endif /* SIMD_LIBRARY_VERSION */ + +#ifdef __cplusplus +} /* extern "C" */ + +namespace simd { + static SIMD_CPPFUNC float dot(const float2 x, const float2 y) { return ::simd_dot(x, y); } + static SIMD_CPPFUNC float dot(const float3 x, const float3 y) { return ::simd_dot(x, y); } + static SIMD_CPPFUNC float dot(const float4 x, const float4 y) { return ::simd_dot(x, y); } + static SIMD_CPPFUNC float dot(const float8 x, const float8 y) { return ::simd_dot(x, y); } + static SIMD_CPPFUNC float dot(const float16 x, const float16 y) { return ::simd_dot(x, y); } + static SIMD_CPPFUNC double dot(const double2 x, const double2 y) { return ::simd_dot(x, y); } + static SIMD_CPPFUNC double dot(const double3 x, const double3 y) { return ::simd_dot(x, y); } + static SIMD_CPPFUNC double dot(const double4 x, const double4 y) { return ::simd_dot(x, y); } + static SIMD_CPPFUNC double dot(const double8 x, const double8 y) { return ::simd_dot(x, y); } + + static SIMD_CPPFUNC float2 project(const float2 x, const float2 y) { return ::simd_project(x, y); } + static SIMD_CPPFUNC float3 project(const float3 x, const float3 y) { return ::simd_project(x, y); } + static SIMD_CPPFUNC float4 project(const float4 x, const float4 y) { return ::simd_project(x, y); } + static SIMD_CPPFUNC float8 project(const float8 x, const float8 y) { return ::simd_project(x, y); } + static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_project(x, y); } + static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_project(x, y); } + static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_project(x, y); } + static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_project(x, y); } + static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_project(x, y); } + + static SIMD_CPPFUNC float length_squared(const float2 x) { return ::simd_length_squared(x); } + static SIMD_CPPFUNC float length_squared(const float3 x) { return ::simd_length_squared(x); } + static SIMD_CPPFUNC float length_squared(const float4 x) { return ::simd_length_squared(x); } + static SIMD_CPPFUNC float length_squared(const float8 x) { return ::simd_length_squared(x); } + static SIMD_CPPFUNC float length_squared(const float16 x) { return ::simd_length_squared(x); } + static SIMD_CPPFUNC double length_squared(const double2 x) { return ::simd_length_squared(x); } + static SIMD_CPPFUNC double length_squared(const double3 x) { return ::simd_length_squared(x); } + static SIMD_CPPFUNC double length_squared(const double4 x) { return ::simd_length_squared(x); } + static SIMD_CPPFUNC double length_squared(const double8 x) { return ::simd_length_squared(x); } + + static SIMD_CPPFUNC float norm_one(const float2 x) { return ::simd_norm_one(x); } + static SIMD_CPPFUNC float norm_one(const float3 x) { return ::simd_norm_one(x); } + static SIMD_CPPFUNC float norm_one(const float4 x) { return ::simd_norm_one(x); } + static SIMD_CPPFUNC float norm_one(const float8 x) { return ::simd_norm_one(x); } + static SIMD_CPPFUNC float norm_one(const float16 x) { return ::simd_norm_one(x); } + static SIMD_CPPFUNC double norm_one(const double2 x) { return ::simd_norm_one(x); } + static SIMD_CPPFUNC double norm_one(const double3 x) { return ::simd_norm_one(x); } + static SIMD_CPPFUNC double norm_one(const double4 x) { return ::simd_norm_one(x); } + static SIMD_CPPFUNC double norm_one(const double8 x) { return ::simd_norm_one(x); } + + static SIMD_CPPFUNC float norm_inf(const float2 x) { return ::simd_norm_inf(x); } + static SIMD_CPPFUNC float norm_inf(const float3 x) { return ::simd_norm_inf(x); } + static SIMD_CPPFUNC float norm_inf(const float4 x) { return ::simd_norm_inf(x); } + static SIMD_CPPFUNC float norm_inf(const float8 x) { return ::simd_norm_inf(x); } + static SIMD_CPPFUNC float norm_inf(const float16 x) { return ::simd_norm_inf(x); } + static SIMD_CPPFUNC double norm_inf(const double2 x) { return ::simd_norm_inf(x); } + static SIMD_CPPFUNC double norm_inf(const double3 x) { return ::simd_norm_inf(x); } + static SIMD_CPPFUNC double norm_inf(const double4 x) { return ::simd_norm_inf(x); } + static SIMD_CPPFUNC double norm_inf(const double8 x) { return ::simd_norm_inf(x); } + + static SIMD_CPPFUNC float length(const float2 x) { return ::simd_length(x); } + static SIMD_CPPFUNC float length(const float3 x) { return ::simd_length(x); } + static SIMD_CPPFUNC float length(const float4 x) { return ::simd_length(x); } + static SIMD_CPPFUNC float length(const float8 x) { return ::simd_length(x); } + static SIMD_CPPFUNC float length(const float16 x) { return ::simd_length(x); } + static SIMD_CPPFUNC double length(const double2 x) { return ::simd_length(x); } + static SIMD_CPPFUNC double length(const double3 x) { return ::simd_length(x); } + static SIMD_CPPFUNC double length(const double4 x) { return ::simd_length(x); } + static SIMD_CPPFUNC double length(const double8 x) { return ::simd_length(x); } + + static SIMD_CPPFUNC float distance_squared(const float2 x, const float2 y) { return ::simd_distance_squared(x, y); } + static SIMD_CPPFUNC float distance_squared(const float3 x, const float3 y) { return ::simd_distance_squared(x, y); } + static SIMD_CPPFUNC float distance_squared(const float4 x, const float4 y) { return ::simd_distance_squared(x, y); } + static SIMD_CPPFUNC float distance_squared(const float8 x, const float8 y) { return ::simd_distance_squared(x, y); } + static SIMD_CPPFUNC float distance_squared(const float16 x, const float16 y) { return ::simd_distance_squared(x, y); } + static SIMD_CPPFUNC double distance_squared(const double2 x, const double2 y) { return ::simd_distance_squared(x, y); } + static SIMD_CPPFUNC double distance_squared(const double3 x, const double3 y) { return ::simd_distance_squared(x, y); } + static SIMD_CPPFUNC double distance_squared(const double4 x, const double4 y) { return ::simd_distance_squared(x, y); } + static SIMD_CPPFUNC double distance_squared(const double8 x, const double8 y) { return ::simd_distance_squared(x, y); } + + static SIMD_CPPFUNC float distance(const float2 x, const float2 y) { return ::simd_distance(x, y); } + static SIMD_CPPFUNC float distance(const float3 x, const float3 y) { return ::simd_distance(x, y); } + static SIMD_CPPFUNC float distance(const float4 x, const float4 y) { return ::simd_distance(x, y); } + static SIMD_CPPFUNC float distance(const float8 x, const float8 y) { return ::simd_distance(x, y); } + static SIMD_CPPFUNC float distance(const float16 x, const float16 y) { return ::simd_distance(x, y); } + static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_distance(x, y); } + static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_distance(x, y); } + static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_distance(x, y); } + static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_distance(x, y); } + + static SIMD_CPPFUNC float2 normalize(const float2 x) { return ::simd_normalize(x); } + static SIMD_CPPFUNC float3 normalize(const float3 x) { return ::simd_normalize(x); } + static SIMD_CPPFUNC float4 normalize(const float4 x) { return ::simd_normalize(x); } + static SIMD_CPPFUNC float8 normalize(const float8 x) { return ::simd_normalize(x); } + static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_normalize(x); } + static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_normalize(x); } + static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_normalize(x); } + static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_normalize(x); } + static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_normalize(x); } + + static SIMD_CPPFUNC float3 cross(const float2 x, const float2 y) { return ::simd_cross(x,y); } + static SIMD_CPPFUNC float3 cross(const float3 x, const float3 y) { return ::simd_cross(x,y); } + static SIMD_CPPFUNC double3 cross(const double2 x, const double2 y) { return ::simd_cross(x,y); } + static SIMD_CPPFUNC double3 cross(const double3 x, const double3 y) { return ::simd_cross(x,y); } + + static SIMD_CPPFUNC float2 reflect(const float2 x, const float2 n) { return ::simd_reflect(x,n); } + static SIMD_CPPFUNC float3 reflect(const float3 x, const float3 n) { return ::simd_reflect(x,n); } + static SIMD_CPPFUNC float4 reflect(const float4 x, const float4 n) { return ::simd_reflect(x,n); } + static SIMD_CPPFUNC double2 reflect(const double2 x, const double2 n) { return ::simd_reflect(x,n); } + static SIMD_CPPFUNC double3 reflect(const double3 x, const double3 n) { return ::simd_reflect(x,n); } + static SIMD_CPPFUNC double4 reflect(const double4 x, const double4 n) { return ::simd_reflect(x,n); } + + static SIMD_CPPFUNC float2 refract(const float2 x, const float2 n, const float eta) { return ::simd_refract(x,n,eta); } + static SIMD_CPPFUNC float3 refract(const float3 x, const float3 n, const float eta) { return ::simd_refract(x,n,eta); } + static SIMD_CPPFUNC float4 refract(const float4 x, const float4 n, const float eta) { return ::simd_refract(x,n,eta); } + static SIMD_CPPFUNC double2 refract(const double2 x, const double2 n, const float eta) { return ::simd_refract(x,n,eta); } + static SIMD_CPPFUNC double3 refract(const double3 x, const double3 n, const float eta) { return ::simd_refract(x,n,eta); } + static SIMD_CPPFUNC double4 refract(const double4 x, const double4 n, const float eta) { return ::simd_refract(x,n,eta); } + + /* precise and fast sub-namespaces */ + namespace precise { + static SIMD_CPPFUNC float2 project(const float2 x, const float2 y) { return ::simd_precise_project(x, y); } + static SIMD_CPPFUNC float3 project(const float3 x, const float3 y) { return ::simd_precise_project(x, y); } + static SIMD_CPPFUNC float4 project(const float4 x, const float4 y) { return ::simd_precise_project(x, y); } + static SIMD_CPPFUNC float8 project(const float8 x, const float8 y) { return ::simd_precise_project(x, y); } + static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_precise_project(x, y); } + static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_precise_project(x, y); } + static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_precise_project(x, y); } + static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_precise_project(x, y); } + static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_precise_project(x, y); } + + static SIMD_CPPFUNC float length(const float2 x) { return ::simd_precise_length(x); } + static SIMD_CPPFUNC float length(const float3 x) { return ::simd_precise_length(x); } + static SIMD_CPPFUNC float length(const float4 x) { return ::simd_precise_length(x); } + static SIMD_CPPFUNC float length(const float8 x) { return ::simd_precise_length(x); } + static SIMD_CPPFUNC float length(const float16 x) { return ::simd_precise_length(x); } + static SIMD_CPPFUNC double length(const double2 x) { return ::simd_precise_length(x); } + static SIMD_CPPFUNC double length(const double3 x) { return ::simd_precise_length(x); } + static SIMD_CPPFUNC double length(const double4 x) { return ::simd_precise_length(x); } + static SIMD_CPPFUNC double length(const double8 x) { return ::simd_precise_length(x); } + + static SIMD_CPPFUNC float distance(const float2 x, const float2 y) { return ::simd_precise_distance(x, y); } + static SIMD_CPPFUNC float distance(const float3 x, const float3 y) { return ::simd_precise_distance(x, y); } + static SIMD_CPPFUNC float distance(const float4 x, const float4 y) { return ::simd_precise_distance(x, y); } + static SIMD_CPPFUNC float distance(const float8 x, const float8 y) { return ::simd_precise_distance(x, y); } + static SIMD_CPPFUNC float distance(const float16 x, const float16 y) { return ::simd_precise_distance(x, y); } + static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_precise_distance(x, y); } + static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_precise_distance(x, y); } + static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_precise_distance(x, y); } + static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_precise_distance(x, y); } + + static SIMD_CPPFUNC float2 normalize(const float2 x) { return ::simd_precise_normalize(x); } + static SIMD_CPPFUNC float3 normalize(const float3 x) { return ::simd_precise_normalize(x); } + static SIMD_CPPFUNC float4 normalize(const float4 x) { return ::simd_precise_normalize(x); } + static SIMD_CPPFUNC float8 normalize(const float8 x) { return ::simd_precise_normalize(x); } + static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_precise_normalize(x); } + static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_precise_normalize(x); } + static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_precise_normalize(x); } + static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_precise_normalize(x); } + static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_precise_normalize(x); } + } + + namespace fast { + static SIMD_CPPFUNC float2 project(const float2 x, const float2 y) { return ::simd_fast_project(x, y); } + static SIMD_CPPFUNC float3 project(const float3 x, const float3 y) { return ::simd_fast_project(x, y); } + static SIMD_CPPFUNC float4 project(const float4 x, const float4 y) { return ::simd_fast_project(x, y); } + static SIMD_CPPFUNC float8 project(const float8 x, const float8 y) { return ::simd_fast_project(x, y); } + static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_fast_project(x, y); } + static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_fast_project(x, y); } + static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_fast_project(x, y); } + static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_fast_project(x, y); } + static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_fast_project(x, y); } + + static SIMD_CPPFUNC float length(const float2 x) { return ::simd_fast_length(x); } + static SIMD_CPPFUNC float length(const float3 x) { return ::simd_fast_length(x); } + static SIMD_CPPFUNC float length(const float4 x) { return ::simd_fast_length(x); } + static SIMD_CPPFUNC float length(const float8 x) { return ::simd_fast_length(x); } + static SIMD_CPPFUNC float length(const float16 x) { return ::simd_fast_length(x); } + static SIMD_CPPFUNC double length(const double2 x) { return ::simd_fast_length(x); } + static SIMD_CPPFUNC double length(const double3 x) { return ::simd_fast_length(x); } + static SIMD_CPPFUNC double length(const double4 x) { return ::simd_fast_length(x); } + static SIMD_CPPFUNC double length(const double8 x) { return ::simd_fast_length(x); } + + static SIMD_CPPFUNC float distance(const float2 x, const float2 y) { return ::simd_fast_distance(x, y); } + static SIMD_CPPFUNC float distance(const float3 x, const float3 y) { return ::simd_fast_distance(x, y); } + static SIMD_CPPFUNC float distance(const float4 x, const float4 y) { return ::simd_fast_distance(x, y); } + static SIMD_CPPFUNC float distance(const float8 x, const float8 y) { return ::simd_fast_distance(x, y); } + static SIMD_CPPFUNC float distance(const float16 x, const float16 y) { return ::simd_fast_distance(x, y); } + static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_fast_distance(x, y); } + static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_fast_distance(x, y); } + static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_fast_distance(x, y); } + static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_fast_distance(x, y); } + + static SIMD_CPPFUNC float2 normalize(const float2 x) { return ::simd_fast_normalize(x); } + static SIMD_CPPFUNC float3 normalize(const float3 x) { return ::simd_fast_normalize(x); } + static SIMD_CPPFUNC float4 normalize(const float4 x) { return ::simd_fast_normalize(x); } + static SIMD_CPPFUNC float8 normalize(const float8 x) { return ::simd_fast_normalize(x); } + static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_fast_normalize(x); } + static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_fast_normalize(x); } + static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_fast_normalize(x); } + static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_fast_normalize(x); } + static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_fast_normalize(x); } + } +} + +extern "C" { +#endif /* __cplusplus */ + +#pragma mark - Implementation + +static float SIMD_CFUNC simd_dot(simd_float2 __x, simd_float2 __y) { return simd_reduce_add(__x*__y); } +static float SIMD_CFUNC simd_dot(simd_float3 __x, simd_float3 __y) { return simd_reduce_add(__x*__y); } +static float SIMD_CFUNC simd_dot(simd_float4 __x, simd_float4 __y) { return simd_reduce_add(__x*__y); } +static float SIMD_CFUNC simd_dot(simd_float8 __x, simd_float8 __y) { return simd_reduce_add(__x*__y); } +static float SIMD_CFUNC simd_dot(simd_float16 __x, simd_float16 __y) { return simd_reduce_add(__x*__y); } +static double SIMD_CFUNC simd_dot(simd_double2 __x, simd_double2 __y) { return simd_reduce_add(__x*__y); } +static double SIMD_CFUNC simd_dot(simd_double3 __x, simd_double3 __y) { return simd_reduce_add(__x*__y); } +static double SIMD_CFUNC simd_dot(simd_double4 __x, simd_double4 __y) { return simd_reduce_add(__x*__y); } +static double SIMD_CFUNC simd_dot(simd_double8 __x, simd_double8 __y) { return simd_reduce_add(__x*__y); } + +static simd_float2 SIMD_CFUNC simd_precise_project(simd_float2 __x, simd_float2 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } +static simd_float3 SIMD_CFUNC simd_precise_project(simd_float3 __x, simd_float3 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } +static simd_float4 SIMD_CFUNC simd_precise_project(simd_float4 __x, simd_float4 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } +static simd_float8 SIMD_CFUNC simd_precise_project(simd_float8 __x, simd_float8 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } +static simd_float16 SIMD_CFUNC simd_precise_project(simd_float16 __x, simd_float16 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } +static simd_double2 SIMD_CFUNC simd_precise_project(simd_double2 __x, simd_double2 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } +static simd_double3 SIMD_CFUNC simd_precise_project(simd_double3 __x, simd_double3 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } +static simd_double4 SIMD_CFUNC simd_precise_project(simd_double4 __x, simd_double4 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } +static simd_double8 SIMD_CFUNC simd_precise_project(simd_double8 __x, simd_double8 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; } + +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } + +#if defined __FAST_MATH__ +static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y) { return simd_fast_project(__x,__y); } +static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y) { return simd_fast_project(__x,__y); } +static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y) { return simd_fast_project(__x,__y); } +static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y) { return simd_fast_project(__x,__y); } +static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y) { return simd_fast_project(__x,__y); } +static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y) { return simd_fast_project(__x,__y); } +static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y) { return simd_fast_project(__x,__y); } +static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y) { return simd_fast_project(__x,__y); } +static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y) { return simd_fast_project(__x,__y); } +#else +static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y) { return simd_precise_project(__x,__y); } +static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y) { return simd_precise_project(__x,__y); } +static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y) { return simd_precise_project(__x,__y); } +static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y) { return simd_precise_project(__x,__y); } +static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y) { return simd_precise_project(__x,__y); } +static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y) { return simd_precise_project(__x,__y); } +static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y) { return simd_precise_project(__x,__y); } +static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y) { return simd_precise_project(__x,__y); } +static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y) { return simd_precise_project(__x,__y); } +#endif + +static float SIMD_CFUNC simd_precise_length(simd_float2 __x) { return sqrtf(simd_length_squared(__x)); } +static float SIMD_CFUNC simd_precise_length(simd_float3 __x) { return sqrtf(simd_length_squared(__x)); } +static float SIMD_CFUNC simd_precise_length(simd_float4 __x) { return sqrtf(simd_length_squared(__x)); } +static float SIMD_CFUNC simd_precise_length(simd_float8 __x) { return sqrtf(simd_length_squared(__x)); } +static float SIMD_CFUNC simd_precise_length(simd_float16 __x) { return sqrtf(simd_length_squared(__x)); } +static double SIMD_CFUNC simd_precise_length(simd_double2 __x) { return sqrt(simd_length_squared(__x)); } +static double SIMD_CFUNC simd_precise_length(simd_double3 __x) { return sqrt(simd_length_squared(__x)); } +static double SIMD_CFUNC simd_precise_length(simd_double4 __x) { return sqrt(simd_length_squared(__x)); } +static double SIMD_CFUNC simd_precise_length(simd_double8 __x) { return sqrt(simd_length_squared(__x)); } + +static float SIMD_CFUNC simd_fast_length(simd_float2 __x) { return simd_precise_length(__x); } +static float SIMD_CFUNC simd_fast_length(simd_float3 __x) { return simd_precise_length(__x); } +static float SIMD_CFUNC simd_fast_length(simd_float4 __x) { return simd_precise_length(__x); } +static float SIMD_CFUNC simd_fast_length(simd_float8 __x) { return simd_precise_length(__x); } +static float SIMD_CFUNC simd_fast_length(simd_float16 __x) { return simd_precise_length(__x); } +static double SIMD_CFUNC simd_fast_length(simd_double2 __x) { return simd_precise_length(__x); } +static double SIMD_CFUNC simd_fast_length(simd_double3 __x) { return simd_precise_length(__x); } +static double SIMD_CFUNC simd_fast_length(simd_double4 __x) { return simd_precise_length(__x); } +static double SIMD_CFUNC simd_fast_length(simd_double8 __x) { return simd_precise_length(__x); } + +#if defined __FAST_MATH__ +static float SIMD_CFUNC simd_length(simd_float2 __x) { return simd_fast_length(__x); } +static float SIMD_CFUNC simd_length(simd_float3 __x) { return simd_fast_length(__x); } +static float SIMD_CFUNC simd_length(simd_float4 __x) { return simd_fast_length(__x); } +static float SIMD_CFUNC simd_length(simd_float8 __x) { return simd_fast_length(__x); } +static float SIMD_CFUNC simd_length(simd_float16 __x) { return simd_fast_length(__x); } +static double SIMD_CFUNC simd_length(simd_double2 __x) { return simd_fast_length(__x); } +static double SIMD_CFUNC simd_length(simd_double3 __x) { return simd_fast_length(__x); } +static double SIMD_CFUNC simd_length(simd_double4 __x) { return simd_fast_length(__x); } +static double SIMD_CFUNC simd_length(simd_double8 __x) { return simd_fast_length(__x); } +#else +static float SIMD_CFUNC simd_length(simd_float2 __x) { return simd_precise_length(__x); } +static float SIMD_CFUNC simd_length(simd_float3 __x) { return simd_precise_length(__x); } +static float SIMD_CFUNC simd_length(simd_float4 __x) { return simd_precise_length(__x); } +static float SIMD_CFUNC simd_length(simd_float8 __x) { return simd_precise_length(__x); } +static float SIMD_CFUNC simd_length(simd_float16 __x) { return simd_precise_length(__x); } +static double SIMD_CFUNC simd_length(simd_double2 __x) { return simd_precise_length(__x); } +static double SIMD_CFUNC simd_length(simd_double3 __x) { return simd_precise_length(__x); } +static double SIMD_CFUNC simd_length(simd_double4 __x) { return simd_precise_length(__x); } +static double SIMD_CFUNC simd_length(simd_double8 __x) { return simd_precise_length(__x); } +#endif + +static float SIMD_CFUNC simd_length_squared(simd_float2 __x) { return simd_dot(__x,__x); } +static float SIMD_CFUNC simd_length_squared(simd_float3 __x) { return simd_dot(__x,__x); } +static float SIMD_CFUNC simd_length_squared(simd_float4 __x) { return simd_dot(__x,__x); } +static float SIMD_CFUNC simd_length_squared(simd_float8 __x) { return simd_dot(__x,__x); } +static float SIMD_CFUNC simd_length_squared(simd_float16 __x) { return simd_dot(__x,__x); } +static double SIMD_CFUNC simd_length_squared(simd_double2 __x) { return simd_dot(__x,__x); } +static double SIMD_CFUNC simd_length_squared(simd_double3 __x) { return simd_dot(__x,__x); } +static double SIMD_CFUNC simd_length_squared(simd_double4 __x) { return simd_dot(__x,__x); } +static double SIMD_CFUNC simd_length_squared(simd_double8 __x) { return simd_dot(__x,__x); } + +static float SIMD_CFUNC simd_norm_one(simd_float2 __x) { return simd_reduce_add(__tg_fabs(__x)); } +static float SIMD_CFUNC simd_norm_one(simd_float3 __x) { return simd_reduce_add(__tg_fabs(__x)); } +static float SIMD_CFUNC simd_norm_one(simd_float4 __x) { return simd_reduce_add(__tg_fabs(__x)); } +static float SIMD_CFUNC simd_norm_one(simd_float8 __x) { return simd_reduce_add(__tg_fabs(__x)); } +static float SIMD_CFUNC simd_norm_one(simd_float16 __x) { return simd_reduce_add(__tg_fabs(__x)); } +static double SIMD_CFUNC simd_norm_one(simd_double2 __x) { return simd_reduce_add(__tg_fabs(__x)); } +static double SIMD_CFUNC simd_norm_one(simd_double3 __x) { return simd_reduce_add(__tg_fabs(__x)); } +static double SIMD_CFUNC simd_norm_one(simd_double4 __x) { return simd_reduce_add(__tg_fabs(__x)); } +static double SIMD_CFUNC simd_norm_one(simd_double8 __x) { return simd_reduce_add(__tg_fabs(__x)); } + +static float SIMD_CFUNC simd_norm_inf(simd_float2 __x) { return simd_reduce_max(__tg_fabs(__x)); } +static float SIMD_CFUNC simd_norm_inf(simd_float3 __x) { return simd_reduce_max(__tg_fabs(__x)); } +static float SIMD_CFUNC simd_norm_inf(simd_float4 __x) { return simd_reduce_max(__tg_fabs(__x)); } +static float SIMD_CFUNC simd_norm_inf(simd_float8 __x) { return simd_reduce_max(__tg_fabs(__x)); } +static float SIMD_CFUNC simd_norm_inf(simd_float16 __x) { return simd_reduce_max(__tg_fabs(__x)); } +static double SIMD_CFUNC simd_norm_inf(simd_double2 __x) { return simd_reduce_max(__tg_fabs(__x)); } +static double SIMD_CFUNC simd_norm_inf(simd_double3 __x) { return simd_reduce_max(__tg_fabs(__x)); } +static double SIMD_CFUNC simd_norm_inf(simd_double4 __x) { return simd_reduce_max(__tg_fabs(__x)); } +static double SIMD_CFUNC simd_norm_inf(simd_double8 __x) { return simd_reduce_max(__tg_fabs(__x)); } + +static float SIMD_CFUNC simd_precise_distance(simd_float2 __x, simd_float2 __y) { return simd_precise_length(__x - __y); } +static float SIMD_CFUNC simd_precise_distance(simd_float3 __x, simd_float3 __y) { return simd_precise_length(__x - __y); } +static float SIMD_CFUNC simd_precise_distance(simd_float4 __x, simd_float4 __y) { return simd_precise_length(__x - __y); } +static float SIMD_CFUNC simd_precise_distance(simd_float8 __x, simd_float8 __y) { return simd_precise_length(__x - __y); } +static float SIMD_CFUNC simd_precise_distance(simd_float16 __x, simd_float16 __y) { return simd_precise_length(__x - __y); } +static double SIMD_CFUNC simd_precise_distance(simd_double2 __x, simd_double2 __y) { return simd_precise_length(__x - __y); } +static double SIMD_CFUNC simd_precise_distance(simd_double3 __x, simd_double3 __y) { return simd_precise_length(__x - __y); } +static double SIMD_CFUNC simd_precise_distance(simd_double4 __x, simd_double4 __y) { return simd_precise_length(__x - __y); } +static double SIMD_CFUNC simd_precise_distance(simd_double8 __x, simd_double8 __y) { return simd_precise_length(__x - __y); } + +static float SIMD_CFUNC simd_fast_distance(simd_float2 __x, simd_float2 __y) { return simd_fast_length(__x - __y); } +static float SIMD_CFUNC simd_fast_distance(simd_float3 __x, simd_float3 __y) { return simd_fast_length(__x - __y); } +static float SIMD_CFUNC simd_fast_distance(simd_float4 __x, simd_float4 __y) { return simd_fast_length(__x - __y); } +static float SIMD_CFUNC simd_fast_distance(simd_float8 __x, simd_float8 __y) { return simd_fast_length(__x - __y); } +static float SIMD_CFUNC simd_fast_distance(simd_float16 __x, simd_float16 __y) { return simd_fast_length(__x - __y); } +static double SIMD_CFUNC simd_fast_distance(simd_double2 __x, simd_double2 __y) { return simd_fast_length(__x - __y); } +static double SIMD_CFUNC simd_fast_distance(simd_double3 __x, simd_double3 __y) { return simd_fast_length(__x - __y); } +static double SIMD_CFUNC simd_fast_distance(simd_double4 __x, simd_double4 __y) { return simd_fast_length(__x - __y); } +static double SIMD_CFUNC simd_fast_distance(simd_double8 __x, simd_double8 __y) { return simd_fast_length(__x - __y); } + +#if defined __FAST_MATH__ +static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y) { return simd_fast_distance(__x,__y); } +static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y) { return simd_fast_distance(__x,__y); } +static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y) { return simd_fast_distance(__x,__y); } +static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y) { return simd_fast_distance(__x,__y); } +static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y) { return simd_fast_distance(__x,__y); } +static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y) { return simd_fast_distance(__x,__y); } +static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y) { return simd_fast_distance(__x,__y); } +static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y) { return simd_fast_distance(__x,__y); } +static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y) { return simd_fast_distance(__x,__y); } +#else +static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y) { return simd_precise_distance(__x,__y); } +static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y) { return simd_precise_distance(__x,__y); } +static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y) { return simd_precise_distance(__x,__y); } +static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y) { return simd_precise_distance(__x,__y); } +static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y) { return simd_precise_distance(__x,__y); } +static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y) { return simd_precise_distance(__x,__y); } +static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y) { return simd_precise_distance(__x,__y); } +static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y) { return simd_precise_distance(__x,__y); } +static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y) { return simd_precise_distance(__x,__y); } +#endif + +static float SIMD_CFUNC simd_distance_squared(simd_float2 __x, simd_float2 __y) { return simd_length_squared(__x - __y); } +static float SIMD_CFUNC simd_distance_squared(simd_float3 __x, simd_float3 __y) { return simd_length_squared(__x - __y); } +static float SIMD_CFUNC simd_distance_squared(simd_float4 __x, simd_float4 __y) { return simd_length_squared(__x - __y); } +static float SIMD_CFUNC simd_distance_squared(simd_float8 __x, simd_float8 __y) { return simd_length_squared(__x - __y); } +static float SIMD_CFUNC simd_distance_squared(simd_float16 __x, simd_float16 __y) { return simd_length_squared(__x - __y); } +static double SIMD_CFUNC simd_distance_squared(simd_double2 __x, simd_double2 __y) { return simd_length_squared(__x - __y); } +static double SIMD_CFUNC simd_distance_squared(simd_double3 __x, simd_double3 __y) { return simd_length_squared(__x - __y); } +static double SIMD_CFUNC simd_distance_squared(simd_double4 __x, simd_double4 __y) { return simd_length_squared(__x - __y); } +static double SIMD_CFUNC simd_distance_squared(simd_double8 __x, simd_double8 __y) { return simd_length_squared(__x - __y); } + +static simd_float2 SIMD_CFUNC simd_precise_normalize(simd_float2 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } +static simd_float3 SIMD_CFUNC simd_precise_normalize(simd_float3 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } +static simd_float4 SIMD_CFUNC simd_precise_normalize(simd_float4 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } +static simd_float8 SIMD_CFUNC simd_precise_normalize(simd_float8 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } +static simd_float16 SIMD_CFUNC simd_precise_normalize(simd_float16 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } +static simd_double2 SIMD_CFUNC simd_precise_normalize(simd_double2 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } +static simd_double3 SIMD_CFUNC simd_precise_normalize(simd_double3 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } +static simd_double4 SIMD_CFUNC simd_precise_normalize(simd_double4 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } +static simd_double8 SIMD_CFUNC simd_precise_normalize(simd_double8 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); } + +static simd_float2 SIMD_CFUNC simd_fast_normalize(simd_float2 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } +static simd_float3 SIMD_CFUNC simd_fast_normalize(simd_float3 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } +static simd_float4 SIMD_CFUNC simd_fast_normalize(simd_float4 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } +static simd_float8 SIMD_CFUNC simd_fast_normalize(simd_float8 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } +static simd_float16 SIMD_CFUNC simd_fast_normalize(simd_float16 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } +static simd_double2 SIMD_CFUNC simd_fast_normalize(simd_double2 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } +static simd_double3 SIMD_CFUNC simd_fast_normalize(simd_double3 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } +static simd_double4 SIMD_CFUNC simd_fast_normalize(simd_double4 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } +static simd_double8 SIMD_CFUNC simd_fast_normalize(simd_double8 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); } + +#if defined __FAST_MATH__ +static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x) { return simd_fast_normalize(__x); } +static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x) { return simd_fast_normalize(__x); } +static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x) { return simd_fast_normalize(__x); } +static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x) { return simd_fast_normalize(__x); } +static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x) { return simd_fast_normalize(__x); } +static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x) { return simd_fast_normalize(__x); } +static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x) { return simd_fast_normalize(__x); } +static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x) { return simd_fast_normalize(__x); } +static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x) { return simd_fast_normalize(__x); } +#else +static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x) { return simd_precise_normalize(__x); } +static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x) { return simd_precise_normalize(__x); } +static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x) { return simd_precise_normalize(__x); } +static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x) { return simd_precise_normalize(__x); } +static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x) { return simd_precise_normalize(__x); } +static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x) { return simd_precise_normalize(__x); } +static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x) { return simd_precise_normalize(__x); } +static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x) { return simd_precise_normalize(__x); } +static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x) { return simd_precise_normalize(__x); } +#endif + +static 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 }; } +static simd_float3 SIMD_CFUNC simd_cross(simd_float3 __x, simd_float3 __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; } +static 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 }; } +static simd_double3 SIMD_CFUNC simd_cross(simd_double3 __x, simd_double3 __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; } + +static simd_float2 SIMD_CFUNC simd_reflect(simd_float2 __x, simd_float2 __n) { return __x - 2*simd_dot(__x,__n)*__n; } +static simd_float3 SIMD_CFUNC simd_reflect(simd_float3 __x, simd_float3 __n) { return __x - 2*simd_dot(__x,__n)*__n; } +static simd_float4 SIMD_CFUNC simd_reflect(simd_float4 __x, simd_float4 __n) { return __x - 2*simd_dot(__x,__n)*__n; } +static simd_double2 SIMD_CFUNC simd_reflect(simd_double2 __x, simd_double2 __n) { return __x - 2*simd_dot(__x,__n)*__n; } +static simd_double3 SIMD_CFUNC simd_reflect(simd_double3 __x, simd_double3 __n) { return __x - 2*simd_dot(__x,__n)*__n; } +static simd_double4 SIMD_CFUNC simd_reflect(simd_double4 __x, simd_double4 __n) { return __x - 2*simd_dot(__x,__n)*__n; } + +static simd_float2 SIMD_CFUNC simd_refract(simd_float2 __x, simd_float2 __n, float __eta) { + const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n)); + return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float2)0.0f; +} +static simd_float3 SIMD_CFUNC simd_refract(simd_float3 __x, simd_float3 __n, float __eta) { + const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n)); + return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float3)0.0f; +} +static simd_float4 SIMD_CFUNC simd_refract(simd_float4 __x, simd_float4 __n, float __eta) { + const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n)); + return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float4)0.0f; +} +static simd_double2 SIMD_CFUNC simd_refract(simd_double2 __x, simd_double2 __n, double __eta) { + const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n)); + return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double2)0.0; +} +static simd_double3 SIMD_CFUNC simd_refract(simd_double3 __x, simd_double3 __n, double __eta) { + const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n)); + return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double3)0.0; +} +static simd_double4 SIMD_CFUNC simd_refract(simd_double4 __x, simd_double4 __n, double __eta) { + const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n)); + return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double4)0.0; +} + +#if SIMD_LIBRARY_VERSION >= 2 +static float SIMD_CFUNC simd_orient(simd_float2 __x, simd_float2 __y) { + return _simd_orient_vf2(__x, __y); +} +static double SIMD_CFUNC simd_orient(simd_double2 __x, simd_double2 __y) { + return _simd_orient_vd2(__x, __y); +} +static float SIMD_CFUNC simd_orient(simd_float3 __x, simd_float3 __y, simd_float3 __z) { + return _simd_orient_vf3(__x, __y, __z); +} +static double SIMD_CFUNC simd_orient(simd_double3 __x, simd_double3 __y, simd_double3 __z) { + simd_double3 __args[3] = { __x, __y, __z }; + return _simd_orient_vd3((const double *)__args); +} + +static float SIMD_CFUNC simd_orient(simd_float2 __a, simd_float2 __b, simd_float2 __c) { + return _simd_orient_pf2(__a, __b, __c); +} +static double SIMD_CFUNC simd_orient(simd_double2 __a, simd_double2 __b, simd_double2 __c) { + return _simd_orient_pd2(__a, __b, __c); +} +static float SIMD_CFUNC simd_orient(simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d) { + return _simd_orient_pf3(__a, __b, __c, __d); +} +static double SIMD_CFUNC simd_orient(simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d) { + simd_double3 __args[4] = { __a, __b, __c, __d }; + return _simd_orient_vd3((const double *)__args); +} + +static float SIMD_CFUNC simd_incircle(simd_float2 __x, simd_float2 __a, simd_float2 __b, simd_float2 __c) { + return _simd_incircle_pf2(__x, __a, __b, __c); +} +static double SIMD_CFUNC simd_incircle(simd_double2 __x, simd_double2 __a, simd_double2 __b, simd_double2 __c) { + return _simd_incircle_pd2(__x, __a, __b, __c); +} +static float SIMD_CFUNC simd_insphere(simd_float3 __x, simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d) { + return _simd_insphere_pf3(__x, __a, __b, __c, __d); +} +static double SIMD_CFUNC simd_insphere(simd_double3 __x, simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d) { + simd_double3 __args[5] = { __x, __a, __b, __c, __d }; + return _simd_insphere_pd3((const double *)__args); +} +#endif /* SIMD_LIBRARY_VERSION */ + +#ifdef __cplusplus +} +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* __SIMD_COMMON_HEADER__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/logic.h b/lib/libc/include/x86_64-macos-gnu/simd/logic.h new file mode 100644 index 0000000000..0d447a910c --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/logic.h @@ -0,0 +1,1315 @@ +/*! @header + * The interfaces declared in this header provide logical and bitwise + * operations on vectors. Some of these function operate elementwise, + * and some produce a scalar result that depends on all lanes of the input. + * + * For functions returning a boolean value, the return type in C and + * Objective-C is _Bool; for C++ it is bool. + * + * Function Result + * ------------------------------------------------------------------ + * simd_all(comparison) True if and only if the comparison is true + * in every vector lane. e.g.: + * + * if (simd_all(x == 0.0f)) { + * // executed if every lane of x + * // contains zero. + * } + * + * The precise function of simd_all is to + * return the high-order bit of the result + * of a horizontal bitwise AND of all vector + * lanes. + * + * simd_any(comparison) True if and only if the comparison is true + * in at least one vector lane. e.g.: + * + * if (simd_any(x < 0.0f)) { + * // executed if any lane of x + * // contains a negative value. + * } + * + * The precise function of simd_all is to + * return the high-order bit of the result + * of a horizontal bitwise OR of all vector + * lanes. + * + * simd_select(x,y,mask) For each lane in the result, selects the + * corresponding element of x if the high- + * order bit of the corresponding element of + * mask is 0, and the corresponding element + * of y otherwise. + * + * simd_bitselect(x,y,mask) For each bit in the result, selects the + * corresponding bit of x if the corresponding + * bit of mask is clear, and the corresponding + * of y otherwise. + * + * In C++, these functions are available under the simd:: namespace: + * + * C++ Function Equivalent C Function + * -------------------------------------------------------------------- + * simd::all(comparison) simd_all(comparison) + * simd::any(comparison) simd_any(comparison) + * simd::select(x,y,mask) simd_select(x,y,mask) + * simd::bitselect(x,y,mask) simd_bitselect(x,y,mask) + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_LOGIC_HEADER +#define SIMD_LOGIC_HEADER + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char32 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char64 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar32 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar64 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short32 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort32 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_long2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_long3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_long4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_long8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. + * @discussion Deprecated. Use simd_any instead. */ +#define vector_any simd_any + +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char32 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char64 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar32 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar64 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short32 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort32 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_long2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_long3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_long4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_long8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. + * @discussion Deprecated. Use simd_all instead. */ +#define vector_all simd_all + +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float2 simd_select(simd_float2 x, simd_float2 y, simd_int2 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float3 simd_select(simd_float3 x, simd_float3 y, simd_int3 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float4 simd_select(simd_float4 x, simd_float4 y, simd_int4 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float8 simd_select(simd_float8 x, simd_float8 y, simd_int8 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float16 simd_select(simd_float16 x, simd_float16 y, simd_int16 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_double2 simd_select(simd_double2 x, simd_double2 y, simd_long2 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_double3 simd_select(simd_double3 x, simd_double3 y, simd_long3 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_double4 simd_select(simd_double4 x, simd_double4 y, simd_long4 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_double8 simd_select(simd_double8 x, simd_double8 y, simd_long8 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. + * @discussion Deprecated. Use simd_select instead. */ +#define vector_select simd_select + +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char2 simd_bitselect(simd_char2 x, simd_char2 y, simd_char2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char3 simd_bitselect(simd_char3 x, simd_char3 y, simd_char3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char4 simd_bitselect(simd_char4 x, simd_char4 y, simd_char4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char8 simd_bitselect(simd_char8 x, simd_char8 y, simd_char8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char16 simd_bitselect(simd_char16 x, simd_char16 y, simd_char16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char32 simd_bitselect(simd_char32 x, simd_char32 y, simd_char32 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char64 simd_bitselect(simd_char64 x, simd_char64 y, simd_char64 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar2 simd_bitselect(simd_uchar2 x, simd_uchar2 y, simd_char2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar3 simd_bitselect(simd_uchar3 x, simd_uchar3 y, simd_char3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar4 simd_bitselect(simd_uchar4 x, simd_uchar4 y, simd_char4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar8 simd_bitselect(simd_uchar8 x, simd_uchar8 y, simd_char8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar16 simd_bitselect(simd_uchar16 x, simd_uchar16 y, simd_char16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar32 simd_bitselect(simd_uchar32 x, simd_uchar32 y, simd_char32 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar64 simd_bitselect(simd_uchar64 x, simd_uchar64 y, simd_char64 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short2 simd_bitselect(simd_short2 x, simd_short2 y, simd_short2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short3 simd_bitselect(simd_short3 x, simd_short3 y, simd_short3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short4 simd_bitselect(simd_short4 x, simd_short4 y, simd_short4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short8 simd_bitselect(simd_short8 x, simd_short8 y, simd_short8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short16 simd_bitselect(simd_short16 x, simd_short16 y, simd_short16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short32 simd_bitselect(simd_short32 x, simd_short32 y, simd_short32 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort2 simd_bitselect(simd_ushort2 x, simd_ushort2 y, simd_short2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort3 simd_bitselect(simd_ushort3 x, simd_ushort3 y, simd_short3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort4 simd_bitselect(simd_ushort4 x, simd_ushort4 y, simd_short4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort8 simd_bitselect(simd_ushort8 x, simd_ushort8 y, simd_short8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort16 simd_bitselect(simd_ushort16 x, simd_ushort16 y, simd_short16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort32 simd_bitselect(simd_ushort32 x, simd_ushort32 y, simd_short32 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int2 simd_bitselect(simd_int2 x, simd_int2 y, simd_int2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int3 simd_bitselect(simd_int3 x, simd_int3 y, simd_int3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int4 simd_bitselect(simd_int4 x, simd_int4 y, simd_int4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int8 simd_bitselect(simd_int8 x, simd_int8 y, simd_int8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int16 simd_bitselect(simd_int16 x, simd_int16 y, simd_int16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint2 simd_bitselect(simd_uint2 x, simd_uint2 y, simd_int2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint3 simd_bitselect(simd_uint3 x, simd_uint3 y, simd_int3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint4 simd_bitselect(simd_uint4 x, simd_uint4 y, simd_int4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint8 simd_bitselect(simd_uint8 x, simd_uint8 y, simd_int8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint16 simd_bitselect(simd_uint16 x, simd_uint16 y, simd_int16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float2 simd_bitselect(simd_float2 x, simd_float2 y, simd_int2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float3 simd_bitselect(simd_float3 x, simd_float3 y, simd_int3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float4 simd_bitselect(simd_float4 x, simd_float4 y, simd_int4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float8 simd_bitselect(simd_float8 x, simd_float8 y, simd_int8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float16 simd_bitselect(simd_float16 x, simd_float16 y, simd_int16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_long2 simd_bitselect(simd_long2 x, simd_long2 y, simd_long2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_long3 simd_bitselect(simd_long3 x, simd_long3 y, simd_long3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_long4 simd_bitselect(simd_long4 x, simd_long4 y, simd_long4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_long8 simd_bitselect(simd_long8 x, simd_long8 y, simd_long8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ulong2 simd_bitselect(simd_ulong2 x, simd_ulong2 y, simd_long2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ulong3 simd_bitselect(simd_ulong3 x, simd_ulong3 y, simd_long3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ulong4 simd_bitselect(simd_ulong4 x, simd_ulong4 y, simd_long4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ulong8 simd_bitselect(simd_ulong8 x, simd_ulong8 y, simd_long8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_double2 simd_bitselect(simd_double2 x, simd_double2 y, simd_long2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_double3 simd_bitselect(simd_double3 x, simd_double3 y, simd_long3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_double4 simd_bitselect(simd_double4 x, simd_double4 y, simd_long4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_double8 simd_bitselect(simd_double8 x, simd_double8 y, simd_long8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. + * @discussion Deprecated. Use simd_bitselect instead. */ +#define vector_bitselect simd_bitselect + +#ifdef __cplusplus +} /* extern "C" */ + +namespace simd { + /*! @abstract True if and only if the high-order bit of every lane is set. */ + template static SIMD_CPPFUNC simd_bool all(const inttypeN predicate) { return ::simd_all(predicate); } + /*! @abstract True if and only if the high-order bit of any lane is set. */ + template static SIMD_CPPFUNC simd_bool any(const inttypeN predicate) { return ::simd_any(predicate); } + /*! @abstract Each lane of the result is selected from the corresponding lane + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ + template static SIMD_CPPFUNC fptypeN select(const fptypeN x, const fptypeN y, const inttypeN predicate) { return ::simd_select(x,y,predicate); } + /*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ + template static SIMD_CPPFUNC typeN bitselect(const typeN x, const typeN y, const inttypeN mask) { return ::simd_bitselect(x,y,mask); } +} + +extern "C" { +#endif /* __cplusplus */ + +#pragma mark - Implementations + +static inline SIMD_CFUNC simd_bool simd_any(simd_char2 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x3); +#elif defined __arm64__ + return simd_any(x.xyxy); +#else + union { uint16_t i; simd_char2 v; } u = { .v = x }; + return (u.i & 0x8080); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char3 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x7); +#elif defined __arm64__ + return simd_any(x.xyzz); +#else + union { uint32_t i; simd_char3 v; } u = { .v = x }; + return (u.i & 0x808080); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char4 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xf); +#elif defined __arm64__ + return simd_any(x.xyzwxyzw); +#else + union { uint32_t i; simd_char4 v; } u = { .v = x }; + return (u.i & 0x80808080); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char8 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xff); +#elif defined __arm64__ + return vmaxv_u8(x) & 0x80; +#else + union { uint64_t i; simd_char8 v; } u = { .v = x }; + return (u.i & 0x8080808080808080); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char16 x) { +#if defined __SSE2__ + return _mm_movemask_epi8((__m128i)x); +#elif defined __arm64__ + return vmaxvq_u8(x) & 0x80; +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char32 x) { +#if defined __AVX2__ + return _mm256_movemask_epi8(x); +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char64 x) { + return simd_any(x.lo | x.hi); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar2 x) { + return simd_any((simd_char2)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar3 x) { + return simd_any((simd_char3)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar4 x) { + return simd_any((simd_char4)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar8 x) { + return simd_any((simd_char8)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar16 x) { + return simd_any((simd_char16)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar32 x) { + return simd_any((simd_char32)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar64 x) { + return simd_any((simd_char64)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short2 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xa); +#elif defined __arm64__ + return simd_any(x.xyxy); +#else + union { uint32_t i; simd_short2 v; } u = { .v = x }; + return (u.i & 0x80008000); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short3 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0x2a); +#elif defined __arm64__ + return simd_any(x.xyzz); +#else + union { uint64_t i; simd_short3 v; } u = { .v = x }; + return (u.i & 0x800080008000); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short4 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xaa); +#elif defined __arm64__ + return vmaxv_u16(x) & 0x8000; +#else + union { uint64_t i; simd_short4 v; } u = { .v = x }; + return (u.i & 0x8000800080008000); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short8 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)x) & 0xaaaa); +#elif defined __arm64__ + return vmaxvq_u16(x) & 0x8000; +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short16 x) { +#if defined __AVX2__ + return (_mm256_movemask_epi8(x) & 0xaaaaaaaa); +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short32 x) { + return simd_any(x.lo | x.hi); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort2 x) { + return simd_any((simd_short2)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort3 x) { + return simd_any((simd_short3)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort4 x) { + return simd_any((simd_short4)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort8 x) { + return simd_any((simd_short8)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort16 x) { + return simd_any((simd_short16)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort32 x) { + return simd_any((simd_short32)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int2 x) { +#if defined __SSE2__ + return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x3); +#elif defined __arm64__ + return vmaxv_u32(x) & 0x80000000; +#else + union { uint64_t i; simd_int2 v; } u = { .v = x }; + return (u.i & 0x8000000080000000); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int3 x) { +#if defined __SSE2__ + return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x7); +#elif defined __arm64__ + return simd_any(x.xyzz); +#else + return (x.x | x.y | x.z) & 0x80000000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int4 x) { +#if defined __SSE2__ + return _mm_movemask_ps((__m128)x); +#elif defined __arm64__ + return vmaxvq_u32(x) & 0x80000000; +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int8 x) { +#if defined __AVX__ + return _mm256_movemask_ps(x); +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int16 x) { + return simd_any(x.lo | x.hi); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint2 x) { + return simd_any((simd_int2)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint3 x) { + return simd_any((simd_int3)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint4 x) { + return simd_any((simd_int4)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint8 x) { + return simd_any((simd_int8)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint16 x) { + return simd_any((simd_int16)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_long2 x) { +#if defined __SSE2__ + return _mm_movemask_pd((__m128d)x); +#elif defined __arm64__ + return (x.x | x.y) & 0x8000000000000000U; +#else + return (x.x | x.y) & 0x8000000000000000U; +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_long3 x) { +#if defined __AVX__ + return (_mm256_movemask_pd(simd_make_long4_undef(x)) & 0x7); +#else + return (x.x | x.y | x.z) & 0x8000000000000000U; +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_long4 x) { +#if defined __AVX__ + return _mm256_movemask_pd(x); +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_long8 x) { + return simd_any(x.lo | x.hi); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong2 x) { + return simd_any((simd_long2)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong3 x) { + return simd_any((simd_long3)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong4 x) { + return simd_any((simd_long4)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong8 x) { + return simd_any((simd_long8)x); +} + +static inline SIMD_CFUNC simd_bool simd_all(simd_char2 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x3) == 0x3; +#elif defined __arm64__ + return simd_all(x.xyxy); +#else + union { uint16_t i; simd_char2 v; } u = { .v = x }; + return (u.i & 0x8080) == 0x8080; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char3 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x7) == 0x7; +#elif defined __arm64__ + return simd_all(x.xyzz); +#else + union { uint32_t i; simd_char3 v; } u = { .v = x }; + return (u.i & 0x808080) == 0x808080; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char4 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xf) == 0xf; +#elif defined __arm64__ + return simd_all(x.xyzwxyzw); +#else + union { uint32_t i; simd_char4 v; } u = { .v = x }; + return (u.i & 0x80808080) == 0x80808080; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char8 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xff) == 0xff; +#elif defined __arm64__ + return vminv_u8(x) & 0x80; +#else + union { uint64_t i; simd_char8 v; } u = { .v = x }; + return (u.i & 0x8080808080808080) == 0x8080808080808080; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char16 x) { +#if defined __SSE2__ + return _mm_movemask_epi8((__m128i)x) == 0xffff; +#elif defined __arm64__ + return vminvq_u8(x) & 0x80; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char32 x) { +#if defined __AVX2__ + return _mm256_movemask_epi8(x) == 0xffffffff; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char64 x) { + return simd_all(x.lo & x.hi); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar2 x) { + return simd_all((simd_char2)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar3 x) { + return simd_all((simd_char3)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar4 x) { + return simd_all((simd_char4)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar8 x) { + return simd_all((simd_char8)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar16 x) { + return simd_all((simd_char16)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar32 x) { + return simd_all((simd_char32)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar64 x) { + return simd_all((simd_char64)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short2 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xa) == 0xa; +#elif defined __arm64__ + return simd_all(x.xyxy); +#else + union { uint32_t i; simd_short2 v; } u = { .v = x }; + return (u.i & 0x80008000) == 0x80008000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short3 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0x2a) == 0x2a; +#elif defined __arm64__ + return simd_all(x.xyzz); +#else + union { uint64_t i; simd_short3 v; } u = { .v = x }; + return (u.i & 0x800080008000) == 0x800080008000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short4 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xaa) == 0xaa; +#elif defined __arm64__ + return vminv_u16(x) & 0x8000; +#else + union { uint64_t i; simd_short4 v; } u = { .v = x }; + return (u.i & 0x8000800080008000) == 0x8000800080008000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short8 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)x) & 0xaaaa) == 0xaaaa; +#elif defined __arm64__ + return vminvq_u16(x) & 0x8000; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short16 x) { +#if defined __AVX2__ + return (_mm256_movemask_epi8(x) & 0xaaaaaaaa) == 0xaaaaaaaa; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short32 x) { + return simd_all(x.lo & x.hi); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort2 x) { + return simd_all((simd_short2)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort3 x) { + return simd_all((simd_short3)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort4 x) { + return simd_all((simd_short4)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort8 x) { + return simd_all((simd_short8)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort16 x) { + return simd_all((simd_short16)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort32 x) { + return simd_all((simd_short32)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int2 x) { +#if defined __SSE2__ + return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x3) == 0x3; +#elif defined __arm64__ + return vminv_u32(x) & 0x80000000; +#else + union { uint64_t i; simd_int2 v; } u = { .v = x }; + return (u.i & 0x8000000080000000) == 0x8000000080000000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int3 x) { +#if defined __SSE2__ + return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x7) == 0x7; +#elif defined __arm64__ + return simd_all(x.xyzz); +#else + return (x.x & x.y & x.z) & 0x80000000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int4 x) { +#if defined __SSE2__ + return _mm_movemask_ps((__m128)x) == 0xf; +#elif defined __arm64__ + return vminvq_u32(x) & 0x80000000; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int8 x) { +#if defined __AVX__ + return _mm256_movemask_ps(x) == 0xff; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int16 x) { + return simd_all(x.lo & x.hi); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint2 x) { + return simd_all((simd_int2)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint3 x) { + return simd_all((simd_int3)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint4 x) { + return simd_all((simd_int4)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint8 x) { + return simd_all((simd_int8)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint16 x) { + return simd_all((simd_int16)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_long2 x) { +#if defined __SSE2__ + return _mm_movemask_pd((__m128d)x) == 0x3; +#elif defined __arm64__ + return (x.x & x.y) & 0x8000000000000000U; +#else + return (x.x & x.y) & 0x8000000000000000U; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_long3 x) { +#if defined __AVX__ + return (_mm256_movemask_pd(simd_make_long4_undef(x)) & 0x7) == 0x7; +#else + return (x.x & x.y & x.z) & 0x8000000000000000U; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_long4 x) { +#if defined __AVX__ + return _mm256_movemask_pd(x) == 0xf; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_long8 x) { + return simd_all(x.lo & x.hi); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong2 x) { + return simd_all((simd_long2)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong3 x) { + return simd_all((simd_long3)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong4 x) { + return simd_all((simd_long4)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong8 x) { + return simd_all((simd_long8)x); +} + +static inline SIMD_CFUNC simd_float2 simd_select(simd_float2 x, simd_float2 y, simd_int2 mask) { + return simd_make_float2(simd_select(simd_make_float4_undef(x), simd_make_float4_undef(y), simd_make_int4_undef(mask))); +} +static inline SIMD_CFUNC simd_float3 simd_select(simd_float3 x, simd_float3 y, simd_int3 mask) { + return simd_make_float3(simd_select(simd_make_float4_undef(x), simd_make_float4_undef(y), simd_make_int4_undef(mask))); +} +static inline SIMD_CFUNC simd_float4 simd_select(simd_float4 x, simd_float4 y, simd_int4 mask) { +#if defined __SSE4_1__ + return _mm_blendv_ps(x, y, (__m128)mask); +#else + return simd_bitselect(x, y, mask >> 31); +#endif +} +static inline SIMD_CFUNC simd_float8 simd_select(simd_float8 x, simd_float8 y, simd_int8 mask) { +#if defined __AVX__ + return _mm256_blendv_ps(x, y, mask); +#else + return simd_bitselect(x, y, mask >> 31); +#endif +} +static inline SIMD_CFUNC simd_float16 simd_select(simd_float16 x, simd_float16 y, simd_int16 mask) { + return simd_bitselect(x, y, mask >> 31); +} +static inline SIMD_CFUNC simd_double2 simd_select(simd_double2 x, simd_double2 y, simd_long2 mask) { +#if defined __SSE4_1__ + return _mm_blendv_pd(x, y, (__m128d)mask); +#else + return simd_bitselect(x, y, mask >> 63); +#endif +} +static inline SIMD_CFUNC simd_double3 simd_select(simd_double3 x, simd_double3 y, simd_long3 mask) { + return simd_make_double3(simd_select(simd_make_double4_undef(x), simd_make_double4_undef(y), simd_make_long4_undef(mask))); +} +static inline SIMD_CFUNC simd_double4 simd_select(simd_double4 x, simd_double4 y, simd_long4 mask) { +#if defined __AVX__ + return _mm256_blendv_pd(x, y, mask); +#else + return simd_bitselect(x, y, mask >> 63); +#endif +} +static inline SIMD_CFUNC simd_double8 simd_select(simd_double8 x, simd_double8 y, simd_long8 mask) { + return simd_bitselect(x, y, mask >> 63); +} + +static inline SIMD_CFUNC simd_char2 simd_bitselect(simd_char2 x, simd_char2 y, simd_char2 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char3 simd_bitselect(simd_char3 x, simd_char3 y, simd_char3 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char4 simd_bitselect(simd_char4 x, simd_char4 y, simd_char4 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char8 simd_bitselect(simd_char8 x, simd_char8 y, simd_char8 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char16 simd_bitselect(simd_char16 x, simd_char16 y, simd_char16 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char32 simd_bitselect(simd_char32 x, simd_char32 y, simd_char32 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char64 simd_bitselect(simd_char64 x, simd_char64 y, simd_char64 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_uchar2 simd_bitselect(simd_uchar2 x, simd_uchar2 y, simd_char2 mask) { + return (simd_uchar2)simd_bitselect((simd_char2)x, (simd_char2)y, mask); +} +static inline SIMD_CFUNC simd_uchar3 simd_bitselect(simd_uchar3 x, simd_uchar3 y, simd_char3 mask) { + return (simd_uchar3)simd_bitselect((simd_char3)x, (simd_char3)y, mask); +} +static inline SIMD_CFUNC simd_uchar4 simd_bitselect(simd_uchar4 x, simd_uchar4 y, simd_char4 mask) { + return (simd_uchar4)simd_bitselect((simd_char4)x, (simd_char4)y, mask); +} +static inline SIMD_CFUNC simd_uchar8 simd_bitselect(simd_uchar8 x, simd_uchar8 y, simd_char8 mask) { + return (simd_uchar8)simd_bitselect((simd_char8)x, (simd_char8)y, mask); +} +static inline SIMD_CFUNC simd_uchar16 simd_bitselect(simd_uchar16 x, simd_uchar16 y, simd_char16 mask) { + return (simd_uchar16)simd_bitselect((simd_char16)x, (simd_char16)y, mask); +} +static inline SIMD_CFUNC simd_uchar32 simd_bitselect(simd_uchar32 x, simd_uchar32 y, simd_char32 mask) { + return (simd_uchar32)simd_bitselect((simd_char32)x, (simd_char32)y, mask); +} +static inline SIMD_CFUNC simd_uchar64 simd_bitselect(simd_uchar64 x, simd_uchar64 y, simd_char64 mask) { + return (simd_uchar64)simd_bitselect((simd_char64)x, (simd_char64)y, mask); +} +static inline SIMD_CFUNC simd_short2 simd_bitselect(simd_short2 x, simd_short2 y, simd_short2 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short3 simd_bitselect(simd_short3 x, simd_short3 y, simd_short3 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short4 simd_bitselect(simd_short4 x, simd_short4 y, simd_short4 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short8 simd_bitselect(simd_short8 x, simd_short8 y, simd_short8 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short16 simd_bitselect(simd_short16 x, simd_short16 y, simd_short16 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short32 simd_bitselect(simd_short32 x, simd_short32 y, simd_short32 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_ushort2 simd_bitselect(simd_ushort2 x, simd_ushort2 y, simd_short2 mask) { + return (simd_ushort2)simd_bitselect((simd_short2)x, (simd_short2)y, mask); +} +static inline SIMD_CFUNC simd_ushort3 simd_bitselect(simd_ushort3 x, simd_ushort3 y, simd_short3 mask) { + return (simd_ushort3)simd_bitselect((simd_short3)x, (simd_short3)y, mask); +} +static inline SIMD_CFUNC simd_ushort4 simd_bitselect(simd_ushort4 x, simd_ushort4 y, simd_short4 mask) { + return (simd_ushort4)simd_bitselect((simd_short4)x, (simd_short4)y, mask); +} +static inline SIMD_CFUNC simd_ushort8 simd_bitselect(simd_ushort8 x, simd_ushort8 y, simd_short8 mask) { + return (simd_ushort8)simd_bitselect((simd_short8)x, (simd_short8)y, mask); +} +static inline SIMD_CFUNC simd_ushort16 simd_bitselect(simd_ushort16 x, simd_ushort16 y, simd_short16 mask) { + return (simd_ushort16)simd_bitselect((simd_short16)x, (simd_short16)y, mask); +} +static inline SIMD_CFUNC simd_ushort32 simd_bitselect(simd_ushort32 x, simd_ushort32 y, simd_short32 mask) { + return (simd_ushort32)simd_bitselect((simd_short32)x, (simd_short32)y, mask); +} +static inline SIMD_CFUNC simd_int2 simd_bitselect(simd_int2 x, simd_int2 y, simd_int2 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_int3 simd_bitselect(simd_int3 x, simd_int3 y, simd_int3 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_int4 simd_bitselect(simd_int4 x, simd_int4 y, simd_int4 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_int8 simd_bitselect(simd_int8 x, simd_int8 y, simd_int8 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_int16 simd_bitselect(simd_int16 x, simd_int16 y, simd_int16 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_uint2 simd_bitselect(simd_uint2 x, simd_uint2 y, simd_int2 mask) { + return (simd_uint2)simd_bitselect((simd_int2)x, (simd_int2)y, mask); +} +static inline SIMD_CFUNC simd_uint3 simd_bitselect(simd_uint3 x, simd_uint3 y, simd_int3 mask) { + return (simd_uint3)simd_bitselect((simd_int3)x, (simd_int3)y, mask); +} +static inline SIMD_CFUNC simd_uint4 simd_bitselect(simd_uint4 x, simd_uint4 y, simd_int4 mask) { + return (simd_uint4)simd_bitselect((simd_int4)x, (simd_int4)y, mask); +} +static inline SIMD_CFUNC simd_uint8 simd_bitselect(simd_uint8 x, simd_uint8 y, simd_int8 mask) { + return (simd_uint8)simd_bitselect((simd_int8)x, (simd_int8)y, mask); +} +static inline SIMD_CFUNC simd_uint16 simd_bitselect(simd_uint16 x, simd_uint16 y, simd_int16 mask) { + return (simd_uint16)simd_bitselect((simd_int16)x, (simd_int16)y, mask); +} +static inline SIMD_CFUNC simd_float2 simd_bitselect(simd_float2 x, simd_float2 y, simd_int2 mask) { + return (simd_float2)simd_bitselect((simd_int2)x, (simd_int2)y, mask); +} +static inline SIMD_CFUNC simd_float3 simd_bitselect(simd_float3 x, simd_float3 y, simd_int3 mask) { + return (simd_float3)simd_bitselect((simd_int3)x, (simd_int3)y, mask); +} +static inline SIMD_CFUNC simd_float4 simd_bitselect(simd_float4 x, simd_float4 y, simd_int4 mask) { + return (simd_float4)simd_bitselect((simd_int4)x, (simd_int4)y, mask); +} +static inline SIMD_CFUNC simd_float8 simd_bitselect(simd_float8 x, simd_float8 y, simd_int8 mask) { + return (simd_float8)simd_bitselect((simd_int8)x, (simd_int8)y, mask); +} +static inline SIMD_CFUNC simd_float16 simd_bitselect(simd_float16 x, simd_float16 y, simd_int16 mask) { + return (simd_float16)simd_bitselect((simd_int16)x, (simd_int16)y, mask); +} +static inline SIMD_CFUNC simd_long2 simd_bitselect(simd_long2 x, simd_long2 y, simd_long2 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_long3 simd_bitselect(simd_long3 x, simd_long3 y, simd_long3 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_long4 simd_bitselect(simd_long4 x, simd_long4 y, simd_long4 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_long8 simd_bitselect(simd_long8 x, simd_long8 y, simd_long8 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_ulong2 simd_bitselect(simd_ulong2 x, simd_ulong2 y, simd_long2 mask) { + return (simd_ulong2)simd_bitselect((simd_long2)x, (simd_long2)y, mask); +} +static inline SIMD_CFUNC simd_ulong3 simd_bitselect(simd_ulong3 x, simd_ulong3 y, simd_long3 mask) { + return (simd_ulong3)simd_bitselect((simd_long3)x, (simd_long3)y, mask); +} +static inline SIMD_CFUNC simd_ulong4 simd_bitselect(simd_ulong4 x, simd_ulong4 y, simd_long4 mask) { + return (simd_ulong4)simd_bitselect((simd_long4)x, (simd_long4)y, mask); +} +static inline SIMD_CFUNC simd_ulong8 simd_bitselect(simd_ulong8 x, simd_ulong8 y, simd_long8 mask) { + return (simd_ulong8)simd_bitselect((simd_long8)x, (simd_long8)y, mask); +} +static inline SIMD_CFUNC simd_double2 simd_bitselect(simd_double2 x, simd_double2 y, simd_long2 mask) { + return (simd_double2)simd_bitselect((simd_long2)x, (simd_long2)y, mask); +} +static inline SIMD_CFUNC simd_double3 simd_bitselect(simd_double3 x, simd_double3 y, simd_long3 mask) { + return (simd_double3)simd_bitselect((simd_long3)x, (simd_long3)y, mask); +} +static inline SIMD_CFUNC simd_double4 simd_bitselect(simd_double4 x, simd_double4 y, simd_long4 mask) { + return (simd_double4)simd_bitselect((simd_long4)x, (simd_long4)y, mask); +} +static inline SIMD_CFUNC simd_double8 simd_bitselect(simd_double8 x, simd_double8 y, simd_long8 mask) { + return (simd_double8)simd_bitselect((simd_long8)x, (simd_long8)y, mask); +} + +#ifdef __cplusplus +} +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* __SIMD_LOGIC_HEADER__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/math.h b/lib/libc/include/x86_64-macos-gnu/simd/math.h new file mode 100644 index 0000000000..9f3894dd6d --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/math.h @@ -0,0 +1,5380 @@ +/*! @header + * The interfaces declared in this header provide elementwise math operations + * on vectors; each lane of the result vector depends only on the data in the + * corresponding lane of the argument(s) to the function. + * + * You should not use the C functions declared in this header directly (these + * are functions with names like `__tg_cos(x)`). These are merely + * implementation details of overloading; instead of calling + * `__tg_cos(x)`, call `cos(x)`. If you are writing C++, use `simd::cos(x)`. + * + * Note that while these vector functions are relatively recent additions, + * scalar fallback is provided for all of them, so they are available even + * when targeting older OS versions. + * + * The following functions are available: + * + * C name C++ name Notes + * ---------------------------------------------------------------------- + * acos(x) simd::acos(x) + * asin(x) simd::asin(x) + * atan(x) simd::atan(x) + * atan2(y,x) simd::atan2(y,x) The argument order matches the scalar + * atan2 function, which gives the angle + * of a line with slope y/x. + * cos(x) simd::cos(x) + * sin(x) simd::sin(x) + * tan(x) simd::tan(x) + * + * cospi(x) simd::cospi(x) Returns cos(pi*x), sin(pi*x), tan(pi*x) + * sinpi(x) simd::sinpi(x) more efficiently and accurately than + * tanpi(x) simd::tanpi(x) would otherwise be possible + * + * acosh(x) simd::acosh(x) + * asinh(x) simd::asinh(x) + * atanh(x) simd::atanh(x) + * + * cosh(x) simd::cosh(x) + * sinh(x) simd::sinh(x) + * tanh(x) simd::tanh(x) + * + * exp(x) simd::exp(x) + * exp2(x) simd::exp2(x) + * exp10(x) simd::exp10(x) More efficient that pow(10,x). + * expm1(x) simd::expm1(x) exp(x)-1, accurate even for tiny x. + * + * log(x) simd::log(x) + * log2(x) simd::log2(x) + * log10(x) simd::log10(x) + * log1p(x) simd::log1p(x) log(1+x), accurate even for tiny x. + * + * fabs(x) simd::fabs(x) + * cbrt(x) simd::cbrt(x) + * sqrt(x) simd::sqrt(x) + * pow(x,y) simd::pow(x,y) + * copysign(x,y) simd::copysign(x,y) + * hypot(x,y) simd::hypot(x,y) sqrt(x*x + y*y), computed without + * overflow.1 + * erf(x) simd::erf(x) + * erfc(x) simd::erfc(x) + * tgamma(x) simd::tgamma(x) + * + * fmod(x,y) simd::fmod(x,y) + * remainder(x,y) simd::remainder(x,y) + * + * ceil(x) simd::ceil(x) + * floor(x) simd::floor(x) + * rint(x) simd::rint(x) + * round(x) simd::round(x) + * trunc(x) simd::trunc(x) + * + * fdim(x,y) simd::fdim(x,y) + * fmax(x,y) simd::fmax(x,y) When one argument to fmin or fmax is + * fmin(x,y) simd::fmin(x,y) constant, use it as the *second* (y) + * argument to get better codegen on some + * architectures. E.g., write fmin(x,2) + * instead of fmin(2,x). + * fma(x,y,z) simd::fma(x,y,z) Fast on arm64 and when targeting AVX2 + * and later; may be quite expensive on + * older hardware. + * simd_muladd(x,y,z) simd::muladd(x,y,z) + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_MATH_HEADER +#define SIMD_MATH_HEADER + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_acos(simd_float2 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_acos(simd_float3 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_acos(simd_double3 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x); + +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_asin(simd_float2 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_asin(simd_float3 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_asin(simd_double3 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x); + +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_atan(simd_float2 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_atan(simd_float3 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_atan(simd_double3 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x); + +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_cos(simd_float2 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_cos(simd_float3 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_cos(simd_double3 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x); + +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_sin(simd_float2 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_sin(simd_float3 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_sin(simd_double3 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x); + +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_tan(simd_float2 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_tan(simd_float3 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_tan(simd_double3 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x); + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_cospi(simd_float2 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_cospi(simd_float3 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_cospi(simd_double3 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x); +#endif + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_sinpi(simd_float2 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_sinpi(simd_float3 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_sinpi(simd_double3 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x); +#endif + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_tanpi(simd_float2 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_tanpi(simd_float3 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_tanpi(simd_double3 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x); +#endif + +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_acosh(simd_float2 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_acosh(simd_float3 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_acosh(simd_double3 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_asinh(simd_float2 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_asinh(simd_float3 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_asinh(simd_double3 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_atanh(simd_float2 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_atanh(simd_float3 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_atanh(simd_double3 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_cosh(simd_float2 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_cosh(simd_float3 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_cosh(simd_double3 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_sinh(simd_float2 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_sinh(simd_float3 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_sinh(simd_double3 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_tanh(simd_float2 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_tanh(simd_float3 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_tanh(simd_double3 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_exp(simd_float2 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_exp(simd_float3 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_exp(simd_double3 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x); + +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_exp2(simd_float2 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_exp2(simd_float3 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_exp2(simd_double3 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x); + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_exp10(simd_float2 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_exp10(simd_float3 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_exp10(simd_double3 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x); +#endif + +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_expm1(simd_float2 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_expm1(simd_float3 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_expm1(simd_double3 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x); + +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_log(simd_float2 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_log(simd_float3 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_log(simd_double3 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x); + +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_log2(simd_float2 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_log2(simd_float3 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_log2(simd_double3 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x); + +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_log10(simd_float2 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_log10(simd_float3 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_log10(simd_double3 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x); + +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_log1p(simd_float2 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_log1p(simd_float3 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_log1p(simd_double3 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x); + +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fabs(simd_float2 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fabs(simd_float3 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fabs(simd_float4 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fabs(simd_float8 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fabs(simd_float16 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fabs(simd_double2 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fabs(simd_double3 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fabs(simd_double4 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fabs(simd_double8 x); + +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_cbrt(simd_float2 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_cbrt(simd_float3 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_cbrt(simd_double3 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x); + +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_sqrt(simd_float2 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_sqrt(simd_float3 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_sqrt(simd_float4 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_sqrt(simd_float8 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_sqrt(simd_float16 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_sqrt(simd_double2 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_sqrt(simd_double3 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_sqrt(simd_double4 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_sqrt(simd_double8 x); + +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_erf(simd_float2 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_erf(simd_float3 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_erf(simd_double3 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x); + +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_erfc(simd_float2 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_erfc(simd_float3 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_erfc(simd_double3 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x); + +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_tgamma(simd_float2 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_tgamma(simd_float3 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_tgamma(simd_double3 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x); + +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_ceil(simd_float2 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_ceil(simd_float3 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_ceil(simd_float4 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_ceil(simd_float8 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_ceil(simd_float16 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_ceil(simd_double2 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_ceil(simd_double3 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_ceil(simd_double4 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_ceil(simd_double8 x); + +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_floor(simd_float2 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_floor(simd_float3 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_floor(simd_float4 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_floor(simd_float8 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_floor(simd_float16 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_floor(simd_double2 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_floor(simd_double3 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_floor(simd_double4 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_floor(simd_double8 x); + +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_rint(simd_float2 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_rint(simd_float3 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_rint(simd_float4 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_rint(simd_float8 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_rint(simd_float16 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_rint(simd_double2 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_rint(simd_double3 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_rint(simd_double4 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_rint(simd_double8 x); + +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_round(simd_float2 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_round(simd_float3 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_round(simd_double3 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x); + +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_trunc(simd_float2 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_trunc(simd_float3 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_trunc(simd_float4 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_trunc(simd_float8 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_trunc(simd_float16 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_trunc(simd_double2 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_trunc(simd_double3 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_trunc(simd_double4 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_trunc(simd_double8 x); + + +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_atan2(simd_float2 y, simd_float2 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_atan2(simd_float3 y, simd_float3 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_atan2(simd_double3 y, simd_double3 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x); + +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_hypot(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_hypot(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_hypot(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_pow(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_pow(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_pow(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fmod(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fmod(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fmod(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_remainder(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_remainder(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_remainder(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_copysign(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_copysign(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_copysign(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_copysign(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_copysign(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_copysign(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_copysign(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_copysign(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_copysign(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_nextafter(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_nextafter(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_nextafter(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fdim(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fdim(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fdim(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fdim(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fdim(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fdim(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fdim(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fdim(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fdim(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fmax(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fmax(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fmax(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fmax(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fmax(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fmax(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fmax(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fmax(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fmax(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fmin(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fmin(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fmin(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fmin(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fmin(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fmin(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fmin(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fmin(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fmin(simd_double8 x, simd_double8 y); + + +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fma(simd_float2 x, simd_float2 y, simd_float2 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fma(simd_float3 x, simd_float3 y, simd_float3 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fma(simd_float4 x, simd_float4 y, simd_float4 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fma(simd_float8 x, simd_float8 y, simd_float8 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fma(simd_float16 x, simd_float16 y, simd_float16 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fma(simd_double2 x, simd_double2 y, simd_double2 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fma(simd_double3 x, simd_double3 y, simd_double3 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fma(simd_double4 x, simd_double4 y, simd_double4 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fma(simd_double8 x, simd_double8 y, simd_double8 z); + +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC float simd_muladd(float x, float y, float z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float2 simd_muladd(simd_float2 x, simd_float2 y, simd_float2 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float3 simd_muladd(simd_float3 x, simd_float3 y, simd_float3 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float4 simd_muladd(simd_float4 x, simd_float4 y, simd_float4 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float8 simd_muladd(simd_float8 x, simd_float8 y, simd_float8 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float16 simd_muladd(simd_float16 x, simd_float16 y, simd_float16 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC double simd_muladd(double x, double y, double z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_double2 simd_muladd(simd_double2 x, simd_double2 y, simd_double2 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_double3 simd_muladd(simd_double3 x, simd_double3 y, simd_double3 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_double4 simd_muladd(simd_double4 x, simd_double4 y, simd_double4 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_double8 simd_muladd(simd_double8 x, simd_double8 y, simd_double8 z); + +#ifdef __cplusplus +} /* extern "C" */ + +#include +/*! @abstract Do not call this function directly; use simd::acos instead. */ +static SIMD_CPPFUNC float __tg_acos(float x) { return ::acos(x); } +/*! @abstract Do not call this function directly; use simd::acos instead. */ +static SIMD_CPPFUNC double __tg_acos(double x) { return ::acos(x); } +/*! @abstract Do not call this function directly; use simd::asin instead. */ +static SIMD_CPPFUNC float __tg_asin(float x) { return ::asin(x); } +/*! @abstract Do not call this function directly; use simd::asin instead. */ +static SIMD_CPPFUNC double __tg_asin(double x) { return ::asin(x); } +/*! @abstract Do not call this function directly; use simd::atan instead. */ +static SIMD_CPPFUNC float __tg_atan(float x) { return ::atan(x); } +/*! @abstract Do not call this function directly; use simd::atan instead. */ +static SIMD_CPPFUNC double __tg_atan(double x) { return ::atan(x); } +/*! @abstract Do not call this function directly; use simd::cos instead. */ +static SIMD_CPPFUNC float __tg_cos(float x) { return ::cos(x); } +/*! @abstract Do not call this function directly; use simd::cos instead. */ +static SIMD_CPPFUNC double __tg_cos(double x) { return ::cos(x); } +/*! @abstract Do not call this function directly; use simd::sin instead. */ +static SIMD_CPPFUNC float __tg_sin(float x) { return ::sin(x); } +/*! @abstract Do not call this function directly; use simd::sin instead. */ +static SIMD_CPPFUNC double __tg_sin(double x) { return ::sin(x); } +/*! @abstract Do not call this function directly; use simd::tan instead. */ +static SIMD_CPPFUNC float __tg_tan(float x) { return ::tan(x); } +/*! @abstract Do not call this function directly; use simd::tan instead. */ +static SIMD_CPPFUNC double __tg_tan(double x) { return ::tan(x); } +/*! @abstract Do not call this function directly; use simd::cospi instead. */ +static SIMD_CPPFUNC float __tg_cospi(float x) { return ::__cospi(x); } +/*! @abstract Do not call this function directly; use simd::cospi instead. */ +static SIMD_CPPFUNC double __tg_cospi(double x) { return ::__cospi(x); } +/*! @abstract Do not call this function directly; use simd::sinpi instead. */ +static SIMD_CPPFUNC float __tg_sinpi(float x) { return ::__sinpi(x); } +/*! @abstract Do not call this function directly; use simd::sinpi instead. */ +static SIMD_CPPFUNC double __tg_sinpi(double x) { return ::__sinpi(x); } +/*! @abstract Do not call this function directly; use simd::tanpi instead. */ +static SIMD_CPPFUNC float __tg_tanpi(float x) { return ::__tanpi(x); } +/*! @abstract Do not call this function directly; use simd::tanpi instead. */ +static SIMD_CPPFUNC double __tg_tanpi(double x) { return ::__tanpi(x); } +/*! @abstract Do not call this function directly; use simd::acosh instead. */ +static SIMD_CPPFUNC float __tg_acosh(float x) { return ::acosh(x); } +/*! @abstract Do not call this function directly; use simd::acosh instead. */ +static SIMD_CPPFUNC double __tg_acosh(double x) { return ::acosh(x); } +/*! @abstract Do not call this function directly; use simd::asinh instead. */ +static SIMD_CPPFUNC float __tg_asinh(float x) { return ::asinh(x); } +/*! @abstract Do not call this function directly; use simd::asinh instead. */ +static SIMD_CPPFUNC double __tg_asinh(double x) { return ::asinh(x); } +/*! @abstract Do not call this function directly; use simd::atanh instead. */ +static SIMD_CPPFUNC float __tg_atanh(float x) { return ::atanh(x); } +/*! @abstract Do not call this function directly; use simd::atanh instead. */ +static SIMD_CPPFUNC double __tg_atanh(double x) { return ::atanh(x); } +/*! @abstract Do not call this function directly; use simd::cosh instead. */ +static SIMD_CPPFUNC float __tg_cosh(float x) { return ::cosh(x); } +/*! @abstract Do not call this function directly; use simd::cosh instead. */ +static SIMD_CPPFUNC double __tg_cosh(double x) { return ::cosh(x); } +/*! @abstract Do not call this function directly; use simd::sinh instead. */ +static SIMD_CPPFUNC float __tg_sinh(float x) { return ::sinh(x); } +/*! @abstract Do not call this function directly; use simd::sinh instead. */ +static SIMD_CPPFUNC double __tg_sinh(double x) { return ::sinh(x); } +/*! @abstract Do not call this function directly; use simd::tanh instead. */ +static SIMD_CPPFUNC float __tg_tanh(float x) { return ::tanh(x); } +/*! @abstract Do not call this function directly; use simd::tanh instead. */ +static SIMD_CPPFUNC double __tg_tanh(double x) { return ::tanh(x); } +/*! @abstract Do not call this function directly; use simd::exp instead. */ +static SIMD_CPPFUNC float __tg_exp(float x) { return ::exp(x); } +/*! @abstract Do not call this function directly; use simd::exp instead. */ +static SIMD_CPPFUNC double __tg_exp(double x) { return ::exp(x); } +/*! @abstract Do not call this function directly; use simd::exp2 instead. */ +static SIMD_CPPFUNC float __tg_exp2(float x) { return ::exp2(x); } +/*! @abstract Do not call this function directly; use simd::exp2 instead. */ +static SIMD_CPPFUNC double __tg_exp2(double x) { return ::exp2(x); } +/*! @abstract Do not call this function directly; use simd::exp10 instead. */ +static SIMD_CPPFUNC float __tg_exp10(float x) { return ::__exp10(x); } +/*! @abstract Do not call this function directly; use simd::exp10 instead. */ +static SIMD_CPPFUNC double __tg_exp10(double x) { return ::__exp10(x); } +/*! @abstract Do not call this function directly; use simd::expm1 instead. */ +static SIMD_CPPFUNC float __tg_expm1(float x) { return ::expm1(x); } +/*! @abstract Do not call this function directly; use simd::expm1 instead. */ +static SIMD_CPPFUNC double __tg_expm1(double x) { return ::expm1(x); } +/*! @abstract Do not call this function directly; use simd::log instead. */ +static SIMD_CPPFUNC float __tg_log(float x) { return ::log(x); } +/*! @abstract Do not call this function directly; use simd::log instead. */ +static SIMD_CPPFUNC double __tg_log(double x) { return ::log(x); } +/*! @abstract Do not call this function directly; use simd::log2 instead. */ +static SIMD_CPPFUNC float __tg_log2(float x) { return ::log2(x); } +/*! @abstract Do not call this function directly; use simd::log2 instead. */ +static SIMD_CPPFUNC double __tg_log2(double x) { return ::log2(x); } +/*! @abstract Do not call this function directly; use simd::log10 instead. */ +static SIMD_CPPFUNC float __tg_log10(float x) { return ::log10(x); } +/*! @abstract Do not call this function directly; use simd::log10 instead. */ +static SIMD_CPPFUNC double __tg_log10(double x) { return ::log10(x); } +/*! @abstract Do not call this function directly; use simd::log1p instead. */ +static SIMD_CPPFUNC float __tg_log1p(float x) { return ::log1p(x); } +/*! @abstract Do not call this function directly; use simd::log1p instead. */ +static SIMD_CPPFUNC double __tg_log1p(double x) { return ::log1p(x); } +/*! @abstract Do not call this function directly; use simd::fabs instead. */ +static SIMD_CPPFUNC float __tg_fabs(float x) { return ::fabs(x); } +/*! @abstract Do not call this function directly; use simd::fabs instead. */ +static SIMD_CPPFUNC double __tg_fabs(double x) { return ::fabs(x); } +/*! @abstract Do not call this function directly; use simd::cbrt instead. */ +static SIMD_CPPFUNC float __tg_cbrt(float x) { return ::cbrt(x); } +/*! @abstract Do not call this function directly; use simd::cbrt instead. */ +static SIMD_CPPFUNC double __tg_cbrt(double x) { return ::cbrt(x); } +/*! @abstract Do not call this function directly; use simd::sqrt instead. */ +static SIMD_CPPFUNC float __tg_sqrt(float x) { return ::sqrt(x); } +/*! @abstract Do not call this function directly; use simd::sqrt instead. */ +static SIMD_CPPFUNC double __tg_sqrt(double x) { return ::sqrt(x); } +/*! @abstract Do not call this function directly; use simd::erf instead. */ +static SIMD_CPPFUNC float __tg_erf(float x) { return ::erf(x); } +/*! @abstract Do not call this function directly; use simd::erf instead. */ +static SIMD_CPPFUNC double __tg_erf(double x) { return ::erf(x); } +/*! @abstract Do not call this function directly; use simd::erfc instead. */ +static SIMD_CPPFUNC float __tg_erfc(float x) { return ::erfc(x); } +/*! @abstract Do not call this function directly; use simd::erfc instead. */ +static SIMD_CPPFUNC double __tg_erfc(double x) { return ::erfc(x); } +/*! @abstract Do not call this function directly; use simd::tgamma instead. */ +static SIMD_CPPFUNC float __tg_tgamma(float x) { return ::tgamma(x); } +/*! @abstract Do not call this function directly; use simd::tgamma instead. */ +static SIMD_CPPFUNC double __tg_tgamma(double x) { return ::tgamma(x); } +/*! @abstract Do not call this function directly; use simd::ceil instead. */ +static SIMD_CPPFUNC float __tg_ceil(float x) { return ::ceil(x); } +/*! @abstract Do not call this function directly; use simd::ceil instead. */ +static SIMD_CPPFUNC double __tg_ceil(double x) { return ::ceil(x); } +/*! @abstract Do not call this function directly; use simd::floor instead. */ +static SIMD_CPPFUNC float __tg_floor(float x) { return ::floor(x); } +/*! @abstract Do not call this function directly; use simd::floor instead. */ +static SIMD_CPPFUNC double __tg_floor(double x) { return ::floor(x); } +/*! @abstract Do not call this function directly; use simd::rint instead. */ +static SIMD_CPPFUNC float __tg_rint(float x) { return ::rint(x); } +/*! @abstract Do not call this function directly; use simd::rint instead. */ +static SIMD_CPPFUNC double __tg_rint(double x) { return ::rint(x); } +/*! @abstract Do not call this function directly; use simd::round instead. */ +static SIMD_CPPFUNC float __tg_round(float x) { return ::round(x); } +/*! @abstract Do not call this function directly; use simd::round instead. */ +static SIMD_CPPFUNC double __tg_round(double x) { return ::round(x); } +/*! @abstract Do not call this function directly; use simd::trunc instead. */ +static SIMD_CPPFUNC float __tg_trunc(float x) { return ::trunc(x); } +/*! @abstract Do not call this function directly; use simd::trunc instead. */ +static SIMD_CPPFUNC double __tg_trunc(double x) { return ::trunc(x); } +/*! @abstract Do not call this function directly; use simd::atan2 instead. */ +static SIMD_CPPFUNC float __tg_atan2(float x, float y) { return ::atan2(x, y); } +/*! @abstract Do not call this function directly; use simd::atan2 instead. */ +static SIMD_CPPFUNC double __tg_atan2(double x, float y) { return ::atan2(x, y); } +/*! @abstract Do not call this function directly; use simd::hypot instead. */ +static SIMD_CPPFUNC float __tg_hypot(float x, float y) { return ::hypot(x, y); } +/*! @abstract Do not call this function directly; use simd::hypot instead. */ +static SIMD_CPPFUNC double __tg_hypot(double x, float y) { return ::hypot(x, y); } +/*! @abstract Do not call this function directly; use simd::pow instead. */ +static SIMD_CPPFUNC float __tg_pow(float x, float y) { return ::pow(x, y); } +/*! @abstract Do not call this function directly; use simd::pow instead. */ +static SIMD_CPPFUNC double __tg_pow(double x, float y) { return ::pow(x, y); } +/*! @abstract Do not call this function directly; use simd::fmod instead. */ +static SIMD_CPPFUNC float __tg_fmod(float x, float y) { return ::fmod(x, y); } +/*! @abstract Do not call this function directly; use simd::fmod instead. */ +static SIMD_CPPFUNC double __tg_fmod(double x, float y) { return ::fmod(x, y); } +/*! @abstract Do not call this function directly; use simd::remainder + * instead. */ +static SIMD_CPPFUNC float __tg_remainder(float x, float y) { return ::remainder(x, y); } +/*! @abstract Do not call this function directly; use simd::remainder + * instead. */ +static SIMD_CPPFUNC double __tg_remainder(double x, float y) { return ::remainder(x, y); } +/*! @abstract Do not call this function directly; use simd::copysign + * instead. */ +static SIMD_CPPFUNC float __tg_copysign(float x, float y) { return ::copysign(x, y); } +/*! @abstract Do not call this function directly; use simd::copysign + * instead. */ +static SIMD_CPPFUNC double __tg_copysign(double x, float y) { return ::copysign(x, y); } +/*! @abstract Do not call this function directly; use simd::nextafter + * instead. */ +static SIMD_CPPFUNC float __tg_nextafter(float x, float y) { return ::nextafter(x, y); } +/*! @abstract Do not call this function directly; use simd::nextafter + * instead. */ +static SIMD_CPPFUNC double __tg_nextafter(double x, float y) { return ::nextafter(x, y); } +/*! @abstract Do not call this function directly; use simd::fdim instead. */ +static SIMD_CPPFUNC float __tg_fdim(float x, float y) { return ::fdim(x, y); } +/*! @abstract Do not call this function directly; use simd::fdim instead. */ +static SIMD_CPPFUNC double __tg_fdim(double x, float y) { return ::fdim(x, y); } +/*! @abstract Do not call this function directly; use simd::fmax instead. */ +static SIMD_CPPFUNC float __tg_fmax(float x, float y) { return ::fmax(x, y); } +/*! @abstract Do not call this function directly; use simd::fmax instead. */ +static SIMD_CPPFUNC double __tg_fmax(double x, float y) { return ::fmax(x, y); } +/*! @abstract Do not call this function directly; use simd::fmin instead. */ +static SIMD_CPPFUNC float __tg_fmin(float x, float y) { return ::fmin(x, y); } +/*! @abstract Do not call this function directly; use simd::fmin instead. */ +static SIMD_CPPFUNC double __tg_fmin(double x, float y) { return ::fmin(x, y); } +/*! @abstract Do not call this function directly; use simd::fma instead. */ +static SIMD_CPPFUNC float __tg_fma(float x, float y, float z) { return ::fma(x, y, z); } +/*! @abstract Do not call this function directly; use simd::fma instead. */ +static SIMD_CPPFUNC double __tg_fma(double x, double y, double z) { return ::fma(x, y, z); } + +namespace simd { +/*! @abstract Generalizes the function acos to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN acos(fptypeN x) { return ::__tg_acos(x); } + +/*! @abstract Generalizes the function asin to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN asin(fptypeN x) { return ::__tg_asin(x); } + +/*! @abstract Generalizes the function atan to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN atan(fptypeN x) { return ::__tg_atan(x); } + +/*! @abstract Generalizes the function cos to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN cos(fptypeN x) { return ::__tg_cos(x); } + +/*! @abstract Generalizes the function sin to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN sin(fptypeN x) { return ::__tg_sin(x); } + +/*! @abstract Generalizes the function tan to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN tan(fptypeN x) { return ::__tg_tan(x); } + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Generalizes the function cospi to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN cospi(fptypeN x) { return ::__tg_cospi(x); } +#endif + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Generalizes the function sinpi to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN sinpi(fptypeN x) { return ::__tg_sinpi(x); } +#endif + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Generalizes the function tanpi to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN tanpi(fptypeN x) { return ::__tg_tanpi(x); } +#endif + +/*! @abstract Generalizes the function acosh to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN acosh(fptypeN x) { return ::__tg_acosh(x); } + +/*! @abstract Generalizes the function asinh to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN asinh(fptypeN x) { return ::__tg_asinh(x); } + +/*! @abstract Generalizes the function atanh to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN atanh(fptypeN x) { return ::__tg_atanh(x); } + +/*! @abstract Generalizes the function cosh to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN cosh(fptypeN x) { return ::__tg_cosh(x); } + +/*! @abstract Generalizes the function sinh to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN sinh(fptypeN x) { return ::__tg_sinh(x); } + +/*! @abstract Generalizes the function tanh to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN tanh(fptypeN x) { return ::__tg_tanh(x); } + +/*! @abstract Generalizes the function exp to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN exp(fptypeN x) { return ::__tg_exp(x); } + +/*! @abstract Generalizes the function exp2 to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN exp2(fptypeN x) { return ::__tg_exp2(x); } + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Generalizes the function exp10 to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN exp10(fptypeN x) { return ::__tg_exp10(x); } +#endif + +/*! @abstract Generalizes the function expm1 to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN expm1(fptypeN x) { return ::__tg_expm1(x); } + +/*! @abstract Generalizes the function log to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN log(fptypeN x) { return ::__tg_log(x); } + +/*! @abstract Generalizes the function log2 to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN log2(fptypeN x) { return ::__tg_log2(x); } + +/*! @abstract Generalizes the function log10 to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN log10(fptypeN x) { return ::__tg_log10(x); } + +/*! @abstract Generalizes the function log1p to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN log1p(fptypeN x) { return ::__tg_log1p(x); } + +/*! @abstract Generalizes the function fabs to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fabs(fptypeN x) { return ::__tg_fabs(x); } + +/*! @abstract Generalizes the function cbrt to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN cbrt(fptypeN x) { return ::__tg_cbrt(x); } + +/*! @abstract Generalizes the function sqrt to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN sqrt(fptypeN x) { return ::__tg_sqrt(x); } + +/*! @abstract Generalizes the function erf to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN erf(fptypeN x) { return ::__tg_erf(x); } + +/*! @abstract Generalizes the function erfc to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN erfc(fptypeN x) { return ::__tg_erfc(x); } + +/*! @abstract Generalizes the function tgamma to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN tgamma(fptypeN x) { return ::__tg_tgamma(x); } + +/*! @abstract Generalizes the function ceil to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN ceil(fptypeN x) { return ::__tg_ceil(x); } + +/*! @abstract Generalizes the function floor to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN floor(fptypeN x) { return ::__tg_floor(x); } + +/*! @abstract Generalizes the function rint to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN rint(fptypeN x) { return ::__tg_rint(x); } + +/*! @abstract Generalizes the function round to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN round(fptypeN x) { return ::__tg_round(x); } + +/*! @abstract Generalizes the function trunc to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN trunc(fptypeN x) { return ::__tg_trunc(x); } + +/*! @abstract Generalizes the function atan2 to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN atan2(fptypeN y, fptypeN x) { return ::__tg_atan2(y, x); } + +/*! @abstract Generalizes the function hypot to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN hypot(fptypeN x, fptypeN y) { return ::__tg_hypot(x, y); } + +/*! @abstract Generalizes the function pow to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN pow(fptypeN x, fptypeN y) { return ::__tg_pow(x, y); } + +/*! @abstract Generalizes the function fmod to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fmod(fptypeN x, fptypeN y) { return ::__tg_fmod(x, y); } + +/*! @abstract Generalizes the function remainder to operate on + * vectors of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN remainder(fptypeN x, fptypeN y) { return ::__tg_remainder(x, y); } + +/*! @abstract Generalizes the function copysign to operate on + * vectors of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN copysign(fptypeN x, fptypeN y) { return ::__tg_copysign(x, y); } + +/*! @abstract Generalizes the function nextafter to operate on + * vectors of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN nextafter(fptypeN x, fptypeN y) { return ::__tg_nextafter(x, y); } + +/*! @abstract Generalizes the function fdim to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fdim(fptypeN x, fptypeN y) { return ::__tg_fdim(x, y); } + +/*! @abstract Generalizes the function fmax to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fmax(fptypeN x, fptypeN y) { return ::__tg_fmax(x, y); } + +/*! @abstract Generalizes the function fmin to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fmin(fptypeN x, fptypeN y) { return ::__tg_fmin(x, y); } + +/*! @abstract Generalizes the function fma to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fma(fptypeN x, fptypeN y, fptypeN z) { return ::__tg_fma(x, y, z); } + +/*! @abstract Computes x*y + z by the most efficient means available; either + * a fused multiply add or separate multiply and add. */ + template + static SIMD_CPPFUNC fptypeN muladd(fptypeN x, fptypeN y, fptypeN z) { return ::simd_muladd(x, y, z); } +}; + +extern "C" { +#else +#include +/* C and Objective-C, we need some infrastructure to piggyback on tgmath.h */ +static SIMD_OVERLOAD simd_float2 __tg_promote(simd_float2); +static SIMD_OVERLOAD simd_float3 __tg_promote(simd_float3); +static SIMD_OVERLOAD simd_float4 __tg_promote(simd_float4); +static SIMD_OVERLOAD simd_float8 __tg_promote(simd_float8); +static SIMD_OVERLOAD simd_float16 __tg_promote(simd_float16); +static SIMD_OVERLOAD simd_double2 __tg_promote(simd_double2); +static SIMD_OVERLOAD simd_double3 __tg_promote(simd_double3); +static SIMD_OVERLOAD simd_double4 __tg_promote(simd_double4); +static SIMD_OVERLOAD simd_double8 __tg_promote(simd_double8); + +/* Apple extensions to , added in macOS 10.9 and iOS 7.0 */ +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_9 || \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0 || \ + __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_19_0 +static inline SIMD_CFUNC float __tg_cospi(float x) { return __cospif(x); } +static inline SIMD_CFUNC double __tg_cospi(double x) { return __cospi(x); } +#undef cospi +/*! @abstract `cospi(x)` computes `cos(pi * x)` without intermediate rounding. + * + * @discussion Both faster and more accurate than multiplying by `pi` and then + * calling `cos`. Defined for `float` and `double` as well as vectors of + * floats and doubles as provided by ``. */ +#define cospi(__x) __tg_cospi(__tg_promote1((__x))(__x)) + +static inline SIMD_CFUNC float __tg_sinpi(float x) { return __sinpif(x); } +static inline SIMD_CFUNC double __tg_sinpi(double x) { return __sinpi(x); } +#undef sinpi +/*! @abstract `sinpi(x)` computes `sin(pi * x)` without intermediate rounding. + * + * @discussion Both faster and more accurate than multiplying by `pi` and then + * calling `sin`. Defined for `float` and `double` as well as vectors + * of floats and doubles as provided by ``. */ +#define sinpi(__x) __tg_sinpi(__tg_promote1((__x))(__x)) + +static inline SIMD_CFUNC float __tg_tanpi(float x) { return __tanpif(x); } +static inline SIMD_CFUNC double __tg_tanpi(double x) { return __tanpi(x); } +#undef tanpi +/*! @abstract `tanpi(x)` computes `tan(pi * x)` without intermediate rounding. + * + * @discussion Both faster and more accurate than multiplying by `pi` and then + * calling `tan`. Defined for `float` and `double` as well as vectors of + * floats and doubles as provided by ``. */ +#define tanpi(__x) __tg_tanpi(__tg_promote1((__x))(__x)) + +static inline SIMD_CFUNC float __tg_exp10(float x) { return __exp10f(x); } +static inline SIMD_CFUNC double __tg_exp10(double x) { return __exp10(x); } +#undef exp10 +/*! @abstract `exp10(x)` computes `10**x` more efficiently and accurately + * than `pow(10, x)`. + * + * @discussion Defined for `float` and `double` as well as vectors of floats + * and doubles as provided by ``. */ +#define exp10(__x) __tg_exp10(__tg_promote1((__x))(__x)) +#endif + + +#endif /* !__cplusplus */ + +#pragma mark - fabs implementation +static inline SIMD_CFUNC simd_float2 __tg_fabs(simd_float2 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float3 __tg_fabs(simd_float3 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float4 __tg_fabs(simd_float4 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float8 __tg_fabs(simd_float8 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float16 __tg_fabs(simd_float16 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_double2 __tg_fabs(simd_double2 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double3 __tg_fabs(simd_double3 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double4 __tg_fabs(simd_double4 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double8 __tg_fabs(simd_double8 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); } + +#pragma mark - fmin, fmax implementation +static SIMD_CFUNC simd_float2 __tg_fmin(simd_float2 x, simd_float2 y) { +#if defined __SSE2__ + return simd_make_float2(__tg_fmin(simd_make_float4_undef(x), simd_make_float4_undef(y))); +#elif defined __arm64__ + return vminnm_f32(x, y); +#elif defined __arm__ && __FINITE_MATH_ONLY__ + return vmin_f32(x, y); +#else + return simd_bitselect(y, x, (x <= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_fmin(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_fmin(simd_make_float4_undef(x), simd_make_float4_undef(y))); +} + +static SIMD_CFUNC simd_float4 __tg_fmin(simd_float4 x, simd_float4 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__ + return _mm_range_ps(x, y, 4); +#elif defined __SSE2__ && __FINITE_MATH_ONLY__ + return _mm_min_ps(x, y); +#elif defined __SSE2__ + return simd_bitselect(_mm_min_ps(x, y), x, y != y); +#elif defined __arm64__ + return vminnmq_f32(x, y); +#elif defined __arm__ && __FINITE_MATH_ONLY__ + return vminq_f32(x, y); +#else + return simd_bitselect(y, x, (x <= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_fmin(simd_float8 x, simd_float8 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__ + return _mm256_range_ps(x, y, 4); +#elif defined __AVX__ && __FINITE_MATH_ONLY__ + return _mm256_min_ps(x, y); +#elif defined __AVX__ + return simd_bitselect(_mm256_min_ps(x, y), x, y != y); +#else + return simd_make_float8(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_fmin(simd_float16 x, simd_float16 y) { +#if defined __x86_64__ && defined __AVX512DQ__ && !__FINITE_MATH_ONLY__ + return _mm512_range_ps(x, y, 4); +#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__ + return _mm512_min_ps(x, y); +#elif defined __x86_64__ && defined __AVX512F__ + return simd_bitselect(_mm512_min_ps(x, y), x, y != y); +#else + return simd_make_float16(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_double2 __tg_fmin(simd_double2 x, simd_double2 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ + return _mm_range_pd(x, y, 4); +#elif defined __SSE2__ && __FINITE_MATH_ONLY__ + return _mm_min_pd(x, y); +#elif defined __SSE2__ + return simd_bitselect(_mm_min_pd(x, y), x, y != y); +#elif defined __arm64__ + return vminnmq_f64(x, y); +#else + return simd_bitselect(y, x, (x <= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_fmin(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_fmin(simd_make_double4_undef(x), simd_make_double4_undef(y))); +} + +static SIMD_CFUNC simd_double4 __tg_fmin(simd_double4 x, simd_double4 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ + return _mm256_range_pd(x, y, 4); +#elif defined __AVX__ && __FINITE_MATH_ONLY__ + return _mm256_min_pd(x, y); +#elif defined __AVX__ + return simd_bitselect(_mm256_min_pd(x, y), x, y != y); +#else + return simd_make_double4(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_fmin(simd_double8 x, simd_double8 y) { +#if defined __x86_64__ && defined __AVX512DQ__ + return _mm512_range_pd(x, y, 4); +#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__ + return _mm512_min_pd(x, y); +#elif defined __x86_64__ && defined __AVX512F__ + return simd_bitselect(_mm512_min_pd(x, y), x, y != y); +#else + return simd_make_double8(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_float2 __tg_fmax(simd_float2 x, simd_float2 y) { +#if defined __SSE2__ + return simd_make_float2(__tg_fmax(simd_make_float4_undef(x), simd_make_float4_undef(y))); +#elif defined __arm64__ + return vmaxnm_f32(x, y); +#elif defined __arm__ && __FINITE_MATH_ONLY__ + return vmax_f32(x, y); +#else + return simd_bitselect(y, x, (x >= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_fmax(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_fmax(simd_make_float4_undef(x), simd_make_float4_undef(y))); +} + +static SIMD_CFUNC simd_float4 __tg_fmax(simd_float4 x, simd_float4 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__ + return _mm_range_ps(x, y, 5); +#elif defined __SSE2__ && __FINITE_MATH_ONLY__ + return _mm_max_ps(x, y); +#elif defined __SSE2__ + return simd_bitselect(_mm_max_ps(x, y), x, y != y); +#elif defined __arm64__ + return vmaxnmq_f32(x, y); +#elif defined __arm__ && __FINITE_MATH_ONLY__ + return vmaxq_f32(x, y); +#else + return simd_bitselect(y, x, (x >= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_fmax(simd_float8 x, simd_float8 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__ + return _mm256_range_ps(x, y, 5); +#elif defined __AVX__ && __FINITE_MATH_ONLY__ + return _mm256_max_ps(x, y); +#elif defined __AVX__ + return simd_bitselect(_mm256_max_ps(x, y), x, y != y); +#else + return simd_make_float8(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_fmax(simd_float16 x, simd_float16 y) { +#if defined __x86_64__ && defined __AVX512DQ__ && !__FINITE_MATH_ONLY__ + return _mm512_range_ps(x, y, 5); +#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__ + return _mm512_max_ps(x, y); +#elif defined __x86_64__ && defined __AVX512F__ + return simd_bitselect(_mm512_max_ps(x, y), x, y != y); +#else + return simd_make_float16(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_double2 __tg_fmax(simd_double2 x, simd_double2 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ + return _mm_range_pd(x, y, 5); +#elif defined __SSE2__ && __FINITE_MATH_ONLY__ + return _mm_max_pd(x, y); +#elif defined __SSE2__ + return simd_bitselect(_mm_max_pd(x, y), x, y != y); +#elif defined __arm64__ + return vmaxnmq_f64(x, y); +#else + return simd_bitselect(y, x, (x >= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_fmax(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_fmax(simd_make_double4_undef(x), simd_make_double4_undef(y))); +} + +static SIMD_CFUNC simd_double4 __tg_fmax(simd_double4 x, simd_double4 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ + return _mm256_range_pd(x, y, 5); +#elif defined __AVX__ && __FINITE_MATH_ONLY__ + return _mm256_max_pd(x, y); +#elif defined __AVX__ + return simd_bitselect(_mm256_max_pd(x, y), x, y != y); +#else + return simd_make_double4(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_fmax(simd_double8 x, simd_double8 y) { +#if defined __x86_64__ && defined __AVX512DQ__ + return _mm512_range_pd(x, y, 5); +#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__ + return _mm512_max_pd(x, y); +#elif defined __x86_64__ && defined __AVX512F__ + return simd_bitselect(_mm512_max_pd(x, y), x, y != y); +#else + return simd_make_double8(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi)); +#endif +} + +#pragma mark - copysign implementation +static inline SIMD_CFUNC simd_float2 __tg_copysign(simd_float2 x, simd_float2 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float3 __tg_copysign(simd_float3 x, simd_float3 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float4 __tg_copysign(simd_float4 x, simd_float4 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float8 __tg_copysign(simd_float8 x, simd_float8 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float16 __tg_copysign(simd_float16 x, simd_float16 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_double2 __tg_copysign(simd_double2 x, simd_double2 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double3 __tg_copysign(simd_double3 x, simd_double3 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double4 __tg_copysign(simd_double4 x, simd_double4 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double8 __tg_copysign(simd_double8 x, simd_double8 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); } + +#pragma mark - sqrt implementation +static SIMD_CFUNC simd_float2 __tg_sqrt(simd_float2 x) { +#if defined __SSE2__ + return simd_make_float2(__tg_sqrt(simd_make_float4_undef(x))); +#elif defined __arm64__ + return vsqrt_f32(x); +#else + return simd_make_float2(sqrt(x.x), sqrt(x.y)); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_sqrt(simd_float3 x) { + return simd_make_float3(__tg_sqrt(simd_make_float4_undef(x))); +} + +static SIMD_CFUNC simd_float4 __tg_sqrt(simd_float4 x) { +#if defined __SSE2__ + return _mm_sqrt_ps(x); +#elif defined __arm64__ + return vsqrtq_f32(x); +#else + return simd_make_float4(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_sqrt(simd_float8 x) { +#if defined __AVX__ + return _mm256_sqrt_ps(x); +#else + return simd_make_float8(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_sqrt(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_sqrt_ps(x); +#else + return simd_make_float16(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double2 __tg_sqrt(simd_double2 x) { +#if defined __SSE2__ + return _mm_sqrt_pd(x); +#elif defined __arm64__ + return vsqrtq_f64(x); +#else + return simd_make_double2(sqrt(x.x), sqrt(x.y)); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_sqrt(simd_double3 x) { + return simd_make_double3(__tg_sqrt(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_sqrt(simd_double4 x) { +#if defined __AVX__ + return _mm256_sqrt_pd(x); +#else + return simd_make_double4(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_sqrt(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_sqrt_pd(x); +#else + return simd_make_double8(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +#pragma mark - ceil, floor, rint, trunc implementation +static SIMD_CFUNC simd_float2 __tg_ceil(simd_float2 x) { +#if defined __arm64__ + return vrndp_f32(x); +#else + return simd_make_float2(__tg_ceil(simd_make_float4_undef(x))); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_ceil(simd_float3 x) { + return simd_make_float3(__tg_ceil(simd_make_float4_undef(x))); +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_ceil_f4(simd_float4 x); +#endif + +static SIMD_CFUNC simd_float4 __tg_ceil(simd_float4 x) { +#if defined __SSE4_1__ + return _mm_round_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndpq_f32(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_ceil_f4(x); +#else + simd_float4 truncated = __tg_trunc(x); + simd_float4 adjust = simd_bitselect((simd_float4)0, 1, truncated < x); + return __tg_copysign(truncated + adjust, x); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_ceil(simd_float8 x) { +#if defined __AVX__ + return _mm256_round_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_float8(__tg_ceil(x.lo), __tg_ceil(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_ceil(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_float16(__tg_ceil(x.lo), __tg_ceil(x.hi)); +#endif +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_ceil_d2(simd_double2 x); +#endif + +static SIMD_CFUNC simd_double2 __tg_ceil(simd_double2 x) { +#if defined __SSE4_1__ + return _mm_round_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndpq_f64(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_ceil_d2(x); +#else + simd_double2 truncated = __tg_trunc(x); + simd_double2 adjust = simd_bitselect((simd_double2)0, 1, truncated < x); + return __tg_copysign(truncated + adjust, x); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_ceil(simd_double3 x) { + return simd_make_double3(__tg_ceil(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_ceil(simd_double4 x) { +#if defined __AVX__ + return _mm256_round_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_double4(__tg_ceil(x.lo), __tg_ceil(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_ceil(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_double8(__tg_ceil(x.lo), __tg_ceil(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float2 __tg_floor(simd_float2 x) { +#if defined __arm64__ + return vrndm_f32(x); +#else + return simd_make_float2(__tg_floor(simd_make_float4_undef(x))); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_floor(simd_float3 x) { + return simd_make_float3(__tg_floor(simd_make_float4_undef(x))); +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_floor_f4(simd_float4 x); +#endif + +static SIMD_CFUNC simd_float4 __tg_floor(simd_float4 x) { +#if defined __SSE4_1__ + return _mm_round_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndmq_f32(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_floor_f4(x); +#else + simd_float4 truncated = __tg_trunc(x); + simd_float4 adjust = simd_bitselect((simd_float4)0, 1, truncated > x); + return truncated - adjust; +#endif +} + +static SIMD_CFUNC simd_float8 __tg_floor(simd_float8 x) { +#if defined __AVX__ + return _mm256_round_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_float8(__tg_floor(x.lo), __tg_floor(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_floor(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_float16(__tg_floor(x.lo), __tg_floor(x.hi)); +#endif +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_floor_d2(simd_double2 x); +#endif + +static SIMD_CFUNC simd_double2 __tg_floor(simd_double2 x) { +#if defined __SSE4_1__ + return _mm_round_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndmq_f64(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_floor_d2(x); +#else + simd_double2 truncated = __tg_trunc(x); + simd_double2 adjust = simd_bitselect((simd_double2)0, 1, truncated > x); + return truncated - adjust; +#endif +} + +static SIMD_CFUNC simd_double3 __tg_floor(simd_double3 x) { + return simd_make_double3(__tg_floor(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_floor(simd_double4 x) { +#if defined __AVX__ + return _mm256_round_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_double4(__tg_floor(x.lo), __tg_floor(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_floor(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_double8(__tg_floor(x.lo), __tg_floor(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float2 __tg_rint(simd_float2 x) { +#if defined __arm64__ + return vrndx_f32(x); +#else + return simd_make_float2(__tg_rint(simd_make_float4_undef(x))); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_rint(simd_float3 x) { + return simd_make_float3(__tg_rint(simd_make_float4_undef(x))); +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_rint_f4(simd_float4 x); +#endif + +static SIMD_CFUNC simd_float4 __tg_rint(simd_float4 x) { +#if defined __SSE4_1__ + return _mm_round_ps(x, _MM_FROUND_RINT); +#elif defined __arm64__ + return vrndxq_f32(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_rint_f4(x); +#else + simd_float4 magic = __tg_copysign(0x1.0p23, x); + simd_int4 x_is_small = __tg_fabs(x) < 0x1.0p23; + return simd_bitselect(x, (x + magic) - magic, x_is_small & 0x7fffffff); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_rint(simd_float8 x) { +#if defined __AVX__ + return _mm256_round_ps(x, _MM_FROUND_RINT); +#else + return simd_make_float8(__tg_rint(x.lo), __tg_rint(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_rint(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_ps(x, _MM_FROUND_RINT); +#else + return simd_make_float16(__tg_rint(x.lo), __tg_rint(x.hi)); +#endif +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_rint_d2(simd_double2 x); +#endif + +static SIMD_CFUNC simd_double2 __tg_rint(simd_double2 x) { +#if defined __SSE4_1__ + return _mm_round_pd(x, _MM_FROUND_RINT); +#elif defined __arm64__ + return vrndxq_f64(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_rint_d2(x); +#else + simd_double2 magic = __tg_copysign(0x1.0p52, x); + simd_long2 x_is_small = __tg_fabs(x) < 0x1.0p52; + return simd_bitselect(x, (x + magic) - magic, x_is_small & 0x7fffffffffffffff); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_rint(simd_double3 x) { + return simd_make_double3(__tg_rint(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_rint(simd_double4 x) { +#if defined __AVX__ + return _mm256_round_pd(x, _MM_FROUND_RINT); +#else + return simd_make_double4(__tg_rint(x.lo), __tg_rint(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_rint(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_pd(x, _MM_FROUND_RINT); +#else + return simd_make_double8(__tg_rint(x.lo), __tg_rint(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float2 __tg_trunc(simd_float2 x) { +#if defined __arm64__ + return vrnd_f32(x); +#else + return simd_make_float2(__tg_trunc(simd_make_float4_undef(x))); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_trunc(simd_float3 x) { + return simd_make_float3(__tg_trunc(simd_make_float4_undef(x))); +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_trunc_f4(simd_float4 x); +#endif + +static SIMD_CFUNC simd_float4 __tg_trunc(simd_float4 x) { +#if defined __SSE4_1__ + return _mm_round_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndq_f32(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_trunc_f4(x); +#else + simd_float4 binade = simd_bitselect(0, x, 0x7f800000); + simd_int4 mask = (simd_int4)__tg_fmin(-2*binade + 1, -0); + simd_float4 result = simd_bitselect(0, x, mask); + return simd_bitselect(x, result, binade < 0x1.0p23); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_trunc(simd_float8 x) { +#if defined __AVX__ + return _mm256_round_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return simd_make_float8(__tg_trunc(x.lo), __tg_trunc(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_trunc(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return simd_make_float16(__tg_trunc(x.lo), __tg_trunc(x.hi)); +#endif +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_trunc_d2(simd_double2 x); +#endif + +static SIMD_CFUNC simd_double2 __tg_trunc(simd_double2 x) { +#if defined __SSE4_1__ + return _mm_round_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndq_f64(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_trunc_d2(x); +#else + simd_double2 binade = simd_bitselect(0, x, 0x7ff0000000000000); + simd_long2 mask = (simd_long2)__tg_fmin(-2*binade + 1, -0); + simd_double2 result = simd_bitselect(0, x, mask); + return simd_bitselect(x, result, binade < 0x1.0p52); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_trunc(simd_double3 x) { + return simd_make_double3(__tg_trunc(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_trunc(simd_double4 x) { +#if defined __AVX__ + return _mm256_round_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return simd_make_double4(__tg_trunc(x.lo), __tg_trunc(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_trunc(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return simd_make_double8(__tg_trunc(x.lo), __tg_trunc(x.hi)); +#endif +} + +#pragma mark - sine, cosine implementation +static inline SIMD_CFUNC simd_float2 __tg_sin(simd_float2 x) { + return simd_make_float2(__tg_sin(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_sin(simd_float3 x) { + return simd_make_float3(__tg_sin(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_sin_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) { + return _simd_sin_f4(x); +} +#elif SIMD_LIBRARY_VERSION == 1 +extern simd_float4 __sin_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) { + return __sin_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) { + return simd_make_float4(sin(x.x), sin(x.y), sin(x.z), sin(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_sin_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x) { + return _simd_sin_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x) { + return simd_make_float8(__tg_sin(x.lo), __tg_sin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_sin_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x) { + return _simd_sin_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x) { + return simd_make_float16(__tg_sin(x.lo), __tg_sin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_sin_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) { + return _simd_sin_d2(x); +} +#elif SIMD_LIBRARY_VERSION == 1 +extern simd_double2 __sin_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) { + return __sin_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) { + return simd_make_double2(sin(x.x), sin(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_sin(simd_double3 x) { + return simd_make_double3(__tg_sin(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_sin_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x) { + return _simd_sin_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x) { + return simd_make_double4(__tg_sin(x.lo), __tg_sin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_sin_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x) { + return _simd_sin_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x) { + return simd_make_double8(__tg_sin(x.lo), __tg_sin(x.hi)); +} +#endif + +static inline SIMD_CFUNC simd_float2 __tg_cos(simd_float2 x) { + return simd_make_float2(__tg_cos(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_cos(simd_float3 x) { + return simd_make_float3(__tg_cos(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_cos_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) { + return _simd_cos_f4(x); +} +#elif SIMD_LIBRARY_VERSION == 1 +extern simd_float4 __cos_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) { + return __cos_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) { + return simd_make_float4(cos(x.x), cos(x.y), cos(x.z), cos(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_cos_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x) { + return _simd_cos_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x) { + return simd_make_float8(__tg_cos(x.lo), __tg_cos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_cos_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x) { + return _simd_cos_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x) { + return simd_make_float16(__tg_cos(x.lo), __tg_cos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_cos_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) { + return _simd_cos_d2(x); +} +#elif SIMD_LIBRARY_VERSION == 1 +extern simd_double2 __cos_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) { + return __cos_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) { + return simd_make_double2(cos(x.x), cos(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_cos(simd_double3 x) { + return simd_make_double3(__tg_cos(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_cos_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x) { + return _simd_cos_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x) { + return simd_make_double4(__tg_cos(x.lo), __tg_cos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_cos_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x) { + return _simd_cos_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x) { + return simd_make_double8(__tg_cos(x.lo), __tg_cos(x.hi)); +} +#endif + + +#pragma mark - acos implementation +static inline SIMD_CFUNC simd_float2 __tg_acos(simd_float2 x) { + return simd_make_float2(__tg_acos(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_acos(simd_float3 x) { + return simd_make_float3(__tg_acos(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_acos_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x) { + return _simd_acos_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x) { + return simd_make_float4(acos(x.x), acos(x.y), acos(x.z), acos(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_acos_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x) { + return _simd_acos_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x) { + return simd_make_float8(__tg_acos(x.lo), __tg_acos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_acos_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x) { + return _simd_acos_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x) { + return simd_make_float16(__tg_acos(x.lo), __tg_acos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_acos_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x) { + return _simd_acos_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x) { + return simd_make_double2(acos(x.x), acos(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_acos(simd_double3 x) { + return simd_make_double3(__tg_acos(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_acos_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x) { + return _simd_acos_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x) { + return simd_make_double4(__tg_acos(x.lo), __tg_acos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_acos_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x) { + return _simd_acos_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x) { + return simd_make_double8(__tg_acos(x.lo), __tg_acos(x.hi)); +} +#endif + +#pragma mark - asin implementation +static inline SIMD_CFUNC simd_float2 __tg_asin(simd_float2 x) { + return simd_make_float2(__tg_asin(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_asin(simd_float3 x) { + return simd_make_float3(__tg_asin(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_asin_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x) { + return _simd_asin_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x) { + return simd_make_float4(asin(x.x), asin(x.y), asin(x.z), asin(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_asin_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x) { + return _simd_asin_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x) { + return simd_make_float8(__tg_asin(x.lo), __tg_asin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_asin_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x) { + return _simd_asin_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x) { + return simd_make_float16(__tg_asin(x.lo), __tg_asin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_asin_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x) { + return _simd_asin_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x) { + return simd_make_double2(asin(x.x), asin(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_asin(simd_double3 x) { + return simd_make_double3(__tg_asin(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_asin_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x) { + return _simd_asin_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x) { + return simd_make_double4(__tg_asin(x.lo), __tg_asin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_asin_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x) { + return _simd_asin_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x) { + return simd_make_double8(__tg_asin(x.lo), __tg_asin(x.hi)); +} +#endif + +#pragma mark - atan implementation +static inline SIMD_CFUNC simd_float2 __tg_atan(simd_float2 x) { + return simd_make_float2(__tg_atan(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_atan(simd_float3 x) { + return simd_make_float3(__tg_atan(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_atan_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x) { + return _simd_atan_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x) { + return simd_make_float4(atan(x.x), atan(x.y), atan(x.z), atan(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_atan_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x) { + return _simd_atan_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x) { + return simd_make_float8(__tg_atan(x.lo), __tg_atan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_atan_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x) { + return _simd_atan_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x) { + return simd_make_float16(__tg_atan(x.lo), __tg_atan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_atan_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x) { + return _simd_atan_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x) { + return simd_make_double2(atan(x.x), atan(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_atan(simd_double3 x) { + return simd_make_double3(__tg_atan(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_atan_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x) { + return _simd_atan_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x) { + return simd_make_double4(__tg_atan(x.lo), __tg_atan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_atan_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x) { + return _simd_atan_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x) { + return simd_make_double8(__tg_atan(x.lo), __tg_atan(x.hi)); +} +#endif + +#pragma mark - tan implementation +static inline SIMD_CFUNC simd_float2 __tg_tan(simd_float2 x) { + return simd_make_float2(__tg_tan(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_tan(simd_float3 x) { + return simd_make_float3(__tg_tan(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_tan_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x) { + return _simd_tan_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x) { + return simd_make_float4(tan(x.x), tan(x.y), tan(x.z), tan(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_tan_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x) { + return _simd_tan_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x) { + return simd_make_float8(__tg_tan(x.lo), __tg_tan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_tan_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x) { + return _simd_tan_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x) { + return simd_make_float16(__tg_tan(x.lo), __tg_tan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_tan_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x) { + return _simd_tan_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x) { + return simd_make_double2(tan(x.x), tan(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_tan(simd_double3 x) { + return simd_make_double3(__tg_tan(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_tan_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x) { + return _simd_tan_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x) { + return simd_make_double4(__tg_tan(x.lo), __tg_tan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_tan_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x) { + return _simd_tan_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x) { + return simd_make_double8(__tg_tan(x.lo), __tg_tan(x.hi)); +} +#endif + +#pragma mark - cospi implementation +#if SIMD_LIBRARY_VERSION >= 1 +static inline SIMD_CFUNC simd_float2 __tg_cospi(simd_float2 x) { + return simd_make_float2(__tg_cospi(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_cospi(simd_float3 x) { + return simd_make_float3(__tg_cospi(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_cospi_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x) { + return _simd_cospi_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x) { + return simd_make_float4(__cospi(x.x), __cospi(x.y), __cospi(x.z), __cospi(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_cospi_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x) { + return _simd_cospi_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x) { + return simd_make_float8(__tg_cospi(x.lo), __tg_cospi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_cospi_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x) { + return _simd_cospi_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x) { + return simd_make_float16(__tg_cospi(x.lo), __tg_cospi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_cospi_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x) { + return _simd_cospi_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x) { + return simd_make_double2(__cospi(x.x), __cospi(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_cospi(simd_double3 x) { + return simd_make_double3(__tg_cospi(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_cospi_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x) { + return _simd_cospi_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x) { + return simd_make_double4(__tg_cospi(x.lo), __tg_cospi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_cospi_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x) { + return _simd_cospi_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x) { + return simd_make_double8(__tg_cospi(x.lo), __tg_cospi(x.hi)); +} +#endif + +#endif /* SIMD_LIBRARY_VERSION */ +#pragma mark - sinpi implementation +#if SIMD_LIBRARY_VERSION >= 1 +static inline SIMD_CFUNC simd_float2 __tg_sinpi(simd_float2 x) { + return simd_make_float2(__tg_sinpi(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_sinpi(simd_float3 x) { + return simd_make_float3(__tg_sinpi(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_sinpi_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x) { + return _simd_sinpi_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x) { + return simd_make_float4(__sinpi(x.x), __sinpi(x.y), __sinpi(x.z), __sinpi(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_sinpi_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x) { + return _simd_sinpi_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x) { + return simd_make_float8(__tg_sinpi(x.lo), __tg_sinpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_sinpi_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x) { + return _simd_sinpi_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x) { + return simd_make_float16(__tg_sinpi(x.lo), __tg_sinpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_sinpi_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x) { + return _simd_sinpi_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x) { + return simd_make_double2(__sinpi(x.x), __sinpi(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_sinpi(simd_double3 x) { + return simd_make_double3(__tg_sinpi(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_sinpi_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x) { + return _simd_sinpi_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x) { + return simd_make_double4(__tg_sinpi(x.lo), __tg_sinpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_sinpi_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x) { + return _simd_sinpi_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x) { + return simd_make_double8(__tg_sinpi(x.lo), __tg_sinpi(x.hi)); +} +#endif + +#endif /* SIMD_LIBRARY_VERSION */ +#pragma mark - tanpi implementation +#if SIMD_LIBRARY_VERSION >= 1 +static inline SIMD_CFUNC simd_float2 __tg_tanpi(simd_float2 x) { + return simd_make_float2(__tg_tanpi(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_tanpi(simd_float3 x) { + return simd_make_float3(__tg_tanpi(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_tanpi_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x) { + return _simd_tanpi_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x) { + return simd_make_float4(__tanpi(x.x), __tanpi(x.y), __tanpi(x.z), __tanpi(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_tanpi_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x) { + return _simd_tanpi_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x) { + return simd_make_float8(__tg_tanpi(x.lo), __tg_tanpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_tanpi_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x) { + return _simd_tanpi_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x) { + return simd_make_float16(__tg_tanpi(x.lo), __tg_tanpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_tanpi_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x) { + return _simd_tanpi_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x) { + return simd_make_double2(__tanpi(x.x), __tanpi(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_tanpi(simd_double3 x) { + return simd_make_double3(__tg_tanpi(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_tanpi_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x) { + return _simd_tanpi_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x) { + return simd_make_double4(__tg_tanpi(x.lo), __tg_tanpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_tanpi_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x) { + return _simd_tanpi_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x) { + return simd_make_double8(__tg_tanpi(x.lo), __tg_tanpi(x.hi)); +} +#endif + +#endif /* SIMD_LIBRARY_VERSION */ +#pragma mark - acosh implementation +static inline SIMD_CFUNC simd_float2 __tg_acosh(simd_float2 x) { + return simd_make_float2(__tg_acosh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_acosh(simd_float3 x) { + return simd_make_float3(__tg_acosh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_acosh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x) { + return _simd_acosh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x) { + return simd_make_float4(acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_acosh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x) { + return _simd_acosh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x) { + return simd_make_float8(__tg_acosh(x.lo), __tg_acosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_acosh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x) { + return _simd_acosh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x) { + return simd_make_float16(__tg_acosh(x.lo), __tg_acosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_acosh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x) { + return _simd_acosh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x) { + return simd_make_double2(acosh(x.x), acosh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_acosh(simd_double3 x) { + return simd_make_double3(__tg_acosh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_acosh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x) { + return _simd_acosh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x) { + return simd_make_double4(__tg_acosh(x.lo), __tg_acosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_acosh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x) { + return _simd_acosh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x) { + return simd_make_double8(__tg_acosh(x.lo), __tg_acosh(x.hi)); +} +#endif + +#pragma mark - asinh implementation +static inline SIMD_CFUNC simd_float2 __tg_asinh(simd_float2 x) { + return simd_make_float2(__tg_asinh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_asinh(simd_float3 x) { + return simd_make_float3(__tg_asinh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_asinh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x) { + return _simd_asinh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x) { + return simd_make_float4(asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_asinh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x) { + return _simd_asinh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x) { + return simd_make_float8(__tg_asinh(x.lo), __tg_asinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_asinh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x) { + return _simd_asinh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x) { + return simd_make_float16(__tg_asinh(x.lo), __tg_asinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_asinh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x) { + return _simd_asinh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x) { + return simd_make_double2(asinh(x.x), asinh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_asinh(simd_double3 x) { + return simd_make_double3(__tg_asinh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_asinh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x) { + return _simd_asinh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x) { + return simd_make_double4(__tg_asinh(x.lo), __tg_asinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_asinh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x) { + return _simd_asinh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x) { + return simd_make_double8(__tg_asinh(x.lo), __tg_asinh(x.hi)); +} +#endif + +#pragma mark - atanh implementation +static inline SIMD_CFUNC simd_float2 __tg_atanh(simd_float2 x) { + return simd_make_float2(__tg_atanh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_atanh(simd_float3 x) { + return simd_make_float3(__tg_atanh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_atanh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x) { + return _simd_atanh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x) { + return simd_make_float4(atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_atanh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x) { + return _simd_atanh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x) { + return simd_make_float8(__tg_atanh(x.lo), __tg_atanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_atanh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x) { + return _simd_atanh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x) { + return simd_make_float16(__tg_atanh(x.lo), __tg_atanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_atanh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x) { + return _simd_atanh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x) { + return simd_make_double2(atanh(x.x), atanh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_atanh(simd_double3 x) { + return simd_make_double3(__tg_atanh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_atanh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x) { + return _simd_atanh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x) { + return simd_make_double4(__tg_atanh(x.lo), __tg_atanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_atanh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x) { + return _simd_atanh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x) { + return simd_make_double8(__tg_atanh(x.lo), __tg_atanh(x.hi)); +} +#endif + +#pragma mark - cosh implementation +static inline SIMD_CFUNC simd_float2 __tg_cosh(simd_float2 x) { + return simd_make_float2(__tg_cosh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_cosh(simd_float3 x) { + return simd_make_float3(__tg_cosh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_cosh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x) { + return _simd_cosh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x) { + return simd_make_float4(cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_cosh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x) { + return _simd_cosh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x) { + return simd_make_float8(__tg_cosh(x.lo), __tg_cosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_cosh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x) { + return _simd_cosh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x) { + return simd_make_float16(__tg_cosh(x.lo), __tg_cosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_cosh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x) { + return _simd_cosh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x) { + return simd_make_double2(cosh(x.x), cosh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_cosh(simd_double3 x) { + return simd_make_double3(__tg_cosh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_cosh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x) { + return _simd_cosh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x) { + return simd_make_double4(__tg_cosh(x.lo), __tg_cosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_cosh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x) { + return _simd_cosh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x) { + return simd_make_double8(__tg_cosh(x.lo), __tg_cosh(x.hi)); +} +#endif + +#pragma mark - sinh implementation +static inline SIMD_CFUNC simd_float2 __tg_sinh(simd_float2 x) { + return simd_make_float2(__tg_sinh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_sinh(simd_float3 x) { + return simd_make_float3(__tg_sinh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_sinh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x) { + return _simd_sinh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x) { + return simd_make_float4(sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_sinh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x) { + return _simd_sinh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x) { + return simd_make_float8(__tg_sinh(x.lo), __tg_sinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_sinh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x) { + return _simd_sinh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x) { + return simd_make_float16(__tg_sinh(x.lo), __tg_sinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_sinh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x) { + return _simd_sinh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x) { + return simd_make_double2(sinh(x.x), sinh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_sinh(simd_double3 x) { + return simd_make_double3(__tg_sinh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_sinh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x) { + return _simd_sinh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x) { + return simd_make_double4(__tg_sinh(x.lo), __tg_sinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_sinh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x) { + return _simd_sinh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x) { + return simd_make_double8(__tg_sinh(x.lo), __tg_sinh(x.hi)); +} +#endif + +#pragma mark - tanh implementation +static inline SIMD_CFUNC simd_float2 __tg_tanh(simd_float2 x) { + return simd_make_float2(__tg_tanh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_tanh(simd_float3 x) { + return simd_make_float3(__tg_tanh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_tanh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x) { + return _simd_tanh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x) { + return simd_make_float4(tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_tanh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x) { + return _simd_tanh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x) { + return simd_make_float8(__tg_tanh(x.lo), __tg_tanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_tanh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x) { + return _simd_tanh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x) { + return simd_make_float16(__tg_tanh(x.lo), __tg_tanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_tanh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x) { + return _simd_tanh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x) { + return simd_make_double2(tanh(x.x), tanh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_tanh(simd_double3 x) { + return simd_make_double3(__tg_tanh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_tanh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x) { + return _simd_tanh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x) { + return simd_make_double4(__tg_tanh(x.lo), __tg_tanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_tanh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x) { + return _simd_tanh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x) { + return simd_make_double8(__tg_tanh(x.lo), __tg_tanh(x.hi)); +} +#endif + +#pragma mark - exp implementation +static inline SIMD_CFUNC simd_float2 __tg_exp(simd_float2 x) { + return simd_make_float2(__tg_exp(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_exp(simd_float3 x) { + return simd_make_float3(__tg_exp(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_exp_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x) { + return _simd_exp_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x) { + return simd_make_float4(exp(x.x), exp(x.y), exp(x.z), exp(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_exp_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x) { + return _simd_exp_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x) { + return simd_make_float8(__tg_exp(x.lo), __tg_exp(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_exp_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x) { + return _simd_exp_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x) { + return simd_make_float16(__tg_exp(x.lo), __tg_exp(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_exp_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x) { + return _simd_exp_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x) { + return simd_make_double2(exp(x.x), exp(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_exp(simd_double3 x) { + return simd_make_double3(__tg_exp(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_exp_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x) { + return _simd_exp_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x) { + return simd_make_double4(__tg_exp(x.lo), __tg_exp(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_exp_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x) { + return _simd_exp_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x) { + return simd_make_double8(__tg_exp(x.lo), __tg_exp(x.hi)); +} +#endif + +#pragma mark - exp2 implementation +static inline SIMD_CFUNC simd_float2 __tg_exp2(simd_float2 x) { + return simd_make_float2(__tg_exp2(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_exp2(simd_float3 x) { + return simd_make_float3(__tg_exp2(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_exp2_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x) { + return _simd_exp2_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x) { + return simd_make_float4(exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_exp2_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x) { + return _simd_exp2_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x) { + return simd_make_float8(__tg_exp2(x.lo), __tg_exp2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_exp2_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x) { + return _simd_exp2_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x) { + return simd_make_float16(__tg_exp2(x.lo), __tg_exp2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_exp2_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x) { + return _simd_exp2_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x) { + return simd_make_double2(exp2(x.x), exp2(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_exp2(simd_double3 x) { + return simd_make_double3(__tg_exp2(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_exp2_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x) { + return _simd_exp2_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x) { + return simd_make_double4(__tg_exp2(x.lo), __tg_exp2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_exp2_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x) { + return _simd_exp2_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x) { + return simd_make_double8(__tg_exp2(x.lo), __tg_exp2(x.hi)); +} +#endif + +#pragma mark - exp10 implementation +#if SIMD_LIBRARY_VERSION >= 1 +static inline SIMD_CFUNC simd_float2 __tg_exp10(simd_float2 x) { + return simd_make_float2(__tg_exp10(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_exp10(simd_float3 x) { + return simd_make_float3(__tg_exp10(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_exp10_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x) { + return _simd_exp10_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x) { + return simd_make_float4(__exp10(x.x), __exp10(x.y), __exp10(x.z), __exp10(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_exp10_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x) { + return _simd_exp10_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x) { + return simd_make_float8(__tg_exp10(x.lo), __tg_exp10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_exp10_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x) { + return _simd_exp10_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x) { + return simd_make_float16(__tg_exp10(x.lo), __tg_exp10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_exp10_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x) { + return _simd_exp10_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x) { + return simd_make_double2(__exp10(x.x), __exp10(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_exp10(simd_double3 x) { + return simd_make_double3(__tg_exp10(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_exp10_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x) { + return _simd_exp10_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x) { + return simd_make_double4(__tg_exp10(x.lo), __tg_exp10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_exp10_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x) { + return _simd_exp10_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x) { + return simd_make_double8(__tg_exp10(x.lo), __tg_exp10(x.hi)); +} +#endif + +#endif /* SIMD_LIBRARY_VERSION */ +#pragma mark - expm1 implementation +static inline SIMD_CFUNC simd_float2 __tg_expm1(simd_float2 x) { + return simd_make_float2(__tg_expm1(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_expm1(simd_float3 x) { + return simd_make_float3(__tg_expm1(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_expm1_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x) { + return _simd_expm1_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x) { + return simd_make_float4(expm1(x.x), expm1(x.y), expm1(x.z), expm1(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_expm1_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x) { + return _simd_expm1_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x) { + return simd_make_float8(__tg_expm1(x.lo), __tg_expm1(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_expm1_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x) { + return _simd_expm1_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x) { + return simd_make_float16(__tg_expm1(x.lo), __tg_expm1(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_expm1_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x) { + return _simd_expm1_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x) { + return simd_make_double2(expm1(x.x), expm1(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_expm1(simd_double3 x) { + return simd_make_double3(__tg_expm1(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_expm1_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x) { + return _simd_expm1_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x) { + return simd_make_double4(__tg_expm1(x.lo), __tg_expm1(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_expm1_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x) { + return _simd_expm1_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x) { + return simd_make_double8(__tg_expm1(x.lo), __tg_expm1(x.hi)); +} +#endif + +#pragma mark - log implementation +static inline SIMD_CFUNC simd_float2 __tg_log(simd_float2 x) { + return simd_make_float2(__tg_log(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_log(simd_float3 x) { + return simd_make_float3(__tg_log(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_log_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x) { + return _simd_log_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x) { + return simd_make_float4(log(x.x), log(x.y), log(x.z), log(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_log_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x) { + return _simd_log_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x) { + return simd_make_float8(__tg_log(x.lo), __tg_log(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_log_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x) { + return _simd_log_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x) { + return simd_make_float16(__tg_log(x.lo), __tg_log(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_log_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x) { + return _simd_log_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x) { + return simd_make_double2(log(x.x), log(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_log(simd_double3 x) { + return simd_make_double3(__tg_log(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_log_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x) { + return _simd_log_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x) { + return simd_make_double4(__tg_log(x.lo), __tg_log(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_log_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x) { + return _simd_log_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x) { + return simd_make_double8(__tg_log(x.lo), __tg_log(x.hi)); +} +#endif + +#pragma mark - log2 implementation +static inline SIMD_CFUNC simd_float2 __tg_log2(simd_float2 x) { + return simd_make_float2(__tg_log2(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_log2(simd_float3 x) { + return simd_make_float3(__tg_log2(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_log2_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x) { + return _simd_log2_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x) { + return simd_make_float4(log2(x.x), log2(x.y), log2(x.z), log2(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_log2_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x) { + return _simd_log2_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x) { + return simd_make_float8(__tg_log2(x.lo), __tg_log2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_log2_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x) { + return _simd_log2_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x) { + return simd_make_float16(__tg_log2(x.lo), __tg_log2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_log2_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x) { + return _simd_log2_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x) { + return simd_make_double2(log2(x.x), log2(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_log2(simd_double3 x) { + return simd_make_double3(__tg_log2(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_log2_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x) { + return _simd_log2_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x) { + return simd_make_double4(__tg_log2(x.lo), __tg_log2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_log2_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x) { + return _simd_log2_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x) { + return simd_make_double8(__tg_log2(x.lo), __tg_log2(x.hi)); +} +#endif + +#pragma mark - log10 implementation +static inline SIMD_CFUNC simd_float2 __tg_log10(simd_float2 x) { + return simd_make_float2(__tg_log10(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_log10(simd_float3 x) { + return simd_make_float3(__tg_log10(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_log10_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x) { + return _simd_log10_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x) { + return simd_make_float4(log10(x.x), log10(x.y), log10(x.z), log10(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_log10_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x) { + return _simd_log10_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x) { + return simd_make_float8(__tg_log10(x.lo), __tg_log10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_log10_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x) { + return _simd_log10_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x) { + return simd_make_float16(__tg_log10(x.lo), __tg_log10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_log10_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x) { + return _simd_log10_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x) { + return simd_make_double2(log10(x.x), log10(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_log10(simd_double3 x) { + return simd_make_double3(__tg_log10(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_log10_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x) { + return _simd_log10_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x) { + return simd_make_double4(__tg_log10(x.lo), __tg_log10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_log10_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x) { + return _simd_log10_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x) { + return simd_make_double8(__tg_log10(x.lo), __tg_log10(x.hi)); +} +#endif + +#pragma mark - log1p implementation +static inline SIMD_CFUNC simd_float2 __tg_log1p(simd_float2 x) { + return simd_make_float2(__tg_log1p(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_log1p(simd_float3 x) { + return simd_make_float3(__tg_log1p(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_log1p_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x) { + return _simd_log1p_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x) { + return simd_make_float4(log1p(x.x), log1p(x.y), log1p(x.z), log1p(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_log1p_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x) { + return _simd_log1p_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x) { + return simd_make_float8(__tg_log1p(x.lo), __tg_log1p(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_log1p_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x) { + return _simd_log1p_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x) { + return simd_make_float16(__tg_log1p(x.lo), __tg_log1p(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_log1p_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x) { + return _simd_log1p_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x) { + return simd_make_double2(log1p(x.x), log1p(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_log1p(simd_double3 x) { + return simd_make_double3(__tg_log1p(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_log1p_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x) { + return _simd_log1p_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x) { + return simd_make_double4(__tg_log1p(x.lo), __tg_log1p(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_log1p_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x) { + return _simd_log1p_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x) { + return simd_make_double8(__tg_log1p(x.lo), __tg_log1p(x.hi)); +} +#endif + +#pragma mark - cbrt implementation +static inline SIMD_CFUNC simd_float2 __tg_cbrt(simd_float2 x) { + return simd_make_float2(__tg_cbrt(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_cbrt(simd_float3 x) { + return simd_make_float3(__tg_cbrt(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_cbrt_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x) { + return _simd_cbrt_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x) { + return simd_make_float4(cbrt(x.x), cbrt(x.y), cbrt(x.z), cbrt(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_cbrt_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x) { + return _simd_cbrt_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x) { + return simd_make_float8(__tg_cbrt(x.lo), __tg_cbrt(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_cbrt_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x) { + return _simd_cbrt_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x) { + return simd_make_float16(__tg_cbrt(x.lo), __tg_cbrt(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_cbrt_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x) { + return _simd_cbrt_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x) { + return simd_make_double2(cbrt(x.x), cbrt(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_cbrt(simd_double3 x) { + return simd_make_double3(__tg_cbrt(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_cbrt_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x) { + return _simd_cbrt_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x) { + return simd_make_double4(__tg_cbrt(x.lo), __tg_cbrt(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_cbrt_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x) { + return _simd_cbrt_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x) { + return simd_make_double8(__tg_cbrt(x.lo), __tg_cbrt(x.hi)); +} +#endif + +#pragma mark - erf implementation +static inline SIMD_CFUNC simd_float2 __tg_erf(simd_float2 x) { + return simd_make_float2(__tg_erf(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_erf(simd_float3 x) { + return simd_make_float3(__tg_erf(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_erf_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x) { + return _simd_erf_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x) { + return simd_make_float4(erf(x.x), erf(x.y), erf(x.z), erf(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_erf_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x) { + return _simd_erf_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x) { + return simd_make_float8(__tg_erf(x.lo), __tg_erf(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_erf_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x) { + return _simd_erf_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x) { + return simd_make_float16(__tg_erf(x.lo), __tg_erf(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_erf_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x) { + return _simd_erf_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x) { + return simd_make_double2(erf(x.x), erf(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_erf(simd_double3 x) { + return simd_make_double3(__tg_erf(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_erf_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x) { + return _simd_erf_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x) { + return simd_make_double4(__tg_erf(x.lo), __tg_erf(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_erf_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x) { + return _simd_erf_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x) { + return simd_make_double8(__tg_erf(x.lo), __tg_erf(x.hi)); +} +#endif + +#pragma mark - erfc implementation +static inline SIMD_CFUNC simd_float2 __tg_erfc(simd_float2 x) { + return simd_make_float2(__tg_erfc(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_erfc(simd_float3 x) { + return simd_make_float3(__tg_erfc(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_erfc_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x) { + return _simd_erfc_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x) { + return simd_make_float4(erfc(x.x), erfc(x.y), erfc(x.z), erfc(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_erfc_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x) { + return _simd_erfc_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x) { + return simd_make_float8(__tg_erfc(x.lo), __tg_erfc(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_erfc_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x) { + return _simd_erfc_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x) { + return simd_make_float16(__tg_erfc(x.lo), __tg_erfc(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_erfc_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x) { + return _simd_erfc_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x) { + return simd_make_double2(erfc(x.x), erfc(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_erfc(simd_double3 x) { + return simd_make_double3(__tg_erfc(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_erfc_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x) { + return _simd_erfc_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x) { + return simd_make_double4(__tg_erfc(x.lo), __tg_erfc(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_erfc_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x) { + return _simd_erfc_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x) { + return simd_make_double8(__tg_erfc(x.lo), __tg_erfc(x.hi)); +} +#endif + +#pragma mark - tgamma implementation +static inline SIMD_CFUNC simd_float2 __tg_tgamma(simd_float2 x) { + return simd_make_float2(__tg_tgamma(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_tgamma(simd_float3 x) { + return simd_make_float3(__tg_tgamma(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_tgamma_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x) { + return _simd_tgamma_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x) { + return simd_make_float4(tgamma(x.x), tgamma(x.y), tgamma(x.z), tgamma(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_tgamma_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x) { + return _simd_tgamma_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x) { + return simd_make_float8(__tg_tgamma(x.lo), __tg_tgamma(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_tgamma_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x) { + return _simd_tgamma_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x) { + return simd_make_float16(__tg_tgamma(x.lo), __tg_tgamma(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_tgamma_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x) { + return _simd_tgamma_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x) { + return simd_make_double2(tgamma(x.x), tgamma(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_tgamma(simd_double3 x) { + return simd_make_double3(__tg_tgamma(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_tgamma_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x) { + return _simd_tgamma_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x) { + return simd_make_double4(__tg_tgamma(x.lo), __tg_tgamma(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_tgamma_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x) { + return _simd_tgamma_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x) { + return simd_make_double8(__tg_tgamma(x.lo), __tg_tgamma(x.hi)); +} +#endif + +#pragma mark - round implementation +static inline SIMD_CFUNC simd_float2 __tg_round(simd_float2 x) { + return simd_make_float2(__tg_round(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_round(simd_float3 x) { + return simd_make_float3(__tg_round(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_round_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x) { +#if defined __arm64__ + return vrndaq_f32(x); +#else + return _simd_round_f4(x); +#endif +} +#else +static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x) { + return simd_make_float4(round(x.x), round(x.y), round(x.z), round(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_round_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x) { + return _simd_round_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x) { + return simd_make_float8(__tg_round(x.lo), __tg_round(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_round_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x) { + return _simd_round_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x) { + return simd_make_float16(__tg_round(x.lo), __tg_round(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_round_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x) { +#if defined __arm64__ + return vrndaq_f64(x); +#else + return _simd_round_d2(x); +#endif +} +#else +static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x) { + return simd_make_double2(round(x.x), round(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_round(simd_double3 x) { + return simd_make_double3(__tg_round(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_round_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x) { + return _simd_round_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x) { + return simd_make_double4(__tg_round(x.lo), __tg_round(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_round_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x) { + return _simd_round_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x) { + return simd_make_double8(__tg_round(x.lo), __tg_round(x.hi)); +} +#endif + +#pragma mark - atan2 implementation +static inline SIMD_CFUNC simd_float2 __tg_atan2(simd_float2 y, simd_float2 x) { + return simd_make_float2(__tg_atan2(simd_make_float4(y), simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_atan2(simd_float3 y, simd_float3 x) { + return simd_make_float3(__tg_atan2(simd_make_float4(y), simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_atan2_f4(simd_float4 y, simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x) { + return _simd_atan2_f4(y, x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x) { + return simd_make_float4(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_atan2_f8(simd_float8 y, simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x) { + return _simd_atan2_f8(y, x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x) { + return simd_make_float8(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_atan2_f16(simd_float16 y, simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x) { + return _simd_atan2_f16(y, x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x) { + return simd_make_float16(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_atan2_d2(simd_double2 y, simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x) { + return _simd_atan2_d2(y, x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x) { + return simd_make_double2(atan2(y.x, x.x), atan2(y.y, x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_atan2(simd_double3 y, simd_double3 x) { + return simd_make_double3(__tg_atan2(simd_make_double4(y), simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_atan2_d4(simd_double4 y, simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x) { + return _simd_atan2_d4(y, x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x) { + return simd_make_double4(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_atan2_d8(simd_double8 y, simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x) { + return _simd_atan2_d8(y, x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x) { + return simd_make_double8(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi)); +} +#endif + +#pragma mark - hypot implementation +static inline SIMD_CFUNC simd_float2 __tg_hypot(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_hypot(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_hypot(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_hypot(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_hypot_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y) { + return _simd_hypot_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y) { + return simd_make_float4(hypot(x.x, y.x), hypot(x.y, y.y), hypot(x.z, y.z), hypot(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_hypot_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y) { + return _simd_hypot_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_hypot_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y) { + return _simd_hypot_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_hypot_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y) { + return _simd_hypot_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y) { + return simd_make_double2(hypot(x.x, y.x), hypot(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_hypot(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_hypot(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_hypot_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y) { + return _simd_hypot_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_hypot_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y) { + return _simd_hypot_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi)); +} +#endif + +#pragma mark - pow implementation +static inline SIMD_CFUNC simd_float2 __tg_pow(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_pow(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_pow(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_pow(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_pow_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y) { + return _simd_pow_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y) { + return simd_make_float4(pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_pow_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y) { + return _simd_pow_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_pow_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y) { + return _simd_pow_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_pow_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y) { + return _simd_pow_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y) { + return simd_make_double2(pow(x.x, y.x), pow(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_pow(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_pow(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_pow_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y) { + return _simd_pow_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_pow_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y) { + return _simd_pow_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi)); +} +#endif + +#pragma mark - fmod implementation +static inline SIMD_CFUNC simd_float2 __tg_fmod(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_fmod(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_fmod(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_fmod(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_fmod_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y) { + return _simd_fmod_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y) { + return simd_make_float4(fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z), fmod(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_fmod_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y) { + return _simd_fmod_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_fmod_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y) { + return _simd_fmod_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_fmod_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y) { + return _simd_fmod_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y) { + return simd_make_double2(fmod(x.x, y.x), fmod(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_fmod(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_fmod(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_fmod_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y) { + return _simd_fmod_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_fmod_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y) { + return _simd_fmod_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi)); +} +#endif + +#pragma mark - remainder implementation +static inline SIMD_CFUNC simd_float2 __tg_remainder(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_remainder(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_remainder(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_remainder(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_remainder_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y) { + return _simd_remainder_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y) { + return simd_make_float4(remainder(x.x, y.x), remainder(x.y, y.y), remainder(x.z, y.z), remainder(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_remainder_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y) { + return _simd_remainder_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_remainder_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y) { + return _simd_remainder_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_remainder_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y) { + return _simd_remainder_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y) { + return simd_make_double2(remainder(x.x, y.x), remainder(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_remainder(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_remainder(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_remainder_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y) { + return _simd_remainder_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_remainder_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y) { + return _simd_remainder_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi)); +} +#endif + +#pragma mark - nextafter implementation +static inline SIMD_CFUNC simd_float2 __tg_nextafter(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_nextafter(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_nextafter(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_nextafter(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_nextafter_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y) { + return _simd_nextafter_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y) { + return simd_make_float4(nextafter(x.x, y.x), nextafter(x.y, y.y), nextafter(x.z, y.z), nextafter(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_nextafter_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y) { + return _simd_nextafter_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_nextafter_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y) { + return _simd_nextafter_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_nextafter_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y) { + return _simd_nextafter_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y) { + return simd_make_double2(nextafter(x.x, y.x), nextafter(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_nextafter(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_nextafter(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_nextafter_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y) { + return _simd_nextafter_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_nextafter_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y) { + return _simd_nextafter_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi)); +} +#endif + +static inline SIMD_CFUNC simd_float2 __tg_fdim(simd_float2 x, simd_float2 y) { return simd_bitselect(x-y, 0, x= 3 +extern simd_float4 _simd_fma_f4(simd_float4 x, simd_float4 y, simd_float4 z); +#endif +static inline SIMD_CFUNC simd_float4 __tg_fma(simd_float4 x, simd_float4 y, simd_float4 z) { +#if defined __arm64__ || defined __ARM_VFPV4__ + return vfmaq_f32(z, x, y); +#elif (defined __i386__ || defined __x86_64__) && defined __FMA__ + return _mm_fmadd_ps(x, y, z); +#elif SIMD_LIBRARY_VERSION >= 3 + return _simd_fma_f4(x, y, z); +#else + 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)); +#endif +} + +static inline SIMD_CFUNC simd_float8 __tg_fma(simd_float8 x, simd_float8 y, simd_float8 z) { +#if (defined __i386__ || defined __x86_64__) && defined __FMA__ + return _mm256_fmadd_ps(x, y, z); +#else + return simd_make_float8(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 __tg_fma(simd_float16 x, simd_float16 y, simd_float16 z) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_fmadd_ps(x, y, z); +#else + return simd_make_float16(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi)); +#endif +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_fma_d2(simd_double2 x, simd_double2 y, simd_double2 z); +#endif +static inline SIMD_CFUNC simd_double2 __tg_fma(simd_double2 x, simd_double2 y, simd_double2 z) { +#if defined __arm64__ + return vfmaq_f64(z, x, y); +#elif (defined __i386__ || defined __x86_64__) && defined __FMA__ + return _mm_fmadd_pd(x, y, z); +#elif SIMD_LIBRARY_VERSION >= 3 + return _simd_fma_d2(x, y, z); +#else + return simd_make_double2(fma(x.x, y.x, z.x), fma(x.y, y.y, z.y)); +#endif +} + +static inline SIMD_CFUNC simd_double3 __tg_fma(simd_double3 x, simd_double3 y, simd_double3 z) { + return simd_make_double3(__tg_fma(simd_make_double4(x), simd_make_double4(y), simd_make_double4(z))); +} + +static inline SIMD_CFUNC simd_double4 __tg_fma(simd_double4 x, simd_double4 y, simd_double4 z) { +#if (defined __i386__ || defined __x86_64__) && defined __FMA__ + return _mm256_fmadd_pd(x, y, z); +#else + return simd_make_double4(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi)); +#endif +} + +static inline SIMD_CFUNC simd_double8 __tg_fma(simd_double8 x, simd_double8 y, simd_double8 z) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_fmadd_pd(x, y, z); +#else + return simd_make_double8(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi)); +#endif +} + +static inline SIMD_CFUNC float simd_muladd(float x, float y, float z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float2 simd_muladd(simd_float2 x, simd_float2 y, simd_float2 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float3 simd_muladd(simd_float3 x, simd_float3 y, simd_float3 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float4 simd_muladd(simd_float4 x, simd_float4 y, simd_float4 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float8 simd_muladd(simd_float8 x, simd_float8 y, simd_float8 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float16 simd_muladd(simd_float16 x, simd_float16 y, simd_float16 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC double simd_muladd(double x, double y, double z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_double2 simd_muladd(simd_double2 x, simd_double2 y, simd_double2 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_double3 simd_muladd(simd_double3 x, simd_double3 y, simd_double3 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_double4 simd_muladd(simd_double4 x, simd_double4 y, simd_double4 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_double8 simd_muladd(simd_double8 x, simd_double8 y, simd_double8 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_MATH_HEADER */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/matrix.h b/lib/libc/include/x86_64-macos-gnu/simd/matrix.h new file mode 100644 index 0000000000..6c0941a296 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/matrix.h @@ -0,0 +1,1786 @@ +/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved. + * + * Function Result + * ------------------------------------------------------------------ + * + * simd_diagonal_matrix(x) A square matrix with the vector x + * as its diagonal. + * + * simd_matrix(c0, c1, ... ) A matrix with the specified vectors + * as columns. + * + * simd_matrix_from_rows(r0, r1, ... ) A matrix with the specified vectors + * as rows. + * + * simd_mul(a,x) Scalar product a*x. + * + * simd_linear_combination(a,x,b,y) a*x + b*y. + * + * simd_add(x,y) Macro wrapping linear_combination + * to compute x + y. + * + * simd_sub(x,y) Macro wrapping linear_combination + * to compute x - y. + * + * simd_transpose(x) Transpose of the matrix x. + * + * simd_inverse(x) Inverse of x if x is non-singular. If + * x is singular, the result is undefined. + * + * simd_mul(x,y) If x is a matrix, returns the matrix + * product x*y, where y is either a matrix + * or a column vector. If x is a vector, + * returns the product x*y where x is + * interpreted as a row vector. + * + * simd_equal(x,y) Returns true if and only if every + * element of x is exactly equal to the + * corresponding element of y. + * + * simd_almost_equal_elements(x,y,tol) + * Returns true if and only if for each + * entry xij in x, the corresponding + * element yij in y satisfies + * |xij - yij| <= tol. + * + * simd_almost_equal_elements_relative(x,y,tol) + * Returns true if and only if for each + * entry xij in x, the corresponding + * element yij in y satisfies + * |xij - yij| <= tol*|xij|. + * + * The header also defines a few useful global matrix objects: + * matrix_identity_floatNxM and matrix_identity_doubleNxM, may be used to get + * an identity matrix of the specified size. + * + * In C++, we are able to use namespacing to make the functions more concise; + * we also overload some common arithmetic operators to work with the matrix + * types: + * + * C++ Function Equivalent C Function + * -------------------------------------------------------------------- + * simd::inverse simd_inverse + * simd::transpose simd_transpose + * operator+ simd_add + * operator- simd_sub + * operator+= N/A + * operator-= N/A + * operator* simd_mul or simd_mul + * operator*= simd_mul or simd_mul + * operator== simd_equal + * operator!= !simd_equal + * simd::almost_equal_elements simd_almost_equal_elements + * simd::almost_equal_elements_relative simd_almost_equal_elements_relative + * + * provides constructors for C++ matrix types. + */ + +#ifndef SIMD_MATRIX_HEADER +#define SIMD_MATRIX_HEADER + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include +#include +#include + +#ifdef __cplusplus + extern "C" { +#endif + +extern const simd_float2x2 matrix_identity_float2x2 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +extern const simd_float3x3 matrix_identity_float3x3 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +extern const simd_float4x4 matrix_identity_float4x4 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +extern const simd_double2x2 matrix_identity_double2x2 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +extern const simd_double3x3 matrix_identity_double3x3 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +extern const simd_double4x4 matrix_identity_double4x4 __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); + +static simd_float2x2 SIMD_CFUNC simd_diagonal_matrix(simd_float2 __x); +static simd_float3x3 SIMD_CFUNC simd_diagonal_matrix(simd_float3 __x); +static simd_float4x4 SIMD_CFUNC simd_diagonal_matrix(simd_float4 __x); +static simd_double2x2 SIMD_CFUNC simd_diagonal_matrix(simd_double2 __x); +static simd_double3x3 SIMD_CFUNC simd_diagonal_matrix(simd_double3 __x); +static simd_double4x4 SIMD_CFUNC simd_diagonal_matrix(simd_double4 __x); +#define matrix_from_diagonal simd_diagonal_matrix + +static simd_float2x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1); +static simd_float3x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1, simd_float2 col2); +static simd_float4x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1, simd_float2 col2, simd_float2 col3); +static simd_float2x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1); +static simd_float3x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1, simd_float3 col2); +static simd_float4x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1, simd_float3 col2, simd_float3 col3); +static simd_float2x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1); +static simd_float3x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1, simd_float4 col2); +static simd_float4x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1, simd_float4 col2, simd_float4 col3); +static simd_double2x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1); +static simd_double3x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1, simd_double2 col2); +static simd_double4x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1, simd_double2 col2, simd_double2 col3); +static simd_double2x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1); +static simd_double3x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1, simd_double3 col2); +static simd_double4x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1, simd_double3 col2, simd_double3 col3); +static simd_double2x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1); +static simd_double3x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1, simd_double4 col2); +static simd_double4x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1, simd_double4 col2, simd_double4 col3); +#define matrix_from_columns simd_matrix + +static simd_float2x2 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1); +static simd_float2x3 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1, simd_float2 row2); +static simd_float2x4 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1, simd_float2 row2, simd_float2 row3); +static simd_float3x2 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1); +static simd_float3x3 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1, simd_float3 row2); +static simd_float3x4 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1, simd_float3 row2, simd_float3 row3); +static simd_float4x2 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1); +static simd_float4x3 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1, simd_float4 row2); +static simd_float4x4 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1, simd_float4 row2, simd_float4 row3); +static simd_double2x2 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1); +static simd_double2x3 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1, simd_double2 row2); +static simd_double2x4 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1, simd_double2 row2, simd_double2 row3); +static simd_double3x2 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1); +static simd_double3x3 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1, simd_double3 row2); +static simd_double3x4 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1, simd_double3 row2, simd_double3 row3); +static simd_double4x2 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1); +static simd_double4x3 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1, simd_double4 row2); +static simd_double4x4 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1, simd_double4 row2, simd_double4 row3); +#define matrix_from_rows simd_matrix_from_rows + +static simd_float3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatf q); +static simd_float4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatf q); +static simd_double3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatd q); +static simd_double4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatd q); + +static simd_float2x2 SIMD_CFUNC simd_mul(float __a, simd_float2x2 __x); +static simd_float3x2 SIMD_CFUNC simd_mul(float __a, simd_float3x2 __x); +static simd_float4x2 SIMD_CFUNC simd_mul(float __a, simd_float4x2 __x); +static simd_float2x3 SIMD_CFUNC simd_mul(float __a, simd_float2x3 __x); +static simd_float3x3 SIMD_CFUNC simd_mul(float __a, simd_float3x3 __x); +static simd_float4x3 SIMD_CFUNC simd_mul(float __a, simd_float4x3 __x); +static simd_float2x4 SIMD_CFUNC simd_mul(float __a, simd_float2x4 __x); +static simd_float3x4 SIMD_CFUNC simd_mul(float __a, simd_float3x4 __x); +static simd_float4x4 SIMD_CFUNC simd_mul(float __a, simd_float4x4 __x); +static simd_double2x2 SIMD_CFUNC simd_mul(double __a, simd_double2x2 __x); +static simd_double3x2 SIMD_CFUNC simd_mul(double __a, simd_double3x2 __x); +static simd_double4x2 SIMD_CFUNC simd_mul(double __a, simd_double4x2 __x); +static simd_double2x3 SIMD_CFUNC simd_mul(double __a, simd_double2x3 __x); +static simd_double3x3 SIMD_CFUNC simd_mul(double __a, simd_double3x3 __x); +static simd_double4x3 SIMD_CFUNC simd_mul(double __a, simd_double4x3 __x); +static simd_double2x4 SIMD_CFUNC simd_mul(double __a, simd_double2x4 __x); +static simd_double3x4 SIMD_CFUNC simd_mul(double __a, simd_double3x4 __x); +static simd_double4x4 SIMD_CFUNC simd_mul(double __a, simd_double4x4 __x); + +static simd_float2x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x2 __x, float __b, simd_float2x2 __y); +static simd_float3x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x2 __x, float __b, simd_float3x2 __y); +static simd_float4x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x2 __x, float __b, simd_float4x2 __y); +static simd_float2x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x3 __x, float __b, simd_float2x3 __y); +static simd_float3x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x3 __x, float __b, simd_float3x3 __y); +static simd_float4x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x3 __x, float __b, simd_float4x3 __y); +static simd_float2x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x4 __x, float __b, simd_float2x4 __y); +static simd_float3x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x4 __x, float __b, simd_float3x4 __y); +static simd_float4x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x4 __x, float __b, simd_float4x4 __y); +static simd_double2x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x2 __x, double __b, simd_double2x2 __y); +static simd_double3x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x2 __x, double __b, simd_double3x2 __y); +static simd_double4x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x2 __x, double __b, simd_double4x2 __y); +static simd_double2x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x3 __x, double __b, simd_double2x3 __y); +static simd_double3x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x3 __x, double __b, simd_double3x3 __y); +static simd_double4x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x3 __x, double __b, simd_double4x3 __y); +static simd_double2x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x4 __x, double __b, simd_double2x4 __y); +static simd_double3x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x4 __x, double __b, simd_double3x4 __y); +static simd_double4x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x4 __x, double __b, simd_double4x4 __y); +#define matrix_linear_combination simd_linear_combination + +static simd_float2x2 SIMD_CFUNC simd_add(simd_float2x2 __x, simd_float2x2 __y); +static simd_float3x2 SIMD_CFUNC simd_add(simd_float3x2 __x, simd_float3x2 __y); +static simd_float4x2 SIMD_CFUNC simd_add(simd_float4x2 __x, simd_float4x2 __y); +static simd_float2x3 SIMD_CFUNC simd_add(simd_float2x3 __x, simd_float2x3 __y); +static simd_float3x3 SIMD_CFUNC simd_add(simd_float3x3 __x, simd_float3x3 __y); +static simd_float4x3 SIMD_CFUNC simd_add(simd_float4x3 __x, simd_float4x3 __y); +static simd_float2x4 SIMD_CFUNC simd_add(simd_float2x4 __x, simd_float2x4 __y); +static simd_float3x4 SIMD_CFUNC simd_add(simd_float3x4 __x, simd_float3x4 __y); +static simd_float4x4 SIMD_CFUNC simd_add(simd_float4x4 __x, simd_float4x4 __y); +static simd_double2x2 SIMD_CFUNC simd_add(simd_double2x2 __x, simd_double2x2 __y); +static simd_double3x2 SIMD_CFUNC simd_add(simd_double3x2 __x, simd_double3x2 __y); +static simd_double4x2 SIMD_CFUNC simd_add(simd_double4x2 __x, simd_double4x2 __y); +static simd_double2x3 SIMD_CFUNC simd_add(simd_double2x3 __x, simd_double2x3 __y); +static simd_double3x3 SIMD_CFUNC simd_add(simd_double3x3 __x, simd_double3x3 __y); +static simd_double4x3 SIMD_CFUNC simd_add(simd_double4x3 __x, simd_double4x3 __y); +static simd_double2x4 SIMD_CFUNC simd_add(simd_double2x4 __x, simd_double2x4 __y); +static simd_double3x4 SIMD_CFUNC simd_add(simd_double3x4 __x, simd_double3x4 __y); +static simd_double4x4 SIMD_CFUNC simd_add(simd_double4x4 __x, simd_double4x4 __y); +#define matrix_add simd_add + +static simd_float2x2 SIMD_CFUNC simd_sub(simd_float2x2 __x, simd_float2x2 __y); +static simd_float3x2 SIMD_CFUNC simd_sub(simd_float3x2 __x, simd_float3x2 __y); +static simd_float4x2 SIMD_CFUNC simd_sub(simd_float4x2 __x, simd_float4x2 __y); +static simd_float2x3 SIMD_CFUNC simd_sub(simd_float2x3 __x, simd_float2x3 __y); +static simd_float3x3 SIMD_CFUNC simd_sub(simd_float3x3 __x, simd_float3x3 __y); +static simd_float4x3 SIMD_CFUNC simd_sub(simd_float4x3 __x, simd_float4x3 __y); +static simd_float2x4 SIMD_CFUNC simd_sub(simd_float2x4 __x, simd_float2x4 __y); +static simd_float3x4 SIMD_CFUNC simd_sub(simd_float3x4 __x, simd_float3x4 __y); +static simd_float4x4 SIMD_CFUNC simd_sub(simd_float4x4 __x, simd_float4x4 __y); +static simd_double2x2 SIMD_CFUNC simd_sub(simd_double2x2 __x, simd_double2x2 __y); +static simd_double3x2 SIMD_CFUNC simd_sub(simd_double3x2 __x, simd_double3x2 __y); +static simd_double4x2 SIMD_CFUNC simd_sub(simd_double4x2 __x, simd_double4x2 __y); +static simd_double2x3 SIMD_CFUNC simd_sub(simd_double2x3 __x, simd_double2x3 __y); +static simd_double3x3 SIMD_CFUNC simd_sub(simd_double3x3 __x, simd_double3x3 __y); +static simd_double4x3 SIMD_CFUNC simd_sub(simd_double4x3 __x, simd_double4x3 __y); +static simd_double2x4 SIMD_CFUNC simd_sub(simd_double2x4 __x, simd_double2x4 __y); +static simd_double3x4 SIMD_CFUNC simd_sub(simd_double3x4 __x, simd_double3x4 __y); +static simd_double4x4 SIMD_CFUNC simd_sub(simd_double4x4 __x, simd_double4x4 __y); +#define matrix_sub simd_sub + +static simd_float2x2 SIMD_CFUNC simd_transpose(simd_float2x2 __x); +static simd_float2x3 SIMD_CFUNC simd_transpose(simd_float3x2 __x); +static simd_float2x4 SIMD_CFUNC simd_transpose(simd_float4x2 __x); +static simd_float3x2 SIMD_CFUNC simd_transpose(simd_float2x3 __x); +static simd_float3x3 SIMD_CFUNC simd_transpose(simd_float3x3 __x); +static simd_float3x4 SIMD_CFUNC simd_transpose(simd_float4x3 __x); +static simd_float4x2 SIMD_CFUNC simd_transpose(simd_float2x4 __x); +static simd_float4x3 SIMD_CFUNC simd_transpose(simd_float3x4 __x); +static simd_float4x4 SIMD_CFUNC simd_transpose(simd_float4x4 __x); +static simd_double2x2 SIMD_CFUNC simd_transpose(simd_double2x2 __x); +static simd_double2x3 SIMD_CFUNC simd_transpose(simd_double3x2 __x); +static simd_double2x4 SIMD_CFUNC simd_transpose(simd_double4x2 __x); +static simd_double3x2 SIMD_CFUNC simd_transpose(simd_double2x3 __x); +static simd_double3x3 SIMD_CFUNC simd_transpose(simd_double3x3 __x); +static simd_double3x4 SIMD_CFUNC simd_transpose(simd_double4x3 __x); +static simd_double4x2 SIMD_CFUNC simd_transpose(simd_double2x4 __x); +static simd_double4x3 SIMD_CFUNC simd_transpose(simd_double3x4 __x); +static simd_double4x4 SIMD_CFUNC simd_transpose(simd_double4x4 __x); +#define matrix_transpose simd_transpose + +static float SIMD_CFUNC simd_determinant(simd_float2x2 __x); +static float SIMD_CFUNC simd_determinant(simd_float3x3 __x); +static float SIMD_CFUNC simd_determinant(simd_float4x4 __x); +static double SIMD_CFUNC simd_determinant(simd_double2x2 __x); +static double SIMD_CFUNC simd_determinant(simd_double3x3 __x); +static double SIMD_CFUNC simd_determinant(simd_double4x4 __x); +#define matrix_determinant simd_determinant + +static simd_float2x2 SIMD_CFUNC simd_inverse(simd_float2x2 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +static simd_float3x3 SIMD_CFUNC simd_inverse(simd_float3x3 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +static simd_float4x4 SIMD_CFUNC simd_inverse(simd_float4x4 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +static simd_double2x2 SIMD_CFUNC simd_inverse(simd_double2x2 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +static simd_double3x3 SIMD_CFUNC simd_inverse(simd_double3x3 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +static simd_double4x4 SIMD_CFUNC simd_inverse(simd_double4x4 __x) __API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0)); +#define matrix_invert simd_inverse + +static simd_float2 SIMD_CFUNC simd_mul(simd_float2x2 __x, simd_float2 __y); +static simd_float2 SIMD_CFUNC simd_mul(simd_float3x2 __x, simd_float3 __y); +static simd_float2 SIMD_CFUNC simd_mul(simd_float4x2 __x, simd_float4 __y); +static simd_float3 SIMD_CFUNC simd_mul(simd_float2x3 __x, simd_float2 __y); +static simd_float3 SIMD_CFUNC simd_mul(simd_float3x3 __x, simd_float3 __y); +static simd_float3 SIMD_CFUNC simd_mul(simd_float4x3 __x, simd_float4 __y); +static simd_float4 SIMD_CFUNC simd_mul(simd_float2x4 __x, simd_float2 __y); +static simd_float4 SIMD_CFUNC simd_mul(simd_float3x4 __x, simd_float3 __y); +static simd_float4 SIMD_CFUNC simd_mul(simd_float4x4 __x, simd_float4 __y); +static simd_double2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double2 __y); +static simd_double2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double3 __y); +static simd_double2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double4 __y); +static simd_double3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double2 __y); +static simd_double3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double3 __y); +static simd_double3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double4 __y); +static simd_double4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double2 __y); +static simd_double4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double3 __y); +static simd_double4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double4 __y); +static simd_float2 SIMD_CFUNC simd_mul(simd_float2 __x, simd_float2x2 __y); +static simd_float3 SIMD_CFUNC simd_mul(simd_float2 __x, simd_float3x2 __y); +static simd_float4 SIMD_CFUNC simd_mul(simd_float2 __x, simd_float4x2 __y); +static simd_float2 SIMD_CFUNC simd_mul(simd_float3 __x, simd_float2x3 __y); +static simd_float3 SIMD_CFUNC simd_mul(simd_float3 __x, simd_float3x3 __y); +static simd_float4 SIMD_CFUNC simd_mul(simd_float3 __x, simd_float4x3 __y); +static simd_float2 SIMD_CFUNC simd_mul(simd_float4 __x, simd_float2x4 __y); +static simd_float3 SIMD_CFUNC simd_mul(simd_float4 __x, simd_float3x4 __y); +static simd_float4 SIMD_CFUNC simd_mul(simd_float4 __x, simd_float4x4 __y); +static simd_double2 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double2x2 __y); +static simd_double3 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double3x2 __y); +static simd_double4 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double4x2 __y); +static simd_double2 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double2x3 __y); +static simd_double3 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double3x3 __y); +static simd_double4 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double4x3 __y); +static simd_double2 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double2x4 __y); +static simd_double3 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double3x4 __y); +static simd_double4 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double4x4 __y); +static simd_float2x2 SIMD_CFUNC simd_mul(simd_float2x2 __x, simd_float2x2 __y); +static simd_float3x2 SIMD_CFUNC simd_mul(simd_float2x2 __x, simd_float3x2 __y); +static simd_float4x2 SIMD_CFUNC simd_mul(simd_float2x2 __x, simd_float4x2 __y); +static simd_float2x3 SIMD_CFUNC simd_mul(simd_float2x3 __x, simd_float2x2 __y); +static simd_float3x3 SIMD_CFUNC simd_mul(simd_float2x3 __x, simd_float3x2 __y); +static simd_float4x3 SIMD_CFUNC simd_mul(simd_float2x3 __x, simd_float4x2 __y); +static simd_float2x4 SIMD_CFUNC simd_mul(simd_float2x4 __x, simd_float2x2 __y); +static simd_float3x4 SIMD_CFUNC simd_mul(simd_float2x4 __x, simd_float3x2 __y); +static simd_float4x4 SIMD_CFUNC simd_mul(simd_float2x4 __x, simd_float4x2 __y); +static simd_double2x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double2x2 __y); +static simd_double3x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double3x2 __y); +static simd_double4x2 SIMD_CFUNC simd_mul(simd_double2x2 __x, simd_double4x2 __y); +static simd_double2x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double2x2 __y); +static simd_double3x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double3x2 __y); +static simd_double4x3 SIMD_CFUNC simd_mul(simd_double2x3 __x, simd_double4x2 __y); +static simd_double2x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double2x2 __y); +static simd_double3x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double3x2 __y); +static simd_double4x4 SIMD_CFUNC simd_mul(simd_double2x4 __x, simd_double4x2 __y); +static simd_float2x2 SIMD_CFUNC simd_mul(simd_float3x2 __x, simd_float2x3 __y); +static simd_float3x2 SIMD_CFUNC simd_mul(simd_float3x2 __x, simd_float3x3 __y); +static simd_float4x2 SIMD_CFUNC simd_mul(simd_float3x2 __x, simd_float4x3 __y); +static simd_float2x3 SIMD_CFUNC simd_mul(simd_float3x3 __x, simd_float2x3 __y); +static simd_float3x3 SIMD_CFUNC simd_mul(simd_float3x3 __x, simd_float3x3 __y); +static simd_float4x3 SIMD_CFUNC simd_mul(simd_float3x3 __x, simd_float4x3 __y); +static simd_float2x4 SIMD_CFUNC simd_mul(simd_float3x4 __x, simd_float2x3 __y); +static simd_float3x4 SIMD_CFUNC simd_mul(simd_float3x4 __x, simd_float3x3 __y); +static simd_float4x4 SIMD_CFUNC simd_mul(simd_float3x4 __x, simd_float4x3 __y); +static simd_double2x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double2x3 __y); +static simd_double3x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double3x3 __y); +static simd_double4x2 SIMD_CFUNC simd_mul(simd_double3x2 __x, simd_double4x3 __y); +static simd_double2x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double2x3 __y); +static simd_double3x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double3x3 __y); +static simd_double4x3 SIMD_CFUNC simd_mul(simd_double3x3 __x, simd_double4x3 __y); +static simd_double2x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double2x3 __y); +static simd_double3x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double3x3 __y); +static simd_double4x4 SIMD_CFUNC simd_mul(simd_double3x4 __x, simd_double4x3 __y); +static simd_float2x2 SIMD_CFUNC simd_mul(simd_float4x2 __x, simd_float2x4 __y); +static simd_float3x2 SIMD_CFUNC simd_mul(simd_float4x2 __x, simd_float3x4 __y); +static simd_float4x2 SIMD_CFUNC simd_mul(simd_float4x2 __x, simd_float4x4 __y); +static simd_float2x3 SIMD_CFUNC simd_mul(simd_float4x3 __x, simd_float2x4 __y); +static simd_float3x3 SIMD_CFUNC simd_mul(simd_float4x3 __x, simd_float3x4 __y); +static simd_float4x3 SIMD_CFUNC simd_mul(simd_float4x3 __x, simd_float4x4 __y); +static simd_float2x4 SIMD_CFUNC simd_mul(simd_float4x4 __x, simd_float2x4 __y); +static simd_float3x4 SIMD_CFUNC simd_mul(simd_float4x4 __x, simd_float3x4 __y); +static simd_float4x4 SIMD_CFUNC simd_mul(simd_float4x4 __x, simd_float4x4 __y); +static simd_double2x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double2x4 __y); +static simd_double3x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double3x4 __y); +static simd_double4x2 SIMD_CFUNC simd_mul(simd_double4x2 __x, simd_double4x4 __y); +static simd_double2x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double2x4 __y); +static simd_double3x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double3x4 __y); +static simd_double4x3 SIMD_CFUNC simd_mul(simd_double4x3 __x, simd_double4x4 __y); +static simd_double2x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double2x4 __y); +static simd_double3x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double3x4 __y); +static simd_double4x4 SIMD_CFUNC simd_mul(simd_double4x4 __x, simd_double4x4 __y); + +static simd_bool SIMD_CFUNC simd_equal(simd_float2x2 __x, simd_float2x2 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_float2x3 __x, simd_float2x3 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_float2x4 __x, simd_float2x4 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_float3x2 __x, simd_float3x2 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_float3x3 __x, simd_float3x3 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_float3x4 __x, simd_float3x4 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_float4x2 __x, simd_float4x2 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_float4x3 __x, simd_float4x3 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_float4x4 __x, simd_float4x4 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double2x2 __x, simd_double2x2 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double2x3 __x, simd_double2x3 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double2x4 __x, simd_double2x4 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double3x2 __x, simd_double3x2 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double3x3 __x, simd_double3x3 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double3x4 __x, simd_double3x4 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double4x2 __x, simd_double4x2 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double4x3 __x, simd_double4x3 __y); +static simd_bool SIMD_CFUNC simd_equal(simd_double4x4 __x, simd_double4x4 __y); +#define matrix_equal simd_equal + +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x2 __x, simd_float2x2 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x3 __x, simd_float2x3 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x4 __x, simd_float2x4 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x2 __x, simd_float3x2 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x3 __x, simd_float3x3 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x4 __x, simd_float3x4 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x2 __x, simd_float4x2 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x3 __x, simd_float4x3 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x4 __x, simd_float4x4 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x2 __x, simd_double2x2 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x3 __x, simd_double2x3 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x4 __x, simd_double2x4 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x2 __x, simd_double3x2 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x3 __x, simd_double3x3 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x4 __x, simd_double3x4 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x2 __x, simd_double4x2 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x3 __x, simd_double4x3 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x4 __x, simd_double4x4 __y, double __tol); +#define matrix_almost_equal_elements simd_almost_equal_elements + +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x2 __x, simd_float2x2 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x3 __x, simd_float2x3 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x4 __x, simd_float2x4 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x2 __x, simd_float3x2 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x3 __x, simd_float3x3 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x4 __x, simd_float3x4 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x2 __x, simd_float4x2 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x3 __x, simd_float4x3 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x4 __x, simd_float4x4 __y, float __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x2 __x, simd_double2x2 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x3 __x, simd_double2x3 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x4 __x, simd_double2x4 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x2 __x, simd_double3x2 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x3 __x, simd_double3x3 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x4 __x, simd_double3x4 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x2 __x, simd_double4x2 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x3 __x, simd_double4x3 __y, double __tol); +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x4 __x, simd_double4x4 __y, double __tol); +#define matrix_almost_equal_elements_relative simd_almost_equal_elements_relative + +#ifdef __cplusplus +} /* extern "C" */ + +namespace simd { + static SIMD_CPPFUNC float2x2 operator+(const float2x2 x, const float2x2 y) { return float2x2(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC float2x3 operator+(const float2x3 x, const float2x3 y) { return float2x3(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC float2x4 operator+(const float2x4 x, const float2x4 y) { return float2x4(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC float3x2 operator+(const float3x2 x, const float3x2 y) { return float3x2(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC float3x3 operator+(const float3x3 x, const float3x3 y) { return float3x3(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC float3x4 operator+(const float3x4 x, const float3x4 y) { return float3x4(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC float4x2 operator+(const float4x2 x, const float4x2 y) { return float4x2(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC float4x3 operator+(const float4x3 x, const float4x3 y) { return float4x3(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC float4x4 operator+(const float4x4 x, const float4x4 y) { return float4x4(::simd_linear_combination(1, x, 1, y)); } + + static SIMD_CPPFUNC float2x2 operator-(const float2x2 x, const float2x2 y) { return float2x2(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC float2x3 operator-(const float2x3 x, const float2x3 y) { return float2x3(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC float2x4 operator-(const float2x4 x, const float2x4 y) { return float2x4(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC float3x2 operator-(const float3x2 x, const float3x2 y) { return float3x2(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC float3x3 operator-(const float3x3 x, const float3x3 y) { return float3x3(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC float3x4 operator-(const float3x4 x, const float3x4 y) { return float3x4(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC float4x2 operator-(const float4x2 x, const float4x2 y) { return float4x2(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC float4x3 operator-(const float4x3 x, const float4x3 y) { return float4x3(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC float4x4 operator-(const float4x4 x, const float4x4 y) { return float4x4(::simd_linear_combination(1, x, -1, y)); } + + static SIMD_CPPFUNC float2x2& operator+=(float2x2& x, const float2x2 y) { x = x + y; return x; } + static SIMD_CPPFUNC float2x3& operator+=(float2x3& x, const float2x3 y) { x = x + y; return x; } + static SIMD_CPPFUNC float2x4& operator+=(float2x4& x, const float2x4 y) { x = x + y; return x; } + static SIMD_CPPFUNC float3x2& operator+=(float3x2& x, const float3x2 y) { x = x + y; return x; } + static SIMD_CPPFUNC float3x3& operator+=(float3x3& x, const float3x3 y) { x = x + y; return x; } + static SIMD_CPPFUNC float3x4& operator+=(float3x4& x, const float3x4 y) { x = x + y; return x; } + static SIMD_CPPFUNC float4x2& operator+=(float4x2& x, const float4x2 y) { x = x + y; return x; } + static SIMD_CPPFUNC float4x3& operator+=(float4x3& x, const float4x3 y) { x = x + y; return x; } + static SIMD_CPPFUNC float4x4& operator+=(float4x4& x, const float4x4 y) { x = x + y; return x; } + + static SIMD_CPPFUNC float2x2& operator-=(float2x2& x, const float2x2 y) { x = x - y; return x; } + static SIMD_CPPFUNC float2x3& operator-=(float2x3& x, const float2x3 y) { x = x - y; return x; } + static SIMD_CPPFUNC float2x4& operator-=(float2x4& x, const float2x4 y) { x = x - y; return x; } + static SIMD_CPPFUNC float3x2& operator-=(float3x2& x, const float3x2 y) { x = x - y; return x; } + static SIMD_CPPFUNC float3x3& operator-=(float3x3& x, const float3x3 y) { x = x - y; return x; } + static SIMD_CPPFUNC float3x4& operator-=(float3x4& x, const float3x4 y) { x = x - y; return x; } + static SIMD_CPPFUNC float4x2& operator-=(float4x2& x, const float4x2 y) { x = x - y; return x; } + static SIMD_CPPFUNC float4x3& operator-=(float4x3& x, const float4x3 y) { x = x - y; return x; } + static SIMD_CPPFUNC float4x4& operator-=(float4x4& x, const float4x4 y) { x = x - y; return x; } + + static SIMD_CPPFUNC float2x2 transpose(const float2x2 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC float2x3 transpose(const float3x2 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC float2x4 transpose(const float4x2 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC float3x2 transpose(const float2x3 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC float3x3 transpose(const float3x3 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC float3x4 transpose(const float4x3 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC float4x2 transpose(const float2x4 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC float4x3 transpose(const float3x4 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC float4x4 transpose(const float4x4 x) { return ::simd_transpose(x); } + + static SIMD_CPPFUNC float determinant(const float2x2 x) { return ::simd_determinant(x); } + static SIMD_CPPFUNC float determinant(const float3x3 x) { return ::simd_determinant(x); } + static SIMD_CPPFUNC float determinant(const float4x4 x) { return ::simd_determinant(x); } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgcc-compat" + 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); } + 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); } + 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); } +#pragma clang diagnostic pop + + static SIMD_CPPFUNC float2x2 operator*(const float a, const float2x2 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float2x3 operator*(const float a, const float2x3 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float2x4 operator*(const float a, const float2x4 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float3x2 operator*(const float a, const float3x2 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float3x3 operator*(const float a, const float3x3 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float3x4 operator*(const float a, const float3x4 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float4x2 operator*(const float a, const float4x2 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float4x3 operator*(const float a, const float4x3 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float4x4 operator*(const float a, const float4x4 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float2x2 operator*(const float2x2 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float2x3 operator*(const float2x3 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float2x4 operator*(const float2x4 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float3x2 operator*(const float3x2 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float3x3 operator*(const float3x3 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float3x4 operator*(const float3x4 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float4x2 operator*(const float4x2 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float4x3 operator*(const float4x3 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float4x4 operator*(const float4x4 x, const float a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC float2x2& operator*=(float2x2& x, const float a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC float2x3& operator*=(float2x3& x, const float a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC float2x4& operator*=(float2x4& x, const float a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC float3x2& operator*=(float3x2& x, const float a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC float3x3& operator*=(float3x3& x, const float a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC float3x4& operator*=(float3x4& x, const float a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC float4x2& operator*=(float4x2& x, const float a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC float4x3& operator*=(float4x3& x, const float a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC float4x4& operator*=(float4x4& x, const float a) { x = ::simd_mul(a, x); return x; } + + static SIMD_CPPFUNC float2 operator*(const float2 x, const float2x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3 operator*(const float2 x, const float3x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4 operator*(const float2 x, const float4x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2 operator*(const float3 x, const float2x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3 operator*(const float3 x, const float3x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4 operator*(const float3 x, const float4x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2 operator*(const float4 x, const float2x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3 operator*(const float4 x, const float3x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4 operator*(const float4 x, const float4x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2 operator*(const float2x2 x, const float2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2 operator*(const float3x2 x, const float3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2 operator*(const float4x2 x, const float4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3 operator*(const float2x3 x, const float2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3 operator*(const float3x3 x, const float3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3 operator*(const float4x3 x, const float4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4 operator*(const float2x4 x, const float2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4 operator*(const float3x4 x, const float3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4 operator*(const float4x4 x, const float4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2& operator*=(float2& x, const float2x2 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float3& operator*=(float3& x, const float3x3 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float4& operator*=(float4& x, const float4x4 y) { x = ::simd_mul(x, y); return x; } + + static SIMD_CPPFUNC float2x2 operator*(const float2x2 x, const float2x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x2 operator*(const float2x2 x, const float3x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x2 operator*(const float2x2 x, const float4x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x3 operator*(const float2x3 x, const float2x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x3 operator*(const float2x3 x, const float3x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x3 operator*(const float2x3 x, const float4x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x4 operator*(const float2x4 x, const float2x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x4 operator*(const float2x4 x, const float3x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x4 operator*(const float2x4 x, const float4x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x2 operator*(const float3x2 x, const float2x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x2 operator*(const float3x2 x, const float3x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x2 operator*(const float3x2 x, const float4x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x3 operator*(const float3x3 x, const float2x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x3 operator*(const float3x3 x, const float3x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x3 operator*(const float3x3 x, const float4x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x4 operator*(const float3x4 x, const float2x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x4 operator*(const float3x4 x, const float3x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x4 operator*(const float3x4 x, const float4x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x2 operator*(const float4x2 x, const float2x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x2 operator*(const float4x2 x, const float3x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x2 operator*(const float4x2 x, const float4x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x3 operator*(const float4x3 x, const float2x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x3 operator*(const float4x3 x, const float3x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x3 operator*(const float4x3 x, const float4x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x4 operator*(const float4x4 x, const float2x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float3x4 operator*(const float4x4 x, const float3x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float4x4 operator*(const float4x4 x, const float4x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC float2x2& operator*=(float2x2& x, const float2x2 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float2x3& operator*=(float2x3& x, const float2x2 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float2x4& operator*=(float2x4& x, const float2x2 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float3x2& operator*=(float3x2& x, const float3x3 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float3x3& operator*=(float3x3& x, const float3x3 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float3x4& operator*=(float3x4& x, const float3x3 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float4x2& operator*=(float4x2& x, const float4x4 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float4x3& operator*=(float4x3& x, const float4x4 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC float4x4& operator*=(float4x4& x, const float4x4 y) { x = ::simd_mul(x, y); return x; } + + static SIMD_CPPFUNC bool operator==(const float2x2& x, const float2x2& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const float2x3& x, const float2x3& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const float2x4& x, const float2x4& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const float3x2& x, const float3x2& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const float3x3& x, const float3x3& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const float3x4& x, const float3x4& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const float4x2& x, const float4x2& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const float4x3& x, const float4x3& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const float4x4& x, const float4x4& y) { return ::simd_equal(x, y); } + + static SIMD_CPPFUNC bool operator!=(const float2x2& x, const float2x2& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const float2x3& x, const float2x3& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const float2x4& x, const float2x4& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const float3x2& x, const float3x2& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const float3x3& x, const float3x3& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const float3x4& x, const float3x4& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const float4x2& x, const float4x2& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const float4x3& x, const float4x3& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const float4x4& x, const float4x4& y) { return !(x == y); } + + static SIMD_CPPFUNC bool almost_equal_elements(const float2x2 x, const float2x2 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const float2x3 x, const float2x3 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const float2x4 x, const float2x4 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const float3x2 x, const float3x2 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const float3x3 x, const float3x3 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const float3x4 x, const float3x4 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const float4x2 x, const float4x2 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const float4x3 x, const float4x3 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const float4x4 x, const float4x4 y, const float tol) { return ::simd_almost_equal_elements(x, y, tol); } + + 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); } + 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); } + 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); } + 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); } + 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); } + 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); } + 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); } + 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); } + 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); } + + static SIMD_CPPFUNC double2x2 operator+(const double2x2 x, const double2x2 y) { return double2x2(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC double2x3 operator+(const double2x3 x, const double2x3 y) { return double2x3(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC double2x4 operator+(const double2x4 x, const double2x4 y) { return double2x4(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC double3x2 operator+(const double3x2 x, const double3x2 y) { return double3x2(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC double3x3 operator+(const double3x3 x, const double3x3 y) { return double3x3(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC double3x4 operator+(const double3x4 x, const double3x4 y) { return double3x4(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC double4x2 operator+(const double4x2 x, const double4x2 y) { return double4x2(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC double4x3 operator+(const double4x3 x, const double4x3 y) { return double4x3(::simd_linear_combination(1, x, 1, y)); } + static SIMD_CPPFUNC double4x4 operator+(const double4x4 x, const double4x4 y) { return double4x4(::simd_linear_combination(1, x, 1, y)); } + + static SIMD_CPPFUNC double2x2 operator-(const double2x2 x, const double2x2 y) { return double2x2(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC double2x3 operator-(const double2x3 x, const double2x3 y) { return double2x3(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC double2x4 operator-(const double2x4 x, const double2x4 y) { return double2x4(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC double3x2 operator-(const double3x2 x, const double3x2 y) { return double3x2(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC double3x3 operator-(const double3x3 x, const double3x3 y) { return double3x3(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC double3x4 operator-(const double3x4 x, const double3x4 y) { return double3x4(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC double4x2 operator-(const double4x2 x, const double4x2 y) { return double4x2(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC double4x3 operator-(const double4x3 x, const double4x3 y) { return double4x3(::simd_linear_combination(1, x, -1, y)); } + static SIMD_CPPFUNC double4x4 operator-(const double4x4 x, const double4x4 y) { return double4x4(::simd_linear_combination(1, x, -1, y)); } + + static SIMD_CPPFUNC double2x2& operator+=(double2x2& x, const double2x2 y) { x = x + y; return x; } + static SIMD_CPPFUNC double2x3& operator+=(double2x3& x, const double2x3 y) { x = x + y; return x; } + static SIMD_CPPFUNC double2x4& operator+=(double2x4& x, const double2x4 y) { x = x + y; return x; } + static SIMD_CPPFUNC double3x2& operator+=(double3x2& x, const double3x2 y) { x = x + y; return x; } + static SIMD_CPPFUNC double3x3& operator+=(double3x3& x, const double3x3 y) { x = x + y; return x; } + static SIMD_CPPFUNC double3x4& operator+=(double3x4& x, const double3x4 y) { x = x + y; return x; } + static SIMD_CPPFUNC double4x2& operator+=(double4x2& x, const double4x2 y) { x = x + y; return x; } + static SIMD_CPPFUNC double4x3& operator+=(double4x3& x, const double4x3 y) { x = x + y; return x; } + static SIMD_CPPFUNC double4x4& operator+=(double4x4& x, const double4x4 y) { x = x + y; return x; } + + static SIMD_CPPFUNC double2x2& operator-=(double2x2& x, const double2x2 y) { x = x - y; return x; } + static SIMD_CPPFUNC double2x3& operator-=(double2x3& x, const double2x3 y) { x = x - y; return x; } + static SIMD_CPPFUNC double2x4& operator-=(double2x4& x, const double2x4 y) { x = x - y; return x; } + static SIMD_CPPFUNC double3x2& operator-=(double3x2& x, const double3x2 y) { x = x - y; return x; } + static SIMD_CPPFUNC double3x3& operator-=(double3x3& x, const double3x3 y) { x = x - y; return x; } + static SIMD_CPPFUNC double3x4& operator-=(double3x4& x, const double3x4 y) { x = x - y; return x; } + static SIMD_CPPFUNC double4x2& operator-=(double4x2& x, const double4x2 y) { x = x - y; return x; } + static SIMD_CPPFUNC double4x3& operator-=(double4x3& x, const double4x3 y) { x = x - y; return x; } + static SIMD_CPPFUNC double4x4& operator-=(double4x4& x, const double4x4 y) { x = x - y; return x; } + + static SIMD_CPPFUNC double2x2 transpose(const double2x2 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC double2x3 transpose(const double3x2 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC double2x4 transpose(const double4x2 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC double3x2 transpose(const double2x3 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC double3x3 transpose(const double3x3 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC double3x4 transpose(const double4x3 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC double4x2 transpose(const double2x4 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC double4x3 transpose(const double3x4 x) { return ::simd_transpose(x); } + static SIMD_CPPFUNC double4x4 transpose(const double4x4 x) { return ::simd_transpose(x); } + + static SIMD_CPPFUNC double determinant(const double2x2 x) { return ::simd_determinant(x); } + static SIMD_CPPFUNC double determinant(const double3x3 x) { return ::simd_determinant(x); } + static SIMD_CPPFUNC double determinant(const double4x4 x) { return ::simd_determinant(x); } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgcc-compat" + 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); } + 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); } + 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); } +#pragma clang diagnostic pop + + static SIMD_CPPFUNC double2x2 operator*(const double a, const double2x2 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double2x3 operator*(const double a, const double2x3 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double2x4 operator*(const double a, const double2x4 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double3x2 operator*(const double a, const double3x2 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double3x3 operator*(const double a, const double3x3 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double3x4 operator*(const double a, const double3x4 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double4x2 operator*(const double a, const double4x2 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double4x3 operator*(const double a, const double4x3 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double4x4 operator*(const double a, const double4x4 x) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double2x2 operator*(const double2x2 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double2x3 operator*(const double2x3 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double2x4 operator*(const double2x4 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double3x2 operator*(const double3x2 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double3x3 operator*(const double3x3 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double3x4 operator*(const double3x4 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double4x2 operator*(const double4x2 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double4x3 operator*(const double4x3 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double4x4 operator*(const double4x4 x, const double a) { return ::simd_mul(a, x); } + static SIMD_CPPFUNC double2x2& operator*=(double2x2& x, const double a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC double2x3& operator*=(double2x3& x, const double a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC double2x4& operator*=(double2x4& x, const double a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC double3x2& operator*=(double3x2& x, const double a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC double3x3& operator*=(double3x3& x, const double a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC double3x4& operator*=(double3x4& x, const double a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC double4x2& operator*=(double4x2& x, const double a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC double4x3& operator*=(double4x3& x, const double a) { x = ::simd_mul(a, x); return x; } + static SIMD_CPPFUNC double4x4& operator*=(double4x4& x, const double a) { x = ::simd_mul(a, x); return x; } + + static SIMD_CPPFUNC double2 operator*(const double2 x, const double2x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3 operator*(const double2 x, const double3x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4 operator*(const double2 x, const double4x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2 operator*(const double3 x, const double2x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3 operator*(const double3 x, const double3x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4 operator*(const double3 x, const double4x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2 operator*(const double4 x, const double2x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3 operator*(const double4 x, const double3x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4 operator*(const double4 x, const double4x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2 operator*(const double2x2 x, const double2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2 operator*(const double3x2 x, const double3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2 operator*(const double4x2 x, const double4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3 operator*(const double2x3 x, const double2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3 operator*(const double3x3 x, const double3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3 operator*(const double4x3 x, const double4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4 operator*(const double2x4 x, const double2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4 operator*(const double3x4 x, const double3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4 operator*(const double4x4 x, const double4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2& operator*=(double2& x, const double2x2 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double3& operator*=(double3& x, const double3x3 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double4& operator*=(double4& x, const double4x4 y) { x = ::simd_mul(x, y); return x; } + + static SIMD_CPPFUNC double2x2 operator*(const double2x2 x, const double2x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x2 operator*(const double2x2 x, const double3x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x2 operator*(const double2x2 x, const double4x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x3 operator*(const double2x3 x, const double2x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x3 operator*(const double2x3 x, const double3x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x3 operator*(const double2x3 x, const double4x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x4 operator*(const double2x4 x, const double2x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x4 operator*(const double2x4 x, const double3x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x4 operator*(const double2x4 x, const double4x2 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x2 operator*(const double3x2 x, const double2x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x2 operator*(const double3x2 x, const double3x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x2 operator*(const double3x2 x, const double4x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x3 operator*(const double3x3 x, const double2x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x3 operator*(const double3x3 x, const double3x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x3 operator*(const double3x3 x, const double4x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x4 operator*(const double3x4 x, const double2x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x4 operator*(const double3x4 x, const double3x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x4 operator*(const double3x4 x, const double4x3 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x2 operator*(const double4x2 x, const double2x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x2 operator*(const double4x2 x, const double3x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x2 operator*(const double4x2 x, const double4x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x3 operator*(const double4x3 x, const double2x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x3 operator*(const double4x3 x, const double3x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x3 operator*(const double4x3 x, const double4x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x4 operator*(const double4x4 x, const double2x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double3x4 operator*(const double4x4 x, const double3x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double4x4 operator*(const double4x4 x, const double4x4 y) { return ::simd_mul(x, y); } + static SIMD_CPPFUNC double2x2& operator*=(double2x2& x, const double2x2 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double2x3& operator*=(double2x3& x, const double2x2 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double2x4& operator*=(double2x4& x, const double2x2 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double3x2& operator*=(double3x2& x, const double3x3 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double3x3& operator*=(double3x3& x, const double3x3 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double3x4& operator*=(double3x4& x, const double3x3 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double4x2& operator*=(double4x2& x, const double4x4 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double4x3& operator*=(double4x3& x, const double4x4 y) { x = ::simd_mul(x, y); return x; } + static SIMD_CPPFUNC double4x4& operator*=(double4x4& x, const double4x4 y) { x = ::simd_mul(x, y); return x; } + + static SIMD_CPPFUNC bool operator==(const double2x2& x, const double2x2& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const double2x3& x, const double2x3& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const double2x4& x, const double2x4& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const double3x2& x, const double3x2& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const double3x3& x, const double3x3& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const double3x4& x, const double3x4& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const double4x2& x, const double4x2& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const double4x3& x, const double4x3& y) { return ::simd_equal(x, y); } + static SIMD_CPPFUNC bool operator==(const double4x4& x, const double4x4& y) { return ::simd_equal(x, y); } + + static SIMD_CPPFUNC bool operator!=(const double2x2& x, const double2x2& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const double2x3& x, const double2x3& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const double2x4& x, const double2x4& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const double3x2& x, const double3x2& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const double3x3& x, const double3x3& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const double3x4& x, const double3x4& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const double4x2& x, const double4x2& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const double4x3& x, const double4x3& y) { return !(x == y); } + static SIMD_CPPFUNC bool operator!=(const double4x4& x, const double4x4& y) { return !(x == y); } + + static SIMD_CPPFUNC bool almost_equal_elements(const double2x2 x, const double2x2 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const double2x3 x, const double2x3 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const double2x4 x, const double2x4 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const double3x2 x, const double3x2 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const double3x3 x, const double3x3 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const double3x4 x, const double3x4 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const double4x2 x, const double4x2 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const double4x3 x, const double4x3 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + static SIMD_CPPFUNC bool almost_equal_elements(const double4x4 x, const double4x4 y, const double tol) { return ::simd_almost_equal_elements(x, y, tol); } + + 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); } + 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); } + 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); } + 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); } + 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); } + 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); } + 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); } + 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); } + 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); } +} + +extern "C" { +#endif /* __cplusplus */ + +#pragma mark - Implementation + +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } + +static simd_float2x2 SIMD_CFUNC simd_matrix(simd_float2 col0, simd_float2 col1) { simd_float2x2 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; } +static simd_float2x3 SIMD_CFUNC simd_matrix(simd_float3 col0, simd_float3 col1) { simd_float2x3 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; } +static simd_float2x4 SIMD_CFUNC simd_matrix(simd_float4 col0, simd_float4 col1) { simd_float2x4 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; } +static simd_double2x2 SIMD_CFUNC simd_matrix(simd_double2 col0, simd_double2 col1) { simd_double2x2 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; } +static simd_double2x3 SIMD_CFUNC simd_matrix(simd_double3 col0, simd_double3 col1) { simd_double2x3 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; } +static simd_double2x4 SIMD_CFUNC simd_matrix(simd_double4 col0, simd_double4 col1) { simd_double2x4 __r = { .columns[0] = col0, .columns[1] = col1 }; return __r; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } + +static simd_float2x2 SIMD_CFUNC simd_matrix_from_rows(simd_float2 row0, simd_float2 row1) { return simd_transpose(simd_matrix(row0, row1)); } +static simd_float3x2 SIMD_CFUNC simd_matrix_from_rows(simd_float3 row0, simd_float3 row1) { return simd_transpose(simd_matrix(row0, row1)); } +static simd_float4x2 SIMD_CFUNC simd_matrix_from_rows(simd_float4 row0, simd_float4 row1) { return simd_transpose(simd_matrix(row0, row1)); } +static simd_double2x2 SIMD_CFUNC simd_matrix_from_rows(simd_double2 row0, simd_double2 row1) { return simd_transpose(simd_matrix(row0, row1)); } +static simd_double3x2 SIMD_CFUNC simd_matrix_from_rows(simd_double3 row0, simd_double3 row1) { return simd_transpose(simd_matrix(row0, row1)); } +static simd_double4x2 SIMD_CFUNC simd_matrix_from_rows(simd_double4 row0, simd_double4 row1) { return simd_transpose(simd_matrix(row0, row1)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } +static 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)); } + +static simd_float3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatf q) { + simd_float4x4 r = simd_matrix4x4(q); + return (simd_float3x3){ r.columns[0].xyz, r.columns[1].xyz, r.columns[2].xyz }; +} + +static simd_float4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatf q) { + simd_float4 v = q.vector; + simd_float4x4 r = { + .columns[0] = { 1 - 2*(v.y*v.y + v.z*v.z), + 2*(v.x*v.y + v.z*v.w), + 2*(v.x*v.z - v.y*v.w), 0 }, + .columns[1] = { 2*(v.x*v.y - v.z*v.w), + 1 - 2*(v.z*v.z + v.x*v.x), + 2*(v.y*v.z + v.x*v.w), 0 }, + .columns[2] = { 2*(v.z*v.x + v.y*v.w), + 2*(v.y*v.z - v.x*v.w), + 1 - 2*(v.y*v.y + v.x*v.x), 0 }, + .columns[3] = { 0, 0, 0, 1 } + }; + return r; +} + +static simd_double3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatd q) { + simd_double4x4 r = simd_matrix4x4(q); + return (simd_double3x3){ r.columns[0].xyz, r.columns[1].xyz, r.columns[2].xyz }; +} + +static simd_double4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatd q) { + simd_double4 v = q.vector; + simd_double4x4 r = { + .columns[0] = { 1 - 2*(v.y*v.y + v.z*v.z), + 2*(v.x*v.y + v.z*v.w), + 2*(v.x*v.z - v.y*v.w), 0 }, + .columns[1] = { 2*(v.x*v.y - v.z*v.w), + 1 - 2*(v.z*v.z + v.x*v.x), + 2*(v.y*v.z + v.x*v.w), 0 }, + .columns[2] = { 2*(v.z*v.x + v.y*v.w), + 2*(v.y*v.z - v.x*v.w), + 1 - 2*(v.y*v.y + v.x*v.x), 0 }, + .columns[3] = { 0, 0, 0, 1 } + }; + return r; +} + +static simd_float2x2 SIMD_CFUNC matrix_scale(float __a, simd_float2x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_float2x3 SIMD_CFUNC matrix_scale(float __a, simd_float2x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_float2x4 SIMD_CFUNC matrix_scale(float __a, simd_float2x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_double2x2 SIMD_CFUNC matrix_scale(double __a, simd_double2x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_double2x3 SIMD_CFUNC matrix_scale(double __a, simd_double2x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_double2x4 SIMD_CFUNC matrix_scale(double __a, simd_double2x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } + +static simd_float2x2 SIMD_CFUNC simd_mul(float __a, simd_float2x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_float2x3 SIMD_CFUNC simd_mul(float __a, simd_float2x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_float2x4 SIMD_CFUNC simd_mul(float __a, simd_float2x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_double2x2 SIMD_CFUNC simd_mul(double __a, simd_double2x2 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_double2x3 SIMD_CFUNC simd_mul(double __a, simd_double2x3 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } +static simd_double2x4 SIMD_CFUNC simd_mul(double __a, simd_double2x4 __x) { __x.columns[0] *= __a; __x.columns[1] *= __a; return __x; } +static 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; } +static 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; } + +static simd_float2x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x2 __x, float __b, simd_float2x2 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + return __x; +} +static simd_float3x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x2 __x, float __b, simd_float3x2 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + return __x; +} +static simd_float4x2 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x2 __x, float __b, simd_float4x2 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3]; + return __x; +} +static simd_float2x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x3 __x, float __b, simd_float2x3 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + return __x; +} +static simd_float3x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x3 __x, float __b, simd_float3x3 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + return __x; +} +static simd_float4x3 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x3 __x, float __b, simd_float4x3 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3]; + return __x; +} +static simd_float2x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float2x4 __x, float __b, simd_float2x4 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + return __x; +} +static simd_float3x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float3x4 __x, float __b, simd_float3x4 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + return __x; +} +static simd_float4x4 SIMD_CFUNC simd_linear_combination(float __a, simd_float4x4 __x, float __b, simd_float4x4 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3]; + return __x; +} +static simd_double2x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x2 __x, double __b, simd_double2x2 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + return __x; +} +static simd_double3x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x2 __x, double __b, simd_double3x2 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + return __x; +} +static simd_double4x2 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x2 __x, double __b, simd_double4x2 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3]; + return __x; +} +static simd_double2x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x3 __x, double __b, simd_double2x3 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + return __x; +} +static simd_double3x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x3 __x, double __b, simd_double3x3 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + return __x; +} +static simd_double4x3 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x3 __x, double __b, simd_double4x3 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3]; + return __x; +} +static simd_double2x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double2x4 __x, double __b, simd_double2x4 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + return __x; +} +static simd_double3x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double3x4 __x, double __b, simd_double3x4 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + return __x; +} +static simd_double4x4 SIMD_CFUNC simd_linear_combination(double __a, simd_double4x4 __x, double __b, simd_double4x4 __y) { + __x.columns[0] = __a*__x.columns[0] + __b*__y.columns[0]; + __x.columns[1] = __a*__x.columns[1] + __b*__y.columns[1]; + __x.columns[2] = __a*__x.columns[2] + __b*__y.columns[2]; + __x.columns[3] = __a*__x.columns[3] + __b*__y.columns[3]; + return __x; +} + +static simd_float2x2 SIMD_CFUNC simd_add(simd_float2x2 __x, simd_float2x2 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_float3x2 SIMD_CFUNC simd_add(simd_float3x2 __x, simd_float3x2 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_float4x2 SIMD_CFUNC simd_add(simd_float4x2 __x, simd_float4x2 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_float2x3 SIMD_CFUNC simd_add(simd_float2x3 __x, simd_float2x3 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_float3x3 SIMD_CFUNC simd_add(simd_float3x3 __x, simd_float3x3 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_float4x3 SIMD_CFUNC simd_add(simd_float4x3 __x, simd_float4x3 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_float2x4 SIMD_CFUNC simd_add(simd_float2x4 __x, simd_float2x4 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_float3x4 SIMD_CFUNC simd_add(simd_float3x4 __x, simd_float3x4 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_float4x4 SIMD_CFUNC simd_add(simd_float4x4 __x, simd_float4x4 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double2x2 SIMD_CFUNC simd_add(simd_double2x2 __x, simd_double2x2 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double3x2 SIMD_CFUNC simd_add(simd_double3x2 __x, simd_double3x2 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double4x2 SIMD_CFUNC simd_add(simd_double4x2 __x, simd_double4x2 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double2x3 SIMD_CFUNC simd_add(simd_double2x3 __x, simd_double2x3 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double3x3 SIMD_CFUNC simd_add(simd_double3x3 __x, simd_double3x3 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double4x3 SIMD_CFUNC simd_add(simd_double4x3 __x, simd_double4x3 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double2x4 SIMD_CFUNC simd_add(simd_double2x4 __x, simd_double2x4 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double3x4 SIMD_CFUNC simd_add(simd_double3x4 __x, simd_double3x4 __y) { return simd_linear_combination(1, __x, 1, __y); } +static simd_double4x4 SIMD_CFUNC simd_add(simd_double4x4 __x, simd_double4x4 __y) { return simd_linear_combination(1, __x, 1, __y); } + +static simd_float2x2 SIMD_CFUNC simd_sub(simd_float2x2 __x, simd_float2x2 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_float3x2 SIMD_CFUNC simd_sub(simd_float3x2 __x, simd_float3x2 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_float4x2 SIMD_CFUNC simd_sub(simd_float4x2 __x, simd_float4x2 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_float2x3 SIMD_CFUNC simd_sub(simd_float2x3 __x, simd_float2x3 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_float3x3 SIMD_CFUNC simd_sub(simd_float3x3 __x, simd_float3x3 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_float4x3 SIMD_CFUNC simd_sub(simd_float4x3 __x, simd_float4x3 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_float2x4 SIMD_CFUNC simd_sub(simd_float2x4 __x, simd_float2x4 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_float3x4 SIMD_CFUNC simd_sub(simd_float3x4 __x, simd_float3x4 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_float4x4 SIMD_CFUNC simd_sub(simd_float4x4 __x, simd_float4x4 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double2x2 SIMD_CFUNC simd_sub(simd_double2x2 __x, simd_double2x2 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double3x2 SIMD_CFUNC simd_sub(simd_double3x2 __x, simd_double3x2 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double4x2 SIMD_CFUNC simd_sub(simd_double4x2 __x, simd_double4x2 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double2x3 SIMD_CFUNC simd_sub(simd_double2x3 __x, simd_double2x3 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double3x3 SIMD_CFUNC simd_sub(simd_double3x3 __x, simd_double3x3 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double4x3 SIMD_CFUNC simd_sub(simd_double4x3 __x, simd_double4x3 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double2x4 SIMD_CFUNC simd_sub(simd_double2x4 __x, simd_double2x4 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double3x4 SIMD_CFUNC simd_sub(simd_double3x4 __x, simd_double3x4 __y) { return simd_linear_combination(1, __x, -1, __y); } +static simd_double4x4 SIMD_CFUNC simd_sub(simd_double4x4 __x, simd_double4x4 __y) { return simd_linear_combination(1, __x, -1, __y); } + +static simd_float2x2 SIMD_CFUNC simd_transpose(simd_float2x2 __x) { +#if defined __SSE__ + simd_float4 __x0, __x1; + __x0.xy = __x.columns[0]; + __x1.xy = __x.columns[1]; + simd_float4 __r01 = _mm_unpacklo_ps(__x0, __x1); + return simd_matrix(__r01.lo, __r01.hi); +#else + return simd_matrix((simd_float2){__x.columns[0][0], __x.columns[1][0]}, + (simd_float2){__x.columns[0][1], __x.columns[1][1]}); +#endif +} + +static simd_float3x2 SIMD_CFUNC simd_transpose(simd_float2x3 __x) { +#if defined __SSE__ + simd_float4 __x0, __x1; + __x0.xyz = __x.columns[0]; + __x1.xyz = __x.columns[1]; + simd_float4 __r01 = _mm_unpacklo_ps(__x0, __x1); + simd_float4 __r2x = _mm_unpackhi_ps(__x0, __x1); + return simd_matrix(__r01.lo, __r01.hi, __r2x.lo); +#else + return simd_matrix((simd_float2){__x.columns[0][0], __x.columns[1][0]}, + (simd_float2){__x.columns[0][1], __x.columns[1][1]}, + (simd_float2){__x.columns[0][2], __x.columns[1][2]}); +#endif +} + +static simd_float4x2 SIMD_CFUNC simd_transpose(simd_float2x4 __x) { +#if defined __SSE__ + simd_float4 __r01 = _mm_unpacklo_ps(__x.columns[0], __x.columns[1]); + simd_float4 __r23 = _mm_unpackhi_ps(__x.columns[0], __x.columns[1]); + return simd_matrix(__r01.lo, __r01.hi, __r23.lo, __r23.hi); +#else + return simd_matrix((simd_float2){__x.columns[0][0], __x.columns[1][0]}, + (simd_float2){__x.columns[0][1], __x.columns[1][1]}, + (simd_float2){__x.columns[0][2], __x.columns[1][2]}, + (simd_float2){__x.columns[0][3], __x.columns[1][3]}); +#endif +} + +static simd_float2x3 SIMD_CFUNC simd_transpose(simd_float3x2 __x) { +#if defined __SSE__ + simd_float4 __x0, __x1, __x2; + __x0.xy = __x.columns[0]; + __x1.xy = __x.columns[1]; + __x2.xy = __x.columns[2]; + simd_float4 __t = _mm_unpacklo_ps(__x0, __x1); + simd_float4 __r0 = _mm_shuffle_ps(__t,__x2,0xc4); + simd_float4 __r1 = _mm_shuffle_ps(__t,__x2,0xde); + return simd_matrix(__r0.xyz, __r1.xyz); +#else + return simd_matrix((simd_float3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]}, + (simd_float3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]}); +#endif +} + +static simd_float3x3 SIMD_CFUNC simd_transpose(simd_float3x3 __x) { +#if defined __SSE__ + simd_float4 __x0, __x1, __x2; + __x0.xyz = __x.columns[0]; + __x1.xyz = __x.columns[1]; + __x2.xyz = __x.columns[2]; + simd_float4 __t0 = _mm_unpacklo_ps(__x0, __x1); + simd_float4 __t1 = _mm_unpackhi_ps(__x0, __x1); + simd_float4 __r0 = __t0; __r0.hi = __x2.lo; + simd_float4 __r1 = _mm_shuffle_ps(__t0, __x2, 0xde); + simd_float4 __r2 = __x2; __r2.lo = __t1.lo; + return simd_matrix(__r0.xyz, __r1.xyz, __r2.xyz); +#else + return simd_matrix((simd_float3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]}, + (simd_float3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]}, + (simd_float3){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2]}); +#endif +} + +static simd_float4x3 SIMD_CFUNC simd_transpose(simd_float3x4 __x) { +#if defined __SSE__ + simd_float4 __t0 = _mm_unpacklo_ps(__x.columns[0],__x.columns[1]); /* 00 10 01 11 */ + simd_float4 __t1 = _mm_unpackhi_ps(__x.columns[0],__x.columns[1]); /* 02 12 03 13 */ + simd_float4 __r0 = __t0; __r0.hi = __x.columns[2].lo; + simd_float4 __r1 = _mm_shuffle_ps(__t0, __x.columns[2], 0xde); + simd_float4 __r2 = __x.columns[2]; __r2.lo = __t1.lo; + simd_float4 __r3 = _mm_shuffle_ps(__t1, __x.columns[2], 0xfe); + return simd_matrix(__r0.xyz, __r1.xyz, __r2.xyz, __r3.xyz); +#else + return simd_matrix((simd_float3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]}, + (simd_float3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]}, + (simd_float3){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2]}, + (simd_float3){__x.columns[0][3], __x.columns[1][3], __x.columns[2][3]}); +#endif +} + +static simd_float2x4 SIMD_CFUNC simd_transpose(simd_float4x2 __x) { +#if defined __SSE__ + simd_float4 __x0, __x1, __x2, __x3; + __x0.xy = __x.columns[0]; + __x1.xy = __x.columns[1]; + __x2.xy = __x.columns[2]; + __x3.xy = __x.columns[3]; + simd_float4 __t0 = _mm_unpacklo_ps(__x0,__x2); + simd_float4 __t1 = _mm_unpacklo_ps(__x1,__x3); + simd_float4 __r0 = _mm_unpacklo_ps(__t0,__t1); + simd_float4 __r1 = _mm_unpackhi_ps(__t0,__t1); + return simd_matrix(__r0,__r1); +#else + return simd_matrix((simd_float4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]}, + (simd_float4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]}); +#endif +} + +static simd_float3x4 SIMD_CFUNC simd_transpose(simd_float4x3 __x) { +#if defined __SSE__ + simd_float4 __x0, __x1, __x2, __x3; + __x0.xyz = __x.columns[0]; + __x1.xyz = __x.columns[1]; + __x2.xyz = __x.columns[2]; + __x3.xyz = __x.columns[3]; + simd_float4 __t0 = _mm_unpacklo_ps(__x0,__x2); + simd_float4 __t1 = _mm_unpackhi_ps(__x0,__x2); + simd_float4 __t2 = _mm_unpacklo_ps(__x1,__x3); + simd_float4 __t3 = _mm_unpackhi_ps(__x1,__x3); + simd_float4 __r0 = _mm_unpacklo_ps(__t0,__t2); + simd_float4 __r1 = _mm_unpackhi_ps(__t0,__t2); + simd_float4 __r2 = _mm_unpacklo_ps(__t1,__t3); + return simd_matrix(__r0,__r1,__r2); +#else + return simd_matrix((simd_float4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]}, + (simd_float4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]}, + (simd_float4){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2], __x.columns[3][2]}); +#endif +} + +static simd_float4x4 SIMD_CFUNC simd_transpose(simd_float4x4 __x) { +#if defined __SSE__ + simd_float4 __t0 = _mm_unpacklo_ps(__x.columns[0],__x.columns[2]); + simd_float4 __t1 = _mm_unpackhi_ps(__x.columns[0],__x.columns[2]); + simd_float4 __t2 = _mm_unpacklo_ps(__x.columns[1],__x.columns[3]); + simd_float4 __t3 = _mm_unpackhi_ps(__x.columns[1],__x.columns[3]); + simd_float4 __r0 = _mm_unpacklo_ps(__t0,__t2); + simd_float4 __r1 = _mm_unpackhi_ps(__t0,__t2); + simd_float4 __r2 = _mm_unpacklo_ps(__t1,__t3); + simd_float4 __r3 = _mm_unpackhi_ps(__t1,__t3); + return simd_matrix(__r0,__r1,__r2,__r3); +#else + return simd_matrix((simd_float4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]}, + (simd_float4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]}, + (simd_float4){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2], __x.columns[3][2]}, + (simd_float4){__x.columns[0][3], __x.columns[1][3], __x.columns[2][3], __x.columns[3][3]}); +#endif +} + +static simd_double2x2 SIMD_CFUNC simd_transpose(simd_double2x2 __x) { + return simd_matrix((simd_double2){__x.columns[0][0], __x.columns[1][0]}, + (simd_double2){__x.columns[0][1], __x.columns[1][1]}); +} + +static simd_double3x2 SIMD_CFUNC simd_transpose(simd_double2x3 __x) { + return simd_matrix((simd_double2){__x.columns[0][0], __x.columns[1][0]}, + (simd_double2){__x.columns[0][1], __x.columns[1][1]}, + (simd_double2){__x.columns[0][2], __x.columns[1][2]}); +} + +static simd_double4x2 SIMD_CFUNC simd_transpose(simd_double2x4 __x) { + return simd_matrix((simd_double2){__x.columns[0][0], __x.columns[1][0]}, + (simd_double2){__x.columns[0][1], __x.columns[1][1]}, + (simd_double2){__x.columns[0][2], __x.columns[1][2]}, + (simd_double2){__x.columns[0][3], __x.columns[1][3]}); +} + +static simd_double2x3 SIMD_CFUNC simd_transpose(simd_double3x2 __x) { + return simd_matrix((simd_double3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]}, + (simd_double3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]}); +} + +static simd_double3x3 SIMD_CFUNC simd_transpose(simd_double3x3 __x) { + return simd_matrix((simd_double3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]}, + (simd_double3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]}, + (simd_double3){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2]}); +} + +static simd_double4x3 SIMD_CFUNC simd_transpose(simd_double3x4 __x) { + return simd_matrix((simd_double3){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0]}, + (simd_double3){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1]}, + (simd_double3){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2]}, + (simd_double3){__x.columns[0][3], __x.columns[1][3], __x.columns[2][3]}); +} + +static simd_double2x4 SIMD_CFUNC simd_transpose(simd_double4x2 __x) { + return simd_matrix((simd_double4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]}, + (simd_double4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]}); +} + +static simd_double3x4 SIMD_CFUNC simd_transpose(simd_double4x3 __x) { + return simd_matrix((simd_double4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]}, + (simd_double4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]}, + (simd_double4){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2], __x.columns[3][2]}); +} + +static simd_double4x4 SIMD_CFUNC simd_transpose(simd_double4x4 __x) { + return simd_matrix((simd_double4){__x.columns[0][0], __x.columns[1][0], __x.columns[2][0], __x.columns[3][0]}, + (simd_double4){__x.columns[0][1], __x.columns[1][1], __x.columns[2][1], __x.columns[3][1]}, + (simd_double4){__x.columns[0][2], __x.columns[1][2], __x.columns[2][2], __x.columns[3][2]}, + (simd_double4){__x.columns[0][3], __x.columns[1][3], __x.columns[2][3], __x.columns[3][3]}); +} + +static simd_float3 SIMD_CFUNC __rotate1( simd_float3 __x) { return __builtin_shufflevector(__x,__x,1,2,0); } +static simd_float3 SIMD_CFUNC __rotate2( simd_float3 __x) { return __builtin_shufflevector(__x,__x,2,0,1); } +static simd_float4 SIMD_CFUNC __rotate1( simd_float4 __x) { return __builtin_shufflevector(__x,__x,1,2,3,0); } +static simd_float4 SIMD_CFUNC __rotate2( simd_float4 __x) { return __builtin_shufflevector(__x,__x,2,3,0,1); } +static simd_float4 SIMD_CFUNC __rotate3( simd_float4 __x) { return __builtin_shufflevector(__x,__x,3,0,1,2); } +static simd_double3 SIMD_CFUNC __rotate1(simd_double3 __x) { return __builtin_shufflevector(__x,__x,1,2,0); } +static simd_double3 SIMD_CFUNC __rotate2(simd_double3 __x) { return __builtin_shufflevector(__x,__x,2,0,1); } +static simd_double4 SIMD_CFUNC __rotate1(simd_double4 __x) { return __builtin_shufflevector(__x,__x,1,2,3,0); } +static simd_double4 SIMD_CFUNC __rotate2(simd_double4 __x) { return __builtin_shufflevector(__x,__x,2,3,0,1); } +static simd_double4 SIMD_CFUNC __rotate3(simd_double4 __x) { return __builtin_shufflevector(__x,__x,3,0,1,2); } + +static 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]; } +static 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]; } +static 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]))); } +static 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]))); } +static float SIMD_CFUNC simd_determinant( simd_float4x4 __x) { + 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])) + + __rotate2(__x.columns[1])*(__rotate3(__x.columns[2])*__rotate1(__x.columns[3])-__rotate1(__x.columns[2])*__rotate3(__x.columns[3])) + + __rotate3(__x.columns[1])*(__rotate1(__x.columns[2])*__rotate2(__x.columns[3])-__rotate2(__x.columns[2])*__rotate1(__x.columns[3]))); + return simd_reduce_add(codet.even - codet.odd); +} +static double SIMD_CFUNC simd_determinant(simd_double4x4 __x) { + 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])) + + __rotate2(__x.columns[1])*(__rotate3(__x.columns[2])*__rotate1(__x.columns[3])-__rotate1(__x.columns[2])*__rotate3(__x.columns[3])) + + __rotate3(__x.columns[1])*(__rotate1(__x.columns[2])*__rotate2(__x.columns[3])-__rotate2(__x.columns[2])*__rotate1(__x.columns[3]))); + return simd_reduce_add(codet.even - codet.odd); +} + +static simd_float2x2 SIMD_CFUNC simd_inverse( simd_float2x2 __x) { return __invert_f2(__x); } +static simd_float3x3 SIMD_CFUNC simd_inverse( simd_float3x3 __x) { return __invert_f3(__x); } +static simd_float4x4 SIMD_CFUNC simd_inverse( simd_float4x4 __x) { return __invert_f4(__x); } +static simd_double2x2 SIMD_CFUNC simd_inverse(simd_double2x2 __x) { return __invert_d2(__x); } +static simd_double3x3 SIMD_CFUNC simd_inverse(simd_double3x3 __x) { return __invert_d3(__x); } +static simd_double4x4 SIMD_CFUNC simd_inverse(simd_double4x4 __x) { return __invert_d4(__x); } + +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } + +static simd_float2 SIMD_CFUNC simd_mul( simd_float2 __x, simd_float2x2 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_float3 SIMD_CFUNC simd_mul( simd_float2 __x, simd_float3x2 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_float4 SIMD_CFUNC simd_mul( simd_float2 __x, simd_float4x2 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_float2 SIMD_CFUNC simd_mul( simd_float3 __x, simd_float2x3 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_float3 SIMD_CFUNC simd_mul( simd_float3 __x, simd_float3x3 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_float4 SIMD_CFUNC simd_mul( simd_float3 __x, simd_float4x3 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_float2 SIMD_CFUNC simd_mul( simd_float4 __x, simd_float2x4 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_float3 SIMD_CFUNC simd_mul( simd_float4 __x, simd_float3x4 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_float4 SIMD_CFUNC simd_mul( simd_float4 __x, simd_float4x4 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double2 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double2x2 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double3 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double3x2 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double4 SIMD_CFUNC simd_mul(simd_double2 __x, simd_double4x2 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double2 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double2x3 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double3 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double3x3 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double4 SIMD_CFUNC simd_mul(simd_double3 __x, simd_double4x3 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double2 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double2x4 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double3 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double3x4 __y) { return simd_mul(simd_transpose(__y), __x); } +static simd_double4 SIMD_CFUNC simd_mul(simd_double4 __x, simd_double4x4 __y) { return simd_mul(simd_transpose(__y), __x); } + +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } + +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } + +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } +static 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; } + +static simd_float2 SIMD_CFUNC matrix_multiply( simd_float2x2 __x, simd_float2 __y) { return simd_mul(__x, __y); } +static simd_float3 SIMD_CFUNC matrix_multiply( simd_float2x3 __x, simd_float2 __y) { return simd_mul(__x, __y); } +static simd_float4 SIMD_CFUNC matrix_multiply( simd_float2x4 __x, simd_float2 __y) { return simd_mul(__x, __y); } +static simd_float2 SIMD_CFUNC matrix_multiply( simd_float3x2 __x, simd_float3 __y) { return simd_mul(__x, __y); } +static simd_float3 SIMD_CFUNC matrix_multiply( simd_float3x3 __x, simd_float3 __y) { return simd_mul(__x, __y); } +static simd_float4 SIMD_CFUNC matrix_multiply( simd_float3x4 __x, simd_float3 __y) { return simd_mul(__x, __y); } +static simd_float2 SIMD_CFUNC matrix_multiply( simd_float4x2 __x, simd_float4 __y) { return simd_mul(__x, __y); } +static simd_float3 SIMD_CFUNC matrix_multiply( simd_float4x3 __x, simd_float4 __y) { return simd_mul(__x, __y); } +static simd_float4 SIMD_CFUNC matrix_multiply( simd_float4x4 __x, simd_float4 __y) { return simd_mul(__x, __y); } +static simd_double2 SIMD_CFUNC matrix_multiply(simd_double2x2 __x, simd_double2 __y) { return simd_mul(__x, __y); } +static simd_double3 SIMD_CFUNC matrix_multiply(simd_double2x3 __x, simd_double2 __y) { return simd_mul(__x, __y); } +static simd_double4 SIMD_CFUNC matrix_multiply(simd_double2x4 __x, simd_double2 __y) { return simd_mul(__x, __y); } +static simd_double2 SIMD_CFUNC matrix_multiply(simd_double3x2 __x, simd_double3 __y) { return simd_mul(__x, __y); } +static simd_double3 SIMD_CFUNC matrix_multiply(simd_double3x3 __x, simd_double3 __y) { return simd_mul(__x, __y); } +static simd_double4 SIMD_CFUNC matrix_multiply(simd_double3x4 __x, simd_double3 __y) { return simd_mul(__x, __y); } +static simd_double2 SIMD_CFUNC matrix_multiply(simd_double4x2 __x, simd_double4 __y) { return simd_mul(__x, __y); } +static simd_double3 SIMD_CFUNC matrix_multiply(simd_double4x3 __x, simd_double4 __y) { return simd_mul(__x, __y); } +static simd_double4 SIMD_CFUNC matrix_multiply(simd_double4x4 __x, simd_double4 __y) { return simd_mul(__x, __y); } + +static simd_float2 SIMD_CFUNC matrix_multiply( simd_float2 __x, simd_float2x2 __y) { return simd_mul(__x, __y); } +static simd_float3 SIMD_CFUNC matrix_multiply( simd_float2 __x, simd_float3x2 __y) { return simd_mul(__x, __y); } +static simd_float4 SIMD_CFUNC matrix_multiply( simd_float2 __x, simd_float4x2 __y) { return simd_mul(__x, __y); } +static simd_float2 SIMD_CFUNC matrix_multiply( simd_float3 __x, simd_float2x3 __y) { return simd_mul(__x, __y); } +static simd_float3 SIMD_CFUNC matrix_multiply( simd_float3 __x, simd_float3x3 __y) { return simd_mul(__x, __y); } +static simd_float4 SIMD_CFUNC matrix_multiply( simd_float3 __x, simd_float4x3 __y) { return simd_mul(__x, __y); } +static simd_float2 SIMD_CFUNC matrix_multiply( simd_float4 __x, simd_float2x4 __y) { return simd_mul(__x, __y); } +static simd_float3 SIMD_CFUNC matrix_multiply( simd_float4 __x, simd_float3x4 __y) { return simd_mul(__x, __y); } +static simd_float4 SIMD_CFUNC matrix_multiply( simd_float4 __x, simd_float4x4 __y) { return simd_mul(__x, __y); } +static simd_double2 SIMD_CFUNC matrix_multiply(simd_double2 __x, simd_double2x2 __y) { return simd_mul(__x, __y); } +static simd_double3 SIMD_CFUNC matrix_multiply(simd_double2 __x, simd_double3x2 __y) { return simd_mul(__x, __y); } +static simd_double4 SIMD_CFUNC matrix_multiply(simd_double2 __x, simd_double4x2 __y) { return simd_mul(__x, __y); } +static simd_double2 SIMD_CFUNC matrix_multiply(simd_double3 __x, simd_double2x3 __y) { return simd_mul(__x, __y); } +static simd_double3 SIMD_CFUNC matrix_multiply(simd_double3 __x, simd_double3x3 __y) { return simd_mul(__x, __y); } +static simd_double4 SIMD_CFUNC matrix_multiply(simd_double3 __x, simd_double4x3 __y) { return simd_mul(__x, __y); } +static simd_double2 SIMD_CFUNC matrix_multiply(simd_double4 __x, simd_double2x4 __y) { return simd_mul(__x, __y); } +static simd_double3 SIMD_CFUNC matrix_multiply(simd_double4 __x, simd_double3x4 __y) { return simd_mul(__x, __y); } +static simd_double4 SIMD_CFUNC matrix_multiply(simd_double4 __x, simd_double4x4 __y) { return simd_mul(__x, __y); } + +static simd_float2x2 SIMD_CFUNC matrix_multiply( simd_float2x2 __x, simd_float2x2 __y) { return simd_mul(__x, __y); } +static simd_double2x2 SIMD_CFUNC matrix_multiply(simd_double2x2 __x, simd_double2x2 __y) { return simd_mul(__x, __y); } +static simd_float2x3 SIMD_CFUNC matrix_multiply( simd_float2x3 __x, simd_float2x2 __y) { return simd_mul(__x, __y); } +static simd_double2x3 SIMD_CFUNC matrix_multiply(simd_double2x3 __x, simd_double2x2 __y) { return simd_mul(__x, __y); } +static simd_float2x4 SIMD_CFUNC matrix_multiply( simd_float2x4 __x, simd_float2x2 __y) { return simd_mul(__x, __y); } +static simd_double2x4 SIMD_CFUNC matrix_multiply(simd_double2x4 __x, simd_double2x2 __y) { return simd_mul(__x, __y); } +static simd_float2x2 SIMD_CFUNC matrix_multiply( simd_float3x2 __x, simd_float2x3 __y) { return simd_mul(__x, __y); } +static simd_double2x2 SIMD_CFUNC matrix_multiply(simd_double3x2 __x, simd_double2x3 __y) { return simd_mul(__x, __y); } +static simd_float2x3 SIMD_CFUNC matrix_multiply( simd_float3x3 __x, simd_float2x3 __y) { return simd_mul(__x, __y); } +static simd_double2x3 SIMD_CFUNC matrix_multiply(simd_double3x3 __x, simd_double2x3 __y) { return simd_mul(__x, __y); } +static simd_float2x4 SIMD_CFUNC matrix_multiply( simd_float3x4 __x, simd_float2x3 __y) { return simd_mul(__x, __y); } +static simd_double2x4 SIMD_CFUNC matrix_multiply(simd_double3x4 __x, simd_double2x3 __y) { return simd_mul(__x, __y); } +static simd_float2x2 SIMD_CFUNC matrix_multiply( simd_float4x2 __x, simd_float2x4 __y) { return simd_mul(__x, __y); } +static simd_double2x2 SIMD_CFUNC matrix_multiply(simd_double4x2 __x, simd_double2x4 __y) { return simd_mul(__x, __y); } +static simd_float2x3 SIMD_CFUNC matrix_multiply( simd_float4x3 __x, simd_float2x4 __y) { return simd_mul(__x, __y); } +static simd_double2x3 SIMD_CFUNC matrix_multiply(simd_double4x3 __x, simd_double2x4 __y) { return simd_mul(__x, __y); } +static simd_float2x4 SIMD_CFUNC matrix_multiply( simd_float4x4 __x, simd_float2x4 __y) { return simd_mul(__x, __y); } +static simd_double2x4 SIMD_CFUNC matrix_multiply(simd_double4x4 __x, simd_double2x4 __y) { return simd_mul(__x, __y); } + +static simd_float3x2 SIMD_CFUNC matrix_multiply( simd_float2x2 __x, simd_float3x2 __y) { return simd_mul(__x, __y); } +static simd_double3x2 SIMD_CFUNC matrix_multiply(simd_double2x2 __x, simd_double3x2 __y) { return simd_mul(__x, __y); } +static simd_float3x3 SIMD_CFUNC matrix_multiply( simd_float2x3 __x, simd_float3x2 __y) { return simd_mul(__x, __y); } +static simd_double3x3 SIMD_CFUNC matrix_multiply(simd_double2x3 __x, simd_double3x2 __y) { return simd_mul(__x, __y); } +static simd_float3x4 SIMD_CFUNC matrix_multiply( simd_float2x4 __x, simd_float3x2 __y) { return simd_mul(__x, __y); } +static simd_double3x4 SIMD_CFUNC matrix_multiply(simd_double2x4 __x, simd_double3x2 __y) { return simd_mul(__x, __y); } +static simd_float3x2 SIMD_CFUNC matrix_multiply( simd_float3x2 __x, simd_float3x3 __y) { return simd_mul(__x, __y); } +static simd_double3x2 SIMD_CFUNC matrix_multiply(simd_double3x2 __x, simd_double3x3 __y) { return simd_mul(__x, __y); } +static simd_float3x3 SIMD_CFUNC matrix_multiply( simd_float3x3 __x, simd_float3x3 __y) { return simd_mul(__x, __y); } +static simd_double3x3 SIMD_CFUNC matrix_multiply(simd_double3x3 __x, simd_double3x3 __y) { return simd_mul(__x, __y); } +static simd_float3x4 SIMD_CFUNC matrix_multiply( simd_float3x4 __x, simd_float3x3 __y) { return simd_mul(__x, __y); } +static simd_double3x4 SIMD_CFUNC matrix_multiply(simd_double3x4 __x, simd_double3x3 __y) { return simd_mul(__x, __y); } +static simd_float3x2 SIMD_CFUNC matrix_multiply( simd_float4x2 __x, simd_float3x4 __y) { return simd_mul(__x, __y); } +static simd_double3x2 SIMD_CFUNC matrix_multiply(simd_double4x2 __x, simd_double3x4 __y) { return simd_mul(__x, __y); } +static simd_float3x3 SIMD_CFUNC matrix_multiply( simd_float4x3 __x, simd_float3x4 __y) { return simd_mul(__x, __y); } +static simd_double3x3 SIMD_CFUNC matrix_multiply(simd_double4x3 __x, simd_double3x4 __y) { return simd_mul(__x, __y); } +static simd_float3x4 SIMD_CFUNC matrix_multiply( simd_float4x4 __x, simd_float3x4 __y) { return simd_mul(__x, __y); } +static simd_double3x4 SIMD_CFUNC matrix_multiply(simd_double4x4 __x, simd_double3x4 __y) { return simd_mul(__x, __y); } + +static simd_float4x2 SIMD_CFUNC matrix_multiply( simd_float2x2 __x, simd_float4x2 __y) { return simd_mul(__x, __y); } +static simd_double4x2 SIMD_CFUNC matrix_multiply(simd_double2x2 __x, simd_double4x2 __y) { return simd_mul(__x, __y); } +static simd_float4x3 SIMD_CFUNC matrix_multiply( simd_float2x3 __x, simd_float4x2 __y) { return simd_mul(__x, __y); } +static simd_double4x3 SIMD_CFUNC matrix_multiply(simd_double2x3 __x, simd_double4x2 __y) { return simd_mul(__x, __y); } +static simd_float4x4 SIMD_CFUNC matrix_multiply( simd_float2x4 __x, simd_float4x2 __y) { return simd_mul(__x, __y); } +static simd_double4x4 SIMD_CFUNC matrix_multiply(simd_double2x4 __x, simd_double4x2 __y) { return simd_mul(__x, __y); } +static simd_float4x2 SIMD_CFUNC matrix_multiply( simd_float3x2 __x, simd_float4x3 __y) { return simd_mul(__x, __y); } +static simd_double4x2 SIMD_CFUNC matrix_multiply(simd_double3x2 __x, simd_double4x3 __y) { return simd_mul(__x, __y); } +static simd_float4x3 SIMD_CFUNC matrix_multiply( simd_float3x3 __x, simd_float4x3 __y) { return simd_mul(__x, __y); } +static simd_double4x3 SIMD_CFUNC matrix_multiply(simd_double3x3 __x, simd_double4x3 __y) { return simd_mul(__x, __y); } +static simd_float4x4 SIMD_CFUNC matrix_multiply( simd_float3x4 __x, simd_float4x3 __y) { return simd_mul(__x, __y); } +static simd_double4x4 SIMD_CFUNC matrix_multiply(simd_double3x4 __x, simd_double4x3 __y) { return simd_mul(__x, __y); } +static simd_float4x2 SIMD_CFUNC matrix_multiply( simd_float4x2 __x, simd_float4x4 __y) { return simd_mul(__x, __y); } +static simd_double4x2 SIMD_CFUNC matrix_multiply(simd_double4x2 __x, simd_double4x4 __y) { return simd_mul(__x, __y); } +static simd_float4x3 SIMD_CFUNC matrix_multiply( simd_float4x3 __x, simd_float4x4 __y) { return simd_mul(__x, __y); } +static simd_double4x3 SIMD_CFUNC matrix_multiply(simd_double4x3 __x, simd_double4x4 __y) { return simd_mul(__x, __y); } +static simd_float4x4 SIMD_CFUNC matrix_multiply( simd_float4x4 __x, simd_float4x4 __y) { return simd_mul(__x, __y); } +static simd_double4x4 SIMD_CFUNC matrix_multiply(simd_double4x4 __x, simd_double4x4 __y) { return simd_mul(__x, __y); } + +static simd_bool SIMD_CFUNC simd_equal(simd_float2x2 __x, simd_float2x2 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_float2x3 __x, simd_float2x3 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_float2x4 __x, simd_float2x4 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_float3x2 __x, simd_float3x2 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_float3x3 __x, simd_float3x3 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_float3x4 __x, simd_float3x4 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_float4x2 __x, simd_float4x2 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2]) & + (__x.columns[3] == __y.columns[3])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_float4x3 __x, simd_float4x3 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2]) & + (__x.columns[3] == __y.columns[3])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_float4x4 __x, simd_float4x4 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2]) & + (__x.columns[3] == __y.columns[3])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double2x2 __x, simd_double2x2 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double2x3 __x, simd_double2x3 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double2x4 __x, simd_double2x4 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double3x2 __x, simd_double3x2 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double3x3 __x, simd_double3x3 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double3x4 __x, simd_double3x4 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double4x2 __x, simd_double4x2 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2]) & + (__x.columns[3] == __y.columns[3])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double4x3 __x, simd_double4x3 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2]) & + (__x.columns[3] == __y.columns[3])); +} +static simd_bool SIMD_CFUNC simd_equal(simd_double4x4 __x, simd_double4x4 __y) { + return simd_all((__x.columns[0] == __y.columns[0]) & + (__x.columns[1] == __y.columns[1]) & + (__x.columns[2] == __y.columns[2]) & + (__x.columns[3] == __y.columns[3])); +} + +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x2 __x, simd_float2x2 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x3 __x, simd_float2x3 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float2x4 __x, simd_float2x4 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x2 __x, simd_float3x2 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x3 __x, simd_float3x3 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float3x4 __x, simd_float3x4 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x2 __x, simd_float4x2 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x3 __x, simd_float4x3 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_float4x4 __x, simd_float4x4 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x2 __x, simd_double2x2 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x3 __x, simd_double2x3 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double2x4 __x, simd_double2x4 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x2 __x, simd_double3x2 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x3 __x, simd_double3x3 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double3x4 __x, simd_double3x4 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x2 __x, simd_double4x2 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x3 __x, simd_double4x3 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol)); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements(simd_double4x4 __x, simd_double4x4 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol)); +} + +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x2 __x, simd_float2x2 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x3 __x, simd_float2x3 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float2x4 __x, simd_float2x4 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x2 __x, simd_float3x2 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x3 __x, simd_float3x3 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float3x4 __x, simd_float3x4 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x2 __x, simd_float4x2 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x3 __x, simd_float4x3 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_float4x4 __x, simd_float4x4 __y, float __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x2 __x, simd_double2x2 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x3 __x, simd_double2x3 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double2x4 __x, simd_double2x4 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x2 __x, simd_double3x2 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x3 __x, simd_double3x3 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double3x4 __x, simd_double3x4 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x2 __x, simd_double4x2 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x3 __x, simd_double4x3 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3]))); +} +static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x4 __x, simd_double4x4 __y, double __tol) { + return simd_all((__tg_fabs(__x.columns[0] - __y.columns[0]) <= __tol*__tg_fabs(__x.columns[0])) & + (__tg_fabs(__x.columns[1] - __y.columns[1]) <= __tol*__tg_fabs(__x.columns[1])) & + (__tg_fabs(__x.columns[2] - __y.columns[2]) <= __tol*__tg_fabs(__x.columns[2])) & + (__tg_fabs(__x.columns[3] - __y.columns[3]) <= __tol*__tg_fabs(__x.columns[3]))); +} + +#ifdef __cplusplus +} +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* __SIMD_HEADER__ */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/matrix_types.h b/lib/libc/include/x86_64-macos-gnu/simd/matrix_types.h new file mode 100644 index 0000000000..0f2e90df66 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/matrix_types.h @@ -0,0 +1,264 @@ +/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved. + * + * This header defines nine matrix types for each of float and double, which + * are intended for use together with the vector types defined in + * . + * + * For compatibility with common graphics libraries, these matrices are stored + * in column-major order, and implemented as arrays of column vectors. + * Column-major storage order may seem a little strange if you aren't used to + * it, but for most usage the memory layout of the matrices shouldn't matter + * at all; instead you should think of matrices as abstract mathematical + * objects that you use to perform arithmetic without worrying about the + * details of the underlying representation. + * + * WARNING: vectors of length three are internally represented as length four + * vectors with one element of padding (for alignment purposes). This means + * that when a floatNx3 or doubleNx3 is viewed as a vector, it appears to + * have 4*N elements instead of the expected 3*N (with one padding element + * at the end of each column). The matrix elements are laid out in memory + * as follows: + * + * { 0, 1, 2, x, 3, 4, 5, x, ... } + * + * (where the scalar indices used above indicate the conceptual column- + * major storage order). If you aren't monkeying around with the internal + * storage details of matrices, you don't need to worry about this at all. + * Consider this yet another good reason to avoid doing so. */ + +#ifndef SIMD_MATRIX_TYPES_HEADER +#define SIMD_MATRIX_TYPES_HEADER + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES + +/* Matrix types available in C, Objective-C, and C++ */ +typedef simd_float2x2 matrix_float2x2; +typedef simd_float3x2 matrix_float3x2; +typedef simd_float4x2 matrix_float4x2; + +typedef simd_float2x3 matrix_float2x3; +typedef simd_float3x3 matrix_float3x3; +typedef simd_float4x3 matrix_float4x3; + +typedef simd_float2x4 matrix_float2x4; +typedef simd_float3x4 matrix_float3x4; +typedef simd_float4x4 matrix_float4x4; + +typedef simd_double2x2 matrix_double2x2; +typedef simd_double3x2 matrix_double3x2; +typedef simd_double4x2 matrix_double4x2; + +typedef simd_double2x3 matrix_double2x3; +typedef simd_double3x3 matrix_double3x3; +typedef simd_double4x3 matrix_double4x3; + +typedef simd_double2x4 matrix_double2x4; +typedef simd_double3x4 matrix_double3x4; +typedef simd_double4x4 matrix_double4x4; + +#ifdef __cplusplus +#if defined SIMD_MATRIX_HEADER +static simd_float3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatf q); +static simd_float4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatf q); +static simd_double3x3 SIMD_NOINLINE simd_matrix3x3(simd_quatd q); +static simd_double4x4 SIMD_NOINLINE simd_matrix4x4(simd_quatd q); +#endif + +namespace simd { + + struct float2x2 : ::simd_float2x2 { + float2x2() { columns[0] = 0; columns[1] = 0; } +#if __has_feature(cxx_delegating_constructors) + float2x2(float diagonal) : float2x2((float2)diagonal) { } +#endif + float2x2(float2 v) { columns[0] = (float2){v.x,0}; columns[1] = (float2){0,v.y}; } + float2x2(float2 c0, float2 c1) { columns[0] = c0; columns[1] = c1; } + float2x2(::simd_float2x2 m) : ::simd_float2x2(m) { } + }; + + struct float3x2 : ::simd_float3x2 { + float3x2() { columns[0] = 0; columns[1] = 0; columns[2] = 0; } +#if __has_feature(cxx_delegating_constructors) + float3x2(float diagonal) : float3x2((float2)diagonal) { } +#endif + float3x2(float2 v) { columns[0] = (float2){v.x,0}; columns[1] = (float2){0,v.y}; columns[2] = 0; } + float3x2(float2 c0, float2 c1, float2 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; } + float3x2(::simd_float3x2 m) : ::simd_float3x2(m) { } + }; + + struct float4x2 : ::simd_float4x2 { + float4x2() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; } +#if __has_feature(cxx_delegating_constructors) + float4x2(float diagonal) : float4x2((float2)diagonal) { } +#endif + float4x2(float2 v) { columns[0] = (float2){v.x,0}; columns[1] = (float2){0,v.y}; columns[2] = 0; columns[3] = 0; } + float4x2(float2 c0, float2 c1, float2 c2, float2 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; } + float4x2(::simd_float4x2 m) : ::simd_float4x2(m) { } + }; + + struct float2x3 : ::simd_float2x3 { + float2x3() { columns[0] = 0; columns[1] = 0; } +#if __has_feature(cxx_delegating_constructors) + float2x3(float diagonal) : float2x3((float2)diagonal) { } +#endif + float2x3(float2 v) { columns[0] = (float3){v.x,0,0}; columns[1] = (float3){0,v.y,0}; } + float2x3(float3 c0, float3 c1) { columns[0] = c0; columns[1] = c1; } + float2x3(::simd_float2x3 m) : ::simd_float2x3(m) { } + }; + + struct float3x3 : ::simd_float3x3 { + float3x3() { columns[0] = 0; columns[1] = 0; columns[2] = 0; } +#if __has_feature(cxx_delegating_constructors) + float3x3(float diagonal) : float3x3((float3)diagonal) { } +#endif + float3x3(float3 v) { columns[0] = (float3){v.x,0,0}; columns[1] = (float3){0,v.y,0}; columns[2] = (float3){0,0,v.z}; } + float3x3(float3 c0, float3 c1, float3 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; } + float3x3(::simd_float3x3 m) : ::simd_float3x3(m) { } +#if defined SIMD_MATRIX_HEADER + float3x3(::simd_quatf q) : ::simd_float3x3(::simd_matrix3x3(q)) { } +#endif + }; + + struct float4x3 : ::simd_float4x3 { + float4x3() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; } +#if __has_feature(cxx_delegating_constructors) + float4x3(float diagonal) : float4x3((float3)diagonal) { } +#endif + 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; } + float4x3(float3 c0, float3 c1, float3 c2, float3 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; } + float4x3(::simd_float4x3 m) : ::simd_float4x3(m) { } + }; + + struct float2x4 : ::simd_float2x4 { + float2x4() { columns[0] = 0; columns[1] = 0; } +#if __has_feature(cxx_delegating_constructors) + float2x4(float diagonal) : float2x4((float2)diagonal) { } +#endif + float2x4(float2 v) { columns[0] = (float4){v.x,0,0,0}; columns[1] = (float4){0,v.y,0,0}; } + float2x4(float4 c0, float4 c1) { columns[0] = c0; columns[1] = c1; } + float2x4(::simd_float2x4 m) : ::simd_float2x4(m) { } + }; + + struct float3x4 : ::simd_float3x4 { + float3x4() { columns[0] = 0; columns[1] = 0; columns[2] = 0; } +#if __has_feature(cxx_delegating_constructors) + float3x4(float diagonal) : float3x4((float3)diagonal) { } +#endif + 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}; } + float3x4(float4 c0, float4 c1, float4 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; } + float3x4(::simd_float3x4 m) : ::simd_float3x4(m) { } + }; + + struct float4x4 : ::simd_float4x4 { + float4x4() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; } +#if __has_feature(cxx_delegating_constructors) + float4x4(float diagonal) : float4x4((float4)diagonal) { } +#endif + 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}; } + float4x4(float4 c0, float4 c1, float4 c2, float4 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; } + float4x4(::simd_float4x4 m) : ::simd_float4x4(m) { } +#if defined SIMD_MATRIX_HEADER + float4x4(::simd_quatf q) : ::simd_float4x4(::simd_matrix4x4(q)) { } +#endif + }; + + struct double2x2 : ::simd_double2x2 { + double2x2() { columns[0] = 0; columns[1] = 0; } +#if __has_feature(cxx_delegating_constructors) + double2x2(double diagonal) : double2x2((double2)diagonal) { } +#endif + double2x2(double2 v) { columns[0] = (double2){v.x,0}; columns[1] = (double2){0,v.y}; } + double2x2(double2 c0, double2 c1) { columns[0] = c0; columns[1] = c1; } + double2x2(::simd_double2x2 m) : ::simd_double2x2(m) { } + }; + + struct double3x2 : ::simd_double3x2 { + double3x2() { columns[0] = 0; columns[1] = 0; columns[2] = 0; } +#if __has_feature(cxx_delegating_constructors) + double3x2(double diagonal) : double3x2((double2)diagonal) { } +#endif + double3x2(double2 v) { columns[0] = (double2){v.x,0}; columns[1] = (double2){0,v.y}; columns[2] = 0; } + double3x2(double2 c0, double2 c1, double2 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; } + double3x2(::simd_double3x2 m) : ::simd_double3x2(m) { } + }; + + struct double4x2 : ::simd_double4x2 { + double4x2() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; } +#if __has_feature(cxx_delegating_constructors) + double4x2(double diagonal) : double4x2((double2)diagonal) { } +#endif + double4x2(double2 v) { columns[0] = (double2){v.x,0}; columns[1] = (double2){0,v.y}; columns[2] = 0; columns[3] = 0; } + double4x2(double2 c0, double2 c1, double2 c2, double2 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; } + double4x2(::simd_double4x2 m) : ::simd_double4x2(m) { } + }; + + struct double2x3 : ::simd_double2x3 { + double2x3() { columns[0] = 0; columns[1] = 0; } +#if __has_feature(cxx_delegating_constructors) + double2x3(double diagonal) : double2x3((double2)diagonal) { } +#endif + double2x3(double2 v) { columns[0] = (double3){v.x,0,0}; columns[1] = (double3){0,v.y,0}; } + double2x3(double3 c0, double3 c1) { columns[0] = c0; columns[1] = c1; } + double2x3(::simd_double2x3 m) : ::simd_double2x3(m) { } + }; + + struct double3x3 : ::simd_double3x3 { + double3x3() { columns[0] = 0; columns[1] = 0; columns[2] = 0; } +#if __has_feature(cxx_delegating_constructors) + double3x3(double diagonal) : double3x3((double3)diagonal) { } +#endif + double3x3(double3 v) { columns[0] = (double3){v.x,0,0}; columns[1] = (double3){0,v.y,0}; columns[2] = (double3){0,0,v.z}; } + double3x3(double3 c0, double3 c1, double3 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; } + double3x3(::simd_double3x3 m) : ::simd_double3x3(m) { } +#if defined SIMD_MATRIX_HEADER + double3x3(::simd_quatd q) : ::simd_double3x3(::simd_matrix3x3(q)) { } +#endif + }; + + struct double4x3 : ::simd_double4x3 { + double4x3() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; } +#if __has_feature(cxx_delegating_constructors) + double4x3(double diagonal) : double4x3((double3)diagonal) { } +#endif + 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; } + double4x3(double3 c0, double3 c1, double3 c2, double3 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; } + double4x3(::simd_double4x3 m) : ::simd_double4x3(m) { } + }; + + struct double2x4 : ::simd_double2x4 { + double2x4() { columns[0] = 0; columns[1] = 0; } +#if __has_feature(cxx_delegating_constructors) + double2x4(double diagonal) : double2x4((double2)diagonal) { } +#endif + double2x4(double2 v) { columns[0] = (double4){v.x,0,0,0}; columns[1] = (double4){0,v.y,0,0}; } + double2x4(double4 c0, double4 c1) { columns[0] = c0; columns[1] = c1; } + double2x4(::simd_double2x4 m) : ::simd_double2x4(m) { } + }; + + struct double3x4 : ::simd_double3x4 { + double3x4() { columns[0] = 0; columns[1] = 0; columns[2] = 0; } +#if __has_feature(cxx_delegating_constructors) + double3x4(double diagonal) : double3x4((double3)diagonal) { } +#endif + 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}; } + double3x4(double4 c0, double4 c1, double4 c2) { columns[0] = c0; columns[1] = c1; columns[2] = c2; } + double3x4(::simd_double3x4 m) : ::simd_double3x4(m) { } + }; + + struct double4x4 : ::simd_double4x4 { + double4x4() { columns[0] = 0; columns[1] = 0; columns[2] = 0; columns[3] = 0; } +#if __has_feature(cxx_delegating_constructors) + double4x4(double diagonal) : double4x4((double4)diagonal) { } +#endif + 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}; } + double4x4(double4 c0, double4 c1, double4 c2, double4 c3) { columns[0] = c0; columns[1] = c1; columns[2] = c2; columns[3] = c3; } + double4x4(::simd_double4x4 m) : ::simd_double4x4(m) { } +#if defined SIMD_MATRIX_HEADER + double4x4(::simd_quatd q) : ::simd_double4x4(::simd_matrix4x4(q)) { } +#endif + }; +} +#endif /* __cplusplus */ +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_MATRIX_TYPES_HEADER */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/packed.h b/lib/libc/include/x86_64-macos-gnu/simd/packed.h new file mode 100644 index 0000000000..aac9259370 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/packed.h @@ -0,0 +1,1031 @@ +/*! @header + * This header defines fixed size vector types with relaxed alignment. For + * each vector type defined by that is not a 1- or 3- + * element vector, there is a corresponding type defined by this header that + * requires only the alignment matching that of the underlying scalar type. + * + * These types should be used to access buffers that may not be sufficiently + * aligned to allow them to be accessed using the "normal" simd vector types. + * As an example of this usage, suppose that you want to load a vector of + * four floats from an array of floats. The type simd_float4 has sixteen byte + * alignment, whereas an array of floats has only four byte alignment. + * Thus, naively casting a pointer into the array to (simd_float4 *) would + * invoke undefined behavior, and likely produce an alignment fault at + * runtime. Instead, use the corresponding packed type to load from the array: + * + *
+ *  @textblock
+ *  simd_float4 vector = *(packed_simd_float4 *)&array[i];
+ *  // do something with vector ...
+ *  @/textblock
+ *  
+ * + * It's important to note that the packed_ types are only needed to work with + * memory; once the data is loaded, we simply operate on it as usual using + * the simd_float4 type, as illustrated above. + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_PACKED_TYPES +#define SIMD_PACKED_TYPES + +# include +# if SIMD_COMPILER_HAS_REQUIRED_FEATURES +/*! @abstract A vector of two 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::char2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(1))) char simd_packed_char2; + +/*! @abstract A vector of four 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::char4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(1))) char simd_packed_char4; + +/*! @abstract A vector of eight 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ this type is also available as simd::packed::char8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(1))) char simd_packed_char8; + +/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::char16. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(1))) char simd_packed_char16; + +/*! @abstract A vector of thirty-two 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::char32. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(1))) char simd_packed_char32; + +/*! @abstract A vector of sixty-four 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::char64. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(64),__aligned__(1))) char simd_packed_char64; + +/*! @abstract A vector of two 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::uchar2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(1))) unsigned char simd_packed_uchar2; + +/*! @abstract A vector of four 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::uchar4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(1))) unsigned char simd_packed_uchar4; + +/*! @abstract A vector of eight 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::uchar8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(1))) unsigned char simd_packed_uchar8; + +/*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::uchar16. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(1))) unsigned char simd_packed_uchar16; + +/*! @abstract A vector of thirty-two 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::uchar32. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(1))) unsigned char simd_packed_uchar32; + +/*! @abstract A vector of sixty-four 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::uchar64. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(64),__aligned__(1))) unsigned char simd_packed_uchar64; + +/*! @abstract A vector of two 16-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::short2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(2))) short simd_packed_short2; + +/*! @abstract A vector of four 16-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::short4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(2))) short simd_packed_short4; + +/*! @abstract A vector of eight 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::short8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(2))) short simd_packed_short8; + +/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as + * simd::packed::short16. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(2))) short simd_packed_short16; + +/*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers with relaxed alignment. + * @description In C++ this type is also available as + * simd::packed::short32. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(2))) short simd_packed_short32; + +/*! @abstract A vector of two 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::ushort2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(2))) unsigned short simd_packed_ushort2; + +/*! @abstract A vector of four 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::ushort4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(2))) unsigned short simd_packed_ushort4; + +/*! @abstract A vector of eight 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::ushort8. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(2))) unsigned short simd_packed_ushort8; + +/*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::ushort16. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(2))) unsigned short simd_packed_ushort16; + +/*! @abstract A vector of thirty-two 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::ushort32. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(2))) unsigned short simd_packed_ushort32; + +/*! @abstract A vector of two 32-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::int2. The alignment of this type is that of the underlying + * scalar element type, so you can use it to load or store from an array of + * that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) int simd_packed_int2; + +/*! @abstract A vector of four 32-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::int4. The alignment of this type is that of the underlying + * scalar element type, so you can use it to load or store from an array of + * that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) int simd_packed_int4; + +/*! @abstract A vector of eight 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::int8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) int simd_packed_int8; + +/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::int16. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) int simd_packed_int16; + +/*! @abstract A vector of two 32-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::uint2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) unsigned int simd_packed_uint2; + +/*! @abstract A vector of four 32-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::uint4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) unsigned int simd_packed_uint4; + +/*! @abstract A vector of eight 32-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::uint8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) unsigned int simd_packed_uint8; + +/*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::uint16. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) unsigned int simd_packed_uint16; + +/*! @abstract A vector of two 32-bit floating-point numbers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::float2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) float simd_packed_float2; + +/*! @abstract A vector of four 32-bit floating-point numbers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::float4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) float simd_packed_float4; + +/*! @abstract A vector of eight 32-bit floating-point numbers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::float8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) float simd_packed_float8; + +/*! @abstract A vector of sixteen 32-bit floating-point numbers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::float16. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) float simd_packed_float16; + +/*! @abstract A vector of two 64-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::long2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) simd_long1 simd_packed_long2; +#else +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) simd_long1 simd_packed_long2; +#endif + +/*! @abstract A vector of four 64-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::long4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) simd_long1 simd_packed_long4; +#else +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) simd_long1 simd_packed_long4; +#endif + +/*! @abstract A vector of eight 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::long8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) simd_long1 simd_packed_long8; +#else +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) simd_long1 simd_packed_long8; +#endif + +/*! @abstract A vector of two 64-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::ulong2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) simd_ulong1 simd_packed_ulong2; +#else +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) simd_ulong1 simd_packed_ulong2; +#endif + +/*! @abstract A vector of four 64-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::ulong4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) simd_ulong1 simd_packed_ulong4; +#else +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) simd_ulong1 simd_packed_ulong4; +#endif + +/*! @abstract A vector of eight 64-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::ulong8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) simd_ulong1 simd_packed_ulong8; +#else +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) simd_ulong1 simd_packed_ulong8; +#endif + +/*! @abstract A vector of two 64-bit floating-point numbers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::double2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) double simd_packed_double2; +#else +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) double simd_packed_double2; +#endif + +/*! @abstract A vector of four 64-bit floating-point numbers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::double4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) double simd_packed_double4; +#else +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) double simd_packed_double4; +#endif + +/*! @abstract A vector of eight 64-bit floating-point numbers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::double8. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) double simd_packed_double8; +#else +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) double simd_packed_double8; +#endif + +/* MARK: C++ vector types */ +#if defined __cplusplus +namespace simd { + namespace packed { + /*! @abstract A vector of two 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_char2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_char2 char2; + + /*! @abstract A vector of four 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_char4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_char4 char4; + + /*! @abstract A vector of eight 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_char8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_char8 char8; + + /*! @abstract A vector of sixteen 8-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_char16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_char16 char16; + + /*! @abstract A vector of thirty-two 8-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_char32. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_char32 char32; + + /*! @abstract A vector of sixty-four 8-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_char64. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_char64 char64; + + /*! @abstract A vector of two 8-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_uchar2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_uchar2 uchar2; + + /*! @abstract A vector of four 8-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_uchar4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_uchar4 uchar4; + + /*! @abstract A vector of eight 8-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uchar8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uchar8 uchar8; + + /*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uchar16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uchar16 uchar16; + + /*! @abstract A vector of thirty-two 8-bit unsigned integers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uchar32. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uchar32 uchar32; + + /*! @abstract A vector of sixty-four 8-bit unsigned integers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uchar64. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uchar64 uchar64; + + /*! @abstract A vector of two 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_short2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_short2 short2; + + /*! @abstract A vector of four 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_short4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_short4 short4; + + /*! @abstract A vector of eight 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_short8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_short8 short8; + + /*! @abstract A vector of sixteen 16-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_short16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_short16 short16; + + /*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_short32. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_short32 short32; + + /*! @abstract A vector of two 16-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_ushort2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_ushort2 ushort2; + + /*! @abstract A vector of four 16-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_ushort4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_ushort4 ushort4; + + /*! @abstract A vector of eight 16-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_ushort8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_ushort8 ushort8; + + /*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_ushort16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_ushort16 ushort16; + + /*! @abstract A vector of thirty-two 16-bit unsigned integers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_ushort32. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_ushort32 ushort32; + + /*! @abstract A vector of two 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_int2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_int2 int2; + + /*! @abstract A vector of four 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_int4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_int4 int4; + + /*! @abstract A vector of eight 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_int8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_int8 int8; + + /*! @abstract A vector of sixteen 32-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_int16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_int16 int16; + + /*! @abstract A vector of two 32-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_uint2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_uint2 uint2; + + /*! @abstract A vector of four 32-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_uint4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_uint4 uint4; + + /*! @abstract A vector of eight 32-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uint8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uint8 uint8; + + /*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uint16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uint16 uint16; + + /*! @abstract A vector of two 32-bit floating-point numbers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_float2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_float2 float2; + + /*! @abstract A vector of four 32-bit floating-point numbers with + * relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_float4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_float4 float4; + + /*! @abstract A vector of eight 32-bit floating-point numbers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_float8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_float8 float8; + + /*! @abstract A vector of sixteen 32-bit floating-point numbers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_float16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_float16 float16; + + /*! @abstract A vector of two 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_long2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_long2 long2; + + /*! @abstract A vector of four 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_long4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_long4 long4; + + /*! @abstract A vector of eight 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_long8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_long8 long8; + + /*! @abstract A vector of two 64-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_ulong2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_ulong2 ulong2; + + /*! @abstract A vector of four 64-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_ulong4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_ulong4 ulong4; + + /*! @abstract A vector of eight 64-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_ulong8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_ulong8 ulong8; + + /*! @abstract A vector of two 64-bit floating-point numbers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_double2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_double2 double2; + + /*! @abstract A vector of four 64-bit floating-point numbers with + * relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_double4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_double4 double4; + + /*! @abstract A vector of eight 64-bit floating-point numbers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_double8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_double8 double8; + + } /* namespace simd::packed:: */ +} /* namespace simd:: */ +#endif /* __cplusplus */ + +/* MARK: Deprecated vector types */ +/*! @group Deprecated vector types + * @discussion These are the original types used by earlier versions of the + * simd library; they are provided here for compatability with existing source + * files. Use the new ("simd_"-prefixed) types for future development. */ +/*! @abstract A vector of two 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char2 + * or simd::packed::char2 instead. */ +typedef simd_packed_char2 packed_char2; + +/*! @abstract A vector of four 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char4 + * or simd::packed::char4 instead. */ +typedef simd_packed_char4 packed_char4; + +/*! @abstract A vector of eight 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char8 + * or simd::packed::char8 instead. */ +typedef simd_packed_char8 packed_char8; + +/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char16 + * or simd::packed::char16 instead. */ +typedef simd_packed_char16 packed_char16; + +/*! @abstract A vector of thirty-two 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char32 + * or simd::packed::char32 instead. */ +typedef simd_packed_char32 packed_char32; + +/*! @abstract A vector of sixty-four 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char64 + * or simd::packed::char64 instead. */ +typedef simd_packed_char64 packed_char64; + +/*! @abstract A vector of two 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar2 + * or simd::packed::uchar2 instead. */ +typedef simd_packed_uchar2 packed_uchar2; + +/*! @abstract A vector of four 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar4 + * or simd::packed::uchar4 instead. */ +typedef simd_packed_uchar4 packed_uchar4; + +/*! @abstract A vector of eight 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar8 + * or simd::packed::uchar8 instead. */ +typedef simd_packed_uchar8 packed_uchar8; + +/*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar16 + * or simd::packed::uchar16 instead. */ +typedef simd_packed_uchar16 packed_uchar16; + +/*! @abstract A vector of thirty-two 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar32 + * or simd::packed::uchar32 instead. */ +typedef simd_packed_uchar32 packed_uchar32; + +/*! @abstract A vector of sixty-four 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar64 + * or simd::packed::uchar64 instead. */ +typedef simd_packed_uchar64 packed_uchar64; + +/*! @abstract A vector of two 16-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short2 + * or simd::packed::short2 instead. */ +typedef simd_packed_short2 packed_short2; + +/*! @abstract A vector of four 16-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short4 + * or simd::packed::short4 instead. */ +typedef simd_packed_short4 packed_short4; + +/*! @abstract A vector of eight 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short8 + * or simd::packed::short8 instead. */ +typedef simd_packed_short8 packed_short8; + +/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short16 + * or simd::packed::short16 instead. */ +typedef simd_packed_short16 packed_short16; + +/*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short32 + * or simd::packed::short32 instead. */ +typedef simd_packed_short32 packed_short32; + +/*! @abstract A vector of two 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ushort2 + * or simd::packed::ushort2 instead. */ +typedef simd_packed_ushort2 packed_ushort2; + +/*! @abstract A vector of four 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ushort4 + * or simd::packed::ushort4 instead. */ +typedef simd_packed_ushort4 packed_ushort4; + +/*! @abstract A vector of eight 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ushort8 + * or simd::packed::ushort8 instead. */ +typedef simd_packed_ushort8 packed_ushort8; + +/*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use + * simd_packed_ushort16 or simd::packed::ushort16 instead. */ +typedef simd_packed_ushort16 packed_ushort16; + +/*! @abstract A vector of thirty-two 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use + * simd_packed_ushort32 or simd::packed::ushort32 instead. */ +typedef simd_packed_ushort32 packed_ushort32; + +/*! @abstract A vector of two 32-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_int2 or + * simd::packed::int2 instead. */ +typedef simd_packed_int2 packed_int2; + +/*! @abstract A vector of four 32-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_int4 or + * simd::packed::int4 instead. */ +typedef simd_packed_int4 packed_int4; + +/*! @abstract A vector of eight 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_int8 or + * simd::packed::int8 instead. */ +typedef simd_packed_int8 packed_int8; + +/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_int16 + * or simd::packed::int16 instead. */ +typedef simd_packed_int16 packed_int16; + +/*! @abstract A vector of two 32-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uint2 + * or simd::packed::uint2 instead. */ +typedef simd_packed_uint2 packed_uint2; + +/*! @abstract A vector of four 32-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uint4 + * or simd::packed::uint4 instead. */ +typedef simd_packed_uint4 packed_uint4; + +/*! @abstract A vector of eight 32-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uint8 + * or simd::packed::uint8 instead. */ +typedef simd_packed_uint8 packed_uint8; + +/*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uint16 + * or simd::packed::uint16 instead. */ +typedef simd_packed_uint16 packed_uint16; + +/*! @abstract A vector of two 32-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_float2 + * or simd::packed::float2 instead. */ +typedef simd_packed_float2 packed_float2; + +/*! @abstract A vector of four 32-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_float4 + * or simd::packed::float4 instead. */ +typedef simd_packed_float4 packed_float4; + +/*! @abstract A vector of eight 32-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_float8 + * or simd::packed::float8 instead. */ +typedef simd_packed_float8 packed_float8; + +/*! @abstract A vector of sixteen 32-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_float16 + * or simd::packed::float16 instead. */ +typedef simd_packed_float16 packed_float16; + +/*! @abstract A vector of two 64-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_long2 + * or simd::packed::long2 instead. */ +typedef simd_packed_long2 packed_long2; + +/*! @abstract A vector of four 64-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_long4 + * or simd::packed::long4 instead. */ +typedef simd_packed_long4 packed_long4; + +/*! @abstract A vector of eight 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_long8 + * or simd::packed::long8 instead. */ +typedef simd_packed_long8 packed_long8; + +/*! @abstract A vector of two 64-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ulong2 + * or simd::packed::ulong2 instead. */ +typedef simd_packed_ulong2 packed_ulong2; + +/*! @abstract A vector of four 64-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ulong4 + * or simd::packed::ulong4 instead. */ +typedef simd_packed_ulong4 packed_ulong4; + +/*! @abstract A vector of eight 64-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ulong8 + * or simd::packed::ulong8 instead. */ +typedef simd_packed_ulong8 packed_ulong8; + +/*! @abstract A vector of two 64-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_double2 + * or simd::packed::double2 instead. */ +typedef simd_packed_double2 packed_double2; + +/*! @abstract A vector of four 64-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_double4 + * or simd::packed::double4 instead. */ +typedef simd_packed_double4 packed_double4; + +/*! @abstract A vector of eight 64-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_double8 + * or simd::packed::double8 instead. */ +typedef simd_packed_double8 packed_double8; + +# endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/simd/quaternion.h b/lib/libc/include/x86_64-macos-gnu/simd/quaternion.h new file mode 100644 index 0000000000..5f386dea16 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/quaternion.h @@ -0,0 +1,1194 @@ +/*! @header + * This header defines functions for constructing and using quaternions. + * @copyright 2015-2016 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_QUATERNIONS +#define SIMD_QUATERNIONS + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* MARK: - C and Objective-C float interfaces */ + +/*! @abstract Constructs a quaternion from four scalar values. + * + * @param ix The first component of the imaginary (vector) part. + * @param iy The second component of the imaginary (vector) part. + * @param iz The third component of the imaginary (vector) part. + * + * @param r The real (scalar) part. */ +static inline SIMD_CFUNC simd_quatf simd_quaternion(float ix, float iy, float iz, float r) { + return (simd_quatf){ { ix, iy, iz, r } }; +} + +/*! @abstract Constructs a quaternion from an array of four scalars. + * + * @discussion Note that the imaginary part of the quaternion comes from + * array elements 0, 1, and 2, and the real part comes from element 3. */ +static inline SIMD_NONCONST simd_quatf simd_quaternion(const float xyzr[4]) { + return (simd_quatf){ *(const simd_packed_float4 *)xyzr }; +} + +/*! @abstract Constructs a quaternion from a four-element vector. + * + * @discussion Note that the imaginary (vector) part of the quaternion comes + * from lanes 0, 1, and 2 of the vector, and the real (scalar) part comes from + * lane 3. */ +static inline SIMD_CFUNC simd_quatf simd_quaternion(simd_float4 xyzr) { + return (simd_quatf){ xyzr }; +} + +/*! @abstract Constructs a quaternion that rotates by `angle` radians about + * `axis`. */ +static inline SIMD_CFUNC simd_quatf simd_quaternion(float angle, simd_float3 axis); + +/*! @abstract Construct a quaternion that rotates from one vector to another. + * + * @param from A normalized three-element vector. + * @param to A normalized three-element vector. + * + * @discussion The rotation axis is `simd_cross(from, to)`. If `from` and + * `to` point in opposite directions (to within machine precision), an + * arbitrary rotation axis is chosen, and the angle is pi radians. */ +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3 from, simd_float3 to); + +/*! @abstract Construct a quaternion from a 3x3 rotation `matrix`. + * + * @discussion If `matrix` is not orthogonal with determinant 1, the result + * is undefined. */ +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3x3 matrix); + +/*! @abstract Construct a quaternion from a 4x4 rotation `matrix`. + * + * @discussion The last row and column of the matrix are ignored. This + * function is equivalent to calling simd_quaternion with the upper-left 3x3 + * submatrix . */ +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float4x4 matrix); + +/*! @abstract The real (scalar) part of the quaternion `q`. */ +static inline SIMD_CFUNC float simd_real(simd_quatf q) { + return q.vector.w; +} + +/*! @abstract The imaginary (vector) part of the quaternion `q`. */ +static inline SIMD_CFUNC simd_float3 simd_imag(simd_quatf q) { + return q.vector.xyz; +} + +/*! @abstract The angle (in radians) of rotation represented by `q`. */ +static inline SIMD_CFUNC float simd_angle(simd_quatf q); + +/*! @abstract The normalized axis (a 3-element vector) around which the + * action of the quaternion `q` rotates. */ +static inline SIMD_CFUNC simd_float3 simd_axis(simd_quatf q); + +/*! @abstract The sum of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatf simd_add(simd_quatf p, simd_quatf q); + +/*! @abstract The difference of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatf simd_sub(simd_quatf p, simd_quatf q); + +/*! @abstract The product of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf p, simd_quatf q); + +/*! @abstract The quaternion `q` scaled by the real value `a`. */ +static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf q, float a); + +/*! @abstract The quaternion `q` scaled by the real value `a`. */ +static inline SIMD_CFUNC simd_quatf simd_mul(float a, simd_quatf q); + +/*! @abstract The conjugate of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatf simd_conjugate(simd_quatf q); + +/*! @abstract The (multiplicative) inverse of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatf simd_inverse(simd_quatf q); + +/*! @abstract The negation (additive inverse) of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatf simd_negate(simd_quatf q); + +/*! @abstract The dot product of the quaternions `p` and `q` interpreted as + * four-dimensional vectors. */ +static inline SIMD_CFUNC float simd_dot(simd_quatf p, simd_quatf q); + +/*! @abstract The length of the quaternion `q`. */ +static inline SIMD_CFUNC float simd_length(simd_quatf q); + +/*! @abstract The unit quaternion obtained by normalizing `q`. */ +static inline SIMD_CFUNC simd_quatf simd_normalize(simd_quatf q); + +/*! @abstract Rotates the vector `v` by the quaternion `q`. */ +static inline SIMD_CFUNC simd_float3 simd_act(simd_quatf q, simd_float3 v); + +/*! @abstract Logarithm of the quaternion `q`. + * @discussion Do not call this function directly; use `log(q)` instead. + * + * We can write a quaternion `q` in the form: `r(cos(t) + sin(t)v)` where + * `r` is the length of `q`, `t` is an angle, and `v` is a unit 3-vector. + * The logarithm of `q` is `log(r) + tv`, just like the logarithm of the + * complex number `r*(cos(t) + i sin(t))` is `log(r) + it`. + * + * Note that this function is not robust against poorly-scaled non-unit + * quaternions, because it is primarily used for spline interpolation of + * unit quaternions. If you need to compute a robust logarithm of general + * quaternions, you can use the following approach: + * + * scale = simd_reduce_max(simd_abs(q.vector)); + * logq = log(simd_recip(scale)*q); + * logq.real += log(scale); + * return logq; */ +static SIMD_NOINLINE simd_quatf __tg_log(simd_quatf q); + +/*! @abstract Inverse of `log( )`; the exponential map on quaternions. + * @discussion Do not call this function directly; use `exp(q)` instead. */ +static SIMD_NOINLINE simd_quatf __tg_exp(simd_quatf q); + +/*! @abstract Spherical linear interpolation along the shortest arc between + * quaternions `q0` and `q1`. */ +static SIMD_NOINLINE simd_quatf simd_slerp(simd_quatf q0, simd_quatf q1, float t); + +/*! @abstract Spherical linear interpolation along the longest arc between + * quaternions `q0` and `q1`. */ +static SIMD_NOINLINE simd_quatf simd_slerp_longest(simd_quatf q0, simd_quatf q1, float t); + +/*! @abstract Interpolate between quaternions along a spherical cubic spline. + * + * @discussion The function interpolates between q1 and q2. q0 is the left + * endpoint of the previous interval, and q3 is the right endpoint of the next + * interval. Use this function to smoothly interpolate between a sequence of + * rotations. */ +static SIMD_NOINLINE simd_quatf simd_spline(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t); + +/*! @abstract Spherical cubic Bezier interpolation between quaternions. + * + * @discussion The function treats q0 ... q3 as control points and uses slerp + * in place of lerp in the De Castlejeau algorithm. The endpoints of + * interpolation are thus q0 and q3, and the curve will not generally pass + * through q1 or q2. Note that the convex hull property of "standard" Bezier + * curve does not hold on the sphere. */ +static SIMD_NOINLINE simd_quatf simd_bezier(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t); + +#ifdef __cplusplus +} /* extern "C" */ +/* MARK: - C++ float interfaces */ + +namespace simd { + struct quatf : ::simd_quatf { + /*! @abstract The identity quaternion. */ + quatf( ) : ::simd_quatf(::simd_quaternion((float4){0,0,0,1})) { } + + /*! @abstract Constructs a C++ quaternion from a C quaternion. */ + quatf(::simd_quatf q) : ::simd_quatf(q) { } + + /*! @abstract Constructs a quaternion from components. */ + quatf(float ix, float iy, float iz, float r) : ::simd_quatf(::simd_quaternion(ix, iy, iz, r)) { } + + /*! @abstract Constructs a quaternion from an array of scalars. */ + quatf(const float xyzr[4]) : ::simd_quatf(::simd_quaternion(xyzr)) { } + + /*! @abstract Constructs a quaternion from a vector. */ + quatf(float4 xyzr) : ::simd_quatf(::simd_quaternion(xyzr)) { } + + /*! @abstract Quaternion representing rotation about `axis` by `angle` + * radians. */ + quatf(float angle, float3 axis) : ::simd_quatf(::simd_quaternion(angle, axis)) { } + + /*! @abstract Quaternion that rotates `from` into `to`. */ + quatf(float3 from, float3 to) : ::simd_quatf(::simd_quaternion(from, to)) { } + + /*! @abstract Constructs a quaternion from a rotation matrix. */ + quatf(::simd_float3x3 matrix) : ::simd_quatf(::simd_quaternion(matrix)) { } + + /*! @abstract Constructs a quaternion from a rotation matrix. */ + quatf(::simd_float4x4 matrix) : ::simd_quatf(::simd_quaternion(matrix)) { } + + /*! @abstract The real (scalar) part of the quaternion. */ + float real(void) const { return ::simd_real(*this); } + + /*! @abstract The imaginary (vector) part of the quaternion. */ + float3 imag(void) const { return ::simd_imag(*this); } + + /*! @abstract The angle the quaternion rotates by. */ + float angle(void) const { return ::simd_angle(*this); } + + /*! @abstract The axis the quaternion rotates about. */ + float3 axis(void) const { return ::simd_axis(*this); } + + /*! @abstract The length of the quaternion. */ + float length(void) const { return ::simd_length(*this); } + + /*! @abstract Act on the vector `v` by rotation. */ + float3 operator()(const ::simd_float3 v) const { return ::simd_act(*this, v); } + }; + + static SIMD_CPPFUNC quatf operator+(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_add(p, q); } + static SIMD_CPPFUNC quatf operator-(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_sub(p, q); } + static SIMD_CPPFUNC quatf operator-(const ::simd_quatf p) { return ::simd_negate(p); } + static SIMD_CPPFUNC quatf operator*(const float r, const ::simd_quatf p) { return ::simd_mul(r, p); } + static SIMD_CPPFUNC quatf operator*(const ::simd_quatf p, const float r) { return ::simd_mul(p, r); } + static SIMD_CPPFUNC quatf operator*(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_mul(p, q); } + static SIMD_CPPFUNC quatf operator/(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_mul(p, ::simd_inverse(q)); } + static SIMD_CPPFUNC quatf operator+=(quatf &p, const ::simd_quatf q) { return p = p+q; } + static SIMD_CPPFUNC quatf operator-=(quatf &p, const ::simd_quatf q) { return p = p-q; } + static SIMD_CPPFUNC quatf operator*=(quatf &p, const float r) { return p = p*r; } + static SIMD_CPPFUNC quatf operator*=(quatf &p, const ::simd_quatf q) { return p = p*q; } + static SIMD_CPPFUNC quatf operator/=(quatf &p, const ::simd_quatf q) { return p = p/q; } + + /*! @abstract The conjugate of the quaternion `q`. */ + static SIMD_CPPFUNC quatf conjugate(const ::simd_quatf p) { return ::simd_conjugate(p); } + + /*! @abstract The (multiplicative) inverse of the quaternion `q`. */ + static SIMD_CPPFUNC quatf inverse(const ::simd_quatf p) { return ::simd_inverse(p); } + + /*! @abstract The dot product of the quaternions `p` and `q` interpreted as + * four-dimensional vectors. */ + static SIMD_CPPFUNC float dot(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_dot(p, q); } + + /*! @abstract The unit quaternion obtained by normalizing `q`. */ + static SIMD_CPPFUNC quatf normalize(const ::simd_quatf p) { return ::simd_normalize(p); } + + /*! @abstract logarithm of the quaternion `q`. */ + static SIMD_CPPFUNC quatf log(const ::simd_quatf q) { return ::__tg_log(q); } + + /*! @abstract exponential map of quaterion `q`. */ + static SIMD_CPPFUNC quatf exp(const ::simd_quatf q) { return ::__tg_exp(q); } + + /*! @abstract Spherical linear interpolation along the shortest arc between + * quaternions `q0` and `q1`. */ + static SIMD_CPPFUNC quatf slerp(const ::simd_quatf p0, const ::simd_quatf p1, float t) { return ::simd_slerp(p0, p1, t); } + + /*! @abstract Spherical linear interpolation along the longest arc between + * quaternions `q0` and `q1`. */ + static SIMD_CPPFUNC quatf slerp_longest(const ::simd_quatf p0, const ::simd_quatf p1, float t) { return ::simd_slerp_longest(p0, p1, t); } + + /*! @abstract Interpolate between quaternions along a spherical cubic spline. + * + * @discussion The function interpolates between q1 and q2. q0 is the left + * endpoint of the previous interval, and q3 is the right endpoint of the next + * interval. Use this function to smoothly interpolate between a sequence of + * rotations. */ + 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); } + + /*! @abstract Spherical cubic Bezier interpolation between quaternions. + * + * @discussion The function treats q0 ... q3 as control points and uses slerp + * in place of lerp in the De Castlejeau algorithm. The endpoints of + * interpolation are thus q0 and q3, and the curve will not generally pass + * through q1 or q2. Note that the convex hull property of "standard" Bezier + * curve does not hold on the sphere. */ + 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); } +} + +extern "C" { +#endif /* __cplusplus */ + +/* MARK: - float implementations */ + +#include +#include + +/* tg_promote is implementation gobbledygook that enables the compile-time + * dispatching in tgmath.h to work its magic. */ +static simd_quatf __attribute__((__overloadable__)) __tg_promote(simd_quatf); + +/*! @abstract Constructs a quaternion from imaginary and real parts. + * @discussion This function is hidden behind an underscore to avoid confusion + * with the angle-axis constructor. */ +static inline SIMD_CFUNC simd_quatf _simd_quaternion(simd_float3 imag, float real) { + return simd_quaternion(simd_make_float4(imag, real)); +} + +static inline SIMD_CFUNC simd_quatf simd_quaternion(float angle, simd_float3 axis) { + return _simd_quaternion(sin(angle/2) * axis, cos(angle/2)); +} + +static inline SIMD_CFUNC float simd_angle(simd_quatf q) { + return 2*atan2(simd_length(q.vector.xyz), q.vector.w); +} + +static inline SIMD_CFUNC simd_float3 simd_axis(simd_quatf q) { + return simd_normalize(q.vector.xyz); +} + +static inline SIMD_CFUNC simd_quatf simd_add(simd_quatf p, simd_quatf q) { + return simd_quaternion(p.vector + q.vector); +} + +static inline SIMD_CFUNC simd_quatf simd_sub(simd_quatf p, simd_quatf q) { + return simd_quaternion(p.vector - q.vector); +} + +static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf p, simd_quatf q) { + #pragma STDC FP_CONTRACT ON + return simd_quaternion((p.vector.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) + + p.vector.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5)) + + (p.vector.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6) + + p.vector.w * q.vector)); +} + +static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf q, float a) { + return simd_quaternion(a * q.vector); +} + +static inline SIMD_CFUNC simd_quatf simd_mul(float a, simd_quatf q) { + return simd_mul(q,a); +} + +static inline SIMD_CFUNC simd_quatf simd_conjugate(simd_quatf q) { + return simd_quaternion(q.vector * (simd_float4){-1,-1,-1, 1}); +} + +static inline SIMD_CFUNC simd_quatf simd_inverse(simd_quatf q) { + return simd_quaternion(simd_conjugate(q).vector * simd_recip(simd_length_squared(q.vector))); +} + +static inline SIMD_CFUNC simd_quatf simd_negate(simd_quatf q) { + return simd_quaternion(-q.vector); +} + +static inline SIMD_CFUNC float simd_dot(simd_quatf p, simd_quatf q) { + return simd_dot(p.vector, q.vector); +} + +static inline SIMD_CFUNC float simd_length(simd_quatf q) { + return simd_length(q.vector); +} + +static inline SIMD_CFUNC simd_quatf simd_normalize(simd_quatf q) { + float length_squared = simd_length_squared(q.vector); + if (length_squared == 0) { + return simd_quaternion((simd_float4){0,0,0,1}); + } + return simd_quaternion(q.vector * simd_rsqrt(length_squared)); +} + +#if defined __arm__ || defined __arm64__ +/*! @abstract Multiplies the vector `v` by the quaternion `q`. + * + * @discussion This IS NOT the action of `q` on `v` (i.e. this is not rotation + * by `q`. That operation is provided by `simd_act(q, v)`. This function is an + * implementation detail and you should not call it directly. It may be + * removed or modified in future versions of the simd module. */ +static inline SIMD_CFUNC simd_quatf _simd_mul_vq(simd_float3 v, simd_quatf q) { + #pragma STDC FP_CONTRACT ON + return simd_quaternion(v.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) + + v.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5) + + v.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6)); +} +#endif + +static inline SIMD_CFUNC simd_float3 simd_act(simd_quatf q, simd_float3 v) { +#if defined __arm__ || defined __arm64__ + return simd_mul(q, _simd_mul_vq(v, simd_conjugate(q))).vector.xyz; +#else + #pragma STDC FP_CONTRACT ON + simd_float3 t = 2*simd_cross(simd_imag(q),v); + return v + simd_real(q)*t + simd_cross(simd_imag(q), t); +#endif +} + +static SIMD_NOINLINE simd_quatf __tg_log(simd_quatf q) { + float real = __tg_log(simd_length_squared(q.vector))/2; + if (simd_equal(simd_imag(q), 0)) return _simd_quaternion(0, real); + simd_float3 imag = __tg_acos(simd_real(q)/simd_length(q)) * simd_normalize(simd_imag(q)); + return _simd_quaternion(imag, real); +} + +static SIMD_NOINLINE simd_quatf __tg_exp(simd_quatf q) { + // angle is actually *twice* the angle of the rotation corresponding to + // the resulting quaternion, which is why we don't simply use the (angle, + // axis) constructor to generate `unit`. + float angle = simd_length(simd_imag(q)); + if (angle == 0) return _simd_quaternion(0, exp(simd_real(q))); + simd_float3 axis = simd_normalize(simd_imag(q)); + simd_quatf unit = _simd_quaternion(sin(angle)*axis, cosf(angle)); + return simd_mul(exp(simd_real(q)), unit); +} + +/*! @abstract Implementation detail of the `simd_quaternion(from, to)` + * initializer. + * + * @discussion Computes the quaternion rotation `from` to `to` if they are + * separated by less than 90 degrees. Not numerically stable for larger + * angles. This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static inline SIMD_CFUNC simd_quatf _simd_quaternion_reduced(simd_float3 from, simd_float3 to) { + simd_float3 half = simd_normalize(from + to); + return _simd_quaternion(simd_cross(from, half), simd_dot(from, half)); +} + +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3 from, simd_float3 to) { + + // If the angle between from and to is not too big, we can compute the + // rotation accurately using a simple implementation. + if (simd_dot(from, to) >= 0) { + return _simd_quaternion_reduced(from, to); + } + + // Because from and to are more than 90 degrees apart, we compute the + // rotation in two stages (from -> half), (half -> to) to preserve numerical + // accuracy. + simd_float3 half = from + to; + + if (simd_length_squared(half) == 0) { + // half is nearly zero, so from and to point in nearly opposite directions + // and the rotation is numerically underspecified. Pick an axis orthogonal + // to the vectors, and use an angle of pi radians. + simd_float3 abs_from = simd_abs(from); + if (abs_from.x <= abs_from.y && abs_from.x <= abs_from.z) + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){1,0,0})), 0.f); + else if (abs_from.y <= abs_from.z) + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){0,1,0})), 0.f); + else + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){0,0,1})), 0.f); + } + + // Compute the two-step rotation. */ + half = simd_normalize(half); + return simd_mul(_simd_quaternion_reduced(from, half), + _simd_quaternion_reduced(half, to)); +} + +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3x3 matrix) { + const simd_float3 *mat = matrix.columns; + float trace = mat[0][0] + mat[1][1] + mat[2][2]; + if (trace >= 0.0) { + float r = 2*sqrt(1 + trace); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[1][2] - mat[2][1]), + rinv*(mat[2][0] - mat[0][2]), + rinv*(mat[0][1] - mat[1][0]), + r/4); + } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) { + float r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]); + float rinv = simd_recip(r); + return simd_quaternion(r/4, + rinv*(mat[0][1] + mat[1][0]), + rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] - mat[2][1])); + } else if (mat[1][1] >= mat[2][2]) { + float r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][1] + mat[1][0]), + r/4, + rinv*(mat[1][2] + mat[2][1]), + rinv*(mat[2][0] - mat[0][2])); + } else { + float r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] + mat[2][1]), + r/4, + rinv*(mat[0][1] - mat[1][0])); + } +} + +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float4x4 matrix) { + const simd_float4 *mat = matrix.columns; + float trace = mat[0][0] + mat[1][1] + mat[2][2]; + if (trace >= 0.0) { + float r = 2*sqrt(1 + trace); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[1][2] - mat[2][1]), + rinv*(mat[2][0] - mat[0][2]), + rinv*(mat[0][1] - mat[1][0]), + r/4); + } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) { + float r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]); + float rinv = simd_recip(r); + return simd_quaternion(r/4, + rinv*(mat[0][1] + mat[1][0]), + rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] - mat[2][1])); + } else if (mat[1][1] >= mat[2][2]) { + float r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][1] + mat[1][0]), + r/4, + rinv*(mat[1][2] + mat[2][1]), + rinv*(mat[2][0] - mat[0][2])); + } else { + float r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] + mat[2][1]), + r/4, + rinv*(mat[0][1] - mat[1][0])); + } +} + +/*! @abstract The angle between p and q interpreted as 4-dimensional vectors. + * + * @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE float _simd_angle(simd_quatf p, simd_quatf q) { + return 2*atan2(simd_length(p.vector - q.vector), simd_length(p.vector + q.vector)); +} + +/*! @abstract sin(x)/x. + * + * @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_CFUNC float _simd_sinc(float x) { + if (x == 0) return 1; + return sin(x)/x; +} + +/*! @abstract Spherical lerp between q0 and q1. + * + * @discussion This function may interpolate along either the longer or + * shorter path between q0 and q1; it is used as an implementation detail + * in `simd_slerp` and `simd_slerp_longest`; you should use those functions + * instead of calling this directly. */ +static SIMD_NOINLINE simd_quatf _simd_slerp_internal(simd_quatf q0, simd_quatf q1, float t) { + float s = 1 - t; + float a = _simd_angle(q0, q1); + float r = simd_recip(_simd_sinc(a)); + return simd_normalize(simd_quaternion(_simd_sinc(s*a)*r*s*q0.vector + _simd_sinc(t*a)*r*t*q1.vector)); +} + +static SIMD_NOINLINE simd_quatf simd_slerp(simd_quatf q0, simd_quatf q1, float t) { + if (simd_dot(q0, q1) >= 0) + return _simd_slerp_internal(q0, q1, t); + return _simd_slerp_internal(q0, simd_negate(q1), t); +} + +static SIMD_NOINLINE simd_quatf simd_slerp_longest(simd_quatf q0, simd_quatf q1, float t) { + if (simd_dot(q0, q1) >= 0) + return _simd_slerp_internal(q0, simd_negate(q1), t); + return _simd_slerp_internal(q0, q1, t); +} + +/*! @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE simd_quatf _simd_intermediate(simd_quatf q0, simd_quatf q1, simd_quatf q2) { + simd_quatf p0 = __tg_log(simd_mul(q0, simd_inverse(q1))); + simd_quatf p2 = __tg_log(simd_mul(q2, simd_inverse(q1))); + return simd_normalize(simd_mul(q1, __tg_exp(simd_mul(-0.25, simd_add(p0,p2))))); +} + +/*! @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE simd_quatf _simd_squad(simd_quatf q0, simd_quatf qa, simd_quatf qb, simd_quatf q1, float t) { + simd_quatf r0 = _simd_slerp_internal(q0, q1, t); + simd_quatf r1 = _simd_slerp_internal(qa, qb, t); + return _simd_slerp_internal(r0, r1, 2*t*(1 - t)); +} + +static SIMD_NOINLINE simd_quatf simd_spline(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t) { + simd_quatf qa = _simd_intermediate(q0, q1, q2); + simd_quatf qb = _simd_intermediate(q1, q2, q3); + return _simd_squad(q1, qa, qb, q2, t); +} + +static SIMD_NOINLINE simd_quatf simd_bezier(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t) { + simd_quatf q01 = _simd_slerp_internal(q0, q1, t); + simd_quatf q12 = _simd_slerp_internal(q1, q2, t); + simd_quatf q23 = _simd_slerp_internal(q2, q3, t); + simd_quatf q012 = _simd_slerp_internal(q01, q12, t); + simd_quatf q123 = _simd_slerp_internal(q12, q23, t); + return _simd_slerp_internal(q012, q123, t); +} + +/* MARK: - C and Objective-C double interfaces */ + +/*! @abstract Constructs a quaternion from four scalar values. + * + * @param ix The first component of the imaginary (vector) part. + * @param iy The second component of the imaginary (vector) part. + * @param iz The third component of the imaginary (vector) part. + * + * @param r The real (scalar) part. */ +static inline SIMD_CFUNC simd_quatd simd_quaternion(double ix, double iy, double iz, double r) { + return (simd_quatd){ { ix, iy, iz, r } }; +} + +/*! @abstract Constructs a quaternion from an array of four scalars. + * + * @discussion Note that the imaginary part of the quaternion comes from + * array elements 0, 1, and 2, and the real part comes from element 3. */ +static inline SIMD_NONCONST simd_quatd simd_quaternion(const double xyzr[4]) { + return (simd_quatd){ *(const simd_packed_double4 *)xyzr }; +} + +/*! @abstract Constructs a quaternion from a four-element vector. + * + * @discussion Note that the imaginary (vector) part of the quaternion comes + * from lanes 0, 1, and 2 of the vector, and the real (scalar) part comes from + * lane 3. */ +static inline SIMD_CFUNC simd_quatd simd_quaternion(simd_double4 xyzr) { + return (simd_quatd){ xyzr }; +} + +/*! @abstract Constructs a quaternion that rotates by `angle` radians about + * `axis`. */ +static inline SIMD_CFUNC simd_quatd simd_quaternion(double angle, simd_double3 axis); + +/*! @abstract Construct a quaternion that rotates from one vector to another. + * + * @param from A normalized three-element vector. + * @param to A normalized three-element vector. + * + * @discussion The rotation axis is `simd_cross(from, to)`. If `from` and + * `to` point in opposite directions (to within machine precision), an + * arbitrary rotation axis is chosen, and the angle is pi radians. */ +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3 from, simd_double3 to); + +/*! @abstract Construct a quaternion from a 3x3 rotation `matrix`. + * + * @discussion If `matrix` is not orthogonal with determinant 1, the result + * is undefined. */ +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3x3 matrix); + +/*! @abstract Construct a quaternion from a 4x4 rotation `matrix`. + * + * @discussion The last row and column of the matrix are ignored. This + * function is equivalent to calling simd_quaternion with the upper-left 3x3 + * submatrix . */ +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double4x4 matrix); + +/*! @abstract The real (scalar) part of the quaternion `q`. */ +static inline SIMD_CFUNC double simd_real(simd_quatd q) { + return q.vector.w; +} + +/*! @abstract The imaginary (vector) part of the quaternion `q`. */ +static inline SIMD_CFUNC simd_double3 simd_imag(simd_quatd q) { + return q.vector.xyz; +} + +/*! @abstract The angle (in radians) of rotation represented by `q`. */ +static inline SIMD_CFUNC double simd_angle(simd_quatd q); + +/*! @abstract The normalized axis (a 3-element vector) around which the + * action of the quaternion `q` rotates. */ +static inline SIMD_CFUNC simd_double3 simd_axis(simd_quatd q); + +/*! @abstract The sum of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatd simd_add(simd_quatd p, simd_quatd q); + +/*! @abstract The difference of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatd simd_sub(simd_quatd p, simd_quatd q); + +/*! @abstract The product of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd p, simd_quatd q); + +/*! @abstract The quaternion `q` scaled by the real value `a`. */ +static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd q, double a); + +/*! @abstract The quaternion `q` scaled by the real value `a`. */ +static inline SIMD_CFUNC simd_quatd simd_mul(double a, simd_quatd q); + +/*! @abstract The conjugate of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatd simd_conjugate(simd_quatd q); + +/*! @abstract The (multiplicative) inverse of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatd simd_inverse(simd_quatd q); + +/*! @abstract The negation (additive inverse) of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatd simd_negate(simd_quatd q); + +/*! @abstract The dot product of the quaternions `p` and `q` interpreted as + * four-dimensional vectors. */ +static inline SIMD_CFUNC double simd_dot(simd_quatd p, simd_quatd q); + +/*! @abstract The length of the quaternion `q`. */ +static inline SIMD_CFUNC double simd_length(simd_quatd q); + +/*! @abstract The unit quaternion obtained by normalizing `q`. */ +static inline SIMD_CFUNC simd_quatd simd_normalize(simd_quatd q); + +/*! @abstract Rotates the vector `v` by the quaternion `q`. */ +static inline SIMD_CFUNC simd_double3 simd_act(simd_quatd q, simd_double3 v); + +/*! @abstract Logarithm of the quaternion `q`. + * @discussion Do not call this function directly; use `log(q)` instead. + * + * We can write a quaternion `q` in the form: `r(cos(t) + sin(t)v)` where + * `r` is the length of `q`, `t` is an angle, and `v` is a unit 3-vector. + * The logarithm of `q` is `log(r) + tv`, just like the logarithm of the + * complex number `r*(cos(t) + i sin(t))` is `log(r) + it`. + * + * Note that this function is not robust against poorly-scaled non-unit + * quaternions, because it is primarily used for spline interpolation of + * unit quaternions. If you need to compute a robust logarithm of general + * quaternions, you can use the following approach: + * + * scale = simd_reduce_max(simd_abs(q.vector)); + * logq = log(simd_recip(scale)*q); + * logq.real += log(scale); + * return logq; */ +static SIMD_NOINLINE simd_quatd __tg_log(simd_quatd q); + +/*! @abstract Inverse of `log( )`; the exponential map on quaternions. + * @discussion Do not call this function directly; use `exp(q)` instead. */ +static SIMD_NOINLINE simd_quatd __tg_exp(simd_quatd q); + +/*! @abstract Spherical linear interpolation along the shortest arc between + * quaternions `q0` and `q1`. */ +static SIMD_NOINLINE simd_quatd simd_slerp(simd_quatd q0, simd_quatd q1, double t); + +/*! @abstract Spherical linear interpolation along the longest arc between + * quaternions `q0` and `q1`. */ +static SIMD_NOINLINE simd_quatd simd_slerp_longest(simd_quatd q0, simd_quatd q1, double t); + +/*! @abstract Interpolate between quaternions along a spherical cubic spline. + * + * @discussion The function interpolates between q1 and q2. q0 is the left + * endpoint of the previous interval, and q3 is the right endpoint of the next + * interval. Use this function to smoothly interpolate between a sequence of + * rotations. */ +static SIMD_NOINLINE simd_quatd simd_spline(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t); + +/*! @abstract Spherical cubic Bezier interpolation between quaternions. + * + * @discussion The function treats q0 ... q3 as control points and uses slerp + * in place of lerp in the De Castlejeau algorithm. The endpoints of + * interpolation are thus q0 and q3, and the curve will not generally pass + * through q1 or q2. Note that the convex hull property of "standard" Bezier + * curve does not hold on the sphere. */ +static SIMD_NOINLINE simd_quatd simd_bezier(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t); + +#ifdef __cplusplus +} /* extern "C" */ +/* MARK: - C++ double interfaces */ + +namespace simd { + struct quatd : ::simd_quatd { + /*! @abstract The identity quaternion. */ + quatd( ) : ::simd_quatd(::simd_quaternion((double4){0,0,0,1})) { } + + /*! @abstract Constructs a C++ quaternion from a C quaternion. */ + quatd(::simd_quatd q) : ::simd_quatd(q) { } + + /*! @abstract Constructs a quaternion from components. */ + quatd(double ix, double iy, double iz, double r) : ::simd_quatd(::simd_quaternion(ix, iy, iz, r)) { } + + /*! @abstract Constructs a quaternion from an array of scalars. */ + quatd(const double xyzr[4]) : ::simd_quatd(::simd_quaternion(xyzr)) { } + + /*! @abstract Constructs a quaternion from a vector. */ + quatd(double4 xyzr) : ::simd_quatd(::simd_quaternion(xyzr)) { } + + /*! @abstract Quaternion representing rotation about `axis` by `angle` + * radians. */ + quatd(double angle, double3 axis) : ::simd_quatd(::simd_quaternion(angle, axis)) { } + + /*! @abstract Quaternion that rotates `from` into `to`. */ + quatd(double3 from, double3 to) : ::simd_quatd(::simd_quaternion(from, to)) { } + + /*! @abstract Constructs a quaternion from a rotation matrix. */ + quatd(::simd_double3x3 matrix) : ::simd_quatd(::simd_quaternion(matrix)) { } + + /*! @abstract Constructs a quaternion from a rotation matrix. */ + quatd(::simd_double4x4 matrix) : ::simd_quatd(::simd_quaternion(matrix)) { } + + /*! @abstract The real (scalar) part of the quaternion. */ + double real(void) const { return ::simd_real(*this); } + + /*! @abstract The imaginary (vector) part of the quaternion. */ + double3 imag(void) const { return ::simd_imag(*this); } + + /*! @abstract The angle the quaternion rotates by. */ + double angle(void) const { return ::simd_angle(*this); } + + /*! @abstract The axis the quaternion rotates about. */ + double3 axis(void) const { return ::simd_axis(*this); } + + /*! @abstract The length of the quaternion. */ + double length(void) const { return ::simd_length(*this); } + + /*! @abstract Act on the vector `v` by rotation. */ + double3 operator()(const ::simd_double3 v) const { return ::simd_act(*this, v); } + }; + + static SIMD_CPPFUNC quatd operator+(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_add(p, q); } + static SIMD_CPPFUNC quatd operator-(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_sub(p, q); } + static SIMD_CPPFUNC quatd operator-(const ::simd_quatd p) { return ::simd_negate(p); } + static SIMD_CPPFUNC quatd operator*(const double r, const ::simd_quatd p) { return ::simd_mul(r, p); } + static SIMD_CPPFUNC quatd operator*(const ::simd_quatd p, const double r) { return ::simd_mul(p, r); } + static SIMD_CPPFUNC quatd operator*(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_mul(p, q); } + static SIMD_CPPFUNC quatd operator/(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_mul(p, ::simd_inverse(q)); } + static SIMD_CPPFUNC quatd operator+=(quatd &p, const ::simd_quatd q) { return p = p+q; } + static SIMD_CPPFUNC quatd operator-=(quatd &p, const ::simd_quatd q) { return p = p-q; } + static SIMD_CPPFUNC quatd operator*=(quatd &p, const double r) { return p = p*r; } + static SIMD_CPPFUNC quatd operator*=(quatd &p, const ::simd_quatd q) { return p = p*q; } + static SIMD_CPPFUNC quatd operator/=(quatd &p, const ::simd_quatd q) { return p = p/q; } + + /*! @abstract The conjugate of the quaternion `q`. */ + static SIMD_CPPFUNC quatd conjugate(const ::simd_quatd p) { return ::simd_conjugate(p); } + + /*! @abstract The (multiplicative) inverse of the quaternion `q`. */ + static SIMD_CPPFUNC quatd inverse(const ::simd_quatd p) { return ::simd_inverse(p); } + + /*! @abstract The dot product of the quaternions `p` and `q` interpreted as + * four-dimensional vectors. */ + static SIMD_CPPFUNC double dot(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_dot(p, q); } + + /*! @abstract The unit quaternion obtained by normalizing `q`. */ + static SIMD_CPPFUNC quatd normalize(const ::simd_quatd p) { return ::simd_normalize(p); } + + /*! @abstract logarithm of the quaternion `q`. */ + static SIMD_CPPFUNC quatd log(const ::simd_quatd q) { return ::__tg_log(q); } + + /*! @abstract exponential map of quaterion `q`. */ + static SIMD_CPPFUNC quatd exp(const ::simd_quatd q) { return ::__tg_exp(q); } + + /*! @abstract Spherical linear interpolation along the shortest arc between + * quaternions `q0` and `q1`. */ + static SIMD_CPPFUNC quatd slerp(const ::simd_quatd p0, const ::simd_quatd p1, double t) { return ::simd_slerp(p0, p1, t); } + + /*! @abstract Spherical linear interpolation along the longest arc between + * quaternions `q0` and `q1`. */ + static SIMD_CPPFUNC quatd slerp_longest(const ::simd_quatd p0, const ::simd_quatd p1, double t) { return ::simd_slerp_longest(p0, p1, t); } + + /*! @abstract Interpolate between quaternions along a spherical cubic spline. + * + * @discussion The function interpolates between q1 and q2. q0 is the left + * endpoint of the previous interval, and q3 is the right endpoint of the next + * interval. Use this function to smoothly interpolate between a sequence of + * rotations. */ + 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); } + + /*! @abstract Spherical cubic Bezier interpolation between quaternions. + * + * @discussion The function treats q0 ... q3 as control points and uses slerp + * in place of lerp in the De Castlejeau algorithm. The endpoints of + * interpolation are thus q0 and q3, and the curve will not generally pass + * through q1 or q2. Note that the convex hull property of "standard" Bezier + * curve does not hold on the sphere. */ + 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); } +} + +extern "C" { +#endif /* __cplusplus */ + +/* MARK: - double implementations */ + +#include +#include + +/* tg_promote is implementation gobbledygook that enables the compile-time + * dispatching in tgmath.h to work its magic. */ +static simd_quatd __attribute__((__overloadable__)) __tg_promote(simd_quatd); + +/*! @abstract Constructs a quaternion from imaginary and real parts. + * @discussion This function is hidden behind an underscore to avoid confusion + * with the angle-axis constructor. */ +static inline SIMD_CFUNC simd_quatd _simd_quaternion(simd_double3 imag, double real) { + return simd_quaternion(simd_make_double4(imag, real)); +} + +static inline SIMD_CFUNC simd_quatd simd_quaternion(double angle, simd_double3 axis) { + return _simd_quaternion(sin(angle/2) * axis, cos(angle/2)); +} + +static inline SIMD_CFUNC double simd_angle(simd_quatd q) { + return 2*atan2(simd_length(q.vector.xyz), q.vector.w); +} + +static inline SIMD_CFUNC simd_double3 simd_axis(simd_quatd q) { + return simd_normalize(q.vector.xyz); +} + +static inline SIMD_CFUNC simd_quatd simd_add(simd_quatd p, simd_quatd q) { + return simd_quaternion(p.vector + q.vector); +} + +static inline SIMD_CFUNC simd_quatd simd_sub(simd_quatd p, simd_quatd q) { + return simd_quaternion(p.vector - q.vector); +} + +static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd p, simd_quatd q) { + #pragma STDC FP_CONTRACT ON + return simd_quaternion((p.vector.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) + + p.vector.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5)) + + (p.vector.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6) + + p.vector.w * q.vector)); +} + +static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd q, double a) { + return simd_quaternion(a * q.vector); +} + +static inline SIMD_CFUNC simd_quatd simd_mul(double a, simd_quatd q) { + return simd_mul(q,a); +} + +static inline SIMD_CFUNC simd_quatd simd_conjugate(simd_quatd q) { + return simd_quaternion(q.vector * (simd_double4){-1,-1,-1, 1}); +} + +static inline SIMD_CFUNC simd_quatd simd_inverse(simd_quatd q) { + return simd_quaternion(simd_conjugate(q).vector * simd_recip(simd_length_squared(q.vector))); +} + +static inline SIMD_CFUNC simd_quatd simd_negate(simd_quatd q) { + return simd_quaternion(-q.vector); +} + +static inline SIMD_CFUNC double simd_dot(simd_quatd p, simd_quatd q) { + return simd_dot(p.vector, q.vector); +} + +static inline SIMD_CFUNC double simd_length(simd_quatd q) { + return simd_length(q.vector); +} + +static inline SIMD_CFUNC simd_quatd simd_normalize(simd_quatd q) { + double length_squared = simd_length_squared(q.vector); + if (length_squared == 0) { + return simd_quaternion((simd_double4){0,0,0,1}); + } + return simd_quaternion(q.vector * simd_rsqrt(length_squared)); +} + +#if defined __arm__ || defined __arm64__ +/*! @abstract Multiplies the vector `v` by the quaternion `q`. + * + * @discussion This IS NOT the action of `q` on `v` (i.e. this is not rotation + * by `q`. That operation is provided by `simd_act(q, v)`. This function is an + * implementation detail and you should not call it directly. It may be + * removed or modified in future versions of the simd module. */ +static inline SIMD_CFUNC simd_quatd _simd_mul_vq(simd_double3 v, simd_quatd q) { + #pragma STDC FP_CONTRACT ON + return simd_quaternion(v.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) + + v.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5) + + v.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6)); +} +#endif + +static inline SIMD_CFUNC simd_double3 simd_act(simd_quatd q, simd_double3 v) { +#if defined __arm__ || defined __arm64__ + return simd_mul(q, _simd_mul_vq(v, simd_conjugate(q))).vector.xyz; +#else + #pragma STDC FP_CONTRACT ON + simd_double3 t = 2*simd_cross(simd_imag(q),v); + return v + simd_real(q)*t + simd_cross(simd_imag(q), t); +#endif +} + +static SIMD_NOINLINE simd_quatd __tg_log(simd_quatd q) { + double real = __tg_log(simd_length_squared(q.vector))/2; + if (simd_equal(simd_imag(q), 0)) return _simd_quaternion(0, real); + simd_double3 imag = __tg_acos(simd_real(q)/simd_length(q)) * simd_normalize(simd_imag(q)); + return _simd_quaternion(imag, real); +} + +static SIMD_NOINLINE simd_quatd __tg_exp(simd_quatd q) { + // angle is actually *twice* the angle of the rotation corresponding to + // the resulting quaternion, which is why we don't simply use the (angle, + // axis) constructor to generate `unit`. + double angle = simd_length(simd_imag(q)); + if (angle == 0) return _simd_quaternion(0, exp(simd_real(q))); + simd_double3 axis = simd_normalize(simd_imag(q)); + simd_quatd unit = _simd_quaternion(sin(angle)*axis, cosf(angle)); + return simd_mul(exp(simd_real(q)), unit); +} + +/*! @abstract Implementation detail of the `simd_quaternion(from, to)` + * initializer. + * + * @discussion Computes the quaternion rotation `from` to `to` if they are + * separated by less than 90 degrees. Not numerically stable for larger + * angles. This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static inline SIMD_CFUNC simd_quatd _simd_quaternion_reduced(simd_double3 from, simd_double3 to) { + simd_double3 half = simd_normalize(from + to); + return _simd_quaternion(simd_cross(from, half), simd_dot(from, half)); +} + +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3 from, simd_double3 to) { + + // If the angle between from and to is not too big, we can compute the + // rotation accurately using a simple implementation. + if (simd_dot(from, to) >= 0) { + return _simd_quaternion_reduced(from, to); + } + + // Because from and to are more than 90 degrees apart, we compute the + // rotation in two stages (from -> half), (half -> to) to preserve numerical + // accuracy. + simd_double3 half = from + to; + + if (simd_length_squared(half) == 0) { + // half is nearly zero, so from and to point in nearly opposite directions + // and the rotation is numerically underspecified. Pick an axis orthogonal + // to the vectors, and use an angle of pi radians. + simd_double3 abs_from = simd_abs(from); + if (abs_from.x <= abs_from.y && abs_from.x <= abs_from.z) + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){1,0,0})), 0.f); + else if (abs_from.y <= abs_from.z) + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){0,1,0})), 0.f); + else + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){0,0,1})), 0.f); + } + + // Compute the two-step rotation. */ + half = simd_normalize(half); + return simd_mul(_simd_quaternion_reduced(from, half), + _simd_quaternion_reduced(half, to)); +} + +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3x3 matrix) { + const simd_double3 *mat = matrix.columns; + double trace = mat[0][0] + mat[1][1] + mat[2][2]; + if (trace >= 0.0) { + double r = 2*sqrt(1 + trace); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[1][2] - mat[2][1]), + rinv*(mat[2][0] - mat[0][2]), + rinv*(mat[0][1] - mat[1][0]), + r/4); + } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) { + double r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]); + double rinv = simd_recip(r); + return simd_quaternion(r/4, + rinv*(mat[0][1] + mat[1][0]), + rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] - mat[2][1])); + } else if (mat[1][1] >= mat[2][2]) { + double r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][1] + mat[1][0]), + r/4, + rinv*(mat[1][2] + mat[2][1]), + rinv*(mat[2][0] - mat[0][2])); + } else { + double r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] + mat[2][1]), + r/4, + rinv*(mat[0][1] - mat[1][0])); + } +} + +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double4x4 matrix) { + const simd_double4 *mat = matrix.columns; + double trace = mat[0][0] + mat[1][1] + mat[2][2]; + if (trace >= 0.0) { + double r = 2*sqrt(1 + trace); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[1][2] - mat[2][1]), + rinv*(mat[2][0] - mat[0][2]), + rinv*(mat[0][1] - mat[1][0]), + r/4); + } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) { + double r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]); + double rinv = simd_recip(r); + return simd_quaternion(r/4, + rinv*(mat[0][1] + mat[1][0]), + rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] - mat[2][1])); + } else if (mat[1][1] >= mat[2][2]) { + double r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][1] + mat[1][0]), + r/4, + rinv*(mat[1][2] + mat[2][1]), + rinv*(mat[2][0] - mat[0][2])); + } else { + double r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] + mat[2][1]), + r/4, + rinv*(mat[0][1] - mat[1][0])); + } +} + +/*! @abstract The angle between p and q interpreted as 4-dimensional vectors. + * + * @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE double _simd_angle(simd_quatd p, simd_quatd q) { + return 2*atan2(simd_length(p.vector - q.vector), simd_length(p.vector + q.vector)); +} + +/*! @abstract sin(x)/x. + * + * @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_CFUNC double _simd_sinc(double x) { + if (x == 0) return 1; + return sin(x)/x; +} + +/*! @abstract Spherical lerp between q0 and q1. + * + * @discussion This function may interpolate along either the longer or + * shorter path between q0 and q1; it is used as an implementation detail + * in `simd_slerp` and `simd_slerp_longest`; you should use those functions + * instead of calling this directly. */ +static SIMD_NOINLINE simd_quatd _simd_slerp_internal(simd_quatd q0, simd_quatd q1, double t) { + double s = 1 - t; + double a = _simd_angle(q0, q1); + double r = simd_recip(_simd_sinc(a)); + return simd_normalize(simd_quaternion(_simd_sinc(s*a)*r*s*q0.vector + _simd_sinc(t*a)*r*t*q1.vector)); +} + +static SIMD_NOINLINE simd_quatd simd_slerp(simd_quatd q0, simd_quatd q1, double t) { + if (simd_dot(q0, q1) >= 0) + return _simd_slerp_internal(q0, q1, t); + return _simd_slerp_internal(q0, simd_negate(q1), t); +} + +static SIMD_NOINLINE simd_quatd simd_slerp_longest(simd_quatd q0, simd_quatd q1, double t) { + if (simd_dot(q0, q1) >= 0) + return _simd_slerp_internal(q0, simd_negate(q1), t); + return _simd_slerp_internal(q0, q1, t); +} + +/*! @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE simd_quatd _simd_intermediate(simd_quatd q0, simd_quatd q1, simd_quatd q2) { + simd_quatd p0 = __tg_log(simd_mul(q0, simd_inverse(q1))); + simd_quatd p2 = __tg_log(simd_mul(q2, simd_inverse(q1))); + return simd_normalize(simd_mul(q1, __tg_exp(simd_mul(-0.25, simd_add(p0,p2))))); +} + +/*! @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE simd_quatd _simd_squad(simd_quatd q0, simd_quatd qa, simd_quatd qb, simd_quatd q1, double t) { + simd_quatd r0 = _simd_slerp_internal(q0, q1, t); + simd_quatd r1 = _simd_slerp_internal(qa, qb, t); + return _simd_slerp_internal(r0, r1, 2*t*(1 - t)); +} + +static SIMD_NOINLINE simd_quatd simd_spline(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t) { + simd_quatd qa = _simd_intermediate(q0, q1, q2); + simd_quatd qb = _simd_intermediate(q1, q2, q3); + return _simd_squad(q1, qa, qb, q2, t); +} + +static SIMD_NOINLINE simd_quatd simd_bezier(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t) { + simd_quatd q01 = _simd_slerp_internal(q0, q1, t); + simd_quatd q12 = _simd_slerp_internal(q1, q2, t); + simd_quatd q23 = _simd_slerp_internal(q2, q3, t); + simd_quatd q012 = _simd_slerp_internal(q01, q12, t); + simd_quatd q123 = _simd_slerp_internal(q12, q23, t); + return _simd_slerp_internal(q012, q123, t); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_QUATERNIONS */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/simd.h b/lib/libc/include/x86_64-macos-gnu/simd/simd.h new file mode 100644 index 0000000000..2850d75ae9 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/simd.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2014 Apple, Inc. All rights reserved. + * + * This header provides small vector (simd) and matrix types, and basic + * arithmetic and mathematical functions for them. The vast majority of these + * operations are implemented as header inlines, as they can be performed + * using just a few instructions on most processors. + * + * These functions are broken into two groups; vector and matrix. This header + * includes all of them, but these may also be included separately. Consult + * these two headers for detailed documentation of what types and operations + * are available. + */ + +#ifndef __SIMD_HEADER__ +#define __SIMD_HEADER__ + +#include +#include +#include + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/simd/types.h b/lib/libc/include/x86_64-macos-gnu/simd/types.h new file mode 100644 index 0000000000..e094467047 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/types.h @@ -0,0 +1,128 @@ +/*! @header + * @copyright 2015-2016 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_TYPES +#define SIMD_TYPES + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES + +/*! @group Matrices + * @discussion + * This header defines nine matrix types for each of float and double, which + * are intended for use together with the vector types defined in + * . + * + * For compatibility with common graphics libraries, these matrices are stored + * in column-major order, and implemented as arrays of column vectors. + * Column-major storage order may seem a little strange if you aren't used to + * it, but for most usage the memory layout of the matrices shouldn't matter + * at all; instead you should think of matrices as abstract mathematical + * objects that you use to perform arithmetic without worrying about the + * details of the underlying representation. + * + * WARNING: vectors of length three are internally represented as length four + * vectors with one element of padding (for alignment purposes). This means + * that when a floatNx3 or doubleNx3 is viewed as a vector, it appears to + * have 4*N elements instead of the expected 3*N (with one padding element + * at the end of each column). The matrix elements are laid out in memory + * as follows: + * + * { 0, 1, 2, x, 3, 4, 5, x, ... } + * + * (where the scalar indices used above indicate the conceptual column- + * major storage order). If you aren't monkeying around with the internal + * storage details of matrices, you don't need to worry about this at all. + * Consider this yet another good reason to avoid doing so. */ + +/*! @abstract A matrix with 2 rows and 2 columns. */ +typedef struct { simd_float2 columns[2]; } simd_float2x2; + +/*! @abstract A matrix with 2 rows and 3 columns. */ +typedef struct { simd_float2 columns[3]; } simd_float3x2; + +/*! @abstract A matrix with 2 rows and 4 columns. */ +typedef struct { simd_float2 columns[4]; } simd_float4x2; + +/*! @abstract A matrix with 3 rows and 2 columns. */ +typedef struct { simd_float3 columns[2]; } simd_float2x3; + +/*! @abstract A matrix with 3 rows and 3 columns. */ +typedef struct { simd_float3 columns[3]; } simd_float3x3; + +/*! @abstract A matrix with 3 rows and 4 columns. */ +typedef struct { simd_float3 columns[4]; } simd_float4x3; + +/*! @abstract A matrix with 4 rows and 2 columns. */ +typedef struct { simd_float4 columns[2]; } simd_float2x4; + +/*! @abstract A matrix with 4 rows and 3 columns. */ +typedef struct { simd_float4 columns[3]; } simd_float3x4; + +/*! @abstract A matrix with 4 rows and 4 columns. */ +typedef struct { simd_float4 columns[4]; } simd_float4x4; + +/*! @abstract A matrix with 2 rows and 2 columns. */ +typedef struct { simd_double2 columns[2]; } simd_double2x2; + +/*! @abstract A matrix with 2 rows and 3 columns. */ +typedef struct { simd_double2 columns[3]; } simd_double3x2; + +/*! @abstract A matrix with 2 rows and 4 columns. */ +typedef struct { simd_double2 columns[4]; } simd_double4x2; + +/*! @abstract A matrix with 3 rows and 2 columns. */ +typedef struct { simd_double3 columns[2]; } simd_double2x3; + +/*! @abstract A matrix with 3 rows and 3 columns. */ +typedef struct { simd_double3 columns[3]; } simd_double3x3; + +/*! @abstract A matrix with 3 rows and 4 columns. */ +typedef struct { simd_double3 columns[4]; } simd_double4x3; + +/*! @abstract A matrix with 4 rows and 2 columns. */ +typedef struct { simd_double4 columns[2]; } simd_double2x4; + +/*! @abstract A matrix with 4 rows and 3 columns. */ +typedef struct { simd_double4 columns[3]; } simd_double3x4; + +/*! @abstract A matrix with 4 rows and 4 columns. */ +typedef struct { simd_double4 columns[4]; } simd_double4x4; + + +/*! @group Quaternions + * @discussion Unlike vectors, quaternions are not raw clang extended-vector + * types, because if they were you'd be able to intermix them with vectors + * in arithmetic operations freely, but the arithmetic would not do what you + * want it to do (it would simply perform the arithmetic operation + * componentwise on the quaternion and vector). + * + * Quaternions aren't unions in C/Obj-C, because then the C++ types couldn't + * inherit from the C types, which would make intermixing rather painful (you + * can't inherit from a union). This means that we can't provide nice member + * access like .real and .imag; you need to use functions to access the pieces + * of a quaternion instead. + * + * This also means that you need to use functions instead of operators to do + * arithmetic with quaternions in C and Obj-C. In C++, we are able to provide + * operator overloads for arithmetic. + * + * Internally, a quaternion is represented as a vector of four elements. The + * first three elements are the "imaginary" (or "vector") part of the + * quaternion, and the last element is the "real" (or "scalar") part. As with + * everything simd, you will generally get better performance if you avoid + * using the internal storage details of the type, and instead treat these + * quaternions as abstract mathematical objects once they are created. + * + * While the C types are defined here, the operations on quaternions and the + * C++ quaternion types are defined in */ + +/*! @abstract A single-precision quaternion. */ +typedef struct { simd_float4 vector; } simd_quatf; + +/*! @abstract A double-precision quaternion. */ +typedef struct { simd_double4 vector; } simd_quatd; + +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_TYPES */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/vector.h b/lib/libc/include/x86_64-macos-gnu/simd/vector.h new file mode 100644 index 0000000000..7ab8f2adbc --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/vector.h @@ -0,0 +1,52 @@ +/* Copyright (c) 2014 Apple, Inc. All rights reserved. + * + * This header provides small vector (simd) types and basic arithmetic and + * math functions that operate on them. + * + * A wide assortment of vector types are provided in , + * which is included by this header. The most important (as far as the rest + * of this library is concerned) are vector_floatN (where N is 2, 3, 4, 8, or + * 16), and vector_doubleN (where N is 2, 3, 4, or 8). + * + * All of the vector types are based on what clang call "OpenCL vectors", + * defined with the __ext_vector_type__ attribute. Many C operators "just + * work" with these types, so it is not necessary to make function calls + * to do basic arithmetic: + * + * simd_float4 x, y; + * x = x + y; // vector sum of x and y. + * + * scalar values are implicitly promoted to vectors (with a "splat"), so it + * is possible to easily write expressions involving scalars as well: + * + * simd_float4 x; + * x = 2*x; // scale x by 2. + * + * Besides the basic operations provided by the compiler, this header provides + * a set of mathematical and geometric primitives for use with these types. + * In C and Objective-C, these functions are prefixed with vector_; in C++, + * unprefixed names are available within the simd:: namespace. + * + * simd_float3 x, y; + * vector_max(x,y) // elementwise maximum of x and y + * fabs(x) // same as vector_abs(x) + * vector_clamp(x,0,1) // x clamped to the range [0,1]. This has no + * // standard-library analogue, so there is no + * // alternate name. + * + * Matrix and matrix-vector operations are also available in . + */ + +#ifndef __SIMD_VECTOR_HEADER__ +#define __SIMD_VECTOR_HEADER__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/simd/vector_make.h b/lib/libc/include/x86_64-macos-gnu/simd/vector_make.h new file mode 100644 index 0000000000..34396b2608 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/vector_make.h @@ -0,0 +1,6768 @@ +/*! @header + * This header defines functions for constructing, extending, and truncating + * simd vector types. + * + * For each vector type `simd_typeN` supported by , the following + * constructors are provided: + * + * ~~~ + * simd_typeN simd_make_typeN(type other); + * simd_typeN simd_make_typeN(simd_typeM other); + * ~~~ + * For the scalar-input version, or if M < N, these functions zero-extend + * `other` to produce a wider vector. If M == N, `other` is passed through + * unmodified. If `M > N`, `other` is truncated to form the result. + * + * ~~~ + * simd_typeN simd_make_typeN_undef(type other); + * simd_typeN simd_make_typeN_undef(simd_typeM other); + * ~~~ + * These functions are only available for M < N and for scalar inputs. They + * extend `other` to produce a wider vector where the contents of the newly- + * formed lanes are undefined. + * + * In addition, if N is 2, 3, or 4, the following constructors are available: + * ~~~ + * simd_make_typeN(parts ...) + * ~~~ + * where parts is a list of scalars and smaller vectors such that the sum of + * the number of lanes in the arguments is equal to N. For example, a + * `simd_float3` can be constructed from three `floats`, or a `float` and a + * `simd_float2` in any order: + * ~~~ + * simd_float2 ab = { 1, 2 }; + * simd_float3 vector = simd_make_float3(ab, 3); + * ~~~ + * + * @copyright 2014-2016 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_VECTOR_CONSTRUCTORS +#define SIMD_VECTOR_CONSTRUCTORS + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES + +#ifdef __cplusplus +extern "C" { +#endif + +/*! @abstract Concatenates `x` and `y` to form a vector of two 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(char x, char y) { + simd_char2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(char other) { + simd_char2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2_undef(char other) { + simd_char2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char8 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char16 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char32 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char2 simd_make_char2(simd_char64 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(char x, char y, char z) { + simd_char3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(char x, simd_char2 yz) { + simd_char3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char2 xy, char z) { + simd_char3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(char other) { + simd_char3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3_undef(char other) { + simd_char3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char2 other) { + simd_char3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3_undef(simd_char2 other) { + simd_char3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char8 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char16 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char32 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char3 simd_make_char3(simd_char64 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 8-bit signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(char x, char y, char z, char w) { + simd_char4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(char x, char y, simd_char2 zw) { + simd_char4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(char x, simd_char2 yz, char w) { + simd_char4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char2 xy, char z, char w) { + simd_char4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(char x, simd_char3 yzw) { + simd_char4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char2 xy, simd_char2 zw) { + simd_char4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char3 xyz, char w) { + simd_char4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(char other) { + simd_char4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4_undef(char other) { + simd_char4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char2 other) { + simd_char4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4_undef(simd_char2 other) { + simd_char4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char3 other) { + simd_char4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4_undef(simd_char3 other) { + simd_char4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char8 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char16 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char32 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 8-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_char4 simd_make_char4(simd_char64 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char4 lo, simd_char4 hi) { + simd_char8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(char other) { + simd_char8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8_undef(char other) { + simd_char8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char2 other) { + simd_char8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8_undef(simd_char2 other) { + simd_char8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char3 other) { + simd_char8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8_undef(simd_char3 other) { + simd_char8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char4 other) { + simd_char8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8_undef(simd_char4 other) { + simd_char8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char8 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of eight 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char16 other) { + return simd_make_char8(other.lo); +} + +/*! @abstract Truncates `other` to form a vector of eight 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char32 other) { + return simd_make_char8(other.lo); +} + +/*! @abstract Truncates `other` to form a vector of eight 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char8 simd_make_char8(simd_char64 other) { + return simd_make_char8(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char8 lo, simd_char8 hi) { + simd_char16 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(char other) { + simd_char16 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(char other) { + simd_char16 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char2 other) { + simd_char16 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(simd_char2 other) { + simd_char16 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char3 other) { + simd_char16 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(simd_char3 other) { + simd_char16 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char4 other) { + simd_char16 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(simd_char4 other) { + simd_char16 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char8 other) { + simd_char16 result = 0; + result.lo = simd_make_char8(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16_undef(simd_char8 other) { + simd_char16 result; + result.lo = simd_make_char8(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char16 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char32 other) { + return simd_make_char16(other.lo); +} + +/*! @abstract Truncates `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char16 simd_make_char16(simd_char64 other) { + return simd_make_char16(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two + * 8-bit signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char16 lo, simd_char16 hi) { + simd_char32 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(char other) { + simd_char32 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(char other) { + simd_char32 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char2 other) { + simd_char32 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char2 other) { + simd_char32 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char3 other) { + simd_char32 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char3 other) { + simd_char32 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char4 other) { + simd_char32 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char4 other) { + simd_char32 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char8 other) { + simd_char32 result = 0; + result.lo = simd_make_char16(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char8 other) { + simd_char32 result; + result.lo = simd_make_char16(other); + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char16 other) { + simd_char32 result = 0; + result.lo = simd_make_char16(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32_undef(simd_char16 other) { + simd_char32 result; + result.lo = simd_make_char16(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char32 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of thirty-two 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char32 simd_make_char32(simd_char64 other) { + return simd_make_char32(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixty-four + * 8-bit signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char32 lo, simd_char32 hi) { + simd_char64 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(char other) { + simd_char64 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(char other) { + simd_char64 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char2 other) { + simd_char64 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char2 other) { + simd_char64 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char3 other) { + simd_char64 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char3 other) { + simd_char64 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char4 other) { + simd_char64 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char4 other) { + simd_char64 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char8 other) { + simd_char64 result = 0; + result.lo = simd_make_char32(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char8 other) { + simd_char64 result; + result.lo = simd_make_char32(other); + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char16 other) { + simd_char64 result = 0; + result.lo = simd_make_char32(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char16 other) { + simd_char64 result; + result.lo = simd_make_char32(other); + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char32 other) { + simd_char64 result = 0; + result.lo = simd_make_char32(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64_undef(simd_char32 other) { + simd_char64 result; + result.lo = simd_make_char32(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_char64 simd_make_char64(simd_char64 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(unsigned char x, unsigned char y) { + simd_uchar2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(unsigned char other) { + simd_uchar2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2_undef(unsigned char other) { + simd_uchar2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar8 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar16 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar32 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar2 simd_make_uchar2(simd_uchar64 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(unsigned char x, unsigned char y, unsigned char z) { + simd_uchar3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(unsigned char x, simd_uchar2 yz) { + simd_uchar3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar2 xy, unsigned char z) { + simd_uchar3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(unsigned char other) { + simd_uchar3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3_undef(unsigned char other) { + simd_uchar3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar2 other) { + simd_uchar3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3_undef(simd_uchar2 other) { + simd_uchar3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar8 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar16 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar32 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar3 simd_make_uchar3(simd_uchar64 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 8-bit unsigned integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char x, unsigned char y, unsigned char z, unsigned char w) { + simd_uchar4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char x, unsigned char y, simd_uchar2 zw) { + simd_uchar4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char x, simd_uchar2 yz, unsigned char w) { + simd_uchar4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar2 xy, unsigned char z, unsigned char w) { + simd_uchar4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char x, simd_uchar3 yzw) { + simd_uchar4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar2 xy, simd_uchar2 zw) { + simd_uchar4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar3 xyz, unsigned char w) { + simd_uchar4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(unsigned char other) { + simd_uchar4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4_undef(unsigned char other) { + simd_uchar4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar2 other) { + simd_uchar4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4_undef(simd_uchar2 other) { + simd_uchar4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar3 other) { + simd_uchar4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4_undef(simd_uchar3 other) { + simd_uchar4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar8 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar16 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar32 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar4 simd_make_uchar4(simd_uchar64 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar4 lo, simd_uchar4 hi) { + simd_uchar8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(unsigned char other) { + simd_uchar8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8_undef(unsigned char other) { + simd_uchar8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar2 other) { + simd_uchar8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8_undef(simd_uchar2 other) { + simd_uchar8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar3 other) { + simd_uchar8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8_undef(simd_uchar3 other) { + simd_uchar8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar4 other) { + simd_uchar8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8_undef(simd_uchar4 other) { + simd_uchar8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar8 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of eight 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar16 other) { + return simd_make_uchar8(other.lo); +} + +/*! @abstract Truncates `other` to form a vector of eight 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar32 other) { + return simd_make_uchar8(other.lo); +} + +/*! @abstract Truncates `other` to form a vector of eight 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar8 simd_make_uchar8(simd_uchar64 other) { + return simd_make_uchar8(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar8 lo, simd_uchar8 hi) { + simd_uchar16 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(unsigned char other) { + simd_uchar16 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(unsigned char other) { + simd_uchar16 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar2 other) { + simd_uchar16 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(simd_uchar2 other) { + simd_uchar16 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar3 other) { + simd_uchar16 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(simd_uchar3 other) { + simd_uchar16 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar4 other) { + simd_uchar16 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(simd_uchar4 other) { + simd_uchar16 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar8 other) { + simd_uchar16 result = 0; + result.lo = simd_make_uchar8(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16_undef(simd_uchar8 other) { + simd_uchar16 result; + result.lo = simd_make_uchar8(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar16 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of sixteen 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar32 other) { + return simd_make_uchar16(other.lo); +} + +/*! @abstract Truncates `other` to form a vector of sixteen 8-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uchar16 simd_make_uchar16(simd_uchar64 other) { + return simd_make_uchar16(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two + * 8-bit unsigned integers. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar16 lo, simd_uchar16 hi) { + simd_uchar32 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(unsigned char other) { + simd_uchar32 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(unsigned char other) { + simd_uchar32 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar2 other) { + simd_uchar32 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar2 other) { + simd_uchar32 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar3 other) { + simd_uchar32 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar3 other) { + simd_uchar32 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar4 other) { + simd_uchar32 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar4 other) { + simd_uchar32 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar8 other) { + simd_uchar32 result = 0; + result.lo = simd_make_uchar16(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar8 other) { + simd_uchar32 result; + result.lo = simd_make_uchar16(other); + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar16 other) { + simd_uchar32 result = 0; + result.lo = simd_make_uchar16(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32_undef(simd_uchar16 other) { + simd_uchar32 result; + result.lo = simd_make_uchar16(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar32 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of thirty-two 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar32 simd_make_uchar32(simd_uchar64 other) { + return simd_make_uchar32(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixty-four + * 8-bit unsigned integers. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar32 lo, simd_uchar32 hi) { + simd_uchar64 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(unsigned char other) { + simd_uchar64 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(unsigned char other) { + simd_uchar64 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar2 other) { + simd_uchar64 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar2 other) { + simd_uchar64 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar3 other) { + simd_uchar64 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar3 other) { + simd_uchar64 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar4 other) { + simd_uchar64 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar4 other) { + simd_uchar64 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar8 other) { + simd_uchar64 result = 0; + result.lo = simd_make_uchar32(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar8 other) { + simd_uchar64 result; + result.lo = simd_make_uchar32(other); + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar16 other) { + simd_uchar64 result = 0; + result.lo = simd_make_uchar32(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar16 other) { + simd_uchar64 result; + result.lo = simd_make_uchar32(other); + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixty-four 8-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar32 other) { + simd_uchar64 result = 0; + result.lo = simd_make_uchar32(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64_undef(simd_uchar32 other) { + simd_uchar64 result; + result.lo = simd_make_uchar32(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uchar64 simd_make_uchar64(simd_uchar64 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2(short x, short y) { + simd_short2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2(short other) { + simd_short2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2_undef(short other) { + simd_short2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short8 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short16 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_short2 simd_make_short2(simd_short32 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(short x, short y, short z) { + simd_short3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(short x, simd_short2 yz) { + simd_short3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short2 xy, short z) { + simd_short3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(short other) { + simd_short3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3_undef(short other) { + simd_short3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short2 other) { + simd_short3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3_undef(simd_short2 other) { + simd_short3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short8 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short16 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short3 simd_make_short3(simd_short32 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 16-bit signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(short x, short y, short z, short w) { + simd_short4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(short x, short y, simd_short2 zw) { + simd_short4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(short x, simd_short2 yz, short w) { + simd_short4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short2 xy, short z, short w) { + simd_short4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(short x, simd_short3 yzw) { + simd_short4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short2 xy, simd_short2 zw) { + simd_short4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short3 xyz, short w) { + simd_short4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(short other) { + simd_short4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4_undef(short other) { + simd_short4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short2 other) { + simd_short4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4_undef(simd_short2 other) { + simd_short4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short3 other) { + simd_short4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4_undef(simd_short3 other) { + simd_short4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short8 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short16 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short4 simd_make_short4(simd_short32 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short4 lo, simd_short4 hi) { + simd_short8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8(short other) { + simd_short8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8_undef(short other) { + simd_short8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short2 other) { + simd_short8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8_undef(simd_short2 other) { + simd_short8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short3 other) { + simd_short8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8_undef(simd_short3 other) { + simd_short8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short4 other) { + simd_short8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8_undef(simd_short4 other) { + simd_short8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short8 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of eight 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short16 other) { + return simd_make_short8(other.lo); +} + +/*! @abstract Truncates `other` to form a vector of eight 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short8 simd_make_short8(simd_short32 other) { + return simd_make_short8(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short8 lo, simd_short8 hi) { + simd_short16 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16(short other) { + simd_short16 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(short other) { + simd_short16 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short2 other) { + simd_short16 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(simd_short2 other) { + simd_short16 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short3 other) { + simd_short16 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(simd_short3 other) { + simd_short16 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short4 other) { + simd_short16 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(simd_short4 other) { + simd_short16 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short8 other) { + simd_short16 result = 0; + result.lo = simd_make_short8(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16_undef(simd_short8 other) { + simd_short16 result; + result.lo = simd_make_short8(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short16 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short16 simd_make_short16(simd_short32 other) { + return simd_make_short16(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two + * 16-bit signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short16 lo, simd_short16 hi) { + simd_short32 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32(short other) { + simd_short32 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(short other) { + simd_short32 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short2 other) { + simd_short32 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short2 other) { + simd_short32 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short3 other) { + simd_short32 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short3 other) { + simd_short32 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short4 other) { + simd_short32 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short4 other) { + simd_short32 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short8 other) { + simd_short32 result = 0; + result.lo = simd_make_short16(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short8 other) { + simd_short32 result; + result.lo = simd_make_short16(other); + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short16 other) { + simd_short32 result = 0; + result.lo = simd_make_short16(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32_undef(simd_short16 other) { + simd_short32 result; + result.lo = simd_make_short16(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_short32 simd_make_short32(simd_short32 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(unsigned short x, unsigned short y) { + simd_ushort2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(unsigned short other) { + simd_ushort2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2_undef(unsigned short other) { + simd_ushort2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort8 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort16 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort2 simd_make_ushort2(simd_ushort32 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(unsigned short x, unsigned short y, unsigned short z) { + simd_ushort3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(unsigned short x, simd_ushort2 yz) { + simd_ushort3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort2 xy, unsigned short z) { + simd_ushort3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(unsigned short other) { + simd_ushort3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3_undef(unsigned short other) { + simd_ushort3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort2 other) { + simd_ushort3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3_undef(simd_ushort2 other) { + simd_ushort3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort8 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort16 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort3 simd_make_ushort3(simd_ushort32 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 16-bit unsigned integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) { + simd_ushort4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short x, unsigned short y, simd_ushort2 zw) { + simd_ushort4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short x, simd_ushort2 yz, unsigned short w) { + simd_ushort4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort2 xy, unsigned short z, unsigned short w) { + simd_ushort4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short x, simd_ushort3 yzw) { + simd_ushort4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort2 xy, simd_ushort2 zw) { + simd_ushort4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort3 xyz, unsigned short w) { + simd_ushort4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(unsigned short other) { + simd_ushort4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4_undef(unsigned short other) { + simd_ushort4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort2 other) { + simd_ushort4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4_undef(simd_ushort2 other) { + simd_ushort4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort3 other) { + simd_ushort4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4_undef(simd_ushort3 other) { + simd_ushort4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort8 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort16 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort4 simd_make_ushort4(simd_ushort32 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort4 lo, simd_ushort4 hi) { + simd_ushort8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(unsigned short other) { + simd_ushort8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8_undef(unsigned short other) { + simd_ushort8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort2 other) { + simd_ushort8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8_undef(simd_ushort2 other) { + simd_ushort8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort3 other) { + simd_ushort8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8_undef(simd_ushort3 other) { + simd_ushort8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort4 other) { + simd_ushort8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8_undef(simd_ushort4 other) { + simd_ushort8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort8 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of eight 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort16 other) { + return simd_make_ushort8(other.lo); +} + +/*! @abstract Truncates `other` to form a vector of eight 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort8 simd_make_ushort8(simd_ushort32 other) { + return simd_make_ushort8(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort8 lo, simd_ushort8 hi) { + simd_ushort16 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(unsigned short other) { + simd_ushort16 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(unsigned short other) { + simd_ushort16 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort2 other) { + simd_ushort16 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(simd_ushort2 other) { + simd_ushort16 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort3 other) { + simd_ushort16 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(simd_ushort3 other) { + simd_ushort16 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort4 other) { + simd_ushort16 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(simd_ushort4 other) { + simd_ushort16 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort8 other) { + simd_ushort16 result = 0; + result.lo = simd_make_ushort8(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16_undef(simd_ushort8 other) { + simd_ushort16 result; + result.lo = simd_make_ushort8(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort16 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of sixteen 16-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ushort16 simd_make_ushort16(simd_ushort32 other) { + return simd_make_ushort16(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two + * 16-bit unsigned integers. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort16 lo, simd_ushort16 hi) { + simd_ushort32 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(unsigned short other) { + simd_ushort32 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(unsigned short other) { + simd_ushort32 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort2 other) { + simd_ushort32 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort2 other) { + simd_ushort32 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort3 other) { + simd_ushort32 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort3 other) { + simd_ushort32 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort4 other) { + simd_ushort32 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort4 other) { + simd_ushort32 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort8 other) { + simd_ushort32 result = 0; + result.lo = simd_make_ushort16(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort8 other) { + simd_ushort32 result; + result.lo = simd_make_ushort16(other); + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of thirty-two 16-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort16 other) { + simd_ushort32 result = 0; + result.lo = simd_make_ushort16(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32_undef(simd_ushort16 other) { + simd_ushort32 result; + result.lo = simd_make_ushort16(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ushort32 simd_make_ushort32(simd_ushort32 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int2 simd_make_int2(int x, int y) { + simd_int2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int2 simd_make_int2(int other) { + simd_int2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int2 simd_make_int2_undef(int other) { + simd_int2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int8 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_int2 simd_make_int2(simd_int16 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(int x, int y, int z) { + simd_int3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(int x, simd_int2 yz) { + simd_int3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int2 xy, int z) { + simd_int3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(int other) { + simd_int3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3_undef(int other) { + simd_int3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int2 other) { + simd_int3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3_undef(simd_int2 other) { + simd_int3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int8 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int3 simd_make_int3(simd_int16 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 32-bit signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(int x, int y, int z, int w) { + simd_int4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(int x, int y, simd_int2 zw) { + simd_int4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(int x, simd_int2 yz, int w) { + simd_int4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int2 xy, int z, int w) { + simd_int4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(int x, simd_int3 yzw) { + simd_int4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int2 xy, simd_int2 zw) { + simd_int4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int3 xyz, int w) { + simd_int4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(int other) { + simd_int4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4_undef(int other) { + simd_int4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int2 other) { + simd_int4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4_undef(simd_int2 other) { + simd_int4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int3 other) { + simd_int4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4_undef(simd_int3 other) { + simd_int4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int8 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int4 simd_make_int4(simd_int16 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int4 lo, simd_int4 hi) { + simd_int8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8(int other) { + simd_int8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8_undef(int other) { + simd_int8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int2 other) { + simd_int8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8_undef(simd_int2 other) { + simd_int8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int3 other) { + simd_int8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8_undef(simd_int3 other) { + simd_int8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int4 other) { + simd_int8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8_undef(simd_int4 other) { + simd_int8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int8 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of eight 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int8 simd_make_int8(simd_int16 other) { + return simd_make_int8(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int8 lo, simd_int8 hi) { + simd_int16 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16(int other) { + simd_int16 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(int other) { + simd_int16 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int2 other) { + simd_int16 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(simd_int2 other) { + simd_int16 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int3 other) { + simd_int16 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(simd_int3 other) { + simd_int16 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int4 other) { + simd_int16 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(simd_int4 other) { + simd_int16 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int8 other) { + simd_int16 result = 0; + result.lo = simd_make_int8(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16_undef(simd_int8 other) { + simd_int16 result; + result.lo = simd_make_int8(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_int16 simd_make_int16(simd_int16 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint2 simd_make_uint2(unsigned int x, unsigned int y) { + simd_uint2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint2 simd_make_uint2(unsigned int other) { + simd_uint2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint2 simd_make_uint2_undef(unsigned int other) { + simd_uint2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint8 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint2 simd_make_uint2(simd_uint16 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(unsigned int x, unsigned int y, unsigned int z) { + simd_uint3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(unsigned int x, simd_uint2 yz) { + simd_uint3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint2 xy, unsigned int z) { + simd_uint3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(unsigned int other) { + simd_uint3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3_undef(unsigned int other) { + simd_uint3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint2 other) { + simd_uint3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3_undef(simd_uint2 other) { + simd_uint3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint8 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint3 simd_make_uint3(simd_uint16 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 32-bit unsigned integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int x, unsigned int y, unsigned int z, unsigned int w) { + simd_uint4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int x, unsigned int y, simd_uint2 zw) { + simd_uint4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int x, simd_uint2 yz, unsigned int w) { + simd_uint4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint2 xy, unsigned int z, unsigned int w) { + simd_uint4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int x, simd_uint3 yzw) { + simd_uint4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint2 xy, simd_uint2 zw) { + simd_uint4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint3 xyz, unsigned int w) { + simd_uint4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(unsigned int other) { + simd_uint4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4_undef(unsigned int other) { + simd_uint4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint2 other) { + simd_uint4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4_undef(simd_uint2 other) { + simd_uint4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint3 other) { + simd_uint4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4_undef(simd_uint3 other) { + simd_uint4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint8 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint4 simd_make_uint4(simd_uint16 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint4 lo, simd_uint4 hi) { + simd_uint8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8(unsigned int other) { + simd_uint8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8_undef(unsigned int other) { + simd_uint8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint2 other) { + simd_uint8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8_undef(simd_uint2 other) { + simd_uint8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint3 other) { + simd_uint8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8_undef(simd_uint3 other) { + simd_uint8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint4 other) { + simd_uint8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8_undef(simd_uint4 other) { + simd_uint8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint8 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of eight 32-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_uint8 simd_make_uint8(simd_uint16 other) { + return simd_make_uint8(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint8 lo, simd_uint8 hi) { + simd_uint16 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16(unsigned int other) { + simd_uint16 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(unsigned int other) { + simd_uint16 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint2 other) { + simd_uint16 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(simd_uint2 other) { + simd_uint16 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint3 other) { + simd_uint16 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(simd_uint3 other) { + simd_uint16 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint4 other) { + simd_uint16 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(simd_uint4 other) { + simd_uint16 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint8 other) { + simd_uint16 result = 0; + result.lo = simd_make_uint8(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16_undef(simd_uint8 other) { + simd_uint16 result; + result.lo = simd_make_uint8(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_uint16 simd_make_uint16(simd_uint16 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float2 simd_make_float2(float x, float y) { + simd_float2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float2 simd_make_float2(float other) { + simd_float2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 32-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +static inline SIMD_CFUNC simd_float2 simd_make_float2_undef(float other) { + simd_float2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float8 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float2 simd_make_float2(simd_float16 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(float x, float y, float z) { + simd_float3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(float x, simd_float2 yz) { + simd_float3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float2 xy, float z) { + simd_float3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(float other) { + simd_float3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3_undef(float other) { + simd_float3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float2 other) { + simd_float3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3_undef(simd_float2 other) { + simd_float3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float8 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float3 simd_make_float3(simd_float16 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 32-bit floating-point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(float x, float y, float z, float w) { + simd_float4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(float x, float y, simd_float2 zw) { + simd_float4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(float x, simd_float2 yz, float w) { + simd_float4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float2 xy, float z, float w) { + simd_float4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(float x, simd_float3 yzw) { + simd_float4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float2 xy, simd_float2 zw) { + simd_float4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float3 xyz, float w) { + simd_float4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(float other) { + simd_float4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4_undef(float other) { + simd_float4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float2 other) { + simd_float4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4_undef(simd_float2 other) { + simd_float4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float3 other) { + simd_float4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 32-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4_undef(simd_float3 other) { + simd_float4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float8 other) { + return other.xyzw; +} + +/*! @abstract Truncates `other` to form a vector of four 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float4 simd_make_float4(simd_float16 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float4 lo, simd_float4 hi) { + simd_float8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8(float other) { + simd_float8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8_undef(float other) { + simd_float8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float2 other) { + simd_float8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8_undef(simd_float2 other) { + simd_float8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float3 other) { + simd_float8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8_undef(simd_float3 other) { + simd_float8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float4 other) { + simd_float8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8_undef(simd_float4 other) { + simd_float8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float8 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of eight 32-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_float8 simd_make_float8(simd_float16 other) { + return simd_make_float8(other.lo); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float8 lo, simd_float8 hi) { + simd_float16 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16(float other) { + simd_float16 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(float other) { + simd_float16 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float2 other) { + simd_float16 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(simd_float2 other) { + simd_float16 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float3 other) { + simd_float16 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(simd_float3 other) { + simd_float16 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float4 other) { + simd_float16 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(simd_float4 other) { + simd_float16 result; + result.xyzw = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of sixteen 32-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float8 other) { + simd_float16 result = 0; + result.lo = simd_make_float8(other); + return result; +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16_undef(simd_float8 other) { + simd_float16 result; + result.lo = simd_make_float8(other); + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_float16 simd_make_float16(simd_float16 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long1 x, simd_long1 y) { + simd_long2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long1 other) { + simd_long2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long2 simd_make_long2_undef(simd_long1 other) { + simd_long2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit signed (twos- + * complement) integers. */ +static inline SIMD_CFUNC simd_long2 simd_make_long2(simd_long8 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long1 x, simd_long1 y, simd_long1 z) { + simd_long3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long1 x, simd_long2 yz) { + simd_long3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long2 xy, simd_long1 z) { + simd_long3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long1 other) { + simd_long3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3_undef(simd_long1 other) { + simd_long3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long2 other) { + simd_long3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3_undef(simd_long2 other) { + simd_long3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long3 simd_make_long3(simd_long8 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 64-bit signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 x, simd_long1 y, simd_long1 z, simd_long1 w) { + simd_long4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 x, simd_long1 y, simd_long2 zw) { + simd_long4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 x, simd_long2 yz, simd_long1 w) { + simd_long4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long2 xy, simd_long1 z, simd_long1 w) { + simd_long4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 x, simd_long3 yzw) { + simd_long4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long2 xy, simd_long2 zw) { + simd_long4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long3 xyz, simd_long1 w) { + simd_long4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long1 other) { + simd_long4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4_undef(simd_long1 other) { + simd_long4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long2 other) { + simd_long4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4_undef(simd_long2 other) { + simd_long4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long3 other) { + simd_long4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4_undef(simd_long3 other) { + simd_long4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long4 simd_make_long4(simd_long8 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long4 lo, simd_long4 hi) { + simd_long8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long1 other) { + simd_long8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8_undef(simd_long1 other) { + simd_long8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long2 other) { + simd_long8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8_undef(simd_long2 other) { + simd_long8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long3 other) { + simd_long8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8_undef(simd_long3 other) { + simd_long8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long4 other) { + simd_long8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8_undef(simd_long4 other) { + simd_long8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_long8 simd_make_long8(simd_long8 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong1 x, simd_ulong1 y) { + simd_ulong2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong1 other) { + simd_ulong2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2_undef(simd_ulong1 other) { + simd_ulong2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong2 simd_make_ulong2(simd_ulong8 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong1 x, simd_ulong1 y, simd_ulong1 z) { + simd_ulong3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong1 x, simd_ulong2 yz) { + simd_ulong3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong2 xy, simd_ulong1 z) { + simd_ulong3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong1 other) { + simd_ulong3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3_undef(simd_ulong1 other) { + simd_ulong3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong2 other) { + simd_ulong3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3_undef(simd_ulong2 other) { + simd_ulong3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong3 simd_make_ulong3(simd_ulong8 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 64-bit unsigned integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 x, simd_ulong1 y, simd_ulong1 z, simd_ulong1 w) { + simd_ulong4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 x, simd_ulong1 y, simd_ulong2 zw) { + simd_ulong4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 x, simd_ulong2 yz, simd_ulong1 w) { + simd_ulong4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong2 xy, simd_ulong1 z, simd_ulong1 w) { + simd_ulong4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 x, simd_ulong3 yzw) { + simd_ulong4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong2 xy, simd_ulong2 zw) { + simd_ulong4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong3 xyz, simd_ulong1 w) { + simd_ulong4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong1 other) { + simd_ulong4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4_undef(simd_ulong1 other) { + simd_ulong4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong2 other) { + simd_ulong4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4_undef(simd_ulong2 other) { + simd_ulong4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong3 other) { + simd_ulong4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4_undef(simd_ulong3 other) { + simd_ulong4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong4 simd_make_ulong4(simd_ulong8 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit + * unsigned integers. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong4 lo, simd_ulong4 hi) { + simd_ulong8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong1 other) { + simd_ulong8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8_undef(simd_ulong1 other) { + simd_ulong8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong2 other) { + simd_ulong8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8_undef(simd_ulong2 other) { + simd_ulong8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong3 other) { + simd_ulong8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8_undef(simd_ulong3 other) { + simd_ulong8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit unsigned + * integers. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong4 other) { + simd_ulong8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8_undef(simd_ulong4 other) { + simd_ulong8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_ulong8 simd_make_ulong8(simd_ulong8 other) { + return other; +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double2 simd_make_double2(double x, double y) { + simd_double2 result; + result.x = x; + result.y = y; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of two 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double2 simd_make_double2(double other) { + simd_double2 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of two 64-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +static inline SIMD_CFUNC simd_double2 simd_make_double2_undef(double other) { + simd_double2 result; + result.x = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_double2 simd_make_double2(simd_double2 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double2 simd_make_double2(simd_double3 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double2 simd_make_double2(simd_double4 other) { + return other.xy; +} + +/*! @abstract Truncates `other` to form a vector of two 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double2 simd_make_double2(simd_double8 other) { + return other.xy; +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3(double x, double y, double z) { + simd_double3 result; + result.x = x; + result.y = y; + result.z = z; + return result; +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3(double x, simd_double2 yz) { + simd_double3 result; + result.x = x; + result.yz = yz; + return result; +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double2 xy, double z) { + simd_double3 result; + result.xy = xy; + result.z = z; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3(double other) { + simd_double3 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 64-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3_undef(double other) { + simd_double3 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of three 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double2 other) { + simd_double3 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of three 64-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3_undef(simd_double2 other) { + simd_double3 result; + result.xy = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double3 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of three 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double4 other) { + return other.xyz; +} + +/*! @abstract Truncates `other` to form a vector of three 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double3 simd_make_double3(simd_double8 other) { + return other.xyz; +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 64-bit floating-point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(double x, double y, double z, double w) { + simd_double4 result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(double x, double y, simd_double2 zw) { + simd_double4 result; + result.x = x; + result.y = y; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(double x, simd_double2 yz, double w) { + simd_double4 result; + result.x = x; + result.yz = yz; + result.w = w; + return result; +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double2 xy, double z, double w) { + simd_double4 result; + result.xy = xy; + result.z = z; + result.w = w; + return result; +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(double x, simd_double3 yzw) { + simd_double4 result; + result.x = x; + result.yzw = yzw; + return result; +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double2 xy, simd_double2 zw) { + simd_double4 result; + result.xy = xy; + result.zw = zw; + return result; +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double3 xyz, double w) { + simd_double4 result; + result.xyz = xyz; + result.w = w; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(double other) { + simd_double4 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4_undef(double other) { + simd_double4 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double2 other) { + simd_double4 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4_undef(simd_double2 other) { + simd_double4 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of four 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double3 other) { + simd_double4 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of four 64-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4_undef(simd_double3 other) { + simd_double4 result; + result.xyz = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double4 other) { + return other; +} + +/*! @abstract Truncates `other` to form a vector of four 64-bit floating- + * point numbers. */ +static inline SIMD_CFUNC simd_double4 simd_make_double4(simd_double8 other) { + return other.xyzw; +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double4 lo, simd_double4 hi) { + simd_double8 result; + result.lo = lo; + result.hi = hi; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8(double other) { + simd_double8 result = 0; + result.x = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8_undef(double other) { + simd_double8 result; + result.x = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double2 other) { + simd_double8 result = 0; + result.xy = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8_undef(simd_double2 other) { + simd_double8 result; + result.xy = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double3 other) { + simd_double8 result = 0; + result.xyz = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8_undef(simd_double3 other) { + simd_double8 result; + result.xyz = other; + return result; +} + +/*! @abstract Zero-extends `other` to form a vector of eight 64-bit + * floating-point numbers. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double4 other) { + simd_double8 result = 0; + result.xyzw = other; + return result; +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8_undef(simd_double4 other) { + simd_double8 result; + result.xyzw = other; + return result; +} + +/*! @abstract Returns `other` unmodified. This function is a convenience for + * templated and autogenerated code. */ +static inline SIMD_CFUNC simd_double8 simd_make_double8(simd_double8 other) { + return other; +} + +#ifdef __cplusplus +} /* extern "C" */ + +namespace simd { +/*! @abstract Concatenates `x` and `y` to form a vector of two 8-bit signed + * (twos-complement) integers. */ +static inline SIMD_CPPFUNC char2 make_char2(char x, char y) { + return ::simd_make_char2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 8-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC char2 make_char2(typeN other) { + return ::simd_make_char2(other); +} + +/*! @abstract Extends `other` to form a vector of two 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC char2 make_char2_undef(typeN other) { + return ::simd_make_char2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char3 make_char3(char x, char y, char z) { + return ::simd_make_char3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char3 make_char3(char x, char2 yz) { + return ::simd_make_char3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char3 make_char3(char2 xy, char z) { + return ::simd_make_char3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 8-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC char3 make_char3(typeN other) { + return ::simd_make_char3(other); +} + +/*! @abstract Extends `other` to form a vector of three 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC char3 make_char3_undef(typeN other) { + return ::simd_make_char3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 8-bit signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char4 make_char4(char x, char y, char z, char w) { + return ::simd_make_char4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char4 make_char4(char x, char y, char2 zw) { + return ::simd_make_char4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char4 make_char4(char x, char2 yz, char w) { + return ::simd_make_char4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char4 make_char4(char2 xy, char z, char w) { + return ::simd_make_char4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char4 make_char4(char x, char3 yzw) { + return ::simd_make_char4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char4 make_char4(char2 xy, char2 zw) { + return ::simd_make_char4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char4 make_char4(char3 xyz, char w) { + return ::simd_make_char4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 8-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC char4 make_char4(typeN other) { + return ::simd_make_char4(other); +} + +/*! @abstract Extends `other` to form a vector of four 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC char4 make_char4_undef(typeN other) { + return ::simd_make_char4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char8 make_char8(char4 lo, char4 hi) { + return ::simd_make_char8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 8-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC char8 make_char8(typeN other) { + return ::simd_make_char8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC char8 make_char8_undef(typeN other) { + return ::simd_make_char8_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 8-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char16 make_char16(char8 lo, char8 hi) { + return ::simd_make_char16(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen + * 8-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC char16 make_char16(typeN other) { + return ::simd_make_char16(other); +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +template static SIMD_CPPFUNC char16 make_char16_undef(typeN other) { + return ::simd_make_char16_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two + * 8-bit signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char32 make_char32(char16 lo, char16 hi) { + return ::simd_make_char32(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of thirty- + * two 8-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC char32 make_char32(typeN other) { + return ::simd_make_char32(other); +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +template static SIMD_CPPFUNC char32 make_char32_undef(typeN other) { + return ::simd_make_char32_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixty-four + * 8-bit signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC char64 make_char64(char32 lo, char32 hi) { + return ::simd_make_char64(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixty- + * four 8-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC char64 make_char64(typeN other) { + return ::simd_make_char64(other); +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +template static SIMD_CPPFUNC char64 make_char64_undef(typeN other) { + return ::simd_make_char64_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar2 make_uchar2(unsigned char x, unsigned char y) { + return ::simd_make_uchar2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 8-bit unsigned integers. */ +template static SIMD_CPPFUNC uchar2 make_uchar2(typeN other) { + return ::simd_make_uchar2(other); +} + +/*! @abstract Extends `other` to form a vector of two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uchar2 make_uchar2_undef(typeN other) { + return ::simd_make_uchar2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar3 make_uchar3(unsigned char x, unsigned char y, unsigned char z) { + return ::simd_make_uchar3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar3 make_uchar3(unsigned char x, uchar2 yz) { + return ::simd_make_uchar3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar3 make_uchar3(uchar2 xy, unsigned char z) { + return ::simd_make_uchar3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 8-bit unsigned integers. */ +template static SIMD_CPPFUNC uchar3 make_uchar3(typeN other) { + return ::simd_make_uchar3(other); +} + +/*! @abstract Extends `other` to form a vector of three 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uchar3 make_uchar3_undef(typeN other) { + return ::simd_make_uchar3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 8-bit unsigned integers. */ +static inline SIMD_CPPFUNC uchar4 make_uchar4(unsigned char x, unsigned char y, unsigned char z, unsigned char w) { + return ::simd_make_uchar4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar4 make_uchar4(unsigned char x, unsigned char y, uchar2 zw) { + return ::simd_make_uchar4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar4 make_uchar4(unsigned char x, uchar2 yz, unsigned char w) { + return ::simd_make_uchar4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar4 make_uchar4(uchar2 xy, unsigned char z, unsigned char w) { + return ::simd_make_uchar4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar4 make_uchar4(unsigned char x, uchar3 yzw) { + return ::simd_make_uchar4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar4 make_uchar4(uchar2 xy, uchar2 zw) { + return ::simd_make_uchar4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar4 make_uchar4(uchar3 xyz, unsigned char w) { + return ::simd_make_uchar4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 8-bit unsigned integers. */ +template static SIMD_CPPFUNC uchar4 make_uchar4(typeN other) { + return ::simd_make_uchar4(other); +} + +/*! @abstract Extends `other` to form a vector of four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uchar4 make_uchar4_undef(typeN other) { + return ::simd_make_uchar4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar8 make_uchar8(uchar4 lo, uchar4 hi) { + return ::simd_make_uchar8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 8-bit unsigned integers. */ +template static SIMD_CPPFUNC uchar8 make_uchar8(typeN other) { + return ::simd_make_uchar8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uchar8 make_uchar8_undef(typeN other) { + return ::simd_make_uchar8_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 8-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uchar16 make_uchar16(uchar8 lo, uchar8 hi) { + return ::simd_make_uchar16(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen + * 8-bit unsigned integers. */ +template static SIMD_CPPFUNC uchar16 make_uchar16(typeN other) { + return ::simd_make_uchar16(other); +} + +/*! @abstract Extends `other` to form a vector of sixteen 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uchar16 make_uchar16_undef(typeN other) { + return ::simd_make_uchar16_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two + * 8-bit unsigned integers. */ +static inline SIMD_CPPFUNC uchar32 make_uchar32(uchar16 lo, uchar16 hi) { + return ::simd_make_uchar32(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of thirty- + * two 8-bit unsigned integers. */ +template static SIMD_CPPFUNC uchar32 make_uchar32(typeN other) { + return ::simd_make_uchar32(other); +} + +/*! @abstract Extends `other` to form a vector of thirty-two 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uchar32 make_uchar32_undef(typeN other) { + return ::simd_make_uchar32_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixty-four + * 8-bit unsigned integers. */ +static inline SIMD_CPPFUNC uchar64 make_uchar64(uchar32 lo, uchar32 hi) { + return ::simd_make_uchar64(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixty- + * four 8-bit unsigned integers. */ +template static SIMD_CPPFUNC uchar64 make_uchar64(typeN other) { + return ::simd_make_uchar64(other); +} + +/*! @abstract Extends `other` to form a vector of sixty-four 8-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uchar64 make_uchar64_undef(typeN other) { + return ::simd_make_uchar64_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 16-bit signed + * (twos-complement) integers. */ +static inline SIMD_CPPFUNC short2 make_short2(short x, short y) { + return ::simd_make_short2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 16-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC short2 make_short2(typeN other) { + return ::simd_make_short2(other); +} + +/*! @abstract Extends `other` to form a vector of two 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC short2 make_short2_undef(typeN other) { + return ::simd_make_short2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short3 make_short3(short x, short y, short z) { + return ::simd_make_short3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short3 make_short3(short x, short2 yz) { + return ::simd_make_short3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short3 make_short3(short2 xy, short z) { + return ::simd_make_short3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 16-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC short3 make_short3(typeN other) { + return ::simd_make_short3(other); +} + +/*! @abstract Extends `other` to form a vector of three 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC short3 make_short3_undef(typeN other) { + return ::simd_make_short3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 16-bit signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short4 make_short4(short x, short y, short z, short w) { + return ::simd_make_short4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short4 make_short4(short x, short y, short2 zw) { + return ::simd_make_short4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short4 make_short4(short x, short2 yz, short w) { + return ::simd_make_short4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short4 make_short4(short2 xy, short z, short w) { + return ::simd_make_short4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short4 make_short4(short x, short3 yzw) { + return ::simd_make_short4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short4 make_short4(short2 xy, short2 zw) { + return ::simd_make_short4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short4 make_short4(short3 xyz, short w) { + return ::simd_make_short4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 16-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC short4 make_short4(typeN other) { + return ::simd_make_short4(other); +} + +/*! @abstract Extends `other` to form a vector of four 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC short4 make_short4_undef(typeN other) { + return ::simd_make_short4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short8 make_short8(short4 lo, short4 hi) { + return ::simd_make_short8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 16-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC short8 make_short8(typeN other) { + return ::simd_make_short8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC short8 make_short8_undef(typeN other) { + return ::simd_make_short8_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 16-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short16 make_short16(short8 lo, short8 hi) { + return ::simd_make_short16(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen + * 16-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC short16 make_short16(typeN other) { + return ::simd_make_short16(other); +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +template static SIMD_CPPFUNC short16 make_short16_undef(typeN other) { + return ::simd_make_short16_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two + * 16-bit signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC short32 make_short32(short16 lo, short16 hi) { + return ::simd_make_short32(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of thirty- + * two 16-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC short32 make_short32(typeN other) { + return ::simd_make_short32(other); +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +template static SIMD_CPPFUNC short32 make_short32_undef(typeN other) { + return ::simd_make_short32_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort2 make_ushort2(unsigned short x, unsigned short y) { + return ::simd_make_ushort2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 16-bit unsigned integers. */ +template static SIMD_CPPFUNC ushort2 make_ushort2(typeN other) { + return ::simd_make_ushort2(other); +} + +/*! @abstract Extends `other` to form a vector of two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ushort2 make_ushort2_undef(typeN other) { + return ::simd_make_ushort2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort3 make_ushort3(unsigned short x, unsigned short y, unsigned short z) { + return ::simd_make_ushort3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort3 make_ushort3(unsigned short x, ushort2 yz) { + return ::simd_make_ushort3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort3 make_ushort3(ushort2 xy, unsigned short z) { + return ::simd_make_ushort3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 16-bit unsigned integers. */ +template static SIMD_CPPFUNC ushort3 make_ushort3(typeN other) { + return ::simd_make_ushort3(other); +} + +/*! @abstract Extends `other` to form a vector of three 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ushort3 make_ushort3_undef(typeN other) { + return ::simd_make_ushort3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 16-bit unsigned integers. */ +static inline SIMD_CPPFUNC ushort4 make_ushort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) { + return ::simd_make_ushort4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort4 make_ushort4(unsigned short x, unsigned short y, ushort2 zw) { + return ::simd_make_ushort4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort4 make_ushort4(unsigned short x, ushort2 yz, unsigned short w) { + return ::simd_make_ushort4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort4 make_ushort4(ushort2 xy, unsigned short z, unsigned short w) { + return ::simd_make_ushort4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort4 make_ushort4(unsigned short x, ushort3 yzw) { + return ::simd_make_ushort4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort4 make_ushort4(ushort2 xy, ushort2 zw) { + return ::simd_make_ushort4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort4 make_ushort4(ushort3 xyz, unsigned short w) { + return ::simd_make_ushort4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 16-bit unsigned integers. */ +template static SIMD_CPPFUNC ushort4 make_ushort4(typeN other) { + return ::simd_make_ushort4(other); +} + +/*! @abstract Extends `other` to form a vector of four 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ushort4 make_ushort4_undef(typeN other) { + return ::simd_make_ushort4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort8 make_ushort8(ushort4 lo, ushort4 hi) { + return ::simd_make_ushort8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 16-bit unsigned integers. */ +template static SIMD_CPPFUNC ushort8 make_ushort8(typeN other) { + return ::simd_make_ushort8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ushort8 make_ushort8_undef(typeN other) { + return ::simd_make_ushort8_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 16-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ushort16 make_ushort16(ushort8 lo, ushort8 hi) { + return ::simd_make_ushort16(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen + * 16-bit unsigned integers. */ +template static SIMD_CPPFUNC ushort16 make_ushort16(typeN other) { + return ::simd_make_ushort16(other); +} + +/*! @abstract Extends `other` to form a vector of sixteen 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ushort16 make_ushort16_undef(typeN other) { + return ::simd_make_ushort16_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of thirty-two + * 16-bit unsigned integers. */ +static inline SIMD_CPPFUNC ushort32 make_ushort32(ushort16 lo, ushort16 hi) { + return ::simd_make_ushort32(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of thirty- + * two 16-bit unsigned integers. */ +template static SIMD_CPPFUNC ushort32 make_ushort32(typeN other) { + return ::simd_make_ushort32(other); +} + +/*! @abstract Extends `other` to form a vector of thirty-two 16-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ushort32 make_ushort32_undef(typeN other) { + return ::simd_make_ushort32_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit signed + * (twos-complement) integers. */ +static inline SIMD_CPPFUNC int2 make_int2(int x, int y) { + return ::simd_make_int2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 32-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC int2 make_int2(typeN other) { + return ::simd_make_int2(other); +} + +/*! @abstract Extends `other` to form a vector of two 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC int2 make_int2_undef(typeN other) { + return ::simd_make_int2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int3 make_int3(int x, int y, int z) { + return ::simd_make_int3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int3 make_int3(int x, int2 yz) { + return ::simd_make_int3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int3 make_int3(int2 xy, int z) { + return ::simd_make_int3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 32-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC int3 make_int3(typeN other) { + return ::simd_make_int3(other); +} + +/*! @abstract Extends `other` to form a vector of three 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC int3 make_int3_undef(typeN other) { + return ::simd_make_int3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 32-bit signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int4 make_int4(int x, int y, int z, int w) { + return ::simd_make_int4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int4 make_int4(int x, int y, int2 zw) { + return ::simd_make_int4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int4 make_int4(int x, int2 yz, int w) { + return ::simd_make_int4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int4 make_int4(int2 xy, int z, int w) { + return ::simd_make_int4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int4 make_int4(int x, int3 yzw) { + return ::simd_make_int4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int4 make_int4(int2 xy, int2 zw) { + return ::simd_make_int4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int4 make_int4(int3 xyz, int w) { + return ::simd_make_int4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 32-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC int4 make_int4(typeN other) { + return ::simd_make_int4(other); +} + +/*! @abstract Extends `other` to form a vector of four 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC int4 make_int4_undef(typeN other) { + return ::simd_make_int4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int8 make_int8(int4 lo, int4 hi) { + return ::simd_make_int8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 32-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC int8 make_int8(typeN other) { + return ::simd_make_int8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC int8 make_int8_undef(typeN other) { + return ::simd_make_int8_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC int16 make_int16(int8 lo, int8 hi) { + return ::simd_make_int16(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen + * 32-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC int16 make_int16(typeN other) { + return ::simd_make_int16(other); +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit signed + * (twos-complement) integers. The contents of the newly-created vector + * lanes are unspecified. */ +template static SIMD_CPPFUNC int16 make_int16_undef(typeN other) { + return ::simd_make_int16_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint2 make_uint2(unsigned int x, unsigned int y) { + return ::simd_make_uint2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 32-bit unsigned integers. */ +template static SIMD_CPPFUNC uint2 make_uint2(typeN other) { + return ::simd_make_uint2(other); +} + +/*! @abstract Extends `other` to form a vector of two 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uint2 make_uint2_undef(typeN other) { + return ::simd_make_uint2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint3 make_uint3(unsigned int x, unsigned int y, unsigned int z) { + return ::simd_make_uint3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint3 make_uint3(unsigned int x, uint2 yz) { + return ::simd_make_uint3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint3 make_uint3(uint2 xy, unsigned int z) { + return ::simd_make_uint3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 32-bit unsigned integers. */ +template static SIMD_CPPFUNC uint3 make_uint3(typeN other) { + return ::simd_make_uint3(other); +} + +/*! @abstract Extends `other` to form a vector of three 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uint3 make_uint3_undef(typeN other) { + return ::simd_make_uint3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 32-bit unsigned integers. */ +static inline SIMD_CPPFUNC uint4 make_uint4(unsigned int x, unsigned int y, unsigned int z, unsigned int w) { + return ::simd_make_uint4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint4 make_uint4(unsigned int x, unsigned int y, uint2 zw) { + return ::simd_make_uint4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint4 make_uint4(unsigned int x, uint2 yz, unsigned int w) { + return ::simd_make_uint4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint4 make_uint4(uint2 xy, unsigned int z, unsigned int w) { + return ::simd_make_uint4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint4 make_uint4(unsigned int x, uint3 yzw) { + return ::simd_make_uint4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint4 make_uint4(uint2 xy, uint2 zw) { + return ::simd_make_uint4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint4 make_uint4(uint3 xyz, unsigned int w) { + return ::simd_make_uint4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 32-bit unsigned integers. */ +template static SIMD_CPPFUNC uint4 make_uint4(typeN other) { + return ::simd_make_uint4(other); +} + +/*! @abstract Extends `other` to form a vector of four 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uint4 make_uint4_undef(typeN other) { + return ::simd_make_uint4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint8 make_uint8(uint4 lo, uint4 hi) { + return ::simd_make_uint8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 32-bit unsigned integers. */ +template static SIMD_CPPFUNC uint8 make_uint8(typeN other) { + return ::simd_make_uint8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uint8 make_uint8_undef(typeN other) { + return ::simd_make_uint8_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC uint16 make_uint16(uint8 lo, uint8 hi) { + return ::simd_make_uint16(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen + * 32-bit unsigned integers. */ +template static SIMD_CPPFUNC uint16 make_uint16(typeN other) { + return ::simd_make_uint16(other); +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC uint16 make_uint16_undef(typeN other) { + return ::simd_make_uint16_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float2 make_float2(float x, float y) { + return ::simd_make_float2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 32-bit floating-point numbers. */ +template static SIMD_CPPFUNC float2 make_float2(typeN other) { + return ::simd_make_float2(other); +} + +/*! @abstract Extends `other` to form a vector of two 32-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +template static SIMD_CPPFUNC float2 make_float2_undef(typeN other) { + return ::simd_make_float2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float3 make_float3(float x, float y, float z) { + return ::simd_make_float3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float3 make_float3(float x, float2 yz) { + return ::simd_make_float3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float3 make_float3(float2 xy, float z) { + return ::simd_make_float3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 32-bit floating-point numbers. */ +template static SIMD_CPPFUNC float3 make_float3(typeN other) { + return ::simd_make_float3(other); +} + +/*! @abstract Extends `other` to form a vector of three 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC float3 make_float3_undef(typeN other) { + return ::simd_make_float3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 32-bit floating-point numbers. */ +static inline SIMD_CPPFUNC float4 make_float4(float x, float y, float z, float w) { + return ::simd_make_float4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float4 make_float4(float x, float y, float2 zw) { + return ::simd_make_float4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float4 make_float4(float x, float2 yz, float w) { + return ::simd_make_float4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float4 make_float4(float2 xy, float z, float w) { + return ::simd_make_float4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float4 make_float4(float x, float3 yzw) { + return ::simd_make_float4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float4 make_float4(float2 xy, float2 zw) { + return ::simd_make_float4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float4 make_float4(float3 xyz, float w) { + return ::simd_make_float4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 32-bit floating-point numbers. */ +template static SIMD_CPPFUNC float4 make_float4(typeN other) { + return ::simd_make_float4(other); +} + +/*! @abstract Extends `other` to form a vector of four 32-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +template static SIMD_CPPFUNC float4 make_float4_undef(typeN other) { + return ::simd_make_float4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float8 make_float8(float4 lo, float4 hi) { + return ::simd_make_float8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 32-bit floating-point numbers. */ +template static SIMD_CPPFUNC float8 make_float8(typeN other) { + return ::simd_make_float8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC float8 make_float8_undef(typeN other) { + return ::simd_make_float8_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of sixteen 32-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC float16 make_float16(float8 lo, float8 hi) { + return ::simd_make_float16(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of sixteen + * 32-bit floating-point numbers. */ +template static SIMD_CPPFUNC float16 make_float16(typeN other) { + return ::simd_make_float16(other); +} + +/*! @abstract Extends `other` to form a vector of sixteen 32-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC float16 make_float16_undef(typeN other) { + return ::simd_make_float16_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit signed + * (twos-complement) integers. */ +static inline SIMD_CPPFUNC long2 make_long2(long1 x, long1 y) { + return ::simd_make_long2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 64-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC long2 make_long2(typeN other) { + return ::simd_make_long2(other); +} + +/*! @abstract Extends `other` to form a vector of two 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC long2 make_long2_undef(typeN other) { + return ::simd_make_long2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long3 make_long3(long1 x, long1 y, long1 z) { + return ::simd_make_long3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long3 make_long3(long1 x, long2 yz) { + return ::simd_make_long3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long3 make_long3(long2 xy, long1 z) { + return ::simd_make_long3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 64-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC long3 make_long3(typeN other) { + return ::simd_make_long3(other); +} + +/*! @abstract Extends `other` to form a vector of three 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC long3 make_long3_undef(typeN other) { + return ::simd_make_long3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 64-bit signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long4 make_long4(long1 x, long1 y, long1 z, long1 w) { + return ::simd_make_long4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long4 make_long4(long1 x, long1 y, long2 zw) { + return ::simd_make_long4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long4 make_long4(long1 x, long2 yz, long1 w) { + return ::simd_make_long4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long4 make_long4(long2 xy, long1 z, long1 w) { + return ::simd_make_long4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long4 make_long4(long1 x, long3 yzw) { + return ::simd_make_long4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long4 make_long4(long2 xy, long2 zw) { + return ::simd_make_long4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long4 make_long4(long3 xyz, long1 w) { + return ::simd_make_long4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 64-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC long4 make_long4(typeN other) { + return ::simd_make_long4(other); +} + +/*! @abstract Extends `other` to form a vector of four 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC long4 make_long4_undef(typeN other) { + return ::simd_make_long4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit + * signed (twos-complement) integers. */ +static inline SIMD_CPPFUNC long8 make_long8(long4 lo, long4 hi) { + return ::simd_make_long8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 64-bit signed (twos-complement) integers. */ +template static SIMD_CPPFUNC long8 make_long8(typeN other) { + return ::simd_make_long8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit signed (twos- + * complement) integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC long8 make_long8_undef(typeN other) { + return ::simd_make_long8_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong2 make_ulong2(ulong1 x, ulong1 y) { + return ::simd_make_ulong2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 64-bit unsigned integers. */ +template static SIMD_CPPFUNC ulong2 make_ulong2(typeN other) { + return ::simd_make_ulong2(other); +} + +/*! @abstract Extends `other` to form a vector of two 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ulong2 make_ulong2_undef(typeN other) { + return ::simd_make_ulong2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong3 make_ulong3(ulong1 x, ulong1 y, ulong1 z) { + return ::simd_make_ulong3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong3 make_ulong3(ulong1 x, ulong2 yz) { + return ::simd_make_ulong3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong3 make_ulong3(ulong2 xy, ulong1 z) { + return ::simd_make_ulong3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 64-bit unsigned integers. */ +template static SIMD_CPPFUNC ulong3 make_ulong3(typeN other) { + return ::simd_make_ulong3(other); +} + +/*! @abstract Extends `other` to form a vector of three 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ulong3 make_ulong3_undef(typeN other) { + return ::simd_make_ulong3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 64-bit unsigned integers. */ +static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong1 x, ulong1 y, ulong1 z, ulong1 w) { + return ::simd_make_ulong4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong1 x, ulong1 y, ulong2 zw) { + return ::simd_make_ulong4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong1 x, ulong2 yz, ulong1 w) { + return ::simd_make_ulong4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong2 xy, ulong1 z, ulong1 w) { + return ::simd_make_ulong4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong1 x, ulong3 yzw) { + return ::simd_make_ulong4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong2 xy, ulong2 zw) { + return ::simd_make_ulong4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong4 make_ulong4(ulong3 xyz, ulong1 w) { + return ::simd_make_ulong4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 64-bit unsigned integers. */ +template static SIMD_CPPFUNC ulong4 make_ulong4(typeN other) { + return ::simd_make_ulong4(other); +} + +/*! @abstract Extends `other` to form a vector of four 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ulong4 make_ulong4_undef(typeN other) { + return ::simd_make_ulong4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit + * unsigned integers. */ +static inline SIMD_CPPFUNC ulong8 make_ulong8(ulong4 lo, ulong4 hi) { + return ::simd_make_ulong8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 64-bit unsigned integers. */ +template static SIMD_CPPFUNC ulong8 make_ulong8(typeN other) { + return ::simd_make_ulong8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit unsigned + * integers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC ulong8 make_ulong8_undef(typeN other) { + return ::simd_make_ulong8_undef(other); +} + +/*! @abstract Concatenates `x` and `y` to form a vector of two 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double2 make_double2(double x, double y) { + return ::simd_make_double2(x, y); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of two + * 64-bit floating-point numbers. */ +template static SIMD_CPPFUNC double2 make_double2(typeN other) { + return ::simd_make_double2(other); +} + +/*! @abstract Extends `other` to form a vector of two 64-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +template static SIMD_CPPFUNC double2 make_double2_undef(typeN other) { + return ::simd_make_double2_undef(other); +} + +/*! @abstract Concatenates `x`, `y` and `z` to form a vector of three 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double3 make_double3(double x, double y, double z) { + return ::simd_make_double3(x, y, z); +} + +/*! @abstract Concatenates `x` and `yz` to form a vector of three 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double3 make_double3(double x, double2 yz) { + return ::simd_make_double3(x, yz); +} + +/*! @abstract Concatenates `xy` and `z` to form a vector of three 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double3 make_double3(double2 xy, double z) { + return ::simd_make_double3(xy, z); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of three + * 64-bit floating-point numbers. */ +template static SIMD_CPPFUNC double3 make_double3(typeN other) { + return ::simd_make_double3(other); +} + +/*! @abstract Extends `other` to form a vector of three 64-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC double3 make_double3_undef(typeN other) { + return ::simd_make_double3_undef(other); +} + +/*! @abstract Concatenates `x`, `y`, `z` and `w` to form a vector of four + * 64-bit floating-point numbers. */ +static inline SIMD_CPPFUNC double4 make_double4(double x, double y, double z, double w) { + return ::simd_make_double4(x, y, z, w); +} + +/*! @abstract Concatenates `x`, `y` and `zw` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double4 make_double4(double x, double y, double2 zw) { + return ::simd_make_double4(x, y, zw); +} + +/*! @abstract Concatenates `x`, `yz` and `w` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double4 make_double4(double x, double2 yz, double w) { + return ::simd_make_double4(x, yz, w); +} + +/*! @abstract Concatenates `xy`, `z` and `w` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double4 make_double4(double2 xy, double z, double w) { + return ::simd_make_double4(xy, z, w); +} + +/*! @abstract Concatenates `x` and `yzw` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double4 make_double4(double x, double3 yzw) { + return ::simd_make_double4(x, yzw); +} + +/*! @abstract Concatenates `xy` and `zw` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double4 make_double4(double2 xy, double2 zw) { + return ::simd_make_double4(xy, zw); +} + +/*! @abstract Concatenates `xyz` and `w` to form a vector of four 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double4 make_double4(double3 xyz, double w) { + return ::simd_make_double4(xyz, w); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of four + * 64-bit floating-point numbers. */ +template static SIMD_CPPFUNC double4 make_double4(typeN other) { + return ::simd_make_double4(other); +} + +/*! @abstract Extends `other` to form a vector of four 64-bit floating-point + * numbers. The contents of the newly-created vector lanes are unspecified. */ +template static SIMD_CPPFUNC double4 make_double4_undef(typeN other) { + return ::simd_make_double4_undef(other); +} + +/*! @abstract Concatenates `lo` and `hi` to form a vector of eight 64-bit + * floating-point numbers. */ +static inline SIMD_CPPFUNC double8 make_double8(double4 lo, double4 hi) { + return ::simd_make_double8(lo, hi); +} + +/*! @abstract Truncates or zero-extends `other` to form a vector of eight + * 64-bit floating-point numbers. */ +template static SIMD_CPPFUNC double8 make_double8(typeN other) { + return ::simd_make_double8(other); +} + +/*! @abstract Extends `other` to form a vector of eight 64-bit floating- + * point numbers. The contents of the newly-created vector lanes are + * unspecified. */ +template static SIMD_CPPFUNC double8 make_double8_undef(typeN other) { + return ::simd_make_double8_undef(other); +} + +} /* namespace simd */ +#endif /* __cplusplus */ +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_VECTOR_CONSTRUCTORS */ diff --git a/lib/libc/include/x86_64-macos-gnu/simd/vector_types.h b/lib/libc/include/x86_64-macos-gnu/simd/vector_types.h new file mode 100644 index 0000000000..223d696e10 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/simd/vector_types.h @@ -0,0 +1,1281 @@ +/*! @header + * This header defines fixed size vector types that are useful both for + * graphics and geometry, and for software vectorization without + * architecture-specific intrinsics. + * + * These types are based on a clang feature called "Extended vector types" + * or "OpenCL vector types" (despite the name, these types work just fine + * in C, Objective-C, and C++). There are a few tricks that make these + * types nicer to work with than traditional simd intrinsic types: + * + * - Basic arithmetic operators are overloaded to perform lanewise + * operations with these types, including both vector-vector and + * vector-scalar operations. + * + * - It is possible to access vector components both via array-style + * subscripting and by using the "." operator with component names + * "x", "y", "z", "w", and permutations thereof. + * + * - There are also some named subvectors: .lo and .hi are the first + * and second halves of a vector, and .even and .odd are the even- + * and odd-indexed elements of a vector. + * + * - Clang provides some useful builtins that operate on these vector + * types: __builtin_shufflevector and __builtin_convertvector. + * + * - The headers define a large assortment of vector and + * matrix operations that work on these types. + * + * - You can also use the simd types with the architecture-specific + * intrinsics defined in and . + * + * The following vector types are defined by this header: + * + * simd_charN where N is 1, 2, 3, 4, 8, 16, 32, or 64. + * simd_ucharN where N is 1, 2, 3, 4, 8, 16, 32, or 64. + * simd_shortN where N is 1, 2, 3, 4, 8, 16, or 32. + * simd_ushortN where N is 1, 2, 3, 4, 8, 16, or 32. + * simd_intN where N is 1, 2, 3, 4, 8, or 16. + * simd_uintN where N is 1, 2, 3, 4, 8, or 16. + * simd_floatN where N is 1, 2, 3, 4, 8, or 16. + * simd_longN where N is 1, 2, 3, 4, or 8. + * simd_ulongN where N is 1, 2, 3, 4, or 8. + * simd_doubleN where N is 1, 2, 3, 4, or 8. + * + * These types generally have greater alignment than the underlying scalar + * type; they are aligned to either the size of the vector[1] or 16 bytes, + * whichever is smaller. + * + * [1] Note that sizeof a three-element vector is the same as sizeof the + * corresponding four-element vector, because three-element vectors have + * a hidden lane of padding. + * + * In earlier versions of the simd library, the alignment of vectors could + * be larger than 16B, up to the "architectural vector size" of 16, 32, or + * 64B, depending on what options were passed on the command line when + * compiling. This super-alignment does not interact well with malloc, and + * makes it difficult for libraries to provide a stable API, while conferring + * relatively little performance benefit, so it has been relaxed. + * + * For each simd_typeN type where N is not 1 or 3, there is also a + * corresponding simd_packed_typeN type that requires only the alignment + * matching that of the underlying scalar type. Use this if you need to + * work with pointers-to or arrays-of scalar values: + * + * void myFunction(float *pointerToFourFloats) { + * // This is a bug, because `pointerToFourFloats` does not satisfy + * // the alignment requirements of the `simd_float4` type; attempting + * // to dereference (load from) `vecptr` is likely to crash at runtime. + * simd_float4 *vecptr = (simd_float4 *)pointerToFourFloats; + * + * // Instead, convert to `simd_packed_float4`: + * simd_packed_float4 *vecptr = (simd_packed_float4 *)pointerToFourFloats; + * // The `simd_packed_float4` type has the same alignment requirements + * // as `float`, so this conversion is safe, and lets us load a vector. + * // Note that `simd_packed_float4` can be assigned to `simd_float4` + * // without any conversion; they types only behave differently as + * // pointers or arrays. + * simd_float4 vector = vecptr[0]; + * } + * + * All of the simd_-prefixed types are also available in the C++ simd:: + * namespace; simd_char4 can be used as simd::char4, for example. These types + * largely match the Metal shader language vector types, except that there + * are no vector types larger than 4 elements in Metal. + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_VECTOR_TYPES +#define SIMD_VECTOR_TYPES + +# include +# if SIMD_COMPILER_HAS_REQUIRED_FEATURES + +/* MARK: Basic vector types */ + +/*! @group C and Objective-C vector types + * @discussion These are the basic types that underpin the simd library. */ + +/*! @abstract A scalar 8-bit signed (twos-complement) integer. */ +typedef char simd_char1; + +/*! @abstract A vector of two 8-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::char2. The alignment of this type is greater than the alignment of + * char; if you need to operate on data buffers that may not be suitably + * aligned, you should access them using simd_packed_char2 instead. */ +typedef __attribute__((__ext_vector_type__(2))) char simd_char2; + +/*! @abstract A vector of three 8-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::char3. Note that vectors of this type are padded to have the same + * size and alignment as simd_char4. */ +typedef __attribute__((__ext_vector_type__(3))) char simd_char3; + +/*! @abstract A vector of four 8-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::char4. The alignment of this type is greater than the alignment of + * char; if you need to operate on data buffers that may not be suitably + * aligned, you should access them using simd_packed_char4 instead. */ +typedef __attribute__((__ext_vector_type__(4))) char simd_char4; + +/*! @abstract A vector of eight 8-bit signed (twos-complement) integers. + * @description In C++ this type is also available as simd::char8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of char; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_char8 instead. */ +typedef __attribute__((__ext_vector_type__(8))) char simd_char8; + +/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers. + * @description In C++ this type is also available as simd::char16. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of char; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_char16 instead. */ +typedef __attribute__((__ext_vector_type__(16))) char simd_char16; + +/*! @abstract A vector of thirty-two 8-bit signed (twos-complement) + * integers. + * @description In C++ this type is also available as simd::char32. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of char; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_char32 instead. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(16))) char simd_char32; + +/*! @abstract A vector of sixty-four 8-bit signed (twos-complement) + * integers. + * @description In C++ this type is also available as simd::char64. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of char; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_char64 instead. */ +typedef __attribute__((__ext_vector_type__(64),__aligned__(16))) char simd_char64; + +/*! @abstract A scalar 8-bit unsigned integer. */ +typedef unsigned char simd_uchar1; + +/*! @abstract A vector of two 8-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::uchar2. The alignment of this type is greater than the alignment + * of unsigned char; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_uchar2 + * instead. */ +typedef __attribute__((__ext_vector_type__(2))) unsigned char simd_uchar2; + +/*! @abstract A vector of three 8-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::uchar3. Note that vectors of this type are padded to have the same + * size and alignment as simd_uchar4. */ +typedef __attribute__((__ext_vector_type__(3))) unsigned char simd_uchar3; + +/*! @abstract A vector of four 8-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::uchar4. The alignment of this type is greater than the alignment + * of unsigned char; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_uchar4 + * instead. */ +typedef __attribute__((__ext_vector_type__(4))) unsigned char simd_uchar4; + +/*! @abstract A vector of eight 8-bit unsigned integers. + * @description In C++ this type is also available as simd::uchar8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned char; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_uchar8 instead. */ +typedef __attribute__((__ext_vector_type__(8))) unsigned char simd_uchar8; + +/*! @abstract A vector of sixteen 8-bit unsigned integers. + * @description In C++ this type is also available as simd::uchar16. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned char; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_uchar16 instead. */ +typedef __attribute__((__ext_vector_type__(16))) unsigned char simd_uchar16; + +/*! @abstract A vector of thirty-two 8-bit unsigned integers. + * @description In C++ this type is also available as simd::uchar32. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned char; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_uchar32 instead. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(16))) unsigned char simd_uchar32; + +/*! @abstract A vector of sixty-four 8-bit unsigned integers. + * @description In C++ this type is also available as simd::uchar64. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned char; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_uchar64 instead. */ +typedef __attribute__((__ext_vector_type__(64),__aligned__(16))) unsigned char simd_uchar64; + +/*! @abstract A scalar 16-bit signed (twos-complement) integer. */ +typedef short simd_short1; + +/*! @abstract A vector of two 16-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::short2. The alignment of this type is greater than the alignment + * of short; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_short2 + * instead. */ +typedef __attribute__((__ext_vector_type__(2))) short simd_short2; + +/*! @abstract A vector of three 16-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::short3. Note that vectors of this type are padded to have the same + * size and alignment as simd_short4. */ +typedef __attribute__((__ext_vector_type__(3))) short simd_short3; + +/*! @abstract A vector of four 16-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::short4. The alignment of this type is greater than the alignment + * of short; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_short4 + * instead. */ +typedef __attribute__((__ext_vector_type__(4))) short simd_short4; + +/*! @abstract A vector of eight 16-bit signed (twos-complement) integers. + * @description In C++ this type is also available as simd::short8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of short; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_short8 instead. */ +typedef __attribute__((__ext_vector_type__(8))) short simd_short8; + +/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers. + * @description In C++ this type is also available as simd::short16. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of short; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_short16 instead. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) short simd_short16; + +/*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers. + * @description In C++ this type is also available as simd::short32. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of short; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_short32 instead. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(16))) short simd_short32; + +/*! @abstract A scalar 16-bit unsigned integer. */ +typedef unsigned short simd_ushort1; + +/*! @abstract A vector of two 16-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::ushort2. The alignment of this type is greater than the alignment + * of unsigned short; if you need to operate on data buffers that may not + * be suitably aligned, you should access them using simd_packed_ushort2 + * instead. */ +typedef __attribute__((__ext_vector_type__(2))) unsigned short simd_ushort2; + +/*! @abstract A vector of three 16-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::ushort3. Note that vectors of this type are padded to have the + * same size and alignment as simd_ushort4. */ +typedef __attribute__((__ext_vector_type__(3))) unsigned short simd_ushort3; + +/*! @abstract A vector of four 16-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::ushort4. The alignment of this type is greater than the alignment + * of unsigned short; if you need to operate on data buffers that may not + * be suitably aligned, you should access them using simd_packed_ushort4 + * instead. */ +typedef __attribute__((__ext_vector_type__(4))) unsigned short simd_ushort4; + +/*! @abstract A vector of eight 16-bit unsigned integers. + * @description In C++ this type is also available as simd::ushort8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned short; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_ushort8 instead. */ +typedef __attribute__((__ext_vector_type__(8))) unsigned short simd_ushort8; + +/*! @abstract A vector of sixteen 16-bit unsigned integers. + * @description In C++ this type is also available as simd::ushort16. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned short; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_ushort16 instead. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) unsigned short simd_ushort16; + +/*! @abstract A vector of thirty-two 16-bit unsigned integers. + * @description In C++ this type is also available as simd::ushort32. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned short; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_ushort32 instead. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(16))) unsigned short simd_ushort32; + +/*! @abstract A scalar 32-bit signed (twos-complement) integer. */ +typedef int simd_int1; + +/*! @abstract A vector of two 32-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::int2. The alignment of this type is greater than the alignment of + * int; if you need to operate on data buffers that may not be suitably + * aligned, you should access them using simd_packed_int2 instead. */ +typedef __attribute__((__ext_vector_type__(2))) int simd_int2; + +/*! @abstract A vector of three 32-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::int3. Note that vectors of this type are padded to have the same + * size and alignment as simd_int4. */ +typedef __attribute__((__ext_vector_type__(3))) int simd_int3; + +/*! @abstract A vector of four 32-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::int4. The alignment of this type is greater than the alignment of + * int; if you need to operate on data buffers that may not be suitably + * aligned, you should access them using simd_packed_int4 instead. */ +typedef __attribute__((__ext_vector_type__(4))) int simd_int4; + +/*! @abstract A vector of eight 32-bit signed (twos-complement) integers. + * @description In C++ this type is also available as simd::int8. This type + * is not available in Metal. The alignment of this type is greater than + * the alignment of int; if you need to operate on data buffers that may + * not be suitably aligned, you should access them using simd_packed_int8 + * instead. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) int simd_int8; + +/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers. + * @description In C++ this type is also available as simd::int16. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of int; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_int16 instead. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) int simd_int16; + +/*! @abstract A scalar 32-bit unsigned integer. */ +typedef unsigned int simd_uint1; + +/*! @abstract A vector of two 32-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::uint2. The alignment of this type is greater than the alignment of + * unsigned int; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_uint2 + * instead. */ +typedef __attribute__((__ext_vector_type__(2))) unsigned int simd_uint2; + +/*! @abstract A vector of three 32-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::uint3. Note that vectors of this type are padded to have the same + * size and alignment as simd_uint4. */ +typedef __attribute__((__ext_vector_type__(3))) unsigned int simd_uint3; + +/*! @abstract A vector of four 32-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::uint4. The alignment of this type is greater than the alignment of + * unsigned int; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_uint4 + * instead. */ +typedef __attribute__((__ext_vector_type__(4))) unsigned int simd_uint4; + +/*! @abstract A vector of eight 32-bit unsigned integers. + * @description In C++ this type is also available as simd::uint8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned int; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_uint8 instead. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) unsigned int simd_uint8; + +/*! @abstract A vector of sixteen 32-bit unsigned integers. + * @description In C++ this type is also available as simd::uint16. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of unsigned int; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_uint16 instead. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) unsigned int simd_uint16; + +/*! @abstract A scalar 32-bit floating-point number. */ +typedef float simd_float1; + +/*! @abstract A vector of two 32-bit floating-point numbers. + * @description In C++ and Metal, this type is also available as + * simd::float2. The alignment of this type is greater than the alignment + * of float; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_float2 + * instead. */ +typedef __attribute__((__ext_vector_type__(2))) float simd_float2; + +/*! @abstract A vector of three 32-bit floating-point numbers. + * @description In C++ and Metal, this type is also available as + * simd::float3. Note that vectors of this type are padded to have the same + * size and alignment as simd_float4. */ +typedef __attribute__((__ext_vector_type__(3))) float simd_float3; + +/*! @abstract A vector of four 32-bit floating-point numbers. + * @description In C++ and Metal, this type is also available as + * simd::float4. The alignment of this type is greater than the alignment + * of float; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_float4 + * instead. */ +typedef __attribute__((__ext_vector_type__(4))) float simd_float4; + +/*! @abstract A vector of eight 32-bit floating-point numbers. + * @description In C++ this type is also available as simd::float8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of float; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_float8 instead. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) float simd_float8; + +/*! @abstract A vector of sixteen 32-bit floating-point numbers. + * @description In C++ this type is also available as simd::float16. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of float; if you need to operate on data buffers that + * may not be suitably aligned, you should access them using + * simd_packed_float16 instead. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(16))) float simd_float16; + +/*! @abstract A scalar 64-bit signed (twos-complement) integer. */ +#if defined __LP64__ +typedef long simd_long1; +#else +typedef long long simd_long1; +#endif + +/*! @abstract A vector of two 64-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::long2. The alignment of this type is greater than the alignment of + * simd_long1; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_long2 + * instead. */ +typedef __attribute__((__ext_vector_type__(2))) simd_long1 simd_long2; + +/*! @abstract A vector of three 64-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::long3. Note that vectors of this type are padded to have the same + * size and alignment as simd_long4. */ +typedef __attribute__((__ext_vector_type__(3),__aligned__(16))) simd_long1 simd_long3; + +/*! @abstract A vector of four 64-bit signed (twos-complement) integers. + * @description In C++ and Metal, this type is also available as + * simd::long4. The alignment of this type is greater than the alignment of + * simd_long1; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_long4 + * instead. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(16))) simd_long1 simd_long4; + +/*! @abstract A vector of eight 64-bit signed (twos-complement) integers. + * @description In C++ this type is also available as simd::long8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of simd_long1; if you need to operate on data buffers + * that may not be suitably aligned, you should access them using + * simd_packed_long8 instead. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) simd_long1 simd_long8; + +/*! @abstract A scalar 64-bit unsigned integer. */ +#if defined __LP64__ +typedef unsigned long simd_ulong1; +#else +typedef unsigned long long simd_ulong1; +#endif + +/*! @abstract A vector of two 64-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::ulong2. The alignment of this type is greater than the alignment + * of simd_ulong1; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_ulong2 + * instead. */ +typedef __attribute__((__ext_vector_type__(2))) simd_ulong1 simd_ulong2; + +/*! @abstract A vector of three 64-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::ulong3. Note that vectors of this type are padded to have the same + * size and alignment as simd_ulong4. */ +typedef __attribute__((__ext_vector_type__(3),__aligned__(16))) simd_ulong1 simd_ulong3; + +/*! @abstract A vector of four 64-bit unsigned integers. + * @description In C++ and Metal, this type is also available as + * simd::ulong4. The alignment of this type is greater than the alignment + * of simd_ulong1; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_ulong4 + * instead. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(16))) simd_ulong1 simd_ulong4; + +/*! @abstract A vector of eight 64-bit unsigned integers. + * @description In C++ this type is also available as simd::ulong8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of simd_ulong1; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd_packed_ulong8 instead. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) simd_ulong1 simd_ulong8; + +/*! @abstract A scalar 64-bit floating-point number. */ +typedef double simd_double1; + +/*! @abstract A vector of two 64-bit floating-point numbers. + * @description In C++ and Metal, this type is also available as + * simd::double2. The alignment of this type is greater than the alignment + * of double; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_double2 + * instead. */ +typedef __attribute__((__ext_vector_type__(2))) double simd_double2; + +/*! @abstract A vector of three 64-bit floating-point numbers. + * @description In C++ and Metal, this type is also available as + * simd::double3. Note that vectors of this type are padded to have the + * same size and alignment as simd_double4. */ +typedef __attribute__((__ext_vector_type__(3),__aligned__(16))) double simd_double3; + +/*! @abstract A vector of four 64-bit floating-point numbers. + * @description In C++ and Metal, this type is also available as + * simd::double4. The alignment of this type is greater than the alignment + * of double; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd_packed_double4 + * instead. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(16))) double simd_double4; + +/*! @abstract A vector of eight 64-bit floating-point numbers. + * @description In C++ this type is also available as simd::double8. This + * type is not available in Metal. The alignment of this type is greater + * than the alignment of double; if you need to operate on data buffers + * that may not be suitably aligned, you should access them using + * simd_packed_double8 instead. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(16))) double simd_double8; + +/* MARK: C++ vector types */ +#if defined __cplusplus +/*! @group C++ and Metal vector types + * @discussion Shorter type names available within the simd:: namespace. + * Each of these types is interchangable with the corresponding C type + * with the `simd_` prefix. */ +namespace simd { + /*! @abstract A scalar 8-bit signed (twos-complement) integer. + * @discussion In C and Objective-C, this type is available as + * simd_char1. */ +typedef ::simd_char1 char1; + + /*! @abstract A vector of two 8-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_char2. The alignment of this type is greater than the alignment + * of char; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_char2 + * instead. */ +typedef ::simd_char2 char2; + + /*! @abstract A vector of three 8-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_char3. Vectors of this type are padded to have the same size and + * alignment as simd_char4. */ +typedef ::simd_char3 char3; + + /*! @abstract A vector of four 8-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_char4. The alignment of this type is greater than the alignment + * of char; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_char4 + * instead. */ +typedef ::simd_char4 char4; + + /*! @abstract A vector of eight 8-bit signed (twos-complement) integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_char8. The alignment of this type is + * greater than the alignment of char; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_char8 instead. */ +typedef ::simd_char8 char8; + + /*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_char16. The alignment of this type is + * greater than the alignment of char; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_char16 instead. */ +typedef ::simd_char16 char16; + + /*! @abstract A vector of thirty-two 8-bit signed (twos-complement) + * integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_char32. The alignment of this type is + * greater than the alignment of char; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_char32 instead. */ +typedef ::simd_char32 char32; + + /*! @abstract A vector of sixty-four 8-bit signed (twos-complement) + * integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_char64. The alignment of this type is + * greater than the alignment of char; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_char64 instead. */ +typedef ::simd_char64 char64; + + /*! @abstract A scalar 8-bit unsigned integer. + * @discussion In C and Objective-C, this type is available as + * simd_uchar1. */ +typedef ::simd_uchar1 uchar1; + + /*! @abstract A vector of two 8-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_uchar2. The alignment of this type is greater than the alignment + * of unsigned char; if you need to operate on data buffers that may not + * be suitably aligned, you should access them using simd::packed_uchar2 + * instead. */ +typedef ::simd_uchar2 uchar2; + + /*! @abstract A vector of three 8-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_uchar3. Vectors of this type are padded to have the same size and + * alignment as simd_uchar4. */ +typedef ::simd_uchar3 uchar3; + + /*! @abstract A vector of four 8-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_uchar4. The alignment of this type is greater than the alignment + * of unsigned char; if you need to operate on data buffers that may not + * be suitably aligned, you should access them using simd::packed_uchar4 + * instead. */ +typedef ::simd_uchar4 uchar4; + + /*! @abstract A vector of eight 8-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_uchar8. The alignment of this type is + * greater than the alignment of unsigned char; if you need to operate on + * data buffers that may not be suitably aligned, you should access them + * using simd::packed_uchar8 instead. */ +typedef ::simd_uchar8 uchar8; + + /*! @abstract A vector of sixteen 8-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_uchar16. The alignment of this type is + * greater than the alignment of unsigned char; if you need to operate on + * data buffers that may not be suitably aligned, you should access them + * using simd::packed_uchar16 instead. */ +typedef ::simd_uchar16 uchar16; + + /*! @abstract A vector of thirty-two 8-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_uchar32. The alignment of this type is + * greater than the alignment of unsigned char; if you need to operate on + * data buffers that may not be suitably aligned, you should access them + * using simd::packed_uchar32 instead. */ +typedef ::simd_uchar32 uchar32; + + /*! @abstract A vector of sixty-four 8-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_uchar64. The alignment of this type is + * greater than the alignment of unsigned char; if you need to operate on + * data buffers that may not be suitably aligned, you should access them + * using simd::packed_uchar64 instead. */ +typedef ::simd_uchar64 uchar64; + + /*! @abstract A scalar 16-bit signed (twos-complement) integer. + * @discussion In C and Objective-C, this type is available as + * simd_short1. */ +typedef ::simd_short1 short1; + + /*! @abstract A vector of two 16-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_short2. The alignment of this type is greater than the alignment + * of short; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_short2 + * instead. */ +typedef ::simd_short2 short2; + + /*! @abstract A vector of three 16-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_short3. Vectors of this type are padded to have the same size and + * alignment as simd_short4. */ +typedef ::simd_short3 short3; + + /*! @abstract A vector of four 16-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_short4. The alignment of this type is greater than the alignment + * of short; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_short4 + * instead. */ +typedef ::simd_short4 short4; + + /*! @abstract A vector of eight 16-bit signed (twos-complement) integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_short8. The alignment of this type is + * greater than the alignment of short; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_short8 instead. */ +typedef ::simd_short8 short8; + + /*! @abstract A vector of sixteen 16-bit signed (twos-complement) + * integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_short16. The alignment of this type is + * greater than the alignment of short; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_short16 instead. */ +typedef ::simd_short16 short16; + + /*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_short32. The alignment of this type is + * greater than the alignment of short; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_short32 instead. */ +typedef ::simd_short32 short32; + + /*! @abstract A scalar 16-bit unsigned integer. + * @discussion In C and Objective-C, this type is available as + * simd_ushort1. */ +typedef ::simd_ushort1 ushort1; + + /*! @abstract A vector of two 16-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_ushort2. The alignment of this type is greater than the alignment + * of unsigned short; if you need to operate on data buffers that may not + * be suitably aligned, you should access them using simd::packed_ushort2 + * instead. */ +typedef ::simd_ushort2 ushort2; + + /*! @abstract A vector of three 16-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_ushort3. Vectors of this type are padded to have the same size + * and alignment as simd_ushort4. */ +typedef ::simd_ushort3 ushort3; + + /*! @abstract A vector of four 16-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_ushort4. The alignment of this type is greater than the alignment + * of unsigned short; if you need to operate on data buffers that may not + * be suitably aligned, you should access them using simd::packed_ushort4 + * instead. */ +typedef ::simd_ushort4 ushort4; + + /*! @abstract A vector of eight 16-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_ushort8. The alignment of this type is + * greater than the alignment of unsigned short; if you need to operate + * on data buffers that may not be suitably aligned, you should access + * them using simd::packed_ushort8 instead. */ +typedef ::simd_ushort8 ushort8; + + /*! @abstract A vector of sixteen 16-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_ushort16. The alignment of this type is + * greater than the alignment of unsigned short; if you need to operate + * on data buffers that may not be suitably aligned, you should access + * them using simd::packed_ushort16 instead. */ +typedef ::simd_ushort16 ushort16; + + /*! @abstract A vector of thirty-two 16-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_ushort32. The alignment of this type is + * greater than the alignment of unsigned short; if you need to operate + * on data buffers that may not be suitably aligned, you should access + * them using simd::packed_ushort32 instead. */ +typedef ::simd_ushort32 ushort32; + + /*! @abstract A scalar 32-bit signed (twos-complement) integer. + * @discussion In C and Objective-C, this type is available as simd_int1. */ +typedef ::simd_int1 int1; + + /*! @abstract A vector of two 32-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as simd_int2. + * The alignment of this type is greater than the alignment of int; if + * you need to operate on data buffers that may not be suitably aligned, + * you should access them using simd::packed_int2 instead. */ +typedef ::simd_int2 int2; + + /*! @abstract A vector of three 32-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as simd_int3. + * Vectors of this type are padded to have the same size and alignment as + * simd_int4. */ +typedef ::simd_int3 int3; + + /*! @abstract A vector of four 32-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as simd_int4. + * The alignment of this type is greater than the alignment of int; if + * you need to operate on data buffers that may not be suitably aligned, + * you should access them using simd::packed_int4 instead. */ +typedef ::simd_int4 int4; + + /*! @abstract A vector of eight 32-bit signed (twos-complement) integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_int8. The alignment of this type is + * greater than the alignment of int; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_int8 instead. */ +typedef ::simd_int8 int8; + + /*! @abstract A vector of sixteen 32-bit signed (twos-complement) + * integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_int16. The alignment of this type is + * greater than the alignment of int; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_int16 instead. */ +typedef ::simd_int16 int16; + + /*! @abstract A scalar 32-bit unsigned integer. + * @discussion In C and Objective-C, this type is available as + * simd_uint1. */ +typedef ::simd_uint1 uint1; + + /*! @abstract A vector of two 32-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_uint2. The alignment of this type is greater than the alignment + * of unsigned int; if you need to operate on data buffers that may not + * be suitably aligned, you should access them using simd::packed_uint2 + * instead. */ +typedef ::simd_uint2 uint2; + + /*! @abstract A vector of three 32-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_uint3. Vectors of this type are padded to have the same size and + * alignment as simd_uint4. */ +typedef ::simd_uint3 uint3; + + /*! @abstract A vector of four 32-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_uint4. The alignment of this type is greater than the alignment + * of unsigned int; if you need to operate on data buffers that may not + * be suitably aligned, you should access them using simd::packed_uint4 + * instead. */ +typedef ::simd_uint4 uint4; + + /*! @abstract A vector of eight 32-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_uint8. The alignment of this type is + * greater than the alignment of unsigned int; if you need to operate on + * data buffers that may not be suitably aligned, you should access them + * using simd::packed_uint8 instead. */ +typedef ::simd_uint8 uint8; + + /*! @abstract A vector of sixteen 32-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_uint16. The alignment of this type is + * greater than the alignment of unsigned int; if you need to operate on + * data buffers that may not be suitably aligned, you should access them + * using simd::packed_uint16 instead. */ +typedef ::simd_uint16 uint16; + + /*! @abstract A scalar 32-bit floating-point number. + * @discussion In C and Objective-C, this type is available as + * simd_float1. */ +typedef ::simd_float1 float1; + + /*! @abstract A vector of two 32-bit floating-point numbers. + * @description In C or Objective-C, this type is available as + * simd_float2. The alignment of this type is greater than the alignment + * of float; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_float2 + * instead. */ +typedef ::simd_float2 float2; + + /*! @abstract A vector of three 32-bit floating-point numbers. + * @description In C or Objective-C, this type is available as + * simd_float3. Vectors of this type are padded to have the same size and + * alignment as simd_float4. */ +typedef ::simd_float3 float3; + + /*! @abstract A vector of four 32-bit floating-point numbers. + * @description In C or Objective-C, this type is available as + * simd_float4. The alignment of this type is greater than the alignment + * of float; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_float4 + * instead. */ +typedef ::simd_float4 float4; + + /*! @abstract A vector of eight 32-bit floating-point numbers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_float8. The alignment of this type is + * greater than the alignment of float; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_float8 instead. */ +typedef ::simd_float8 float8; + + /*! @abstract A vector of sixteen 32-bit floating-point numbers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_float16. The alignment of this type is + * greater than the alignment of float; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_float16 instead. */ +typedef ::simd_float16 float16; + + /*! @abstract A scalar 64-bit signed (twos-complement) integer. + * @discussion In C and Objective-C, this type is available as + * simd_long1. */ +typedef ::simd_long1 long1; + + /*! @abstract A vector of two 64-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_long2. The alignment of this type is greater than the alignment + * of simd_long1; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_long2 + * instead. */ +typedef ::simd_long2 long2; + + /*! @abstract A vector of three 64-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_long3. Vectors of this type are padded to have the same size and + * alignment as simd_long4. */ +typedef ::simd_long3 long3; + + /*! @abstract A vector of four 64-bit signed (twos-complement) integers. + * @description In C or Objective-C, this type is available as + * simd_long4. The alignment of this type is greater than the alignment + * of simd_long1; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_long4 + * instead. */ +typedef ::simd_long4 long4; + + /*! @abstract A vector of eight 64-bit signed (twos-complement) integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_long8. The alignment of this type is + * greater than the alignment of simd_long1; if you need to operate on + * data buffers that may not be suitably aligned, you should access them + * using simd::packed_long8 instead. */ +typedef ::simd_long8 long8; + + /*! @abstract A scalar 64-bit unsigned integer. + * @discussion In C and Objective-C, this type is available as + * simd_ulong1. */ +typedef ::simd_ulong1 ulong1; + + /*! @abstract A vector of two 64-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_ulong2. The alignment of this type is greater than the alignment + * of simd_ulong1; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_ulong2 + * instead. */ +typedef ::simd_ulong2 ulong2; + + /*! @abstract A vector of three 64-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_ulong3. Vectors of this type are padded to have the same size and + * alignment as simd_ulong4. */ +typedef ::simd_ulong3 ulong3; + + /*! @abstract A vector of four 64-bit unsigned integers. + * @description In C or Objective-C, this type is available as + * simd_ulong4. The alignment of this type is greater than the alignment + * of simd_ulong1; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_ulong4 + * instead. */ +typedef ::simd_ulong4 ulong4; + + /*! @abstract A vector of eight 64-bit unsigned integers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_ulong8. The alignment of this type is + * greater than the alignment of simd_ulong1; if you need to operate on + * data buffers that may not be suitably aligned, you should access them + * using simd::packed_ulong8 instead. */ +typedef ::simd_ulong8 ulong8; + + /*! @abstract A scalar 64-bit floating-point number. + * @discussion In C and Objective-C, this type is available as + * simd_double1. */ +typedef ::simd_double1 double1; + + /*! @abstract A vector of two 64-bit floating-point numbers. + * @description In C or Objective-C, this type is available as + * simd_double2. The alignment of this type is greater than the alignment + * of double; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_double2 + * instead. */ +typedef ::simd_double2 double2; + + /*! @abstract A vector of three 64-bit floating-point numbers. + * @description In C or Objective-C, this type is available as + * simd_double3. Vectors of this type are padded to have the same size + * and alignment as simd_double4. */ +typedef ::simd_double3 double3; + + /*! @abstract A vector of four 64-bit floating-point numbers. + * @description In C or Objective-C, this type is available as + * simd_double4. The alignment of this type is greater than the alignment + * of double; if you need to operate on data buffers that may not be + * suitably aligned, you should access them using simd::packed_double4 + * instead. */ +typedef ::simd_double4 double4; + + /*! @abstract A vector of eight 64-bit floating-point numbers. + * @description This type is not available in Metal. In C or Objective-C, + * this type is available as simd_double8. The alignment of this type is + * greater than the alignment of double; if you need to operate on data + * buffers that may not be suitably aligned, you should access them using + * simd::packed_double8 instead. */ +typedef ::simd_double8 double8; + +} /* namespace simd:: */ +#endif /* __cplusplus */ + +/* MARK: Deprecated vector types */ +/*! @group Deprecated vector types + * @discussion These are the original types used by earlier versions of the + * simd library; they are provided here for compatability with existing source + * files. Use the new ("simd_"-prefixed) types for future development. */ + +/*! @abstract A vector of two 8-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_char2 or + * simd::char2 instead. */ +typedef simd_char2 vector_char2; + +/*! @abstract A vector of three 8-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_char3 or + * simd::char3 instead. */ +typedef simd_char3 vector_char3; + +/*! @abstract A vector of four 8-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_char4 or + * simd::char4 instead. */ +typedef simd_char4 vector_char4; + +/*! @abstract A vector of eight 8-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_char8 or + * simd::char8 instead. */ +typedef simd_char8 vector_char8; + +/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_char16 or + * simd::char16 instead. */ +typedef simd_char16 vector_char16; + +/*! @abstract A vector of thirty-two 8-bit signed (twos-complement) + * integers. + * @description This type is deprecated; you should use simd_char32 or + * simd::char32 instead. */ +typedef simd_char32 vector_char32; + +/*! @abstract A vector of two 8-bit unsigned integers. + * @description This type is deprecated; you should use simd_uchar2 or + * simd::uchar2 instead. */ +typedef simd_uchar2 vector_uchar2; + +/*! @abstract A vector of three 8-bit unsigned integers. + * @description This type is deprecated; you should use simd_uchar3 or + * simd::uchar3 instead. */ +typedef simd_uchar3 vector_uchar3; + +/*! @abstract A vector of four 8-bit unsigned integers. + * @description This type is deprecated; you should use simd_uchar4 or + * simd::uchar4 instead. */ +typedef simd_uchar4 vector_uchar4; + +/*! @abstract A vector of eight 8-bit unsigned integers. + * @description This type is deprecated; you should use simd_uchar8 or + * simd::uchar8 instead. */ +typedef simd_uchar8 vector_uchar8; + +/*! @abstract A vector of sixteen 8-bit unsigned integers. + * @description This type is deprecated; you should use simd_uchar16 or + * simd::uchar16 instead. */ +typedef simd_uchar16 vector_uchar16; + +/*! @abstract A vector of thirty-two 8-bit unsigned integers. + * @description This type is deprecated; you should use simd_uchar32 or + * simd::uchar32 instead. */ +typedef simd_uchar32 vector_uchar32; + +/*! @abstract A vector of two 16-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_short2 or + * simd::short2 instead. */ +typedef simd_short2 vector_short2; + +/*! @abstract A vector of three 16-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_short3 or + * simd::short3 instead. */ +typedef simd_short3 vector_short3; + +/*! @abstract A vector of four 16-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_short4 or + * simd::short4 instead. */ +typedef simd_short4 vector_short4; + +/*! @abstract A vector of eight 16-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_short8 or + * simd::short8 instead. */ +typedef simd_short8 vector_short8; + +/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_short16 or + * simd::short16 instead. */ +typedef simd_short16 vector_short16; + +/*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers. + * @description This type is deprecated; you should use simd_short32 or + * simd::short32 instead. */ +typedef simd_short32 vector_short32; + +/*! @abstract A vector of two 16-bit unsigned integers. + * @description This type is deprecated; you should use simd_ushort2 or + * simd::ushort2 instead. */ +typedef simd_ushort2 vector_ushort2; + +/*! @abstract A vector of three 16-bit unsigned integers. + * @description This type is deprecated; you should use simd_ushort3 or + * simd::ushort3 instead. */ +typedef simd_ushort3 vector_ushort3; + +/*! @abstract A vector of four 16-bit unsigned integers. + * @description This type is deprecated; you should use simd_ushort4 or + * simd::ushort4 instead. */ +typedef simd_ushort4 vector_ushort4; + +/*! @abstract A vector of eight 16-bit unsigned integers. + * @description This type is deprecated; you should use simd_ushort8 or + * simd::ushort8 instead. */ +typedef simd_ushort8 vector_ushort8; + +/*! @abstract A vector of sixteen 16-bit unsigned integers. + * @description This type is deprecated; you should use simd_ushort16 or + * simd::ushort16 instead. */ +typedef simd_ushort16 vector_ushort16; + +/*! @abstract A vector of thirty-two 16-bit unsigned integers. + * @description This type is deprecated; you should use simd_ushort32 or + * simd::ushort32 instead. */ +typedef simd_ushort32 vector_ushort32; + +/*! @abstract A vector of two 32-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_int2 or + * simd::int2 instead. */ +typedef simd_int2 vector_int2; + +/*! @abstract A vector of three 32-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_int3 or + * simd::int3 instead. */ +typedef simd_int3 vector_int3; + +/*! @abstract A vector of four 32-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_int4 or + * simd::int4 instead. */ +typedef simd_int4 vector_int4; + +/*! @abstract A vector of eight 32-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_int8 or + * simd::int8 instead. */ +typedef simd_int8 vector_int8; + +/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_int16 or + * simd::int16 instead. */ +typedef simd_int16 vector_int16; + +/*! @abstract A vector of two 32-bit unsigned integers. + * @description This type is deprecated; you should use simd_uint2 or + * simd::uint2 instead. */ +typedef simd_uint2 vector_uint2; + +/*! @abstract A vector of three 32-bit unsigned integers. + * @description This type is deprecated; you should use simd_uint3 or + * simd::uint3 instead. */ +typedef simd_uint3 vector_uint3; + +/*! @abstract A vector of four 32-bit unsigned integers. + * @description This type is deprecated; you should use simd_uint4 or + * simd::uint4 instead. */ +typedef simd_uint4 vector_uint4; + +/*! @abstract A vector of eight 32-bit unsigned integers. + * @description This type is deprecated; you should use simd_uint8 or + * simd::uint8 instead. */ +typedef simd_uint8 vector_uint8; + +/*! @abstract A vector of sixteen 32-bit unsigned integers. + * @description This type is deprecated; you should use simd_uint16 or + * simd::uint16 instead. */ +typedef simd_uint16 vector_uint16; + +/*! @abstract A vector of two 32-bit floating-point numbers. + * @description This type is deprecated; you should use simd_float2 or + * simd::float2 instead. */ +typedef simd_float2 vector_float2; + +/*! @abstract A vector of three 32-bit floating-point numbers. + * @description This type is deprecated; you should use simd_float3 or + * simd::float3 instead. */ +typedef simd_float3 vector_float3; + +/*! @abstract A vector of four 32-bit floating-point numbers. + * @description This type is deprecated; you should use simd_float4 or + * simd::float4 instead. */ +typedef simd_float4 vector_float4; + +/*! @abstract A vector of eight 32-bit floating-point numbers. + * @description This type is deprecated; you should use simd_float8 or + * simd::float8 instead. */ +typedef simd_float8 vector_float8; + +/*! @abstract A vector of sixteen 32-bit floating-point numbers. + * @description This type is deprecated; you should use simd_float16 or + * simd::float16 instead. */ +typedef simd_float16 vector_float16; + +/*! @abstract A scalar 64-bit signed (twos-complement) integer. + * @description This type is deprecated; you should use simd_long1 or + * simd::long1 instead. */ +typedef simd_long1 vector_long1; + +/*! @abstract A vector of two 64-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_long2 or + * simd::long2 instead. */ +typedef simd_long2 vector_long2; + +/*! @abstract A vector of three 64-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_long3 or + * simd::long3 instead. */ +typedef simd_long3 vector_long3; + +/*! @abstract A vector of four 64-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_long4 or + * simd::long4 instead. */ +typedef simd_long4 vector_long4; + +/*! @abstract A vector of eight 64-bit signed (twos-complement) integers. + * @description This type is deprecated; you should use simd_long8 or + * simd::long8 instead. */ +typedef simd_long8 vector_long8; + +/*! @abstract A scalar 64-bit unsigned integer. + * @description This type is deprecated; you should use simd_ulong1 or + * simd::ulong1 instead. */ +typedef simd_ulong1 vector_ulong1; + +/*! @abstract A vector of two 64-bit unsigned integers. + * @description This type is deprecated; you should use simd_ulong2 or + * simd::ulong2 instead. */ +typedef simd_ulong2 vector_ulong2; + +/*! @abstract A vector of three 64-bit unsigned integers. + * @description This type is deprecated; you should use simd_ulong3 or + * simd::ulong3 instead. */ +typedef simd_ulong3 vector_ulong3; + +/*! @abstract A vector of four 64-bit unsigned integers. + * @description This type is deprecated; you should use simd_ulong4 or + * simd::ulong4 instead. */ +typedef simd_ulong4 vector_ulong4; + +/*! @abstract A vector of eight 64-bit unsigned integers. + * @description This type is deprecated; you should use simd_ulong8 or + * simd::ulong8 instead. */ +typedef simd_ulong8 vector_ulong8; + +/*! @abstract A vector of two 64-bit floating-point numbers. + * @description This type is deprecated; you should use simd_double2 or + * simd::double2 instead. */ +typedef simd_double2 vector_double2; + +/*! @abstract A vector of three 64-bit floating-point numbers. + * @description This type is deprecated; you should use simd_double3 or + * simd::double3 instead. */ +typedef simd_double3 vector_double3; + +/*! @abstract A vector of four 64-bit floating-point numbers. + * @description This type is deprecated; you should use simd_double4 or + * simd::double4 instead. */ +typedef simd_double4 vector_double4; + +/*! @abstract A vector of eight 64-bit floating-point numbers. + * @description This type is deprecated; you should use simd_double8 or + * simd::double8 instead. */ +typedef simd_double8 vector_double8; + +# endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/spawn.h b/lib/libc/include/x86_64-macos-gnu/spawn.h index a80f4d936a..667447b08c 100644 --- a/lib/libc/include/x86_64-macos-gnu/spawn.h +++ b/lib/libc/include/x86_64-macos-gnu/spawn.h @@ -135,12 +135,18 @@ __BEGIN_DECLS int posix_spawnattr_getbinpref_np(const posix_spawnattr_t * __restrict, size_t, cpu_type_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); +int posix_spawnattr_getarchpref_np(const posix_spawnattr_t * __restrict, + 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); + int posix_spawnattr_setauditsessionport_np(posix_spawnattr_t * __restrict, mach_port_t) __API_AVAILABLE(macos(10.6), ios(3.2)); int posix_spawnattr_setbinpref_np(posix_spawnattr_t * __restrict, size_t, cpu_type_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); +int posix_spawnattr_setarchpref_np(posix_spawnattr_t * __restrict, + 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); + int posix_spawnattr_setexceptionports_np(posix_spawnattr_t * __restrict, exception_mask_t, mach_port_t, 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, int posix_spawnattr_setsuidcredport_np(posix_spawnattr_t * __restrict, mach_port_t) __API_UNAVAILABLE(ios, macos); +int posix_spawnattr_setnosmt_np(const posix_spawnattr_t * __restrict attr) __API_AVAILABLE(macos(11.0)); + +/* + * Set CPU Security Mitigation on the spawned process + * This attribute affects all threads and is inherited on fork and exec + */ +int posix_spawnattr_set_csm_np(const posix_spawnattr_t * __restrict attr, uint32_t flags) __API_AVAILABLE(macos(11.0)); +/* + * flags for CPU Security Mitigation attribute + * POSIX_SPAWN_NP_CSM_ALL should be used in most cases, + * the individual flags are provided only for performance evaluation etc + */ +#define POSIX_SPAWN_NP_CSM_ALL 0x0001 +#define POSIX_SPAWN_NP_CSM_NOSMT 0x0002 +#define POSIX_SPAWN_NP_CSM_TECS 0x0004 + int posix_spawn_file_actions_addinherit_np(posix_spawn_file_actions_t *, int) __API_AVAILABLE(macos(10.7), ios(4.3)) __API_UNAVAILABLE(watchos, tvos); diff --git a/lib/libc/include/x86_64-macos-gnu/stdint.h b/lib/libc/include/x86_64-macos-gnu/stdint.h index 87c93c7d69..f4bb4cd758 100644 --- a/lib/libc/include/x86_64-macos-gnu/stdint.h +++ b/lib/libc/include/x86_64-macos-gnu/stdint.h @@ -3,15 +3,6 @@ * All rights reserved. */ -/* - * Note from the Zig project: - * - * Apple released their libc as a whole under the APSL 2.0 license [1], which - * includes this file. Therefore, this file is governed by the APSL 2.0 license. - * - * [1]: https://opensource.apple.com/source/Libc/Libc-1353.100.2/ - */ - #ifndef _STDINT_H_ #define _STDINT_H_ diff --git a/lib/libc/include/x86_64-macos-gnu/stdio.h b/lib/libc/include/x86_64-macos-gnu/stdio.h index ab46f071ea..f4d489a946 100644 --- a/lib/libc/include/x86_64-macos-gnu/stdio.h +++ b/lib/libc/include/x86_64-macos-gnu/stdio.h @@ -217,7 +217,7 @@ __END_DECLS /* Additional functionality provided by: * POSIX.2-1992 C Language Binding Option */ -#if TARGET_OS_EMBEDDED +#if TARGET_OS_IPHONE #define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg) #else #define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg) diff --git a/lib/libc/include/x86_64-macos-gnu/stdlib.h b/lib/libc/include/x86_64-macos-gnu/stdlib.h index 035e6c0adc..825d8a52ff 100644 --- a/lib/libc/include/x86_64-macos-gnu/stdlib.h +++ b/lib/libc/include/x86_64-macos-gnu/stdlib.h @@ -178,7 +178,7 @@ unsigned long long strtoull(const char *__str, char **__endptr, int __base); #endif /* !__DARWIN_NO_LONG_LONG */ -#if TARGET_OS_EMBEDDED +#if TARGET_OS_IPHONE #define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg) #else #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 *__ void sranddev(void); void srandomdev(void); void *reallocf(void *__ptr, size_t __size) __alloc_size(2); +long long + strtonum(const char *__numstr, long long __minval, long long __maxval, const char **__errstrp) + __API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)); #if !__DARWIN_NO_LONG_LONG long long strtoq(const char *__str, char **__endptr, int __base); diff --git a/lib/libc/include/x86_64-macos-gnu/string.h b/lib/libc/include/x86_64-macos-gnu/string.h index 6329c62d8b..f0c7fc602e 100644 --- a/lib/libc/include/x86_64-macos-gnu/string.h +++ b/lib/libc/include/x86_64-macos-gnu/string.h @@ -170,6 +170,10 @@ void swab(const void * __restrict, void * __restrict, ssize_t); __OSX_AVAILABLE(10.12.1) __IOS_AVAILABLE(10.1) __TVOS_AVAILABLE(10.0.1) __WATCHOS_AVAILABLE(3.1) int timingsafe_bcmp(const void *__b1, const void *__b2, size_t __len); + +__OSX_AVAILABLE(11.0) __IOS_AVAILABLE(14.0) +__TVOS_AVAILABLE(14.0) __WATCHOS_AVAILABLE(7.0) +int strsignal_r(int __sig, char *__strsignalbuf, size_t __buflen); __END_DECLS /* Some functions historically defined in string.h were placed in strings.h diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h index cba5882afb..94db17084d 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h @@ -2,7 +2,7 @@ * Copyright (c) 2003-2012 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -11,10 +11,10 @@ * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. - * + * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,11 +22,11 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ -#ifndef _PTHREAD_ATTR_T -#define _PTHREAD_ATTR_T +#ifndef _PTHREAD_ATTR_T +#define _PTHREAD_ATTR_T #include /* __darwin_pthread_attr_t */ typedef __darwin_pthread_attr_t pthread_attr_t; #endif /* _PTHREAD_ATTR_T */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h index b6a7b42f4a..4f9a05fc32 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h @@ -2,7 +2,7 @@ * Copyright (c) 2003-2012 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -11,10 +11,10 @@ * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. - * + * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,7 +22,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef _PTHREAD_COND_T diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h index 6e9227a8a3..a18e5a814e 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h @@ -2,7 +2,7 @@ * Copyright (c) 2003-2012 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -11,10 +11,10 @@ * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. - * + * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,7 +22,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef _PTHREAD_CONDATTR_T diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h index 75c4e350b4..0c61c8964e 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h @@ -2,7 +2,7 @@ * Copyright (c) 2003-2012 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -11,10 +11,10 @@ * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. - * + * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,7 +22,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef _PTHREAD_RWLOCK_T diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h index 6ccd234725..936a565638 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h @@ -2,7 +2,7 @@ * Copyright (c) 2003-2012 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -11,10 +11,10 @@ * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. - * + * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,7 +22,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef _PTHREAD_RWLOCKATTR_T diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h index 4d9e3dac95..519f6e0bdc 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h @@ -2,7 +2,7 @@ * Copyright (c) 2003-2012 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -11,10 +11,10 @@ * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. - * + * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,7 +22,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef _PTHREAD_T diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h index d9d51b89ea..123c31a583 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h @@ -2,7 +2,7 @@ * Copyright (c) 2003-2013 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in @@ -11,10 +11,10 @@ * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. - * + * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,7 +22,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_select.h b/lib/libc/include/x86_64-macos-gnu/sys/_select.h index 567d621856..174814916d 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_select.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_select.h @@ -36,8 +36,13 @@ #ifndef _SYS__SELECT_H_ #define _SYS__SELECT_H_ +#include /* __DARWIN_EXTSN_C, __DARWIN_1050, __DARWIN_ALIAS_C */ +#include /* fd_set */ +#include /* struct timeval */ + int select(int, fd_set * __restrict, fd_set * __restrict, fd_set * __restrict, struct timeval * __restrict) + #if defined(_DARWIN_C_SOURCE) || defined(_DARWIN_UNLIMITED_SELECT) __DARWIN_EXTSN_C(select) #else /* !_DARWIN_C_SOURCE && !_DARWIN_UNLIMITED_SELECT */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h b/lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h index 1bbcd58ebd..cf75ecec51 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h @@ -305,6 +305,30 @@ #define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_6(x) #endif +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130700 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_7(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_7(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_2(x) +#endif + #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1000 #define __DARWIN_ALIAS_STARTING_MAC___MAC_10_0(x) x #else @@ -497,3 +521,15 @@ #define __DARWIN_ALIAS_STARTING_MAC___MAC_10_15_1(x) #endif +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101600 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_16(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_16(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_0(x) +#endif + diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h b/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h index daadcfe6ec..1a933496a2 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h @@ -51,12 +51,16 @@ typedef struct fd_set { __int32_t fds_bits[__DARWIN_howmany(__DARWIN_FD_SETSIZE, __DARWIN_NFDBITS)]; } fd_set; -int __darwin_check_fd_set_overflow(int, const void *, int) __attribute__((__weak_import__)); +int __darwin_check_fd_set_overflow(int, const void *, int) __API_AVAILABLE(macosx(11.0), ios(14.0), tvos(14.0), watchos(7.0)); __END_DECLS __header_always_inline int __darwin_check_fd_set(int _a, const void *_b) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability-new" +#endif if ((uintptr_t)&__darwin_check_fd_set_overflow != (uintptr_t) 0) { #if defined(_DARWIN_UNLIMITED_SELECT) || defined(_DARWIN_C_SOURCE) return __darwin_check_fd_set_overflow(_a, _b, 1); @@ -66,6 +70,9 @@ __darwin_check_fd_set(int _a, const void *_b) } else { return 1; } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } /* This inline avoids argument side-effect issues with FD_ISSET() */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_guid_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_types/_guid_t.h new file mode 100644 index 0000000000..df29f9ca39 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/sys/_types/_guid_t.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _KAUTH_GUID +#define _KAUTH_GUID +/* Apple-style globally unique identifier */ +typedef union { +#define KAUTH_GUID_SIZE 16 /* 128-bit identifier */ + unsigned char g_guid[KAUTH_GUID_SIZE]; + unsigned int g_guid_asint[KAUTH_GUID_SIZE / sizeof(unsigned int)]; +} guid_t; +#define _GUID_T +#endif /* _KAUTH_GUID */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h index 9176298a5f..14eb9f7ea0 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h @@ -27,5 +27,5 @@ */ #ifndef _INT8_T #define _INT8_T -typedef __signed char int8_t; +typedef signed char int8_t; #endif /* _INT8_T */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h b/lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h index 65184e44e4..2360422938 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h @@ -38,6 +38,7 @@ #include /* __darwin_size_t */ #include /* _STRUCT_MCONTEXT */ #include /* __darwin_sigset_t */ +#include /* _STRUCT_SIGALTSTACK */ _STRUCT_UCONTEXT { diff --git a/lib/libc/include/x86_64-macos-gnu/sys/acl.h b/lib/libc/include/x86_64-macos-gnu/sys/acl.h new file mode 100644 index 0000000000..fce4eafd0a --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/sys/acl.h @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2004, 2010 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _SYS_ACL_H +#define _SYS_ACL_H + +#include +#include +#include + +#define __DARWIN_ACL_READ_DATA (1<<1) +#define __DARWIN_ACL_LIST_DIRECTORY __DARWIN_ACL_READ_DATA +#define __DARWIN_ACL_WRITE_DATA (1<<2) +#define __DARWIN_ACL_ADD_FILE __DARWIN_ACL_WRITE_DATA +#define __DARWIN_ACL_EXECUTE (1<<3) +#define __DARWIN_ACL_SEARCH __DARWIN_ACL_EXECUTE +#define __DARWIN_ACL_DELETE (1<<4) +#define __DARWIN_ACL_APPEND_DATA (1<<5) +#define __DARWIN_ACL_ADD_SUBDIRECTORY __DARWIN_ACL_APPEND_DATA +#define __DARWIN_ACL_DELETE_CHILD (1<<6) +#define __DARWIN_ACL_READ_ATTRIBUTES (1<<7) +#define __DARWIN_ACL_WRITE_ATTRIBUTES (1<<8) +#define __DARWIN_ACL_READ_EXTATTRIBUTES (1<<9) +#define __DARWIN_ACL_WRITE_EXTATTRIBUTES (1<<10) +#define __DARWIN_ACL_READ_SECURITY (1<<11) +#define __DARWIN_ACL_WRITE_SECURITY (1<<12) +#define __DARWIN_ACL_CHANGE_OWNER (1<<13) +#define __DARWIN_ACL_SYNCHRONIZE (1<<20) + +#define __DARWIN_ACL_EXTENDED_ALLOW 1 +#define __DARWIN_ACL_EXTENDED_DENY 2 + +#define __DARWIN_ACL_ENTRY_INHERITED (1<<4) +#define __DARWIN_ACL_ENTRY_FILE_INHERIT (1<<5) +#define __DARWIN_ACL_ENTRY_DIRECTORY_INHERIT (1<<6) +#define __DARWIN_ACL_ENTRY_LIMIT_INHERIT (1<<7) +#define __DARWIN_ACL_ENTRY_ONLY_INHERIT (1<<8) +#define __DARWIN_ACL_FLAG_NO_INHERIT (1<<17) + +/* + * Implementation constants. + * + * The ACL_TYPE_EXTENDED binary format permits 169 entries plus + * the ACL header in a page. Give ourselves some room to grow; + * this limit is arbitrary. + */ +#define ACL_MAX_ENTRIES 128 + +/* 23.2.2 Individual object access permissions - nonstandard */ +typedef enum { + ACL_READ_DATA = __DARWIN_ACL_READ_DATA, + ACL_LIST_DIRECTORY = __DARWIN_ACL_LIST_DIRECTORY, + ACL_WRITE_DATA = __DARWIN_ACL_WRITE_DATA, + ACL_ADD_FILE = __DARWIN_ACL_ADD_FILE, + ACL_EXECUTE = __DARWIN_ACL_EXECUTE, + ACL_SEARCH = __DARWIN_ACL_SEARCH, + ACL_DELETE = __DARWIN_ACL_DELETE, + ACL_APPEND_DATA = __DARWIN_ACL_APPEND_DATA, + ACL_ADD_SUBDIRECTORY = __DARWIN_ACL_ADD_SUBDIRECTORY, + ACL_DELETE_CHILD = __DARWIN_ACL_DELETE_CHILD, + ACL_READ_ATTRIBUTES = __DARWIN_ACL_READ_ATTRIBUTES, + ACL_WRITE_ATTRIBUTES = __DARWIN_ACL_WRITE_ATTRIBUTES, + ACL_READ_EXTATTRIBUTES = __DARWIN_ACL_READ_EXTATTRIBUTES, + ACL_WRITE_EXTATTRIBUTES = __DARWIN_ACL_WRITE_EXTATTRIBUTES, + ACL_READ_SECURITY = __DARWIN_ACL_READ_SECURITY, + ACL_WRITE_SECURITY = __DARWIN_ACL_WRITE_SECURITY, + ACL_CHANGE_OWNER = __DARWIN_ACL_CHANGE_OWNER, + ACL_SYNCHRONIZE = __DARWIN_ACL_SYNCHRONIZE, +} acl_perm_t; + +/* 23.2.5 ACL entry tag type bits - nonstandard */ +typedef enum { + ACL_UNDEFINED_TAG = 0, + ACL_EXTENDED_ALLOW = __DARWIN_ACL_EXTENDED_ALLOW, + ACL_EXTENDED_DENY = __DARWIN_ACL_EXTENDED_DENY +} acl_tag_t; + +/* 23.2.6 Individual ACL types */ +typedef enum { + ACL_TYPE_EXTENDED = 0x00000100, +/* Posix 1003.1e types - not supported */ + ACL_TYPE_ACCESS = 0x00000000, + ACL_TYPE_DEFAULT = 0x00000001, +/* The following types are defined on FreeBSD/Linux - not supported */ + ACL_TYPE_AFS = 0x00000002, + ACL_TYPE_CODA = 0x00000003, + ACL_TYPE_NTFS = 0x00000004, + ACL_TYPE_NWFS = 0x00000005 +} acl_type_t; + +/* 23.2.7 ACL qualifier constants */ + +#define ACL_UNDEFINED_ID NULL /* XXX ? */ + +/* 23.2.8 ACL Entry Constants */ +typedef enum { + ACL_FIRST_ENTRY = 0, + ACL_NEXT_ENTRY = -1, + ACL_LAST_ENTRY = -2 +} acl_entry_id_t; + +/* nonstandard ACL / entry flags */ +typedef enum { + ACL_FLAG_DEFER_INHERIT = (1 << 0), /* tentative */ + ACL_FLAG_NO_INHERIT = __DARWIN_ACL_FLAG_NO_INHERIT, + ACL_ENTRY_INHERITED = __DARWIN_ACL_ENTRY_INHERITED, + ACL_ENTRY_FILE_INHERIT = __DARWIN_ACL_ENTRY_FILE_INHERIT, + ACL_ENTRY_DIRECTORY_INHERIT = __DARWIN_ACL_ENTRY_DIRECTORY_INHERIT, + ACL_ENTRY_LIMIT_INHERIT = __DARWIN_ACL_ENTRY_LIMIT_INHERIT, + ACL_ENTRY_ONLY_INHERIT = __DARWIN_ACL_ENTRY_ONLY_INHERIT +} acl_flag_t; + +/* "External" ACL types */ + +struct _acl; +struct _acl_entry; +struct _acl_permset; +struct _acl_flagset; + +typedef struct _acl *acl_t; +typedef struct _acl_entry *acl_entry_t; +typedef struct _acl_permset *acl_permset_t; +typedef struct _acl_flagset *acl_flagset_t; + +typedef u_int64_t acl_permset_mask_t; + +__BEGIN_DECLS +/* 23.1.6.1 ACL Storage Management */ +extern acl_t acl_dup(acl_t acl); +extern int acl_free(void *obj_p); +extern acl_t acl_init(int count); + +/* 23.1.6.2 (1) ACL Entry manipulation */ +extern int acl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d); +extern int acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p); +extern int acl_create_entry_np(acl_t *acl_p, acl_entry_t *entry_p, int entry_index); +extern int acl_delete_entry(acl_t acl, acl_entry_t entry_d); +extern int acl_get_entry(acl_t acl, int entry_id, acl_entry_t *entry_p); +extern int acl_valid(acl_t acl); +extern int acl_valid_fd_np(int fd, acl_type_t type, acl_t acl); +extern int acl_valid_file_np(const char *path, acl_type_t type, acl_t acl); +extern int acl_valid_link_np(const char *path, acl_type_t type, acl_t acl); + +/* 23.1.6.2 (2) Manipulate permissions within an ACL entry */ +extern int acl_add_perm(acl_permset_t permset_d, acl_perm_t perm); +extern int acl_calc_mask(acl_t *acl_p); /* not supported */ +extern int acl_clear_perms(acl_permset_t permset_d); +extern int acl_delete_perm(acl_permset_t permset_d, acl_perm_t perm); +extern int acl_get_perm_np(acl_permset_t permset_d, acl_perm_t perm); +extern int acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p); +extern int acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d); + +/* nonstandard - manipulate permissions within an ACL entry using bitmasks */ +extern int acl_maximal_permset_mask_np(acl_permset_mask_t * mask_p) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +extern 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); +extern 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); + +/* nonstandard - manipulate flags on ACLs and entries */ +extern int acl_add_flag_np(acl_flagset_t flagset_d, acl_flag_t flag); +extern int acl_clear_flags_np(acl_flagset_t flagset_d); +extern int acl_delete_flag_np(acl_flagset_t flagset_d, acl_flag_t flag); +extern int acl_get_flag_np(acl_flagset_t flagset_d, acl_flag_t flag); +extern int acl_get_flagset_np(void *obj_p, acl_flagset_t *flagset_p); +extern int acl_set_flagset_np(void *obj_p, acl_flagset_t flagset_d); + +/* 23.1.6.2 (3) Manipulate ACL entry tag type and qualifier */ +extern void *acl_get_qualifier(acl_entry_t entry_d); +extern int acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p); +extern int acl_set_qualifier(acl_entry_t entry_d, const void *tag_qualifier_p); +extern int acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type); + +/* 23.1.6.3 ACL manipulation on an Object */ +extern int acl_delete_def_file(const char *path_p); /* not supported */ +extern acl_t acl_get_fd(int fd); +extern acl_t acl_get_fd_np(int fd, acl_type_t type); +extern acl_t acl_get_file(const char *path_p, acl_type_t type); +extern acl_t acl_get_link_np(const char *path_p, acl_type_t type); +extern int acl_set_fd(int fd, acl_t acl); +extern int acl_set_fd_np(int fd, acl_t acl, acl_type_t acl_type); +extern int acl_set_file(const char *path_p, acl_type_t type, acl_t acl); +extern int acl_set_link_np(const char *path_p, acl_type_t type, acl_t acl); + +/* 23.1.6.4 ACL Format translation */ +extern ssize_t acl_copy_ext(void *buf_p, acl_t acl, ssize_t size); +extern ssize_t acl_copy_ext_native(void *buf_p, acl_t acl, ssize_t size); +extern acl_t acl_copy_int(const void *buf_p); +extern acl_t acl_copy_int_native(const void *buf_p); +extern acl_t acl_from_text(const char *buf_p); +extern ssize_t acl_size(acl_t acl); +extern char *acl_to_text(acl_t acl, ssize_t *len_p); +__END_DECLS + +#endif /* _SYS_ACL_H */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/attr.h b/lib/libc/include/x86_64-macos-gnu/sys/attr.h index c9b825b0ae..6ee6fca4ed 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/attr.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/attr.h @@ -51,6 +51,7 @@ #define FSOPT_ATTR_CMN_EXTENDED 0x00000020 +#define FSOPT_RETURN_REALDEV 0x00000200 /* we currently aren't anywhere near this amount for a valid * fssearchblock.sizeofsearchparams1 or fssearchblock.sizeofsearchparams2 @@ -239,6 +240,10 @@ typedef struct vol_capabilities_attr { * that implies multiple volumes must be mounted in order to boot and root the * operating system. Typically, this means a read-only system volume and a * writable data volume. + * + * VOL_CAP_FMT_SEALED: When set, this volume is cryptographically sealed. + * Any modifications to volume data or metadata will be detected and may + * render the volume unusable. */ #define VOL_CAP_FMT_PERSISTENTOBJECTIDS 0x00000001 #define VOL_CAP_FMT_SYMBOLICLINKS 0x00000002 @@ -265,6 +270,7 @@ typedef struct vol_capabilities_attr { #define VOL_CAP_FMT_NO_PERMISSIONS 0x00400000 #define VOL_CAP_FMT_SHARED_SPACE 0x00800000 #define VOL_CAP_FMT_VOL_GROUPS 0x01000000 +#define VOL_CAP_FMT_SEALED 0x02000000 /* * VOL_CAP_INT_SEARCHFS: When set, the volume implements the @@ -515,8 +521,9 @@ typedef struct vol_attributes_attr { #define ATTR_CMNEXT_REALFSID 0x00000080 #define ATTR_CMNEXT_CLONEID 0x00000100 #define ATTR_CMNEXT_EXT_FLAGS 0x00000200 +#define ATTR_CMNEXT_RECURSIVE_GENCOUNT 0x00000400 -#define ATTR_CMNEXT_VALIDMASK 0x000003fc +#define ATTR_CMNEXT_VALIDMASK 0x000007fc #define ATTR_CMNEXT_SETMASK 0x00000000 /* Deprecated fork attributes */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/cdefs.h b/lib/libc/include/x86_64-macos-gnu/sys/cdefs.h index 443b7496a5..bf259fe23f 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/cdefs.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/cdefs.h @@ -174,6 +174,15 @@ #define __cold #endif +/* __exported denotes symbols that should be exported even when symbols + * are hidden by default. + * __exported_push/_exported_pop are pragmas used to delimit a range of + * symbols that should be exported even when symbols are hidden by default. + */ +#define __exported __attribute__((__visibility__("default"))) +#define __exported_push _Pragma("GCC visibility push(default)") +#define __exported_pop _Pragma("GCC visibility pop") + /* __deprecated causes the compiler to produce a warning when encountering * code using the deprecated functionality. * __deprecated_msg() does the same, and compilers that support it will print @@ -202,9 +211,17 @@ #define __kpi_deprecated(_msg) /* __unavailable causes the compiler to error out when encountering - * code using the tagged function of variable. + * code using the tagged function */ -#define __unavailable __attribute__((__unavailable__)) +#if __has_attribute(unavailable) +#define __unavailable __attribute__((__unavailable__)) +#else +#define __unavailable +#endif + +#define __kpi_unavailable + +#define __kpi_deprecated_arm64_macos_unavailable /* Delete pseudo-keywords wherever they are not available or needed. */ #ifndef __dead @@ -471,9 +488,19 @@ /* These settings are particular to each product. */ /* Platform: MacOSX */ +#if defined(__i386__) #define __DARWIN_ONLY_64_BIT_INO_T 0 -/* #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) */ +#define __DARWIN_ONLY_UNIX_CONFORMANCE 0 #define __DARWIN_ONLY_VERS_1050 0 +#elif defined(__x86_64__) +#define __DARWIN_ONLY_64_BIT_INO_T 0 +#define __DARWIN_ONLY_UNIX_CONFORMANCE 1 +#define __DARWIN_ONLY_VERS_1050 0 +#else +#define __DARWIN_ONLY_64_BIT_INO_T 1 +#define __DARWIN_ONLY_UNIX_CONFORMANCE 1 +#define __DARWIN_ONLY_VERS_1050 1 +#endif /* * The __DARWIN_ALIAS macros are used to do symbol renaming; they allow @@ -493,14 +520,6 @@ * pre-10.5, and it is the default compilation environment, revert the * compilation environment to pre-__DARWIN_UNIX03. */ -#if !defined(__DARWIN_ONLY_UNIX_CONFORMANCE) -# if defined(__LP64__) -# define __DARWIN_ONLY_UNIX_CONFORMANCE 1 -# else /* !__LP64__ */ -# define __DARWIN_ONLY_UNIX_CONFORMANCE 0 -# endif /* __LP64__ */ -#endif /* !__DARWIN_ONLY_UNIX_CONFORMANCE */ - #if !defined(__DARWIN_UNIX03) # if __DARWIN_ONLY_UNIX_CONFORMANCE # if defined(_NONSTD_SOURCE) @@ -803,6 +822,8 @@ */ #if !defined(__sys_cdefs_arch_unknown__) && defined(__i386__) #elif !defined(__sys_cdefs_arch_unknown__) && defined(__x86_64__) +#elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm__) +#elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm64__) #else #error Unsupported architecture #endif diff --git a/lib/libc/include/x86_64-macos-gnu/sys/event.h b/lib/libc/include/x86_64-macos-gnu/sys/event.h index de14e54236..d6e1b18e94 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/event.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/event.h @@ -262,7 +262,7 @@ enum { #define NOTE_EXEC 0x20000000 /* process exec'd */ #define NOTE_REAP ((unsigned int)eNoteReapDeprecated /* 0x10000000 */ ) /* process reaped */ #define NOTE_SIGNAL 0x08000000 /* shared with EVFILT_SIGNAL */ -#define NOTE_EXITSTATUS 0x04000000 /* exit status to be returned, valid for child process only */ +#define NOTE_EXITSTATUS 0x04000000 /* exit status to be returned, valid for child process or when allowed to signal target pid */ #define NOTE_EXIT_DETAIL 0x02000000 /* provide details on reasons for exit */ #define NOTE_PDATAMASK 0x000fffff /* mask for signal & exit status */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/fcntl.h b/lib/libc/include/x86_64-macos-gnu/sys/fcntl.h index ef0db5a3cf..f6665cee43 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/fcntl.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/fcntl.h @@ -107,24 +107,51 @@ * which was documented to use FREAD/FWRITE, continues to work. */ #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#define FREAD 0x0001 -#define FWRITE 0x0002 +#define FREAD 0x00000001 +#define FWRITE 0x00000002 #endif -#define O_NONBLOCK 0x0004 /* no delay */ -#define O_APPEND 0x0008 /* set append mode */ +#define O_NONBLOCK 0x00000004 /* no delay */ +#define O_APPEND 0x00000008 /* set append mode */ #include #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#define O_SHLOCK 0x0010 /* open with shared file lock */ -#define O_EXLOCK 0x0020 /* open with exclusive file lock */ -#define O_ASYNC 0x0040 /* signal pgrp when data ready */ +#define O_SHLOCK 0x00000010 /* open with shared file lock */ +#define O_EXLOCK 0x00000020 /* open with exclusive file lock */ +#define O_ASYNC 0x00000040 /* signal pgrp when data ready */ #define O_FSYNC O_SYNC /* source compatibility: do not use */ -#define O_NOFOLLOW 0x0100 /* don't follow symlinks */ +#define O_NOFOLLOW 0x00000100 /* don't follow symlinks */ #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ -#define O_CREAT 0x0200 /* create if nonexistant */ -#define O_TRUNC 0x0400 /* truncate to zero length */ -#define O_EXCL 0x0800 /* error if already exists */ +#define O_CREAT 0x00000200 /* create if nonexistant */ +#define O_TRUNC 0x00000400 /* truncate to zero length */ +#define O_EXCL 0x00000800 /* error if already exists */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define O_EVTONLY 0x00008000 /* descriptor requested for event notifications only */ +#endif + + +#define O_NOCTTY 0x00020000 /* don't assign controlling terminal */ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define O_DIRECTORY 0x00100000 +#define O_SYMLINK 0x00200000 /* allow open of a symlink */ +#endif + +// O_DSYNC 0x00400000 /* synch I/O data integrity */ +#include + + +#if __DARWIN_C_LEVEL >= 200809L +#define O_CLOEXEC 0x01000000 /* implicitly set FD_CLOEXEC */ +#endif + + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define O_NOFOLLOW_ANY 0x20000000 /* no symlinks allowed in path */ +#endif + #if __DARWIN_C_LEVEL >= 200809L /* @@ -145,30 +172,6 @@ #endif #endif -#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#define O_EVTONLY 0x8000 /* descriptor requested for event notifications only */ -#endif - - -#define O_NOCTTY 0x20000 /* don't assign controlling terminal */ - - -#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#define O_DIRECTORY 0x100000 -#define O_SYMLINK 0x200000 /* allow open of a symlink */ -#endif - -#include - - -#if __DARWIN_C_LEVEL >= 200809L -#define O_CLOEXEC 0x1000000 /* implicitly set FD_CLOEXEC */ -#endif - - - - - /* Data Protection Flags */ #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) #define O_DP_GETRAWENCRYPTED 0x0001 @@ -224,7 +227,7 @@ #define F_FLUSH_DATA 40 #define F_CHKCLEAN 41 /* Used for regression test */ #define F_PREALLOCATE 42 /* Preallocate storage */ -#define F_SETSIZE 43 /* Truncate a file without zeroing space */ +#define F_SETSIZE 43 /* Truncate a file. Equivalent to calling truncate(2) */ #define F_RDADVISE 44 /* Issue an advisory read async with no copy to user */ #define F_RDAHEAD 45 /* turn read ahead off/on for this fd */ /* @@ -293,6 +296,10 @@ #define F_GETPATH_NOFIRMLINK 102 /* return the full path without firmlinks of the fd */ +#define F_ADDFILESIGS_INFO 103 /* Add signature from same file, return information */ +#define F_ADDFILESUPPL 104 /* Add supplemental signature from same file with fd reference to original */ +#define F_GETSIGSINFO 105 /* Look up code signature information attached to a file or slice */ + // FS-specific fcntl()'s numbers begin at 0x00010000 and go up #define FCNTL_FS_SPECIFIC_BASE 0x00010000 @@ -374,30 +381,34 @@ struct radvisory { }; -/** Information the user passes in to get the codeblobs out of the kernel */ -typedef struct fcodeblobs { - void *f_cd_hash; - size_t f_hash_size; - void *f_cd_buffer; - size_t f_cd_size; - unsigned int *f_out_size; - int f_arch; - int __padding; -} fcodeblobs_t; - - /* * detached code signatures data type - * information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS. * F_ADDFILESIGS is a shortcut for files that contain their own signature and * doesn't require mapping of the file in order to load the signature. */ +#define USER_FSIGNATURES_CDHASH_LEN 20 typedef struct fsignatures { off_t fs_file_start; void *fs_blob_start; size_t fs_blob_size; + + /* The following fields are only applicable to F_ADDFILESIGS_INFO (64bit only). */ + /* Prior to F_ADDFILESIGS_INFO, this struct ended after fs_blob_size. */ + size_t fs_fsignatures_size;// input: size of this struct (for compatibility) + char fs_cdhash[USER_FSIGNATURES_CDHASH_LEN]; // output: cdhash + int fs_hash_type;// output: hash algorithm type for cdhash } fsignatures_t; +typedef struct fsupplement { + off_t fs_file_start; /* offset of Mach-O image in FAT file */ + off_t fs_blob_start; /* offset of signature in Mach-O image */ + size_t fs_blob_size; /* signature blob size */ + int fs_orig_fd; /* address of original image */ +} fsupplement_t; + + + /* * DYLD needs to check if the object is allowed to be combined * into the main binary. This is done between the code signature @@ -415,6 +426,19 @@ typedef struct fchecklv { } fchecklv_t; +/* At this time F_GETSIGSINFO can only indicate platformness. + * As additional requestable information is defined, new keys will be added and the + * fgetsigsinfo_t structure will be lengthened to add space for the additional information + */ +#define GETSIGSINFO_PLATFORM_BINARY 1 + +/* fgetsigsinfo_t used by F_GETSIGSINFO command */ +typedef struct fgetsigsinfo { + off_t fg_file_start; /* IN: Offset in the file to look for a signature, -1 for any signature */ + int fg_info_request; /* IN: Key indicating the info requested */ + int fg_sig_is_platform; /* OUT: 1 if the signature is a plat form binary, 0 if not */ +} fgetsigsinfo_t; + /* lock operations for flock(2) */ #define LOCK_SH 0x01 /* shared file lock */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/ioccom.h b/lib/libc/include/x86_64-macos-gnu/sys/ioccom.h index cabce8cf7e..f9d23260e3 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/ioccom.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/ioccom.h @@ -83,7 +83,7 @@ #define IOC_OUT (__uint32_t)0x40000000 /* copy parameters in */ #define IOC_IN (__uint32_t)0x80000000 -/* copy paramters in and out */ +/* copy parameters in and out */ #define IOC_INOUT (IOC_IN|IOC_OUT) /* mask for IN/OUT/VOID */ #define IOC_DIRMASK (__uint32_t)0xe0000000 diff --git a/lib/libc/include/x86_64-macos-gnu/sys/kauth.h b/lib/libc/include/x86_64-macos-gnu/sys/kauth.h new file mode 100644 index 0000000000..c620159658 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/sys/kauth.h @@ -0,0 +1,410 @@ +/* + * Copyright (c) 2004-2010 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + +#ifndef _SYS_KAUTH_H +#define _SYS_KAUTH_H + +#include +#include +#include +#include /* u_int8_t, etc. */ +#include /* __offsetof() */ +#include /* uid_t */ +#include /* gid_t */ +#include /* NGROUPS_MAX */ + +#ifdef __APPLE_API_EVOLVING + +/* + * Identities. + */ + +#define KAUTH_UID_NONE (~(uid_t)0 - 100) /* not a valid UID */ +#define KAUTH_GID_NONE (~(gid_t)0 - 100) /* not a valid GID */ + +#include + +/* NT Security Identifier, structure as defined by Microsoft */ +#pragma pack(1) /* push packing of 1 byte */ +typedef struct { + u_int8_t sid_kind; + u_int8_t sid_authcount; + u_int8_t sid_authority[6]; +#define KAUTH_NTSID_MAX_AUTHORITIES 16 + u_int32_t sid_authorities[KAUTH_NTSID_MAX_AUTHORITIES]; +} ntsid_t; +#pragma pack() /* pop packing to previous packing level */ +#define _NTSID_T + +/* valid byte count inside a SID structure */ +#define KAUTH_NTSID_HDRSIZE (8) +#define KAUTH_NTSID_SIZE(_s) (KAUTH_NTSID_HDRSIZE + ((_s)->sid_authcount * sizeof(u_int32_t))) + +/* + * External lookup message payload; this structure is shared between the + * kernel group membership resolver, and the user space group membership + * resolver daemon, and is use to communicate resolution requests from the + * kernel to user space, and the result of that request from user space to + * the kernel. + */ +struct kauth_identity_extlookup { + u_int32_t el_seqno; /* request sequence number */ + u_int32_t el_result; /* lookup result */ +#define KAUTH_EXTLOOKUP_SUCCESS 0 /* results here are good */ +#define KAUTH_EXTLOOKUP_BADRQ 1 /* request badly formatted */ +#define KAUTH_EXTLOOKUP_FAILURE 2 /* transient failure during lookup */ +#define KAUTH_EXTLOOKUP_FATAL 3 /* permanent failure during lookup */ +#define KAUTH_EXTLOOKUP_INPROG 100 /* request in progress */ + u_int32_t el_flags; +#define KAUTH_EXTLOOKUP_VALID_UID (1<<0) +#define KAUTH_EXTLOOKUP_VALID_UGUID (1<<1) +#define KAUTH_EXTLOOKUP_VALID_USID (1<<2) +#define KAUTH_EXTLOOKUP_VALID_GID (1<<3) +#define KAUTH_EXTLOOKUP_VALID_GGUID (1<<4) +#define KAUTH_EXTLOOKUP_VALID_GSID (1<<5) +#define KAUTH_EXTLOOKUP_WANT_UID (1<<6) +#define KAUTH_EXTLOOKUP_WANT_UGUID (1<<7) +#define KAUTH_EXTLOOKUP_WANT_USID (1<<8) +#define KAUTH_EXTLOOKUP_WANT_GID (1<<9) +#define KAUTH_EXTLOOKUP_WANT_GGUID (1<<10) +#define KAUTH_EXTLOOKUP_WANT_GSID (1<<11) +#define KAUTH_EXTLOOKUP_WANT_MEMBERSHIP (1<<12) +#define KAUTH_EXTLOOKUP_VALID_MEMBERSHIP (1<<13) +#define KAUTH_EXTLOOKUP_ISMEMBER (1<<14) +#define KAUTH_EXTLOOKUP_VALID_PWNAM (1<<15) +#define KAUTH_EXTLOOKUP_WANT_PWNAM (1<<16) +#define KAUTH_EXTLOOKUP_VALID_GRNAM (1<<17) +#define KAUTH_EXTLOOKUP_WANT_GRNAM (1<<18) +#define KAUTH_EXTLOOKUP_VALID_SUPGRPS (1<<19) +#define KAUTH_EXTLOOKUP_WANT_SUPGRPS (1<<20) + + __darwin_pid_t el_info_pid; /* request on behalf of PID */ + u_int64_t el_extend; /* extension field */ + u_int32_t el_info_reserved_1; /* reserved (APPLE) */ + + uid_t el_uid; /* user ID */ + guid_t el_uguid; /* user GUID */ + u_int32_t el_uguid_valid; /* TTL on translation result (seconds) */ + ntsid_t el_usid; /* user NT SID */ + u_int32_t el_usid_valid; /* TTL on translation result (seconds) */ + gid_t el_gid; /* group ID */ + guid_t el_gguid; /* group GUID */ + u_int32_t el_gguid_valid; /* TTL on translation result (seconds) */ + ntsid_t el_gsid; /* group SID */ + u_int32_t el_gsid_valid; /* TTL on translation result (seconds) */ + u_int32_t el_member_valid; /* TTL on group lookup result */ + u_int32_t el_sup_grp_cnt; /* count of supplemental groups up to NGROUPS */ + gid_t el_sup_groups[NGROUPS_MAX]; /* supplemental group list */ +}; + +struct kauth_cache_sizes { + u_int32_t kcs_group_size; + u_int32_t kcs_id_size; +}; + +#define KAUTH_EXTLOOKUP_REGISTER (0) +#define KAUTH_EXTLOOKUP_RESULT (1<<0) +#define KAUTH_EXTLOOKUP_WORKER (1<<1) +#define KAUTH_EXTLOOKUP_DEREGISTER (1<<2) +#define KAUTH_GET_CACHE_SIZES (1<<3) +#define KAUTH_SET_CACHE_SIZES (1<<4) +#define KAUTH_CLEAR_CACHES (1<<5) + +#define IDENTITYSVC_ENTITLEMENT "com.apple.private.identitysvc" + + + +/* + * Generic Access Control Lists. + */ +#if defined(KERNEL) || defined (_SYS_ACL_H) + +typedef u_int32_t kauth_ace_rights_t; + +/* Access Control List Entry (ACE) */ +struct kauth_ace { + guid_t ace_applicable; + u_int32_t ace_flags; +#define KAUTH_ACE_KINDMASK 0xf +#define KAUTH_ACE_PERMIT 1 +#define KAUTH_ACE_DENY 2 +#define KAUTH_ACE_AUDIT 3 /* not implemented */ +#define KAUTH_ACE_ALARM 4 /* not implemented */ +#define KAUTH_ACE_INHERITED (1<<4) +#define KAUTH_ACE_FILE_INHERIT (1<<5) +#define KAUTH_ACE_DIRECTORY_INHERIT (1<<6) +#define KAUTH_ACE_LIMIT_INHERIT (1<<7) +#define KAUTH_ACE_ONLY_INHERIT (1<<8) +#define KAUTH_ACE_SUCCESS (1<<9) /* not implemented (AUDIT/ALARM) */ +#define KAUTH_ACE_FAILURE (1<<10) /* not implemented (AUDIT/ALARM) */ +/* All flag bits controlling ACE inheritance */ +#define KAUTH_ACE_INHERIT_CONTROL_FLAGS \ + (KAUTH_ACE_FILE_INHERIT | \ + KAUTH_ACE_DIRECTORY_INHERIT | \ + KAUTH_ACE_LIMIT_INHERIT | \ + KAUTH_ACE_ONLY_INHERIT) + kauth_ace_rights_t ace_rights; /* scope specific */ + /* These rights are never tested, but may be present in an ACL */ +#define KAUTH_ACE_GENERIC_ALL (1<<21) +#define KAUTH_ACE_GENERIC_EXECUTE (1<<22) +#define KAUTH_ACE_GENERIC_WRITE (1<<23) +#define KAUTH_ACE_GENERIC_READ (1<<24) +}; + +#ifndef _KAUTH_ACE +#define _KAUTH_ACE +typedef struct kauth_ace *kauth_ace_t; +#endif + + +/* Access Control List */ +struct kauth_acl { + u_int32_t acl_entrycount; + u_int32_t acl_flags; + + struct kauth_ace acl_ace[1]; +}; + +/* + * XXX this value needs to be raised - 3893388 + */ +#define KAUTH_ACL_MAX_ENTRIES 128 + +/* + * The low 16 bits of the flags field are reserved for filesystem + * internal use and must be preserved by all APIs. This includes + * round-tripping flags through user-space interfaces. + */ +#define KAUTH_ACL_FLAGS_PRIVATE (0xffff) + +/* + * The high 16 bits of the flags are used to store attributes and + * to request specific handling of the ACL. + */ + +/* inheritance will be deferred until the first rename operation */ +#define KAUTH_ACL_DEFER_INHERIT (1<<16) +/* this ACL must not be overwritten as part of an inheritance operation */ +#define KAUTH_ACL_NO_INHERIT (1<<17) + +/* acl_entrycount that tells us the ACL is not valid */ +#define KAUTH_FILESEC_NOACL ((u_int32_t)(-1)) + +/* + * If the acl_entrycount field is KAUTH_FILESEC_NOACL, then the size is the + * same as a kauth_acl structure; the intent is to put an actual entrycount of + * KAUTH_FILESEC_NOACL on disk to distinguish a kauth_filesec_t with an empty + * entry (Windows treats this as "deny all") from one that merely indicates a + * file group and/or owner guid values. + */ +#define KAUTH_ACL_SIZE(c) (__offsetof(struct kauth_acl, acl_ace) + ((u_int32_t)(c) != KAUTH_FILESEC_NOACL ? ((c) * sizeof(struct kauth_ace)) : 0)) +#define KAUTH_ACL_COPYSIZE(p) KAUTH_ACL_SIZE((p)->acl_entrycount) + + +#ifndef _KAUTH_ACL +#define _KAUTH_ACL +typedef struct kauth_acl *kauth_acl_t; +#endif + + + +/* + * Extended File Security. + */ + +/* File Security information */ +struct kauth_filesec { + u_int32_t fsec_magic; +#define KAUTH_FILESEC_MAGIC 0x012cc16d + guid_t fsec_owner; + guid_t fsec_group; + + struct kauth_acl fsec_acl; +}; + +/* backwards compatibility */ +#define fsec_entrycount fsec_acl.acl_entrycount +#define fsec_flags fsec_acl.acl_flags +#define fsec_ace fsec_acl.acl_ace +#define KAUTH_FILESEC_FLAGS_PRIVATE KAUTH_ACL_FLAGS_PRIVATE +#define KAUTH_FILESEC_DEFER_INHERIT KAUTH_ACL_DEFER_INHERIT +#define KAUTH_FILESEC_NO_INHERIT KAUTH_ACL_NO_INHERIT +#define KAUTH_FILESEC_NONE ((kauth_filesec_t)0) +#define KAUTH_FILESEC_WANTED ((kauth_filesec_t)1) + +#ifndef _KAUTH_FILESEC +#define _KAUTH_FILESEC +typedef struct kauth_filesec *kauth_filesec_t; +#endif + +#define KAUTH_FILESEC_SIZE(c) (__offsetof(struct kauth_filesec, fsec_acl) + __offsetof(struct kauth_acl, acl_ace) + (c) * sizeof(struct kauth_ace)) +#define KAUTH_FILESEC_COPYSIZE(p) KAUTH_FILESEC_SIZE(((p)->fsec_entrycount == KAUTH_FILESEC_NOACL) ? 0 : (p)->fsec_entrycount) +#define KAUTH_FILESEC_COUNT(s) (((s) - KAUTH_FILESEC_SIZE(0)) / sizeof(struct kauth_ace)) +#define KAUTH_FILESEC_VALID(s) ((s) >= KAUTH_FILESEC_SIZE(0) && (((s) - KAUTH_FILESEC_SIZE(0)) % sizeof(struct kauth_ace)) == 0) + +#define KAUTH_FILESEC_XATTR "com.apple.system.Security" + +/* Allowable first arguments to kauth_filesec_acl_setendian() */ +#define KAUTH_ENDIAN_HOST 0x00000001 /* set host endianness */ +#define KAUTH_ENDIAN_DISK 0x00000002 /* set disk endianness */ + +#endif /* KERNEL || */ + + + +/* Actions, also rights bits in an ACE */ + +#if defined(KERNEL) || defined (_SYS_ACL_H) +#define KAUTH_VNODE_READ_DATA (1U<<1) +#define KAUTH_VNODE_LIST_DIRECTORY KAUTH_VNODE_READ_DATA +#define KAUTH_VNODE_WRITE_DATA (1U<<2) +#define KAUTH_VNODE_ADD_FILE KAUTH_VNODE_WRITE_DATA +#define KAUTH_VNODE_EXECUTE (1U<<3) +#define KAUTH_VNODE_SEARCH KAUTH_VNODE_EXECUTE +#define KAUTH_VNODE_DELETE (1U<<4) +#define KAUTH_VNODE_APPEND_DATA (1U<<5) +#define KAUTH_VNODE_ADD_SUBDIRECTORY KAUTH_VNODE_APPEND_DATA +#define KAUTH_VNODE_DELETE_CHILD (1U<<6) +#define KAUTH_VNODE_READ_ATTRIBUTES (1U<<7) +#define KAUTH_VNODE_WRITE_ATTRIBUTES (1U<<8) +#define KAUTH_VNODE_READ_EXTATTRIBUTES (1U<<9) +#define KAUTH_VNODE_WRITE_EXTATTRIBUTES (1U<<10) +#define KAUTH_VNODE_READ_SECURITY (1U<<11) +#define KAUTH_VNODE_WRITE_SECURITY (1U<<12) +#define KAUTH_VNODE_TAKE_OWNERSHIP (1U<<13) + +/* backwards compatibility only */ +#define KAUTH_VNODE_CHANGE_OWNER KAUTH_VNODE_TAKE_OWNERSHIP + +/* For Windows interoperability only */ +#define KAUTH_VNODE_SYNCHRONIZE (1U<<20) + +/* (1<<21) - (1<<24) are reserved for generic rights bits */ + +/* Actions not expressed as rights bits */ +/* + * Authorizes the vnode as the target of a hard link. + */ +#define KAUTH_VNODE_LINKTARGET (1U<<25) + +/* + * Indicates that other steps have been taken to authorise the action, + * but authorisation should be denied for immutable objects. + */ +#define KAUTH_VNODE_CHECKIMMUTABLE (1U<<26) + +/* Action modifiers */ +/* + * The KAUTH_VNODE_ACCESS bit is passed to the callback if the authorisation + * request in progress is advisory, rather than authoritative. Listeners + * performing consequential work (i.e. not strictly checking authorisation) + * may test this flag to avoid performing unnecessary work. + * + * This bit will never be present in an ACE. + */ +#define KAUTH_VNODE_ACCESS (1U<<31) + +/* + * The KAUTH_VNODE_NOIMMUTABLE bit is passed to the callback along with the + * KAUTH_VNODE_WRITE_SECURITY bit (and no others) to indicate that the + * caller wishes to change one or more of the immutable flags, and the + * state of these flags should not be considered when authorizing the request. + * The system immutable flags are only ignored when the system securelevel + * is low enough to allow their removal. + */ +#define KAUTH_VNODE_NOIMMUTABLE (1U<<30) + + +/* + * fake right that is composed by the following... + * vnode must have search for owner, group and world allowed + * plus there must be no deny modes present for SEARCH... this fake + * right is used by the fast lookup path to avoid checking + * for an exact match on the last credential to lookup + * the component being acted on + */ +#define KAUTH_VNODE_SEARCHBYANYONE (1U<<29) + + +/* + * when passed as an 'action' to "vnode_uncache_authorized_actions" + * it indicates that all of the cached authorizations for that + * vnode should be invalidated + */ +#define KAUTH_INVALIDATE_CACHED_RIGHTS ((kauth_action_t)~0) + + + +/* The expansions of the GENERIC bits at evaluation time */ +#define KAUTH_VNODE_GENERIC_READ_BITS (KAUTH_VNODE_READ_DATA | \ + KAUTH_VNODE_READ_ATTRIBUTES | \ + KAUTH_VNODE_READ_EXTATTRIBUTES | \ + KAUTH_VNODE_READ_SECURITY) + +#define KAUTH_VNODE_GENERIC_WRITE_BITS (KAUTH_VNODE_WRITE_DATA | \ + KAUTH_VNODE_APPEND_DATA | \ + KAUTH_VNODE_DELETE | \ + KAUTH_VNODE_DELETE_CHILD | \ + KAUTH_VNODE_WRITE_ATTRIBUTES | \ + KAUTH_VNODE_WRITE_EXTATTRIBUTES | \ + KAUTH_VNODE_WRITE_SECURITY) + +#define KAUTH_VNODE_GENERIC_EXECUTE_BITS (KAUTH_VNODE_EXECUTE) + +#define KAUTH_VNODE_GENERIC_ALL_BITS (KAUTH_VNODE_GENERIC_READ_BITS | \ + KAUTH_VNODE_GENERIC_WRITE_BITS | \ + KAUTH_VNODE_GENERIC_EXECUTE_BITS) + +/* + * Some sets of bits, defined here for convenience. + */ +#define KAUTH_VNODE_WRITE_RIGHTS (KAUTH_VNODE_ADD_FILE | \ + KAUTH_VNODE_ADD_SUBDIRECTORY | \ + KAUTH_VNODE_DELETE_CHILD | \ + KAUTH_VNODE_WRITE_DATA | \ + KAUTH_VNODE_APPEND_DATA | \ + KAUTH_VNODE_DELETE | \ + KAUTH_VNODE_WRITE_ATTRIBUTES | \ + KAUTH_VNODE_WRITE_EXTATTRIBUTES | \ + KAUTH_VNODE_WRITE_SECURITY | \ + KAUTH_VNODE_TAKE_OWNERSHIP | \ + KAUTH_VNODE_LINKTARGET | \ + KAUTH_VNODE_CHECKIMMUTABLE) + + +#endif /* KERNEL || */ + + +#endif /* __APPLE_API_EVOLVING */ +#endif /* _SYS_KAUTH_H */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/mman.h b/lib/libc/include/x86_64-macos-gnu/sys/mman.h index 45ed2b8f8c..3eaab26d53 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/mman.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/mman.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2019 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2020 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -89,6 +89,10 @@ #include #include +#if __DARWIN_C_LEVEL >= 200809L +#include +#endif /* __DARWIN_C_LEVEL */ + /* * Protections are chosen from these bits, or-ed together */ @@ -145,9 +149,17 @@ #define MAP_RESILIENT_CODESIGN 0x2000 /* no code-signing failures */ #define MAP_RESILIENT_MEDIA 0x4000 /* no backing-store failures */ -#if !defined(CONFIG_EMBEDDED) -#define MAP_32BIT 0x8000 /* Return virtual addresses <4G only: Requires entitlement */ -#endif /* !defined(CONFIG_EMBEDDED) */ +#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 +#define MAP_32BIT 0x8000 /* Return virtual addresses <4G only */ +#endif /* defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 */ + + +/* + * Flags used to support translated processes. + */ +#define MAP_TRANSLATED_ALLOW_EXECUTE 0x20000 /* allow execute in translated processes */ + +#define MAP_UNIX03 0x40000 /* UNIX03 compliance */ #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ @@ -213,6 +225,7 @@ + __BEGIN_DECLS /* [ML] */ int mlockall(int); diff --git a/lib/libc/include/x86_64-macos-gnu/sys/mount.h b/lib/libc/include/x86_64-macos-gnu/sys/mount.h index b1d5386eae..543af06a3c 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/mount.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/mount.h @@ -324,7 +324,7 @@ struct vfsidctl { * New style VFS sysctls, do not reuse/conflict with the namespace for * private sysctls. */ -#define VFS_CTL_STATFS 0x00010001 /* statfs */ +#define VFS_CTL_OSTATFS 0x00010001 /* old legacy statfs */ #define VFS_CTL_UMOUNT 0x00010002 /* unmount */ #define VFS_CTL_QUERY 0x00010003 /* anything wrong? (vfsquery) */ #define VFS_CTL_NEWADDR 0x00010004 /* reconnect to new address */ @@ -334,6 +334,17 @@ struct vfsidctl { #define VFS_CTL_DISC 0x00010008 /* server disconnected */ #define VFS_CTL_SERVERINFO 0x00010009 /* information about fs server */ #define VFS_CTL_NSTATUS 0x0001000A /* netfs mount status */ +#define VFS_CTL_STATFS64 0x0001000B /* statfs64 */ + +/* + * Automatically select the correct VFS_CTL_*STATFS* flavor based + * on what "struct statfs" layout the client will use. + */ +#if __DARWIN_64_BIT_INO_T +#define VFS_CTL_STATFS VFS_CTL_STATFS64 +#else +#define VFS_CTL_STATFS VFS_CTL_OSTATFS +#endif struct vfsquery { u_int32_t vq_flags; diff --git a/lib/libc/include/x86_64-macos-gnu/sys/param.h b/lib/libc/include/x86_64-macos-gnu/sys/param.h index e271b592b3..8540595d3c 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/param.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/param.h @@ -197,10 +197,10 @@ #define MAXSYMLINKS 32 /* Bit map related macros. */ -#define setbit(a, i) (((char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY)) -#define clrbit(a, i) (((char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY))) -#define isset(a, i) (((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) -#define isclr(a, i) ((((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) +#define setbit(a, i) (((unsigned char *)(a))[(i)/NBBY] |= 1u<<((i)%NBBY)) +#define clrbit(a, i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1u<<((i)%NBBY))) +#define isset(a, i) (((unsigned char *)(a))[(i)/NBBY] & (1u<<((i)%NBBY))) +#define isclr(a, i) ((((unsigned char *)(a))[(i)/NBBY] & (1u<<((i)%NBBY))) == 0) /* Macros for counting and rounding. */ #ifndef howmany @@ -218,24 +218,6 @@ #define MAX(a, b) (((a)>(b))?(a):(b)) #endif /* MAX */ -/* - * Constants for setting the parameters of the kernel memory allocator. - * - * 2 ** MINBUCKET is the smallest unit of memory that will be - * allocated. It must be at least large enough to hold a pointer. - * - * Units of memory less or equal to MAXALLOCSAVE will permanently - * allocate physical memory; requests for these size pieces of - * memory are quite fast. Allocations greater than MAXALLOCSAVE must - * always allocate and free physical memory; requests for these - * size allocations should be done infrequently as they will be slow. - * - * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and - * MAXALLOCSIZE must be a power of two. - */ -#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ -#define MAXALLOCSAVE (2 * CLBYTES) - /* * Scale factor for scaled integers used to count %cpu time and load avgs. * diff --git a/lib/libc/include/x86_64-macos-gnu/sys/proc.h b/lib/libc/include/x86_64-macos-gnu/sys/proc.h index ff25bdd61b..1ecbc39518 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/proc.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/proc.h @@ -84,6 +84,7 @@ struct session; struct pgrp; struct proc; +struct proc_ident; /* Exported fields for kern sysctls */ struct extern_proc { diff --git a/lib/libc/include/x86_64-macos-gnu/sys/resource.h b/lib/libc/include/x86_64-macos-gnu/sys/resource.h index a1d512cb2e..f3dbca00e0 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/resource.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/resource.h @@ -188,7 +188,13 @@ struct rusage { #define RUSAGE_INFO_V2 2 #define RUSAGE_INFO_V3 3 #define RUSAGE_INFO_V4 4 -#define RUSAGE_INFO_CURRENT RUSAGE_INFO_V4 +#define RUSAGE_INFO_V5 5 +#define RUSAGE_INFO_CURRENT RUSAGE_INFO_V5 + +/* + * Flags for RUSAGE_INFO_V5 + */ +#define RU_PROC_RUNS_RESLIDE 0x00000001 /* proc has reslid shared cache */ typedef void *rusage_info_t; @@ -318,7 +324,47 @@ struct rusage_info_v4 { uint64_t ri_runnable_time; }; -typedef struct rusage_info_v4 rusage_info_current; +struct rusage_info_v5 { + uint8_t ri_uuid[16]; + uint64_t ri_user_time; + uint64_t ri_system_time; + uint64_t ri_pkg_idle_wkups; + uint64_t ri_interrupt_wkups; + uint64_t ri_pageins; + uint64_t ri_wired_size; + uint64_t ri_resident_size; + uint64_t ri_phys_footprint; + uint64_t ri_proc_start_abstime; + uint64_t ri_proc_exit_abstime; + uint64_t ri_child_user_time; + uint64_t ri_child_system_time; + uint64_t ri_child_pkg_idle_wkups; + uint64_t ri_child_interrupt_wkups; + uint64_t ri_child_pageins; + uint64_t ri_child_elapsed_abstime; + uint64_t ri_diskio_bytesread; + uint64_t ri_diskio_byteswritten; + uint64_t ri_cpu_time_qos_default; + uint64_t ri_cpu_time_qos_maintenance; + uint64_t ri_cpu_time_qos_background; + uint64_t ri_cpu_time_qos_utility; + uint64_t ri_cpu_time_qos_legacy; + uint64_t ri_cpu_time_qos_user_initiated; + uint64_t ri_cpu_time_qos_user_interactive; + uint64_t ri_billed_system_time; + uint64_t ri_serviced_system_time; + uint64_t ri_logical_writes; + uint64_t ri_lifetime_max_phys_footprint; + uint64_t ri_instructions; + uint64_t ri_cycles; + uint64_t ri_billed_energy; + uint64_t ri_serviced_energy; + uint64_t ri_interval_max_phys_footprint; + uint64_t ri_runnable_time; + uint64_t ri_flags; +}; + +typedef struct rusage_info_v5 rusage_info_current; #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ @@ -409,6 +455,8 @@ struct proc_rlimit_control_wakeupmon { #define IOPOL_TYPE_VFS_ATIME_UPDATES 2 #define IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES 3 #define IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME 4 +#define IOPOL_TYPE_VFS_TRIGGER_RESOLVE 5 +#define IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION 6 /* scope */ #define IOPOL_SCOPE_PROCESS 0 @@ -438,6 +486,12 @@ struct proc_rlimit_control_wakeupmon { #define IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT 0 #define IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME 1 +#define IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT 0 +#define IOPOL_VFS_TRIGGER_RESOLVE_OFF 1 + +#define IOPOL_VFS_CONTENT_PROTECTION_DEFAULT 0 +#define IOPOL_VFS_CONTENT_PROTECTION_IGNORE 1 + #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/shm.h b/lib/libc/include/x86_64-macos-gnu/sys/shm.h index ab138cf564..634858abe2 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/shm.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/shm.h @@ -109,7 +109,11 @@ typedef unsigned short shmatt_t; * headers at this time, to avoid the resulting namespace * pollution, which is why we discourages its use. */ +#if __arm64__ +#define SHMLBA (16*1024) /* [XSI] Segment low boundary address multiple*/ +#else /* __arm64__ */ #define SHMLBA 4096 /* [XSI] Segment low boundary address multiple*/ +#endif /* __arm64__ */ /* "official" access mode definitions; somewhat braindead since you have * to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/socket.h b/lib/libc/include/x86_64-macos-gnu/sys/socket.h index eb4bf144a1..4e1ff6e503 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/socket.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/socket.h @@ -160,8 +160,8 @@ #define SO_ERROR 0x1007 /* get error status and clear */ #define SO_TYPE 0x1008 /* get socket type */ #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#define SO_LABEL 0x1010 /* socket's MAC label */ -#define SO_PEERLABEL 0x1011 /* socket's peer MAC label */ +#define SO_LABEL 0x1010 /* deprecated */ +#define SO_PEERLABEL 0x1011 /* deprecated */ #ifdef __APPLE__ #define SO_NREAD 0x1020 /* APPLE: get 1st-packet byte count */ #define SO_NKE 0x1021 /* APPLE: Install socket-level NKE */ @@ -182,7 +182,7 @@ #define SO_NET_SERVICE_TYPE 0x1116 /* Network service type */ -#define SO_NETSVC_MARKING_LEVEL 0x1119 /* Get QoS marking in effect for socket */ +#define SO_NETSVC_MARKING_LEVEL 0x1119 /* Get QoS marking in effect for socket */ /* * Network Service Type for option SO_NET_SERVICE_TYPE @@ -398,7 +398,8 @@ struct so_np_extensions { #define AF_RESERVED_36 36 /* Reserved for internal usage */ #define AF_IEEE80211 37 /* IEEE 802.11 protocol */ #define AF_UTUN 38 -#define AF_MAX 40 +#define AF_VSOCK 40 /* VM Sockets */ +#define AF_MAX 41 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ /* @@ -486,6 +487,7 @@ struct sockaddr_storage { #define PF_PPP AF_PPP #define PF_RESERVED_36 AF_RESERVED_36 #define PF_UTUN AF_UTUN +#define PF_VSOCK AF_VSOCK #define PF_MAX AF_MAX /* @@ -578,6 +580,13 @@ struct msghdr { #define MSG_NEEDSA 0x10000 /* Fail receive if socket address cannot be allocated */ #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#if __DARWIN_C_LEVEL >= 200809L +#define MSG_NOSIGNAL 0x80000 /* do not generate SIGPIPE on EOF */ +#endif /* __DARWIN_C_LEVEL */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + /* * Header for ancillary data objects in msg_control buffer. * Used for additional information with/about a datagram @@ -671,7 +680,7 @@ struct cmsgcred { #define SHUT_WR 1 /* shut down the writing side */ #define SHUT_RDWR 2 /* shut down both sides */ -#if !defined(_POSIX_C_SOURCE) +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) /* * sendfile(2) header/trailer struct */ @@ -683,7 +692,7 @@ struct sf_hdtr { }; -#endif /* !_POSIX_C_SOURCE */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ __BEGIN_DECLS diff --git a/lib/libc/include/x86_64-macos-gnu/sys/spawn.h b/lib/libc/include/x86_64-macos-gnu/sys/spawn.h index 498e6a9476..2ec5ce26c0 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/spawn.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/spawn.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2006-2020 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -61,6 +61,8 @@ #define POSIX_SPAWN_SETSID 0x0400 #define POSIX_SPAWN_CLOEXEC_DEFAULT 0x4000 +#define _POSIX_SPAWN_RESLIDE 0x0800 + /* * Possible values to be set for the process control actions on resource starvation. * POSIX_SPAWN_PCONTROL_THROTTLE indicates that the process is to be throttled on starvation. diff --git a/lib/libc/include/x86_64-macos-gnu/sys/stat.h b/lib/libc/include/x86_64-macos-gnu/sys/stat.h index 79dbd1dc95..27cf31a498 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/stat.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/stat.h @@ -361,6 +361,7 @@ struct stat64 __DARWIN_STRUCT_STAT64; #endif +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL /* * Extended flags ("EF") returned by ATTR_CMNEXT_EXT_FLAGS from getattrlist/getattrlistbulk */ @@ -369,7 +370,8 @@ struct stat64 __DARWIN_STRUCT_STAT64; #define EF_IS_SYNC_ROOT 0x00000004 /* file is a sync root for iCloud */ #define EF_IS_PURGEABLE 0x00000008 /* file is purgeable */ #define EF_IS_SPARSE 0x00000010 /* file has at least one sparse region */ - +#define EF_IS_SYNTHETIC 0x00000020 /* a synthetic directory/symlink */ +#endif diff --git a/lib/libc/include/x86_64-macos-gnu/sys/sysctl.h b/lib/libc/include/x86_64-macos-gnu/sys/sysctl.h index 73293ac8f4..e11a2eb4f7 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/sysctl.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/sysctl.h @@ -553,8 +553,8 @@ extern struct loadavg averunnable; /* * CTL_HW identifiers */ -#define HW_MACHINE 1 /* string: machine class */ -#define HW_MODEL 2 /* string: specific machine model */ +#define HW_MACHINE 1 /* string: machine class (deprecated: use HW_PRODUCT) */ +#define HW_MODEL 2 /* string: specific machine model (deprecated: use HW_TARGET) */ #define HW_NCPU 3 /* int: number of cpus */ #define HW_BYTEORDER 4 /* int: machine byte order */ #define HW_PHYSMEM 5 /* int: total memory */ @@ -578,12 +578,14 @@ extern struct loadavg averunnable; #define HW_TB_FREQ 23 /* int: Bus Frequency */ #define HW_MEMSIZE 24 /* uint64_t: physical ram size */ #define HW_AVAILCPU 25 /* int: number of available CPUs */ -#define HW_MAXID 26 /* number of valid hw ids */ +#define HW_TARGET 26 /* string: model identifier */ +#define HW_PRODUCT 27 /* string: product identifier */ +#define HW_MAXID 28 /* number of valid hw ids */ #define CTL_HW_NAMES { \ { 0, 0 }, \ - { "machine", CTLTYPE_STRING }, \ - { "model", CTLTYPE_STRING }, \ + { "machine", CTLTYPE_STRING }, /* Deprecated: use hw.product */ \ + { "model", CTLTYPE_STRING }, /* Deprecated: use hw.target */ \ { "ncpu", CTLTYPE_INT }, \ { "byteorder", CTLTYPE_INT }, \ { "physmem", CTLTYPE_INT }, \ @@ -606,7 +608,9 @@ extern struct loadavg averunnable; { "l3cachesize", CTLTYPE_INT }, \ { "tbfrequency", CTLTYPE_INT }, \ { "memsize", CTLTYPE_QUAD }, \ - { "availcpu", CTLTYPE_INT } \ + { "availcpu", CTLTYPE_INT }, \ + { "target", CTLTYPE_STRING }, \ + { "product", CTLTYPE_STRING }, \ } /* @@ -755,7 +759,7 @@ extern struct loadavg averunnable; #define CTL_DEBUG_MAXID 20 -#if (CTL_MAXID != 9) || (KERN_MAXID != 72) || (VM_MAXID != 6) || (HW_MAXID != 26) || (USER_MAXID != 21) || (CTL_DEBUG_MAXID != 20) +#if (CTL_MAXID != 9) || (KERN_MAXID != 72) || (VM_MAXID != 6) || (HW_MAXID != 28) || (USER_MAXID != 21) || (CTL_DEBUG_MAXID != 20) #error Use the SYSCTL_*() macros and OID_AUTO instead! #endif diff --git a/lib/libc/include/x86_64-macos-gnu/sys/syslimits.h b/lib/libc/include/x86_64-macos-gnu/sys/syslimits.h index 28424700fa..1c2aa9a18c 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/syslimits.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/syslimits.h @@ -68,11 +68,19 @@ #include #if !defined(_ANSI_SOURCE) + +/* max bytes for an exec function */ +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) +#define ARG_MAX (1024 * 1024) +#else +#define ARG_MAX (256 * 1024) +#endif + /* * Note: CHILD_MAX *must* be less than hard_maxproc, which is set at * compile time; you *cannot* set it higher than the hard limit!! */ -#define ARG_MAX (256 * 1024) /* max bytes for an exec function */ + #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) #define CHILD_MAX 266 /* max simultaneous processes */ #define GID_MAX 2147483647U /* max value for a gid_t (2^31-2) */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/uio.h b/lib/libc/include/x86_64-macos-gnu/sys/uio.h index 40305923fa..3edd282425 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/uio.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/uio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2008 Apple Inc. All rights reserved. + * Copyright (c) 2000-2019 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -64,8 +64,10 @@ #ifndef _SYS_UIO_H_ #define _SYS_UIO_H_ +#include #include #include +#include /* * [XSI] The ssize_t and size_t types shall be defined as described @@ -76,7 +78,7 @@ /* * [XSI] Structure whose address is passed as the second parameter to the - * readv() and writev() functions. + * readv(), preadv(), writev() and pwritev() functions. */ #include @@ -95,6 +97,15 @@ enum uio_rw { UIO_READ, UIO_WRITE }; __BEGIN_DECLS ssize_t readv(int, const struct iovec *, int) __DARWIN_ALIAS_C(readv); ssize_t writev(int, const struct iovec *, int) __DARWIN_ALIAS_C(writev); + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) + +ssize_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)); +ssize_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)); + +#endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */ + __END_DECLS + #endif /* !_SYS_UIO_H_ */ diff --git a/lib/libc/include/x86_64-macos-gnu/sys/un.h b/lib/libc/include/x86_64-macos-gnu/sys/un.h index 93d37f9e6e..6d91a9ad88 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/un.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/un.h @@ -90,6 +90,7 @@ struct sockaddr_un { #define LOCAL_PEEREPID 0x003 /* retrieve eff. peer pid */ #define LOCAL_PEERUUID 0x004 /* retrieve peer UUID */ #define LOCAL_PEEREUUID 0x005 /* retrieve eff. peer UUID */ +#define LOCAL_PEERTOKEN 0x006 /* retrieve peer audit token */ #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_inttypes.h b/lib/libc/include/x86_64-macos-gnu/xlocale/_inttypes.h index db72853f86..8a7f563e37 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_inttypes.h +++ b/lib/libc/include/x86_64-macos-gnu/xlocale/_inttypes.h @@ -26,6 +26,7 @@ #include #include +#include /* wchar_t */ #include <_xlocale.h> __BEGIN_DECLS diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_wchar.h b/lib/libc/include/x86_64-macos-gnu/xlocale/_wchar.h index 260f540bd6..b8eb41e096 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_wchar.h +++ b/lib/libc/include/x86_64-macos-gnu/xlocale/_wchar.h @@ -27,6 +27,8 @@ #include <_stdio.h> #include <_xlocale.h> #include +#include +#include /* wchar_t */ /* Initially added in Issue 4 */ __BEGIN_DECLS diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/activity.h b/lib/libc/include/x86_64-macos-gnu/xpc/activity.h new file mode 100644 index 0000000000..c4f58e8f6c --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/xpc/activity.h @@ -0,0 +1,447 @@ +#ifndef __XPC_ACTIVITY_H__ +#define __XPC_ACTIVITY_H__ + +#ifndef __XPC_INDIRECT__ +#error "Please #include instead of this file directly." +// For HeaderDoc. +#include +#endif // __XPC_INDIRECT__ + +#ifdef __BLOCKS__ + +XPC_ASSUME_NONNULL_BEGIN +__BEGIN_DECLS + +/* + * The following are a collection of keys and values used to set an activity's + * execution criteria. + */ + +/*! + * @constant XPC_ACTIVITY_INTERVAL + * An integer property indicating the desired time interval (in seconds) of the + * activity. The activity will not be run more than once per time interval. + * Due to the nature of XPC Activity finding an opportune time to run + * the activity, any two occurrences may be more or less than 'interval' + * seconds apart, but on average will be 'interval' seconds apart. + * The presence of this key implies the following, unless overridden: + * - XPC_ACTIVITY_REPEATING with a value of true + * - XPC_ACTIVITY_DELAY with a value of half the 'interval' + * The delay enforces a minimum distance between any two occurrences. + * - XPC_ACTIVITY_GRACE_PERIOD with a value of half the 'interval'. + * The grace period is the amount of time allowed to pass after the end of + * the interval before more aggressive scheduling occurs. The grace period + * does not increase the size of the interval. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_INTERVAL; + +/*! + * @constant XPC_ACTIVITY_REPEATING + * A boolean property indicating whether this is a repeating activity. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_REPEATING; + +/*! + * @constant XPC_ACTIVITY_DELAY + * An integer property indicating the number of seconds to delay before + * beginning the activity. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_DELAY; + +/*! + * @constant XPC_ACTIVITY_GRACE_PERIOD + * An integer property indicating the number of seconds to allow as a grace + * period before the scheduling of the activity becomes more aggressive. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_GRACE_PERIOD; + + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_1_MIN; + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_5_MIN; + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_15_MIN; + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_30_MIN; + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_1_HOUR; + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_4_HOURS; + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_8_HOURS; + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_1_DAY; + +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const int64_t XPC_ACTIVITY_INTERVAL_7_DAYS; + +/*! + * @constant XPC_ACTIVITY_PRIORITY + * A string property indicating the priority of the activity. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_PRIORITY; + +/*! + * @constant XPC_ACTIVITY_PRIORITY_MAINTENANCE + * A string indicating activity is maintenance priority. + * + * Maintenance priority is intended for user-invisible maintenance tasks + * such as garbage collection or optimization. + * + * Maintenance activities are not permitted to run if the device thermal + * condition exceeds a nominal level or if the battery level is lower than 20%. + * In Low Power Mode (on supported devices), maintenance activities are not + * permitted to run while the device is on battery, or plugged in and the + * battery level is lower than 30%. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_PRIORITY_MAINTENANCE; + +/*! + * @constant XPC_ACTIVITY_PRIORITY_UTILITY + * A string indicating activity is utility priority. + * + * Utility priority is intended for user-visible tasks such as fetching data + * from the network, copying files, or importing data. + * + * Utility activities are not permitted to run if the device thermal condition + * exceeds a moderate level or if the battery level is less than 10%. In Low + * Power Mode (on supported devices) when on battery power, utility activities + * are only permitted when they are close to their deadline (90% of their time + * window has elapsed). + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_PRIORITY_UTILITY; + +/*! + * @constant XPC_ACTIVITY_ALLOW_BATTERY + * A Boolean value indicating whether the activity should be allowed to run + * while the computer is on battery power. The default value is false for + * maintenance priority activity and true for utility priority activity. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_ALLOW_BATTERY; + +/*! + * @constant XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP + * A Boolean value indicating whether the activity should only be performed + * while device appears to be asleep. Note that the definition of screen sleep + * may vary by platform and may include states where the device is known to be + * idle despite the fact that the display itself is still powered. Defaults to + * false. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const char * const XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP; // bool + +/*! + * @constant XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL + * An integer percentage of minimum battery charge required to allow the + * activity to run. A default minimum battery level is determined by the + * system. + */ +__OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_9, __MAC_10_9, __IPHONE_7_0, __IPHONE_7_0, + "REQUIRE_BATTERY_LEVEL is not implemented") +XPC_EXPORT +const char * const XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL; // int (%) + +/*! + * @constant XPC_ACTIVITY_REQUIRE_HDD_SPINNING + * A Boolean value indicating whether the activity should only be performed + * while the hard disk drive (HDD) is spinning. Computers with flash storage + * are considered to be equivalent to HDD spinning. Defaults to false. + */ +__OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_9, __MAC_10_9, __IPHONE_7_0, __IPHONE_7_0, + "REQUIRE_HDD_SPINNING is not implemented") +XPC_EXPORT +const char * const XPC_ACTIVITY_REQUIRE_HDD_SPINNING; // bool + +/*! + * @define XPC_TYPE_ACTIVITY + * A type representing the XPC activity object. + */ +#define XPC_TYPE_ACTIVITY (&_xpc_type_activity) +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_activity); + +/*! + * @typedef xpc_activity_t + * + * @abstract + * An XPC activity object. + * + * @discussion + * This object represents a set of execution criteria and a current execution + * state for background activity on the system. Once an activity is registered, + * the system will evaluate its criteria to determine whether the activity is + * eligible to run under current system conditions. When an activity becomes + * eligible to run, its execution state will be updated and an invocation of + * its handler block will be made. + */ +XPC_DECL(xpc_activity); + +/*! + * @typedef xpc_activity_handler_t + * + * @abstract + * A block that is called when an XPC activity becomes eligible to run. + */ +XPC_NONNULL1 +typedef void (^xpc_activity_handler_t)(xpc_activity_t activity); + +/*! + * @constant XPC_ACTIVITY_CHECK_IN + * This constant may be passed to xpc_activity_register() as the criteria + * dictionary in order to check in with the system for previously registered + * activity using the same identifier (for example, an activity taken from a + * launchd property list). + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT +const xpc_object_t XPC_ACTIVITY_CHECK_IN; + +/*! + * @function xpc_activity_register + * + * @abstract + * Registers an activity with the system. + * + * @discussion + * Registers a new activity with the system. The criteria of the activity are + * described by the dictionary passed to this function. If an activity with the + * same identifier already exists, the criteria provided override the existing + * criteria unless the special dictionary XPC_ACTIVITY_CHECK_IN is used. The + * XPC_ACTIVITY_CHECK_IN dictionary instructs the system to first look up an + * existing activity without modifying its criteria. Once the existing activity + * is found (or a new one is created with an empty set of criteria) the handler + * will be called with an activity object in the XPC_ACTIVITY_STATE_CHECK_IN + * state. + * + * @param identifier + * A unique identifier for the activity. Each application has its own namespace. + * The identifier should remain constant across registrations, relaunches of + * the application, and reboots. It should identify the kind of work being done, + * not a particular invocation of the work. + * + * @param criteria + * A dictionary of criteria for the activity. + * + * @param handler + * The handler block to be called when the activity changes state to one of the + * following states: + * - XPC_ACTIVITY_STATE_CHECK_IN (optional) + * - XPC_ACTIVITY_STATE_RUN + * + * The handler block is never invoked reentrantly. It will be invoked on a + * dispatch queue with an appropriate priority to perform the activity. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_activity_register(const char *identifier, xpc_object_t criteria, + xpc_activity_handler_t handler); + +/*! + * @function xpc_activity_copy_criteria + * + * @abstract + * Returns an XPC dictionary describing the execution criteria of an activity. + * This will return NULL in cases where the activity has already completed, e.g. + * when checking in to an event that finished and was not rescheduled. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT XPC_WARN_RESULT XPC_RETURNS_RETAINED XPC_NONNULL1 +xpc_object_t _Nullable +xpc_activity_copy_criteria(xpc_activity_t activity); + +/*! + * @function xpc_activity_set_criteria + * + * @abstract + * Modifies the execution criteria of an activity. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_activity_set_criteria(xpc_activity_t activity, xpc_object_t criteria); + +/*! + * @enum xpc_activity_state_t + * An activity is defined to be in one of the following states. Applications + * may check the current state of the activity using xpc_activity_get_state() + * in the handler block provided to xpc_activity_register(). + * + * The application can modify the state of the activity by calling + * xpc_activity_set_state() with one of the following: + * - XPC_ACTIVITY_STATE_DEFER + * - XPC_ACTIVITY_STATE_CONTINUE + * - XPC_ACTIVITY_STATE_DONE + * + * @constant XPC_ACTIVITY_STATE_CHECK_IN + * An activity in this state has just completed a checkin with the system after + * XPC_ACTIVITY_CHECK_IN was provided as the criteria dictionary to + * xpc_activity_register. The state gives the application an opportunity to + * inspect and modify the activity's criteria. + * + * @constant XPC_ACTIVITY_STATE_WAIT + * An activity in this state is waiting for an opportunity to run. This value + * is never returned within the activity's handler block, as the block is + * invoked in response to XPC_ACTIVITY_STATE_CHECK_IN or XPC_ACTIVITY_STATE_RUN. + * + * Note: + * A launchd job may idle exit while an activity is in the wait state and be + * relaunched in response to the activity becoming runnable. The launchd job + * simply needs to re-register for the activity on its next launch by passing + * XPC_ACTIVITY_STATE_CHECK_IN to xpc_activity_register(). + * + * @constant XPC_ACTIVITY_STATE_RUN + * An activity in this state is eligible to run based on its criteria. + * + * @constant XPC_ACTIVITY_STATE_DEFER + * An application may pass this value to xpc_activity_set_state() to indicate + * that the activity should be deferred (placed back into the WAIT state) until + * a time when its criteria are met again. Deferring an activity does not reset + * any of its time-based criteria (in other words, it will remain past due). + * + * IMPORTANT: + * This should be done in response to observing xpc_activity_should_defer(). + * It should not be done unilaterally. If you determine that conditions are bad + * to do your activity's work for reasons you can't express in a criteria + * dictionary, you should set the activity's state to XPC_ACTIVITY_STATE_DONE. + * + * + * @constant XPC_ACTIVITY_STATE_CONTINUE + * An application may pass this value to xpc_activity_set_state() to indicate + * that the activity will continue its operation beyond the return of its + * handler block. This can be used to extend an activity to include asynchronous + * operations. The activity's handler block will not be invoked again until the + * state has been updated to either XPC_ACTIVITY_STATE_DEFER or, in the case + * of repeating activity, XPC_ACTIVITY_STATE_DONE. + * + * @constant XPC_ACTIVITY_STATE_DONE + * An application may pass this value to xpc_activity_set_state() to indicate + * that the activity has completed. For non-repeating activity, the resources + * associated with the activity will be automatically released upon return from + * the handler block. For repeating activity, timers present in the activity's + * criteria will be reset. + */ +enum { + XPC_ACTIVITY_STATE_CHECK_IN, + XPC_ACTIVITY_STATE_WAIT, + XPC_ACTIVITY_STATE_RUN, + XPC_ACTIVITY_STATE_DEFER, + XPC_ACTIVITY_STATE_CONTINUE, + XPC_ACTIVITY_STATE_DONE, +}; +typedef long xpc_activity_state_t; + +/*! + * @function xpc_activity_get_state + * + * @abstract + * Returns the current state of an activity. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +xpc_activity_state_t +xpc_activity_get_state(xpc_activity_t activity); + +/*! + * @function xpc_activity_set_state + * + * @abstract + * Updates the current state of an activity. + * + * @return + * Returns true if the state was successfully updated; otherwise, returns + * false if the requested state transition is not valid. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +bool +xpc_activity_set_state(xpc_activity_t activity, xpc_activity_state_t state); + +/*! + * @function xpc_activity_should_defer + * + * @abstract + * Test whether an activity should be deferred. + * + * @discussion + * This function may be used to test whether the criteria of a long-running + * activity are still satisfied. If not, the system indicates that the + * application should defer the activity. The application may acknowledge the + * deferral by calling xpc_activity_set_state() with XPC_ACTIVITY_STATE_DEFER. + * Once deferred, the system will place the activity back into the WAIT state + * and re-invoke the handler block at the earliest opportunity when the criteria + * are once again satisfied. + * + * @return + * Returns true if the activity should be deferred. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +bool +xpc_activity_should_defer(xpc_activity_t activity); + +/*! + * @function xpc_activity_unregister + * + * @abstract + * Unregisters an activity found by its identifier. + * + * @discussion + * A dynamically registered activity will be deleted in response to this call. + * Statically registered activity (from a launchd property list) will be + * deleted until the job is next loaded (e.g. at next boot). + * + * Unregistering an activity has no effect on any outstanding xpc_activity_t + * objects or any currently executing xpc_activity_handler_t blocks; however, + * no new handler block invocations will be made after it is unregistered. + * + * @param identifier + * The identifier of the activity to unregister. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_activity_unregister(const char *identifier); + +__END_DECLS +XPC_ASSUME_NONNULL_END + +#endif // __BLOCKS__ + +#endif // __XPC_ACTIVITY_H__ + diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/availability.h b/lib/libc/include/x86_64-macos-gnu/xpc/availability.h new file mode 100644 index 0000000000..27650a5e53 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/xpc/availability.h @@ -0,0 +1,124 @@ +#ifndef __XPC_AVAILABILITY_H__ +#define __XPC_AVAILABILITY_H__ + +#include + +// Certain parts of the project use all the project's headers but have to build +// against newer OSX SDKs than ebuild uses -- liblaunch_host being the example. +// So we need to define these. +#ifndef __MAC_10_16 +#define __MAC_10_16 101600 +#endif // __MAC_10_16 + +#ifndef __MAC_10_15 +#define __MAC_10_15 101500 +#define __AVAILABILITY_INTERNAL__MAC_10_15 \ +__attribute__((availability(macosx, introduced=10.15))) +#endif // __MAC_10_15 + +#ifndef __MAC_10_14 +#define __MAC_10_14 101400 +#define __AVAILABILITY_INTERNAL__MAC_10_14 \ +__attribute__((availability(macosx, introduced=10.14))) +#endif // __MAC_10_14 + +#ifndef __MAC_10_13 +#define __MAC_10_13 101300 +#define __AVAILABILITY_INTERNAL__MAC_10_13 \ + __attribute__((availability(macosx, introduced=10.13))) +#endif // __MAC_10_13 + +#ifndef __MAC_10_12 +#define __MAC_10_12 101200 +#define __AVAILABILITY_INTERNAL__MAC_10_12 \ + __attribute__((availability(macosx, introduced=10.12))) +#endif // __MAC_10_12 + +#ifndef __MAC_10_11 +#define __MAC_10_11 101100 +#define __AVAILABILITY_INTERNAL__MAC_10_11 \ + __attribute__((availability(macosx, introduced=10.11))) +#endif // __MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13 +#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13 +#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13 + +#if __has_include() +#include +#else // __has_include() +#ifndef IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED +#define IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED 999999 +#endif // IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED +#endif // __has_include() + +#ifndef __WATCHOS_UNAVAILABLE +#define __WATCHOS_UNAVAILABLE +#endif + +#ifndef __TVOS_UNAVAILABLE +#define __TVOS_UNAVAILABLE +#endif + +// simulator host-side bits build against SDKs not having __*_AVAILABLE() yet +#ifndef __OSX_AVAILABLE +#define __OSX_AVAILABLE(...) +#endif + +#ifndef __IOS_AVAILABLE +#define __IOS_AVAILABLE(...) +#endif + +#ifndef __TVOS_AVAILABLE +#define __TVOS_AVAILABLE(...) +#endif + +#ifndef __WATCHOS_AVAILABLE +#define __WATCHOS_AVAILABLE(...) +#endif + +#ifndef __API_AVAILABLE +#define __API_AVAILABLE(...) +#endif + +#endif // __XPC_AVAILABILITY_H__ diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/base.h b/lib/libc/include/x86_64-macos-gnu/xpc/base.h new file mode 100644 index 0000000000..3b265efd0a --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/xpc/base.h @@ -0,0 +1,213 @@ +// Copyright (c) 2009-2011 Apple Inc. All rights reserved. + +#ifndef __XPC_BASE_H__ +#define __XPC_BASE_H__ + +#include + +__BEGIN_DECLS + +#if !defined(__has_include) +#define __has_include(x) 0 +#endif // !defined(__has_include) + +#if !defined(__has_attribute) +#define __has_attribute(x) 0 +#endif // !defined(__has_attribute) + +#if !defined(__has_feature) +#define __has_feature(x) 0 +#endif // !defined(__has_feature) + +#if !defined(__has_extension) +#define __has_extension(x) 0 +#endif // !defined(__has_extension) + +#if __has_include() +#include +#else // __has_include() +#include +#endif // __has_include() + +#include + +#ifndef __XPC_INDIRECT__ +#error "Please #include instead of this file directly." +#endif // __XPC_INDIRECT__ + +#pragma mark Attribute Shims +#ifdef __GNUC__ +#define XPC_CONSTRUCTOR __attribute__((constructor)) +#define XPC_NORETURN __attribute__((__noreturn__)) +#define XPC_NOTHROW __attribute__((__nothrow__)) +#define XPC_NONNULL1 __attribute__((__nonnull__(1))) +#define XPC_NONNULL2 __attribute__((__nonnull__(2))) +#define XPC_NONNULL3 __attribute__((__nonnull__(3))) +#define XPC_NONNULL4 __attribute__((__nonnull__(4))) +#define XPC_NONNULL5 __attribute__((__nonnull__(5))) +#define XPC_NONNULL6 __attribute__((__nonnull__(6))) +#define XPC_NONNULL7 __attribute__((__nonnull__(7))) +#define XPC_NONNULL8 __attribute__((__nonnull__(8))) +#define XPC_NONNULL9 __attribute__((__nonnull__(9))) +#define XPC_NONNULL10 __attribute__((__nonnull__(10))) +#define XPC_NONNULL11 __attribute__((__nonnull__(11))) +#define XPC_NONNULL_ALL __attribute__((__nonnull__)) +#define XPC_SENTINEL __attribute__((__sentinel__)) +#define XPC_PURE __attribute__((__pure__)) +#define XPC_WARN_RESULT __attribute__((__warn_unused_result__)) +#define XPC_MALLOC __attribute__((__malloc__)) +#define XPC_UNUSED __attribute__((__unused__)) +#define XPC_USED __attribute__((__used__)) +#define XPC_PACKED __attribute__((__packed__)) +#define XPC_PRINTF(m, n) __attribute__((format(printf, m, n))) +#define XPC_INLINE static __inline__ __attribute__((__always_inline__)) +#define XPC_NOINLINE __attribute__((noinline)) +#define XPC_NOIMPL __attribute__((unavailable)) + +#if __has_attribute(noescape) +#define XPC_NOESCAPE __attribute__((__noescape__)) +#else +#define XPC_NOESCAPE +#endif + +#if __has_extension(attribute_unavailable_with_message) +#define XPC_UNAVAILABLE(m) __attribute__((unavailable(m))) +#else // __has_extension(attribute_unavailable_with_message) +#define XPC_UNAVAILABLE(m) XPC_NOIMPL +#endif // __has_extension(attribute_unavailable_with_message) + +#define XPC_EXPORT extern __attribute__((visibility("default"))) +#define XPC_NOEXPORT __attribute__((visibility("hidden"))) +#define XPC_WEAKIMPORT extern __attribute__((weak_import)) +#define XPC_DEBUGGER_EXCL XPC_NOEXPORT XPC_USED +#define XPC_TRANSPARENT_UNION __attribute__((transparent_union)) +#if __clang__ +#define XPC_DEPRECATED(m) __attribute__((deprecated(m))) +#else // __clang__ +#define XPC_DEPRECATED(m) __attribute__((deprecated)) +#endif // __clang + +#if defined(__XPC_TEST__) && __XPC_TEST__ +#define XPC_TESTSTATIC +#define XPC_TESTEXTERN extern +#else // defined(__XPC_TEST__) && __XPC_TEST__ +#define XPC_TESTSTATIC static +#endif // defined(__XPC_TEST__) && __XPC_TEST__ + +#if __has_feature(objc_arc) +#define XPC_GIVES_REFERENCE __strong +#define XPC_UNRETAINED __unsafe_unretained +#define XPC_BRIDGE(xo) ((__bridge void *)(xo)) +#define XPC_BRIDGEREF_BEGIN(xo) ((__bridge_retained void *)(xo)) +#define XPC_BRIDGEREF_BEGIN_WITH_REF(xo) ((__bridge void *)(xo)) +#define XPC_BRIDGEREF_MIDDLE(xo) ((__bridge id)(xo)) +#define XPC_BRIDGEREF_END(xo) ((__bridge_transfer id)(xo)) +#else // __has_feature(objc_arc) +#define XPC_GIVES_REFERENCE +#define XPC_UNRETAINED +#define XPC_BRIDGE(xo) (xo) +#define XPC_BRIDGEREF_BEGIN(xo) (xo) +#define XPC_BRIDGEREF_BEGIN_WITH_REF(xo) (xo) +#define XPC_BRIDGEREF_MIDDLE(xo) (xo) +#define XPC_BRIDGEREF_END(xo) (xo) +#endif // __has_feature(objc_arc) + +#define _xpc_unreachable() __builtin_unreachable() +#else // __GNUC__ +/*! @parseOnly */ +#define XPC_CONSTRUCTOR +/*! @parseOnly */ +#define XPC_NORETURN +/*! @parseOnly */ +#define XPC_NOTHROW +/*! @parseOnly */ +#define XPC_NONNULL1 +/*! @parseOnly */ +#define XPC_NONNULL2 +/*! @parseOnly */ +#define XPC_NONNULL3 +/*! @parseOnly */ +#define XPC_NONNULL4 +/*! @parseOnly */ +#define XPC_NONNULL5 +/*! @parseOnly */ +#define XPC_NONNULL6 +/*! @parseOnly */ +#define XPC_NONNULL7 +/*! @parseOnly */ +#define XPC_NONNULL8 +/*! @parseOnly */ +#define XPC_NONNULL9 +/*! @parseOnly */ +#define XPC_NONNULL10 +/*! @parseOnly */ +#define XPC_NONNULL11 +/*! @parseOnly */ +#define XPC_NONNULL(n) +/*! @parseOnly */ +#define XPC_NONNULL_ALL +/*! @parseOnly */ +#define XPC_SENTINEL +/*! @parseOnly */ +#define XPC_PURE +/*! @parseOnly */ +#define XPC_WARN_RESULT +/*! @parseOnly */ +#define XPC_MALLOC +/*! @parseOnly */ +#define XPC_UNUSED +/*! @parseOnly */ +#define XPC_PACKED +/*! @parseOnly */ +#define XPC_PRINTF(m, n) +/*! @parseOnly */ +#define XPC_INLINE static inline +/*! @parseOnly */ +#define XPC_NOINLINE +/*! @parseOnly */ +#define XPC_NOIMPL +/*! @parseOnly */ +#define XPC_EXPORT extern +/*! @parseOnly */ +#define XPC_WEAKIMPORT +/*! @parseOnly */ +#define XPC_DEPRECATED +/*! @parseOnly */ +#define XPC_UNAVAILABLE(m) +/*! @parseOnly */ +#define XPC_NOESCAPE +#endif // __GNUC__ + +#if __has_feature(assume_nonnull) +#define XPC_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +#define XPC_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +#define XPC_ASSUME_NONNULL_BEGIN +#define XPC_ASSUME_NONNULL_END +#endif + +#if __has_feature(nullability_on_arrays) +#define XPC_NONNULL_ARRAY _Nonnull +#else +#define XPC_NONNULL_ARRAY +#endif + +#ifdef OS_CLOSED_OPTIONS +#define XPC_FLAGS_ENUM(_name, _type, ...) \ + OS_CLOSED_OPTIONS(_name, _type, __VA_ARGS__) +#else // OS_CLOSED_ENUM +#define XPC_FLAGS_ENUM(_name, _type, ...) \ + OS_ENUM(_name, _type, __VA_ARGS__) +#endif // OS_CLOSED_ENUM + +#ifdef OS_CLOSED_ENUM +#define XPC_ENUM(_name, _type, ...) \ + OS_CLOSED_ENUM(_name, _type, __VA_ARGS__) +#else // OS_CLOSED_ENUM +#define XPC_ENUM(_name, _type, ...) \ + OS_ENUM(_name, _type, __VA_ARGS__) +#endif // OS_CLOSED_ENUM + +__END_DECLS + +#endif // __XPC_BASE_H__ diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/connection.h b/lib/libc/include/x86_64-macos-gnu/xpc/connection.h new file mode 100644 index 0000000000..02d7e16d85 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/xpc/connection.h @@ -0,0 +1,748 @@ +#ifndef __XPC_CONNECTION_H__ +#define __XPC_CONNECTION_H__ + +#ifndef __XPC_INDIRECT__ +#error "Please #include instead of this file directly." +// For HeaderDoc. +#include +#endif // __XPC_INDIRECT__ + +#ifndef __BLOCKS__ +#error "XPC connections require Blocks support." +#endif // __BLOCKS__ + +XPC_ASSUME_NONNULL_BEGIN +__BEGIN_DECLS + +/*! + * @constant XPC_ERROR_CONNECTION_INTERRUPTED + * Will be delivered to the connection's event handler if the remote service + * exited. The connection is still live even in this case, and resending a + * message will cause the service to be launched on-demand. This error serves + * as a client's indication that it should resynchronize any state that it had + * given the service. + * + * Any messages in the queue to be sent will be unwound and canceled when this + * error occurs. In the case where a message waiting to be sent has a reply + * handler, that handler will be invoked with this error. In the context of the + * reply handler, this error indicates that a reply to the message will never + * arrive. + * + * Messages that do not have reply handlers associated with them will be + * silently disposed of. This error will only be given to peer connections. + */ +#define XPC_ERROR_CONNECTION_INTERRUPTED \ + XPC_GLOBAL_OBJECT(_xpc_error_connection_interrupted) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_dictionary_s _xpc_error_connection_interrupted; + +/*! + * @constant XPC_ERROR_CONNECTION_INVALID + * Will be delivered to the connection's event handler if the named service + * provided to xpc_connection_create() could not be found in the XPC service + * namespace. The connection is useless and should be disposed of. + * + * Any messages in the queue to be sent will be unwound and canceled when this + * error occurs, similarly to the behavior when XPC_ERROR_CONNECTION_INTERRUPTED + * occurs. The only difference is that the XPC_ERROR_CONNECTION_INVALID will be + * given to outstanding reply handlers and the connection's event handler. + * + * This error may be given to any type of connection. + */ +#define XPC_ERROR_CONNECTION_INVALID \ + XPC_GLOBAL_OBJECT(_xpc_error_connection_invalid) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_dictionary_s _xpc_error_connection_invalid; + +/*! + * @constant XPC_ERROR_TERMINATION_IMMINENT + * On macOS, this error will be delivered to a peer connection's event handler + * when the XPC runtime has determined that the program should exit and that + * all outstanding transactions must be wound down, and no new transactions can + * be opened. + * + * After this error has been delivered to the event handler, no more messages + * will be received by the connection. The runtime will still attempt to deliver + * outgoing messages, but this error should be treated as an indication that + * the program will exit very soon, and any outstanding business over the + * connection should be wrapped up as quickly as possible and the connection + * canceled shortly thereafter. + * + * This error will only be delivered to peer connections received through a + * listener or the xpc_main() event handler. + */ +#define XPC_ERROR_TERMINATION_IMMINENT \ + XPC_GLOBAL_OBJECT(_xpc_error_termination_imminent) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_dictionary_s _xpc_error_termination_imminent; + +/*! + * @constant XPC_CONNECTION_MACH_SERVICE_LISTENER + * Passed to xpc_connection_create_mach_service(). This flag indicates that the + * caller is the listener for the named service. This flag may only be passed + * for services which are advertised in the process' launchd.plist(5). You may + * not use this flag to dynamically add services to the Mach bootstrap + * namespace. + */ +#define XPC_CONNECTION_MACH_SERVICE_LISTENER (1 << 0) + +/*! + * @constant XPC_CONNECTION_MACH_SERVICE_PRIVILEGED + * Passed to xpc_connection_create_mach_service(). This flag indicates that the + * job advertising the service name in its launchd.plist(5) should be in the + * privileged Mach bootstrap. This is typically accomplished by placing your + * launchd.plist(5) in /Library/LaunchDaemons. If specified alongside the + * XPC_CONNECTION_MACH_SERVICE_LISTENER flag, this flag is a no-op. + */ +#define XPC_CONNECTION_MACH_SERVICE_PRIVILEGED (1 << 1) + +/*! + * @typedef xpc_finalizer_f + * A function that is invoked when a connection is being torn down and its + * context needs to be freed. The sole argument is the value that was given to + * {@link xpc_connection_set_context} or NULL if no context has been set. It is + * not safe to reference the connection from within this function. + * + * @param value + * The context object that is to be disposed of. + */ +typedef void (*xpc_finalizer_t)(void * _Nullable value); + +/*! + * @function xpc_connection_create + * Creates a new connection object. + * + * @param name + * If non-NULL, the name of the service with which to connect. The returned + * connection will be a peer. + * + * If NULL, an anonymous listener connection will be created. You can embed the + * ability to create new peer connections in an endpoint, which can be inserted + * into a message and sent to another process . + * + * @param targetq + * The GCD queue to which the event handler block will be submitted. This + * parameter may be NULL, in which case the connection's target queue will be + * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. + * The target queue may be changed later with a call to + * xpc_connection_set_target_queue(). + * + * @result + * A new connection object. The caller is responsible for disposing of the + * returned object with {@link xpc_release} when it is no longer needed. + * + * @discussion + * This method will succeed even if the named service does not exist. This is + * because the XPC namespace is not queried for the service name until the + * connection has been activated. See {@link xpc_connection_activate()}. + * + * XPC connections, like dispatch sources, are returned in an inactive state, so + * you must call {@link xpc_connection_activate()} in order to begin receiving + * events from the connection. Also like dispatch sources, connections must be + * activated and not suspended in order to be safely released. It is + * a programming error to release an inactive or suspended connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_connection_t +xpc_connection_create(const char * _Nullable name, + dispatch_queue_t _Nullable targetq); + +/*! + * @function xpc_connection_create_mach_service + * Creates a new connection object representing a Mach service. + * + * @param name + * The name of the remote service with which to connect. The service name must + * exist in a Mach bootstrap that is accessible to the process and be advertised + * in a launchd.plist. + * + * @param targetq + * The GCD queue to which the event handler block will be submitted. This + * parameter may be NULL, in which case the connection's target queue will be + * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. + * The target queue may be changed later with a call to + * xpc_connection_set_target_queue(). + * + * @param flags + * Additional attributes with which to create the connection. + * + * @result + * A new connection object. + * + * @discussion + * If the XPC_CONNECTION_MACH_SERVICE_LISTENER flag is given to this method, + * then the connection returned will be a listener connection. Otherwise, a peer + * connection will be returned. See the documentation for + * {@link xpc_connection_set_event_handler()} for the semantics of listener + * connections versus peer connections. + * + * This method will succeed even if the named service does not exist. This is + * because the Mach namespace is not queried for the service name until the + * connection has been activated. See {@link xpc_connection_activate()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_connection_t +xpc_connection_create_mach_service(const char *name, + dispatch_queue_t _Nullable targetq, uint64_t flags); + +/*! + * @function xpc_connection_create_from_endpoint + * Creates a new connection from the given endpoint. + * + * @param endpoint + * The endpoint from which to create the new connection. + * + * @result + * A new peer connection to the listener represented by the given endpoint. + * + * The same responsibilities of setting an event handler and activating the + * connection after calling xpc_connection_create() apply to the connection + * returned by this API. Since the connection yielded by this API is not + * associated with a name (and therefore is not rediscoverable), this connection + * will receive XPC_ERROR_CONNECTION_INVALID if the listening side crashes, + * exits or cancels the listener connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_connection_t +xpc_connection_create_from_endpoint(xpc_endpoint_t endpoint); + +/*! + * @function xpc_connection_set_target_queue + * Sets the target queue of the given connection. + * + * @param connection + * The connection object which is to be manipulated. + * + * @param targetq + * The GCD queue to which the event handler block will be submitted. This + * parameter may be NULL, in which case the connection's target queue will be + * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. + * + * @discussion + * Setting the target queue is asynchronous and non-preemptive and therefore + * this method will not interrupt the execution of an already-running event + * handler block. Setting the target queue may be likened to issuing a barrier + * to the connection which does the actual work of changing the target queue. + * + * The XPC runtime guarantees this non-preemptiveness even for concurrent target + * queues. If the target queue is a concurrent queue, then XPC still guarantees + * that there will never be more than one invocation of the connection's event + * handler block executing concurrently. If you wish to process events + * concurrently, you can dispatch_async(3) to a concurrent queue from within + * the event handler. + * + * IMPORTANT: When called from within the event handler block, + * dispatch_get_current_queue(3) is NOT guaranteed to return a pointer to the + * queue set with this method. + * + * Despite this seeming inconsistency, the XPC runtime guarantees that, when the + * target queue is a serial queue, the event handler block will execute + * synchonously with respect to other blocks submitted to that same queue. When + * the target queue is a concurrent queue, the event handler block may run + * concurrently with other blocks submitted to that queue, but it will never run + * concurrently with other invocations of itself for the same connection, as + * discussed previously. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_connection_set_target_queue(xpc_connection_t connection, + dispatch_queue_t _Nullable targetq); + +/*! + * @function xpc_connection_set_event_handler + * Sets the event handler block for the connection. + * + * @param connection + * The connection object which is to be manipulated. + * + * @param handler + * The event handler block. + * + * @discussion + * Setting the event handler is asynchronous and non-preemptive, and therefore + * this method will not interrupt the execution of an already-running event + * handler block. If the event handler is executing at the time of this call, it + * will finish, and then the connection's event handler will be changed before + * the next invocation of the event handler. The XPC runtime guarantees this + * non-preemptiveness even for concurrent target queues. + * + * Connection event handlers are non-reentrant, so it is safe to call + * xpc_connection_set_event_handler() from within the event handler block. + * + * The event handler's execution should be treated as a barrier to all + * connection activity. When it is executing, the connection will not attempt to + * send or receive messages, including reply messages. Thus, it is not safe to + * call xpc_connection_send_message_with_reply_sync() on the connection from + * within the event handler. + * + * You do not hold a reference on the object received as the event handler's + * only argument. Regardless of the type of object received, it is safe to call + * xpc_retain() on the object to obtain a reference to it. + * + * A connection may receive different events depending upon whether it is a + * listener or not. Any connection may receive an error in its event handler. + * But while normal connections may receive messages in addition to errors, + * listener connections will receive connections and and not messages. + * + * Connections received by listeners are equivalent to those returned by + * xpc_connection_create() with a non-NULL name argument and a NULL targetq + * argument with the exception that you do not hold a reference on them. + * You must set an event handler and activate the connection. If you do not wish + * to accept the connection, you may simply call xpc_connection_cancel() on it + * and return. The runtime will dispose of it for you. + * + * If there is an error in the connection, this handler will be invoked with the + * error dictionary as its argument. This dictionary will be one of the well- + * known XPC_ERROR_* dictionaries. + * + * Regardless of the type of event, ownership of the event object is NOT + * implicitly transferred. Thus, the object will be released and deallocated at + * some point in the future after the event handler returns. If you wish the + * event's lifetime to persist, you must retain it with xpc_retain(). + * + * Connections received through the event handler will be released and + * deallocated after the connection has gone invalid and delivered that event to + * its event handler. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_set_event_handler(xpc_connection_t connection, + xpc_handler_t handler); + +/*! + * @function xpc_connection_activate + * Activates the connection. Connections start in an inactive state, so you must + * call xpc_connection_activate() on a connection before it will send or receive + * any messages. + * + * @param connection + * The connection object which is to be manipulated. + * + * @discussion + * Calling xpc_connection_activate() on an active connection has no effect. + * Releasing the last reference on an inactive connection that was created with + * an xpc_connection_create*() call is undefined. + * + * For backward compatibility reasons, xpc_connection_resume() on an inactive + * and not otherwise suspended xpc connection has the same effect as calling + * xpc_connection_activate(). For new code, using xpc_connection_activate() + * is preferred. + */ +__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) +__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_activate(xpc_connection_t connection); + +/*! + * @function xpc_connection_suspend + * Suspends the connection so that the event handler block will not fire and + * that the connection will not attempt to send any messages it has in its + * queue. All calls to xpc_connection_suspend() must be balanced with calls to + * xpc_connection_resume() before releasing the last reference to the + * connection. + * + * @param connection + * The connection object which is to be manipulated. + * + * @discussion + * Suspension is asynchronous and non-preemptive, and therefore this method will + * not interrupt the execution of an already-running event handler block. If + * the event handler is executing at the time of this call, it will finish, and + * then the connection will be suspended before the next scheduled invocation + * of the event handler. The XPC runtime guarantees this non-preemptiveness even + * for concurrent target queues. + * + * Connection event handlers are non-reentrant, so it is safe to call + * xpc_connection_suspend() from within the event handler block. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_suspend(xpc_connection_t connection); + +/*! + * @function xpc_connection_resume + * Resumes the connection. + * + * @param connection + * The connection object which is to be manipulated. + * + * @discussion + * In order for a connection to become live, every call to + * xpc_connection_suspend() must be balanced with a call to + * xpc_connection_resume(). + * + * For backward compatibility reasons, xpc_connection_resume() on an inactive + * and not otherwise suspended xpc connection has the same effect as calling + * xpc_connection_activate(). For new code, using xpc_connection_activate() + * is preferred. + * + * Calling xpc_connection_resume() more times than xpc_connection_suspend() + * has been called is otherwise considered an error. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_resume(xpc_connection_t connection); + +/*! + * @function xpc_connection_send_message + * Sends a message over the connection to the destination service. + * + * @param connection + * The connection over which the message shall be sent. + * + * @param message + * The message to send. This must be a dictionary object. This dictionary is + * logically copied by the connection, so it is safe to modify the dictionary + * after this call. + * + * @discussion + * Messages are delivered in FIFO order. This API is safe to call from multiple + * GCD queues. There is no indication that a message was delivered successfully. + * This is because even once the message has been successfully enqueued on the + * remote end, there are no guarantees about when the runtime will dequeue the + * message and invoke the other connection's event handler block. + * + * If this API is used to send a message that is in reply to another message, + * there is no guarantee of ordering between the invocations of the connection's + * event handler and the reply handler for that message, even if they are + * targeted to the same queue. + * + * After extensive study, we have found that clients who are interested in + * the state of the message on the server end are typically holding open + * transactions related to that message. And the only reliable way to track the + * lifetime of that transaction is at the protocol layer. So the server should + * send a reply message, which upon receiving, will cause the client to close + * its transaction. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_send_message(xpc_connection_t connection, xpc_object_t message); + +/*! + * @function xpc_connection_send_barrier + * Issues a barrier against the connection's message-send activity. + * + * @param connection + * The connection against which the barrier is to be issued. + * + * @param barrier + * The barrier block to issue. This barrier prevents concurrent message-send + * activity on the connection. No messages will be sent while the barrier block + * is executing. + * + * @discussion + * XPC guarantees that, even if the connection's target queue is a concurrent + * queue, there are no other messages being sent concurrently while the barrier + * block is executing. XPC does not guarantee that the receipt of messages + * (either through the connection's event handler or through reply handlers) + * will be suspended while the barrier is executing. + * + * A barrier is issued relative to the message-send queue. Thus, if you call + * xpc_connection_send_message() five times and then call + * xpc_connection_send_barrier(), the barrier will be invoked after the fifth + * message has been sent and its memory disposed of. You may safely cancel a + * connection from within a barrier block. + * + * If a barrier is issued after sending a message which expects a reply, the + * behavior is the same as described above. The receipt of a reply message will + * not influence when the barrier runs. + * + * A barrier block can be useful for throttling resource consumption on the + * connected side of a connection. For example, if your connection sends many + * large messages, you can use a barrier to limit the number of messages that + * are inflight at any given time. This can be particularly useful for messages + * that contain kernel resources (like file descriptors) which have a system- + * wide limit. + * + * If a barrier is issued on a canceled connection, it will be invoked + * immediately. If a connection has been canceled and still has outstanding + * barriers, those barriers will be invoked as part of the connection's + * unwinding process. + * + * It is important to note that a barrier block's execution order is not + * guaranteed with respect to other blocks that have been scheduled on the + * target queue of the connection. Or said differently, + * xpc_connection_send_barrier(3) is not equivalent to dispatch_async(3). + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_send_barrier(xpc_connection_t connection, + dispatch_block_t barrier); + +/*! + * @function xpc_connection_send_message_with_reply + * Sends a message over the connection to the destination service and associates + * a handler to be invoked when the remote service sends a reply message. + * + * @param connection + * The connection over which the message shall be sent. + * + * @param message + * The message to send. This must be a dictionary object. + * + * @param replyq + * The GCD queue to which the reply handler will be submitted. This may be a + * concurrent queue. + * + * @param handler + * The handler block to invoke when a reply to the message is received from + * the connection. If the remote service exits prematurely before the reply was + * received, the XPC_ERROR_CONNECTION_INTERRUPTED error will be returned. + * If the connection went invalid before the message could be sent, the + * XPC_ERROR_CONNECTION_INVALID error will be returned. + * + * @discussion + * If the given GCD queue is a concurrent queue, XPC cannot guarantee that there + * will not be multiple reply handlers being invoked concurrently. XPC does not + * guarantee any ordering for the invocation of reply handers. So if multiple + * messages are waiting for replies and the connection goes invalid, there is no + * guarantee that the reply handlers will be invoked in FIFO order. Similarly, + * XPC does not guarantee that reply handlers will not run concurrently with + * the connection's event handler in the case that the reply queue and the + * connection's target queue are the same concurrent queue. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL4 +void +xpc_connection_send_message_with_reply(xpc_connection_t connection, + xpc_object_t message, dispatch_queue_t _Nullable replyq, + xpc_handler_t handler); + +/*! + * @function xpc_connection_send_message_with_reply_sync + * Sends a message over the connection and blocks the caller until a reply is + * received. + * + * @param connection + * The connection over which the message shall be sent. + * + * @param message + * The message to send. This must be a dictionary object. + * + * @result + * The message that the remote service sent in reply to the original message. + * If the remote service exits prematurely before the reply was received, the + * XPC_ERROR_CONNECTION_INTERRUPTED error will be returned. If the connection + * went invalid before the message could be sent, the + * XPC_ERROR_CONNECTION_INVALID error will be returned. + * + * You are responsible for releasing the returned object. + * + * @discussion + * This API supports priority inversion avoidance, and should be used instead of + * combining xpc_connection_send_message_with_reply() with a semaphore. + * + * Invoking this API from a queue that is a part of the target queue hierarchy + * results in deadlocks under certain conditions. + * + * Be judicious about your use of this API. It can block indefinitely, so if you + * are using it to implement an API that can be called from the main thread, you + * may wish to consider allowing the API to take a queue and callback block so + * that results may be delivered asynchronously if possible. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT XPC_RETURNS_RETAINED +xpc_object_t +xpc_connection_send_message_with_reply_sync(xpc_connection_t connection, + xpc_object_t message); + +/*! + * @function xpc_connection_cancel + * Cancels the connection and ensures that its event handler will not fire + * again. After this call, any messages that have not yet been sent will be + * discarded, and the connection will be unwound. If there are messages that are + * awaiting replies, they will have their reply handlers invoked with the + * XPC_ERROR_CONNECTION_INVALID error. + * + * @param connection + * The connection object which is to be manipulated. + * + * @discussion + * Cancellation is asynchronous and non-preemptive and therefore this method + * will not interrupt the execution of an already-running event handler block. + * If the event handler is executing at the time of this call, it will finish, + * and then the connection will be canceled, causing a final invocation of the + * event handler to be scheduled with the XPC_ERROR_CONNECTION_INVALID error. + * After that invocation, there will be no further invocations of the event + * handler. + * + * The XPC runtime guarantees this non-preemptiveness even for concurrent target + * queues. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_cancel(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_name + * Returns the name of the service with which the connections was created. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The name of the remote service. If you obtained the connection through an + * invocation of another connection's event handler, NULL is returned. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +const char * _Nullable +xpc_connection_get_name(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_euid + * Returns the EUID of the remote peer. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The EUID of the remote peer at the time the connection was made. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +uid_t +xpc_connection_get_euid(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_egid + * Returns the EGID of the remote peer. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The EGID of the remote peer at the time the connection was made. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +gid_t +xpc_connection_get_egid(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_pid + * Returns the PID of the remote peer. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The PID of the remote peer. + * + * @discussion + * A given PID is not guaranteed to be unique across an entire boot cycle. + * Great care should be taken when dealing with this information, as it can go + * stale after the connection is established. OS X recycles PIDs, and therefore + * another process could spawn and claim the PID before a message is actually + * received from the connection. + * + * XPC will deliver an error to your event handler if the remote process goes + * away, but there are no guarantees as to the timing of this notification's + * delivery either at the kernel layer or at the XPC layer. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +pid_t +xpc_connection_get_pid(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_asid + * Returns the audit session identifier of the remote peer. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The audit session ID of the remote peer at the time the connection was made. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +au_asid_t +xpc_connection_get_asid(xpc_connection_t connection); + +/*! + * @function xpc_connection_set_context + * Sets context on an connection. + * + * @param connection + * The connection which is to be manipulated. + * + * @param context + * The context to associate with the connection. + * + * @discussion + * If you must manage the memory of the context object, you must set a finalizer + * to dispose of it. If this method is called on a connection which already has + * context associated with it, the finalizer will NOT be invoked. The finalizer + * is only invoked when the connection is being deallocated. + * + * It is recommended that, instead of changing the actual context pointer + * associated with the object, you instead change the state of the context + * object itself. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_connection_set_context(xpc_connection_t connection, + void * _Nullable context); + +/*! + * @function xpc_connection_get_context + * Returns the context associated with the connection. + * + * @param connection + * The connection which is to be examined. + * + * @result + * The context associated with the connection. NULL if there has been no context + * associated with the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +void * _Nullable +xpc_connection_get_context(xpc_connection_t connection); + +/*! + * @function xpc_connection_set_finalizer_f + * Sets the finalizer for the given connection. + * + * @param connection + * The connection on which to set the finalizer. + * + * @param finalizer + * The function that will be invoked when the connection's retain count has + * dropped to zero and is being torn down. + * + * @discussion + * This method disposes of the context value associated with a connection, as + * set by {@link xpc_connection_set_context}. + * + * For many uses of context objects, this API allows for a convenient shorthand + * for freeing them. For example, for a context object allocated with malloc(3): + * + * xpc_connection_set_finalizer_f(object, free); + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_connection_set_finalizer_f(xpc_connection_t connection, + xpc_finalizer_t _Nullable finalizer); + +__END_DECLS +XPC_ASSUME_NONNULL_END + +#endif // __XPC_CONNECTION_H__ diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/debug.h b/lib/libc/include/x86_64-macos-gnu/xpc/debug.h new file mode 100644 index 0000000000..b50361c6e9 --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/xpc/debug.h @@ -0,0 +1,23 @@ +#ifndef __XPC_DEBUG_H__ +#define __XPC_DEBUG_H__ + +/*! + * @function xpc_debugger_api_misuse_info + * Returns a pointer to a string describing the reason XPC aborted the calling + * process. On OS X, this will be the same string present in the "Application + * Specific Information" section of the crash report. + * + * @result + * A pointer to the human-readable string describing the reason the caller was + * aborted. If XPC was not responsible for the program's termination, NULL will + * be returned. + * + * @discussion + * This function is only callable from within a debugger. It is not meant to be + * called by the program directly. + */ +XPC_DEBUGGER_EXCL +const char * +xpc_debugger_api_misuse_info(void); + +#endif // __XPC_DEBUG_H__ diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/endpoint.h b/lib/libc/include/x86_64-macos-gnu/xpc/endpoint.h new file mode 100644 index 0000000000..aa43449b1d --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/xpc/endpoint.h @@ -0,0 +1,22 @@ +#ifndef __XPC_ENDPOINT_H__ +#define __XPC_ENDPOINT_H__ + +/*! + * @function xpc_endpoint_create + * Creates a new endpoint from a connection that is suitable for embedding into + * messages. + * + * @param connection + * Only connections obtained through calls to xpc_connection_create*() may be + * given to this API. Passing any other type of connection is not supported and + * will result in undefined behavior. + * + * @result + * A new endpoint object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_endpoint_t _Nonnull +xpc_endpoint_create(xpc_connection_t _Nonnull connection); + +#endif // __XPC_ENDPOINT_H__ diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/xpc.h b/lib/libc/include/x86_64-macos-gnu/xpc/xpc.h new file mode 100644 index 0000000000..3e6d38960d --- /dev/null +++ b/lib/libc/include/x86_64-macos-gnu/xpc/xpc.h @@ -0,0 +1,2701 @@ +// Copyright (c) 2009-2020 Apple Inc. All rights reserved. + +#ifndef __XPC_H__ +#define __XPC_H__ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __XPC_INDIRECT__ +#define __XPC_INDIRECT__ +#endif // __XPC_INDIRECT__ + +#include + +#if __has_include() +#include +#else // __has_include() +#define XPC_TRANSACTION_DEPRECATED +#endif // __has_include() + +XPC_ASSUME_NONNULL_BEGIN +__BEGIN_DECLS + +#ifndef __OSX_AVAILABLE_STARTING +#define __OSX_AVAILABLE_STARTING(x, y) +#endif // __OSX_AVAILABLE_STARTING + +#define XPC_API_VERSION 20200610 + +/*! + * @typedef xpc_type_t + * A type that describes XPC object types. + */ +typedef const struct _xpc_type_s * xpc_type_t; +#ifndef XPC_TYPE +#define XPC_TYPE(type) const struct _xpc_type_s type +#endif // XPC_TYPE + +/*! + * @typedef xpc_object_t + * A type that can describe all XPC objects. Dictionaries, arrays, strings, etc. + * are all described by this type. + * + * XPC objects are created with a retain count of 1, and therefore it is the + * caller's responsibility to call xpc_release() on them when they are no longer + * needed. + */ + +#if OS_OBJECT_USE_OBJC +/* By default, XPC objects are declared as Objective-C types when building with + * an Objective-C compiler. This allows them to participate in ARC, in RR + * management by the Blocks runtime and in leaks checking by the static + * analyzer, and enables them to be added to Cocoa collections. + * + * See for details. + */ +OS_OBJECT_DECL(xpc_object); +#ifndef XPC_DECL +#define XPC_DECL(name) typedef xpc_object_t name##_t +#endif // XPC_DECL + +#define XPC_GLOBAL_OBJECT(object) ((OS_OBJECT_BRIDGE xpc_object_t)&(object)) +#define XPC_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED +XPC_INLINE XPC_NONNULL_ALL +void +_xpc_object_validate(xpc_object_t object) { + (void)*(unsigned long volatile *)(OS_OBJECT_BRIDGE void *)object; +} +#else // OS_OBJECT_USE_OBJC +typedef void * xpc_object_t; +#define XPC_DECL(name) typedef struct _##name##_s * name##_t +#define XPC_GLOBAL_OBJECT(object) (&(object)) +#define XPC_RETURNS_RETAINED +#endif // OS_OBJECT_USE_OBJC + +/*! + * @typedef xpc_handler_t + * The type of block that is accepted by the XPC connection APIs. + * + * @param object + * An XPC object that is to be handled. If there was an error, this object will + * be equal to one of the well-known XPC_ERROR_* dictionaries and can be + * compared with the equality operator. + * + * @discussion + * You are not responsible for releasing the event object. + */ +#if __BLOCKS__ +typedef void (^xpc_handler_t)(xpc_object_t object); +#endif // __BLOCKS__ + +/*! + * @define XPC_TYPE_CONNECTION + * A type representing a connection to a named service. This connection is + * bidirectional and can be used to both send and receive messages. A + * connection carries the credentials of the remote service provider. + */ +#define XPC_TYPE_CONNECTION (&_xpc_type_connection) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_connection); +XPC_DECL(xpc_connection); + +/*! + * @typedef xpc_connection_handler_t + * The type of the function that will be invoked for a bundled XPC service when + * there is a new connection on the service. + * + * @param connection + * A new connection that is equivalent to one received by a listener connection. + * See the documentation for {@link xpc_connection_set_event_handler} for the + * semantics associated with the received connection. + */ +typedef void (*xpc_connection_handler_t)(xpc_connection_t connection); + +/*! + * @define XPC_TYPE_ENDPOINT + * A type representing a connection in serialized form. Unlike a connection, an + * endpoint is an inert object that does not have any runtime activity + * associated with it. Thus, it is safe to pass an endpoint in a message. Upon + * receiving an endpoint, the recipient can use + * xpc_connection_create_from_endpoint() to create as many distinct connections + * as desired. + */ +#define XPC_TYPE_ENDPOINT (&_xpc_type_endpoint) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_endpoint); +XPC_DECL(xpc_endpoint); + +/*! + * @define XPC_TYPE_NULL + * A type representing a null object. This type is useful for disambiguating + * an unset key in a dictionary and one which has been reserved but set empty. + * Also, this type is a way to represent a "null" value in dictionaries, which + * do not accept NULL. + */ +#define XPC_TYPE_NULL (&_xpc_type_null) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_null); + +/*! + * @define XPC_TYPE_BOOL + * A type representing a Boolean value. + */ +#define XPC_TYPE_BOOL (&_xpc_type_bool) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_bool); + +/*! + * @define XPC_BOOL_TRUE + * A constant representing a Boolean value of true. You may compare a Boolean + * object against this constant to determine its value. + */ +#define XPC_BOOL_TRUE XPC_GLOBAL_OBJECT(_xpc_bool_true) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_bool_s _xpc_bool_true; + +/*! + * @define XPC_BOOL_FALSE + * A constant representing a Boolean value of false. You may compare a Boolean + * object against this constant to determine its value. + */ +#define XPC_BOOL_FALSE XPC_GLOBAL_OBJECT(_xpc_bool_false) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_bool_s _xpc_bool_false; + +/*! + * @define XPC_TYPE_INT64 + * A type representing a signed, 64-bit integer value. + */ +#define XPC_TYPE_INT64 (&_xpc_type_int64) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_int64); + +/*! + * @define XPC_TYPE_UINT64 + * A type representing an unsigned, 64-bit integer value. + */ +#define XPC_TYPE_UINT64 (&_xpc_type_uint64) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_uint64); + +/*! + * @define XPC_TYPE_DOUBLE + * A type representing an IEEE-compliant, double-precision floating point value. + */ +#define XPC_TYPE_DOUBLE (&_xpc_type_double) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_double); + +/*! + * @define XPC_TYPE_DATE +* A type representing a date interval. The interval is with respect to the + * Unix epoch. XPC dates are in Unix time and are thus unaware of local time + * or leap seconds. + */ +#define XPC_TYPE_DATE (&_xpc_type_date) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_date); + +/*! + * @define XPC_TYPE_DATA + * A type representing a an arbitrary buffer of bytes. + */ +#define XPC_TYPE_DATA (&_xpc_type_data) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_data); + +/*! + * @define XPC_TYPE_STRING + * A type representing a NUL-terminated C-string. + */ +#define XPC_TYPE_STRING (&_xpc_type_string) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_string); + +/*! + * @define XPC_TYPE_UUID + * A type representing a Universally Unique Identifier as defined by uuid(3). + */ +#define XPC_TYPE_UUID (&_xpc_type_uuid) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_uuid); + +/*! + * @define XPC_TYPE_FD + * A type representing a POSIX file descriptor. + */ +#define XPC_TYPE_FD (&_xpc_type_fd) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_fd); + +/*! + * @define XPC_TYPE_SHMEM + * A type representing a region of shared memory. + */ +#define XPC_TYPE_SHMEM (&_xpc_type_shmem) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_shmem); + +/*! + * @define XPC_TYPE_ARRAY + * A type representing an array of XPC objects. This array must be contiguous, + * i.e. it cannot contain NULL values. If you wish to indicate that a slot + * is empty, you can insert a null object. The array will grow as needed to + * accommodate more objects. + */ +#define XPC_TYPE_ARRAY (&_xpc_type_array) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_array); + +/*! + * @define XPC_TYPE_DICTIONARY + * A type representing a dictionary of XPC objects, keyed off of C-strings. + * You may insert NULL values into this collection. The dictionary will grow + * as needed to accommodate more key/value pairs. + */ +#define XPC_TYPE_DICTIONARY (&_xpc_type_dictionary) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_dictionary); + +/*! + * @define XPC_TYPE_ERROR + * A type representing an error object. Errors in XPC are dictionaries, but + * xpc_get_type() will return this type when given an error object. You + * cannot create an error object directly; XPC will only give them to handlers. + * These error objects have pointer values that are constant across the lifetime + * of your process and can be safely compared. + * + * These constants are enumerated in the header for the connection object. Error + * dictionaries may reserve keys so that they can be queried to obtain more + * detailed information about the error. Currently, the only reserved key is + * XPC_ERROR_KEY_DESCRIPTION. + */ +#define XPC_TYPE_ERROR (&_xpc_type_error) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_error); + +/*! + * @define XPC_ERROR_KEY_DESCRIPTION + * In an error dictionary, querying for this key will return a string object + * that describes the error in a human-readable way. + */ +#define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const char * const _xpc_error_key_description; + +/*! + * @define XPC_EVENT_KEY_NAME + * In an event dictionary, this querying for this key will return a string + * object that describes the event. + */ +#define XPC_EVENT_KEY_NAME _xpc_event_key_name +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const char * const _xpc_event_key_name; + +XPC_ASSUME_NONNULL_END +#if !defined(__XPC_BUILDING_XPC__) || !__XPC_BUILDING_XPC__ +#include +#include +#if __BLOCKS__ +#include +#include +#endif // __BLOCKS__ +#undef __XPC_INDIRECT__ +#include +#endif // !defined(__XPC_BUILDING_XPC__) || !__XPC_BUILDING_XPC__ +XPC_ASSUME_NONNULL_BEGIN + +#pragma mark XPC Object Protocol +/*! + * @function xpc_retain + * + * @abstract + * Increments the reference count of an object. + * + * @param object + * The object which is to be manipulated. + * + * @result + * The object which was given. + * + * @discussion + * Calls to xpc_retain() must be balanced with calls to xpc_release() + * to avoid leaking memory. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +xpc_object_t +xpc_retain(xpc_object_t object); +#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#undef xpc_retain +#define xpc_retain(object) ({ xpc_object_t _o = (object); \ + _xpc_object_validate(_o); [_o retain]; }) +#endif // OS_OBJECT_USE_OBJC_RETAIN_RELEASE + +/*! + * @function xpc_release + * + * @abstract + * Decrements the reference count of an object. + * + * @param object + * The object which is to be manipulated. + * + * @discussion + * The caller must take care to balance retains and releases. When creating or + * retaining XPC objects, the creator obtains a reference on the object. Thus, + * it is the caller's responsibility to call xpc_release() on those objects when + * they are no longer needed. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_release(xpc_object_t object); +#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#undef xpc_release +#define xpc_release(object) ({ xpc_object_t _o = (object); \ + _xpc_object_validate(_o); [_o release]; }) +#endif // OS_OBJECT_USE_OBJC_RETAIN_RELEASE + +/*! + * @function xpc_get_type + * + * @abstract + * Returns the type of an object. + * + * @param object + * The object to examine. + * + * @result + * An opaque pointer describing the type of the object. This pointer is suitable + * direct comparison to exported type constants with the equality operator. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +xpc_type_t +xpc_get_type(xpc_object_t object); + +/*! + * @function xpc_type_get_name + * + * @abstract + * Returns a string describing an XPC object type. + * + * @param type + * The type to describe. + * + * @result + * A string describing the type of an object, like "string" or "int64". + * This string should not be freed or modified. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_15, __IPHONE_13_0) +XPC_EXPORT XPC_NONNULL1 +const char * +xpc_type_get_name(xpc_type_t type); + +/*! + * @function xpc_copy + * + * @abstract + * Creates a copy of the object. + * + * @param object + * The object to copy. + * + * @result + * The new object. NULL if the object type does not support copying or if + * sufficient memory for the copy could not be allocated. Service objects do + * not support copying. + * + * @discussion + * When called on an array or dictionary, xpc_copy() will perform a deep copy. + * + * The object returned is not necessarily guaranteed to be a new object, and + * whether it is will depend on the implementation of the object being copied. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT XPC_RETURNS_RETAINED +xpc_object_t _Nullable +xpc_copy(xpc_object_t object); + +/*! + * @function xpc_equal + * + * @abstract + * Compares two objects for equality. + * + * @param object1 + * The first object to compare. + * + * @param object2 + * The second object to compare. + * + * @result + * Returns true if the objects are equal, otherwise false. Two objects must be + * of the same type in order to be equal. + * + * For two arrays to be equal, they must contain the same values at the + * same indexes. For two dictionaries to be equal, they must contain the same + * values for the same keys. + * + * Two objects being equal implies that their hashes (as returned by xpc_hash()) + * are also equal. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_WARN_RESULT +bool +xpc_equal(xpc_object_t object1, xpc_object_t object2); + +/*! + * @function xpc_hash + * + * @abstract + * Calculates a hash value for the given object. + * + * @param object + * The object for which to calculate a hash value. This value may be modded + * with a table size for insertion into a dictionary-like data structure. + * + * @result + * The calculated hash value. + * + * @discussion + * Note that the computed hash values for any particular type and value of an + * object can change from across releases and platforms and should not be + * assumed to be constant across all time and space or stored persistently. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_WARN_RESULT +size_t +xpc_hash(xpc_object_t object); + +/*! + * @function xpc_copy_description + * + * @abstract + * Copies a debug string describing the object. + * + * @param object + * The object which is to be examined. + * + * @result + * A string describing object which contains information useful for debugging. + * This string should be disposed of with free(3) when done. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_WARN_RESULT XPC_NONNULL1 +char * +xpc_copy_description(xpc_object_t object); + +#pragma mark XPC Object Types +#pragma mark Null +/*! + * @function xpc_null_create + * + * @abstract + * Creates an XPC object representing the null object. + * + * @result + * A new null object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_null_create(void); + +#pragma mark Boolean +/*! + * @function xpc_bool_create + * + * @abstract + * Creates an XPC Boolean object. + * + * @param value + * The Boolean primitive value which is to be boxed. + * + * @result + * A new Boolean object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_bool_create(bool value); + +/*! + * @function xpc_bool_get_value + * + * @abstract + * Returns the underlying Boolean value from the object. + * + * @param xbool + * The Boolean object which is to be examined. + * + * @result + * The underlying Boolean value or false if the given object was not an XPC + * Boolean object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +bool +xpc_bool_get_value(xpc_object_t xbool); + +#pragma mark Signed Integer +/*! + * @function xpc_int64_create + * + * @abstract + * Creates an XPC signed integer object. + * + * @param value + * The signed integer value which is to be boxed. + * + * @result + * A new signed integer object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_int64_create(int64_t value); + +/*! + * @function xpc_int64_get_value + * + * @abstract + * Returns the underlying signed 64-bit integer value from an object. + * + * @param xint + * The signed integer object which is to be examined. + * + * @result + * The underlying signed 64-bit value or 0 if the given object was not an XPC + * integer object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int64_t +xpc_int64_get_value(xpc_object_t xint); + +#pragma mark Unsigned Integer +/*! + * @function xpc_uint64_create + * + * @abstract + * Creates an XPC unsigned integer object. + * + * @param value + * The unsigned integer value which is to be boxed. + * + * @result + * A new unsigned integer object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_uint64_create(uint64_t value); + +/*! + * @function xpc_uint64_get_value + * + * @abstract + * Returns the underlying unsigned 64-bit integer value from an object. + * + * @param xuint + * The unsigned integer object which is to be examined. + * + * @result + * The underlying unsigned integer value or 0 if the given object was not an XPC + * unsigned integer object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +uint64_t +xpc_uint64_get_value(xpc_object_t xuint); + +#pragma mark Double +/*! + * @function xpc_double_create + * + * @abstract + * Creates an XPC double object. + * + * @param value + * The floating point quantity which is to be boxed. + * + * @result + * A new floating point object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_double_create(double value); + +/*! + * @function xpc_double_get_value + * + * @abstract + * Returns the underlying double-precision floating point value from an object. + * + * @param xdouble + * The floating point object which is to be examined. + * + * @result + * The underlying floating point value or NAN if the given object was not an XPC + * floating point object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +double +xpc_double_get_value(xpc_object_t xdouble); + +#pragma mark Date +/*! + * @function xpc_date_create + * + * @abstract + * Creates an XPC date object. + * + * @param interval + * The date interval which is to be boxed. Negative values indicate the number + * of nanoseconds before the epoch. Positive values indicate the number of + * nanoseconds after the epoch. + * + * @result + * A new date object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_date_create(int64_t interval); + +/*! + * @function xpc_date_create_from_current + * + * @abstract + * Creates an XPC date object representing the current date. + * + * @result + * A new date object representing the current date. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_date_create_from_current(void); + +/*! + * @function xpc_date_get_value + * + * @abstract + * Returns the underlying date interval from an object. + * + * @param xdate + * The date object which is to be examined. + * + * @result + * The underlying date interval or 0 if the given object was not an XPC date + * object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int64_t +xpc_date_get_value(xpc_object_t xdate); + +#pragma mark Data +/*! + * @function xpc_data_create + * + * @abstract + * Creates an XPC object representing buffer of bytes. + * + * @param bytes + * The buffer of bytes which is to be boxed. You may create an empty data object + * by passing NULL for this parameter and 0 for the length. Passing NULL with + * any other length will result in undefined behavior. + * + * @param length + * The number of bytes which are to be boxed. + * + * @result + * A new data object. + * + * @discussion + * This method will copy the buffer given into internal storage. After calling + * this method, it is safe to dispose of the given buffer. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_data_create(const void * _Nullable bytes, size_t length); + +/*! + * @function xpc_data_create_with_dispatch_data + * + * @abstract + * Creates an XPC object representing buffer of bytes described by the given GCD + * data object. + * + * @param ddata + * The GCD data object containing the bytes which are to be boxed. This object + * is retained by the data object. + * + * @result + * A new data object. + * + * @discussion + * The object returned by this method will refer to the buffer returned by + * dispatch_data_create_map(). The point where XPC will make the call to + * dispatch_data_create_map() is undefined. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_object_t +xpc_data_create_with_dispatch_data(dispatch_data_t ddata); + +/*! + * @function xpc_data_get_length + * + * @abstract + * Returns the length of the data encapsulated by an XPC data object. + * + * @param xdata + * The data object which is to be examined. + * + * @result + * The length of the underlying boxed data or 0 if the given object was not an + * XPC data object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +size_t +xpc_data_get_length(xpc_object_t xdata); + +/*! + * @function xpc_data_get_bytes_ptr + * + * @abstract + * Returns a pointer to the internal storage of a data object. + * + * @param xdata + * The data object which is to be examined. + * + * @result + * A pointer to the underlying boxed data or NULL if the given object was not an + * XPC data object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const void * _Nullable +xpc_data_get_bytes_ptr(xpc_object_t xdata); + +/*! + * @function xpc_data_get_bytes + * + * @abstract + * Copies the bytes stored in an data objects into the specified buffer. + * + * @param xdata + * The data object which is to be examined. + * + * @param buffer + * The buffer in which to copy the data object's bytes. + * + * @param off + * The offset at which to begin the copy. If this offset is greater than the + * length of the data element, nothing is copied. Pass 0 to start the copy + * at the beginning of the buffer. + * + * @param length + * The length of the destination buffer. + * + * @result + * The number of bytes that were copied into the buffer or 0 if the given object + * was not an XPC data object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2 +size_t +xpc_data_get_bytes(xpc_object_t xdata, + void *buffer, size_t off, size_t length); + +#pragma mark String +/*! + * @function xpc_string_create + * + * @abstract + * Creates an XPC object representing a NUL-terminated C-string. + * + * @param string + * The C-string which is to be boxed. + * + * @result + * A new string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_object_t +xpc_string_create(const char *string); + +/*! + * @function xpc_string_create_with_format + * + * @abstract + * Creates an XPC object representing a C-string that is generated from the + * given format string and arguments. + * + * @param fmt + * The printf(3)-style format string from which to construct the final C-string + * to be boxed. + * + * @param ... + * The arguments which correspond to those specified in the format string. + * + * @result + * A new string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +XPC_PRINTF(1, 2) +xpc_object_t +xpc_string_create_with_format(const char *fmt, ...); + +/*! + * @function xpc_string_create_with_format_and_arguments + * + * @abstract + * Creates an XPC object representing a C-string that is generated from the + * given format string and argument list pointer. + * + * @param fmt + * The printf(3)-style format string from which to construct the final C-string + * to be boxed. + * + * @param ap + * A pointer to the arguments which correspond to those specified in the format + * string. + * + * @result + * A new string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +XPC_PRINTF(1, 0) +xpc_object_t +xpc_string_create_with_format_and_arguments(const char *fmt, va_list ap); + +/*! + * @function xpc_string_get_length + * + * @abstract + * Returns the length of the underlying string. + * + * @param xstring + * The string object which is to be examined. + * + * @result + * The length of the underlying string, not including the NUL-terminator, or 0 + * if the given object was not an XPC string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +size_t +xpc_string_get_length(xpc_object_t xstring); + +/*! + * @function xpc_string_get_string_ptr + * + * @abstract + * Returns a pointer to the internal storage of a string object. + * + * @param xstring + * The string object which is to be examined. + * + * @result + * A pointer to the string object's internal storage or NULL if the given object + * was not an XPC string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const char * _Nullable +xpc_string_get_string_ptr(xpc_object_t xstring); + +#pragma mark UUID +/*! + * @function xpc_uuid_create + * + * @abstract + * Creates an XPC object representing a universally-unique identifier (UUID) as + * described by uuid(3). + * + * @param uuid + * The UUID which is to be boxed. + * + * @result + * A new UUID object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_object_t +xpc_uuid_create(const uuid_t XPC_NONNULL_ARRAY uuid); + +/*! + * @function xpc_uuid_get_bytes + * + * @abstract + * Returns a pointer to the the boxed UUID bytes in an XPC UUID object. + * + * @param xuuid + * The UUID object which is to be examined. + * + * @result + * The underlying uuid_t bytes or NULL if the given object was not + * an XPC UUID object. The returned pointer may be safely passed to the uuid(3) + * APIs. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +const uint8_t * _Nullable +xpc_uuid_get_bytes(xpc_object_t xuuid); + +#pragma mark File Descriptors +/*! + * @function xpc_fd_create + * + * @abstract + * Creates an XPC object representing a POSIX file descriptor. + * + * @param fd + * The file descriptor which is to be boxed. + * + * @result + * A new file descriptor object. NULL if sufficient memory could not be + * allocated or if the given file descriptor was not valid. + * + * @discussion + * This method performs the equivalent of a dup(2) on the descriptor, and thus + * it is safe to call close(2) on the descriptor after boxing it with a file + * descriptor object. + * + * IMPORTANT: Pointer equality is the ONLY valid test for equality between two + * file descriptor objects. There is no reliable way to determine whether two + * file descriptors refer to the same inode with the same capabilities, so two + * file descriptor objects created from the same underlying file descriptor + * number will not compare equally with xpc_equal(). This is also true of a + * file descriptor object created using xpc_copy() and the original. + * + * This also implies that two collections containing file descriptor objects + * cannot be equal unless the exact same object was inserted into both. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t _Nullable +xpc_fd_create(int fd); + +/*! + * @function xpc_fd_dup + * + * @abstract + * Returns a file descriptor that is equivalent to the one boxed by the file + * file descriptor object. + * + * @param xfd + * The file descriptor object which is to be examined. + * + * @result + * A file descriptor that is equivalent to the one originally given to + * xpc_fd_create(). If the descriptor could not be created or if the given + * object was not an XPC file descriptor, -1 is returned. + * + * @discussion + * Multiple invocations of xpc_fd_dup() will not return the same file descriptor + * number, but they will return descriptors that are equivalent, as though they + * had been created by dup(2). + * + * The caller is responsible for calling close(2) on the returned descriptor. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int +xpc_fd_dup(xpc_object_t xfd); + +#pragma mark Shared Memory +/*! + * @function xpc_shmem_create + * + * @abstract + * Creates an XPC object representing the given shared memory region. + * + * @param region + * A pointer to a region of shared memory, created through a call to mmap(2) + * with the MAP_SHARED flag, which is to be boxed. + * + * @param length + * The length of the region. + * + * @result + * A new shared memory object. + * + * @discussion + * Only memory regions whose exact characteristics are known to the caller + * should be boxed using this API. Memory returned from malloc(3) may not be + * safely shared on either OS X or iOS because the underlying virtual memory + * objects for malloc(3)ed allocations are owned by the malloc(3) subsystem and + * not the caller of malloc(3). + * + * If you wish to share a memory region that you receive from another subsystem, + * part of the interface contract with that other subsystem must include how to + * create the region of memory, or sharing it may be unsafe. + * + * Certain operations may internally fragment a region of memory in a way that + * would truncate the range detected by the shared memory object. vm_copy(), for + * example, may split the region into multiple parts to avoid copying certain + * page ranges. For this reason, it is recommended that you delay all VM + * operations until the shared memory object has been created so that the VM + * system knows that the entire range is intended for sharing. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_object_t +xpc_shmem_create(void *region, size_t length); + +/*! + * @function xpc_shmem_map + * + * @abstract + * Maps the region boxed by the XPC shared memory object into the caller's + * address space. + * + * @param xshmem + * The shared memory object to be examined. + * + * @param region + * On return, this will point to the region at which the shared memory was + * mapped. + * + * @result + * The length of the region that was mapped. If the mapping failed or if the + * given object was not an XPC shared memory object, 0 is returned. The length + * of the mapped region will always be an integral page size, even if the + * creator of the region specified a non-integral page size. + * + * @discussion + * The resulting region must be disposed of with munmap(2). + * + * It is the responsibility of the caller to manage protections on the new + * region accordingly. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +size_t +xpc_shmem_map(xpc_object_t xshmem, void * _Nullable * _Nonnull region); + +#pragma mark Array +/*! + * @typedef xpc_array_applier_t + * A block to be invoked for every value in the array. + * + * @param index + * The current index in the iteration. + * + * @param value + * The current value in the iteration. + * + * @result + * A Boolean indicating whether iteration should continue. + */ +#ifdef __BLOCKS__ +typedef bool (^xpc_array_applier_t)(size_t index, xpc_object_t _Nonnull value); +#endif // __BLOCKS__ + +/*! + * @function xpc_array_create + * + * @abstract + * Creates an XPC object representing an array of XPC objects. + * + * @discussion + * This array must be contiguous and cannot contain any NULL values. If you + * wish to insert the equivalent of a NULL value, you may use the result of + * {@link xpc_null_create}. + * + * @param objects + * An array of XPC objects which is to be boxed. The order of this array is + * preserved in the object. If this array contains a NULL value, the behavior + * is undefined. This parameter may be NULL only if the count is 0. + * + * @param count + * The number of objects in the given array. If the number passed is less than + * the actual number of values in the array, only the specified number of items + * are inserted into the resulting array. If the number passed is more than + * the the actual number of values, the behavior is undefined. + * + * @result + * A new array object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_array_create(const xpc_object_t _Nonnull * _Nullable objects, size_t count); + +/*! + * @function xpc_array_create_empty + * + * @abstract + * Creates an XPC object representing an array of XPC objects. + * + * @result + * A new array object. + * + * @see + * xpc_array_create + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_array_create_empty(void); + +/*! + * @function xpc_array_set_value + * + * @abstract + * Inserts the specified object into the array at the specified index. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array). + * If the index is outside that range, the behavior is undefined. + * + * @param value + * The object to insert. This value is retained by the array and cannot be + * NULL. If there is already a value at the specified index, it is released, + * and the new value is inserted in its place. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_value(xpc_object_t xarray, size_t index, xpc_object_t value); + +/*! + * @function xpc_array_append_value + * + * @abstract + * Appends an object to an XPC array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param value + * The object to append. This object is retained by the array. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_array_append_value(xpc_object_t xarray, xpc_object_t value); + +/*! + * @function xpc_array_get_count + * + * @abstract + * Returns the count of values currently in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @result + * The count of values in the array or 0 if the given object was not an XPC + * array. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +size_t +xpc_array_get_count(xpc_object_t xarray); + +/*! + * @function xpc_array_get_value + * + * @abstract + * Returns the value at the specified index in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the range of + * indexes as specified in xpc_array_set_value(). + * + * @result + * The object at the specified index within the array or NULL if the given + * object was not an XPC array. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +xpc_object_t +xpc_array_get_value(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_apply + * + * @abstract + * Invokes the given block for every value in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @param applier + * The block which this function applies to every element in the array. + * + * @result + * A Boolean indicating whether iteration of the array completed successfully. + * Iteration will only fail if the applier block returns false. + * + * @discussion + * You should not modify an array's contents during iteration. The array indexes + * are iterated in order. + */ +#ifdef __BLOCKS__ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +bool +xpc_array_apply(xpc_object_t xarray, XPC_NOESCAPE xpc_array_applier_t applier); +#endif // __BLOCKS__ + +#pragma mark Array Primitive Setters +/*! + * @define XPC_ARRAY_APPEND + * A constant that may be passed as the destination index to the class of + * primitive XPC array setters indicating that the given primitive should be + * appended to the array. + */ +#define XPC_ARRAY_APPEND ((size_t)(-1)) + +/*! + * @function xpc_array_set_bool + * + * @abstract + * Inserts a bool (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The bool value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_bool(xpc_object_t xarray, size_t index, bool value); + +/*! + * @function xpc_array_set_int64 + * + * @abstract + * Inserts an int64_t (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The int64_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_int64(xpc_object_t xarray, size_t index, int64_t value); + +/*! + * @function xpc_array_set_uint64 + * + * @abstract + * Inserts a uint64_t (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The uint64_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_uint64(xpc_object_t xarray, size_t index, uint64_t value); + +/*! + * @function xpc_array_set_double + * + * @abstract + * Inserts a double (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The double value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_double(xpc_object_t xarray, size_t index, double value); + +/*! + * @function xpc_array_set_date + * + * @abstract + * Inserts a date value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The date value to insert, represented as an int64_t. After + * calling this method, the XPC object corresponding to the primitive value + * inserted may be safely retrieved with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_date(xpc_object_t xarray, size_t index, int64_t value); + +/*! + * @function xpc_array_set_data + * + * @abstract + * Inserts a raw data value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param bytes + * The raw data to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. + * + * @param length + * The length of the data. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_data(xpc_object_t xarray, size_t index, const void *bytes, + size_t length); + +/*! + * @function xpc_array_set_string + * + * @abstract + * Inserts a C string into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param string + * The C string to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_string(xpc_object_t xarray, size_t index, const char *string); + +/*! + * @function xpc_array_set_uuid + * + * @abstract + * Inserts a uuid_t (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param uuid + * The UUID primitive to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_uuid(xpc_object_t xarray, size_t index, + const uuid_t XPC_NONNULL_ARRAY uuid); + +/*! + * @function xpc_array_set_fd + * + * @abstract + * Inserts a file descriptor into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param fd + * The file descriptor to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_fd(xpc_object_t xarray, size_t index, int fd); + +/*! + * @function xpc_array_set_connection + * + * @abstract + * Inserts a connection into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param connection + * The connection to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. The connection is NOT retained by the array. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_connection(xpc_object_t xarray, size_t index, + xpc_connection_t connection); + +#pragma mark Array Primitive Getters +/*! + * @function xpc_array_get_bool + * + * @abstract + * Gets a bool primitive value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying bool value at the specified index. false if the + * value at the specified index is not a Boolean value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +bool +xpc_array_get_bool(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_int64 + * + * @abstract + * Gets an int64_t primitive value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying int64_t value at the specified index. 0 if the + * value at the specified index is not a signed integer value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int64_t +xpc_array_get_int64(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_uint64 + * + * @abstract + * Gets a uint64_t primitive value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying uint64_t value at the specified index. 0 if the + * value at the specified index is not an unsigned integer value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +uint64_t +xpc_array_get_uint64(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_double + * + * @abstract + * Gets a double primitive value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying double value at the specified index. NAN if the + * value at the specified index is not a floating point value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +double +xpc_array_get_double(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_date + * + * @abstract + * Gets a date interval from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying date interval at the specified index. 0 if the value at the + * specified index is not a date value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int64_t +xpc_array_get_date(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_data + * + * @abstract + * Gets a pointer to the raw bytes of a data object from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @param length + * Upon return output, will contain the length of the data corresponding to the + * specified key. + * + * @result + * The underlying bytes at the specified index. NULL if the value at the + * specified index is not a data value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const void * _Nullable +xpc_array_get_data(xpc_object_t xarray, size_t index, + size_t * _Nullable length); + +/*! + * @function xpc_array_get_string + * + * @abstract + * Gets a C string value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying C string at the specified index. NULL if the value at the + * specified index is not a C string value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const char * _Nullable +xpc_array_get_string(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_uuid + * + * @abstract + * Gets a uuid_t value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying uuid_t value at the specified index. The null + * UUID if the value at the specified index is not a UUID value. The returned + * pointer may be safely passed to the uuid(3) APIs. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const uint8_t * _Nullable +xpc_array_get_uuid(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_dup_fd + * + * @abstract + * Gets a file descriptor from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * A new file descriptor created from the value at the specified index. You are + * responsible for close(2)ing this descriptor. -1 if the value at the specified + * index is not a file descriptor value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int +xpc_array_dup_fd(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_create_connection + * + * @abstract + * Creates a connection object from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * A new connection created from the value at the specified index. You are + * responsible for calling xpc_release() on the returned connection. NULL if the + * value at the specified index is not an endpoint containing a connection. Each + * call to this method for the same index in the same array will yield a + * different connection. See {@link xpc_connection_create_from_endpoint()} for + * discussion as to the responsibilities when dealing with the returned + * connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_connection_t _Nullable +xpc_array_create_connection(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_dictionary + * + * @abstract + * Returns the dictionary at the specified index in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the range of + * indexes as specified in xpc_array_set_value(). + * + * @result + * The object at the specified index within the array or NULL if the given + * object was not an XPC array or if the the value at the specified index was + * not a dictionary. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_array_get_dictionary(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_array + * + * @abstract + * Returns the array at the specified index in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the range of + * indexes as specified in xpc_array_set_value(). + * + * @result + * The object at the specified index within the array or NULL if the given + * object was not an XPC array or if the the value at the specified index was + * not an array. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_array_get_array(xpc_object_t xarray, size_t index); + +#pragma mark Dictionary +/*! + * @typedef xpc_dictionary_applier_t + * A block to be invoked for every key/value pair in the dictionary. + * + * @param key + * The current key in the iteration. + * + * @param value + * The current value in the iteration. + * + * @result + * A Boolean indicating whether iteration should continue. + */ +#ifdef __BLOCKS__ +typedef bool (^xpc_dictionary_applier_t)(const char * _Nonnull key, + xpc_object_t _Nonnull value); +#endif // __BLOCKS__ + +/*! + * @function xpc_dictionary_create + * + * @abstract + * Creates an XPC object representing a dictionary of XPC objects keyed to + * C-strings. + * + * @param keys + * An array of C-strings that are to be the keys for the values to be inserted. + * Each element of this array is copied into the dictionary's internal storage. + * Elements of this array may NOT be NULL. + * + * @param values + * A C-array that is parallel to the array of keys, consisting of objects that + * are to be inserted. Each element in this array is retained. Elements in this + * array may be NULL. + * + * @param count + * The number of key/value pairs in the given arrays. If the count is less than + * the actual count of values, only that many key/value pairs will be inserted + * into the dictionary. + * + * If the count is more than the the actual count of key/value pairs, the + * behavior is undefined. If one array is NULL and the other is not, the + * behavior is undefined. If both arrays are NULL and the count is non-0, the + * behavior is undefined. + * + * @result + * The new dictionary object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_dictionary_create(const char * _Nonnull const * _Nullable keys, + const xpc_object_t _Nullable * _Nullable values, size_t count); + +/*! + * @function xpc_dictionary_create_empty + * + * @abstract + * Creates an XPC object representing a dictionary of XPC objects keyed to + * C-strings. + * + * @result + * The new dictionary object. + * + * @see + * xpc_dictionary_create + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_dictionary_create_empty(void); + +/*! + * @function xpc_dictionary_create_reply + * + * @abstract + * Creates a dictionary that is in reply to the given dictionary. + * + * @param original + * The original dictionary that is to be replied to. + * + * @result + * The new dictionary object. NULL if the object was not a dictionary with a + * reply context. + * + * @discussion + * After completing successfully on a dictionary, this method may not be called + * again on that same dictionary. Attempts to do so will return NULL. + * + * When this dictionary is sent across the reply connection, the remote end's + * reply handler is invoked. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_dictionary_create_reply(xpc_object_t original); + +/*! + * @function xpc_dictionary_set_value + * + * @abstract + * Sets the value for the specified key to the specified object. + * + * @param xdict + * The dictionary object which is to be manipulated. + * + * @param key + * The key for which the value shall be set. + * + * @param value + * The object to insert. The object is retained by the dictionary. If there + * already exists a value for the specified key, the old value is released + * and overwritten by the new value. This parameter may be NULL, in which case + * the value corresponding to the specified key is deleted if present. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_value(xpc_object_t xdict, const char *key, + xpc_object_t _Nullable value); + +/*! + * @function xpc_dictionary_get_value + * + * @abstract + * Returns the value for the specified key. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The object for the specified key within the dictionary. NULL if there is no + * value associated with the specified key or if the given object was not an + * XPC dictionary. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2 +xpc_object_t _Nullable +xpc_dictionary_get_value(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_count + * + * @abstract + * Returns the number of values stored in the dictionary. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @result + * The number of values stored in the dictionary or 0 if the given object was + * not an XPC dictionary. Calling xpc_dictionary_set_value() with a non-NULL + * value will increment the count. Calling xpc_dictionary_set_value() with a + * NULL value will decrement the count. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +size_t +xpc_dictionary_get_count(xpc_object_t xdict); + +/*! + * @function xpc_dictionary_apply + * + * @abstract + * Invokes the given block for every key/value pair in the dictionary. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param applier + * The block which this function applies to every key/value pair in the + * dictionary. + * + * @result + * A Boolean indicating whether iteration of the dictionary completed + * successfully. Iteration will only fail if the applier block returns false. + * + * @discussion + * You should not modify a dictionary's contents during iteration. There is no + * guaranteed order of iteration over dictionaries. + */ +#ifdef __BLOCKS__ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +bool +xpc_dictionary_apply(xpc_object_t xdict, + XPC_NOESCAPE xpc_dictionary_applier_t applier); +#endif // __BLOCKS__ + +/*! + * @function xpc_dictionary_get_remote_connection + * + * @abstract + * Returns the connection from which the dictionary was received. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @result + * If the dictionary was received by a connection event handler or a dictionary + * created through xpc_dictionary_create_reply(), a connection object over which + * a reply message can be sent is returned. For any other dictionary, NULL is + * returned. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_connection_t _Nullable +xpc_dictionary_get_remote_connection(xpc_object_t xdict); + +#pragma mark Dictionary Primitive Setters +/*! + * @function xpc_dictionary_set_bool + * + * @abstract + * Inserts a bool (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The bool value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_bool(xpc_object_t xdict, const char *key, bool value); + +/*! + * @function xpc_dictionary_set_int64 + * + * @abstract + * Inserts an int64_t (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The int64_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_int64(xpc_object_t xdict, const char *key, int64_t value); + +/*! + * @function xpc_dictionary_set_uint64 + * + * @abstract + * Inserts a uint64_t (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The uint64_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_uint64(xpc_object_t xdict, const char *key, uint64_t value); + +/*! + * @function xpc_dictionary_set_double + * + * @abstract + * Inserts a double (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The double value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_double(xpc_object_t xdict, const char *key, double value); + +/*! + * @function xpc_dictionary_set_date + * + * @abstract + * Inserts a date (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The date value to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_date(xpc_object_t xdict, const char *key, int64_t value); + +/*! + * @function xpc_dictionary_set_data + * + * @abstract + * Inserts a raw data value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param bytes + * The bytes to insert. After calling this method, the XPC object corresponding + * to the primitive value inserted may be safely retrieved with + * {@link xpc_dictionary_get_value()}. + * + * @param length + * The length of the data. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_dictionary_set_data(xpc_object_t xdict, const char *key, const void *bytes, + size_t length); + +/*! + * @function xpc_dictionary_set_string + * + * @abstract + * Inserts a C string value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param string + * The C string to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_dictionary_set_string(xpc_object_t xdict, const char *key, + const char *string); + +/*! + * @function xpc_dictionary_set_uuid + * + * @abstract + * Inserts a uuid (primitive) value into an array. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param uuid + * The uuid_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_dictionary_set_uuid(xpc_object_t xdict, const char *key, + const uuid_t XPC_NONNULL_ARRAY uuid); + +/*! + * @function xpc_dictionary_set_fd + * + * @abstract + * Inserts a file descriptor into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param fd + * The file descriptor to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_fd(xpc_object_t xdict, const char *key, int fd); + +/*! + * @function xpc_dictionary_set_connection + * + * @abstract + * Inserts a connection into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param connection + * The connection to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. The connection is NOT retained by + * the dictionary. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_dictionary_set_connection(xpc_object_t xdict, const char *key, + xpc_connection_t connection); + +#pragma mark Dictionary Primitive Getters +/*! + * @function xpc_dictionary_get_bool + * + * @abstract + * Gets a bool primitive value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying bool value for the specified key. false if the + * the value for the specified key is not a Boolean value or if there is no + * value for the specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +bool +xpc_dictionary_get_bool(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_int64 + * + * @abstract + * Gets an int64 primitive value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying int64_t value for the specified key. 0 if the + * value for the specified key is not a signed integer value or if there is no + * value for the specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +int64_t +xpc_dictionary_get_int64(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_uint64 + * + * @abstract + * Gets a uint64 primitive value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying uint64_t value for the specified key. 0 if the + * value for the specified key is not an unsigned integer value or if there is + * no value for the specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +uint64_t +xpc_dictionary_get_uint64(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_double + * + * @abstract + * Gets a double primitive value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying double value for the specified key. NAN if the + * value for the specified key is not a floating point value or if there is no + * value for the specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +double +xpc_dictionary_get_double(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_date + * + * @abstract + * Gets a date value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying date interval for the specified key. 0 if the value for the + * specified key is not a date value or if there is no value for the specified + * key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +int64_t +xpc_dictionary_get_date(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_data + * + * @abstract + * Gets a raw data value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @param length + * For the data type, the third parameter, upon output, will contain the length + * of the data corresponding to the specified key. May be NULL. + * + * @result + * The underlying raw data for the specified key. NULL if the value for the + * specified key is not a data value or if there is no value for the specified + * key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const void * _Nullable +xpc_dictionary_get_data(xpc_object_t xdict, const char *key, + size_t * _Nullable length); + +/*! + * @function xpc_dictionary_get_string + * + * @abstract + * Gets a C string value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying C string for the specified key. NULL if the value for the + * specified key is not a C string value or if there is no value for the + * specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +const char * _Nullable +xpc_dictionary_get_string(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_uuid + * + * @abstract + * Gets a uuid value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying uuid_t value for the specified key. NULL is the + * value at the specified index is not a UUID value. The returned pointer may be + * safely passed to the uuid(3) APIs. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2 +const uint8_t * _Nullable +xpc_dictionary_get_uuid(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_dup_fd + * + * @abstract + * Creates a file descriptor from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * A new file descriptor created from the value for the specified key. You are + * responsible for close(2)ing this descriptor. -1 if the value for the + * specified key is not a file descriptor value or if there is no value for the + * specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +int +xpc_dictionary_dup_fd(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_create_connection + * + * @abstract + * Creates a connection from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * A new connection created from the value for the specified key. You are + * responsible for calling xpc_release() on the returned connection. NULL if the + * value for the specified key is not an endpoint containing a connection or if + * there is no value for the specified key. Each call to this method for the + * same key in the same dictionary will yield a different connection. See + * {@link xpc_connection_create_from_endpoint()} for discussion as to the + * responsibilities when dealing with the returned connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_connection_t _Nullable +xpc_dictionary_create_connection(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_dictionary + * + * @abstract + * Returns the dictionary value for the specified key. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The object for the specified key within the dictionary. NULL if there is no + * value associated with the specified key, if the given object was not an + * XPC dictionary, or if the object for the specified key is not a dictionary. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_dictionary_get_dictionary(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_array + * + * @abstract + * Returns the array value for the specified key. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The object for the specified key within the dictionary. NULL if there is no + * value associated with the specified key, if the given object was not an + * XPC dictionary, or if the object for the specified key is not an array. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_dictionary_get_array(xpc_object_t xdict, const char *key); + +#pragma mark Runtime +/*! + * @function xpc_main + * The springboard into the XPCService runtime. This function will set up your + * service bundle's listener connection and manage it automatically. After this + * initial setup, this function will, by default, call dispatch_main(). You may + * override this behavior by setting the RunLoopType key in your XPC service + * bundle's Info.plist under the XPCService dictionary. + * + * @param handler + * The handler with which to accept new connections. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NORETURN XPC_NONNULL1 +void +xpc_main(xpc_connection_handler_t handler); + +#pragma mark Transactions +/*! + * @function xpc_transaction_begin + * Informs the XPC runtime that a transaction has begun and that the service + * should not exit due to inactivity. + * + * @discussion + * A service with no outstanding transactions may automatically exit due to + * inactivity as determined by the system. + * + * This function may be used to manually manage transactions in cases where + * their automatic management (as described below) does not meet the needs of an + * XPC service. This function also updates the transaction count used for sudden + * termination, i.e. vproc_transaction_begin(), and these two interfaces may be + * used in combination. + * + * The XPC runtime will automatically begin a transaction on behalf of a service + * when a new message is received. If no reply message is expected, the + * transaction is automatically ended when the connection event handler returns. + * If a reply message is created, the transaction will end when the reply + * message is sent or released. An XPC service may use xpc_transaction_begin() + * and xpc_transaction_end() to inform the XPC runtime about activity that + * occurs outside of this common pattern. + * + * On macOS, when the XPC runtime has determined that the service should exit, + * the event handlers for all active peer connections will receive + * {@link XPC_ERROR_TERMINATION_IMMINENT} as an indication that they should + * unwind their existing transactions. After this error is delivered to a + * connection's event handler, no more messages will be delivered to the + * connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_TRANSACTION_DEPRECATED +XPC_EXPORT +void +xpc_transaction_begin(void); + +/*! + * @function xpc_transaction_end + * Informs the XPC runtime that a transaction has ended. + * + * @discussion + * As described in {@link xpc_transaction_begin()}, this API may be used + * interchangeably with vproc_transaction_end(). + * + * See the discussion for {@link xpc_transaction_begin()} for details regarding + * the XPC runtime's idle-exit policy. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_TRANSACTION_DEPRECATED +XPC_EXPORT +void +xpc_transaction_end(void); + +#pragma mark XPC Event Stream +/*! + * @function xpc_set_event_stream_handler + * Sets the event handler to invoke when streamed events are received. + * + * @param stream + * The name of the event stream for which this handler will be invoked. + * + * @param targetq + * The GCD queue to which the event handler block will be submitted. This + * parameter may be NULL, in which case the connection's target queue will be + * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. + * + * @param handler + * The event handler block. The event which this block receives as its first + * parameter will always be a dictionary which contains the XPC_EVENT_KEY_NAME + * key. The value for this key will be a string whose value is the name assigned + * to the XPC event specified in the launchd.plist. Future keys may be added to + * this dictionary. + * + * @discussion + * Multiple calls to this function for the same event stream will result in + * undefined behavior. + * + * There is no API to pause delivery of XPC events. If a process that + * has set an XPC event handler exits, events may be dropped due to races + * between the event handler running and the process exiting. + */ +#if __BLOCKS__ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_set_event_stream_handler(const char *stream, + dispatch_queue_t _Nullable targetq, xpc_handler_t handler); +#endif // __BLOCKS__ + +__END_DECLS +XPC_ASSUME_NONNULL_END + +#endif // __XPC_H__