emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Emacs on QNX


From: Elad Lahav
Subject: Emacs on QNX
Date: Sun, 22 Oct 2017 22:13:55 +0000

Hello all,

I built Emacs on QNX 7.0. For the most part, the process was straight-
forward and required only minimal changes to the source (see below for
a diff). However, I ran into a problem when trying to run Emacs. The
investigation pointed to the use of sbrk(), which QNX dropped many
years ago. There is still a stub that returns -1 and sets errno to
ENOMEM, but the Emacs code doesn't check for that, and interprets the
result as the address 0xffffffffffffffff. Hilarity ensues.

To overcome the problem, I wrote a naive implementation of sbrk() in a
dynamically-linked library (attached). It doesn't fully adhere to the
original semantics of sbrk(), but is enough to get Emacs running
properly.

Why is sbrk() still used? With 64-bit address spaces and ASLR it is
hard to imagine this API being useful. I am surprised that other
operating systems still support it. Is there a different route I can
take that doesn't require the emulated sbrk()?

Thanks,
--Elad


diff -u -r emacs-25.2.orig/configure.ac emacs-25.2/configure.ac
--- emacs-25.2.orig/configure.ac        2017-02-03 09:34:30.000000000 -0500
+++ emacs-25.2/configure.ac     2017-10-22 03:01:12.000000000 -0400
@@ -698,6 +698,14 @@
     esac
   ;;
 
+  ## QNX Neutrino 
+  *-nto-qnx* )
+    echo Found QNX
+    opsys=qnxnto
+    CFLAGS="$CFLAGS -D__NO_EXT_QNX"
+    LDFLAGS="$LDFLAGS -L/usr/lib -lsocket -lsbrk"
+  ;;
+
   ## Intel 386 machines where we don't care about the manufacturer.
   i[3456]86-*-* )
     case "${canonical}" in
@@ -4465,7 +4473,7 @@
     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
     ;;
 
-  gnu | openbsd )
+  gnu | openbsd | qnxnto )
     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
     ;;
 
diff -u -r emacs-25.2.orig/src/unexelf.c emacs-25.2/src/unexelf.c
--- emacs-25.2.orig/src/unexelf.c       2017-02-03 05:25:45.000000000 -0500
+++ emacs-25.2/src/unexelf.c    2017-10-22 03:11:10.000000000 -0400
@@ -58,7 +58,9 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#if !defined (__NetBSD__) && !defined (__OpenBSD__)
+#if defined(__QNX__)
+#include <sys/elf.h>
+#elif !defined (__NetBSD__) && !defined (__OpenBSD__)
 #include <elf.h>
 #endif /* not __NetBSD__ and not __OpenBSD__ */
 #include <sys/mman.h>

---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential 
information, privileged material (including material protected by the 
solicitor-client or other applicable privileges), or constitute non-public 
information. Any use of this information by anyone other than the intended 
recipient is prohibited. If you have received this transmission in error, 
please immediately reply to the sender and delete this information from your 
system. Use, dissemination, distribution, or reproduction of this transmission 
by unintended recipients is not authorized and may be unlawful.

Attachment: libsbrk.c
Description: libsbrk.c


reply via email to

[Prev in Thread] Current Thread [Next in Thread]