Skip to content

Commit

Permalink
malloc
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
  • Loading branch information
c0d3z3r0 committed May 24, 2020
1 parent 598defe commit a8859dc
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions module/zstd/include/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,14 @@ MALLOC_DECLARE(M_ZSTD);
#elif defined(__linux__)

//#include <linux/slab.h>
//#include <linux/mm.h>
#include <linux/gfp.h>

#undef GCC_VERSION

// TODO fix malloc*; this currently breaks build
/*
#define malloc(sz) kmalloc(sz, GFP_KERNEL | __GFP_NOFAIL)
#define free(ptr) kfree(ptr)
#define calloc(n, sz) kzalloc((n) * (sz), GFP_KERNEL | __GFP_NOFAIL)
*/
extern void *spl_kmem_alloc(size_t sz, int fl, const char *func, int line);
extern void *spl_kmem_zalloc(size_t sz, int fl, const char *func, int line);
extern void spl_kmem_free(const void *ptr, size_t sz);
#define KM_SLEEP 0x0000 /* can block for memory; success guaranteed */
#define KM_NOSLEEP 0x0001 /* cannot block for memory; may fail */
#define KM_ZERO 0x1000 /* zero the allocation */
#undef malloc
#define malloc(sz) spl_kmem_alloc((sz), KM_SLEEP, __func__, __LINE__)
#define free(ptr) spl_kmem_free((ptr), 0)
#define calloc(n, sz) \
spl_kmem_zalloc((n) * (sz), KM_SLEEP, __func__, __LINE__)

#else
#error "Unsupported platform"
Expand Down

0 comments on commit a8859dc

Please sign in to comment.