-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Implement a more seamless way to provide missing functions on z/OS #167703
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
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6db3e61
Use wrapper to get for strnlen/strsignal
perry-ca 2afefdc
Add names for signals
perry-ca bb5329d
build on z/OS
perry-ca 14a2af3
clean up make file & source
perry-ca be245cf
fix formatting
perry-ca 625d015
Update llvm/include/llvm/Support/SystemZ/zos_wrappers/string.h
perry-ca 9c11acd
Merge branch 'main' into perry/zos-strnlen
perry-ca bfa2faa
Merge branch 'main' into perry/zos-strnlen
perry-ca b0a9778
Merge branch 'main' into perry/zos-strnlen
perry-ca 901c4c1
Merge branch 'main' into perry/zos-strnlen
perry-ca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| //===- string.h - Common z/OS Include File ----------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file declares z/OS implementations for common functions. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_SUPPORT_ZOSWRAPPER_STRING_H | ||
| #define LLVM_SUPPORT_ZOSWRAPPER_STRING_H | ||
perry-ca marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #include_next <string.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| // z/OS Unix System Services does not have support for: | ||
| // - strsignal() | ||
| // - strnlen() | ||
| // Implementations are provided for z/OS. | ||
|
|
||
| char *strsignal(int sig) asm("llvm_zos_strsignal"); | ||
boomanaiden154 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| size_t strnlen(const char *S, size_t MaxLen) asm("llvm_zos_strnlen"); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| //===-- zOSLibFunctions.cpp -----------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines z/OS implementations for common functions. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifdef __MVS__ | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <sys/resource.h> | ||
| #include <sys/wait.h> | ||
tltao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const char *signalName[] = { | ||
tltao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /* 0 */ nullptr, | ||
| /* 1 */ "Hangup", // SIGHUP | ||
| /* 2 */ "Interrupt", // SIGINT | ||
| /* 3 */ "Aborted", // SIGABRT | ||
| /* 4 */ "Illegal instruction", // SIGILL | ||
| /* 5 */ "Polling event", // SIGPOLL | ||
| /* 6 */ "Socket data available", // SIGURG | ||
| /* 7 */ "Stopped (signal)", // SIGSTOP | ||
| /* 8 */ "Floating point exception", // SIGFPE | ||
| /* 9 */ "Killed", // SIGKILL | ||
| /* 10 */ "Bus error", // SIGBUS | ||
| /* 11 */ "Segmentation fault", // SIGSEGV | ||
| /* 12 */ "Bad system call", // SIGSYS | ||
| /* 13 */ "Broken pipe", // SIGPIPE | ||
| /* 14 */ "Alarm clock", // SIGALRM | ||
| /* 15 */ "Terminated", // SIGTERM | ||
| /* 16 */ "User defined signal 1", // SIGUSR1 | ||
| /* 17 */ "User defined signal 2", // SIGUSR2 | ||
| /* 18 */ "Abend", // SIGABND | ||
| /* 19 */ "Continued", // SIGCONT | ||
| /* 20 */ "Child exited", // SIGCHLD | ||
| /* 21 */ "Stopped (tty input)", // SIGTTIN | ||
| /* 22 */ "Stopped (tty output)", // SIGTTOU | ||
| /* 23 */ "I/O complete", // SIGIO | ||
| /* 24 */ "Quit", // SIGQUIT | ||
| /* 25 */ "Stopped", // SIGTSTP | ||
| /* 26 */ "Trace/breakpoint trap", // SIGTRAP | ||
| /* 27 */ "I/O error", // SIGIOERR | ||
| /* 28 */ "Window changed", // SIGWINCH | ||
| /* 29 */ "CPU time limit exceeded", // SIGXCPU | ||
| /* 30 */ "File size limit exceeded", // SIGXFSZ | ||
| /* 31 */ "Virtual timer expired", // SIGVTALRM | ||
| /* 32 */ "Profiling timer expired", // SIGPROF | ||
| /* 33 */ "OMVS subsystem shutdown", // SIGDANGER | ||
| /* 34 */ "Thread stop", // SIGTHSTOP | ||
| /* 35 */ "Thread resume", // SIGTHCONT | ||
| /* 36 */ nullptr, // n/a | ||
| /* 37 */ "Toggle syscall trace", // SIGTRACE | ||
| /* 38 */ nullptr, // SIGDCE | ||
| /* 39 */ "System dump", // SIGDUMP | ||
| }; | ||
|
|
||
| // z/OS Unix System Services does not have strsignal() support, so the | ||
| // strsignal() function is implemented here. | ||
| char *strsignal(int sig) { | ||
| if (static_cast<size_t>(sig) < (sizeof(signalName) / sizeof(signalName[0])) && | ||
| signalName[sig]) | ||
| return const_cast<char *>(signalName[sig]); | ||
| static char msg[256]; | ||
| sprintf(msg, "Unknown signal %d", sig); | ||
| return msg; | ||
| } | ||
|
|
||
| // z/OS Unix System Services does not have strnlen() support, so the strnlen() | ||
| // function is implemented here. | ||
| size_t strnlen(const char *S, size_t MaxLen) { | ||
| const char *PtrToNullChar = | ||
| static_cast<const char *>(memchr(S, '\0', MaxLen)); | ||
| return PtrToNullChar ? PtrToNullChar - S : MaxLen; | ||
| } | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.