summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-11 03:14:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-11 03:14:21 +0000
commit5b8af7521f8c5f1c218157250d07604bf1b56101 (patch)
tree89fe812310e4770fecf5c0ea99aa0c0ed9a6134b
parent9c0119c4bdc31b90fdd236c816aa02504934f94b (diff)
* missing/signbit.c: added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--configure.in4
-rw-r--r--missing/signbit.c19
3 files changed, 25 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index fc8de0b0d9..aa6e87d804 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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);
+}