diff --git a/builder.py b/builder.py index b30c363..7aa5d93 100644 --- a/builder.py +++ b/builder.py @@ -1334,6 +1334,9 @@ class CExternal(object): All class attributes that are `llvm.core.FunctionType` are converted to `CFunc` instance during instantiation. ''' + + _calling_convention_ = None # default + def __init__(self, cbuilder): is_func = lambda x: isinstance(x, lc.FunctionType) non_magic = lambda s: not ( s.startswith('__') and s.endswith('__') ) @@ -1347,6 +1350,9 @@ class CExternal(object): mod = cbuilder.function.module for fname, ftype in to_declare: func = mod.get_or_insert_function(ftype, name=fname) + if self._calling_convention_: + func.calling_convention = self._calling_convention_ + if func.type.pointee != ftype: raise NameError("Function has already been declared " "with a different type: %s != %s"