faux.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /** @file faux.h
  2. * @brief Additional usefull data types and base functions.
  3. */
  4. #ifndef _faux_types_h
  5. #define _faux_types_h
  6. #include <stdlib.h>
  7. /**
  8. * A standard boolean type. The possible values are
  9. * BOOL_FALSE and BOOL_TRUE.
  10. */
  11. typedef enum {
  12. BOOL_FALSE = 0,
  13. BOOL_TRUE = 1
  14. } bool_t;
  15. /** @def C_DECL_BEGIN
  16. * This macro can be used instead standard preprocessor
  17. * directive like this:
  18. * @code
  19. * #ifdef __cplusplus
  20. * extern "C" {
  21. * #endif
  22. *
  23. * int foobar(void);
  24. *
  25. * #ifdef __cplusplus
  26. * }
  27. * #endif
  28. * @endcode
  29. * It make linker to use C-style linking for functions.
  30. * Use C_DECL_BEGIN before functions declaration and C_DECL_END
  31. * after declaration:
  32. * @code
  33. * C_DECL_BEGIN
  34. *
  35. * int foobar(void);
  36. *
  37. * C_DECL_END
  38. * @endcode
  39. */
  40. /** @def C_DECL_END
  41. * See the macro C_DECL_BEGIN.
  42. * @sa C_DECL_BEGIN
  43. */
  44. #ifdef __cplusplus
  45. #define C_DECL_BEGIN extern "C" {
  46. #define C_DECL_END }
  47. #else
  48. #define C_DECL_BEGIN
  49. #define C_DECL_END
  50. #endif
  51. C_DECL_BEGIN
  52. // Memory
  53. void faux_free(void *ptr);
  54. void *faux_malloc(size_t size);
  55. void faux_bzero(void *ptr, size_t size);
  56. void *faux_zmalloc(size_t size);
  57. // IO
  58. ssize_t faux_write(int fd, const void *buf, size_t n);
  59. ssize_t faux_read(int fd, void *buf, size_t n);
  60. C_DECL_END
  61. #endif /* _faux_types_h */