Module Name: src Committed By: thorpej Date: Wed Dec 22 18:04:54 UTC 2021
Modified Files: src/sys/external/bsd/common/include/linux: slab.h Log Message: Reduce code duplication: kmem_cache_create() is now exactly the same as kmem_cache_create_dtor() except for the dtor argument, so implement the former in terms of the latter. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/common/include/linux/slab.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/common/include/linux/slab.h diff -u src/sys/external/bsd/common/include/linux/slab.h:1.12 src/sys/external/bsd/common/include/linux/slab.h:1.13 --- src/sys/external/bsd/common/include/linux/slab.h:1.12 Wed Dec 22 16:57:29 2021 +++ src/sys/external/bsd/common/include/linux/slab.h Wed Dec 22 18:04:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slab.h,v 1.12 2021/12/22 16:57:29 thorpej Exp $ */ +/* $NetBSD: slab.h,v 1.13 2021/12/22 18:04:53 thorpej Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -194,27 +194,6 @@ kmem_cache_dtor(void *cookie, void *ptr) (*kc->kc_dtor)(ptr); } -static inline struct kmem_cache * -kmem_cache_create(const char *name, size_t size, size_t align, - unsigned long flags, void (*ctor)(void *)) -{ - struct kmem_cache *kc; - int pcflags = 0; - - if (ISSET(flags, SLAB_HWCACHE_ALIGN)) - align = roundup(MAX(1, align), CACHE_LINE_SIZE); - if (ISSET(flags, SLAB_TYPESAFE_BY_RCU)) - pcflags |= PR_PSERIALIZE; - - kc = kmem_alloc(sizeof(*kc), KM_SLEEP); - kc->kc_pool_cache = pool_cache_init(size, align, 0, pcflags, name, NULL, - IPL_VM, &kmem_cache_ctor, NULL, kc); - kc->kc_size = size; - kc->kc_ctor = ctor; - - return kc; -} - /* XXX extension */ static inline struct kmem_cache * kmem_cache_create_dtor(const char *name, size_t size, size_t align, @@ -230,7 +209,8 @@ kmem_cache_create_dtor(const char *name, kc = kmem_alloc(sizeof(*kc), KM_SLEEP); kc->kc_pool_cache = pool_cache_init(size, align, 0, pcflags, name, NULL, - IPL_VM, &kmem_cache_ctor, &kmem_cache_dtor, kc); + IPL_VM, &kmem_cache_ctor, dtor != NULL ? &kmem_cache_dtor : NULL, + kc); kc->kc_size = size; kc->kc_ctor = ctor; kc->kc_dtor = dtor; @@ -238,6 +218,13 @@ kmem_cache_create_dtor(const char *name, return kc; } +static inline struct kmem_cache * +kmem_cache_create(const char *name, size_t size, size_t align, + unsigned long flags, void (*ctor)(void *)) +{ + return kmem_cache_create_dtor(name, size, align, flags, ctor, NULL); +} + #define KMEM_CACHE(T, F) \ kmem_cache_create(#T, sizeof(struct T), __alignof__(struct T), \ (F), NULL)