* node.h (rb_notimplement_body_p): declared.

* vm_method.c (Init_eval_method): suppress a warning.

* io.c (rb_io_fsync): use rb_f_notimplement if not implemented.
  (rb_io_close_on_exec_p): ditto.
  (rb_io_set_close_on_exec): ditto.
  (rb_io_fcntl): ditto.
  (rb_f_syscall): ditto.

* dir.c (dir_tell): ditto.
  (dir_seek): ditto.
  (dir_s_chroot): ditto.

* process.c (proc_getpgrp): ditto.
  (proc_setpgrp): ditto.
  (proc_getpgid): ditto.
  (proc_setpgid): ditto.
  (proc_setsid): ditto.
  (proc_getpriority): ditto.
  (proc_setpriority): ditto.
  (proc_getrlimit): ditto.
  (proc_setrlimit): ditto.
  (p_sys_setuid): ditto.
  (p_sys_setruid): ditto.
  (p_sys_seteuid): ditto.
  (p_sys_setreuid): ditto.
  (p_sys_setresuid): ditto.
  (p_sys_setgid): ditto.
  (p_sys_setrgid): ditto.
  (p_sys_setegid): ditto.
  (p_sys_setregid): ditto.
  (p_sys_setreuid): ditto.
  (p_sys_setresgid): ditto.
  (p_sys_issetugid): ditto.
  (proc_getgroups): ditto.
  (proc_setgroups): ditto.
  (proc_initgroups): ditto.
  (proc_daemon): ditto.
  (rb_proc_times): ditto.

* file.c (rb_file_s_lchown): ditto.
  (rb_file_s_link): ditto.
  (rb_file_s_symlink): ditto.
  (rb_file_s_readlink): ditto.
  (rb_file_s_truncate): ditto.
  (rb_file_truncate): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-04-16 16:58:06 +00:00
parent 50cea7a5c9
commit 8e8ae2a9c5
8 changed files with 214 additions and 178 deletions

View file

@ -1,3 +1,53 @@
Fri Apr 17 01:51:17 2009 Tanaka Akira <akr@fsij.org>
* node.h (rb_notimplement_body_p): declared.
* vm_method.c (Init_eval_method): suppress a warning.
* io.c (rb_io_fsync): use rb_f_notimplement if not implemented.
(rb_io_close_on_exec_p): ditto.
(rb_io_set_close_on_exec): ditto.
(rb_io_fcntl): ditto.
(rb_f_syscall): ditto.
* dir.c (dir_tell): ditto.
(dir_seek): ditto.
(dir_s_chroot): ditto.
* process.c (proc_getpgrp): ditto.
(proc_setpgrp): ditto.
(proc_getpgid): ditto.
(proc_setpgid): ditto.
(proc_setsid): ditto.
(proc_getpriority): ditto.
(proc_setpriority): ditto.
(proc_getrlimit): ditto.
(proc_setrlimit): ditto.
(p_sys_setuid): ditto.
(p_sys_setruid): ditto.
(p_sys_seteuid): ditto.
(p_sys_setreuid): ditto.
(p_sys_setresuid): ditto.
(p_sys_setgid): ditto.
(p_sys_setrgid): ditto.
(p_sys_setegid): ditto.
(p_sys_setregid): ditto.
(p_sys_setreuid): ditto.
(p_sys_setresgid): ditto.
(p_sys_issetugid): ditto.
(proc_getgroups): ditto.
(proc_setgroups): ditto.
(proc_initgroups): ditto.
(proc_daemon): ditto.
(rb_proc_times): ditto.
* file.c (rb_file_s_lchown): ditto.
(rb_file_s_link): ditto.
(rb_file_s_symlink): ditto.
(rb_file_s_readlink): ditto.
(rb_file_s_truncate): ditto.
(rb_file_truncate): ditto.
Fri Apr 17 00:53:47 2009 Yusuke Endoh <mame@tsg.ne.jp> Fri Apr 17 00:53:47 2009 Yusuke Endoh <mame@tsg.ne.jp>
* lib/cgi/core.rb (read_multipart): When path is not defined, * lib/cgi/core.rb (read_multipart): When path is not defined,

2
NEWS
View file

@ -50,7 +50,7 @@ with all sufficient information, see the ChangeLog file.
* Kernel * Kernel
* extended methods: * extended methods:
* respond_to? returns false for not-implemented methods * respond_to? returns false for not-implemented methods
such as fork on Windows. such as Process.fork on Windows.
* rss * rss

25
dir.c
View file

