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

[UNIKRAFT PATCH 2/3] libdruntime: Expose standard file descriptors symbols to the runtime



---
 gluecode.c                                    | 10 +++
 ...ndard-descriptors-visibility-problem.patch | 62 +++++++++++++++++++
 2 files changed, 72 insertions(+)
 create mode 100644 
patches/0002-Solve-standard-descriptors-visibility-problem.patch

diff --git a/gluecode.c b/gluecode.c
index 952d14d..7bd174c 100644
--- a/gluecode.c
+++ b/gluecode.c
@@ -45,6 +45,16 @@
 #include <math.h>
 
 
+FILE *_stdin;
+FILE *_stdout;
+FILE *_stderr;
+
+void initStdIO() {
+    _stdin = stdin;
+    _stdout = stdout;
+    _stderr = stderr;
+}
+
 typedef __sigset_t  sigset_t;
 int sigfillset(sigset_t *set)
 {
diff --git a/patches/0002-Solve-standard-descriptors-visibility-problem.patch 
b/patches/0002-Solve-standard-descriptors-visibility-problem.patch
new file mode 100644
index 0000000..1b9722f
--- /dev/null
+++ b/patches/0002-Solve-standard-descriptors-visibility-problem.patch
@@ -0,0 +1,62 @@
+From 356f85a077adfcb4a1c66163b7d3a2c38a1667b3 Mon Sep 17 00:00:00 2001
+From: Marius-Cristian Baciu <2309bmcristi@xxxxxxxxx>
+Date: Sat, 18 Jul 2020 23:58:35 +0300
+Subject: [PATCH] Solve standard descriptors visibility problem
+
+initStdio() is a routine we have defined in D runtime lib's gluecode.c
+---
+ libphobos/libdruntime/core/stdc/stdio.d | 10 +++++++---
+ libphobos/libdruntime/rt/dmain2.d       |  7 +++++++
+ 2 files changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/libphobos/libdruntime/core/stdc/stdio.d 
b/libphobos/libdruntime/core/stdc/stdio.d
+index 6ce3f9d13..8ed585bcb 100644
+--- a/libphobos/libdruntime/core/stdc/stdio.d
++++ b/libphobos/libdruntime/core/stdc/stdio.d
+@@ -907,11 +907,15 @@ else version (CRuntime_Glibc)
+     }
+ 
+     ///
+-    extern shared FILE* stdin;
++    extern shared FILE* _stdin;
+     ///
+-    extern shared FILE* stdout;
++    extern shared FILE* _stdout;
+     ///
+-    extern shared FILE* stderr;
++    extern shared FILE* _stderr;
++
++    alias _stdin    stdin;
++    alias _stdout   stdout;
++    alias _stderr   stderr;
+ }
+ else version (Darwin)
+ {
+diff --git a/libphobos/libdruntime/rt/dmain2.d 
b/libphobos/libdruntime/rt/dmain2.d
+index f45565c97..7e42b63fb 100644
+--- a/libphobos/libdruntime/rt/dmain2.d
++++ b/libphobos/libdruntime/rt/dmain2.d
+@@ -156,6 +156,10 @@ extern (C) __gshared bool rt_trapExceptions = true;
+ 
+ alias void delegate(Throwable) ExceptionHandler;
+ 
++version (UNIKRAFT) {
++    extern (C) void initStdIO();
++}
++
+ /**
+  * Keep track of how often rt_init/rt_term were called.
+  */
+@@ -168,6 +172,9 @@ shared size_t _initCount;
+  */
+ extern (C) int rt_init()
+ {
++    version (UNIKRAFT) {
++        initStdIO();
++    }
+     /* @@BUG 11380 @@ Need to synchronize rt_init/rt_term calls for
+        version (Shared) druntime, because multiple C threads might
+        initialize different D libraries without knowing about the
+-- 
+2.17.1
+
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.