Chia-I Wu | d4589d3 | 2010-04-23 16:07:47 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Chia-I Wu | d4589d3 | 2010-04-23 16:07:47 +0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2010 LunarG Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Chia-I Wu <olv@lunarg.com> |
| 26 | */ |
| 27 | |
Ben Crocker | c26be2b | 2017-06-02 19:37:55 -0400 | [diff] [blame] | 28 | #include <stdlib.h> |
| 29 | #include <stdint.h> |
| 30 | |
Chia-I Wu | 56eb5d7 | 2010-04-22 15:33:43 +0800 | [diff] [blame] | 31 | #include "entry.h" |
Chia-I Wu | 96c52d1 | 2010-08-24 15:51:57 +0800 | [diff] [blame] | 32 | #include "u_current.h" |
Ben Crocker | c26be2b | 2017-06-02 19:37:55 -0400 | [diff] [blame] | 33 | #include "util/u_endian.h" |
Brian Paul | c3f352e | 2015-03-04 19:17:57 -0700 | [diff] [blame] | 34 | |
| 35 | #define _U_STRINGIFY(x) #x |
| 36 | #define U_STRINGIFY(x) _U_STRINGIFY(x) |
Chia-I Wu | 96c52d1 | 2010-08-24 15:51:57 +0800 | [diff] [blame] | 37 | |
| 38 | /* define macros for use by assembly dispatchers */ |
| 39 | #define ENTRY_CURRENT_TABLE U_STRINGIFY(u_current_table) |
Chia-I Wu | 56eb5d7 | 2010-04-22 15:33:43 +0800 | [diff] [blame] | 40 | |
Chia-I Wu | 97185bf | 2010-12-17 00:24:27 +0800 | [diff] [blame] | 41 | /* in bridge mode, mapi is a user of glapi */ |
| 42 | #ifdef MAPI_MODE_BRIDGE |
| 43 | #define ENTRY_CURRENT_TABLE_GET "_glapi_get_dispatch" |
| 44 | #else |
Brian Paul | 846a7e8 | 2014-03-05 07:47:41 -0700 | [diff] [blame] | 45 | #define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_table_internal) |
Chia-I Wu | 97185bf | 2010-12-17 00:24:27 +0800 | [diff] [blame] | 46 | #endif |
| 47 | |
Chia-I Wu | 56eb5d7 | 2010-04-22 15:33:43 +0800 | [diff] [blame] | 48 | #if defined(USE_X86_ASM) && defined(__GNUC__) |
| 49 | # ifdef GLX_USE_TLS |
| 50 | # include "entry_x86_tls.h" |
| 51 | # else |
| 52 | # include "entry_x86_tsd.h" |
| 53 | # endif |
Chia-I Wu | de39940 | 2010-04-22 16:22:13 +0800 | [diff] [blame] | 54 | #elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(GLX_USE_TLS) |
| 55 | # include "entry_x86-64_tls.h" |
Ben Crocker | c26be2b | 2017-06-02 19:37:55 -0400 | [diff] [blame] | 56 | #elif defined(USE_PPC64LE_ASM) && defined(__GNUC__) && defined(PIPE_ARCH_LITTLE_ENDIAN) |
| 57 | # ifdef GLX_USE_TLS |
| 58 | # include "entry_ppc64le_tls.h" |
| 59 | # else |
| 60 | # include "entry_ppc64le_tsd.h" |
| 61 | # endif |
Chia-I Wu | 56eb5d7 | 2010-04-22 15:33:43 +0800 | [diff] [blame] | 62 | #else |
| 63 | |
Emil Velikov | 4562d88 | 2017-04-13 18:23:50 +0100 | [diff] [blame] | 64 | static inline const struct _glapi_table * |
Chia-I Wu | 97185bf | 2010-12-17 00:24:27 +0800 | [diff] [blame] | 65 | entry_current_get(void) |
| 66 | { |
| 67 | #ifdef MAPI_MODE_BRIDGE |
| 68 | return GET_DISPATCH(); |
| 69 | #else |
Brian Paul | 846a7e8 | 2014-03-05 07:47:41 -0700 | [diff] [blame] | 70 | return u_current_get_table(); |
Chia-I Wu | 97185bf | 2010-12-17 00:24:27 +0800 | [diff] [blame] | 71 | #endif |
| 72 | } |
| 73 | |
Chia-I Wu | d4589d3 | 2010-04-23 16:07:47 +0800 | [diff] [blame] | 74 | /* C version of the public entries */ |
Chia-I Wu | e6a7ef3 | 2010-12-24 15:06:41 +0800 | [diff] [blame] | 75 | #define MAPI_TMP_DEFINES |
| 76 | #define MAPI_TMP_PUBLIC_DECLARES |
Chia-I Wu | d4589d3 | 2010-04-23 16:07:47 +0800 | [diff] [blame] | 77 | #define MAPI_TMP_PUBLIC_ENTRIES |
| 78 | #include "mapi_tmp.h" |
| 79 | |
Chia-I Wu | 97185bf | 2010-12-17 00:24:27 +0800 | [diff] [blame] | 80 | #ifndef MAPI_MODE_BRIDGE |
| 81 | |
Chia-I Wu | d4589d3 | 2010-04-23 16:07:47 +0800 | [diff] [blame] | 82 | void |
| 83 | entry_patch_public(void) |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | mapi_func |
Chia-I Wu | e6a7ef3 | 2010-12-24 15:06:41 +0800 | [diff] [blame] | 88 | entry_get_public(int slot) |
| 89 | { |
| 90 | /* pubic_entries are defined by MAPI_TMP_PUBLIC_ENTRIES */ |
| 91 | return public_entries[slot]; |
| 92 | } |
| 93 | |
| 94 | mapi_func |
Chia-I Wu | d4589d3 | 2010-04-23 16:07:47 +0800 | [diff] [blame] | 95 | entry_generate(int slot) |
| 96 | { |
| 97 | return NULL; |
| 98 | } |
| 99 | |
| 100 | void |
| 101 | entry_patch(mapi_func entry, int slot) |
| 102 | { |
| 103 | } |
Chia-I Wu | 56eb5d7 | 2010-04-22 15:33:43 +0800 | [diff] [blame] | 104 | |
Chia-I Wu | 97185bf | 2010-12-17 00:24:27 +0800 | [diff] [blame] | 105 | #endif /* MAPI_MODE_BRIDGE */ |
| 106 | |
Chia-I Wu | 56eb5d7 | 2010-04-22 15:33:43 +0800 | [diff] [blame] | 107 | #endif /* asm */ |