[libc-commits] [libc] d2024bb - [libc][Fix] Move generic stdio implementations to a new directory

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed Aug 9 13:32:41 PDT 2023


Author: Joseph Huber
Date: 2023-08-09T15:32:34-05:00
New Revision: d2024bbce3720e47dd0c5d8bdc1e4f77b639e0e4

URL: https://github.com/llvm/llvm-project/commit/d2024bbce3720e47dd0c5d8bdc1e4f77b639e0e4
DIFF: https://github.com/llvm/llvm-project/commit/d2024bbce3720e47dd0c5d8bdc1e4f77b639e0e4.diff

LOG: [libc][Fix] Move generic stdio implementations to a new directory

For whatever reason, the CMake did not like having the `generic_`
version live in the same directory. This patch pushes them to a new
directory, which is probably clearer anyway.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D157544

Added: 
    libc/src/stdio/generic/CMakeLists.txt
    libc/src/stdio/generic/fputs.cpp
    libc/src/stdio/generic/puts.cpp
    libc/src/stdio/generic/stderr.cpp
    libc/src/stdio/generic/stdin.cpp
    libc/src/stdio/generic/stdout.cpp

Modified: 
    libc/src/stdio/CMakeLists.txt

Removed: 
    libc/src/stdio/fputs.cpp
    libc/src/stdio/puts.cpp
    libc/src/stdio/stderr.cpp
    libc/src/stdio/stdin.cpp
    libc/src/stdio/stdout.cpp


################################################################################
diff  --git a/libc/src/stdio/CMakeLists.txt b/libc/src/stdio/CMakeLists.txt
index 5e05ec73e3c1e1..91e7184e0f375b 100644
--- a/libc/src/stdio/CMakeLists.txt
+++ b/libc/src/stdio/CMakeLists.txt
@@ -8,16 +8,17 @@ function(add_stdio_entrypoint_object name)
       DEPENDS
         .${LIBC_TARGET_OS}.${name}
     )
-  elseif(TARGET libc.src.stdio.generic_${name})
+  elseif(TARGET libc.src.stdio.generic.${name})
     add_entrypoint_object(
       ${name}
       ALIAS
       DEPENDS
-        .generic_${name}
+        .generic.${name}
     )
   endif()
 endfunction(add_stdio_entrypoint_object)
 
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/generic)
 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
 endif()
@@ -341,33 +342,6 @@ add_entrypoint_object(
     libc.src.__support.File.platform_file
 )
 
-add_entrypoint_object(
-  generic_fputs
-  SRCS
-    fputs.cpp
-  HDRS
-    fputs.h
-  DEPENDS
-    libc.src.errno.errno
-    libc.include.stdio
-    libc.src.__support.File.file
-    libc.src.__support.File.platform_file
-)
-
-
-add_entrypoint_object(
-  generic_puts
-  SRCS
-    puts.cpp
-  HDRS
-    puts.h
-  DEPENDS
-    libc.src.errno.errno
-    libc.include.stdio
-    libc.src.__support.File.file
-    libc.src.__support.File.platform_file
-)
-
 add_entrypoint_object(
   fseek
   SRCS
@@ -405,42 +379,6 @@ add_entrypoint_object(
     libc.src.__support.File.file
 )
 
-add_entrypoint_object(
-  generic_stdin
-  SRCS
-    stdin.cpp
-  HDRS
-    stdin.h
-  DEPENDS
-    libc.include.stdio
-    libc.src.__support.File.file
-    libc.src.__support.File.platform_file
-)
-
-add_entrypoint_object(
-  generic_stdout
-  SRCS
-    stdout.cpp
-  HDRS
-    stdout.h
-  DEPENDS
-    libc.include.stdio
-    libc.src.__support.File.file
-    libc.src.__support.File.platform_file
-)
-
-add_entrypoint_object(
-  generic_stderr
-  SRCS
-    stderr.cpp
-  HDRS
-    stderr.h
-  DEPENDS
-    libc.include.stdio
-    libc.src.__support.File.file
-    libc.src.__support.File.platform_file
-)
-
 add_entrypoint_object(
   setbuf
   SRCS

diff  --git a/libc/src/stdio/generic/CMakeLists.txt b/libc/src/stdio/generic/CMakeLists.txt
new file mode 100644
index 00000000000000..50220b2df5d8f6
--- /dev/null
+++ b/libc/src/stdio/generic/CMakeLists.txt
@@ -0,0 +1,66 @@
+if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+  # The GPU build cannot use any generic implementations.
+  return()
+endif()
+
+add_entrypoint_object(
+  fputs
+  SRCS
+    fputs.cpp
+  HDRS
+    ../fputs.h
+  DEPENDS
+    libc.src.errno.errno
+    libc.include.stdio
+    libc.src.__support.File.file
+    libc.src.__support.File.platform_file
+)
+
+add_entrypoint_object(
+  puts
+  SRCS
+    puts.cpp
+  HDRS
+    ../puts.h
+  DEPENDS
+    libc.src.errno.errno
+    libc.include.stdio
+    libc.src.__support.File.file
+    libc.src.__support.File.platform_file
+)
+
+add_entrypoint_object(
+  stdin
+  SRCS
+    stdin.cpp
+  HDRS
+    ../stdin.h
+  DEPENDS
+    libc.include.stdio
+    libc.src.__support.File.file
+    libc.src.__support.File.platform_file
+)
+
+add_entrypoint_object(
+  stdout
+  SRCS
+    stdout.cpp
+  HDRS
+    ../stdout.h
+  DEPENDS
+    libc.include.stdio
+    libc.src.__support.File.file
+    libc.src.__support.File.platform_file
+)
+
+add_entrypoint_object(
+  stderr
+  SRCS
+    stderr.cpp
+  HDRS
+    ../stderr.h
+  DEPENDS
+    libc.include.stdio
+    libc.src.__support.File.file
+    libc.src.__support.File.platform_file
+)

diff  --git a/libc/src/stdio/fputs.cpp b/libc/src/stdio/generic/fputs.cpp
similarity index 100%
rename from libc/src/stdio/fputs.cpp
rename to libc/src/stdio/generic/fputs.cpp

diff  --git a/libc/src/stdio/puts.cpp b/libc/src/stdio/generic/puts.cpp
similarity index 100%
rename from libc/src/stdio/puts.cpp
rename to libc/src/stdio/generic/puts.cpp

diff  --git a/libc/src/stdio/stderr.cpp b/libc/src/stdio/generic/stderr.cpp
similarity index 100%
rename from libc/src/stdio/stderr.cpp
rename to libc/src/stdio/generic/stderr.cpp

diff  --git a/libc/src/stdio/stdin.cpp b/libc/src/stdio/generic/stdin.cpp
similarity index 100%
rename from libc/src/stdio/stdin.cpp
rename to libc/src/stdio/generic/stdin.cpp

diff  --git a/libc/src/stdio/stdout.cpp b/libc/src/stdio/generic/stdout.cpp
similarity index 100%
rename from libc/src/stdio/stdout.cpp
rename to libc/src/stdio/generic/stdout.cpp


        


More information about the libc-commits mailing list