view test/callback_suite/make-invoke-macros.lua @ 27:523c45dfa8fb

- refactored arm calling conventions' callvm code, so that the code that keeps the caller from overwriting the return value on some platforms also works on OpenBSD (before we casted the function pointer to have long long as return type, to hint the caller that there is one, but that triggers an intentional SIGABRT on OpenBSD for security reasons; now the decl reflects this, directly)
author cslag
date Tue, 15 Sep 2015 12:48:52 +0200
parents 3e629dc19168
children d8f0e6cecdab
line wrap: on
line source

require "config"
if mode == "ordered" then
  minargs = 0
end
local i
for i = minargs, maxargs do
  local line = "#define F" .. i .. "(ID,R"
  local argdef = ""
  local argset = ""
  if i > 0 then
    line = line .. ","
    local j
    for j = 0, i-1 do
      if j > 0 then 
        argdef = argdef .. ","
        argset = argset .. ","
      end
      argdef = argdef .. "A" .. j
      argset = argset .. "A[" .. j .. "].A" .. j
    end
  end
  line = line .. argdef .. ") void ID(void* addr) { Result.R = ((CONFIG_API R(*)("  .. argdef .. "))addr)(" .. argset .. ");}\n"
  io.write(line)
end
io.flush()