Use fast FPU mode
authorAlberto Mardegan <mardy@users.sourceforge.net>
Thu, 7 Jul 2011 05:54:42 +0000 (08:54 +0300)
committerAlberto Mardegan <mardy@users.sourceforge.net>
Thu, 7 Jul 2011 05:54:42 +0000 (08:54 +0300)
share/maemo.c

index fa67e8a..7a16ff8 100644 (file)
@@ -31,6 +31,36 @@ static Uint32 disable_display_blank(Uint32 interval, void *param)
     return interval;
 }
 
+/* Fast FPU mode is a bit inaccurate (non IEEE), but definitely faster */
+static void fpu_set_fast_mode(int fast_mode)
+{
+#ifdef __arm__
+  if (fast_mode)
+  {
+      int tmp;
+      __asm__ volatile(
+        "fmrx       %[tmp], fpscr\n"
+        "orr        %[tmp], %[tmp], #(1 << 24)\n" /* flush-to-zero */
+        "orr        %[tmp], %[tmp], #(1 << 25)\n" /* default NaN */
+        "bic        %[tmp], %[tmp], #((1 << 15) | (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8))\n" /* clear exception bits */
+        "fmxr       fpscr, %[tmp]\n"
+        : [tmp] "=r" (tmp)
+      );
+  }
+  else
+  {
+      int tmp;
+      __asm__ volatile(
+        "fmrx       %[tmp], fpscr\n"
+        "bic        %[tmp], %[tmp], #(1 << 24)\n" /* flush-to-zero */
+        "bic        %[tmp], %[tmp], #(1 << 25)\n" /* default NaN */
+        "fmxr       fpscr, %[tmp]\n"
+        : [tmp] "=r" (tmp)
+      );
+  }
+#endif /* if __arm__ */
+}
+
 int maemo_init(const char *program)
 {
     osso_context = osso_initialize(program, "1.0", 0, NULL);
@@ -41,6 +71,8 @@ int maemo_init(const char *program)
 
     osso_display_blanking_pause(osso_context);
     screen_timer_id = SDL_AddTimer(30000, disable_display_blank, NULL);
+
+    fpu_set_fast_mode(1);
     return 1;
 }