aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mapi/glapi
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mapi/glapi')
-rw-r--r--mesalib/src/mapi/glapi/SConscript3
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_enums.py4
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py6
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_x86_asm.py14
-rw-r--r--mesalib/src/mapi/glapi/glapi.h15
-rw-r--r--mesalib/src/mapi/glapi/glapi_entrypoint.c9
-rw-r--r--mesalib/src/mapi/glapi/glapi_priv.h4
7 files changed, 16 insertions, 39 deletions
diff --git a/mesalib/src/mapi/glapi/SConscript b/mesalib/src/mapi/glapi/SConscript
index 97ebfe638..8ded46f32 100644
--- a/mesalib/src/mapi/glapi/SConscript
+++ b/mesalib/src/mapi/glapi/SConscript
@@ -8,6 +8,8 @@ Import('*')
env = env.Clone()
+env.MSVC2013Compat()
+
env.Append(CPPDEFINES = [
'MAPI_MODE_UTIL',
])
@@ -25,6 +27,7 @@ if env['platform'] == 'windows':
env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
env.Append(CPPPATH = [
+ '#/src',
'#/src/mapi',
'#/src/mesa',
Dir('..'), # src/mapi build path
diff --git a/mesalib/src/mapi/glapi/gen/gl_enums.py b/mesalib/src/mapi/glapi/gen/gl_enums.py
index 35919d68a..d61618f4d 100644
--- a/mesalib/src/mapi/glapi/gen/gl_enums.py
+++ b/mesalib/src/mapi/glapi/gen/gl_enums.py
@@ -83,7 +83,7 @@ const char *_mesa_lookup_enum_by_nr( int nr )
STATIC_ASSERT(sizeof(enum_string_table) < (1 << 16));
elt = bsearch(& nr, enum_string_table_offsets,
- Elements(enum_string_table_offsets),
+ ARRAY_SIZE(enum_string_table_offsets),
sizeof(enum_string_table_offsets[0]),
(cfunc) compar_nr);
@@ -127,7 +127,7 @@ static const char *prim_names[PRIM_MAX+3] = {
const char *
_mesa_lookup_prim_by_nr(GLuint nr)
{
- if (nr < Elements(prim_names))
+ if (nr < ARRAY_SIZE(prim_names))
return prim_names[nr];
else
return "invalid mode";
diff --git a/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py b/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py
index 19e0e15b0..5a69e0343 100644
--- a/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py
+++ b/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py
@@ -138,10 +138,6 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'
print '# endif'
print ''
- print '#if defined(HAVE_PTHREAD) || defined(_WIN32)'
- print '# define THREADS'
- print '#endif'
- print ''
print '\t.text'
print ''
print '#ifdef GLX_USE_TLS'
@@ -170,7 +166,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '\tmovl\t(%rax), %edi'
print '\tjmp\tpthread_getspecific@PLT'
print ''
- print '#elif defined(THREADS)'
+ print '#else'
print ''
print '\t.extern\t_glapi_get_dispatch'
print ''
diff --git a/mesalib/src/mapi/glapi/gen/gl_x86_asm.py b/mesalib/src/mapi/glapi/gen/gl_x86_asm.py
index d87d0bd24..f855dbaaa 100644
--- a/mesalib/src/mapi/glapi/gen/gl_x86_asm.py
+++ b/mesalib/src/mapi/glapi/gen/gl_x86_asm.py
@@ -78,9 +78,6 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '#define GLOBL_FN(x) GLOBL x'
print '#endif'
print ''
- print '#if defined(HAVE_PTHREAD) || defined(_WIN32)'
- print '# define THREADS'
- print '#endif'
print ''
print '#ifdef GLX_USE_TLS'
print ''
@@ -109,7 +106,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'
print '1:\tCALL(_x86_get_dispatch) ;\t\t\t\\'
print '\tJMP(GL_OFFSET(off))'
- print '#elif defined(THREADS)'
+ print '#else'
print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'
print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
@@ -120,13 +117,6 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'
print '1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\'
print '\tJMP(GL_OFFSET(off))'
- print '#else /* Non-threaded version. */'
- print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'
- print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
- print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
- print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
- print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
- print '\tJMP(GL_OFFSET(off))'
print '#endif'
print ''
print '#ifdef HAVE_ALIAS'
@@ -164,7 +154,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '\tCALL(GLNAME(pthread_getspecific))'
print '\tADD_L(CONST(28), ESP)'
print '\tRET'
- print '#elif defined(THREADS)'
+ print '#else'
print 'EXTERN GLNAME(_glapi_get_dispatch)'
print '#endif'
print ''
diff --git a/mesalib/src/mapi/glapi/glapi.h b/mesalib/src/mapi/glapi/glapi.h
index e2fa9252f..8d991fb3b 100644
--- a/mesalib/src/mapi/glapi/glapi.h
+++ b/mesalib/src/mapi/glapi/glapi.h
@@ -44,7 +44,7 @@
#ifndef _GLAPI_H
#define _GLAPI_H
-#include "u_thread.h"
+#include "util/macros.h"
#ifdef __cplusplus
@@ -102,21 +102,12 @@ _GLAPI_EXPORT extern const void *_glapi_Context;
_GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch;
_GLAPI_EXPORT extern void *_glapi_Context;
-# ifdef THREADS
-
-# define GET_DISPATCH() \
+#define GET_DISPATCH() \
(likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
-# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \
+#define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \
(likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
-# else
-
-# define GET_DISPATCH() _glapi_Dispatch
-# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_Context
-
-# endif
-
#endif /* defined (GLX_USE_TLS) */
diff --git a/mesalib/src/mapi/glapi/glapi_entrypoint.c b/mesalib/src/mapi/glapi/glapi_entrypoint.c
index 362a8f11b..7facd8aca 100644
--- a/mesalib/src/mapi/glapi/glapi_entrypoint.c
+++ b/mesalib/src/mapi/glapi/glapi_entrypoint.c
@@ -29,6 +29,7 @@
*/
+#include "c11/threads.h"
#include "glapi/glapi_priv.h"
#include "u_execmem.h"
@@ -120,11 +121,9 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset)
#if defined(GLX_USE_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
}
@@ -338,7 +337,7 @@ 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 );
+ static once_flag flag = ONCE_FLAG_INIT;
+ call_once(&flag, init_glapi_relocs);
#endif
}
diff --git a/mesalib/src/mapi/glapi/glapi_priv.h b/mesalib/src/mapi/glapi/glapi_priv.h
index 92925faac..d3682603d 100644
--- a/mesalib/src/mapi/glapi/glapi_priv.h
+++ b/mesalib/src/mapi/glapi/glapi_priv.h
@@ -86,10 +86,8 @@ get_entrypoint_address(unsigned int functionOffset);
#if defined(USE_X86_ASM)
# if defined(GLX_USE_TLS)
# define DISPATCH_FUNCTION_SIZE 16
-# elif defined(THREADS)
-# define DISPATCH_FUNCTION_SIZE 32
# else
-# define DISPATCH_FUNCTION_SIZE 16
+# define DISPATCH_FUNCTION_SIZE 32
# endif
#endif