Declared in SWI-Prolog.h as follows:
typedef foreign_t (*pl_function_t)(); PL_EXPORT(int) PL_register_foreign(const char *name, int arity, pl_function_t func, int flags, ...);
and defined in pl-fli.c
although with a different argument list:
int PL_register_foreign(const char *name, int arity, Func f, int flags, ...)
In shared libraries, this function is called from a specially designated C function that is called on module load so that the predicates implemented implemented by the module become visible. See: https://eu.swi-prolog.org/pldoc/man?section=foreignlink