Permalink
Browse files

make syscall module compatible with Node.js 4.x

  • Loading branch information...
neelance committed Sep 29, 2015
1 parent 2fed3e6 commit d942555ec097c1b3260ed89fff69afc2ceb93bec
Showing with 9 additions and 3 deletions.
  1. +1 −1 doc/syscalls.md
  2. +8 −2 node-syscall/syscall.cc
View
@@ -17,7 +17,7 @@ When running your code with Node.js on Windows, it is theoretically possible to
### Node.js on OS X and Linux
GopherJS has support for system calls on OS X and Linux. Before running your code with Node.js, you need to install the system calls module. The module is only compatible with version 0.12 of Node.js. If you want to use an older version you can opt to not install the module, but then system calls are not available.
GopherJS has support for system calls on OS X and Linux. Before running your code with Node.js, you need to install the system calls module. The module is compatible with Node.js version 0.12 and above. If you want to use an older version you can opt to not install the module, but then system calls are not available.
Compile and install the module with:
```
View
@@ -7,13 +7,19 @@
using namespace v8;
#if NODE_MAJOR_VERSION == 0
#define ARRAY_BUFFER_DATA_OFFSET 23
#else
#define ARRAY_BUFFER_DATA_OFFSET 31
#endif
intptr_t toNative(Local<Value> value) {
if (value.IsEmpty()) {
return 0;
}
if (value->IsArrayBufferView()) {
Local<ArrayBufferView> view = Local<ArrayBufferView>::Cast(value);
return *reinterpret_cast<intptr_t*>(*reinterpret_cast<char**>(*view->Buffer()) + 23) + view->ByteOffset(); // ugly hack, because of https://codereview.chromium.org/25221002
return *reinterpret_cast<intptr_t*>(*reinterpret_cast<char**>(*view->Buffer()) + ARRAY_BUFFER_DATA_OFFSET) + view->ByteOffset(); // ugly hack, because of https://codereview.chromium.org/25221002
}
if (value->IsArray()) {
Local<Array> array = Local<Array>::Cast(value);
@@ -89,4 +95,4 @@ void init(Handle<Object> target) {
NODE_SET_METHOD(target, "Syscall6", Syscall6);
}
NODE_MODULE(syscall, init);
NODE_MODULE(syscall, init);

0 comments on commit d942555

Please sign in to comment.