Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/games/aestats/files/fbsd_stub.c
16461 views
1
#include <sys/param.h>
2
#include <sys/stat.h>
3
#include <runetype.h>
4
#include <stdlib.h>
5
6
long int
7
__strtol_internal(__const char *__restrict __nptr, char **__restrict __endptr,
8
int __base, int __group)
9
{
10
11
return (strtol(__nptr, __endptr, __base));
12
}
13
14
/*
15
* This one is special. We cannot simply call stat(2) and be done with it:
16
* Linux' and FreeBSD's ``struct stat'' have different sizes (88 and 96,
17
* respectively per my testing here, but YMMV), leading us to core dump
18
* if we do so. Instead, copy only mtime field from FreeBSD's ``struct
19
* stat'' into proper place of provided Linux' ``struct stat'' buffer.
20
*/
21
struct __linux_stat {
22
char pad0[0x40];
23
struct timespec __st_mtim;
24
char pad1[0x10];
25
};
26
27
int
28
__xstat(int __ver, __const char *__filename, struct __linux_stat *__stat_buf)
29
{
30
struct stat sb;
31
int err = stat(__filename, &sb);
32
33
if (!err)
34
__stat_buf->__st_mtim = sb.st_mtimespec;
35
return (err);
36
}
37
38
const int *__ctype_tolower;
39
const int *__ctype_toupper;
40
41
static void __fbsd_prepare(void) __attribute__ ((constructor));
42
43
static void
44
__fbsd_prepare(void)
45
{
46
#if __FreeBSD_version > 502118
47
__ctype_tolower = _CurrentRuneLocale->__maplower;
48
__ctype_toupper = _CurrentRuneLocale->__mapupper;
49
#else
50
__ctype_tolower = _CurrentRuneLocale->maplower;
51
__ctype_toupper = _CurrentRuneLocale->mapupper;
52
#endif
53
}
54
55