~alpine/aports

main/erlang: Enabling hipe v1 PROPOSED

Marlus Saraiva: 1
 main/erlang: Enabling hipe

 5 files changed, 34 insertions(+), 1158 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.alpinelinux.org/~alpine/aports/patches/1347/mbox | git am -3
Learn more about email & git

[alpine-aports] [PATCH] main/erlang: Enabling hipe Export this patch

---
 .../0006-Do-not-install-erlang-sources.patch       | 224 ------
 main/erlang/0040-otp-update-version-18.0.1.patch   |  86 ---
 main/erlang/0050-otp-update-version-18.0.2.patch   | 839 ---------------------
 main/erlang/0070-hipe_x86_signal-fix.patch         |  21 +
 main/erlang/APKBUILD                               |  22 +-
 5 files changed, 34 insertions(+), 1158 deletions(-)
 delete mode 100644 main/erlang/0040-otp-update-version-18.0.1.patch
 delete mode 100644 main/erlang/0050-otp-update-version-18.0.2.patch
 create mode 100644 main/erlang/0070-hipe_x86_signal-fix.patch

diff --git a/main/erlang/0006-Do-not-install-erlang-sources.patch b/main/erlang/0006-Do-not-install-erlang-sources.patch
index 9b7f421..a79dbba 100644
--- a/main/erlang/0006-Do-not-install-erlang-sources.patch
+++ b/main/erlang/0006-Do-not-install-erlang-sources.patch
@@ -744,230 +744,6 @@
 	$(INSTALL_DIR) "$(RELSYSDIR)/ebin"
 	$(INSTALL_DATA) $(BEHAVIOUR_TARGET_FILES) $(TARGET_FILES) $(APP_TARGET) \
 	$(APPUP_TARGET) "$(RELSYSDIR)/ebin"
--- /dev/null
+++ otp_src_18.1-fixed/lib/ssh/src/Makefile.orig
@@ -0,0 +1,221 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2004-2013. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# %CopyrightEnd%
+#
+
+#
+include $(ERL_TOP)/make/target.mk
+include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+# ----------------------------------------------------
+# Application version
+# ----------------------------------------------------
+include ../vsn.mk
+VSN=$(SSH_VSN)
+
+# ----------------------------------------------------
+# Release directory specification
+# ----------------------------------------------------
+RELSYSDIR = $(RELEASE_PATH)/lib/ssh-$(VSN)
+
+# ----------------------------------------------------
+# Common Macros
+# ----------------------------------------------------
+
+# Behaviour (api) modules are first so they are compiled when
+# the compiler reaches a callback module using them.
+BEHAVIOUR_MODULES= \
+	ssh_sftpd_file_api \
+        ssh_channel \
+	ssh_daemon_channel \
+	ssh_client_key_api \
+	ssh_server_key_api
+
+MODULES= \
+	ssh \
+	ssh_sup \
+	sshc_sup \
+	sshd_sup \
+	ssh_connection_sup \
+	ssh_connection \
+	ssh_connection_handler \
+	ssh_shell \
+	ssh_system_sup \
+	ssh_subsystem_sup \
+	ssh_channel_sup \
+	ssh_acceptor_sup \
+	ssh_acceptor \
+	ssh_app \
+	ssh_auth\
+	ssh_bits \
+	ssh_cli \
+	ssh_file \
+	ssh_io \
+	ssh_info \
+	ssh_message \
+	ssh_no_io \
+	ssh_sftp \
+	ssh_sftpd \
+	ssh_sftpd_file\
+	ssh_transport \
+	ssh_xfer
+
+HRL_FILES =
+
+ERL_FILES= \
+	$(MODULES:%=%.erl) \
+	$(BEHAVIOUR_MODULES:%=%.erl)
+
+
+TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR))
+
+BEHAVIOUR_TARGET_FILES= $(BEHAVIOUR_MODULES:%=$(EBIN)/%.$(EMULATOR))
+
+APP_FILE= ssh.app
+APPUP_FILE= ssh.appup
+
+APP_SRC= $(APP_FILE).src
+APP_TARGET= $(EBIN)/$(APP_FILE)
+
+APPUP_SRC= $(APPUP_FILE).src
+APPUP_TARGET= $(EBIN)/$(APPUP_FILE)
+
+INTERNAL_HRL_FILES = ssh_auth.hrl ssh_connect.hrl ssh_transport.hrl ssh.hrl ssh_userauth.hrl ssh_xfer.hrl
+
+# ----------------------------------------------------
+# FLAGS
+# ----------------------------------------------------
+EXTRA_ERLC_FLAGS = +warn_unused_vars
+ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/kernel/src \
+	-pz $(EBIN) \
+	-pz $(ERL_TOP)/lib/public_key/ebin \
+	$(EXTRA_ERLC_FLAGS)
+
+
+# ----------------------------------------------------
+# Targets
+# ----------------------------------------------------
+
+$(TARGET_FILES): $(BEHAVIOUR_TARGET_FILES)
+
+debug opt: $(TARGET_FILES) $(APP_TARGET) $(APPUP_TARGET)
+
+clean:
+	rm -f $(TARGET_FILES) $(APP_TARGET) $(APPUP_TARGET) $(BEHAVIOUR_TARGET_FILES)
+	rm -f errs core *~
+
+$(APP_TARGET):	$(APP_SRC) ../vsn.mk
+	$(vsn_verbose)sed -e 's;%VSN%;$(VSN);' $< > $@
+
+$(APPUP_TARGET):	$(APPUP_SRC) ../vsn.mk
+	$(vsn_verbose)sed -e 's;%VSN%;$(VSN);' $< > $@
+
+
+docs:
+
+# ----------------------------------------------------
+# Release Target
+# ---------------------------------------------------- 
+include $(ERL_TOP)/make/otp_release_targets.mk
+
+release_spec: opt
+	$(INSTALL_DIR) "$(RELSYSDIR)/src"
+	$(INSTALL_DATA) $(INTERNAL_HRL_FILES) $(ERL_FILES) "$(RELSYSDIR)/src"
+	$(INSTALL_DIR) "$(RELSYSDIR)/ebin"
+	$(INSTALL_DATA) $(BEHAVIOUR_TARGET_FILES) $(TARGET_FILES) $(APP_TARGET) \
+	$(APPUP_TARGET) "$(RELSYSDIR)/ebin"
+	$(INSTALL_DIR) "$(RELSYSDIR)/include"
+
+
+release_docs_spec:
+
+
+deps:
+	erlc -M $(ERL_FILES) \
+	| sed 's@$(ERL_TOP)/lib@../..@g' \
+	| sed 's/\.$(EMULATOR)/\.$$\(EMULATOR\)/' \
+	| sed 's@^ssh_@$$(EBIN)/ssh_@'
+
+ssh.$(EMULATOR): ssh.erl ssh.hrl ssh_connect.hrl \
+  ../../public_key/include/public_key.hrl \
+  ../../public_key/include/OTP-PUB-KEY.hrl \
+  ../../public_key/include/PKCS-FRAME.hrl \
+  ../../kernel/include/file.hrl
+$(EBIN)/ssh_sup.$(EMULATOR): ssh_sup.erl
+sshc_sup.$(EMULATOR): sshc_sup.erl
+sshd_sup.$(EMULATOR): sshd_sup.erl ssh.hrl
+$(EBIN)/ssh_connection_sup.$(EMULATOR): ssh_connection_sup.erl
+$(EBIN)/ssh_connection.$(EMULATOR): ssh_connection.erl ssh.hrl ssh_connect.hrl \
+  ssh_transport.hrl
+$(EBIN)/ssh_connection_handler.$(EMULATOR): ssh_connection_handler.erl ssh.hrl \
+  ssh_transport.hrl ssh_auth.hrl ssh_connect.hrl
+$(EBIN)/ssh_shell.$(EMULATOR): ssh_shell.erl ssh_connect.hrl
+$(EBIN)/ssh_system_sup.$(EMULATOR): ssh_system_sup.erl ssh.hrl
+$(EBIN)/ssh_subsystem_sup.$(EMULATOR): ssh_subsystem_sup.erl
+$(EBIN)/ssh_channel_sup.$(EMULATOR): ssh_channel_sup.erl
+$(EBIN)/ssh_acceptor_sup.$(EMULATOR): ssh_acceptor_sup.erl ssh.hrl
+$(EBIN)/ssh_acceptor.$(EMULATOR): ssh_acceptor.erl ssh.hrl
+$(EBIN)/ssh_app.$(EMULATOR): ssh_app.erl
+$(EBIN)/ssh_auth.$(EMULATOR): ssh_auth.erl \
+  ../../public_key/include/public_key.hrl \
+  ../../public_key/include/OTP-PUB-KEY.hrl \
+  ../../public_key/include/PKCS-FRAME.hrl \
+  ssh.hrl ssh_auth.hrl ssh_transport.hrl
+$(EBIN)/ssh_bits.$(EMULATOR): ssh_bits.erl ssh.hrl
+$(EBIN)/ssh_cli.$(EMULATOR): ssh_cli.erl ssh.hrl ssh_connect.hrl
+$(EBIN)/ssh_file.$(EMULATOR): ssh_file.erl \
+  ../../public_key/include/public_key.hrl \
+  ../../public_key/include/OTP-PUB-KEY.hrl \
+  ../../public_key/include/PKCS-FRAME.hrl \
+  ../../kernel/include/file.hrl ssh.hrl
+$(EBIN)/ssh_io.$(EMULATOR): ssh_io.erl ssh.hrl
+$(EBIN)/ssh_info.$(EMULATOR): ssh_info.erl
+$(EBIN)/ssh_message.$(EMULATOR): ssh_message.erl \
+  ../../public_key/include/public_key.hrl \
+  ../../public_key/include/OTP-PUB-KEY.hrl \
+  ../../public_key/include/PKCS-FRAME.hrl \
+  ssh.hrl ssh_connect.hrl ssh_auth.hrl ssh_transport.hrl
+$(EBIN)/ssh_no_io.$(EMULATOR): ssh_no_io.erl ssh_transport.hrl
+$(EBIN)/ssh_sftp.$(EMULATOR): ssh_sftp.erl \
+  ../../kernel/include/file.hrl ssh.hrl \
+  ssh_xfer.hrl
+$(EBIN)/ssh_sftpd.$(EMULATOR): ssh_sftpd.erl \
+  ../../kernel/include/file.hrl ssh.hrl \
+  ssh_xfer.hrl
+$(EBIN)/ssh_sftpd_file.$(EMULATOR): ssh_sftpd_file.erl
+$(EBIN)/ssh_transport.$(EMULATOR): ssh_transport.erl \
+  ../../public_key/include/public_key.hrl \
+  ../../public_key/include/OTP-PUB-KEY.hrl \
+  ../../public_key/include/PKCS-FRAME.hrl \
+  ../../kernel/include/inet.hrl \
+  ssh_transport.hrl ssh.hrl
+$(EBIN)/ssh_xfer.$(EMULATOR): ssh_xfer.erl ssh.hrl ssh_xfer.hrl
+$(EBIN)/ssh_sftpd_file_api.$(EMULATOR): ssh_sftpd_file_api.erl
+$(EBIN)/ssh_channel.$(EMULATOR): ssh_channel.erl ssh_connect.hrl
+$(EBIN)/ssh_daemon_channel.$(EMULATOR): ssh_daemon_channel.erl
+$(EBIN)/ssh_client_key_api.$(EMULATOR): ssh_client_key_api.erl \
+  ../../public_key/include/public_key.hrl \
+  ../../public_key/include/OTP-PUB-KEY.hrl \
+  ../../public_key/include/PKCS-FRAME.hrl \
+  ssh.hrl
+$(EBIN)/ssh_server_key_api.$(EMULATOR): ssh_server_key_api.erl \
+  ../../public_key/include/public_key.hrl \
+  ../../public_key/include/OTP-PUB-KEY.hrl \
+  ../../public_key/include/PKCS-FRAME.hrl \
+  ssh.hrl
+
--- otp_src_18.1-orig/lib/ssl/src/Makefile
+++ otp_src_18.1-fixed/lib/ssl/src/Makefile
@@ -141,7 +141,7 @@
diff --git a/main/erlang/0040-otp-update-version-18.0.1.patch b/main/erlang/0040-otp-update-version-18.0.1.patch
deleted file mode 100644
index b35daab..0000000
--- a/main/erlang/0040-otp-update-version-18.0.1.patch
@@ -1,86 +0,0 @@
--- a/OTP_VERSION
+++ b/OTP_VERSION
@@ -1 +1 @@
-18.0
+18.0.1
--- a/erts/doc/src/notes.xml
+++ b/erts/doc/src/notes.xml
@@ -31,6 +31,22 @@
   </header>
   <p>This document describes the changes made to the ERTS application.</p>
 
