From 8806a6f8ee9066cc59852da6652cbb014cd709c0 Mon Sep 17 00:00:00 2001 From: rtoy <rtoy> Date: Thu, 11 Nov 2010 21:48:24 +0000 Subject: [PATCH] When storing strings to the core file, swap the bytes of Unicode strings if the byte order of the backend and the native backend are different. --- compiler/generic/new-genesis.lisp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/generic/new-genesis.lisp b/compiler/generic/new-genesis.lisp index cc9f023c8..767d4d8fb 100644 --- a/compiler/generic/new-genesis.lisp +++ b/compiler/generic/new-genesis.lisp @@ -4,7 +4,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/new-genesis.lisp,v 1.90 2010/07/19 23:08:37 rtoy Rel $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/new-genesis.lisp,v 1.91 2010/11/11 21:48:24 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -434,6 +434,13 @@ ;;(format t "s-t-c: len = ~d, ~S~%" len string) (dotimes (k len) (setf (aref bytes k) (logand #xffff (char-code (aref string k))))) + (unless (eq (c:backend-byte-order c:*backend*) + (c:backend-byte-order c:*native-backend*)) + ;; Swap byte order of unicode strings. + (dotimes (k len) + (let ((x (aref bytes k))) + (setf (aref bytes k) (+ (ldb (byte 8 8) x) + (ash (ldb (byte 8 0) x) 8)))))) (copy-to-system-area bytes (* vm:vector-data-offset ;; the word size of the native backend which ;; may be different from the target backend -- GitLab