osdep.h 34 KB

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