Created
December 7, 2009 08:14
-
-
Save imasahiro/250706 to your computer and use it in GitHub Desktop.
patch for mac-gcc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: include/mk.h | |
=================================================================== | |
--- include/mk.h (revision 29) | |
+++ include/mk.h (working copy) | |
@@ -755,10 +755,19 @@ | |
#ifdef _DEBUG | |
int mk_execute_expr( MK_VM_STRUCT *vm, MK_NODE_EXPR *pTarget, int hasParent ); | |
#else | |
+static inline int mk_execute_expr( MK_VM_STRUCT *vm, MK_NODE_EXPR *pTarget, int hasParent ) | |
+{ | |
+ int ret = ( ( abs( (INT_PTR)vm->stackTop - (INT_PTR)&vm ) < MK_SIZEOF_MAX_STACK_SIZE ) ? ¥ | |
+ vm->callNodeExpr[MK_TYPE_ATTRIBUTE_INDEX((pTarget)->flags)](vm, pTarget, hasParent ) : ¥ | |
+ mk_raise_internal_error( vm, "", 0, MK_ERROR_TYPE_VM_ERROR | 11, NULL ) ); | |
+ return ret; | |
+} | |
+/* | |
#define mk_execute_expr( vm, pTarget, hasParent ) ¥ | |
( ( abs( (INT_PTR)vm->stackTop - (INT_PTR)&vm ) < MK_SIZEOF_MAX_STACK_SIZE ) ? ¥ | |
vm->callNodeExpr[MK_TYPE_ATTRIBUTE_INDEX((pTarget)->flags)](vm, pTarget, hasParent ) : ¥ | |
mk_raise_internal_error( vm, "", 0, MK_ERROR_TYPE_VM_ERROR | 11, NULL ) ) | |
+ */ | |
#endif | |
MK_CLASS *mk_vm_get_class_by_name( MK_VM_STRUCT *vm, const MK_CHAR *pname ); | |
MK_CLASS *mk_vm_get_class( MK_VM_STRUCT *vm, MK_VM_FRAME_ITEM *pTarget ); | |
@@ -817,7 +826,7 @@ | |
if(ptarget!=NULL && ptarget->used < ptarget->size ) ¥ | |
ptarget->items[ptarget->used++] = elem; ¥ | |
else ¥ | |
- mk_insert_at_vector( &ptarget, 0xffffffff, elem ); | |
+ mk_insert_at_vector( ptarget, 0xffffffff, elem ); | |
#define mk_size_vector( ptarget ) ¥ | |
( ( ptarget != NULL ) ? ptarget->used : 0 ) | |
Index: src/node.c | |
=================================================================== | |
--- src/node.c (revision 29) | |
+++ src/node.c (working copy) | |
@@ -1,7 +1,11 @@ | |
#include "mk.h" | |
#include <stdlib.h> | |
#include <string.h> | |
+#ifdef __APPLE__ | |
+#include <sys/malloc.h> | |
+#else | |
#include <malloc.h> | |
+#endif | |
#define free_if_not_memory_pool( p ) ¥ | |
{ ¥ | |
Index: src/native.c | |
=================================================================== | |
--- src/native.c (revision 29) | |
+++ src/native.c (working copy) | |
@@ -35,28 +35,28 @@ | |
{ | |
// gcc | |
// need compile option "-masm=intel" | |
- __asm__ __volatile__( | |
+ asm volatile( | |
"push %6 ¥t¥n" | |
- "mov eax, %3 ¥t¥n" // eax <= ptrLocalStack | |
- "mov edx, %2 ¥t¥n" // ecx <= sizeParam | |
- "inc edx ¥t¥n" | |
+ "movl %3, %%eax ¥t¥n" // eax <= ptrLocalStack | |
+ "movl %2, %%edx ¥t¥n" // ecx <= sizeParam | |
+ "inc %%edx ¥t¥n" | |
"1: ¥t¥n" | |
- "dec edx ¥t¥n" | |
+ "dec %%edx ¥t¥n" | |
"jz 2f ¥t¥n" // if( edx == 0 ) jmp 2f | |
- "push [eax] ¥t¥n" | |
- "sub eax, 4 ¥t¥n" // sub eax, MK_SIZEOF_PTR | |
+ "push %%eax ¥t¥n" | |
+ "sub $0x04, %%eax ¥t¥n" // sub eax, MK_SIZEOF_PTR | |
"jmp 1b ¥t¥n" | |
"2: ¥t¥n" | |
- "push [%5] ¥t¥n" // push [vm] | |
- "call %4 ¥t¥n" // function( vm, arg1, arg2, ..., result ) | |
- "mov %1, eax ¥t¥n" // retCode <= eax | |
- "mov edx, %2 ¥t¥n" // edx <= sizeParam | |
- "add edx, 2 ¥t¥n" | |
- "shl edx, 2 ¥t¥n" // 32bit:2 64bit:3 | |
- "add esp, edx ¥t¥n" // fix stack( need _cdecl call only. ) | |
+ "push %5 ¥t¥n" // push [vm] | |
+ "call *%4 ¥t¥n" // function( vm, arg1, arg2, ..., result ) | |
+ "movl %%eax,%1 ¥t¥n" // retCode <= eax | |
+ "movl %2, %%edx ¥t¥n" // edx <= sizeParam | |
+ "addl $0x02, %%edx ¥t¥n" | |
+ "shl $0x02, %%edx ¥t¥n" // 32bit:2 64bit:3 | |
+ "add %%edx, %%esp ¥t¥n" // fix stack( need _cdecl call only. ) | |
: "=m"(result), "=m"(retCode) // output ope | |
: "m"(sizeParam), "m"(ptrLocalStack),"m"(function), "m"(vm), "m"(pResult) // input ope | |
- : "eax", "ecx", "edx", "memory" | |
+ : "%eax", "%ecx", "%edx", "memory" | |
); | |
} | |
#elif _MSC_VER | |
Index: Makefile_macosx | |
=================================================================== | |
--- Makefile_macosx (revision 0) | |
+++ Makefile_macosx (revision 0) | |
@@ -0,0 +1,30 @@ | |
+# mk script language Mekefile | |
+ | |
+CC = gcc-mp-4.4 | |
+CFLAGS = -O2 | |
+CFLAGSDBG = -O0 -g -D_DEBUG | |
+INCLUDE = ./include/ | |
+SRC = ./src/ | |
+BIN = ./bin/ | |
+TARGET = mksc | |
+TARGETDBG =mkscd | |
+ | |
+all: release debug | |
+ | |
+release : $(BIN)$(TARGET) | |
+ | |
+debug : $(BIN)$(TARGETDBG) | |
+ | |
+$(BIN)$(TARGET): | |
+ if [ ! -d bin ]; then mkdir bin; fi | |
+ $(CC) $(CFLAGS) -I$(INCLUDE) $(SRC)*.c -o $(BIN)$(TARGET) | |
+ | |
+$(BIN)$(TARGETDBG): | |
+ if [ ! -d bin ]; then mkdir bin; fi | |
+ $(CC) $(CFLAGSDBG) -I$(INCLUDE) $(SRC)*.c -o $(BIN)$(TARGETDBG) | |
+ | |
+clean: | |
+ rm -f $(BIN)$(TARGET) $(BIN)$(TARGETDBG) | |
+ | |
+install: | |
+ cp $(BIN)$(TARGET) /usr/bin/ | |
Index: Makefile_linux | |
=================================================================== | |
--- Makefile_linux (revision 29) | |
+++ Makefile_linux (working copy) | |
@@ -1,8 +1,8 @@ | |
# mk script language Mekefile | |
CC = gcc | |
-CFLAGS = -masm=intel -O2 | |
-CFLAGSDBG = -masm=intel -O0 -g -D_DEBUG | |
+CFLAGS = -O2 | |
+CFLAGSDBG = -O0 -g -D_DEBUG | |
INCLUDE = ./include/ | |
SRC = ./src/ | |
BIN = ./bin/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment