definitions.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * definitions.h
  3. *
  4. * Created on: May 3, 2018
  5. * Author: vader
  6. */
  7. #ifndef SRC_DEFINITIONS_H_
  8. #define SRC_DEFINITIONS_H_
  9. #include <stdint.h>
  10. #define ERROR_ZERO_IN_A_POSITION -1
  11. typedef uint16_t gf;
  12. typedef uint32_t gf_p;
  13. typedef int bool;
  14. #define true 1
  15. #define false 0
  16. #define EXIT_FAILURE 1
  17. #define EXIT_SUCCESS 0
  18. struct signature_block {
  19. gf* signature;
  20. };
  21. struct matrix {
  22. int rows; // number of rows
  23. int cols; // number of columns
  24. gf* data;
  25. };
  26. typedef struct matrix matrix;
  27. struct polynomial {
  28. int degree;
  29. int size;
  30. gf * coefficient;
  31. };
  32. typedef struct polynomial polynomial;
  33. #ifdef DEBUG
  34. #define PRINT_DEBUG(s, ...) fprintf(stdout, s, ##__VA_ARGS__);
  35. #else
  36. #define PRINT_DEBUG(s, ...) do {} while (0)
  37. #endif
  38. #ifdef DEBUG_DECAP
  39. #define PRINT_DEBUG_DECAP(s, ...) fprintf(stdout, s, ##__VA_ARGS__);
  40. #else
  41. #define PRINT_DEBUG_DECAP(s, ...) do {} while (0)
  42. #endif
  43. #ifdef DEBUG_DECODING
  44. #define PRINT_DEBUG_DEC(s, ...) fprintf(stdout, s, ##__VA_ARGS__);
  45. #else
  46. #define PRINT_DEBUG_DEC(s, ...) do {} while (0)
  47. #endif
  48. #ifdef DEBUG_ENCAP
  49. #define PRINT_DEBUG_ENCAP(s, ...) fprintf(stdout, s, ##__VA_ARGS__);
  50. #else
  51. #define PRINT_DEBUG_ENCAP(s, ...) do {} while (0)
  52. #endif
  53. #ifdef DEBUG_UTIL
  54. #define PRINT_DEBUG_UTIL(s, ...) fprintf(stdout, s, ##__VA_ARGS__);
  55. #else
  56. #define PRINT_DEBUG_UTIL(s, ...) do {} while (0)
  57. #endif
  58. #ifdef DEBUG
  59. #define print_vector(vector, size) {\
  60. PRINT_DEBUG("[");\
  61. for (int i = 0; i < size; i++) {\
  62. PRINT_DEBUG(" %" PRIu16 " ,", ((gf*)vector)[i]);\
  63. }\
  64. PRINT_DEBUG("]\n");\
  65. }
  66. #else
  67. #define print_vector(vector, size){return EXIT_SUCCESS;}
  68. #endif
  69. #endif /* SRC_DEFINITIONS_H_ */