ua_architecture.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 <open62541/architecture_base.h>
  11. #include <errno.h>
  12. #include <time.h>
  13. #include <arpa/inet.h>
  14. #include <netinet/in.h>
  15. #include <netdb.h>
  16. #include <sys/ioctl.h>
  17. #include <hostLib.h>
  18. #include <selectLib.h>
  19. #define UA_sleep_ms(X) \
  20. { \
  21. struct timespec timeToSleep; \
  22. timeToSleep.tv_sec = X / 1000; \
  23. timeToSleep.tv_nsec = 1000000 * (X % 1000); \
  24. nanosleep(&timeToSleep, NULL); \
  25. }
  26. #ifdef UINT32_C
  27. # undef UINT32_C
  28. #endif
  29. #define UINT32_C(x) ((x) + (UINT32_MAX - UINT32_MAX))
  30. #ifdef UA_BINARY_OVERLAYABLE_FLOAT
  31. # undef UA_BINARY_OVERLAYABLE_FLOAT
  32. #endif
  33. #define UA_BINARY_OVERLAYABLE_FLOAT 1
  34. #define OPTVAL_TYPE int
  35. #include <fcntl.h>
  36. #include <unistd.h> // read, write, close
  37. #include <netinet/tcp.h>
  38. #define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
  39. #define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
  40. #define UA_access access
  41. #define UA_IPV6 1
  42. #define UA_SOCKET int
  43. #define UA_INVALID_SOCKET -1
  44. #define UA_ERRNO errno
  45. #define UA_INTERRUPTED EINTR
  46. #define UA_AGAIN EAGAIN
  47. #define UA_EAGAIN EAGAIN
  48. #define UA_WOULDBLOCK EWOULDBLOCK
  49. #define UA_ERR_CONNECTION_PROGRESS EINPROGRESS
  50. #define UA_ENABLE_LOG_COLORS
  51. #define UA_getnameinfo getnameinfo
  52. #define UA_send send
  53. #define UA_recv recv
  54. #define UA_sendto sendto
  55. #define UA_recvfrom recvfrom
  56. #define UA_htonl htonl
  57. #define UA_ntohl ntohl
  58. #define UA_close close
  59. #define UA_select select
  60. #define UA_shutdown shutdown
  61. #define UA_socket socket
  62. #define UA_bind bind
  63. #define UA_listen listen
  64. #define UA_accept accept
  65. #define UA_connect connect
  66. #define UA_getaddrinfo getaddrinfo
  67. #define UA_getsockopt getsockopt
  68. #define UA_setsockopt setsockopt
  69. #define UA_freeaddrinfo freeaddrinfo
  70. #define UA_gethostname gethostname
  71. #define UA_getsockname getsockname
  72. #define UA_inet_pton inet_pton
  73. #if UA_IPV6
  74. # define UA_if_nametoindex if_nametoindex
  75. #endif
  76. #include <stdlib.h>
  77. #define UA_free free
  78. #define UA_malloc malloc
  79. #define UA_calloc calloc
  80. #define UA_realloc realloc
  81. #include <stdio.h>
  82. #define UA_snprintf snprintf
  83. #define UA_LOG_SOCKET_ERRNO_WRAP(LOG) { \
  84. char *errno_str = strerror(errno); \
  85. LOG; \
  86. }
  87. #define UA_LOG_SOCKET_ERRNO_GAI_WRAP(LOG) { \
  88. char *errno_str = gai_strerror(errno); \
  89. LOG; \
  90. }
  91. #if UA_MULTITHREADING >= 100
  92. #error Multithreading unsupported
  93. #else
  94. #define UA_LOCK_TYPE_NAME
  95. #define UA_LOCK_TYPE(mutexName)
  96. #define UA_LOCK_TYPE_POINTER(mutexName)
  97. #define UA_LOCK_INIT(mutexName)
  98. #define UA_LOCK_DESTROY(mutexName)
  99. #define UA_LOCK(mutexName)
  100. #define UA_UNLOCK(mutexName)
  101. #define UA_LOCK_ASSERT(mutexName, num)
  102. #endif
  103. #include <open62541/architecture_functions.h>
  104. #endif /* PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_ */
  105. #endif /* UA_ARCHITECTURE_VXWORKS */