Switch from GPLv2 to GPLv2+
[fw/altos] / src / kernel / ao_convert_pa.c
index 20162c1f5c1fea5ae5ec52b097e269344c2f4d3b..8ae0e7c93bcedd95d90e8e4f3db299c0be09e3ae 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -39,11 +40,11 @@ static const alt_t altitude_table[] AO_CONST_ATTRIB = {
 #define ALT_MASK       (ALT_SCALE - 1)
 
 alt_t
-ao_pa_to_altitude(int32_t pa)
+ao_pa_to_altitude(pres_t pa)
 {
        int16_t o;
        int16_t part;
-       int32_t low, high;
+       alt_t low, high;
 
        if (pa < 0)
                pa = 0;
@@ -52,16 +53,16 @@ ao_pa_to_altitude(int32_t pa)
        o = pa >> ALT_SHIFT;
        part = pa & ALT_MASK;
 
-       low = (int32_t) FETCH_ALT(o) * (ALT_SCALE - part);
-       high = (int32_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1);
+       low = (alt_t) FETCH_ALT(o) * (ALT_SCALE - part);
+       high = (alt_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1);
        return (low + high) >> ALT_SHIFT;
 }
 
 #ifdef AO_CONVERT_TEST
-int32_t
-ao_altitude_to_pa(int32_t alt)
+pres_t
+ao_altitude_to_pa(alt_t alt)
 {
-       int32_t         span, sub_span;
+       alt_t   span, sub_span;
        uint16_t        l, h, m;
        int32_t         pa;
 
@@ -76,7 +77,7 @@ ao_altitude_to_pa(int32_t alt)
        }
        span = altitude_table[l] - altitude_table[h];
        sub_span = altitude_table[l] - alt;
-       pa = ((((int32_t) l * (span - sub_span) + (int32_t) h * sub_span) << ALT_SHIFT) + (span >> 1)) / span;
+       pa = ((((alt_t) l * (span - sub_span) + (alt_t) h * sub_span) << ALT_SHIFT) + (span >> 1)) / span;
        if (pa > 120000)
                pa = 120000;
        if (pa < 0)