[clang] [llvm] [NFC][SystemZ][z/OS] Rename autoconversion-related functions to be less generic (PR #107399)
Abhina Sree via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 5 06:17:21 PDT 2024
https://github.com/abhina-sree created https://github.com/llvm/llvm-project/pull/107399
This patch renames the functions in AutoConvert.h/cpp to have a less generic name because they are z/OS specific.
>From 34e044dc5677b345570a202dd0542440a7eee8d9 Mon Sep 17 00:00:00 2001
From: Abhina Sreeskantharajan <Abhina.Sreeskantharajan at ibm.com>
Date: Thu, 5 Sep 2024 09:16:11 -0400
Subject: [PATCH] [NFC][SystemZ][z/OS] Rename autoconversion-related functions
to be less generic
---
clang/tools/c-arcmt-test/c-arcmt-test.c | 4 ++--
clang/tools/c-index-test/c-index-test.c | 4 ++--
llvm/include/llvm/Support/AutoConvert.h | 14 +++++++-------
llvm/lib/Support/AutoConvert.cpp | 20 ++++++++++----------
llvm/lib/Support/InitLLVM.cpp | 10 +++++-----
llvm/lib/Support/MemoryBuffer.cpp | 2 +-
llvm/lib/Support/Unix/Path.inc | 8 ++++----
llvm/lib/Support/Unix/Program.inc | 2 +-
llvm/lib/Support/raw_ostream.cpp | 4 ++--
llvm/utils/count/count.c | 4 ++--
10 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/clang/tools/c-arcmt-test/c-arcmt-test.c b/clang/tools/c-arcmt-test/c-arcmt-test.c
index 00999f188c7dce..4d0c418714b950 100644
--- a/clang/tools/c-arcmt-test/c-arcmt-test.c
+++ b/clang/tools/c-arcmt-test/c-arcmt-test.c
@@ -109,10 +109,10 @@ static void flush_atexit(void) {
int main(int argc, const char **argv) {
#ifdef __MVS__
- if (enableAutoConversion(fileno(stdout)) == -1)
+ if (enablezOSAutoConversion(fileno(stdout)) == -1)
fprintf(stderr, "Setting conversion on stdout failed\n");
- if (enableAutoConversion(fileno(stderr)) == -1)
+ if (enablezOSAutoConversion(fileno(stderr)) == -1)
fprintf(stderr, "Setting conversion on stderr failed\n");
#endif
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index f472a67f3bc5b7..b48f44950ab754 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -5180,10 +5180,10 @@ int main(int argc, const char **argv) {
thread_info client_data;
#ifdef __MVS__
- if (enableAutoConversion(fileno(stdout)) == -1)
+ if (enablezOSAutoConversion(fileno(stdout)) == -1)
fprintf(stderr, "Setting conversion on stdout failed\n");
- if (enableAutoConversion(fileno(stderr)) == -1)
+ if (enablezOSAutoConversion(fileno(stderr)) == -1)
fprintf(stderr, "Setting conversion on stderr failed\n");
#endif
diff --git a/llvm/include/llvm/Support/AutoConvert.h b/llvm/include/llvm/Support/AutoConvert.h
index f4fe80b22a8760..6f45c4683f7775 100644
--- a/llvm/include/llvm/Support/AutoConvert.h
+++ b/llvm/include/llvm/Support/AutoConvert.h
@@ -27,9 +27,9 @@
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
-int enableAutoConversion(int FD);
-int disableAutoConversion(int FD);
-int restoreStdHandleAutoConversion(int FD);
+int enablezOSAutoConversion(int FD);
+int disablezOSAutoConversion(int FD);
+int restorezOSStdHandleAutoConversion(int FD);
#ifdef __cplusplus
}
#endif // __cplusplus
@@ -39,18 +39,18 @@ namespace llvm {
/// \brief Disable the z/OS enhanced ASCII auto-conversion for the file
/// descriptor.
-std::error_code disableAutoConversion(int FD);
+std::error_code disablezOSAutoConversion(int FD);
/// \brief Query the z/OS enhanced ASCII auto-conversion status of a file
/// descriptor and force the conversion if the file is not tagged with a
/// codepage.
-std::error_code enableAutoConversion(int FD);
+std::error_code enablezOSAutoConversion(int FD);
/// Restore the z/OS enhanced ASCII auto-conversion for the std handle.
-std::error_code restoreStdHandleAutoConversion(int FD);
+std::error_code restorezOSStdHandleAutoConversion(int FD);
/// \brief Set the tag information for a file descriptor.
-std::error_code setFileTag(int FD, int CCSID, bool Text);
+std::error_code setzOSFileTag(int FD, int CCSID, bool Text);
} // namespace llvm
#endif // __cplusplus
diff --git a/llvm/lib/Support/AutoConvert.cpp b/llvm/lib/Support/AutoConvert.cpp
index c509284ee916ef..66570735f8fc88 100644
--- a/llvm/lib/Support/AutoConvert.cpp
+++ b/llvm/lib/Support/AutoConvert.cpp
@@ -22,7 +22,7 @@
static int savedStdHandleAutoConversionMode[3] = {-1, -1, -1};
-int disableAutoConversion(int FD) {
+int disablezOSAutoConversion(int FD) {
static const struct f_cnvrt Convert = {
SETCVTOFF, // cvtcmd
0, // pccsid
@@ -32,7 +32,7 @@ int disableAutoConversion(int FD) {
return fcntl(FD, F_CONTROL_CVT, &Convert);
}
-int restoreStdHandleAutoConversion(int FD) {
+int restorezOSStdHandleAutoConversion(int FD) {
assert(FD == STDIN_FILENO || FD == STDOUT_FILENO || FD == STDERR_FILENO);
if (savedStdHandleAutoConversionMode[FD] == -1)
return 0;
@@ -44,7 +44,7 @@ int restoreStdHandleAutoConversion(int FD) {
return (fcntl(FD, F_CONTROL_CVT, &Cvt));
}
-int enableAutoConversion(int FD) {
+int enablezOSAutoConversion(int FD) {
struct f_cnvrt Query = {
QUERYCVT, // cvtcmd
0, // pccsid
@@ -81,28 +81,28 @@ int enableAutoConversion(int FD) {
return fcntl(FD, F_CONTROL_CVT, &Query);
}
-std::error_code llvm::disableAutoConversion(int FD) {
- if (::disableAutoConversion(FD) == -1)
+std::error_code llvm::disablezOSAutoConversion(int FD) {
+ if (::disablezOSAutoConversion(FD) == -1)
return errnoAsErrorCode();
return std::error_code();
}
-std::error_code llvm::enableAutoConversion(int FD) {
- if (::enableAutoConversion(FD) == -1)
+std::error_code llvm::enablezOSAutoConversion(int FD) {
+ if (::enablezOSAutoConversion(FD) == -1)
return errnoAsErrorCode();
return std::error_code();
}
-std::error_code llvm::restoreStdHandleAutoConversion(int FD) {
- if (::restoreStdHandleAutoConversion(FD) == -1)
+std::error_code llvm::restorezOSStdHandleAutoConversion(int FD) {
+ if (::restorezOSStdHandleAutoConversion(FD) == -1)
return errnoAsErrorCode();
return std::error_code();
}
-std::error_code llvm::setFileTag(int FD, int CCSID, bool Text) {
+std::error_code llvm::setzOSFileTag(int FD, int CCSID, bool Text) {
assert((!Text || (CCSID != FT_UNTAGGED && CCSID != FT_BINARY)) &&
"FT_UNTAGGED and FT_BINARY are not allowed for text files");
struct file_tag Tag;
diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp
index b7e463a19122db..2b3ddd39b08791 100644
--- a/llvm/lib/Support/InitLLVM.cpp
+++ b/llvm/lib/Support/InitLLVM.cpp
@@ -27,9 +27,9 @@ void CleanupStdHandles(void *Cookie) {
llvm::raw_ostream *Outs = &llvm::outs(), *Errs = &llvm::errs();
Outs->flush();
Errs->flush();
- llvm::restoreStdHandleAutoConversion(STDIN_FILENO);
- llvm::restoreStdHandleAutoConversion(STDOUT_FILENO);
- llvm::restoreStdHandleAutoConversion(STDERR_FILENO);
+ llvm::restorezOSStdHandleAutoConversion(STDIN_FILENO);
+ llvm::restorezOSStdHandleAutoConversion(STDOUT_FILENO);
+ llvm::restorezOSStdHandleAutoConversion(STDERR_FILENO);
}
#endif
@@ -70,8 +70,8 @@ InitLLVM::InitLLVM(int &Argc, const char **&Argv,
// If turning on conversion for stderr fails then the error message
// may be garbled. There is no solution to this problem.
- ExitOnErr(errorCodeToError(llvm::enableAutoConversion(STDERR_FILENO)));
- ExitOnErr(errorCodeToError(llvm::enableAutoConversion(STDOUT_FILENO)));
+ ExitOnErr(errorCodeToError(llvm::enablezOSAutoConversion(STDERR_FILENO)));
+ ExitOnErr(errorCodeToError(llvm::enablezOSAutoConversion(STDOUT_FILENO)));
#endif
#ifdef _WIN32
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp
index fb7e804fd7e843..aea81964ba9fde 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -505,7 +505,7 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize,
#ifdef __MVS__
// Set codepage auto-conversion for z/OS.
- if (auto EC = llvm::enableAutoConversion(FD))
+ if (auto EC = llvm::enablezOSAutoConversion(FD))
return EC;
#endif
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index cf05db546e0214..8098392a7fd906 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -1096,17 +1096,17 @@ std::error_code openFile(const Twine &Name, int &ResultFD,
!Stat.st_tag.ft_txtflag && !Stat.st_tag.ft_ccsid &&
Stat.st_size == 0;
if (Flags & OF_Text) {
- if (auto EC = llvm::enableAutoConversion(ResultFD))
+ if (auto EC = llvm::enablezOSAutoConversion(ResultFD))
return EC;
if (DoSetTag) {
- if (auto EC = llvm::setFileTag(ResultFD, CCSID_IBM_1047, true))
+ if (auto EC = llvm::setzOSFileTag(ResultFD, CCSID_IBM_1047, true))
return EC;
}
} else {
- if (auto EC = llvm::disableAutoConversion(ResultFD))
+ if (auto EC = llvm::disablezOSAutoConversion(ResultFD))
return EC;
if (DoSetTag) {
- if (auto EC = llvm::setFileTag(ResultFD, FT_BINARY, false))
+ if (auto EC = llvm::setzOSFileTag(ResultFD, FT_BINARY, false))
return EC;
}
}
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 2742734bb11ed0..ec0fad7076b450 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -533,7 +533,7 @@ std::error_code llvm::sys::ChangeStdoutMode(fs::OpenFlags Flags) {
std::error_code llvm::sys::ChangeStdinToBinary() {
#ifdef __MVS__
- return disableAutoConversion(STDIN_FILENO);
+ return disablezOSAutoConversion(STDIN_FILENO);
#else
// Do nothing, as Unix doesn't differentiate between text and binary.
return std::error_code();
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 2ce54faa9857e6..48f04091e9e39b 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -894,7 +894,7 @@ raw_fd_ostream &llvm::outs() {
// Set buffer settings to model stdout behavior.
std::error_code EC;
#ifdef __MVS__
- EC = enableAutoConversion(STDOUT_FILENO);
+ EC = enablezOSAutoConversion(STDOUT_FILENO);
assert(!EC);
#endif
static raw_fd_ostream S("-", EC, sys::fs::OF_None);
@@ -905,7 +905,7 @@ raw_fd_ostream &llvm::outs() {
raw_fd_ostream &llvm::errs() {
// Set standard error to be unbuffered.
#ifdef __MVS__
- std::error_code EC = enableAutoConversion(STDERR_FILENO);
+ std::error_code EC = enablezOSAutoConversion(STDERR_FILENO);
assert(!EC);
#endif
static raw_fd_ostream S(STDERR_FILENO, false, true);
diff --git a/llvm/utils/count/count.c b/llvm/utils/count/count.c
index 300be2aa8a18e2..9166145fcc10a0 100644
--- a/llvm/utils/count/count.c
+++ b/llvm/utils/count/count.c
@@ -12,10 +12,10 @@
int main(int argc, char **argv) {
#ifdef __MVS__
- if (enableAutoConversion(fileno(stdin)) == -1)
+ if (enablezOSAutoConversion(fileno(stdin)) == -1)
fprintf(stderr, "Setting conversion on stdin failed\n");
- if (enableAutoConversion(fileno(stderr)) == -1)
+ if (enablezOSAutoConversion(fileno(stderr)) == -1)
fprintf(stdout, "Setting conversion on stderr failed\n");
#endif
size_t Count, NumLines, NumRead;
More information about the cfe-commits
mailing list