diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-05 20:46:56 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-05 20:46:56 +0000 |
commit | 894628ac02f087a715513d260a1dc70b1e38414f (patch) | |
tree | 27e6ec90d16a88dbcfb2c421c72b4ec7337e35e4 | |
parent | e1e61c5b60c4d4806e9565ea480394be0c0b1425 (diff) | |
download | ruby-894628ac02f087a715513d260a1dc70b1e38414f.tar.gz |
io.c: fix compilation when IOV_MAX is not defined
GNU/Hurd has writev(2) but does not define IOV_MAX
[ruby-core:87417] [Bug #14827]
Reported-by: Paul Sonnenschein
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | io.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1626,6 +1626,16 @@ io_fwritev(int argc, VALUE *argv, rb_io_t *fptr) return n; } + +static int +iovcnt_ok(int iovcnt) +{ +#ifdef IOV_MAX + return iovcnt < IOV_MAX; +#else /* GNU/Hurd has writev, but no IOV_MAX */ + return 1; +#endif +} #endif /* HAVE_WRITEV */ static VALUE @@ -1649,7 +1659,7 @@ io_writev(int argc, VALUE *argv, VALUE io) for (i = 0; i < argc; i += cnt) { #ifdef HAVE_WRITEV - if ((fptr->mode & (FMODE_SYNC|FMODE_TTY)) && ((cnt = argc - i) < IOV_MAX)) { + if ((fptr->mode & (FMODE_SYNC|FMODE_TTY)) && iovcnt_ok(cnt = argc - i)) { n = io_fwritev(cnt, &argv[i], fptr); } else |