[前][次][番号順一覧][スレッド一覧]

ruby-changes:23621

From: yugui <ko1@a...>
Date: Thu, 17 May 2012 11:49:14 +0900 (JST)
Subject: [ruby-changes:23621] yugui:r35672 (trunk): Imports Ruby's port to NativeClient (a.k.a NaCl).

yugui	2012-05-17 11:48:59 +0900 (Thu, 17 May 2012)

  New Revision: 35672

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35672

  Log:
    Imports Ruby's port to NativeClient (a.k.a NaCl).
    Patch by Google Inc. [ruby-core:45073].
    
    * configure.in (RUBY_NACL): New M4 func to configure variables for
      NaCl.
      (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
      of Pepper interface types.
      (BTESTRUBY): New variable to specify which ruby should be run on
      "make btest". NaCl can run the built binary by sel_ldr, but it need
      rbconfig.rb. So this variable is distinguished from $MINIRUBY.
      
    * thread_pthread.c: Disabled some features on NaCl.
    
    * io.c: ditto.
    
    * process.c: ditto.
    
    * signal.c: ditto.
    
    * file.c: ditto.
    
    * missing/flock.c: ditto.
    
    * nacl/pepper_main.c: An example implementation of Pepper application
      that embeds Ruby.
    
    * nacl/example.html: An example of web page that uses the Pepper
      application.
    
    * nacl/nacl-config.rb: Detects variants of NaCl SDK.
    
    * nacl/GNUmakefile.in: Makefile template for NaCl specific build
      process.
    
    * nacl/package.rb: script for packaging a NaCl-Ruby embedding
      application. 
    
    * nacl/reate_nmf.rb: Wrapper script of create_nmf.py
    
    * dln.c (dln_load): Added a hack to call on NaCl.
    
    * util.c (ruby_getcwd): Path to the current directort is not available
      on NaCl.

  Added directories:
    trunk/nacl/
  Added files:
    trunk/ext/Setup.nacl
    trunk/nacl/GNUmakefile.in
    trunk/nacl/README.nacl
    trunk/nacl/create_nmf.rb
    trunk/nacl/dirent.h
    trunk/nacl/example.html
    trunk/nacl/ioctl.h
    trunk/nacl/nacl-config.rb
    trunk/nacl/package.rb
    trunk/nacl/pepper_main.c
    trunk/nacl/resource.h
    trunk/nacl/select.h
    trunk/nacl/signal.h
    trunk/nacl/stat.h
    trunk/nacl/unistd.h
    trunk/nacl/utime.h
  Modified files:
    trunk/ChangeLog
    trunk/Makefile.in
    trunk/common.mk
    trunk/configure.in
    trunk/dir.c
    trunk/dln.c
    trunk/ext/extmk.rb
    trunk/ext/pty/extconf.rb
    trunk/file.c
    trunk/gc.c
    trunk/gc.h
    trunk/io.c
    trunk/iseq.c
    trunk/missing/flock.c
    trunk/process.c
    trunk/signal.c
    trunk/thread.c
    trunk/thread_pthread.c
    trunk/util.c
    trunk/vm_core.h
    trunk/win32/Makefile.sub

Index: configure.in
===================================================================
--- configure.in	(revision 35671)
+++ configure.in	(revision 35672)
@@ -51,6 +51,79 @@
 ])
 ])
 
