4
0

human.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef HUMAN_H_
  2. # define HUMAN_H_ 1
  3. # if HAVE_CONFIG_H
  4. # include <config.h>
  5. # endif
  6. # if HAVE_INTTYPES_H
  7. # include <inttypes.h>
  8. # endif
  9. # if HAVE_LIMITS_H
  10. # include <limits.h>
  11. # endif
  12. # ifndef CHAR_BIT
  13. # define CHAR_BIT 8
  14. # endif
  15. /* A conservative bound on the maximum length of a human-readable string.
  16. The output can be the product of the largest uintmax_t and the largest int,
  17. so add their sizes before converting to a bound on digits. */
  18. # define LONGEST_HUMAN_READABLE ((sizeof (uintmax_t) + sizeof (int)) \
  19. * CHAR_BIT / 3)
  20. # ifndef PARAMS
  21. # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
  22. # define PARAMS(Args) Args
  23. # else
  24. # define PARAMS(Args) ()
  25. # endif
  26. # endif
  27. enum human_inexact_style
  28. {
  29. human_floor = -1,
  30. human_round_to_even = 0,
  31. human_ceiling = 1
  32. };
  33. char *human_readable PARAMS ((uintmax_t, char *, int, int));
  34. char *human_readable_inexact PARAMS ((uintmax_t, char *, int, int,
  35. enum human_inexact_style));
  36. void human_block_size PARAMS ((char const *, int, int *));
  37. #endif /* HUMAN_H_ */