fm_stdlib.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef __FM_STDLIB_H__
  2. #define __FM_STDLIB_H__
  3. #include "fm_typedef.h"
  4. #include <linux/string.h>
  5. #include <linux/slab.h>
  6. #if 1
  7. #define fm_memset(buf, a, len) \
  8. ({ \
  9. void *__ret = (void *)0; \
  10. __ret = memset((buf), (a), (len)); \
  11. __ret; \
  12. })
  13. #define fm_memcpy(dst, src, len) \
  14. ({ \
  15. void *__ret = (void *)0; \
  16. __ret = memcpy((dst), (src), (len)); \
  17. __ret; \
  18. })
  19. #define fm_malloc(len) \
  20. ({ \
  21. void *__ret = (void *)0; \
  22. __ret = kmalloc(len, GFP_KERNEL); \
  23. __ret; \
  24. })
  25. #define fm_zalloc(len) \
  26. ({ \
  27. void *__ret = (void *)0; \
  28. __ret = kzalloc(len, GFP_KERNEL); \
  29. __ret; \
  30. })
  31. #define fm_free(ptr) kfree(ptr)
  32. #define fm_vmalloc(len) \
  33. ({ \
  34. void *__ret = (void *)0; \
  35. __ret = vmalloc(len); \
  36. __ret; \
  37. })
  38. #define fm_vfree(ptr) vfree(ptr)
  39. #else
  40. inline void *fm_memset(void *buf, fm_s8 val, fm_s32 len)
  41. {
  42. return memset(buf, val, len);
  43. }
  44. inline void *fm_memcpy(void *dst, const void *src, fm_s32 len)
  45. {
  46. return memcpy(dst, src, len);
  47. }
  48. #endif
  49. #endif /* __FM_STDLIB_H__ */