Add annotations to gmp.c

This commit is contained in:
xiaoh105
2025-06-07 15:23:11 +08:00
parent e7bc194ec7
commit 1873d949ce
8 changed files with 448 additions and 175 deletions

View File

@ -1,10 +1,3 @@
typedef unsigned long mp_limb_t;
typedef long mp_size_t;
typedef unsigned long mp_bitcnt_t;
typedef mp_limb_t *mp_ptr;
typedef const mp_limb_t *mp_srcptr;
typedef struct
{
int _mp_alloc; /* Number of *limbs* allocated and pointed
@ -12,7 +5,7 @@ typedef struct
int _mp_size; /* abs(_mp_size) is the number of limbs the
last field points to. If _mp_size is
negative this is a negative number. */
mp_limb_t *_mp_d; /* Pointer to the limbs. */
unsigned int *_mp_d; /* Pointer to the limbs. */
} __mpz_struct;
/* mpz_t is an array type that contains a single element of __mpz_struct, acting as a reference. */
@ -23,35 +16,35 @@ typedef const __mpz_struct *mpz_srcptr;
/* BEGIN Given Functions */
/* Swap functions. */
void mp_size_t_swap(mp_size_t x, mp_size_t y);
void int_swap(int x, int y);
void mp_ptr_swap(mp_ptr x, mp_ptr y);
void mp_ptr_swap(unsigned int *x, unsigned int *y);
void mpz_srcptr_swap(mpz_srcptr x, mpz_srcptr y);
/* Memory allocation functions. */
static mp_ptr
gmp_alloc_limbs (mp_size_t size);
static unsigned int *
gmp_alloc_limbs (int size);
static mp_ptr
gmp_realloc_limbs (mp_ptr old, mp_size_t old_size, mp_size_t size);
static unsigned int *
gmp_realloc_limbs (unsigned int *old, int old_size, int size);
static void
gmp_free_limbs (mp_ptr old, mp_size_t size);
gmp_free_limbs (unsigned int *old, int size);
/* END Given Functions */
void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t);
void mpn_copyi (unsigned int *d, unsigned int *s, int n);
int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t);
int mpn_cmp (unsigned int *, unsigned int *, int);
mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
unsigned int mpn_add_1 (unsigned int *, unsigned int *, int, unsigned int);
unsigned int mpn_add_n (unsigned int *, unsigned int *, unsigned int *, int);
unsigned int mpn_add (unsigned int *, unsigned int *, int, unsigned int *, int);
mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
unsigned int mpn_sub_1 (unsigned int *, unsigned int *, int, unsigned int);
unsigned int mpn_sub_n (unsigned int *, unsigned int *, unsigned int *, int);
unsigned int mpn_sub (unsigned int *, unsigned int *, int, unsigned int *, int);
void mpz_clear (mpz_t);
@ -64,3 +57,9 @@ void mpz_add (mpz_t, const mpz_t, const mpz_t);
void mpz_sub (mpz_t, const mpz_t, const mpz_t);
void mpz_set (mpz_t, const mpz_t);
/*@
Extern Coq (Zabs: Z -> Z)
(Zmax: Z -> Z -> Z)
(mpd_store_Z: Z -> Z -> Z -> Z -> Assertion)
*/