aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/glx/glapi.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
committermarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
commit76bcc36ed305418a3ddc5752d287ede894243e1b (patch)
treebacb320c825768471ce56f058f17ce863d592376 /xorg-server/glx/glapi.c
parent7d894e32566b710952c44cbc71939ad1d9e2fa8d (diff)
parent0f834b91a4768673833ab4917e87d86c237bb1a6 (diff)
downloadvcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.gz
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.bz2
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.zip
Merge remote-tracking branch 'origin/released'
Conflicts: pixman/pixman/pixman-mmx.c xorg-server/Xext/shm.c xorg-server/Xext/syncsrv.h xorg-server/Xext/xvmain.c xorg-server/Xi/exevents.c xorg-server/Xi/opendev.c xorg-server/composite/compalloc.c xorg-server/composite/compoverlay.c xorg-server/dix/colormap.c xorg-server/dix/devices.c xorg-server/dix/dispatch.c xorg-server/dix/dixfonts.c xorg-server/dix/eventconvert.c xorg-server/dix/events.c xorg-server/dix/gc.c xorg-server/dix/getevents.c xorg-server/dix/main.c xorg-server/dix/privates.c xorg-server/dix/registry.c xorg-server/dix/resource.c xorg-server/exa/exa_accel.c xorg-server/exa/exa_migration_classic.c xorg-server/exa/exa_unaccel.c xorg-server/fb/fb.h xorg-server/fb/fbcopy.c xorg-server/fb/fbpixmap.c xorg-server/glx/dispatch.h xorg-server/glx/glapi.h xorg-server/glx/glapi_gentable.c xorg-server/glx/glapitable.h xorg-server/glx/glprocs.h xorg-server/glx/glxcmds.c xorg-server/glx/glxcmdsswap.c xorg-server/glx/glxdricommon.c xorg-server/glx/glxdriswrast.c xorg-server/glx/glxext.c xorg-server/glx/indirect_dispatch.c xorg-server/glx/indirect_dispatch.h xorg-server/glx/indirect_dispatch_swap.c xorg-server/glx/indirect_size.h xorg-server/glx/indirect_size_get.h xorg-server/glx/indirect_table.c xorg-server/glx/indirect_util.c xorg-server/glx/rensize.c xorg-server/glx/single2swap.c xorg-server/glx/singlepix.c xorg-server/glx/singlepixswap.c xorg-server/glx/singlesize.c xorg-server/hw/dmx/dmxinit.c xorg-server/hw/kdrive/ephyr/ephyr.c xorg-server/hw/kdrive/ephyr/hostx.c xorg-server/hw/kdrive/ephyr/hostx.h xorg-server/hw/kdrive/src/kinput.c xorg-server/hw/xfree86/common/compiler.h xorg-server/hw/xwin/InitInput.c xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/ddraw.h xorg-server/hw/xwin/glx/glwrap.c xorg-server/hw/xwin/glx/indirect.c xorg-server/hw/xwin/glx/wgl_ext_api.h xorg-server/hw/xwin/glx/winpriv.c xorg-server/hw/xwin/win.h xorg-server/hw/xwin/winallpriv.c xorg-server/hw/xwin/winauth.c xorg-server/hw/xwin/winclipboard.h xorg-server/hw/xwin/winclipboardinit.c xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardunicode.c xorg-server/hw/xwin/winclipboardwndproc.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winclipboardxevents.c xorg-server/hw/xwin/wincmap.c xorg-server/hw/xwin/winconfig.c xorg-server/hw/xwin/wincreatewnd.c xorg-server/hw/xwin/wincursor.c xorg-server/hw/xwin/windialogs.c xorg-server/hw/xwin/winengine.c xorg-server/hw/xwin/winerror.c xorg-server/hw/xwin/wingc.c xorg-server/hw/xwin/wingetsp.c xorg-server/hw/xwin/winkeybd.c xorg-server/hw/xwin/winkeybd.h xorg-server/hw/xwin/winlayouts.h xorg-server/hw/xwin/winmisc.c xorg-server/hw/xwin/winmonitors.c xorg-server/hw/xwin/winmouse.c xorg-server/hw/xwin/winmsg.c xorg-server/hw/xwin/winmsg.h xorg-server/hw/xwin/winmultiwindowclass.c xorg-server/hw/xwin/winmultiwindowicons.c xorg-server/hw/xwin/winmultiwindowshape.c xorg-server/hw/xwin/winmultiwindowwindow.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winmultiwindowwndproc.c xorg-server/hw/xwin/winnativegdi.c xorg-server/hw/xwin/winpfbdd.c xorg-server/hw/xwin/winpixmap.c xorg-server/hw/xwin/winpolyline.c xorg-server/hw/xwin/winprefs.c xorg-server/hw/xwin/winprocarg.c xorg-server/hw/xwin/winregistry.c xorg-server/hw/xwin/winscrinit.c xorg-server/hw/xwin/winsetsp.c xorg-server/hw/xwin/winshaddd.c xorg-server/hw/xwin/winshadddnl.c xorg-server/hw/xwin/winshadgdi.c xorg-server/hw/xwin/wintrayicon.c xorg-server/hw/xwin/winwin32rootless.c xorg-server/hw/xwin/winwin32rootlesswindow.c xorg-server/hw/xwin/winwin32rootlesswndproc.c xorg-server/hw/xwin/winwindow.c xorg-server/hw/xwin/winwindow.h xorg-server/hw/xwin/winwindowswm.c xorg-server/hw/xwin/winwndproc.c xorg-server/include/callback.h xorg-server/include/dixstruct.h xorg-server/include/misc.h xorg-server/include/os.h xorg-server/include/scrnintstr.h xorg-server/mi/micmap.c xorg-server/mi/miinitext.c xorg-server/mi/mioverlay.c xorg-server/mi/misprite.c xorg-server/mi/mivaltree.c xorg-server/mi/miwindow.c xorg-server/miext/damage/damage.c xorg-server/miext/rootless/rootlessGC.c xorg-server/miext/rootless/rootlessWindow.c xorg-server/os/WaitFor.c xorg-server/os/access.c xorg-server/os/connection.c xorg-server/os/io.c xorg-server/os/log.c xorg-server/os/osinit.c xorg-server/os/utils.c xorg-server/os/xdmcp.c xorg-server/os/xprintf.c xorg-server/os/xstrans.c xorg-server/render/mipict.c xorg-server/xkb/xkbActions.c xorg-server/xkb/xkbInit.c xorg-server/xkeyboard-config/compat/default.in
Diffstat (limited to 'xorg-server/glx/glapi.c')
-rw-r--r--xorg-server/glx/glapi.c332
1 files changed, 162 insertions, 170 deletions
diff --git a/xorg-server/glx/glapi.c b/xorg-server/glx/glapi.c
index a7913a3a1..29a28f414 100644
--- a/xorg-server/glx/glapi.c
+++ b/xorg-server/glx/glapi.c
@@ -85,9 +85,9 @@ static void init_glapi_relocs(void);
/*@{*/
#if defined(GLX_USE_TLS)
-PUBLIC TLS struct _glapi_table * _glapi_tls_Dispatch = NULL;
+PUBLIC TLS struct _glapi_table *_glapi_tls_Dispatch = NULL;
-PUBLIC TLS void * _glapi_tls_Context;
+PUBLIC TLS void *_glapi_tls_Context;
PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL;
PUBLIC const void *_glapi_Context = NULL;
@@ -100,20 +100,21 @@ _glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */
static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
#if defined(WIN32_THREADS)
-void FreeTSD(_glthread_TSD *p);
-void FreeAllTSD(void)
+void FreeTSD(_glthread_TSD * p);
+void
+FreeAllTSD(void)
{
- FreeTSD(&_gl_DispatchTSD);
- FreeTSD(&ContextTSD);
+ FreeTSD(&_gl_DispatchTSD);
+ FreeTSD(&ContextTSD);
}
-#endif /* defined(WIN32_THREADS) */
+#endif /* defined(WIN32_THREADS) */
-#endif /* defined(THREADS) */
+#endif /* defined(THREADS) */
PUBLIC struct _glapi_table *_glapi_Dispatch = NULL;
PUBLIC void *_glapi_Context = NULL;
-#endif /* defined(GLX_USE_TLS) */
+#endif /* defined(GLX_USE_TLS) */
/*@}*/
/*
@@ -133,17 +134,15 @@ void
_glapi_set_context(void *context)
{
#if defined(GLX_USE_TLS)
- _glapi_tls_Context = context;
+ _glapi_tls_Context = context;
#elif defined(THREADS)
- _glthread_SetTSD(&ContextTSD, context);
- _glapi_Context = context;
+ _glthread_SetTSD(&ContextTSD, context);
+ _glapi_Context = context;
#else
- _glapi_Context = context;
+ _glapi_Context = context;
#endif
}
-
-
/**
* Get the current context pointer for this thread.
* The context pointer is an opaque type which should be cast from
@@ -153,14 +152,12 @@ void *
_glapi_get_context(void)
{
#if defined(GLX_USE_TLS)
- return _glapi_tls_Context;
+ return _glapi_tls_Context;
#else
- return _glapi_Context;
+ return _glapi_Context;
#endif
}
-
-
/**
* Set the global or per-thread dispatch table pointer.
*/
@@ -168,77 +165,74 @@ void
_glapi_set_dispatch(struct _glapi_table *dispatch)
{
#if defined(PTHREADS) || defined(GLX_USE_TLS)
- static pthread_once_t once_control = PTHREAD_ONCE_INIT;
- pthread_once( & once_control, init_glapi_relocs );
+ static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+
+ pthread_once(&once_control, init_glapi_relocs);
#endif
#if defined(GLX_USE_TLS)
- _glapi_tls_Dispatch = dispatch;
+ _glapi_tls_Dispatch = dispatch;
#elif defined(THREADS)
- _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch);
- _glapi_Dispatch = dispatch;
+ _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch);
+ _glapi_Dispatch = dispatch;
#else /*THREADS*/
- _glapi_Dispatch = dispatch;
+ _glapi_Dispatch = dispatch;
#endif /*THREADS*/
}
-
-
/**
* Return pointer to current dispatch table for calling thread.
*/
struct _glapi_table *
_glapi_get_dispatch(void)
{
- struct _glapi_table * api;
+ struct _glapi_table *api;
+
#if defined(GLX_USE_TLS)
- api = _glapi_tls_Dispatch;
+ api = _glapi_tls_Dispatch;
#else
- api = _glapi_Dispatch;
+ api = _glapi_Dispatch;
#endif
- return api;
+ return api;
}
-
-
/***
*** The rest of this file is pretty much concerned with GetProcAddress
*** functionality.
***/
#if defined(USE_X64_64_ASM) && defined(GLX_USE_TLS)
-# define DISPATCH_FUNCTION_SIZE 16
+#define DISPATCH_FUNCTION_SIZE 16
#elif defined(USE_X86_ASM)
-# if defined(THREADS) && !defined(GLX_USE_TLS)
-# define DISPATCH_FUNCTION_SIZE 32
-# else
-# define DISPATCH_FUNCTION_SIZE 16
-# endif
+#if defined(THREADS) && !defined(GLX_USE_TLS)
+#define DISPATCH_FUNCTION_SIZE 32
+#else
+#define DISPATCH_FUNCTION_SIZE 16
+#endif
#endif
-
/* The code in this file is auto-generated with Python */
#include "glprocs.h"
-
/**
* Search the table of static entrypoint functions for the named function
* and return the corresponding glprocs_table_t entry.
*/
static const glprocs_table_t *
-find_entry( const char * n )
+find_entry(const char *n)
{
- GLuint i;
- for (i = 0; static_functions[i].Name_offset >= 0; i++) {
- const char *testName = gl_string_table + static_functions[i].Name_offset;
- if (strcmp(testName, n) == 0) {
- return &static_functions[i];
- }
- }
- return NULL;
+ GLuint i;
+
+ for (i = 0; static_functions[i].Name_offset >= 0; i++) {
+ const char *testName =
+ gl_string_table + static_functions[i].Name_offset;
+ if (strcmp(testName, n) == 0) {
+ return &static_functions[i];
+ }
+ }
+ return NULL;
}
-
/**
* Return dispatch table offset of the named static (built-in) function.
* Return -1 if function not found.
@@ -246,14 +240,13 @@ find_entry( const char * n )
static GLint
get_static_proc_offset(const char *funcName)
{
- const glprocs_table_t * const f = find_entry( funcName );
- if (f) {
- return f->Offset;
- }
- return -1;
-}
-
+ const glprocs_table_t *const f = find_entry(funcName);
+ if (f) {
+ return f->Offset;
+ }
+ return -1;
+}
/**********************************************************************
* Extension function management.
@@ -264,7 +257,6 @@ get_static_proc_offset(const char *funcName)
*/
#define MAX_EXTENSION_FUNCS 300
-
/*
* The dispatch table size (number of entries) is the size of the
* _glapi_table struct plus the number of dynamic entries we can add.
@@ -273,7 +265,6 @@ get_static_proc_offset(const char *funcName)
*/
#define DISPATCH_TABLE_SIZE (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS)
-
/**
* Track information about a function added to the GL API.
*/
@@ -281,7 +272,7 @@ struct _glapi_function {
/**
* Name of the function.
*/
- const char * name;
+ const char *name;
/**
* Text string that describes the types of the parameters passed to the
@@ -292,14 +283,14 @@ struct _glapi_function {
* - 'f' for \c GLfloat and \c GLclampf
* - 'd' for \c GLdouble and \c GLclampd
*/
- const char * parameter_signature;
+ const char *parameter_signature;
/**
* Offset in the dispatch table where the pointer to the real function is
* located. If the driver has not requested that the named function be
* added to the dispatch table, this will have the value ~0.
*/
- unsigned dispatch_offset;
+ unsigned dispatch_offset;
};
static struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS];
@@ -319,22 +310,21 @@ static GLuint NumExtEntryPoints = 0;
*/
static struct _glapi_function *
-add_function_name( const char * funcName )
+add_function_name(const char *funcName)
{
- struct _glapi_function * entry = NULL;
-
- if (NumExtEntryPoints < MAX_EXTENSION_FUNCS) {
- entry = &ExtEntryTable[NumExtEntryPoints];
-
- ExtEntryTable[NumExtEntryPoints].name = strdup(funcName);
- ExtEntryTable[NumExtEntryPoints].parameter_signature = NULL;
- ExtEntryTable[NumExtEntryPoints].dispatch_offset = ~0;
- NumExtEntryPoints++;
- }
-
- return entry;
-}
+ struct _glapi_function *entry = NULL;
+
+ if (NumExtEntryPoints < MAX_EXTENSION_FUNCS) {
+ entry = &ExtEntryTable[NumExtEntryPoints];
+
+ ExtEntryTable[NumExtEntryPoints].name = strdup(funcName);
+ ExtEntryTable[NumExtEntryPoints].parameter_signature = NULL;
+ ExtEntryTable[NumExtEntryPoints].dispatch_offset = ~0;
+ NumExtEntryPoints++;
+ }
+ return entry;
+}
/**
* Fill-in the dispatch stub for the named function.
@@ -384,90 +374,91 @@ add_function_name( const char * funcName )
*/
PUBLIC int
-_glapi_add_dispatch( const char * const * function_names,
- const char * parameter_signature )
+_glapi_add_dispatch(const char *const *function_names,
+ const char *parameter_signature)
{
- static int next_dynamic_offset = FIRST_DYNAMIC_OFFSET;
- const char * const real_sig = (parameter_signature != NULL)
- ? parameter_signature : "";
- struct _glapi_function * entry[8];
- GLboolean is_static[8];
- unsigned i;
- unsigned j;
- int offset = ~0;
- int new_offset;
-
-
- (void) memset(is_static, 0, sizeof(is_static));
- (void) memset(entry, 0, sizeof(entry));
-
- for (i = 0 ; function_names[i] != NULL ; i++) {
- /* Do some trivial validation on the name of the function. */
-
- if (function_names[i][0] != 'g' || function_names[i][1] != 'l')
- return GL_FALSE;
-
- /* Determine if the named function already exists. If the function does
- * exist, it must have the same parameter signature as the function
- * being added.
- */
-
- new_offset = get_static_proc_offset(function_names[i]);
- if (new_offset >= 0) {
- /* FIXME: Make sure the parameter signatures match! How do we get
- * FIXME: the parameter signature for static functions?
- */
-
- if ((offset != ~0) && (new_offset != offset)) {
- return -1;
- }
-
- is_static[i] = GL_TRUE;
- offset = new_offset;
- }
-
- for (j = 0; j < NumExtEntryPoints; j++) {
- if (strcmp(ExtEntryTable[j].name, function_names[i]) == 0) {
- /* The offset may be ~0 if the function name was added by
- * glXGetProcAddress but never filled in by the driver.
- */
-
- if (ExtEntryTable[j].dispatch_offset != ~0) {
- if (strcmp(real_sig, ExtEntryTable[j].parameter_signature) != 0)
- return -1;
-
- if ((offset != ~0) && (ExtEntryTable[j].dispatch_offset != offset)) {
- return -1;
- }
-
- offset = ExtEntryTable[j].dispatch_offset;
- }
-
- entry[i] = & ExtEntryTable[j];
- break;
- }
- }
- }
-
- if (offset == ~0) {
- offset = next_dynamic_offset;
- next_dynamic_offset++;
- }
-
- for (i = 0 ; function_names[i] != NULL ; i++) {
- if (!is_static[i]) {
- if (entry[i] == NULL) {
- entry[i] = add_function_name(function_names[i]);
- if (entry[i] == NULL)
- return -1;
- }
-
- entry[i]->parameter_signature = strdup(real_sig);
- entry[i]->dispatch_offset = offset;
- }
- }
-
- return offset;
+ static int next_dynamic_offset = FIRST_DYNAMIC_OFFSET;
+ const char *const real_sig = (parameter_signature != NULL)
+ ? parameter_signature : "";
+ struct _glapi_function *entry[8];
+ GLboolean is_static[8];
+ unsigned i;
+ unsigned j;
+ int offset = ~0;
+ int new_offset;
+
+ (void) memset(is_static, 0, sizeof(is_static));
+ (void) memset(entry, 0, sizeof(entry));
+
+ for (i = 0; function_names[i] != NULL; i++) {
+ /* Do some trivial validation on the name of the function. */
+
+ if (function_names[i][0] != 'g' || function_names[i][1] != 'l')
+ return GL_FALSE;
+
+ /* Determine if the named function already exists. If the function does
+ * exist, it must have the same parameter signature as the function
+ * being added.
+ */
+
+ new_offset = get_static_proc_offset(function_names[i]);
+ if (new_offset >= 0) {
+ /* FIXME: Make sure the parameter signatures match! How do we get
+ * FIXME: the parameter signature for static functions?
+ */
+
+ if ((offset != ~0) && (new_offset != offset)) {
+ return -1;
+ }
+
+ is_static[i] = GL_TRUE;
+ offset = new_offset;
+ }
+
+ for (j = 0; j < NumExtEntryPoints; j++) {
+ if (strcmp(ExtEntryTable[j].name, function_names[i]) == 0) {
+ /* The offset may be ~0 if the function name was added by
+ * glXGetProcAddress but never filled in by the driver.
+ */
+
+ if (ExtEntryTable[j].dispatch_offset != ~0) {
+ if (strcmp(real_sig, ExtEntryTable[j].parameter_signature)
+ != 0)
+ return -1;
+
+ if ((offset != ~0) &&
+ (ExtEntryTable[j].dispatch_offset != offset)) {
+ return -1;
+ }
+
+ offset = ExtEntryTable[j].dispatch_offset;
+ }
+
+ entry[i] = &ExtEntryTable[j];
+ break;
+ }
+ }
+ }
+
+ if (offset == ~0) {
+ offset = next_dynamic_offset;
+ next_dynamic_offset++;
+ }
+
+ for (i = 0; function_names[i] != NULL; i++) {
+ if (!is_static[i]) {
+ if (entry[i] == NULL) {
+ entry[i] = add_function_name(function_names[i]);
+ if (entry[i] == NULL)
+ return -1;
+ }
+
+ entry[i]->parameter_signature = strdup(real_sig);
+ entry[i]->dispatch_offset = offset;
+ }
+ }
+
+ return offset;
}
/*
@@ -488,7 +479,7 @@ _glapi_get_proc_address(const char *funcName)
GLuint
_glapi_get_dispatch_table_size(void)
{
- return DISPATCH_TABLE_SIZE;
+ return DISPATCH_TABLE_SIZE;
}
#if defined(PTHREADS) || defined(GLX_USE_TLS)
@@ -496,22 +487,23 @@ _glapi_get_dispatch_table_size(void)
* Perform platform-specific GL API entry-point fixups.
*/
static void
-init_glapi_relocs( void )
+init_glapi_relocs(void)
{
#if defined(USE_X86_ASM) && defined(GLX_USE_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 */
+ 0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */
};
- GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */
- const GLubyte * const get_disp = (const GLubyte *) run_time_patch;
- GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start;
+ GLuint *offset = (GLuint *) & run_time_patch[2]; /* 32-bits for x86/32 */
+ const GLubyte *const get_disp = (const GLubyte *) run_time_patch;
+ GLubyte *curr_func = (GLubyte *) gl_dispatch_functions_start;
*offset = _x86_get_dispatch();
- while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) {
- (void) memcpy( curr_func, get_disp, sizeof(run_time_patch));
- curr_func += DISPATCH_FUNCTION_SIZE;
+ while (curr_func != (GLubyte *) gl_dispatch_functions_end) {
+ (void) memcpy(curr_func, get_disp, sizeof(run_time_patch));
+ curr_func += DISPATCH_FUNCTION_SIZE;
}
#endif
}
-#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */
+#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */