Path: blob/main/games/aestats/files/fbsd_stub.c
16461 views
#include <sys/param.h>1#include <sys/stat.h>2#include <runetype.h>3#include <stdlib.h>45long int6__strtol_internal(__const char *__restrict __nptr, char **__restrict __endptr,7int __base, int __group)8{910return (strtol(__nptr, __endptr, __base));11}1213/*14* This one is special. We cannot simply call stat(2) and be done with it:15* Linux' and FreeBSD's ``struct stat'' have different sizes (88 and 96,16* respectively per my testing here, but YMMV), leading us to core dump17* if we do so. Instead, copy only mtime field from FreeBSD's ``struct18* stat'' into proper place of provided Linux' ``struct stat'' buffer.19*/20struct __linux_stat {21char pad0[0x40];22struct timespec __st_mtim;23char pad1[0x10];24};2526int27__xstat(int __ver, __const char *__filename, struct __linux_stat *__stat_buf)28{29struct stat sb;30int err = stat(__filename, &sb);3132if (!err)33__stat_buf->__st_mtim = sb.st_mtimespec;34return (err);35}3637const int *__ctype_tolower;38const int *__ctype_toupper;3940static void __fbsd_prepare(void) __attribute__ ((constructor));4142static void43__fbsd_prepare(void)44{45#if __FreeBSD_version > 50211846__ctype_tolower = _CurrentRuneLocale->__maplower;47__ctype_toupper = _CurrentRuneLocale->__mapupper;48#else49__ctype_tolower = _CurrentRuneLocale->maplower;50__ctype_toupper = _CurrentRuneLocale->mapupper;51#endif52}535455