Add support for IBM z/OS (#5304)

This commit is contained in:
Steven Pitman 2020-07-15 10:17:56 -04:00 committed by GitHub
parent 84514ee6ee
commit 87b660d580
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

View file

@ -40,7 +40,10 @@ def _get_openssl_libraries(platform):
# -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)
return ["ssl", "crypto", "pthread"]
if sys.platform == 'zos':
return ["ssl", "crypto"]
else:
return ["ssl", "crypto", "pthread"]
def _extra_compile_args(platform):

View file

@ -20,6 +20,10 @@ INCLUDES = """
#include <stdlib.h>
#include <pthread.h>
#endif
#ifdef __MVS__
#include <errno.h>
#endif
"""
TYPES = """
@ -66,11 +70,23 @@ typedef pthread_mutex_t Cryptography_mutex;
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
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));

View file

@ -6,7 +6,9 @@
#include <fcntl.h>
#include <unistd.h>
/* for defined(BSD) */
#include <sys/param.h>
#ifndef __MVS__
#include <sys/param.h>
#endif
#ifdef BSD
/* for SYS_getentropy */