BitVecOr
- Function
- August 22, 2025
Table of Contents
BitVecOr
BitVecOr
Description
Perform bitwise OR operation between two bitvectors. Result is stored in the first bitvector.
Parameters
Name | Direction | Description |
---|---|---|
result | out | Bitvector to store result in |
a | in | First bitvector operand |
b | in | Second bitvector operand |
Usage example (from documentation)
BitVecOr(&result, &flags1, &flags2);
Usage example (Cross-references)
- In
BitVec.c:469
:
}
void BitVecOr(BitVec *result, BitVec *a, BitVec *b) {
ValidateBitVec(result);
ValidateBitVec(a);
// Test BitVecOr function
bool test_bitvec_or(void) {
printf("Testing BitVecOr\n");
BitVec bv1 = BitVecInit();
// Perform OR operation
BitVecOr(&result, &bv1, &bv2);
// Expected result: 1110 (1100 OR 1010)
result = result && (result_bv.length == 0);
BitVecOr(&result_bv, &bv1, &bv2);
result = result && (result_bv.length == 0);
// Test OR with different lengths (result should be max length)
BitVecOr(&result, &bv1, &bv2);
test_result = test_result && (result.length == 8);
test_result = test_result && (BitVecGet(&result, 0) == false);
BitVecOr(&result, &bv1, &bv2);
test_result = test_result && (BitVecGet(&result, 0) == true);
// Test A OR A = A
BitVecOr(&result, &bv1, &bv1);
bool or_identity = true;
for (int i = 0; i < 16; i++) {
}
BitVecOr(&result, &bv1, &bv2);
bool or_ones = true;
for (int i = 0; i < 16; i++) {
// Test A OR B = B OR A
BitVecOr(&result1, &bv1, &bv2);
BitVecOr(&result2, &bv2, &bv1);
// Test A OR B = B OR A
BitVecOr(&result1, &bv1, &bv2);
BitVecOr(&result2, &bv2, &bv1);
bool or_commutative = true;
// Test NULL operand - should abort
BitVecOr(&result, &bv1, NULL);
BitVecDeinit(&result);
// Test BitVecOr function
bool test_bitvec_or(void) {
printf("Testing BitVecOr\n");
BitVec bv1 = BitVecInit();
// Perform OR operation
BitVecOr(&result, &bv1, &bv2);
// Expected result: 1110 (1100 OR 1010)
result = result && (result_bv.length == 0);
BitVecOr(&result_bv, &bv1, &bv2);
result = result && (result_bv.length == 0);
// Test OR with different lengths (result should be max length)
BitVecOr(&result, &bv1, &bv2);
test_result = test_result && (result.length == 8);
test_result = test_result && (BitVecGet(&result, 0) == false);
BitVecOr(&result, &bv1, &bv2);
test_result = test_result && (BitVecGet(&result, 0) == true);
// Test A OR A = A
BitVecOr(&result, &bv1, &bv1);
bool or_identity = true;
for (int i = 0; i < 16; i++) {
}
BitVecOr(&result, &bv1, &bv2);
bool or_ones = true;
for (int i = 0; i < 16; i++) {
// Test A OR B = B OR A
BitVecOr(&result1, &bv1, &bv2);
BitVecOr(&result2, &bv2, &bv1);
// Test A OR B = B OR A
BitVecOr(&result1, &bv1, &bv2);
BitVecOr(&result2, &bv2, &bv1);
bool or_commutative = true;
// Test NULL operand - should abort
BitVecOr(&result, &bv1, NULL);
BitVecDeinit(&result);