Module: Mesa
Branch: main
Commit: de53069af6f8d94db42337203c8bd09b432b6f61
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=de53069af6f8d94db42337203c8bd09b432b6f61

Author: Yonggang Luo <[email protected]>
Date:   Thu Nov  3 03:09:12 2022 +0800

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 <[email protected]>
Reviewed-by: Jesse Natalie <[email protected]>
Acked-by: Brian Paul [email protected]
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19472>

---

 src/mapi/entry.c                      |  4 ++++
 src/mapi/glapi/gen/api_exec_decl_h.py |  2 +-
 src/mapi/glapi/gen/api_save_h.py      |  2 +-
 src/mapi/glapi/gen/glX_proto_send.py  |  2 +-
 src/mapi/glapi/gen/glX_proto_size.py  |  4 ++--
 src/mapi/glapi/gen/gl_apitemp.py      |  4 ++--
 src/mapi/glapi/gen/gl_marshal_h.py    |  2 +-
 src/mapi/glapi/gen/gl_table.py        |  4 ++--
 src/mapi/mapi_abi.py                  | 14 +++++++-------
 src/mapi/new/gen_gldispatch_mapi.py   | 13 +++++--------
 10 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/src/mapi/entry.c b/src/mapi/entry.c
index b862175dff6..be6072e75ac 100644
--- a/src/mapi/entry.c
+++ b/src/mapi/entry.c
@@ -84,4 +84,8 @@ entry_patch(mapi_func entry, int slot)
 
 #endif /* MAPI_MODE_BRIDGE */
 
+#if defined(_WIN32) && defined(_WINDOWS_)
+#error "Should not include <windows.h> here"
+#endif
+
 #endif /* asm */
diff --git a/src/mapi/glapi/gen/api_exec_decl_h.py 
b/src/mapi/glapi/gen/api_exec_decl_h.py
index d6e39673860..92eb439da8a 100644
--- a/src/mapi/glapi/gen/api_exec_decl_h.py
+++ b/src/mapi/glapi/gen/api_exec_decl_h.py
@@ -47,7 +47,7 @@ class PrintCode(gl_XML.gl_print_base):
             #ifndef API_EXEC_DECL_H
             #define API_EXEC_DECL_H
 
-            #include "GL/gl.h"
+            #include "util/glheader.h"
 
             #define GL_API GLAPI
             #define GL_APIENTRY GLAPIENTRY
diff --git a/src/mapi/glapi/gen/api_save_h.py b/src/mapi/glapi/gen/api_save_h.py
index d2838f5fbe5..71d0b19cfee 100644
--- a/src/mapi/glapi/gen/api_save_h.py
+++ b/src/mapi/glapi/gen/api_save_h.py
@@ -46,7 +46,7 @@ class PrintCode(gl_XML.gl_print_base):
             #ifndef API_SAVE_H
             #define API_SAVE_H
 
-            #include "GL/gl.h"
+            #include "util/glheader.h"
             """))
 
         for f in api.functionIterateAll():
diff --git a/src/mapi/glapi/gen/glX_proto_send.py 
b/src/mapi/glapi/gen/glX_proto_send.py
index d37ac6a0a82..fb8a349ab48 100644
--- a/src/mapi/glapi/gen/glX_proto_send.py
+++ b/src/mapi/glapi/gen/glX_proto_send.py
@@ -164,7 +164,7 @@ class PrintGlxProtoStubs(glX_proto_common.glx_print_proto):
 
     def printRealHeader(self):
         print('')
-        print('#include <GL/gl.h>')
+        print('#include "util/glheader.h"')
         print('#include "indirect.h"')
         print('#include "glxclient.h"')
         print('#include "indirect_size.h"')
diff --git a/src/mapi/glapi/gen/glX_proto_size.py 
b/src/mapi/glapi/gen/glX_proto_size.py
index 37c896bc2d7..a31aa0e749e 100644
--- a/src/mapi/glapi/gen/glX_proto_size.py
+++ b/src/mapi/glapi/gen/glX_proto_size.py
@@ -313,7 +313,7 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
     def printRealHeader(self):
         print('')
         print('#include <X11/Xfuncproto.h>')
-        print('#include <GL/gl.h>')
+        print('#include "util/glheader.h"')
         if self.emit_get:
             print('#include "indirect_size_get.h"')
             print('#include "glxserver.h"')
@@ -440,7 +440,7 @@ class PrintGlxReqSize_c(PrintGlxReqSize_common):
 
     def printRealHeader(self):
         print('')
-        print('#include <GL/gl.h>')
+        print('#include "util/glheader.h"')
         print('#include "glxserver.h"')
         print('#include "glxbyteorder.h"')
         print('#include "indirect_size.h"')
diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py
index 4e93eda1e4e..429b8504658 100644
--- a/src/mapi/glapi/gen/gl_apitemp.py
+++ b/src/mapi/glapi/gen/gl_apitemp.py
@@ -164,8 +164,8 @@ class PrintGlOffsets(gl_XML.gl_print_base):
 #error RETURN_DISPATCH must be defined
 #endif
 
-#ifdef MemoryBarrier
-#undef MemoryBarrier
+#if defined(_WIN32) && defined(_WINDOWS_)
+#error "Should not include <windows.h> here"
 #endif
 
 """)
diff --git a/src/mapi/glapi/gen/gl_marshal_h.py 
b/src/mapi/glapi/gen/gl_marshal_h.py
index e3c94697163..5f5d76617d2 100644
--- a/src/mapi/glapi/gen/gl_marshal_h.py
+++ b/src/mapi/glapi/gen/gl_marshal_h.py
@@ -52,7 +52,7 @@ class PrintCode(gl_XML.gl_print_base):
         print(footer)
 
     def printBody(self, api):
-        print('#include "GL/gl.h"')
+        print('#include "util/glheader.h"')
         print('')
         print('enum marshal_dispatch_cmd_id')
         print('{')
diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py
index ae42a080cd8..ae1300cdb89 100644
--- a/src/mapi/glapi/gen/gl_table.py
+++ b/src/mapi/glapi/gen/gl_table.py
@@ -55,8 +55,8 @@ class PrintGlTable(gl_XML.gl_print_base):
         print('extern "C" {')
         print('#endif')
         print('')
-        print('#ifdef MemoryBarrier')
-        print('#undef MemoryBarrier')
+        print('#if defined(_WIN32) && defined(_WINDOWS_)')
+        print('#error "Should not include <windows.h> here"')
         print('#endif')
         print('')
         print('struct _glapi_table')
diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py
index deb3ee27050..f1d3c0d3caa 100644
--- a/src/mapi/mapi_abi.py
+++ b/src/mapi/mapi_abi.py
@@ -479,8 +479,8 @@ class ABIPrinter(object):
         print('#ifdef MAPI_TMP_DEFINES')
         print(self.c_public_includes())
         print()
-        print('#ifdef MemoryBarrier')
-        print('#undef MemoryBarrier')
+        print('#if defined(_WIN32) && defined(_WINDOWS_)')
+        print('#error "Should not include <windows.h> here"')
         print('#endif')
         print()
         print(self.c_public_declarations(self.prefix_lib))
@@ -578,10 +578,10 @@ class GLAPIPrinter(ABIPrinter):
             self._override_for_api(ent)
         super(GLAPIPrinter, self).__init__(entries)
 
-        self.api_defines = ['GL_GLEXT_PROTOTYPES']
-        self.api_headers = ['"GL/gl.h"', '"GL/glext.h"']
+        self.api_defines = []
+        self.api_headers = []
         self.api_call = 'GLAPI'
-        self.api_entry = 'APIENTRY'
+        self.api_entry = 'GLAPIENTRY'
         self.api_attrs = ''
 
         self.lib_need_table_size = False
@@ -608,7 +608,7 @@ class GLAPIPrinter(ABIPrinter):
 #define GLAPI_PREFIX(func)  gl##func
 #define GLAPI_PREFIX_STR(func)  "gl"#func
 
-typedef int GLclampx;
+#include "util/glheader.h"
 #endif /* _GLAPI_TMP_H_ */"""
 
         return header
@@ -635,7 +635,7 @@ class SharedGLAPIPrinter(GLAPIPrinter):
     def _get_c_header(self):
         header = """#ifndef _GLAPI_TMP_H_
 #define _GLAPI_TMP_H_
-typedef int GLclampx;
+#include "util/glheader.h"
 #endif /* _GLAPI_TMP_H_ */"""
 
         return header
diff --git a/src/mapi/new/gen_gldispatch_mapi.py 
b/src/mapi/new/gen_gldispatch_mapi.py
index e5678867df2..19fabf9b003 100755
--- a/src/mapi/new/gen_gldispatch_mapi.py
+++ b/src/mapi/new/gen_gldispatch_mapi.py
@@ -57,7 +57,6 @@ def _main():
 
 #ifndef _GLAPI_TMP_H_
 #define _GLAPI_TMP_H_
-typedef int GLclampx;
 #endif /* _GLAPI_TMP_H_ */
 """.lstrip("\n"))
 
@@ -75,13 +74,11 @@ typedef int GLclampx;
 def generate_defines(functions):
     text = r"""
 #ifdef MAPI_TMP_DEFINES
-#define GL_GLEXT_PROTOTYPES
-#include "GL/gl.h"
-#include "GL/glext.h"
+#include "util/glheader.h"
 
 """.lstrip("\n")
     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 += "#endif /* MAPI_TMP_DEFINES */\n"
     return text
@@ -99,7 +96,7 @@ def generate_noop_array(functions):
     text += "#ifdef DEBUG\n\n"
 
     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"
         if (len(func.args) > 0):
             text += "  "
@@ -147,11 +144,11 @@ def generate_public_entries(functions):
     for func in functions:
         retStr = ("return " if func.hasReturn() else "")
         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();
    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)

Reply via email to