Skip to content

Commit 08b9a07

Browse files
committed
iox-eclipse-iceoryx#33 adding stub functions so that windows at least compiles; semaphore implemented
Signed-off-by: Christian Eltzschig <[email protected]>
1 parent 34a1845 commit 08b9a07

File tree

26 files changed

+237
-34
lines changed

26 files changed

+237
-34
lines changed

iceoryx_utils/include/iceoryx_utils/fixed_string/string100.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CString100
5757
// >0 the first character that does not match has a greater value in str1 than in str2
5858
int32_t compare(const CString100& str2) const;
5959

60-
uint capacity() const;
60+
unsigned int capacity() const;
6161

6262
const char* to_cstring() const;
6363

@@ -87,4 +87,3 @@ inline std::ostream& operator<<(std::ostream& stream, const iox::cxx::CString100
8787
stream << string.to_cstring();
8888
return stream;
8989
}
90-

iceoryx_utils/include/iceoryx_utils/internal/concurrent/trigger_queue.hpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515
#pragma once
1616

17-
#include "iceoryx_utils/internal/concurrent/smart_lock.hpp"
1817
#include "iceoryx_utils/cxx/optional.hpp"
18+
#include "iceoryx_utils/internal/concurrent/smart_lock.hpp"
1919
#include "iceoryx_utils/posix_wrapper/semaphore.hpp"
2020

21+
2122
#include <cstdint>
2223
#include <queue>
2324

@@ -93,10 +94,7 @@ class TriggerQueue
9394
/// methods which can be autogenerated by the compiler, ctor, dtor, copy,
9495
/// move) we check CAPACITY > 0 by declaring a member variable via a
9596
/// lambda which itselfs contains the check.
96-
bool compileTimeCheck = []() {
97-
static_assert(CAPACITY > 0, "The trigger queue must have at least one element!");
98-
return true;
99-
};
97+
static_assert(CAPACITY > 0, "The trigger queue must have at least one element!");
10098

10199
public:
102100
/// @todo replace this with a multi push / multi pop lockfree fifo
@@ -168,4 +166,3 @@ class TriggerQueue
168166
} // namespace iox
169167

170168
#include "iceoryx_utils/internal/concurrent/trigger_queue.inl"
171-

iceoryx_utils/include/iceoryx_utils/internal/posix_wrapper/posix_access_rights.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "iceoryx_utils/cxx/optional.hpp"
1818
#include "iceoryx_utils/cxx/vector.hpp"
1919

20+
#include "iceoryx_utils/platform/types.hpp"
21+
2022
#include <string>
2123

2224
namespace iox
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
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/acl.hpp

+54-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,60 @@
2121
#define ACL_OTHER 4
2222
#define ACL_READ 5
2323
#define ACL_WRITE 6
24+
#define ACL_MASK 7
2425

25-
using acl_t = int;
26+
struct __acl_ext
27+
{
28+
};
29+
30+
using acl_t = struct __acl_ext*;
2631
using acl_permset_t = int;
2732
using acl_perm_t = int;
33+
using acl_entry_t = int;
34+
using acl_tag_t = int;
35+
36+
inline int acl_valid(acl_t acl)
37+
{
38+
return 0;
39+
}
40+
41+
inline int acl_set_fd(int fd, acl_t acl)
42+
{
43+
return 0;
44+
}
45+
46+
inline acl_t acl_init(int count)
47+
{
48+
static struct __acl_ext stub;
49+
return &stub;
50+
}
51+
52+
inline int acl_free(void*)
53+
{
54+
return 0;
55+
}
56+
57+
inline int acl_create_entry(acl_t* acl_p, acl_entry_t* entry_p)
58+
{
59+
return 0;
60+
}
61+
62+
inline int acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type)
63+
{
64+
return 0;
65+
}
66+
67+
inline int acl_set_qualifier(acl_entry_t entry_d, const void* qualifier_p)
68+
{
69+
return 0;
70+
}
71+
72+
inline int acl_get_permset(acl_entry_t entry_d, acl_permset_t* permset_p)
73+
{
74+
return 0;
75+
}
76+
77+
int acl_add_perm(acl_permset_t permset_d, acl_perm_t perm)
78+
{
79+
return 0;
80+
}
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+
#define __PRETTY_FUNCTION__ __FUNCSIG__

iceoryx_utils/platform/win/include/iceoryx_utils/platform/pthread.hpp

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

1717
#include <thread>
1818

