Fix NQP on big-endian platforms, tested by landry@ on both powerpc and sparc64.
Thanks to Jonathan Worthington for coming up with a fix upstream. Also, add -Werror fixes for powerpc, tested by aja@. ok landry@
This commit is contained in:
parent
f6b3b7c3b5
commit
7969fd62e7
@ -1,6 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.5 2012/06/04 18:43:18 pascal Exp $
|
||||
|
||||
NOT_FOR_ARCHS = ${BE_ARCHS}
|
||||
# $OpenBSD: Makefile,v 1.6 2012/06/12 08:21:54 pascal Exp $
|
||||
|
||||
SHARED_ONLY = Yes
|
||||
|
||||
|
@ -1,7 +1,16 @@
|
||||
$OpenBSD: patch-3rdparty_dyncall_dyncallback_dyncall_callback_ppc32_c,v 1.1 2012/05/09 13:50:58 pascal Exp $
|
||||
--- 3rdparty/dyncall/dyncallback/dyncall_callback_ppc32.c.orig Wed May 9 15:41:23 2012
|
||||
+++ 3rdparty/dyncall/dyncallback/dyncall_callback_ppc32.c Wed May 9 15:41:37 2012
|
||||
@@ -35,7 +35,7 @@ void dcbInitCallback(DCCallback* pcb, const char* sign
|
||||
$OpenBSD: patch-3rdparty_dyncall_dyncallback_dyncall_callback_ppc32_c,v 1.2 2012/06/12 08:21:54 pascal Exp $
|
||||
--- 3rdparty/dyncall/dyncallback/dyncall_callback_ppc32.c.orig Wed Apr 25 22:05:34 2012
|
||||
+++ 3rdparty/dyncall/dyncallback/dyncall_callback_ppc32.c Sun Jun 3 13:13:46 2012
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "dyncall_callback.h"
|
||||
#include "dyncall_callback_ppc32.h"
|
||||
|
||||
+#include "dyncall_alloc_wx.h"
|
||||
+
|
||||
void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler* handler, void* userdata)
|
||||
{
|
||||
const char* ptr;
|
||||
@@ -35,7 +37,7 @@ void dcbInitCallback(DCCallback* pcb, const char* sign
|
||||
pcb->userdata = userdata;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,16 @@
|
||||
$OpenBSD: patch-3rdparty_dyncall_dyncallback_dyncall_thunk_ppc32_c,v 1.1 2012/05/09 13:50:58 pascal Exp $
|
||||
--- 3rdparty/dyncall/dyncallback/dyncall_thunk_ppc32.c.orig Wed May 9 15:45:36 2012
|
||||
+++ 3rdparty/dyncall/dyncallback/dyncall_thunk_ppc32.c Wed May 9 15:44:50 2012
|
||||
@@ -28,7 +28,7 @@
|
||||
unsigned short hi16(x) { return ( (unsigned short) (((unsigned int)x)>>16UL) ); }
|
||||
unsigned short lo16(x) { return ( (unsigned short) ((unsigned int)x) ); }
|
||||
$OpenBSD: patch-3rdparty_dyncall_dyncallback_dyncall_thunk_ppc32_c,v 1.2 2012/06/12 08:21:54 pascal Exp $
|
||||
--- 3rdparty/dyncall/dyncallback/dyncall_thunk_ppc32.c.orig Wed Apr 25 22:05:34 2012
|
||||
+++ 3rdparty/dyncall/dyncallback/dyncall_thunk_ppc32.c Sat Jun 2 17:56:52 2012
|
||||
@@ -25,10 +25,12 @@
|
||||
|
||||
#include "dyncall_thunk.h"
|
||||
|
||||
-unsigned short hi16(x) { return ( (unsigned short) (((unsigned int)x)>>16UL) ); }
|
||||
-unsigned short lo16(x) { return ( (unsigned short) ((unsigned int)x) ); }
|
||||
+unsigned short hi16(DCThunk *);
|
||||
+unsigned short lo16(DCThunk *);
|
||||
+unsigned short hi16(DCThunk* x) { return ( (unsigned short) (((unsigned int)x)>>16UL) ); }
|
||||
+unsigned short lo16(DCThunk* x) { return ( (unsigned short) ((unsigned int)x) ); }
|
||||
|
||||
-void dcbInitThunk(DCThunk* p, void (*entry)())
|
||||
+void dcbInitThunk(DCThunk* p, void (*entry)(void))
|
||||
|
112
lang/nqp/patches/patch-src_6model_serialization_c
Normal file
112
lang/nqp/patches/patch-src_6model_serialization_c
Normal file
@ -0,0 +1,112 @@
|
||||
$OpenBSD: patch-src_6model_serialization_c,v 1.1 2012/06/12 08:21:54 pascal Exp $
|
||||
|
||||
http://github.com/perl6/nqp/commit/b1226fb1bf4857662b9baa326b20ae410c464695
|
||||
|
||||
--- src/6model/serialization.c.orig Wed Apr 25 22:05:35 2012
|
||||
+++ src/6model/serialization.c Mon Jun 11 22:25:08 2012
|
||||
@@ -57,32 +57,57 @@ static INTVAL perl6_lexpad_id = 0;
|
||||
static INTVAL ctmthunk_id = 0;
|
||||
static INTVAL ownedhash_id = 0;
|
||||
|
||||
+/* Endian translation (file format is little endian, so on big endian we need
|
||||
+ * to twiddle. */
|
||||
+#if PARROT_BIGENDIAN
|
||||
+static void switch_endian(char *bytes, size_t size)
|
||||
+{
|
||||
+ size_t low = 0;
|
||||
+ size_t high = size - 1;
|
||||
+ while (high > low) {
|
||||
+ char tmp = bytes[low];
|
||||
+ bytes[low] = bytes[high];
|
||||
+ bytes[high] = tmp;
|
||||
+ low++;
|
||||
+ high--;
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/* ***************************************************************************
|
||||
* Serialization (writing related)
|
||||
* ***************************************************************************/
|
||||
|
||||
/* Writes an int64 into a buffer. */
|
||||
static void write_int64(char *buffer, size_t offset, Parrot_Int8 value) {
|
||||
- /* XXX: Big Endian Handling! */
|
||||
memcpy(buffer + offset, &value, 8);
|
||||
+#if PARROT_BIGENDIAN
|
||||
+ switch_endian(buffer + offset, 8);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/* Writes an int32 into a buffer. */
|
||||
static void write_int32(char *buffer, size_t offset, Parrot_Int4 value) {
|
||||
- /* XXX: Big Endian Handling! */
|
||||
memcpy(buffer + offset, &value, 4);
|
||||
+#if PARROT_BIGENDIAN
|
||||
+ switch_endian(buffer + offset, 4);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/* Writes an int16 into a buffer. */
|
||||
static void write_int16(char *buffer, size_t offset, Parrot_Int2 value) {
|
||||
- /* XXX: Big Endian Handling! */
|
||||
memcpy(buffer + offset, &value, 2);
|
||||
+#if PARROT_BIGENDIAN
|
||||
+ switch_endian(buffer + offset, 2);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/* Writes an double into a buffer. */
|
||||
static void write_double(char *buffer, size_t offset, double value) {
|
||||
- /* XXX: Big Endian Handling! */
|
||||
memcpy(buffer + offset, &value, 8);
|
||||
+#if PARROT_BIGENDIAN
|
||||
+ switch_endian(buffer + offset, 8);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/* Adds an item to the string heap if needed, and returns the index where
|
||||
@@ -1016,7 +1041,9 @@ STRING * Serialization_serialize(PARROT_INTERP, PMC *s
|
||||
/* Reads an int64 from a buffer. */
|
||||
static Parrot_Int8 read_int64(char *buffer, size_t offset) {
|
||||
Parrot_Int8 value;
|
||||
- /* XXX: Big Endian Handling! */
|
||||
+#if PARROT_BIGENDIAN
|
||||
+ switch_endian(buffer + offset, 8);
|
||||
+#endif
|
||||
memcpy(&value, buffer + offset, 8);
|
||||
return value;
|
||||
}
|
||||
@@ -1024,7 +1051,9 @@ static Parrot_Int8 read_int64(char *buffer, size_t off
|
||||
/* Reads an int32 from a buffer. */
|
||||
static Parrot_Int4 read_int32(char *buffer, size_t offset) {
|
||||
Parrot_Int4 value;
|
||||
- /* XXX: Big Endian Handling! */
|
||||
+#if PARROT_BIGENDIAN
|
||||
+ switch_endian(buffer + offset, 4);
|
||||
+#endif
|
||||
memcpy(&value, buffer + offset, 4);
|
||||
return value;
|
||||
}
|
||||
@@ -1032,7 +1061,9 @@ static Parrot_Int4 read_int32(char *buffer, size_t off
|
||||
/* Reads an int16 from a buffer. */
|
||||
static Parrot_Int2 read_int16(char *buffer, size_t offset) {
|
||||
Parrot_Int2 value;
|
||||
- /* XXX: Big Endian Handling! */
|
||||
+#if PARROT_BIGENDIAN
|
||||
+ switch_endian(buffer + offset, 2);
|
||||
+#endif
|
||||
memcpy(&value, buffer + offset, 2);
|
||||
return value;
|
||||
}
|
||||
@@ -1040,7 +1071,9 @@ static Parrot_Int2 read_int16(char *buffer, size_t off
|
||||
/* Reads double from a buffer. */
|
||||
static double read_double(char *buffer, size_t offset) {
|
||||
double value;
|
||||
- /* XXX: Big Endian Handling! */
|
||||
+#if PARROT_BIGENDIAN
|
||||
+ switch_endian(buffer + offset, 8);
|
||||
+#endif
|
||||
memcpy(&value, buffer + offset, 8);
|
||||
return value;
|
||||
}
|
Loading…
Reference in New Issue
Block a user