iron.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #pragma clang diagnostic ignored "-Wincompatible-pointer-types"
  3. #include <math.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include "iron_string.h"
  8. #include "iron_array.h"
  9. #include "iron_map.h"
  10. #include "iron_armpack.h"
  11. #include "iron_json.h"
  12. #include "iron_gc.h"
  13. #define f64 double
  14. #define i64 int64_t
  15. #define u64 uint64_t
  16. #define f32 float
  17. #define i32 int32_t
  18. #define u32 uint32_t
  19. #define i16 int16_t
  20. #define u16 uint16_t
  21. #define i8 int8_t
  22. #define u8 uint8_t
  23. #define string_t char
  24. #define any void *
  25. #define any_ptr void **
  26. #define u8_ptr u8 *
  27. #define u32_ptr u32 *
  28. #define f32_ptr f32 *
  29. #define null NULL
  30. #define DEREFERENCE *
  31. #define ADDRESS &
  32. void _kickstart();
  33. void kickstart() {
  34. int bos;
  35. gc_start(&bos);
  36. _kickstart();
  37. }
  38. f32 math_floor(f32 x) { return floorf(x); }
  39. f32 math_cos(f32 x) { return cosf(x); }
  40. f32 math_sin(f32 x) { return sinf(x); }
  41. f32 math_tan(f32 x) { return tanf(x); }
  42. f32 math_sqrt(f32 x) { return sqrtf(x); }
  43. f32 math_abs(f32 x) { return fabsf(x); }
  44. f32 math_random() { return rand() / (float)RAND_MAX; }
  45. f32 math_atan2(f32 y, f32 x) { return atan2f(y, x); }
  46. f32 math_asin(f32 x) { return asinf(x); }
  47. f32 math_pi() { return 3.14159265358979323846; }
  48. f32 math_pow(f32 x, f32 y) { return powf(x, y); }
  49. f32 math_round(f32 x) { return roundf(x); }
  50. f32 math_ceil(f32 x) { return ceilf(x); }
  51. f32 math_min(f32 x, f32 y) { return x < y ? x : y; }
  52. f32 math_max(f32 x, f32 y) { return x > y ? x : y; }
  53. f32 math_log(f32 x) { return logf(x); }
  54. f32 math_log2(f32 x) { return log2f(x); }
  55. f32 math_atan(f32 x) { return atanf(x); }
  56. f32 math_acos(f32 x) { return acosf(x); }
  57. f32 math_exp(f32 x) { return expf(x); }
  58. f32 math_fmod(f32 x, f32 y) { return fmod(x, y); }
  59. #ifdef _WIN32
  60. i32 parse_int(const char *s) { return _strtoi64(s, NULL, 10); }
  61. i32 parse_int_hex(const char *s) { return _strtoi64(s, NULL, 16); }
  62. #else
  63. i32 parse_int(const char *s) { return strtol(s, NULL, 10); }
  64. i32 parse_int_hex(const char *s) { return strtol(s, NULL, 16); }
  65. #endif
  66. f32 parse_float(const char *s) { return strtof(s, NULL); }