Commit e7f9e560 authored by Joseph Noir's avatar Joseph Noir

Change thrown exception to gcc compatibility

parent b64f0644
......@@ -23,7 +23,8 @@
#ifdef __RIOTBUILD_FLAG
#include <utility>
#include <system_error>
//#include <system_error>
#include <stdexcept>
#include <cstdio>
......@@ -160,10 +161,12 @@ class unique_lock {
template<class Mutex>
void unique_lock<Mutex>::lock() {
if (m_mtx == nullptr) {
std::__throw_system_error(EPERM, "unique_lock::lock: references null mutex");
//std::__throw_system_error(EPERM, "unique_lock::lock: references null mutex");
throw std::runtime_error("unique_lock::lock: references null mutex");
}
if (m_owns) {
std::__throw_system_error(EDEADLK, "unique_lock::lock: already locked");
//std::__throw_system_error(EDEADLK, "unique_lock::lock: already locked");
throw std::runtime_error("");
}
m_mtx->lock();
m_owns = true;
......@@ -172,11 +175,12 @@ void unique_lock<Mutex>::lock() {
template<class Mutex>
bool unique_lock<Mutex>::try_lock() {
if (m_mtx == nullptr) {
std::__throw_system_error(EPERM,
"unique_lock::try_lock: references null mutex");
//std::__throw_system_error(EPERM,
throw std::runtime_error("unique_lock::try_lock: references null mutex");
}
if (m_owns) {
std::__throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");
//std::__throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");
throw std::runtime_error("unique_lock::try_lock lock: already locked");
}
m_owns = m_mtx->try_lock();
return m_owns;
......@@ -215,7 +219,8 @@ bool unique_lock<Mutex>::try_lock() {
template<class Mutex>
void unique_lock<Mutex>::unlock() {
if (!m_owns) {
std::__throw_system_error(EPERM, "unique_lock::unlock: not locked");
//std::__throw_system_error(EPERM, "unique_lock::unlock: not locked");
throw std::runtime_error("unique_lock::unlock: not locked");
}
m_mtx->unlock();
m_owns = false;
......
......@@ -26,11 +26,13 @@
#include <tuple>
#include <chrono>
#include <memory>
#include <utility>
#include <exception>
#include <functional>
#include <type_traits>
#include <system_error>
//#include <system_error>
#include <stdexcept>
extern "C" {
#include "thread.h"
......@@ -191,8 +193,8 @@ thread::thread(F&& f, Args&&... args) {
if (m_handle >= 0) {
p.release();
} else {
std::__throw_system_error(static_cast<int>(m_handle),
"Failed to create thread.");
//std::__throw_system_error(static_cast<int>(m_handle),
throw std::runtime_error("Failed to create thread.");
}
}
......
#include <system_error>
//#include <system_error>
#include <stdexcept>
extern "C" {
#include "irq.h"
#include "vtimer.h"
#include "sched.h"
#include "vtimer.h"
#include "priority_queue.h"
}
#include "caf/condition_variable.hpp"
......@@ -18,28 +20,21 @@ condition_variable::~condition_variable() {
}
void condition_variable::notify_one() noexcept {
printf("notify_one start\n");
unsigned old_state = disableIRQ();
priority_queue_node_t *head = priority_queue_remove_head(&m_queue);
int other_prio = -1;
if (head != NULL) {
printf("notify_one -> head is not NULL\n");
tcb_t *other_thread = (tcb_t *) sched_threads[head->data];
if (other_thread) {
printf("notify_one -> other thread exists\n");
other_prio = other_thread->priority;
sched_set_status(other_thread, STATUS_PENDING);
}
head->data = -1u;
}
restoreIRQ(old_state);
printf("notify_one -> restored irq\n");
if (other_prio >= 0) {
printf("notify_one -> sched_switch incoming\n");
sched_switch(other_prio);
printf("notify_one -> sched_switch called\n");
}
printf("notify_one end\n");
}
void condition_variable::notify_all() noexcept {
......@@ -68,8 +63,8 @@ void condition_variable::notify_all() noexcept {
void condition_variable::wait(unique_lock<mutex>& lock) noexcept {
if (!lock.owns_lock()) {
std::__throw_system_error(EPERM,
"condition_variable::wait: mutex not locked");
// std::__throw_system_error(EPERM,
throw std::runtime_error("condition_variable::wait: mutex not locked");
}
priority_queue_node_t n;
n.priority = sched_active_thread->priority;
......@@ -95,8 +90,8 @@ void condition_variable::wait(unique_lock<mutex>& lock) noexcept {
time_point<system_clock,
nanoseconds> tp) noexcept {
if (!lock.owns_lock()) {
std::__throw_system_error(EPERM,
"condition_variable::timed wait: mutex not locked");
//std::__throw_system_error(EPERM,
throw std::runtime_error("condition_variable::timed wait: mutex not locked");
}
nanoseconds d = tp.time_since_epoch();
if (d > nanoseconds(0x59682F000000E941)) {
......
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