def map_math_functions(self): c_helpers = _helperlib.c_helpers for name in ['cpow', 'sdiv', 'srem', 'udiv', 'urem']: le.dylib_add_symbol("numba.math.%s" % name, c_helpers[name]) if sys.platform.startswith('win32') and not le.dylib_address_of_symbol( '__ftol2'): le.dylib_add_symbol("__ftol2", c_helpers["fptoui"]) elif sys.platform.startswith( 'linux') and not le.dylib_address_of_symbol('__fixunsdfdi'): le.dylib_add_symbol("__fixunsdfdi", c_helpers["fptoui"]) # Necessary for Python3 le.dylib_add_symbol("numba.round", c_helpers["round_even"]) le.dylib_add_symbol("numba.roundf", c_helpers["roundf_even"]) # windows symbol hacks if sys.platform.startswith('win32') and self.is32bit: _windows_symbol_hacks_32bits() # List available C-math for fname in intrinsics.INTR_MATH: if le.dylib_address_of_symbol(fname): # Exist self.cmath_provider[fname] = 'builtin' else: # Non-exist # Bind from C code le.dylib_add_symbol(fname, c_helpers[fname]) self.cmath_provider[fname] = 'indirect'
def map_math_functions(self): le.dylib_add_symbol("numba.math.cpow", _helperlib.get_cpow()) le.dylib_add_symbol("numba.math.sdiv", _helperlib.get_sdiv()) le.dylib_add_symbol("numba.math.srem", _helperlib.get_srem()) le.dylib_add_symbol("numba.math.udiv", _helperlib.get_udiv()) le.dylib_add_symbol("numba.math.urem", _helperlib.get_urem()) if sys.platform.startswith('win32') and not le.dylib_address_of_symbol('__ftol2'): le.dylib_add_symbol("__ftol2", _helperlib.get_fptoui()) elif sys.platform.startswith('linux') and not le.dylib_address_of_symbol('__fixunsdfdi'): le.dylib_add_symbol("__fixunsdfdi", _helperlib.get_fptoui()) # Necessary for Python3 le.dylib_add_symbol("numba.round", _helperlib.get_round_even()) le.dylib_add_symbol("numba.roundf", _helperlib.get_roundf_even()) # windows symbol hacks if sys.platform.startswith('win32') and self.is32bit: _windows_symbol_hacks_32bits() # List available C-math for fname in intrinsics.INTR_MATH: if le.dylib_address_of_symbol(fname): # Exist self.cmath_provider[fname] = 'builtin' else: # Non-exist # Bind from C code imp = getattr(_helperlib, "get_%s" % fname) le.dylib_add_symbol(fname, imp()) self.cmath_provider[fname] = 'indirect'
def _windows_symbol_hacks_32bits(): # if we don't have _ftol2, bind _ftol as _ftol2 ftol2 = le.dylib_address_of_symbol("_ftol2") if not ftol2: ftol = le.dylib_address_of_symbol("_ftol") assert ftol le.dylib_add_symbol("_ftol2", ftol)
def map_math_functions(self): c_helpers = _helperlib.c_helpers for name in ['cpow', 'sdiv', 'srem', 'udiv', 'urem']: le.dylib_add_symbol("numba.math.%s" % name, c_helpers[name]) if sys.platform.startswith( 'win32') and not le.dylib_address_of_symbol('__ftol2'): le.dylib_add_symbol("__ftol2", c_helpers["fptoui"]) elif sys.platform.startswith( 'linux') and not le.dylib_address_of_symbol('__fixunsdfdi'): le.dylib_add_symbol("__fixunsdfdi", c_helpers["fptoui"]) # Necessary for Python3 le.dylib_add_symbol("numba.round", c_helpers["round_even"]) le.dylib_add_symbol("numba.roundf", c_helpers["roundf_even"]) # windows symbol hacks if sys.platform.startswith('win32') and self.is32bit: _windows_symbol_hacks_32bits() # List available C-math for fname in intrinsics.INTR_MATH: if le.dylib_address_of_symbol(fname): # Exist self.cmath_provider[fname] = 'builtin' else: # Non-exist # Bind from C code le.dylib_add_symbol(fname, c_helpers[fname]) self.cmath_provider[fname] = 'indirect'
def map_math_functions(self): c_helpers = _helperlib.c_helpers for name in ['cpow', 'sdiv', 'srem', 'udiv', 'urem']: le.dylib_add_symbol("numba.math.%s" % name, c_helpers[name]) if sys.platform.startswith('win32') and self.is32bit: # For Windows XP __ftol2 is not defined, we will just use # __ftol as a replacement. # On Windows 7, this is not necessary but will work anyway. ftol = le.dylib_address_of_symbol('_ftol') _add_missing_symbol("_ftol2", ftol) elif sys.platform.startswith('linux') and self.is32bit: _add_missing_symbol("__fixunsdfdi", c_helpers["fptoui"]) _add_missing_symbol("__fixunssfdi", c_helpers["fptouif"]) # Necessary for Python3 le.dylib_add_symbol("numba.round", c_helpers["round_even"]) le.dylib_add_symbol("numba.roundf", c_helpers["roundf_even"]) # List available C-math for fname in intrinsics.INTR_MATH: if le.dylib_address_of_symbol(fname): # Exist self.cmath_provider[fname] = 'builtin' else: # Non-exist # Bind from C code le.dylib_add_symbol(fname, c_helpers[fname]) self.cmath_provider[fname] = 'indirect'
def remove_native_function(self, func): """ Remove internal references to nonpython mode function *func*. KeyError is raised if the function isn't known to us. """ name, ptr = self.native_funcs.pop(func) # If the symbol wasn't redefined, NULL it out. # (otherwise, it means the corresponding Python function was # re-compiled, and the new target is still alive) if le.dylib_address_of_symbol(name) == ptr: le.dylib_add_symbol(name, 0)
def _add_missing_symbol(symbol, addr): """Add missing symbol into LLVM internal symtab """ if not le.dylib_address_of_symbol(symbol): le.dylib_add_symbol(symbol, addr)