@ -550,6 +550,7 @@ dir_each(VALUE dir)
return dir; return dir;
} }
#ifdef HAVE_TELLDIR
/* /*
* call-seq: * call-seq:
* dir.pos => integer * dir.pos => integer
@ -566,18 +567,18 @@ dir_each(VALUE dir)
static VALUE static VALUE
dir_tell(VALUE dir) dir_tell(VALUE dir)
{ {
#ifdef HAVE_TELLDIR
struct dir_data *dirp; struct dir_data *dirp;
long pos; long pos;
GetDIR(dir, dirp); GetDIR(dir, dirp);
pos = telldir(dirp->dir); pos = telldir(dirp->dir);
return rb_int2inum(pos); return rb_int2inum(pos);
#else
rb_notimplement();
#endif
} }
#else
#define dir_tell rb_f_notimplement
#endif
#ifdef HAVE_SEEKDIR
/* /*
* call-seq: * call-seq:
* dir.seek( integer ) => dir * dir.seek( integer ) => dir
@ -599,13 +600,12 @@ dir_seek(VALUE dir, VALUE pos)
long p = NUM2LONG(pos); long p = NUM2LONG(pos);
GetDIR(dir, dirp); GetDIR(dir, dirp);
#ifdef HAVE_SEEKDIR
seekdir(dirp->dir, p); seekdir(dirp->dir, p);
return dir; return dir;
#else
rb_notimplement();
#endif
} }
#else
#define dir_seek rb_f_notimplement
#endif
/* /*
* call-seq: * call-seq:
@ -826,6 +826,7 @@ check_dirname(volatile VALUE *dir)
} }
} }
#if defined(HAVE_CHROOT) && !defined(__CHECKER__)
/* /*
* call-seq: * call-seq:
* Dir.chroot( string ) => 0 * Dir.chroot( string ) => 0
@ -838,18 +839,16 @@ check_dirname(volatile VALUE *dir)
static VALUE static VALUE
dir_s_chroot(VALUE dir, VALUE path) dir_s_chroot(VALUE dir, VALUE path)
{ {
#if defined(HAVE_CHROOT) && !defined(__CHECKER__)
check_dirname(&path); check_dirname(&path);
if (chroot(RSTRING_PTR(path)) == -1) if (chroot(RSTRING_PTR(path)) == -1)
rb_sys_fail(RSTRING_PTR(path)); rb_sys_fail(RSTRING_PTR(path));
return INT2FIX(0); return INT2FIX(0);
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define dir_s_chroot rb_f_notimplement
#endif
/* /*
* call-seq: * call-seq:

53
file.c
View file

@ -2066,11 +2066,7 @@ rb_file_s_lchown(int argc, VALUE *argv)
return LONG2FIX(n); return LONG2FIX(n);
} }
#else #else
static VALUE #define rb_file_s_lchown rb_f_notimplement
rb_file_s_lchown(int argc, VALUE *argv)
{
rb_notimplement();
}
#endif #endif
struct timespec rb_time_timespec(VALUE time); struct timespec rb_time_timespec(VALUE time);
@ -2244,6 +2240,7 @@ sys_fail2(VALUE s1, VALUE s2)
rb_sys_fail(buf); rb_sys_fail(buf);
} }
#ifdef HAVE_LINK
/* /*
* call-seq: * call-seq:
* File.link(old_name, new_name) => 0 * File.link(old_name, new_name) => 0
@ -2259,7 +2256,6 @@ sys_fail2(VALUE s1, VALUE s2)
static VALUE static VALUE
rb_file_s_link(VALUE klass, VALUE from, VALUE to) rb_file_s_link(VALUE klass, VALUE from, VALUE to)
{ {
#ifdef HAVE_LINK
rb_secure(2); rb_secure(2);
FilePathValue(from); FilePathValue(from);
FilePathValue(to); FilePathValue(to);
@ -2268,12 +2264,12 @@ rb_file_s_link(VALUE klass, VALUE from, VALUE to)
sys_fail2(from, to); sys_fail2(from, to);
} }
return INT2FIX(0); return INT2FIX(0);
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define rb_file_s_link rb_f_notimplement
#endif
#ifdef HAVE_SYMLINK
/* /*
* call-seq: * call-seq:
* File.symlink(old_name, new_name) => 0 * File.symlink(old_name, new_name) => 0
@ -2289,7 +2285,6 @@ rb_file_s_link(VALUE klass, VALUE from, VALUE to)
static VALUE static VALUE
rb_file_s_symlink(VALUE klass, VALUE from, VALUE to) rb_file_s_symlink(VALUE klass, VALUE from, VALUE to)
{ {
#ifdef HAVE_SYMLINK
rb_secure(2); rb_secure(2);
FilePathValue(from); FilePathValue(from);
FilePathValue(to); FilePathValue(to);
@ -2298,12 +2293,12 @@ rb_file_s_symlink(VALUE klass, VALUE from, VALUE to)
sys_fail2(from, to); sys_fail2(from, to);
} }
return INT2FIX(0); return INT2FIX(0);
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define rb_file_s_symlink rb_f_notimplement
#endif
#ifdef HAVE_READLINK
/* /*
* call-seq: * call-seq:
* File.readlink(link_name) -> file_name * File.readlink(link_name) -> file_name
@ -2318,7 +2313,6 @@ rb_file_s_symlink(VALUE klass, VALUE from, VALUE to)
static VALUE static VALUE
rb_file_s_readlink(VALUE klass, VALUE path) rb_file_s_readlink(VALUE klass, VALUE path)
{ {
#ifdef HAVE_READLINK
char *buf; char *buf;
int size = 100; int size = 100;
ssize_t rv; ssize_t rv;
@ -2343,11 +2337,10 @@ rb_file_s_readlink(VALUE klass, VALUE path)
xfree(buf); xfree(buf);
return v; return v;
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define rb_file_s_readlink rb_f_notimplement
#endif
static void static void
unlink_internal(const char *path, void *arg) unlink_internal(const char *path, void *arg)
@ -3383,6 +3376,7 @@ rb_file_s_join(VALUE klass, VALUE args)
return rb_file_join(args, separator); return rb_file_join(args, separator);
} }
#if defined(HAVE_TRUNCATE) || defined(HAVE_CHSIZE)
/* /*
* call-seq: * call-seq:
* File.truncate(file_name, integer) => 0 * File.truncate(file_name, integer) => 0
@ -3409,8 +3403,7 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
#ifdef HAVE_TRUNCATE #ifdef HAVE_TRUNCATE
if (truncate(StringValueCStr(path), pos) < 0) if (truncate(StringValueCStr(path), pos) < 0)
rb_sys_fail(RSTRING_PTR(path)); rb_sys_fail(RSTRING_PTR(path));
#else #else /* defined(HAVE_CHSIZE) */
# ifdef HAVE_CHSIZE
{ {
int tmpfd; int tmpfd;
@ -3429,13 +3422,14 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
} }
close(tmpfd); close(tmpfd);
} }
# else
rb_notimplement();
# endif
#endif #endif
return INT2FIX(0); return INT2FIX(0);
} }
#else
#define rb_file_s_truncate rb_f_notimplement
#endif
#if defined(HAVE_FTRUNCATE) || defined(HAVE_CHSIZE)
/* /*
* call-seq: * call-seq:
* file.truncate(integer) => 0 * file.truncate(integer) => 0
@ -3466,16 +3460,15 @@ rb_file_truncate(VALUE obj, VALUE len)
#ifdef HAVE_FTRUNCATE #ifdef HAVE_FTRUNCATE
if (ftruncate(fptr->fd, pos) < 0) if (ftruncate(fptr->fd, pos) < 0)
rb_sys_fail_path(fptr->pathv); rb_sys_fail_path(fptr->pathv);
#else #else /* defined(HAVE_CHSIZE) */
# ifdef HAVE_CHSIZE
if (chsize(fptr->fd, pos) < 0) if (chsize(fptr->fd, pos) < 0)
rb_sys_fail(fptr->pathv); rb_sys_fail(fptr->pathv);
# else
rb_notimplement();
# endif
#endif #endif
return INT2FIX(0); return INT2FIX(0);
} }
#else
#define rb_file_truncate rb_f_notimplement
#endif
# ifndef LOCK_SH # ifndef LOCK_SH
# define LOCK_SH 1 # define LOCK_SH 1

