mapi: #include "util/glheader.h" instead of #include "GL/gl.h"

Also add macro to guard windows.h won't be included

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Brian Paul brianp@vmware.com
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19472>
This commit is contained in:
Yonggang Luo
2022-11-03 03:09:12 +08:00
committed by Marge Bot
parent 2c89401f75
commit de53069af6
10 changed files with 26 additions and 25 deletions

View File

@@ -84,4 +84,8 @@ entry_patch(mapi_func entry, int slot)
#endif /* MAPI_MODE_BRIDGE */ #endif /* MAPI_MODE_BRIDGE */
#if defined(_WIN32) && defined(_WINDOWS_)
#error "Should not include <windows.h> here"
#endif
#endif /* asm */ #endif /* asm */

View File

@@ -47,7 +47,7 @@ class PrintCode(gl_XML.gl_print_base):
#ifndef API_EXEC_DECL_H #ifndef API_EXEC_DECL_H
#define API_EXEC_DECL_H #define API_EXEC_DECL_H
#include "GL/gl.h" #include "util/glheader.h"
#define GL_API GLAPI #define GL_API GLAPI
#define GL_APIENTRY GLAPIENTRY #define GL_APIENTRY GLAPIENTRY

View File

@@ -46,7 +46,7 @@ class PrintCode(gl_XML.gl_print_base):
#ifndef API_SAVE_H #ifndef API_SAVE_H
#define API_SAVE_H #define API_SAVE_H
#include "GL/gl.h" #include "util/glheader.h"
""")) """))
for f in api.functionIterateAll(): for f in api.functionIterateAll():

View File

@@ -164,7 +164,7 @@ class PrintGlxProtoStubs(glX_proto_common.glx_print_proto):
def printRealHeader(self): def printRealHeader(self):
print('') print('')
print('#include <GL/gl.h>') print('#include "util/glheader.h"')
print('#include "indirect.h"') print('#include "indirect.h"')
print('#include "glxclient.h"') print('#include "glxclient.h"')
print('#include "indirect_size.h"') print('#include "indirect_size.h"')

View File

@@ -313,7 +313,7 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
def printRealHeader(self): def printRealHeader(self):
print('') print('')
print('#include <X11/Xfuncproto.h>') print('#include <X11/Xfuncproto.h>')
print('#include <GL/gl.h>') print('#include "util/glheader.h"')
if self.emit_get: if self.emit_get:
print('#include "indirect_size_get.h"') print('#include "indirect_size_get.h"')
print('#include "glxserver.h"') print('#include "glxserver.h"')
@@ -440,7 +440,7 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common):
def printRealHeader(self): def printRealHeader(self):
print('') print('')
print('#include <GL/gl.h>') print('#include "util/glheader.h"')
print('#include "glxserver.h"') print('#include "glxserver.h"')
print('#include "glxbyteorder.h"') print('#include "glxbyteorder.h"')
print('#include "indirect_size.h"') print('#include "indirect_size.h"')

View File

@@ -164,8 +164,8 @@ class PrintGlOffsets(gl_XML.gl_print_base):
#error RETURN_DISPATCH must be defined #error RETURN_DISPATCH must be defined
#endif #endif
#ifdef MemoryBarrier #if defined(_WIN32) && defined(_WINDOWS_)
#undef MemoryBarrier #error "Should not include <windows.h> here"
#endif #endif
""") """)

View File

@@ -52,7 +52,7 @@ class PrintCode(gl_XML.gl_print_base):
print(footer) print(footer)
def printBody(self, api): def printBody(self, api):
print('#include "GL/gl.h"') print('#include "util/glheader.h"')
print('') print('')
print('enum marshal_dispatch_cmd_id') print('enum marshal_dispatch_cmd_id')
print('{') print('{')

View File

@@ -55,8 +55,8 @@ class PrintGlTable(gl_XML.gl_print_base):
print('extern "C" {') print('extern "C" {')
print('#endif') print('#endif')
print('') print('')
print('#ifdef MemoryBarrier') print('#if defined(_WIN32) && defined(_WINDOWS_)')
print('#undef MemoryBarrier') print('#error "Should not include <windows.h> here"')
print('#endif') print('#endif')
print('') print('')
print('struct _glapi_table') print('struct _glapi_table')

View File

@@ -479,8 +479,8 @@ class ABIPrinter(object):
print('#ifdef MAPI_TMP_DEFINES') print('#ifdef MAPI_TMP_DEFINES')
print(self.c_public_includes()) print(self.c_public_includes())
print() print()
print('#ifdef MemoryBarrier') print('#if defined(_WIN32) && defined(_WINDOWS_)')
print('#undef MemoryBarrier') print('#error "Should not include <windows.h> here"')
print('#endif') print('#endif')
print() print()
print(self.c_public_declarations(self.prefix_lib)) print(self.c_public_declarations(self.prefix_lib))
@@ -578,10 +578,10 @@ class GLAPIPrinter(ABIPrinter):
self._override_for_api(ent) self._override_for_api(ent)
super(GLAPIPrinter, self).__init__(entries) super(GLAPIPrinter, self).__init__(entries)
self.api_defines = ['GL_GLEXT_PROTOTYPES'] self.api_defines = []
self.api_headers = ['"GL/gl.h"', '"GL/glext.h"'] self.api_headers = []
self.api_call = 'GLAPI' self.api_call = 'GLAPI'
self.api_entry = 'APIENTRY' self.api_entry = 'GLAPIENTRY'
self.api_attrs = '' self.api_attrs = ''
self.lib_need_table_size = False self.lib_need_table_size = False
@@ -608,7 +608,7 @@ class GLAPIPrinter(ABIPrinter):
#define GLAPI_PREFIX(func) gl##func #define GLAPI_PREFIX(func) gl##func
#define GLAPI_PREFIX_STR(func) "gl"#func #define GLAPI_PREFIX_STR(func) "gl"#func
typedef int GLclampx; #include "util/glheader.h"
#endif /* _GLAPI_TMP_H_ */""" #endif /* _GLAPI_TMP_H_ */"""
return header return header
@@ -635,7 +635,7 @@ class SharedGLAPIPrinter(GLAPIPrinter):
def _get_c_header(self): def _get_c_header(self):
header = """#ifndef _GLAPI_TMP_H_ header = """#ifndef _GLAPI_TMP_H_
#define _GLAPI_TMP_H_ #define _GLAPI_TMP_H_
typedef int GLclampx; #include "util/glheader.h"
#endif /* _GLAPI_TMP_H_ */""" #endif /* _GLAPI_TMP_H_ */"""
return header return header

View File

@@ -57,7 +57,6 @@ def _main():
#ifndef _GLAPI_TMP_H_ #ifndef _GLAPI_TMP_H_
#define _GLAPI_TMP_H_ #define _GLAPI_TMP_H_
typedef int GLclampx;
#endif /* _GLAPI_TMP_H_ */ #endif /* _GLAPI_TMP_H_ */
""".lstrip("\n")) """.lstrip("\n"))
@@ -75,13 +74,11 @@ typedef int GLclampx;
def generate_defines(functions): def generate_defines(functions):
text = r""" text = r"""
#ifdef MAPI_TMP_DEFINES #ifdef MAPI_TMP_DEFINES
#define GL_GLEXT_PROTOTYPES #include "util/glheader.h"
#include "GL/gl.h"
#include "GL/glext.h"
""".lstrip("\n") """.lstrip("\n")
for func in functions: for func in functions:
text += "GLAPI {f.rt} APIENTRY {f.name}({f.decArgs});\n".format(f=func) text += "GLAPI {f.rt} GLAPIENTRY {f.name}({f.decArgs});\n".format(f=func)
text += "#undef MAPI_TMP_DEFINES\n" text += "#undef MAPI_TMP_DEFINES\n"
text += "#endif /* MAPI_TMP_DEFINES */\n" text += "#endif /* MAPI_TMP_DEFINES */\n"
return text return text
@@ -99,7 +96,7 @@ def generate_noop_array(functions):
text += "#ifdef DEBUG\n\n" text += "#ifdef DEBUG\n\n"
for func in functions: for func in functions:
text += "static {f.rt} APIENTRY noop{f.basename}({f.decArgs})\n".format(f=func) text += "static {f.rt} GLAPIENTRY noop{f.basename}({f.decArgs})\n".format(f=func)
text += "{\n" text += "{\n"
if (len(func.args) > 0): if (len(func.args) > 0):
text += " " text += " "
@@ -147,11 +144,11 @@ def generate_public_entries(functions):
for func in functions: for func in functions:
retStr = ("return " if func.hasReturn() else "") retStr = ("return " if func.hasReturn() else "")
text += r""" text += r"""
GLAPI {f.rt} APIENTRY {f.name}({f.decArgs}) GLAPI {f.rt} GLAPIENTRY {f.name}({f.decArgs})
{{ {{
const struct _glapi_table *_tbl = entry_current_get(); const struct _glapi_table *_tbl = entry_current_get();
mapi_func _func = ((const mapi_func *) _tbl)[{f.slot}]; mapi_func _func = ((const mapi_func *) _tbl)[{f.slot}];
{retStr}(({f.rt} (APIENTRY *)({f.decArgs})) _func)({f.callArgs}); {retStr}(({f.rt} (GLAPIENTRY *)({f.decArgs})) _func)({f.callArgs});
}} }}
""".lstrip("\n").format(f=func, retStr=retStr) """.lstrip("\n").format(f=func, retStr=retStr)