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 18 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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 mmCompletionHandle;
  42. typedef CRITICAL_SECTION mmMutexFC;
  43. typedef CONDITION_VARIABLE mmCond;
  44. typedef VOID *(*userProcFunc)(VOID *pulArg);
  45. typedef struct {
  46. userProcFunc procFunc;
  47. VOID *pulArg;
  48. } mmUserBlock_t;
  49. typedef DWORD mmThreadKey;
  50. typedef SYSTEMTIME mmSystemTime_t;
  51. typedef HANDLE mmSem_t;
  52. typedef SOCKET mmSockHandle;
  53. typedef struct sockaddr mmSockAddr;
  54. typedef int mmSocklen_t;
  55. typedef int mmSemTimeout_t;
  56. typedef long mmAtomicType;
  57. typedef DWORD mmExitCode;
  58. typedef int mmKey_t;
  59. typedef HANDLE mmMsgid;
  60. typedef INT32 mmSsize_t;
  61. typedef enum {
  62. DT_DIR = FILE_ATTRIBUTE_DIRECTORY,
  63. } mmDtype;
  64. typedef struct {
  65. unsigned char d_type;
  66. char d_name[MAX_PATH]; // file name
  67. } mmDirent;
  68. typedef int (*mmFilter)(const mmDirent *entry);
  69. typedef int (*mmSort)(const mmDirent **a, const mmDirent **b);
  70. typedef struct {
  71. VOID *sendBuf;
  72. INT32 sendLen;
  73. } mmIovSegment;
  74. typedef PVOID mmInAddr;
  75. typedef enum {
  76. pollTypeRead = 1, // pipeline reading
  77. pollTypeRecv, // socket receive
  78. pollTypeIoctl, // ioctl read
  79. } mmPollType;
  80. typedef struct {
  81. HANDLE completionHandle;
  82. mmPollType overlapType;
  83. OVERLAPPED oa;
  84. } mmComPletionKey, *pmmComPletionKey;
  85. typedef struct {
  86. VOID *priv; // User defined private content
  87. mmPollHandle bufHandle; // Value of handle corresponding to buf
  88. mmPollType bufType; // Data types polled to
  89. VOID *buf;
  90. UINT32 bufLen;
  91. UINT32 bufRes;
  92. } mmPollData, *pmmPollData;
  93. typedef VOID (*mmPollBack)(pmmPollData);
  94. typedef struct {
  95. mmPollHandle handle; // The file descriptor or handle of poll is required
  96. mmPollType pollType; // Operation type requiring poll,read or recv or ioctl
  97. INT32 ioctlCode; // IOCTL operation code, dedicated to IOCTL
  98. mmComPletionKey completionKey; // The default value is blank, which will be used in windows to receive the data with
  99. // different handle
  100. } mmPollfd;
  101. typedef struct {
  102. OVERLAPPED oa;
  103. HANDLE completionHandle;
  104. WSABUF DataBuf;
  105. } PRE_IO_DATA, *PPRE_IO_DATA;
  106. typedef OVERLAPPED mmOverLap;
  107. typedef struct {
  108. UINT32 createFlag;
  109. INT32 oaFlag; // Overlap operation is supported if it is not 0
  110. } mmCreateFlag;
  111. typedef struct {
  112. VOID *inbuf;
  113. INT32 inbufLen;
  114. VOID *outbuf;
  115. INT32 outbufLen;
  116. mmOverLap *oa;
  117. } mmIoctlBuf;
  118. typedef struct {
  119. HANDLE timerQueue;
  120. HANDLE timerHandle;
  121. } mmTimerHandle;
  122. typedef struct {
  123. LONG tv_sec;
  124. LONG tv_usec;
  125. } mmTimeval;
  126. typedef struct {
  127. INT32 tz_minuteswest; // How many minutes is it different from Greenwich
  128. INT32 tz_dsttime; // DST correction type
  129. } mmTimezone;
  130. typedef struct {
  131. LONG tv_sec;
  132. LONG tv_nsec;
  133. } mmTimespec;
  134. typedef mmTimerHandle mmTimer;
  135. #define mmTLS __declspec(thread)
  136. typedef struct stat mmStat_t;
  137. typedef struct _stat64 mmStat64_t;
  138. typedef int mmMode_t;
  139. typedef int MODE;
  140. typedef struct {
  141. const char *name;
  142. int has_arg;
  143. int *flag;
  144. int val;
  145. } mmStructOption;
  146. typedef struct {
  147. ULONGLONG totalSize;
  148. ULONGLONG freeSize;
  149. ULONGLONG availSize;
  150. } mmDiskSize;
  151. typedef struct {
  152. char addr[MMPA_MACINFO_DEFAULT_SIZE]; // ex:aa-bb-cc-dd-ee-ff\0
  153. } mmMacInfo;
  154. typedef struct {
  155. char arch[MMPA_CPUDESC_DEFAULT_SIZE];
  156. char manufacturer[MMPA_CPUDESC_DEFAULT_SIZE]; // vendor
  157. char version[MMPA_CPUDESC_DEFAULT_SIZE]; // modelname
  158. INT32 frequency; // cpu frequency
  159. INT32 maxFrequency; // max speed
  160. INT32 ncores; // cpu cores
  161. INT32 nthreads; // cpu thread count
  162. INT32 ncounts; // logical cpu nums
  163. } mmCpuDesc;
  164. typedef struct {
  165. char **argv;
  166. INT32 argvCount;
  167. char **envp;
  168. INT32 envpCount;
  169. } mmArgvEnv;
  170. // Windows currently does not support properties other than thread separation properties
  171. typedef struct {
  172. INT32 detachFlag; // Thread detach property: 0 do not detach 1 detach
  173. INT32 priorityFlag;
  174. INT32 priority;
  175. INT32 policyFlag;
  176. INT32 policy;
  177. INT32 stackFlag;
  178. UINT32 stackSize;
  179. } mmThreadAttr;
  180. typedef VOID (*mmPf)(VOID);
  181. #define M_FILE_RDONLY GENERIC_READ
  182. #define M_FILE_WRONLY GENERIC_WRITE
  183. #define M_FILE_RDWR (GENERIC_READ | GENERIC_WRITE)
  184. #define M_FILE_CREAT OPEN_ALWAYS
  185. #define M_RDONLY _O_RDONLY
  186. #define M_WRONLY _O_WRONLY
  187. #define M_RDWR _O_RDWR
  188. #define M_CREAT _O_CREAT
  189. #define M_BINARY _O_BINARY
  190. #define M_IREAD _S_IREAD
  191. #define M_IRUSR _S_IREAD
  192. #define M_IWRITE _S_IWRITE
  193. #define M_IWUSR _S_IWRITE
  194. #define M_IXUSR 0
  195. #define M_MSG_CREAT 1
  196. #define M_MSG_EXCL 2
  197. #define M_MSG_NOWAIT 3
  198. #define M_WAIT_NOHANG 1
  199. #define M_WAIT_UNTRACED 2
  200. #define M_UMASK_USRREAD _S_IREAD
  201. #define M_UMASK_GRPREAD _S_IREAD
  202. #define M_UMASK_OTHREAD _S_IREAD
  203. #define M_UMASK_USRWRITE _S_IWRITE
  204. #define M_UMASK_GRPWRITE _S_IWRITE
  205. #define M_UMASK_OTHWRITE _S_IWRITE
  206. #define M_UMASK_USREXEC 0
  207. #define M_UMASK_GRPEXEC 0
  208. #define M_UMASK_OTHEXEC 0
  209. #define mmConstructor(x) __declspec(allocate(".CRT$XCU")) mmPf con = x
  210. #define mmDestructor(x) __declspec(allocate(".CRT$XPU")) mmPf de = x
  211. #define MMPA_PRINT_ERROR ((opterr) && (*options != ':'))
  212. #define MMPA_FLAG_PERMUTE 0x01 // permute non-options to the end of argv
  213. #define MMPA_FLAG_ALLARGS 0x02 // treat non-options as args to option "-1"
  214. #define MMPA_FLAG_LONGONLY 0x04 // operate as getopt_long_only
  215. // return values
  216. #define MMPA_BADCH (INT32)'?'
  217. #define MMPA_BADARG ((*options == ':') ? (INT32)':' : (INT32)'?')
  218. #define MMPA_INORDER (INT32)1
  219. #define MMPA_NO_ARGUMENT 0
  220. #define MMPA_REQUIRED_ARGUMENT 1
  221. #define MMPA_OPTIONAL_ARGUMENT 2
  222. #define MMPA_EMSG ""
  223. #define MMPA_MAX_PATH MAX_PATH
  224. #define M_F_OK 0
  225. #define M_W_OK 2
  226. #define M_R_OK 4
  227. #define MMPA_RTLD_NOW 0
  228. #define MMPA_RTLD_GLOBAL 0
  229. #define MMPA_DL_EXT_NAME ".dll"
  230. #define __attribute__(v)
  231. _declspec(dllexport) INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock);
  232. _declspec(dllexport) INT32 mmJoinTask(mmThread *threadHandle);
  233. _declspec(dllexport) INT32 mmMutexInit(mmMutex_t *mutex);
  234. _declspec(dllexport) INT32 mmMutexLock(mmMutex_t *mutex);
  235. _declspec(dllexport) INT32 mmMutexUnLock(mmMutex_t *mutex);
  236. _declspec(dllexport) INT32 mmMutexDestroy(mmMutex_t *mutex);
  237. _declspec(dllexport) INT32 mmCondInit(mmCond *cond);
  238. _declspec(dllexport) INT32 mmCondLockInit(mmMutexFC *mutex);
  239. _declspec(dllexport) INT32 mmCondLock(mmMutexFC *mutex);
  240. _declspec(dllexport) INT32 mmCondUnLock(mmMutexFC *mutex);
  241. _declspec(dllexport) INT32 mmCondLockDestroy(mmMutexFC *mutex);
  242. _declspec(dllexport) INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex);
  243. _declspec(dllexport) INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond);
  244. _declspec(dllexport) INT32 mmCondNotify(mmCond *cond);
  245. _declspec(dllexport) INT32 mmCondNotifyAll(mmCond *cond);
  246. _declspec(dllexport) INT32 mmCondDestroy(mmCond *cond);
  247. _declspec(dllexport) INT32 mmGetPid(VOID);
  248. _declspec(dllexport) INT32 mmGetTid(VOID);
  249. _declspec(dllexport) INT32 mmGetPidHandle(mmProcess *processHandle);
  250. _declspec(dllexport) INT32 mmGetLocalTime(mmSystemTime_t *sysTime);
  251. _declspec(dllexport) INT32 mmSemInit(mmSem_t *sem, UINT32 value);
  252. _declspec(dllexport) INT32 mmSemWait(mmSem_t *sem);
  253. _declspec(dllexport) INT32 mmSemPost(mmSem_t *sem);
  254. _declspec(dllexport) INT32 mmSemDestroy(mmSem_t *sem);
  255. _declspec(dllexport) INT32 mmOpen(const CHAR *pathName, INT32 flags);
  256. _declspec(dllexport) INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode);
  257. _declspec(dllexport) INT32 mmClose(INT32 fd);
  258. _declspec(dllexport) mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen);
  259. _declspec(dllexport) mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen);
  260. _declspec(dllexport) mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol);
  261. _declspec(dllexport) INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
  262. _declspec(dllexport) INT32 mmListen(mmSockHandle sockFd, INT32 backLog);
  263. _declspec(dllexport) mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen);
  264. _declspec(dllexport) INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
  265. _declspec(dllexport) INT32 mmCloseSocket(mmSockHandle sockFd);
  266. _declspec(dllexport) mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag);
  267. _declspec(dllexport) mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag);
  268. _declspec(dllexport) INT32 mmSAStartup(VOID);
  269. _declspec(dllexport) INT32 mmSACleanup(VOID);
  270. _declspec(dllexport) VOID *mmDlopen(const CHAR *fileName, INT mode);
  271. _declspec(dllexport) VOID *mmDlsym(VOID *handle, CHAR *fileName);
  272. _declspec(dllexport) INT32 mmDlclose(VOID *handle);
  273. _declspec(dllexport) CHAR *mmDlerror(VOID);
  274. _declspec(dllexport) INT32
  275. mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period);
  276. _declspec(dllexport) INT32 mmDeleteTimer(mmTimer timerHandle);
  277. _declspec(dllexport) INT32 mmStatGet(const CHAR *path, mmStat_t *buffer);
  278. _declspec(dllexport) INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer);
  279. _declspec(dllexport) INT32 mmMkdir(const CHAR *pathName, mmMode_t mode);
  280. _declspec(dllexport) INT32 mmSleep(UINT32 milliSecond);
  281. _declspec(dllexport) INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock);
  282. _declspec(dllexport) INT32 mmGetProcessPrio(mmProcess pid);
  283. _declspec(dllexport) INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio);
  284. _declspec(dllexport) INT32 mmGetThreadPrio(mmThread *threadHandle);
  285. _declspec(dllexport) INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio);
  286. _declspec(dllexport) INT32 mmAccess(const CHAR *pathName);
  287. _declspec(dllexport) INT32 mmAccess2(const CHAR *pathName, INT32 mode);
  288. _declspec(dllexport) INT32 mmRmdir(const CHAR *pathName);
  289. _declspec(dllexport) INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr);
  290. _declspec(dllexport) INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout);
  291. _declspec(dllexport) mmSsize_t mmWritev(mmSockHandle fd, mmIovSegment *iov, INT32 iovcnt);
  292. _declspec(dllexport) VOID mmMb();
  293. _declspec(dllexport) INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr);
  294. _declspec(dllexport) mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag);
  295. _declspec(dllexport) mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len);
  296. _declspec(dllexport) mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len);
  297. _declspec(dllexport) INT32 mmCloseFile(mmProcess fileId);
  298. _declspec(dllexport) mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value);
  299. _declspec(dllexport) mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value);
  300. _declspec(dllexport) mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value);
  301. _declspec(dllexport) INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock);
  302. _declspec(dllexport) INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
  303. _declspec(dllexport) INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
  304. _declspec(dllexport) VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]);
  305. _declspec(dllexport) INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
  306. _declspec(dllexport) INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
  307. _declspec(dllexport) VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount);
  308. _declspec(dllexport) mmCompletionHandle mmCreateCompletionPort();
  309. _declspec(dllexport) VOID mmCloseCompletionPort(mmCompletionHandle handle);
  310. _declspec(dllexport) INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP,
  311. pmmPollData polledData, mmPollBack pollBack);
  312. _declspec(dllexport) INT32 mmGetErrorCode();
  313. _declspec(dllexport) INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone);
  314. _declspec(dllexport) mmTimespec mmGetTickCount();
  315. _declspec(dllexport) INT32 mmGetRealPath(CHAR *path, CHAR *realPath);
  316. _declspec(dllexport) INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen);
  317. _declspec(dllexport) INT32 mmDup2(INT32 oldFd, INT32 newFd);
  318. _declspec(dllexport) INT32 mmDup(INT32 fd);
  319. _declspec(dllexport) INT32 mmUnlink(const CHAR *filename);
  320. _declspec(dllexport) INT32 mmChmod(const CHAR *filename, INT32 mode);
  321. _declspec(dllexport) INT32 mmFileno(FILE *stream);
  322. _declspec(dllexport) INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort);
  323. _declspec(dllexport) VOID mmScandirFree(mmDirent **entryList, INT32 count);
  324. _declspec(dllexport) mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag);
  325. _declspec(dllexport) mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag);
  326. _declspec(dllexport) INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);
  327. _declspec(dllexport) INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);
  328. _declspec(dllexport) INT32 mmMsgClose(mmMsgid msqid);
  329. _declspec(dllexport) INT32 mmLocalTimeR(const time_t *timep, struct tm *result);
  330. _declspec(dllexport) INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts);
  331. _declspec(dllexport) INT32
  332. mmGetOptLong(INT32 argc, CHAR *const *argv, const CHAR *opts, const mmStructOption *longopts, INT32 *longindex);
  333. _declspec(dllexport) LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag);
  334. _declspec(dllexport) INT32 mmFtruncate(mmProcess fd, UINT32 length);
  335. _declspec(dllexport) INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *));
  336. _declspec(dllexport) INT32 mmTlsSet(mmThreadKey key, const VOID *value);
  337. _declspec(dllexport) VOID *mmTlsGet(mmThreadKey key);
  338. _declspec(dllexport) INT32 mmTlsDelete(mmThreadKey key);
  339. _declspec(dllexport) INT32 mmGetOsType();
  340. _declspec(dllexport) INT32 mmFsync(mmProcess fd);
  341. _declspec(dllexport) INT32 mmChdir(const CHAR *path);
  342. _declspec(dllexport) INT32 mmUmask(INT32 pmode);
  343. _declspec(dllexport) INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options);
  344. _declspec(dllexport) INT32 mmGetCwd(CHAR *buffer, INT32 maxLen);
  345. _declspec(dllexport) CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr);
  346. _declspec(dllexport) INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len);
  347. _declspec(dllexport) INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite);
  348. _declspec(dllexport) CHAR *mmDirName(CHAR *path);
  349. _declspec(dllexport) CHAR *mmBaseName(CHAR *path);
  350. _declspec(dllexport) INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize);
  351. _declspec(dllexport) INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name);
  352. _declspec(dllexport) INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size);
  353. /*
  354. * Function: set the thread name of the currently executing thread - internal call of thread, which is not supported
  355. * under Windows temporarily, and is null.
  356. * Input: name: the thread name to be set
  357. * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the
  358. * execution failure returns EN_ERROR
  359. */
  360. _declspec(dllexport) INT32 mmSetCurrentThreadName(const CHAR *name);
  361. /*
  362. * Function: Get the thread name of the currently executing thread - thread body call, not supported under windows, null
  363. * implementation.
  364. * Input:name:The name of the thread to get, and the cache is allocated by the user,size>=MMPA_THREADNAME_SIZE.
  365. * The input parameter error returns EN_INVALID_PARAM, the execution success returns
  366. * EN_OK, and the execution failure returns EN_ERROR
  367. */
  368. _declspec(dllexport) INT32 mmGetCurrentThreadName(CHAR *name, INT32 size);
  369. _declspec(dllexport) INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length);
  370. _declspec(dllexport) INT32 mmIsDir(const CHAR *fileName);
  371. _declspec(dllexport) INT32 mmGetOsName(CHAR *name, INT32 nameSize);
  372. _declspec(dllexport) INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength);
  373. _declspec(dllexport) INT32 mmGetMac(mmMacInfo **list, INT32 *count);
  374. _declspec(dllexport) INT32 mmGetMacFree(mmMacInfo *list, INT32 count);
  375. _declspec(dllexport) INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count);
  376. _declspec(dllexport) INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count);
  377. _declspec(dllexport) INT32
  378. mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile, mmProcess *id);
  379. _declspec(dllexport) INT32
  380. mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr);
  381. #ifdef __cplusplus
  382. #if __cplusplus
  383. }
  384. #endif /* __cpluscplus */
  385. #endif // __cpluscplus
  386. #endif // MMPA_WIN_MMPA_WIN_H_

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