open62541
1.3.12
Open source implementation of OPC UA
Loading...
Searching...
No Matches
doc
open62541
arch
wec7
ua_architecture.h
Go to the documentation of this file.
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 2018 (c) Stephan Kantelberg
5
*/
6
7
#ifdef UA_ARCHITECTURE_WEC7
8
9
#ifndef PLUGINS_ARCH_WEC7_UA_ARCHITECTURE_H_
10
#define PLUGINS_ARCH_WEC7_UA_ARCHITECTURE_H_
11
12
#ifndef _BSD_SOURCE
13
# define _BSD_SOURCE
14
#endif
15
16
/** Disable some security warnings on MSVC */
17
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
18
# define _CRT_SECURE_NO_WARNINGS
19
#endif
20
21
#include "stdint.h"
22
#ifdef UNDER_CE
23
#define MAX_STRERROR 31
24
static
char
*errorStrings[]= {
"Error 0"
,
""
,
"No such file or directory"
,
""
,
""
,
""
,
""
,
"Arg list too long"
,
25
"Exec format error"
,
"Bad file number"
,
""
,
""
,
"Not enough core"
,
"Permission denied"
,
""
,
""
,
26
""
,
"File exists"
,
"Cross-device link"
,
""
,
""
,
""
,
"Invalid argument"
,
""
,
"Too many open files"
,
27
""
,
""
,
""
,
"No space left on device"
,
""
,
""
,
""
,
""
,
"Math argument"
,
"Result too large"
,
""
,
28
"Resource deadlock would occur"
,
"Unknown error under wince"
};
29
30
char
*strerror(
int
errnum);
31
#endif
32
33
#include <stdlib.h>
34
#if defined(_WIN32)
35
# include <malloc.h>
36
#endif
37
38
#include <stdio.h>
39
#include <errno.h>
40
#include <winsock2.h>
41
#include <windows.h>
42
#include <ws2tcpip.h>
43
44
#ifdef _MSC_VER
45
# ifndef UNDER_CE
46
# include <io.h>
//access
47
# define UA_access _access
48
# endif
49
#else
50
# include <unistd.h>
//access and tests
51
# define UA_access access
52
#endif
53
54
#define ssize_t int
55
#define OPTVAL_TYPE char
56
#ifdef UA_sleep_ms
57
void
UA_sleep_ms
(
unsigned
long
ms);
58
#else
59
# define UA_sleep_ms(X) Sleep(X)
60
#endif
61
62
// Windows does not support ansi colors
63
// #define UA_ENABLE_LOG_COLORS
64
65
#if defined(__MINGW32__)
//mingw defines SOCKET as long long unsigned int, giving errors in logging and when comparing with UA_Int32
66
# define UA_SOCKET int
67
# define UA_INVALID_SOCKET -1
68
#else
69
# define UA_SOCKET SOCKET
70
# define UA_INVALID_SOCKET INVALID_SOCKET
71
#endif
72
#define UA_ERRNO WSAGetLastError()
73
#define UA_INTERRUPTED WSAEINTR
74
#define UA_AGAIN WSAEWOULDBLOCK
75
#define UA_EAGAIN EAGAIN
76
#define UA_WOULDBLOCK WSAEWOULDBLOCK
77
#define UA_ERR_CONNECTION_PROGRESS WSAEWOULDBLOCK
78
79
typedef
struct
pollfd {
80
SOCKET fd;
81
SHORT events;
82
SHORT revents;
83
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
84
85
#define UA_POLLIN 0
86
#define UA_POLLOUT 0
87
88
#define UA_fd_set(fd, fds) FD_SET((UA_SOCKET)fd, fds)
89
#define UA_fd_isset(fd, fds) FD_ISSET((UA_SOCKET)fd, fds)
90
91
#ifdef UNDER_CE
92
#define UA_ERRNO WSAGetLastError()
93
#endif
94
95
#define UA_getnameinfo getnameinfo
96
#define UA_poll(fds,nfds,timeout) 1
97
#define UA_send(sockfd, buf, len, flags) send(sockfd, buf, (int)(len), flags)
98
#define UA_recv recv
99
#define UA_sendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto(sockfd, (const char*)(buf), (int)(len), flags, dest_addr, (int) (addrlen))
100
#define UA_recvfrom(sockfd, buf, len, flags, src_addr, addrlen) recvfrom(sockfd, (char*)(buf), (int)(len), flags, src_addr, addrlen)
101
#define UA_recvmsg
102
#define UA_htonl htonl
103
#define UA_ntohl ntohl
104
#define UA_close closesocket
105
#define UA_select(nfds, readfds, writefds, exceptfds, timeout) select((int)(nfds), readfds, writefds, exceptfds, timeout)
106
#define UA_shutdown shutdown
107
#define UA_socket socket
108
#define UA_bind bind
109
#define UA_listen listen
110
#define UA_accept accept
111
#define UA_connect(sockfd, addr, addrlen) connect(sockfd, addr, (int)(addrlen))
112
#define UA_getaddrinfo getaddrinfo
113
#define UA_getsockopt getsockopt
114
#define UA_setsockopt(sockfd, level, optname, optval, optlen) setsockopt(sockfd, level, optname, (const char*) (optval), optlen)
115
#define UA_ioctl
116
#define UA_freeaddrinfo freeaddrinfo
117
#define UA_gethostname gethostname
118
#define UA_getsockname getsockname
119
#define UA_inet_pton InetPton
120
121
#ifdef maxStringLength
//defined in mingw64
122
# undef maxStringLength
123
#endif
124
125
#ifndef UA_free
126
#define UA_free free
127
#define UA_malloc malloc
128
#define UA_calloc calloc
129
#define UA_realloc realloc
130
#endif
131
132
#define UA_snprintf(source, size, string, ...) _snprintf_s(source, size, _TRUNCATE, string, __VA_ARGS__)
133
#define UA_strncasecmp _strnicmp
134
135
#define UA_LOG_SOCKET_ERRNO_WRAP(LOG) { \
136
LPVOID errno_str = NULL; \
137
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, \
138
NULL, WSAGetLastError(), \
139
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \
140
(LPWSTR)&errno_str, \
141
0, NULL); \
142
LOG; \
143
LocalFree(errno_str); \
144
}
145
#define UA_LOG_SOCKET_ERRNO_GAI_WRAP UA_LOG_SOCKET_ERRNO_WRAP
146
147
#if UA_MULTITHREADING >= 100
148
#error Multithreading unsupported
149
#else
150
#define UA_LOCK_INIT(lock)
151
#define UA_LOCK_DESTROY(lock)
152
#define UA_LOCK(lock)
153
#define UA_UNLOCK(lock)
154
#define UA_LOCK_ASSERT(lock, num)
155
#endif
156
157
#include <
open62541/architecture_functions.h
>
158
159
/** Fix redefinition of SLIST_ENTRY on mingw winnt.h */
160
#if !defined(_SYS_QUEUE_H_) && defined(SLIST_ENTRY)
161
# undef SLIST_ENTRY
162
#endif
163
164
#endif
/* PLUGINS_ARCH_WEC7_UA_ARCHITECTURE_H_ */
165
166
#endif
/* UA_ARCHITECTURE_WEC7 */
architecture_functions.h
UA_sleep_ms
#define UA_sleep_ms(X)
This work is licensed under a Creative Commons CCZero 1.0 Universal License.
Definition
ua_freeRTOS.h:17
Generated by
1.11.0