diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | missing/signbit.c | 19 |
3 files changed, 25 insertions, 2 deletions
@@ -1,3 +1,7 @@ +Thu Mar 11 12:14:17 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * missing/signbit.c: added. + Thu Mar 11 11:16:33 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * configure.in: check if target_archs has changed. diff --git a/configure.in b/configure.in index 33fd245c23..6675d783a4 100644 --- a/configure.in +++ b/configure.in @@ -1114,7 +1114,7 @@ AS_CASE([$rb_cv_broken_glibc_ia64_erfc],[yes],[ac_cv_func_erf=no]) AS_CASE(["$target_os"],[mingw*],[],[AC_REPLACE_FUNCS(vsnprintf)]) AC_REPLACE_FUNCS(dup2 memmove strerror\ strchr strstr crypt flock\ - isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt \ + isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt signbit \ strlcpy strlcat) AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot getcwd eaccess\ truncate ftruncate chsize times utimes utimensat fcntl lockf lstat\ @@ -1124,7 +1124,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot getcwd eacce getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\ getpriority getrlimit setrlimit sysconf \ dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp snprintf\ - setsid telldir seekdir fchmod cosh sinh tanh log2 round signbit\ + setsid telldir seekdir fchmod cosh sinh tanh log2 round\ setuid setgid daemon select_large_fdset setenv unsetenv\ mktime timegm gmtime_r clock_gettime gettimeofday\ pread sendfile shutdown sigaltstack) diff --git a/missing/signbit.c b/missing/signbit.c new file mode 100644 index 0000000000..2f7ce8c601 --- /dev/null +++ b/missing/signbit.c @@ -0,0 +1,19 @@ +#include <limits.h> +#include "ruby.h" + +int +signbit(double x) +{ + enum {double_per_long = sizeof(double) / sizeof(long)}; + enum {long_msb = sizeof(long) * CHAR_BIT - 1}; + union {double d; unsigned long i[double_per_long];} u; + unsigned long l; + + u.d = x; +#ifdef WORDS_BIGENDIAN + l = u.i[0]; +#else + l = u.i[double_per_long - 1]; +#endif + return (int)(l >> long_msb); +} |