+<section><title>Erts 7.0.1</title>
+
+    <section><title>Fixed Bugs and Malfunctions</title>
+      <list>
+        <item>
+          <p>
+	    Fix a rare hanging of the VM seen to happen just after
+	    emulator start. Bug exists since R14.</p>
+          <p>
+	    Own Id: OTP-12859 Aux Id: seq12882 </p>
+        </item>
+      </list>
+    </section>
+
+</section>
+
 <section><title>Erts 7.0</title>
 
     <section><title>Fixed Bugs and Malfunctions</title>
--- a/erts/emulator/sys/common/erl_poll.c
+++ b/erts/emulator/sys/common/erl_poll.c
@@ -431,7 +431,7 @@ static ERTS_INLINE int
 is_interrupted_reset(ErtsPollSet ps)
 {
 #if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
-    return (erts_atomic32_xchg_nob(&ps->wakeup_state, ERTS_POLL_NOT_WOKEN)
+    return (erts_atomic32_xchg_acqb(&ps->wakeup_state, ERTS_POLL_NOT_WOKEN)
 	    == ERTS_POLL_WOKEN_INTR);
 #else
     return 0;
@@ -442,7 +442,7 @@ static ERTS_INLINE void
 woke_up(ErtsPollSet ps)
 {
 #if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
-    erts_aint32_t wakeup_state = erts_atomic32_read_nob(&ps->wakeup_state);
+    erts_aint32_t wakeup_state = erts_atomic32_read_acqb(&ps->wakeup_state);
     if (wakeup_state == ERTS_POLL_NOT_WOKEN)
 	(void) erts_atomic32_cmpxchg_nob(&ps->wakeup_state,
 					 ERTS_POLL_WOKEN,
@@ -469,14 +469,9 @@ wake_poller(ErtsPollSet ps, int interrupted, int async_signal_safe)
 	    wakeup_state = erts_atomic32_cmpxchg_relb(&ps->wakeup_state,
 						      ERTS_POLL_WOKEN,
 						      ERTS_POLL_NOT_WOKEN);
-	else {
-	    /*
-	     * We might unnecessarily write to the pipe, however,
-	     * that isn't problematic.
-	     */
-	    wakeup_state = erts_atomic32_read_nob(&ps->wakeup_state);
-	    erts_atomic32_set_relb(&ps->wakeup_state, ERTS_POLL_WOKEN_INTR);
-	}
+	else
+            wakeup_state = erts_atomic32_xchg_relb(&ps->wakeup_state,
+                                                   ERTS_POLL_WOKEN_INTR);
 	wake = wakeup_state == ERTS_POLL_NOT_WOKEN;
     }
     /*
--- a/erts/vsn.mk
+++ b/erts/vsn.mk
@@ -18,7 +18,7 @@
 # %CopyrightEnd%
 # 
 
-VSN = 7.0
+VSN = 7.0.1
 
 # Port number 4365 in 4.2
 # Port number 4366 in 4.3
--- a/otp_versions.table
+++ b/otp_versions.table
@@ -1,3 +1,4 @@
+OTP-18.0.1 : erts-7.0.1 # asn1-4.0 common_test-1.11 compiler-6.0 cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosNotification-1.2 cosProperty-1.2 cosTime-1.2 cosTransactions-1.3 crypto-3.6 debugger-4.1 dialyzer-2.8 diameter-1.10 edoc-0.7.17 eldap-1.2 erl_docgen-0.4 erl_interface-3.8 et-1.5.1 eunit-2.2.10 gs-1.6 hipe-3.12 ic-4.4 inets-6.0 jinterface-1.6 kernel-4.0 megaco-3.18 mnesia-4.13 observer-2.1 odbc-2.11 orber-3.8 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1 percept-0.8.11 public_key-1.0 reltool-0.7 runtime_tools-1.9 sasl-2.5 snmp-5.2 ssh-4.0 ssl-7.0 stdlib-2.5 syntax_tools-1.7 test_server-3.9 tools-2.8 typer-0.9.9 webtool-0.9 wx-1.4 xmerl-1.3.8 :
 OTP-18.0 : asn1-4.0 common_test-1.11 compiler-6.0 cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosNotification-1.2 cosProperty-1.2 cosTime-1.2 cosTransactions-1.3 crypto-3.6 debugger-4.1 dialyzer-2.8 diameter-1.10 edoc-0.7.17 eldap-1.2 erl_docgen-0.4 erl_interface-3.8 erts-7.0 et-1.5.1 eunit-2.2.10 gs-1.6 hipe-3.12 ic-4.4 inets-6.0 jinterface-1.6 kernel-4.0 megaco-3.18 mnesia-4.13 observer-2.1 odbc-2.11 orber-3.8 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1 percept-0.8.11 public_key-1.0 reltool-0.7 runtime_tools-1.9 sasl-2.5 snmp-5.2 ssh-4.0 ssl-7.0 stdlib-2.5 syntax_tools-1.7 test_server-3.9 tools-2.8 typer-0.9.9 webtool-0.9 wx-1.4 xmerl-1.3.8 # :
 OTP-17.5.6 : inets-5.10.9 ssh-3.2.4 ssl-6.0.1 # asn1-3.0.4 common_test-1.10.1 compiler-5.0.4 cosEvent-2.1.15 cosEventDomain-1.1.14 cosFileTransfer-1.1.16 cosNotification-1.1.21 cosProperty-1.1.17 cosTime-1.1.14 cosTransactions-1.2.14 crypto-3.5 debugger-4.0.3 dialyzer-2.7.4 diameter-1.9.2 edoc-0.7.16 eldap-1.1.1 erl_docgen-0.3.7 erl_interface-3.7.20 erts-6.4.1 et-1.5 eunit-2.2.9 gs-1.5.16 hipe-3.11.3 ic-4.3.6 jinterface-1.5.12 kernel-3.2 megaco-3.17.3 mnesia-4.12.5 observer-2.0.4 odbc-2.10.22 orber-3.7.1 os_mon-2.3.1 ose-1.0.2 otp_mibs-1.0.10 parsetools-2.0.12 percept-0.8.10 public_key-0.23 reltool-0.6.6 runtime_tools-1.8.16 sasl-2.4.1 snmp-5.1.2 stdlib-2.4 syntax_tools-1.6.18 test_server-3.8.1 tools-2.7.2 typer-0.9.8 webtool-0.8.10 wx-1.3.3 xmerl-1.3.7 :
 OTP-17.5.5 : diameter-1.9.2 # asn1-3.0.4 common_test-1.10.1 compiler-5.0.4 cosEvent-2.1.15 cosEventDomain-1.1.14 cosFileTransfer-1.1.16 cosNotification-1.1.21 cosProperty-1.1.17 cosTime-1.1.14 cosTransactions-1.2.14 crypto-3.5 debugger-4.0.3 dialyzer-2.7.4 edoc-0.7.16 eldap-1.1.1 erl_docgen-0.3.7 erl_interface-3.7.20 erts-6.4.1 et-1.5 eunit-2.2.9 gs-1.5.16 hipe-3.11.3 ic-4.3.6 inets-5.10.8 jinterface-1.5.12 kernel-3.2 megaco-3.17.3 mnesia-4.12.5 observer-2.0.4 odbc-2.10.22 orber-3.7.1 os_mon-2.3.1 ose-1.0.2 otp_mibs-1.0.10 parsetools-2.0.12 percept-0.8.10 public_key-0.23 reltool-0.6.6 runtime_tools-1.8.16 sasl-2.4.1 snmp-5.1.2 ssh-3.2.3 ssl-6.0 stdlib-2.4 syntax_tools-1.6.18 test_server-3.8.1 tools-2.7.2 typer-0.9.8 webtool-0.8.10 wx-1.3.3 xmerl-1.3.7 :
diff --git a/main/erlang/0050-otp-update-version-18.0.2.patch b/main/erlang/0050-otp-update-version-18.0.2.patch
deleted file mode 100644
index ccae0a6..0000000
--- a/main/erlang/0050-otp-update-version-18.0.2.patch
@@ -1,839 +0,0 @@
--- a/HOWTO/INSTALL.md
+++ b/HOWTO/INSTALL.md
@@ -400,6 +400,12 @@ Some of the available `configure` options are:
 	no automatic dependency handling between applications. If you disable
 	an application that another application depends on, you also have to disable the
 	dependant application.
+*   `--enable-gettimeofday-as-os-system-time` - Force usage of `gettimeofday()` for
+    OS system time.
+*   `--enable-prefer-elapsed-monotonic-time-during-suspend` - Prefer an OS monotonic
+    time source with elapsed time during suspend.
+*   `--disable-prefer-elapsed-monotonic-time-during-suspend` - Do not prefer an OS
+    monotonic time source with elapsed time during suspend.
 *   `--enable-dirty-schedulers` - Enable the **experimental** dirty schedulers
     functionality. Note that the dirty schedulers functionality is experimental,
     and **not supported**. This functionality **will** be subject to backward
--- a/OTP_VERSION
+++ b/OTP_VERSION
@@ -1 +1 @@
-18.0.1
+18.0.2
--- a/erts/aclocal.m4
+++ b/erts/aclocal.m4
@@ -726,9 +726,15 @@ esac
 
 AC_DEFUN(ERL_MONOTONIC_CLOCK,
 [
-  default_resolution_clock_gettime_monotonic="CLOCK_HIGHRES CLOCK_BOOTTIME CLOCK_MONOTONIC"
-  low_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST"
-  high_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_PRECISE"
+  if test "$3" = "yes"; then
+     default_resolution_clock_gettime_monotonic="CLOCK_HIGHRES CLOCK_BOOTTIME CLOCK_MONOTONIC"
+     low_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST"
+     high_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_PRECISE"
+  else
+     default_resolution_clock_gettime_monotonic="CLOCK_HIGHRES CLOCK_UPTIME CLOCK_MONOTONIC"
+     low_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_COARSE CLOCK_UPTIME_FAST"
+     high_resolution_clock_gettime_monotonic="CLOCK_UPTIME_PRECISE"
+  fi
 
   case "$1" in
     high_resolution)
@@ -1466,7 +1472,7 @@ AC_ARG_WITH(with_sparc_memory_order,
 LM_CHECK_THR_LIB
 ERL_INTERNAL_LIBS
 
-ERL_MONOTONIC_CLOCK(high_resolution)
+ERL_MONOTONIC_CLOCK(high_resolution, undefined, no)
 
 case $erl_monotonic_clock_func in
   clock_gettime)
@@ -2202,7 +2208,7 @@ AC_DEFUN(ERL_TIME_CORRECTION,
 
 AC_ARG_WITH(clock-resolution,
 AS_HELP_STRING([--with-clock-resolution=high|low|default],
-               [specify wanted clock resolution)]))
+               [specify wanted clock resolution]))
 
 AC_ARG_WITH(clock-gettime-realtime-id,
 AS_HELP_STRING([--with-clock-gettime-realtime-id=CLOCKID],
@@ -2212,6 +2218,24 @@ AC_ARG_WITH(clock-gettime-monotonic-id,
 AS_HELP_STRING([--with-clock-gettime-monotonic-id=CLOCKID],
                [specify clock id to use with clock_gettime() for monotonic time)]))
 
+AC_ARG_ENABLE(prefer-elapsed-monotonic-time-during-suspend,
+	      AS_HELP_STRING([--enable-prefer-elapsed-monotonic-time-during-suspend],
+                             [Prefer an OS monotonic time source with elapsed time during suspend])
+	      AS_HELP_STRING([--disable-prefer-elapsed-monotonic-time-during-suspend],
+                             [Do not prefer an OS monotonic time source with elapsed time during suspend]),
+[ case "$enableval" in
+    yes) prefer_elapsed_monotonic_time_during_suspend=yes ;;
+    *)  prefer_elapsed_monotonic_time_during_suspend=no ;;
+  esac ], prefer_elapsed_monotonic_time_during_suspend=no)
+
+AC_ARG_ENABLE(gettimeofday-as-os-system-time,
+	      AS_HELP_STRING([--enable-gettimeofday-as-os-system-time],
+                             [Force usage of gettimeofday() for OS system time]),
+[ case "$enableval" in
+    yes) force_gettimeofday_os_system_time=yes ;;
+    *)  force_gettimeofday_os_system_time=no ;;
+  esac ], force_gettimeofday_os_system_time=no)
+
 case "$with_clock_resolution" in
    ""|no|yes)
      with_clock_resolution=default;;
@@ -2222,6 +2246,17 @@ case "$with_clock_resolution" in
      ;;
 esac
 
+if test "$force_gettimeofday_os_system_time" = "yes"; then
+
+  AC_CHECK_FUNCS([gettimeofday])
+  if test "$ac_cv_func_gettimeofday" = "yes"; then
+    AC_DEFINE(OS_SYSTEM_TIME_GETTIMEOFDAY,  [1], [Define if you want to implement erts_os_system_time() using gettimeofday()])
+  else
+    AC_MSG_ERROR([No gettimeofday() available])
+  fi
+
+else # $force_gettimeofday_os_system_time != yes
+
 case "$with_clock_gettime_realtime_id" in
    ""|no)
      with_clock_gettime_realtime_id=no
@@ -2239,23 +2274,6 @@ case "$with_clock_gettime_realtime_id" in
      ;;
 esac
 
-case "$with_clock_gettime_monotonic_id" in
-   ""|no)
-     with_clock_gettime_monotonic_id=no
-     ;;
-   CLOCK_*CPUTIME*)
-     AC_MSG_ERROR([Invalid clock_gettime() monotonic clock id: Refusing to use the cputime clock id $with_clock_gettime_monotonic_id as monotonic clock id])
-     ;;
-   CLOCK_REALTIME*|CLOCK_TAI*)
-     AC_MSG_ERROR([Invalid clock_gettime() monotonic clock id: Refusing to use the realtime clock id $with_clock_gettime_monotonic_id as monotonic clock id])
-     ;;
-   CLOCK_*)
-     ;;
-   *)
-     AC_MSG_ERROR([Invalid clock_gettime() clock id: $with_clock_gettime_monotonic_id])
-     ;;
-esac
--
 case "$with_clock_resolution-$with_clock_gettime_realtime_id" in
   high-no)
 	ERL_WALL_CLOCK(high_resolution);;
@@ -2296,15 +2314,34 @@ if test "x$erl_wall_clock_id" != "x"; then
     AC_DEFINE_UNQUOTED(WALL_CLOCK_ID, [$erl_wall_clock_id], [Define to wall clock id to use])
 fi
 
+fi # $force_gettimeofday_os_system_time != yes
+
+case "$with_clock_gettime_monotonic_id" in
+   ""|no)
+     with_clock_gettime_monotonic_id=no
+     ;;
+   CLOCK_*CPUTIME*)
+     AC_MSG_ERROR([Invalid clock_gettime() monotonic clock id: Refusing to use the cputime clock id $with_clock_gettime_monotonic_id as monotonic clock id])
+     ;;
+   CLOCK_REALTIME*|CLOCK_TAI*)
+     AC_MSG_ERROR([Invalid clock_gettime() monotonic clock id: Refusing to use the realtime clock id $with_clock_gettime_monotonic_id as monotonic clock id])
+     ;;
+   CLOCK_*)
+     ;;
+   *)
+     AC_MSG_ERROR([Invalid clock_gettime() clock id: $with_clock_gettime_monotonic_id])
+     ;;
+esac
+
 case "$with_clock_resolution-$with_clock_gettime_monotonic_id" in
   high-no)
-	ERL_MONOTONIC_CLOCK(high_resolution);;
+	ERL_MONOTONIC_CLOCK(high_resolution, undefined, $prefer_elapsed_monotonic_time_during_suspend);;
   low-no)
-	ERL_MONOTONIC_CLOCK(low_resolution);;
+	ERL_MONOTONIC_CLOCK(low_resolution, undefined, $prefer_elapsed_monotonic_time_during_suspend);;
   default-no)
-	ERL_MONOTONIC_CLOCK(default_resolution);;
+	ERL_MONOTONIC_CLOCK(default_resolution, undefined, $prefer_elapsed_monotonic_time_during_suspend);;
   *)
-	ERL_MONOTONIC_CLOCK(custom_resolution, $with_clock_gettime_monotonic_id);;
+	ERL_MONOTONIC_CLOCK(custom_resolution, $with_clock_gettime_monotonic_id, $prefer_elapsed_monotonic_time_during_suspend);;
 esac
 
 case "$erl_monotonic_clock_func-$erl_monotonic_clock_id-$with_clock_gettime_monotonic_id" in
@@ -2352,7 +2389,7 @@ if test $erl_cv_clock_gettime_monotonic_raw = yes; then
   AC_DEFINE(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, [1], [Define if you have clock_gettime(CLOCK_MONOTONIC_RAW, _)])
 fi
 
-ERL_MONOTONIC_CLOCK(high_resolution)
+ERL_MONOTONIC_CLOCK(high_resolution, undefined, no)
 
 case $$erl_monotonic_clock_low_resolution-$erl_monotonic_clock_func in
   no-mach_clock_get_time)
--- a/erts/doc/src/notes.xml
+++ b/erts/doc/src/notes.xml
@@ -31,6 +31,82 @@
   </header>
   <p>This document describes the changes made to the ERTS application.</p>
 
+<section><title>Erts 7.0.2</title>
+
+    <section><title>Fixed Bugs and Malfunctions</title>
+      <list>
+        <item>
+          <p>
+	    A process could end up in an inconsistent half exited
+	    state in the runtime system without SMP support. This
+	    could occur if the processes was traced by a port that it
+	    also was linked to, and the port terminated abnormally
+	    while handling a trace message for the process.</p>
+          <p>
+	    This bug has always existed in the runtime system without
+	    SMP support, but never in the runtime system with SMP
+	    support.</p>
+          <p>
+	    Own Id: OTP-12889 Aux Id: seq12885 </p>
+        </item>
+        <item>
+          <p>
+	    Removed unnecessary copying of data when retrieving
+	    corrected Erlang monotonic time.</p>
+          <p>
+	    Own Id: OTP-12894</p>
+        </item>
+        <item>
+          <p>
+	    Changed default OS monotonic clock source chosen at build
+	    time. This in order to improve performance. The behavior
+	    will now on most systems be that (both OS and Erlang)
+	    monotonic time stops when the system is suspended.</p>
+          <p>
+	    If you prefer that monotonic time elapse during suspend
+	    of the machine, you can pass the command line argument
+	    <c>--enable-prefer-elapsed-monotonic-time-during-suspend</c>
+	    to <c>configure</c> when building Erlang/OTP. The
+	    configuration stage will try to find such a clock source,
+	    but might not be able to find it. Note that there might
+	    be a performance penalty associated with such a clock
+	    source.</p>
+          <p>
+	    *** POTENTIAL INCOMPATIBILITY ***</p>
+          <p>
+	    Own Id: OTP-12895</p>
+        </item>
+        <item>
+          <p>
+	    <c>erlang:system_info(end_time)</c> returned a faulty
+	    value on 32-bit architectures.</p>
+          <p>
+	    Own Id: OTP-12896</p>
+        </item>
+      </list>
+    </section>
+
+
+    <section><title>Improvements and New Features</title>
+      <list>
+        <item>
+          <p>
+	    The <c>configure</c> command line argument
+	    <c>--enable-gettimeofday-as-os-system-time</c> has been
+	    added which force usage of <c>gettimeofday()</c> for OS
+	    system time. This will improve performance of
+	    <c>os:system_time()</c> and <c>os:timestamp()</c> on
+	    MacOS X, at the expense of worse accuracy, resolution and
+	    precision of Erlang monotonic time, Erlang system time,
+	    and OS system time.</p>
+          <p>
+	    Own Id: OTP-12892</p>
+        </item>
+      </list>
+    </section>
+
+</section>
+
 <section><title>Erts 7.0.1</title>
 
     <section><title>Fixed Bugs and Malfunctions</title>
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -2163,6 +2163,22 @@ void process_main(void)
 	 OpCase(wait_f):
 
 	 wait2: {
+#ifndef ERTS_SMP
+	     if (ERTS_PROC_IS_EXITING(c_p)) {
+		 /*
+		  * I non smp case:
+		  *
+		  * Currently executing process might be sent an exit
+		  * signal if it is traced by a port that it also is
+		  * linked to, and the port terminates during the
+		  * trace. In this case we do *not* want to clear
+		  * the active flag, which will make the process hang
+		  * in limbo forever.
+		  */
+		 SWAPOUT;
+		 goto do_schedule;
+	     }
+#endif
 	     c_p->i = (BeamInstr *) Arg(0); /* L1 */
 	     SWAPOUT;
 	     c_p->arity = 0;
@@ -6219,6 +6235,23 @@ erts_hibernate(Process* c_p, Eterm module, Eterm function, Eterm args, Eterm* re
     int arity;
     Eterm tmp;
 
+#ifndef ERTS_SMP
+    if (ERTS_PROC_IS_EXITING(c_p)) {
+	/*
+	 * I non smp case:
+	 *
+	 * Currently executing process might be sent an exit
+	 * signal if it is traced by a port that it also is
+	 * linked to, and the port terminates during the
+	 * trace. In this case we do *not* want to clear
+	 * the active flag, which will make the process hang
+	 * in limbo forever. Get out of here and terminate
+	 * the process...
+	 */
+	return -1;
+    }
+#endif
+
     if (is_not_atom(module) || is_not_atom(function)) {
 	/*
 	 * No need to test args here -- done below.
@@ -6295,7 +6328,16 @@ erts_hibernate(Process* c_p, Eterm module, Eterm function, Eterm args, Eterm* re
 	ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p);
 	PROCESS_MAIN_CHK_LOCKS(c_p);
 	erts_smp_proc_lock(c_p, ERTS_PROC_LOCK_MSGQ|ERTS_PROC_LOCK_STATUS);
-#ifdef ERTS_SMP
+#ifndef ERTS_SMP
+	if (ERTS_PROC_IS_EXITING(c_p)) {
+	    /*
+	     * See comment in the begining of the function...
+	     *
+	     * This second test is needed since gc might be traced.
+	     */
+	    return -1;
+	}
+#else /* ERTS_SMP */
 	ERTS_SMP_MSGQ_MV_INQ2PRIVQ(c_p);
 	if (!c_p->msg.len)
 #endif
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -11409,6 +11409,22 @@ set_proc_exiting(Process *p,
     KILL_CATCHES(p);
     p->i = (BeamInstr *) beam_exit;
 
+#ifndef ERTS_SMP
+    if (state & (ERTS_PSFLG_RUNNING|ERTS_PSFLG_RUNNING_SYS)) {
+	/*
+	 * I non smp case:
+	 *
+	 * Currently executing process might be sent an exit
+	 * signal if it is traced by a port that it also is
+	 * linked to, and the port terminates during the
+	 * trace. In this case we want schedule out the
+	 * process as quickly as possible in order to detect
+	 * the event as fast as possible.
+	 */
+	ERTS_VBUMP_ALL_REDS(p);
+    }
+#endif
+
     if (enqueue)
 	add2runq(enqueue > 0 ? p : make_proxy_proc(NULL, p, enq_prio),
 		 state,
--- a/erts/emulator/beam/erl_time.h
+++ b/erts/emulator/beam/erl_time.h
@@ -345,8 +345,10 @@ erts_time_unit_conversion(Uint64 value,
 #endif /* !ERTS_COMPILE_TIME_MONOTONIC_TIME_UNIT */
 
 #define ERTS_MONOTONIC_TIME_END_EXTERNAL				\
-    (ERTS_MONOTONIC_TIME_START_EXTERNAL					\
-     + (ERTS_MONOTONIC_END - ERTS_MONOTONIC_BEGIN))
+    (ERTS_MONOTONIC_TIME_START_EXTERNAL < 0				\
+     ? (ERTS_MONOTONIC_TIME_START_EXTERNAL				\
+	+ (ERTS_MONOTONIC_END - ERTS_MONOTONIC_BEGIN))			\
+     : (ERTS_MONOTONIC_END - ERTS_MONOTONIC_TIME_START_EXTERNAL))
 
 #define ERTS_MSEC_TO_CLKTCKS__(MON) \
     ((MON) * (ERTS_CLKTCK_RESOLUTION/1000))
--- a/erts/emulator/beam/erl_time_sup.c
+++ b/erts/emulator/beam/erl_time_sup.c
@@ -124,7 +124,11 @@ typedef struct {
 
 typedef struct {
     ErtsMonotonicCorrectionInstance prev;
-    ErtsMonotonicCorrectionInstance curr;    
+    ErtsMonotonicCorrectionInstance curr;
+} ErtsMonotonicCorrectionInstances;
+
+typedef struct {
+    ErtsMonotonicCorrectionInstances insts;
     ErtsMonotonicDriftData drift;
     ErtsMonotonicTime last_check;
     int short_check_interval;
@@ -272,27 +276,24 @@ static ERTS_INLINE ErtsMonotonicTime
 read_corrected_time(int os_drift_corrected)
 {
     ErtsMonotonicTime os_mtime;
-    ErtsMonotonicCorrectionData cdata;
-    ErtsMonotonicCorrectionInstance *cip;
+    ErtsMonotonicCorrectionInstance ci;
 
     erts_smp_rwmtx_rlock(&time_sup.inf.c.parmon.rwmtx);
 
     os_mtime = erts_os_monotonic_time();
 
-    cdata = time_sup.inf.c.parmon.cdata;
--
-    erts_smp_rwmtx_runlock(&time_sup.inf.c.parmon.rwmtx);
--
-    if (os_mtime >= cdata.curr.os_mtime)
-	cip = &cdata.curr;
+    if (os_mtime >= time_sup.inf.c.parmon.cdata.insts.curr.os_mtime)
+	ci = time_sup.inf.c.parmon.cdata.insts.curr;
     else {
-	if (os_mtime < cdata.prev.os_mtime)
+	if (os_mtime < time_sup.inf.c.parmon.cdata.insts.prev.os_mtime)
 	    erl_exit(ERTS_ABORT_EXIT,
 		     "OS monotonic time stepped backwards\n");
-	cip = &cdata.prev;
+	ci = time_sup.inf.c.parmon.cdata.insts.prev;
     }
 
-    return calc_corrected_erl_mtime(os_mtime, cip, NULL,
+    erts_smp_rwmtx_runlock(&time_sup.inf.c.parmon.rwmtx);
+
+    return calc_corrected_erl_mtime(os_mtime, &ci, NULL,
 				    os_drift_corrected);
 }
 
@@ -360,9 +361,8 @@ check_time_correction(void *vesdp)
 {
     int init_drift_adj = !vesdp;
     ErtsSchedulerData *esdp = (ErtsSchedulerData *) vesdp;
-    ErtsMonotonicCorrectionData cdata;
     ErtsMonotonicCorrection new_correction;
-    ErtsMonotonicCorrectionInstance *cip;
+    ErtsMonotonicCorrectionInstance ci;
     ErtsMonotonicTime mdiff, sdiff, os_mtime, erl_mtime, os_stime,
 	erl_stime, time_offset, timeout_pos;
     Uint timeout;
@@ -373,16 +373,15 @@ check_time_correction(void *vesdp)
 
     erts_os_times(&os_mtime, &os_stime);
 
-    cdata = time_sup.inf.c.parmon.cdata;
+    ci = time_sup.inf.c.parmon.cdata.insts.curr;
 
     erts_smp_rwmtx_runlock(&time_sup.inf.c.parmon.rwmtx);
 
-    if (os_mtime < cdata.curr.os_mtime)
+    if (os_mtime < ci.os_mtime)
 	erl_exit(ERTS_ABORT_EXIT,
 		 "OS monotonic time stepped backwards\n");
-    cip = &cdata.curr;
 
-    erl_mtime = calc_corrected_erl_mtime(os_mtime, cip, &mdiff,
+    erl_mtime = calc_corrected_erl_mtime(os_mtime, &ci, &mdiff,
 					 os_drift_corrected);
     time_offset = get_time_offset();
     erl_stime = erl_mtime + time_offset;
@@ -397,7 +396,7 @@ check_time_correction(void *vesdp)
 	    time_sup.inf.c.shadow_offset = 0;
     }
 
-    new_correction = cip->correction;
+    new_correction = ci.correction;
 
     if (time_sup.r.o.warp_mode == ERTS_MULTI_TIME_WARP_MODE
 	&& (sdiff < -2*time_sup.r.o.adj.small_diff
@@ -408,7 +407,7 @@ check_time_correction(void *vesdp)
 	set_time_offset(time_offset);
 	schedule_send_time_offset_changed_notifications(time_offset);
 	begin_short_intervals = 1;
-	if (cdata.curr.correction.error != 0) {
+	if (ci.correction.error != 0) {
 	    set_new_correction = 1;
 	    new_correction.error = 0;
 	}
@@ -425,12 +424,12 @@ check_time_correction(void *vesdp)
 	time_sup.inf.c.shadow_offset -= sdiff;
 	sdiff = 0;
 	begin_short_intervals = 1;
-	if (cdata.curr.correction.error != 0) {
+	if (ci.correction.error != 0) {
 	    set_new_correction = 1;
 	    new_correction.error = 0;
 	}
     }
-    else if (cdata.curr.correction.error == 0) {
+    else if (ci.correction.error == 0) {
 	if (sdiff < -time_sup.r.o.adj.small_diff) {
 	    set_new_correction = 1;
 	    if (sdiff < -time_sup.r.o.adj.large_diff)
@@ -446,9 +445,9 @@ check_time_correction(void *vesdp)
 		new_correction.error = -ERTS_TCORR_ERR_SMALL_ADJ;
 	}
     }
-    else if (cdata.curr.correction.error > 0) {
+    else if (ci.correction.error > 0) {
 	if (sdiff < 0) {
-	    if (cdata.curr.correction.error != ERTS_TCORR_ERR_LARGE_ADJ
+	    if (ci.correction.error != ERTS_TCORR_ERR_LARGE_ADJ
 		&& sdiff < -time_sup.r.o.adj.large_diff) {
 		new_correction.error = ERTS_TCORR_ERR_LARGE_ADJ;
 		set_new_correction = 1;
@@ -466,9 +465,9 @@ check_time_correction(void *vesdp)
 	    new_correction.error = 0;
 	}
     }
-    else /* if (cdata.curr.correction.error < 0) */ { 
+    else /* if (ci.correction.error < 0) */ { 
 	if (0 < sdiff) {
-	    if (cdata.curr.correction.error != -ERTS_TCORR_ERR_LARGE_ADJ
+	    if (ci.correction.error != -ERTS_TCORR_ERR_LARGE_ADJ
 		&& time_sup.r.o.adj.large_diff < sdiff) {
 		new_correction.error = -ERTS_TCORR_ERR_LARGE_ADJ;
 		set_new_correction = 1;
@@ -631,8 +630,8 @@ check_time_correction(void *vesdp)
 #ifdef ERTS_TIME_CORRECTION_PRINT
     print_correction(set_new_correction,
 		     sdiff,
-		     cip->correction.error,
-		     cip->correction.drift,
+		     ci.correction.error,
+		     ci.correction.drift,
 		     new_correction.error,
 		     new_correction.drift,
 		     timeout);
@@ -644,7 +643,7 @@ check_time_correction(void *vesdp)
 	os_mtime = erts_os_monotonic_time();
 
 	/* Save previous correction instance */
-	time_sup.inf.c.parmon.cdata.prev = *cip;
+	time_sup.inf.c.parmon.cdata.insts.prev = ci;
 
 	/*
 	 * Current correction instance begin when
@@ -657,15 +656,15 @@ check_time_correction(void *vesdp)
 	 * next OS monotonic time using previous
 	 * correction.
 	 */
-	erl_mtime = calc_corrected_erl_mtime(os_mtime, cip, NULL,
+	erl_mtime = calc_corrected_erl_mtime(os_mtime, &ci, NULL,
 					     os_drift_corrected);
 
 	/*
 	 * Save new current correction instance.
 	 */
-	time_sup.inf.c.parmon.cdata.curr.erl_mtime = erl_mtime;
-	time_sup.inf.c.parmon.cdata.curr.os_mtime = os_mtime;
-	time_sup.inf.c.parmon.cdata.curr.correction = new_correction;
+	time_sup.inf.c.parmon.cdata.insts.curr.erl_mtime = erl_mtime;
+	time_sup.inf.c.parmon.cdata.insts.curr.os_mtime = os_mtime;
+	time_sup.inf.c.parmon.cdata.insts.curr.correction = new_correction;
 
 	erts_smp_rwmtx_rwunlock(&time_sup.inf.c.parmon.rwmtx);
     }
@@ -784,24 +783,22 @@ static ErtsMonotonicTime
 finalize_corrected_time_offset(ErtsSystemTime *stimep)
 {
     ErtsMonotonicTime os_mtime;
-    ErtsMonotonicCorrectionData cdata;
-    ErtsMonotonicCorrectionInstance *cip;
+    ErtsMonotonicCorrectionInstance ci;
     int os_drift_corrected = time_sup.r.o.os_corrected_monotonic_time;
 
     erts_smp_rwmtx_rlock(&time_sup.inf.c.parmon.rwmtx);
 
     erts_os_times(&os_mtime, stimep);
 
-    cdata = time_sup.inf.c.parmon.cdata;
+    ci = time_sup.inf.c.parmon.cdata.insts.curr;
 
     erts_smp_rwmtx_runlock(&time_sup.inf.c.parmon.rwmtx);
 
-    if (os_mtime < cdata.curr.os_mtime)
+    if (os_mtime < ci.os_mtime)
 	erl_exit(ERTS_ABORT_EXIT,
 		 "OS monotonic time stepped backwards\n");
-    cip = &cdata.curr;
 
-    return calc_corrected_erl_mtime(os_mtime, cip, NULL,
+    return calc_corrected_erl_mtime(os_mtime, &ci, NULL,
 				    os_drift_corrected);
 }
 
@@ -1128,13 +1125,13 @@ erts_init_time_sup(int time_correction, ErtsTimeWarpMode time_warp_mode)
     
 	cdatap->drift.intervals[0].time.sys = time_sup.inf.c.sinit;
 	cdatap->drift.intervals[0].time.mon = time_sup.inf.c.minit;
-	cdatap->curr.correction.drift = 0;
-	cdatap->curr.correction.error = 0;
-	cdatap->curr.erl_mtime = ERTS_MONOTONIC_BEGIN;
-	cdatap->curr.os_mtime = time_sup.inf.c.minit;
+	cdatap->insts.curr.correction.drift = 0;
+	cdatap->insts.curr.correction.error = 0;
+	cdatap->insts.curr.erl_mtime = ERTS_MONOTONIC_BEGIN;
+	cdatap->insts.curr.os_mtime = time_sup.inf.c.minit;
 	cdatap->last_check = time_sup.inf.c.minit;
 	cdatap->short_check_interval = ERTS_INIT_SHORT_INTERVAL_COUNTER;
-	cdatap->prev = cdatap->curr;
+	cdatap->insts.prev = cdatap->insts.curr;
 
 	if (!time_sup.r.o.os_corrected_monotonic_time)
 	    time_sup.r.o.get_time = get_corrected_time;
--- a/erts/emulator/test/trace_port_SUITE.erl
+++ b/erts/emulator/test/trace_port_SUITE.erl
@@ -35,7 +35,8 @@
 	 fake_schedule_after_getting_linked/1,
 	 fake_schedule_after_getting_unlinked/1,
 	 gc/1,
-	 default_tracer/1]).
+	 default_tracer/1,
+	 tracer_port_crash/1]).
 
 -include_lib("test_server/include/test_server.hrl").
 
@@ -45,7 +46,7 @@ test_cases() ->
      fake_schedule_after_register,
      fake_schedule_after_getting_linked,
      fake_schedule_after_getting_unlinked, gc,
-     default_tracer].
+     default_tracer, tracer_port_crash].
 
 suite() -> [{ct_hooks,[ts_install_cth]}].
 
@@ -473,6 +474,42 @@ default_tracer(Config) when is_list(Config) ->
     ?line M = N,
     ok.
 
+tracer_port_crash(Config) when is_list(Config) ->
+    case test_server:is_native(?MODULE) orelse
+	test_server:is_native(lists) of
+	true -> 
+	    {skip,"Native code"};
+	false ->
+	    Tr = start_tracer(Config),
+	    Port = get(tracer_port),
+	    Tracee = spawn(fun () ->
+				   register(trace_port_linker, self()),
+				   link(Port),
+				   receive go -> ok end,
+				   lists:reverse([1,b,c]),
+				   receive die -> ok end
+			   end),
+	    Tr ! {unlink_tracer_port, self()},
+	    receive {unlinked_tracer_port, Tr} -> ok end,
+	    port_control(Port, $c, []), %% Make port commands crash tracer port...
+	    trace_func({lists,reverse,1}, []),
+	    trace_pid(Tracee, true, [call]),
+	    trace_info(Tracee, flags),
+	    trace_info(self(), tracer),
+	    Tracee ! go,
+	    receive after 1000 -> ok end,
+	    case whereis(trace_port_linker) of
+		undefined ->
+		    ok;
+		Id ->
+%		    erts_debug:set_internal_state(available_internal_state, true),
+%		    erts_debug:set_internal_state(abort, {trace_port_linker, Id})
+		    ?t:fail({trace_port_linker, Id})
+	    end,
+	    undefined = process_info(Tracee),
+	    ok
+    end.
+
 %%% Help functions.
 
 huge_data() -> huge_data(16384).
@@ -631,6 +668,10 @@ tracer_loop(RelayTo, Port) ->
 	{Port,{data,Msg}} ->
 	    RelayTo ! binary_to_term(Msg),
 	    tracer_loop(RelayTo, Port);
+	{unlink_tracer_port, From} ->
+	    unlink(Port),
+	    From ! {unlinked_tracer_port, self()},
+	    tracer_loop(RelayTo, Port);
 	Other ->
 	    exit({bad_message,Other})
     end.
--- a/erts/emulator/test/trace_port_SUITE_data/echo_drv.c
+++ b/erts/emulator/test/trace_port_SUITE_data/echo_drv.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include "erl_driver.h"
+#include <errno.h>
 
 
 
@@ -14,6 +15,7 @@ enum e_heavy {
 typedef struct _erl_drv_data {
     ErlDrvPort   erlang_port;
     enum e_heavy heavy;
+    int crash;
 } EchoDrvData;
 
 static EchoDrvData echo_drv_data, *echo_drv_data_p;
@@ -78,6 +80,7 @@ static EchoDrvData *echo_drv_start(ErlDrvPort port, char *command)
     echo_drv_data_p = &echo_drv_data;
     echo_drv_data_p->erlang_port = port;
     echo_drv_data_p->heavy = heavy_off;
+    echo_drv_data_p->crash = 0;
     return echo_drv_data_p;
 }
 
@@ -87,6 +90,12 @@ static void echo_drv_stop(EchoDrvData *data_p) {
 
 static void echo_drv_output(ErlDrvData drv_data, char *buf, ErlDrvSizeT len) {
     EchoDrvData* data_p = (EchoDrvData *) drv_data;
+
+    if (data_p->crash) {
+	driver_failure_posix(data_p->erlang_port, EINTR);
+	return;
+    }
+
     driver_output(data_p->erlang_port, buf, len);
     switch (data_p->heavy) {
     case heavy_off:
@@ -100,6 +109,7 @@ static void echo_drv_output(ErlDrvData drv_data, char *buf, ErlDrvSizeT len) {
 	data_p->heavy = heavy_off;
 	break;
     }
+
 }
 
 static void echo_drv_finish() {
@@ -115,6 +125,8 @@ static ErlDrvSSizeT echo_drv_control(ErlDrvData drv_data,
     case 'h':
 	data_p->heavy = heavy_set;
 	break;
+    case 'c':
+	data_p->crash = 1;
     }
     return 0;
 }
--- a/erts/vsn.mk
+++ b/erts/vsn.mk
@@ -18,7 +18,7 @@
 # %CopyrightEnd%
 # 
 
-VSN = 7.0.1
+VSN = 7.0.2
 
 # Port number 4365 in 4.2
 # Port number 4366 in 4.3
--- a/lib/runtime_tools/c_src/trace_file_drv.c
+++ b/lib/runtime_tools/c_src/trace_file_drv.c
@@ -327,9 +327,11 @@ static ErlDrvData trace_file_start(ErlDrvPort port, char *buff)
 		   | O_BINARY
 #endif
 		   , 0777)) < 0) {
+	int saved_errno = errno;
 	if (wrap)
 	    driver_free(wrap);
 	driver_free(data);
+	errno = saved_errno;
 	return ERL_DRV_ERROR_ERRNO;
     } 
 
@@ -525,14 +527,19 @@ static void *my_alloc(size_t size)
 ** A write wrapper that regards it as an error if not all data was written.
 */
 static int do_write(FILETYPE fd, unsigned char *buff, int siz) {
-    int w = write(fd, buff, siz);
-    if (w != siz) {
-	if (w >= 0) {
-	    errno = ENOSPC;
+    int w;
+    while (1) {
+	w = write(fd, buff, siz);
+	if (w < 0 && errno == EINTR)
+	    continue;
+	else if (w != siz) {
+	    if (w >= 0) {
+		errno = ENOSPC;
+	    }
+	    return -1;
 	}
-	return -1;
+	return siz;
     }
-    return siz;
 }
 
 /*
@@ -627,8 +634,10 @@ static void close_unlink_port(TraceFileData *data)
 */
 static int wrap_file(TraceFileData *data) {
     if (my_flush(data) < 0) {
+	int saved_errno = errno;
 	close(data->fd);
 	data->fd = -1;
+	errno = saved_errno;
 	return -1;
     }
     close(data->fd);
@@ -644,12 +653,15 @@ static int wrap_file(TraceFileData *data) {
 	next_name(&data->wrap->del);
     }
     next_name(&data->wrap->cur);
+try_open:
     data->fd = open(data->wrap->cur.name, O_WRONLY | O_TRUNC | O_CREAT
 #ifdef O_BINARY
 	      | O_BINARY
 #endif
 	      , 0777);
     if (data->fd < 0) {
+	if (errno == EINTR)
+	    goto try_open;
 	data->fd = -1;
 	return -1;
     }
--- a/lib/runtime_tools/doc/src/notes.xml
+++ b/lib/runtime_tools/doc/src/notes.xml
@@ -32,6 +32,23 @@
   <p>This document describes the changes made to the Runtime_Tools
     application.</p>
 
+<section><title>Runtime_Tools 1.9.1</title>
+
+    <section><title>Fixed Bugs and Malfunctions</title>
+      <list>
+        <item>
+          <p>
+	    The <c>trace_file_drv</c> did not handle <c>EINTR</c>
+	    correct which caused it to fail when the runtime system
+	    received a signal.</p>
+          <p>
+	    Own Id: OTP-12890 Aux Id: seq12885 </p>
+        </item>
+      </list>
+    </section>
+
+</section>
+
 <section><title>Runtime_Tools 1.9</title>
 
     <section><title>Improvements and New Features</title>
--- a/lib/runtime_tools/vsn.mk
+++ b/lib/runtime_tools/vsn.mk
@@ -1 +1 @@
-RUNTIME_TOOLS_VSN = 1.9
+RUNTIME_TOOLS_VSN = 1.9.1
--- a/otp_versions.table
+++ b/otp_versions.table
@@ -1,3 +1,4 @@
+OTP-18.0.2 : erts-7.0.2 runtime_tools-1.9.1 # asn1-4.0 common_test-1.11 compiler-6.0 cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosNotification-1.2 cosProperty-1.2 cosTime-1.2 cosTransactions-1.3 crypto-3.6 debugger-4.1 dialyzer-2.8 diameter-1.10 edoc-0.7.17 eldap-1.2 erl_docgen-0.4 erl_interface-3.8 et-1.5.1 eunit-2.2.10 gs-1.6 hipe-3.12 ic-4.4 inets-6.0 jinterface-1.6 kernel-4.0 megaco-3.18 mnesia-4.13 observer-2.1 odbc-2.11 orber-3.8 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1 percept-0.8.11 public_key-1.0 reltool-0.7 sasl-2.5 snmp-5.2 ssh-4.0 ssl-7.0 stdlib-2.5 syntax_tools-1.7 test_server-3.9 tools-2.8 typer-0.9.9 webtool-0.9 wx-1.4 xmerl-1.3.8 :
 OTP-18.0.1 : erts-7.0.1 # asn1-4.0 common_test-1.11 compiler-6.0 cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosNotification-1.2 cosProperty-1.2 cosTime-1.2 cosTransactions-1.3 crypto-3.6 debugger-4.1 dialyzer-2.8 diameter-1.10 edoc-0.7.17 eldap-1.2 erl_docgen-0.4 erl_interface-3.8 et-1.5.1 eunit-2.2.10 gs-1.6 hipe-3.12 ic-4.4 inets-6.0 jinterface-1.6 kernel-4.0 megaco-3.18 mnesia-4.13 observer-2.1 odbc-2.11 orber-3.8 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1 percept-0.8.11 public_key-1.0 reltool-0.7 runtime_tools-1.9 sasl-2.5 snmp-5.2 ssh-4.0 ssl-7.0 stdlib-2.5 syntax_tools-1.7 test_server-3.9 tools-2.8 typer-0.9.9 webtool-0.9 wx-1.4 xmerl-1.3.8 :
 OTP-18.0 : asn1-4.0 common_test-1.11 compiler-6.0 cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosNotification-1.2 cosProperty-1.2 cosTime-1.2 cosTransactions-1.3 crypto-3.6 debugger-4.1 dialyzer-2.8 diameter-1.10 edoc-0.7.17 eldap-1.2 erl_docgen-0.4 erl_interface-3.8 erts-7.0 et-1.5.1 eunit-2.2.10 gs-1.6 hipe-3.12 ic-4.4 inets-6.0 jinterface-1.6 kernel-4.0 megaco-3.18 mnesia-4.13 observer-2.1 odbc-2.11 orber-3.8 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1 percept-0.8.11 public_key-1.0 reltool-0.7 runtime_tools-1.9 sasl-2.5 snmp-5.2 ssh-4.0 ssl-7.0 stdlib-2.5 syntax_tools-1.7 test_server-3.9 tools-2.8 typer-0.9.9 webtool-0.9 wx-1.4 xmerl-1.3.8 # :
 OTP-17.5.6 : inets-5.10.9 ssh-3.2.4 ssl-6.0.1 # asn1-3.0.4 common_test-1.10.1 compiler-5.0.4 cosEvent-2.1.15 cosEventDomain-1.1.14 cosFileTransfer-1.1.16 cosNotification-1.1.21 cosProperty-1.1.17 cosTime-1.1.14 cosTransactions-1.2.14 crypto-3.5 debugger-4.0.3 dialyzer-2.7.4 diameter-1.9.2 edoc-0.7.16 eldap-1.1.1 erl_docgen-0.3.7 erl_interface-3.7.20 erts-6.4.1 et-1.5 eunit-2.2.9 gs-1.5.16 hipe-3.11.3 ic-4.3.6 jinterface-1.5.12 kernel-3.2 megaco-3.17.3 mnesia-4.12.5 observer-2.0.4 odbc-2.10.22 orber-3.7.1 os_mon-2.3.1 ose-1.0.2 otp_mibs-1.0.10 parsetools-2.0.12 percept-0.8.10 public_key-0.23 reltool-0.6.6 runtime_tools-1.8.16 sasl-2.4.1 snmp-5.1.2 stdlib-2.4 syntax_tools-1.6.18 test_server-3.8.1 tools-2.7.2 typer-0.9.8 webtool-0.8.10 wx-1.3.3 xmerl-1.3.7 :
diff --git a/main/erlang/0070-hipe_x86_signal-fix.patch b/main/erlang/0070-hipe_x86_signal-fix.patch
new file mode 100644
index 0000000..728d47d
--- /dev/null
+++ b/main/erlang/0070-hipe_x86_signal-fix.patch
@@ -0,0 +1,21 @@
--- otp_src_18.1-orig/erts/emulator/hipe/hipe_x86_signal.c
+++ otp_src_18.1-fixed/erts/emulator/hipe/hipe_x86_signal.c
@@ -221,16 +221,15 @@
 #include <dlfcn.h>
 static int (*__next_sigaction)(int, const struct sigaction*, struct sigaction*);
 #define init_done()	(__next_sigaction != 0)
-#define __SIGACTION _sigaction
+#define __SIGACTION __sigaction
 static void do_init(void)
 {
-    __next_sigaction = dlsym(RTLD_NEXT, "_sigaction");
+    __next_sigaction = dlsym(RTLD_NEXT, "__sigaction");
     if (__next_sigaction != 0)
 	return;
     perror("dlsym");
     abort();
 }
-#define _NSIG NSIG
 #define INIT()	do { if (!init_done()) do_init(); } while (0)
 #endif	/* not glibc or darwin */
 
diff --git a/main/erlang/APKBUILD b/main/erlang/APKBUILD
index eca4c68..b2d13c6 100644
--- a/main/erlang/APKBUILD
+++ b/main/erlang/APKBUILD
@@ -4,13 +4,13 @@
pkgname=erlang
pkgver=18.1
_srcver=18.1
pkgrel=0
pkgrel=1
pkgdesc="General-purpose programming language and runtime environment"
url="http://www.erlang.org/"
license="ASL 2.0"
arch="all"
depends="$pkgname-kernel $pkgname-stdlib $pkgname-compiler"
makedepends="perl-dev zlib-dev ncurses-dev openssl-dev openjdk7 unixodbc-dev"
makedepends="m4 perl-dev zlib-dev ncurses-dev openssl-dev openjdk7 unixodbc-dev"
install=""
subpackages="$pkgname-dev
             $pkgname-asn1:asn
@@ -76,7 +76,8 @@ source="http://www.erlang.org/download/otp_src_$_srcver.tar.gz
        0010-fix-nteventlog-remove.patch
        0020-remove-private-unit32.patch
        0030-replace_glibc_check.patch
        0060-set-disksup_posix_only-to-true.patch"
        0060-set-disksup_posix_only-to-true.patch
        0070-hipe_x86_signal-fix.patch"

_builddir="$srcdir"/otp_src_$_srcver

@@ -215,33 +216,36 @@ ef4b726309a749010553259080960753  0002-Remove-rpath.patch
458118f96fb0c973a30630c070bd94aa  0003-Do-not-install-C-sources.patch
1c3b158ac8408fced9a0f3630f4498f1  0004-Do-not-install-Java-sources.patch
f4aa0cc27dc57ea4dcd57191b1948a4d  0005-Do-not-install-nteventlog-and-related-doc-files-on-n.patch
115f105e3af69b94e078cc56cfd6f062  0006-Do-not-install-erlang-sources.patch
90f36608d2d8f71c8eb19126af06978b  0006-Do-not-install-erlang-sources.patch
b438c37818b5c82443682c3693dd7e53  0007-Split-off-webtool-dependency-from-tools.patch
0dd300003ff68fc46dc3c839c2541d53  0010-fix-nteventlog-remove.patch
062605d7f01f4685f1897ba2decc23a8  0020-remove-private-unit32.patch
7a5c956b7bf79e34a0f980d1e2a65bee  0030-replace_glibc_check.patch
d17fbaafa9f7820ade09b239c00aede6  0060-set-disksup_posix_only-to-true.patch"
d17fbaafa9f7820ade09b239c00aede6  0060-set-disksup_posix_only-to-true.patch
02a18c698b0ff37d0bcf106db57c1136  0070-hipe_x86_signal-fix.patch"
sha256sums="e4a147228a6b7fa60dce05c8adfb3cbc254d97cf6e45456d93d93adbde8b0f11  otp_src_18.1.tar.gz
536e78192f915733cbbb264883af6d9b11c9e70c2c4d3d825b58c4dbec36db86  0001-Do-not-format-man-pages-and-do-not-install-miscellan.patch
b2e5844215d7f5f5026a77342dd698d16103cc726d23f8265bcc8399d1a82bb9  0002-Remove-rpath.patch
81062f0eb9a72cbfac600fab56823161f92e1e5107b359f27f9f0ec511b8aec5  0003-Do-not-install-C-sources.patch
2ed61274decb534ab4142bd0a2116a75e3fe82d33a8ff145524173ce5773b0e2  0004-Do-not-install-Java-sources.patch
71c8a55fe036d5a04ba2c008b51d8950c3f18d83edaffb9bef2a9d19dd2f79f3  0005-Do-not-install-nteventlog-and-related-doc-files-on-n.patch
d5dd09daa693729f93305d9fc4391faca8bd601f572df02db5da1bf01fa8dc58  0006-Do-not-install-erlang-sources.patch
594745af27e73d8213e190eea654285bc4bdda706de4275f2b6dd64b2af720c3  0006-Do-not-install-erlang-sources.patch
9704a53bc4bd6f5624f9ce3f201128204011f4579f19b547df74d92ae22777cf  0007-Split-off-webtool-dependency-from-tools.patch
019c62ea3fee60068caa8c3152d7f96e76591fc5dc096abfcea48ec1593eb758  0010-fix-nteventlog-remove.patch
0b63ff5ce4e642d4225d5cc4d52d88dd5daf83ce5a2549ba0e5a14ce05e17ac2  0020-remove-private-unit32.patch
e3158dbb4bcb4677ceda39a374326c069de78a52e598ef8169a288b86a040a62  0030-replace_glibc_check.patch
3ffda0b3acbde755b496c1a974c20e1ca580432c403944c1c16836f48e248429  0060-set-disksup_posix_only-to-true.patch"
3ffda0b3acbde755b496c1a974c20e1ca580432c403944c1c16836f48e248429  0060-set-disksup_posix_only-to-true.patch
97c430677f18f81bafc6af7bb45c5dddc5222597350a6813cb338d21acec464a  0070-hipe_x86_signal-fix.patch"
sha512sums="31e3a4f3d8da7877757fa4df427c59462cb68e0177f93698146ce17127406fd0ee77f819044cef10e4a18ed075deb44343d915148cf1fd4bce09a1e39edaaee6  otp_src_18.1.tar.gz
172f9b0f61748bf2f04737df0451bcc9c0812db0f365f0ef7c7c244fceb991987f79a5274eea578a89cc7d077f84645d1395d9dbcbf14010268b896a080c2ccf  0001-Do-not-format-man-pages-and-do-not-install-miscellan.patch
97c40c185b71b23ffcb924639af390b9a0be897070e396a9413e193e6d43048dfe3b86bcd0c5598b81a66ce1349de9e09f5228a452b51b6612cd947bbafb6377  0002-Remove-rpath.patch
1cae89d1e8f9d375ae08c7de2b8f7a5143bcded90eef878e97c408542a50e9a880166311820013301e46364be0ae090d3fc515b6f915ead14e787b98290beec1  0003-Do-not-install-C-sources.patch
b174e3c9103aa26e3b4993ae77b849a55f733e6f8e5dd7bb641a8548aea7fcc91b99d772c91ff8864fff5c30b388438f8cb41d7ac941a86fc7bb1891f9838068  0004-Do-not-install-Java-sources.patch
923addcb1f6472829ba13ccc91ad3cef161f269478404f0a19bc4997118e06edd7459011a60769eb393eac930f30d4bd6c5526301382a5f9815862237f4664d3  0005-Do-not-install-nteventlog-and-related-doc-files-on-n.patch
12aff88e06a4fe4f25bb7ae16257195779388f903bbb38dfcfa1a36f81874493eb5e73836c340c60ddfe28e175fe165754c695d4f77b401cc84c6f711ce2c24e  0006-Do-not-install-erlang-sources.patch
b9aea9344703688ef5b98d530417c59166749de4f6d91fe8d01abaa7bd1946495ec4ab23e854947192659f49b35cbbead7c4f47836c3579ff844f23217e75cb4  0006-Do-not-install-erlang-sources.patch
d65fcfc3a9441941c6292c33d354964a82da11cc7a411dd0440719e490075ed588c1e70690e80650561749010d737394567f12ff73bd460f0d00c792c77cfae3  0007-Split-off-webtool-dependency-from-tools.patch
b7387f92f8c27a0565c7885bba4b357183c62d422616e073bc5ffad338a0e22cb5165dcb3b95bf0b920ba00831599f2216027883f4be255aa6f6150b68b7a37c  0010-fix-nteventlog-remove.patch
18f70c3a99ac8c44bc9d90dc3f0c072ad4df4ffe57a8d0677087c9e940ba138d7a7698d5cdbbe14875a6012d353a679fdb33d40fca3a3211f712af8c4b0cb0b4  0020-remove-private-unit32.patch
b554882bee1a70322cc8c5b973986047deaf4528fe1371df39cf72b27b2497a859463bdf8847ea6ea96cb0caaa6bd143c96a5dee28839164a547a66a30fcffd0  0030-replace_glibc_check.patch
f3c50f8610e08173c365a575737079b0259db6fc0dfa5b1be63c281b52358bbce9e2595132a8f6a06772785d7d38d108f8da8515e2f7706cd03b6585aab4d071  0060-set-disksup_posix_only-to-true.patch"
f3c50f8610e08173c365a575737079b0259db6fc0dfa5b1be63c281b52358bbce9e2595132a8f6a06772785d7d38d108f8da8515e2f7706cd03b6585aab4d071  0060-set-disksup_posix_only-to-true.patch
400bcc630db8902e4781f9590c6d81089d7e6751a17c09ad1f05a0308fc6737391a718c73936b411e3b6bcbc65e5ea555d92012dacaa806a9db9cd219d887753  0070-hipe_x86_signal-fix.patch"
-- 
2.4.1



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---