-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed SYS___pthread_chdir value for FreeBSD when making call to syscall #109
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,14 +27,24 @@ | |
@SuppressWarnings("WeakerAccess") | ||
public class LibC | ||
{ | ||
|
||
public static int SYS___pthread_chdir = 348; | ||
|
||
static { | ||
if (OS == OperatingSystem.MAC) { | ||
O_NONBLOCK = 0x0004; // MacOS X, Freebsd | ||
O_NONBLOCK = 0x0004; // MacOS X, Freebsd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the pull request, but please remove unrelated whitespace changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace has been removed, sorry about that. |
||
} | ||
|
||
else { | ||
O_NONBLOCK = 2048; // Linux | ||
} | ||
|
||
|
||
// changing the value based on https://github.com/freebsd/freebsd/blob/master/sys/sys/syscall.h | ||
String osname = System.getProperty("os.name").toLowerCase(); | ||
if ( osname.contains("freebsd") ) { | ||
SYS___pthread_chdir = 12; | ||
} | ||
|
||
Native.register(NativeLibrary.getProcess()); | ||
} | ||
|
||
|
@@ -81,8 +91,7 @@ public static native int posix_spawnp(IntByReference restrict_pid, String restri | |
// We can't use JNA direct mapping for syscall(), since it takes varargs. | ||
public interface SyscallLibrary extends Library | ||
{ | ||
public static final int SYS___pthread_chdir = 348; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't put the |
||
int syscall(int syscall_number, Object... args); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem like this should be mutable. This is clearly intended to be a constant.
Rather than initializing this here and changing it in the
static
block, which requires this to be mutable, leave it uninitialized here and update thestatic
block to set the "right" value:If this constant is going to move to
LibC
, should it be further down, with the others (likeO_NONBLOCK
)? Alternatively, perhaps the constant should just stay where it was, paired with a newstatic
block insideSyscallLibrary
to initialize it?