|
| 1 | +/* |
| 2 | + * @APPLE_APACHE_LICENSE_HEADER_START@ |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * @APPLE_APACHE_LICENSE_HEADER_END@ |
| 17 | + */ |
| 18 | + |
| 19 | +#ifndef __OS_LINUX_BASE__ |
| 20 | +#define __OS_LINUX_BASE__ |
| 21 | + |
| 22 | +// #include <sys/event.h> |
| 23 | + |
| 24 | +// marker for hacks we have made to make progress |
| 25 | +#define __LINUX_PORT_HDD__ 1 |
| 26 | + |
| 27 | +/* |
| 28 | + * Stub out defines for some mach types and related macros |
| 29 | + */ |
| 30 | + |
| 31 | +typedef uint32_t mach_port_t; |
| 32 | + |
| 33 | +#define MACH_PORT_NULL (0) |
| 34 | +#define MACH_PORT_DEAD (-1) |
| 35 | + |
| 36 | +#define EVFILT_MACHPORT (-8) |
| 37 | + |
| 38 | +typedef uint32_t mach_error_t; |
| 39 | + |
| 40 | +typedef uint32_t mach_vm_size_t; |
| 41 | + |
| 42 | +typedef uint32_t mach_msg_return_t; |
| 43 | + |
| 44 | +typedef uintptr_t mach_vm_address_t; |
| 45 | + |
| 46 | +typedef uint32_t dispatch_mach_msg_t; |
| 47 | + |
| 48 | +typedef uint32_t dispatch_mach_t; |
| 49 | + |
| 50 | +typedef uint32_t dispatch_mach_reason_t; |
| 51 | + |
| 52 | +typedef uint32_t voucher_activity_mode_t; |
| 53 | + |
| 54 | +typedef uint32_t voucher_activity_trace_id_t; |
| 55 | + |
| 56 | +typedef uint32_t voucher_activity_id_t; |
| 57 | + |
| 58 | +typedef uint32_t _voucher_activity_buffer_hook_t;; |
| 59 | + |
| 60 | +typedef uint32_t voucher_activity_flag_t; |
| 61 | + |
| 62 | +typedef struct |
| 63 | +{ |
| 64 | +} mach_msg_header_t; |
| 65 | + |
| 66 | + |
| 67 | +typedef void (*dispatch_mach_handler_function_t)(void*, dispatch_mach_reason_t, |
| 68 | + dispatch_mach_msg_t, mach_error_t); |
| 69 | + |
| 70 | +typedef void (*dispatch_mach_msg_destructor_t)(void*); |
| 71 | + |
| 72 | +typedef uint32_t voucher_activity_mode_t; |
| 73 | + |
| 74 | +struct voucher_offsets_s { |
| 75 | + uint32_t vo_version; |
| 76 | +}; |
| 77 | + |
| 78 | + |
| 79 | +/* |
| 80 | + * Stub out defines for other missing types |
| 81 | + */ |
| 82 | + |
| 83 | +// Pulled from OS X man page for kevent |
| 84 | +struct kevent64_s { |
| 85 | + uint64_t ident; /* identifier for this event */ |
| 86 | + int16_t filter; /* filter for event */ |
| 87 | + uint16_t flags; /* general flags */ |
| 88 | + uint32_t fflags; /* filter-specific flags */ |
| 89 | + int64_t data; /* filter-specific data */ |
| 90 | + uint64_t udata; /* opaque user data identifier */ |
| 91 | + uint64_t ext[2]; /* filter-specific extensions */ |
| 92 | +}; |
| 93 | + |
| 94 | + |
| 95 | +// PAGE_SIZE and SIZE_T_MAX should not be hardcoded like this here. |
| 96 | +#define PAGE_SIZE (4096) |
| 97 | +#define SIZE_T_MAX (0x7fffffff) |
| 98 | + |
| 99 | +// Define to 0 the NOTE_ values that are not present on Linux. |
| 100 | +// Revisit this...would it be better to ifdef out the uses instead?? |
| 101 | +#define NOTE_VM_PRESSURE 0 |
| 102 | +#define NOTE_ABSOLUTE 0 |
| 103 | +#define NOTE_NSECONDS 0 |
| 104 | +#define NOTE_LEEWAY 0 |
| 105 | +#define NOTE_CRITICAL 0 |
| 106 | +#define NOTE_BACKGROUND 0 |
| 107 | + |
| 108 | +/* |
| 109 | + * Stub out misc linking and compilation attributes |
| 110 | + */ |
| 111 | + |
| 112 | +#ifdef OS_EXPORT |
| 113 | +#undef OS_EXPORT |
| 114 | +#endif |
| 115 | +#define OS_EXPORT |
| 116 | + |
| 117 | +#ifdef OS_WARN_RESULT_NEEDS_RELEASE |
| 118 | +#undef OS_WARN_RESULT_NEEDS_RELEASE |
| 119 | +#endif |
| 120 | + |
| 121 | +#ifdef OS_WARN_RESULT |
| 122 | +#undef OS_WARN_RESULT |
| 123 | +#endif |
| 124 | +#define OS_WARN_RESULT |
| 125 | + |
| 126 | +#ifdef OS_NOTHROW |
| 127 | +#undef OS_NOTHROW |
| 128 | +#endif |
| 129 | +#define OS_NOTHROW |
| 130 | + |
| 131 | + |
| 132 | +// These and similar macros come from Availabilty.h on OS X |
| 133 | +// Need a better way to do this long term. |
| 134 | +#define __OSX_AVAILABLE_BUT_DEPRECATED(a,b,c,d) // |
| 135 | +#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(a,b,c,d,msg) // |
| 136 | + |
| 137 | + |
| 138 | +// Print a warning when an unported code path executes. |
| 139 | +#define LINUX_PORT_ERROR() do { printf("LINUX_PORT_ERROR_CALLED %s:%d: %s\n",__FILE__,__LINE__,__FUNCTION__); } while (0) |
| 140 | + |
| 141 | + |
| 142 | +#endif /* __OS_LINUX_BASE__ */ |
0 commit comments