summaryrefslogtreecommitdiff
path: root/nuttx/lib/lib_fixedmath.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-12-14 20:51:11 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-12-14 20:51:11 +0000
commit33d20a1c87eb7cae586cc0d444729eda6c46e723 (patch)
tree8232edf97066c2d2c3afaf3fea3b51ff51f702cb /nuttx/lib/lib_fixedmath.c
parent6260f872623acfe046f62a728405dbadc2a60c8c (diff)
downloadpx4-nuttx-33d20a1c87eb7cae586cc0d444729eda6c46e723.tar.gz
px4-nuttx-33d20a1c87eb7cae586cc0d444729eda6c46e723.tar.bz2
px4-nuttx-33d20a1c87eb7cae586cc0d444729eda6c46e723.zip
Switching to C99 stdint.h types
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2338 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib/lib_fixedmath.c')
-rw-r--r--nuttx/lib/lib_fixedmath.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/nuttx/lib/lib_fixedmath.c b/nuttx/lib/lib_fixedmath.c
index dcd100559..d1717d945 100644
--- a/nuttx/lib/lib_fixedmath.c
+++ b/nuttx/lib/lib_fixedmath.c
@@ -1,7 +1,7 @@
/****************************************************************************
* lib/lib_fixedmath.c
*
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -38,12 +38,15 @@
****************************************************************************/
#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
#include <fixedmath.h>
#ifndef CONFIG_HAVE_LONG_LONG
/****************************************************************************
- * Definitions
+ * Pre-processor Definitions
****************************************************************************/
/****************************************************************************
@@ -66,23 +69,23 @@
* Name: fixsign
****************************************************************************/
-static void fixsign(b16_t *parg1, b16_t *parg2, boolean *pnegate)
+static void fixsign(b16_t *parg1, b16_t *parg2, bool *pnegate)
{
- boolean negate = FALSE;
+ bool negate = false;
b16_t arg;
arg = *parg1;
if (arg < 0)
{
*parg1 = -arg;
- negate = TRUE;
+ negate = true;
}
arg = *parg2;
if (arg < 0)
{
*parg2 = -arg;
- negate ^= TRUE;
+ negate ^= true;
}
*pnegate = negate;
@@ -92,7 +95,7 @@ static void fixsign(b16_t *parg1, b16_t *parg2, boolean *pnegate)
* Name: adjustsign
****************************************************************************/
-static b16_t adjustsign(b16_t result, boolean negate)
+static b16_t adjustsign(b16_t result, bool negate)
{
/* If the product is negative, then we overflowed */
@@ -127,7 +130,7 @@ static b16_t adjustsign(b16_t result, boolean negate)
b16_t b16mulb16(b16_t m1, b16_t m2)
{
- boolean negate;
+ bool negate;
b16_t product;
fixsign(&m1, &m2, &negate);
@@ -153,10 +156,10 @@ ub16_t ub16mulub16(ub16_t m1, ub16_t m2)
* = a*2**16 + b + c*2**-16
*/
- uint32 m1i = ((uint32)m1 >> 16);
- uint32 m2i = ((uint32)m1 >> 16);
- uint32 m1f = ((uint32)m1 & 0x0000ffff);
- uint32 m2f = ((uint32)m2 & 0x0000ffff);
+ uint32_t m1i = ((uint32_t)m1 >> 16);
+ uint32_t m2i = ((uint32_t)m1 >> 16);
+ uint32_t m1f = ((uint32_t)m1 & 0x0000ffff);
+ uint32_t m2f = ((uint32_t)m2 & 0x0000ffff);
return (m1i*m2i << 16) + m1i*m2f + m2i*m1f + (((m1f*m2f) + b16HALF) >> 16);
}
@@ -202,8 +205,8 @@ ub16_t ub16sqr(ub16_t a)
* = (mi*mi)*2**16 + 2*(mi*mf) + mf*mf*2**-16 (b16)
*/
- uint32 mi = ((uint32)a >> 16);
- uint32 mf = ((uint32)a & 0x0000ffff);
+ uint32_t mi = ((uint32_t)a >> 16);
+ uint32_t mf = ((uint32_t)a & 0x0000ffff);
return (mi*mi << 16) + (mi*mf << 1) + ((mf*mf + b16HALF) >> 16);
}
@@ -214,7 +217,7 @@ ub16_t ub16sqr(ub16_t a)
b16_t b16divb16(b16_t num, b16_t denom)
{
- boolean negate;
+ bool negate;
b16_t quotient;
fixsign(&num, &denom, &negate);
@@ -228,9 +231,9 @@ b16_t b16divb16(b16_t num, b16_t denom)
ub16_t ub16divub16(ub16_t num, ub16_t denom)
{
- uint32 term1;
- uint32 numf;
- uint32 product;
+ uint32_t term1;
+ uint32_t numf;
+ uint32_t product;
/* Let:
*
@@ -245,7 +248,7 @@ ub16_t ub16divub16(ub16_t num, ub16_t denom)
/* Check for overflow in the first part of the quotient */
- term1 = ((uint32)num & 0xffff0000) / denom;
+ term1 = ((uint32_t)num & 0xffff0000) / denom;
if (term1 >= 0x00010000)
{
return ub16MAX; /* Will overflow */