Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 1 | From 8793466326dd10b0d2dbb83c64beff5cc8c0fc7d Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 13 Jun 2018 23:11:58 -0700 |
| 4 | Subject: [PATCH] Rename poll.h to vm_poll.h |
| 5 | |
| 6 | musl libc's system headers pulls in open-vm-tools' poll.h. To avoid this |
| 7 | we rename poll.h to vm_poll.h. |
| 8 | |
| 9 | Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | --- |
| 12 | open-vm-tools/lib/asyncsocket/asyncsocket.c | 2 +- |
| 13 | open-vm-tools/lib/hgfsServer/hgfsServer.c | 2 +- |
| 14 | open-vm-tools/lib/include/asyncsocket.h | 2 +- |
| 15 | open-vm-tools/lib/include/pollImpl.h | 2 +- |
| 16 | open-vm-tools/lib/include/{poll.h => vm_poll.h} | 2 +- |
| 17 | open-vm-tools/lib/rpcIn/rpcin.c | 2 +- |
| 18 | .../services/plugins/grabbitmqProxy/grabbitmqProxyPlugin.c | 2 +- |
| 19 | 7 files changed, 7 insertions(+), 7 deletions(-) |
| 20 | rename open-vm-tools/lib/include/{poll.h => vm_poll.h} (99%) |
| 21 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 22 | --- a/open-vm-tools/lib/asyncsocket/asyncsocket.c |
| 23 | +++ b/open-vm-tools/lib/asyncsocket/asyncsocket.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | @@ -86,7 +86,7 @@ |
| 25 | #include "random.h" |
| 26 | #include "asyncsocket.h" |
| 27 | #include "asyncSocketBase.h" |
| 28 | -#include "poll.h" |
| 29 | +#include "vm_poll.h" |
| 30 | #include "log.h" |
| 31 | #include "err.h" |
| 32 | #include "hostinfo.h" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 33 | --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c |
| 34 | +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | @@ -48,7 +48,7 @@ |
| 36 | #include "hgfsServerOplock.h" |
| 37 | #include "hgfsDirNotify.h" |
| 38 | #include "userlock.h" |
| 39 | -#include "poll.h" |
| 40 | +#include "vm_poll.h" |
| 41 | #include "mutexRankLib.h" |
| 42 | #include "vm_basic_asm.h" |
| 43 | #include "unicodeOperations.h" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 44 | --- a/open-vm-tools/lib/include/asyncsocket.h |
| 45 | +++ b/open-vm-tools/lib/include/asyncsocket.h |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 46 | @@ -164,7 +164,7 @@ typedef struct AsyncSocket AsyncSocket; |
| 47 | * Or the client can specify its favorite poll class and locking behavior. |
| 48 | * Use of IVmdbPoll is only supported for regular sockets and for Attach. |
| 49 | */ |
| 50 | -#include "poll.h" |
| 51 | +#include "vm_poll.h" |
| 52 | struct IVmdbPoll; |
| 53 | typedef struct AsyncSocketPollParams { |
| 54 | int flags; /* Default 0, only POLL_FLAG_NO_BULL is valid */ |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 55 | --- a/open-vm-tools/lib/include/pollImpl.h |
| 56 | +++ b/open-vm-tools/lib/include/pollImpl.h |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 57 | @@ -44,7 +44,7 @@ |
| 58 | #define INCLUDE_ALLOW_USERLEVEL |
| 59 | #include "includeCheck.h" |
| 60 | |
| 61 | -#include "poll.h" |
| 62 | +#include "vm_poll.h" |
| 63 | #include "vm_basic_asm.h" |
| 64 | |
| 65 | #if defined(__cplusplus) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 66 | --- a/open-vm-tools/lib/include/poll.h |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame^] | 67 | +++ /dev/null |
| 68 | @@ -1,330 +0,0 @@ |
| 69 | -/********************************************************* |
| 70 | - * Copyright (C) 1998-2018 VMware, Inc. All rights reserved. |
| 71 | - * |
| 72 | - * This program is free software; you can redistribute it and/or modify it |
| 73 | - * under the terms of the GNU Lesser General Public License as published |
| 74 | - * by the Free Software Foundation version 2.1 and no later version. |
| 75 | - * |
| 76 | - * This program is distributed in the hope that it will be useful, but |
| 77 | - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 78 | - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public |
| 79 | - * License for more details. |
| 80 | - * |
| 81 | - * You should have received a copy of the GNU Lesser General Public License |
| 82 | - * along with this program; if not, write to the Free Software Foundation, Inc., |
| 83 | - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 84 | - * |
| 85 | - *********************************************************/ |
| 86 | - |
| 87 | -/********************************************************* |
| 88 | - * The contents of this file are subject to the terms of the Common |
| 89 | - * Development and Distribution License (the "License") version 1.0 |
| 90 | - * and no later version. You may not use this file except in |
| 91 | - * compliance with the License. |
| 92 | - * |
| 93 | - * You can obtain a copy of the License at |
| 94 | - * http://www.opensource.org/licenses/cddl1.php |
| 95 | - * |
| 96 | - * See the License for the specific language governing permissions |
| 97 | - * and limitations under the License. |
| 98 | - * |
| 99 | - *********************************************************/ |
| 100 | - |
| 101 | - |
| 102 | -#ifndef _POLL_H_ |
| 103 | -#define _POLL_H_ |
| 104 | - |
| 105 | -#define INCLUDE_ALLOW_USERLEVEL |
| 106 | -#define INCLUDE_ALLOW_VMCORE |
| 107 | -#include "includeCheck.h" |
| 108 | - |
| 109 | -#include "vm_basic_types.h" |
| 110 | -#include "vm_basic_defs.h" |
| 111 | -#include "vmware.h" |
| 112 | -#include "userlock.h" |
| 113 | - |
| 114 | -#if defined(__cplusplus) |
| 115 | -extern "C" { |
| 116 | -#endif |
| 117 | - |
| 118 | -#ifdef _WIN32 |
| 119 | -#define HZ 100 |
| 120 | -#elif defined linux |
| 121 | -#include <asm/param.h> |
| 122 | -#elif __APPLE__ |
| 123 | -#include <TargetConditionals.h> |
| 124 | -/* |
| 125 | - * Old SDKs don't define TARGET_OS_IPHONE at all. |
| 126 | - * New ones define it to 0 on Mac OS X, 1 on iOS. |
| 127 | - */ |
| 128 | -#if !defined(TARGET_OS_IPHONE) || TARGET_OS_IPHONE == 0 |
| 129 | -#include <sys/kernel.h> |
| 130 | -#endif |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 131 | -#include <sys/poll.h> |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame^] | 132 | -#define HZ 100 |
| 133 | -#endif |
| 134 | -#ifdef __ANDROID__ |
| 135 | -/* |
| 136 | - * <poll.h> of android should be included, but its name is same |
| 137 | - * with this file. So its content is put here to avoid conflict. |
| 138 | - */ |
| 139 | -#include <asm/poll.h> |
| 140 | -#define HZ 100 |
| 141 | -typedef unsigned int nfds_t; |
| 142 | -int poll(struct pollfd *, nfds_t, long); |
| 143 | -#endif |
| 144 | - |
| 145 | - |
| 146 | -/* |
| 147 | - * Poll event types: each type has a different reason for firing, |
| 148 | - * or condition that must be met before firing. |
| 149 | - */ |
| 150 | - |
| 151 | -typedef enum { |
| 152 | - /* |
| 153 | - * Actual Poll queue types against which you can register callbacks. |
| 154 | - */ |
| 155 | - POLL_VIRTUALREALTIME = -1, /* Negative because it doesn't have its own Q */ |
| 156 | - POLL_VTIME = 0, |
| 157 | - POLL_REALTIME, |
| 158 | - POLL_DEVICE, |
| 159 | - POLL_MAIN_LOOP, |
| 160 | - POLL_NUM_QUEUES |
| 161 | -} PollEventType; |
| 162 | - |
| 163 | - |
| 164 | -/* |
| 165 | - * Classes of events |
| 166 | - * |
| 167 | - * These are the predefined classes. More can be declared |
| 168 | - * with Poll_AllocClass(). |
| 169 | - */ |
| 170 | - |
| 171 | -typedef enum PollClass { |
| 172 | - POLL_CLASS_MAIN, |
| 173 | - POLL_CLASS_PAUSE, |
| 174 | - POLL_CLASS_IPC, |
| 175 | - POLL_CLASS_CPT, |
| 176 | - POLL_CLASS_MKS, |
| 177 | - POLL_FIXED_CLASSES, |
| 178 | - POLL_DEFAULT_FIXED_CLASSES, |
| 179 | - /* Size enum to maximum */ |
| 180 | - POLL_MAX_CLASSES = 31, |
| 181 | -} PollClass; |
| 182 | - |
| 183 | -/* |
| 184 | - * Do not use; Special pseudo private poll class supported by |
| 185 | - * PollDefault only |
| 186 | - */ |
| 187 | -#define POLL_DEFAULT_CLASS_NET POLL_FIXED_CLASSES |
| 188 | -#define POLL_DEFAULT_CS_NET PollClassSet_Singleton(POLL_DEFAULT_CLASS_NET) |
| 189 | - |
| 190 | -/* |
| 191 | - * Each callback is registered in a set of classes |
| 192 | - */ |
| 193 | - |
| 194 | -typedef struct PollClassSet { |
| 195 | - uintptr_t bits; |
| 196 | -} PollClassSet; |
| 197 | - |
| 198 | -/* An empty PollClassSet. */ |
| 199 | -static INLINE PollClassSet |
| 200 | -PollClassSet_Empty(void) |
| 201 | -{ |
| 202 | - PollClassSet set = { 0 }; |
| 203 | - return set; |
| 204 | -} |
| 205 | - |
| 206 | -/* A PollClassSet with the single member. */ |
| 207 | -static INLINE PollClassSet |
| 208 | -PollClassSet_Singleton(PollClass c) |
| 209 | -{ |
| 210 | - PollClassSet s = PollClassSet_Empty(); |
| 211 | - |
| 212 | - ASSERT_ON_COMPILE(POLL_MAX_CLASSES < sizeof s.bits * 8); |
| 213 | - ASSERT(c < POLL_MAX_CLASSES); |
| 214 | - |
| 215 | - s.bits = CONST3264U(1) << c; |
| 216 | - return s; |
| 217 | -} |
| 218 | - |
| 219 | -/* Combine two PollClassSets. */ |
| 220 | -static INLINE PollClassSet |
| 221 | -PollClassSet_Union(PollClassSet lhs, PollClassSet rhs) |
| 222 | -{ |
| 223 | - PollClassSet set; |
| 224 | - set.bits = lhs.bits | rhs.bits; |
| 225 | - return set; |
| 226 | -} |
| 227 | - |
| 228 | -/* Add single class to PollClassSet. */ |
| 229 | -static INLINE PollClassSet |
| 230 | -PollClassSet_Include(PollClassSet set, PollClass c) |
| 231 | -{ |
| 232 | - return PollClassSet_Union(set, PollClassSet_Singleton(c)); |
| 233 | -} |
| 234 | - |
| 235 | - |
| 236 | -#define POLL_CS_MAIN PollClassSet_Singleton(POLL_CLASS_MAIN) |
| 237 | -#define POLL_CS_PAUSE PollClassSet_Union(POLL_CS_MAIN, \ |
| 238 | - PollClassSet_Singleton(POLL_CLASS_PAUSE)) |
| 239 | -#define POLL_CS_CPT PollClassSet_Union(POLL_CS_PAUSE, \ |
| 240 | - PollClassSet_Singleton(POLL_CLASS_CPT)) |
| 241 | -#define POLL_CS_IPC PollClassSet_Union(POLL_CS_CPT, \ |
| 242 | - PollClassSet_Singleton(POLL_CLASS_IPC)) |
| 243 | -#define POLL_CS_VMDB POLL_CS_PAUSE /* POLL_CLASS_VMDB is retired */ |
| 244 | -#define POLL_CS_MKS PollClassSet_Singleton(POLL_CLASS_MKS) |
| 245 | -/* |
| 246 | - * DANGER. You don't need POLL_CS_ALWAYS. Really. So don't use it. |
| 247 | - */ |
| 248 | -#define POLL_CS_ALWAYS PollClassSet_Union(POLL_CS_CPT, POLL_CS_IPC) |
| 249 | - |
| 250 | -/* |
| 251 | - * Poll class-set taxonomy: |
| 252 | - * POLL_CS_MAIN |
| 253 | - * - Unless you NEED another class, use POLL_CS_MAIN. |
| 254 | - * POLL_CS_PAUSE |
| 255 | - * - For callbacks that must occur even if the guest is paused. |
| 256 | - * Most VMDB or Foundry commands are in this category. |
| 257 | - * POLL_CS_CPT |
| 258 | - * - Only for callbacks which can trigger intermediate Checkpoint |
| 259 | - * transitions. |
| 260 | - * The ONLY such callback is Migrate. |
| 261 | - * POLL_CS_IPC |
| 262 | - * - Only for callbacks which can contain Msg_(Post|Hint|Question) |
| 263 | - * responses, and for signal handlers (why)? |
| 264 | - * Vigor, VMDB, and Foundry can contain Msg_* responses. |
| 265 | - * POLL_CS_MKS |
| 266 | - * - Callback runs in MKS thread. |
| 267 | - * POLL_CS_ALWAYS |
| 268 | - * - Only for events that must be processed immediately. |
| 269 | - * The ONLY such callback is OvhdMemVmxSizeCheck. |
| 270 | - */ |
| 271 | - |
| 272 | - |
| 273 | -/* |
| 274 | - * Poll_Callback flags |
| 275 | - */ |
| 276 | - |
| 277 | -#define POLL_FLAG_PERIODIC 0x01 // keep after firing |
| 278 | -#define POLL_FLAG_REMOVE_AT_POWEROFF 0x02 // self-explanatory |
| 279 | -#define POLL_FLAG_READ 0x04 // device is ready for reading |
| 280 | -#define POLL_FLAG_WRITE 0x08 // device is ready for writing |
| 281 | -#define POLL_FLAG_SOCKET 0x10 // device is a Windows socket |
| 282 | -#define POLL_FLAG_NO_BULL 0x20 // callback does its own locking |
| 283 | -#define POLL_FLAG_WINSOCK 0x40 // Winsock style write events |
| 284 | -#define POLL_FLAG_FD 0x80 // device is a Windows file descriptor. |
| 285 | -#define POLL_FLAG_ACCEPT_INVALID_FDS 0x100 // For broken 3rd party libs, e.g. curl |
| 286 | -#define POLL_FLAG_THUNK_TO_WND 0x200 // thunk callback to window message loop |
| 287 | - |
| 288 | - |
| 289 | -typedef void (*PollerFunction)(void *clientData); |
| 290 | -typedef void (*PollerFireWrapper)(PollerFunction func, |
| 291 | - void *funcData, |
| 292 | - void *wrapperData); |
| 293 | -typedef Bool (*PollerErrorFn)(const char *errorStr); |
| 294 | - |
| 295 | -/* |
| 296 | - * Initialisers: |
| 297 | - * |
| 298 | - * For the sake of convenience, we declare the initialisers |
| 299 | - * for custom implmentations here, even though the actual |
| 300 | - * implementations are distinct from the core poll code. |
| 301 | - */ |
| 302 | - |
| 303 | -typedef struct PollOptions { |
| 304 | - Bool locked; // Use internal MXUser for locking |
| 305 | - Bool allowFullQueue; // Don't assert when device event queue is full. |
| 306 | - VThreadID windowsMsgThread; // thread that processes Windows messages |
| 307 | - PollerFireWrapper fireWrapperFn; // optional; may be useful for stats |
| 308 | - void *fireWrapperData; // optional |
| 309 | - PollerErrorFn errorFn; // optional; called upon unrecoverable error |
| 310 | -} PollOptions; |
| 311 | - |
| 312 | - |
| 313 | -void Poll_InitDefault(void); |
| 314 | -void Poll_InitDefaultEx(const PollOptions *opts); |
| 315 | -void Poll_InitGtk(void); // On top of glib for Linux |
| 316 | -void Poll_InitCF(void); // On top of CoreFoundation for OSX |
| 317 | - |
| 318 | - |
| 319 | -/* |
| 320 | - * Functions |
| 321 | - */ |
| 322 | -int Poll_SocketPair(Bool vmci, Bool stream, int fds[2]); |
| 323 | -void Poll_Loop(Bool loop, Bool *exit, PollClass c); |
| 324 | -void Poll_LoopTimeout(Bool loop, Bool *exit, PollClass c, int timeout); |
| 325 | -Bool Poll_LockingEnabled(void); |
| 326 | -void Poll_Exit(void); |
| 327 | - |
| 328 | - |
| 329 | -/* |
| 330 | - * Poll_Callback adds a callback regardless of whether an identical one exists. |
| 331 | - * The exception to this rule is POLL_DEVICE callbacks: there is a maximum of |
| 332 | - * one read and one write callback per fd. |
| 333 | - * |
| 334 | - * Poll_CallbackRemove removes one callback. If there are multiple identical |
| 335 | - * callbacks, which one is removed is an implementation detail. Note that in |
| 336 | - * the case of POLL_DEVICE and POLL_REALTIME callbacks, the fd/delay used to |
| 337 | - * create the callback is not specified when removing, so all callbacks |
| 338 | - * of those types with the same flags, function, and clientData are considered |
| 339 | - * "identical" even if their fd/delay differed. |
| 340 | - */ |
| 341 | - |
| 342 | -VMwareStatus Poll_Callback(PollClassSet classSet, |
| 343 | - int flags, |
| 344 | - PollerFunction f, |
| 345 | - void *clientData, |
| 346 | - PollEventType type, |
| 347 | - PollDevHandle info, // fd/microsec delay |
| 348 | - MXUserRecLock *lck); |
| 349 | -Bool Poll_CallbackRemove(PollClassSet classSet, |
| 350 | - int flags, |
| 351 | - PollerFunction f, |
| 352 | - void *clientData, |
| 353 | - PollEventType type); |
| 354 | -Bool Poll_CallbackRemoveOneByCB(PollClassSet classSet, |
| 355 | - int flags, |
| 356 | - PollerFunction f, |
| 357 | - PollEventType type, |
| 358 | - void **clientData); |
| 359 | - |
| 360 | -void Poll_NotifyChange(PollClassSet classSet); |
| 361 | - |
| 362 | -/* |
| 363 | - * Wrappers for Poll_Callback and Poll_CallbackRemove that present |
| 364 | - * simpler subsets of those interfaces. |
| 365 | - */ |
| 366 | - |
| 367 | -VMwareStatus Poll_CB_Device(PollerFunction f, |
| 368 | - void *clientData, |
| 369 | - PollDevHandle device, |
| 370 | - Bool periodic); |
| 371 | - |
| 372 | -Bool Poll_CB_DeviceRemove(PollerFunction f, |
| 373 | - void *clientData, |
| 374 | - Bool periodic); |
| 375 | - |
| 376 | - |
| 377 | -VMwareStatus Poll_CB_RTime(PollerFunction f, |
| 378 | - void *clientData, |
| 379 | - int64 delay, // microseconds |
| 380 | - Bool periodic, |
| 381 | - MXUserRecLock *lock); |
| 382 | - |
| 383 | -Bool Poll_CB_RTimeRemove(PollerFunction f, |
| 384 | - void *clientData, |
| 385 | - Bool periodic); |
| 386 | - |
| 387 | - |
| 388 | -#ifdef _WIN32 |
| 389 | -void Poll_SetPumpsWindowsMessages(Bool pumps); |
| 390 | -void Poll_SetWindowMessageRecipient(HWND hWnd, UINT msg, Bool alwaysThunk); |
| 391 | -Bool Poll_FireWndCallback(void *lparam); |
| 392 | -#endif |
| 393 | - |
| 394 | -#if defined(__cplusplus) |
| 395 | -} // extern "C" |
| 396 | -#endif |
| 397 | - |
| 398 | -#endif // _POLL_H_ |
| 399 | --- /dev/null |
| 400 | +++ b/open-vm-tools/lib/include/vm_poll.h |
| 401 | @@ -0,0 +1,330 @@ |
| 402 | +/********************************************************* |
| 403 | + * Copyright (C) 1998-2018 VMware, Inc. All rights reserved. |
| 404 | + * |
| 405 | + * This program is free software; you can redistribute it and/or modify it |
| 406 | + * under the terms of the GNU Lesser General Public License as published |
| 407 | + * by the Free Software Foundation version 2.1 and no later version. |
| 408 | + * |
| 409 | + * This program is distributed in the hope that it will be useful, but |
| 410 | + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 411 | + * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public |
| 412 | + * License for more details. |
| 413 | + * |
| 414 | + * You should have received a copy of the GNU Lesser General Public License |
| 415 | + * along with this program; if not, write to the Free Software Foundation, Inc., |
| 416 | + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 417 | + * |
| 418 | + *********************************************************/ |
| 419 | + |
| 420 | +/********************************************************* |
| 421 | + * The contents of this file are subject to the terms of the Common |
| 422 | + * Development and Distribution License (the "License") version 1.0 |
| 423 | + * and no later version. You may not use this file except in |
| 424 | + * compliance with the License. |
| 425 | + * |
| 426 | + * You can obtain a copy of the License at |
| 427 | + * http://www.opensource.org/licenses/cddl1.php |
| 428 | + * |
| 429 | + * See the License for the specific language governing permissions |
| 430 | + * and limitations under the License. |
| 431 | + * |
| 432 | + *********************************************************/ |
| 433 | + |
| 434 | + |
| 435 | +#ifndef _POLL_H_ |
| 436 | +#define _POLL_H_ |
| 437 | + |
| 438 | +#define INCLUDE_ALLOW_USERLEVEL |
| 439 | +#define INCLUDE_ALLOW_VMCORE |
| 440 | +#include "includeCheck.h" |
| 441 | + |
| 442 | +#include "vm_basic_types.h" |
| 443 | +#include "vm_basic_defs.h" |
| 444 | +#include "vmware.h" |
| 445 | +#include "userlock.h" |
| 446 | + |
| 447 | +#if defined(__cplusplus) |
| 448 | +extern "C" { |
| 449 | +#endif |
| 450 | + |
| 451 | +#ifdef _WIN32 |
| 452 | +#define HZ 100 |
| 453 | +#elif defined linux |
| 454 | +#include <asm/param.h> |
| 455 | +#elif __APPLE__ |
| 456 | +#include <TargetConditionals.h> |
| 457 | +/* |
| 458 | + * Old SDKs don't define TARGET_OS_IPHONE at all. |
| 459 | + * New ones define it to 0 on Mac OS X, 1 on iOS. |
| 460 | + */ |
| 461 | +#if !defined(TARGET_OS_IPHONE) || TARGET_OS_IPHONE == 0 |
| 462 | +#include <sys/kernel.h> |
| 463 | +#endif |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 464 | +#include <poll.h> |
Brad Bishop | 2d39a06 | 2019-10-28 08:33:36 -0400 | [diff] [blame^] | 465 | +#define HZ 100 |
| 466 | +#endif |
| 467 | +#ifdef __ANDROID__ |
| 468 | +/* |
| 469 | + * <poll.h> of android should be included, but its name is same |
| 470 | + * with this file. So its content is put here to avoid conflict. |
| 471 | + */ |
| 472 | +#include <asm/poll.h> |
| 473 | +#define HZ 100 |
| 474 | +typedef unsigned int nfds_t; |
| 475 | +int poll(struct pollfd *, nfds_t, long); |
| 476 | +#endif |
| 477 | + |
| 478 | + |
| 479 | +/* |
| 480 | + * Poll event types: each type has a different reason for firing, |
| 481 | + * or condition that must be met before firing. |
| 482 | + */ |
| 483 | + |
| 484 | +typedef enum { |
| 485 | + /* |
| 486 | + * Actual Poll queue types against which you can register callbacks. |
| 487 | + */ |
| 488 | + POLL_VIRTUALREALTIME = -1, /* Negative because it doesn't have its own Q */ |
| 489 | + POLL_VTIME = 0, |
| 490 | + POLL_REALTIME, |
| 491 | + POLL_DEVICE, |
| 492 | + POLL_MAIN_LOOP, |
| 493 | + POLL_NUM_QUEUES |
| 494 | +} PollEventType; |
| 495 | + |
| 496 | + |
| 497 | +/* |
| 498 | + * Classes of events |
| 499 | + * |
| 500 | + * These are the predefined classes. More can be declared |
| 501 | + * with Poll_AllocClass(). |
| 502 | + */ |
| 503 | + |
| 504 | +typedef enum PollClass { |
| 505 | + POLL_CLASS_MAIN, |
| 506 | + POLL_CLASS_PAUSE, |
| 507 | + POLL_CLASS_IPC, |
| 508 | + POLL_CLASS_CPT, |
| 509 | + POLL_CLASS_MKS, |
| 510 | + POLL_FIXED_CLASSES, |
| 511 | + POLL_DEFAULT_FIXED_CLASSES, |
| 512 | + /* Size enum to maximum */ |
| 513 | + POLL_MAX_CLASSES = 31, |
| 514 | +} PollClass; |
| 515 | + |
| 516 | +/* |
| 517 | + * Do not use; Special pseudo private poll class supported by |
| 518 | + * PollDefault only |
| 519 | + */ |
| 520 | +#define POLL_DEFAULT_CLASS_NET POLL_FIXED_CLASSES |
| 521 | +#define POLL_DEFAULT_CS_NET PollClassSet_Singleton(POLL_DEFAULT_CLASS_NET) |
| 522 | + |
| 523 | +/* |
| 524 | + * Each callback is registered in a set of classes |
| 525 | + */ |
| 526 | + |
| 527 | +typedef struct PollClassSet { |
| 528 | + uintptr_t bits; |
| 529 | +} PollClassSet; |
| 530 | + |
| 531 | +/* An empty PollClassSet. */ |
| 532 | +static INLINE PollClassSet |
| 533 | +PollClassSet_Empty(void) |
| 534 | +{ |
| 535 | + PollClassSet set = { 0 }; |
| 536 | + return set; |
| 537 | +} |
| 538 | + |
| 539 | +/* A PollClassSet with the single member. */ |
| 540 | +static INLINE PollClassSet |
| 541 | +PollClassSet_Singleton(PollClass c) |
| 542 | +{ |
| 543 | + PollClassSet s = PollClassSet_Empty(); |
| 544 | + |
| 545 | + ASSERT_ON_COMPILE(POLL_MAX_CLASSES < sizeof s.bits * 8); |
| 546 | + ASSERT(c < POLL_MAX_CLASSES); |
| 547 | + |
| 548 | + s.bits = CONST3264U(1) << c; |
| 549 | + return s; |
| 550 | +} |
| 551 | + |
| 552 | +/* Combine two PollClassSets. */ |
| 553 | +static INLINE PollClassSet |
| 554 | +PollClassSet_Union(PollClassSet lhs, PollClassSet rhs) |
| 555 | +{ |
| 556 | + PollClassSet set; |
| 557 | + set.bits = lhs.bits | rhs.bits; |
| 558 | + return set; |
| 559 | +} |
| 560 | + |
| 561 | +/* Add single class to PollClassSet. */ |
| 562 | +static INLINE PollClassSet |
| 563 | +PollClassSet_Include(PollClassSet set, PollClass c) |
| 564 | +{ |
| 565 | + return PollClassSet_Union(set, PollClassSet_Singleton(c)); |
| 566 | +} |
| 567 | + |
| 568 | + |
| 569 | +#define POLL_CS_MAIN PollClassSet_Singleton(POLL_CLASS_MAIN) |
| 570 | +#define POLL_CS_PAUSE PollClassSet_Union(POLL_CS_MAIN, \ |
| 571 | + PollClassSet_Singleton(POLL_CLASS_PAUSE)) |
| 572 | +#define POLL_CS_CPT PollClassSet_Union(POLL_CS_PAUSE, \ |
| 573 | + PollClassSet_Singleton(POLL_CLASS_CPT)) |
| 574 | +#define POLL_CS_IPC PollClassSet_Union(POLL_CS_CPT, \ |
| 575 | + PollClassSet_Singleton(POLL_CLASS_IPC)) |
| 576 | +#define POLL_CS_VMDB POLL_CS_PAUSE /* POLL_CLASS_VMDB is retired */ |
| 577 | +#define POLL_CS_MKS PollClassSet_Singleton(POLL_CLASS_MKS) |
| 578 | +/* |
| 579 | + * DANGER. You don't need POLL_CS_ALWAYS. Really. So don't use it. |
| 580 | + */ |
| 581 | +#define POLL_CS_ALWAYS PollClassSet_Union(POLL_CS_CPT, POLL_CS_IPC) |
| 582 | + |
| 583 | +/* |
| 584 | + * Poll class-set taxonomy: |
| 585 | + * POLL_CS_MAIN |
| 586 | + * - Unless you NEED another class, use POLL_CS_MAIN. |
| 587 | + * POLL_CS_PAUSE |
| 588 | + * - For callbacks that must occur even if the guest is paused. |
| 589 | + * Most VMDB or Foundry commands are in this category. |
| 590 | + * POLL_CS_CPT |
| 591 | + * - Only for callbacks which can trigger intermediate Checkpoint |
| 592 | + * transitions. |
| 593 | + * The ONLY such callback is Migrate. |
| 594 | + * POLL_CS_IPC |
| 595 | + * - Only for callbacks which can contain Msg_(Post|Hint|Question) |
| 596 | + * responses, and for signal handlers (why)? |
| 597 | + * Vigor, VMDB, and Foundry can contain Msg_* responses. |
| 598 | + * POLL_CS_MKS |
| 599 | + * - Callback runs in MKS thread. |
| 600 | + * POLL_CS_ALWAYS |
| 601 | + * - Only for events that must be processed immediately. |
| 602 | + * The ONLY such callback is OvhdMemVmxSizeCheck. |
| 603 | + */ |
| 604 | + |
| 605 | + |
| 606 | +/* |
| 607 | + * Poll_Callback flags |
| 608 | + */ |
| 609 | + |
| 610 | +#define POLL_FLAG_PERIODIC 0x01 // keep after firing |
| 611 | +#define POLL_FLAG_REMOVE_AT_POWEROFF 0x02 // self-explanatory |
| 612 | +#define POLL_FLAG_READ 0x04 // device is ready for reading |
| 613 | +#define POLL_FLAG_WRITE 0x08 // device is ready for writing |
| 614 | +#define POLL_FLAG_SOCKET 0x10 // device is a Windows socket |
| 615 | +#define POLL_FLAG_NO_BULL 0x20 // callback does its own locking |
| 616 | +#define POLL_FLAG_WINSOCK 0x40 // Winsock style write events |
| 617 | +#define POLL_FLAG_FD 0x80 // device is a Windows file descriptor. |
| 618 | +#define POLL_FLAG_ACCEPT_INVALID_FDS 0x100 // For broken 3rd party libs, e.g. curl |
| 619 | +#define POLL_FLAG_THUNK_TO_WND 0x200 // thunk callback to window message loop |
| 620 | + |
| 621 | + |
| 622 | +typedef void (*PollerFunction)(void *clientData); |
| 623 | +typedef void (*PollerFireWrapper)(PollerFunction func, |
| 624 | + void *funcData, |
| 625 | + void *wrapperData); |
| 626 | +typedef Bool (*PollerErrorFn)(const char *errorStr); |
| 627 | + |
| 628 | +/* |
| 629 | + * Initialisers: |
| 630 | + * |
| 631 | + * For the sake of convenience, we declare the initialisers |
| 632 | + * for custom implmentations here, even though the actual |
| 633 | + * implementations are distinct from the core poll code. |
| 634 | + */ |
| 635 | + |
| 636 | +typedef struct PollOptions { |
| 637 | + Bool locked; // Use internal MXUser for locking |
| 638 | + Bool allowFullQueue; // Don't assert when device event queue is full. |
| 639 | + VThreadID windowsMsgThread; // thread that processes Windows messages |
| 640 | + PollerFireWrapper fireWrapperFn; // optional; may be useful for stats |
| 641 | + void *fireWrapperData; // optional |
| 642 | + PollerErrorFn errorFn; // optional; called upon unrecoverable error |
| 643 | +} PollOptions; |
| 644 | + |
| 645 | + |
| 646 | +void Poll_InitDefault(void); |
| 647 | +void Poll_InitDefaultEx(const PollOptions *opts); |
| 648 | +void Poll_InitGtk(void); // On top of glib for Linux |
| 649 | +void Poll_InitCF(void); // On top of CoreFoundation for OSX |
| 650 | + |
| 651 | + |
| 652 | +/* |
| 653 | + * Functions |
| 654 | + */ |
| 655 | +int Poll_SocketPair(Bool vmci, Bool stream, int fds[2]); |
| 656 | +void Poll_Loop(Bool loop, Bool *exit, PollClass c); |
| 657 | +void Poll_LoopTimeout(Bool loop, Bool *exit, PollClass c, int timeout); |
| 658 | +Bool Poll_LockingEnabled(void); |
| 659 | +void Poll_Exit(void); |
| 660 | + |
| 661 | + |
| 662 | +/* |
| 663 | + * Poll_Callback adds a callback regardless of whether an identical one exists. |
| 664 | + * The exception to this rule is POLL_DEVICE callbacks: there is a maximum of |
| 665 | + * one read and one write callback per fd. |
| 666 | + * |
| 667 | + * Poll_CallbackRemove removes one callback. If there are multiple identical |
| 668 | + * callbacks, which one is removed is an implementation detail. Note that in |
| 669 | + * the case of POLL_DEVICE and POLL_REALTIME callbacks, the fd/delay used to |
| 670 | + * create the callback is not specified when removing, so all callbacks |
| 671 | + * of those types with the same flags, function, and clientData are considered |
| 672 | + * "identical" even if their fd/delay differed. |
| 673 | + */ |
| 674 | + |
| 675 | +VMwareStatus Poll_Callback(PollClassSet classSet, |
| 676 | + int flags, |
| 677 | + PollerFunction f, |
| 678 | + void *clientData, |
| 679 | + PollEventType type, |
| 680 | + PollDevHandle info, // fd/microsec delay |
| 681 | + MXUserRecLock *lck); |
| 682 | +Bool Poll_CallbackRemove(PollClassSet classSet, |
| 683 | + int flags, |
| 684 | + PollerFunction f, |
| 685 | + void *clientData, |
| 686 | + PollEventType type); |
| 687 | +Bool Poll_CallbackRemoveOneByCB(PollClassSet classSet, |
| 688 | + int flags, |
| 689 | + PollerFunction f, |
| 690 | + PollEventType type, |
| 691 | + void **clientData); |
| 692 | + |
| 693 | +void Poll_NotifyChange(PollClassSet classSet); |
| 694 | + |
| 695 | +/* |
| 696 | + * Wrappers for Poll_Callback and Poll_CallbackRemove that present |
| 697 | + * simpler subsets of those interfaces. |
| 698 | + */ |
| 699 | + |
| 700 | +VMwareStatus Poll_CB_Device(PollerFunction f, |
| 701 | + void *clientData, |
| 702 | + PollDevHandle device, |
| 703 | + Bool periodic); |
| 704 | + |
| 705 | +Bool Poll_CB_DeviceRemove(PollerFunction f, |
| 706 | + void *clientData, |
| 707 | + Bool periodic); |
| 708 | + |
| 709 | + |
| 710 | +VMwareStatus Poll_CB_RTime(PollerFunction f, |
| 711 | + void *clientData, |
| 712 | + int64 delay, // microseconds |
| 713 | + Bool periodic, |
| 714 | + MXUserRecLock *lock); |
| 715 | + |
| 716 | +Bool Poll_CB_RTimeRemove(PollerFunction f, |
| 717 | + void *clientData, |
| 718 | + Bool periodic); |
| 719 | + |
| 720 | + |
| 721 | +#ifdef _WIN32 |
| 722 | +void Poll_SetPumpsWindowsMessages(Bool pumps); |
| 723 | +void Poll_SetWindowMessageRecipient(HWND hWnd, UINT msg, Bool alwaysThunk); |
| 724 | +Bool Poll_FireWndCallback(void *lparam); |
| 725 | +#endif |
| 726 | + |
| 727 | +#if defined(__cplusplus) |
| 728 | +} // extern "C" |
| 729 | +#endif |
| 730 | + |
| 731 | +#endif // _POLL_H_ |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 732 | --- a/open-vm-tools/lib/rpcIn/rpcin.c |
| 733 | +++ b/open-vm-tools/lib/rpcIn/rpcin.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 734 | @@ -57,7 +57,7 @@ |
| 735 | |
| 736 | #if defined(VMTOOLS_USE_VSOCKET) |
| 737 | # include <glib.h> |
| 738 | -# include "poll.h" |
| 739 | +# include "vm_poll.h" |
| 740 | # include "asyncsocket.h" |
| 741 | # include "vmci_defs.h" |
| 742 | #include "dataMap.h" |