Skip to content

Commit

Permalink
Fix andrasq#2: Use new v8 GetBackingStore() API when supported
Browse files Browse the repository at this point in the history
 - check for V8_MAJOR_VERSION >= 8, and use new GetBackingStore() API if so

 - See nodejs/nan#888 for more details

 - Relax dependency on nan ~2.14 so this can build on modern Node.js versions
   with nan >= 2.14.1
  • Loading branch information
trinitronx committed Jun 11, 2024
1 parent 0399c58 commit de61fd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"keywords": [ "Andras", "quick", "fast", "getrusage", "cpu", "memory", "resources", "used" ],

"dependencies": {
"nan": "2.14.0"
"nan": "^2.14.0"
},
"devDependencies": {
"qnit": "^0.25"
Expand Down
6 changes: 6 additions & 0 deletions qrusage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ double * getFloat64ArrayPointer( unsigned int length, v8::Local<v8::Value> arg )
v8::Local<v8::Float64Array> array = arg.As<v8::Float64Array>();
if (array->Length() >= length) {
v8::Local<v8::ArrayBuffer> ab = array->Buffer();
// Actually it's 7.9 here but this would lead to ABI issues with Node.js 13
// using 7.8 till 13.2.0.
#if (V8_MAJOR_VERSION >= 8)
double* fields = static_cast<double*>(ab->GetBackingStore()->Data());
#else
double* fields = static_cast<double*>(ab->GetContents().Data());
#endif
return fields;
}
}
Expand Down

0 comments on commit de61fd7

Please sign in to comment.