gmp-utils: New API to simply use of GMP's integer/rational/float objects
authorJoel Brobecker <brobecker@adacore.com>
Sun, 15 Nov 2020 08:09:44 +0000 (03:09 -0500)
committerJoel Brobecker <brobecker@adacore.com>
Sun, 15 Nov 2020 08:09:44 +0000 (03:09 -0500)
commitb34c74ab9a6b8dc0ace3d0cc67bf62de8a74ea00
treecebf5c4bc8bee8820f497d92258416be8e997564
parent1b4ac058f7daeb9bac9ab0e63a7e73535208dfef
gmp-utils: New API to simply use of GMP's integer/rational/float objects

This API was motivated by a number of reasons:
  - GMP's API does not handle "long long" and "unsigned long long",
    so using LONGEST and ULONGEST is not straightforward;
  - Automate the need to initialize GMP objects before use, and
    clear them when no longer used.

However, this API grew also to help with similar matter such
as formatting to a string, and also reading/writing fixed-point
values from byte buffers.

Dedicated unit testing is also added.

gdb/ChangeLog:

        * gmp-utils.h,  gmp-utils.h: New file.
        * unittests/gmp-utils-selftests.c: New file.
        * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
        unittests/gmp-utils-selftests.c.
        (COMMON_SFILES) Add gmp-utils.c.
        (HFILES_NO_SRCDIR): Add gmp-utils.h.
gdb/ChangeLog
gdb/Makefile.in
gdb/gmp-utils.c [new file with mode: 0644]
gdb/gmp-utils.h [new file with mode: 0644]
gdb/unittests/gmp-utils-selftests.c [new file with mode: 0644]