From c0a1fd129290dcefe48a076dd8a93be0307b510f Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Tue, 22 Sep 2009 21:45:26 +0000 Subject: [PATCH] Removed NR_TASKS from macros manipulating endpoint_t - the magic numbers ANY, NONE and SELF are kept for the compatibility with the current userspace. It is OK as long as NR_PROCS is greater so they don't colide with other endpoints - the 32 bit endpoint_t value is split in half, lower 16 bits for process slot number and upper half for generation number - transition to a structured endpoint_t in the future possible --- include/minix/com.h | 6 ++++-- include/minix/endpoint.h | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/minix/com.h b/include/minix/com.h index ef8dc8f04..47e781c85 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -9,8 +9,10 @@ #define ANY 0x7ace /* used to indicate 'any process' */ #define NONE 0x6ace /* used to indicate 'no process at all' */ #define SELF 0x8ace /* used to indicate 'own process' */ -#define _MAX_MAGIC_PROC (SELF) /* used by - to determine generation size */ +/* check if the magic process numbers are valid process table slot numbers */ +#if (ANY < NR_PROCS) +#error "Magic process number in the process table range" +#endif /*===========================================================================* * Process numbers of processes in the system image * diff --git a/include/minix/endpoint.h b/include/minix/endpoint.h index 97a778763..105a58b4d 100644 --- a/include/minix/endpoint.h +++ b/include/minix/endpoint.h @@ -15,12 +15,14 @@ * the generation size is big enough to start the next generation * above the highest magic number. */ -#define _ENDPOINT_GENERATION_SIZE (NR_TASKS+_MAX_MAGIC_PROC+1) -#define _ENDPOINT_MAX_GENERATION (INT_MAX/_ENDPOINT_GENERATION_SIZE-1) +#define _ENDPOINT_GENERATION_BITS 16 +#define _ENDPOINT_PNUM_BITS 16 +#define _ENDPOINT_MAX_GENERATION ((1 << _ENDPOINT_GENERATION_BITS)-1) +#define _ENDPOINT_MAX_PNUM ((1 << _ENDPOINT_PNUM_BITS) - 1) /* Generation + Process slot number <-> endpoint. */ -#define _ENDPOINT(g, p) ((g) * _ENDPOINT_GENERATION_SIZE + (p)) -#define _ENDPOINT_G(e) (((e)+NR_TASKS) / _ENDPOINT_GENERATION_SIZE) -#define _ENDPOINT_P(e) ((((e)+NR_TASKS) % _ENDPOINT_GENERATION_SIZE) - NR_TASKS) +#define _ENDPOINT(g, p) ((endpoint_t)(((g) << _ENDPOINT_PNUM_BITS) | (p))) +#define _ENDPOINT_G(e) ((u16_t)((e) >> _ENDPOINT_PNUM_BITS)) +#define _ENDPOINT_P(e) ((i16_t)((e) & _ENDPOINT_MAX_PNUM)) #endif -- 2.44.0