xref: /aosp_15_r20/external/mesa3d/src/asahi/lib/dyld_interpose.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /*
2*61046927SAndroid Build Coastguard Worker  * Copyright (C) 2010 Apple Inc. All rights reserved.
3*61046927SAndroid Build Coastguard Worker  *
4*61046927SAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
5*61046927SAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions
6*61046927SAndroid Build Coastguard Worker  * are met:
7*61046927SAndroid Build Coastguard Worker  * 1. Redistributions of source code must retain the above copyright
8*61046927SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer.
9*61046927SAndroid Build Coastguard Worker  * 2. Redistributions in binary form must reproduce the above copyright
10*61046927SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer in the
11*61046927SAndroid Build Coastguard Worker  *    documentation and/or other materials provided with the distribution.
12*61046927SAndroid Build Coastguard Worker  *
13*61046927SAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14*61046927SAndroid Build Coastguard Worker  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15*61046927SAndroid Build Coastguard Worker  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16*61046927SAndroid Build Coastguard Worker  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17*61046927SAndroid Build Coastguard Worker  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18*61046927SAndroid Build Coastguard Worker  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19*61046927SAndroid Build Coastguard Worker  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20*61046927SAndroid Build Coastguard Worker  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21*61046927SAndroid Build Coastguard Worker  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22*61046927SAndroid Build Coastguard Worker  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23*61046927SAndroid Build Coastguard Worker  * THE POSSIBILITY OF SUCH DAMAGE.
24*61046927SAndroid Build Coastguard Worker  */
25*61046927SAndroid Build Coastguard Worker 
26*61046927SAndroid Build Coastguard Worker /*
27*61046927SAndroid Build Coastguard Worker  * Macro found in WebKit source code:
28*61046927SAndroid Build Coastguard Worker  *
29*61046927SAndroid Build Coastguard Worker  * https://chromium.googlesource.com/chromium/blink.git/+/8ced00ca9f81cd8403584ae9123d9f3bb696c86a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm
30*61046927SAndroid Build Coastguard Worker  */
31*61046927SAndroid Build Coastguard Worker #ifndef DYLD_INTERPOSE
32*61046927SAndroid Build Coastguard Worker 
33*61046927SAndroid Build Coastguard Worker #define DYLD_INTERPOSE(_replacement, _replacee)                                \
34*61046927SAndroid Build Coastguard Worker    __attribute__((used)) static struct {                                       \
35*61046927SAndroid Build Coastguard Worker       const void *replacement;                                                 \
36*61046927SAndroid Build Coastguard Worker       const void *replacee;                                                    \
37*61046927SAndroid Build Coastguard Worker    } _interpose_##_replacee __attribute__((section("__DATA,__interpose"))) = { \
38*61046927SAndroid Build Coastguard Worker       (const void *)(unsigned long)&_replacement,                              \
39*61046927SAndroid Build Coastguard Worker       (const void *)(unsigned long)&_replacee};
40*61046927SAndroid Build Coastguard Worker 
41*61046927SAndroid Build Coastguard Worker #endif
42