+AC_DEFUN([RUBY_NACL],
+[
+ AS_CASE(["${host_os}"], 
+[nacl], [
+  ac_cv_exeext=.nexe
+  host_vendor=chromium
+  ac_cv_host=chromium
+  AC_MSG_CHECKING([wheather \$NACL_SDK_ROOT is set])
+  if test x"${NACL_SDK_ROOT}" = x; then
+    AC_MSG_RESULT([no])
+    AC_MSG_ERROR([You need to set \$NACL_SDK_ROOT environment variable to build for NativeClient])
+  fi
+  AC_MSG_RESULT([yes])
+
+  nacl_cv_build_variant=glibc
+  AC_ARG_WITH(newlib,
+              AS_HELP_STRING([--with-newlib], [uses newlib version of NativeClient SDK]),
+              [AS_CASE([$withval],
+                       [no], [nacl_cv_build_variant=glibc],
+                       [yes], [nacl_cv_build_variant=newlib])])
+
+  AS_CASE(["$build_cpu"],
+          [x86_64|i?86], [nacl_cv_cpu_nick=x86], [nacl_cv_cpu_nick=$build_cpu])
+  AS_CASE(["$build_os"],
+          [linux*], [nacl_cv_os_nick=linux],
+          [darwin*], [nacl_cv_os_nick=mac],
+          [cygwin*|mingw*], [nacl_cv_os_nick=win],
+          [nacl_cv_os_nick=$build_os])
+
+  host="$host_cpu-chromium-$host_os-"
+  ac_tool_prefix="$host_cpu-nacl-"
+
+  AC_MSG_CHECKING([NativeClient toolchain])
+  if test -d \
+    "${NACL_SDK_ROOT}/toolchain/${nacl_cv_os_nick}_${nacl_cv_cpu_nick}_${nacl_cv_build_variant}"; then
+    NACL_TOOLCHAIN="${nacl_cv_os_nick}_${nacl_cv_cpu_nick}_${nacl_cv_build_variant}"
+  else
+    AS_CASE(
+      ["${nacl_cv_build_variant}"],
+      [glibc], [if test \
+        -d "${NACL_SDK_ROOT}/toolchain/${nacl_cv_os_nick}_${nacl_cv_cpu_nick}_newlib" \
+        -a -d "${NACL_SDK_ROOT}/toolchain/${nacl_cv_os_nick}_${nacl_cv_cpu_nick}"; then
+        NACL_TOOLCHAIN="${nacl_cv_os_nick}_${nacl_cv_cpu_nick}"
+      fi],
+      [newlib], [ NACL_TOOLCHAIN="${nacl_cv_os_nick}_${nacl_cv_cpu_nick}" ])
+  fi
+  if test ! -e "${NACL_SDK_ROOT}/toolchain/${NACL_TOOLCHAIN}/${ac_tool_prefix}gcc"; then
+    if test "${build_cpu}" = i686 -a -e "${NACL_SDK_ROOT}/toolchain/${NACL_TOOLCHAIN}/nacl-gcc"; then
+      ac_tool_prefix=nacl-
+    fi
+    if test "${build_cpu}" = x86_64 -a -e "${NACL_SDK_ROOT}/toolchain/${NACL_TOOLCHAIN}/nacl-gcc"; then
+      ac_tool_prefix=nacl64-
+    fi
+  fi
+  if test -z "${NACL_TOOLCHAIN}"; then
+    AC_MSG_ERROR([Unrecognized --host and --build combination or NaCl SDK is not installed])
+  fi
+  PATH="${PATH}:${NACL_SDK_ROOT}/toolchain/${NACL_TOOLCHAIN}/bin"
+  AC_MSG_RESULT(${NACL_TOOLCHAIN})
+
+  AC_SUBST(NACL_TOOLCHAIN)
+  AC_SUBST(NACL_SDK_ROOT)
+  AC_SUBST(NACL_SDK_VARIANT, nacl_cv_build_variant)
+])])
+
+AC_DEFUN([RUBY_NACL_CHECK_PEPPER_TYPES],
+[
+ AC_CHECK_TYPES([struct PPB_Core, struct PPB_Messaging, struct PPB_Var,
+              struct PPB_URLLoader, struct PPB_URLRequestInfo,
+              struct PPB_URLResponseInfo, struct PPB_FileRef,
+              struct PPP_Instance])
+])
+
 AC_DEFUN([RUBY_CPPOUTFILE],
 [AC_CACHE_CHECK(whether ${CPP} accepts -o, rb_cv_cppoutfile,
 [cppflags=$CPPFLAGS
@@ -283,6 +356,7 @@
     cxxflags="$cxxflags "'${optflags} ${debugflags} ${warnflags}'
 fi
 
+RUBY_NACL
 if test x"${build}" != x"${host}"; then
   AC_CHECK_TOOL(CC, gcc)
 fi
@@ -377,6 +451,7 @@
 
 AC_CHECK_PROGS(DOT, dot)
 AC_CHECK_PROGS(DOXYGEN, doxygen)
+AS_CASE(["${host_os}"], [nacl], [AC_PATH_PROG(PYTHON, python)])
 
 AC_CHECK_PROG(PKG_CONFIG, pkg-config, [pkg-config], [], [],
     [`"$as_dir/$ac_word$ac_exec_ext" --print-errors --version > /dev/null 2>&1 || echo "$as_dir/$ac_word$ac_exec_ext"`])
@@ -509,7 +584,7 @@
 
     # -fstack-protector
     AS_CASE(["$target_os"],
-    [mingw*], [
+    [mingw*|nacl], [
 	stack_protector=no
     ],
     [
@@ -1135,6 +1210,14 @@
 		],
 [superux*], [	ac_cv_func_setitimer=no
 		],
+[nacl], [
+  LIBS="-lm -lnosys $LIBS"
+  if test "${nacl_cv_build_variant}" = "newlib"; then
+    RUBY_APPEND_OPTION(CPPFLAGS, -DNACL_NEWLIB)
+  else
+    RUBY_APPEND_OPTION(XCFLAGS, -fPIC)
+  fi
+  ],
 [	LIBS="-lm $LIBS"])
 AC_CHECK_LIB(crypt, crypt)
 AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
@@ -1201,6 +1284,9 @@
 
 AC_CHECK_TYPES([struct timespec], [], [], [@%:@ifdef HAVE_TIME_H
 @%:@include <time.h>
+@%:@endif
+@%:@ifdef HAVE_SYS_TIME_H
+@%:@include <sys/time.h>
 @%:@endif])
 
 AC_CHECK_TYPES([struct timezone], [], [], [@%:@ifdef HAVE_TIME_H
@@ -1263,6 +1349,8 @@
 RUBY_DEFINT(uintptr_t, void*, unsigned)
 RUBY_DEFINT(ssize_t, size_t, [], [@%:@include <sys/types.h>])	dnl may differ from int, so not use AC_TYPE_SSIZE_T.
 
+RUBY_NACL_CHECK_PEPPER_TYPES
+
 AC_CACHE_CHECK(for stack end address, rb_cv_stack_end_address,
 [rb_cv_stack_end_address=no
 for addr in __libc_stack_end _SEND; do
@@ -1451,11 +1539,11 @@
 	      getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
 	      getpriority getrlimit setrlimit sysconf close getpwnam_r getgrnam_r\
 	      dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp\
-	      setsid telldir seekdir fchmod cosh sinh tanh log2 round\
+	      setsid telldir seekdir fchmod cosh sinh tanh log2 round llabs\
 	      setuid setgid daemon select_large_fdset setenv unsetenv\
               mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\
               pread sendfile shutdown sigaltstack dl_iterate_phdr\
-              dup3 pipe2 posix_memalign memalign)
+              dup3 pipe2 posix_memalign memalign ioctl)
 
 AC_CACHE_CHECK(for unsetenv returns a value, rb_cv_unsetenv_return_value,
   [AC_TRY_COMPILE([
@@ -1917,7 +2005,8 @@
 	pthread_getattr_np pthread_attr_get_np pthread_attr_getstack\
 	pthread_get_stackaddr_np pthread_get_stacksize_np \
 	thr_stksegment pthread_stackseg_np pthread_getthrds_np \
-	pthread_condattr_setclock pthread_sigmask)
+        pthread_cond_initialize pthread_condattr_setclock pthread_condattr_init \
+        pthread_sigmask)
 fi
 if test x"$ac_cv_header_ucontext_h" = xyes; then
     if test x"$rb_with_pthread" = xyes; then
@@ -2034,11 +2123,14 @@
   if test "$with_dln_a_out" = yes; then
     AC_MSG_ERROR(dln_a_out does not work with ELF)
   fi
-  AC_LIBOBJ([addr2line])
+  AC_CHECK_HEADERS([elf.h elf_abi.h])
+  if test $ac_cv_header_elf_h = yes -o $ac_cv_header_elf_abi_h = yes; then
+    AC_LIBOBJ([addr2line])
+  fi
 fi
 
 AS_CASE(["$target_os"],
-[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu], [
+[linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu | nacl], [
     if test "$rb_cv_binary_elf" = no; then
 	with_dln_a_out=yes
     else
@@ -2218,6 +2310,7 @@
 			rb_cv_dlopen=yes],
 	[os2-emx*], [	LDFLAGS="$LDFLAGS -Zomf"
 			],
+        [nacl], [ LDSHARED='$(CC) -shared' ],
 	[ 	: ${LDSHARED='$(LD)'}])
   AC_MSG_RESULT($rb_cv_dlopen)
 fi
@@ -2342,6 +2435,9 @@
   [*djgpp*], [
     setup=Setup.dj
     ],
+  [nacl], [
+    setup=Setup.nacl
+    ],
   [
     setup=Setup
     ])
@@ -2352,6 +2448,7 @@
   prefix=$ac_default_prefix
 fi
 
+BTESTRUBY='$(MINIRUBY)'
 if test x"$cross_compiling" = xyes; then
   test x"$MINIRUBY" = x && MINIRUBY="${RUBY-$BASERUBY} -I`pwd` "-r'$(arch)-fake'
   XRUBY_LIBDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["libdir"]']`
@@ -2364,6 +2461,20 @@
   RUNRUBY='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
   XRUBY='$(MINIRUBY)'
   TEST_RUNNABLE=no
+
+  if test "$host_os" = "nacl"; then 
+      if test "$build_cpu" = "$host_cpu" || test "${nacl_cv_cpu_nick}" = "x86" -a "$host_cpu" = "i686"; then
+          nacl_cv_sel_ldr='`$(MINIRUBY) $(srcdir)/nacl/nacl-config.rb sel_ldr`'
+          nacl_cv_irt_core='`$(MINIRUBY) $(srcdir)/nacl/nacl-config.rb irt_core`'
+          nacl_cv_runnable_ld='`$(MINIRUBY) $(srcdir)/nacl/nacl-config.rb runnable_ld`'
+          nacl_cv_host_lib='`$(MINIRUBY) $(srcdir)/nacl/nacl-config.rb host_lib`'
+          TEST_RUNNABLE=yes
+          BTESTRUBY="${nacl_cv_sel_ldr} -a -B ${nacl_cv_irt_core} -w 1:3 -w 2:4"
+          BTESTRUBY="$BTESTRUBY -- ${nacl_cv_runnable_ld} --library-path ${nacl_cv_host_lib}"
+          BTESTRUBY="$BTESTRUBY `pwd`/"'miniruby$(EXEEXT) -I`cd $(srcdir)/lib; pwd` -I.'
+          BTESTRUBY="$BTESTRUBY"' -I$(EXTOUT)/common 3>&1 4>&2 1>/dev/null 2>/dev/null '
+      fi
+  fi
 else
   MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib -I.'
   MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common'
@@ -2374,6 +2485,7 @@
 fi
 AC_SUBST(TEST_RUNNABLE)
 AC_SUBST(MINIRUBY)
+AC_SUBST(BTESTRUBY)
 AC_SUBST(PREP)
 AC_SUBST(RUNRUBY)
 AC_SUBST(XRUBY)
@@ -2600,6 +2712,7 @@
 SYMBOL_PREFIX="$rb_cv_symbol_prefix"
 test "x$SYMBOL_PREFIX" = xNONE && SYMBOL_PREFIX=''
 MINIDLNOBJ=dmydln.o
+
 AS_CASE(["$target_os"],
     [linux*], [
 	],
@@ -2679,7 +2792,10 @@
 	AS_CASE(["$YACC"],[*yacc*], [
 	    XCFLAGS="$XCFLAGS -DYYMAXDEPTH=300"
 	    YACC="$YACC -Nl40000 -Nm40000"
-	])])
+	])],
+    [nacl], [
+	FIRSTMAKEFILE=GNUmakefile:nacl/GNUmakefile.in
+	])
 MINIOBJS="$MINIDLNOBJ"
 
 AS_CASE(["$THREAD_MODEL"],
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35671)
+++ ChangeLog	(revision 35672)
@@ -1,6 +1,53 @@
+Thu May 17 11:33:07 2012  Yuki Yugui Sonoda  <yugui@g...>
+
+	Imports Ruby's port to NativeClient (a.k.a NaCl).
+	Patch by Google Inc. [ruby-core:45073].
+
+	* configure.in (RUBY_NACL): New M4 func to configure variables for
+	  NaCl.
+	  (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
+	  of Pepper interface types.
+	  (BTESTRUBY): New variable to specify which ruby should be run on
+	  "make btest". NaCl can run the built binary by sel_ldr, but it need
+	  rbconfig.rb. So this variable is distinguished from $MINIRUBY.
+	  
+	* thread_pthread.c: Disabled some features on NaCl.
+
+	* io.c: ditto.
+
+	* process.c: ditto.
+
+	* signal.c: ditto.
+
+	* file.c: ditto.
+
+	* missing/flock.c: ditto.
+
+	* nacl/pepper_main.c: An example implementation of Pepper application
+	  that embeds Ruby.
+
+	* nacl/example.html: An example of web page that uses the Pepper
+	  application.
+
+	* nacl/nacl-config.rb: Detects variants of NaCl SDK.
+
+	* nacl/GNUmakefile.in: Makefile template for NaCl specific build
+	  process.
+
+	* nacl/package.rb: script for packaging a NaCl-Ruby embedding
+	  application. 
+
+	* nacl/reate_nmf.rb: Wrapper script of create_nmf.py
+
+	* dln.c (dln_load): Added a hack to call on NaCl.
+
+	* util.c (ruby_getcwd): Path to the current directort is not available
+	  on NaCl.
+
 Thu May 17 10:54:58 2012  Nobuyoshi Nakada  <nobu@r...>
 
-	* ext/tk/extconf.rb: add -l options to $libs not $LDFLAGS, to be
+	* ext/tk/extconf.rb: add -l options to $libs not $LDFLAGS,
+	to be
 	  passed to EXTLIBS in exts.mk.
 
 	* enc/encinit.c.erb: use %-lines to adjust indent in the generated file.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 35671)
+++ thread_pthread.c	(revision 35672)
@@ -27,6 +27,9 @@
 #if HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
+#if defined(__native_client__) && defined(NACL_NEWLIB)
+# include "nacl/select.h"
+#endif
 
 static void native_mutex_lock(pthread_mutex_t *lock);
 static void native_mutex_unlock(pthread_mutex_t *lock);
@@ -137,9 +140,11 @@
 gvl_init(rb_vm_t *vm)
 {
     native_mutex_initialize(&vm->gvl.lock);
+#ifdef HAVE_PTHREAD_CONDATTR_INIT
     native_cond_initialize(&vm->gvl.cond, RB_CONDATTR_CLOCK_MONOTONIC);
     native_cond_initialize(&vm->gvl.switch_cond, RB_CONDATTR_CLOCK_MONOTONIC);
     native_cond_initialize(&vm->gvl.switch_wait_cond, RB_CONDATTR_CLOCK_MONOTONIC);
+#endif
     vm->gvl.acquired = 0;
     vm->gvl.waiting = 0;
     vm->gvl.need_yield = 0;
@@ -148,9 +153,11 @@
 static void
 gvl_destroy(rb_vm_t *vm)
 {
+#ifdef HAVE_PTHREAD_CONDATTR_INIT
     native_cond_destroy(&vm->gvl.switch_wait_cond);
     native_cond_destroy(&vm->gvl.switch_cond);
     native_cond_destroy(&vm->gvl.cond);
+#endif
     native_mutex_destroy(&vm->gvl.lock);
 }
 
@@ -232,6 +239,9 @@
     }
 }
 
+#ifdef HAVE_PTHREAD_CONDATTR_INIT
+int pthread_condattr_init(pthread_condattr_t *attr);
+
 static void
 native_cond_initialize(rb_thread_cond_t *cond, int flags)
 {
@@ -266,6 +276,7 @@
 	rb_bug_errno("pthread_cond_destroy", r);
     }
 }
+#endif
 
 /*
  * In OS X 10.7 (Lion), pthread_cond_signal and pthread_cond_broadcast return
@@ -439,20 +450,26 @@
 #ifdef USE_SIGNAL_THREAD_LIST
     native_mutex_initialize(&signal_thread_list_lock);
 #endif
+#ifndef __native_client__
     posix_signal(SIGVTALRM, null_func);
+#endif
 }
 
 static void
 native_thread_init(rb_thread_t *th)
 {
+#ifdef HAVE_PTHREAD_CONDATTR_INIT
     native_cond_initialize(&th->native_thread_data.sleep_cond, RB_CONDATTR_CLOCK_MONOTONIC);
+#endif
     ruby_thread_set_native(th);
 }
 
 static void
 native_thread_destroy(rb_thread_t *th)
 {
+#ifdef HAVE_PTHREAD_CONDATTR_INIT
     native_cond_destroy(&th->native_thread_data.sleep_cond);
+#endif
 }
 
 #define USE_THREAD_CACHE 0
@@ -1197,6 +1214,7 @@
 static void
 rb_thread_create_timer_thread(void)
 {
+#ifndef __native_client__
     if (!timer_thread_id) {
 	pthread_attr_t attr;
 	int err;
@@ -1256,6 +1274,7 @@
 	}
 	pthread_attr_destroy(&attr);
     }
+#endif
 }
 
 static int
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 35671)
+++ vm_core.h	(revision 35672)
@@ -92,6 +92,10 @@
 #endif
 #endif
 
+#ifdef __native_client__
+#undef OPT_DIRECT_THREADED_CODE
+#endif
+
 /* call threaded code */
 #if    OPT_CALL_THREADED_CODE
 #if    OPT_DIRECT_THREADED_CODE
Index: iseq.c
===================================================================
--- iseq.c	(revision 35671)
+++ iseq.c	(revision 35672)
@@ -1548,4 +1548,3 @@
     rb_define_singleton_method(rb_cISeq, "disasm", iseq_s_disasm, 1);
     rb_define_singleton_method(rb_cISeq, "disassemble", iseq_s_disasm, 1);
 }
-
Index: io.c
===================================================================
--- io.c	(revision 35671)
+++ io.c	(revision 35672)
@@ -28,7 +28,9 @@
 #if defined HAVE_NET_SOCKET_H
 # include <net/socket.h>
 #elif defined HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
+# ifndef __native_client__
+#  include <sys/socket.h>
+# endif
 #endif
 
 #if defined(__BOW__) || defined(__CYGWIN__) || defined(_WIN32) || defined(__EMX__) || defined(__BEOS__) || defined(__HAIKU__)
@@ -47,6 +49,9 @@
 #if defined(HAVE_SYS_IOCTL_H) && !defined(_WIN32)
 #include <sys/ioctl.h>
 #endif
+#if defined(__native_client__) && defined(NACL_NEWLIB)
+# include "nacl/ioctl.h"
+#endif
 #if defined(HAVE_FCNTL_H) || defined(_WIN32)
 #include <fcntl.h>
 #elif defined(HAVE_SYS_FCNTL_H)
@@ -161,7 +166,7 @@
 rb_maygvl_fd_fix_cloexec(int fd)
 {
   /* MinGW don't have F_GETFD and FD_CLOEXEC.  [ruby-core:40281] */
-#ifdef F_GETFD
+#if defined(F_GETFD) && !defined(__native_client__)
     int flags, flags2, ret;
     flags = fcntl(fd, F_GETFD); /* should not fail except EBADF. */
     if (flags == -1) {
@@ -187,7 +192,6 @@
     if (max_file_descriptor < fd) max_file_descriptor = fd;
 }
 
-
 int
 rb_cloexec_open(const char *pathname, int flags, mode_t mode)
 {
@@ -1502,6 +1506,7 @@
 
 static void clear_readconv(rb_io_t *fptr);
 
+#if defined(HAVE_FSYNC) || !defined(_WIN32)
 /*
  *  call-seq:
  *     ios.rewind    -> 0
@@ -1540,6 +1545,7 @@
 
     return INT2FIX(0);
 }
+#endif
 
 static int
 io_fillbuf(rb_io_t *fptr)
@@ -1629,6 +1635,7 @@
     return Qfalse;
 }
 
+#ifdef HAVE_FSYNC
 /*
  *  call-seq:
  *     ios.sync    -> true or false
@@ -1683,8 +1690,6 @@
     return sync;
 }
 
-#ifdef HAVE_FSYNC
-
 /*
  *  call-seq:
  *     ios.fsync   -> 0 or nil
@@ -1709,14 +1714,19 @@
 
     if (io_fflush(fptr) < 0)
         rb_sys_fail(0);
-#ifndef _WIN32	/* already called in io_fflush() */
+# ifndef _WIN32	/* already called in io_fflush() */
     if ((int)rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd) < 0)
 	rb_sys_fail_path(fptr->pathv);
-#endif
+# endif
     return INT2FIX(0);
 }
 #else
-#define rb_io_fsync rb_f_notimplement
+# define rb_io_fsync rb_f_notimplement
+# define rb_io_sync rb_f_notimplement
+static VALUE rb_io_set_sync(VALUE io, VALUE sync) {
+  rb_notimplement();
+  /* NEVER REACHED */ return Qundef;
+}
 #endif
 
 #ifdef HAVE_FDATASYNC
@@ -8200,10 +8210,10 @@
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
  typedef unsigned long ioctl_req_t;
- #define NUM2IOCTLREQ(num) NUM2ULONG(num)
+# define NUM2IOCTLREQ(num) NUM2ULONG(num)
 #else
  typedef int ioctl_req_t;
- #define NUM2IOCTLREQ(num) NUM2INT(num)
+# define NUM2IOCTLREQ(num) NUM2INT(num)
 #endif
 
 struct ioctl_arg {
Index: thread.c
===================================================================
--- thread.c	(revision 35671)
+++ thread.c	(revision 35672)
@@ -2420,6 +2420,11 @@
     memcpy(dst->fdset, src->fdset, size);
 }
 
+#ifdef __native_client__
+int select(int nfds, fd_set *readfds, fd_set *writefds,
+           fd_set *exceptfds, struct timeval *timeout);
+#endif
+
 int
 rb_fd_select(int n, rb_fdset_t *readfds, rb_fdset_t *writefds, rb_fdset_t *exceptfds, struct timeval *timeout)
 {
@@ -3298,7 +3303,9 @@
 	    if (err) rb_bug("%s", err);
 	}
 	native_mutex_destroy(&mutex->lock);
+#ifdef HAVE_PTHREAD_COND_INITIALIZE
 	native_cond_destroy(&mutex->cond);
+#endif
     }
     ruby_xfree(ptr);
 }
