Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/common/include/linux Reduce code duplicatio...
details: https://anonhg.NetBSD.org/src/rev/663a3031a641
branches: trunk
changeset: 1029135:663a3031a641
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Dec 22 18:04:53 2021 +0000
description:
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.
diffstat:
sys/external/bsd/common/include/linux/slab.h | 33 ++++++++-------------------
1 files changed, 10 insertions(+), 23 deletions(-)
diffs (61 lines):
diff -r e4e888ab3061 -r 663a3031a641 sys/external/bsd/common/include/linux/slab.h
--- a/sys/external/bsd/common/include/linux/slab.h Wed Dec 22 17:28:17 2021 +0000
+++ b/sys/external/bsd/common/include/linux/slab.h Wed Dec 22 18:04:53 2021 +0000
@@ -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 @@
(*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 @@
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 @@
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)
Home |
Main Index |
Thread Index |
Old Index