Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zepeng Liu
OPC UA PubSub
Commits
e796417d
Commit
e796417d
authored
Jun 14, 2018
by
Patrick Bellot
Browse files
linux64_ingocs2 is ready
parent
7a5863ab
Changes
11
Hide whitespace changes
Inline
Side-by-side
opcua/.cproject
View file @
e796417d
...
...
@@ -35,6 +35,8 @@
<option
id=
"gnu.cpp.compiler.option.include.files.1016416781"
name=
"Include files (-include)"
superClass=
"gnu.cpp.compiler.option.include.files"
useByScannerDiscovery=
"false"
/>
<option
id=
"gnu.cpp.compiler.option.include.paths.780294207"
name=
"Include paths (-I)"
superClass=
"gnu.cpp.compiler.option.include.paths"
useByScannerDiscovery=
"false"
valueType=
"includePath"
>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/s2opc_stack}/include_linux""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/${ProjName}}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/opcua-client}""
/>
</option>
<inputType
id=
"cdt.managedbuild.tool.gnu.cpp.compiler.input.1464493100"
superClass=
"cdt.managedbuild.tool.gnu.cpp.compiler.input"
/>
</tool>
...
...
opcua/lib/StandardDataTypes/OpcUa_IPCS_ByteString.h
View file @
e796417d
...
...
@@ -98,6 +98,7 @@ public:
}
length
=
_length
;
array
=
_array
;
NOT_USED
(
takeItForYou
)
;
}
ByteString
(
uint32_t
value
)
...
...
opcua/lib/StandardDataTypes/OpcUa_IPCS_String.h
View file @
e796417d
...
...
@@ -95,6 +95,7 @@ public:
:
BaseDataType
()
{
str
=
_str
;
NOT_USED
(
takeItForYou
)
;
}
String
(
const
char
*
const
_str
)
...
...
opcua/lib/s2opc/S2OPC_ClientServices.cpp
View file @
e796417d
...
...
@@ -157,6 +157,8 @@ MYDLL void ClientService_ServiceFault(
OpcUa_ServiceFault_Clear
(
response
)
;
free
(
responseHeader
)
;
free
(
response
)
;
NOT_USED
(
scConnectionId
)
;
}
...
...
@@ -199,6 +201,8 @@ MYDLL void ClientService_CreateSession(
OpcUa_CreateSessionResponse_Clear
(
response
)
;
free
(
responseHeader
)
;
free
(
response
)
;
NOT_USED
(
scConnectionId
)
;
}
...
...
s2opc_stack/.settings/language.settings.xml
0 → 100644
View file @
e796417d
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration
id=
"cdt.managedbuild.config.gnu.so.debug.564995990"
name=
"Debug"
>
<extension
point=
"org.eclipse.cdt.core.LanguageSettingsProvider"
>
<provider
copy-of=
"extension"
id=
"org.eclipse.cdt.ui.UserLanguageSettingsProvider"
/>
<provider-reference
id=
"org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider"
ref=
"shared-provider"
/>
<provider-reference
id=
"org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"
ref=
"shared-provider"
/>
<provider
class=
"org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector"
console=
"false"
env-hash=
"1968678984014786712"
id=
"org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"
keep-relative-paths=
"false"
name=
"CDT GCC Built-in Compiler Settings"
parameter=
"${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}""
prefer-non-shared=
"true"
>
<language-scope
id=
"org.eclipse.cdt.core.gcc"
/>
<language-scope
id=
"org.eclipse.cdt.core.g++"
/>
</provider>
</extension>
</configuration>
<configuration
id=
"cdt.managedbuild.config.gnu.so.release.573252170"
name=
"Release"
>
<extension
point=
"org.eclipse.cdt.core.LanguageSettingsProvider"
>
<provider
copy-of=
"extension"
id=
"org.eclipse.cdt.ui.UserLanguageSettingsProvider"
/>
<provider-reference
id=
"org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider"
ref=
"shared-provider"
/>
<provider-reference
id=
"org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"
ref=
"shared-provider"
/>
<provider
class=
"org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector"
console=
"false"
env-hash=
"1968678984014786712"
id=
"org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"
keep-relative-paths=
"false"
name=
"CDT GCC Built-in Compiler Settings"
parameter=
"${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}""
prefer-non-shared=
"true"
>
<language-scope
id=
"org.eclipse.cdt.core.gcc"
/>
<language-scope
id=
"org.eclipse.cdt.core.g++"
/>
</provider>
</extension>
</configuration>
</project>
s2opc_stack/helpers_platform_dep/
w
in
dows
/p_sockets.c
→
s2opc_stack/helpers_platform_dep/
l
in
ux
/p_sockets.c
View file @
e796417d
...
...
@@ -17,30 +17,22 @@
#include "sopc_raw_sockets.h"
#include "sopc_threads.h"
#include <errno.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <string.h>
#include <unistd.h>
static
WSADATA
wsaData
;
#include "sopc_threads.h"
bool
Socket_Network_Initialize
()
{
bool
status
=
true
;
int
result
=
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsaData
);
if
(
result
!=
0
)
{
status
=
false
;
}
return
status
;
return
true
;
}
bool
Socket_Network_Clear
()
{
bool
status
=
true
;
int
result
=
WSACleanup
();
if
(
result
!=
0
)
{
status
=
false
;
}
return
status
;
return
true
;
}
SOPC_ReturnStatus
Socket_AddrInfo_Get
(
char
*
hostname
,
char
*
port
,
Socket_AddressInfo
**
addrs
)
...
...
@@ -78,7 +70,7 @@ Socket_AddressInfo* Socket_AddrInfo_IterNext(Socket_AddressInfo* addr)
uint8_t
Socket_AddrInfo_IsIPV6
(
Socket_AddressInfo
*
addr
)
{
return
addr
->
ai_family
==
A
F_INET6
;
return
addr
->
ai_family
==
P
F_INET6
;
}
void
Socket_AddrInfoDelete
(
Socket_AddressInfo
**
addrs
)
...
...
@@ -99,32 +91,33 @@ SOPC_ReturnStatus Socket_Configure(Socket sock, bool setNonBlocking)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
const
int
trueInt
=
true
;
u_long
ltrue
=
1
;
int
setOptStatus
=
-
1
;
if
(
sock
!=
SOPC_INVALID_SOCKET
)
{
status
=
SOPC_STATUS_OK
;
// Deactivate Nagle's algorithm since we always write a TCP UA binary message (and not just few bytes)
setOptStatus
=
setsockopt
(
sock
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
const
void
*
)
&
trueInt
,
sizeof
(
int
));
/*
if(setOptStatus !=
SOCKET_ERROR
){
if(setOptStatus !=
-1
){
int rcvbufsize = UINT16_MAX;
setOptStatus = setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
(char*)
&rcvbufsize, sizeof(int));
setOptStatus = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &rcvbufsize, sizeof(int));
}
if(setOptStatus !=
SOCKET_ERROR
){
if(setOptStatus !=
-1
){
int sndbufsize = UINT16_MAX;
setOptStatus = setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
(char*)
&sndbufsize, sizeof(int));
setOptStatus = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &sndbufsize, sizeof(int));
}
*/
if
(
setOptStatus
!=
SOCKET_ERROR
&&
setNonBlocking
!=
false
)
if
(
setOptStatus
!=
-
1
&&
setNonBlocking
!=
false
)
{
setOptStatus
=
ioctlsocket
(
sock
,
FIONBIO
,
&
ltrue
);
// True => Non blocking
setOptStatus
=
fcntl
(
sock
,
F_SETFL
,
O_NONBLOCK
);
}
if
(
setOptStatus
==
SOCKET_ERROR
)
if
(
setOptStatus
<
0
)
{
status
=
SOPC_STATUS_NOK
;
}
...
...
@@ -137,33 +130,38 @@ SOPC_ReturnStatus Socket_CreateNew(Socket_AddressInfo* addr, bool setReuseAddr,
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
const
int
trueInt
=
true
;
int
setOptStatus
=
SOCKET_ERROR
;
int
setOptStatus
=
-
1
;
if
(
addr
!=
NULL
&&
sock
!=
NULL
)
{
status
=
SOPC_STATUS_OK
;
*
sock
=
socket
(
addr
->
ai_family
,
addr
->
ai_socktype
,
addr
->
ai_protocol
);
if
(
*
sock
!=
SOPC_INVALID_SOCKET
)
{
status
=
Socket_Configure
(
*
sock
,
setNonBlocking
);
}
else
{
status
=
SOPC_STATUS_NOK
;
}
if
(
status
==
SOPC_STATUS_OK
)
{
setOptStatus
=
0
;
}
// else
SOCKET_ERROR
due to init
if
(
SOPC_STATUS_OK
==
status
)
{
setOptStatus
=
0
;
}
// else
-1
due to init
if
(
setOptStatus
!=
SOCKET_ERROR
&&
setReuseAddr
!=
false
)
{
setOptStatus
=
setsockopt
(
*
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
const
void
*
)
&
trueInt
,
sizeof
(
int
));
}
if
(
setOptStatus
!=
-
1
&&
setReuseAddr
!=
false
)
{
setOptStatus
=
setsockopt
(
*
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
const
void
*
)
&
trueInt
,
sizeof
(
int
));
}
// Enforce IPV6 sockets can be used for IPV4 connections (if socket is IPV6)
if
(
setOptStatus
!=
SOCKET_ERROR
&&
addr
->
ai_family
==
AF_INET6
)
{
const
int
falseInt
=
false
;
setOptStatus
=
setsockopt
(
*
sock
,
IPPROTO_IPV6
,
IPV6_V6ONLY
,
(
const
void
*
)
&
falseInt
,
sizeof
(
int
));
}
// Enforce IPV6 sockets can be used for IPV4 connections (if socket is IPV6)
if
(
setOptStatus
!=
-
1
&&
addr
->
ai_family
==
AF_INET6
)
{
const
int
falseInt
=
false
;
setOptStatus
=
setsockopt
(
*
sock
,
IPPROTO_IPV6
,
IPV6_V6ONLY
,
(
const
void
*
)
&
falseInt
,
sizeof
(
int
));
}
if
(
setOptStatus
==
SOCKET_ERROR
)
if
(
setOptStatus
<
0
)
{
status
=
SOPC_STATUS_NOK
;
}
...
...
@@ -177,13 +175,13 @@ SOPC_ReturnStatus Socket_Listen(Socket sock, Socket_AddressInfo* addr)
int
bindListenStatus
=
-
1
;
if
(
addr
!=
NULL
)
{
bindListenStatus
=
bind
(
sock
,
addr
->
ai_addr
,
(
int
)
addr
->
ai_addrlen
);
if
(
bindListenStatus
!=
SOCKET_ERROR
)
bindListenStatus
=
bind
(
sock
,
addr
->
ai_addr
,
addr
->
ai_addrlen
);
if
(
bindListenStatus
!=
-
1
)
{
bindListenStatus
=
listen
(
sock
,
SOMAXCONN
);
}
}
if
(
bindListenStatus
!=
SOCKET_ERROR
)
if
(
bindListenStatus
!=
-
1
)
{
status
=
SOPC_STATUS_OK
;
}
...
...
@@ -193,9 +191,16 @@ SOPC_ReturnStatus Socket_Listen(Socket sock, Socket_AddressInfo* addr)
SOPC_ReturnStatus
Socket_Accept
(
Socket
listeningSock
,
bool
setNonBlocking
,
Socket
*
acceptedSock
)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
if
(
listeningSock
!=
SOPC_INVALID_SOCKET
&&
acceptedSock
!=
NULL
)
struct
sockaddr
remoteAddr
;
socklen_t
addrLen
=
0
;
if
(
listeningSock
!=
-
1
&&
acceptedSock
!=
NULL
)
{
*
acceptedSock
=
accept
(
listeningSock
,
NULL
,
NULL
);
*
acceptedSock
=
accept
(
listeningSock
,
&
remoteAddr
,
&
addrLen
);
// printf("selectserver: new connection from %s on socket %d\n",
// inet_ntop(remoteaddr.sa_family,
// get_in_addr((struct sockaddr*)&remoteaddr),
// remoteIP, INET6_ADDRSTRLEN),
// acceptSock);
if
(
*
acceptedSock
!=
SOPC_INVALID_SOCKET
)
{
status
=
Socket_Configure
(
*
acceptedSock
,
setNonBlocking
);
...
...
@@ -208,14 +213,12 @@ SOPC_ReturnStatus Socket_Connect(Socket sock, Socket_AddressInfo* addr)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
connectStatus
=
-
1
;
int
wsaError
=
0
;
if
(
addr
!=
NULL
&&
sock
!=
SOPC_INVALID_SOCKET
)
if
(
addr
!=
NULL
&&
sock
!=
-
1
)
{
connectStatus
=
connect
(
sock
,
addr
->
ai_addr
,
(
int
)
addr
->
ai_addrlen
);
if
(
connectStatus
==
SOCKET_ERROR
)
connectStatus
=
connect
(
sock
,
addr
->
ai_addr
,
addr
->
ai_addrlen
);
if
(
connectStatus
<
0
)
{
wsaError
=
WSAGetLastError
();
if
(
wsaError
==
WSAEWOULDBLOCK
)
if
(
errno
==
EINPROGRESS
)
{
// Non blocking connection started
connectStatus
=
0
;
...
...
@@ -234,9 +237,9 @@ SOPC_ReturnStatus Socket_CheckAckConnect(Socket sock)
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
error
=
0
;
socklen_t
len
=
sizeof
(
int
);
if
(
sock
!=
SOPC_INVALID_SOCKET
)
if
(
sock
!=
-
1
)
{
if
(
getsockopt
(
sock
,
SOL_SOCKET
,
SO_ERROR
,
(
char
*
)
&
error
,
&
len
)
<
0
||
error
!=
0
)
if
(
getsockopt
(
sock
,
SOL_SOCKET
,
SO_ERROR
,
&
error
,
&
len
)
<
0
||
error
!=
0
)
{
status
=
SOPC_STATUS_NOK
;
}
...
...
@@ -250,17 +253,21 @@ SOPC_ReturnStatus Socket_CheckAckConnect(Socket sock)
void
SocketSet_Add
(
Socket
sock
,
SocketSet
*
sockSet
)
{
if
(
sock
!=
SOPC_INVALID_SOCKET
&&
sockSet
!=
NULL
)
if
(
sock
!=
-
1
&&
sockSet
!=
NULL
)
{
FD_SET
(
sock
,
sockSet
);
FD_SET
(
sock
,
&
sockSet
->
set
);
if
(
sock
>
sockSet
->
fdmax
)
{
sockSet
->
fdmax
=
sock
;
}
}
}
bool
SocketSet_IsPresent
(
Socket
sock
,
SocketSet
*
sockSet
)
{
if
(
sock
!=
SOPC_INVALID_SOCKET
&&
sockSet
!=
NULL
)
if
(
sock
!=
-
1
&&
sockSet
!=
NULL
)
{
if
(
false
==
FD_ISSET
(
sock
,
sockSet
))
if
(
false
==
FD_ISSET
(
sock
,
&
sockSet
->
set
))
{
return
false
;
}
...
...
@@ -276,16 +283,29 @@ void SocketSet_Clear(SocketSet* sockSet)
{
if
(
sockSet
!=
NULL
)
{
FD_ZERO
(
sockSet
);
FD_ZERO
(
&
sockSet
->
set
);
sockSet
->
fdmax
=
0
;
}
}
int32_t
Socket_WaitSocketEvents
(
SocketSet
*
readSet
,
SocketSet
*
writeSet
,
SocketSet
*
exceptSet
,
uint32_t
waitMs
)
{
int32_t
nbReady
=
0
;
const
int
ignored
=
0
;
// ignored in winsocks
struct
timeval
timeout
;
struct
timeval
*
val
;
int
fdmax
=
0
;
if
(
readSet
->
fdmax
>
writeSet
->
fdmax
)
{
fdmax
=
readSet
->
fdmax
;
}
else
{
fdmax
=
writeSet
->
fdmax
;
}
if
(
exceptSet
->
fdmax
>
fdmax
)
{
fdmax
=
exceptSet
->
fdmax
;
}
if
(
waitMs
==
0
)
{
...
...
@@ -297,8 +317,8 @@ int32_t Socket_WaitSocketEvents(SocketSet* readSet, SocketSet* writeSet, SocketS
timeout
.
tv_usec
=
1000
*
(
waitMs
%
1000
);
val
=
&
timeout
;
}
nbReady
=
select
(
ignored
,
readSet
,
writeSet
,
exceptSet
,
val
);
if
(
nbReady
==
SOCKET_ERROR
||
nbReady
>
INT32_MAX
||
nbReady
<
INT32_MIN
)
nbReady
=
select
(
fdmax
+
1
,
&
readSet
->
set
,
&
writeSet
->
set
,
&
exceptSet
->
set
,
val
);
if
(
nbReady
>
INT32_MAX
||
nbReady
<
INT32_MIN
)
return
-
1
;
return
(
int32_t
)
nbReady
;
}
...
...
@@ -307,26 +327,24 @@ SOPC_ReturnStatus Socket_Write(Socket sock, uint8_t* data, uint32_t count, uint3
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
res
=
0
;
int
wsaError
=
0
;
if
(
sock
!=
SOPC_INVALID_SOCKET
&&
data
!=
NULL
&&
count
<=
INT32_MAX
&&
sentBytes
!=
NULL
)
{
status
=
SOPC_STATUS_NOK
;
res
=
send
(
sock
,
(
char
*
)
data
,
count
,
0
);
res
=
send
(
sock
,
data
,
count
,
0
);
*
sentBytes
=
(
uint32_t
)
res
;
if
(
res
==
SOCKET_ERROR
)
if
(
res
>=
0
&&
(
uint32_t
)
res
==
count
)
{
status
=
SOPC_STATUS_OK
;
}
else
{
wsaError
=
WSAGetLastError
();
// ERROR CASE
if
(
wsaError
==
WSA
EWOULDBLOCK
)
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
// Try again in those cases
status
=
SOPC_STATUS_WOULD_BLOCK
;
}
// keep SOPC_STATUS_NOK
}
//
else: error,
keep SOPC_STATUS_NOK
}
else
if
(
res
>=
0
&&
(
uint32_t
)
res
==
count
)
{
status
=
SOPC_STATUS_OK
;
}
// else SOPC_STATUS_NOK
}
return
status
;
}
...
...
@@ -336,7 +354,14 @@ SOPC_ReturnStatus Socket_Read(Socket sock, uint8_t* data, uint32_t dataSize, int
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
if
(
sock
!=
SOPC_INVALID_SOCKET
&&
data
!=
NULL
&&
dataSize
>
0
)
{
*
readCount
=
recv
(
sock
,
(
char
*
)
data
,
dataSize
,
0
);
*
readCount
=
recv
(
sock
,
data
,
dataSize
,
0
);
/* Extract of man recv (release 3.54 of the Linux man-pages project):
* RETURN VALUE
* These calls return the number of bytes received, or -1 if an error occurred. In the event of an error,
* errno is set to indicate the error. The return value will be 0 when the peer has performed an orderly
* shutdown. */
if
(
*
readCount
>
0
)
{
status
=
SOPC_STATUS_OK
;
...
...
@@ -347,7 +372,13 @@ SOPC_ReturnStatus Socket_Read(Socket sock, uint8_t* data, uint32_t dataSize, int
}
else
if
(
*
readCount
==
-
1
)
{
if
(
WSAGetLastError
()
==
WSAEWOULDBLOCK
)
/* Extract of man recv (release 3.54 of the Linux man-pages project):
* If no messages are available at the socket, the receive calls wait for a message to arrive, unless the
* socket is onblocking (see fcntl(2)), in which case the value -1 is returned and the external variable
* errno is set to EAGAIN or WOULDBLOCK. The receive calls normally return any data available, up to the
* requested amount, rather than waiting for receipt of the full amount requested.*/
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
status
=
SOPC_STATUS_WOULD_BLOCK
;
}
...
...
@@ -364,9 +395,9 @@ void Socket_Close(Socket* sock)
{
if
(
sock
!=
NULL
&&
*
sock
!=
SOPC_INVALID_SOCKET
)
{
if
(
close
socket
(
*
sock
)
!=
SOCKET_ERROR
)
if
(
close
(
*
sock
)
!=
-
1
)
{
*
sock
=
-
1
;
*
sock
=
SOPC_INVALID_SOCKET
;
}
}
}
s2opc_stack/helpers_platform_dep/
w
in
dows
/p_sockets.h
→
s2opc_stack/helpers_platform_dep/
l
in
ux
/p_sockets.h
View file @
e796417d
...
...
@@ -18,18 +18,15 @@
#ifndef SOPC_P_SOCKETS_H_
#define SOPC_P_SOCKETS_H_
#include <
winsock2
.h>
#include <
ws2tcpip
.h>
#include <
netdb
.h>
#include <
sys/select
.h>
#define MAX_SEND_ATTEMPTS 20
#define SLEEP_NEXT_SEND_ATTEMP 50 // milliseconds
#define SOPC_INVALID_SOCKET INVALID_SOCKET
#define SOPC_INVALID_SOCKET -1
/**
* \brief Socket base type
*/
typedef
SOCKET
Socket
;
typedef
int
Socket
;
/**
* \brief Socket addressing information for listening or connecting operation type
...
...
@@ -39,6 +36,10 @@ typedef struct addrinfo Socket_AddressInfo;
/**
* \brief Set of sockets type
*/
typedef
fd_set
SocketSet
;
typedef
struct
{
int
fdmax
;
/**< max of the set */
fd_set
set
;
/**< set */
}
SocketSet
;
#endif
/* SOPC_P_SOCKETS_H_ */
s2opc_stack/helpers_platform_dep/
w
in
dows
/p_threads.c
→
s2opc_stack/helpers_platform_dep/
l
in
ux
/p_threads.c
View file @
e796417d
...
...
@@ -15,6 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <unistd.h>
#include "sopc_mutexes.h"
#include "sopc_threads.h"
#include "sopc_time.h"
...
...
@@ -22,10 +25,18 @@
SOPC_ReturnStatus
Condition_Init
(
Condition
*
cond
)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
retCode
=
0
;
if
(
cond
!=
NULL
)
{
InitializeConditionVariable
(
cond
);
status
=
SOPC_STATUS_OK
;
retCode
=
pthread_cond_init
(
cond
,
NULL
);
if
(
retCode
==
0
)
{
status
=
SOPC_STATUS_OK
;
}
else
{
status
=
SOPC_STATUS_NOK
;
}
}
return
status
;
}
...
...
@@ -33,9 +44,18 @@ SOPC_ReturnStatus Condition_Init(Condition* cond)
SOPC_ReturnStatus
Condition_Clear
(
Condition
*
cond
)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
retCode
=
0
;
if
(
cond
!=
NULL
)
{
status
=
SOPC_STATUS_OK
;
retCode
=
pthread_cond_destroy
(
cond
);
if
(
retCode
==
0
)
{
status
=
SOPC_STATUS_OK
;
}
else
{
status
=
SOPC_STATUS_NOK
;
}
}
return
status
;
}
...
...
@@ -43,10 +63,18 @@ SOPC_ReturnStatus Condition_Clear(Condition* cond)
SOPC_ReturnStatus
Condition_SignalAll
(
Condition
*
cond
)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
retCode
=
0
;
if
(
cond
!=
NULL
)
{
WakeAllConditionVariable
(
cond
);
status
=
SOPC_STATUS_OK
;
retCode
=
pthread_cond_broadcast
(
cond
);
if
(
retCode
==
0
)
{
status
=
SOPC_STATUS_OK
;
}
else
{
status
=
SOPC_STATUS_NOK
;
}
}
return
status
;
}
...
...
@@ -54,10 +82,18 @@ SOPC_ReturnStatus Condition_SignalAll(Condition* cond)
SOPC_ReturnStatus
Mutex_Initialization
(
Mutex
*
mut
)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
retCode
=
0
;
if
(
mut
!=
NULL
)
{
InitializeSRWLock
(
mut
);
status
=
SOPC_STATUS_OK
;
retCode
=
pthread_mutex_init
(
mut
,
NULL
);
if
(
retCode
==
0
)
{
status
=
SOPC_STATUS_OK
;
}
else
{
status
=
SOPC_STATUS_NOK
;
}
}
return
status
;
}
...
...
@@ -65,9 +101,18 @@ SOPC_ReturnStatus Mutex_Initialization(Mutex* mut)
SOPC_ReturnStatus
Mutex_Clear
(
Mutex
*
mut
)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
retCode
=
0
;
if
(
mut
!=
NULL
)
{
status
=
SOPC_STATUS_OK
;
retCode
=
pthread_mutex_destroy
(
mut
);
if
(
retCode
==
0
)
{
status
=
SOPC_STATUS_OK
;
}
else
{
status
=
SOPC_STATUS_NOK
;
}
}
return
status
;
}
...
...
@@ -75,10 +120,18 @@ SOPC_ReturnStatus Mutex_Clear(Mutex* mut)
SOPC_ReturnStatus
Mutex_Lock
(
Mutex
*
mut
)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
retCode
=
0
;
if
(
mut
!=
NULL
)
{
AcquireSRWLockExclusive
(
mut
);
status
=
SOPC_STATUS_OK
;
retCode
=
pthread_mutex_lock
(
mut
);
if
(
retCode
==
0
)
{
status
=
SOPC_STATUS_OK
;
}
else
{
status
=
SOPC_STATUS_NOK
;
}
}
return
status
;
}
...
...
@@ -86,10 +139,18 @@ SOPC_ReturnStatus Mutex_Lock(Mutex* mut)
SOPC_ReturnStatus
Mutex_Unlock
(
Mutex
*
mut
)
{
SOPC_ReturnStatus
status
=
SOPC_STATUS_INVALID_PARAMETERS
;
int
retCode
=
0
;
if
(
mut
!=
NULL
)
{
ReleaseSRWLockExclusive
(
mut
);
status
=
SOPC_STATUS_OK
;
retCode
=
pthread_mutex_unlock
(
mut
);
if
(
retCode
==
0
)
{