unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Elad Lahav <elahav@blackberry.com>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: Emacs on QNX
Date: Tue, 24 Oct 2017 13:14:34 -0700	[thread overview]
Message-ID: <611f69c3-4e4d-1a04-2621-ffa3eeb7ebf3@cs.ucla.edu> (raw)
In-Reply-To: <1508809949.3465.3.camel@blackberry.com>

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

On 10/23/2017 06:52 PM, Elad Lahav wrote:
> The attached patch seems to work.

Thanks. That appears to be against an older version of Emacs, though. I 
adapted it to emacs-26 (this simplified it) and installed the attached. 
Please give a try, e.g., by running these shell commands:

     git clone -b emacs-26 git://git.sv.gnu.org/emacs.git
     cd emacs
     ./autogen.sh
     ./configure
     make

assuming you have the relevant build tools.


[-- Attachment #2: 0001-Port-to-QNX.patch --]
[-- Type: text/x-patch, Size: 3466 bytes --]

From c95cc1e19eaab9df5789e3b07e2cf16298f06078 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 24 Oct 2017 12:54:28 -0700
Subject: [PATCH] Port to QNX

Simplified version of a patch proposed by Elad Lahav in:
https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00716.html
which is based on a previous patch I proposed in:
https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00707.html
* configure.ac (opsys, CFLAGS, LIBS_SYSTEM, hybrid_malloc)
(system_alloc, FIRST_PTY_LETTER, CYGWIN_OBJ):
Set appropriately for QNX.
* src/unexelf.c [__QNX__]: Include <sys/elf.h> instead of <elf.h>.
(unexec): Check for sbrk failure, and fall back on old BSS end.
---
 configure.ac  | 15 +++++++++++++--
 src/unexelf.c | 15 +++++++++------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 646a637cf3..ca75136474 100644
--- a/configure.ac
+++ b/configure.ac
@@ -699,6 +699,12 @@ AC_DEFUN
     esac
   ;;
 
+  ## QNX Neutrino
+  *-nto-qnx* )
+    opsys=qnxnto
+    CFLAGS="$CFLAGS -D__NO_EXT_QNX"
+  ;;
+
   ## Intel 386 machines where we don't care about the manufacturer.
   i[3456]86-*-* )
     case "${canonical}" in
@@ -1507,6 +1513,8 @@ AC_DEFUN
 
   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
 
+  qnxnto) LIBS_SYSTEM="-lsocket" ;;
+
   sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
 
   ## Motif needs -lgen.
@@ -2210,7 +2218,8 @@ AC_DEFUN
 case "$opsys" in
   ## darwin ld insists on the use of malloc routines in the System framework.
   darwin | mingw32 | nacl | sol2-10) ;;
-  cygwin) hybrid_malloc=yes
+  cygwin | qnxto)
+	  hybrid_malloc=yes
           system_malloc= ;;
   *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;;
 esac
@@ -4603,7 +4612,7 @@ AC_DEFUN
     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
     ;;
 
-  gnu | openbsd )
+  gnu | openbsd | qnxnto )
     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
     ;;
 
@@ -5144,6 +5153,8 @@ AC_DEFUN
   CYGWIN_OBJ=
   PRE_ALLOC_OBJ=
   POST_ALLOC_OBJ=lastfile.o
+elif test "$opsys" = "qnxnto"; then
+  CYGWIN_OBJ=sheap.o
 else
   CYGWIN_OBJ=
   PRE_ALLOC_OBJ=lastfile.o
diff --git a/src/unexelf.c b/src/unexelf.c
index 1cdcfeb44e..756de5835c 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -58,9 +58,11 @@ what you give them.   Help stamp out software-hoarding!  */
 #include <sys/types.h>
 #include <unistd.h>
 
-#if !defined (__NetBSD__) && !defined (__OpenBSD__)
-#include <elf.h>
-#endif /* not __NetBSD__ and not __OpenBSD__ */
+#ifdef __QNX__
+# include <sys/elf.h>
+#elif !defined __NetBSD__ && !defined __OpenBSD__
+# include <elf.h>
+#endif
 #include <sys/mman.h>
 #if defined (_SYSTYPE_SYSV)
 #include <sys/elf_mips.h>
@@ -222,7 +224,6 @@ unexec (const char *new_name, const char *old_name)
 {
   int new_file, old_file;
   off_t new_file_size;
-  void *new_break;
 
   /* Pointers to the base of the image of the two files.  */
   caddr_t old_base, new_base;
@@ -326,11 +327,13 @@ unexec (const char *new_name, const char *old_name)
   if (old_bss_index == -1)
     fatal ("no bss section found");
 
+  void *no_break = (void *) (intptr_t) -1;
+  void *new_break = no_break;
 #ifdef HAVE_SBRK
   new_break = sbrk (0);
-#else
-  new_break = (byte *) old_bss_addr + old_bss_size;
 #endif
+  if (new_break == no_break)
+    new_break = (byte *) old_bss_addr + old_bss_size;
   new_bss_addr = (ElfW (Addr)) new_break;
   bss_size_growth = new_bss_addr - old_bss_addr;
   new_data2_size = bss_size_growth;
-- 
2.13.6


  reply	other threads:[~2017-10-24 20:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-22 22:13 Emacs on QNX Elad Lahav
2017-10-23  4:51 ` Paul Eggert
2017-10-23 11:27   ` Elad Lahav
2017-10-24  1:52     ` Elad Lahav
2017-10-24 20:14       ` Paul Eggert [this message]
2017-10-25  2:27         ` Elad Lahav
2017-10-26  3:52           ` Paul Eggert
2017-11-09 17:17             ` Elad Lahav
2017-11-09 17:23               ` Eli Zaretskii
2017-11-30 17:43                 ` Elad Lahav
2017-11-30 23:41                   ` Paul Eggert
2017-12-01  2:06                     ` Elad Lahav
2017-12-01  3:37                       ` Paul Eggert
2017-12-01 11:55                         ` Elad Lahav
2017-12-11  0:25                     ` Elad Lahav
2017-11-09 17:30               ` Noam Postavsky
2017-11-09 17:33                 ` Elad Lahav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=611f69c3-4e4d-1a04-2621-ffa3eeb7ebf3@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=elahav@blackberry.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).