osdep.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425
  1. /**
  2. osdep.h -- O/S abstraction for products using MakeMe.
  3. */
  4. #ifndef _h_OSDEP
  5. #define _h_OSDEP 1
  6. /********************************** Includes **********************************/
  7. #include "me.h"
  8. /******************************* Default Features *****************************/
  9. /*
  10. MakeMe defaults
  11. */
  12. #ifndef ME_COM_SSL
  13. #define ME_COM_SSL 0 /**< Build without SSL support */
  14. #endif
  15. #ifndef ME_DEBUG
  16. #define ME_DEBUG 0 /**< Default to a debug build */
  17. #endif
  18. #ifndef ME_FLOAT
  19. #define ME_FLOAT 1 /**< Build with floating point support */
  20. #endif
  21. #ifndef ME_ROM
  22. #define ME_ROM 0 /**< Build for execute from ROM */
  23. #endif
  24. /********************************* CPU Families *******************************/
  25. /*
  26. CPU Architectures
  27. */
  28. #define ME_CPU_UNKNOWN 0
  29. #define ME_CPU_ARM 1 /**< Arm */
  30. #define ME_CPU_ITANIUM 2 /**< Intel Itanium */
  31. #define ME_CPU_X86 3 /**< X86 */
  32. #define ME_CPU_X64 4 /**< AMD64 or EMT64 */
  33. #define ME_CPU_MIPS 5 /**< Mips */
  34. #define ME_CPU_PPC 6 /**< Power PC */
  35. #define ME_CPU_SPARC 7 /**< Sparc */
  36. #define ME_CPU_TIDSP 8 /**< TI DSP */
  37. #define ME_CPU_SH 9 /**< SuperH */
  38. /*
  39. Byte orderings
  40. */
  41. #define ME_LITTLE_ENDIAN 1 /**< Little endian byte ordering */
  42. #define ME_BIG_ENDIAN 2 /**< Big endian byte ordering */
  43. /*
  44. Use compiler definitions to determine the CPU type.
  45. The default endianness can be overridden by configure --endian big|little.
  46. */
  47. #if defined(__alpha__)
  48. #define ME_CPU "alpha"
  49. #define ME_CPU_ARCH ME_CPU_ALPHA
  50. #define CPU_ENDIAN ME_LITTLE_ENDIAN
  51. #elif defined(__arm__)
  52. #define ME_CPU "arm"
  53. #define ME_CPU_ARCH ME_CPU_ARM
  54. #define CPU_ENDIAN ME_LITTLE_ENDIAN
  55. #elif defined(__arm64__) || defined(__aarch64__)
  56. #define ME_CPU "arm"
  57. #define ME_CPU_ARCH ME_CPU_ARM
  58. #define CPU_ENDIAN ME_LITTLE_ENDIAN
  59. #elif defined(__x86_64__) || defined(_M_AMD64)
  60. #define ME_CPU "x64"
  61. #define ME_CPU_ARCH ME_CPU_X64
  62. #define CPU_ENDIAN ME_LITTLE_ENDIAN
  63. #elif defined(__i386__) || defined(__i486__) || defined(__i585__) || defined(__i686__) || defined(_M_IX86)
  64. #define ME_CPU "x86"
  65. #define ME_CPU_ARCH ME_CPU_X86
  66. #define CPU_ENDIAN ME_LITTLE_ENDIAN
  67. #elif defined(_M_IA64)
  68. #define ME_CPU "ia64"
  69. #define ME_CPU_ARCH ME_CPU_ITANIUM
  70. #define CPU_ENDIAN ME_LITTLE_ENDIAN
  71. #elif defined(__mips__) || defined(__mips64)
  72. #define ME_CPU "mips"
  73. #define ME_CPU_ARCH ME_CPU_MIPS
  74. #define CPU_ENDIAN ME_BIG_ENDIAN
  75. #elif defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__) || defined(__ppc)
  76. #define ME_CPU "ppc"
  77. #define ME_CPU_ARCH ME_CPU_PPC
  78. #define CPU_ENDIAN ME_BIG_ENDIAN
  79. #elif defined(__sparc__)
  80. #define ME_CPU "sparc"
  81. #define ME_CPU_ARCH ME_CPU_SPARC
  82. #define CPU_ENDIAN ME_BIG_ENDIAN
  83. #elif defined(_TMS320C6X)
  84. #define TIDSP 1
  85. #define ME_CPU "tidsp"
  86. #define ME_CPU_ARCH ME_CPU_SPARC
  87. #define CPU_ENDIAN ME_LITTLE_ENDIAN
  88. #elif defined(__sh__)
  89. #define ME_CPU "sh"
  90. #define ME_CPU_ARCH ME_CPU_SH
  91. #define CPU_ENDIAN ME_LITTLE_ENDIAN
  92. #else
  93. #error "Cannot determine CPU type in osdep.h"
  94. #endif
  95. /*
  96. Set the default endian if me.h does not define it explicitly
  97. */
  98. #ifndef ME_ENDIAN
  99. #define ME_ENDIAN CPU_ENDIAN
  100. #endif
  101. /*
  102. Operating system defines. Use compiler standard defintions to sleuth. Works for all except VxWorks which does not
  103. define any special symbol. NOTE: Support for SCOV Unix, LynxOS and UnixWare is deprecated.
  104. */
  105. #if defined(__APPLE__)
  106. #define ME_OS "macosx"
  107. #define MACOSX 1
  108. #define ME_UNIX_LIKE 1
  109. #define ME_WIN_LIKE 0
  110. #define ME_BSD_LIKE 1
  111. #define HAS_USHORT 1
  112. #define HAS_UINT 1
  113. #elif defined(__linux__)
  114. #define ME_OS "linux"
  115. #define LINUX 1
  116. #define ME_UNIX_LIKE 1
  117. #define ME_WIN_LIKE 0
  118. #elif defined(__FreeBSD__)
  119. #define ME_OS "freebsd"
  120. #define FREEBSD 1
  121. #define ME_UNIX_LIKE 1
  122. #define ME_WIN_LIKE 0
  123. #define ME_BSD_LIKE 1
  124. #define HAS_USHORT 1
  125. #define HAS_UINT 1
  126. #elif defined(__OpenBSD__)
  127. #define ME_OS "freebsd"
  128. #define OPENBSD 1
  129. #define ME_UNIX_LIKE 1
  130. #define ME_WIN_LIKE 0
  131. #define ME_BSD_LIKE 1
  132. #elif defined(_WIN32)
  133. #define ME_OS "windows"
  134. #define WINDOWS 1
  135. #define ME_UNIX_LIKE 0
  136. #define ME_WIN_LIKE 1
  137. #elif defined(__OS2__)
  138. #define ME_OS "os2"
  139. #define OS2 0
  140. #define ME_UNIX_LIKE 0
  141. #define ME_WIN_LIKE 0
  142. #elif defined(MSDOS) || defined(__DME__)
  143. #define ME_OS "msdos"
  144. #define WINDOWS 0
  145. #define ME_UNIX_LIKE 0
  146. #define ME_WIN_LIKE 0
  147. #elif defined(__NETWARE_386__)
  148. #define ME_OS "netware"
  149. #define NETWARE 0
  150. #define ME_UNIX_LIKE 0
  151. #define ME_WIN_LIKE 0
  152. #elif defined(__bsdi__)
  153. #define ME_OS "bsdi"
  154. #define BSDI 1
  155. #define ME_UNIX_LIKE 1
  156. #define ME_WIN_LIKE 0
  157. #define ME_BSD_LIKE 1
  158. #elif defined(__NetBSD__)
  159. #define ME_OS "netbsd"
  160. #define NETBSD 1
  161. #define ME_UNIX_LIKE 1
  162. #define ME_WIN_LIKE 0
  163. #define ME_BSD_LIKE 1
  164. #elif defined(__QNX__)
  165. #define ME_OS "qnx"
  166. #define QNX 0
  167. #define ME_UNIX_LIKE 0
  168. #define ME_WIN_LIKE 0
  169. #elif defined(__hpux)
  170. #define ME_OS "hpux"
  171. #define HPUX 1
  172. #define ME_UNIX_LIKE 1
  173. #define ME_WIN_LIKE 0
  174. #elif defined(_AIX)
  175. #define ME_OS "aix"
  176. #define AIX 1
  177. #define ME_UNIX_LIKE 1
  178. #define ME_WIN_LIKE 0
  179. #elif defined(__CYGWIN__)
  180. #define ME_OS "cygwin"
  181. #define CYGWIN 1
  182. #define ME_UNIX_LIKE 1
  183. #define ME_WIN_LIKE 0
  184. #elif defined(__VMS)
  185. #define ME_OS "vms"
  186. #define VMS 1
  187. #define ME_UNIX_LIKE 0
  188. #define ME_WIN_LIKE 0
  189. #elif defined(VXWORKS)
  190. /* VxWorks does not have a pre-defined symbol */
  191. #define ME_OS "vxworks"
  192. #define ME_UNIX_LIKE 0
  193. #define ME_WIN_LIKE 0
  194. #define HAS_USHORT 1
  195. #elif defined(ECOS)
  196. /* ECOS may not have a pre-defined symbol */
  197. #define ME_OS "ecos"
  198. #define ME_UNIX_LIKE 0
  199. #define ME_WIN_LIKE 0
  200. #elif defined(TIDSP)
  201. #define ME_OS "tidsp"
  202. #define ME_UNIX_LIKE 0
  203. #define ME_WIN_LIKE 0
  204. #define HAS_INT32 1
  205. #endif
  206. #if __WORDSIZE == 64 || __amd64 || __x86_64 || __x86_64__ || _WIN64 || __mips64 || __arch64__ || __arm64__ || __aarch64__
  207. #define ME_64 1
  208. #define ME_WORDSIZE 64
  209. #else
  210. #define ME_64 0
  211. #define ME_WORDSIZE 32
  212. #endif
  213. /*
  214. Unicode
  215. */
  216. #ifndef ME_CHAR_LEN
  217. #define ME_CHAR_LEN 1
  218. #endif
  219. #if ME_CHAR_LEN == 4
  220. typedef int wchar;
  221. #define UT(s) L ## s
  222. #define UNICODE 1
  223. #elif ME_CHAR_LEN == 2
  224. typedef short wchar;
  225. #define UT(s) L ## s
  226. #define UNICODE 1
  227. #else
  228. typedef char wchar;
  229. #define UT(s) s
  230. #endif
  231. #define ME_PLATFORM ME_OS "-" ME_CPU "-" ME_PROFILE
  232. /********************************* O/S Includes *******************************/
  233. /*
  234. Out-of-order definitions and includes. Order really matters in this section.
  235. */
  236. #if WINDOWS
  237. #undef _CRT_SECURE_NO_DEPRECATE
  238. #define _CRT_SECURE_NO_DEPRECATE 1
  239. #undef _CRT_SECURE_NO_WARNINGS
  240. #define _CRT_SECURE_NO_WARNINGS 1
  241. #define _WINSOCK_DEPRECATED_NO_WARNINGS 1
  242. #ifndef _WIN32_WINNT
  243. /* Target Windows 7 by default */
  244. #define _WIN32_WINNT 0x601
  245. #endif
  246. /*
  247. Work-around to allow the windows 7.* SDK to be used with VS 2012
  248. MSC_VER 1800 2013
  249. MSC_VER 1900 2015
  250. */
  251. #if _MSC_VER >= 1700
  252. #define SAL_SUPP_H
  253. #define SPECSTRING_SUPP_H
  254. #endif
  255. #endif
  256. #if LINUX
  257. /*
  258. Use GNU extensions for:
  259. RTLD_DEFAULT for dlsym()
  260. */
  261. #define _GNU_SOURCE 1
  262. #if !ME_64
  263. #define _LARGEFILE64_SOURCE 1
  264. #ifdef __USE_FILE_OFFSET64
  265. #define _FILE_OFFSET_BITS 64
  266. #endif
  267. #endif
  268. #endif
  269. #if VXWORKS
  270. #ifndef _VSB_CONFIG_FILE
  271. #define _VSB_CONFIG_FILE "vsbConfig.h"
  272. #endif
  273. #include <vxWorks.h>
  274. #endif
  275. #if ME_WIN_LIKE
  276. #include <winsock2.h>
  277. #include <windows.h>
  278. #include <winbase.h>
  279. #include <winuser.h>
  280. #include <shlobj.h>
  281. #include <shellapi.h>
  282. #include <wincrypt.h>
  283. #include <ws2tcpip.h>
  284. #include <conio.h>
  285. #include <process.h>
  286. #include <windows.h>
  287. #include <shlobj.h>
  288. #if _MSC_VER >= 1800
  289. #include <stdbool.h>
  290. #endif
  291. #if ME_DEBUG
  292. #include <crtdbg.h>
  293. #endif
  294. #endif
  295. /*
  296. Includes in alphabetic order
  297. */
  298. #include <ctype.h>
  299. #if ME_WIN_LIKE
  300. #include <direct.h>
  301. #else
  302. #include <dirent.h>
  303. #endif
  304. #if ME_UNIX_LIKE
  305. #include <dlfcn.h>
  306. #endif
  307. #include <fcntl.h>
  308. #include <errno.h>
  309. #if ME_FLOAT
  310. #include <float.h>
  311. #define __USE_ISOC99 1
  312. #include <math.h>
  313. #endif
  314. #if ME_UNIX_LIKE
  315. #include <grp.h>
  316. #endif
  317. #if ME_WIN_LIKE
  318. #include <io.h>
  319. #endif
  320. #if MACOSX || LINUX
  321. #include <libgen.h>
  322. #endif
  323. #include <limits.h>
  324. #if ME_UNIX_LIKE || VXWORKS
  325. #include <sys/socket.h>
  326. #include <arpa/inet.h>
  327. #include <netdb.h>
  328. #include <net/if.h>
  329. #include <netinet/in.h>
  330. #include <netinet/tcp.h>
  331. #include <netinet/ip.h>
  332. #endif
  333. #if ME_UNIX_LIKE
  334. #include <pthread.h>
  335. #include <pwd.h>
  336. #if !CYGWIN
  337. #include <resolv.h>
  338. #endif
  339. #endif
  340. #if ME_BSD_LIKE
  341. #include <readpassphrase.h>
  342. #include <sys/sysctl.h>
  343. #include <sys/event.h>
  344. #endif
  345. #include <setjmp.h>
  346. #include <signal.h>
  347. #include <stdarg.h>
  348. #if ME_UNIX_LIKE
  349. #include <stdint.h>
  350. #endif
  351. #include <stdio.h>
  352. #include <stdlib.h>
  353. #include <string.h>
  354. #if ME_UNIX_LIKE
  355. #include <syslog.h>
  356. #endif
  357. #if !TIDSP
  358. #include <sys/stat.h>
  359. #include <sys/types.h>
  360. #endif
  361. #if ME_UNIX_LIKE
  362. #include <sys/ioctl.h>
  363. #include <sys/mman.h>
  364. #include <sys/resource.h>
  365. #include <sys/select.h>
  366. #include <sys/time.h>
  367. #include <sys/times.h>
  368. #include <sys/utsname.h>
  369. #include <sys/uio.h>
  370. #include <sys/wait.h>
  371. #include <poll.h>
  372. #include <unistd.h>
  373. #endif
  374. #include <time.h>
  375. #if !VXWORKS && !TIDSP
  376. #include <wchar.h>
  377. #endif
  378. /*
  379. Extra includes per O/S
  380. */
  381. #if CYGWIN
  382. #include "w32api/windows.h"
  383. #include "sys/cygwin.h"
  384. #endif
  385. #if LINUX
  386. #include <linux/version.h>
  387. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  388. #include <sys/epoll.h>
  389. #endif
  390. #include <sys/prctl.h>
  391. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
  392. #include <sys/eventfd.h>
  393. #endif
  394. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
  395. #define HAS_INOTIFY 1
  396. #include <sys/inotify.h>
  397. #else
  398. #define HAS_INOTIFY 0
  399. #endif
  400. #if !__UCLIBC__
  401. #include <sys/sendfile.h>
  402. #endif
  403. #endif
  404. #if MACOSX
  405. #include <stdbool.h>
  406. #include <mach-o/dyld.h>
  407. #include <mach-o/dyld.h>
  408. #include <mach/mach_init.h>
  409. #include <mach/mach_time.h>
  410. #include <mach/task.h>
  411. #include <libkern/OSAtomic.h>
  412. #endif
  413. #if VXWORKS
  414. #include <vxWorks.h>
  415. #include <envLib.h>
  416. #include <iosLib.h>
  417. #include <loadLib.h>
  418. #include <selectLib.h>
  419. #include <sockLib.h>
  420. #include <inetLib.h>
  421. #include <ioLib.h>
  422. #include <pipeDrv.h>
  423. #include <hostLib.h>
  424. #include <sysSymTbl.h>
  425. #include <sys/fcntlcom.h>
  426. #include <tickLib.h>
  427. #include <taskHookLib.h>
  428. #include <unldLib.h>
  429. #if _WRS_VXWORKS_MAJOR >= 6
  430. #include <taskLibCommon.h>
  431. #include <wait.h>
  432. #endif
  433. #if _WRS_VXWORKS_MAJOR > 6 || (_WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR >= 8)
  434. #include <symSync.h>
  435. #include <vxAtomicLib.h>
  436. #endif
  437. #endif
  438. #if TIDSP
  439. #include <mathf.h>
  440. #include <netmain.h>
  441. #include <nettools/inc/dnsif.h>
  442. #include <socket.h>
  443. #include <file.h>
  444. #endif
  445. #if ME_COMPILER_HAS_ATOMIC
  446. #include <stdatomic.h>
  447. #endif
  448. /************************************** Types *********************************/
  449. /*
  450. Standard types
  451. */
  452. #ifndef HAS_BOOL
  453. #ifndef __cplusplus
  454. #if !MACOSX
  455. #define HAS_BOOL 1
  456. /**
  457. Boolean data type.
  458. */
  459. #if !WINDOWS || ((_MSC_VER < 1800) && !defined(bool))
  460. /* Bool introduced via stdbool in VS 2015 */
  461. typedef char bool;
  462. #endif
  463. #endif
  464. #endif
  465. #endif
  466. #ifndef HAS_UCHAR
  467. #define HAS_UCHAR 1
  468. /**
  469. Unsigned char data type.
  470. */
  471. typedef unsigned char uchar;
  472. #endif
  473. #ifndef HAS_SCHAR
  474. #define HAS_SCHAR 1
  475. /**
  476. Signed char data type.
  477. */
  478. typedef signed char schar;
  479. #endif
  480. #ifndef HAS_CCHAR
  481. #define HAS_CCHAR 1
  482. /**
  483. Constant char data type.
  484. */
  485. typedef const char cchar;
  486. #endif
  487. #ifndef HAS_CUCHAR
  488. #define HAS_CUCHAR 1
  489. /**
  490. Unsigned char data type.
  491. */
  492. typedef const unsigned char cuchar;
  493. #endif
  494. #ifndef HAS_USHORT
  495. #define HAS_USHORT 1
  496. /**
  497. Unsigned short data type.
  498. */
  499. typedef unsigned short ushort;
  500. #endif
  501. #ifndef HAS_CUSHORT
  502. #define HAS_CUSHORT 1
  503. /**
  504. Constant unsigned short data type.
  505. */
  506. typedef const unsigned short cushort;
  507. #endif
  508. #ifndef HAS_CVOID
  509. #define HAS_CVOID 1
  510. /**
  511. Constant void data type.
  512. */
  513. typedef const void cvoid;
  514. #endif
  515. #ifndef HAS_INT8
  516. #define HAS_INT8 1
  517. /**
  518. Integer 8 bits data type.
  519. */
  520. typedef char int8;
  521. #endif
  522. #ifndef HAS_UINT8
  523. #define HAS_UINT8 1
  524. /**
  525. Unsigned integer 8 bits data type.
  526. */
  527. typedef unsigned char uint8;
  528. #endif
  529. #ifndef HAS_INT16
  530. #define HAS_INT16 1
  531. /**
  532. Integer 16 bits data type.
  533. */
  534. typedef short int16;
  535. #endif
  536. #ifndef HAS_UINT16
  537. #define HAS_UINT16 1
  538. /**
  539. Unsigned integer 16 bits data type.
  540. */
  541. typedef unsigned short uint16;
  542. #endif
  543. #ifndef HAS_INT32
  544. #define HAS_INT32 1
  545. /**
  546. Integer 32 bits data type.
  547. */
  548. typedef int int32;
  549. #endif
  550. #ifndef HAS_UINT32
  551. #define HAS_UINT32 1
  552. /**
  553. Unsigned integer 32 bits data type.
  554. */
  555. typedef unsigned int uint32;
  556. #endif
  557. #ifndef HAS_UINT
  558. #define HAS_UINT 1
  559. /**
  560. Unsigned integer (machine dependent bit size) data type.
  561. */
  562. typedef unsigned int uint;
  563. #endif
  564. #ifndef HAS_ULONG
  565. #define HAS_ULONG 1
  566. /**
  567. Unsigned long (machine dependent bit size) data type.
  568. */
  569. typedef unsigned long ulong;
  570. #endif
  571. #ifndef HAS_CINT
  572. #define HAS_CINT 1
  573. /**
  574. Constant int data type.
  575. */
  576. typedef const int cint;
  577. #endif
  578. #ifndef HAS_SSIZE
  579. #define HAS_SSIZE 1
  580. #if ME_UNIX_LIKE || VXWORKS || DOXYGEN
  581. /**
  582. Signed integer size field large enough to hold a pointer offset.
  583. */
  584. typedef ssize_t ssize;
  585. #elif TIDSP
  586. typedef int ssize_t;
  587. typedef ssize_t ssize;
  588. #else
  589. typedef SSIZE_T ssize;
  590. #endif
  591. #endif
  592. /*
  593. Windows uses uint for write/read counts (Ugh!)
  594. */
  595. #if ME_WIN_LIKE
  596. typedef uint wsize;
  597. #else
  598. typedef ssize wsize;
  599. #endif
  600. #ifndef HAS_INT64
  601. #if ME_UNIX_LIKE
  602. __extension__ typedef long long int int64;
  603. #elif VXWORKS || DOXYGEN
  604. /**
  605. Integer 64 bit data type.
  606. */
  607. typedef long long int int64;
  608. #elif ME_WIN_LIKE
  609. typedef __int64 int64;
  610. #else
  611. typedef long long int int64;
  612. #endif
  613. #endif
  614. #ifndef HAS_UINT64
  615. #if ME_UNIX_LIKE
  616. __extension__ typedef unsigned long long int uint64;
  617. #elif VXWORKS || DOXYGEN
  618. typedef unsigned long long int uint64;
  619. #elif ME_WIN_LIKE
  620. typedef unsigned __int64 uint64;
  621. #else
  622. typedef unsigned long long int uint64;
  623. #endif
  624. #endif
  625. /**
  626. Signed file offset data type. Supports large files greater than 4GB in size on all systems.
  627. */
  628. typedef int64 Offset;
  629. #if DOXYGEN
  630. /** Size to hold the length of a socket address */
  631. typedef int Socklen;
  632. #elif VXWORKS
  633. typedef int Socklen;
  634. #else
  635. typedef socklen_t Socklen;
  636. #endif
  637. #if DOXYGEN || ME_UNIX_LIKE || VXWORKS
  638. /** Argument for sockets */
  639. typedef int Socket;
  640. #ifndef SOCKET_ERROR
  641. #define SOCKET_ERROR -1
  642. #endif
  643. #define SOCKET_ERROR -1
  644. #ifndef INVALID_SOCKET
  645. #define INVALID_SOCKET -1
  646. #endif
  647. #elif ME_WIN_LIKE
  648. typedef SOCKET Socket;
  649. #elif TIDSP
  650. typedef SOCKET Socket;
  651. #define SOCKET_ERROR INVALID_SOCKET
  652. #else
  653. typedef int Socket;
  654. #ifndef SOCKET_ERROR
  655. #define SOCKET_ERROR -1
  656. #endif
  657. #ifndef INVALID_SOCKET
  658. #define INVALID_SOCKET -1
  659. #endif
  660. #endif
  661. typedef int64 Time;
  662. /**
  663. Elapsed time data type. Stores time in milliseconds from some arbitrary start epoch.
  664. */
  665. typedef int64 Ticks;
  666. /**
  667. Time/Ticks units per second (milliseconds)
  668. */
  669. #define TPS 1000
  670. /*********************************** Defines **********************************/
  671. #ifndef BITSPERBYTE
  672. #define BITSPERBYTE ((int) (8 * sizeof(char)))
  673. #endif
  674. #ifndef BITS
  675. #define BITS(type) ((int) (BITSPERBYTE * (int) sizeof(type)))
  676. #endif
  677. #if ME_FLOAT
  678. #ifndef MAXFLOAT
  679. #if ME_WIN_LIKE
  680. #define MAXFLOAT DBL_MAX
  681. #else
  682. #define MAXFLOAT FLT_MAX
  683. #endif
  684. #endif
  685. #if VXWORKS
  686. #undef isnan
  687. #define isnan(n) ((n) != (n))
  688. #define isnanf(n) ((n) != (n))
  689. #define isinf(n) ((n) == (1.0 / 0.0) || (n) == (-1.0 / 0.0))
  690. #define isinff(n) ((n) == (1.0 / 0.0) || (n) == (-1.0 / 0.0))
  691. #endif
  692. #if ME_WIN_LIKE
  693. #define isNan(f) (_isnan(f))
  694. #elif VXWORKS || MACOSX || LINUX
  695. #define isNan(f) (isnan(f))
  696. #else
  697. #define isNan(f) (fpclassify(f) == FP_NAN)
  698. #endif
  699. #endif
  700. #if ME_WIN_LIKE
  701. #define INT64(x) (x##i64)
  702. #define UINT64(x) (x##Ui64)
  703. #else
  704. #define INT64(x) (x##LL)
  705. #define UINT64(x) (x##ULL)
  706. #endif
  707. #ifndef MAXINT
  708. #if INT_MAX
  709. #define MAXINT INT_MAX
  710. #else
  711. #define MAXINT 0x7fffffff
  712. #endif
  713. #endif
  714. #ifndef MAXUINT
  715. #if UINT_MAX
  716. #define MAXUINT UINT_MAX
  717. #else
  718. #define MAXUINT 0xffffffff
  719. #endif
  720. #endif
  721. #ifndef MAXINT64
  722. #define MAXINT64 INT64(0x7fffffffffffffff)
  723. #endif
  724. #ifndef MAXUINT64
  725. #define MAXUINT64 INT64(0xffffffffffffffff)
  726. #endif
  727. #if SIZE_T_MAX
  728. #define MAXSIZE SIZE_T_MAX
  729. #elif ME_64
  730. #define MAXSIZE INT64(0xffffffffffffffff)
  731. #else
  732. #define MAXSIZE MAXINT
  733. #endif
  734. #if SSIZE_T_MAX
  735. #define MAXSSIZE SSIZE_T_MAX
  736. #elif ME_64
  737. #define MAXSSIZE INT64(0x7fffffffffffffff)
  738. #else
  739. #define MAXSSIZE MAXINT
  740. #endif
  741. #if OFF_T_MAX
  742. #define MAXOFF OFF_T_MAX
  743. #else
  744. #define MAXOFF INT64(0x7fffffffffffffff)
  745. #endif
  746. /*
  747. Word size and conversions between integer and pointer.
  748. */
  749. #if ME_64
  750. #define ITOP(i) ((void*) ((int64) i))
  751. #define PTOI(i) ((int) ((int64) i))
  752. #define LTOP(i) ((void*) ((int64) i))
  753. #define PTOL(i) ((int64) i)
  754. #else
  755. #define ITOP(i) ((void*) ((int) i))
  756. #define PTOI(i) ((int) i)
  757. #define LTOP(i) ((void*) ((int) i))
  758. #define PTOL(i) ((int64) (int) i)
  759. #endif
  760. #undef PUBLIC
  761. #undef PUBLIC_DATA
  762. #undef PRIVATE
  763. #if ME_WIN_LIKE
  764. /*
  765. Use PUBLIC on function declarations and definitions (*.c and *.h).
  766. */
  767. #define PUBLIC __declspec(dllexport)
  768. #define PUBLIC_DATA __declspec(dllexport)
  769. #define PRIVATE static
  770. #else
  771. #define PUBLIC
  772. #define PUBLIC_DATA extern
  773. #define PRIVATE static
  774. #endif
  775. /* Undefines for Qt - Ugh */
  776. #undef max
  777. #undef min
  778. #define max(a,b) (((a) > (b)) ? (a) : (b))
  779. #define min(a,b) (((a) < (b)) ? (a) : (b))
  780. #ifndef PRINTF_ATTRIBUTE
  781. #if ((__GNUC__ >= 3) && !DOXYGEN) || MACOSX
  782. /**
  783. Use gcc attribute to check printf fns. a1 is the 1-based index of the parameter containing the format,
  784. and a2 the index of the first argument. Note that some gcc 2.x versions don't handle this properly
  785. */
  786. #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
  787. #else
  788. #define PRINTF_ATTRIBUTE(a1, a2)
  789. #endif
  790. #endif
  791. /*
  792. Optimize expression evaluation code depending if the value is likely or not
  793. */
  794. #undef likely
  795. #undef unlikely
  796. #if (__GNUC__ >= 3)
  797. #define likely(x) __builtin_expect(!!(x), 1)
  798. #define unlikely(x) __builtin_expect(!!(x), 0)
  799. #else
  800. #define likely(x) (x)
  801. #define unlikely(x) (x)
  802. #endif
  803. #if !__UCLIBC__ && !CYGWIN && __USE_XOPEN2K
  804. #define ME_COMPILER_HAS_SPINLOCK 1
  805. #endif
  806. #if ME_COMPILER_HAS_DOUBLE_BRACES
  807. #define NULL_INIT {{0}}
  808. #else
  809. #define NULL_INIT {0}
  810. #endif
  811. #ifdef __USE_FILE_OFFSET64
  812. #define ME_COMPILER_HAS_OFF64 1
  813. #else
  814. #define ME_COMPILER_HAS_OFF64 0
  815. #endif
  816. #if ME_UNIX_LIKE
  817. #define ME_COMPILER_HAS_FCNTL 1
  818. #endif
  819. #ifndef R_OK
  820. #define R_OK 4
  821. #define W_OK 2
  822. #if ME_WIN_LIKE
  823. #define X_OK R_OK
  824. #else
  825. #define X_OK 1
  826. #endif
  827. #define F_OK 0
  828. #endif
  829. #if MACOSX
  830. #define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH"
  831. #else
  832. #define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
  833. #endif
  834. #if VXWORKS
  835. /*
  836. Old VxWorks cannot do array[]
  837. */
  838. #define ARRAY_FLEX 0
  839. #else
  840. #define ARRAY_FLEX
  841. #endif
  842. /*
  843. Deprecated API warnings
  844. */
  845. #if ((__GNUC__ >= 3) || MACOSX) && !VXWORKS && ME_DEPRECATED_WARNINGS
  846. #define ME_DEPRECATED(MSG) __attribute__ ((deprecated(MSG)))
  847. #else
  848. #define ME_DEPRECATED(MSG)
  849. #endif
  850. #define NOT_USED(x) ((void*) x)
  851. /********************************** Tunables *********************************/
  852. /*
  853. These can be defined in main.bit settings (pascal case) to override. E.g.
  854. settings: {
  855. maxPath: 4096
  856. }
  857. */
  858. #ifndef ME_MAX_FNAME
  859. #define ME_MAX_FNAME 256 /**< Reasonable filename size */
  860. #endif
  861. #ifndef ME_MAX_PATH
  862. #define ME_MAX_PATH 1024 /**< Reasonable filename size */
  863. #endif
  864. #ifndef ME_BUFSIZE
  865. #define ME_BUFSIZE 4096 /**< Reasonable size for buffers */
  866. #endif
  867. #ifndef ME_MAX_BUFFER
  868. #define ME_MAX_BUFFER ME_BUFSIZE /* DEPRECATE */
  869. #endif
  870. #ifndef ME_MAX_ARGC
  871. #define ME_MAX_ARGC 32 /**< Maximum number of command line args if using MAIN()*/
  872. #endif
  873. #ifndef ME_DOUBLE_BUFFER
  874. #define ME_DOUBLE_BUFFER (DBL_MANT_DIG - DBL_MIN_EXP + 4)
  875. #endif
  876. #ifndef ME_MAX_IP
  877. #define ME_MAX_IP 1024
  878. #endif
  879. #ifndef ME_STACK_SIZE
  880. #if ME_COMPILER_HAS_MMU && !VXWORKS
  881. /*
  882. If the system supports virtual memory, then stack size should use system default. Only used pages will
  883. actually consume memory
  884. */
  885. #define ME_STACK_SIZE 0 /**< Default thread stack size (0 means use system default) */
  886. #else
  887. /*
  888. No MMU, so the stack size actually consumes memory. Set this as low as possible.
  889. NOTE: php and ejs use stack heavily.
  890. */
  891. #define ME_STACK_SIZE (128 * 1024) /**< Default thread stack size (0 means use system default) */
  892. #endif
  893. #endif
  894. /*********************************** Fixups ***********************************/
  895. #ifndef ME_INLINE
  896. #if ME_WIN_LIKE
  897. #define ME_INLINE __inline
  898. #else
  899. #define ME_INLINE inline
  900. #endif
  901. #endif
  902. #if ECOS
  903. #define LIBKERN_INLINE /* to avoid kernel inline functions */
  904. #endif /* ECOS */
  905. #if ME_UNIX_LIKE || VXWORKS || TIDSP
  906. #define FILE_TEXT ""
  907. #define FILE_BINARY ""
  908. #endif
  909. #if !TIDSP
  910. #define ME_COMPILER_HAS_MACRO_VARARGS 1
  911. #else
  912. #define ME_COMPILER_HAS_MACRO_VARARGS 1
  913. #endif
  914. #if ME_UNIX_LIKE
  915. #define closesocket(x) close(x)
  916. #if !defined(PTHREAD_MUTEX_RECURSIVE_NP) || FREEBSD
  917. #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
  918. #else
  919. #ifndef PTHREAD_MUTEX_RECURSIVE
  920. #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
  921. #endif
  922. #endif
  923. #endif
  924. #if !ME_WIN_LIKE && !CYGWIN
  925. #ifndef O_BINARY
  926. #define O_BINARY 0
  927. #endif
  928. #ifndef O_TEXT
  929. #define O_TEXT 0
  930. #endif
  931. #endif
  932. #if !LINUX
  933. #define __WALL 0
  934. #if !CYGWIN && !defined(MSG_NOSIGNAL)
  935. #define MSG_NOSIGNAL 0
  936. #endif
  937. #endif
  938. #if ME_BSD_LIKE
  939. /*
  940. Fix for MAC OS X - getenv
  941. */
  942. #if !HAVE_DECL_ENVIRON
  943. #ifdef __APPLE__
  944. #include <crt_externs.h>
  945. #define environ (*_NSGetEnviron())
  946. #else
  947. extern char **environ;
  948. #endif
  949. #endif
  950. #endif
  951. #if SOLARIS
  952. #define INADDR_NONE ((in_addr_t) 0xffffffff)
  953. #endif
  954. #ifdef SIGINFO
  955. #define ME_SIGINFO SIGINFO
  956. #elif defined(SIGPWR)
  957. #define ME_SIGINFO SIGPWR
  958. #else
  959. #define ME_SIGINFO (0)
  960. #endif
  961. #if VXWORKS
  962. #ifndef SHUT_RDWR
  963. #define SHUT_RDWR 2
  964. #endif
  965. #define HAVE_SOCKLEN_T
  966. #if _DIAB_TOOL
  967. #define inline __inline__
  968. #define MPR_INLINE __inline__
  969. #endif
  970. #ifndef closesocket
  971. #define closesocket(x) close(x)
  972. #endif
  973. #ifndef va_copy
  974. #define va_copy(d, s) ((d) = (s))
  975. #endif
  976. #ifndef strcasecmp
  977. #define strcasecmp scaselesscmp
  978. #endif
  979. #ifndef strncasecmp
  980. #define strncasecmp sncaselesscmp
  981. #endif
  982. #endif
  983. #if ME_WIN_LIKE
  984. typedef int uid_t;
  985. typedef void *handle;
  986. typedef char *caddr_t;
  987. typedef long pid_t;
  988. typedef int gid_t;
  989. typedef ushort mode_t;
  990. typedef void *siginfo_t;
  991. typedef int socklen_t;
  992. #define HAVE_SOCKLEN_T
  993. #define MSG_NOSIGNAL 0
  994. #define FILE_BINARY "b"
  995. #define FILE_TEXT "t"
  996. /*
  997. Error codes
  998. */
  999. #define EPERM 1
  1000. #define ENOENT 2
  1001. #define ESRCH 3
  1002. #define EINTR 4
  1003. #define EIO 5
  1004. #define ENXIO 6
  1005. #define E2BIG 7
  1006. #define ENOEXEC 8
  1007. #define EBADF 9
  1008. #define ECHILD 10
  1009. #define EAGAIN 11
  1010. #define ENOMEM 12
  1011. #define EACCES 13
  1012. #define EFAULT 14
  1013. #define EOSERR 15
  1014. #define EBUSY 16
  1015. #define EEXIST 17
  1016. #define EXDEV 18
  1017. #define ENODEV 19
  1018. #define ENOTDIR 20
  1019. #define EISDIR 21
  1020. #define EINVAL 22
  1021. #define ENFILE 23
  1022. #define EMFILE 24
  1023. #define ENOTTY 25
  1024. #define EFBIG 27
  1025. #define ENOSPC 28
  1026. #define ESPIPE 29
  1027. #define EROFS 30
  1028. #define EMLINK 31
  1029. #define EPIPE 32
  1030. #define EDOM 33
  1031. #define ERANGE 34
  1032. #ifndef EWOULDBLOCK
  1033. #define EWOULDBLOCK EAGAIN
  1034. #define EINPROGRESS 36
  1035. #define EALREADY 37
  1036. #define ENETDOWN 43
  1037. #define ECONNRESET 44
  1038. #define ECONNREFUSED 45
  1039. #define EADDRNOTAVAIL 49
  1040. #define EISCONN 56
  1041. #define EADDRINUSE 46
  1042. #define ENETUNREACH 51
  1043. #define ECONNABORTED 53
  1044. #endif
  1045. #ifndef ENOTCONN
  1046. #define ENOTCONN 126
  1047. #endif
  1048. #ifndef EPROTO
  1049. #define EPROTO 134
  1050. #endif
  1051. #undef SHUT_RDWR
  1052. #define SHUT_RDWR 2
  1053. #define TIME_GENESIS UINT64(11644473600000000)
  1054. #ifndef va_copy
  1055. #define va_copy(d, s) ((d) = (s))
  1056. #endif
  1057. #if !WINCE
  1058. #define access _access
  1059. #define chdir _chdir
  1060. #define chmod _chmod
  1061. #define close _close
  1062. #define fileno _fileno
  1063. #define fstat _fstat
  1064. #define getcwd _getcwd
  1065. #define getpid _getpid
  1066. #define gettimezone _gettimezone
  1067. #define lseek _lseek
  1068. #define mkdir(a,b) _mkdir(a)
  1069. #define open _open
  1070. #define putenv _putenv
  1071. #define read _read
  1072. #define rmdir(a) _rmdir(a)
  1073. #define stat _stat
  1074. #define strdup _strdup
  1075. #define tempnam _tempnam
  1076. #define umask _umask
  1077. #define unlink _unlink
  1078. #define write _write
  1079. PUBLIC void sleep(int secs);
  1080. #endif
  1081. #define strcasecmp scaselesscmp
  1082. #define strncasecmp sncaselesscmp
  1083. #pragma comment( lib, "ws2_32.lib" )
  1084. #endif /* WIN_LIKE */
  1085. #if WINCE
  1086. typedef void FILE;
  1087. typedef int off_t;
  1088. #ifndef EOF
  1089. #define EOF -1
  1090. #endif
  1091. #define O_RDONLY 0
  1092. #define O_WRONLY 1
  1093. #define O_RDWR 2
  1094. #define O_NDELAY 0x4
  1095. #define O_NONBLOCK 0x4
  1096. #define O_APPEND 0x8
  1097. #define O_CREAT 0x100
  1098. #define O_TRUNC 0x200
  1099. #define O_TEXT 0x400
  1100. #define O_EXCL 0x800
  1101. #define O_BINARY 0x1000
  1102. /*
  1103. stat flags
  1104. */
  1105. #define S_IFMT 0170000
  1106. #define S_IFDIR 0040000
  1107. #define S_IFCHR 0020000 /* character special */
  1108. #define S_IFIFO 0010000
  1109. #define S_IFREG 0100000
  1110. #define S_IREAD 0000400
  1111. #define S_IWRITE 0000200
  1112. #define S_IEXEC 0000100
  1113. #ifndef S_ISDIR
  1114. #define S_ISDIR(X) (((X) & S_IFMT) == S_IFDIR)
  1115. #endif
  1116. #ifndef S_ISREG
  1117. #define S_ISREG(X) (((X) & S_IFMT) == S_IFREG)
  1118. #endif
  1119. #define STARTF_USESHOWWINDOW 0
  1120. #define STARTF_USESTDHANDLES 0
  1121. #define BUFSIZ ME_BUFSIZE
  1122. #define PATHSIZE ME_MAX_PATH
  1123. #define gethostbyname2(a,b) gethostbyname(a)
  1124. #pragma comment( lib, "ws2.lib" )
  1125. #endif /* WINCE */
  1126. #if TIDSP
  1127. #define EINTR 4
  1128. #define EAGAIN 11
  1129. #define INADDR_NONE 0xFFFFFFFF
  1130. #define PATHSIZE ME_MAX_PATH
  1131. #define NBBY 8
  1132. #define hostent _hostent
  1133. #define NFDBITS ((int) (sizeof(fd_mask) * NBBY))
  1134. typedef long fd_mask;
  1135. typedef int Socklen;
  1136. struct sockaddr_storage { char pad[1024]; };
  1137. #endif /* TIDSP */
  1138. #ifndef NBBY
  1139. #define NBBY 8
  1140. #endif
  1141. /*********************************** Externs **********************************/
  1142. #ifdef __cplusplus
  1143. extern "C" {
  1144. #endif
  1145. #if LINUX
  1146. extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict __attr, int *__restrict __kind);
  1147. extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind);
  1148. extern char **environ;
  1149. #endif
  1150. #if VXWORKS
  1151. #if _WRS_VXWORKS_MAJOR < 6 || (_WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR < 9)
  1152. PUBLIC int gettimeofday(struct timeval *tv, struct timezone *tz);
  1153. #endif
  1154. PUBLIC char *strdup(const char *);
  1155. PUBLIC int sysClkRateGet();
  1156. #if _WRS_VXWORKS_MAJOR < 6
  1157. #define NI_MAXHOST 128
  1158. extern STATUS access(cchar *path, int mode);
  1159. typedef int socklen_t;
  1160. struct sockaddr_storage {
  1161. char pad[1024];
  1162. };
  1163. #else
  1164. /*
  1165. This may or may not be necessary - let us know dev@embedthis.com if your system needs this (and why).
  1166. */
  1167. #if _DIAB_TOOL
  1168. #if ME_CPU_ARCH == ME_CPU_PPC
  1169. #define __va_copy(dest, src) memcpy((dest), (src), sizeof(va_list))
  1170. #endif
  1171. #endif
  1172. #define HAVE_SOCKLEN_T
  1173. #endif
  1174. #endif /* VXWORKS */
  1175. #if ME_WIN_LIKE
  1176. struct timezone {
  1177. int tz_minuteswest; /* minutes W of Greenwich */
  1178. int tz_dsttime; /* type of dst correction */
  1179. };
  1180. PUBLIC int getuid(void);
  1181. PUBLIC int geteuid(void);
  1182. PUBLIC int gettimeofday(struct timeval *tv, struct timezone *tz);
  1183. PUBLIC long lrand48(void);
  1184. PUBLIC long nap(long);
  1185. PUBLIC void srand48(long);
  1186. PUBLIC long ulimit(int, ...);
  1187. #endif
  1188. #if WINCE
  1189. struct stat {
  1190. int st_dev;
  1191. int st_ino;
  1192. ushort st_mode;
  1193. short st_nlink;
  1194. short st_uid;
  1195. short st_gid;
  1196. int st_rdev;
  1197. long st_size;
  1198. time_t st_atime;
  1199. time_t st_mtime;
  1200. time_t st_ctime;
  1201. };
  1202. extern int access(cchar *filename, int flags);
  1203. extern int chdir(cchar dirname);
  1204. extern int chmod(cchar *path, int mode);
  1205. extern int close(int handle);
  1206. extern void exit(int status);
  1207. extern long _get_osfhandle(int handle);
  1208. extern char *getcwd(char* buffer, int maxlen);
  1209. extern char *getenv(cchar *charstuff);
  1210. extern pid_t getpid();
  1211. extern long lseek(int handle, long offset, int origin);
  1212. extern int mkdir(cchar *dir, int mode);
  1213. extern time_t mktime(struct tm *pt);
  1214. extern int _open_osfhandle(int *handle, int flags);
  1215. extern uint open(cchar *file, int mode,...);
  1216. extern int read(int handle, void *buffer, uint count);
  1217. extern int rename(cchar *from, cchar *to);
  1218. extern int rmdir(cchar dir);
  1219. extern uint sleep(uint secs);
  1220. extern int stat(cchar *path, struct stat *stat);
  1221. extern char *strdup(char *s);
  1222. extern int write(int handle, cvoid *buffer, uint count);
  1223. extern int umask(int mode);
  1224. extern int unlink(cchar *path);
  1225. extern int errno;
  1226. #undef CreateFile
  1227. #define CreateFile CreateFileA
  1228. WINBASEAPI HANDLE WINAPI CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
  1229. LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
  1230. HANDLE hTemplateFile);
  1231. #undef CreateProcess
  1232. #define CreateProcess CreateProcessA
  1233. #undef FindFirstFile
  1234. #define FindFirstFile FindFirstFileA
  1235. WINBASEAPI HANDLE WINAPI FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData);
  1236. #undef FindNextFile
  1237. #define FindNextFile FindNextFileA
  1238. WINBASEAPI BOOL WINAPI FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData);
  1239. #undef GetModuleFileName
  1240. #define GetModuleFileName GetModuleFileNameA
  1241. WINBASEAPI DWORD WINAPI GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
  1242. #undef GetModuleHandle
  1243. #define GetModuleHandle GetModuleHandleA
  1244. WINBASEAPI HMODULE WINAPI GetModuleHandleA(LPCSTR lpModuleName);
  1245. #undef GetProcAddress
  1246. #define GetProcAddress GetProcAddressA
  1247. #undef GetFileAttributes
  1248. #define GetFileAttributes GetFileAttributesA
  1249. extern DWORD GetFileAttributesA(cchar *path);
  1250. extern void GetSystemTimeAsFileTime(FILETIME *ft);
  1251. #undef LoadLibrary
  1252. #define LoadLibrary LoadLibraryA
  1253. HINSTANCE WINAPI LoadLibraryA(LPCSTR lpLibFileName);
  1254. #define WSAGetLastError GetLastError
  1255. #define _get_timezone getTimezone
  1256. extern int getTimezone(int *secs);
  1257. extern struct tm *localtime_r(const time_t *when, struct tm *tp);
  1258. extern struct tm *gmtime_r(const time_t *t, struct tm *tp);
  1259. #endif /* WINCE */
  1260. #ifdef __cplusplus
  1261. }
  1262. #endif
  1263. #endif /* _h_OSDEP */
  1264. /*
  1265. Copyright (c) Michael O'Brien. All Rights Reserved.
  1266. This is proprietary software and requires a commercial license from the author.
  1267. */