Move more stuff into libc
Fix some function signatures in libc and change file extensions from .cpp to .c
Update patch