/* This work is licensed under a Creative Commons CCZero 1.0 Universal License. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. * * Copyright 2016-2017 (c) Julius Pfrommer, Fraunhofer IOSB * Copyright 2017 (c) Stefan Profanter, fortiss GmbH */ #ifndef PLUGINS_ARCH_POSIX_UA_ARCHITECTURE_H_ #define PLUGINS_ARCH_POSIX_UA_ARCHITECTURE_H_ /* Enable POSIX features */ #if !defined(_XOPEN_SOURCE) # define _XOPEN_SOURCE 600 #endif #ifndef _DEFAULT_SOURCE # define _DEFAULT_SOURCE #endif /* On older systems we need to define _BSD_SOURCE. * _DEFAULT_SOURCE is an alias for that. */ #ifndef _BSD_SOURCE # define _BSD_SOURCE #endif #include #define CLOSESOCKET(S) close(S) #include #include #include #include # include # define UA_sleep_ms(X) usleep(X * 1000) #define SOCKET int #define WIN32_INT #define OPTVAL_TYPE int #define ERR_CONNECTION_PROGRESS EINPROGRESS #include #include // read, write, close #ifdef __QNX__ # include #endif #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) # include # if defined(BSD) # include # endif #endif #if !defined(__CYGWIN__) # include #endif /* unsigned int for windows and workaround to a glibc bug */ /* Additionally if GNU_LIBRARY is not defined, it may be using * musl libc (e.g. Docker Alpine) */ #if defined(_WIN32) || defined(__OpenBSD__) || \ (defined(__GNU_LIBRARY__) && (__GNU_LIBRARY__ <= 6) && \ (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 16) || \ !defined(__GNU_LIBRARY__)) # define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds) # define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds) #else # define UA_fd_set(fd, fds) FD_SET(fd, fds) # define UA_fd_isset(fd, fds) FD_ISSET(fd, fds) #endif # define errno__ errno # define INTERRUPTED EINTR # define WOULDBLOCK EWOULDBLOCK # define AGAIN EAGAIN #endif /* PLUGINS_ARCH_POSIX_UA_ARCHITECTURE_H_ */