2
0
Эх сурвалжийг харах

ensure 16 memory align on ia32/msvc

Nicolas Cannasse 10 жил өмнө
parent
commit
21a5efadd9
4 өөрчлөгдсөн 40 нэмэгдсэн , 23 устгасан
  1. 22 22
      src/code.c
  2. 16 0
      src/global.c
  3. 1 0
      src/hl.h
  4. 1 1
      src/main.c

+ 22 - 22
src/code.c

@@ -1,25 +1,25 @@
-/*
- * Copyright (C)2015 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#include "hl.h"
+/*
+ * Copyright (C)2015 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include "hl.h"
 
 
 #define OP(_,n) n,
 #define OP(_,n) n,
 #define OP_BEGIN static int hl_op_nargs[] = {
 #define OP_BEGIN static int hl_op_nargs[] = {

+ 16 - 0
src/global.c

@@ -120,3 +120,19 @@ vdynamic *hl_alloc_dynamic( hl_type *t ) {
 	return d;
 	return d;
 }
 }
 
 
+void hl_call( void *f ) {
+#	if !defined(HL_64) && defined(HL_VCC)
+	int old_esp;
+	__asm {
+		mov old_esp, esp
+		mov eax, esp
+		and eax, 15
+		sub esp, eax
+		call f
+		mov esp, old_esp
+	}
+#	else
+	((fptr)f)();
+#	endif
+}
+

+ 1 - 0
src/hl.h

@@ -192,6 +192,7 @@ typedef struct {
 	} v;
 	} v;
 } vdynamic;
 } vdynamic;
 
 
+void hl_call( void *f );
 vdynamic *hl_alloc_dynamic( hl_type *t );
 vdynamic *hl_alloc_dynamic( hl_type *t );
 
 
 #endif
 #endif

+ 1 - 1
src/main.c

@@ -68,7 +68,7 @@ int main( int argc, char *argv[] ) {
 			return 4;
 			return 4;
 		if( !hl_module_init(m) )
 		if( !hl_module_init(m) )
 			return 5;
 			return 5;
-		(*(fptr*)(m->globals_data + m->globals_indexes[m->code->entrypoint]))();
+		hl_call(*(fptr*)(m->globals_data + m->globals_indexes[m->code->entrypoint]));
 		hl_module_free(m);
 		hl_module_free(m);
 		hl_free(&code->alloc);
 		hl_free(&code->alloc);
 	}
 	}