core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

glapi.c File Reference

#include "main/glheader.h"
#include "main/compiler.h"
#include <stdlib.h>
#include <string.h>
#include "glapi.h"
#include "glapioffsets.h"
#include "glapitable.h"
#include "glapitemp.h"

Defines

#define KEYWORD1   static
#define KEYWORD1_ALT   static
#define KEYWORD2   GLAPIENTRY
#define NAME(func)   NoOp##func
#define F   NULL
#define DISPATCH(func, args, msg)
#define RETURN_DISPATCH(func, args, msg)
#define DISPATCH_TABLE_NAME   __glapi_noop_table
#define UNUSED_TABLE_NAME   __unused_noop_functions
#define TABLE_ENTRY(name)   (_glapi_proc) NoOp##name
#define NEED_FUNCTION_POINTER
#define DISPATCH_TABLE_SIZE   (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS)

Functions

PUBLIC void _glapi_noop_enable_warnings (GLboolean enable)
 GL API public functions.
PUBLIC void _glapi_set_warning_func (_glapi_warning_func func)
static GLboolean warn (void)
static GLint NoOpUnused (void)
void _glapi_check_multithread (void)
 We should call this periodically from a function such as glXMakeCurrent in order to test if multiple threads are being used.
PUBLIC void _glapi_set_context (void *context)
 Set the current context pointer for this thread.
PUBLIC void * _glapi_get_context (void)
 Get the current context pointer for this thread.
PUBLIC void _glapi_set_dispatch (struct _glapi_table *dispatch)
 Set the global or per-thread dispatch table pointer.
PUBLIC struct _glapi_table_glapi_get_dispatch (void)
 Return pointer to current dispatch table for calling thread.
PUBLIC GLuint _glapi_get_dispatch_table_size (void)
 Return size of dispatch table struct as number of functions (or slots).
void _glapi_check_table (const struct _glapi_table *table)
 Make sure there are no NULL pointers in the given dispatch table.

Variables

static GLboolean WarnFlag = GL_FALSE
static _glapi_warning_func warning_func
Current dispatch and current context control variables
Depending on whether or not multithreading is support, and the type of support available, several variables are used to store the current context pointer and the current dispatch table pointer.

In the non-threaded case, the variables _glapi_Dispatch and _glapi_Context are used for this purpose.

In the "normal" threaded case, the variables _glapi_Dispatch and _glapi_Context will be NULL if an application is detected as being multithreaded. Single-threaded applications will use _glapi_Dispatch and _glapi_Context just like the case without any threading support. When _glapi_Dispatch and _glapi_Context are NULL, the thread state data _gl_DispatchTSD and ContextTSD are used. Drivers and the static dispatch functions access these variables via _glapi_get_dispatch and _glapi_get_context.

There is a race condition in setting _glapi_Dispatch to NULL. It is possible for the original thread to be setting it at the same instant a new thread, perhaps running on a different processor, is clearing it. Because of that, ThreadSafe, which can only ever be changed to GL_TRUE, is used to determine whether or not the application is multithreaded.

In the TLS case, the variables _glapi_Dispatch and _glapi_Context are hardcoded to NULL. Instead the TLS variables _glapi_tls_Dispatch and _glapi_tls_Context are used. Having _glapi_Dispatch and _glapi_Context be hardcoded to NULL maintains binary compatability between TLS enabled loaders and non-TLS DRI drivers.

PUBLIC struct _glapi_table_glapi_Dispatch
PUBLIC void * _glapi_Context = NULL
 Define the GET_CURRENT_CONTEXT() macro.


Define Documentation

#define DISPATCH ( func,
args,
msg   ) 

Value:

if (warn()) {                                                         \
      warning_func(NULL, "GL User Error: called without context: %s", #func); \
   }

#define DISPATCH_TABLE_NAME   __glapi_noop_table

#define DISPATCH_TABLE_SIZE   (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS)

#define F   NULL

#define KEYWORD1   static

#define KEYWORD1_ALT   static

#define KEYWORD2   GLAPIENTRY

#define NAME ( func   )     NoOp##func

#define NEED_FUNCTION_POINTER

#define RETURN_DISPATCH ( func,
args,
msg   ) 

Value:

if (warn()) {                                                         \
      warning_func(NULL, "GL User Error: called without context: %s", #func); \
   }                                                                          \
   return 0

#define TABLE_ENTRY ( name   )     (_glapi_proc) NoOp##name

#define UNUSED_TABLE_NAME   __unused_noop_functions


Function Documentation

void _glapi_check_multithread ( void   ) 

We should call this periodically from a function such as glXMakeCurrent in order to test if multiple threads are being used.

void _glapi_check_table ( const struct _glapi_table table  ) 

Make sure there are no NULL pointers in the given dispatch table.

Intended for debugging purposes.

PUBLIC void* _glapi_get_context ( void   ) 

Get the current context pointer for this thread.

The context pointer is an opaque type which should be cast from void to the real context pointer type.

PUBLIC struct _glapi_table* _glapi_get_dispatch ( void   )  [read]

Return pointer to current dispatch table for calling thread.

PUBLIC GLuint _glapi_get_dispatch_table_size ( void   ) 

Return size of dispatch table struct as number of functions (or slots).

PUBLIC void _glapi_noop_enable_warnings ( GLboolean  enable  ) 

GL API public functions.

PUBLIC void _glapi_set_context ( void *  context  ) 

Set the current context pointer for this thread.

The context pointer is an opaque type which should be cast to void from the real context pointer type.

PUBLIC void _glapi_set_dispatch ( struct _glapi_table dispatch  ) 

Set the global or per-thread dispatch table pointer.

If the dispatch parameter is NULL we'll plug in the no-op dispatch table (__glapi_noop_table).

PUBLIC void _glapi_set_warning_func ( _glapi_warning_func  func  ) 

static GLint NoOpUnused ( void   )  [static]

static GLboolean warn ( void   )  [static]


Variable Documentation

PUBLIC void* _glapi_Context = NULL

Define the GET_CURRENT_CONTEXT() macro.

Parameters:
C local variable which will hold the current context.

PUBLIC struct _glapi_table* _glapi_Dispatch

Initial value:

 
  (struct _glapi_table *) __glapi_noop_table

GLboolean WarnFlag = GL_FALSE [static]

_glapi_warning_func warning_func [static]


Generated on Sun Sep 27 06:47:56 2009 for Mesa GL API dispatcher by  doxygen 1.5.4