exfat_global.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef _EXFAT_GLOBAL_H
  19. #define _EXFAT_GLOBAL_H
  20. #include <linux/kernel.h>
  21. #include <linux/mm.h>
  22. #include <linux/slab.h>
  23. #include <linux/string.h>
  24. #include <linux/fs.h>
  25. #include "exfat_config.h"
  26. #ifdef CONFIG_EXFAT_SUPPORT_STLOG
  27. #include <linux/stlog.h>
  28. #else
  29. #define ST_LOG(fmt,...)
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. #ifndef TRUE
  35. #define TRUE 1
  36. #endif
  37. #ifndef FALSE
  38. #define FALSE 0
  39. #endif
  40. #ifndef OK
  41. #define OK 0
  42. #endif
  43. #ifndef FAIL
  44. #define FAIL 1
  45. #endif
  46. #ifndef NULL
  47. #define NULL 0
  48. #endif
  49. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  50. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  51. typedef char INT8;
  52. typedef short INT16;
  53. typedef int INT32;
  54. typedef long long INT64;
  55. typedef unsigned char UINT8;
  56. typedef unsigned short UINT16;
  57. typedef unsigned int UINT32;
  58. typedef unsigned long long UINT64;
  59. typedef unsigned char BOOL;
  60. #ifdef MALLOC
  61. #undef MALLOC
  62. #endif
  63. #ifdef FREE
  64. #undef FREE
  65. #endif
  66. #ifdef MEMSET
  67. #undef MEMSET
  68. #endif
  69. #ifdef MEMCPY
  70. #undef MEMCPY
  71. #endif
  72. #ifdef MEMCMP
  73. #undef MEMCMP
  74. #endif
  75. #define MALLOC(size) kmalloc(size, GFP_KERNEL)
  76. #define FREE(mem) if (mem) kfree(mem)
  77. #define MEMSET(mem, value, size) memset(mem, value, size)
  78. #define MEMCPY(dest, src, size) memcpy(dest, src, size)
  79. #define MEMCMP(mem1, mem2, size) memcmp(mem1, mem2, size)
  80. #define COPY_DENTRY(dest, src) memcpy(dest, src, sizeof(DENTRY_T))
  81. #define STRCPY(dest, src) strcpy(dest, src)
  82. #define STRNCPY(dest, src, n) strncpy(dest, src, n)
  83. #define STRCAT(str1, str2) strcat(str1, str2)
  84. #define STRCMP(str1, str2) strcmp(str1, str2)
  85. #define STRNCMP(str1, str2, n) strncmp(str1, str2, n)
  86. #define STRLEN(str) strlen(str)
  87. INT32 __wstrchr(UINT16 *str, UINT16 wchar);
  88. INT32 __wstrlen(UINT16 *str);
  89. #define WSTRCHR(str, wchar) __wstrchr(str, wchar)
  90. #define WSTRLEN(str) __wstrlen(str)
  91. #if EXFAT_CONFIG_DEBUG_MSG
  92. #define PRINTK(...) \
  93. do { \
  94. printk("[EXFAT] " __VA_ARGS__); \
  95. } while(0)
  96. #else
  97. #define PRINTK(...)
  98. #endif
  99. void Bitmap_set_all(UINT8 *bitmap, INT32 mapsize);
  100. void Bitmap_clear_all(UINT8 *bitmap, INT32 mapsize);
  101. INT32 Bitmap_test(UINT8 *bitmap, INT32 i);
  102. void Bitmap_set(UINT8 *bitmap, INT32 i);
  103. void Bitmap_clear(UINT8 *bitmpa, INT32 i);
  104. void Bitmap_nbits_set(UINT8 *bitmap, INT32 offset, INT32 nbits);
  105. void Bitmap_nbits_clear(UINT8 *bitmap, INT32 offset, INT32 nbits);
  106. void my_itoa(INT8 *buf, INT32 v);
  107. INT32 my_log2(UINT32 v);
  108. #ifdef PRINT
  109. #undef PRINT
  110. #endif
  111. #define PRINT printk
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115. #endif