Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion integration_tests/test_c_interop_01.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ltypes import ccall, f64, f32
from ltypes import ccall, f32, f64, i32, i64
from math import pi

@ccall
Expand All @@ -9,7 +9,20 @@ def _lfortran_dsin(x: f64) -> f64:
def _lfortran_ssin(x: f32) -> f32:
pass

@ccall
def _lfortran_bgt32(i: i32, j: i32) -> i32:
pass

@ccall
def _lfortran_bgt64(i: i64, j: i64) -> i64:
pass

assert abs(_lfortran_dsin(pi) - 0) < 1e-12
assert abs(_lfortran_dsin(pi/2) - 1) < 1e-12
assert abs(_lfortran_ssin(pi) - 0) < 1e-6
assert abs(_lfortran_ssin(pi/2) - 1) < 1e-6

assert _lfortran_bgt32(3, 4) == 0
assert _lfortran_bgt32(4, 3) == 1
assert _lfortran_bgt64(3, 4) == 0
assert _lfortran_bgt64(4, 3) == 1
4 changes: 4 additions & 0 deletions src/runtime/ltypes/ltypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def convert_type_to_ctype(arg):
return ctypes.c_double
elif arg == f32:
return ctypes.c_float
elif arg == i64:
return ctypes.c_int64
elif arg == i32:
return ctypes.c_int32
else:
raise NotImplementedError("Type not implemented")
def get_rtlib_dir():
Expand Down