@@ -3333,7 +3340,9 @@
 
     obj = TypedData_Make_Struct(klass, rb_mutex_t, &mutex_data_type, mutex);
     native_mutex_initialize(&mutex->lock);
+#ifdef HAVE_PTHREAD_COND_INITIALIZE
     native_cond_initialize(&mutex->cond, RB_CONDATTR_CLOCK_MONOTONIC);
+#endif
     return obj;
 }
 
@@ -4781,4 +4790,3 @@
     GET_VM()->coverages = Qfalse;
     rb_remove_event_hook(update_coverage);
 }
-
Index: common.mk
===================================================================
--- common.mk	(revision 35671)
+++ common.mk	(revision 35672)
@@ -472,7 +472,7 @@
 btest: $(TEST_RUNNABLE)-btest
 no-btest: PHONY
 yes-btest: miniruby$(EXEEXT) PHONY
-	$(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(MINIRUBY)" $(OPTS)
+	$(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(BTESTRUBY)" $(OPTS)
 
 btest-ruby: $(TEST_RUNNABLE)-btest-ruby
 no-btest-ruby: PHONY
Index: dir.c
===================================================================
--- dir.c	(revision 35671)
+++ dir.c	(revision 35672)
@@ -44,6 +44,10 @@
 #  include "win32/dir.h"
 # endif
 #endif
+#if defined(__native_client__) && defined(NACL_NEWLIB)
+# include "nacl/dirent.h"
+# include "nacl/stat.h"
+#endif
 
 #include <errno.h>
 
Index: win32/Makefile.sub
===================================================================
--- win32/Makefile.sub	(revision 35671)
+++ win32/Makefile.sub	(revision 35672)
@@ -281,6 +281,7 @@
 !else
 XRUBY = $(RUNRUBY)
 !endif
+BTESTRUBY = $(MINIRUBY)
 !ifndef RUBY
 RUBY = ruby
 !endif
Index: gc.c
===================================================================
--- gc.c	(revision 35671)
+++ gc.c	(revision 35672)
@@ -33,7 +33,13 @@
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
+#if defined(__native_client__) && defined(NACL_NEWLIB)
+# include "nacl/resource.h"
+# undef HAVE_POSIX_MEMALIGN
+# undef HAVE_MEMALIGN
 
+#endif
+
 #if defined _WIN32 || defined __CYGWIN__
 #include <windows.h>
 #elif defined(HAVE_POSIX_MEMALIGN)
Index: nacl/ioctl.h
===================================================================
--- nacl/ioctl.h	(revision 0)
+++ nacl/ioctl.h	(revision 35672)
@@ -0,0 +1,7 @@
+// Copyright 2012 Google Inc. All Rights Reserved.
+// Author: yugui@g... (Yugui Sonoda)
+#ifndef RUBY_NACL_IOCTL_H
+#define RUBY_NACL_IOCTL_H
+int ioctl(int fd, int request, ...);
+struct flock{};
+#endif
Index: nacl/pepper_main.c
===================================================================
--- nacl/pepper_main.c	(revision 0)
+++ nacl/pepper_main.c	(revision 35672)
@@ -0,0 +1,924 @@
+/******************************************************************************
+ Copyright 2012 Google Inc. All Rights Reserved.
+ Author: yugui@g... (Yugui Sonoda)
+ ******************************************************************* (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]