0003-Rename-poll-h-into-vm_poll-h-to-fix-build-failure-on-musl.patch 26 KB

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