'libs/ardour' - Platform specific changes and includes
[ardour.git] / libs / ardour / globals.cc
index b21f3038bbeff0fd74139bbc0f67430417275e42..57b1e2db65b14f42b4caf49c936a27a472f26676 100644 (file)
 #include "libardour-config.h"
 #endif
 
+#ifdef interface
+#undef interface
+#endif
+
 #include <cstdio> // Needed so that libraptor (included in lrdf) won't complain
 #include <cstdlib>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#ifndef PLATFORM_WINDOWS
 #include <sys/resource.h>
+#endif
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -42,7 +48,7 @@
 #include "ardour/audio_unit.h"
 #endif
 
-#ifdef __SSE__
+#if defined(__SSE__) || defined(USE_XMMINTRIN)
 #include <xmmintrin.h>
 #endif
 
@@ -55,7 +61,9 @@
 #include <glibmm/fileutils.h>
 #include <glibmm/miscutils.h>
 
+#ifdef HAVE_LRDF
 #include <lrdf.h>
+#endif
 
 #include "pbd/cpus.h"
 #include "pbd/error.h"
@@ -193,6 +201,7 @@ setup_hardware_optimization (bool try_optimization)
 static void
 lotsa_files_please ()
 {
+#ifndef PLATFORM_WINDOWS
        struct rlimit rl;
 
        if (getrlimit (RLIMIT_NOFILE, &rl) == 0) {
@@ -213,6 +222,7 @@ lotsa_files_please ()
        } else {
                error << string_compose (_("Could not get system open files limit (%1)"), strerror (errno)) << endmsg;
        }
+#endif
 }
 
 int
@@ -261,7 +271,9 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
        // allow ardour the absolute maximum number of open files
        lotsa_files_please ();
 
+#ifdef HAVE_LRDF
        lrdf_init();
+#endif
        Library = new AudioLibrary;
 
        BootMessage (_("Loading configuration"));
@@ -356,7 +368,9 @@ int
 ARDOUR::cleanup ()
 {
        delete Library;
+#ifdef HAVE_LRDF
        lrdf_cleanup ();
+#endif
        delete &ControlProtocolManager::instance();
 #ifdef WINDOWS_VST_SUPPORT
        fst_exit ();
@@ -480,28 +494,46 @@ ARDOUR::translation_enable_path ()
 bool
 ARDOUR::translations_are_enabled ()
 {
-        if (Glib::file_test (translation_enable_path(), Glib::FILE_TEST_EXISTS)) {
-               return true;
-       } 
+       int fd = ::open (ARDOUR::translation_enable_path().c_str(), O_RDONLY);
+
+       if (fd < 0) {
+               return translate_by_default;
+       }
+
+       char c;
+       bool ret = false;
 
-       return translate_by_default;
+       if (::read (fd, &c, 1) == 1 && c == '1') {
+               ret = true;
+       }
+
+       ::close (fd);
+
+       return ret;
 }
 
 bool
 ARDOUR::set_translations_enabled (bool yn)
 {
        string i18n_enabler = ARDOUR::translation_enable_path();
+       int fd = ::open (i18n_enabler.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0644);
 
-       if (yn) {
-               int fd = ::open (i18n_enabler.c_str(), O_RDONLY|O_CREAT, 0644);
-               if (fd >= 0) {
-                       close (fd);
-                       return true;
-               } 
+       if (fd < 0) {
                return false;
-       } 
+       }
+       
+       char c;
+       
+       if (yn) {
+               c = '1';
+       } else {
+               c = '0';
+       }
+       
+       ::write (fd, &c, 1);
+       ::close (fd);
 
-       return unlink (i18n_enabler.c_str()) == 0;
+       return true;
 }