X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmapi%2Fglapi%2Fglapi_entrypoint.c;h=ff20bac48101d6545dd8a06eb1886a8662cf2446;hb=efaeac9e847a8234b1ea1cf32304c91f92b840a3;hp=c9c9b157d056b554edc5af04a231cfb258829459;hpb=96ff2edc73ccf11d4d198ba3665507f73ae4a9f7;p=mesa.git diff --git a/src/mapi/glapi/glapi_entrypoint.c b/src/mapi/glapi/glapi_entrypoint.c index c9c9b157d05..ff20bac4810 100644 --- a/src/mapi/glapi/glapi_entrypoint.c +++ b/src/mapi/glapi/glapi_entrypoint.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 7.1 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * @@ -17,9 +16,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. */ /** @@ -29,13 +29,16 @@ */ +#include + +#include "c11/threads.h" #include "glapi/glapi_priv.h" #include "u_execmem.h" #ifdef USE_X86_ASM -#if defined( GLX_USE_TLS ) +#if defined( USE_ELF_TLS ) extern GLubyte gl_dispatch_functions_start[]; extern GLubyte gl_dispatch_functions_end[]; #else @@ -65,7 +68,7 @@ get_entrypoint_address(unsigned int functionOffset) static void init_glapi_relocs( void ) { -#if defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT) +#if defined(USE_ELF_TLS) && !defined(GLX_X86_READONLY_TEXT) extern unsigned long _x86_get_dispatch(void); char run_time_patch[] = { 0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */ @@ -118,13 +121,11 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset) { GLubyte * const code = (GLubyte *) entrypoint; -#if defined(GLX_USE_TLS) +#if defined(USE_ELF_TLS) *((unsigned int *)(code + 8)) = 4 * offset; -#elif defined(THREADS) +#else *((unsigned int *)(code + 11)) = 4 * offset; *((unsigned int *)(code + 22)) = 4 * offset; -#else - *((unsigned int *)(code + 7)) = 4 * offset; #endif } @@ -136,9 +137,9 @@ extern void __glapi_sparc_icache_flush(unsigned int *); static void init_glapi_relocs( void ) { -#if defined(HAVE_PTHREAD) || defined(GLX_USE_TLS) +#if defined(HAVE_PTHREAD) || defined(USE_ELF_TLS) static const unsigned int template[] = { -#ifdef GLX_USE_TLS +#ifdef USE_ELF_TLS 0x05000000, /* sethi %hi(_glapi_tls_Dispatch), %g2 */ 0x8730e00a, /* srl %g3, 10, %g3 */ 0x8410a000, /* or %g2, %lo(_glapi_tls_Dispatch), %g2 */ @@ -189,7 +190,7 @@ init_glapi_relocs( void ) 0x81e80000, /* --> restore */ #endif }; -#ifdef GLX_USE_TLS +#ifdef USE_ELF_TLS extern unsigned int __glapi_sparc_tls_stub; extern unsigned long __glapi_sparc_get_dispatch(void); unsigned int *code = &__glapi_sparc_tls_stub; @@ -202,7 +203,7 @@ init_glapi_relocs( void ) int idx; #endif -#ifdef GLX_USE_TLS +#ifdef USE_ELF_TLS code[0] = template[0] | (dispatch >> 10); code[1] = template[1]; __glapi_sparc_icache_flush(&code[0]); @@ -266,14 +267,14 @@ init_glapi_relocs( void ) _glapi_proc generate_entrypoint(GLuint functionOffset) { -#if defined(HAVE_PTHREAD) || defined(GLX_USE_TLS) +#if defined(HAVE_PTHREAD) || defined(USE_ELF_TLS) static const unsigned int template[] = { 0x07000000, /* sethi %hi(0), %g3 */ 0x8210000f, /* mov %o7, %g1 */ 0x40000000, /* call */ 0x9e100001, /* mov %g1, %o7 */ }; -#ifdef GLX_USE_TLS +#ifdef USE_ELF_TLS extern unsigned int __glapi_sparc_tls_stub; unsigned long call_dest = (unsigned long ) &__glapi_sparc_tls_stub; #else @@ -337,8 +338,8 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) void init_glapi_relocs_once( void ) { -#if defined(HAVE_PTHREAD) || defined(GLX_USE_TLS) - static pthread_once_t once_control = PTHREAD_ONCE_INIT; - pthread_once( & once_control, init_glapi_relocs ); +#if defined(HAVE_PTHREAD) || defined(USE_ELF_TLS) + static once_flag flag = ONCE_FLAG_INIT; + call_once(&flag, init_glapi_relocs); #endif }