Skip to content

Commit 99b5608

Browse files
committed
iox-eclipse-iceoryx#33 added un.hpp platform header for socket support; some casting for mmap return value type deduction
Signed-off-by: Christian Eltzschig <[email protected]>
1 parent 4b1acc3 commit 99b5608

File tree

9 files changed

+105
-10
lines changed

9 files changed

+105
-10
lines changed

iceoryx_utils/include/iceoryx_utils/internal/posix_wrapper/unix_domain_socket.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
#include "iceoryx_utils/internal/units/duration.hpp"
2222
#include "iceoryx_utils/platform/mqueue.hpp"
2323
#include "iceoryx_utils/platform/stat.hpp"
24+
#include "iceoryx_utils/platform/un.hpp"
2425

2526
#include <fcntl.h>
2627
#include <iostream>
27-
#include <sys/un.h>
2828

2929
namespace iox
3030
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once
16+
17+
#include <sys/un.h>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once

iceoryx_utils/platform/win/include/iceoryx_utils/platform/socket.hpp

+21
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
#define AF_INET 0
1818
#define SOCK_STREAM 1
19+
#define SOL_SOCKET 2
20+
#define SO_SNDTIMEO 3
21+
#define SO_RCVTIMEO 4
22+
#define AF_LOCAL 5
23+
#define SOCK_DGRAM 6
1924

2025
using in_port_t = int;
2126
using sa_family_t = int;
@@ -59,3 +64,19 @@ inline int socket(int domain, int type, int protocol)
5964
{
6065
return 0;
6166
}
67+
68+
inline int setsockopt(int sockfd, int level, int optname, const void* optval, socklen_t optlen)
69+
{
70+
return 0;
71+
}
72+
73+
inline ssize_t
74+
sendto(int sockfd, const void* buf, size_t len, int flags, const struct sockaddr* dest_addr, socklen_t addrlen)
75+
{
76+
return 0;
77+
}
78+
79+
inline ssize_t recvfrom(int sockfd, void* buf, size_t len, int flags, struct sockaddr* src_addr, socklen_t* addrlen)
80+
{
81+
return 0;
82+
}

iceoryx_utils/platform/win/include/iceoryx_utils/platform/types.hpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#pragma once
1616

17+
#include <sys/types.h>
18+
1719
using gid_t = int;
1820
using uid_t = int;
1921
using mode_t = int;
@@ -22,9 +24,9 @@ using pid_t = int;
2224
using nlink_t = int;
2325
using blksize_t = int;
2426
using blkcnt_t = int;
25-
// using off_t = int;
27+
// using off_t = int;
2628

27-
mode_t umask(mode_t mask)
28-
{
29-
return mode_t();
30-
}
29+
// mode_t umask(mode_t mask)
30+
//{
31+
// return mode_t();
32+
//}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once
16+
17+
#include "iceoryx_utils/platform/socket.hpp"
18+
19+
struct sockaddr_un
20+
{
21+
sa_family_t sun_family;
22+
char sun_path[108];
23+
};

iceoryx_utils/source/posix_wrapper/shared_memory_object/memory_map.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ MemoryMap::MemoryMap(const void* f_baseAddressHint,
5757
l_memoryProtection = PROT_READ | PROT_WRITE;
5858
break;
5959
}
60-
auto mmapCall = cxx::makeSmartC(mmap,
60+
auto mmapCall = cxx::makeSmartC(static_cast<void* (*)(void*, size_t, int, int, int, off_t)>(mmap),
6161
cxx::ReturnMode::PRE_DEFINED_ERROR_CODE,
62-
{MAP_FAILED},
62+
// we have to perform reinterpret cast since mmap returns MAP_FAILED on error which
63+
// is defined as (void*) -1; see man mmap for that definition
64+
{reinterpret_cast<void*>(MAP_FAILED)},
6365
{},
6466
const_cast<void*>(f_baseAddressHint),
6567
f_length,

iceoryx_utils/source/posix_wrapper/unix_domain_socket.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
#include "iceoryx_utils/internal/posix_wrapper/unix_domain_socket.hpp"
1616
#include "iceoryx_utils/cxx/smart_c.hpp"
17+
#include "iceoryx_utils/platform/socket.hpp"
18+
#include "iceoryx_utils/platform/unistd.hpp"
1719

1820
#include <chrono>
1921
#include <cstdlib>
20-
#include <sys/socket.h>
21-
#include <unistd.h>
2222

2323
namespace iox
2424
{

0 commit comments

Comments
 (0)