Skip to content

Commit

Permalink
base-foc: move util/assert to foc/assert.h
Browse files Browse the repository at this point in the history
Since the ASSERT macro is Fiasco.OC-specific, this patch moves it to a
Fiasco.OC-specific place (foc/assert.h) and prefixes it with "FOC_".

Issue genodelabs#1832
  • Loading branch information
nfeske committed Jan 25, 2016
1 parent cb5861e commit b7959dc
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
8 changes: 4 additions & 4 deletions repos/base-foc/include/base/cap_alloc.h
Expand Up @@ -17,11 +17,11 @@
/* Genode includes */
#include <base/cap_map.h>
#include <base/native_types.h>
#include <util/assert.h>
#include <util/construct_at.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>
#include <foc/assert.h>

/* base-internal includes */
#include <base/internal/utcb_regs.h>
Expand Down Expand Up @@ -86,7 +86,7 @@ namespace Genode {
return &_indices[i];
}
}
ASSERT(0, "cap index allocation failed");
FOC_ASSERT(0, "cap index allocation failed");
return 0;
}

Expand All @@ -101,7 +101,7 @@ namespace Genode {
T* obj = reinterpret_cast<T*>(kcap_to_idx(addr));

if (obj < &_indices[0] || obj >= &_indices[SZ]) {
ASSERT(0, "cap index out of bounds");
FOC_ASSERT(0, "cap index out of bounds");
throw Index_out_of_bounds();
}

Expand All @@ -116,7 +116,7 @@ namespace Genode {
for (size_t i = 0; i < cnt; obj++, i++) {
/* range check given pointer address */
if (obj < &_indices[0] || obj >= &_indices[SZ]) {
ASSERT(0, "cap index out of bounds");
FOC_ASSERT(0, "cap index out of bounds");
throw Index_out_of_bounds();
}
delete obj;
Expand Down
Expand Up @@ -11,17 +11,16 @@
* under the terms of the GNU General Public License version 2.
*/

#ifndef _INCLUDE__UTIL__ASSERT_H_
#define _INCLUDE__UTIL__ASSERT_H_

#include <base/printf.h>
#ifndef _INCLUDE__FOC__ASSERT_H_
#define _INCLUDE__FOC__ASSERT_H_

/* Fiasco.OC includes */
namespace Fiasco {
#include <l4/sys/kdebug.h>
}

#if 1
#define ASSERT(e, s) \
#define FOC_ASSERT(e, s) \
do { if (!(e)) { \
Fiasco::outstring(ESC_ERR s ESC_END "\n"); \
Fiasco::outstring(__FILE__ ":"); \
Expand All @@ -31,7 +30,7 @@ namespace Fiasco {
} \
} while(0)
#else
#define ASSERT(e, s) do { } while (0)
#define FOC_ASSERT(e, s) do { } while (0)
#endif

#endif /* _INCLUDE__UTIL__ASSERT_H_ */
#endif /* _INCLUDE__FOC__ASSERT_H_ */
5 changes: 3 additions & 2 deletions repos/base-foc/src/base/env/cap_map.cc
Expand Up @@ -17,7 +17,8 @@
#include <base/cap_map.h>
#include <base/native_types.h>

#include <util/assert.h>
/* Fiasco.OC-specific Genode includes */
#include <foc/assert.h>

/* base-internal includes */
#include <base/internal/spin_lock.h>
Expand Down Expand Up @@ -98,7 +99,7 @@ Genode::Cap_index* Genode::Capability_map::insert(int id)

Lock_guard<Spin_lock> guard(_lock);

ASSERT(!_tree.first() || !_tree.first()->find_by_id(id),
FOC_ASSERT(!_tree.first() || !_tree.first()->find_by_id(id),
"Double insertion in cap_map()!");

Cap_index *i = cap_idx_alloc()->alloc_range(1);
Expand Down
4 changes: 2 additions & 2 deletions repos/base-foc/src/base/ipc/ipc.cc
Expand Up @@ -25,10 +25,10 @@
#include <base/ipc.h>
#include <base/ipc_msgbuf.h>
#include <base/thread.h>
#include <util/assert.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/cap_selectors.h>
#include <foc/assert.h>

/* base-internal includes */
#include <base/internal/lock_helper.h> /* for 'thread_get_my_native_id()' */
Expand Down Expand Up @@ -67,7 +67,7 @@ void Ipc_ostream::_marshal_capability(Native_capability const &cap)
if (cap.valid())
_snd_msg->snd_append_cap_sel(cap.dst());

ASSERT(!cap.valid() ||
FOC_ASSERT(!cap.valid() ||
l4_msgtag_label(l4_task_cap_valid(L4_BASE_TASK_CAP, cap.dst())),
"Send invalid cap");
}
Expand Down
7 changes: 4 additions & 3 deletions repos/base-foc/src/core/rpc_cap_factory.cc
Expand Up @@ -17,6 +17,9 @@
#include <base/cap_alloc.h>
#include <util/misc_math.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/assert.h>

/* core includes */
#include <rpc_cap_factory.h>
#include <cap_id_alloc.h>
Expand All @@ -31,8 +34,6 @@ namespace Fiasco {
#include <l4/sys/types.h>
}

#include <util/assert.h>

using namespace Genode;


Expand Down Expand Up @@ -99,7 +100,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep)

Core_cap_index* ref = static_cast<Core_cap_index*>(ep.idx());

ASSERT(ref && ref->pt(), "No valid platform_thread");
FOC_ASSERT(ref && ref->pt(), "No valid platform_thread");

/*
* Allocate new id, and ipc-gate and set id as gate-label
Expand Down
10 changes: 7 additions & 3 deletions repos/ports-foc/src/lib/l4lx/genode_block.cc
Expand Up @@ -11,16 +11,20 @@
* under the terms of the GNU General Public License version 2.
*/

/* Genode includes */
#include <base/env.h>
#include <base/printf.h>
#include <base/allocator_avl.h>
#include <block_session/connection.h>
#include <os/config.h>
#include <util/assert.h>

/* Fiasco.OC-specific Genode includes */
#include <foc/assert.h>

#include <vcpu.h>
#include <linux.h>

/* Fiasco.OC includes */
namespace Fiasco {
#include <genode/block.h>
#include <l4/sys/irq.h>
Expand Down Expand Up @@ -62,15 +66,15 @@ namespace {
void insert(void *packet, void *request)
{
int idx = _find(0);
ASSERT(idx >= 0, "Req cache full!");
FOC_ASSERT(idx >= 0, "Req cache full!");

_cache[idx] = Req_entry(packet, request);
}

void remove(void *packet, void **request)
{
int idx = _find(packet);
ASSERT(idx >= 0, "Req cache entry not found!");
FOC_ASSERT(idx >= 0, "Req cache entry not found!");

*request = _cache[idx].req;
_cache[idx].pkt = 0;
Expand Down

0 comments on commit b7959dc

Please sign in to comment.