-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgcc-lua-cdecl-strip-unsupported-attributes.patch
More file actions
62 lines (60 loc) · 1.83 KB
/
gcc-lua-cdecl-strip-unsupported-attributes.patch
File metadata and controls
62 lines (60 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
diff --git i/gcc/cdecl.lua w/gcc/cdecl.lua
index ed9e664..a96f284 100644
--- i/gcc/cdecl.lua
+++ w/gcc/cdecl.lua
@@ -14,30 +14,49 @@ local concat, insert, remove = table.concat, table.insert, table.remove
-- Forward declaration.
local format_node_class
+local luajit_ffi_supported_attributes = {
+ aligned = true,
+ cdecl = true,
+ fastcall = true,
+ mode = true,
+ packed = true,
+ stdcall = true,
+ thiscall = true,
+ vector_size = true,
+}
+
-- GCC C extension: Format declaration or type attributes.
local function format_attributes(node, result, last)
local attr = node:attributes()
if attr and attr ~= last then
- local pos = #result + 1
+ local partial = {}
while true do
- local partial = {}
- insert(partial, attr:purpose():value())
+ local purpose = attr:purpose():value()
local value = attr:value()
+ if not luajit_ffi_supported_attributes[purpose] then
+ goto continue
+ end
+ if #partial > 0 then
+ insert(partial, ", ")
+ end
+ insert(partial, purpose)
if value then
- local value = value:value()
+ value = value:value()
insert(partial, "(")
if value:code() == "string_cst" then insert(partial, [["]]) end
insert(partial, value:value())
if value:code() == "string_cst" then insert(partial, [["]]) end
insert(partial, ")")
end
+ ::continue::
attr = attr:chain()
- insert(result, pos, concat(partial))
if not attr or attr == last then break end
- insert(result, pos, ", ")
end
- insert(result, pos, " __attribute__((")
- insert(result, "))")
+ if #partial > 0 then
+ insert(result, " __attribute__((")
+ insert(result, table.concat(partial))
+ insert(result, "))")
+ end
end
end