2020-05-12 21:24:40 +03:00
|
|
|
#if defined _WIN32
|
2021-07-01 11:20:42 +03:00
|
|
|
|
|
|
|
#ifdef __TINYC__
|
|
|
|
// missing definitions for tcc-0.9.27-win32-bin.zip => 32bit TCC
|
|
|
|
#define CP_UTF8 65001
|
|
|
|
#define strtof strtod
|
|
|
|
#endif
|
|
|
|
|
2020-01-22 14:18:03 +03:00
|
|
|
#include <windows.h>
|
2020-05-12 21:24:40 +03:00
|
|
|
#if !defined __CYGWIN__ && !defined __MINGW32__
|
|
|
|
typedef intptr_t ssize_t;
|
|
|
|
#endif
|
2019-03-04 01:23:13 +03:00
|
|
|
#endif
|
2019-10-03 01:23:27 +03:00
|
|
|
#ifndef _WIN32
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2019-09-28 02:05:30 +03:00
|
|
|
#include <inttypes.h>
|
2020-05-09 13:21:14 +03:00
|
|
|
#include <locale.h>
|
2017-06-26 12:15:03 +03:00
|
|
|
|
2019-10-30 10:47:36 +03:00
|
|
|
typedef char *String;
|
|
|
|
typedef char *Pattern;
|
2019-09-28 02:05:30 +03:00
|
|
|
typedef int64_t Long;
|
2020-05-11 17:10:35 +03:00
|
|
|
typedef uint32_t Char;
|
|
|
|
typedef char CChar;
|
2021-03-04 09:29:52 +03:00
|
|
|
typedef void *c_code;
|
2017-11-22 18:25:05 +03:00
|
|
|
|
2019-06-20 23:13:18 +03:00
|
|
|
#if defined NDEBUG
|
2019-10-30 10:47:36 +03:00
|
|
|
#define CHK_INDEX(i, n)
|
2019-06-20 23:13:18 +03:00
|
|
|
#else
|
2019-12-18 13:33:42 +03:00
|
|
|
|
2020-04-26 23:05:13 +03:00
|
|
|
#define CHK_INDEX_FORMAT_STRING ":%u: bad index: %zd < %zd\n"
|
2019-12-18 13:33:42 +03:00
|
|
|
|
2020-01-22 14:18:03 +03:00
|
|
|
#define CHK_INDEX(i, n) \
|
|
|
|
do { \
|
|
|
|
size_t __si = (size_t)i; \
|
|
|
|
size_t __ni = (size_t)n; \
|
|
|
|
if (!(__si < __ni)) { \
|
|
|
|
printf(__FILE__ CHK_INDEX_FORMAT_STRING, __LINE__, (ssize_t)i, \
|
|
|
|
(ssize_t)n); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
2019-10-30 10:47:36 +03:00
|
|
|
} while (0)
|
2019-06-20 23:13:18 +03:00
|
|
|
#endif
|
|
|
|
|
2021-01-05 09:22:43 +03:00
|
|
|
#define UNHANDLED(file, line) \
|
|
|
|
do { \
|
|
|
|
printf("Unhandled case in 'match' expression at %s:%d\n", file, line); \
|
|
|
|
abort(); \
|
|
|
|
} while (0)
|
|
|
|
|
2017-10-13 13:48:18 +03:00
|
|
|
// Array
|
|
|
|
typedef struct {
|
2017-12-03 21:14:58 +03:00
|
|
|
size_t len;
|
2018-03-07 14:03:59 +03:00
|
|
|
size_t capacity;
|
2017-10-13 13:48:18 +03:00
|
|
|
void *data;
|
|
|
|
} Array;
|
|
|
|
|
2018-06-18 18:22:20 +03:00
|
|
|
// Lambdas
|
|
|
|
typedef struct {
|
|
|
|
void *callback;
|
|
|
|
void *env;
|
2018-08-29 16:10:41 +03:00
|
|
|
void *delete;
|
|
|
|
void *copy;
|
2018-06-18 18:22:20 +03:00
|
|
|
} Lambda;
|
|
|
|
|
2019-10-30 10:47:36 +03:00
|
|
|
typedef void *LambdaEnv;
|