crtnone.cpp 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /*
  2. * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  4. */
  5. #include <bx/debug.h>
  6. #include <bx/sort.h>
  7. #include <bx/readerwriter.h>
  8. #if BX_CRT_NONE
  9. extern "C" void* memcpy(void* _dst, const void* _src, size_t _numBytes)
  10. {
  11. bx::memCopy(_dst, _src, _numBytes);
  12. return _dst;
  13. }
  14. extern "C" void* memmove(void* _dst, const void* _src, size_t _numBytes)
  15. {
  16. bx::memMove(_dst, _src, _numBytes);
  17. return _dst;
  18. }
  19. extern "C" void* memset(void* _dst, int _ch, size_t _numBytes)
  20. {
  21. bx::memSet(_dst, uint8_t(_ch), _numBytes);
  22. return _dst;
  23. }
  24. #if !BX_PLATFORM_NONE
  25. typedef int64_t off64_t;
  26. typedef int32_t pid_t;
  27. extern "C" int32_t memcmp(const void* _lhs, const void* _rhs, size_t _numBytes)
  28. {
  29. return bx::memCmp(_lhs, _rhs, _numBytes);
  30. }
  31. extern "C" size_t strlen(const char* _str)
  32. {
  33. return bx::strLen(_str);
  34. }
  35. extern "C" size_t strLen(const char* _str, size_t _max)
  36. {
  37. return bx::strLen(_str, _max);
  38. }
  39. extern "C" void* strcpy(char* _dst, const char* _src)
  40. {
  41. bx::strCopy(_dst, INT32_MAX, _src, INT32_MAX);
  42. return _dst;
  43. }
  44. extern "C" void* strncpy(char* _dst, const char* _src, size_t _num)
  45. {
  46. bx::strCopy(_dst, INT32_MAX, _src, _num);
  47. return _dst;
  48. }
  49. extern "C" char* strcat(char* _dst, const char* _src)
  50. {
  51. bx::strCat(_dst, INT32_MAX, _src, INT32_MAX);
  52. return _dst;
  53. }
  54. extern "C" const char* strchr(const char* _str, int _ch)
  55. {
  56. return bx::strnchr(_str, _ch);
  57. }
  58. extern "C" int32_t strcmp(const char* _lhs, const char* _rhs)
  59. {
  60. return bx::strncmp(_lhs, _rhs);
  61. }
  62. extern "C" int32_t strncmp(const char* _lhs, const char* _rhs, size_t _max)
  63. {
  64. return bx::strncmp(_lhs, _rhs, _max);
  65. }
  66. extern "C" const char* strstr(const char* _str, const char* _find)
  67. {
  68. return bx::strnstr(_str, _find);
  69. }
  70. extern "C" void qsort(void* _base, size_t _num, size_t _size, bx::ComparisonFn _fn)
  71. {
  72. BX_CHECK(_num <= UINT32_MAX && _size <= UINT32_MAX, "");
  73. return bx::quickSort(_base, _num, _size, _fn);
  74. }
  75. extern "C" int isprint(int _ch)
  76. {
  77. return bx::isPrint(_ch);
  78. }
  79. extern "C" int toupper (int _ch)
  80. {
  81. return bx::toUpper(_ch);
  82. }
  83. extern "C" size_t mbstowcs(wchar_t* _dst, const char* _src, size_t _max)
  84. {
  85. BX_UNUSED(_dst, _src, _max);
  86. return 0;
  87. }
  88. extern "C" char* strdup(const char* _src)
  89. {
  90. BX_UNUSED(_src);
  91. return NULL;
  92. }
  93. extern "C" long int strtol(const char* _str, char** _end, int _base)
  94. {
  95. BX_UNUSED(_str, _end, _base);
  96. return -1;
  97. }
  98. extern "C" int abs(int _value)
  99. {
  100. return _value >= 0 ? _value : -_value;
  101. }
  102. extern "C" float fabsf(float _value)
  103. {
  104. return _value >= 0.0f ? _value : -_value;
  105. }
  106. extern "C" double fabs(double _value)
  107. {
  108. return _value >= 0.0 ? _value : -_value;
  109. }
  110. extern "C" double ldexp(double _x, int _exp)
  111. {
  112. BX_UNUSED(_x, _exp);
  113. return 0.0;
  114. }
  115. extern "C" float expf(float _x)
  116. {
  117. BX_UNUSED(_x);
  118. return 0.0f;
  119. }
  120. extern "C" float logf(float _x)
  121. {
  122. BX_UNUSED(_x);
  123. return 0.0f;
  124. }
  125. extern "C" float log10f(float _x)
  126. {
  127. BX_UNUSED(_x);
  128. return 0.0f;
  129. }
  130. extern "C" float powf(float _x)
  131. {
  132. BX_UNUSED(_x);
  133. return 0.0f;
  134. }
  135. extern "C" double pow(double _x)
  136. {
  137. BX_UNUSED(_x);
  138. return 0.0;
  139. }
  140. extern "C" float sinf(float _x)
  141. {
  142. BX_UNUSED(_x);
  143. return 0.0f;
  144. }
  145. extern "C" float cosf(float _x)
  146. {
  147. BX_UNUSED(_x);
  148. return 0.0f;
  149. }
  150. extern "C" float tanf(float _x)
  151. {
  152. BX_UNUSED(_x);
  153. return 0.0f;
  154. }
  155. extern "C" float atan2f(float _y, float _x)
  156. {
  157. BX_UNUSED(_y, _x);
  158. return 0.0f;
  159. }
  160. extern "C" float sqrtf(float _x)
  161. {
  162. BX_UNUSED(_x);
  163. return 0.0f;
  164. }
  165. extern "C" double sqrt(double _x)
  166. {
  167. BX_UNUSED(_x);
  168. return 0.0;
  169. }
  170. extern "C" float ceilf(float _x)
  171. {
  172. BX_UNUSED(_x);
  173. return 0.0f;
  174. }
  175. extern "C" double ceil(double _x)
  176. {
  177. BX_UNUSED(_x);
  178. return 0.0;
  179. }
  180. extern "C" float floorf(float _x)
  181. {
  182. BX_UNUSED(_x);
  183. return 0.0f;
  184. }
  185. extern "C" double floor(double _x)
  186. {
  187. BX_UNUSED(_x);
  188. return 0.0;
  189. }
  190. extern "C" float acosf(float _x)
  191. {
  192. BX_UNUSED(_x);
  193. return 0.0f;
  194. }
  195. extern "C" float fmodf(float _numer, float _denom)
  196. {
  197. BX_UNUSED(_numer, _denom);
  198. return 0.0f;
  199. }
  200. extern "C" int atoi(const char* _str)
  201. {
  202. BX_UNUSED(_str);
  203. return 0;
  204. }
  205. extern "C" double atof(const char* _str)
  206. {
  207. BX_UNUSED(_str);
  208. return 0.0;
  209. }
  210. extern "C" struct DIR* opendir(const char* dirname)
  211. {
  212. BX_UNUSED(dirname);
  213. return NULL;
  214. }
  215. extern "C" struct dirent* readdir(struct DIR* dirp)
  216. {
  217. BX_UNUSED(dirp);
  218. return NULL;
  219. }
  220. extern "C" int closedir (struct DIR* dirp)
  221. {
  222. BX_UNUSED(dirp);
  223. return 0;
  224. }
  225. extern "C" int vsnprintf(char* _out, size_t _max, const char* _format, va_list _argList)
  226. {
  227. return bx::vsnprintf(_out, _max, _format, _argList);
  228. }
  229. extern "C" int sprintf(char* _out, const char* _format, ...)
  230. {
  231. va_list argList;
  232. va_start(argList, _format);
  233. int32_t len = bx::vsnprintf(_out, INT32_MAX, _format, argList);
  234. va_end(argList);
  235. return len;
  236. }
  237. extern "C" int snprintf(char* _out, size_t _max, const char* _format, ...)
  238. {
  239. va_list argList;
  240. va_start(argList, _format);
  241. int32_t len = bx::vsnprintf(_out, _max, _format, argList);
  242. va_end(argList);
  243. return len;
  244. }
  245. extern "C" int printf(const char* _format, ...)
  246. {
  247. BX_UNUSED(_format);
  248. return -1;
  249. }
  250. extern "C" int fprintf(FILE* _stream, const char* _format, ...)
  251. {
  252. BX_UNUSED(_stream, _format);
  253. return -1;
  254. }
  255. extern "C" int vfprintf(FILE* _stream, const char* _format, va_list _argList)
  256. {
  257. BX_UNUSED(_stream, _format, _argList);
  258. return -1;
  259. }
  260. extern "C" int sscanf(const char* _str, const char* _format, ...)
  261. {
  262. BX_UNUSED(_str, _format);
  263. return -1;
  264. }
  265. extern "C" int fscanf(FILE* _stream, const char* _format, ...)
  266. {
  267. BX_UNUSED(_stream, _format);
  268. return -1;
  269. }
  270. FILE * stdout;
  271. extern "C" FILE* fopen(const char* _filename, const char* _mode)
  272. {
  273. BX_UNUSED(_filename, _mode);
  274. return NULL;
  275. }
  276. extern "C" int fclose(FILE* _stream)
  277. {
  278. BX_UNUSED(_stream);
  279. return -1;
  280. }
  281. extern "C" size_t fread(void* _ptr, size_t _size, size_t _count, FILE* _stream)
  282. {
  283. BX_UNUSED(_ptr, _size, _count, _stream);
  284. return -1;
  285. }
  286. extern "C" size_t fwrite(const void* _ptr, size_t _size, size_t _count, FILE* _stream)
  287. {
  288. BX_UNUSED(_ptr, _size, _count, _stream);
  289. return -1;
  290. }
  291. extern "C" int fseek(FILE* _stream, long int _offset, int _origin)
  292. {
  293. BX_UNUSED(_stream, _offset, _origin);
  294. return -1;
  295. }
  296. extern "C" int fseeko64(FILE* _stream, off64_t _offset, int _whence)
  297. {
  298. BX_UNUSED(_stream, _offset, _whence);
  299. return -1;
  300. }
  301. extern "C" long int ftell(FILE* _stream)
  302. {
  303. BX_UNUSED(_stream);
  304. return -1;
  305. }
  306. extern "C" off64_t ftello64(FILE* _stream)
  307. {
  308. BX_UNUSED(_stream);
  309. return -1;
  310. }
  311. extern "C" int feof(FILE* _stream)
  312. {
  313. BX_UNUSED(_stream);
  314. return -1;
  315. }
  316. extern "C" int ferror(FILE* _stream)
  317. {
  318. BX_UNUSED(_stream);
  319. return -1;
  320. }
  321. extern "C" FILE* popen(const char* _command, const char* _type)
  322. {
  323. BX_UNUSED(_command, _type);
  324. return NULL;
  325. }
  326. extern "C" int pclose(FILE* _stream)
  327. {
  328. BX_UNUSED(_stream);
  329. return -1;
  330. }
  331. extern "C" int execvp(const char* _file, char* const _argv[])
  332. {
  333. BX_UNUSED(_file, _argv);
  334. return -1;
  335. }
  336. extern "C" long syscall(long _num, ...)
  337. {
  338. BX_UNUSED(_num);
  339. return -1;
  340. }
  341. extern "C" long sysconf(int name)
  342. {
  343. BX_UNUSED(name);
  344. return -1;
  345. }
  346. extern "C" pid_t fork()
  347. {
  348. return -1;
  349. }
  350. extern "C" int sched_yield()
  351. {
  352. return -1;
  353. }
  354. extern "C" int prctl(int _option, unsigned long _arg2, unsigned long _arg3, unsigned long _arg4, unsigned long _arg5)
  355. {
  356. BX_UNUSED(_option, _arg2, _arg3, _arg4, _arg5);
  357. return -1;
  358. }
  359. extern "C" int chdir(const char* _path)
  360. {
  361. BX_UNUSED(_path);
  362. return -1;
  363. }
  364. extern "C" char* getcwd(char* _buf, size_t _size)
  365. {
  366. BX_UNUSED(_buf, _size);
  367. return NULL;
  368. }
  369. extern "C" char* getenv(const char* _name)
  370. {
  371. BX_UNUSED(_name);
  372. return NULL;
  373. }
  374. extern "C" int setenv(const char* _name, const char* _value, int _overwrite)
  375. {
  376. BX_UNUSED(_name, _value, _overwrite);
  377. return -1;
  378. }
  379. extern "C" int unsetenv(const char* _name)
  380. {
  381. BX_UNUSED(_name);
  382. return -1;
  383. }
  384. extern "C" time_t time(time_t* _arg)
  385. {
  386. BX_UNUSED(_arg);
  387. return -1;
  388. }
  389. extern "C" int gettimeofday(struct timeval* _tv, struct timezone* _tz)
  390. {
  391. BX_UNUSED(_tv, _tz);
  392. return -1;
  393. }
  394. extern "C" void* realloc(void* _ptr, size_t _size)
  395. {
  396. BX_UNUSED(_ptr, _size);
  397. return NULL;
  398. }
  399. extern "C" void* malloc(size_t _size)
  400. {
  401. return ::realloc(NULL, _size);
  402. }
  403. extern "C" void free(void* _ptr)
  404. {
  405. BX_UNUSED(_ptr);
  406. }
  407. #endif // BX_PLATFORM_*
  408. extern "C" void abort()
  409. {
  410. while (true) {};
  411. }
  412. extern "C" void __assert_fail(const char* _assertion, const char* _file, uint32_t _line, const char* _function)
  413. {
  414. BX_UNUSED(_assertion, _file, _line, _function);
  415. abort();
  416. }
  417. void* __dso_handle = (void*)&__dso_handle;
  418. void operator delete(void*)
  419. {
  420. }
  421. extern "C" void __cxa_pure_virtual()
  422. {
  423. }
  424. extern "C" int __cxa_atexit(void (*_dtorFn)(void*), void* _arg, void* _dsoHandle)
  425. {
  426. BX_UNUSED(_dtorFn, _arg, _dsoHandle);
  427. return 0;
  428. }
  429. extern "C" void __gxx_personality_v0()
  430. {
  431. }
  432. extern "C" void _Unwind_Resume(void*)
  433. {
  434. }
  435. extern "C" int __gcc_personality_v0(int _version, ...)
  436. {
  437. BX_UNUSED(_version);
  438. return 0;
  439. }
  440. namespace __cxxabiv1
  441. {
  442. class __class_type_info
  443. {
  444. public:
  445. virtual ~__class_type_info();
  446. const char* m_name;
  447. };
  448. __class_type_info::~__class_type_info()
  449. {
  450. }
  451. class __si_class_type_info : public __class_type_info
  452. {
  453. public:
  454. virtual ~__si_class_type_info();
  455. };
  456. __si_class_type_info::~__si_class_type_info()
  457. {
  458. }
  459. class __vmi_class_type_info : public __class_type_info
  460. {
  461. public:
  462. virtual ~__vmi_class_type_info();
  463. };
  464. __vmi_class_type_info::~__vmi_class_type_info()
  465. {
  466. }
  467. __extension__ typedef int __guard __attribute__( (mode(__DI__) ) );
  468. extern "C" int __cxa_guard_acquire (__guard* _g)
  469. {
  470. return !*(char*)(_g);
  471. }
  472. extern "C" void __cxa_guard_release (__guard* _g)
  473. {
  474. *(char*)_g = 1;
  475. }
  476. extern "C" void __cxa_guard_abort (__guard* _g)
  477. {
  478. BX_UNUSED(_g);
  479. }
  480. } // namespace __cxxabiv1
  481. #endif // BX_CRT_NONE