osdep.h 33 KB

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