ua_architecture.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #ifdef UA_ARCHITECTURE_VXWORKS
  8. #ifndef PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_
  9. #define PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_
  10. #include <../deps/queue.h> //in some compilers there's already a _SYS_QUEUE_H_ who is included first and doesn't have all functions
  11. #include <errno.h>
  12. #include <arpa/inet.h>
  13. #include <netinet/in.h>
  14. #include <netdb.h>
  15. #include <sys/ioctl.h>
  16. #include <hostLib.h>
  17. #include <selectLib.h>
  18. #define UA_sleep_ms(X) \
  19. { \
  20. struct timespec timeToSleep; \
  21. timeToSleep.tv_sec = X / 1000; \
  22. timeToSleep.tv_nsec = 1000000 * (X % 1000); \
  23. nanosleep(&timeToSleep, NULL); \
  24. }
  25. #ifdef UINT32_C
  26. # undef UINT32_C
  27. #endif
  28. #define UINT32_C(x) ((x) + (UINT32_MAX - UINT32_MAX))
  29. #ifdef UA_BINARY_OVERLAYABLE_FLOAT
  30. # undef UA_BINARY_OVERLAYABLE_FLOAT
  31. #endif
  32. #define UA_BINARY_OVERLAYABLE_FLOAT 1
  33. /* Thread-Local Storage
  34. * --------------------
  35. * Thread-local storage is not required by the main library functionality. It is
  36. * only used for some testing strategies. ``UA_THREAD_LOCAL`` is empty if the
  37. * feature is not available. */
  38. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
  39. # define UA_THREAD_LOCAL _Thread_local /* C11 */
  40. #elif defined(__cplusplus) && __cplusplus > 199711L
  41. # define UA_THREAD_LOCAL thread_local /* C++11 */
  42. #elif defined(__GNUC__)
  43. # define UA_THREAD_LOCAL __thread /* GNU extension */
  44. #else
  45. # define UA_THREAD_LOCAL
  46. #endif
  47. #define OPTVAL_TYPE int
  48. #include <fcntl.h>
  49. #include <unistd.h> // read, write, close
  50. #include <netinet/tcp.h>
  51. #define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
  52. #define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
  53. #define UA_access access
  54. #define UA_IPV6 1
  55. #define UA_SOCKET int
  56. #define UA_INVALID_SOCKET -1
  57. #define UA_ERRNO errno
  58. #define UA_INTERRUPTED EINTR
  59. #define UA_AGAIN EAGAIN
  60. #define UA_EAGAIN EAGAIN
  61. #define UA_WOULDBLOCK EWOULDBLOCK
  62. #define UA_ERR_CONNECTION_PROGRESS EINPROGRESS
  63. #define UA_ENABLE_LOG_COLORS
  64. #define UA_getnameinfo getnameinfo
  65. #define UA_send send
  66. #define UA_recv recv
  67. #define UA_close close
  68. #define UA_select select
  69. #define UA_shutdown shutdown
  70. #define UA_socket socket
  71. #define UA_bind bind
  72. #define UA_listen listen
  73. #define UA_accept accept
  74. #define UA_connect connect
  75. #define UA_getaddrinfo getaddrinfo
  76. #define UA_getsockopt getsockopt
  77. #define UA_setsockopt setsockopt
  78. #define UA_freeaddrinfo freeaddrinfo
  79. #define UA_gethostname gethostname
  80. #include <stdlib.h>
  81. #define UA_free free
  82. #define UA_malloc malloc
  83. #define UA_calloc calloc
  84. #define UA_realloc realloc
  85. #include <stdio.h>
  86. #define UA_snprintf snprintf
  87. #define UA_LOG_SOCKET_ERRNO_WRAP(LOG) { \
  88. char *errno_str = strerror(errno); \
  89. LOG; \
  90. }
  91. #define UA_LOG_SOCKET_ERRNO_GAI_WRAP(LOG) { \
  92. char *errno_str = gai_strerror(errno); \
  93. LOG; \
  94. }
  95. #include "../ua_architecture_functions.h"
  96. #endif /* PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_ */
  97. #endif /* UA_ARCHITECTURE_VXWORKS */