entry.c revision b8e80941
1848b8605Smrg/* 2848b8605Smrg * Mesa 3-D graphics library 3848b8605Smrg * 4848b8605Smrg * Copyright (C) 2010 LunarG Inc. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the "Software"), 8848b8605Smrg * to deal in the Software without restriction, including without limitation 9848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the 11848b8605Smrg * Software is furnished to do so, subject to the following conditions: 12848b8605Smrg * 13848b8605Smrg * The above copyright notice and this permission notice shall be included 14848b8605Smrg * in all copies or substantial portions of the Software. 15848b8605Smrg * 16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17848b8605Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20848b8605Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21848b8605Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22848b8605Smrg * DEALINGS IN THE SOFTWARE. 23848b8605Smrg * 24848b8605Smrg * Authors: 25848b8605Smrg * Chia-I Wu <olv@lunarg.com> 26848b8605Smrg */ 27848b8605Smrg 28b8e80941Smrg#include <stdlib.h> 29b8e80941Smrg#include <stdint.h> 30b8e80941Smrg 31848b8605Smrg#include "entry.h" 32848b8605Smrg#include "u_current.h" 33b8e80941Smrg#include "util/u_endian.h" 34b8e80941Smrg 35b8e80941Smrg#define _U_STRINGIFY(x) #x 36b8e80941Smrg#define U_STRINGIFY(x) _U_STRINGIFY(x) 37848b8605Smrg 38848b8605Smrg/* define macros for use by assembly dispatchers */ 39848b8605Smrg#define ENTRY_CURRENT_TABLE U_STRINGIFY(u_current_table) 40848b8605Smrg 41848b8605Smrg/* in bridge mode, mapi is a user of glapi */ 42848b8605Smrg#ifdef MAPI_MODE_BRIDGE 43848b8605Smrg#define ENTRY_CURRENT_TABLE_GET "_glapi_get_dispatch" 44848b8605Smrg#else 45848b8605Smrg#define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_table_internal) 46848b8605Smrg#endif 47848b8605Smrg 48b8e80941Smrg#if defined(USE_X86_ASM) && defined(__GNUC__) 49848b8605Smrg# ifdef GLX_USE_TLS 50848b8605Smrg# include "entry_x86_tls.h" 51848b8605Smrg# else 52848b8605Smrg# include "entry_x86_tsd.h" 53848b8605Smrg# endif 54848b8605Smrg#elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(GLX_USE_TLS) 55848b8605Smrg# include "entry_x86-64_tls.h" 56b8e80941Smrg#elif defined(USE_PPC64LE_ASM) && defined(__GNUC__) && defined(PIPE_ARCH_LITTLE_ENDIAN) 57b8e80941Smrg# ifdef GLX_USE_TLS 58b8e80941Smrg# include "entry_ppc64le_tls.h" 59b8e80941Smrg# else 60b8e80941Smrg# include "entry_ppc64le_tsd.h" 61b8e80941Smrg# endif 62848b8605Smrg#else 63848b8605Smrg 64b8e80941Smrgstatic inline const struct _glapi_table * 65848b8605Smrgentry_current_get(void) 66848b8605Smrg{ 67848b8605Smrg#ifdef MAPI_MODE_BRIDGE 68848b8605Smrg return GET_DISPATCH(); 69848b8605Smrg#else 70848b8605Smrg return u_current_get_table(); 71848b8605Smrg#endif 72848b8605Smrg} 73848b8605Smrg 74848b8605Smrg/* C version of the public entries */ 75848b8605Smrg#define MAPI_TMP_DEFINES 76848b8605Smrg#define MAPI_TMP_PUBLIC_DECLARES 77848b8605Smrg#define MAPI_TMP_PUBLIC_ENTRIES 78848b8605Smrg#include "mapi_tmp.h" 79848b8605Smrg 80848b8605Smrg#ifndef MAPI_MODE_BRIDGE 81848b8605Smrg 82848b8605Smrgvoid 83848b8605Smrgentry_patch_public(void) 84848b8605Smrg{ 85848b8605Smrg} 86848b8605Smrg 87848b8605Smrgmapi_func 88848b8605Smrgentry_get_public(int slot) 89848b8605Smrg{ 90848b8605Smrg /* pubic_entries are defined by MAPI_TMP_PUBLIC_ENTRIES */ 91848b8605Smrg return public_entries[slot]; 92848b8605Smrg} 93848b8605Smrg 94848b8605Smrgmapi_func 95848b8605Smrgentry_generate(int slot) 96848b8605Smrg{ 97848b8605Smrg return NULL; 98848b8605Smrg} 99848b8605Smrg 100848b8605Smrgvoid 101848b8605Smrgentry_patch(mapi_func entry, int slot) 102848b8605Smrg{ 103848b8605Smrg} 104848b8605Smrg 105848b8605Smrg#endif /* MAPI_MODE_BRIDGE */ 106848b8605Smrg 107848b8605Smrg#endif /* asm */ 108