osdep.h 33 KB

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