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