]> git.saurik.com Git - apple/libdispatch.git/blob - src/shims/linux_stubs.h
libdispatch-703.1.4.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 // marker for hacks we have made to make progress
20 #define __LINUX_PORT_HDD__ 1
21
22 /*
23 * Stub out defines for some mach types and related macros
24 */
25
26 typedef uint32_t mach_port_t;
27
28 #define MACH_PORT_NULL (0)
29 #define MACH_PORT_DEAD (-1)
30
31 typedef uint32_t mach_error_t;
32
33 typedef uint32_t mach_vm_size_t;
34
35 typedef uint32_t mach_msg_return_t;
36
37 typedef uint32_t mach_msg_bits_t;
38
39 typedef uintptr_t mach_vm_address_t;
40
41 typedef uint32_t dispatch_mach_msg_t;
42
43 typedef uint32_t dispatch_mach_t;
44
45 typedef uint32_t dispatch_mach_reason_t;
46
47 typedef uint32_t voucher_activity_mode_t;
48
49 typedef uint32_t voucher_activity_trace_id_t;
50
51 typedef uint32_t voucher_activity_id_t;
52
53 typedef uint32_t _voucher_activity_buffer_hook_t;;
54
55 typedef uint32_t voucher_activity_flag_t;
56
57 typedef struct { } mach_msg_header_t;
58
59
60 typedef void (*dispatch_mach_handler_function_t)(void*, dispatch_mach_reason_t,
61 dispatch_mach_msg_t, mach_error_t);
62
63 typedef void (*dispatch_mach_msg_destructor_t)(void*);
64
65 // Print a warning when an unported code path executes.
66 #define LINUX_PORT_ERROR() do { printf("LINUX_PORT_ERROR_CALLED %s:%d: %s\n",__FILE__,__LINE__,__FUNCTION__); } while (0)
67
68 /*
69 * Stub out defines for other missing types
70 */
71
72 #if __linux__
73 // we fall back to use kevent
74 #define kevent64_s kevent
75 #define kevent64(kq,cl,nc,el,ne,f,to) kevent(kq,cl,nc,el,ne,to)
76 #endif
77
78 // SIZE_T_MAX should not be hardcoded like this here.
79 #define SIZE_T_MAX (0x7fffffff)
80
81 // Define to 0 the NOTE_ values that are not present on Linux.
82 // Revisit this...would it be better to ifdef out the uses instead??
83
84 // The following values are passed as part of the EVFILT_TIMER requests
85
86 #define IGNORE_KEVENT64_EXT /* will force the kevent64_s.ext[] to not be used -> leeway ignored */
87
88 #define NOTE_SECONDS 0x01
89 #define NOTE_USECONDS 0x02
90 #define NOTE_NSECONDS 0x04
91 #define NOTE_ABSOLUTE 0x08
92 #define NOTE_CRITICAL 0x10
93 #define NOTE_BACKGROUND 0x20
94 #define NOTE_LEEWAY 0x40
95
96 // need to catch the following usage if it happens ..
97 // we simply return '0' as a value probably not correct
98
99 #define NOTE_VM_PRESSURE ({LINUX_PORT_ERROR(); 0;})
100
101 #endif