]> git.saurik.com Git - apple/libdispatch.git/blob - src/shims/linux_stubs.h
libdispatch-703.50.37.tar.gz
[apple/libdispatch.git] / src / shims / linux_stubs.h
1 /*
2 * This source file is part of the Swift.org open source project
3 *
4 * Copyright (c) 2015 Apple Inc. and the Swift project authors
5 *
6 * Licensed under Apache License v2.0 with Runtime Library Exception
7 *
8 * See http://swift.org/LICENSE.txt for license information
9 * See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10 *
11 */
12
13 // forward declarations for functions we are stubbing out
14 // in the intial linux port.
15
16 #ifndef __DISPATCH__STUBS__INTERNAL
17 #define __DISPATCH__STUBS__INTERNAL
18
19 /*
20 * Stub out defines for some mach types and related macros
21 */
22
23 typedef uint32_t mach_port_t;
24
25 #define MACH_PORT_NULL (0)
26 #define MACH_PORT_DEAD (-1)
27
28 typedef uint32_t mach_error_t;
29
30 typedef uint32_t mach_vm_size_t;
31
32 typedef uint32_t mach_msg_return_t;
33
34 typedef uint32_t mach_msg_bits_t;
35
36 typedef uintptr_t mach_vm_address_t;
37
38 typedef uint32_t dispatch_mach_msg_t;
39
40 typedef uint32_t dispatch_mach_t;
41
42 typedef uint32_t dispatch_mach_reason_t;
43
44 typedef uint32_t voucher_activity_mode_t;
45
46 typedef uint32_t voucher_activity_trace_id_t;
47
48 typedef uint32_t voucher_activity_id_t;
49
50 typedef uint32_t voucher_activity_flag_t;
51
52 typedef struct { } mach_msg_header_t;
53
54
55 typedef void (*dispatch_mach_handler_function_t)(void*, dispatch_mach_reason_t,
56 dispatch_mach_msg_t, mach_error_t);
57
58 typedef void (*dispatch_mach_msg_destructor_t)(void*);
59
60 // Print a warning when an unported code path executes.
61 #define LINUX_PORT_ERROR() do { printf("LINUX_PORT_ERROR_CALLED %s:%d: %s\n",__FILE__,__LINE__,__FUNCTION__); } while (0)
62
63 /*
64 * Stub out defines for other missing types
65 */
66
67 #if __linux__
68 // we fall back to use kevent
69 #define kevent64_s kevent
70 #define kevent64(kq,cl,nc,el,ne,f,to) kevent(kq,cl,nc,el,ne,to)
71 #endif
72
73 // SIZE_T_MAX should not be hardcoded like this here.
74 #define SIZE_T_MAX (0x7fffffff)
75
76 // Define to 0 the NOTE_ values that are not present on Linux.
77 // Revisit this...would it be better to ifdef out the uses instead??
78
79 // The following values are passed as part of the EVFILT_TIMER requests
80
81 #define IGNORE_KEVENT64_EXT /* will force the kevent64_s.ext[] to not be used -> leeway ignored */
82
83 #ifndef NOTE_SECONDS
84 #define NOTE_SECONDS 0x01
85 #define NOTE_USECONDS 0x02
86 #define NOTE_NSECONDS 0x04
87 #define NOTE_ABSOLUTE 0x08
88 #define KEVENT_NSEC_NOT_SUPPORTED
89 #endif
90 #define NOTE_CRITICAL 0x10
91 #define NOTE_BACKGROUND 0x20
92 #define NOTE_LEEWAY 0x40
93
94 // need to catch the following usage if it happens ..
95 // we simply return '0' as a value probably not correct
96
97 #define NOTE_VM_PRESSURE ({LINUX_PORT_ERROR(); 0;})
98
99 #endif