Skip to content

API discussions/overhaul #243

Closed
Closed
@minad

Description

@minad

Starting from the discussion in #240 with @czurnieden, I thought a bit about the exposed API.

It might make sense to do a bit of an overhaul and make some functions private. In particular mp_digit is exposed to often in the public API and it would be more useful to provide functions taking signed ints or longs. I consider mp_digit to be more of an implementation detail.

Deprecation of the mp_*_d functions could be done gracefully since they can be replaced by the more general mp_*_int functions.

What could also be discussed is going to defined bit sizes since we include stdint.h and provide functions like mp_add_i32 instead of mp_add_int/mp_add_long. This would make the API platform independent. However this might be a bit of a too large deviation from how things are now. (DONE)

Furthermore mp_set is not needed anymore as soon as #221 #253 has been implemented. Right now mp_set still makes sense since it is guaranteed to not allocate. (KEEP)

Then there are a few functions which seem to be internal and it might make sense to not expose them.

Then there is the rand_digit function which is a remnant of before #236 and could be deprecated. (DEPRECATED)

Concerning the bit manipulation functions, there is mp_get_bit but no mp_set_bit. Either add mp_set_bit or internalize mp_get_bit as s_mp_get_bit?

  • mp_get_bit, mp_set_bit (DEPRECATED)

The one complement bitwise functions could also be internalized, since the two complement functions for positive ints are the equivalent.

  • mp_xor, mp_or, mp_and -> mp_tc_* (already there) (DEPRECATED)
  • mp_tc_div_2d -> mp_bit_rsh (DEPRECATED)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions