From 277dc2f3edffc00794087472c32e757652624dd5 Mon Sep 17 00:00:00 2001
From: Duane Rettig <duane@franz.com>
Date: Tue, 14 Jun 2016 11:48:30 -0700
Subject: [PATCH] Allow compilation for arm64 lisp

Add new makefile for arm64 and make changes to allow
add-ons to build cleanly

%Bootstrapping: none
%Testing:none

Change-Id: I8f8bb249deb69767cb65f91feff9ad65b215a9b8
---
 Makefile.arm64 |  5 +++--
 Makefile.wnn   |  2 +-
 wnn/jl.c       |  6 ++++++
 wnn/js.c       | 13 ++++++++++---
 wnn/msg.c      | 13 +++++++++++--
 5 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/Makefile.arm64 b/Makefile.arm64
index 4074bcb4..c9f1331f 100644
--- a/Makefile.arm64
+++ b/Makefile.arm64
@@ -8,16 +8,17 @@ XINCLUDES = -I/usr/include/openmotif
 XLIBDIR  = /usr/lib64/openmotif
 endif
 
-XINCLUDES ?= /usr/include
+XINCLUDES ?= -I/usr/include
 XLIBDIR  ?= /usr/lib64
 
 TKLIB=-lXm -lXpm -lXext -lXp
 XTLIB=-lXt
 XLIB=-lX11
 
+CFLAGS = -fomit-frame-pointer -Wno-unused-result -Wno-pointer-to-int-cast -Wno-unused-but-set-variable -DAcl64Bit -march=armv8-a -mstrict-align
+LDFLAGS = -E
 ifdef FI_USE_DMALLOC
 THREADLIB = -lpthread -ldmallocth
-CFLAGS = -I/usr/local/include
 else
 THREADLIB = -lpthread
 endif
diff --git a/Makefile.wnn b/Makefile.wnn
index 575d382e..10e92de8 100644
--- a/Makefile.wnn
+++ b/Makefile.wnn
@@ -113,7 +113,7 @@ ifeq ($(MACHINE),x86_64)
 REDHATLIBS = -lcrypt
 endif
 ifeq ($(MACHINE),arm64)
-REDHATLIBS = -lcrypt
+REDHATLIBS = -lcrypt -lrt -lm -ldl -lc
 endif
 endif
 
diff --git a/wnn/jl.c b/wnn/jl.c
index b9370cbd..b4c54ef2 100644
--- a/wnn/jl.c
+++ b/wnn/jl.c
@@ -54,6 +54,12 @@
 
 #include "commonhd.h"
 #include "config.h"
+#if defined(__AARCH64EL__)
+#include <bits/types.h>
+#undef __FD_SETSIZE
+#define __FD_SETSIZE 65536
+#include <stdlib.h>
+#endif
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>  /* for F_OK */
diff --git a/wnn/js.c b/wnn/js.c
index 4e8cc75b..c64edd16 100644
--- a/wnn/js.c
+++ b/wnn/js.c
@@ -74,6 +74,13 @@ extern	Variables
 /* removed for building on FC4, x86_64 */
 /* extern	char	*malloc(); */
 
+#if defined(__AARCH64EL__)
+#include <bits/types.h>
+#undef __FD_SETSIZE
+#define __FD_SETSIZE 65536
+#include <stdlib.h>
+#endif
+
 #include <stdio.h>
 #include <ctype.h>
 #ifdef UX386
@@ -641,7 +648,7 @@ register int timeout;
    }
  }
  current_js->sd= current_sd;
- handler_of_jserver_dead(NULL);
+ handler_of_jserver_dead(((WNN_JSERVER_ID *)NULL));
  snd_head(JS_OPEN);
  put4com(JLIB_VERSION);		/* H.T. */
  putscom(host);
@@ -702,7 +709,7 @@ char *lang;
     if(!(env=(struct wnn_env *)malloc(sizeof(struct wnn_env)))){
 	    wnn_errorno=WNN_ALLOC_FAIL;return NULL;
     }
-    handler_of_jserver_dead(NULL);
+    handler_of_jserver_dead(((struct wnn_env *)NULL));
     snd_head(JS_CONNECT);
     putscom(env_name);
     snd_flush();
@@ -795,7 +802,7 @@ register struct wnn_env *env;
  free((char *)env);
  */
  set_current_js(env->js_id);
- handler_of_jserver_dead(NULL);
+ handler_of_jserver_dead((int)NULL);
  snd_env_head(&tmp_env,JS_DISCONNECT);
  snd_flush();
  x=get4com();
diff --git a/wnn/msg.c b/wnn/msg.c
index 808506c0..a7f331aa 100644
--- a/wnn/msg.c
+++ b/wnn/msg.c
@@ -49,6 +49,13 @@
 	    <message id>\t<message>
 */
 
+#if defined(__AARCH64EL__)
+#include <bits/types.h>
+#undef __FD_SETSIZE
+#define __FD_SETSIZE 65536
+#include <stdlib.h>
+#endif
+
 #include <stdio.h>
 #include "commonhd.h"
 #include "wnn_os.h"
@@ -56,6 +63,7 @@
 
 extern char *getenv();
 
+#if !defined(__AARCH64EL__)
 static char *
 bsearch(ky, bs, nel, width, compar)
 char *ky;
@@ -100,6 +108,7 @@ int (*compar)();
     }
     return ((char *) 0);	/* not found */
 }
+#endif
 
 static char *
 getlang(lang)
@@ -205,7 +214,7 @@ register int id;
     if(cd->msg_bd == 0 || cd->msg_cnt == 0)
 	return(NULL);
     bd = (struct msg_bd *)
-	bsearch(id, cd->msg_bd, cd->msg_cnt, sizeof(struct msg_bd), _search);
+	    bsearch(id, cd->msg_bd, cd->msg_cnt, (size_t)sizeof(struct msg_bd), _search);
     if(bd == NULL)
 	return(NULL);
     return(bd->msg);
@@ -361,7 +370,7 @@ char	*msg;
 register char	*lang;
 {
     register struct msg_cat *cd;
-    char ret[128];
+    static char ret[128]; /* bug23992 */
     register char *msg_bd;
 
     if(catd == 0)
-- 
GitLab