version 1.19, 2024/02/21 13:24:37 |
version 1.20, 2024/02/22 13:17:18 |
|
|
int |
int |
it_cmp(struct itype *a, struct itype *b) |
it_cmp(struct itype *a, struct itype *b) |
{ |
{ |
int diff; |
if (a->it_type > b->it_type) |
|
return 1; |
|
if (a->it_type < b->it_type) |
|
return -1; |
|
|
if ((diff = (a->it_type - b->it_type)) != 0) |
/* Basic types need to have the same encoding and size. */ |
return diff; |
if ((a->it_type == CTF_K_INTEGER || a->it_type == CTF_K_FLOAT)) { |
|
if (a->it_enc > b->it_enc) |
|
return 1; |
|
if (a->it_enc < b->it_enc) |
|
return -1; |
|
if (a->it_size > b->it_size) |
|
return 1; |
|
if (a->it_size < b->it_size) |
|
return -1; |
|
} |
|
|
/* Basic types need to have the same size. */ |
|
if ((a->it_type == CTF_K_INTEGER || a->it_type == CTF_K_FLOAT) && |
|
(diff = (a->it_size - b->it_size) != 0)) |
|
return diff; |
|
|
|
/* Arrays need to have same number of elements */ |
/* Arrays need to have same number of elements */ |
if ((a->it_type == CTF_K_ARRAY) && |
if (a->it_type == CTF_K_ARRAY) { |
(diff = (a->it_nelems - b->it_nelems) != 0)) |
if (a->it_nelems > b->it_nelems) |
return diff; |
return 1; |
|
if (a->it_nelems < b->it_nelems) |
|
return -1; |
|
} |
|
|
/* Match by name */ |
/* Match by name */ |
if (!(a->it_flags & ITF_ANON) && !(b->it_flags & ITF_ANON)) |
if (!(a->it_flags & ITF_ANON) && !(b->it_flags & ITF_ANON)) |
|
|
/* Match by reference */ |
/* Match by reference */ |
if ((a->it_refp != NULL) && (b->it_refp != NULL)) |
if ((a->it_refp != NULL) && (b->it_refp != NULL)) |
return it_cmp(a->it_refp, b->it_refp); |
return it_cmp(a->it_refp, b->it_refp); |
|
if (a->it_refp == NULL) |
|
return -1; |
|
if (b->it_refp == NULL) |
|
return 1; |
|
|
return 0; |
return 0; |
} |
} |