Disable node.cc functions that are not supported on windows
authorBert Belder <bertbelder@gmail.com>
Thu, 25 Nov 2010 00:09:06 +0000 (01:09 +0100)
committerBert Belder <bertbelder@gmail.com>
Mon, 20 Dec 2010 22:50:35 +0000 (23:50 +0100)
src/node.cc

index be59630..5357f1f 100644 (file)
@@ -1081,6 +1081,9 @@ static Handle<Value> Cwd(const Arguments& args) {
   return scope.Close(cwd);
 }
 
+
+#ifdef __POSIX__
+
 static Handle<Value> Umask(const Arguments& args){
   HandleScope scope;
   unsigned int old;
@@ -1184,6 +1187,8 @@ static Handle<Value> SetUid(const Arguments& args) {
   return Undefined();
 }
 
+#endif // __POSIX__
+
 
 v8::Handle<v8::Value> Exit(const v8::Arguments& args) {
   HandleScope scope;
@@ -1252,6 +1257,7 @@ v8::Handle<v8::Value> MemoryUsage(const v8::Arguments& args) {
   return scope.Close(info);
 }
 
+#ifdef __POSIX__
 
 Handle<Value> Kill(const Arguments& args) {
   HandleScope scope;
@@ -1349,6 +1355,8 @@ Handle<Value> DLOpen(const v8::Arguments& args) {
   return Undefined();
 }
 
+#endif // __POSIX__
+
 
 // TODO remove me before 0.4
 Handle<Value> Compile(const Arguments& args) {
@@ -1573,7 +1581,11 @@ static Handle<Value> EnvSetter(Local<String> property,
                                const AccessorInfo& info) {
   String::Utf8Value key(property);
   String::Utf8Value val(value);
+#ifdef __POSIX__
   setenv(*key, *val, 1);
+#else  // __WIN32__
+  NO_IMPL_MSG(setenv)
+#endif
   return value;
 }
 
@@ -1593,7 +1605,11 @@ static Handle<Boolean> EnvDeleter(Local<String> property,
                                   const AccessorInfo& info) {
   String::Utf8Value key(property);
   if (getenv(*key)) {
+#ifdef __POSIX__
     unsetenv(*key);    // prototyped as `void unsetenv(const char*)` on some platforms
+#else
+    NO_IMPL_MSG(unsetenv)
+#endif
     return True();
   }
   return False();
@@ -1711,6 +1727,8 @@ static void Load(int argc, char *argv[]) {
   NODE_SET_METHOD(process, "reallyExit", Exit);
   NODE_SET_METHOD(process, "chdir", Chdir);
   NODE_SET_METHOD(process, "cwd", Cwd);
+
+#ifdef __POSIX__
   NODE_SET_METHOD(process, "getuid", GetUid);
   NODE_SET_METHOD(process, "setuid", SetUid);
 
@@ -1720,6 +1738,8 @@ static void Load(int argc, char *argv[]) {
   NODE_SET_METHOD(process, "umask", Umask);
   NODE_SET_METHOD(process, "dlopen", DLOpen);
   NODE_SET_METHOD(process, "_kill", Kill);
+#endif // __POSIX__
+
   NODE_SET_METHOD(process, "memoryUsage", MemoryUsage);
 
   NODE_SET_METHOD(process, "binding", Binding);
@@ -1873,7 +1893,7 @@ static void SignalExit(int signal) {
   _exit(1);
 }
 
-
+#ifdef __POSIX__
 static int RegisterSignalHandler(int signal, void (*handler)(int)) {
   struct sigaction sa;
 
@@ -1882,6 +1902,7 @@ static int RegisterSignalHandler(int signal, void (*handler)(int)) {
   sigfillset(&sa.sa_mask);
   return sigaction(signal, &sa, NULL);
 }
+#endif // __POSIX__
 
 
 int Start(int argc, char *argv[]) {
@@ -1921,10 +1942,12 @@ int Start(int argc, char *argv[]) {
   }
   V8::SetFlagsFromCommandLine(&v8argc, v8argv, false);
 
+#ifdef __POSIX__
   // Ignore SIGPIPE
   RegisterSignalHandler(SIGPIPE, SIG_IGN);
   RegisterSignalHandler(SIGINT, SignalExit);
   RegisterSignalHandler(SIGTERM, SignalExit);
+#endif // __POSIX__
 
 #ifdef __MINGW32__
   // On windows, to use winsock it must be initialized