[libc-commits] [PATCH] D152983: [libc] Move the definitions of the standard IO streams to the platform

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jun 14 19:46:41 PDT 2023


jhuber6 updated this revision to Diff 531594.
jhuber6 added a comment.

Fix extern C


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152983/new/

https://reviews.llvm.org/D152983

Files:
  libc/src/__support/File/gpu/file.cpp
  libc/src/__support/File/linux/file.cpp
  libc/src/stdio/stderr.cpp
  libc/src/stdio/stdin.cpp
  libc/src/stdio/stdout.cpp


Index: libc/src/stdio/stdout.cpp
===================================================================
--- libc/src/stdio/stdout.cpp
+++ libc/src/stdio/stdout.cpp
@@ -10,6 +10,4 @@
 
 #include <stdio.h>
 
-extern "C" {
-FILE *stdout = reinterpret_cast<FILE *>(__llvm_libc::stdout);
-}
+extern "C" FILE *stdout;
Index: libc/src/stdio/stdin.cpp
===================================================================
--- libc/src/stdio/stdin.cpp
+++ libc/src/stdio/stdin.cpp
@@ -10,6 +10,4 @@
 
 #include <stdio.h>
 
-extern "C" {
-FILE *stdin = reinterpret_cast<FILE *>(__llvm_libc::stdin);
-}
+extern "C" FILE *stdin;
Index: libc/src/stdio/stderr.cpp
===================================================================
--- libc/src/stdio/stderr.cpp
+++ libc/src/stdio/stderr.cpp
@@ -10,6 +10,4 @@
 
 #include <stdio.h>
 
-extern "C" {
-FILE *stderr = reinterpret_cast<FILE *>(__llvm_libc::stderr);
-}
+extern "C" FILE *stderr;
Index: libc/src/__support/File/linux/file.cpp
===================================================================
--- libc/src/__support/File/linux/file.cpp
+++ libc/src/__support/File/linux/file.cpp
@@ -183,3 +183,10 @@
 File *stderr = &StdErr;
 
 } // namespace __llvm_libc
+
+// Provide the external defintitions of the standard IO streams.
+extern "C" {
+FILE *stdin = reinterpret_cast<FILE *>(&__llvm_libc::StdIn);
+FILE *stderr = reinterpret_cast<FILE *>(&__llvm_libc::StdErr);
+FILE *stdout = reinterpret_cast<FILE *>(&__llvm_libc::StdOut);
+}
Index: libc/src/__support/File/gpu/file.cpp
===================================================================
--- libc/src/__support/File/gpu/file.cpp
+++ libc/src/__support/File/gpu/file.cpp
@@ -97,3 +97,10 @@
 File *stderr = &StdErr;
 
 } // namespace __llvm_libc
+
+// Provide the external defintitions of the standard IO streams.
+extern "C" {
+FILE *stdin = reinterpret_cast<FILE *>(&__llvm_libc::StdIn);
+FILE *stderr = reinterpret_cast<FILE *>(&__llvm_libc::StdErr);
+FILE *stdout = reinterpret_cast<FILE *>(&__llvm_libc::StdOut);
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152983.531594.patch
Type: text/x-patch
Size: 2015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230615/96658a46/attachment.bin>


More information about the libc-commits mailing list