The estimable Christopher Wellons has another great Emacs post. This time he describes an Emacs Foreign Function Interface that he wrote. He considers it a proof of concept and not quite complete but he shows several examples of using it to call external library functions.
The FFI is implemented as a package that communicates with libffi through a pipe. As Wellons points out that has both advantages and disadvantages but it does appear to work well. Read Wellons' post for the details on how things work and what you can do with it.
If you've wished for an FFI for Emacs take a look at the post and the package. Because it's implemented as a package, it's available now and doesn't need to be integrated into Emacs core. Very impressive work, I think.