--- Gnu-Mach/ipc/ipc_marequest.c 2020/09/02 04:42:36 1.1.1.2 +++ Gnu-Mach/ipc/ipc_marequest.c 2020/09/02 04:45:07 1.1.1.3 @@ -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: @@ -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); @@ -371,9 +342,6 @@ ipc_marequest_destroy(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); } @@ -478,7 +430,7 @@ ipc_marequest_info(maxp, info, count) info[i].hib_count = bucket_count; } - *maxp = ipc_marequest_max; + *maxp = (unsigned int)-1; return ipc_marequest_size; }