From 63e7a4c6e5bf51d8090046ebc5adcb4207448565 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 9 Nov 2011 10:20:51 +0000 Subject: [PATCH] mesa,glsl,mapi: Put extern "C" { ... } where appropriate. Probably a several places missing, but enough to cover all headers (in)directly included by uniform_query.cpp, and fix the MSVC build. --- src/glsl/glsl_types.h | 6 +++--- src/glsl/ir_uniform.h | 9 ++++++--- src/mapi/glapi/glapi.h | 7 +++++-- src/mapi/glapi/glthread.h | 8 ++++++++ src/mapi/mapi/u_thread.h | 22 +++++++++++++++++++--- src/mesa/main/context.h | 9 +++++++++ src/mesa/main/core.h | 8 -------- src/mesa/main/formats.h | 11 +++++++++++ src/mesa/main/glheader.h | 10 ++++++++++ src/mesa/main/mtypes.h | 9 +++++++++ src/mesa/main/shaderapi.h | 11 +++++++++++ src/mesa/main/shaderobj.h | 3 +++ src/mesa/main/simple_list.h | 8 ++++++++ src/mesa/main/uniform_query.cpp | 6 +++--- src/mesa/main/uniforms.h | 11 +++++++++++ src/mesa/math/m_matrix.h | 9 +++++++++ src/mesa/program/hash_table.h | 9 +++++---- src/mesa/program/ir_to_mesa.h | 15 ++++++++------- src/mesa/program/prog_parameter.h | 9 +++++++++ src/mesa/program/prog_statevars.h | 11 +++++++++++ 20 files changed, 158 insertions(+), 33 deletions(-) diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index efbf335..4ac9011 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -29,13 +29,13 @@ #include #include -struct _mesa_glsl_parse_state; -struct glsl_symbol_table; - #ifdef __cplusplus extern "C" { #endif +struct _mesa_glsl_parse_state; +struct glsl_symbol_table; + extern void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); diff --git a/src/glsl/ir_uniform.h b/src/glsl/ir_uniform.h index be9f6b2..225da3f 100644 --- a/src/glsl/ir_uniform.h +++ b/src/glsl/ir_uniform.h @@ -25,15 +25,18 @@ #ifndef IR_UNIFORM_H #define IR_UNIFORM_H -#ifdef __cplusplus -extern "C" { -#endif /* stdbool.h is necessary because this file is included in both C and C++ code. */ #include + #include "program/prog_parameter.h" /* For union gl_constant_value. */ + +#ifdef __cplusplus +extern "C" { +#endif + enum gl_uniform_driver_format { uniform_native = 0, /**< Store data in the native format. */ uniform_int_float, /**< Store integer data as floats. */ diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h index b9351d1..f685475 100644 --- a/src/mapi/glapi/glapi.h +++ b/src/mapi/glapi/glapi.h @@ -44,10 +44,14 @@ #ifndef _GLAPI_H #define _GLAPI_H +#include "glapi/glthread.h" + + #ifdef __cplusplus extern "C" { #endif + #ifdef _GLAPI_NO_EXPORTS # define _GLAPI_EXPORT #else /* _GLAPI_NO_EXPORTS */ @@ -75,8 +79,6 @@ extern "C" { #define _glapi_Context _mglapi_Context #endif -#include "glapi/glthread.h" - typedef void (*_glapi_proc)(void); struct _glapi_table; @@ -180,6 +182,7 @@ _glapi_noop_enable_warnings(unsigned char enable); _GLAPI_EXPORT void _glapi_set_warning_func(_glapi_proc func); + #ifdef __cplusplus } #endif diff --git a/src/mapi/glapi/glthread.h b/src/mapi/glapi/glthread.h index fc4ece7..1c3f4e2 100644 --- a/src/mapi/glapi/glthread.h +++ b/src/mapi/glapi/glthread.h @@ -3,6 +3,10 @@ #include "mapi/u_thread.h" +#ifdef __cplusplus +extern "C" { +#endif + #define _glthread_DECLARE_STATIC_MUTEX(name) u_mutex_declare_static(name) #define _glthread_INIT_MUTEX(name) u_mutex_init(name) #define _glthread_DESTROY_MUTEX(name) u_mutex_destroy(name) @@ -17,4 +21,8 @@ typedef struct u_tsd _glthread_TSD; typedef u_mutex _glthread_Mutex; +#ifdef __cplusplus +} +#endif + #endif /* GLTHREAD_H */ diff --git a/src/mapi/mapi/u_thread.h b/src/mapi/mapi/u_thread.h index 4405ec9..7db22b7 100644 --- a/src/mapi/mapi/u_thread.h +++ b/src/mapi/mapi/u_thread.h @@ -44,12 +44,25 @@ #include "u_compiler.h" -#if defined(PTHREADS) || defined(WIN32) +#if defined(PTHREADS) +#include /* POSIX threads headers */ +#endif +#ifdef _WIN32 +#include +#endif + +#if defined(PTHREADS) || defined(_WIN32) #ifndef THREADS #define THREADS #endif #endif + +#ifdef __cplusplus +extern "C" { +#endif + + /* * POSIX threads. This should be your choice in the Unix world * whenever possible. When building with POSIX threads, be sure @@ -60,7 +73,6 @@ * proper compiling for MT-safe libc etc. */ #if defined(PTHREADS) -#include /* POSIX threads headers */ struct u_tsd { pthread_key_t key; @@ -86,7 +98,6 @@ typedef pthread_mutex_t u_mutex; * used! */ #ifdef WIN32 -#include struct u_tsd { DWORD key; @@ -142,4 +153,9 @@ u_tsd_get(struct u_tsd *tsd); void u_tsd_set(struct u_tsd *tsd, void *ptr); + +#ifdef __cplusplus +} +#endif + #endif /* _U_THREAD_H_ */ diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index a9df0a8..a66dd50 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -53,6 +53,11 @@ #include "mtypes.h" +#ifdef __cplusplus +extern "C" { +#endif + + struct _glapi_table; @@ -285,5 +290,9 @@ do { \ /*@}*/ +#ifdef __cplusplus +} +#endif + #endif /* CONTEXT_H */ diff --git a/src/mesa/main/core.h b/src/mesa/main/core.h index 212f085..c28a8af 100644 --- a/src/mesa/main/core.h +++ b/src/mesa/main/core.h @@ -48,16 +48,8 @@ #include "main/mtypes.h" -#ifdef __cplusplus -extern "C" { -#endif - /* for GLSL */ #include "program/prog_parameter.h" -#ifdef __cplusplus -} -#endif - #endif /* CORE_H */ diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index f24d525..b2cb750 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -35,6 +35,12 @@ #include + +#ifdef __cplusplus +extern "C" { +#endif + + /* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type * for GL_LUMINANCE4_ALPHA4. */ #define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) @@ -322,4 +328,9 @@ GLboolean _mesa_format_matches_format_and_type(gl_format gl_format, GLenum format, GLenum type); + +#ifdef __cplusplus +} +#endif + #endif /* FORMATS_H */ diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index c4fb157..7980111 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -54,6 +54,11 @@ #include "GL/glext.h" +#ifdef __cplusplus +extern "C" { +#endif + + /** * GL_FIXED is defined in glext.h version 64 but these typedefs aren't (yet). */ @@ -172,4 +177,9 @@ typedef void *GLeglImageOES; #define GLX_DONT_CARE 0xFFFFFFFF + +#ifdef __cplusplus +} +#endif + #endif /* GLHEADER_H */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ae6a33e..58dc9af 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -43,6 +43,11 @@ #include "main/formats.h" /* MESA_FORMAT_COUNT */ +#ifdef __cplusplus +extern "C" { +#endif + + /** * Stencil buffer data type. */ @@ -3454,4 +3459,8 @@ enum _debug +#ifdef __cplusplus +} +#endif + #endif /* MTYPES_H */ diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h index bec448d..0ffebdb 100644 --- a/src/mesa/main/shaderapi.h +++ b/src/mesa/main/shaderapi.h @@ -29,6 +29,12 @@ #include "glheader.h" + +#ifdef __cplusplus +extern "C" { +#endif + + struct _glapi_table; struct gl_context; struct gl_shader_program; @@ -194,4 +200,9 @@ _mesa_ActiveProgramEXT(GLuint program); extern GLuint GLAPIENTRY _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string); + +#ifdef __cplusplus +} +#endif + #endif /* SHADERAPI_H */ diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h index 941841d..5470b51 100644 --- a/src/mesa/main/shaderobj.h +++ b/src/mesa/main/shaderobj.h @@ -32,9 +32,12 @@ #include "main/mtypes.h" #include "program/ir_to_mesa.h" + #ifdef __cplusplus extern "C" { #endif + + /** * Internal functions */ diff --git a/src/mesa/main/simple_list.h b/src/mesa/main/simple_list.h index ff7f888..9417108 100644 --- a/src/mesa/main/simple_list.h +++ b/src/mesa/main/simple_list.h @@ -37,6 +37,10 @@ #ifndef _SIMPLE_LIST_H #define _SIMPLE_LIST_H +#ifdef __cplusplus +extern "C" { +#endif + struct simple_node { struct simple_node *next; struct simple_node *prev; @@ -199,4 +203,8 @@ do { \ #define foreach_s(ptr, t, list) \ for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 388e81a..39aa557 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -22,7 +22,9 @@ * 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. */ + #include + #include "main/core.h" #include "main/context.h" #include "ir.h" @@ -30,12 +32,10 @@ #include "program/hash_table.h" #include "../glsl/program.h" #include "../glsl/ir_uniform.h" - -extern "C" { #include "main/shaderapi.h" #include "main/shaderobj.h" #include "uniforms.h" -} + extern "C" void GLAPIENTRY _mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h index c73aab3..123d7b9 100644 --- a/src/mesa/main/uniforms.h +++ b/src/mesa/main/uniforms.h @@ -30,6 +30,11 @@ #include "../glsl/glsl_types.h" #include "../glsl/ir_uniform.h" +#ifdef __cplusplus +extern "C" { +#endif + + struct gl_program; struct _glapi_table; @@ -281,4 +286,10 @@ _mesa_uniform_split_location_offset(GLint location, unsigned *base_location, } /*@}*/ + +#ifdef __cplusplus +} +#endif + + #endif /* UNIFORMS_H */ diff --git a/src/mesa/math/m_matrix.h b/src/mesa/math/m_matrix.h index a69afb8..e8e48aa 100644 --- a/src/mesa/math/m_matrix.h +++ b/src/mesa/math/m_matrix.h @@ -35,6 +35,11 @@ #include "main/glheader.h" +#ifdef __cplusplus +extern "C" { +#endif + + /** * \name Symbolic names to some of the entries in the matrix * @@ -209,4 +214,8 @@ _mesa_transform_vector(GLfloat u[4], const GLfloat v[4], const GLfloat m[16]); /*@}*/ +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/mesa/program/hash_table.h b/src/mesa/program/hash_table.h index 47c37ae..bcf65df 100644 --- a/src/mesa/program/hash_table.h +++ b/src/mesa/program/hash_table.h @@ -37,16 +37,17 @@ #include #include -struct hash_table; struct string_to_uint_map; -typedef unsigned (*hash_func_t)(const void *key); -typedef int (*hash_compare_func_t)(const void *key1, const void *key2); - #ifdef __cplusplus extern "C" { #endif +struct hash_table; + +typedef unsigned (*hash_func_t)(const void *key); +typedef int (*hash_compare_func_t)(const void *key1, const void *key2); + /** * Hash table constructor * diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h index 2891682..aa053d9 100644 --- a/src/mesa/program/ir_to_mesa.h +++ b/src/mesa/program/ir_to_mesa.h @@ -21,24 +21,23 @@ * DEALINGS IN THE SOFTWARE. */ -#include "main/glheader.h" +#pragma once -struct gl_context; -struct gl_shader; -struct gl_shader_program; +#include "main/glheader.h" #ifdef __cplusplus extern "C" { #endif +struct gl_context; +struct gl_shader; +struct gl_shader_program; + void _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *sh); void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); GLboolean _mesa_ir_compile_shader(struct gl_context *ctx, struct gl_shader *shader); GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); -#ifdef __cplusplus -} - void _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program *shader_program, @@ -50,4 +49,6 @@ _mesa_associate_uniform_storage(struct gl_context *ctx, struct gl_shader_program *shader_program, struct gl_program_parameter_list *params); +#ifdef __cplusplus +} #endif diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h index a6793d0..3c6dc8c 100644 --- a/src/mesa/program/prog_parameter.h +++ b/src/mesa/program/prog_parameter.h @@ -35,6 +35,11 @@ #include "prog_statevars.h" +#ifdef __cplusplus +extern "C" { +#endif + + /** * Program parameter flags */ @@ -178,4 +183,8 @@ _mesa_num_parameters_of_type(const struct gl_program_parameter_list *list, gl_register_file type); +#ifdef __cplusplus +} +#endif + #endif /* PROG_PARAMETER_H */ diff --git a/src/mesa/program/prog_statevars.h b/src/mesa/program/prog_statevars.h index 04af3f4..8b731e1 100644 --- a/src/mesa/program/prog_statevars.h +++ b/src/mesa/program/prog_statevars.h @@ -25,8 +25,15 @@ #ifndef PROG_STATEVARS_H #define PROG_STATEVARS_H + #include "main/glheader.h" + +#ifdef __cplusplus +extern "C" { +#endif + + struct gl_context; struct gl_program_parameter_list; @@ -145,4 +152,8 @@ extern void _mesa_load_tracked_matrices(struct gl_context *ctx); +#ifdef __cplusplus +} +#endif + #endif /* PROG_STATEVARS_H */ -- 2.7.4