spb/forge Public MIT
Forge — LLM training from scratch in pure C++20 + Metal on Apple Silicon.
C++ 61.2%
C 23%
Python 7.6%
TeX 7.2%
CMake 1.1%
1//-------------------------------------------------------------------------------------------------------------------------------------------------------------2//3// QuartzCore/CAPrivate.hpp4//5// Copyright 2020-2024 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 at10//11// http://www.apache.org/licenses/LICENSE-2.012//13// Unless required by applicable law or agreed to in writing, software14// 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 and17// limitations under the License.18//19//-------------------------------------------------------------------------------------------------------------------------------------------------------------2021#pragma once2223//-------------------------------------------------------------------------------------------------------------------------------------------------------------2425#include "CADefines.hpp"2627#include <objc/runtime.h>2829//-------------------------------------------------------------------------------------------------------------------------------------------------------------3031#define _CA_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol)32#define _CA_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor)3334//-------------------------------------------------------------------------------------------------------------------------------------------------------------3536#if defined(CA_PRIVATE_IMPLEMENTATION)3738#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN39#define _CA_PRIVATE_VISIBILITY __attribute__((visibility("hidden")))40#else41#define _CA_PRIVATE_VISIBILITY __attribute__((visibility("default")))42#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN4344#define _CA_PRIVATE_IMPORT __attribute__((weak_import))4546#ifdef __OBJC__47#define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol))48#define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol))49#else50#define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol)51#define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol)52#endif // __OBJC__5354#define _CA_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol)55#define _CA_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol)56#define _CA_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _CA_PRIVATE_VISIBILITY = sel_registerName(symbol)57#define _CA_PRIVATE_DEF_STR(type, symbol) \58 _CA_EXTERN type const CA##symbol _CA_PRIVATE_IMPORT; \59 type const CA::symbol = (nullptr != &CA##symbol) ? CA##symbol : nullptr6061#else6263#define _CA_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol64#define _CA_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol65#define _CA_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor66#define _CA_PRIVATE_DEF_STR(type, symbol) extern type const CA::symbol6768#endif // CA_PRIVATE_IMPLEMENTATION6970//-------------------------------------------------------------------------------------------------------------------------------------------------------------7172namespace CA73{74namespace Private75{76 namespace Class77 {78 _CA_PRIVATE_DEF_CLS(CAMetalLayer);79 } // Class80} // Private81} // CA8283//-------------------------------------------------------------------------------------------------------------------------------------------------------------8485namespace CA86{87namespace Private88{89 namespace Protocol90 {9192 _CA_PRIVATE_DEF_PRO(CAMetalDrawable);9394 } // Protocol95} // Private96} // CA9798//-------------------------------------------------------------------------------------------------------------------------------------------------------------99100namespace CA101{102namespace Private103{104 namespace Selector105 {106 _CA_PRIVATE_DEF_SEL(allowsNextDrawableTimeout,107 "allowsNextDrawableTimeout");108 _CA_PRIVATE_DEF_SEL(colorspace,109 "colorspace");110 _CA_PRIVATE_DEF_SEL(device,111 "device");112 _CA_PRIVATE_DEF_SEL(displaySyncEnabled,113 "displaySyncEnabled");114 _CA_PRIVATE_DEF_SEL(drawableSize,115 "drawableSize");116 _CA_PRIVATE_DEF_SEL(framebufferOnly,117 "framebufferOnly");118 _CA_PRIVATE_DEF_SEL(layer,119 "layer");120 _CA_PRIVATE_DEF_SEL(maximumDrawableCount,121 "maximumDrawableCount");122 _CA_PRIVATE_DEF_SEL(nextDrawable,123 "nextDrawable");124 _CA_PRIVATE_DEF_SEL(pixelFormat,125 "pixelFormat");126 _CA_PRIVATE_DEF_SEL(residencySet,127 "residencySet");128 _CA_PRIVATE_DEF_SEL(setAllowsNextDrawableTimeout_,129 "setAllowsNextDrawableTimeout:");130 _CA_PRIVATE_DEF_SEL(setColorspace_,131 "setColorspace:");132 _CA_PRIVATE_DEF_SEL(setDevice_,133 "setDevice:");134 _CA_PRIVATE_DEF_SEL(setDisplaySyncEnabled_,135 "setDisplaySyncEnabled:");136 _CA_PRIVATE_DEF_SEL(setDrawableSize_,137 "setDrawableSize:");138 _CA_PRIVATE_DEF_SEL(setFramebufferOnly_,139 "setFramebufferOnly:");140 _CA_PRIVATE_DEF_SEL(setMaximumDrawableCount_,141 "setMaximumDrawableCount:");142 _CA_PRIVATE_DEF_SEL(setPixelFormat_,143 "setPixelFormat:");144 _CA_PRIVATE_DEF_SEL(setWantsExtendedDynamicRangeContent_,145 "setWantsExtendedDynamicRangeContent:");146 _CA_PRIVATE_DEF_SEL(texture,147 "texture");148 _CA_PRIVATE_DEF_SEL(wantsExtendedDynamicRangeContent,149 "wantsExtendedDynamicRangeContent");150 } // Class151} // Private152} // CA153154//-------------------------------------------------------------------------------------------------------------------------------------------------------------155