compat.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _LINUX_COMPAT_H_
  2. #define _LINUX_COMPAT_H_
  3. #define ndelay(x) udelay(1)
  4. #define dev_dbg(dev, fmt, args...) \
  5. debug(fmt, ##args)
  6. #define dev_vdbg(dev, fmt, args...) \
  7. debug(fmt, ##args)
  8. #define dev_info(dev, fmt, args...) \
  9. printf(fmt, ##args)
  10. #define dev_err(dev, fmt, args...) \
  11. printf(fmt, ##args)
  12. #define printk printf
  13. #define KERN_EMERG
  14. #define KERN_ALERT
  15. #define KERN_CRIT
  16. #define KERN_ERR
  17. #define KERN_WARNING
  18. #define KERN_NOTICE
  19. #define KERN_INFO
  20. #define KERN_DEBUG
  21. #define kmalloc(size, flags) malloc(size)
  22. #define kzalloc(size, flags) calloc(size, 1)
  23. #define vmalloc(size) malloc(size)
  24. #define kfree(ptr) free(ptr)
  25. #define vfree(ptr) free(ptr)
  26. #define DECLARE_WAITQUEUE(...) do { } while (0)
  27. #define add_wait_queue(...) do { } while (0)
  28. #define remove_wait_queue(...) do { } while (0)
  29. #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
  30. /*
  31. * ..and if you can't take the strict
  32. * types, you can specify one yourself.
  33. *
  34. * Or not use min/max at all, of course.
  35. */
  36. #define min_t(type,x,y) \
  37. ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
  38. #define max_t(type,x,y) \
  39. ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
  40. #ifndef BUG
  41. #define BUG() do { \
  42. printf("U-Boot BUG at %s:%d!\n", __FILE__, __LINE__); \
  43. } while (0)
  44. #define BUG_ON(condition) do { if (condition) BUG(); } while(0)
  45. #endif /* BUG */
  46. #define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
  47. , __FILE__, __LINE__); }
  48. #define PAGE_SIZE 4096
  49. /**
  50. * upper_32_bits - return MSB bits 32-63 of a number if little endian, or
  51. * return MSB bits 0-31 of a number if big endian.
  52. * @n: the number we're accessing
  53. *
  54. * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
  55. * the "right shift count >= width of type" warning when that quantity is
  56. * 32-bits.
  57. */
  58. #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
  59. /**
  60. * lower_32_bits - return LSB bits 0-31 of a number if little endian, or
  61. * return LSB bits 32-63 of a number if big endian.
  62. * @n: the number we're accessing
  63. */
  64. #define lower_32_bits(n) ((u32)(n))
  65. #endif