osdep.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  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__
  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. #endif
  344. #include <setjmp.h>
  345. #include <signal.h>
  346. #include <stdarg.h>
  347. #if ME_UNIX_LIKE
  348. #include <stdint.h>
  349. #endif
  350. #include <stdio.h>
  351. #include <stdlib.h>
  352. #include <string.h>
  353. #if ME_UNIX_LIKE
  354. #include <syslog.h>
  355. #endif
  356. #if !TIDSP
  357. #include <sys/stat.h>
  358. #include <sys/types.h>
  359. #endif
  360. #if ME_UNIX_LIKE
  361. #include <sys/ioctl.h>
  362. #include <sys/mman.h>
  363. #include <sys/resource.h>
  364. #include <sys/select.h>
  365. #include <sys/time.h>
  366. #include <sys/times.h>
  367. #include <sys/utsname.h>
  368. #include <sys/uio.h>
  369. #include <sys/wait.h>
  370. #include <poll.h>
  371. #include <unistd.h>
  372. #endif
  373. #include <time.h>
  374. #if !VXWORKS && !TIDSP
  375. #include <wchar.h>
  376. #endif
  377. /*
  378. Extra includes per O/S
  379. */
  380. #if CYGWIN
  381. #include "w32api/windows.h"
  382. #include "sys/cygwin.h"
  383. #endif
  384. #if LINUX
  385. #include <linux/version.h>
  386. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  387. #include <sys/epoll.h>
  388. #endif
  389. #include <sys/prctl.h>
  390. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
  391. #include <sys/eventfd.h>
  392. #endif
  393. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
  394. #define HAS_INOTIFY 1
  395. #include <sys/inotify.h>
  396. #else
  397. #define HAS_INOTIFY 0
  398. #endif
  399. #if !__UCLIBC__
  400. #include <sys/sendfile.h>
  401. #endif
  402. #endif
  403. #if MACOSX
  404. #include <stdbool.h>
  405. #include <mach-o/dyld.h>
  406. #include <mach-o/dyld.h>
  407. #include <mach/mach_init.h>
  408. #include <mach/mach_time.h>
  409. #include <mach/task.h>
  410. #include <libkern/OSAtomic.h>
  411. #endif
  412. #if VXWORKS
  413. #include <vxWorks.h>
  414. #include <envLib.h>
  415. #include <iosLib.h>
  416. #include <loadLib.h>
  417. #include <selectLib.h>
  418. #include <sockLib.h>
  419. #include <inetLib.h>
  420. #include <ioLib.h>
  421. #include <pipeDrv.h>
  422. #include <hostLib.h>
  423. #include <sysSymTbl.h>
  424. #include <sys/fcntlcom.h>
  425. #include <tickLib.h>
  426. #include <taskHookLib.h>
  427. #include <unldLib.h>
  428. #if _WRS_VXWORKS_MAJOR >= 6
  429. #include <wait.h>
  430. #endif
  431. #if _WRS_VXWORKS_MAJOR > 6 || (_WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR >= 8)
  432. #include <symSync.h>
  433. #include <vxAtomicLib.h>
  434. #endif
  435. #endif
  436. #if TIDSP
  437. #include <mathf.h>
  438. #include <netmain.h>
  439. #include <nettools/inc/dnsif.h>
  440. #include <socket.h>
  441. #include <file.h>
  442. #endif
  443. /************************************** Types *********************************/
  444. /*
  445. Standard types
  446. */
  447. #ifndef HAS_BOOL
  448. #ifndef __cplusplus
  449. #if !MACOSX
  450. #define HAS_BOOL 1
  451. /**
  452. Boolean data type.
  453. */
  454. #if !WINDOWS || ((_MSC_VER < 1800) && !defined(bool))
  455. /* Bool introduced via stdbool in VS 2015 */
  456. typedef char bool;
  457. #endif
  458. #endif
  459. #endif
  460. #endif
  461. #ifndef HAS_UCHAR
  462. #define HAS_UCHAR 1
  463. /**
  464. Unsigned char data type.
  465. */
  466. typedef unsigned char uchar;
  467. #endif
  468. #ifndef HAS_SCHAR
  469. #define HAS_SCHAR 1
  470. /**
  471. Signed char data type.
  472. */
  473. typedef signed char schar;
  474. #endif
  475. #ifndef HAS_CCHAR
  476. #define HAS_CCHAR 1
  477. /**
  478. Constant char data type.
  479. */
  480. typedef const char cchar;
  481. #endif
  482. #ifndef HAS_CUCHAR
  483. #define HAS_CUCHAR 1
  484. /**
  485. Unsigned char data type.
  486. */
  487. typedef const unsigned char cuchar;
  488. #endif
  489. /***** jimbo modify ****/
  490. #define HAS_USHORT
  491. #define HAS_UINT
  492. #define HAS_ULONG
  493. #ifndef HAS_USHORT
  494. #define HAS_USHORT 1
  495. /**
  496. Unsigned short data type.
  497. */
  498. typedef unsigned short ushort;
  499. #endif
  500. #ifndef HAS_CUSHORT
  501. #define HAS_CUSHORT 1
  502. /**
  503. Constant unsigned short data type.
  504. */
  505. typedef const unsigned short cushort;
  506. #endif
  507. #ifndef HAS_CVOID
  508. #define HAS_CVOID 1
  509. /**
  510. Constant void data type.
  511. */
  512. typedef const void cvoid;
  513. #endif
  514. #ifndef HAS_INT8
  515. #define HAS_INT8 1
  516. /**
  517. Integer 8 bits data type.
  518. */
  519. typedef char int8;
  520. #endif
  521. #ifndef HAS_UINT8
  522. #define HAS_UINT8 1
  523. /**
  524. Unsigned integer 8 bits data type.
  525. */
  526. typedef unsigned char uint8;
  527. #endif
  528. #ifndef HAS_INT16
  529. #define HAS_INT16 1
  530. /**
  531. Integer 16 bits data type.
  532. */
  533. typedef short int16;
  534. #endif
  535. #ifndef HAS_UINT16
  536. #define HAS_UINT16 1
  537. /**
  538. Unsigned integer 16 bits data type.
  539. */
  540. typedef unsigned short uint16;
  541. #endif
  542. #ifndef HAS_INT32
  543. #define HAS_INT32 1
  544. /**
  545. Integer 32 bits data type.
  546. */
  547. typedef int int32;
  548. #endif
  549. #ifndef HAS_UINT32
  550. #define HAS_UINT32 1
  551. /**
  552. Unsigned integer 32 bits data type.
  553. */
  554. typedef unsigned int uint32;
  555. #endif
  556. #ifndef HAS_UINT
  557. #define HAS_UINT 1
  558. /**
  559. Unsigned integer (machine dependent bit size) data type.
  560. */
  561. typedef unsigned int uint;
  562. #endif
  563. #ifndef HAS_ULONG
  564. #define HAS_ULONG 1
  565. /**
  566. Unsigned long (machine dependent bit size) data type.
  567. */
  568. typedef unsigned long ulong;
  569. #endif
  570. #ifndef HAS_CINT
  571. #define HAS_CINT 1
  572. /**
  573. Constant int data type.
  574. */
  575. typedef const int cint;
  576. #endif
  577. #ifndef HAS_SSIZE
  578. #define HAS_SSIZE 1
  579. #if ME_UNIX_LIKE || VXWORKS || DOXYGEN
  580. /**
  581. Signed integer size field large enough to hold a pointer offset.
  582. */
  583. typedef ssize_t ssize;
  584. #elif TIDSP
  585. typedef int ssize_t;
  586. typedef ssize_t ssize;
  587. #else
  588. typedef SSIZE_T ssize;
  589. #endif
  590. #endif
  591. /*
  592. Windows uses uint for write/read counts (Ugh!)
  593. */
  594. #if ME_WIN_LIKE
  595. typedef uint wsize;
  596. #else
  597. typedef ssize wsize;
  598. #endif
  599. #ifndef HAS_INT64
  600. #if ME_UNIX_LIKE
  601. __extension__ typedef long long int int64;
  602. #elif VXWORKS || DOXYGEN
  603. /**
  604. Integer 64 bit data type.
  605. */
  606. typedef long long int int64;
  607. #elif ME_WIN_LIKE
  608. typedef __int64 int64;
  609. #else
  610. typedef long long int int64;
  611. #endif
  612. #endif
  613. #ifndef HAS_UINT64
  614. #if ME_UNIX_LIKE
  615. __extension__ typedef unsigned long long int uint64;
  616. #elif VXWORKS || DOXYGEN
  617. typedef unsigned long long int uint64;
  618. #elif ME_WIN_LIKE
  619. typedef unsigned __int64 uint64;
  620. #else
  621. typedef unsigned long long int uint64;
  622. #endif
  623. #endif
  624. /**
  625. Signed file offset data type. Supports large files greater than 4GB in size on all systems.
  626. */
  627. typedef int64 Offset;
  628. #if DOXYGEN
  629. /** Size to hold the length of a socket address */
  630. typedef int Socklen;
  631. #elif VXWORKS
  632. typedef int Socklen;
  633. #else
  634. typedef socklen_t Socklen;
  635. #endif
  636. #if DOXYGEN || ME_UNIX_LIKE || VXWORKS
  637. /** Argument for sockets */
  638. typedef int Socket;
  639. #ifndef SOCKET_ERROR
  640. #define SOCKET_ERROR -1
  641. #endif
  642. #define SOCKET_ERROR -1
  643. #ifndef INVALID_SOCKET
  644. #define INVALID_SOCKET -1
  645. #endif
  646. #elif ME_WIN_LIKE
  647. typedef SOCKET Socket;
  648. #elif TIDSP
  649. typedef SOCKET Socket;
  650. #define SOCKET_ERROR INVALID_SOCKET
  651. #else
  652. typedef int Socket;
  653. #ifndef SOCKET_ERROR
  654. #define SOCKET_ERROR -1
  655. #endif
  656. #ifndef INVALID_SOCKET
  657. #define INVALID_SOCKET -1
  658. #endif
  659. #endif
  660. typedef int64 Time;
  661. /**
  662. Elapsed time data type. Stores time in milliseconds from some arbitrary start epoch.
  663. */
  664. typedef int64 Ticks;
  665. /**
  666. Time/Ticks units per second (milliseconds)
  667. */
  668. #define TPS 1000
  669. /*********************************** Defines **********************************/
  670. #ifndef BITSPERBYTE
  671. #define BITSPERBYTE ((int) (8 * sizeof(char)))
  672. #endif
  673. #ifndef BITS
  674. #define BITS(type) ((int) (BITSPERBYTE * (int) sizeof(type)))
  675. #endif
  676. #if ME_FLOAT
  677. #ifndef MAXFLOAT
  678. #if ME_WIN_LIKE
  679. #define MAXFLOAT DBL_MAX
  680. #else
  681. #define MAXFLOAT FLT_MAX
  682. #endif
  683. #endif
  684. #if VXWORKS
  685. #undef isnan
  686. #define isnan(n) ((n) != (n))
  687. #define isnanf(n) ((n) != (n))
  688. #define isinf(n) ((n) == (1.0 / 0.0) || (n) == (-1.0 / 0.0))
  689. #define isinff(n) ((n) == (1.0 / 0.0) || (n) == (-1.0 / 0.0))
  690. #endif
  691. #if ME_WIN_LIKE
  692. #define isNan(f) (_isnan(f))
  693. #elif VXWORKS || MACOSX || LINUX
  694. #define isNan(f) (isnan(f))
  695. #else
  696. #define isNan(f) (fpclassify(f) == FP_NAN)
  697. #endif
  698. #endif
  699. #if ME_WIN_LIKE
  700. #define INT64(x) (x##i64)
  701. #define UINT64(x) (x##Ui64)
  702. #else
  703. #define INT64(x) (x##LL)
  704. #define UINT64(x) (x##ULL)
  705. #endif
  706. #ifndef MAXINT
  707. #if INT_MAX
  708. #define MAXINT INT_MAX
  709. #else
  710. #define MAXINT 0x7fffffff
  711. #endif
  712. #endif
  713. #ifndef MAXUINT
  714. #if UINT_MAX
  715. #define MAXUINT UINT_MAX
  716. #else
  717. #define MAXUINT 0xffffffff
  718. #endif
  719. #endif
  720. #ifndef MAXINT64
  721. #define MAXINT64 INT64(0x7fffffffffffffff)
  722. #endif
  723. #ifndef MAXUINT64
  724. #define MAXUINT64 INT64(0xffffffffffffffff)
  725. #endif
  726. #if SIZE_T_MAX
  727. #define MAXSIZE SIZE_T_MAX
  728. #elif ME_64
  729. #define MAXSIZE INT64(0xffffffffffffffff)
  730. #else
  731. #define MAXSIZE MAXINT
  732. #endif
  733. #if SSIZE_T_MAX
  734. #define MAXSSIZE SSIZE_T_MAX
  735. #elif ME_64
  736. #define MAXSSIZE INT64(0x7fffffffffffffff)
  737. #else
  738. #define MAXSSIZE MAXINT
  739. #endif
  740. #if OFF_T_MAX
  741. #define MAXOFF OFF_T_MAX
  742. #else
  743. #define MAXOFF INT64(0x7fffffffffffffff)
  744. #endif
  745. /*
  746. Word size and conversions between integer and pointer.
  747. */
  748. #if ME_64
  749. #define ITOP(i) ((void*) ((int64) i))
  750. #define PTOI(i) ((int) ((int64) i))
  751. #define LTOP(i) ((void*) ((int64) i))
  752. #define PTOL(i) ((int64) i)
  753. #else
  754. #define ITOP(i) ((void*) ((int) i))
  755. #define PTOI(i) ((int) i)
  756. #define LTOP(i) ((void*) ((int) i))
  757. #define PTOL(i) ((int64) (int) i)
  758. #endif
  759. #undef PUBLIC
  760. #undef PUBLIC_DATA
  761. #undef PRIVATE
  762. #if ME_WIN_LIKE
  763. /*
  764. Use PUBLIC on function declarations and definitions (*.c and *.h).
  765. */
  766. #define PUBLIC __declspec(dllexport)
  767. #define PUBLIC_DATA __declspec(dllexport)
  768. #define PRIVATE static
  769. #else
  770. #define PUBLIC
  771. #define PUBLIC_DATA extern
  772. #define PRIVATE static
  773. #endif
  774. /* Undefines for Qt - Ugh */
  775. #undef max
  776. #undef min
  777. #define max(a,b) (((a) > (b)) ? (a) : (b))
  778. #define min(a,b) (((a) < (b)) ? (a) : (b))
  779. #ifndef PRINTF_ATTRIBUTE
  780. #if ((__GNUC__ >= 3) && !DOXYGEN) || MACOSX
  781. /**
  782. Use gcc attribute to check printf fns. a1 is the 1-based index of the parameter containing the format,
  783. and a2 the index of the first argument. Note that some gcc 2.x versions don't handle this properly
  784. */
  785. #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
  786. #else
  787. #define PRINTF_ATTRIBUTE(a1, a2)
  788. #endif
  789. #endif
  790. /*
  791. Optimize expression evaluation code depending if the value is likely or not
  792. */
  793. #undef likely
  794. #undef unlikely
  795. #if (__GNUC__ >= 3)
  796. #define likely(x) __builtin_expect(!!(x), 1)
  797. #define unlikely(x) __builtin_expect(!!(x), 0)
  798. #else
  799. #define likely(x) (x)
  800. #define unlikely(x) (x)
  801. #endif
  802. #if !__UCLIBC__ && !CYGWIN && __USE_XOPEN2K
  803. #define ME_COMPILER_HAS_SPINLOCK 1
  804. #endif
  805. #if ME_COMPILER_HAS_DOUBLE_BRACES
  806. #define NULL_INIT {{0}}
  807. #else
  808. #define NULL_INIT {0}
  809. #endif
  810. #ifdef __USE_FILE_OFFSET64
  811. #define ME_COMPILER_HAS_OFF64 1
  812. #else
  813. #define ME_COMPILER_HAS_OFF64 0
  814. #endif
  815. #if ME_UNIX_LIKE
  816. #define ME_COMPILER_HAS_FCNTL 1
  817. #endif
  818. #ifndef R_OK
  819. #define R_OK 4
  820. #define W_OK 2
  821. #if ME_WIN_LIKE
  822. #define X_OK R_OK
  823. #else
  824. #define X_OK 1
  825. #endif
  826. #define F_OK 0
  827. #endif
  828. #if MACOSX
  829. #define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH"
  830. #else
  831. #define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
  832. #endif
  833. #if VXWORKS
  834. /*
  835. Old VxWorks can't do array[]
  836. */
  837. #define ARRAY_FLEX 0
  838. #else
  839. #define ARRAY_FLEX
  840. #endif
  841. /*
  842. Deprecated API warnings
  843. */
  844. #if ((__GNUC__ >= 3) || MACOSX) && !VXWORKS && ME_DEPRECATED_WARNINGS
  845. #define ME_DEPRECATED(MSG) __attribute__ ((deprecated(MSG)))
  846. #else
  847. #define ME_DEPRECATED(MSG)
  848. #endif
  849. /********************************** Tunables *********************************/
  850. /*
  851. These can be defined in main.bit settings (pascal case) to override. E.g.
  852. settings: {
  853. maxPath: 4096
  854. }
  855. */
  856. #ifndef ME_MAX_FNAME
  857. #define ME_MAX_FNAME 256 /**< Reasonable filename size */
  858. #endif
  859. #ifndef ME_MAX_PATH
  860. #define ME_MAX_PATH 1024 /**< Reasonable filename size */
  861. #endif
  862. #ifndef ME_BUFSIZE
  863. #define ME_BUFSIZE 4096 /**< Reasonable size for buffers */
  864. #endif
  865. #ifndef ME_MAX_BUFFER
  866. #define ME_MAX_BUFFER ME_BUFSIZE /* DEPRECATE */
  867. #endif
  868. #ifndef ME_MAX_ARGC
  869. #define ME_MAX_ARGC 32 /**< Maximum number of command line args if using MAIN()*/
  870. #endif
  871. #ifndef ME_DOUBLE_BUFFER
  872. #define ME_DOUBLE_BUFFER (DBL_MANT_DIG - DBL_MIN_EXP + 4)
  873. #endif
  874. #ifndef ME_MAX_IP
  875. #define ME_MAX_IP 1024
  876. #endif
  877. #ifndef ME_STACK_SIZE
  878. #if ME_COMPILER_HAS_MMU && !VXWORKS
  879. /*
  880. If the system supports virtual memory, then stack size should use system default. Only used pages will
  881. actually consume memory
  882. */
  883. #define ME_STACK_SIZE 0 /**< Default thread stack size (0 means use system default) */
  884. #else
  885. /*
  886. No MMU, so the stack size actually consumes memory. Set this as low as possible.
  887. NOTE: php and ejs use stack heavily.
  888. */
  889. #define ME_STACK_SIZE (128 * 1024) /**< Default thread stack size (0 means use system default) */
  890. #endif
  891. #endif
  892. /*********************************** Fixups ***********************************/
  893. #ifndef ME_INLINE
  894. #if ME_WIN_LIKE
  895. #define ME_INLINE __inline
  896. #else
  897. #define ME_INLINE inline
  898. #endif
  899. #endif
  900. #if ECOS
  901. #define LIBKERN_INLINE /* to avoid kernel inline functions */
  902. #endif /* ECOS */
  903. #if ME_UNIX_LIKE || VXWORKS || TIDSP
  904. #define FILE_TEXT ""
  905. #define FILE_BINARY ""
  906. #endif
  907. #if !TIDSP
  908. #define ME_COMPILER_HAS_MACRO_VARARGS 1
  909. #else
  910. #define ME_COMPILER_HAS_MACRO_VARARGS 1
  911. #endif
  912. #if ME_UNIX_LIKE
  913. #define closesocket(x) close(x)
  914. #if !defined(PTHREAD_MUTEX_RECURSIVE_NP) || FREEBSD
  915. #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
  916. #else
  917. #ifndef PTHREAD_MUTEX_RECURSIVE
  918. #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
  919. #endif
  920. #endif
  921. #endif
  922. #if !ME_WIN_LIKE && !CYGWIN
  923. #ifndef O_BINARY
  924. #define O_BINARY 0
  925. #endif
  926. #ifndef O_TEXT
  927. #define O_TEXT 0
  928. #endif
  929. #endif
  930. #if !LINUX
  931. #define __WALL 0
  932. #if !CYGWIN && !defined(MSG_NOSIGNAL)
  933. #define MSG_NOSIGNAL 0
  934. #endif
  935. #endif
  936. #if ME_BSD_LIKE
  937. /*
  938. Fix for MAC OS X - getenv
  939. */
  940. #if !HAVE_DECL_ENVIRON
  941. #ifdef __APPLE__
  942. #include <crt_externs.h>
  943. #define environ (*_NSGetEnviron())
  944. #else
  945. extern char **environ;
  946. #endif
  947. #endif
  948. #endif
  949. #if SOLARIS
  950. #define INADDR_NONE ((in_addr_t) 0xffffffff)
  951. #endif
  952. #if VXWORKS
  953. #ifndef SHUT_RDWR
  954. #define SHUT_RDWR 2
  955. #endif
  956. #define HAVE_SOCKLEN_T
  957. #if _DIAB_TOOL
  958. #define inline __inline__
  959. #define MPR_INLINE __inline__
  960. #endif
  961. #ifndef closesocket
  962. #define closesocket(x) close(x)
  963. #endif
  964. #ifndef va_copy
  965. #define va_copy(d, s) ((d) = (s))
  966. #endif
  967. #ifndef strcasecmp
  968. #define strcasecmp scaselesscmp
  969. #endif
  970. #ifndef strncasecmp
  971. #define strncasecmp sncaselesscmp
  972. #endif
  973. #endif
  974. #if ME_WIN_LIKE
  975. typedef int uid_t;
  976. typedef void *handle;
  977. typedef char *caddr_t;
  978. typedef long pid_t;
  979. typedef int gid_t;
  980. typedef ushort mode_t;
  981. typedef void *siginfo_t;
  982. typedef int socklen_t;
  983. #define HAVE_SOCKLEN_T
  984. #define MSG_NOSIGNAL 0
  985. #define FILE_BINARY "b"
  986. #define FILE_TEXT "t"
  987. /*
  988. Error codes
  989. */
  990. #define EPERM 1
  991. #define ENOENT 2
  992. #define ESRCH 3
  993. #define EINTR 4
  994. #define EIO 5
  995. #define ENXIO 6
  996. #define E2BIG 7
  997. #define ENOEXEC 8
  998. #define EBADF 9
  999. #define ECHILD 10
  1000. #define EAGAIN 11
  1001. #define ENOMEM 12
  1002. #define EACCES 13
  1003. #define EFAULT 14
  1004. #define EOSERR 15
  1005. #define EBUSY 16
  1006. #define EEXIST 17
  1007. #define EXDEV 18
  1008. #define ENODEV 19
  1009. #define ENOTDIR 20
  1010. #define EISDIR 21
  1011. #define EINVAL 22
  1012. #define ENFILE 23
  1013. #define EMFILE 24
  1014. #define ENOTTY 25
  1015. #define EFBIG 27
  1016. #define ENOSPC 28
  1017. #define ESPIPE 29
  1018. #define EROFS 30
  1019. #define EMLINK 31
  1020. #define EPIPE 32
  1021. #define EDOM 33
  1022. #define ERANGE 34
  1023. #ifndef EWOULDBLOCK
  1024. #define EWOULDBLOCK EAGAIN
  1025. #define EINPROGRESS 36
  1026. #define EALREADY 37
  1027. #define ENETDOWN 43
  1028. #define ECONNRESET 44
  1029. #define ECONNREFUSED 45
  1030. #define EADDRNOTAVAIL 49
  1031. #define EISCONN 56
  1032. #define EADDRINUSE 46
  1033. #define ENETUNREACH 51
  1034. #define ECONNABORTED 53
  1035. #endif
  1036. #ifndef ENOTCONN
  1037. #define ENOTCONN 126
  1038. #endif
  1039. #ifndef EPROTO
  1040. #define EPROTO 134
  1041. #endif
  1042. #undef SHUT_RDWR
  1043. #define SHUT_RDWR 2
  1044. #define TIME_GENESIS UINT64(11644473600000000)
  1045. #ifndef va_copy
  1046. #define va_copy(d, s) ((d) = (s))
  1047. #endif
  1048. #if !WINCE
  1049. #define access _access
  1050. #define chdir _chdir
  1051. #define chmod _chmod
  1052. #define close _close
  1053. #define fileno _fileno
  1054. #define fstat _fstat
  1055. #define getcwd _getcwd
  1056. #define getpid _getpid
  1057. #define gettimezone _gettimezone
  1058. #define lseek _lseek
  1059. #define mkdir(a,b) _mkdir(a)
  1060. #define open _open
  1061. #define putenv _putenv
  1062. #define read _read
  1063. #define rmdir(a) _rmdir(a)
  1064. #define stat _stat
  1065. #define strdup _strdup
  1066. #define tempnam _tempnam
  1067. #define umask _umask
  1068. #define unlink _unlink
  1069. #define write _write
  1070. PUBLIC void sleep(int secs);
  1071. #endif
  1072. #define strcasecmp scaselesscmp
  1073. #define strncasecmp sncaselesscmp
  1074. #pragma comment( lib, "ws2_32.lib" )
  1075. #endif /* WIN_LIKE */
  1076. #if WINCE
  1077. typedef void FILE;
  1078. typedef int off_t;
  1079. #ifndef EOF
  1080. #define EOF -1
  1081. #endif
  1082. #define O_RDONLY 0
  1083. #define O_WRONLY 1
  1084. #define O_RDWR 2
  1085. #define O_NDELAY 0x4
  1086. #define O_NONBLOCK 0x4
  1087. #define O_APPEND 0x8
  1088. #define O_CREAT 0x100
  1089. #define O_TRUNC 0x200
  1090. #define O_TEXT 0x400
  1091. #define O_EXCL 0x800
  1092. #define O_BINARY 0x1000
  1093. /*
  1094. stat flags
  1095. */
  1096. #define S_IFMT 0170000
  1097. #define S_IFDIR 0040000
  1098. #define S_IFCHR 0020000 /* character special */
  1099. #define S_IFIFO 0010000
  1100. #define S_IFREG 0100000
  1101. #define S_IREAD 0000400
  1102. #define S_IWRITE 0000200
  1103. #define S_IEXEC 0000100
  1104. #ifndef S_ISDIR
  1105. #define S_ISDIR(X) (((X) & S_IFMT) == S_IFDIR)
  1106. #endif
  1107. #ifndef S_ISREG
  1108. #define S_ISREG(X) (((X) & S_IFMT) == S_IFREG)
  1109. #endif
  1110. #define STARTF_USESHOWWINDOW 0
  1111. #define STARTF_USESTDHANDLES 0
  1112. #define BUFSIZ ME_BUFSIZE
  1113. #define PATHSIZE ME_MAX_PATH
  1114. #define gethostbyname2(a,b) gethostbyname(a)
  1115. #pragma comment( lib, "ws2.lib" )
  1116. #endif /* WINCE */
  1117. #if TIDSP
  1118. #define EINTR 4
  1119. #define EAGAIN 11
  1120. #define INADDR_NONE 0xFFFFFFFF
  1121. #define PATHSIZE ME_MAX_PATH
  1122. #define NBBY 8
  1123. #define hostent _hostent
  1124. #define NFDBITS ((int) (sizeof(fd_mask) * NBBY))
  1125. typedef long fd_mask;
  1126. typedef int Socklen;
  1127. struct sockaddr_storage { char pad[1024]; };
  1128. #endif /* TIDSP */
  1129. #ifndef NBBY
  1130. #define NBBY 8
  1131. #endif
  1132. /*********************************** Externs **********************************/
  1133. #ifdef __cplusplus
  1134. extern "C" {
  1135. #endif
  1136. #if LINUX
  1137. extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict __attr, int *__restrict __kind);
  1138. extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind);
  1139. extern char **environ;
  1140. #endif
  1141. #if VXWORKS
  1142. #if _WRS_VXWORKS_MAJOR < 6 || (_WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR < 9)
  1143. PUBLIC int gettimeofday(struct timeval *tv, struct timezone *tz);
  1144. #endif
  1145. PUBLIC char *strdup(const char *);
  1146. PUBLIC int sysClkRateGet();
  1147. #if _WRS_VXWORKS_MAJOR < 6
  1148. #define NI_MAXHOST 128
  1149. extern STATUS access(cchar *path, int mode);
  1150. typedef int socklen_t;
  1151. struct sockaddr_storage {
  1152. char pad[1024];
  1153. };
  1154. #else
  1155. /*
  1156. This may or may not be necessary - let us know dev@embedthis.com if your system needs this (and why).
  1157. */
  1158. #if _DIAB_TOOL
  1159. #if ME_CPU_ARCH == ME_CPU_PPC
  1160. #define __va_copy(dest, src) memcpy((dest), (src), sizeof(va_list))
  1161. #endif
  1162. #endif
  1163. #define HAVE_SOCKLEN_T
  1164. #endif
  1165. #endif /* VXWORKS */
  1166. #if ME_WIN_LIKE
  1167. struct timezone {
  1168. int tz_minuteswest; /* minutes W of Greenwich */
  1169. int tz_dsttime; /* type of dst correction */
  1170. };
  1171. PUBLIC int getuid(void);
  1172. PUBLIC int geteuid(void);
  1173. PUBLIC int gettimeofday(struct timeval *tv, struct timezone *tz);
  1174. PUBLIC long lrand48(void);
  1175. PUBLIC long nap(long);
  1176. PUBLIC void srand48(long);
  1177. PUBLIC long ulimit(int, ...);
  1178. #endif
  1179. #if WINCE
  1180. struct stat {
  1181. int st_dev;
  1182. int st_ino;
  1183. ushort st_mode;
  1184. short st_nlink;
  1185. short st_uid;
  1186. short st_gid;
  1187. int st_rdev;
  1188. long st_size;
  1189. time_t st_atime;
  1190. time_t st_mtime;
  1191. time_t st_ctime;
  1192. };
  1193. extern int access(cchar *filename, int flags);
  1194. extern int chdir(cchar dirname);
  1195. extern int chmod(cchar *path, int mode);
  1196. extern int close(int handle);
  1197. extern void exit(int status);
  1198. extern long _get_osfhandle(int handle);
  1199. extern char *getcwd(char* buffer, int maxlen);
  1200. extern char *getenv(cchar *charstuff);
  1201. extern pid_t getpid();
  1202. extern long lseek(int handle, long offset, int origin);
  1203. extern int mkdir(cchar *dir, int mode);
  1204. extern time_t mktime(struct tm *pt);
  1205. extern int _open_osfhandle(int *handle, int flags);
  1206. extern uint open(cchar *file, int mode,...);
  1207. extern int read(int handle, void *buffer, uint count);
  1208. extern int rename(cchar *from, cchar *to);
  1209. extern int rmdir(cchar dir);
  1210. extern uint sleep(uint secs);
  1211. extern int stat(cchar *path, struct stat *stat);
  1212. extern char *strdup(char *s);
  1213. extern int write(int handle, cvoid *buffer, uint count);
  1214. extern int umask(int mode);
  1215. extern int unlink(cchar *path);
  1216. extern int errno;
  1217. #undef CreateFile
  1218. #define CreateFile CreateFileA
  1219. WINBASEAPI HANDLE WINAPI CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
  1220. LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
  1221. HANDLE hTemplateFile);
  1222. #undef CreateProcess
  1223. #define CreateProcess CreateProcessA
  1224. #undef FindFirstFile
  1225. #define FindFirstFile FindFirstFileA
  1226. WINBASEAPI HANDLE WINAPI FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData);
  1227. #undef FindNextFile
  1228. #define FindNextFile FindNextFileA
  1229. WINBASEAPI BOOL WINAPI FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData);
  1230. #undef GetModuleFileName
  1231. #define GetModuleFileName GetModuleFileNameA
  1232. WINBASEAPI DWORD WINAPI GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
  1233. #undef GetModuleHandle
  1234. #define GetModuleHandle GetModuleHandleA
  1235. WINBASEAPI HMODULE WINAPI GetModuleHandleA(LPCSTR lpModuleName);
  1236. #undef GetProcAddress
  1237. #define GetProcAddress GetProcAddressA
  1238. #undef GetFileAttributes
  1239. #define GetFileAttributes GetFileAttributesA
  1240. extern DWORD GetFileAttributesA(cchar *path);
  1241. extern void GetSystemTimeAsFileTime(FILETIME *ft);
  1242. #undef LoadLibrary
  1243. #define LoadLibrary LoadLibraryA
  1244. HINSTANCE WINAPI LoadLibraryA(LPCSTR lpLibFileName);
  1245. #define WSAGetLastError GetLastError
  1246. #define _get_timezone getTimezone
  1247. extern int getTimezone(int *secs);
  1248. extern struct tm *localtime_r(const time_t *when, struct tm *tp);
  1249. extern struct tm *gmtime_r(const time_t *t, struct tm *tp);
  1250. #endif /* WINCE */
  1251. #ifdef __cplusplus
  1252. }
  1253. #endif
  1254. #endif /* _h_OSDEP */
  1255. /*
  1256. Copyright (c) Michael O'Brien. All Rights Reserved.
  1257. This is proprietary software and requires a commercial license from the author.
  1258. */