Commit 17917a5f authored by Andreas Schmidt's avatar Andreas Schmidt

Fix C++ atomic.

parent 07bc5741
Pipeline #2149 passed with stages
in 1 minute and 8 seconds
......@@ -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})
......@@ -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
......
#ifndef PRRT_SOCKET_H
#define PRRT_SOCKET_H
#include <stdatomic.h>
#include "../defines.h"
#include "../util/list.h"
#include "../util/pipe.h"
......
#include <pthread.h>
#include <stdatomic.h>
#include "../../defines.h"
#include "../types/packet.h"
#include "../../util/common.h"
#include "../../util/dbg.h"
......
......@@ -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;
......
#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;
atomic_int space;
atomic_int items;
_Atomic(int) space;
_Atomic(int) items;
} Pipe;
......
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
#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);
......
#include <gtest/gtest.h>
#include "common.h"
extern "C" {
#include "prrt/util/bitmap.h"
......
#include <gtest/gtest.h>
#include "common.h"
extern "C" {
#include "prrt/util/bptree.h"
......
#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
#include <gtest/gtest.h>
#include "common.h"
#include <cmath>
#include <prrt/proto/types/packet.h>
......
#include <gtest/gtest.h>
#include "common.h"
extern "C" {
#include "prrt/proto/stores/receptionTable.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment