glapi: Fix non-debug builds
[mesa.git] / src / mapi / glapi / glapi_dispatch.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.3
4 *
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file glapi_dispatch.c
28 *
29 * This file generates all the gl* function entrypoints. This code is not
30 * used if optimized assembly stubs are available (e.g., using
31 * glapi/glapi_x86.S on IA32 or glapi/glapi_sparc.S on SPARC).
32 *
33 * \note
34 * This file is also used to build the client-side libGL that loads DRI-based
35 * device drivers. At build-time it is symlinked to src/glx.
36 *
37 * \author Brian Paul <brian@precisioninsight.com>
38 */
39
40 #include "glapi/glapi_priv.h"
41 #include "glapi/glapitable.h"
42 #include "glapi/glapidispatch.h"
43
44 #if !(defined(USE_X86_ASM) || defined(USE_X86_64_ASM) || defined(USE_SPARC_ASM))
45
46 #if defined(WIN32)
47 #define KEYWORD1 GLAPI
48 #else
49 #define KEYWORD1 PUBLIC
50 #endif
51
52 #define KEYWORD2 GLAPIENTRY
53
54 #if defined(USE_MGL_NAMESPACE)
55 #define NAME(func) mgl##func
56 #else
57 #define NAME(func) gl##func
58 #endif
59
60 #define DISPATCH(FUNC, ARGS, MESSAGE) \
61 CALL_ ## FUNC(GET_DISPATCH(), ARGS);
62
63 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
64 return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
65
66
67 #ifndef GLAPIENTRY
68 #define GLAPIENTRY
69 #endif
70
71 #ifdef GLX_INDIRECT_RENDERING
72 /* those link to libglapi.a should provide the entry points */
73 #define _GLAPI_SKIP_PROTO_ENTRY_POINTS
74 #endif
75 #include "glapi/glapitemp.h"
76
77 #endif /* USE_X86_ASM */
78
79
80 #ifdef DEBUG
81
82 static void *logger_data;
83 static void (*logger_func)(void *data, const char *fmt, ...);
84 static struct _glapi_table *real_dispatch; /* FIXME: This need to be TLS etc */
85
86 #define KEYWORD1 static
87 #define KEYWORD1_ALT static
88 #define KEYWORD2
89 #define NAME(func) log_##func
90 #define F logger_data
91
92 static void
93 log_Unused(void)
94 {
95 }
96
97 #define DISPATCH(FUNC, ARGS, MESSAGE) \
98 logger_func MESSAGE; \
99 CALL_ ## FUNC(real_dispatch, ARGS);
100
101 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
102 logger_func MESSAGE; \
103 return CALL_ ## FUNC(real_dispatch, ARGS);
104
105 #define DISPATCH_TABLE_NAME __glapi_logging_table
106
107 #define TABLE_ENTRY(func) (_glapi_proc) log_##func
108
109 #include "glapi/glapitemp.h"
110
111 int
112 _glapi_logging_available(void)
113 {
114 return 1;
115 }
116
117 void
118 _glapi_enable_logging(void (*func)(void *data, const char *fmt, ...),
119 void *data)
120 {
121 real_dispatch = GET_DISPATCH();
122 logger_func = func;
123 logger_data = data;
124 _glapi_set_dispatch(&__glapi_logging_table);
125 }
126
127 #else
128
129 int
130 _glapi_logging_available(void)
131 {
132 return 0;
133 }
134
135 void
136 _glapi_enable_logging(void (*func)(void *data, const char *fmt, ...),
137 void *data)
138 {
139 }
140
141 #endif