From 322467dbe36c51408061edf903fb898bb674cbe2 Mon Sep 17 00:00:00 2001
From: Roland McGrath <mcgrathr@google.com>
Date: Sat, 27 Apr 2019 00:03:24 +0000
Subject: [PATCH] [libc] Move setjmp implementation out of
 third_party/ulib/musl

This code was all written from scratch for Fuchsia.
Move it to system/ulib/c to make its provenance more clear.

Test: no effect on the build
Change-Id: I6b4105157c9233ad3b7ec41124c35cbf144c2ae0
---
 zircon/system/ulib/c/BUILD.gn                                 | 1 +
 .../ulib/musl/src => system/ulib/c}/setjmp/BUILD.gn           | 4 ----
 .../ulib/musl/src => system/ulib/c}/setjmp/aarch64/longjmp.S  | 0
 .../ulib/musl/src => system/ulib/c}/setjmp/aarch64/setjmp.S   | 0
 .../ulib/musl/src => system/ulib/c}/setjmp/setjmp.c           | 4 ++++
 .../ulib/musl/src => system/ulib/c}/setjmp/x86_64/longjmp.S   | 0
 .../ulib/musl/src => system/ulib/c}/setjmp/x86_64/setjmp.S    | 0
 zircon/third_party/ulib/musl/BUILD.gn                         | 2 +-
 zircon/third_party/ulib/musl/src/setjmp/longjmp.c             | 0
 9 files changed, 6 insertions(+), 5 deletions(-)
 rename zircon/{third_party/ulib/musl/src => system/ulib/c}/setjmp/BUILD.gn (71%)
 rename zircon/{third_party/ulib/musl/src => system/ulib/c}/setjmp/aarch64/longjmp.S (100%)
 rename zircon/{third_party/ulib/musl/src => system/ulib/c}/setjmp/aarch64/setjmp.S (100%)
 rename zircon/{third_party/ulib/musl/src => system/ulib/c}/setjmp/setjmp.c (53%)
 rename zircon/{third_party/ulib/musl/src => system/ulib/c}/setjmp/x86_64/longjmp.S (100%)
 rename zircon/{third_party/ulib/musl/src => system/ulib/c}/setjmp/x86_64/setjmp.S (100%)
 delete mode 100644 zircon/third_party/ulib/musl/src/setjmp/longjmp.c

diff --git a/zircon/system/ulib/c/BUILD.gn b/zircon/system/ulib/c/BUILD.gn
index 36f763d835c..2df2d19d403 100644
--- a/zircon/system/ulib/c/BUILD.gn
+++ b/zircon/system/ulib/c/BUILD.gn
@@ -17,6 +17,7 @@ library("c") {
   sources = []
   deps = [
     "$zx/third_party/ulib/musl",
+    "setjmp",
   ]
 
   # Suppress the ${toolchain.implicit_deps} that points back to here.
diff --git a/zircon/third_party/ulib/musl/src/setjmp/BUILD.gn b/zircon/system/ulib/c/setjmp/BUILD.gn
similarity index 71%
rename from zircon/third_party/ulib/musl/src/setjmp/BUILD.gn
rename to zircon/system/ulib/c/setjmp/BUILD.gn
index 23a01521f56..7ea23876370 100644
--- a/zircon/third_party/ulib/musl/src/setjmp/BUILD.gn
+++ b/zircon/system/ulib/c/setjmp/BUILD.gn
@@ -2,9 +2,6 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-# TODO(mcgrathr): This code was all rewritten from scratch.  Move it out of
-# third_party/ulib/musl into system/ulib/c.
-
 source_set("setjmp") {
   deps = [
     "$zx/third_party/ulib/musl:musl_internal",
@@ -12,7 +9,6 @@ source_set("setjmp") {
   sources = [
     "${toolchain.cpu}/longjmp.S",
     "${toolchain.cpu}/setjmp.S",
-    "longjmp.c",
     "setjmp.c",
   ]
 }
diff --git a/zircon/third_party/ulib/musl/src/setjmp/aarch64/longjmp.S b/zircon/system/ulib/c/setjmp/aarch64/longjmp.S
similarity index 100%
rename from zircon/third_party/ulib/musl/src/setjmp/aarch64/longjmp.S
rename to zircon/system/ulib/c/setjmp/aarch64/longjmp.S
diff --git a/zircon/third_party/ulib/musl/src/setjmp/aarch64/setjmp.S b/zircon/system/ulib/c/setjmp/aarch64/setjmp.S
similarity index 100%
rename from zircon/third_party/ulib/musl/src/setjmp/aarch64/setjmp.S
rename to zircon/system/ulib/c/setjmp/aarch64/setjmp.S
diff --git a/zircon/third_party/ulib/musl/src/setjmp/setjmp.c b/zircon/system/ulib/c/setjmp/setjmp.c
similarity index 53%
rename from zircon/third_party/ulib/musl/src/setjmp/setjmp.c
rename to zircon/system/ulib/c/setjmp/setjmp.c
index 50ed889b648..a29dc8276e9 100644
--- a/zircon/third_party/ulib/musl/src/setjmp/setjmp.c
+++ b/zircon/system/ulib/c/setjmp/setjmp.c
@@ -1,3 +1,7 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
 #include <assert.h>
 #include <setjmp.h>
 #include <stdint.h>
diff --git a/zircon/third_party/ulib/musl/src/setjmp/x86_64/longjmp.S b/zircon/system/ulib/c/setjmp/x86_64/longjmp.S
similarity index 100%
rename from zircon/third_party/ulib/musl/src/setjmp/x86_64/longjmp.S
rename to zircon/system/ulib/c/setjmp/x86_64/longjmp.S
diff --git a/zircon/third_party/ulib/musl/src/setjmp/x86_64/setjmp.S b/zircon/system/ulib/c/setjmp/x86_64/setjmp.S
similarity index 100%
rename from zircon/third_party/ulib/musl/src/setjmp/x86_64/setjmp.S
rename to zircon/system/ulib/c/setjmp/x86_64/setjmp.S
diff --git a/zircon/third_party/ulib/musl/BUILD.gn b/zircon/third_party/ulib/musl/BUILD.gn
index 62f1a00e5c2..0e39f4b676e 100644
--- a/zircon/third_party/ulib/musl/BUILD.gn
+++ b/zircon/third_party/ulib/musl/BUILD.gn
@@ -17,6 +17,7 @@ config("headers") {
 group("musl_internal") {
   visibility = [
     "./*",
+    "$zx/system/ulib/c/*",
     "$zx/third_party/ulib/$malloc:*",
   ]
   public_deps = [
@@ -90,7 +91,6 @@ if (toolchain.base_environment == "user") {
       "src/process",
       "src/regex",
       "src/sched",
-      "src/setjmp",
       "src/signal",
       "src/stat",
       "src/stdio",
diff --git a/zircon/third_party/ulib/musl/src/setjmp/longjmp.c b/zircon/third_party/ulib/musl/src/setjmp/longjmp.c
deleted file mode 100644
index e69de29bb2d..00000000000
-- 
GitLab