Searching FPC source code:
$ grep -ir mkstemp *
packages/gtk2/src/glib/gfileutils.inc:function g_mkstemp(tmpl:Pchar):longint;cdecl;external gliblib name 'g_mkstemp';
packages/libc/src/stdlibh.inc:function mkstemp(__template:Pchar):longint;cdecl;external clib name 'mkstemp';
packages/libc/src/stdlibh.inc:function mkstemp64(__template:Pchar):longint;cdecl;external clib name 'mkstemp64';
rtl/netwlibc/libc.imp: mkstemp,
rtl/netwlibc/libc.pp:function mkstemp(_para1:Pchar):longint;cdecl;external libc_nlm name 'mkstemp';
$ grep -ir stdlibh.inc *
packages/libc/fpmake.pp: AddInclude('stdlibh.inc');
packages/libc/src/libc.pp:{$i stdlibh.inc} // stdlib.h
seems defined in libc unit. It's a deprecated unit, though. You might want to use the native Pascal cross platform
SysUtils.GetTempDir and
SysUtils.GetTempFileName, although for setting the permission and ownership you will still need *nix specific calls to
BaseUnix.fpChown and
BaseUnix.fpChmod.