19+
#define PTHREAD_PROCESS_SHARED 0
20+
#define PTHREAD_MUTEX_RECURSIVE_NP 1
21+
#define PTHREAD_MUTEX_FAST_NP 2
22+
#define PTHREAD_PRIO_NONE 3
23+
1924
using pthread_mutex_t = int;
2025
using pthread_mutexattr_t = int;
2126
using pthread_t = std::thread::native_handle_type;
@@ -24,3 +29,53 @@ inline int pthread_setname_np(pthread_t thread, const char* name)
2429
{
2530
return 0;
2631
}
32+
33+
inline int pthread_mutexattr_destroy(pthread_mutexattr_t* attr)
34+
{
35+
return 0;
36+
}
37+
38+
inline int pthread_mutexattr_init(pthread_mutexattr_t* attr)
39+
{
40+
return 0;
41+
}
42+
43+
inline int pthread_mutexattr_setpshared(pthread_mutexattr_t* attr, int pshared)
44+
{
45+
return 0;
46+
}
47+
48+
inline int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type)
49+
{
50+
return 0;
51+
}
52+
53+
inline int pthread_mutexattr_setprotocol(pthread_mutexattr_t* attr, int protocol)
54+
{
55+
return 0;
56+
}
57+
58+
inline int pthread_mutex_destroy(pthread_mutex_t* mutex)
59+
{
60+
return 0;
61+
}
62+
63+
inline int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr)
64+
{
65+
return 0;
66+
}
67+
68+
inline int pthread_mutex_lock(pthread_mutex_t* mutex)
69+
{
70+
return 0;
71+
}
72+
73+
inline int pthread_mutex_trylock(pthread_mutex_t* mutex)
74+
{
75+
return 0;
76+
}
77+
78+
inline int pthread_mutex_unlock(pthread_mutex_t* mutex)
79+
{
80+
return 0;
81+
}

iceoryx_utils/platform/win/include/iceoryx_utils/platform/semaphore.hpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616

1717
#include "iceoryx_utils/platform/types.hpp"
1818

19+
#include <cstdlib>
1920
#include <stdio.h>
21+
#include <type_traits>
2022
#include <windows.h>
2123

2224
#define SEM_FAILED 0
2325

24-
using sem_t = HANDLE;
26+
using sem_t = PVOID;
2527
static constexpr LONG MAX_SEMAPHORE_VALUE = LONG_MAX;
28+
static constexpr int MAX_SEMAPHORE_NAME_LENGTH = 128;
2629

2730
inline int sem_getvalue(sem_t* sem, int* sval)
2831
{
29-
static_assert(false, "Not available for Windows");
30-
return 0;
32+
return -1;
3133
}
3234

3335
inline int sem_post(sem_t* sem)
@@ -87,7 +89,9 @@ inline int sem_init(sem_t* sem, int pshared, unsigned int value)
8789

8890
inline sem_t* sem_open(const char* name, int oflag, mode_t mode, unsigned int value)
8991
{
90-
return OpenSemaphoreW(0, false, name);
92+
wchar_t semaphoreName[MAX_SEMAPHORE_NAME_LENGTH];
93+
mbstowcs(semaphoreName, name, MAX_SEMAPHORE_NAME_LENGTH);
94+
return static_cast<sem_t*>(OpenSemaphoreW(0, false, semaphoreName));
9195
}
9296

9397
inline int sem_unlink(const char* name)

iceoryx_utils/platform/win/include/iceoryx_utils/platform/stat.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
#define S_IWGRP 3
2121
#define S_IROTH 4
2222
#define S_IWOTH 5
23+
#define O_NONBLOCK 6

iceoryx_utils/platform/win/include/iceoryx_utils/platform/time.hpp

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

1515
#pragma once
1616

17+
#include <time.h>
18+
1719
#define CLOCK_REALTIME 0
1820
#define CLOCK_MONOTONIC 01
1921

20-
// using time_t = int;
2122
using suseconds_t = int;
2223
using timer_t = void*;
2324
using clockid_t = int;
@@ -28,12 +29,6 @@ struct timeval
2829
suseconds_t tv_usec;
2930
};
3031

31-
// struct timespec
32-
//{
33-
// time_t tv_sec;
34-
// long tv_nsec;
35-
//};
36-
3732
struct itimerspec
3833
{
3934
timespec it_interval;

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

+5
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ using nlink_t = int;
2323
using blksize_t = int;
2424
using blkcnt_t = int;
2525
// using off_t = int;
26+
27+
mode_t umask(mode_t mask)
28+
{
29+
return mode_t();
30+
}

iceoryx_utils/source/concurrent/locked_loffli.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#include "iceoryx_utils/internal/concurrent/locked_loffli.hpp"
16+
#include "iceoryx_utils/platform/platform-correction.hpp"
1617

1718
#include <cassert>
1819

iceoryx_utils/source/concurrent/loffli.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#include "iceoryx_utils/internal/concurrent/loffli.hpp"
16+
#include "iceoryx_utils/platform/platform-correction.hpp"
1617

1718
#include <cassert>
1819

iceoryx_utils/source/file_reader/file_reader.cpp

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

1515
#include "iceoryx_utils/internal/file_reader/file_reader.hpp"
1616

17+
#include <string>
18+
1719
namespace iox
1820
{
1921
namespace cxx

iceoryx_utils/source/fixed_string/string100.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int32_t CString100::compare(const CString100& str2) const
100100
return strncmp(m_string_vector.data(), str2.m_string_vector.data(), MaxStringSize);
101101
}
102102

103-
uint CString100::capacity() const
103+
unsigned int CString100::capacity() const
104104
{
105105
return MaxStringSize;
106106
}

0 commit comments

Comments
 (0)