aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-26 13:13:11 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-26 13:13:11 +0000
commit6d0dbeb55017985fa5d476b99427f7bf525e9a14 (patch)
tree19aaa311fcff895b2d4aad26b0c8eb77cf65b020
parente00fc16aaa0c1adb27bca40a9871b165c3ca3fb7 (diff)
downloadbusybox-w32-6d0dbeb55017985fa5d476b99427f7bf525e9a14.tar.gz
busybox-w32-6d0dbeb55017985fa5d476b99427f7bf525e9a14.tar.bz2
busybox-w32-6d0dbeb55017985fa5d476b99427f7bf525e9a14.zip
- use ATTRIBUTE_ALWAYS_INLINE if requested
- use shorter boilerplate while at it
-rw-r--r--archival/libunarchive/rangecoder.h43
1 files changed, 6 insertions, 37 deletions
diff --git a/archival/libunarchive/rangecoder.h b/archival/libunarchive/rangecoder.h
index 43f752257..e43ec3908 100644
--- a/archival/libunarchive/rangecoder.h
+++ b/archival/libunarchive/rangecoder.h
@@ -1,39 +1,8 @@
1/*
2 * Small range coder implementation for lzma.
3 * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
4 *
5 * Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)
6 * Copyright (c) 1999-2005 Igor Pavlov
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <stdint.h>
24 1
25#include "libbb.h" 2#include "libbb.h"
26 3
27#ifndef always_inline
28# if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >0)
29# define always_inline __attribute__((always_inline)) inline
30# else
31# define always_inline inline
32# endif
33#endif
34
35#ifdef CONFIG_FEATURE_LZMA_FAST 4#ifdef CONFIG_FEATURE_LZMA_FAST
36# define speed_inline always_inline 5# define speed_inline ATTRIBUTE_ALWAYS_INLINE
37#else 6#else
38# define speed_inline 7# define speed_inline
39#endif 8#endif
@@ -67,7 +36,7 @@ static void rc_read(rc_t * rc)
67} 36}
68 37
69/* Called once */ 38/* Called once */
70static always_inline void rc_init(rc_t * rc, int fd, int buffer_size) 39static ATTRIBUTE_ALWAYS_INLINE void rc_init(rc_t * rc, int fd, int buffer_size)
71{ 40{
72 int i; 41 int i;
73 42
@@ -87,7 +56,7 @@ static always_inline void rc_init(rc_t * rc, int fd, int buffer_size)
87} 56}
88 57
89/* Called once. TODO: bb_maybe_free() */ 58/* Called once. TODO: bb_maybe_free() */
90static always_inline void rc_free(rc_t * rc) 59static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc)
91{ 60{
92 if (ENABLE_FEATURE_CLEAN_UP) 61 if (ENABLE_FEATURE_CLEAN_UP)
93 free(rc->buffer); 62 free(rc->buffer);
@@ -101,7 +70,7 @@ static void rc_do_normalize(rc_t * rc)
101 rc->range <<= 8; 70 rc->range <<= 8;
102 rc->code = (rc->code << 8) | *rc->ptr++; 71 rc->code = (rc->code << 8) | *rc->ptr++;
103} 72}
104static always_inline void rc_normalize(rc_t * rc) 73static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc)
105{ 74{
106 if (rc->range < (1 << RC_TOP_BITS)) { 75 if (rc->range < (1 << RC_TOP_BITS)) {
107 rc_do_normalize(rc); 76 rc_do_normalize(rc);
@@ -118,7 +87,7 @@ static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
118 rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); 87 rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
119 return rc->bound; 88 return rc->bound;
120} 89}
121static always_inline int rc_is_bit_0(rc_t * rc, uint16_t * p) 90static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
122{ 91{
123 uint32_t t = rc_is_bit_0_helper(rc, p); 92 uint32_t t = rc_is_bit_0_helper(rc, p);
124 return rc->code < t; 93 return rc->code < t;
@@ -152,7 +121,7 @@ static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
152} 121}
153 122
154/* Called once */ 123/* Called once */
155static always_inline int rc_direct_bit(rc_t * rc) 124static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
156{ 125{
157 rc_normalize(rc); 126 rc_normalize(rc);
158 rc->range >>= 1; 127 rc->range >>= 1;