Skip to content
Snippets Groups Projects
Commit 0a7f1c0932d7 authored by Steven Pitman's avatar Steven Pitman
Browse files

Add support for IBM z/OS (#5304)

parent 49f846ce8d3a
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,9 @@
# -lpthread required due to usage of pthread an potential
# existance of a static part containing e.g. pthread_atfork
# (https://github.com/pyca/cryptography/issues/5084)
if sys.platform == 'zos':
return ["ssl", "crypto"]
else:
return ["ssl", "crypto", "pthread"]
......
......@@ -20,6 +20,10 @@
#include <stdlib.h>
#include <pthread.h>
#endif
#ifdef __MVS__
#include <errno.h>
#endif
"""
TYPES = """
......@@ -66,7 +70,19 @@
perror("Fatal error in callback initialization: " #call); \
abort(); \
}
#ifdef __MVS__
/* When pthread_mutex_init is called more than once on the same mutex,
on z/OS this throws an EBUSY error.
*/
#define ASSERT_STATUS_INIT(call) \
if ((call) != 0 && errno != EBUSY) { \
perror("Fatal error in callback initialization: " #call); \
abort(); \
}
#else
#define ASSERT_STATUS_INIT ASSERT_STATUS
#endif
static inline void cryptography_mutex_init(Cryptography_mutex *mutex) {
#if !defined(pthread_mutexattr_default)
# define pthread_mutexattr_default ((pthread_mutexattr_t *)NULL)
#endif
......@@ -69,8 +85,8 @@
static inline void cryptography_mutex_init(Cryptography_mutex *mutex) {
#if !defined(pthread_mutexattr_default)
# define pthread_mutexattr_default ((pthread_mutexattr_t *)NULL)
#endif
ASSERT_STATUS(pthread_mutex_init(mutex, pthread_mutexattr_default));
ASSERT_STATUS_INIT(pthread_mutex_init(mutex, pthread_mutexattr_default));
}
static inline void cryptography_mutex_lock(Cryptography_mutex *mutex) {
ASSERT_STATUS(pthread_mutex_lock(mutex));
......
......@@ -6,4 +6,5 @@
#include <fcntl.h>
#include <unistd.h>
/* for defined(BSD) */
#ifndef __MVS__
#include <sys/param.h>
......@@ -9,4 +10,5 @@
#include <sys/param.h>
#endif
#ifdef BSD
/* for SYS_getentropy */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment