Skip to content

Instantly share code, notes, and snippets.

@llueder
Created September 27, 2019 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llueder/72604b607de748a660c627c19dea775e to your computer and use it in GitHub Desktop.
Save llueder/72604b607de748a660c627c19dea775e to your computer and use it in GitHub Desktop.
diff --git a/core/include/rmutex.h b/core/include/rmutex.h
index 77553fb40..59f4bff40 100644
--- a/core/include/rmutex.h
+++ b/core/include/rmutex.h
@@ -24,7 +24,12 @@
#define RMUTEX_H
#include <stdint.h>
+#ifdef __cplusplus
+#include <atomic>
+using namespace std;
+#else
#include <stdatomic.h>
+#endif
#include "mutex.h"
#include "kernel_types.h"
@@ -59,8 +64,18 @@ typedef struct rmutex_t {
* @internal
*/
atomic_int_least16_t owner;
+
+#ifdef __cplusplus
+ rmutex_t& operator=(const rmutex_t& other){
+ mutex = other.mutex;
+ refcount = other.refcount;
+ atomic_store(&owner,atomic_load(&other.owner));
+ return *this;
+ }
+#endif
} rmutex_t;
+
/**
* @brief Static initializer for rmutex_t.
* @details This initializer is preferable to rmutex_init().
diff --git a/tests/gnrc_tcp_client/main.c b/tests/gnrc_tcp_client/main.cpp
similarity index 96%
rename from tests/gnrc_tcp_client/main.c
rename to tests/gnrc_tcp_client/main.cpp
index 4d4d68d5a..ab0440541 100644
--- a/tests/gnrc_tcp_client/main.c
+++ b/tests/gnrc_tcp_client/main.cpp
@@ -42,6 +42,10 @@ uint8_t stacks[CONNS][THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF];
void *cli_thread(void *arg);
+class ClassToTestCpp{
+ ClassToTestCpp() = default;
+};
+
int main(void)
{
gnrc_netif_t *netif;
@@ -229,9 +233,9 @@ void *cli_thread(void *arg)
if (ret >= 0) {
cycles_ok += 1;
}
- printf("TID=%d : %"PRIi32" test cycles completed. %"PRIi32" ok, %"PRIi32" faulty",
+ printf("TID=%d : %" PRIi32 " test cycles completed. %" PRIi32 " ok, %" PRIi32 " faulty",
tid, cycles, cycles_ok, cycles - cycles_ok);
- printf(", %"PRIi32" failed payload verifications\n", failed_payload_verifications);
+ printf(", %" PRIi32 " failed payload verifications\n", failed_payload_verifications);
}
printf("client thread terminating: TID=%d\n", tid);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment