diff --git a/meson.build b/meson.build index 58a739175ea..90d2f3644fa 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,8 @@ project( cc = meson.get_compiler('c') cpp = meson.get_compiler('cpp') +sizeof_pointer = meson.get_compiler('c', native : true).sizeof('void*').to_string() + null_dep = dependency('', required : false) if get_option('layout') != 'mirror' diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py index 3b54a967fdc..bb63bb52d3f 100644 --- a/src/mapi/glapi/gen/glX_XML.py +++ b/src/mapi/glapi/gen/glX_XML.py @@ -38,8 +38,8 @@ class glx_item_factory(gl_XML.gl_item_factory): def create_enum(self, element, context, category): return glx_enum(element, context, category) - def create_api(self): - return glx_api(self) + def create_api(self, pointer_type): + return glx_api(self, pointer_type) class glx_enum(gl_XML.gl_enum): diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index 3ee3fd2bcdd..f7802bb48a5 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -33,13 +33,13 @@ import typeexpr import static_data -def parse_GL_API( file_name, factory = None ): +def parse_GL_API(file_name, factory=None, pointer_size=0): if not factory: factory = gl_item_factory() - api = factory.create_api() - api.parse_file( file_name ) + api = factory.create_api(pointer_size) + api.parse_file(file_name) # After the XML has been processed, we need to go back and assign # dispatch offsets to the functions that request that their offsets @@ -855,12 +855,12 @@ class gl_item_factory(object): def create_parameter(self, element, context): return gl_parameter(element, context) - def create_api(self): - return gl_api(self) + def create_api(self, pointer_size): + return gl_api(self, pointer_size) class gl_api(object): - def __init__(self, factory): + def __init__(self, factory, pointer_size): self.functions_by_name = OrderedDict() self.enums_by_name = {} self.types_by_name = {} @@ -871,6 +871,7 @@ class gl_api(object): self.factory = factory self.next_offset = 0 + self.pointer_size = pointer_size typeexpr.create_initial_types() return diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py index 6b8e0136e4c..f82194603fa 100644 --- a/src/mapi/glapi/gen/gl_marshal.py +++ b/src/mapi/glapi/gen/gl_marshal.py @@ -341,10 +341,12 @@ if __name__ == '__main__': file_name = sys.argv[1] file_index = int(sys.argv[2]) file_count = int(sys.argv[3]) + pointer_size = int(sys.argv[4]) except Exception: show_usage() printer = PrintCode() - api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory()) + assert pointer_size != 0 + api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory(), pointer_size) printer.Print(api) diff --git a/src/mapi/glapi/gen/gl_marshal_h.py b/src/mapi/glapi/gen/gl_marshal_h.py index 4dd8acc3dfd..467998ec9f6 100644 --- a/src/mapi/glapi/gen/gl_marshal_h.py +++ b/src/mapi/glapi/gen/gl_marshal_h.py @@ -86,18 +86,14 @@ def show_usage(): if __name__ == '__main__': - file_name = 'gl_API.xml' - try: - (args, trail) = getopt.getopt(sys.argv[1:], 'm:f:') + file_name = sys.argv[1] + pointer_size = int(sys.argv[2]) except Exception: show_usage() - for (arg,val) in args: - if arg == '-f': - file_name = val - printer = PrintCode() - api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory()) + assert pointer_size != 0 + api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory(), pointer_size) printer.Print(api) diff --git a/src/mapi/glapi/gen/gl_unmarshal_table.py b/src/mapi/glapi/gen/gl_unmarshal_table.py index 1cd04a6d834..07c6ad371fa 100644 --- a/src/mapi/glapi/gen/gl_unmarshal_table.py +++ b/src/mapi/glapi/gen/gl_unmarshal_table.py @@ -89,10 +89,12 @@ def show_usage(): if __name__ == '__main__': try: file_name = sys.argv[1] + pointer_size = int(sys.argv[2]) except Exception: show_usage() printer = PrintCode() - api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory()) + assert pointer_size != 0 + api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory(), pointer_size) printer.Print(api) diff --git a/src/mapi/glapi/gen/marshal_XML.py b/src/mapi/glapi/gen/marshal_XML.py index 11c3715601d..fba077a75da 100644 --- a/src/mapi/glapi/gen/marshal_XML.py +++ b/src/mapi/glapi/gen/marshal_XML.py @@ -92,15 +92,15 @@ class marshal_function(gl_XML.gl_function): 'GLhandleARB': 4, 'int': 4, 'float': 4, + 'GLintptr': self.context.pointer_size, + 'GLsizeiptr': self.context.pointer_size, + 'GLsync': self.context.pointer_size, + 'GLDEBUGPROC': self.context.pointer_size, 'GLdouble': 8, 'GLclampd': 8, - 'GLintptr': 8, - 'GLsizeiptr': 8, 'GLint64': 8, 'GLuint64': 8, 'GLuint64EXT': 8, - 'GLsync': 8, - 'GLDEBUGPROC': 8, } val = mapping.get(type, 9999) if val == 9999: diff --git a/src/mapi/glapi/gen/meson.build b/src/mapi/glapi/gen/meson.build index a80a7538228..6af53b29e17 100644 --- a/src/mapi/glapi/gen/meson.build +++ b/src/mapi/glapi/gen/meson.build @@ -275,7 +275,7 @@ main_unmarshal_table_c = custom_target( 'unmarshal_table.c', input : ['gl_unmarshal_table.py', 'gl_and_es_API.xml'], output : 'unmarshal_table.c', - command : [prog_python, '@INPUT0@', '@INPUT1@'], + command : [prog_python, '@INPUT0@', '@INPUT1@', sizeof_pointer], depend_files : files('marshal_XML.py') + glapi_gen_depends, capture : true, ) @@ -286,7 +286,7 @@ foreach x : ['0', '1', '2', '3', '4', '5', '6', '7'] 'marshal_generated' + x + '.c', input : ['gl_marshal.py', 'gl_and_es_API.xml'], output : 'marshal_generated' + x + '.c', - command : [prog_python, '@INPUT0@', '@INPUT1@', x, '8'], + command : [prog_python, '@INPUT0@', '@INPUT1@', x, '8', sizeof_pointer], depend_files : files('marshal_XML.py') + glapi_gen_depends, capture : true, ) diff --git a/src/mesa/main/meson.build b/src/mesa/main/meson.build index a4637597159..c8171e89ae5 100644 --- a/src/mesa/main/meson.build +++ b/src/mesa/main/meson.build @@ -31,7 +31,7 @@ main_marshal_generated_h = custom_target( 'marshal_generated.h', input : [files('../../mapi/glapi/gen/gl_marshal_h.py'), gl_and_es_api_files], output : 'marshal_generated.h', - command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'], + command : [prog_python, '@INPUT0@', '@INPUT1@', sizeof_pointer], depend_files : files('../../mapi/glapi/gen/marshal_XML.py') + glapi_gen_depends, capture : true, )