yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
ba7001c
develop
1//------------------------------------------------------------------------------------------------------------------------------------------------------------- 2// 3// Metal/MTLPrivate.hpp 4// 5// Copyright 2020-2021 Apple Inc. 6// 7// Licensed under the Apache License, Version 2.0 (the "License"); 8// you may not use this file except in compliance with the License. 9// You may obtain a copy of the License at 10// 11// http://www.apache.org/licenses/LICENSE-2.0 12// 13// Unless required by applicable law or agreed to in writing, software 14// distributed under the License is distributed on an "AS IS" BASIS, 15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16// See the License for the specific language governing permissions and 17// limitations under the License. 18// 19//------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 21#pragma once 22 23//------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 25#include "MTLDefines.hpp" 26 27#include <objc/runtime.h> 28 29//------------------------------------------------------------------------------------------------------------------------------------------------------------- 30 31#define _MTL_PRIVATE_CLS (symbol ) (Private::Class::s_k##symbol) 32#define _MTL_PRIVATE_SEL (accessor ) (Private::Selector::s_k##accessor) 33 34//------------------------------------------------------------------------------------------------------------------------------------------------------------- 35 36#if defined(MTL_PRIVATE_IMPLEMENTATION ) 37 38#define _MTL_PRIVATE_VISIBILITY __attribute__((visibility("default"))) 39#define _MTL_PRIVATE_IMPORT __attribute__((weak_import)) 40 41#if __OBJC__ 42#define _MTL_PRIVATE_OBJC_LOOKUP_CLASS (symbol ) ((__bridge void*)objc_lookUpClass(#symbol)) 43#else 44#define _MTL_PRIVATE_OBJC_LOOKUP_CLASS (symbol ) objc_lookUpClass(#symbol) 45#endif // __OBJC__ 46 47#define _MTL_PRIVATE_DEF_CLS (symbol ) void* s_k##symbol _MTL_PRIVATE_VISIBILITY = _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol); 48#define _MTL_PRIVATE_DEF_PRO (symbol ) 49#define _MTL_PRIVATE_DEF_SEL (accessor ,symbol ) SEL s_k##accessor _MTL_PRIVATE_VISIBILITY = sel_registerName(symbol); 50 51#if defined(__MAC_10_16 )|| defined(__MAC_11_0 )|| defined(__MAC_12_0 )|| defined(__IPHONE_14_0 )|| defined(__IPHONE_15_0 )|| defined(__TVOS_14_0 )|| defined(__TVOS_15_0 ) 52 53#define _MTL_PRIVATE_DEF_STR (type ,symbol ) \ 54 _MTL_EXTERN type const MTL##symbol _MTL_PRIVATE_IMPORT; \ 55 type const MTL::symbol = (nullptr != &MTL##symbol) ? MTL##symbol : nullptr; 56 57#else 58 59#include <dlfcn.h> 60 61namespace MTL 62{ 63namespace Private 64{ 65 66template < typename _Type > 67inline _Type const LoadSymbol (const char * pSymbol ) 68 { 69const _Type * pAddress = static_cast < _Type *> (dlsym (RTLD_DEFAULT ,pSymbol )); 70 71return pAddress ?* pAddress :nullptr ; 72 } 73 74}// Private 75}// MTL 76 77#define _MTL_PRIVATE_DEF_STR (type ,symbol ) \ 78 _MTL_EXTERN type const MTL##symbol; \ 79 type const MTL::symbol = Private::LoadSymbol<type>("MTL" #symbol); 80 81#endif // defined(__MAC_10_16) || defined(__MAC_11_0) || defined(__MAC_12_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) 82 83#else 84 85#define _MTL_PRIVATE_DEF_CLS (symbol ) extern void* s_k##symbol; 86#define _MTL_PRIVATE_DEF_PRO (symbol ) 87#define _MTL_PRIVATE_DEF_SEL (accessor ,symbol ) extern SEL s_k##accessor; 88#define _MTL_PRIVATE_DEF_STR (type ,symbol ) 89 90#endif // MTL_PRIVATE_IMPLEMENTATION 91 92//------------------------------------------------------------------------------------------------------------------------------------------------------------- 93 94namespace MTL 95{ 96namespace Private 97{ 98namespace Class 99 { 100 101 }// Class 102}// Private 103}// MTL 104 105//------------------------------------------------------------------------------------------------------------------------------------------------------------- 106 107namespace MTL 108{ 109namespace Private 110{ 111namespace Protocol 112 { 113 114 }// Protocol 115}// Private 116}// MTL 117 118//------------------------------------------------------------------------------------------------------------------------------------------------------------- 119 120namespace MTL 121{ 122namespace Private 123{ 124namespace Selector 125 { 126 127_MTL_PRIVATE_DEF_SEL (beginScope , 128"beginScope" ); 129_MTL_PRIVATE_DEF_SEL (endScope , 130"endScope" ); 131 }// Class 132}// Private 133}// MTL 134 135//-------------------------------------------------------------------------------------------------------------------------------------------------------------