-
-
Save bnoordhuis/ddfdd701f172dd8af63f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/node_file.cc b/src/node_file.cc | |
index 60c094b..b6518d2 100644 | |
--- a/src/node_file.cc | |
+++ b/src/node_file.cc | |
@@ -682,12 +682,14 @@ static Handle<Value> Open(const Arguments& args) { | |
#ifndef _LARGEFILE_SOURCE | |
#define ASSERT_OFFSET(a) \ | |
+ STATIC_ASSERT(sizeof(off_t) * CHAR_BIT >= 64); \ | |
if (!(a)->IsUndefined() && !(a)->IsNull() && !(a)->IsInt32()) { \ | |
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \ | |
} | |
#define GET_OFFSET(a) ((a)->IsNumber() ? (a)->Int32Value() : -1) | |
#else | |
#define ASSERT_OFFSET(a) \ | |
+ STATIC_ASSERT(sizeof(off_t) * CHAR_BIT >= 64); \ | |
if (!(a)->IsUndefined() && !(a)->IsNull() && !IsInt64((a)->NumberValue())) { \ | |
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \ | |
} | |
diff --git a/src/node_internals.h b/src/node_internals.h | |
index 8d07392..2f9611c 100644 | |
--- a/src/node_internals.h | |
+++ b/src/node_internals.h | |
@@ -60,6 +60,10 @@ inline static int snprintf(char* buf, unsigned int len, const char* fmt, ...) { | |
# define ROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a)) | |
#endif | |
+#ifndef STATIC_ASSERT | |
+# define STATIC_ASSERT(expr) static_cast<void>((sizeof(char[-1 + !!(expr)]))) | |
+#endif | |
+ | |
// this would have been a template function were it not for the fact that g++ | |
// sometimes fails to resolve it... | |
#define THROW_ERROR(fun) \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment