##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: January 2017 # Modified: 2017-01-12/20:14-0500 # # Tectonics: # bacon -f basicnative.bac # unicon -s baconffi.icn -x ##+ # # baconffi.icn, test calling BaCon without wrapper with libffi # $include "natives.inc" procedure main() # will be RTLD_LAZY | RTLD_GLOBAL (so add to the search path) addLibrary := loadfunc("./uniffi.so", "addLibrary") # allow arbitrary C functions, marshalled by libffi native := loadfunc("./uniffi.so", "ffi") # add the testing functions to the dlsym search path, # the handle is somewhat irrelevant, but won't be soonish dlHandle := addLibrary("./basicnative.so") # pass two integers, get back a sum write("Unicon calling BaCon function \"basic\" with 40 and 2") ans := native("basic", TYPEINT, 40, 2) write("Unicon got ", ans) # pass two integers that create an accumulator in assembly dlHandle := addLibrary("./asmmix.so") write("Unicon calling \"asmmix\" with 2 and 4") ans := native("asmmix", TYPEINT, 2, 4) write("Unicon accumulator of 2+4 + 2+4 + 2: ", ans) end