blob: 5610ed9beb6d5a8cdc16f883895502782518e5b4 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001From 69171c22f3872ecb4c1ab27985e93ca44084595e Mon Sep 17 00:00:00 2001
2From: Fan Xin <fan.xin@jp.fujitsu.com>
3Date: Mon, 5 Jun 2017 13:26:38 +0900
Brad Bishop6e60e8b2018-02-01 10:27:11 -05004Subject: [PATCH] aslfiles.c: manipulate fds instead of FILE
5
6Copying what stdout/stderr point to is not portable and fails with
7musl because FILE is an undefined struct.
8
9Instead, use lower-level Unix functions to modify the file that stderr
10writes into. This works on the platforms that Yocto targets.
11
12Upstream-Status: Inappropriate [embedded specific]
13
14Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016Rebase on acpica 20170303
17
18Signed-off-by: Fan Xin <fan.xin@jp.fujitsu.com>
19---
20 acpica-unix2-20170303/source/compiler/aslfiles.c | 14 +++++++++++---
21 1 file changed, 11 insertions(+), 3 deletions(-)
22
23diff --git a/acpica-unix2-20170303/source/compiler/aslfiles.c b/acpica-unix2-20170303/source/compiler/aslfiles.c
24index 809090c..97898b1 100644
25--- a/acpica-unix2-20170303/source/compiler/aslfiles.c
26+++ b/acpica-unix2-20170303/source/compiler/aslfiles.c
27@@ -44,6 +44,10 @@
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028 #include "aslcompiler.h"
29 #include "acapps.h"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050030 #include "dtcompiler.h"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050031+#include <sys/types.h>
32+#include <sys/stat.h>
33+#include <fcntl.h>
34+#include <unistd.h>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050035
Brad Bishop6e60e8b2018-02-01 10:27:11 -050036 #define _COMPONENT ACPI_COMPILER
37 ACPI_MODULE_NAME ("aslfiles")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050038@@ -607,6 +611,8 @@ FlOpenMiscOutputFiles (
Brad Bishop6e60e8b2018-02-01 10:27:11 -050039
40 if (Gbl_DebugFlag)
41 {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050042+ int fd;
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043+
44 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
45 if (!Filename)
46 {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050047@@ -618,10 +624,10 @@ FlOpenMiscOutputFiles (
48 /* Open the debug file as STDERR, text mode */
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049
50 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
51- Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
52- freopen (Filename, "w+t", stderr);
Brad Bishopd7bf8c12018-02-25 22:55:05 -050053
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054- if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
55+ fd = open(Filename, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
56+ if (fd < 0 ||
57+ dup2(fd, fileno(stderr)))
58 {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050059 /*
60 * A problem with freopen is that on error, we no longer
61@@ -635,6 +641,8 @@ FlOpenMiscOutputFiles (
62 exit (1);
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063 }
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064
Brad Bishopd7bf8c12018-02-25 22:55:05 -050065+ Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = stderr;
66+
Brad Bishop6e60e8b2018-02-01 10:27:11 -050067 AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
68 AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
Brad Bishopd7bf8c12018-02-25 22:55:05 -050069 }
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070--
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500711.9.1
Brad Bishop6e60e8b2018-02-01 10:27:11 -050072