44
io.c
View file

@ -1282,6 +1282,7 @@ rb_io_set_sync(VALUE io, VALUE sync)
return sync; return sync;
} }
#ifdef HAVE_FSYNC
/* /*
* call-seq: * call-seq:
* ios.fsync => 0 or nil * ios.fsync => 0 or nil
@ -1297,7 +1298,6 @@ rb_io_set_sync(VALUE io, VALUE sync)
static VALUE static VALUE
rb_io_fsync(VALUE io) rb_io_fsync(VALUE io)
{ {
#ifdef HAVE_FSYNC
rb_io_t *fptr; rb_io_t *fptr;
io = GetWriteIO(io); io = GetWriteIO(io);
@ -1308,11 +1308,10 @@ rb_io_fsync(VALUE io)
if (fsync(fptr->fd) < 0) if (fsync(fptr->fd) < 0)
rb_sys_fail_path(fptr->pathv); rb_sys_fail_path(fptr->pathv);
return INT2FIX(0); return INT2FIX(0);
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define rb_io_fsync rb_f_notimplement
#endif
/* /*
* call-seq: * call-seq:
@ -3024,6 +3023,7 @@ rb_io_isatty(VALUE io)
return Qtrue; return Qtrue;
} }
#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
/* /*
* call-seq: * call-seq:
* ios.close_on_exec? => true or false * ios.close_on_exec? => true or false
@ -3041,7 +3041,6 @@ rb_io_isatty(VALUE io)
static VALUE static VALUE
rb_io_close_on_exec_p(VALUE io) rb_io_close_on_exec_p(VALUE io)
{ {
#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
rb_io_t *fptr; rb_io_t *fptr;
VALUE write_io; VALUE write_io;
int fd, ret; int fd, ret;
@ -3061,12 +3060,12 @@ rb_io_close_on_exec_p(VALUE io)
if (!(ret & FD_CLOEXEC)) return Qfalse; if (!(ret & FD_CLOEXEC)) return Qfalse;
} }
return Qtrue; return Qtrue;
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define rb_io_close_on_exec_p rb_f_notimplement
#endif
#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
/* /*
* call-seq: * call-seq:
* ios.close_on_exec = bool => true or false * ios.close_on_exec = bool => true or false
@ -3082,7 +3081,6 @@ rb_io_close_on_exec_p(VALUE io)
static VALUE static VALUE
rb_io_set_close_on_exec(VALUE io, VALUE arg) rb_io_set_close_on_exec(VALUE io, VALUE arg)
{ {
#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
int flag = RTEST(arg) ? FD_CLOEXEC : 0; int flag = RTEST(arg) ? FD_CLOEXEC : 0;
rb_io_t *fptr; rb_io_t *fptr;
VALUE write_io; VALUE write_io;
@ -3111,11 +3109,11 @@ rb_io_set_close_on_exec(VALUE io, VALUE arg)
if (ret == -1) rb_sys_fail_path(fptr->pathv); if (ret == -1) rb_sys_fail_path(fptr->pathv);
} }
} }
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define rb_io_set_close_on_exec rb_f_notimplement
#endif
#define FMODE_PREP (1<<16) #define FMODE_PREP (1<<16)
#define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP) #define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
@ -6937,6 +6935,7 @@ rb_io_ioctl(int argc, VALUE *argv, VALUE io)
return rb_io_ctl(io, req, arg, 1); return rb_io_ctl(io, req, arg, 1);
} }
#ifdef HAVE_FCNTL
/* /*
* call-seq: * call-seq:
* ios.fcntl(integer_cmd, arg) => integer * ios.fcntl(integer_cmd, arg) => integer
@ -6953,17 +6952,16 @@ rb_io_ioctl(int argc, VALUE *argv, VALUE io)
static VALUE static VALUE
rb_io_fcntl(int argc, VALUE *argv, VALUE io) rb_io_fcntl(int argc, VALUE *argv, VALUE io)
{ {
#ifdef HAVE_FCNTL
VALUE req, arg; VALUE req, arg;
rb_scan_args(argc, argv, "11", &req, &arg); rb_scan_args(argc, argv, "11", &req, &arg);
return rb_io_ctl(io, req, arg, 0); return rb_io_ctl(io, req, arg, 0);
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define rb_io_fcntl rb_f_notimplement
#endif
#if defined(HAVE_SYSCALL) && !defined(__CHECKER__)
/* /*
* call-seq: * call-seq:
* syscall(fixnum [, args...]) => integer * syscall(fixnum [, args...]) => integer
@ -6986,7 +6984,6 @@ rb_io_fcntl(int argc, VALUE *argv, VALUE io)
static VALUE static VALUE
rb_f_syscall(int argc, VALUE *argv) rb_f_syscall(int argc, VALUE *argv)
{ {
#if defined(HAVE_SYSCALL) && !defined(__CHECKER__)
#ifdef atarist #ifdef atarist
unsigned long arg[14]; /* yes, we really need that many ! */ unsigned long arg[14]; /* yes, we really need that many ! */
#else #else
@ -7078,11 +7075,10 @@ rb_f_syscall(int argc, VALUE *argv)
if (retval < 0) rb_sys_fail(0); if (retval < 0) rb_sys_fail(0);
return INT2NUM(retval); return INT2NUM(retval);
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define rb_f_syscall rb_f_notimplement
#endif
static VALUE static VALUE
io_new_instance(VALUE args) io_new_instance(VALUE args)

