bstruct_bstruct_test.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. DO NOT EDIT THIS FILE!
  3. This file was automatically generated by the bstruct generator.
  4. */
  5. #include <stdint.h>
  6. #include <misc/balign.h>
  7. typedef struct str0_struct str0;
  8. typedef struct {
  9. int x_off;
  10. int x_size;
  11. #ifndef NDEBUG
  12. int x_count;
  13. #endif
  14. int len;
  15. int align;
  16. } str0Params;
  17. static void str0Params_Init (str0Params *o, int n)
  18. {
  19. int cur_size;
  20. int cur_align;
  21. int cur_count;
  22. o->len = 0;
  23. o->align = 1;
  24. cur_size = (sizeof(int));
  25. cur_align = (__alignof__(int));
  26. cur_count = (n);
  27. o->x_off = balign_up(o->len, cur_align);
  28. o->x_size = cur_size;
  29. #ifndef NDEBUG
  30. o->x_count = cur_count;
  31. #endif
  32. o->len = o->x_off + (cur_count * cur_size);
  33. o->align = (cur_align > o->align ? cur_align : o->align);
  34. }
  35. static int * str0_x (str0Params *o, str0 *s)
  36. {
  37. return (int *)((uint8_t *)s + o->x_off);
  38. }
  39. static int * str0_x_at (str0Params *o, str0 *s, int i)
  40. {
  41. ASSERT(i >= 0)
  42. ASSERT(i < o->x_count)
  43. return (int *)((uint8_t *)s + o->x_off + i * o->x_size);
  44. }
  45. typedef struct str1_struct str1;
  46. typedef struct {
  47. int a_off;
  48. int a_size;
  49. #ifndef NDEBUG
  50. int a_count;
  51. #endif
  52. int b_off;
  53. int b_size;
  54. #ifndef NDEBUG
  55. int b_count;
  56. #endif
  57. int c_off;
  58. int c_size;
  59. #ifndef NDEBUG
  60. int c_count;
  61. #endif
  62. str0Params d_params;
  63. int d_off;
  64. int d_size;
  65. #ifndef NDEBUG
  66. int d_count;
  67. #endif
  68. int len;
  69. int align;
  70. } str1Params;
  71. static void str1Params_Init (str1Params *o, int nb, int nc, int m)
  72. {
  73. int cur_size;
  74. int cur_align;
  75. int cur_count;
  76. o->len = 0;
  77. o->align = 1;
  78. cur_size = (sizeof(int));
  79. cur_align = (__alignof__(int));
  80. cur_count = (1);
  81. o->a_off = balign_up(o->len, cur_align);
  82. o->a_size = cur_size;
  83. #ifndef NDEBUG
  84. o->a_count = cur_count;
  85. #endif
  86. o->len = o->a_off + (cur_count * cur_size);
  87. o->align = (cur_align > o->align ? cur_align : o->align);
  88. cur_size = (sizeof(char));
  89. cur_align = (__alignof__(char));
  90. cur_count = (nb);
  91. o->b_off = balign_up(o->len, cur_align);
  92. o->b_size = cur_size;
  93. #ifndef NDEBUG
  94. o->b_count = cur_count;
  95. #endif
  96. o->len = o->b_off + (cur_count * cur_size);
  97. o->align = (cur_align > o->align ? cur_align : o->align);
  98. cur_size = (sizeof(double));
  99. cur_align = (__alignof__(double));
  100. cur_count = (nc);
  101. o->c_off = balign_up(o->len, cur_align);
  102. o->c_size = cur_size;
  103. #ifndef NDEBUG
  104. o->c_count = cur_count;
  105. #endif
  106. o->len = o->c_off + (cur_count * cur_size);
  107. o->align = (cur_align > o->align ? cur_align : o->align);
  108. str0Params_Init(&o->d_params, m);
  109. cur_size = o->d_params.len;
  110. cur_align = o->d_params.align;
  111. cur_count = (1);
  112. o->d_off = balign_up(o->len, cur_align);
  113. o->d_size = cur_size;
  114. #ifndef NDEBUG
  115. o->d_count = cur_count;
  116. #endif
  117. o->len = o->d_off + (cur_count * cur_size);
  118. o->align = (cur_align > o->align ? cur_align : o->align);
  119. }
  120. static int * str1_a (str1Params *o, str1 *s)
  121. {
  122. return (int *)((uint8_t *)s + o->a_off);
  123. }
  124. static int * str1_a_at (str1Params *o, str1 *s, int i)
  125. {
  126. ASSERT(i >= 0)
  127. ASSERT(i < o->a_count)
  128. return (int *)((uint8_t *)s + o->a_off + i * o->a_size);
  129. }
  130. static char * str1_b (str1Params *o, str1 *s)
  131. {
  132. return (char *)((uint8_t *)s + o->b_off);
  133. }
  134. static char * str1_b_at (str1Params *o, str1 *s, int i)
  135. {
  136. ASSERT(i >= 0)
  137. ASSERT(i < o->b_count)
  138. return (char *)((uint8_t *)s + o->b_off + i * o->b_size);
  139. }
  140. static double * str1_c (str1Params *o, str1 *s)
  141. {
  142. return (double *)((uint8_t *)s + o->c_off);
  143. }
  144. static double * str1_c_at (str1Params *o, str1 *s, int i)
  145. {
  146. ASSERT(i >= 0)
  147. ASSERT(i < o->c_count)
  148. return (double *)((uint8_t *)s + o->c_off + i * o->c_size);
  149. }
  150. static str0 * str1_d (str1Params *o, str1 *s)
  151. {
  152. return (str0 *)((uint8_t *)s + o->d_off);
  153. }
  154. static str0 * str1_d_at (str1Params *o, str1 *s, int i)
  155. {
  156. ASSERT(i >= 0)
  157. ASSERT(i < o->d_count)
  158. return (str0 *)((uint8_t *)s + o->d_off + i * o->d_size);
  159. }