Skip to content

Commit f22bc4b

Browse files
committed
header files to stub out types/functions for linux port
1 parent a60acd6 commit f22bc4b

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

os/base.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Stub out Apple internal header file to redirect to linux_base.h.
2+
// Maybe not the best fix in the long run, but avoids having to #ifdef
3+
// the include of <os/base.h> in all of the other files....
4+
5+
#ifndef __OS_BASE__
6+
#define __OS_BASE__
7+
8+
#include <os/linux_base.h>
9+
10+
#endif

os/linux_base.h

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
#ifndef __OS_LINUX_BASE__
3+
#define __OS_LINUX_BASE__
4+
5+
6+
// marker for hacks we have made to make progress
7+
#define __LINUX_PORT_HDD__ 1
8+
9+
/*
10+
* Stub out defines for some mach types and related macros
11+
*/
12+
13+
typedef uint32_t mach_port_t;
14+
15+
#define MACH_PORT_NULL 0
16+
#define MACH_PORT_DEAD -1
17+
18+
19+
typedef uint32_t mach_error_t;
20+
21+
typedef uint32_t dispatch_mach_msg_t;
22+
23+
typedef uint32_t dispatch_mach_t;
24+
25+
typedef uint32_t dispatch_mach_reason_t;
26+
27+
typedef uint32_t mach_vm_size_t;
28+
29+
typedef uintptr_t mach_vm_address_t;
30+
31+
typedef struct
32+
{
33+
} mach_msg_header_t;
34+
35+
36+
typedef void (*dispatch_mach_handler_function_t)(void*);
37+
typedef void (*dispatch_mach_msg_destructor_t)(void*);
38+
39+
/*
40+
* Stub out defines for other missing types
41+
*/
42+
43+
struct kevent64_s
44+
{
45+
};
46+
47+
/*
48+
* Stub out misc linking and compilation attributes
49+
*/
50+
51+
#ifdef OS_EXPORT
52+
#undef OS_EXPORT
53+
#endif
54+
#define OS_EXPORT
55+
56+
#ifdef DISPATCH_EXPORT
57+
#undef DISPATCH_EXPORT
58+
#endif
59+
#define DISPATCH_EXPORT
60+
61+
#ifdef DISPATCH_NONNULL_ALL
62+
#undef DISPATCH_NONNULL_ALL
63+
#endif
64+
#define DISPATCH_NONNULL_ALL
65+
66+
#ifdef OS_WARN_RESULT_NEEDS_RELEASE
67+
#undef OS_WARN_RESULT_NEEDS_RELEASE
68+
#endif
69+
70+
#ifdef OS_WARN_RESULT
71+
#undef OS_WARN_RESULT
72+
#endif
73+
#define OS_WARN_RESULT
74+
75+
#ifdef OS_NOTHROW
76+
#undef OS_NOTHROW
77+
#endif
78+
#define OS_NOTHROW
79+
80+
81+
// NOTE (Dave), these and similar macros come from Availabity.h on OS X
82+
#define __OSX_AVAILABLE_BUT_DEPRECATED(a,b,c,d) //
83+
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(a,b,c,d,msg) //
84+
85+
86+
// Print a warning when an unported code path executes.
87+
#define LINUX_PORT_ERROR() do { printf("LINUX_PORT_ERROR_CALLED %s:%d: %s\n",__FILE__,__LINE__,__FUNCTION__); } while (0)
88+
89+
90+
// Functions we are stubbing out
91+
#include<os/stubs.h>
92+
93+
94+
#endif /* __OS_LINUX_BASE__ */

os/stubs.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef __OS_STUBS__
2+
#define __OS_STUBS__
3+
4+
5+
6+
int sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
7+
void *newp, size_t newlen);
8+
9+
mach_port_t pthread_mach_thread_np();
10+
11+
mach_port_t mach_task_self();
12+
13+
void mach_vm_deallocate(mach_port_t, mach_vm_address_t, mach_vm_size_t);
14+
15+
#endif
16+
17+

0 commit comments

Comments
 (0)