Move foreign and foreign_value out of the Ctypes module.
Implement them using the external interfaces of Dl and Ctypes.