Subject: Attempt at aarch64 support
From: Orion Poplawski <[email-masked]>
To: [email-masked]
Date: Wed, 07 May 2014 20:43:35 -0600

Package: nx-libs
Version: 3.5.0.24
Tags: patch

This is quick hack attempt at aarch64 support.  It allows nx-libs to
compile, but I have nothing to test on and I suspect it may be
incorrect, but it's a start.

-- 
Orion Poplawski
Technical Manager                     303-415-9701 x222
NWRA/CoRA Division                    FAX: 303-415-9702
3380 Mitchell Lane                  [email-masked]
Boulder, CO 80301              http://www.cora.nwra.com
diff -up nx-libs-3.5.0.24/nx-X11/config/cf/Imake.cf.aarch64 nx-libs-3.5.0.24/nx-X11/config/cf/Imake.cf
--- nx-libs-3.5.0.24/nx-X11/config/cf/Imake.cf.aarch64	2014-05-07 01:56:12.000000000 -0600
+++ nx-libs-3.5.0.24/nx-X11/config/cf/Imake.cf	2014-05-07 19:27:07.748795509 -0600
@@ -908,6 +908,9 @@ XCOMM Keep cpp from replacing path eleme
 #  endif
 #  undef __ARMEB__
 # endif
+# ifdef __aarch64__
+#  define Arm64Architecture
+# endif
 # ifdef mc68000
 #  define Mc68020Architecture
 #  undef mc68000
diff -up nx-libs-3.5.0.24/nx-X11/config/cf/linux.cf.aarch64 nx-libs-3.5.0.24/nx-X11/config/cf/linux.cf
--- nx-libs-3.5.0.24/nx-X11/config/cf/linux.cf.aarch64	2014-05-07 02:00:04.000000000 -0600
+++ nx-libs-3.5.0.24/nx-X11/config/cf/linux.cf	2014-05-07 19:28:17.823777953 -0600
@@ -844,6 +844,16 @@ InstallNamedTargetNoClobber(install,file
 # define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
 #endif /* Arm32Achitecture */
 
+#ifdef Arm64Architecture
+# define DefaultCCOptions
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O3
+# endif
+# define LinuxMachineDefines	-D__aarch64__ -U__arm -Uarm
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif /* Arm64Achitecture */
+
 #ifdef HPArchitecture
 # define OptimizedCDebugFlags	-O2  GccAliasingArgs
 # define LinuxMachineDefines	-D__hppa__
diff -up nx-libs-3.5.0.24/nx-X11/config/cf/Imake.tmpl.aarch64 nx-libs-3.5.0.24/nx-X11/config/cf/Imake.tmpl
--- nx-libs-3.5.0.24/nx-X11/config/cf/Imake.tmpl.aarch64	2014-05-07 02:00:04.000000000 -0600
+++ nx-libs-3.5.0.24/nx-X11/config/cf/Imake.tmpl	2014-05-07 19:59:05.266769630 -0600
@@ -526,6 +526,10 @@ XCOMM the platform-specific parameters -
 #define ByteOrder		X_BIG_ENDIAN
 #elif defined(Arm32Architecture)
 #define ByteOrder		X_LITTLE_ENDIAN
+#elif defined(Arm64ebArchitecture)
+#define ByteOrder		X_BIG_ENDIAN
+#elif defined(Arm64Architecture)
+#define ByteOrder		X_LITTLE_ENDIAN
 #elif defined(RsArchitecture)
 #define ByteOrder		X_BIG_ENDIAN
 #elif defined(PpcArchitecture) || defined(Ppc64Architecture)
diff -up nx-libs-3.5.0.24/nx-X11/programs/Xserver/include/servermd.h.aarch64 nx-libs-3.5.0.24/nx-X11/programs/Xserver/include/servermd.h
--- nx-libs-3.5.0.24/nx-X11/programs/Xserver/include/servermd.h.aarch64	2014-05-07 01:56:12.000000000 -0600
+++ nx-libs-3.5.0.24/nx-X11/programs/Xserver/include/servermd.h	2014-05-07 19:55:11.760395141 -0600
@@ -154,6 +154,28 @@ SOFTWARE.
 
 #endif /* __arm32__ */
 
+#ifdef __aarch64__
+
+#ifdef __AARCH64EL__
+#define IMAGE_BYTE_ORDER        LSBFirst
+#define BITMAP_BIT_ORDER        LSBFirst
+#endif
+#ifdef __AARCH64EB__
+#define IMAGE_BYTE_ORDER        MSBFirst
+#define BITMAP_BIT_ORDER        MSBFirst
+#endif
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16)
+#  define BITMAP_SCANLINE_UNIT  8
+# endif
+
+#define GLYPHPADBYTES           4
+#define GETLEFTBITS_ALIGNMENT   1
+#define LARGE_INSTRUCTION_CACHE
+#define AVOID_MEMORY_READ
+
+#endif /* __aarch64__ */
+
 #if defined (hpux) || defined __hppa__
 
 #define IMAGE_BYTE_ORDER	MSBFirst