Skip to content

Commit be9994b

Browse files
authored
[SystemZ][z/OS] Refactor AutoConvert more (#143955)
This patch removes the C++ disablezOSAutoConversion,enablezOSAutoConversion declarations and also updates Path.inc to use the common function.
1 parent a5cbd2a commit be9994b

File tree

4 files changed

+19
-33
lines changed

4 files changed

+19
-33
lines changed

llvm/include/llvm/Support/AutoConvert.h

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <_Ccsid.h>
1919
#endif
2020
#ifdef __cplusplus
21-
#include "llvm/Support/ErrorOr.h"
21+
#include "llvm/Support/Error.h"
2222
#include <system_error>
2323
#endif /* __cplusplus */
2424

@@ -41,6 +41,21 @@ int restorezOSStdHandleAutoConversion(int FD);
4141
#ifdef __cplusplus
4242
namespace llvm {
4343

44+
#ifdef __MVS__
45+
46+
/** \brief Set the tag information for a file descriptor. */
47+
std::error_code setzOSFileTag(int FD, int CCSID, bool Text);
48+
49+
/** \brief Get the the tag ccsid for a file name or a file descriptor. */
50+
ErrorOr<__ccsid_t> getzOSFileTag(const char *FileName, const int FD = -1);
51+
52+
/** \brief Query the file tag to determine if it needs conversion to UTF-8
53+
* codepage.
54+
*/
55+
ErrorOr<bool> needzOSConversion(const char *FileName, const int FD = -1);
56+
57+
#endif /* __MVS__*/
58+
4459
inline std::error_code disableAutoConversion(int FD) {
4560
#ifdef __MVS__
4661
if (::disablezOSAutoConversion(FD) == -1)
@@ -79,34 +94,6 @@ inline ErrorOr<bool> needConversion(const char *FileName, const int FD = -1) {
7994
return false;
8095
}
8196

82-
#ifdef __MVS__
83-
84-
/** \brief Disable the z/OS enhanced ASCII auto-conversion for the file
85-
* descriptor.
86-
*/
87-
std::error_code disablezOSAutoConversion(int FD);
88-
89-
/** \brief Query the z/OS enhanced ASCII auto-conversion status of a file
90-
* descriptor and force the conversion if the file is not tagged with a
91-
* codepage.
92-
*/
93-
std::error_code enablezOSAutoConversion(int FD);
94-
95-
/** Restore the z/OS enhanced ASCII auto-conversion for the std handle. */
96-
std::error_code restorezOSStdHandleAutoConversion(int FD);
97-
98-
/** \brief Set the tag information for a file descriptor. */
99-
std::error_code setzOSFileTag(int FD, int CCSID, bool Text);
100-
101-
/** \brief Get the the tag ccsid for a file name or a file descriptor. */
102-
ErrorOr<__ccsid_t> getzOSFileTag(const char *FileName, const int FD = -1);
103-
104-
/** \brief Query the file tag to determine if it needs conversion to UTF-8
105-
* codepage.
106-
*/
107-
ErrorOr<bool> needzOSConversion(const char *FileName, const int FD = -1);
108-
109-
#endif /* __MVS__*/
11097
} /* namespace llvm */
11198
#endif /* __cplusplus */
11299

llvm/lib/Support/AutoConvert.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#ifdef __MVS__
1515

1616
#include "llvm/Support/AutoConvert.h"
17-
#include "llvm/Support/Error.h"
1817
#include <cassert>
1918
#include <fcntl.h>
2019
#include <sys/stat.h>

llvm/lib/Support/Unix/Path.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,14 +1097,14 @@ std::error_code openFile(const Twine &Name, int &ResultFD,
10971097
!Stat.st_tag.ft_txtflag && !Stat.st_tag.ft_ccsid &&
10981098
Stat.st_size == 0;
10991099
if (Flags & OF_Text) {
1100-
if (auto EC = llvm::enablezOSAutoConversion(ResultFD))
1100+
if (auto EC = llvm::enableAutoConversion(ResultFD))
11011101
return EC;
11021102
if (DoSetTag) {
11031103
if (auto EC = llvm::setzOSFileTag(ResultFD, CCSID_IBM_1047, true))
11041104
return EC;
11051105
}
11061106
} else {
1107-
if (auto EC = llvm::disablezOSAutoConversion(ResultFD))
1107+
if (auto EC = llvm::disableAutoConversion(ResultFD))
11081108
return EC;
11091109
if (DoSetTag) {
11101110
if (auto EC = llvm::setzOSFileTag(ResultFD, FT_BINARY, false))

llvm/lib/Support/Unix/Program.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ std::error_code llvm::sys::ChangeStdoutMode(fs::OpenFlags Flags) {
516516

517517
std::error_code llvm::sys::ChangeStdinToBinary() {
518518
#ifdef __MVS__
519-
return disablezOSAutoConversion(STDIN_FILENO);
519+
return disableAutoConversion(STDIN_FILENO);
520520
#else
521521
// Do nothing, as Unix doesn't differentiate between text and binary.
522522
return std::error_code();

0 commit comments

Comments
 (0)