| 1 |
|
| #ifdef __cplusplus |
| 2 |
|
| extern "C" { |
| 3 |
|
| #endif |
| 4 |
|
| |
| 5 |
|
| #include "ulib/compare.h" |
| 6 |
|
| #include "ulib/pack.h" |
| 7 |
|
| #include "ulib/util.h" |
| 8 |
|
| |
| 9 |
|
| #ifdef __cplusplus |
| 10 |
|
| } |
| 11 |
|
| #endif |
| 12 |
|
| |
| 13 |
|
| #define UUCMP(u1,u2) if (u1 != u2) return((u1) > (u2) ? 1 : -1); |
| 14 |
|
| |
| 15 |
7 |
| IV uu_compare_struct0(const struct_uu_t *us1, const struct_uu_t *us2) { |
| 16 |
7 |
▶ | UUCMP(us1->v0.low, us2->v0.low); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v0.low, us2->v0.low); |
0 |
7 |
7 |
| UUCMP(us1->v0.low, us2->v0.low); |
0 |
0 |
0 |
|
| 17 |
7 |
▶ | UUCMP(us1->v0.high, us2->v0.high); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v0.high, us2->v0.high); |
0 |
7 |
7 |
| UUCMP(us1->v0.high, us2->v0.high); |
0 |
0 |
0 |
|
| 18 |
7 |
| return 0; |
| 19 |
|
| } |
| 20 |
|
| |
| 21 |
19 |
| IV uu_compare_struct1(const struct_uu_t *us1, const struct_uu_t *us2) { |
| 22 |
19 |
▶ | UUCMP(us1->v1.time_low, us2->v1.time_low); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v1.time_low, us2->v1.time_low); |
4 |
15 |
19 |
| UUCMP(us1->v1.time_low, us2->v1.time_low); |
2 |
2 |
4 |
|
| 23 |
15 |
▶ | UUCMP(us1->v1.time_mid, us2->v1.time_mid); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v1.time_mid, us2->v1.time_mid); |
0 |
15 |
15 |
| UUCMP(us1->v1.time_mid, us2->v1.time_mid); |
0 |
0 |
0 |
|
| 24 |
15 |
▶ | UUCMP(us1->v1.time_high_and_version, us2->v1.time_high_and_version); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v1.time_high_and_version, us2->v1.time_high_and_version); |
0 |
15 |
15 |
| UUCMP(us1->v1.time_high_and_version, us2->v1.time_high_and_version); |
0 |
0 |
0 |
|
| 25 |
15 |
▶ | UUCMP(us1->v1.clock_seq_and_variant, us2->v1.clock_seq_and_variant); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v1.clock_seq_and_variant, us2->v1.clock_seq_and_variant); |
0 |
15 |
15 |
| UUCMP(us1->v1.clock_seq_and_variant, us2->v1.clock_seq_and_variant); |
0 |
0 |
0 |
|
| 26 |
15 |
| return memcmp(us1->v1.node, us2->v1.node, 6); |
| 27 |
|
| } |
| 28 |
|
| |
| 29 |
19 |
| IV uu_compare_struct3(const struct_uu_t *us1, const struct_uu_t *us2) { |
| 30 |
19 |
▶ | UUCMP(us1->v3.md5_high32, us2->v3.md5_high32); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v3.md5_high32, us2->v3.md5_high32); |
0 |
19 |
19 |
| UUCMP(us1->v3.md5_high32, us2->v3.md5_high32); |
0 |
0 |
0 |
|
| 31 |
19 |
▶ | UUCMP(us1->v3.md5_high16, us2->v3.md5_high16); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v3.md5_high16, us2->v3.md5_high16); |
0 |
19 |
19 |
| UUCMP(us1->v3.md5_high16, us2->v3.md5_high16); |
0 |
0 |
0 |
|
| 32 |
19 |
▶ | UUCMP(us1->v3.md5_mid_and_version, us2->v3.md5_mid_and_version); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v3.md5_mid_and_version, us2->v3.md5_mid_and_version); |
0 |
19 |
19 |
| UUCMP(us1->v3.md5_mid_and_version, us2->v3.md5_mid_and_version); |
0 |
0 |
0 |
|
| 33 |
19 |
▶ | UUCMP(us1->v3.md5_low_and_variant, us2->v3.md5_low_and_variant); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v3.md5_low_and_variant, us2->v3.md5_low_and_variant); |
0 |
19 |
19 |
| UUCMP(us1->v3.md5_low_and_variant, us2->v3.md5_low_and_variant); |
0 |
0 |
0 |
|
| 34 |
19 |
▶ | UUCMP(us1->v3.md5_low, us2->v3.md5_low); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v3.md5_low, us2->v3.md5_low); |
0 |
19 |
19 |
| UUCMP(us1->v3.md5_low, us2->v3.md5_low); |
0 |
0 |
0 |
|
| 35 |
19 |
| return 0; |
| 36 |
|
| } |
| 37 |
|
| |
| 38 |
117 |
| IV uu_compare_struct4(const struct_uu_t *us1, const struct_uu_t *us2) { |
| 39 |
117 |
▶ | UUCMP(us1->v4.rand_a, us2->v4.rand_a); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v4.rand_a, us2->v4.rand_a); |
102 |
15 |
117 |
| UUCMP(us1->v4.rand_a, us2->v4.rand_a); |
101 |
1 |
102 |
|
| 40 |
15 |
▶ | UUCMP(us1->v4.rand_b_and_version, us2->v4.rand_b_and_version); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v4.rand_b_and_version, us2->v4.rand_b_and_version); |
0 |
15 |
15 |
| UUCMP(us1->v4.rand_b_and_version, us2->v4.rand_b_and_version); |
0 |
0 |
0 |
|
| 41 |
15 |
▶ | UUCMP(us1->v4.rand_c_and_variant, us2->v4.rand_c_and_variant); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v4.rand_c_and_variant, us2->v4.rand_c_and_variant); |
0 |
15 |
15 |
| UUCMP(us1->v4.rand_c_and_variant, us2->v4.rand_c_and_variant); |
0 |
0 |
0 |
|
| 42 |
15 |
▶ | UUCMP(us1->v4.rand_d, us2->v4.rand_d); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v4.rand_d, us2->v4.rand_d); |
0 |
15 |
15 |
| UUCMP(us1->v4.rand_d, us2->v4.rand_d); |
0 |
0 |
0 |
|
| 43 |
15 |
| return 0; |
| 44 |
|
| } |
| 45 |
|
| |
| 46 |
19 |
| IV uu_compare_struct5(const struct_uu_t *us1, const struct_uu_t *us2) { |
| 47 |
19 |
▶ | UUCMP(us1->v5.sha1_high32, us2->v5.sha1_high32); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v5.sha1_high32, us2->v5.sha1_high32); |
0 |
19 |
19 |
| UUCMP(us1->v5.sha1_high32, us2->v5.sha1_high32); |
0 |
0 |
0 |
|
| 48 |
19 |
▶ | UUCMP(us1->v5.sha1_high16, us2->v5.sha1_high16); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v5.sha1_high16, us2->v5.sha1_high16); |
0 |
19 |
19 |
| UUCMP(us1->v5.sha1_high16, us2->v5.sha1_high16); |
0 |
0 |
0 |
|
| 49 |
19 |
▶ | UUCMP(us1->v5.sha1_mid_and_version, us2->v5.sha1_mid_and_version); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v5.sha1_mid_and_version, us2->v5.sha1_mid_and_version); |
0 |
19 |
19 |
| UUCMP(us1->v5.sha1_mid_and_version, us2->v5.sha1_mid_and_version); |
0 |
0 |
0 |
|
| 50 |
19 |
▶ | UUCMP(us1->v5.sha1_low_and_variant, us2->v5.sha1_low_and_variant); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v5.sha1_low_and_variant, us2->v5.sha1_low_and_variant); |
0 |
19 |
19 |
| UUCMP(us1->v5.sha1_low_and_variant, us2->v5.sha1_low_and_variant); |
0 |
0 |
0 |
|
| 51 |
19 |
▶ | UUCMP(us1->v5.sha1_low, us2->v5.sha1_low); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v5.sha1_low, us2->v5.sha1_low); |
0 |
19 |
19 |
| UUCMP(us1->v5.sha1_low, us2->v5.sha1_low); |
0 |
0 |
0 |
|
| 52 |
19 |
| return 0; |
| 53 |
|
| } |
| 54 |
|
| |
| 55 |
15 |
| IV uu_compare_struct6(const struct_uu_t *us1, const struct_uu_t *us2) { |
| 56 |
15 |
▶ | UUCMP(us1->v6.time_high, us2->v6.time_high); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v6.time_high, us2->v6.time_high); |
0 |
15 |
15 |
| UUCMP(us1->v6.time_high, us2->v6.time_high); |
0 |
0 |
0 |
|
| 57 |
15 |
▶ | UUCMP(us1->v6.time_mid, us2->v6.time_mid ); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v6.time_mid, us2->v6.time_mid ); |
0 |
15 |
15 |
| UUCMP(us1->v6.time_mid, us2->v6.time_mid ); |
0 |
0 |
0 |
|
| 58 |
15 |
▶ | UUCMP(us1->v6.time_low_and_version, us2->v6.time_low_and_version ); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v6.time_low_and_version, us2->v6.time_low_and_version ); |
2 |
13 |
15 |
| UUCMP(us1->v6.time_low_and_version, us2->v6.time_low_and_version ); |
1 |
1 |
2 |
|
| 59 |
13 |
▶ | UUCMP(us1->v6.clock_seq_and_variant, us2->v6.clock_seq_and_variant); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v6.clock_seq_and_variant, us2->v6.clock_seq_and_variant); |
0 |
13 |
13 |
| UUCMP(us1->v6.clock_seq_and_variant, us2->v6.clock_seq_and_variant); |
0 |
0 |
0 |
|
| 60 |
13 |
| return memcmp(us1->v6.node, us2->v6.node, 6); |
| 61 |
|
| return 0; |
| 62 |
|
| } |
| 63 |
|
| |
| 64 |
15 |
| IV uu_compare_struct7(const struct_uu_t *us1, const struct_uu_t *us2) { |
| 65 |
15 |
▶ | UUCMP(us1->v7.time_high, us2->v7.time_high); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v7.time_high, us2->v7.time_high); |
0 |
15 |
15 |
| UUCMP(us1->v7.time_high, us2->v7.time_high); |
0 |
0 |
0 |
|
| 66 |
15 |
▶ | UUCMP(us1->v7.time_low, us2->v7.time_low ); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v7.time_low, us2->v7.time_low ); |
0 |
15 |
15 |
| UUCMP(us1->v7.time_low, us2->v7.time_low ); |
0 |
0 |
0 |
|
| 67 |
15 |
▶ | UUCMP(us1->v7.rand_a_and_version, us2->v7.rand_a_and_version); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v7.rand_a_and_version, us2->v7.rand_a_and_version); |
2 |
13 |
15 |
| UUCMP(us1->v7.rand_a_and_version, us2->v7.rand_a_and_version); |
1 |
1 |
2 |
|
| 68 |
13 |
▶ | UUCMP(us1->v7.rand_b_and_variant, us2->v7.rand_b_and_variant); |
Branch: 2 branches
| Branch | True | False | Total |
| UUCMP(us1->v7.rand_b_and_variant, us2->v7.rand_b_and_variant); |
0 |
13 |
13 |
| UUCMP(us1->v7.rand_b_and_variant, us2->v7.rand_b_and_variant); |
0 |
0 |
0 |
|
| 69 |
13 |
| return 0; |
| 70 |
|
| } |
| 71 |
|
| |
| 72 |
296 |
| IV uu_compare_binary(const uu_t uu1, const uu_t uu2) { |
| 73 |
|
| IV typ1, typ2, var1, var2; |
| 74 |
|
| struct_uu_t us1, us2; |
| 75 |
|
| |
| 76 |
296 |
| uu_pack_unpack(uu1, &us1); |
| 77 |
296 |
| uu_pack_unpack(uu2, &us2); |
| 78 |
|
| |
| 79 |
296 |
| var1 = uu_variant(&us1); |
| 80 |
296 |
| var2 = uu_variant(&us2); |
| 81 |
|
| |
| 82 |
296 |
▶ | if (var1 != var2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (var1 != var2) |
23 |
273 |
296 |
|
| 83 |
23 |
▶ | return var1 > var2 ? 1 : -1; |
Branch: 1 branch
| Branch | True | False | Total |
| return var1 > var2 ? 1 : -1; |
14 |
9 |
23 |
|
| 84 |
|
| |
| 85 |
273 |
| typ1 = uu_type(&us1); |
| 86 |
273 |
| typ2 = uu_type(&us2); |
| 87 |
|
| |
| 88 |
273 |
▶ | if (typ1 != typ2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (typ1 != typ2) |
62 |
211 |
273 |
|
| 89 |
62 |
▶ | return typ1 > typ2 ? 1 : -1; |
Branch: 1 branch
| Branch | True | False | Total |
| return typ1 > typ2 ? 1 : -1; |
31 |
31 |
62 |
|
| 90 |
|
| |
| 91 |
211 |
| switch(typ1) { |
| 92 |
19 |
| case 1: return uu_compare_struct1(&us1, &us2); |
| 93 |
19 |
| case 3: return uu_compare_struct3(&us1, &us2); |
| 94 |
117 |
| case 4: return uu_compare_struct4(&us1, &us2); |
| 95 |
19 |
| case 5: return uu_compare_struct5(&us1, &us2); |
| 96 |
15 |
| case 6: return uu_compare_struct6(&us1, &us2); |
| 97 |
15 |
| case 7: return uu_compare_struct7(&us1, &us2); |
| 98 |
|
| } |
| 99 |
|
| |
| 100 |
|
| /* handles null and unknown types */ |
| 101 |
7 |
| return uu_compare_struct0(&us1, &us2); |
| 102 |
|
| } |
| 103 |
|
| |
| 104 |
|
| |
| 105 |
113 |
| IV uu_compare_isnull_binary(const uu_t in) |
| 106 |
|
| { |
| 107 |
113 |
| const U8 *cp = in; |
| 108 |
|
| IV i; |
| 109 |
|
| |
| 110 |
529 |
▶ | for (i=0; i<sizeof(uu_t); i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i=0; i<sizeof(uu_t); i++) |
503 |
26 |
529 |
|
| 111 |
503 |
▶ | if (*cp++) |
Branch: 1 branch
| Branch | True | False | Total |
| if (*cp++) |
87 |
416 |
503 |
|
| 112 |
87 |
| return 0; |
| 113 |
26 |
| return 1; |
| 114 |
|
| } |
| 115 |
|
| |
| 116 |
0 |
| IV uu_compare_isnull_struct(const struct_uu_t *in) { |
| 117 |
0 |
▶ | if (in->v0.low) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (in->v0.low) return 0; |
0 |
0 |
0 |
|
| 118 |
0 |
▶ | if (in->v0.high) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (in->v0.high) return 0; |
0 |
0 |
0 |
|
| 119 |
0 |
| return 1; |
| 120 |
|
| } |
| 121 |
|
| |
| 122 |
|
| /* ex:set ts=2 sw=2 itab=spaces: */ |