diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-12 17:55:03 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-12 17:55:03 +0000 |
commit | dad6eee444e6b0deaf0ca53ef582ae614f8b433a (patch) | |
tree | 392737dab829535bdf16848c6dc26825495ef393 /nuttx/mm/mm_granfree.c | |
parent | 43069a49aac009d47ee2e86053fde7e877a48cad (diff) | |
download | px4-firmware-dad6eee444e6b0deaf0ca53ef582ae614f8b433a.tar.gz px4-firmware-dad6eee444e6b0deaf0ca53ef582ae614f8b433a.tar.bz2 px4-firmware-dad6eee444e6b0deaf0ca53ef582ae614f8b433a.zip |
Misc fixes and optimizations for the granule allocator
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5136 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/mm/mm_granfree.c')
-rw-r--r-- | nuttx/mm/mm_granfree.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/nuttx/mm/mm_granfree.c b/nuttx/mm/mm_granfree.c index aa14207f3..fcab11af9 100644 --- a/nuttx/mm/mm_granfree.c +++ b/nuttx/mm/mm_granfree.c @@ -99,26 +99,38 @@ static inline void gran_common_free(FAR struct gran_s *priv, granmask = (1 << priv->log2gran) - 1; ngranules = (size + granmask) >> priv->log2gran; - /* Clear bits in the first GAT entry */ + /* Clear bits in the GAT entry or entries */ avail = 32 - gatbit; if (ngranules > avail) { - priv->gat[gatidx] &= ~(0xffffffff << gatbit); + /* Clear bits in the first GAT entry */ + + gatmask = (0xffffffff << gatbit); + DEBUGASSERT((priv->gat[gatidx] & gatmask) == gatmask); + + priv->gat[gatidx] &= ~gatmask; ngranules -= avail; /* Clear bits in the second GAT entry */ gatmask = 0xffffffff >> (32 - ngranules); - priv->gat[gatidx+1] &= ~(gatmask << gatbit); + DEBUGASSERT((priv->gat[gatidx+1] & gatmask) == gatmask); + + priv->gat[gatidx+1] &= ~gatmask; } /* Handle the case where where all of the granules came from one entry */ else { - gatmask = 0xffffffff >> (32 - ngranules); - priv->gat[gatidx] &= ~(gatmask << gatbit); + /* Clear bits in a single GAT entry */ + + gatmask = 0xffffffff >> (32 - ngranules); + gatmask <<= gatbit; + DEBUGASSERT((priv->gat[gatidx] & gatmask) == gatmask); + + priv->gat[gatidx] &= ~gatmask; } gran_leave_critical(priv); |