[libc-commits] [libc] [libc] cmake and config for wchar file entrypoints (PR #196167)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Wed May 6 12:59:56 PDT 2026


https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/196167

Add CMake and config files for wide character file entrypoints. Part 11/11.

Previous parts:
https://github.com/llvm/llvm-project/pull/196157
https://github.com/llvm/llvm-project/pull/196158
https://github.com/llvm/llvm-project/pull/196159
https://github.com/llvm/llvm-project/pull/196160
https://github.com/llvm/llvm-project/pull/196161
https://github.com/llvm/llvm-project/pull/196162
https://github.com/llvm/llvm-project/pull/196163
https://github.com/llvm/llvm-project/pull/196164
https://github.com/llvm/llvm-project/pull/196165
https://github.com/llvm/llvm-project/pull/196166

Assisted by Gemini


>From 7533b95d43150305c6a15d52fc8318e21be2e565 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Wed, 6 May 2026 18:28:55 +0000
Subject: [PATCH] [libc] cmake and config for wchar file entrypoints

Add CMake and config files for wide character file entrypoints. Part 11/11.

Assisted by Gemini
---
 libc/config/linux/aarch64/entrypoints.txt |  11 ++
 libc/config/linux/riscv/entrypoints.txt   |  11 ++
 libc/config/linux/x86_64/entrypoints.txt  |  11 ++
 libc/include/wchar.yaml                   |  68 ++++++++
 libc/src/wchar/CMakeLists.txt             | 151 ++++++++++++++++-
 libc/test/src/wchar/CMakeLists.txt        | 188 ++++++++++++++++++++++
 6 files changed, 438 insertions(+), 2 deletions(-)

diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index ea3f4cd8f51a0..f332358dd4175 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -396,6 +396,17 @@ set(TARGET_LIBC_ENTRYPOINTS
     # wchar.h entrypoints
     libc.src.wchar.wcslen
     libc.src.wchar.wctob
+    libc.src.wchar.fgetwc
+    libc.src.wchar.fgetws
+    libc.src.wchar.fputwc
+    libc.src.wchar.fputws
+    libc.src.wchar.fwide
+    libc.src.wchar.getwc
+    libc.src.wchar.getwchar
+    libc.src.wchar.putwc
+    libc.src.wchar.putwchar
+    libc.src.wchar.ungetwc
+
 
     # wctype.h entrypoints
     libc.src.wctype.iswalpha
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index d8d520c6d4236..df7194208ed37 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -400,6 +400,17 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wchar.btowc
     libc.src.wchar.wcslen
     libc.src.wchar.wctob
+    libc.src.wchar.fgetwc
+    libc.src.wchar.fgetws
+    libc.src.wchar.fputwc
+    libc.src.wchar.fputws
+    libc.src.wchar.fwide
+    libc.src.wchar.getwc
+    libc.src.wchar.getwchar
+    libc.src.wchar.putwc
+    libc.src.wchar.putwchar
+    libc.src.wchar.ungetwc
+
 
     # wctype.h entrypoints
     libc.src.wctype.iswalpha
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index dfd6064951d52..125a0a8eacfa8 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -452,6 +452,17 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.wchar.wcstoll
     libc.src.wchar.wcstoul
     libc.src.wchar.wcstoull
+    libc.src.wchar.fgetwc
+    libc.src.wchar.fgetws
+    libc.src.wchar.fputwc
+    libc.src.wchar.fputws
+    libc.src.wchar.fwide
+    libc.src.wchar.getwc
+    libc.src.wchar.getwchar
+    libc.src.wchar.putwc
+    libc.src.wchar.putwchar
+    libc.src.wchar.ungetwc
+
 
     # wctype.h entrypoints
     libc.src.wctype.iswalpha
diff --git a/libc/include/wchar.yaml b/libc/include/wchar.yaml
index 6575f2504c900..fa1a147e55387 100644
--- a/libc/include/wchar.yaml
+++ b/libc/include/wchar.yaml
@@ -369,3 +369,71 @@ functions:
       - type: wchar_t *__restrict
       - type: const wchar_t *__restrict
       - type: size_t
+  - name: fgetwc
+    standards:
+      - stdc
+    return_type: wint_t
+    arguments:
+      - type: FILE *
+  - name: fgetws
+    standards:
+      - stdc
+    return_type: wchar_t *
+    arguments:
+      - type: wchar_t *__restrict
+      - type: int
+      - type: FILE *__restrict
+  - name: fputwc
+    standards:
+      - stdc
+    return_type: wint_t
+    arguments:
+      - type: wchar_t
+      - type: FILE *
+  - name: fputws
+    standards:
+      - stdc
+    return_type: int
+    arguments:
+      - type: const wchar_t *__restrict
+      - type: FILE *__restrict
+  - name: fwide
+    standards:
+      - stdc
+    return_type: int
+    arguments:
+      - type: FILE *
+      - type: int
+  - name: getwc
+    standards:
+      - stdc
+    return_type: wint_t
+    arguments:
+      - type: FILE *
+  - name: getwchar
+    standards:
+      - stdc
+    return_type: wint_t
+    arguments:
+      - type: void
+  - name: putwc
+    standards:
+      - stdc
+    return_type: wint_t
+    arguments:
+      - type: wchar_t
+      - type: FILE *
+  - name: putwchar
+    standards:
+      - stdc
+    return_type: wint_t
+    arguments:
+      - type: wchar_t
+  - name: ungetwc
+    standards:
+      - stdc
+    return_type: wint_t
+    arguments:
+      - type: wint_t
+      - type: FILE *
+
diff --git a/libc/src/wchar/CMakeLists.txt b/libc/src/wchar/CMakeLists.txt
index 89383c33c6a4e..faea583ca5cc8 100644
--- a/libc/src/wchar/CMakeLists.txt
+++ b/libc/src/wchar/CMakeLists.txt
@@ -557,12 +557,159 @@ add_entrypoint_object(
 add_entrypoint_object(
   wcsxfrm
   SRCS
-    wcsxfrm.cpp
+  wcsxfrm.cpp
   HDRS
-    wcsxfrm.h
+  wcsxfrm.h
   DEPENDS
     libc.hdr.types.size_t
     libc.hdr.types.wchar_t
     libc.src.__support.macros.config
     libc.src.__support.common
 )
+
+add_entrypoint_object(
+  fwide
+  SRCS
+    fwide.cpp
+  HDRS
+    fwide.h
+  DEPENDS
+    libc.hdr.types.FILE
+    libc.src.__support.File.file
+    libc.src.__support.macros.null_check
+)
+
+add_entrypoint_object(
+  fputwc
+  SRCS
+    fputwc.cpp
+  HDRS
+    fputwc.h
+  DEPENDS
+    libc.hdr.types.FILE
+    libc.hdr.types.wint_t
+    libc.hdr.types.wchar_t
+    libc.hdr.wchar_macros
+    libc.src.__support.File.file
+    libc.src.__support.libc_errno
+    libc.src.__support.macros.null_check
+)
+
+add_entrypoint_object(
+  fgetwc
+  SRCS
+    fgetwc.cpp
+  HDRS
+    fgetwc.h
+  DEPENDS
+    libc.hdr.types.FILE
+    libc.hdr.types.wint_t
+    libc.hdr.types.wchar_t
+    libc.src.__support.File.file
+    libc.src.__support.libc_errno
+    libc.src.__support.macros.null_check
+)
+
+add_entrypoint_object(
+  fputws
+  SRCS
+    fputws.cpp
+  HDRS
+    fputws.h
+  DEPENDS
+    libc.hdr.types.FILE
+    libc.hdr.types.wchar_t
+    libc.src.__support.File.file
+    libc.src.__support.libc_errno
+    libc.src.string.string_utils
+    libc.src.__support.macros.null_check
+)
+
+add_entrypoint_object(
+  fgetws
+  SRCS
+    fgetws.cpp
+  HDRS
+    fgetws.h
+  DEPENDS
+    libc.hdr.types.FILE
+    libc.hdr.types.wchar_t
+    libc.src.__support.File.file
+    libc.src.__support.libc_errno
+    libc.src.__support.macros.null_check
+)
+
+add_entrypoint_object(
+  ungetwc
+  SRCS
+    ungetwc.cpp
+  HDRS
+    ungetwc.h
+  DEPENDS
+    libc.hdr.types.FILE
+    libc.hdr.types.wint_t
+    libc.src.__support.File.file
+    libc.src.__support.macros.null_check
+)
+
+add_entrypoint_object(
+  getwc
+  SRCS
+    getwc.cpp
+  HDRS
+    getwc.h
+  DEPENDS
+    libc.hdr.types.FILE
+    libc.hdr.types.wint_t
+    libc.src.__support.File.file
+    libc.src.__support.libc_errno
+    libc.src.__support.macros.null_check
+)
+
+add_entrypoint_object(
+  getwchar
+  SRCS
+    getwchar.cpp
+  HDRS
+    getwchar.h
+  DEPENDS
+    libc.src.stdio.stdin
+    libc.src.__support.File.file
+    libc.src.__support.libc_errno
+)
+
+add_entrypoint_object(
+  putwc
+  SRCS
+    putwc.cpp
+  HDRS
+    putwc.h
+  DEPENDS
+    libc.hdr.types.FILE
+    libc.hdr.types.wint_t
+    libc.src.__support.File.file
+    libc.src.__support.libc_errno
+    libc.src.__support.macros.null_check
+)
+
+add_entrypoint_object(
+  putwchar
+  SRCS
+    putwchar.cpp
+  HDRS
+    putwchar.h
+  DEPENDS
+    libc.src.stdio.stdout
+    libc.src.__support.File.file
+    libc.src.__support.libc_errno
+)
+
+
+
+
+
+
+
+
+
+
diff --git a/libc/test/src/wchar/CMakeLists.txt b/libc/test/src/wchar/CMakeLists.txt
index 3fd279f19c755..42b12c21b711c 100644
--- a/libc/test/src/wchar/CMakeLists.txt
+++ b/libc/test/src/wchar/CMakeLists.txt
@@ -537,3 +537,191 @@ add_libc_unittest(
   DEPENDS
     libc.src.wchar.wcsxfrm
 )
+
+add_libc_test(
+  fwide_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    fwide_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.wchar.fwide
+)
+
+add_libc_test(
+  fputwc_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    fputwc_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fread
+    libc.src.stdio.fwrite
+    libc.src.stdio.ferror
+    libc.src.wchar.fputwc
+    libc.src.wchar.fwide
+    libc.test.UnitTest.ErrnoCheckingTest
+)
+
+add_libc_test(
+  fgetwc_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    fgetwc_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.feof
+    libc.src.stdio.ferror
+    libc.src.stdio.fwrite
+    libc.src.wchar.fgetwc
+    libc.src.wchar.fwide
+    libc.test.UnitTest.ErrnoCheckingTest
+)
+
+add_libc_test(
+  fputws_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    fputws_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fread
+    libc.src.stdio.ferror
+    libc.src.wchar.fputws
+    libc.src.wchar.fwide
+    libc.test.UnitTest.ErrnoCheckingTest
+)
+
+add_libc_test(
+  fgetws_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    fgetws_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fwrite
+    libc.src.stdio.ferror
+    libc.src.wchar.fgetws
+    libc.src.wchar.fwide
+    libc.src.wchar.wcscmp
+    libc.test.UnitTest.ErrnoCheckingTest
+)
+
+add_libc_test(
+  ungetwc_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    ungetwc_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fwrite
+    libc.src.stdio.feof
+    libc.src.stdio.ferror
+    libc.src.stdio.fseek
+    libc.src.wchar.fgetwc
+    libc.src.wchar.fwide
+    libc.src.wchar.ungetwc
+)
+
+add_libc_test(
+  getwc_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    getwc_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fwrite
+    libc.src.stdio.feof
+    libc.src.stdio.ferror
+    libc.src.wchar.getwc
+    libc.src.wchar.fwide
+    libc.test.UnitTest.ErrnoCheckingTest
+)
+
+add_libc_test(
+  getwchar_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    getwchar_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fwrite
+    libc.src.stdio.feof
+    libc.src.stdio.ferror
+    libc.src.stdio.stdin
+    libc.src.wchar.getwchar
+    libc.src.wchar.fwide
+    libc.src.wchar.ungetwc
+    libc.test.UnitTest.ErrnoCheckingTest
+)
+
+add_libc_test(
+  putwc_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    putwc_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fread
+    libc.src.stdio.ferror
+    libc.src.wchar.putwc
+    libc.src.wchar.fwide
+    libc.test.UnitTest.ErrnoCheckingTest
+)
+
+add_libc_test(
+  putwchar_test
+  SUITE
+    libc_wchar_unittests
+  SRCS
+    putwchar_test.cpp
+  DEPENDS
+    libc.include.stdio
+    libc.src.stdio.fopen
+    libc.src.stdio.fclose
+    libc.src.stdio.fread
+    libc.src.stdio.ferror
+    libc.src.stdio.stdout
+    libc.src.wchar.putwchar
+    libc.src.wchar.fwide
+    libc.test.UnitTest.ErrnoCheckingTest
+)
+
+
+
+
+
+
+
+
+
+
+
+



More information about the libc-commits mailing list