aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/ipxe/bigint.h13
-rw-r--r--src/tests/bigint_test.c10
2 files changed, 23 insertions, 0 deletions
diff --git a/src/include/ipxe/bigint.h b/src/include/ipxe/bigint.h
index 36138dd..820d306 100644
--- a/src/include/ipxe/bigint.h
+++ b/src/include/ipxe/bigint.h
@@ -8,6 +8,8 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+#include <assert.h>
+
/**
* Define a big-integer type
*
@@ -177,6 +179,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
} while ( 0 )
/**
+ * Copy big integer
+ *
+ * @v source Source big integer
+ * @v dest Destination big integer
+ */
+#define bigint_copy( source, dest ) do { \
+ build_assert ( sizeof ( *(source) ) == sizeof ( *(dest) ) ); \
+ bigint_shrink ( (source), (dest) ); \
+ } while ( 0 )
+
+/**
* Multiply big integers
*
* @v multiplicand Big integer to be multiplied
diff --git a/src/tests/bigint_test.c b/src/tests/bigint_test.c
index 02568df..484c591 100644
--- a/src/tests/bigint_test.c
+++ b/src/tests/bigint_test.c
@@ -149,6 +149,16 @@ void bigint_shrink_sample ( const bigint_element_t *source0,
bigint_shrink ( source, dest );
}
+void bigint_copy_sample ( const bigint_element_t *source0,
+ bigint_element_t *dest0, unsigned int size ) {
+ const bigint_t ( size ) *source __attribute__ (( may_alias ))
+ = ( ( const void * ) source0 );
+ bigint_t ( size ) *dest __attribute__ (( may_alias ))
+ = ( ( void * ) dest0 );
+
+ bigint_copy ( source, dest );
+}
+
void bigint_multiply_sample ( const bigint_element_t *multiplicand0,
unsigned int multiplicand_size,
const bigint_element_t *multiplier0,