From 682c62f8bb086eb4f5f38ed601ab261c0a103973 Mon Sep 17 00:00:00 2001 From: Bora Sahin Date: Mon, 16 Nov 2009 21:49:37 +0200 Subject: [PATCH] A fix and a helper macro for the thread library. The fix solves the problem of giving the last slice from a pool. The helper macro makes utcb space creation easy for the user because we have to consider a few things like alignment and total allocated space. --- conts/libl4thread/include/l4thread/thread.h | 4 ++++ conts/libl4thread/src/bit.c | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/conts/libl4thread/include/l4thread/thread.h b/conts/libl4thread/include/l4thread/thread.h index 8cd3125..7afe124 100644 --- a/conts/libl4thread/include/l4thread/thread.h +++ b/conts/libl4thread/include/l4thread/thread.h @@ -6,6 +6,10 @@ #ifndef __LIB_THREAD_H__ #define __LIB_THREAD_H__ +/* A helper macro easing utcb space creation. */ +#define DECLARE_UTCB_SPACE(name, entries) \ + char name[(entries + PAGE_SIZE / UTCB_SIZE) * UTCB_SIZE] ALIGN(PAGE_SIZE); + int l4_set_stack_params(unsigned long stack_top, unsigned long stack_bottom, unsigned long stack_size); diff --git a/conts/libl4thread/src/bit.c b/conts/libl4thread/src/bit.c index b021211..7c0ab4e 100644 --- a/conts/libl4thread/src/bit.c +++ b/conts/libl4thread/src/bit.c @@ -49,8 +49,7 @@ int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit, return -1; /* This is a state machine that checks n contiguous free bits. */ - /* FIXME: It should be <= instead of <. Fix & test in a single patch */ - while (i + nbits < limit) { + while (i + nbits <= limit) { first = i; last = i; while (!(word[BITWISE_GETWORD(last)] & BITWISE_GETBIT(last))) {