allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / scripts / squashfs / lzma / C / 7zip / Compress / Branch / BranchPPC.c
blob407bae6112b8004230b09b8fef16ccaa73fc026c
1 // BranchPPC.c
3 #include "BranchPPC.h"
5 UInt32 PPC_B_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
7 UInt32 i;
8 for (i = 0; i + 4 <= size; i += 4)
10 // PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link)
11 if ((data[i] >> 2) == 0x12 &&
13 (data[i + 3] & 3) == 1
14 // || (data[i+3] & 3) == 3
18 UInt32 src = ((data[i + 0] & 3) << 24) |
19 (data[i + 1] << 16) |
20 (data[i + 2] << 8) |
21 (data[i + 3] & (~3));
23 UInt32 dest;
24 if (encoding)
25 dest = nowPos + i + src;
26 else
27 dest = src - (nowPos + i);
28 data[i + 0] = 0x48 | ((dest >> 24) & 0x3);
29 data[i + 1] = (dest >> 16);
30 data[i + 2] = (dest >> 8);
31 data[i + 3] &= 0x3;
32 data[i + 3] |= dest;
35 return i;