utils.h 875 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef PCIBX_UTILS_H_
  2. #define PCIBX_UTILS_H_
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <stdint.h>
  6. #define pcibx_stringify_1(x) #x
  7. #define pcibx_stringify(x) pcibx_stringify_1(x)
  8. #ifdef ATTRIBUTE_FORMAT
  9. # undef ATTRIBUTE_FORMAT
  10. #endif
  11. #ifdef __GNUC__
  12. # define ATTRIBUTE_FORMAT(t, a, b) __attribute__((format(t, a, b)))
  13. #else
  14. # define ATTRIBUTE_FORMAT(t, a, b) /* nothing */
  15. #endif
  16. int prinfo(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
  17. int prerror(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
  18. void internal_error(const char *message);
  19. #define internal_error_on(condition) \
  20. do { \
  21. if (condition) \
  22. internal_error(pcibx_stringify(condition)); \
  23. } while (0)
  24. void * malloce(size_t size);
  25. void * realloce(void *ptr, size_t newsize);
  26. void udelay(unsigned int usecs);
  27. void msleep(unsigned int msecs);
  28. #endif /* PCIBX_UTILS_H_ */