summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <mail@waldemar-brodkorb.de>2012-01-09 19:07:06 +0100
committerWaldemar Brodkorb <mail@waldemar-brodkorb.de>2012-01-09 19:07:06 +0100
commit3759be713eb1f3812412b7c9eff3767944786a7d (patch)
tree932fcc22559b0d874fa293b4d9c3b5f3ee0af995
parentc83c6ef149028b71e580a536289704d0ba811802 (diff)
update to 3.1.8, add lzma-loader for brcm47xx, kernel stuff + patches does not work on Asus WL500gp
-rw-r--r--Config.in4
-rw-r--r--mk/kernel-ver.mk6
-rw-r--r--target/config/Config.in3
-rw-r--r--target/linux/patches/3.1.8/bsd-compatibility.patch (renamed from target/linux/patches/3.1.5/bsd-compatibility.patch)0
-rw-r--r--target/linux/patches/3.1.8/cris-etrax.patch (renamed from target/linux/patches/3.1.5/cris-etrax.patch)0
-rw-r--r--target/linux/patches/3.1.8/defaults.patch (renamed from target/linux/patches/3.1.5/defaults.patch)0
-rw-r--r--target/linux/patches/3.1.8/fon2100.patch (renamed from target/linux/patches/3.1.5/fon2100.patch)0
-rw-r--r--target/linux/patches/3.1.8/gemalto.patch (renamed from target/linux/patches/3.1.5/gemalto.patch)0
-rw-r--r--target/linux/patches/3.1.8/mmc-host.patch (renamed from target/linux/patches/3.1.5/mmc-host.patch)0
-rw-r--r--target/linux/patches/3.1.8/non-static.patch (renamed from target/linux/patches/3.1.5/non-static.patch)0
-rw-r--r--target/linux/patches/3.1.8/sparc-include.patch (renamed from target/linux/patches/3.1.5/sparc-include.patch)0
-rw-r--r--target/linux/patches/3.1.8/startup.patch (renamed from target/linux/patches/3.1.5/startup.patch)0
-rw-r--r--target/linux/patches/3.1.8/usb-defaults-off.patch (renamed from target/linux/patches/3.1.5/usb-defaults-off.patch)0
-rw-r--r--target/linux/patches/3.1.8/uuid.patch (renamed from target/linux/patches/3.1.5/uuid.patch)0
-rw-r--r--target/linux/patches/3.1.8/vga-cons-default-off.patch (renamed from target/linux/patches/3.1.5/vga-cons-default-off.patch)0
-rw-r--r--target/linux/patches/3.1.8/wlan-cf.patch (renamed from target/linux/patches/3.1.5/wlan-cf.patch)0
-rw-r--r--target/linux/patches/3.1.8/x86-build.patch (renamed from target/linux/patches/3.1.5/x86-build.patch)0
-rw-r--r--target/linux/patches/3.1.8/zlib-inflate.patch (renamed from target/linux/patches/3.1.5/zlib-inflate.patch)0
-rw-r--r--target/mips/Makefile30
-rw-r--r--target/tools/lzma-loader/.svn/entries300
-rw-r--r--target/tools/lzma-loader/.svn/text-base/LzmaDecode.c.svn-base663
-rw-r--r--target/tools/lzma-loader/.svn/text-base/LzmaDecode.h.svn-base100
-rw-r--r--target/tools/lzma-loader/.svn/text-base/Makefile.svn-base77
-rw-r--r--target/tools/lzma-loader/.svn/text-base/README.svn-base55
-rw-r--r--target/tools/lzma-loader/.svn/text-base/decompress.c.svn-base186
-rw-r--r--target/tools/lzma-loader/.svn/text-base/decompress.lds.in.svn-base20
-rw-r--r--target/tools/lzma-loader/.svn/text-base/head.S.svn-base160
-rw-r--r--target/tools/lzma-loader/.svn/text-base/loader.lds.in.svn-base17
-rw-r--r--target/tools/lzma-loader/Makefile5
-rw-r--r--target/tools/lzma-loader/src/LzmaDecode.c663
-rw-r--r--target/tools/lzma-loader/src/LzmaDecode.h100
-rw-r--r--target/tools/lzma-loader/src/LzmaDecode.obin0 -> 6248 bytes
-rw-r--r--target/tools/lzma-loader/src/Makefile78
-rw-r--r--target/tools/lzma-loader/src/README55
-rw-r--r--target/tools/lzma-loader/src/data.lds1
-rw-r--r--target/tools/lzma-loader/src/data.obin0 -> 3996 bytes
-rwxr-xr-xtarget/tools/lzma-loader/src/decompressbin0 -> 71097 bytes
-rw-r--r--target/tools/lzma-loader/src/decompress.c186
-rwxr-xr-xtarget/tools/lzma-loader/src/decompress.imagebin0 -> 3484 bytes
-rw-r--r--target/tools/lzma-loader/src/decompress.lds20
-rw-r--r--target/tools/lzma-loader/src/decompress.lds.in20
-rw-r--r--target/tools/lzma-loader/src/decompress.obin0 -> 2680 bytes
-rw-r--r--target/tools/lzma-loader/src/head.S160
-rw-r--r--target/tools/lzma-loader/src/head.obin0 -> 1204 bytes
-rwxr-xr-xtarget/tools/lzma-loader/src/loaderbin0 -> 3804 bytes
-rwxr-xr-xtarget/tools/lzma-loader/src/loader.elfbin0 -> 8486 bytes
-rw-r--r--target/tools/lzma-loader/src/loader.gzbin0 -> 2374 bytes
-rw-r--r--target/tools/lzma-loader/src/loader.lds17
-rw-r--r--target/tools/lzma-loader/src/loader.lds.in17
-rwxr-xr-xtarget/tools/lzma-loader/src/loader.obin0 -> 8486 bytes
-rw-r--r--target/tools/lzma/Makefile31
-rw-r--r--target/tools/lzma/patches/001-large_files.patch13
-rw-r--r--target/tools/lzma/patches/002-lzmp.patch1059
-rw-r--r--target/tools/lzma/patches/003-compile_fixes.patch26
-rw-r--r--target/tools/lzma/patches/100-static_library.patch70
-rw-r--r--toolchain/kernel-headers/patches/3.1.8/aufs2.patch (renamed from toolchain/kernel-headers/patches/3.1.5/aufs2.patch)0
-rw-r--r--toolchain/kernel-headers/patches/3.1.8/cleankernel.patch (renamed from toolchain/kernel-headers/patches/3.1.5/cleankernel.patch)0
-rw-r--r--toolchain/kernel-headers/patches/3.1.8/etrax-header.patch (renamed from toolchain/kernel-headers/patches/3.1.5/etrax-header.patch)0
-rw-r--r--toolchain/kernel-headers/patches/3.1.8/linux-gcc-check.patch (renamed from toolchain/kernel-headers/patches/3.1.5/linux-gcc-check.patch)0
-rw-r--r--toolchain/kernel-headers/patches/3.1.8/microperl.patch (renamed from toolchain/kernel-headers/patches/3.1.5/microperl.patch)0
60 files changed, 4125 insertions, 17 deletions
diff --git a/Config.in b/Config.in
index 4358b3a7a..1b3868d6b 100644
--- a/Config.in
+++ b/Config.in
@@ -84,8 +84,8 @@ config ADK_KERNEL_VERSION_3_0_9
prompt "3.0.9"
boolean
-config ADK_KERNEL_VERSION_3_1_5
- prompt "3.1.5"
+config ADK_KERNEL_VERSION_3_1_8
+ prompt "3.1.8"
boolean
endchoice
diff --git a/mk/kernel-ver.mk b/mk/kernel-ver.mk
index ff1fc0cc4..683c83dc3 100644
--- a/mk/kernel-ver.mk
+++ b/mk/kernel-ver.mk
@@ -8,8 +8,8 @@ KERNEL_VERSION:= 3.0.9
KERNEL_RELEASE:= 1
KERNEL_MD5SUM:= 71992fa4dfc289a959f9ce266d08d77b
endif
-ifeq ($(ADK_KERNEL_VERSION_3_1_5),y)
-KERNEL_VERSION:= 3.1.5
+ifeq ($(ADK_KERNEL_VERSION_3_1_8),y)
+KERNEL_VERSION:= 3.1.8
KERNEL_RELEASE:= 1
-KERNEL_MD5SUM:= 20cc2ecedbd996c223db61f249afbe3e
+KERNEL_MD5SUM:= 69dfba755ab8691a426d8061c94a7ddc
endif
diff --git a/target/config/Config.in b/target/config/Config.in
index b6d56b051..a9f994772 100644
--- a/target/config/Config.in
+++ b/target/config/Config.in
@@ -119,6 +119,9 @@ config ADK_TARGET_BROADCOM_MODEL_LINKSYS_WRT54G
config ADK_TARGET_BROADCOM_MODEL_LINKSYS_WRT54GS
boolean "Linksys WRT54gs"
+config ADK_TARGET_BROADCOM_MODEL_ASUS_WL500GP
+ boolean "Asus WL500gP"
+
endchoice
if ADK_LINUX_NATIVE
diff --git a/target/linux/patches/3.1.5/bsd-compatibility.patch b/target/linux/patches/3.1.8/bsd-compatibility.patch
index 9e91a62de..9e91a62de 100644
--- a/target/linux/patches/3.1.5/bsd-compatibility.patch
+++ b/target/linux/patches/3.1.8/bsd-compatibility.patch
diff --git a/target/linux/patches/3.1.5/cris-etrax.patch b/target/linux/patches/3.1.8/cris-etrax.patch
index a80d9a8b8..a80d9a8b8 100644
--- a/target/linux/patches/3.1.5/cris-etrax.patch
+++ b/target/linux/patches/3.1.8/cris-etrax.patch
diff --git a/target/linux/patches/3.1.5/defaults.patch b/target/linux/patches/3.1.8/defaults.patch
index 58aae610b..58aae610b 100644
--- a/target/linux/patches/3.1.5/defaults.patch
+++ b/target/linux/patches/3.1.8/defaults.patch
diff --git a/target/linux/patches/3.1.5/fon2100.patch b/target/linux/patches/3.1.8/fon2100.patch
index 038ff7020..038ff7020 100644
--- a/target/linux/patches/3.1.5/fon2100.patch
+++ b/target/linux/patches/3.1.8/fon2100.patch
diff --git a/target/linux/patches/3.1.5/gemalto.patch b/target/linux/patches/3.1.8/gemalto.patch
index f3c223b5e..f3c223b5e 100644
--- a/target/linux/patches/3.1.5/gemalto.patch
+++ b/target/linux/patches/3.1.8/gemalto.patch
diff --git a/target/linux/patches/3.1.5/mmc-host.patch b/target/linux/patches/3.1.8/mmc-host.patch
index 3d0e37add..3d0e37add 100644
--- a/target/linux/patches/3.1.5/mmc-host.patch
+++ b/target/linux/patches/3.1.8/mmc-host.patch
diff --git a/target/linux/patches/3.1.5/non-static.patch b/target/linux/patches/3.1.8/non-static.patch
index a967703d0..a967703d0 100644
--- a/target/linux/patches/3.1.5/non-static.patch
+++ b/target/linux/patches/3.1.8/non-static.patch
diff --git a/target/linux/patches/3.1.5/sparc-include.patch b/target/linux/patches/3.1.8/sparc-include.patch
index 2f8ffd061..2f8ffd061 100644
--- a/target/linux/patches/3.1.5/sparc-include.patch
+++ b/target/linux/patches/3.1.8/sparc-include.patch
diff --git a/target/linux/patches/3.1.5/startup.patch b/target/linux/patches/3.1.8/startup.patch
index 68e8987b0..68e8987b0 100644
--- a/target/linux/patches/3.1.5/startup.patch
+++ b/target/linux/patches/3.1.8/startup.patch
diff --git a/target/linux/patches/3.1.5/usb-defaults-off.patch b/target/linux/patches/3.1.8/usb-defaults-off.patch
index 31367108a..31367108a 100644
--- a/target/linux/patches/3.1.5/usb-defaults-off.patch
+++ b/target/linux/patches/3.1.8/usb-defaults-off.patch
diff --git a/target/linux/patches/3.1.5/uuid.patch b/target/linux/patches/3.1.8/uuid.patch
index 2529fdab5..2529fdab5 100644
--- a/target/linux/patches/3.1.5/uuid.patch
+++ b/target/linux/patches/3.1.8/uuid.patch
diff --git a/target/linux/patches/3.1.5/vga-cons-default-off.patch b/target/linux/patches/3.1.8/vga-cons-default-off.patch
index 178aeeeb9..178aeeeb9 100644
--- a/target/linux/patches/3.1.5/vga-cons-default-off.patch
+++ b/target/linux/patches/3.1.8/vga-cons-default-off.patch
diff --git a/target/linux/patches/3.1.5/wlan-cf.patch b/target/linux/patches/3.1.8/wlan-cf.patch
index fc20759e2..fc20759e2 100644
--- a/target/linux/patches/3.1.5/wlan-cf.patch
+++ b/target/linux/patches/3.1.8/wlan-cf.patch
diff --git a/target/linux/patches/3.1.5/x86-build.patch b/target/linux/patches/3.1.8/x86-build.patch
index 339140f41..339140f41 100644
--- a/target/linux/patches/3.1.5/x86-build.patch
+++ b/target/linux/patches/3.1.8/x86-build.patch
diff --git a/target/linux/patches/3.1.5/zlib-inflate.patch b/target/linux/patches/3.1.8/zlib-inflate.patch
index 58e1f6d21..58e1f6d21 100644
--- a/target/linux/patches/3.1.5/zlib-inflate.patch
+++ b/target/linux/patches/3.1.8/zlib-inflate.patch
diff --git a/target/mips/Makefile b/target/mips/Makefile
index 507cfaae2..215bb8e01 100644
--- a/target/mips/Makefile
+++ b/target/mips/Makefile
@@ -22,20 +22,26 @@ tools-compile:
$(MAKE) -C ../tools/addpattern all
$(MAKE) -C ../tools/srec2bin all
$(MAKE) -C ../tools/squashfs all
+ $(MAKE) -C ../tools/lzma all
+ $(MAKE) -C ../tools/lzma-loader all
ifeq ($(ADK_TARGET_SYSTEM_BROADCOM_BCM47XX),y)
kernel-install: tools-compile
- ${TARGET_CROSS}objcopy ${OSTRIP} -S ${LINUX_DIR}/vmlinuz.elf \
+ ${TARGET_CROSS}objcopy ${OSTRIP} -S ${LINUX_DIR}/vmlinux \
${BUILD_DIR}/${TARGET_KERNEL}
+ cat $(LINUX_DIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(LINUX_DIR)/vmlinux.lzma
${BUILD_DIR}/${ROOTFSSQUASHFS}: ${BUILD_DIR}/root.squashfs
- ${TARGET_CROSS}objcopy -O binary ${BUILD_DIR}/${TARGET_KERNEL} \
- ${BUILD_DIR}/${TARGET_KERNEL}.bin
- gzip -n9 <${BUILD_DIR}/${TARGET_KERNEL}.bin \
- >${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
- printf '\0' >>${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
- PATH='${TARGET_PATH}' trx -o $@~ -f ${BUILD_DIR}/${TARGET_KERNEL}.bin.gz -a 1024 -f ${BUILD_DIR}/root.squashfs
+ cp $(TOPDIR)/target/tools/lzma-loader/src/loader.gz \
+ $(LINUX_DIR)/loader.gz
+ printf '\0' >>$(LINUX_DIR)/loader.gz
+ PATH='${TARGET_PATH}' trx -o $@~ -f $(LINUX_DIR)/loader.gz \
+ -f $(LINUX_DIR)/vmlinux.lzma -a 1024 -f ${BUILD_DIR}/root.squashfs
+ifneq ($(ADK_TARGET_BROADCOM_MODEL_ASUS_WL500GP),y)
PATH='${TARGET_PATH}' addpattern -4 ${ADK_TOOLS_ADDPATTERN_ARGS} -g -i $@~ -o $@
+else
+ cp $@~ $@
+endif
endif
ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_AG241),y)
@@ -160,12 +166,12 @@ imageinstall: kernel-install ${BUILD_DIR}/${ROOTFSSQUASHFS}
echo The image file is $(ROOTFSSQUASHFS); \
fi
ifeq ($(ADK_TARGET_SYSTEM_FON_FON2100),y)
- echo The kernel file is $(TARGET_KERNEL)
+ @echo The kernel file is $(TARGET_KERNEL)
endif
ifeq ($(ADK_TARGET_SYSTEM_BROADCOM_BCM47XX),y)
- echo 'You can flash the image via tftp:'
- echo 'tftp 192.168.1.1'
- echo 'tftp> binary'
- echo "tftp> put $(ROOTFSSQUASHFS) upgrade_code.bin"
+ @echo 'You can flash the image via tftp:'
+ @echo 'tftp 192.168.1.1'
+ @echo 'tftp> binary'
+ @echo "tftp> put $(ROOTFSSQUASHFS) upgrade_code.bin"
endif
endif
diff --git a/target/tools/lzma-loader/.svn/entries b/target/tools/lzma-loader/.svn/entries
new file mode 100644
index 000000000..2934ab892
--- /dev/null
+++ b/target/tools/lzma-loader/.svn/entries
@@ -0,0 +1,300 @@
+10
+
+dir
+29646
+svn://svn.openwrt.org/openwrt/trunk/target/linux/brcm47xx/image/lzma-loader/src
+svn://svn.openwrt.org/openwrt
+
+
+
+2010-12-02T21:27:54.805904Z
+24217
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3c298f89-4303-0410-b956-a3cf2f4a3e73
+
+head.S
+file
+
+
+
+
+2011-11-10T10:12:04.000000Z
+566bfb5f462e85d45d1d0c4faca0dadd
+2010-06-26T20:41:49.877730Z
+21945
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3585
+
+decompress.c
+file
+
+
+
+
+2011-11-10T10:12:04.000000Z
+b9ae9d76bf7f1f35ce46b5e496a02aa1
+2010-12-02T21:27:54.805904Z
+24217
+hauke
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5426
+
+LzmaDecode.c
+file
+
+
+
+
+2011-11-10T10:12:04.000000Z
+14403972ddbcfadbe017a6aeb3e8fae1
+2010-06-26T20:41:49.877730Z
+21945
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17104
+
+decompress.lds.in
+file
+
+
+
+
+2011-11-10T10:12:04.000000Z
+c80cc6ad34b26e0af3c1d764218a3a61
+2010-06-26T20:41:49.877730Z
+21945
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+186
+
+loader.lds.in
+file
+
+
+
+
+2011-11-10T10:12:04.000000Z
+f06b23d31242fb56a60b864b741c1266
+2010-06-26T20:41:49.877730Z
+21945
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+151
+
+LzmaDecode.h
+file
+
+
+
+
+2011-11-10T10:12:04.000000Z
+12fcb710de789e54587079c021ae5e33
+2010-06-26T20:41:49.877730Z
+21945
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2465
+
+Makefile
+file
+
+
+
+
+2011-11-10T10:12:04.000000Z
+61400e27cb7c0099046d83e2146e0053
+2010-06-26T20:41:49.877730Z
+21945
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2325
+
+README
+file
+
+
+
+
+2011-11-10T10:12:04.000000Z
+b29e81088cc18e92dede243f094c4134
+2010-06-26T20:41:49.877730Z
+21945
+nbd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2464
+
diff --git a/target/tools/lzma-loader/.svn/text-base/LzmaDecode.c.svn-base b/target/tools/lzma-loader/.svn/text-base/LzmaDecode.c.svn-base
new file mode 100644
index 000000000..951700bdd
--- /dev/null
+++ b/target/tools/lzma-loader/.svn/text-base/LzmaDecode.c.svn-base
@@ -0,0 +1,663 @@
+/*
+ LzmaDecode.c
+ LZMA Decoder
+
+ LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25)
+ http://www.7-zip.org/
+
+ LZMA SDK is licensed under two licenses:
+ 1) GNU Lesser General Public License (GNU LGPL)
+ 2) Common Public License (CPL)
+ It means that you can select one of these two licenses and
+ follow rules of that license.
+
+ SPECIAL EXCEPTION:
+ Igor Pavlov, as the author of this code, expressly permits you to
+ statically or dynamically link your code (or bind by name) to the
+ interfaces of this file without subjecting your linked code to the
+ terms of the CPL or GNU LGPL. Any modifications or additions
+ to this file, however, are subject to the LGPL or CPL terms.
+*/
+
+#include "LzmaDecode.h"
+
+#ifndef Byte
+#define Byte unsigned char
+#endif
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+
+typedef struct _CRangeDecoder
+{
+ Byte *Buffer;
+ Byte *BufferLim;
+ UInt32 Range;
+ UInt32 Code;
+ #ifdef _LZMA_IN_CB
+ ILzmaInCallback *InCallback;
+ int Result;
+ #endif
+ int ExtraBytes;
+} CRangeDecoder;
+
+Byte RangeDecoderReadByte(CRangeDecoder *rd)
+{
+ if (rd->Buffer == rd->BufferLim)
+ {
+ #ifdef _LZMA_IN_CB
+ UInt32 size;
+ rd->Result = rd->InCallback->Read(rd->InCallback, &rd->Buffer, &size);
+ rd->BufferLim = rd->Buffer + size;
+ if (size == 0)
+ #endif
+ {
+ rd->ExtraBytes = 1;
+ return 0xFF;
+ }
+ }
+ return (*rd->Buffer++);
+}
+
+/* #define ReadByte (*rd->Buffer++) */
+#define ReadByte (RangeDecoderReadByte(rd))
+
+void RangeDecoderInit(CRangeDecoder *rd,
+ #ifdef _LZMA_IN_CB
+ ILzmaInCallback *inCallback
+ #else
+ Byte *stream, UInt32 bufferSize
+ #endif
+ )
+{
+ int i;
+ #ifdef _LZMA_IN_CB
+ rd->InCallback = inCallback;
+ rd->Buffer = rd->BufferLim = 0;
+ #else
+ rd->Buffer = stream;
+ rd->BufferLim = stream + bufferSize;
+ #endif
+ rd->ExtraBytes = 0;
+ rd->Code = 0;
+ rd->Range = (0xFFFFFFFF);
+ for(i = 0; i < 5; i++)
+ rd->Code = (rd->Code << 8) | ReadByte;
+}
+
+#define RC_INIT_VAR UInt32 range = rd->Range; UInt32 code = rd->Code;
+#define RC_FLUSH_VAR rd->Range = range; rd->Code = code;
+#define RC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | ReadByte; }
+
+UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits)
+{
+ RC_INIT_VAR
+ UInt32 result = 0;
+ int i;
+ for (i = numTotalBits; i > 0; i--)
+ {
+ /* UInt32 t; */
+ range >>= 1;
+
+ result <<= 1;
+ if (code >= range)
+ {
+ code -= range;
+ result |= 1;
+ }
+ /*
+ t = (code - range) >> 31;
+ t &= 1;
+ code -= range & (t - 1);
+ result = (result + result) | (1 - t);
+ */
+ RC_NORMALIZE
+ }
+ RC_FLUSH_VAR
+ return result;
+}
+
+int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd)
+{
+ UInt32 bound = (rd->Range >> kNumBitModelTotalBits) * *prob;
+ if (rd->Code < bound)
+ {
+ rd->Range = bound;
+ *prob += (kBitModelTotal - *prob) >> kNumMoveBits;
+ if (rd->Range < kTopValue)
+ {
+ rd->Code = (rd->Code << 8) | ReadByte;
+ rd->Range <<= 8;
+ }
+ return 0;
+ }
+ else
+ {
+ rd->Range -= bound;
+ rd->Code -= bound;
+ *prob -= (*prob) >> kNumMoveBits;
+ if (rd->Range < kTopValue)
+ {
+ rd->Code = (rd->Code << 8) | ReadByte;
+ rd->Range <<= 8;
+ }
+ return 1;
+ }
+}
+
+#define RC_GET_BIT2(prob, mi, A0, A1) \
+ UInt32 bound = (range >> kNumBitModelTotalBits) * *prob; \
+ if (code < bound) \
+ { A0; range = bound; *prob += (kBitModelTotal - *prob) >> kNumMoveBits; mi <<= 1; } \
+ else \
+ { A1; range -= bound; code -= bound; *prob -= (*prob) >> kNumMoveBits; mi = (mi + mi) + 1; } \
+ RC_NORMALIZE
+
+#define RC_GET_BIT(prob, mi) RC_GET_BIT2(prob, mi, ; , ;)
+
+int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
+{
+ int mi = 1;
+ int i;
+ #ifdef _LZMA_LOC_OPT
+ RC_INIT_VAR
+ #endif
+ for(i = numLevels; i > 0; i--)
+ {
+ #ifdef _LZMA_LOC_OPT
+ CProb *prob = probs + mi;
+ RC_GET_BIT(prob, mi)
+ #else
+ mi = (mi + mi) + RangeDecoderBitDecode(probs + mi, rd);
+ #endif
+ }
+ #ifdef _LZMA_LOC_OPT
+ RC_FLUSH_VAR
+ #endif
+ return mi - (1 << numLevels);
+}
+
+int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
+{
+ int mi = 1;
+ int i;
+ int symbol = 0;
+ #ifdef _LZMA_LOC_OPT
+ RC_INIT_VAR
+ #endif
+ for(i = 0; i < numLevels; i++)
+ {
+ #ifdef _LZMA_LOC_OPT
+ CProb *prob = probs + mi;
+ RC_GET_BIT2(prob, mi, ; , symbol |= (1 << i))
+ #else
+ int bit = RangeDecoderBitDecode(probs + mi, rd);
+ mi = mi + mi + bit;
+ symbol |= (bit << i);
+ #endif