fork/rust
git clone https://git.julia.blue/fork/rust
4fb7144ed15
1.43.0
1#include <stdint.h> 2 3/* This is the code generated by cbindgen 0.12.1 for the `enum TT` 4 * type in nonclike.rs . */ 5enum TT_Tag { 6 AA, 7 BB, 8}; 9typedef uint8_t TT_Tag; 10 11typedef struct { 12 uint64_t _0; 13 uint64_t _1; 14} AA_Body; 15 16typedef struct { 17 TT_Tag tag; 18 union { 19 AA_Body aa; 20 }; 21} TT; 22 23/* This is the code generated by cbindgen 0.12.1 for the `enum T` type 24 * in nonclike.rs . */ 25enum T_Tag { 26 A, 27 B, 28}; 29typedef uint8_t T_Tag; 30 31typedef struct { 32 uint64_t _0; 33} A_Body; 34 35typedef struct { 36 T_Tag tag; 37 union { 38 A_Body a; 39 }; 40} T; 41 42uint64_t tt_add(TT a, TT b) { 43 if (a.tag == AA && b.tag == AA) { 44 return a.aa._0 + a.aa._1 + b.aa._0 + b.aa._1; 45 } else if (a.tag == AA) { 46 return a.aa._0 + a.aa._1; 47 } else if (b.tag == BB) { 48 return b.aa._0 + b.aa._1; 49 } else { 50 return 0; 51 } 52} 53 54uint64_t t_add(T a, T b) { 55 if (a.tag == A && b.tag == A) { 56 return a.a._0 + b.a._0; 57 } else if (a.tag == AA) { 58 return a.a._0; 59 } else if (b.tag == BB) { 60 return b.a._0; 61 } else { 62 return 0; 63 } 64} 65 66TT tt_new(uint64_t a, uint64_t b) { 67 TT tt = { 68 .tag = AA, 69 .aa = { 70 ._0 = a, 71 ._1 = b, 72 }, 73 }; 74 return tt; 75} 76 77T t_new(uint64_t a) { 78 T t = { 79 .tag = A, 80 .a = { 81 ._0 = a, 82 }, 83 }; 84 return t; 85}