--- Gnu-Mach/ipc/ipc_marequest.c 2020/09/02 04:36:56 1.1 +++ Gnu-Mach/ipc/ipc_marequest.c 2020/09/02 04:47:19 1.1.1.4 @@ -34,14 +34,11 @@ * Functions to handle msg-accepted requests. */ -#include - #include #include #include -#include #include -#include +#include #include #include #include @@ -51,7 +48,6 @@ #include #include -#include #if MACH_IPC_DEBUG #include #include @@ -61,11 +57,10 @@ #endif -zone_t ipc_marequest_zone; -int ipc_marequest_max = IMAR_MAX; +struct kmem_cache ipc_marequest_cache; -#define imar_alloc() ((ipc_marequest_t) zalloc(ipc_marequest_zone)) -#define imar_free(imar) zfree(ipc_marequest_zone, (vm_offset_t) (imar)) +#define imar_alloc() ((ipc_marequest_t) kmem_cache_alloc(&ipc_marequest_cache)) +#define imar_free(imar) kmem_cache_free(&ipc_marequest_cache, (vm_offset_t) (imar)) typedef unsigned int ipc_marequest_index_t; @@ -99,17 +94,13 @@ ipc_marequest_bucket_t ipc_marequest_tab */ void -ipc_marequest_init() +ipc_marequest_init(void) { ipc_marequest_index_t i; - /* if not configured, initialize ipc_marequest_size */ + /* initialize ipc_marequest_size */ - if (ipc_marequest_size == 0) { - ipc_marequest_size = ipc_marequest_max >> 8; - if (ipc_marequest_size < 16) - ipc_marequest_size = 16; - } + ipc_marequest_size = IPC_MAREQUEST_SIZE; /* make sure it is a power of two */ @@ -145,11 +136,8 @@ ipc_marequest_init() bucket->imarb_head = IMAR_NULL; } - ipc_marequest_zone = - zinit(sizeof(struct ipc_marequest), - ipc_marequest_max * sizeof(struct ipc_marequest), - sizeof(struct ipc_marequest), - IPC_ZONE_TYPE, "ipc msg-accepted requests"); + kmem_cache_init(&ipc_marequest_cache, "ipc_marequest", + sizeof(struct ipc_marequest), 0, NULL, NULL, NULL, 0); } /* @@ -160,9 +148,6 @@ ipc_marequest_init() * * The "notify" argument should name a receive right * that is used to create the send-once notify port. - * - * [MACH_IPC_COMPAT] If "notify" is MACH_PORT_NULL, - * then an old-style msg-accepted request is created. * Conditions: * Nothing locked; refs held for space and port. * Returns: @@ -175,11 +160,11 @@ ipc_marequest_init() */ mach_msg_return_t -ipc_marequest_create(space, port, notify, marequestp) - ipc_space_t space; - ipc_port_t port; - mach_port_t notify; - ipc_marequest_t *marequestp; +ipc_marequest_create( + ipc_space_t space, + ipc_port_t port, + mach_port_t notify, + ipc_marequest_t *marequestp) { mach_port_t name; ipc_entry_t entry; @@ -187,10 +172,6 @@ ipc_marequest_create(space, port, notify ipc_marequest_t marequest; ipc_marequest_bucket_t bucket; -#if !MACH_IPC_COMPAT - assert(notify != MACH_PORT_NULL); -#endif !MACH_IPC_COMPAT - marequest = imar_alloc(); if (marequest == IMAR_NULL) return MACH_SEND_NO_NOTIFY; @@ -225,11 +206,6 @@ ipc_marequest_create(space, port, notify return MACH_SEND_NOTIFY_IN_PROGRESS; } -#if MACH_IPC_COMPAT - if (notify == MACH_PORT_NULL) - soright = IP_NULL; - else -#endif MACH_IPC_COMPAT if ((soright = ipc_port_lookup_notify(space, notify)) == IP_NULL) { is_write_unlock(space); @@ -252,11 +228,6 @@ ipc_marequest_create(space, port, notify imarb_unlock(bucket); } else { -#if MACH_IPC_COMPAT - if (notify == MACH_PORT_NULL) - soright = IP_NULL; - else -#endif MACH_IPC_COMPAT if ((soright = ipc_port_lookup_notify(space, notify)) == IP_NULL) { is_write_unlock(space); @@ -285,9 +256,9 @@ ipc_marequest_create(space, port, notify */ void -ipc_marequest_cancel(space, name) - ipc_space_t space; - mach_port_t name; +ipc_marequest_cancel( + ipc_space_t space, + mach_port_t name) { ipc_marequest_bucket_t bucket; ipc_marequest_t marequest, *last; @@ -321,9 +292,10 @@ ipc_marequest_cancel(space, name) */ void -ipc_marequest_rename(space, old, new) - ipc_space_t space; - mach_port_t old, new; +ipc_marequest_rename( + ipc_space_t space, + mach_port_t old, + mach_port_t new) { ipc_marequest_bucket_t bucket; ipc_marequest_t marequest, *last; @@ -365,15 +337,11 @@ ipc_marequest_rename(space, old, new) */ void -ipc_marequest_destroy(marequest) - ipc_marequest_t marequest; +ipc_marequest_destroy(ipc_marequest_t marequest) { ipc_space_t space = marequest->imar_space; mach_port_t name; ipc_port_t soright; -#if MACH_IPC_COMPAT - ipc_port_t sright = IP_NULL; -#endif MACH_IPC_COMPAT is_write_lock(space); @@ -408,10 +376,6 @@ ipc_marequest_destroy(marequest) entry->ie_bits &= ~IE_BITS_MAREQUEST; -#if MACH_IPC_COMPAT - if (soright == IP_NULL) - sright = ipc_space_make_notify(space); -#endif MACH_IPC_COMPAT } else name = MACH_PORT_NULL; } @@ -421,18 +385,6 @@ ipc_marequest_destroy(marequest) imar_free(marequest); -#if MACH_IPC_COMPAT - if (soright == IP_NULL) { - if (IP_VALID(sright)) { - assert(name != MACH_PORT_NULL); - ipc_notify_msg_accepted_compat(sright, name); - } - - return; - } - assert(sright == IP_NULL); -#endif MACH_IPC_COMPAT - assert(soright != IP_NULL); ipc_notify_msg_accepted(soright, name); } @@ -452,10 +404,10 @@ ipc_marequest_destroy(marequest) */ unsigned int -ipc_marequest_info(maxp, info, count) - unsigned int *maxp; - hash_info_bucket_t *info; - unsigned int count; +ipc_marequest_info( + unsigned int *maxp, + hash_info_bucket_t *info, + unsigned int count) { ipc_marequest_index_t i; @@ -478,8 +430,8 @@ ipc_marequest_info(maxp, info, count) info[i].hib_count = bucket_count; } - *maxp = ipc_marequest_max; + *maxp = (unsigned int)-1; return ipc_marequest_size; } -#endif MACH_IPC_DEBUG +#endif /* MACH_IPC_DEBUG */