vfprintf.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef VFPRINTF_H
  2. #define VFPRINTF_H
  3. #include <limits.h>
  4. #include <string.h>
  5. //#include <stdarg.h>
  6. //#include <stddef.h>
  7. //#include <wchar.h>
  8. #include <inttypes.h>
  9. #include <endian.h>
  10. //#include <stdio.h>
  11. //#include <float.h>
  12. #define LDBL_TRUE_MIN 3.6451995318824746025e-4951L
  13. #define LDBL_MIN 3.3621031431120935063e-4932L
  14. #define LDBL_MAX 1.1897314953572317650e+4932L
  15. #define LDBL_EPSILON 1.0842021724855044340e-19L
  16. #define LDBL_MANT_DIG 64
  17. #define LDBL_MIN_EXP (-16381)
  18. #define LDBL_MAX_EXP 16384
  19. //libm.h
  20. #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
  21. #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
  22. union ldshape {
  23. long double f;
  24. struct {
  25. uint64_t m;
  26. uint16_t se;
  27. } i;
  28. };
  29. #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
  30. union ldshape {
  31. long double f;
  32. struct {
  33. uint64_t lo;
  34. uint32_t mid;
  35. uint16_t top;
  36. uint16_t se;
  37. } i;
  38. struct {
  39. uint64_t lo;
  40. uint64_t hi;
  41. } i2;
  42. };
  43. #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_ENDIAN
  44. union ldshape {
  45. long double f;
  46. struct {
  47. uint16_t se;
  48. uint16_t top;
  49. uint32_t mid;
  50. uint64_t lo;
  51. } i;
  52. struct {
  53. uint64_t hi;
  54. uint64_t lo;
  55. } i2;
  56. };
  57. #else
  58. #error Unsupported long double representation
  59. #endif
  60. int fmt_fp(char*, long double, int, int, int, int);
  61. #endif