You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mmpa_win.h 21 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MMPA_WIN_MMPA_WIN_H
  17. #define MMPA_WIN_MMPA_WIN_H
  18. #ifdef __cplusplus
  19. #if __cplusplus
  20. extern "C" {
  21. #endif // __cpluscplus
  22. #endif // __cpluscplus
  23. #ifdef MMPA_DLL
  24. #define MMPA_DLL_API __declspec(dllexport)
  25. #else
  26. #define MMPA_DLL_API __declspec(dllimport)
  27. #endif
  28. #define MMPA_MACINFO_DEFAULT_SIZE 18
  29. #define MMPA_CPUDESC_DEFAULT_SIZE 64
  30. MMPA_DLL_API extern char *optarg;
  31. MMPA_DLL_API extern int opterr;
  32. MMPA_DLL_API extern int optind;
  33. MMPA_DLL_API extern int optopt;
  34. #pragma section(".CRT$XCU", long, read)
  35. #pragma section(".CRT$XPU", long, read)
  36. typedef HANDLE mmMutex_t;
  37. typedef HANDLE mmThread;
  38. typedef HANDLE mmProcess;
  39. typedef HANDLE mmPollHandle;
  40. typedef HANDLE mmPipeHandle;
  41. typedef HANDLE mmFileHandle;
  42. typedef HANDLE mmCompletionHandle;
  43. typedef HANDLE mmFd_t;
  44. typedef CRITICAL_SECTION mmMutexFC;
  45. typedef CONDITION_VARIABLE mmCond;
  46. typedef VOID *(*userProcFunc)(VOID *pulArg);
  47. typedef struct {
  48. userProcFunc procFunc;
  49. VOID *pulArg;
  50. } mmUserBlock_t;
  51. typedef DWORD mmThreadKey;
  52. typedef SYSTEMTIME mmSystemTime_t;
  53. typedef HANDLE mmSem_t;
  54. typedef SOCKET mmSockHandle;
  55. typedef SRWLOCK mmRWLock_t;
  56. typedef struct sockaddr mmSockAddr;
  57. typedef int mmSocklen_t;
  58. typedef int mmSemTimeout_t;
  59. typedef long mmAtomicType;
  60. typedef DWORD mmExitCode;
  61. typedef DWORD mmErrorMsg;
  62. typedef int mmKey_t;
  63. typedef HANDLE mmMsgid;
  64. typedef long int mmOfft_t;
  65. typedef int mmPid_t;
  66. typedef INT32 mmSsize_t;
  67. typedef int mmSize; // size
  68. typedef size_t mmSize_t;
  69. typedef VOID mmshmId_ds;
  70. typedef enum {
  71. DT_DIR = FILE_ATTRIBUTE_DIRECTORY,
  72. } mmDtype;
  73. typedef struct {
  74. unsigned char d_type;
  75. char d_name[MAX_PATH]; // file name
  76. } mmDirent;
  77. typedef int (*mmFilter)(const mmDirent *entry);
  78. typedef int (*mmSort)(const mmDirent **a, const mmDirent **b);
  79. typedef struct {
  80. VOID *sendBuf;
  81. INT32 sendLen;
  82. } mmIovSegment;
  83. typedef PVOID mmInAddr;
  84. typedef enum {
  85. pollTypeRead = 1, // pipeline reading
  86. pollTypeRecv, // socket receive
  87. pollTypeIoctl, // ioctl read
  88. } mmPollType;
  89. typedef struct {
  90. HANDLE completionHandle;
  91. mmPollType overlapType;
  92. OVERLAPPED oa;
  93. } mmComPletionKey, *pmmComPletionKey;
  94. typedef struct {
  95. VOID *priv; // User defined private content
  96. mmPollHandle bufHandle; // Value of handle corresponding to buf
  97. mmPollType bufType; // Data types polled to
  98. VOID *buf;
  99. UINT32 bufLen;
  100. UINT32 bufRes;
  101. } mmPollData, *pmmPollData;
  102. typedef VOID (*mmPollBack)(pmmPollData);
  103. typedef struct {
  104. mmPollHandle handle; // The file descriptor or handle of poll is required
  105. mmPollType pollType; // Operation type requiring poll,read or recv or ioctl
  106. INT32 ioctlCode; // IOCTL operation code, dedicated to IOCTL
  107. mmComPletionKey completionKey; // The default value is blank, which will be used in windows to receive the data with
  108. // different handle
  109. } mmPollfd;
  110. typedef struct {
  111. OVERLAPPED oa;
  112. HANDLE completionHandle;
  113. WSABUF DataBuf;
  114. } PRE_IO_DATA, *PPRE_IO_DATA;
  115. typedef OVERLAPPED mmOverLap;
  116. typedef struct {
  117. UINT32 createFlag;
  118. INT32 oaFlag; // Overlap operation is supported if it is not 0
  119. } mmCreateFlag;
  120. typedef struct {
  121. VOID *inbuf;
  122. INT32 inbufLen;
  123. VOID *outbuf;
  124. INT32 outbufLen;
  125. mmOverLap *oa;
  126. } mmIoctlBuf;
  127. typedef struct {
  128. HANDLE timerQueue;
  129. HANDLE timerHandle;
  130. } mmTimerHandle;
  131. typedef struct {
  132. LONG tv_sec;
  133. LONG tv_usec;
  134. } mmTimeval;
  135. typedef struct {
  136. INT32 tz_minuteswest; // How many minutes is it different from Greenwich
  137. INT32 tz_dsttime; // DST correction type
  138. } mmTimezone;
  139. typedef struct {
  140. LONG tv_sec;
  141. LONG tv_nsec;
  142. } mmTimespec;
  143. typedef mmTimerHandle mmTimer;
  144. #define mmTLS __declspec(thread)
  145. typedef struct stat mmStat_t;
  146. typedef struct _stat64 mmStat64_t;
  147. typedef int mmMode_t;
  148. typedef int MODE;
  149. typedef struct {
  150. const char *name;
  151. int has_arg;
  152. int *flag;
  153. int val;
  154. } mmStructOption;
  155. typedef struct {
  156. ULONGLONG totalSize;
  157. ULONGLONG freeSize;
  158. ULONGLONG availSize;
  159. } mmDiskSize;
  160. typedef struct {
  161. const char *dli_fname;
  162. void *dli_fbase;
  163. const char *dli_sname;
  164. void *dli_saddr;
  165. size_t dli_size; /* ELF only */
  166. int dli_bind; /* ELF only */
  167. int dli_type;
  168. } mmDlInfo;
  169. typedef struct {
  170. char addr[MMPA_MACINFO_DEFAULT_SIZE]; // ex:aa-bb-cc-dd-ee-ff\0
  171. } mmMacInfo;
  172. typedef struct {
  173. char arch[MMPA_CPUDESC_DEFAULT_SIZE];
  174. char manufacturer[MMPA_CPUDESC_DEFAULT_SIZE]; // vendor
  175. char version[MMPA_CPUDESC_DEFAULT_SIZE]; // modelname
  176. INT32 frequency; // cpu frequency
  177. INT32 maxFrequency; // max speed
  178. INT32 ncores; // cpu cores
  179. INT32 nthreads; // cpu thread count
  180. INT32 ncounts; // logical cpu nums
  181. } mmCpuDesc;
  182. typedef struct {
  183. char **argv;
  184. INT32 argvCount;
  185. char **envp;
  186. INT32 envpCount;
  187. } mmArgvEnv;
  188. // Windows currently does not support properties other than thread separation properties
  189. typedef struct {
  190. INT32 detachFlag; // Thread detach property: 0 do not detach 1 detach
  191. INT32 priorityFlag;
  192. INT32 priority;
  193. INT32 policyFlag;
  194. INT32 policy;
  195. INT32 stackFlag;
  196. UINT32 stackSize;
  197. } mmThreadAttr;
  198. typedef VOID (*mmPf)(VOID);
  199. #define M_FILE_RDONLY GENERIC_READ
  200. #define M_FILE_WRONLY GENERIC_WRITE
  201. #define M_FILE_RDWR (GENERIC_READ | GENERIC_WRITE)
  202. #define M_FILE_CREAT OPEN_ALWAYS
  203. #define M_RDONLY _O_RDONLY
  204. #define M_WRONLY _O_WRONLY
  205. #define M_RDWR _O_RDWR
  206. #define M_IRWXU _O_RDWR
  207. #define M_CREAT _O_CREAT
  208. #define M_BINARY _O_BINARY
  209. #define M_TRUNC _O_TRUNC
  210. #define M_IREAD _S_IREAD
  211. #define M_IRUSR _S_IREAD
  212. #define M_IWRITE _S_IWRITE
  213. #define M_IWUSR _S_IWRITE
  214. #define M_IXUSR 0
  215. #define M_IN_CREATE FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME
  216. #define M_IN_CLOSE_WRITE FILE_NOTIFY_CHANGE_LAST_WRITE
  217. #define M_IN_IGNORED FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME
  218. #define M_OUT_CREATE 0x00000100
  219. #define M_OUT_CLOSE_WRITE 0x00000008
  220. #define M_OUT_IGNORED 0x00008000
  221. #define M_OUT_ISDIR 0x40000000
  222. #define M_MSG_CREAT 1
  223. #define M_MSG_EXCL 2
  224. #define M_MSG_NOWAIT 3
  225. #define M_WAIT_NOHANG 1
  226. #define M_WAIT_UNTRACED 2
  227. #define M_UMASK_USRREAD _S_IREAD
  228. #define M_UMASK_GRPREAD _S_IREAD
  229. #define M_UMASK_OTHREAD _S_IREAD
  230. #define M_UMASK_USRWRITE _S_IWRITE
  231. #define M_UMASK_GRPWRITE _S_IWRITE
  232. #define M_UMASK_OTHWRITE _S_IWRITE
  233. #define M_UMASK_USREXEC 0
  234. #define M_UMASK_GRPEXEC 0
  235. #define M_UMASK_OTHEXEC 0
  236. #define DT_UNKNOWN 0
  237. #define DT_FIFO 1
  238. #define DT_CHR 2
  239. #define DT_DIR 4
  240. #define DT_BLK 6
  241. #define DT_REG 8
  242. #define DT_LNK 10
  243. #define DT_SOCK 12
  244. #define DT_WHT 14
  245. #define mmConstructor(x) __declspec(allocate(".CRT$XCU")) mmPf con = x
  246. #define mmDestructor(x) __declspec(allocate(".CRT$XPU")) mmPf de = x
  247. #define MMPA_PRINT_ERROR ((opterr) && (*options != ':'))
  248. #define MMPA_FLAG_PERMUTE 0x01 // permute non-options to the end of argv
  249. #define MMPA_FLAG_ALLARGS 0x02 // treat non-options as args to option "-1"
  250. #define MMPA_FLAG_LONGONLY 0x04 // operate as getopt_long_only
  251. // return values
  252. #define MMPA_BADCH (INT32)'?'
  253. #define MMPA_BADARG ((*options == ':') ? (INT32)':' : (INT32)'?')
  254. #define MMPA_INORDER (INT32)1
  255. #define MMPA_NO_ARGUMENT 0
  256. #define MMPA_REQUIRED_ARGUMENT 1
  257. #define MMPA_OPTIONAL_ARGUMENT 2
  258. #define MMPA_EMSG ""
  259. #define MMPA_MAX_PATH MAX_PATH
  260. #define M_NAME_MAX _MAX_FNAME
  261. #define M_F_OK 0
  262. #define M_W_OK 2
  263. #define M_R_OK 4
  264. #define MMPA_STDIN stdin
  265. #define MMPA_STDOUT stdout
  266. #define MMPA_STDERR stderr
  267. #define MMPA_RTLD_NOW 0
  268. #define MMPA_RTLD_GLOBAL 0
  269. #define MMPA_RTLD_LAZY 0
  270. #define MMPA_RTLD_NODELETE 0
  271. #define MMPA_DL_EXT_NAME ".dll"
  272. #define __attribute__(v)
  273. _declspec(dllexport) INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock);
  274. _declspec(dllexport) INT32 mmJoinTask(mmThread *threadHandle);
  275. _declspec(dllexport) INT32 mmMutexInit(mmMutex_t *mutex);
  276. _declspec(dllexport) INT32 mmMutexLock(mmMutex_t *mutex);
  277. _declspec(dllexport) INT32 mmMutexTryLock(mmMutex_t *mutex);
  278. _declspec(dllexport) INT32 mmMutexUnLock(mmMutex_t *mutex);
  279. _declspec(dllexport) INT32 mmMutexDestroy(mmMutex_t *mutex);
  280. _declspec(dllexport) INT32 mmCondInit(mmCond *cond);
  281. _declspec(dllexport) INT32 mmCondLockInit(mmMutexFC *mutex);
  282. _declspec(dllexport) INT32 mmCondLock(mmMutexFC *mutex);
  283. _declspec(dllexport) INT32 mmCondUnLock(mmMutexFC *mutex);
  284. _declspec(dllexport) INT32 mmCondLockDestroy(mmMutexFC *mutex);
  285. _declspec(dllexport) INT32 mmRWLockInit(mmRWLock_t *rwLock);
  286. _declspec(dllexport) INT32 mmRWLockRDLock(mmRWLock_t *rwLock);
  287. _declspec(dllexport) INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock);
  288. _declspec(dllexport) INT32 mmRWLockWRLock(mmRWLock_t *rwLock);
  289. _declspec(dllexport) INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock);
  290. _declspec(dllexport) INT32 mmRDLockUnLock(mmRWLock_t *rwLock);
  291. _declspec(dllexport) INT32 mmWRLockUnLock(mmRWLock_t *rwLock);
  292. _declspec(dllexport) INT32 mmRWLockDestroy(mmRWLock_t *rwLock);
  293. _declspec(dllexport) INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex);
  294. _declspec(dllexport) INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond);
  295. _declspec(dllexport) INT32 mmCondNotify(mmCond *cond);
  296. _declspec(dllexport) INT32 mmCondNotifyAll(mmCond *cond);
  297. _declspec(dllexport) INT32 mmCondDestroy(mmCond *cond);
  298. _declspec(dllexport) INT32 mmGetPid(VOID);
  299. _declspec(dllexport) INT32 mmGetTid(VOID);
  300. _declspec(dllexport) INT32 mmGetPidHandle(mmProcess *processHandle);
  301. _declspec(dllexport) INT32 mmGetLocalTime(mmSystemTime_t *sysTime);
  302. _declspec(dllexport) INT32 mmGetSystemTime(mmSystemTime_t *sysTime);
  303. _declspec(dllexport) INT32 mmSemInit(mmSem_t *sem, UINT32 value);
  304. _declspec(dllexport) INT32 mmSemWait(mmSem_t *sem);
  305. _declspec(dllexport) INT32 mmSemPost(mmSem_t *sem);
  306. _declspec(dllexport) INT32 mmSemDestroy(mmSem_t *sem);
  307. _declspec(dllexport) INT32 mmOpen(const CHAR *pathName, INT32 flags);
  308. _declspec(dllexport) INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode);
  309. _declspec(dllexport) FILE *mmPopen(CHAR *command, CHAR *type);
  310. _declspec(dllexport) INT32 mmClose(INT32 fd);
  311. _declspec(dllexport) INT32 mmPclose(FILE *stream);
  312. _declspec(dllexport) mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen);
  313. _declspec(dllexport) mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen);
  314. _declspec(dllexport) mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol);
  315. _declspec(dllexport) INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
  316. _declspec(dllexport) INT32 mmListen(mmSockHandle sockFd, INT32 backLog);
  317. _declspec(dllexport) mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen);
  318. _declspec(dllexport) INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
  319. _declspec(dllexport) INT32 mmCloseSocket(mmSockHandle sockFd);
  320. _declspec(dllexport) mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag);
  321. _declspec(dllexport) mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag);
  322. _declspec(dllexport) INT32 mmSocketSendTo(mmSockHandle sockFd,
  323. VOID *sendMsg,
  324. INT32 sendLen,
  325. UINT32 sendFlag,
  326. const mmSockAddr* addr,
  327. INT32 tolen);
  328. _declspec(dllexport) mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd,
  329. VOID *recvBuf,
  330. mmSize recvLen,
  331. UINT32 recvFlag,
  332. mmSockAddr* addr,
  333. mmSocklen_t *FromLen);
  334. _declspec(dllexport) INT32 mmSAStartup(VOID);
  335. _declspec(dllexport) INT32 mmSACleanup(VOID);
  336. _declspec(dllexport) VOID *mmDlopen(const CHAR *fileName, INT mode);
  337. _declspec(dllexport) INT32 mmDladdr(VOID *addr, mmDlInfo *info);
  338. _declspec(dllexport) VOID *mmDlsym(VOID *handle, CHAR *fileName);
  339. _declspec(dllexport) INT32 mmDlclose(VOID *handle);
  340. _declspec(dllexport) CHAR *mmDlerror(VOID);
  341. _declspec(dllexport) INT32
  342. mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period);
  343. _declspec(dllexport) INT32 mmDeleteTimer(mmTimer timerHandle);
  344. _declspec(dllexport) INT32 mmStatGet(const CHAR *path, mmStat_t *buffer);
  345. _declspec(dllexport) INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer);
  346. _declspec(dllexport) INT32 mmFStatGet(INT32 fd, mmStat_t *buffer);
  347. _declspec(dllexport) INT32 mmMkdir(const CHAR *pathName, mmMode_t mode);
  348. _declspec(dllexport) INT32 mmSleep(UINT32 milliSecond);
  349. _declspec(dllexport) INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock);
  350. _declspec(dllexport) INT32 mmGetProcessPrio(mmProcess pid);
  351. _declspec(dllexport) INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio);
  352. _declspec(dllexport) INT32 mmGetThreadPrio(mmThread *threadHandle);
  353. _declspec(dllexport) INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio);
  354. _declspec(dllexport) INT32 mmAccess(const CHAR *pathName);
  355. _declspec(dllexport) INT32 mmAccess2(const CHAR *pathName, INT32 mode);
  356. _declspec(dllexport) INT32 mmRmdir(const CHAR *pathName);
  357. _declspec(dllexport) INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr);
  358. _declspec(dllexport) INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout);
  359. _declspec(dllexport) mmSsize_t mmWritev(mmSockHandle fd, mmIovSegment *iov, INT32 iovcnt);
  360. _declspec(dllexport) VOID mmMb();
  361. _declspec(dllexport) INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr);
  362. _declspec(dllexport) mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag);
  363. _declspec(dllexport) mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len);
  364. _declspec(dllexport) mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len);
  365. _declspec(dllexport) INT32 mmCloseFile(mmProcess fileId);
  366. _declspec(dllexport) mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value);
  367. _declspec(dllexport) mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value);
  368. _declspec(dllexport) mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value);
  369. _declspec(dllexport) INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock);
  370. _declspec(dllexport) INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
  371. _declspec(dllexport) INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
  372. _declspec(dllexport) VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]);
  373. _declspec(dllexport) INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
  374. _declspec(dllexport) INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
  375. _declspec(dllexport) VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount);
  376. _declspec(dllexport) mmCompletionHandle mmCreateCompletionPort();
  377. _declspec(dllexport) VOID mmCloseCompletionPort(mmCompletionHandle handle);
  378. _declspec(dllexport) INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP,
  379. pmmPollData polledData, mmPollBack pollBack);
  380. _declspec(dllexport) INT32 mmGetErrorCode();
  381. _declspec(dllexport) CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size);
  382. _declspec(dllexport) INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone);
  383. _declspec(dllexport) mmTimespec mmGetTickCount();
  384. _declspec(dllexport) INT32 mmGetRealPath(CHAR *path, CHAR *realPath);
  385. _declspec(dllexport) INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen);
  386. _declspec(dllexport) INT32 mmDup2(INT32 oldFd, INT32 newFd);
  387. _declspec(dllexport) INT32 mmDup(INT32 fd);
  388. _declspec(dllexport) INT32 mmUnlink(const CHAR *filename);
  389. _declspec(dllexport) INT32 mmChmod(const CHAR *filename, INT32 mode);
  390. _declspec(dllexport) INT32 mmFileno(FILE *stream);
  391. _declspec(dllexport) INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort);
  392. _declspec(dllexport) VOID mmScandirFree(mmDirent **entryList, INT32 count);
  393. _declspec(dllexport) mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag);
  394. _declspec(dllexport) mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag);
  395. _declspec(dllexport) INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);
  396. _declspec(dllexport) INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);
  397. _declspec(dllexport) INT32 mmMsgClose(mmMsgid msqid);
  398. _declspec(dllexport) INT32 mmLocalTimeR(const time_t *timep, struct tm *result);
  399. _declspec(dllexport) INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts);
  400. _declspec(dllexport) INT32
  401. mmGetOptLong(INT32 argc, CHAR *const *argv, const CHAR *opts, const mmStructOption *longopts, INT32 *longindex);
  402. _declspec(dllexport) LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag);
  403. _declspec(dllexport) INT32 mmFtruncate(mmProcess fd, UINT32 length);
  404. _declspec(dllexport) INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *));
  405. _declspec(dllexport) INT32 mmTlsSet(mmThreadKey key, const VOID *value);
  406. _declspec(dllexport) VOID *mmTlsGet(mmThreadKey key);
  407. _declspec(dllexport) INT32 mmTlsDelete(mmThreadKey key);
  408. _declspec(dllexport) INT32 mmGetOsType();
  409. _declspec(dllexport) INT32 mmFsync(mmProcess fd);
  410. _declspec(dllexport) INT32 mmFsync2(INT32 fd);
  411. _declspec(dllexport) INT32 mmChdir(const CHAR *path);
  412. _declspec(dllexport) INT32 mmUmask(INT32 pmode);
  413. _declspec(dllexport) INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options);
  414. _declspec(dllexport) INT32 mmGetCwd(CHAR *buffer, INT32 maxLen);
  415. _declspec(dllexport) CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr);
  416. _declspec(dllexport) INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len);
  417. _declspec(dllexport) INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite);
  418. _declspec(dllexport) CHAR *mmDirName(CHAR *path);
  419. _declspec(dllexport) CHAR *mmBaseName(CHAR *path);
  420. _declspec(dllexport) INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize);
  421. _declspec(dllexport) INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name);
  422. _declspec(dllexport) INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size);
  423. /*
  424. * Function: set the thread name of the currently executing thread - internal call of thread, which is not supported
  425. * under Windows temporarily, and is null.
  426. * Input: name: the thread name to be set
  427. * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the
  428. * execution failure returns EN_ERROR
  429. */
  430. _declspec(dllexport) INT32 mmSetCurrentThreadName(const CHAR *name);
  431. /*
  432. * Function: Get the thread name of the currently executing thread - thread body call, not supported under windows, null
  433. * implementation.
  434. * Input:name:The name of the thread to get, and the cache is allocated by the user,size>=MMPA_THREADNAME_SIZE.
  435. * The input parameter error returns EN_INVALID_PARAM, the execution success returns
  436. * EN_OK, and the execution failure returns EN_ERROR
  437. */
  438. _declspec(dllexport) INT32 mmGetCurrentThreadName(CHAR *name, INT32 size);
  439. _declspec(dllexport) INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length);
  440. _declspec(dllexport) INT32 mmIsDir(const CHAR *fileName);
  441. _declspec(dllexport) INT32 mmGetOsName(CHAR *name, INT32 nameSize);
  442. _declspec(dllexport) INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength);
  443. _declspec(dllexport) INT32 mmGetMac(mmMacInfo **list, INT32 *count);
  444. _declspec(dllexport) INT32 mmGetMacFree(mmMacInfo *list, INT32 count);
  445. _declspec(dllexport) INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count);
  446. _declspec(dllexport) INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count);
  447. _declspec(dllexport) INT32
  448. mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile, mmProcess *id);
  449. _declspec(dllexport) INT32
  450. mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr);
  451. _declspec(dllexport) mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode);
  452. _declspec(dllexport) INT32 mmShmUnlink(const CHAR *name);
  453. _declspec(dllexport) VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags);
  454. _declspec(dllexport) INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra);
  455. #ifdef __cplusplus
  456. #if __cplusplus
  457. }
  458. #endif /* __cpluscplus */
  459. #endif // __cpluscplus
  460. #endif // MMPA_WIN_MMPA_WIN_H_

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示