Skip to content
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

Various enhancements for zopen tools #58

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d95312c
zopen enhancements:
IgorTodorovskiIBM Apr 22, 2024
11eeb20
Add missing header netiniet
IgorTodorovskiIBM Jun 25, 2024
ebe82e0
Add support for getline, getdelim, sysconf, memset
IgorTodorovskiIBM Jun 26, 2024
b32dcd4
Add utimesat and PTHREAD_RWLOCK_INITIALIZER
IgorTodorovskiIBM Jun 27, 2024
7d497c6
Add readlink override to resolve PARMLIB variables like
IgorTodorovskiIBM Jul 11, 2024
8253dfe
Fix getdelim and readlink override
IgorTodorovskiIBM Jul 16, 2024
153ef5f
Fix typo
IgorTodorovskiIBM Jul 16, 2024
b7074a5
Fix getdelim again
IgorTodorovskiIBM Jul 16, 2024
b0cd547
Fix missing }
IgorTodorovskiIBM Jul 16, 2024
276feb4
Address comments
IgorTodorovskiIBM Jul 16, 2024
827486b
Address comments
IgorTodorovskiIBM Jul 16, 2024
4145cf9
Add __threading_support - needed for boost and clang 1.1 builds
IgorTodorovskiIBM Jul 19, 2024
040105d
Update memmem
IgorTodorovskiIBM Jul 22, 2024
8c0764d
Add strverscmp from musl c
IgorTodorovskiIBM Jul 23, 2024
504ba77
Fix readlink and mkostemp - after further testing with zopen tools
IgorTodorovskiIBM Jul 24, 2024
5a1b34b
Fix readlink and mkostemp - after further testing with zopen tools
IgorTodorovskiIBM Jul 24, 2024
b36a272
Add code for profiling instrumentation
IgorTodorovskiIBM Aug 19, 2024
325ed89
Fix typos
IgorTodorovskiIBM Aug 19, 2024
6f56563
Fix typos
IgorTodorovskiIBM Aug 20, 2024
63e621e
replace bzero with calloc (#68)
kishkulk Aug 20, 2024
c098335
revise json
IgorTodorovskiIBM Aug 20, 2024
b548649
Fix tid in instrumentation json
IgorTodorovskiIBM Aug 20, 2024
b1ae73f
Update zos-instrumentation.cc
IgorTodorovskiIBM Aug 20, 2024
51f5dd0
Resolve clang related build issues
IgorTodorovskiIBM Aug 21, 2024
d847fc3
Resolve clang related build issues
IgorTodorovskiIBM Aug 21, 2024
b87bc46
Change dsa to __dsa and use traceEvent objects to make ns the default…
IgorTodorovskiIBM Aug 21, 2024
7738105
Gzip the json file once completed
IgorTodorovskiIBM Aug 21, 2024
0756b23
Only activate __get_stack_start on non-quick startup
IgorTodorovskiIBM Aug 28, 2024
5d413b7
Propagate ZOSLIB_QUICK_STARTUP in cmake
IgorTodorovskiIBM Aug 28, 2024
659b1d5
Change the arch level to arch10 for clang (and arch14 only for zos-ge…
IgorTodorovskiIBM Aug 29, 2024
d2aed54
Add tracing for allocation
IgorTodorovskiIBM Sep 19, 2024
3a4cb7f
Add malloc/free overrides
IgorTodorovskiIBM Sep 19, 2024
9a69e8e
Add export to __readlink
IgorTodorovskiIBM Sep 23, 2024
4e8ca92
Update zos-v2r5-symbolfixes.h
IgorTodorovskiIBM Sep 24, 2024
2dc1f9b
Resolve issue when malloc/free are used as function pointers
IgorTodorovskiIBM Sep 24, 2024
ac3adb8
Add pthread_condattr_setclock to v2r5 symbol list
IgorTodorovskiIBM Oct 9, 2024
6c843ab
Add asprintf and vasprintf to v2r5 symbol list
IgorTodorovskiIBM Oct 9, 2024
ab0e6fa
Update unistd.h - use __asm
IgorTodorovskiIBM Nov 13, 2024
cdd2f75
Fix up product name & remove the c++ copied dir (#70)
perry-ca Nov 15, 2024
3a5c17f
Add dependant code for script command (#71)
sachintu47 Nov 26, 2024
bac1675
Add vasprintf and strcasestr - needed by htop
IgorTodorovskiIBM Jan 3, 2025
a6f5da1
Add a fix for symlinks with $ literals in the beginning
IgorTodorovskiIBM Jan 27, 2025
68f947f
TODO one readlink test that fails on sysplex only
IgorTodorovskiIBM Jan 28, 2025
ab82da4
Update zos-v2r5-symbolfixes.h
IgorTodorovskiIBM Jan 30, 2025
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
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
cmake_minimum_required(VERSION 3.24)
project(libzoslib CXX C ASM)

if(${CMAKE_C_COMPILER} MATCHES xlclang)
include_directories(BEFORE include)
else()
include_directories(BEFORE include include/c++/v1)
endif()
include_directories(BEFORE include)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
Expand Down Expand Up @@ -53,6 +49,11 @@ if(ZOSLIB_GENERIC)
ZOSLIB_GENERIC)
endif()

if(ZOSLIB_QUICK_STARTUP)
list(APPEND zoslib_defines
ZOSLIB_QUICK_STARTUP)
endif()


if(DEFINED ENV{BUILD_VERSION})
list(APPEND zoslib_defines BUILD_VERSION="$ENV{BUILD_VERSION}")
Expand Down Expand Up @@ -81,7 +82,7 @@ else()
list(APPEND zoslib_cflags
-fgnu-keywords
-m64
-march=arch14
-march=arch10
-mzos-target=zosv2r4
-fno-short-enums
-fzos-le-char-mode=ascii)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ ZOSLIB is supported on the following hardware:
* CMake 3.24.2-zos+
* GNU Make 4.3+
* IBM XL C/C++ V2.3.1 for z/OS V2.3 web deliverable (xlclang/xlcang++) or
IBM Open XL C/C++ 2.0 (clang/clang++)
IBM C/C++ for Open Enterprise Languages on z/OS 2.0.0 (clang/clang++) or
IBM Open XL C/C++ 2.1 for z/OS, version 2.1 (ibm-clang64/ibm-clang++64)
* Git
* Ninja (optional)

Expand Down
19 changes: 19 additions & 0 deletions include/netinet/in_systm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
///////////////////////////////////////////////////////////////////////////////
// Licensed Materials - Property of IBM
// ZOSLIB
// (C) Copyright IBM Corp. 2024. All Rights Reserved.
// US Government Users Restricted Rights - Use, duplication
// or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
///////////////////////////////////////////////////////////////////////////////

#ifndef ZOS_IN_SYSTM_H_
#define ZOS_IN_SYSTM_H_

#include <stdint.h>

// Network types
typedef uint16_t n_short;
typedef uint32_t n_long;
typedef uint32_t n_time;

#endif
13 changes: 13 additions & 0 deletions include/paths.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
///////////////////////////////////////////////////////////////////////////////
// Licensed Materials - Property of IBM
// ZOSLIB
// (C) Copyright IBM Corp. 2024. All Rights Reserved.
// US Government Users Restricted Rights - Use, duplication
// or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
///////////////////////////////////////////////////////////////////////////////

#ifndef ZOS_PATHS_H_

#define _PATH_BSHELL "/bin/sh"

#endif
55 changes: 55 additions & 0 deletions include/pthread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
///////////////////////////////////////////////////////////////////////////////
// Licensed Materials - Property of IBM
// ZOSLIB
// (C) Copyright IBM Corp. 2021. All Rights Reserved.
// US Government Users Restricted Rights - Use, duplication
// or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
///////////////////////////////////////////////////////////////////////////////

#ifndef ZOS_PTHREAD_H_
#define ZOS_PTHREAD_H_

#define __XPLAT 1
#include "zos-macros.h"
#include <sys/types.h>


#if defined(__cplusplus)
extern "C" {
#endif
__Z_EXPORT int __pthread_create_extended(pthread_t *thread,
const pthread_attr_t *attr,
void *(*start_routine)(void *),
void *arg);
#if defined(__cplusplus)
}
#endif

#if defined(ZOSLIB_OVERRIDE_CLIB) || defined(ZOSLIB_OVERRIDE_CLIB_PTHREAD)
#define pthread_create __pthread_create_replaced
#endif

#include_next <pthread.h>

#if defined(ZOSLIB_OVERRIDE_CLIB) || defined(ZOSLIB_OVERRIDE_CLIB_PTHREAD)

#if defined(__cplusplus)
extern "C" {
#endif

#undef pthread_create
__Z_EXPORT int pthread_create(pthread_t *thread,
const pthread_attr_t *attr,
void *(*start_routine)(void *),
void *arg) asm("__pthread_create_extended");

#if defined(__cplusplus)
}
#endif
#endif /* defined(ZOSLIB_OVERRIDE_CLIB) || defined(ZOSLIB_OVERRIDE_CLIB_PTHREAD) */

#ifndef PTHREAD_RWLOCK_INITIALIZER
#define PTHREAD_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER_NP
#endif

#endif
38 changes: 38 additions & 0 deletions include/pty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////
//// Licensed Materials - Property of IBM
//// ZOSLIB
//// (C) Copyright IBM Corp. 2022. All Rights Reserved.
//// US Government Users Restricted Rights - Use, duplication
//// or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
/////////////////////////////////////////////////////////////////////////////////
//
#ifndef ZOS_PTY_H
#define ZOS_PTY_H

#include "zos-macros.h"
#include <termios.h>

#ifdef __cplusplus
extern "C" {
#endif


/* Create pseudo tty master slave pair with NAME and set terminal
attributes according to TERMP and WINP and return handles for both
ends in AMASTER and ASLAVE. */
__Z_EXPORT extern int openpty (int *__amaster, int *__aslave, char *__name,
const struct termios *__termp,
const struct winsize *__winp);

/* Create child process and establish the slave pseudo terminal as the
child's controlling terminal. */
__Z_EXPORT extern int forkpty (int *__amaster, char *__name,
const struct termios *__termp,
const struct winsize *__winp);


#ifdef __cplusplus
}
#endif

#endif
4 changes: 4 additions & 0 deletions include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define ZOS_STDIO_H_

#include "zos-macros.h"
#include <sys/types.h>

#define __XPLAT 1

Expand Down Expand Up @@ -39,6 +40,9 @@ extern "C" {
#endif

__Z_EXPORT extern FILE *fopen(const char *filename, const char *mode) __asm("__fopen_ascii");
__Z_EXPORT ssize_t getline(char **lineptr, size_t *n, FILE *stream);
__Z_EXPORT ssize_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *stream);
__Z_EXPORT int vasprintf(char **strp, const char *fmt, va_list ap);

#if defined(__cplusplus)
}
Expand Down
16 changes: 16 additions & 0 deletions include/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ __Z_EXPORT int __mkstemp_ascii(char*);
#define realpath __realpath_replaced
#undef mkstemp
#define mkstemp __mkstemp_replaced
#undef malloc
#define malloc __malloc_replaced
#undef free
#define free __free_replaced
#endif

#if defined(ZOSLIB_OVERRIDE_CLIB_GETENV) && defined(__NATIVE_ASCII_F)
Expand All @@ -46,6 +50,11 @@ __Z_EXPORT int __mkstemp_ascii(char*);

#if defined(ZOSLIB_OVERRIDE_CLIB) || defined(ZOSLIB_OVERRIDE_CLIB_STDLIB)

#undef realpath
#undef mkstemp
#undef malloc
#undef free

#if defined(__cplusplus)
extern "C" {
#endif
Expand All @@ -55,6 +64,8 @@ extern "C" {
*/
#undef realpath
__Z_EXPORT char *realpath(const char * __restrict__, char * __restrict__) __asm("__realpath_extended");
__Z_EXPORT void* malloc(size_t size) __asm("__zoslib_malloc");
__Z_EXPORT void free(void* ptr) __asm("__zoslib_free");

#ifdef __NATIVE_ASCII_F
/**
Expand Down Expand Up @@ -104,6 +115,9 @@ extern "C" {
*/
__Z_EXPORT int getloadavg(double loadavg[], int nelem);
__Z_EXPORT const char * getprogname(void);
__Z_EXPORT int mkostemp(char *, int flags);
__Z_EXPORT int mkstemps(char *, int suffixlen);
__Z_EXPORT int mkostemps(char *, int suffixlen, int flags);
#if defined(__cplusplus)
}
#endif
Expand All @@ -124,6 +138,8 @@ __Z_EXPORT char *mkdtemp(char *);
#endif

#if defined(__cplusplus)
__Z_EXPORT void __zoslib_free(void* ptr);
__Z_EXPORT void* __zoslib_malloc(size_t size);
}
#endif

Expand Down
3 changes: 3 additions & 0 deletions include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ __Z_EXPORT char *strndup(const char *s, size_t n);
__Z_EXPORT char *strsignal(int );
__Z_EXPORT const char *sigdescr_np(int);
__Z_EXPORT const char *sigabbrev_np(int);
__Z_EXPORT void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen);
__Z_EXPORT int strverscmp(const char *l0, const char *r0);
__Z_EXPORT char *strcasestr(const char *haystack, const char *needle);

// Linux includes strings.h in string.h, this avoids the
// warning - implicitly declaring library function 'strcasecmp'
Expand Down
7 changes: 7 additions & 0 deletions include/sys/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@
#ifndef ZOS_SYS_PARAM_H_
#define ZOS_SYS_PARAM_H_

// Could be defined in resolv.h
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif

#define MAXNAMLEN 255
#define MAXPATHLEN 4096

#endif
65 changes: 65 additions & 0 deletions include/sys/signalfd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////
// Licensed Materials - Property of IBM
// ZOSLIB
// (C) Copyright IBM Corp. 2022. All Rights Reserved.
// US Government Users Restricted Rights - Use, duplication
// or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
///////////////////////////////////////////////////////////////////////////////

#ifndef ZOS_SYS_SIGNALFD_H
#define ZOS_SYS_SIGNALFD_H

#include <stdint.h>
#include <signal.h>

/* Flags for signalfd. */
enum {
SFD_CLOEXEC = 02000000,
#define SFD_CLOEXEC SFD_CLOEXEC
SFD_NONBLOCK = 00004000
#define SFD_NONBLOCK SFD_NONBLOCK
};


struct signalfd_siginfo {
uint32_t ssi_signo;
int32_t ssi_errno;
int32_t ssi_code;
uint32_t ssi_pid;
uint32_t ssi_uid;
int32_t ssi_fd;
uint32_t ssi_tid;
uint32_t ssi_band;
uint32_t ssi_overrun;
uint32_t ssi_trapno;
int32_t ssi_status;
uint32_t ssi_int;
uint64_t ssi_ptr;
uint64_t ssi_utime;
uint64_t ssi_stime;
uint64_t ssi_addr;
/*
* Pad strcture to 128 bytes. Remember to update the
* pad size when you add new members. We use a fixed
* size structure to avoid compatibility problems with
* future versions, and we leave extra space for additional
* members. We use fixed size members because this strcture
* comes out of a read(2) and we really don't want to have
* a compat on read(2).
*/
uint8_t __pad[48];
};

#ifdef __cplusplus
extern "C" {
#endif

__Z_EXPORT extern int signalfd(int fd, const sigset_t *mask, int flags);

__Z_EXPORT int signalfd_close(int fd);

#ifdef __cplusplus
}
#endif

#endif
28 changes: 28 additions & 0 deletions include/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,32 @@ __Z_EXPORT int lutimes(const char *filename, const struct timeval tv[2]);

#endif

/* Convenience macros for operations on timevals.
NOTE: `timercmp' does not work for >= or <=. */
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
#define timercmp(a, b, CMP) \
(((a)->tv_sec == (b)->tv_sec) \
? ((a)->tv_usec CMP (b)->tv_usec) \
: ((a)->tv_sec CMP (b)->tv_sec))
#define timeradd(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
if ((result)->tv_usec >= 1000000) \
{ \
++(result)->tv_sec; \
(result)->tv_usec -= 1000000; \
} \
} while (0)
#define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) { \
--(result)->tv_sec; \
(result)->tv_usec += 1000000; \
} \
} while (0)

#endif
26 changes: 26 additions & 0 deletions include/termios.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
///////////////////////////////////////////////////////////////////////////////
//// Licensed Materials - Property of IBM
//// ZOSLIB
//// (C) Copyright IBM Corp. 2022. All Rights Reserved.
//// US Government Users Restricted Rights - Use, duplication
//// or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
/////////////////////////////////////////////////////////////////////////////////
//
#ifndef ZOS_TERMIOS_H
#define ZOS_TERMIOS_H

#include "zos-macros.h"

#include_next <termios.h>

#ifdef __cplusplus
extern "C" {
#endif

__Z_EXPORT void cfmakeraw(struct termios *termios_p);

#ifdef __cplusplus
}
#endif

#endif
Loading