define-stubless-foreign/define-retrying-syscall in syscalls.scm.
Be warned: the scsh-version he started from was neither 0.5.1 nor 0.5.2, but something in between !