OXYGENHUB
◆ main enhanced-x16-emulator / src / compat.h
985 B · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
1
// Commander X16 Emulator
2
// Platform compatibility header for MSVC/Windows builds
3
// Include this instead of <unistd.h> for cross-platform support
4
5
#ifndef COMPAT_H
6
#define COMPAT_H
7
8
#include <limits.h>
9
10
// Ensure PATH_MAX is defined
11
#ifndef PATH_MAX
12
#ifdef _MAX_PATH
13
#define PATH_MAX _MAX_PATH
14
#else
15
#define PATH_MAX 260
16
#endif
17
#endif
18
19
#ifdef _MSC_VER
20
21
#include <io.h>
22
#include <direct.h>
23
#include <windows.h>
24
#include <stdlib.h>
25
26
#define access _access
27
#define F_OK   0
28
29
#define sleep(sec)   Sleep((sec) * 1000)
30
#define usleep(usec) Sleep((usec) / 1000)
31
32
#define localtime_r(src, dst) (!localtime_s((dst), (src)))
33
34
#define getcwd  _getcwd
35
#define chdir   _chdir
36
37
static inline char *realpath(const char *path, char *resolved_path)
38
{
39
	char *ret = _fullpath(resolved_path, path, PATH_MAX);
40
	if (ret && _access(ret, 0) && errno == ENOENT) {
41
		if (resolved_path == NULL)
42
			free(ret);
43
		return NULL;
44
	}
45
	return ret;
46
}
47
48
#else
49
50
#include <unistd.h>
51
52
#endif // _MSC_VER
53
54
#endif // COMPAT_H