ua_architecture.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  3. *
  4. * Copyright 2016-2017 (c) Julius Pfrommer, Fraunhofer IOSB
  5. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  6. */
  7. #ifndef PLUGINS_ARCH_POSIX_UA_ARCHITECTURE_H_
  8. #define PLUGINS_ARCH_POSIX_UA_ARCHITECTURE_H_
  9. /* Enable POSIX features */
  10. #if !defined(_XOPEN_SOURCE)
  11. # define _XOPEN_SOURCE 600
  12. #endif
  13. #ifndef _DEFAULT_SOURCE
  14. # define _DEFAULT_SOURCE
  15. #endif
  16. /* On older systems we need to define _BSD_SOURCE.
  17. * _DEFAULT_SOURCE is an alias for that. */
  18. #ifndef _BSD_SOURCE
  19. # define _BSD_SOURCE
  20. #endif
  21. #include <errno.h>
  22. #define CLOSESOCKET(S) close(S)
  23. #include <arpa/inet.h>
  24. #include <netinet/in.h>
  25. #include <netdb.h>
  26. #include <sys/ioctl.h>
  27. # include <sys/select.h>
  28. # define UA_sleep_ms(X) usleep(X * 1000)
  29. #define SOCKET int
  30. #define WIN32_INT
  31. #define OPTVAL_TYPE int
  32. #define ERR_CONNECTION_PROGRESS EINPROGRESS
  33. #include <fcntl.h>
  34. #include <unistd.h> // read, write, close
  35. #ifdef __QNX__
  36. # include <sys/socket.h>
  37. #endif
  38. #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
  39. # include <sys/param.h>
  40. # if defined(BSD)
  41. # include<sys/socket.h>
  42. # endif
  43. #endif
  44. #if !defined(__CYGWIN__)
  45. # include <netinet/tcp.h>
  46. #endif
  47. /* unsigned int for windows and workaround to a glibc bug */
  48. /* Additionally if GNU_LIBRARY is not defined, it may be using
  49. * musl libc (e.g. Docker Alpine) */
  50. #if defined(_WIN32) || defined(__OpenBSD__) || \
  51. (defined(__GNU_LIBRARY__) && (__GNU_LIBRARY__ <= 6) && \
  52. (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 16) || \
  53. !defined(__GNU_LIBRARY__))
  54. # define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
  55. # define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
  56. #else
  57. # define UA_fd_set(fd, fds) FD_SET(fd, fds)
  58. # define UA_fd_isset(fd, fds) FD_ISSET(fd, fds)
  59. #endif
  60. # define errno__ errno
  61. # define INTERRUPTED EINTR
  62. # define WOULDBLOCK EWOULDBLOCK
  63. # define AGAIN EAGAIN
  64. #endif /* PLUGINS_ARCH_POSIX_UA_ARCHITECTURE_H_ */