diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2019-07-11 16:19:36 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2019-07-11 16:19:36 +0000 |
commit | 9ec6602c9d3c1a8801d996aa3a56c779ce1c5f70 (patch) | |
tree | 5e545ff43b1e5890f0931c244a8b410eb036eb6c /src/headers | |
parent | 846cd5b2b12947753f5fd3f02c49f7d828fb763d (diff) | |
download | skalibs-9ec6602c9d3c1a8801d996aa3a56c779ce1c5f70.tar.xz |
bits-fmtscan refactor, part one
Diffstat (limited to 'src/headers')
-rw-r--r-- | src/headers/bits-header | 3 | ||||
-rw-r--r-- | src/headers/bits-stdint | 2 | ||||
-rw-r--r-- | src/headers/bits-template | 31 | ||||
-rw-r--r-- | src/headers/uint64-noulong64 | 12 | ||||
-rw-r--r-- | src/headers/uint64-ulong64 | 12 |
5 files changed, 49 insertions, 11 deletions
diff --git a/src/headers/bits-header b/src/headers/bits-header index 58eee22..e96eecc 100644 --- a/src/headers/bits-header +++ b/src/headers/bits-header @@ -3,4 +3,5 @@ #ifndef UINT@BITS@_H #define UINT@BITS@_H -#include <sys/types.h> +#include <stddef.h> +#include <stdint.h> diff --git a/src/headers/bits-stdint b/src/headers/bits-stdint deleted file mode 100644 index 31da039..0000000 --- a/src/headers/bits-stdint +++ /dev/null @@ -1,2 +0,0 @@ -#include <stdint.h> - diff --git a/src/headers/bits-template b/src/headers/bits-template index b09036b..fa08dd9 100644 --- a/src/headers/bits-template +++ b/src/headers/bits-template @@ -10,9 +10,8 @@ extern uint@BITS@_t uint@BITS@_bswap (uint@BITS@_t) ; #define UINT@BITS@_XFMT @XFMT@ #define UINT@BITS@_BFMT @BFMT@ -extern size_t uint@BITS@_fmt_base (char *, uint@BITS@_t, unsigned int) ; -extern size_t uint@BITS@0_fmt_base (char *, uint@BITS@_t, size_t, unsigned int) ; - +#define uint@BITS@_fmt_base(s, u, base) uint64_fmt_generic(s, u, base) +#define uint@BITS@0_fmt_base(s, u, n, base) uint640_fmt_generic(s, u, n, base) #define uint@BITS@_fmt(s, u) uint@BITS@_fmt_base(s, (u), 10) #define uint@BITS@0_fmt(s, u, n) uint@BITS@0_fmt_base(s, u, (n), 10) #define uint@BITS@_ofmt(s, o) uint@BITS@_fmt_base(s, (o), 8) @@ -24,8 +23,8 @@ extern size_t uint@BITS@0_fmt_base (char *, uint@BITS@_t, size_t, unsigned int) extern size_t uint@BITS@_fmtlist (char *, uint@BITS@_t const *, size_t) ; -extern size_t uint@BITS@_scan_base (char const *, uint@BITS@_t *, unsigned int) ; -extern size_t uint@BITS@0_scan_base (char const *, uint@BITS@_t *, unsigned int) ; +extern size_t uint@BITS@_scan_base (char const *, uint@BITS@_t *, uint8_t) ; +extern size_t uint@BITS@0_scan_base (char const *, uint@BITS@_t *, uint8_t) ; #define uint@BITS@_scan(s, u) uint@BITS@_scan_base(s, (u), 10) #define uint@BITS@0_scan(s, u) uint@BITS@0_scan_base(s, (u), 10) @@ -38,8 +37,24 @@ extern size_t uint@BITS@0_scan_base (char const *, uint@BITS@_t *, unsigned int) extern size_t uint@BITS@_scanlist (uint@BITS@_t *, size_t, char const *, size_t *) ; -extern size_t int@BITS@_fmt (char *, int@BITS@_t) ; +#define int@BITS@_fmt_base(s, u, base) int64_fmt_generic(s, u, base) +#define int@BITS@_fmt(s, u) int@BITS@_fmt_base(s, (u), 10) +#define int@BITS@_ofmt(s, o) int@BITS@_fmt_base(s, (o), 8) +#define int@BITS@_xfmt(s, x) int@BITS@_fmt_base(s, (x), 16) +#define int@BITS@_bfmt(s, b) int@BITS@0_fmt_base(s, (b), 2) + extern size_t int@BITS@_fmtlist (char *, int@BITS@_t const *, size_t) ; -extern size_t int@BITS@_scan (char const *, int@BITS@_t *) ; -extern size_t int@BITS@0_scan (char const *, int@BITS@_t *) ; + +extern size_t int@BITS@_scan_base (char const *, int@BITS@_t *, uint8_t) ; +extern size_t int@BITS@0_scan_base (char const *, int@BITS@_t *, uint8_t) ; + +#define int@BITS@_scan(s, u) int@BITS@_scan_base(s, (u), 10) +#define int@BITS@0_scan(s, u) int@BITS@0_scan_base(s, (u), 10) +#define int@BITS@_oscan(s, u) int@BITS@_scan_base(s, (u), 8) +#define int@BITS@0_oscan(s, u) int@BITS@0_scan_base(s, (u), 8) +#define int@BITS@_xscan(s, u) int@BITS@_scan_base(s, (u), 16) +#define int@BITS@0_xscan(s, u) int@BITS@0_scan_base(s, (u), 16) +#define int@BITS@_bscan(s, u) int@BITS@_scan_base(s, (u), 2) +#define int@BITS@0_bscan(s, u) int@BITS@0_scan_base(s, (u), 2) + extern size_t int@BITS@_scanlist (int@BITS@_t *, size_t, char const *, size_t *) ; diff --git a/src/headers/uint64-noulong64 b/src/headers/uint64-noulong64 index 1a67c1d..fe61dda 100644 --- a/src/headers/uint64-noulong64 +++ b/src/headers/uint64-noulong64 @@ -1,3 +1,15 @@ typedef unsigned long long uint64_t ; +typedef signed long long int64_t ; +#ifndef INT64_MIN +# define INT64_MIN (-1-0x7fffffffffffffffll) +#endif + +#ifndef INT64_MAX +# define INT64_MAX 0x7fffffffffffffffll +#endif + +#ifndef UINT64_MAX +# define UINT64_MAX 0xffffffffffffffffull +#endif diff --git a/src/headers/uint64-ulong64 b/src/headers/uint64-ulong64 index 84ae235..f01c668 100644 --- a/src/headers/uint64-ulong64 +++ b/src/headers/uint64-ulong64 @@ -1,3 +1,15 @@ typedef unsigned long uint64_t ; +typedef long int64_t ; +#ifndef INT64_MIN +# define INT64_MIN (-1-0x7fffffffffffffffl) +#endif + +#ifndef INT64_MAX +# define INT64_MAX 0x7fffffffffffffffl +#endif + +#ifndef UINT64_MAX +# define UINT64_MAX 0xfffffffffffffffful +#endif |