1#ifndef __LINUX_SLAB_H__
2#define __LINUX_SLAB_H__
6#include <linux/kernel.h>
46#include <linux/kdev_t.h>
48#define KMALLOC_SHIFT_HIGH 22
49#define KMALLOC_MIN_SIZE 8
65#ifndef ARCH_KMALLOC_MINALIGN
66#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
107static inline void* dcl_kmalloc(
unsigned int size) {
112static inline void* dcl_kzalloc(
unsigned int size);
117static inline void* dcl_kmalloc_flags(
unsigned int size,
gfp_t flags) {
119 return dcl_kzalloc(
size);
120 return dcl_kmalloc(
size);
123#define kmalloc(size, flags) dcl_kmalloc_flags(size, flags)
147static inline void* dcl_kcalloc(
size_t n,
size_t size) {
153#define kcalloc(n, size, ...) dcl_kcalloc((n), (size))
176static inline void* dcl_krealloc(
void* ptr,
size_t size) {
180#define krealloc(ptr, size, ...) dcl_krealloc((ptr), (size))
191#define krealloc_array(ptr, n, size, flags) \
192 dcl_krealloc((ptr), array_size((n), (size)))
218static inline size_t kmalloc_size_roundup(
size_t size)
253static inline void* dcl_kzalloc(
unsigned int size) {
257#define kzalloc(size, flags) dcl_kzalloc(size)
288#define kzalloc_obj(type, ...) dcl_kzalloc((unsigned int)sizeof(type))
315#define kmalloc_obj(type, ...) dcl_kmalloc((unsigned int)sizeof(type))
367#define __GFP_NOWARN 0
372#ifndef __GFP_RETRY_MAYFAIL
373#define __GFP_RETRY_MAYFAIL 0
376#define kmalloc_flex(p, member, count, ...) \
377 dcl_kmalloc((unsigned int)(sizeof(typeof(p)) + \
378 sizeof(*((typeof(&p))0)->member) * (size_t)(count)))
396#define kzalloc_flex(p, member, count, ...) \
397 dcl_kzalloc((unsigned int)(sizeof(typeof(p)) + \
398 sizeof(*((typeof(&p))0)->member) * (size_t)(count)))
419#define kzalloc_objs(type, count) \
420 dcl_kzalloc((unsigned int)(sizeof(type) * (unsigned int)(count)))
438#define kmalloc_objs(type, count) \
439 dcl_kmalloc((unsigned int)(sizeof(type) * (unsigned int)(count)))
459#define kvmalloc_objs(type, count) \
460 dcl_kmalloc((unsigned int)(sizeof(type) * (unsigned int)(count)))
469#define kvzalloc_objs(type, count) \
470 kzalloc_objs(type, count)
504static inline void *kmalloc_array(
size_t n,
size_t size,
gfp_t flags)
510 return dcl_kmalloc_flags((
unsigned int)bytes,
flags);
521static inline void *kvmalloc_array(
size_t n,
size_t size,
gfp_t flags)
527 return dcl_kmalloc_flags((
unsigned int)bytes,
flags);
541 return dcl_kmalloc_flags((
unsigned int)
size,
flags);
604static inline void* kmem_cache_alloc_lru(
struct kmem_cache* cache,
605 const void* lru,
gfp_t gfp)
626static inline struct kmem_cache* kmem_cache_create(
const char*
name,
638 cache = dcl_kmalloc(
sizeof(*cache));
645static inline void kmem_cache_destroy(
struct kmem_cache* cache)
650static inline void* kmem_cache_zalloc(
struct kmem_cache* cache,
gfp_t gfp)
653 return dcl_kzalloc(cache->
size);
656static inline void kmem_cache_free(
struct kmem_cache* cache,
void* obj)
662static inline void* kmemdup(
const void* src,
size_t len,
gfp_t gfp)
664 void* p = dcl_kmalloc((
unsigned int)
len);
685static inline char* kstrdup(
const char* s,
gfp_t gfp)
688 char* p = (
char*)dcl_kmalloc((
unsigned int)
len);
716static inline void* memdup_user_nul(
const void* src,
size_t len)
720 if (
len >= (
size_t)0x7fffffff)
723 p = (
char*)dcl_kmalloc((
unsigned int)(
len + 1));
763static inline void free_page(
uintptr_t addr)
790#define DCL_KASPRINTF_MAX 128
792static inline char* kasprintf(
gfp_t gfp,
const char*
fmt, ...)
#define PAGE_SIZE
Definition vmmngr.h:92
unsigned int uintptr_t
Definition stdint.h:94
uint8_t flags
Definition virtio.h:0
int _vsnprintf(char *output, size_t sz, const char *format, va_list ap)
Definition _print.c:814
#define EINVAL
Definition acclib.h:198
#define ENOMEM
Definition acclib.h:192
char * va_list
Definition acmsvcex.h:186
#define va_end(ap)
Definition acmsvcex.h:198
#define va_start(ap, A)
Definition acmsvcex.h:199
#define NULL
Definition actypes.h:561
#define DEFINE_FREE(_name, _type, _free)
Definition cleanup.h:120
#define unlikely(x)
Definition compiler.h:30
#define __user
Definition compiler.h:63
size_t size
Definition drm_bridge.h:1299
struct drm_crtc struct drm_plane struct drm_plane const struct drm_crtc_funcs const char * name
Definition drm_crtc.h:1242
const char * fmt
Definition drm_file.h:466
#define ERR_PTR(err)
Definition err.h:51
size_t len
Definition initial.c:23
void int node
Definition kthread.h:31
unsigned int gfp_t
Definition kernel.h:56
#define check_mul_overflow(a, b, d)
Definition overflow.h:153
void * kvmalloc(size_t size, gfp_t flags)
#define DCL_KASPRINTF_MAX
Definition slab.h:790
#define kmalloc(size, flags)
Definition slab.h:123
void * memdup_array_user(const void __user *src, size_t n, size_t size)
#define __GFP_ZERO
Definition slab.h:370
void * vmemdup_user(const void __user *src, size_t len)
void * memdup_user(const void __user *src, size_t len)
#define kcalloc(n, size,...)
Definition slab.h:153
const char * kstrdup_const(const char *s, gfp_t gfp)
char * kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
void kfree_const(const void *x)
size_t ksize(const void *objp)
void * vmemdup_array_user(const void __user *src, size_t n, size_t size)
void * kvzalloc(size_t size, gfp_t flags)
void kvfree(const void *addr)
#define krealloc(ptr, size,...)
Definition slab.h:180
unsigned int size
Definition slab.h:596