ruby-changes:21672
From: kosaki <ko1@a...>
Date: Sat, 12 Nov 2011 11:34:08 +0900 (JST)
Subject: [ruby-changes:21672] kosaki:r33721 (trunk): * io.c (fcntl_narg_len): introduce narg calculation for fcntl instead
kosaki 2011-11-12 11:33:58 +0900 (Sat, 12 Nov 2011) New Revision: 33721 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33721 Log: * io.c (fcntl_narg_len): introduce narg calculation for fcntl instead of hard coded 256. * io.c (setup_narg): ditto. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33720) +++ ChangeLog (revision 33721) @@ -1,3 +1,9 @@ +Sat Nov 12 11:20:36 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * io.c (fcntl_narg_len): introduce narg calculation for fcntl instead + of hard coded 256. + * io.c (setup_narg): ditto. + Sat Nov 12 11:19:35 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * test/ruby/test_io.rb (test_fcntl_dupfd): add another fcntl test. Index: io.c =================================================================== --- io.c (revision 33720) +++ io.c (revision 33721) @@ -7917,6 +7917,141 @@ return len; } +#ifdef HAVE_FCNTL +#ifdef __linux__ +typedef long fcntl_arg_t; +#else +/* posix */ +typedef int fcntl_arg_t; +#endif + +static long +fcntl_narg_len(int cmd) +{ + long len; + + switch (cmd) { +#ifdef F_DUPFD + case F_DUPFD: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_DUP2FD /* bsd specific */ + case F_DUP2FD: + len = sizeof(int); + break; +#endif +#ifdef F_DUPFD_CLOEXEC /* linux specific */ + case F_DUPFD_CLOEXEC: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETFD + case F_GETFD: + len = 1; + break; +#endif +#ifdef F_SETFD + case F_SETFD: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETFL + case F_GETFL: + len = 1; + break; +#endif +#ifdef F_SETFL + case F_SETFL: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETOWN + case F_GETOWN: + len = 1; + break; +#endif +#ifdef F_SETOWN + case F_SETOWN: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETOWN_EX /* linux specific */ + case F_GETOWN_EX: + len = sizeof(struct f_owner_ex); + break; +#endif +#ifdef F_SETOWN_EX /* linux specific */ + case F_SETOWN_EX: + len = sizeof(struct f_owner_ex); + break; +#endif +#ifdef F_GETLK + case F_GETLK: + len = sizeof(struct flock); + break; +#endif +#ifdef F_SETLK + case F_SETLK: + len = sizeof(struct flock); + break; +#endif +#ifdef F_SETLKW + case F_SETLKW: + len = sizeof(struct flock); + break; +#endif +#ifdef F_READAHEAD /* bsd specific */ + case F_READAHEAD: + len = sizeof(int); + break; +#endif +#ifdef F_RDAHEAD /* Darwin specific */ + case F_RDAHEAD: + len = sizeof(int); + break; +#endif +#ifdef F_GETSIG /* linux specific */ + case F_GETSIG: + len = 1; + break; +#endif +#ifdef F_SETSIG /* linux specific */ + case F_SETSIG: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETLEASE /* linux specific */ + case F_GETLEASE: + len = 1; + break; +#endif +#ifdef F_SETLEASE /* linux specific */ + case F_SETLEASE: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_NOTIFY /* linux specific */ + case F_NOTIFY: + len = sizeof(fcntl_arg_t); + break; +#endif + + default: + len = 256; + break; + } + + return len; +} +#else /* HAVE_FCNTL */ +static long +fcntl_narg_len(int cmd) +{ + return 0; +} +#endif /* HAVE_FCNTL */ + static long setup_narg(int cmd, VALUE *argp, int io_p) { @@ -7945,7 +8080,7 @@ if (io_p) len = ioctl_narg_len(cmd); else - len = 256; + len = fcntl_narg_len(cmd); rb_str_modify(arg); /* expand for data + sentinel. */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/