diff options
author | hselasky <hselasky@FreeBSD.org> | 2016-12-19 09:42:43 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2016-12-19 09:42:43 +0000 |
commit | b977e029e9de6b96e1d7e51a6b7229f64d44cda4 (patch) | |
tree | e05400c3a2322e7b99e4ae079ea987d421a63184 | |
parent | 32883c890314b7942b65af4fa18b076c9eccf86e (diff) | |
download | FreeBSD-src-b977e029e9de6b96e1d7e51a6b7229f64d44cda4.zip FreeBSD-src-b977e029e9de6b96e1d7e51a6b7229f64d44cda4.tar.gz |
MFC r309731:
Prefix the Linux KPI's kmem_xxx() functions with linux_ to avoid
conflict with the opensolaris kernel module.
This patch solves a problem where the kernel linker will incorrectly
resolve opensolaris kmem_xxx() functions as linuxkpi ones, which leads
to a panic when these functions are used.
Submitted by: gallatin @
Sponsored by: Mellanox Technologies
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/slab.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index 235251c..d35f7a1 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -55,7 +55,18 @@ MALLOC_DECLARE(M_KMALLOC); #define vmalloc(size) kmalloc(size, GFP_KERNEL) #define vmalloc_node(size, node) kmalloc(size, GFP_KERNEL) -struct kmem_cache { + +/* + * Prefix some functions with linux_ to avoid namespace conflict + * with the OpenSolaris code in the kernel. + */ +#define kmem_cache linux_kmem_cache +#define kmem_cache_create(...) linux_kmem_cache_create(__VA_ARGS__) +#define kmem_cache_alloc(...) linux_kmem_cache_alloc(__VA_ARGS__) +#define kmem_cache_free(...) linux_kmem_cache_free(__VA_ARGS__) +#define kmem_cache_destroy(...) linux_kmem_cache_destroy(__VA_ARGS__) + +struct linux_kmem_cache { uma_zone_t cache_zone; void (*cache_ctor)(void *); }; @@ -63,7 +74,7 @@ struct kmem_cache { #define SLAB_HWCACHE_ALIGN 0x0001 static inline int -kmem_ctor(void *mem, int size, void *arg, int flags) +linux_kmem_ctor(void *mem, int size, void *arg, int flags) { void (*ctor)(void *); @@ -74,7 +85,7 @@ kmem_ctor(void *mem, int size, void *arg, int flags) } static inline struct kmem_cache * -kmem_cache_create(char *name, size_t size, size_t align, u_long flags, +linux_kmem_cache_create(char *name, size_t size, size_t align, u_long flags, void (*ctor)(void *)) { struct kmem_cache *c; @@ -84,7 +95,7 @@ kmem_cache_create(char *name, size_t size, size_t align, u_long flags, align--; if (flags & SLAB_HWCACHE_ALIGN) align = UMA_ALIGN_CACHE; - c->cache_zone = uma_zcreate(name, size, ctor ? kmem_ctor : NULL, + c->cache_zone = uma_zcreate(name, size, ctor ? linux_kmem_ctor : NULL, NULL, NULL, NULL, align, 0); c->cache_ctor = ctor; @@ -92,19 +103,19 @@ kmem_cache_create(char *name, size_t size, size_t align, u_long flags, } static inline void * -kmem_cache_alloc(struct kmem_cache *c, int flags) +linux_kmem_cache_alloc(struct kmem_cache *c, int flags) { return uma_zalloc_arg(c->cache_zone, c->cache_ctor, flags); } static inline void -kmem_cache_free(struct kmem_cache *c, void *m) +linux_kmem_cache_free(struct kmem_cache *c, void *m) { uma_zfree(c->cache_zone, m); } static inline void -kmem_cache_destroy(struct kmem_cache *c) +linux_kmem_cache_destroy(struct kmem_cache *c) { uma_zdestroy(c->cache_zone); free(c, M_KMALLOC); |