[news] [libzahl] 1.0 release

From: Mattias Andrée <maandree_AT_kth.se>
Date: Sun, 6 Mar 2016 10:22:51 +0100

Greetings everyone!

I am happy to announce the first release of libzahl:
version 1.0 [1].

libzahl is an integer-only bignum library. And this
release contains all functions that I hope to implement
in it:

* Basic bitwise operations.
* Basic arithmetic functions.
* Modular multiplication and modular exponentiation.
* Random number generation.
* Some basic number theoretical functions:
  - Comparison.
  - Odd–even test.
  - Calculation of the greatest common divisor.
  - Primality test.
* Error handling.
* Conversion from and to strings.
* Marshalling.
* Swapping
* The obvious functions:
  - Assignment.
  - Initialisation.
  - Deallocation.

libzahl depends only on libc. However, unless you
are running the Linux kernel you may have to edit
config.mk according to the instructions included
in that file. I hope to make this more automated
in a future release.

libzahl has barely been optimised, thus it performance
is not too great just yet. This will be the primary
goal of future releases.

libzahl is not thread-safe, this may or may not
change in the future. It is however possible to
fork(3p) the process and use the marshalling functions
to send values between the processes efficiently.

And now to its API design...

Before libzahl can be used it has to be initialised.
This is the using the setjmp(3p) and zsetup(3) function:

  jmp_buf env;
  if (setjmp(env)) {
    goto zahl_failure;
  }
  zsetup(env);

As implied by this example code. If an operation cannot
be performed, libzahl performs a long jump to a specified
location. There are a few exceptions where the returned
value of the functions shall be checked instead. This
eliminates the need to clutter the code with if-statements
at every operation, and reduces unnecessary conditional
branching events. zsetup(3) also initialises some temporary
variables use by libzahl's functions.

For all functions that have at least two big integer
parameters, the output parameters are places in the front,
before the input parameters.

All functions support passing non-unique pointers, as
long as they are of the same type and the output parameters
are unique to each other. For example zdivmod(a, b, a, b)
and zdivmod(a, b, b, b) is safe, but not zdivmod(a, a, a,
b), where the first two parameters are output parameters
and the last two parameters are input parameters.

libzahl's big integer data type is defined as
typedef struct { /*....*/ } z_t[1];


Ex animo,
Mattias Andrée

[1] http://git.suckless.org/libzahl/tag/?id=1.0

Received on Sun Mar 06 2016 - 10:22:51 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 06 2016 - 10:24:20 CET