Files
Rusty Russell 6e5cb299dd global: remove unnecessary includes from C files.
Basically, `devtools/reduce-includes.sh */*.c`.

Build time from make clean (RUST=0) (includes building external libs):

Before:
	real    0m38.944000-40.416000(40.1131+/-0.4)s
	user    3m6.790000-17.159000(15.0571+/-2.8)s
	sys     0m35.304000-37.336000(36.8942+/-0.57)s
After:
	real    0m37.872000-39.974000(39.5466+/-0.59)s
	user    3m1.211000-14.968000(12.4556+/-3.9)s
	sys     0m35.008000-36.830000(36.4143+/-0.5)s

Build time after touch config.vars (RUST=0):

Before:
	real    0m19.831000-21.862000(21.5528+/-0.58)s
	user    2m15.361000-30.731000(28.4798+/-4.4)s
	sys     0m21.056000-22.339000(22.0346+/-0.35)s

After:
	real    0m18.384000-21.307000(20.8605+/-0.92)s
	user    2m5.585000-26.843000(23.6017+/-6.7)s
	sys     0m19.650000-22.003000(21.4943+/-0.69)s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-10-23 06:44:04 +10:30

44 lines
1.1 KiB
C

/* Simple tool to convert to/from our internal fp16 representation */
#include "config.h"
#include <ccan/opt/opt.h>
#include <common/fp16.h>
#include <common/setup.h>
#include <inttypes.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
fp16_t fp16val;
u64 u64min, u64max;
char *endp;
common_setup(argv[0]);
opt_register_noarg("-h|--help", opt_usage_and_exit,
"[fp16:val|value]\n"
"Converts to/from fp16, indicates ranges",
"Get usage information");
opt_parse(&argc, argv, opt_log_stderr_exit);
if (argc != 2)
opt_usage_exit_fail("Expect 1 argument");
if (strstarts(argv[1], "fp16:"))
fp16val = strtoul(argv[1] + 5, &endp, 0);
else
fp16val = u64_to_fp16(strtoul(argv[1], &endp, 0), false);
if (*endp)
opt_usage_exit_fail("Expect valid number");
u64min = u64max = fp16_to_u64(fp16val);
while (u64_to_fp16(u64min-1, false) == fp16val)
u64min--;
while (u64_to_fp16(u64max+1, false) == fp16val)
u64max++;
printf("fp16:0x%x\n"
"min %"PRIu64"\n"
"max %"PRIu64"\n",
fp16val, u64min, u64max);
common_shutdown();
}