2 * This source file is part of the Swift.org open source project
4 * Copyright (c) 2015 Apple Inc. and the Swift project authors
6 * Licensed under Apache License v2.0 with Runtime Library Exception
8 * See http://swift.org/LICENSE.txt for license information
9 * See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
13 // forward declarations for functions we are stubbing out
14 // in the intial linux port.
16 #ifndef __DISPATCH__STUBS__INTERNAL
17 #define __DISPATCH__STUBS__INTERNAL
19 // marker for hacks we have made to make progress
20 #define __LINUX_PORT_HDD__ 1
23 * Stub out defines for some mach types and related macros
26 typedef uint32_t mach_port_t
;
28 #define MACH_PORT_NULL (0)
29 #define MACH_PORT_DEAD (-1)
31 typedef uint32_t mach_error_t
;
33 typedef uint32_t mach_vm_size_t
;
35 typedef uint32_t mach_msg_return_t
;
37 typedef uint32_t mach_msg_bits_t
;
39 typedef uintptr_t mach_vm_address_t
;
41 typedef uint32_t dispatch_mach_msg_t
;
43 typedef uint32_t dispatch_mach_t
;
45 typedef uint32_t dispatch_mach_reason_t
;
47 typedef uint32_t voucher_activity_mode_t
;
49 typedef uint32_t voucher_activity_trace_id_t
;
51 typedef uint32_t voucher_activity_id_t
;
53 typedef uint32_t _voucher_activity_buffer_hook_t
;;
55 typedef uint32_t voucher_activity_flag_t
;
57 typedef struct { } mach_msg_header_t
;
60 typedef void (*dispatch_mach_handler_function_t
)(void*, dispatch_mach_reason_t
,
61 dispatch_mach_msg_t
, mach_error_t
);
63 typedef void (*dispatch_mach_msg_destructor_t
)(void*);
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)
69 * Stub out defines for other missing types
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)
78 // SIZE_T_MAX should not be hardcoded like this here.
79 #define SIZE_T_MAX (0x7fffffff)
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??
84 // The following values are passed as part of the EVFILT_TIMER requests
86 #define IGNORE_KEVENT64_EXT /* will force the kevent64_s.ext[] to not be used -> leeway ignored */
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
96 // need to catch the following usage if it happens ..
97 // we simply return '0' as a value probably not correct
99 #define NOTE_VM_PRESSURE ({LINUX_PORT_ERROR(); 0;})