A formal model and specification language for procedure calling conventions
POPL '95 Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
H/Direct: a binary foreign language interface for Haskell
ICFP '98 Proceedings of the third ACM SIGPLAN international conference on Functional programming
A Portable and Optimizing Back End for the SML/NJ Compiler
CC '94 Proceedings of the 5th International Conference on Compiler Construction
Journal of Functional Programming
Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
Hi-index | 0.00 |
The importance of providing a mechanism to call C functions from high-level languages has been understood for many years and, these days, almost all statically-typed high-level-language implementations provide such a mechanism. One glaring omission, however, has been support for calling variadic C functions, such as printf. Variadic functions have been ignored because it is not obvious how to give static types to them and because it is not clear how to generate calling sequence when the arguments to the function may not be known until runtime. In this paper, we address this longstanding omission with an extension to the NLFFI foreign-interface framework used by Standard ML of New Jersey (SML/NJ) and the MLton SML compiler. We describe two different ways of typing variadic functions in NLFFI and an implementation technique based on the idea of using state machines to describe calling conventions. Our implementation is easily retargeted to new architectures and ABIs, and can also be easily added to any HOT language implementation that supports calling C functions.