Fixes from building on macOS

This commit is contained in:
K. Lange 2021-02-11 20:52:30 +09:00
parent 90704df989
commit a15e936d87
6 changed files with 24 additions and 19 deletions

View File

@ -50,6 +50,12 @@ ifeq ($(shell uname -s),Linux)
endif
endif
ifeq ($(shell uname -s),Darwin)
# Assume we're not using ming to build for Windows on macOS
# and enable threads for Darwin, as they've been tested there.
KRK_ENABLE_THREAD ?= 1
endif
ifeq (1,$(KRK_ENABLE_THREAD))
# Thread support is EXPERIMENTAL
# and downright known to be broken

View File

@ -895,8 +895,3 @@ void _createAndBind_strClass(void) {
krk_finalizeClass(striterator);
}
KrkValue krk_string_get(int argc, KrkValue argv[], int hasKw) __attribute__((alias("_str___get__")));
KrkValue krk_string_int(int argc, KrkValue argv[], int hasKw) __attribute__((alias("_str___int__")));
KrkValue krk_string_float(int argc, KrkValue argv[], int hasKw) __attribute__((alias("_str___float__")));
KrkValue krk_string_split(int argc, KrkValue argv[], int hasKw) __attribute__((alias("_str_split")));
KrkValue krk_string_format(int argc, KrkValue argv[], int hasKw) __attribute__((alias("_str_format")));

View File

@ -13,7 +13,7 @@ static KrkValue _tuple_init(int argc, KrkValue argv[], int hasKw) {
}
/* tuple creator */
static KrkValue _tuple_of(int argc, KrkValue argv[], int hasKw) {
KrkValue krk_tuple_of(int argc, KrkValue argv[], int hasKw) {
KrkTuple * self = krk_newTuple(argc);
krk_push(OBJECT_VAL(self));
for (size_t i = 0; i < (size_t)argc; ++i) {
@ -23,8 +23,6 @@ static KrkValue _tuple_of(int argc, KrkValue argv[], int hasKw) {
return OBJECT_VAL(self);
}
KrkValue krk_tuple_of(int argc, KrkValue argv[], int hasKw) __attribute__((alias("_tuple_of")));
#define IS_tuple(o) IS_TUPLE(o)
#define AS_tuple(o) AS_TUPLE(o)

View File

@ -80,7 +80,7 @@ static inline const char * _method_name(const char * func) {
ctype name __attribute__((unused)) = AS_ ## type (argv[i])
#define FUNC_NAME(klass, name) _ ## klass ## _ ## name
#define FUNC_SIG(klass, name) static KrkValue FUNC_NAME(klass,name) (int argc, KrkValue argv[], int hasKw)
#define FUNC_SIG(klass, name) _noexport KrkValue FUNC_NAME(klass,name) (int argc, KrkValue argv[], int hasKw)
#define KRK_METHOD(klass, name, body) FUNC_SIG(klass, name) { \
CHECK_ARG(0,klass,CURRENT_CTYPE,CURRENT_NAME); \
body; return NONE_VAL(); }

View File

@ -87,8 +87,8 @@ KrkThreadState * krk_getCurrentThread(void) {
return &krk_currentThread;
}
static struct Exceptions _exceptions = {NULL};
static struct BaseClasses _baseClasses = {NULL};
static struct Exceptions _exceptions = {0};
static struct BaseClasses _baseClasses = {0};
static KrkValue _specialMethodNames[METHOD__MAX];
/**
@ -264,7 +264,7 @@ void krk_reserve_stack(size_t space) {
* the stack to grow - eg. if you are calling into managed code
* to do anything, or if you are pushing anything.
*/
inline void krk_push(KrkValue value) {
void krk_push(KrkValue value) {
if (unlikely((size_t)(krk_currentThread.stackTop - krk_currentThread.stack) + 1 > krk_currentThread.stackSize)) {
size_t old = krk_currentThread.stackSize;
size_t old_offset = krk_currentThread.stackTop - krk_currentThread.stack;
@ -284,7 +284,7 @@ inline void krk_push(KrkValue value) {
* the repl relies on this it expects to be able to get the last
* pushed value and display it (if it's not None).
*/
inline KrkValue krk_pop() {
KrkValue krk_pop() {
krk_currentThread.stackTop--;
if (unlikely(krk_currentThread.stackTop < krk_currentThread.stack)) {
fprintf(stderr, "Fatal error: stack underflow detected in VM, issuing breakpoint.\n");
@ -294,7 +294,7 @@ inline KrkValue krk_pop() {
}
/* Read a value `distance` units from the top of the stack without poping it. */
inline KrkValue krk_peek(int distance) {
KrkValue krk_peek(int distance) {
return krk_currentThread.stackTop[-1 - distance];
}

View File

@ -203,11 +203,17 @@ extern int krk_loadModule(KrkString * name, KrkValue * moduleOut, KrkString * ru
/* obj_str.h */
extern void krk_addObjects(void);
extern KrkValue krk_string_get(int argc, KrkValue argv[], int hasKw);
extern KrkValue krk_string_int(int argc, KrkValue argv[], int hasKw);
extern KrkValue krk_string_float(int argc, KrkValue argv[], int hasKw);
extern KrkValue krk_string_split(int argc, KrkValue argv[], int hasKw);
extern KrkValue krk_string_format(int argc, KrkValue argv[], int hasKw);
extern KrkValue _str___get__(int argc, KrkValue argv[], int hasKw);
#define krk_string_get _str___get__
extern KrkValue _str___int__(int argc, KrkValue argv[], int hasKw);
#define krk_string_int _str___int__
extern KrkValue _str___float__(int argc, KrkValue argv[], int hasKw);
#define krk_string_float _str___float__
extern KrkValue _str_split(int argc, KrkValue argv[], int hasKw);
#define krk_string_split _str_split
extern KrkValue _str_format(int argc, KrkValue argv[], int hasKw);
#define krk_string_format _str_format
/* obj_dict.h */
extern KrkValue krk_dict_nth_key_fast(size_t capacity, KrkTableEntry * entries, size_t index);