450-powerpc_copysignl.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. --- a/libc/sysdeps/linux/powerpc/Makefile.arch
  2. +++ b/libc/sysdeps/linux/powerpc/Makefile.arch
  3. @@ -5,7 +5,7 @@
  4. # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. #
  6. -CSRC := __syscall_error.c pread_write.c ioctl.c
  7. +CSRC := __syscall_error.c pread_write.c ioctl.c copysignl.c
  8. ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
  9. CSRC += posix_fadvise.c posix_fadvise64.c
  10. --- /dev/null
  11. +++ b/libc/sysdeps/linux/powerpc/copysignl.c
  12. @@ -0,0 +1,89 @@
  13. +/* s_copysignl.c -- long double version of s_copysign.c.
  14. + * Conversion to long double by Ulrich Drepper,
  15. + * Cygnus Support, drepper@cygnus.com.
  16. + */
  17. +
  18. +/*
  19. + * ====================================================
  20. + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  21. + *
  22. + * Developed at SunPro, a Sun Microsystems, Inc. business.
  23. + * Permission to use, copy, modify, and distribute this
  24. + * software is freely granted, provided that this notice
  25. + * is preserved.
  26. + * ====================================================
  27. + */
  28. +
  29. +/*
  30. + * copysignl(long double x, long double y)
  31. + * copysignl(x,y) returns a value with the magnitude of x and
  32. + * with the sign bit of y.
  33. + */
  34. +
  35. +#include <endian.h>
  36. +#include <stdint.h>
  37. +
  38. +#if __FLOAT_WORD_ORDER == BIG_ENDIAN
  39. +
  40. +typedef union
  41. +{
  42. + long double value;
  43. + struct
  44. + {
  45. + int sign_exponent:16;
  46. + unsigned int empty:16;
  47. + uint32_t msw;
  48. + uint32_t lsw;
  49. + } parts;
  50. +} ieee_long_double_shape_type;
  51. +
  52. +#endif
  53. +
  54. +#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
  55. +
  56. +typedef union
  57. +{
  58. + long double value;
  59. + struct
  60. + {
  61. + uint32_t lsw;
  62. + uint32_t msw;
  63. + int sign_exponent:16;
  64. + unsigned int empty:16;
  65. + } parts;
  66. +} ieee_long_double_shape_type;
  67. +
  68. +#endif
  69. +
  70. +/* Get int from the exponent of a long double. */
  71. +
  72. +#define GET_LDOUBLE_EXP(exp,d) \
  73. +do { \
  74. + ieee_long_double_shape_type ge_u; \
  75. + ge_u.value = (d); \
  76. + (exp) = ge_u.parts.sign_exponent; \
  77. +} while (0)
  78. +
  79. +/* Set exponent of a long double from an int. */
  80. +
  81. +#define SET_LDOUBLE_EXP(d,exp) \
  82. +do { \
  83. + ieee_long_double_shape_type se_u; \
  84. + se_u.value = (d); \
  85. + se_u.parts.sign_exponent = (exp); \
  86. + (d) = se_u.value; \
  87. +} while (0)
  88. +
  89. +long double copysignl(long double x, long double y);
  90. +libc_hidden_proto(copysignl);
  91. +
  92. +long double copysignl(long double x, long double y)
  93. +{
  94. + uint32_t es1,es2;
  95. + GET_LDOUBLE_EXP(es1,x);
  96. + GET_LDOUBLE_EXP(es2,y);
  97. + SET_LDOUBLE_EXP(x,(es1&0x7fff)|(es2&0x8000));
  98. + return x;
  99. +}
  100. +
  101. +libc_hidden_def(copysignl);