Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 31810073f3b0
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da9241ffde8f
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on May 24, 2015

  1. [Truffle] Use a different debug port since 8000 is likely to conflict…

    … with other services.
    nirvdrum committed May 24, 2015
    1
    Copy the full SHA
    e62db76 View commit details
  2. Copy the full SHA
    c1f8305 View commit details
  3. Copy the full SHA
    8fd9df6 View commit details
  4. Copy the full SHA
    da9241f View commit details
2 changes: 1 addition & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -226,7 +226,7 @@ def run(*args)
end

if args.delete('--jdebug')
jruby_args += %w[-J-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y]
jruby_args += %w[-J-agentlib:jdwp=transport=dt_socket,server=y,address=51819,suspend=y]
end

if args.delete('--server')
Original file line number Diff line number Diff line change
@@ -264,6 +264,11 @@ public int getAtOffsetShort(RubyBasicObject pointer, int offset, int type) {
return getPointer(pointer).getShort(offset);
}

@Specialization(guards = "type == TYPE_USHORT")
public int getAtOffsetUShort(RubyBasicObject pointer, int offset, int type) {
return getPointer(pointer).getShort(offset);
}

@Specialization(guards = "type == TYPE_LONG")
public long getAtOffsetLong(RubyBasicObject pointer, int offset, int type) {
return getPointer(pointer).getLong(offset);
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ public abstract class FDSetFactoryFactory {
public static FDSetFactory create() {
switch (Platform.getPlatform().getOS()) {
case DARWIN:
case LINUX:
return new FDSetFactory() {

@Override
@@ -26,6 +25,14 @@ public FDSet create() {

};

case LINUX:
return new FDSetFactory() {
@Override
public FDSet create() {
return new LinuxFDSet();
}
};

default:
throw new UnsupportedOperationException();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/

package org.jruby.truffle.runtime.sockets;

import jnr.ffi.Pointer;
import jnr.ffi.provider.MemoryManager;

public class LinuxFDSet implements FDSet {

private final static int MAX_FDS = 1024;
private final static int FIELD_SIZE_IN_BYTES = 4;
private final static int FIELD_SIZE_IN_BITS = FIELD_SIZE_IN_BYTES * 8;

private static final MemoryManager memoryManager = jnr.ffi.Runtime.getSystemRuntime().getMemoryManager();

private final Pointer bitmap;

public LinuxFDSet() {
bitmap = memoryManager.allocateDirect(MAX_FDS / FIELD_SIZE_IN_BITS);
}

@Override
public void set(int fd) {
checkBounds(fd);

final int offset = bitmapAddressOffset(fd);

bitmap.putInt(offset, bitmap.getInt(offset) | bitmapElementMask(fd));
}

@Override
public boolean isSet(int fd) {
checkBounds(fd);

return (bitmap.getInt(bitmapAddressOffset(fd)) & bitmapElementMask(fd)) != 0;
}

@Override
public Pointer getPointer() {
return bitmap;
}

private void checkBounds(int fd) {
if (fd < 0 || fd >= MAX_FDS) {
throw new IllegalArgumentException(String.format("Supplied file descriptor value must be > 0 and < %i", MAX_FDS));
}
}

private int bitmapElementIndex(int fd) {
return fd / FIELD_SIZE_IN_BITS;
}

private int bitmapAddressOffset(int fd) {
return bitmapElementIndex(fd) * FIELD_SIZE_IN_BYTES;
}

private int bitmapElementMask(int fd) {
return 1 << (fd % FIELD_SIZE_IN_BITS);
}
}