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