brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 755b44f Raw
83 lines · cpp
1//===-- zOSLibFunctions.cpp -----------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9//===----------------------------------------------------------------------===//10//11// This file defines z/OS implementations for common functions.12//13//===----------------------------------------------------------------------===//14 15#ifdef __MVS__16#include <stdio.h>17#include <string.h>18#include <sys/resource.h>19#include <sys/wait.h>20 21const char *signalName[] = {22    /*  0 */ nullptr,23    /*  1 */ "Hangup",                   // SIGHUP24    /*  2 */ "Interrupt",                // SIGINT25    /*  3 */ "Aborted",                  // SIGABRT26    /*  4 */ "Illegal instruction",      // SIGILL27    /*  5 */ "Polling event",            // SIGPOLL28    /*  6 */ "Socket data available",    // SIGURG29    /*  7 */ "Stopped (signal)",         // SIGSTOP30    /*  8 */ "Floating point exception", // SIGFPE31    /*  9 */ "Killed",                   // SIGKILL32    /* 10 */ "Bus error",                // SIGBUS33    /* 11 */ "Segmentation fault",       // SIGSEGV34    /* 12 */ "Bad system call",          // SIGSYS35    /* 13 */ "Broken pipe",              // SIGPIPE36    /* 14 */ "Alarm clock",              // SIGALRM37    /* 15 */ "Terminated",               // SIGTERM38    /* 16 */ "User defined signal 1",    // SIGUSR139    /* 17 */ "User defined signal 2",    // SIGUSR240    /* 18 */ "Abend",                    // SIGABND41    /* 19 */ "Continued",                // SIGCONT42    /* 20 */ "Child exited",             // SIGCHLD43    /* 21 */ "Stopped (tty input)",      // SIGTTIN44    /* 22 */ "Stopped (tty output)",     // SIGTTOU45    /* 23 */ "I/O complete",             // SIGIO46    /* 24 */ "Quit",                     // SIGQUIT47    /* 25 */ "Stopped",                  // SIGTSTP48    /* 26 */ "Trace/breakpoint trap",    // SIGTRAP49    /* 27 */ "I/O error",                // SIGIOERR50    /* 28 */ "Window changed",           // SIGWINCH51    /* 29 */ "CPU time limit exceeded",  // SIGXCPU52    /* 30 */ "File size limit exceeded", // SIGXFSZ53    /* 31 */ "Virtual timer expired",    // SIGVTALRM54    /* 32 */ "Profiling timer expired",  // SIGPROF55    /* 33 */ "OMVS subsystem shutdown",  // SIGDANGER56    /* 34 */ "Thread stop",              // SIGTHSTOP57    /* 35 */ "Thread resume",            // SIGTHCONT58    /* 36 */ nullptr,                    // n/a59    /* 37 */ "Toggle syscall trace",     // SIGTRACE60    /* 38 */ nullptr,                    // SIGDCE61    /* 39 */ "System dump",              // SIGDUMP62};63 64// z/OS Unix System Services does not have strsignal() support, so the65// strsignal() function is implemented here.66char *strsignal(int sig) {67  if (static_cast<size_t>(sig) < (sizeof(signalName) / sizeof(signalName[0])) &&68      signalName[sig])69    return const_cast<char *>(signalName[sig]);70  static char msg[256];71  sprintf(msg, "Unknown signal %d", sig);72  return msg;73}74 75// z/OS Unix System Services does not have strnlen() support, so the strnlen()76// function is implemented here.77size_t strnlen(const char *S, size_t MaxLen) {78  const char *PtrToNullChar =79      static_cast<const char *>(memchr(S, '\0', MaxLen));80  return PtrToNullChar ? PtrToNullChar - S : MaxLen;81}82#endif83