12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /* 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 <errno.h>
- #define CLOSESOCKET(S) close(S)
- #include <arpa/inet.h>
- #include <netinet/in.h>
- #include <netdb.h>
- #include <sys/ioctl.h>
- # include <sys/select.h>
- # define UA_sleep_ms(X) usleep(X * 1000)
- #define SOCKET int
- #define WIN32_INT
- #define OPTVAL_TYPE int
- #define ERR_CONNECTION_PROGRESS EINPROGRESS
- #include <fcntl.h>
- #include <unistd.h> // read, write, close
- #ifdef __QNX__
- # include <sys/socket.h>
- #endif
- #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
- # include <sys/param.h>
- # if defined(BSD)
- # include<sys/socket.h>
- # endif
- #endif
- #if !defined(__CYGWIN__)
- # include <netinet/tcp.h>
- #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_ */
|