Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
PRRT
Commits
17917a5f
Commit
17917a5f
authored
Mar 26, 2018
by
Andreas Schmidt
Browse files
Fix C++ atomic.
parent
07bc5741
Pipeline
#2149
passed with stages
in 1 minute and 8 seconds
Changes
13
Pipelines
1
Show whitespace changes
Inline
Side-by-side
prrt/CMakeLists.txt
View file @
17917a5f
...
...
@@ -15,7 +15,7 @@ add_subdirectory(proto)
add_subdirectory
(
util
)
add_executable
(
sender sender.c
)
add_executable
(
receiver receiver.c
)
add_executable
(
receiver receiver.c
../tests/common.h
)
target_link_libraries
(
sender LINK_PUBLIC PRRT UTIL
${
CMAKE_THREAD_LIBS_INIT
}
)
target_link_libraries
(
receiver LINK_PUBLIC PRRT UTIL
${
CMAKE_THREAD_LIBS_INIT
}
)
prrt/defines.h
View file @
17917a5f
...
...
@@ -5,6 +5,13 @@
# define __builtin_ia32_rdtsc() (0)
#endif
#ifndef __cplusplus
# include <stdatomic.h>
#else
# include <atomic>
# define _Atomic(X) std::atomic< X >
#endif
#ifndef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
...
...
prrt/proto/socket.h
View file @
17917a5f
#ifndef PRRT_SOCKET_H
#define PRRT_SOCKET_H
#include
<stdatomic.h>
#include
"../defines.h"
#include
"../util/list.h"
#include
"../util/pipe.h"
...
...
prrt/proto/stores/packetDeliveryStore.c
View file @
17917a5f
#include
<pthread.h>
#include
<stdatomic
.h
>
#include
"../../defines
.h
"
#include
"../types/packet.h"
#include
"../../util/common.h"
#include
"../../util/dbg.h"
...
...
prrt/util/mpsc_queue.h
View file @
17917a5f
...
...
@@ -5,7 +5,7 @@
#define PRRT_MPSC_QUEUE_H
#include
<stdint.h>
#include
<stdatomic
.h
>
#include
"../defines
.h
"
typedef
struct
mpscq_node_t
mpscq_node_t
;
...
...
prrt/util/pipe.h
View file @
17917a5f
#ifndef PRRT_PIPE_H
#define PRRT_PIPE_H
#include
"../defines.h"
#include
"list.h"
#include
"mpsc_queue.h"
#include
<pthread.h>
#include
<stdatomic.h>
typedef
struct
pipe
{
_Atomic
(
mpscq_node_t
*
)
head
;
mpscq_node_t
*
tail
;
a
tomic
_
int
space
;
a
tomic
_
int
items
;
_A
tomic
(
int
)
space
;
_A
tomic
(
int
)
items
;
}
Pipe
;
...
...
tests/CMakeLists.txt
View file @
17917a5f
add_subdirectory
(
lib/gtest-1.8.0
)
include_directories
(
SYSTEM
${
gtest_SOURCE_DIR
}
/include
${
gtest_SOURCE_DIR
}
)
add_executable
(
prrtTests bitmap_tests.cpp receptionTable_tests.cpp delivered_packet_table_tests.cpp bptree_tests.cpp PrrtBlock_tests.cpp
)
add_executable
(
prrtTests
common.h
bitmap_tests.cpp receptionTable_tests.cpp delivered_packet_table_tests.cpp bptree_tests.cpp PrrtBlock_tests.cpp
)
target_link_libraries
(
prrtTests LINK_PUBLIC gtest PRRT UTIL gtest_main
)
\ No newline at end of file
tests/PrrtBlock_tests.cpp
View file @
17917a5f
#include
<gtest/gtest
.h
>
#include
"common
.h
"
extern
"C"
{
...
...
@@ -15,7 +15,8 @@ protected:
virtual
void
SetUp
()
{
cpar
=
PrrtCodingParams_create
();
PrrtCodingParams_update
(
cpar
,
4
,
7
);
// TODO: Should be [3] instead of of NULL
PrrtCodingParams_update
(
cpar
,
4
,
7
,
1
,
NULL
);
encBlock
=
PrrtBlock_create
(
cpar
,
1
);
decBlock
=
PrrtBlock_create
(
cpar
,
1
);
}
...
...
@@ -169,7 +170,7 @@ TEST_F(PrrtBlockTest, EncodeDecode)
TEST_F
(
PrrtBlockTest
,
NoCodingConfigured
)
{
PrrtCodingParams
*
cpar
=
PrrtCodingParams_create
();
PrrtCodingParams_update
(
cpar
,
1
,
1
);
PrrtCodingParams_update
(
cpar
,
1
,
1
,
1
,
NULL
);
PrrtBlock
*
encBlock
=
PrrtBlock_create
(
cpar
,
1
);
PrrtBlock
*
decBlock
=
PrrtBlock_create
(
cpar
,
1
);
...
...
tests/bitmap_tests.cpp
View file @
17917a5f
#include
<gtest/gtest
.h
>
#include
"common
.h
"
extern
"C"
{
#include
"prrt/util/bitmap.h"
...
...
tests/bptree_tests.cpp
View file @
17917a5f
#include
<gtest/gtest
.h
>
#include
"common
.h
"
extern
"C"
{
#include
"prrt/util/bptree.h"
...
...
tests/common.h
0 → 100644
View file @
17917a5f
#ifndef PRRT_COMMON_H
#define PRRT_COMMON_H
#include
<gtest/gtest.h>
#ifndef __cplusplus
# include <stdatomic.h>
#else
# include <atomic>
# define _Atomic(X) std::atomic< X >
#endif
#endif //PRRT_COMMON_H
tests/delivered_packet_table_tests.cpp
View file @
17917a5f
#include
<gtest/gtest.h>
#include
"common.h"
#include
<cmath>
#include
<prrt/proto/types/packet.h>
...
...
tests/receptionTable_tests.cpp
View file @
17917a5f
#include
<gtest/gtest
.h
>
#include
"common
.h
"
extern
"C"
{
#include
"prrt/proto/stores/receptionTable.h"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment