Skip to content

[SystemZ][z/OS] Add missing strnlen function for z/OS to fix build failures #75339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions clang/lib/Lex/HeaderMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
//===----------------------------------------------------------------------===//

#include "clang/Lex/HeaderMap.h"
#include "clang/Lex/HeaderMapTypes.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/FileManager.h"
#include "clang/Lex/HeaderMapTypes.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include <cstring>
#include <memory>
#include <optional>
Expand Down
8 changes: 8 additions & 0 deletions llvm/include/llvm/Support/SystemZ/zOSSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,13 @@ inline pid_t wait4(pid_t pid, int *wstatus, int options,
return Result;
}

// z/OS Unix System Services does not have strnlen() support, so the strnlen()
// function is implemented here.
inline std::size_t strnlen(const char *S, std::size_t MaxLen) {
const char *PtrToNullChar =
static_cast<const char *>(std::memchr(S, '\0', MaxLen));
return PtrToNullChar ? PtrToNullChar - S : MaxLen;
}

#endif
#endif
1 change: 1 addition & 0 deletions llvm/lib/ObjCopy/MachO/MachOLayoutBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/SystemZ/zOSSupport.h"

using namespace llvm;
using namespace llvm::objcopy::macho;
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/ObjCopy/MachO/MachOObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "MachOObject.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include <unordered_set>

using namespace llvm;
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/ObjCopy/MachO/MachOReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Object/MachO.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include <memory>

using namespace llvm;
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/ObjectYAML/MachOEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"

Expand Down
1 change: 1 addition & 0 deletions llvm/lib/ObjectYAML/MachOYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
Expand Down
1 change: 1 addition & 0 deletions llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/SystemZ/zOSSupport.h"

#ifdef __linux__
#ifdef HAVE_LIBPFM
Expand Down
1 change: 1 addition & 0 deletions llvm/tools/llvm-exegesis/lib/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Error.h"

#ifdef LLVM_ON_UNIX
#include "llvm/Support/SystemZ/zOSSupport.h"
#include <string.h>
#endif // LLVM_ON_UNIX

Expand Down
1 change: 1 addition & 0 deletions llvm/tools/llvm-readobj/ELFDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "llvm/Support/RISCVAttributeParser.h"
#include "llvm/Support/RISCVAttributes.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cinttypes>
Expand Down
1 change: 1 addition & 0 deletions llvm/tools/llvm-readobj/ObjDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include "llvm/Support/raw_ostream.h"
#include <map>

Expand Down
1 change: 1 addition & 0 deletions llvm/tools/obj2yaml/macho2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/SystemZ/zOSSupport.h"

#include <string.h> // for memcpy

Expand Down