1# test ffi float support 2try: 3 import ffi 4except ImportError: 5 print("SKIP") 6 raise SystemExit 7 8 9def ffi_open(names): 10 err = None 11 for n in names: 12 try: 13 mod = ffi.open(n) 14 return mod 15 except OSError as e: 16 err = e 17 raise err 18 19 20libm = ffi_open(("libm.so", "libm.so.6", "libc.so.0", "libc.so.6", "libc.dylib")) 21 22# Some libc's implement tgammaf as header macro with tgamma(), so don't assume 23# it'll be in library. 24try: 25 tgammaf = libm.func("f", "tgammaf", "f") 26except OSError: 27 print("SKIP") 28 raise SystemExit 29 30for fun in (tgammaf,): 31 for val in (0.5, 1, 1.0, 1.5, 4, 4.0): 32 print("%.6f" % fun(val)) 33