osdep.h 34 KB

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