lfs_config.h 927 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Configuration and type definitions
  3. *
  4. * Copyright (c) 2017 Christopher Haster
  5. * Distributed under the MIT license
  6. */
  7. #ifndef LFS_CONFIG_H
  8. #define LFS_CONFIG_H
  9. #include <stdint.h>
  10. // Type definitions
  11. typedef uint64_t lfs_lword_t;
  12. typedef uint32_t lfs_word_t;
  13. typedef uint16_t lfs_hword_t;
  14. typedef lfs_word_t lfs_size_t;
  15. typedef lfs_word_t lfs_off_t;
  16. typedef int lfs_error_t;
  17. typedef lfs_lword_t lfs_lsize_t;
  18. typedef lfs_word_t lfs_ino_t;
  19. typedef lfs_hword_t lfs_ioff_t;
  20. // Maximum length of file name
  21. #define LFS_NAME_MAX 255
  22. // Builtin functions
  23. static inline lfs_word_t lfs_max(lfs_word_t a, lfs_word_t b) {
  24. return (a > b) ? a : b;
  25. }
  26. static inline lfs_word_t lfs_min(lfs_word_t a, lfs_word_t b) {
  27. return (a < b) ? a : b;
  28. }
  29. static inline lfs_word_t lfs_ctz(lfs_word_t a) {
  30. return __builtin_ctz(a);
  31. }
  32. static inline lfs_word_t lfs_npw2(lfs_word_t a) {
  33. return 32 - __builtin_clz(a-1);
  34. }
  35. #endif