unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Elad Lahav <elahav@blackberry.com>
To: "eggert@cs.ucla.edu" <eggert@cs.ucla.edu>,
	"Emacs-devel@gnu.org" <Emacs-devel@gnu.org>
Subject: Re: Emacs on QNX
Date: Tue, 24 Oct 2017 01:52:29 +0000	[thread overview]
Message-ID: <1508809949.3465.3.camel@blackberry.com> (raw)
In-Reply-To: <1508758075.3923.6.camel@blackberry.com>

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

The attached patch seems to work.
I changed a couple of places that where code is conditionally-compiled
on CYGWIN instead of HYBRID_MALLOC, and added support for hybrid malloc
to the ELF version of unexec(). I also removed the -L/usr/lib linker
flag, which is not needed.

--Elad
---------------------------------------------------------------------
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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qnx.diff --]
[-- Type: text/x-patch; name="qnx.diff", Size: 4566 bytes --]

diff --git a/configure b/configure
index 8783b80..1e77e47 100755
--- a/configure
+++ b/configure
@@ -5358,6 +5358,12 @@ case "${canonical}" in
     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
@@ -9607,6 +9613,8 @@ case "$opsys" in
 
   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
 
+  qnxnto) LIBS_SYSTEM="-lsocket" ;;
+
   sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
 
   ## Motif needs -lgen.
@@ -11475,7 +11483,7 @@ hybrid_malloc=
 case "$opsys" in
   ## darwin ld insists on the use of malloc routines in the System framework.
   darwin | mingw32 | nacl | sol2-10) system_malloc=yes ;;
-  cygwin) hybrid_malloc=yes;;
+  cygwin | qnxnto ) hybrid_malloc=yes;;
 esac
 
 GMALLOC_OBJ=
@@ -18475,7 +18483,7 @@ case $opsys in
 
     ;;
 
-  gnu | openbsd )
+  gnu | openbsd | qnxnto )
     $as_echo "#define FIRST_PTY_LETTER 'p'" >>confdefs.h
 
     ;;
@@ -19254,6 +19262,8 @@ elif test "$opsys" = "mingw32"; then
   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/configure.ac b/configure.ac
index 2a4e0c1..6ba7db6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -697,6 +697,12 @@ case "${canonical}" in
       *) ;;
     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-*-* )
@@ -1440,6 +1446,8 @@ case "$opsys" in
 
   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
 
+  qnxnto) LIBS_SYSTEM="-lsocket" ;;
+
   sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
 
   ## Motif needs -lgen.
@@ -2137,7 +2145,7 @@ hybrid_malloc=
 case "$opsys" in
   ## darwin ld insists on the use of malloc routines in the System framework.
   darwin | mingw32 | nacl | sol2-10) system_malloc=yes ;;
-  cygwin) hybrid_malloc=yes;;
+  cygwin | qnxnto ) hybrid_malloc=yes;;
 esac
 
 GMALLOC_OBJ=
@@ -4465,7 +4473,7 @@ case $opsys in
     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
     ;;
 
-  gnu | openbsd )
+  gnu | openbsd | qnxnto )
     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
     ;;
 
@@ -5045,6 +5053,8 @@ elif test "$opsys" = "mingw32"; then
   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/gmalloc.c b/src/gmalloc.c
index a63927e..3489277 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -67,7 +67,7 @@ extern _Noreturn void emacs_abort (void) NO_INLINE;
 #define aligned_alloc galigned_alloc
 #define free gfree
 
-#ifdef CYGWIN
+#ifdef HYBRID_MALLOC
 extern void *bss_sbrk (ptrdiff_t size);
 extern int bss_sbrk_did_unexec;
 extern char bss_sbrk_buffer[];
@@ -1516,7 +1516,7 @@ void *
 __default_morecore (ptrdiff_t increment)
 {
   void *result;
-#if defined (CYGWIN)
+#if defined (HYBRID_MALLOC)
   if (!DUMPED)
     {
       return bss_sbrk (increment);
diff --git a/src/unexelf.c b/src/unexelf.c
index 5a56cbd..bf05e29 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__)
+#ifdef __QNX__
+#include <sys/elf.h>
+#elif !defined __NetBSD__ && !defined __OpenBSD__
 #include <elf.h>
-#endif /* not __NetBSD__ and not __OpenBSD__ */
+#endif
 #include <sys/mman.h>
 #if defined (_SYSTYPE_SYSV)
 #include <sys/elf_mips.h>
@@ -191,6 +193,10 @@ verify ((! TYPE_SIGNED (ElfW (Half))
 # define DEBUG_LOG(expr) fprintf (stderr, #expr " 0x%jx\n", (uintmax_t) (expr))
 #endif
 
+#ifdef HYBRID_MALLOC
+extern int bss_sbrk_did_unexec;
+#endif
+
 /* Get the address of a particular section or program header entry,
  * accounting for the size of the entries.
  */
@@ -329,8 +335,15 @@ unexec (const char *new_name, const char *old_name)
   if (old_bss_index == -1)
     fatal ("no bss section found");
 
+#ifdef HYBRID_MALLOC
+  /* The pre-dump hybrid malloc uses an area in the BSS as a heap, 
+     which means that allocations have no impact on the final size.  */
+  new_bss_addr = old_bss_addr + old_bss_size;
+  bss_sbrk_did_unexec = 1;
+#else
   new_break = sbrk (0);
   new_bss_addr = (ElfW (Addr)) new_break;
+#endif
   bss_size_growth = new_bss_addr - old_bss_addr;
   new_data2_size = bss_size_growth;
   new_data2_size += alignof (ElfW (Shdr)) - 1;

  reply	other threads:[~2017-10-24  1:52 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 [this message]
2017-10-24 20:14       ` Paul Eggert
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=1508809949.3465.3.camel@blackberry.com \
    --to=elahav@blackberry.com \
    --cc=Emacs-devel@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).