2
node.h
View file

@ -501,6 +501,8 @@ NODE *rb_node_newnode(enum node_type,VALUE,VALUE,VALUE);
NODE* rb_method_node(VALUE klass, ID id); NODE* rb_method_node(VALUE klass, ID id);
int rb_node_arity(NODE* node); int rb_node_arity(NODE* node);
int rb_notimplement_body_p(NODE*);
struct global_entry *rb_global_entry(ID); struct global_entry *rb_global_entry(ID);
VALUE rb_gvar_get(struct global_entry *); VALUE rb_gvar_get(struct global_entry *);
VALUE rb_gvar_set(struct global_entry *, VALUE); VALUE rb_gvar_set(struct global_entry *, VALUE);

214
process.c
View file

@ -2580,6 +2580,7 @@ rb_fork(int *status, int (*chfunc)(void*), void *charg, VALUE fds)
#endif #endif
#if defined(HAVE_FORK) && !defined(CANNOT_FORK_WITH_PTHREAD)
/* /*
* call-seq: * call-seq:
* Kernel.fork [{ block }] => fixnum or nil * Kernel.fork [{ block }] => fixnum or nil
@ -2601,7 +2602,6 @@ rb_fork(int *status, int (*chfunc)(void*), void *charg, VALUE fds)
* fork doesn't copy other threads. * fork doesn't copy other threads.
*/ */
#if defined(HAVE_FORK) && !defined(CANNOT_FORK_WITH_PTHREAD)
static VALUE static VALUE
rb_f_fork(VALUE obj) rb_f_fork(VALUE obj)
{ {
@ -3251,6 +3251,7 @@ rb_f_sleep(int argc, VALUE *argv)
} }
#if (defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)) || defined(HAVE_GETPGID)
/* /*
* call-seq: * call-seq:
* Process.getpgrp => integer * Process.getpgrp => integer
@ -3265,27 +3266,25 @@ rb_f_sleep(int argc, VALUE *argv)
static VALUE static VALUE
proc_getpgrp(void) proc_getpgrp(void)
{ {
#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID) || defined(HAVE_GETPGID)
rb_pid_t pgrp; rb_pid_t pgrp;
#endif
rb_secure(2); rb_secure(2);
#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID) #if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
pgrp = getpgrp(); pgrp = getpgrp();
if (pgrp < 0) rb_sys_fail(0); if (pgrp < 0) rb_sys_fail(0);
return PIDT2NUM(pgrp); return PIDT2NUM(pgrp);
#else #else /* defined(HAVE_GETPGID) */
# ifdef HAVE_GETPGID
pgrp = getpgid(0); pgrp = getpgid(0);
if (pgrp < 0) rb_sys_fail(0); if (pgrp < 0) rb_sys_fail(0);
return PIDT2NUM(pgrp); return PIDT2NUM(pgrp);
# else
rb_notimplement();
# endif
#endif #endif
} }
#else
#define proc_getpgrp rb_f_notimplement
#endif
#if defined(HAVE_SETPGID) || (defined(HAVE_SETPGRP) && defined(SETPGRP_VOID))
/* /*
* call-seq: * call-seq:
* Process.setpgrp => 0 * Process.setpgrp => 0
@ -3304,15 +3303,17 @@ proc_setpgrp(void)
/* this confusion. */ /* this confusion. */
#ifdef HAVE_SETPGID #ifdef HAVE_SETPGID
if (setpgid(0,0) < 0) rb_sys_fail(0); if (setpgid(0,0) < 0) rb_sys_fail(0);
#elif defined(HAVE_SETPGRP) && defined(SETPGRP_VOID) #else /* defined(HAVE_SETPGRP) && defined(SETPGRP_VOID) */
if (setpgrp() < 0) rb_sys_fail(0); if (setpgrp() < 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif #endif
return INT2FIX(0); return INT2FIX(0);
} }
#else
#define proc_setpgrp rb_f_notimplement
#endif
#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
/* /*
* call-seq: * call-seq:
* Process.getpgid(pid) => integer * Process.getpgid(pid) => integer
@ -3326,19 +3327,19 @@ proc_setpgrp(void)
static VALUE static VALUE
proc_getpgid(VALUE obj, VALUE pid) proc_getpgid(VALUE obj, VALUE pid)
{ {
#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
rb_pid_t i; rb_pid_t i;
rb_secure(2); rb_secure(2);
i = getpgid(NUM2PIDT(pid)); i = getpgid(NUM2PIDT(pid));
if (i < 0) rb_sys_fail(0); if (i < 0) rb_sys_fail(0);
return PIDT2NUM(i); return PIDT2NUM(i);
#else
rb_notimplement();
#endif
} }
#else
#define proc_getpgid rb_f_notimplement
#endif
#ifdef HAVE_SETPGID
/* /*
* call-seq: * call-seq:
* Process.setpgid(pid, integer) => 0 * Process.setpgid(pid, integer) => 0
@ -3350,7 +3351,6 @@ proc_getpgid(VALUE obj, VALUE pid)
static VALUE static VALUE
proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp) proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
{ {
#ifdef HAVE_SETPGID
rb_pid_t ipid, ipgrp; rb_pid_t ipid, ipgrp;
rb_secure(2); rb_secure(2);
@ -3359,12 +3359,13 @@ proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
if (setpgid(ipid, ipgrp) < 0) rb_sys_fail(0); if (setpgid(ipid, ipgrp) < 0) rb_sys_fail(0);
return INT2FIX(0); return INT2FIX(0);
#else
rb_notimplement();
#endif
} }
#else
#define proc_setpgid rb_f_notimplement
#endif
#if defined(HAVE_SETSID) || (defined(HAVE_SETPGRP) && defined(TIOCNOTTY))
/* /*
* call-seq: * call-seq:
* Process.setsid => fixnum * Process.setsid => fixnum
@ -3386,7 +3387,7 @@ proc_setsid(void)
pid = setsid(); pid = setsid();
if (pid < 0) rb_sys_fail(0); if (pid < 0) rb_sys_fail(0);
return PIDT2NUM(pid); return PIDT2NUM(pid);
#elif defined(HAVE_SETPGRP) && defined(TIOCNOTTY) #else /* defined(HAVE_SETPGRP) && defined(TIOCNOTTY) */
rb_pid_t pid; rb_pid_t pid;
int ret; int ret;
@ -3407,12 +3408,14 @@ proc_setsid(void)
close(fd); close(fd);
} }
return PIDT2NUM(pid); return PIDT2NUM(pid);
#else
rb_notimplement();
#endif #endif
} }
#else
#define proc_setsid rb_f_notimplement
#endif
#ifdef HAVE_GETPRIORITY
/* /*
* call-seq: * call-seq:
* Process.getpriority(kind, integer) => fixnum * Process.getpriority(kind, integer) => fixnum
@ -3433,7 +3436,6 @@ proc_setsid(void)
static VALUE static VALUE
proc_getpriority(VALUE obj, VALUE which, VALUE who) proc_getpriority(VALUE obj, VALUE which, VALUE who)
{ {
#ifdef HAVE_GETPRIORITY
int prio, iwhich, iwho; int prio, iwhich, iwho;
rb_secure(2); rb_secure(2);
@ -3444,12 +3446,13 @@ proc_getpriority(VALUE obj, VALUE which, VALUE who)
prio = getpriority(iwhich, iwho); prio = getpriority(iwhich, iwho);
if (errno) rb_sys_fail(0); if (errno) rb_sys_fail(0);
return INT2FIX(prio); return INT2FIX(prio);
#else
rb_notimplement();
#endif
} }
#else
#define proc_getpriority rb_f_notimplement
#endif
#ifdef HAVE_GETPRIORITY
/* /*
* call-seq: * call-seq:
* Process.setpriority(kind, integer, priority) => 0 * Process.setpriority(kind, integer, priority) => 0
@ -3465,7 +3468,6 @@ proc_getpriority(VALUE obj, VALUE which, VALUE who)
static VALUE static VALUE
proc_setpriority(VALUE obj, VALUE which, VALUE who, VALUE prio) proc_setpriority(VALUE obj, VALUE which, VALUE who, VALUE prio)
{ {
#ifdef HAVE_GETPRIORITY
int iwhich, iwho, iprio; int iwhich, iwho, iprio;
rb_secure(2); rb_secure(2);
@ -3476,10 +3478,10 @@ proc_setpriority(VALUE obj, VALUE which, VALUE who, VALUE prio)
if (setpriority(iwhich, iwho, iprio) < 0) if (setpriority(iwhich, iwho, iprio) < 0)
rb_sys_fail(0); rb_sys_fail(0);
return INT2FIX(0); return INT2FIX(0);
#else
rb_notimplement();
#endif
} }
#else
#define proc_setpriority rb_f_notimplement
#endif
#if defined(RLIM2NUM) #if defined(RLIM2NUM)
static int static int
@ -3645,6 +3647,7 @@ rlimit_resource_value(VALUE rval)
} }
#endif #endif
#if defined(HAVE_GETRLIMIT) && defined(RLIM2NUM)
/* /*
* call-seq: * call-seq:
* Process.getrlimit(resource) => [cur_limit, max_limit] * Process.getrlimit(resource) => [cur_limit, max_limit]
@ -3668,7 +3671,6 @@ rlimit_resource_value(VALUE rval)
static VALUE static VALUE
proc_getrlimit(VALUE obj, VALUE resource) proc_getrlimit(VALUE obj, VALUE resource)
{ {
#if defined(HAVE_GETRLIMIT) && defined(RLIM2NUM)
struct rlimit rlim; struct rlimit rlim;
rb_secure(2); rb_secure(2);
@ -3677,11 +3679,12 @@ proc_getrlimit(VALUE obj, VALUE resource)
rb_sys_fail("getrlimit"); rb_sys_fail("getrlimit");
} }
return rb_assoc_new(RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max)); return rb_assoc_new(RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max));
#else
rb_notimplement();
#endif
} }
#else
#define proc_getrlimit rb_f_notimplement
#endif
#if defined(HAVE_SETRLIMIT) && defined(NUM2RLIM)
/* /*
* call-seq: * call-seq:
* Process.setrlimit(resource, cur_limit, max_limit) => nil * Process.setrlimit(resource, cur_limit, max_limit) => nil
@ -3731,7 +3734,6 @@ proc_getrlimit(VALUE obj, VALUE resource)
static VALUE static VALUE
proc_setrlimit(int argc, VALUE *argv, VALUE obj) proc_setrlimit(int argc, VALUE *argv, VALUE obj)
{ {
#if defined(HAVE_SETRLIMIT) && defined(NUM2RLIM)
VALUE resource, rlim_cur, rlim_max; VALUE resource, rlim_cur, rlim_max;
struct rlimit rlim; struct rlimit rlim;
@ -3748,10 +3750,10 @@ proc_setrlimit(int argc, VALUE *argv, VALUE obj)
rb_sys_fail("setrlimit"); rb_sys_fail("setrlimit");
} }
return Qnil; return Qnil;
#else
rb_notimplement();
#endif
} }
#else
#define proc_setrlimit rb_f_notimplement
#endif
static int under_uid_switch = 0; static int under_uid_switch = 0;
static void static void
@ -3785,6 +3787,7 @@ check_gid_switch(void)
*/ */
#if defined HAVE_SETUID
/* /*
* call-seq: * call-seq:
* Process::Sys.setuid(integer) => nil * Process::Sys.setuid(integer) => nil
@ -3797,17 +3800,16 @@ check_gid_switch(void)
static VALUE static VALUE
p_sys_setuid(VALUE obj, VALUE id) p_sys_setuid(VALUE obj, VALUE id)
{ {
#if defined HAVE_SETUID
check_uid_switch(); check_uid_switch();
if (setuid(NUM2UIDT(id)) != 0) rb_sys_fail(0); if (setuid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setuid rb_f_notimplement
#endif
#if defined HAVE_SETRUID
/* /*
* call-seq: * call-seq:
* Process::Sys.setruid(integer) => nil * Process::Sys.setruid(integer) => nil
@ -3820,16 +3822,16 @@ p_sys_setuid(VALUE obj, VALUE id)
static VALUE static VALUE
p_sys_setruid(VALUE obj, VALUE id) p_sys_setruid(VALUE obj, VALUE id)
{ {
#if defined HAVE_SETRUID
check_uid_switch(); check_uid_switch();
if (setruid(NUM2UIDT(id)) != 0) rb_sys_fail(0); if (setruid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setruid rb_f_notimplement
#endif
#if defined HAVE_SETEUID
/* /*
* call-seq: * call-seq:
* Process::Sys.seteuid(integer) => nil * Process::Sys.seteuid(integer) => nil
@ -3842,16 +3844,16 @@ p_sys_setruid(VALUE obj, VALUE id)
static VALUE static VALUE
p_sys_seteuid(VALUE obj, VALUE id) p_sys_seteuid(VALUE obj, VALUE id)
{ {
#if defined HAVE_SETEUID
check_uid_switch(); check_uid_switch();
if (seteuid(NUM2UIDT(id)) != 0) rb_sys_fail(0); if (seteuid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_seteuid rb_f_notimplement
#endif
#if defined HAVE_SETREUID
/* /*
* call-seq: * call-seq:
* Process::Sys.setreuid(rid, eid) => nil * Process::Sys.setreuid(rid, eid) => nil
@ -3866,16 +3868,16 @@ p_sys_seteuid(VALUE obj, VALUE id)
static VALUE static VALUE
p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid) p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid)
{ {
#if defined HAVE_SETREUID
check_uid_switch(); check_uid_switch();
if (setreuid(NUM2UIDT(rid),NUM2UIDT(eid)) != 0) rb_sys_fail(0); if (setreuid(NUM2UIDT(rid),NUM2UIDT(eid)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setreuid rb_f_notimplement
#endif
#if defined HAVE_SETRESUID
/* /*
* call-seq: * call-seq:
* Process::Sys.setresuid(rid, eid, sid) => nil * Process::Sys.setresuid(rid, eid, sid) => nil
@ -3890,14 +3892,13 @@ p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid)
static VALUE static VALUE
p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid) p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
{ {
#if defined HAVE_SETRESUID
check_uid_switch(); check_uid_switch();
if (setresuid(NUM2UIDT(rid),NUM2UIDT(eid),NUM2UIDT(sid)) != 0) rb_sys_fail(0); if (setresuid(NUM2UIDT(rid),NUM2UIDT(eid),NUM2UIDT(sid)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setresuid rb_f_notimplement
#endif
/* /*
@ -4137,6 +4138,7 @@ p_uid_change_privilege(VALUE obj, VALUE id)
#if defined HAVE_SETGID
/* /*
* call-seq: * call-seq:
* Process::Sys.setgid(integer) => nil * Process::Sys.setgid(integer) => nil
@ -4149,16 +4151,16 @@ p_uid_change_privilege(VALUE obj, VALUE id)
static VALUE static VALUE
p_sys_setgid(VALUE obj, VALUE id) p_sys_setgid(VALUE obj, VALUE id)
{ {
#if defined HAVE_SETGID
check_gid_switch(); check_gid_switch();
if (setgid(NUM2GIDT(id)) != 0) rb_sys_fail(0); if (setgid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setgid rb_f_notimplement
#endif
#if defined HAVE_SETRGID
/* /*
* call-seq: * call-seq:
* Process::Sys.setrgid(integer) => nil * Process::Sys.setrgid(integer) => nil
@ -4171,17 +4173,16 @@ p_sys_setgid(VALUE obj, VALUE id)
static VALUE static VALUE
p_sys_setrgid(VALUE obj, VALUE id) p_sys_setrgid(VALUE obj, VALUE id)
{ {
#if defined HAVE_SETRGID
check_gid_switch(); check_gid_switch();
if (setrgid(NUM2GIDT(id)) != 0) rb_sys_fail(0); if (setrgid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setrgid rb_f_notimplement
#endif
#if defined HAVE_SETEGID
/* /*
* call-seq: * call-seq:
* Process::Sys.setegid(integer) => nil * Process::Sys.setegid(integer) => nil
@ -4194,16 +4195,16 @@ p_sys_setrgid(VALUE obj, VALUE id)
static VALUE static VALUE
p_sys_setegid(VALUE obj, VALUE id) p_sys_setegid(VALUE obj, VALUE id)
{ {
#if defined HAVE_SETEGID
check_gid_switch(); check_gid_switch();
if (setegid(NUM2GIDT(id)) != 0) rb_sys_fail(0); if (setegid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setegid rb_f_notimplement
#endif
#if defined HAVE_SETREGID
/* /*
* call-seq: * call-seq:
* Process::Sys.setregid(rid, eid) => nil * Process::Sys.setregid(rid, eid) => nil
@ -4218,15 +4219,15 @@ p_sys_setegid(VALUE obj, VALUE id)
static VALUE static VALUE
p_sys_setregid(VALUE obj, VALUE rid, VALUE eid) p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
{ {
#if defined HAVE_SETREGID
check_gid_switch(); check_gid_switch();
if (setregid(NUM2GIDT(rid),NUM2GIDT(eid)) != 0) rb_sys_fail(0); if (setregid(NUM2GIDT(rid),NUM2GIDT(eid)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setregid rb_f_notimplement
#endif
#if defined HAVE_SETRESGID
/* /*
* call-seq: * call-seq:
* Process::Sys.setresgid(rid, eid, sid) => nil * Process::Sys.setresgid(rid, eid, sid) => nil
@ -4241,16 +4242,16 @@ p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
static VALUE static VALUE
p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid) p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
{ {
#if defined HAVE_SETRESGID
check_gid_switch(); check_gid_switch();
if (setresgid(NUM2GIDT(rid),NUM2GIDT(eid),NUM2GIDT(sid)) != 0) rb_sys_fail(0); if (setresgid(NUM2GIDT(rid),NUM2GIDT(eid),NUM2GIDT(sid)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
return Qnil; return Qnil;
} }
#else
#define p_sys_setresgid rb_f_notimplement
#endif
#if defined HAVE_ISSETUGID
/* /*
* call-seq: * call-seq:
* Process::Sys.issetugid => true or false * Process::Sys.issetugid => true or false
@ -4266,18 +4267,16 @@ p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
static VALUE static VALUE
p_sys_issetugid(VALUE obj) p_sys_issetugid(VALUE obj)
{ {
#if defined HAVE_ISSETUGID
rb_secure(2); rb_secure(2);
if (issetugid()) { if (issetugid()) {
return Qtrue; return Qtrue;
} else { } else {
return Qfalse; return Qfalse;
} }
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
} }
#else
#define p_sys_issetugid rb_f_notimplement
#endif
/* /*
@ -4339,6 +4338,7 @@ proc_setgid(VALUE obj, VALUE id)
static size_t maxgroups = 32; static size_t maxgroups = 32;
#ifdef HAVE_GETGROUPS
/* /*
* call-seq: * call-seq:
* Process.groups => array * Process.groups => array
@ -4353,7 +4353,6 @@ static size_t maxgroups = 32;
static VALUE static VALUE
proc_getgroups(VALUE obj) proc_getgroups(VALUE obj)
{ {
#ifdef HAVE_GETGROUPS
VALUE ary; VALUE ary;
size_t ngroups; size_t ngroups;
rb_gid_t *groups; rb_gid_t *groups;
@ -4370,13 +4369,13 @@ proc_getgroups(VALUE obj)
rb_ary_push(ary, GIDT2NUM(groups[i])); rb_ary_push(ary, GIDT2NUM(groups[i]));
return ary; return ary;
#else
rb_notimplement();
return Qnil;
#endif
} }
#else
#define proc_getgroups rb_f_notimplement
#endif
#ifdef HAVE_SETGROUPS
/* /*
* call-seq: * call-seq:
* Process.groups= array => array * Process.groups= array => array
@ -4393,7 +4392,6 @@ proc_getgroups(VALUE obj)
static VALUE static VALUE
proc_setgroups(VALUE obj, VALUE ary) proc_setgroups(VALUE obj, VALUE ary)
{ {
#ifdef HAVE_SETGROUPS
size_t ngroups; size_t ngroups;
rb_gid_t *groups; rb_gid_t *groups;
int i; int i;
@ -4434,13 +4432,13 @@ proc_setgroups(VALUE obj, VALUE ary)
rb_sys_fail(0); rb_sys_fail(0);
return proc_getgroups(obj); return proc_getgroups(obj);
#else
rb_notimplement();
return Qnil;
#endif
} }
#else
#define proc_setgroups rb_f_notimplement
#endif
#ifdef HAVE_INITGROUPS
/* /*
* call-seq: * call-seq:
* Process.initgroups(username, gid) => array * Process.initgroups(username, gid) => array
@ -4461,16 +4459,14 @@ proc_setgroups(VALUE obj, VALUE ary)
static VALUE static VALUE
proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp) proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp)
{ {
#ifdef HAVE_INITGROUPS
if (initgroups(StringValuePtr(uname), NUM2GIDT(base_grp)) != 0) { if (initgroups(StringValuePtr(uname), NUM2GIDT(base_grp)) != 0) {
rb_sys_fail(0); rb_sys_fail(0);
} }
return proc_getgroups(obj); return proc_getgroups(obj);
#else
rb_notimplement();
return Qnil;
#endif
} }
#else
#define proc_initgroups rb_f_notimplement
#endif
/* /*
@ -4511,6 +4507,7 @@ proc_setmaxgroups(VALUE obj, VALUE val)
return INT2FIX(maxgroups); return INT2FIX(maxgroups);
} }
#if defined(HAVE_DAEMON) || defined(HAVE_FORK)
/* /*
* call-seq: * call-seq:
* Process.daemon() => fixnum * Process.daemon() => fixnum
@ -4528,9 +4525,7 @@ static VALUE
proc_daemon(int argc, VALUE *argv) proc_daemon(int argc, VALUE *argv)
{ {
VALUE nochdir, noclose; VALUE nochdir, noclose;
#if defined(HAVE_DAEMON) || defined(HAVE_FORK)
int n; int n;
#endif
rb_secure(2); rb_secure(2);
rb_scan_args(argc, argv, "02", &nochdir, &noclose); rb_scan_args(argc, argv, "02", &nochdir, &noclose);
@ -4542,7 +4537,7 @@ proc_daemon(int argc, VALUE *argv)
after_fork(); after_fork();
if (n < 0) rb_sys_fail("daemon"); if (n < 0) rb_sys_fail("daemon");
return INT2FIX(n); return INT2FIX(n);
#elif defined(HAVE_FORK) #else /* defined(HAVE_FORK) */
switch (rb_fork(0, 0, 0, Qnil)) { switch (rb_fork(0, 0, 0, Qnil)) {
case -1: case -1:
return (-1); return (-1);
@ -4565,10 +4560,11 @@ proc_daemon(int argc, VALUE *argv)
(void)close (n); (void)close (n);
} }
return INT2FIX(0); return INT2FIX(0);
#else
rb_notimplement();
#endif #endif
} }
#else
#define proc_daemon rb_f_notimplement
#endif
/******************************************************************** /********************************************************************
* *
@ -5306,6 +5302,7 @@ p_gid_switch(VALUE obj)
#endif #endif
#if defined(HAVE_TIMES) && !defined(__CHECKER__)
/* /*
* call-seq: * call-seq:
* Process.times => aStructTms * Process.times => aStructTms
@ -5321,7 +5318,6 @@ p_gid_switch(VALUE obj)
VALUE VALUE
rb_proc_times(VALUE obj) rb_proc_times(VALUE obj)
{ {
#if defined(HAVE_TIMES) && !defined(__CHECKER__)
const double hertz = const double hertz =
#ifdef HAVE__SC_CLK_TCK #ifdef HAVE__SC_CLK_TCK
(double)sysconf(_SC_CLK_TCK); (double)sysconf(_SC_CLK_TCK);
@ -5344,10 +5340,10 @@ rb_proc_times(VALUE obj)
stime = DBL2NUM(buf.tms_stime / hertz), stime = DBL2NUM(buf.tms_stime / hertz),
cutime = DBL2NUM(buf.tms_cutime / hertz), cutime = DBL2NUM(buf.tms_cutime / hertz),
sctime = DBL2NUM(buf.tms_cstime / hertz)); sctime = DBL2NUM(buf.tms_cstime / hertz));
#else
rb_notimplement();
#endif
} }
#else
#define rb_proc_times rb_f_notimplement
#endif
VALUE rb_mProcess; VALUE rb_mProcess;
VALUE rb_mProcUID; VALUE rb_mProcUID;

View file

@ -1160,7 +1160,7 @@ Init_eval_method(void)
undefined = rb_intern("method_undefined"); undefined = rb_intern("method_undefined");
singleton_undefined = rb_intern("singleton_method_undefined"); singleton_undefined = rb_intern("singleton_method_undefined");
rb_global_variable(&notimplement_body); rb_global_variable((VALUE*)&notimplement_body);
notimplement_body = NEW_CFUNC(rb_f_notimplement, -1); notimplement_body = NEW_CFUNC(rb_f_notimplement, -1);
} }