Author Topic: Patch to add atan2 to FluffOS  (Read 1820 times)

Offline Stavros

  • Acquaintance
  • *
  • Posts: 36
    • View Profile
Patch to add atan2 to FluffOS
« on: August 03, 2010, 07:36:40 pm »
For those interested (heh), here is a patch to add atan2 to the math package in FluffOS. It's just the pow code copy/pasted, with atan2 stuck in for the actual C library call, since pow and atan2 have the same signature.

Copy/paste the code block below into a file in the FluffOS source dir, then "patch -p1 < patchfile".

Wodan or any other Fluff maintainers, if you're game I would love to have this added into the official driver so I wouldn't have to remind my admin to patch it back in every time we do a driver upgrade. :)

Stavros

Code: [Select]
diff -rupN fluffos-2.20-base/packages/math.c fluffos-2.20/packages/math.c
--- fluffos-2.20-base/packages/math.c   2010-04-22 13:54:10.000000000 -0500
+++ fluffos-2.20/packages/math.c        2010-08-03 19:46:49.000000000 -0500
@@ -85,6 +85,29 @@ f_atan (void)
 }
 #endif

+#ifdef F_ATAN2
+void
+f_atan2 (void)
+{
+    float val, val2;
+
+    if((sp-1)->type == T_NUMBER)
+        val = (float) (sp-1)->u.number;
+    else
+        val = (sp-1)->u.real;
+
+    if(sp->type == T_NUMBER)
+        val2 = (float) sp->u.number;
+    else
+        val2 = sp->u.real;
+
+
+    (sp - 1)->u.real = atan2(val, val2);
+    sp--;
+    sp->type = T_REAL;
+}
+#endif
+
 #ifdef F_SQRT
 void
 f_sqrt (void)
diff -rupN fluffos-2.20-base/packages/math_spec.c fluffos-2.20/packages/math_spec.c
--- fluffos-2.20-base/packages/math_spec.c      2009-06-11 14:50:42.000000000 -0500
+++ fluffos-2.20/packages/math_spec.c   2010-08-03 19:45:14.000000000 -0500
@@ -6,6 +6,7 @@
     float asin(float);
     float acos(float);
     float atan(float);
+    float atan2(float|int, float|int);
     float sqrt(float|int);
     float log(float);
     float log10(float|int);