Skip to content

Commit 8fce476

Browse files
perry-cazibi2
andauthored
Implement a more seamless way to provide missing functions on z/OS (#167703)
In this PR I'm changing the way we provide the missing functions like strnlen() on z/OS from the separate header file to a wrapper around the system headers that declare these functions. This will be less intrusive. --------- Co-authored-by: Zibi Sarbinowski <zibi@ca.ibm.com>
1 parent 507f236 commit 8fce476

File tree

17 files changed

+126
-62
lines changed

17 files changed

+126
-62
lines changed

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "clang/AST/ASTLambda.h"
2222
#include "clang/AST/Expr.h"
2323
#include "clang/Basic/TargetInfo.h"
24-
#include "llvm/Support/SystemZ/zOSSupport.h"
2524

2625
using namespace clang;
2726
using namespace clang::interp;

llvm/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,11 @@ if(LLVM_TARGET_IS_CROSSCOMPILE_HOST)
12941294
# (this is a variable that CrossCompile sets on recursive invocations)
12951295
endif()
12961296

1297+
# Special hack for z/OS for missing POSIX functions
1298+
if (CMAKE_SYSTEM_NAME MATCHES "OS390")
1299+
include_directories(SYSTEM "${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/SystemZ/zos_wrappers" )
1300+
endif()
1301+
12971302
if( "${CMAKE_SYSTEM_NAME}" MATCHES SunOS )
12981303
# special hack for Solaris to handle crazy system sys/regset.h
12991304
include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")

llvm/include/llvm/Support/SystemZ/zOSSupport.h

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===- string.h - Common z/OS Include File ----------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file declares z/OS implementations for common functions.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_SUPPORT_ZOSWRAPPERS_STRING_H
14+
#define LLVM_SUPPORT_ZOSWRAPPERS_STRING_H
15+
16+
#include_next <string.h>
17+
18+
#ifdef __cplusplus
19+
extern "C" {
20+
#endif
21+
22+
// z/OS Unix System Services does not have support for:
23+
// - strsignal()
24+
// - strnlen()
25+
// Implementations are provided for z/OS.
26+
27+
char *strsignal(int sig) asm("llvm_zos_strsignal");
28+
29+
size_t strnlen(const char *S, size_t MaxLen) asm("llvm_zos_strnlen");
30+
31+
#ifdef __cplusplus
32+
}
33+
#endif
34+
35+
#endif

llvm/lib/ObjCopy/MachO/MachOLayoutBuilder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "llvm/Support/Alignment.h"
1111
#include "llvm/Support/Errc.h"
1212
#include "llvm/Support/ErrorHandling.h"
13-
#include "llvm/Support/SystemZ/zOSSupport.h"
1413

1514
using namespace llvm;
1615
using namespace llvm::objcopy::macho;

llvm/lib/ObjCopy/MachO/MachOObject.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "MachOObject.h"
1010
#include "llvm/ADT/SmallPtrSet.h"
11-
#include "llvm/Support/SystemZ/zOSSupport.h"
1211

1312
using namespace llvm;
1413
using namespace llvm::objcopy::macho;

llvm/lib/ObjCopy/MachO/MachOReader.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "MachOObject.h"
1111
#include "llvm/BinaryFormat/MachO.h"
1212
#include "llvm/Object/MachO.h"
13-
#include "llvm/Support/SystemZ/zOSSupport.h"
1413
#include <memory>
1514

1615
using namespace llvm;

llvm/lib/ObjectYAML/MachOEmitter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "llvm/Support/Error.h"
2020
#include "llvm/Support/FormatVariadic.h"
2121
#include "llvm/Support/LEB128.h"
22-
#include "llvm/Support/SystemZ/zOSSupport.h"
2322
#include "llvm/Support/WithColor.h"
2423
#include "llvm/Support/YAMLTraits.h"
2524
#include "llvm/Support/raw_ostream.h"

llvm/lib/ObjectYAML/MachOYAML.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "llvm/BinaryFormat/MachO.h"
1616
#include "llvm/Support/YAMLTraits.h"
1717
#include "llvm/Support/raw_ostream.h"
18-
#include "llvm/Support/SystemZ/zOSSupport.h"
1918
#include "llvm/TargetParser/Host.h"
2019
#include <cstdint>
2120
#include <cstring>

llvm/lib/Support/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ add_llvm_component_library(LLVMSupport
311311
Threading.cpp
312312
Valgrind.cpp
313313
Watchdog.cpp
314+
zOSLibFunctions.cpp
314315

315316
ADDITIONAL_HEADER_DIRS
316317
Unix

0 commit comments

Comments
 (0)