diff options
author | neal <neal> | 2004-11-30 17:47:08 +0000 |
---|---|---|
committer | neal <neal> | 2004-11-30 17:47:08 +0000 |
commit | e5f9d11d628ac41e27cd52a75e62e8ad7de0aec4 (patch) | |
tree | 88f188b1e6e39dda3b8c940c5914a10755e5bcb8 /libhurd-cap-server/class-init.c | |
parent | a47c5dfdac31ceebebfc470fb4f778e43e4d39f2 (diff) |
libhurd-cap-server/
2004-11-30 Neal H. Walfield <neal@gnu.org>
* cap-server.h: Improve comments.
(hurd_cap_class_create_untyped): Tighten alignment restrictions:
ALIGNMENT must be a power of 2.
* class-init.c (hurd_cap_class_init_untyped): Calculate best
alignment.
* cap-server.h (hurd_cap_obj_get_size): Renamed to ...
(hurd_cap_obj_user_offset): ... this.
(hurd_cap_obj_to_user_untyped): Call hurd_cap_obj_user_offset, not
hurd_cap_obj_get_size.
(hurd_cap_obj_from_user_untyped): Likewise.
* class-init.c (hurd_cap_class_init_untyped): Likewise.
* class-create.c: Improve comments.
* obj-copy-out.c: Likewise.
Diffstat (limited to 'libhurd-cap-server/class-init.c')
-rw-r--r-- | libhurd-cap-server/class-init.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libhurd-cap-server/class-init.c b/libhurd-cap-server/class-init.c index 9c7d185..cdbb7db 100644 --- a/libhurd-cap-server/class-init.c +++ b/libhurd-cap-server/class-init.c @@ -97,11 +97,17 @@ hurd_cap_class_init_untyped (hurd_cap_class_t cap_class, { error_t err; - size += hurd_cap_obj_get_size (alignment); + /* The alignment requirements must be a power of 2. */ + assert ((alignment & (alignment - 1)) == 0 + || ! __func__ ": requested alignment not a power of 2"); - /* FIXME: Find the smallest possible alignment common to the user - object and a struct hurd_cap_obj. */ - assert (alignment >= __alignof__(struct hurd_cap_obj)); + /* Find the smallest alignment requirement common to the user object + and a struct hurd_cap_obj. Since both are required to be a power + of 2, we need simply take the larger one. */ + if (alignment < __alignof__(struct hurd_cap_obj)) + alignment = __alignof__(struct hurd_cap_obj); + + size += hurd_cap_obj_user_offset (alignment); /* Capability object management. */ @@ -139,9 +145,8 @@ hurd_cap_class_init_untyped (hurd_cap_class_t cap_class, if (err) goto err_cond; - /* The cond_waiter member doesn't need to be initialized. It is set - whenever the state changes to _HURD_CAP_STATE_YELLOW by the - inhibitor. */ + /* The cond_waiter member doesn't need to be initialized. It is + only valid when CAP_CLASS->STATE is _HURD_CAP_STATE_YELLOW. */ cap_class->pending_rpcs = NULL; |