Skip to content

Commit

Permalink
Merge pull request #153 from unak/patch-1
Browse files Browse the repository at this point in the history
Support mswin
  • Loading branch information
tarcieri committed Jun 15, 2017
2 parents d810494 + 91fbace commit af3ff15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions ext/nio4r/bytebuffer.c
Expand Up @@ -124,10 +124,11 @@ static VALUE NIO_ByteBuffer_get_position(VALUE self)

static VALUE NIO_ByteBuffer_set_position(VALUE self, VALUE new_position)
{
int pos;
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

int pos = NUM2INT(new_position);
pos = NUM2INT(new_position);

if(pos < 0) {
rb_raise(rb_eArgError, "negative position given");
Expand Down Expand Up @@ -156,10 +157,11 @@ static VALUE NIO_ByteBuffer_get_limit(VALUE self)

static VALUE NIO_ByteBuffer_set_limit(VALUE self, VALUE new_limit)
{
int lim;
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

int lim = NUM2INT(new_limit);
lim = NUM2INT(new_limit);

if(lim < 0) {
rb_raise(rb_eArgError, "negative limit given");
Expand Down Expand Up @@ -237,10 +239,11 @@ static VALUE NIO_ByteBuffer_get(int argc, VALUE *argv, VALUE self)

static VALUE NIO_ByteBuffer_fetch(VALUE self, VALUE index)
{
int i;
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

int i = NUM2INT(index);
i = NUM2INT(index);

if(i < 0) {
rb_raise(rb_eArgError, "negative index given");
Expand All @@ -255,10 +258,11 @@ static VALUE NIO_ByteBuffer_fetch(VALUE self, VALUE index)

static VALUE NIO_ByteBuffer_put(VALUE self, VALUE string)
{
long length;
struct NIO_ByteBuffer *buffer;
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);

long length = RSTRING_LEN(string);
length = RSTRING_LEN(string);

if(length > buffer->limit - buffer->position) {
rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full");
Expand Down
4 changes: 2 additions & 2 deletions ext/nio4r/extconf.rb
Expand Up @@ -18,14 +18,14 @@

$defs << "-DHAVE_SYS_RESOURCE_H" if have_header("sys/resource.h")

CONFIG["optflags"] << " -fno-strict-aliasing"
CONFIG["optflags"] << " -fno-strict-aliasing" unless RUBY_PLATFORM =~ /mswin/

dir_config "nio4r_ext"
create_makefile "nio4r_ext"

# win32 needs to link in "just the right order" for some reason or
# ioctlsocket will be mapped to an [inverted] ruby specific version.
if RUBY_PLATFORM =~ /mingw|win32/
if RUBY_PLATFORM =~ /mingw|mswin/
makefile_contents = File.read "Makefile"

makefile_contents.gsub! "DLDFLAGS = ", "DLDFLAGS = -export-all "
Expand Down

0 comments on commit af3ff15

Please sign in to comment.