Skip to content

Instantly share code, notes, and snippets.

@bnoordhuis bnoordhuis/patsje.patch Secret
Created Apr 5, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.