Merge pull request #25 from SergioMartin86/refactoring
Using common set of tools
This commit is contained in:
commit
d1cc638517
|
@ -1,3 +1,6 @@
|
|||
[submodule "source/quickNES/QuickNES_Core"]
|
||||
path = source/quickNES/core
|
||||
url = https://github.com/SergioMartin86/QuickNES_Core.git
|
||||
[submodule "source/jaffarCommon"]
|
||||
path = extern/jaffarCommon
|
||||
url = https://github.com/SergioMartin86/jaffarCommon.git
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
|||
Subproject commit f15d231ead67f064ff6dc3b1aad07b20da088dab
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2013-2021 Niels Lohmann
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,413 +0,0 @@
|
|||
// metrohash128.cpp
|
||||
//
|
||||
// Copyright 2015-2018 J. Andrew Rogers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "platform.h"
|
||||
#include "metrohash128.h"
|
||||
|
||||
const char * MetroHash128::test_string = "012345678901234567890123456789012345678901234567890123456789012";
|
||||
|
||||
const uint8_t MetroHash128::test_seed_0[16] = {
|
||||
0xC7, 0x7C, 0xE2, 0xBF, 0xA4, 0xED, 0x9F, 0x9B,
|
||||
0x05, 0x48, 0xB2, 0xAC, 0x50, 0x74, 0xA2, 0x97
|
||||
};
|
||||
|
||||
const uint8_t MetroHash128::test_seed_1[16] = {
|
||||
0x45, 0xA3, 0xCD, 0xB8, 0x38, 0x19, 0x9D, 0x7F,
|
||||
0xBD, 0xD6, 0x8D, 0x86, 0x7A, 0x14, 0xEC, 0xEF
|
||||
};
|
||||
|
||||
|
||||
|
||||
MetroHash128::MetroHash128(const uint64_t seed)
|
||||
{
|
||||
Initialize(seed);
|
||||
}
|
||||
|
||||
|
||||
void MetroHash128::Initialize(const uint64_t seed)
|
||||
{
|
||||
// initialize internal hash registers
|
||||
state.v[0] = (static_cast<uint64_t>(seed) - k0) * k3;
|
||||
state.v[1] = (static_cast<uint64_t>(seed) + k1) * k2;
|
||||
state.v[2] = (static_cast<uint64_t>(seed) + k0) * k2;
|
||||
state.v[3] = (static_cast<uint64_t>(seed) - k1) * k3;
|
||||
|
||||
// initialize total length of input
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
|
||||
void MetroHash128::Update(const uint8_t * const buffer, const uint64_t length)
|
||||
{
|
||||
const uint8_t * ptr = reinterpret_cast<const uint8_t*>(buffer);
|
||||
const uint8_t * const end = ptr + length;
|
||||
|
||||
// input buffer may be partially filled
|
||||
if (bytes % 32)
|
||||
{
|
||||
uint64_t fill = 32 - (bytes % 32);
|
||||
if (fill > length)
|
||||
fill = length;
|
||||
|
||||
memcpy(input.b + (bytes % 32), ptr, static_cast<size_t>(fill));
|
||||
ptr += fill;
|
||||
bytes += fill;
|
||||
|
||||
// input buffer is still partially filled
|
||||
if ((bytes % 32) != 0) return;
|
||||
|
||||
// process full input buffer
|
||||
state.v[0] += read_u64(&input.b[ 0]) * k0; state.v[0] = rotate_right(state.v[0],29) + state.v[2];
|
||||
state.v[1] += read_u64(&input.b[ 8]) * k1; state.v[1] = rotate_right(state.v[1],29) + state.v[3];
|
||||
state.v[2] += read_u64(&input.b[16]) * k2; state.v[2] = rotate_right(state.v[2],29) + state.v[0];
|
||||
state.v[3] += read_u64(&input.b[24]) * k3; state.v[3] = rotate_right(state.v[3],29) + state.v[1];
|
||||
}
|
||||
|
||||
// bulk update
|
||||
bytes += (end - ptr);
|
||||
while (ptr <= (end - 32))
|
||||
{
|
||||
// process directly from the source, bypassing the input buffer
|
||||
state.v[0] += read_u64(ptr) * k0; ptr += 8; state.v[0] = rotate_right(state.v[0],29) + state.v[2];
|
||||
state.v[1] += read_u64(ptr) * k1; ptr += 8; state.v[1] = rotate_right(state.v[1],29) + state.v[3];
|
||||
state.v[2] += read_u64(ptr) * k2; ptr += 8; state.v[2] = rotate_right(state.v[2],29) + state.v[0];
|
||||
state.v[3] += read_u64(ptr) * k3; ptr += 8; state.v[3] = rotate_right(state.v[3],29) + state.v[1];
|
||||
}
|
||||
|
||||
// store remaining bytes in input buffer
|
||||
if (ptr < end)
|
||||
memcpy(input.b, ptr, end - ptr);
|
||||
}
|
||||
|
||||
|
||||
void MetroHash128::Finalize(uint8_t * const hash)
|
||||
{
|
||||
// finalize bulk loop, if used
|
||||
if (bytes >= 32)
|
||||
{
|
||||
state.v[2] ^= rotate_right(((state.v[0] + state.v[3]) * k0) + state.v[1], 21) * k1;
|
||||
state.v[3] ^= rotate_right(((state.v[1] + state.v[2]) * k1) + state.v[0], 21) * k0;
|
||||
state.v[0] ^= rotate_right(((state.v[0] + state.v[2]) * k0) + state.v[3], 21) * k1;
|
||||
state.v[1] ^= rotate_right(((state.v[1] + state.v[3]) * k1) + state.v[2], 21) * k0;
|
||||
}
|
||||
|
||||
// process any bytes remaining in the input buffer
|
||||
const uint8_t * ptr = reinterpret_cast<const uint8_t*>(input.b);
|
||||
const uint8_t * const end = ptr + (bytes % 32);
|
||||
|
||||
if ((end - ptr) >= 16)
|
||||
{
|
||||
state.v[0] += read_u64(ptr) * k2; ptr += 8; state.v[0] = rotate_right(state.v[0],33) * k3;
|
||||
state.v[1] += read_u64(ptr) * k2; ptr += 8; state.v[1] = rotate_right(state.v[1],33) * k3;
|
||||
state.v[0] ^= rotate_right((state.v[0] * k2) + state.v[1], 45) * k1;
|
||||
state.v[1] ^= rotate_right((state.v[1] * k3) + state.v[0], 45) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 8)
|
||||
{
|
||||
state.v[0] += read_u64(ptr) * k2; ptr += 8; state.v[0] = rotate_right(state.v[0],33) * k3;
|
||||
state.v[0] ^= rotate_right((state.v[0] * k2) + state.v[1], 27) * k1;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 4)
|
||||
{
|
||||
state.v[1] += read_u32(ptr) * k2; ptr += 4; state.v[1] = rotate_right(state.v[1],33) * k3;
|
||||
state.v[1] ^= rotate_right((state.v[1] * k3) + state.v[0], 46) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 2)
|
||||
{
|
||||
state.v[0] += read_u16(ptr) * k2; ptr += 2; state.v[0] = rotate_right(state.v[0],33) * k3;
|
||||
state.v[0] ^= rotate_right((state.v[0] * k2) + state.v[1], 22) * k1;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 1)
|
||||
{
|
||||
state.v[1] += read_u8 (ptr) * k2; state.v[1] = rotate_right(state.v[1],33) * k3;
|
||||
state.v[1] ^= rotate_right((state.v[1] * k3) + state.v[0], 58) * k0;
|
||||
}
|
||||
|
||||
state.v[0] += rotate_right((state.v[0] * k0) + state.v[1], 13);
|
||||
state.v[1] += rotate_right((state.v[1] * k1) + state.v[0], 37);
|
||||
state.v[0] += rotate_right((state.v[0] * k2) + state.v[1], 13);
|
||||
state.v[1] += rotate_right((state.v[1] * k3) + state.v[0], 37);
|
||||
|
||||
bytes = 0;
|
||||
|
||||
// do any endian conversion here
|
||||
|
||||
memcpy(hash, state.v, 16);
|
||||
}
|
||||
|
||||
|
||||
void MetroHash128::Hash(const uint8_t * buffer, const uint64_t length, uint8_t * const hash, const uint64_t seed)
|
||||
{
|
||||
const uint8_t * ptr = reinterpret_cast<const uint8_t*>(buffer);
|
||||
const uint8_t * const end = ptr + length;
|
||||
|
||||
uint64_t v[4];
|
||||
|
||||
v[0] = (static_cast<uint64_t>(seed) - k0) * k3;
|
||||
v[1] = (static_cast<uint64_t>(seed) + k1) * k2;
|
||||
|
||||
if (length >= 32)
|
||||
{
|
||||
v[2] = (static_cast<uint64_t>(seed) + k0) * k2;
|
||||
v[3] = (static_cast<uint64_t>(seed) - k1) * k3;
|
||||
|
||||
do
|
||||
{
|
||||
v[0] += read_u64(ptr) * k0; ptr += 8; v[0] = rotate_right(v[0],29) + v[2];
|
||||
v[1] += read_u64(ptr) * k1; ptr += 8; v[1] = rotate_right(v[1],29) + v[3];
|
||||
v[2] += read_u64(ptr) * k2; ptr += 8; v[2] = rotate_right(v[2],29) + v[0];
|
||||
v[3] += read_u64(ptr) * k3; ptr += 8; v[3] = rotate_right(v[3],29) + v[1];
|
||||
}
|
||||
while (ptr <= (end - 32));
|
||||
|
||||
v[2] ^= rotate_right(((v[0] + v[3]) * k0) + v[1], 21) * k1;
|
||||
v[3] ^= rotate_right(((v[1] + v[2]) * k1) + v[0], 21) * k0;
|
||||
v[0] ^= rotate_right(((v[0] + v[2]) * k0) + v[3], 21) * k1;
|
||||
v[1] ^= rotate_right(((v[1] + v[3]) * k1) + v[2], 21) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 16)
|
||||
{
|
||||
v[0] += read_u64(ptr) * k2; ptr += 8; v[0] = rotate_right(v[0],33) * k3;
|
||||
v[1] += read_u64(ptr) * k2; ptr += 8; v[1] = rotate_right(v[1],33) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 45) * k1;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 45) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 8)
|
||||
{
|
||||
v[0] += read_u64(ptr) * k2; ptr += 8; v[0] = rotate_right(v[0],33) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 27) * k1;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 4)
|
||||
{
|
||||
v[1] += read_u32(ptr) * k2; ptr += 4; v[1] = rotate_right(v[1],33) * k3;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 46) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 2)
|
||||
{
|
||||
v[0] += read_u16(ptr) * k2; ptr += 2; v[0] = rotate_right(v[0],33) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 22) * k1;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 1)
|
||||
{
|
||||
v[1] += read_u8 (ptr) * k2; v[1] = rotate_right(v[1],33) * k3;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 58) * k0;
|
||||
}
|
||||
|
||||
v[0] += rotate_right((v[0] * k0) + v[1], 13);
|
||||
v[1] += rotate_right((v[1] * k1) + v[0], 37);
|
||||
v[0] += rotate_right((v[0] * k2) + v[1], 13);
|
||||
v[1] += rotate_right((v[1] * k3) + v[0], 37);
|
||||
|
||||
// do any endian conversion here
|
||||
|
||||
memcpy(hash, v, 16);
|
||||
}
|
||||
|
||||
|
||||
bool MetroHash128::ImplementationVerified()
|
||||
{
|
||||
uint8_t hash[16];
|
||||
const uint8_t * key = reinterpret_cast<const uint8_t *>(MetroHash128::test_string);
|
||||
|
||||
// verify one-shot implementation
|
||||
MetroHash128::Hash(key, strlen(MetroHash128::test_string), hash, 0);
|
||||
if (memcmp(hash, MetroHash128::test_seed_0, 16) != 0) return false;
|
||||
|
||||
MetroHash128::Hash(key, strlen(MetroHash128::test_string), hash, 1);
|
||||
if (memcmp(hash, MetroHash128::test_seed_1, 16) != 0) return false;
|
||||
|
||||
// verify incremental implementation
|
||||
MetroHash128 metro;
|
||||
|
||||
metro.Initialize(0);
|
||||
metro.Update(reinterpret_cast<const uint8_t *>(MetroHash128::test_string), strlen(MetroHash128::test_string));
|
||||
metro.Finalize(hash);
|
||||
if (memcmp(hash, MetroHash128::test_seed_0, 16) != 0) return false;
|
||||
|
||||
metro.Initialize(1);
|
||||
metro.Update(reinterpret_cast<const uint8_t *>(MetroHash128::test_string), strlen(MetroHash128::test_string));
|
||||
metro.Finalize(hash);
|
||||
if (memcmp(hash, MetroHash128::test_seed_1, 16) != 0) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void metrohash128_1(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * out)
|
||||
{
|
||||
static const uint64_t k0 = 0xC83A91E1;
|
||||
static const uint64_t k1 = 0x8648DBDB;
|
||||
static const uint64_t k2 = 0x7BDEC03B;
|
||||
static const uint64_t k3 = 0x2F5870A5;
|
||||
|
||||
const uint8_t * ptr = reinterpret_cast<const uint8_t*>(key);
|
||||
const uint8_t * const end = ptr + len;
|
||||
|
||||
uint64_t v[4];
|
||||
|
||||
v[0] = ((static_cast<uint64_t>(seed) - k0) * k3) + len;
|
||||
v[1] = ((static_cast<uint64_t>(seed) + k1) * k2) + len;
|
||||
|
||||
if (len >= 32)
|
||||
{
|
||||
v[2] = ((static_cast<uint64_t>(seed) + k0) * k2) + len;
|
||||
v[3] = ((static_cast<uint64_t>(seed) - k1) * k3) + len;
|
||||
|
||||
do
|
||||
{
|
||||
v[0] += read_u64(ptr) * k0; ptr += 8; v[0] = rotate_right(v[0],29) + v[2];
|
||||
v[1] += read_u64(ptr) * k1; ptr += 8; v[1] = rotate_right(v[1],29) + v[3];
|
||||
v[2] += read_u64(ptr) * k2; ptr += 8; v[2] = rotate_right(v[2],29) + v[0];
|
||||
v[3] += read_u64(ptr) * k3; ptr += 8; v[3] = rotate_right(v[3],29) + v[1];
|
||||
}
|
||||
while (ptr <= (end - 32));
|
||||
|
||||
v[2] ^= rotate_right(((v[0] + v[3]) * k0) + v[1], 26) * k1;
|
||||
v[3] ^= rotate_right(((v[1] + v[2]) * k1) + v[0], 26) * k0;
|
||||
v[0] ^= rotate_right(((v[0] + v[2]) * k0) + v[3], 26) * k1;
|
||||
v[1] ^= rotate_right(((v[1] + v[3]) * k1) + v[2], 30) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 16)
|
||||
{
|
||||
v[0] += read_u64(ptr) * k2; ptr += 8; v[0] = rotate_right(v[0],33) * k3;
|
||||
v[1] += read_u64(ptr) * k2; ptr += 8; v[1] = rotate_right(v[1],33) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 17) * k1;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 17) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 8)
|
||||
{
|
||||
v[0] += read_u64(ptr) * k2; ptr += 8; v[0] = rotate_right(v[0],33) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 20) * k1;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 4)
|
||||
{
|
||||
v[1] += read_u32(ptr) * k2; ptr += 4; v[1] = rotate_right(v[1],33) * k3;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 18) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 2)
|
||||
{
|
||||
v[0] += read_u16(ptr) * k2; ptr += 2; v[0] = rotate_right(v[0],33) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 24) * k1;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 1)
|
||||
{
|
||||
v[1] += read_u8 (ptr) * k2; v[1] = rotate_right(v[1],33) * k3;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 24) * k0;
|
||||
}
|
||||
|
||||
v[0] += rotate_right((v[0] * k0) + v[1], 13);
|
||||
v[1] += rotate_right((v[1] * k1) + v[0], 37);
|
||||
v[0] += rotate_right((v[0] * k2) + v[1], 13);
|
||||
v[1] += rotate_right((v[1] * k3) + v[0], 37);
|
||||
|
||||
// do any endian conversion here
|
||||
|
||||
memcpy(out, v, 16);
|
||||
}
|
||||
|
||||
|
||||
void metrohash128_2(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * out)
|
||||
{
|
||||
static const uint64_t k0 = 0xD6D018F5;
|
||||
static const uint64_t k1 = 0xA2AA033B;
|
||||
static const uint64_t k2 = 0x62992FC1;
|
||||
static const uint64_t k3 = 0x30BC5B29;
|
||||
|
||||
const uint8_t * ptr = reinterpret_cast<const uint8_t*>(key);
|
||||
const uint8_t * const end = ptr + len;
|
||||
|
||||
uint64_t v[4];
|
||||
|
||||
v[0] = ((static_cast<uint64_t>(seed) - k0) * k3) + len;
|
||||
v[1] = ((static_cast<uint64_t>(seed) + k1) * k2) + len;
|
||||
|
||||
if (len >= 32)
|
||||
{
|
||||
v[2] = ((static_cast<uint64_t>(seed) + k0) * k2) + len;
|
||||
v[3] = ((static_cast<uint64_t>(seed) - k1) * k3) + len;
|
||||
|
||||
do
|
||||
{
|
||||
v[0] += read_u64(ptr) * k0; ptr += 8; v[0] = rotate_right(v[0],29) + v[2];
|
||||
v[1] += read_u64(ptr) * k1; ptr += 8; v[1] = rotate_right(v[1],29) + v[3];
|
||||
v[2] += read_u64(ptr) * k2; ptr += 8; v[2] = rotate_right(v[2],29) + v[0];
|
||||
v[3] += read_u64(ptr) * k3; ptr += 8; v[3] = rotate_right(v[3],29) + v[1];
|
||||
}
|
||||
while (ptr <= (end - 32));
|
||||
|
||||
v[2] ^= rotate_right(((v[0] + v[3]) * k0) + v[1], 33) * k1;
|
||||
v[3] ^= rotate_right(((v[1] + v[2]) * k1) + v[0], 33) * k0;
|
||||
v[0] ^= rotate_right(((v[0] + v[2]) * k0) + v[3], 33) * k1;
|
||||
v[1] ^= rotate_right(((v[1] + v[3]) * k1) + v[2], 33) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 16)
|
||||
{
|
||||
v[0] += read_u64(ptr) * k2; ptr += 8; v[0] = rotate_right(v[0],29) * k3;
|
||||
v[1] += read_u64(ptr) * k2; ptr += 8; v[1] = rotate_right(v[1],29) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 29) * k1;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 29) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 8)
|
||||
{
|
||||
v[0] += read_u64(ptr) * k2; ptr += 8; v[0] = rotate_right(v[0],29) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 29) * k1;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 4)
|
||||
{
|
||||
v[1] += read_u32(ptr) * k2; ptr += 4; v[1] = rotate_right(v[1],29) * k3;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 25) * k0;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 2)
|
||||
{
|
||||
v[0] += read_u16(ptr) * k2; ptr += 2; v[0] = rotate_right(v[0],29) * k3;
|
||||
v[0] ^= rotate_right((v[0] * k2) + v[1], 30) * k1;
|
||||
}
|
||||
|
||||
if ((end - ptr) >= 1)
|
||||
{
|
||||
v[1] += read_u8 (ptr) * k2; v[1] = rotate_right(v[1],29) * k3;
|
||||
v[1] ^= rotate_right((v[1] * k3) + v[0], 18) * k0;
|
||||
}
|
||||
|
||||
v[0] += rotate_right((v[0] * k0) + v[1], 33);
|
||||
v[1] += rotate_right((v[1] * k1) + v[0], 33);
|
||||
v[0] += rotate_right((v[0] * k2) + v[1], 33);
|
||||
v[1] += rotate_right((v[1] * k3) + v[0], 33);
|
||||
|
||||
// do any endian conversion here
|
||||
|
||||
memcpy(out, v, 16);
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
// metrohash128.h
|
||||
//
|
||||
// Copyright 2015-2018 J. Andrew Rogers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef METROHASH_METROHASH_128_H
|
||||
#define METROHASH_METROHASH_128_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <utility>
|
||||
|
||||
typedef std::pair<uint64_t, uint64_t> _uint128_t;
|
||||
|
||||
class MetroHash128
|
||||
{
|
||||
public:
|
||||
static const uint32_t bits = 128;
|
||||
|
||||
// Constructor initializes the same as Initialize()
|
||||
MetroHash128(const uint64_t seed=0);
|
||||
|
||||
// Initializes internal state for new hash with optional seed
|
||||
void Initialize(const uint64_t seed=0);
|
||||
|
||||
// Update the hash state with a string of bytes. If the length
|
||||
// is sufficiently long, the implementation switches to a bulk
|
||||
// hashing algorithm directly on the argument buffer for speed.
|
||||
void Update(const void* buffer, const uint64_t length) {
|
||||
Update(reinterpret_cast<const uint8_t*>(buffer), length);
|
||||
}
|
||||
void Update(const uint8_t* buffer, const uint64_t length);
|
||||
template <class T>
|
||||
void Update(const T& x) {
|
||||
Update(&x, sizeof(x));
|
||||
}
|
||||
|
||||
// Constructs the final hash and writes it to the argument buffer.
|
||||
// After a hash is finalized, this instance must be Initialized()-ed
|
||||
// again or the behavior of Update() and Finalize() is undefined.
|
||||
void Finalize(uint8_t * const hash);
|
||||
|
||||
// A non-incremental function implementation. This can be significantly
|
||||
// faster than the incremental implementation for some usage patterns.
|
||||
static void Hash(const uint8_t * buffer, const uint64_t length, uint8_t * const hash, const uint64_t seed=0);
|
||||
|
||||
// Does implementation correctly execute test vectors?
|
||||
static bool ImplementationVerified();
|
||||
|
||||
// test vectors -- Hash(test_string, seed=0) => test_seed_0
|
||||
static const char * test_string;
|
||||
static const uint8_t test_seed_0[16];
|
||||
static const uint8_t test_seed_1[16];
|
||||
|
||||
private:
|
||||
static const uint64_t k0 = 0xC83A91E1;
|
||||
static const uint64_t k1 = 0x8648DBDB;
|
||||
static const uint64_t k2 = 0x7BDEC03B;
|
||||
static const uint64_t k3 = 0x2F5870A5;
|
||||
|
||||
struct { uint64_t v[4]; } state;
|
||||
struct { uint8_t b[32]; } input;
|
||||
uint64_t bytes;
|
||||
};
|
||||
|
||||
|
||||
// Legacy 128-bit hash functions -- do not use
|
||||
void metrohash128_1(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * out);
|
||||
void metrohash128_2(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * out);
|
||||
|
||||
|
||||
#endif // #ifndef METROHASH_METROHASH_128_H
|
|
@ -1,50 +0,0 @@
|
|||
// platform.h
|
||||
//
|
||||
// Copyright 2015-2018 J. Andrew Rogers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef METROHASH_PLATFORM_H
|
||||
#define METROHASH_PLATFORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// rotate right idiom recognized by most compilers
|
||||
inline static uint64_t rotate_right(uint64_t v, unsigned k)
|
||||
{
|
||||
return (v >> k) | (v << (64 - k));
|
||||
}
|
||||
|
||||
// unaligned reads, fast and safe on Nehalem and later microarchitectures
|
||||
inline static uint64_t read_u64(const void * const ptr)
|
||||
{
|
||||
return static_cast<uint64_t>(*reinterpret_cast<const uint64_t*>(ptr));
|
||||
}
|
||||
|
||||
inline static uint64_t read_u32(const void * const ptr)
|
||||
{
|
||||
return static_cast<uint64_t>(*reinterpret_cast<const uint32_t*>(ptr));
|
||||
}
|
||||
|
||||
inline static uint64_t read_u16(const void * const ptr)
|
||||
{
|
||||
return static_cast<uint64_t>(*reinterpret_cast<const uint16_t*>(ptr));
|
||||
}
|
||||
|
||||
inline static uint64_t read_u8 (const void * const ptr)
|
||||
{
|
||||
return static_cast<uint64_t>(*reinterpret_cast<const uint8_t *>(ptr));
|
||||
}
|
||||
|
||||
|
||||
#endif // #ifndef METROHASH_PLATFORM_H
|
|
@ -1,335 +0,0 @@
|
|||
/*
|
||||
sha1.h - header of
|
||||
|
||||
============
|
||||
SHA-1 in C++
|
||||
============
|
||||
|
||||
100% Public Domain.
|
||||
|
||||
Original C Code
|
||||
-- Steve Reid <steve@edmweb.com>
|
||||
Small changes to fit into bglibs
|
||||
-- Bruce Guenter <bruce@untroubled.org>
|
||||
Translation to simpler C++ Code
|
||||
-- Volker Grabsch <vog@notjusthosting.com>
|
||||
Safety fixes
|
||||
-- Eugene Hopkinson <slowriot at voxelstorm dot com>
|
||||
|
||||
Taken and adapted to be a single header from https://github.com/SourMesen/Mesen2/blob/master/Utilities/sha1.cpp
|
||||
by Sergio Martin (eien86)
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
|
||||
static const size_t BLOCK_INTS = 16; /* number of 32bit integers per SHA1 block */
|
||||
static const size_t BLOCK_BYTES = BLOCK_INTS * 4;
|
||||
|
||||
|
||||
static void reset(uint32_t digest[], std::string &buffer, uint64_t &transforms)
|
||||
{
|
||||
/* SHA1 initialization constants */
|
||||
digest[0] = 0x67452301;
|
||||
digest[1] = 0xefcdab89;
|
||||
digest[2] = 0x98badcfe;
|
||||
digest[3] = 0x10325476;
|
||||
digest[4] = 0xc3d2e1f0;
|
||||
|
||||
/* Reset counters */
|
||||
buffer = "";
|
||||
transforms = 0;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t rol(const uint32_t value, const size_t bits)
|
||||
{
|
||||
return (value << bits) | (value >> (32 - bits));
|
||||
}
|
||||
|
||||
|
||||
static uint32_t blk(const uint32_t block[BLOCK_INTS], const size_t i)
|
||||
{
|
||||
return rol(block[(i + 13) & 15] ^ block[(i + 8) & 15] ^ block[(i + 2) & 15] ^ block[i], 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (R0+R1), R2, R3, R4 are the different operations used in SHA1
|
||||
*/
|
||||
|
||||
static void R0(const uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i)
|
||||
{
|
||||
z += ((w&(x^y)) ^ y) + block[i] + 0x5a827999 + rol(v, 5);
|
||||
w = rol(w, 30);
|
||||
}
|
||||
|
||||
|
||||
static void R1(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i)
|
||||
{
|
||||
block[i] = blk(block, i);
|
||||
z += ((w&(x^y)) ^ y) + block[i] + 0x5a827999 + rol(v, 5);
|
||||
w = rol(w, 30);
|
||||
}
|
||||
|
||||
|
||||
static void R2(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i)
|
||||
{
|
||||
block[i] = blk(block, i);
|
||||
z += (w^x^y) + block[i] + 0x6ed9eba1 + rol(v, 5);
|
||||
w = rol(w, 30);
|
||||
}
|
||||
|
||||
|
||||
static void R3(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i)
|
||||
{
|
||||
block[i] = blk(block, i);
|
||||
z += (((w | x)&y) | (w&x)) + block[i] + 0x8f1bbcdc + rol(v, 5);
|
||||
w = rol(w, 30);
|
||||
}
|
||||
|
||||
|
||||
static void R4(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i)
|
||||
{
|
||||
block[i] = blk(block, i);
|
||||
z += (w^x^y) + block[i] + 0xca62c1d6 + rol(v, 5);
|
||||
w = rol(w, 30);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hash a single 512-bit block. This is the core of the algorithm.
|
||||
*/
|
||||
|
||||
static void transform(uint32_t digest[], uint32_t block[BLOCK_INTS], uint64_t &transforms)
|
||||
{
|
||||
/* Copy digest[] to working vars */
|
||||
uint32_t a = digest[0];
|
||||
uint32_t b = digest[1];
|
||||
uint32_t c = digest[2];
|
||||
uint32_t d = digest[3];
|
||||
uint32_t e = digest[4];
|
||||
|
||||
/* 4 rounds of 20 operations each. Loop unrolled. */
|
||||
R0(block, a, b, c, d, e, 0);
|
||||
R0(block, e, a, b, c, d, 1);
|
||||
R0(block, d, e, a, b, c, 2);
|
||||
R0(block, c, d, e, a, b, 3);
|
||||
R0(block, b, c, d, e, a, 4);
|
||||
R0(block, a, b, c, d, e, 5);
|
||||
R0(block, e, a, b, c, d, 6);
|
||||
R0(block, d, e, a, b, c, 7);
|
||||
R0(block, c, d, e, a, b, 8);
|
||||
R0(block, b, c, d, e, a, 9);
|
||||
R0(block, a, b, c, d, e, 10);
|
||||
R0(block, e, a, b, c, d, 11);
|
||||
R0(block, d, e, a, b, c, 12);
|
||||
R0(block, c, d, e, a, b, 13);
|
||||
R0(block, b, c, d, e, a, 14);
|
||||
R0(block, a, b, c, d, e, 15);
|
||||
R1(block, e, a, b, c, d, 0);
|
||||
R1(block, d, e, a, b, c, 1);
|
||||
R1(block, c, d, e, a, b, 2);
|
||||
R1(block, b, c, d, e, a, 3);
|
||||
R2(block, a, b, c, d, e, 4);
|
||||
R2(block, e, a, b, c, d, 5);
|
||||
R2(block, d, e, a, b, c, 6);
|
||||
R2(block, c, d, e, a, b, 7);
|
||||
R2(block, b, c, d, e, a, 8);
|
||||
R2(block, a, b, c, d, e, 9);
|
||||
R2(block, e, a, b, c, d, 10);
|
||||
R2(block, d, e, a, b, c, 11);
|
||||
R2(block, c, d, e, a, b, 12);
|
||||
R2(block, b, c, d, e, a, 13);
|
||||
R2(block, a, b, c, d, e, 14);
|
||||
R2(block, e, a, b, c, d, 15);
|
||||
R2(block, d, e, a, b, c, 0);
|
||||
R2(block, c, d, e, a, b, 1);
|
||||
R2(block, b, c, d, e, a, 2);
|
||||
R2(block, a, b, c, d, e, 3);
|
||||
R2(block, e, a, b, c, d, 4);
|
||||
R2(block, d, e, a, b, c, 5);
|
||||
R2(block, c, d, e, a, b, 6);
|
||||
R2(block, b, c, d, e, a, 7);
|
||||
R3(block, a, b, c, d, e, 8);
|
||||
R3(block, e, a, b, c, d, 9);
|
||||
R3(block, d, e, a, b, c, 10);
|
||||
R3(block, c, d, e, a, b, 11);
|
||||
R3(block, b, c, d, e, a, 12);
|
||||
R3(block, a, b, c, d, e, 13);
|
||||
R3(block, e, a, b, c, d, 14);
|
||||
R3(block, d, e, a, b, c, 15);
|
||||
R3(block, c, d, e, a, b, 0);
|
||||
R3(block, b, c, d, e, a, 1);
|
||||
R3(block, a, b, c, d, e, 2);
|
||||
R3(block, e, a, b, c, d, 3);
|
||||
R3(block, d, e, a, b, c, 4);
|
||||
R3(block, c, d, e, a, b, 5);
|
||||
R3(block, b, c, d, e, a, 6);
|
||||
R3(block, a, b, c, d, e, 7);
|
||||
R3(block, e, a, b, c, d, 8);
|
||||
R3(block, d, e, a, b, c, 9);
|
||||
R3(block, c, d, e, a, b, 10);
|
||||
R3(block, b, c, d, e, a, 11);
|
||||
R4(block, a, b, c, d, e, 12);
|
||||
R4(block, e, a, b, c, d, 13);
|
||||
R4(block, d, e, a, b, c, 14);
|
||||
R4(block, c, d, e, a, b, 15);
|
||||
R4(block, b, c, d, e, a, 0);
|
||||
R4(block, a, b, c, d, e, 1);
|
||||
R4(block, e, a, b, c, d, 2);
|
||||
R4(block, d, e, a, b, c, 3);
|
||||
R4(block, c, d, e, a, b, 4);
|
||||
R4(block, b, c, d, e, a, 5);
|
||||
R4(block, a, b, c, d, e, 6);
|
||||
R4(block, e, a, b, c, d, 7);
|
||||
R4(block, d, e, a, b, c, 8);
|
||||
R4(block, c, d, e, a, b, 9);
|
||||
R4(block, b, c, d, e, a, 10);
|
||||
R4(block, a, b, c, d, e, 11);
|
||||
R4(block, e, a, b, c, d, 12);
|
||||
R4(block, d, e, a, b, c, 13);
|
||||
R4(block, c, d, e, a, b, 14);
|
||||
R4(block, b, c, d, e, a, 15);
|
||||
|
||||
/* Add the working vars back into digest[] */
|
||||
digest[0] += a;
|
||||
digest[1] += b;
|
||||
digest[2] += c;
|
||||
digest[3] += d;
|
||||
digest[4] += e;
|
||||
|
||||
/* Count the number of transformations */
|
||||
transforms++;
|
||||
}
|
||||
|
||||
|
||||
static void buffer_to_block(const std::string &buffer, uint32_t block[BLOCK_INTS])
|
||||
{
|
||||
/* Convert the std::string (byte buffer) to a uint32_t array (MSB) */
|
||||
for(size_t i = 0; i < BLOCK_INTS; i++) {
|
||||
block[i] = (buffer[4 * i + 3] & 0xff)
|
||||
| (buffer[4 * i + 2] & 0xff) << 8
|
||||
| (buffer[4 * i + 1] & 0xff) << 16
|
||||
| (buffer[4 * i + 0] & 0xff) << 24;
|
||||
}
|
||||
}
|
||||
|
||||
class SHA1
|
||||
{
|
||||
public:
|
||||
SHA1()
|
||||
{
|
||||
reset(digest, buffer, transforms);
|
||||
}
|
||||
|
||||
|
||||
void update(const std::string &s)
|
||||
{
|
||||
std::istringstream is(s);
|
||||
update(is);
|
||||
}
|
||||
|
||||
|
||||
void update(std::istream &is)
|
||||
{
|
||||
char sbuf[BLOCK_BYTES];
|
||||
uint32_t block[BLOCK_INTS];
|
||||
|
||||
while(true) {
|
||||
is.read(sbuf, BLOCK_BYTES - buffer.size());
|
||||
buffer.append(sbuf, (size_t)is.gcount());
|
||||
if(buffer.size() != BLOCK_BYTES) {
|
||||
return;
|
||||
}
|
||||
|
||||
buffer_to_block(buffer, block);
|
||||
transform(digest, block, transforms);
|
||||
buffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add padding and return the message digest.
|
||||
*/
|
||||
|
||||
std::string final()
|
||||
{
|
||||
/* Total number of hashed bits */
|
||||
uint64_t total_bits = (transforms*BLOCK_BYTES + buffer.size()) * 8;
|
||||
|
||||
/* Padding */
|
||||
buffer += (char)0x80;
|
||||
size_t orig_size = buffer.size();
|
||||
while(buffer.size() < BLOCK_BYTES) {
|
||||
buffer += (char)0x00;
|
||||
}
|
||||
|
||||
uint32_t block[BLOCK_INTS];
|
||||
buffer_to_block(buffer, block);
|
||||
|
||||
if(orig_size > BLOCK_BYTES - 8) {
|
||||
transform(digest, block, transforms);
|
||||
for(size_t i = 0; i < BLOCK_INTS - 2; i++) {
|
||||
block[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Append total_bits, split this uint64_t into two uint32_t */
|
||||
block[BLOCK_INTS - 1] = (uint32_t)total_bits;
|
||||
block[BLOCK_INTS - 2] = (uint32_t)(total_bits >> 32);
|
||||
transform(digest, block, transforms);
|
||||
|
||||
/* Hex std::string */
|
||||
std::ostringstream result;
|
||||
for(size_t i = 0; i < sizeof(digest) / sizeof(digest[0]); i++) {
|
||||
result << std::uppercase << std::hex << std::setfill('0') << std::setw(8);
|
||||
result << digest[i];
|
||||
}
|
||||
|
||||
/* Reset for next run */
|
||||
reset(digest, buffer, transforms);
|
||||
|
||||
return result.str();
|
||||
}
|
||||
|
||||
|
||||
static std::string GetHash(uint8_t* data, size_t size)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.write((char*)data, size);
|
||||
|
||||
SHA1 checksum;
|
||||
checksum.update(ss);
|
||||
return checksum.final();
|
||||
}
|
||||
|
||||
static std::string GetHash(std::istream &stream)
|
||||
{
|
||||
SHA1 checksum;
|
||||
checksum.update(stream);
|
||||
return checksum.final();
|
||||
}
|
||||
|
||||
static std::string GetHash(const std::string &filename)
|
||||
{
|
||||
std::ifstream stream(filename.c_str(), std::ios::binary);
|
||||
SHA1 checksum;
|
||||
checksum.update(stream);
|
||||
return checksum.final();
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t digest[5];
|
||||
std::string buffer;
|
||||
uint64_t transforms;
|
||||
};
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
.deps/
|
||||
Makefile
|
||||
config.status
|
||||
libtool
|
||||
stamp-h1
|
||||
testing
|
|
@ -1,340 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
|
@ -1,370 +0,0 @@
|
|||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. This file is offered as-is,
|
||||
without warranty of any kind.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
Briefly, the shell commands `./configure; make; make install' should
|
||||
configure, build, and install this package. The following
|
||||
more-detailed instructions are generic; see the `README' file for
|
||||
instructions specific to this package. Some packages provide this
|
||||
`INSTALL' file but do not implement all of the features documented
|
||||
below. The lack of an optional feature in a given package is not
|
||||
necessarily a bug. More recommendations for GNU packages can be found
|
||||
in *note Makefile Conventions: (standards)Makefile Conventions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You need `configure.ac' if
|
||||
you want to change it or regenerate `configure' using a newer version
|
||||
of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system.
|
||||
|
||||
Running `configure' might take a while. While running, it prints
|
||||
some messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package, generally using the just-built uninstalled binaries.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation. When installing into a prefix owned by root, it is
|
||||
recommended that the package be configured and built as a regular
|
||||
user, and only the `make install' phase executed with root
|
||||
privileges.
|
||||
|
||||
5. Optionally, type `make installcheck' to repeat any self-tests, but
|
||||
this time using the binaries in their final installed location.
|
||||
This target does not install anything. Running this target as a
|
||||
regular user, particularly if the prior `make install' required
|
||||
root privileges, verifies that the installation completed
|
||||
correctly.
|
||||
|
||||
6. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
7. Often, you can also type `make uninstall' to remove the installed
|
||||
files again. In practice, not all packages have tested that
|
||||
uninstallation works correctly, even though it is required by the
|
||||
GNU Coding Standards.
|
||||
|
||||
8. Some packages, particularly those that use Automake, provide `make
|
||||
distcheck', which can by used by developers to test that all other
|
||||
targets like `make install' and `make uninstall' work correctly.
|
||||
This target is generally not run by end users.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you can use GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'. This
|
||||
is known as a "VPATH" build.
|
||||
|
||||
With a non-GNU `make', it is safer to compile the package for one
|
||||
architecture at a time in the source code directory. After you have
|
||||
installed the package for one architecture, use `make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
|
||||
On MacOS X 10.5 and later systems, you can create libraries and
|
||||
executables that work on multiple system types--known as "fat" or
|
||||
"universal" binaries--by specifying multiple `-arch' options to the
|
||||
compiler but only a single `-arch' option to the preprocessor. Like
|
||||
this:
|
||||
|
||||
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CPP="gcc -E" CXXCPP="g++ -E"
|
||||
|
||||
This is not guaranteed to produce working output in all cases, you
|
||||
may have to build one architecture at a time and combine the results
|
||||
using the `lipo' tool if you have problems.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX', where PREFIX must be an
|
||||
absolute file name.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them. In general, the
|
||||
default for these options is expressed in terms of `${prefix}', so that
|
||||
specifying just `--prefix' will affect all of the other directory
|
||||
specifications that were not explicitly provided.
|
||||
|
||||
The most portable way to affect installation locations is to pass the
|
||||
correct locations to `configure'; however, many packages provide one or
|
||||
both of the following shortcuts of passing variable assignments to the
|
||||
`make install' command line to change installation locations without
|
||||
having to reconfigure or recompile.
|
||||
|
||||
The first method involves providing an override variable for each
|
||||
affected directory. For example, `make install
|
||||
prefix=/alternate/directory' will choose an alternate location for all
|
||||
directory configuration variables that were expressed in terms of
|
||||
`${prefix}'. Any directories that were specified during `configure',
|
||||
but not in terms of `${prefix}', must each be overridden at install
|
||||
time for the entire installation to be relocated. The approach of
|
||||
makefile variable overrides for each directory variable is required by
|
||||
the GNU Coding Standards, and ideally causes no recompilation.
|
||||
However, some platforms have known limitations with the semantics of
|
||||
shared libraries that end up requiring recompilation when using this
|
||||
method, particularly noticeable in packages that use GNU Libtool.
|
||||
|
||||
The second method involves providing the `DESTDIR' variable. For
|
||||
example, `make install DESTDIR=/alternate/directory' will prepend
|
||||
`/alternate/directory' before all installation names. The approach of
|
||||
`DESTDIR' overrides is not required by the GNU Coding Standards, and
|
||||
does not work on platforms that have drive letters. On the other hand,
|
||||
it does better at avoiding recompilation issues, and works well even
|
||||
when some directory options were not specified in terms of `${prefix}'
|
||||
at `configure' time.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Some packages offer the ability to configure how verbose the
|
||||
execution of `make' will be. For these packages, running `./configure
|
||||
--enable-silent-rules' sets the default to minimal output, which can be
|
||||
overridden with `make V=1'; while running `./configure
|
||||
--disable-silent-rules' sets the default to verbose, which can be
|
||||
overridden with `make V=0'.
|
||||
|
||||
Particular systems
|
||||
==================
|
||||
|
||||
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
|
||||
CC is not installed, it is recommended to use the following options in
|
||||
order to use an ANSI C compiler:
|
||||
|
||||
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
|
||||
|
||||
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||
|
||||
HP-UX `make' updates targets which have the same time stamps as
|
||||
their prerequisites, which makes it generally unusable when shipped
|
||||
generated files such as `configure' are involved. Use GNU `make'
|
||||
instead.
|
||||
|
||||
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
|
||||
a workaround. If GNU CC is not installed, it is therefore recommended
|
||||
to try
|
||||
|
||||
./configure CC="cc"
|
||||
|
||||
and if that doesn't work, try
|
||||
|
||||
./configure CC="cc -nodtk"
|
||||
|
||||
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
|
||||
directory contains several dysfunctional programs; working variants of
|
||||
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
|
||||
in your `PATH', put it _after_ `/usr/bin'.
|
||||
|
||||
On Haiku, software installed for all users goes in `/boot/common',
|
||||
not `/usr/local'. It is recommended to use the following options:
|
||||
|
||||
./configure --prefix=/boot/common
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS
|
||||
KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option `--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
||||
an Autoconf limitation. Until the limitation is lifted, you can use
|
||||
this workaround:
|
||||
|
||||
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of all of the options to `configure', and exit.
|
||||
|
||||
`--help=short'
|
||||
`--help=recursive'
|
||||
Print a summary of the options unique to this package's
|
||||
`configure', and exit. The `short' variant lists options used
|
||||
only in the top level, while the `recursive' variant lists options
|
||||
also present in any nested packages.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--prefix=DIR'
|
||||
Use DIR as the installation prefix. *note Installation Names::
|
||||
for more details, including other options available for fine-tuning
|
||||
the installation locations.
|
||||
|
||||
`--no-create'
|
||||
`-n'
|
||||
Run the configure checks, but stop before creating any output
|
||||
files.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
|
@ -1,140 +0,0 @@
|
|||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
bin_PROGRAMS = xdelta3
|
||||
noinst_PROGRAMS = xdelta3regtest xdelta3decode
|
||||
|
||||
export AFL_HARDEN
|
||||
|
||||
common_SOURCES = \
|
||||
xdelta3-blkcache.h \
|
||||
xdelta3-decode.h \
|
||||
xdelta3-djw.h \
|
||||
xdelta3-fgk.h \
|
||||
xdelta3-hash.h \
|
||||
xdelta3-internal.h \
|
||||
xdelta3-list.h \
|
||||
xdelta3-lzma.h \
|
||||
xdelta3-main.h \
|
||||
xdelta3-merge.h \
|
||||
xdelta3-second.h \
|
||||
xdelta3-test.h \
|
||||
xdelta3-cfgs.h \
|
||||
xdelta3.h
|
||||
|
||||
xdelta3_SOURCES = $(common_SOURCES) xdelta3.c
|
||||
|
||||
xdelta3decode_SOURCES = $(common_SOURCES) xdelta3.c
|
||||
|
||||
xdelta3regtest_SOURCES = $(common_SOURCES) \
|
||||
testing/cmp.h \
|
||||
testing/delta.h \
|
||||
testing/file.h \
|
||||
testing/modify.h \
|
||||
testing/random.h \
|
||||
testing/regtest.cc \
|
||||
testing/regtest_c.c \
|
||||
testing/segment.h \
|
||||
testing/sizes.h \
|
||||
testing/test.h
|
||||
|
||||
# Note: for extra sanity checks, enable -Wconversion. Note there
|
||||
# are a lot of false positives.
|
||||
WFLAGS = -Wall -Wshadow -fno-builtin -Wextra -Wsign-compare \
|
||||
-Wextra -Wno-unused-parameter -Wno-unused-function
|
||||
|
||||
C_WFLAGS = $(WFLAGS) -pedantic -std=c99
|
||||
CXX_WFLAGS = $(WFLAGS)
|
||||
|
||||
common_CFLAGS = \
|
||||
-DREGRESSION_TEST=1 \
|
||||
-DSECONDARY_DJW=1 \
|
||||
-DSECONDARY_FGK=1 \
|
||||
-DXD3_MAIN=1
|
||||
|
||||
if DEBUG_SYMBOLS
|
||||
common_CFLAGS += -g
|
||||
endif
|
||||
|
||||
#common_CFLAGS += -fsanitize=address -fno-omit-frame-pointer
|
||||
#common_CFLAGS += -O2
|
||||
|
||||
# For additional debugging, add -DXD3_DEBUG=1, 2, 3, ...
|
||||
xdelta3_CFLAGS = $(C_WFLAGS) $(common_CFLAGS) -DXD3_DEBUG=0
|
||||
xdelta3_LDADD = -lm
|
||||
|
||||
xdelta3decode_CFLAGS = \
|
||||
$(C_WFLAGS) \
|
||||
-DREGRESSION_TEST=0 \
|
||||
-DSECONDARY_DJW=0 \
|
||||
-DSECONDARY_FGK=0 \
|
||||
-DSECONDARY_LZMA=0 \
|
||||
-DXD3_MAIN=1 \
|
||||
-DXD3_ENCODER=0 \
|
||||
-DXD3_STDIO=1 \
|
||||
-DEXTERNAL_COMPRESSION=0 \
|
||||
-DVCDIFF_TOOLS=0
|
||||
|
||||
xdelta3regtest_CXXFLAGS = \
|
||||
$(CXX_WFLAGS) $(common_CFLAGS) -DNOT_MAIN=1 -DXD3_DEBUG=1
|
||||
xdelta3regtest_CFLAGS = \
|
||||
$(C_WFLAGS) $(common_CFLAGS) -DNOT_MAIN=1 -DXD3_DEBUG=1
|
||||
xdelta3regtest_LDADD = -lm
|
||||
|
||||
man1_MANS = xdelta3.1
|
||||
|
||||
EXTRA_DIST = \
|
||||
README.md \
|
||||
run_release.sh \
|
||||
draft-korn-vcdiff.txt \
|
||||
examples/Makefile \
|
||||
examples/README.md \
|
||||
examples/checksum_test.cc \
|
||||
examples/compare_test.c \
|
||||
examples/encode_decode_test.c \
|
||||
examples/small_page_test.c \
|
||||
examples/speed_test.c \
|
||||
examples/test.h \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test.xcodeproj/project.pbxproj \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/Xd3iOSAppDelegate.h \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/Xd3iOSAppDelegate.m \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/Xd3iOSViewController.h \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/Xd3iOSViewController.m \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/en.lproj/InfoPlist.strings \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/en.lproj/MainStoryboard_iPad.storyboard \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/en.lproj/MainStoryboard_iPhone.storyboard \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/file_v1.bin \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/file_v1_to_v2.bin \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/file_v2.bin \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/main.m \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/xdelta3-ios-test-Info.plist \
|
||||
examples/iOS/xdelta3-ios-test/xdelta3-ios-test/xdelta3-ios-test-Prefix.pch \
|
||||
testing/xdelta3-regtest.py \
|
||||
testing/xdelta3-test.py \
|
||||
xdelta3.1 \
|
||||
xdelta3.i \
|
||||
xdelta3.vcxproj \
|
||||
xdelta3.wxi \
|
||||
xdelta3.wxs
|
||||
|
||||
# Broken, removed from distribution:
|
||||
# xdelta3_pywrap.c
|
||||
# xdelta3.py
|
||||
|
||||
#PYFILES = xdelta3_pywrap.c xdelta3.py
|
||||
#XDELTA3PY = xdelta3.py
|
||||
#XDELTA3PYLIB = xdelta3.la
|
||||
|
||||
#BUILT_SOURCES = $(PYFILES)
|
||||
|
||||
#xdelta3_pywrap.c xdelta3.py : xdelta3.i
|
||||
# $(SWIG) -python -o xdelta3_pywrap.c xdelta3.i
|
||||
|
||||
# OS X for some reason requires:
|
||||
# pythondir = $(PYTHON_SITE_PKG)
|
||||
# pyexecdir = $(PYTHON_SITE_PKG)
|
||||
|
||||
#python_PYTHON = $(XDELTA3PY)
|
||||
#pyexec_LTLIBRARIES = $(XDELTA3PYLIB)
|
||||
#_xdelta3_la_SOURCES = $(srcdir)/xdelta3_pywrap.c $(xdelta3_SOURCES)
|
||||
#_xdelta3_la_CFLAGS = $(common_CFLAGS) -DNOT_MAIN=1 $(PYTHON_CPPFLAGS)
|
||||
#_xdelta3_la_LDFLAGS = -module
|
File diff suppressed because it is too large
Load Diff
|
@ -1,39 +0,0 @@
|
|||
Xdelta 3.x readme.txt
|
||||
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
||||
2009, 2010, 2011, 2012, 2013, 2014, 2015
|
||||
<josh.macdonald@gmail.com>
|
||||
|
||||
|
||||
Thanks for downloading Xdelta!
|
||||
|
||||
This directory contains the Xdelta3 command-line interface (CLI) and source
|
||||
distribution for VCDIFF differential compression, a.k.a. delta
|
||||
compression. The latest information and downloads are available here:
|
||||
|
||||
http://xdelta.org/
|
||||
http://github.com/jmacd/xdelta/
|
||||
|
||||
Xdelta can be configured to use XZ Utils for secondary compression:
|
||||
|
||||
http://tukaani.org/xz/
|
||||
|
||||
The command-line syntax is detailed here:
|
||||
|
||||
https://github.com/jmacd/xdelta/blob/wiki/CommandLineSyntax.md
|
||||
|
||||
Run 'xdelta3 -h' for brief help. Run 'xdelta3 test' for built-in tests.
|
||||
|
||||
Sample commands (like gzip, -e means encode, -d means decode)
|
||||
|
||||
xdelta3 -9 -S lzma -e -f -s OLD_FILE NEW_FILE DELTA_FILE
|
||||
xdelta3 -d -s OLD_FILE DELTA_FILE DECODED_FILE
|
||||
|
||||
File bug reports and browse open support issues here:
|
||||
|
||||
https://github.com/jmacd/xdelta/issues
|
||||
|
||||
The source distribution contains the C/C++/Python APIs, Unix, Microsoft VC++
|
||||
and Cygwin builds. Xdelta3 is covered under the terms of the GPL, see
|
||||
COPYING.
|
||||
|
||||
Commercial inquiries welcome, please contact <josh.macdonald@gmail.com>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,347 +0,0 @@
|
|||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-10-14.11; # UTC
|
||||
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
File diff suppressed because it is too large
Load Diff
|
@ -1,74 +0,0 @@
|
|||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if pointers to integers require aligned access */
|
||||
/* #undef HAVE_ALIGNED_ACCESS_REQUIRED */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `lzma' library (-llzma). */
|
||||
/* #undef HAVE_LIBLZMA */
|
||||
|
||||
/* Define to 1 if you have the <lzma.h> header file. */
|
||||
/* #undef HAVE_LZMA_H */
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "josh.macdonald@gmail.com"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "Xdelta3"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "Xdelta3 3.0.11"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "xdelta3"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "http://xdelta.org/"
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 8
|
||||
|
||||
/* The size of `unsigned int', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_INT 4
|
||||
|
||||
/* The size of `unsigned long', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_LONG 8
|
||||
|
||||
/* The size of `unsigned long long', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_LONG_LONG 8
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
|
@ -1,76 +0,0 @@
|
|||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if pointers to integers require aligned access */
|
||||
#undef HAVE_ALIGNED_ACCESS_REQUIRED
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `lzma' library (-llzma). */
|
||||
#undef HAVE_LIBLZMA
|
||||
|
||||
/* Define to 1 if you have the <lzma.h> header file. */
|
||||
#undef HAVE_LZMA_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#undef SIZEOF_SIZE_T
|
||||
|
||||
/* The size of `unsigned int', as computed by sizeof. */
|
||||
#undef SIZEOF_UNSIGNED_INT
|
||||
|
||||
/* The size of `unsigned long', as computed by sizeof. */
|
||||
#undef SIZEOF_UNSIGNED_LONG
|
||||
|
||||
/* The size of `unsigned long long', as computed by sizeof. */
|
||||
#undef SIZEOF_UNSIGNED_LONG_LONG
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,49 +0,0 @@
|
|||
AC_INIT([Xdelta3], [3.0.11], [josh.macdonald@gmail.com],
|
||||
[xdelta3], [http://xdelta.org/])
|
||||
AC_PREREQ([2.68])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
LT_INIT
|
||||
AM_INIT_AUTOMAKE([1.9 no-define foreign tar-ustar subdir-objects])
|
||||
|
||||
AX_CHECK_ALIGNED_ACCESS_REQUIRED
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
|
||||
AC_CHECK_SIZEOF(size_t)
|
||||
AC_CHECK_SIZEOF(unsigned int)
|
||||
AC_CHECK_SIZEOF(unsigned long)
|
||||
AC_CHECK_SIZEOF(unsigned long long)
|
||||
|
||||
AC_ARG_WITH(
|
||||
[liblzma],
|
||||
[AC_HELP_STRING(
|
||||
[--with-liblzma],
|
||||
[build with liblzma support @<:@default=autodetect@:>@])],
|
||||
[USE_LIBLZMA=$withval],
|
||||
[USE_LIBLZMA=auto])
|
||||
|
||||
if test "x$USE_LIBLZMA" != xno ; then
|
||||
AC_CHECK_HEADERS([lzma.h],,[
|
||||
if test "x$with_liblzma" = xyes ; then
|
||||
AC_MSG_FAILURE([liblzma includes were not found])
|
||||
fi])
|
||||
AC_CHECK_LIB([lzma], [lzma_easy_buffer_encode],,[
|
||||
if test "x$with_liblzma" = xyes ; then
|
||||
AC_MSG_FAILURE([liblzma library were not found])
|
||||
fi])
|
||||
fi
|
||||
|
||||
#AM_PATH_PYTHON(,, [:])
|
||||
#AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
|
||||
#AX_PYTHON_DEVEL()
|
||||
#AX_PKG_SWIG(2.0.0,,)
|
||||
#AX_SWIG_PYTHON
|
||||
|
||||
dnl --enable-debug-symbols : build with debug symbols?
|
||||
AC_ARG_ENABLE(debug-symbols,
|
||||
AS_HELP_STRING(--enable-debug-symbols,[Build with debug symbols (default is NO)]),,enableval=no)
|
||||
AM_CONDITIONAL([DEBUG_SYMBOLS], [test ${enableval} = "yes"])
|
||||
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
|
@ -1,791 +0,0 @@
|
|||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2013-05-30.07; # UTC
|
||||
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the directory component of the given path, and save it in the
|
||||
# global variables '$dir'. Note that this directory component will
|
||||
# be either empty or ending with a '/' character. This is deliberate.
|
||||
set_dir_from ()
|
||||
{
|
||||
case $1 in
|
||||
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
|
||||
*) dir=;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the suffix-stripped basename of the given path, and save it the
|
||||
# global variable '$base'.
|
||||
set_base_from ()
|
||||
{
|
||||
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
|
||||
}
|
||||
|
||||
# If no dependency file was actually created by the compiler invocation,
|
||||
# we still have to create a dummy depfile, to avoid errors with the
|
||||
# Makefile "include basename.Plo" scheme.
|
||||
make_dummy_depfile ()
|
||||
{
|
||||
echo "#dummy" > "$depfile"
|
||||
}
|
||||
|
||||
# Factor out some common post-processing of the generated depfile.
|
||||
# Requires the auxiliary global variable '$tmpdepfile' to be set.
|
||||
aix_post_process_depfile ()
|
||||
{
|
||||
# If the compiler actually managed to produce a dependency file,
|
||||
# post-process it.
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependency.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# $object: dependency.h
|
||||
# and one to simply output
|
||||
# dependency.h:
|
||||
# which is needed to avoid the deleted-header problem.
|
||||
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
|
||||
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
|
||||
} > "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
}
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
# Character ranges might be problematic outside the C locale.
|
||||
# These definitions help.
|
||||
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
lower=abcdefghijklmnopqrstuvwxyz
|
||||
digits=0123456789
|
||||
alpha=${upper}${lower}
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Avoid interferences from the environment.
|
||||
gccflag= dashmflag=
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
|
||||
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
|
||||
## (see the conditional assignment to $gccflag above).
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say). Also, it might not be
|
||||
## supported by the other compilers which use the 'gcc' depmode.
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The second -e expression handles DOS-style file names with drive
|
||||
# letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
|
||||
| tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
tcc)
|
||||
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
|
||||
# FIXME: That version still under development at the moment of writing.
|
||||
# Make that this statement remains true also for stable, released
|
||||
# versions.
|
||||
# It will wrap lines (doesn't matter whether long or short) with a
|
||||
# trailing '\', as in:
|
||||
#
|
||||
# foo.o : \
|
||||
# foo.c \
|
||||
# foo.h \
|
||||
#
|
||||
# It will put a trailing '\' even on the last line, and will use leading
|
||||
# spaces rather than leading tabs (at least since its commit 0394caf7
|
||||
# "Emit spaces for -MD").
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
|
||||
# We have to change lines of the first kind to '$object: \'.
|
||||
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
|
||||
# And for each line of the second kind, we have to emit a 'dep.h:'
|
||||
# dummy dependency, to avoid the deleted-header problem.
|
||||
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
## The order of this option in the case statement is important, since the
|
||||
## shell code in configure will try each of these formats in the order
|
||||
## listed in this file. A plain '-MD' option would be understood by many
|
||||
## compilers, so we must ensure this comes after the gcc and icc options.
|
||||
pgcc)
|
||||
# Portland's C compiler understands '-MD'.
|
||||
# Will always output deps to 'file.d' where file is the root name of the
|
||||
# source file under compilation, even if file resides in a subdirectory.
|
||||
# The object file name does not affect the name of the '.d' file.
|
||||
# pgcc 10.2 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using '\' :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
set_dir_from "$object"
|
||||
# Use the source, not the object, to determine the base name, since
|
||||
# that's sadly what pgcc will do too.
|
||||
set_base_from "$source"
|
||||
tmpdepfile=$base.d
|
||||
|
||||
# For projects that build the same source file twice into different object
|
||||
# files, the pgcc approach of using the *source* file root name can cause
|
||||
# problems in parallel builds. Use a locking strategy to avoid stomping on
|
||||
# the same $tmpdepfile.
|
||||
lockdir=$base.d-lock
|
||||
trap "
|
||||
echo '$0: caught signal, cleaning up...' >&2
|
||||
rmdir '$lockdir'
|
||||
exit 1
|
||||
" 1 2 13 15
|
||||
numtries=100
|
||||
i=$numtries
|
||||
while test $i -gt 0; do
|
||||
# mkdir is a portable test-and-set.
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
# This process acquired the lock.
|
||||
"$@" -MD
|
||||
stat=$?
|
||||
# Release the lock.
|
||||
rmdir "$lockdir"
|
||||
break
|
||||
else
|
||||
# If the lock is being held by a different process, wait
|
||||
# until the winning process is done or we timeout.
|
||||
while test -d "$lockdir" && test $i -gt 0; do
|
||||
sleep 1
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
fi
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
trap - 1 2 13 15
|
||||
if test $i -le 0; then
|
||||
echo "$0: failed to acquire lock after $numtries attempts" >&2
|
||||
echo "$0: check lockdir '$lockdir'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# Libtool generates 2 separate objects for the 2 libraries. These
|
||||
# two compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
|
||||
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
# Same post-processing that is required for AIX mode.
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this sed invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process the last invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed '1,2d' "$tmpdepfile" \
|
||||
| tr ' ' "$nl" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E \
|
||||
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
| sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
|
@ -1,8 +0,0 @@
|
|||
Files in this directory demonstrate how to use the Xdelta3 API. Copyrights
|
||||
are held by the respective authors and these files are not covered by the GPL.
|
||||
|
||||
small_page_test.c -- how to use xdelta3 in an environment such as the kernel
|
||||
for small pages with little memory
|
||||
|
||||
encode_decode_test.c -- how to use xdelta3 to process (encode/decode) data in
|
||||
multiple windows with the non-blocking API
|
|
@ -1,732 +0,0 @@
|
|||
/* Copyright (C) 2007 Josh MacDonald */
|
||||
|
||||
extern "C" {
|
||||
#include "test.h"
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
using std::list;
|
||||
using std::map;
|
||||
using std::vector;
|
||||
|
||||
// MLCG parameters
|
||||
// a, a*
|
||||
uint32_t good_32bit_values[] = {
|
||||
1597334677U, // ...
|
||||
741103597U, 887987685U,
|
||||
};
|
||||
|
||||
// a, a*
|
||||
uint64_t good_64bit_values[] = {
|
||||
1181783497276652981ULL, 4292484099903637661ULL,
|
||||
7664345821815920749ULL, // ...
|
||||
};
|
||||
|
||||
struct true_type { };
|
||||
struct false_type { };
|
||||
|
||||
template <typename Word>
|
||||
int bitsof();
|
||||
|
||||
template<>
|
||||
int bitsof<uint32_t>() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
template<>
|
||||
int bitsof<uint64_t>() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
struct plain {
|
||||
int operator()(const uint8_t &c) {
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Word>
|
||||
struct hhash { // take "h" of the high-bits as a hash value for this
|
||||
// checksum, which are the most "distant" in terms of the
|
||||
// spectral test for the rabin_karp MLCG. For short windows,
|
||||
// the high bits aren't enough, XOR "mask" worth of these in.
|
||||
Word operator()(const Word& t, const int &h, const int &mask) {
|
||||
return (t >> h) ^ (t & mask);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Word>
|
||||
Word good_word();
|
||||
|
||||
template<>
|
||||
uint32_t good_word<uint32_t>() {
|
||||
return good_32bit_values[0];
|
||||
}
|
||||
|
||||
template<>
|
||||
uint64_t good_word<uint64_t>() {
|
||||
return good_64bit_values[0];
|
||||
}
|
||||
|
||||
// CLASSES
|
||||
|
||||
#define SELF Word, CksumSize, CksumSkip, Permute, Hash, Compaction
|
||||
#define MEMBER template <typename Word, \
|
||||
int CksumSize, \
|
||||
int CksumSkip, \
|
||||
typename Permute, \
|
||||
typename Hash, \
|
||||
int Compaction>
|
||||
|
||||
MEMBER
|
||||
struct cksum_params {
|
||||
typedef Word word_type;
|
||||
typedef Permute permute_type;
|
||||
typedef Hash hash_type;
|
||||
|
||||
enum { cksum_size = CksumSize,
|
||||
cksum_skip = CksumSkip,
|
||||
compaction = Compaction,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
MEMBER
|
||||
struct rabin_karp {
|
||||
typedef Word word_type;
|
||||
typedef Permute permute_type;
|
||||
typedef Hash hash_type;
|
||||
|
||||
enum { cksum_size = CksumSize,
|
||||
cksum_skip = CksumSkip,
|
||||
compaction = Compaction,
|
||||
};
|
||||
|
||||
// (a^cksum_size-1 c_0) + (a^cksum_size-2 c_1) ...
|
||||
rabin_karp() {
|
||||
multiplier = good_word<Word>();
|
||||
powers = new Word[cksum_size];
|
||||
powers[cksum_size - 1] = 1;
|
||||
for (int i = cksum_size - 2; i >= 0; i--) {
|
||||
powers[i] = powers[i + 1] * multiplier;
|
||||
}
|
||||
product = powers[0] * multiplier;
|
||||
}
|
||||
|
||||
~rabin_karp() {
|
||||
delete [] powers;
|
||||
}
|
||||
|
||||
Word step(const uint8_t *ptr) {
|
||||
Word h = 0;
|
||||
for (int i = 0; i < cksum_size; i++) {
|
||||
h += permute_type()(ptr[i]) * powers[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
Word state0(const uint8_t *ptr) {
|
||||
incr_state = step(ptr);
|
||||
return incr_state;
|
||||
}
|
||||
|
||||
Word incr(const uint8_t *ptr) {
|
||||
incr_state = multiplier * incr_state -
|
||||
product * permute_type()(ptr[-1]) +
|
||||
permute_type()(ptr[cksum_size - 1]);
|
||||
return incr_state;
|
||||
}
|
||||
|
||||
Word *powers;
|
||||
Word product;
|
||||
Word multiplier;
|
||||
Word incr_state;
|
||||
};
|
||||
|
||||
MEMBER
|
||||
struct adler32_cksum {
|
||||
typedef Word word_type;
|
||||
typedef Permute permute_type;
|
||||
typedef Hash hash_type;
|
||||
|
||||
enum { cksum_size = CksumSize,
|
||||
cksum_skip = CksumSkip,
|
||||
compaction = Compaction,
|
||||
};
|
||||
|
||||
Word step(const uint8_t *ptr) {
|
||||
return xd3_lcksum (ptr, cksum_size);
|
||||
}
|
||||
|
||||
Word state0(const uint8_t *ptr) {
|
||||
incr_state = step(ptr);
|
||||
return incr_state;
|
||||
}
|
||||
|
||||
Word incr(const uint8_t *ptr) {
|
||||
incr_state = xd3_large_cksum_update (incr_state, ptr - 1, cksum_size);
|
||||
return incr_state;
|
||||
}
|
||||
|
||||
Word incr_state;
|
||||
};
|
||||
|
||||
// TESTS
|
||||
|
||||
template <typename Word>
|
||||
struct file_stats {
|
||||
typedef list<const uint8_t*> ptr_list;
|
||||
typedef Word word_type;
|
||||
typedef map<word_type, ptr_list> table_type;
|
||||
typedef typename table_type::iterator table_iterator;
|
||||
typedef typename ptr_list::iterator ptr_iterator;
|
||||
|
||||
int cksum_size;
|
||||
int cksum_skip;
|
||||
int unique;
|
||||
int unique_values;
|
||||
int count;
|
||||
table_type table;
|
||||
|
||||
file_stats(int size, int skip)
|
||||
: cksum_size(size),
|
||||
cksum_skip(skip),
|
||||
unique(0),
|
||||
unique_values(0),
|
||||
count(0) {
|
||||
}
|
||||
|
||||
void reset() {
|
||||
unique = 0;
|
||||
unique_values = 0;
|
||||
count = 0;
|
||||
table.clear();
|
||||
}
|
||||
|
||||
void update(const word_type &word, const uint8_t *ptr) {
|
||||
table_iterator t_i = table.find(word);
|
||||
|
||||
count++;
|
||||
|
||||
if (t_i == table.end()) {
|
||||
table.insert(make_pair(word, ptr_list()));
|
||||
}
|
||||
|
||||
ptr_list &pl = table[word];
|
||||
|
||||
for (ptr_iterator p_i = pl.begin();
|
||||
p_i != pl.end();
|
||||
++p_i) {
|
||||
if (memcmp(*p_i, ptr, cksum_size) == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unique++;
|
||||
pl.push_back(ptr);
|
||||
}
|
||||
|
||||
void freeze() {
|
||||
unique_values = table.size();
|
||||
table.clear();
|
||||
}
|
||||
};
|
||||
|
||||
struct test_result_base;
|
||||
|
||||
static vector<test_result_base*> all_tests;
|
||||
|
||||
struct test_result_base {
|
||||
virtual ~test_result_base() {
|
||||
}
|
||||
virtual void reset() = 0;
|
||||
virtual void print() = 0;
|
||||
virtual void get(const uint8_t* buf, const int buf_size, int iters) = 0;
|
||||
virtual void stat() = 0;
|
||||
virtual int count() = 0;
|
||||
virtual int dups() = 0;
|
||||
virtual double uniqueness() = 0;
|
||||
virtual double fullness() = 0;
|
||||
virtual double collisions() = 0;
|
||||
virtual double coverage() = 0;
|
||||
virtual double compression() = 0;
|
||||
virtual double time() = 0;
|
||||
virtual double score() = 0;
|
||||
virtual void set_score(double min_dups_frac, double min_time) = 0;
|
||||
virtual double total_time() = 0;
|
||||
virtual int total_count() = 0;
|
||||
virtual int total_dups() = 0;
|
||||
};
|
||||
|
||||
struct compare_h {
|
||||
bool operator()(test_result_base *a,
|
||||
test_result_base *b) {
|
||||
return a->score() < b->score();
|
||||
}
|
||||
};
|
||||
|
||||
MEMBER
|
||||
struct test_result : public test_result_base {
|
||||
typedef Word word_type;
|
||||
typedef Permute permute_type;
|
||||
typedef Hash hash_type;
|
||||
|
||||
enum { cksum_size = CksumSize,
|
||||
cksum_skip = CksumSkip,
|
||||
compaction = Compaction,
|
||||
};
|
||||
|
||||
const char *test_name;
|
||||
file_stats<Word> fstats;
|
||||
int test_size;
|
||||
int n_steps;
|
||||
int n_incrs;
|
||||
int s_bits;
|
||||
int s_mask;
|
||||
int t_entries;
|
||||
int h_bits;
|
||||
int h_buckets_full;
|
||||
double h_score;
|
||||
char *hash_table;
|
||||
long accum_millis;
|
||||
int accum_iters;
|
||||
|
||||
// These are not reset
|
||||
double accum_time;
|
||||
int accum_count;
|
||||
int accum_dups;
|
||||
int accum_colls;
|
||||
int accum_size;
|
||||
|
||||
test_result(const char *name)
|
||||
: test_name(name),
|
||||
fstats(cksum_size, cksum_skip),
|
||||
hash_table(NULL),
|
||||
accum_millis(0),
|
||||
accum_iters(0),
|
||||
accum_time(0.0),
|
||||
accum_count(0),
|
||||
accum_dups(0),
|
||||
accum_colls(0),
|
||||
accum_size(0) {
|
||||
all_tests.push_back(this);
|
||||
}
|
||||
|
||||
~test_result() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
// size of file
|
||||
test_size = -1;
|
||||
|
||||
// count
|
||||
n_steps = -1;
|
||||
n_incrs = -1;
|
||||
|
||||
// four values used by new_table()/summarize_table()
|
||||
s_bits = -1;
|
||||
s_mask = -1;
|
||||
t_entries = -1;
|
||||
h_bits = -1;
|
||||
h_buckets_full = -1;
|
||||
|
||||
accum_millis = 0;
|
||||
accum_iters = 0;
|
||||
|
||||
fstats.reset();
|
||||
|
||||
// temporary
|
||||
if (hash_table) {
|
||||
delete(hash_table);
|
||||
hash_table = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int count() {
|
||||
if (cksum_skip == 1) {
|
||||
return n_incrs;
|
||||
} else {
|
||||
return n_steps;
|
||||
}
|
||||
}
|
||||
|
||||
int dups() {
|
||||
return fstats.count - fstats.unique;
|
||||
}
|
||||
|
||||
int colls() {
|
||||
return fstats.unique - fstats.unique_values;
|
||||
}
|
||||
|
||||
double uniqueness() {
|
||||
return 1.0 - (double) dups() / count();
|
||||
}
|
||||
|
||||
double fullness() {
|
||||
return (double) h_buckets_full / (1 << h_bits);
|
||||
}
|
||||
|
||||
double collisions() {
|
||||
return (double) colls() / fstats.unique;
|
||||
}
|
||||
|
||||
double coverage() {
|
||||
return (double) h_buckets_full / uniqueness() / count();
|
||||
}
|
||||
|
||||
double compression() {
|
||||
return 1.0 - coverage();
|
||||
}
|
||||
|
||||
double time() {
|
||||
return (double) accum_millis / accum_iters;
|
||||
}
|
||||
|
||||
double score() {
|
||||
return h_score;
|
||||
}
|
||||
|
||||
void set_score(double min_compression, double min_time) {
|
||||
h_score = (compression() - 0.99 * min_compression)
|
||||
* (time() - 0.99 * min_time);
|
||||
}
|
||||
|
||||
double total_time() {
|
||||
return accum_time;
|
||||
}
|
||||
|
||||
int total_count() {
|
||||
return accum_count;
|
||||
}
|
||||
|
||||
int total_dups() {
|
||||
return accum_dups;
|
||||
}
|
||||
|
||||
int total_colls() {
|
||||
return accum_dups;
|
||||
}
|
||||
|
||||
void stat() {
|
||||
accum_time += time();
|
||||
accum_count += count();
|
||||
accum_dups += dups();
|
||||
accum_colls += colls();
|
||||
accum_size += test_size;
|
||||
}
|
||||
|
||||
void print() {
|
||||
if (fstats.count != count()) {
|
||||
fprintf(stderr, "internal error: %d != %d\n", fstats.count, count());
|
||||
abort();
|
||||
}
|
||||
printf("%s: (%u#%u) count %u uniq %0.2f%% full %u (%0.4f%% coll %0.4f%%) covers %0.2f%% w/ 2^%d @ %.4f MB/s %u iters\n",
|
||||
test_name,
|
||||
cksum_size,
|
||||
cksum_skip,
|
||||
count(),
|
||||
100.0 * uniqueness(),
|
||||
h_buckets_full,
|
||||
100.0 * fullness(),
|
||||
100.0 * collisions(),
|
||||
100.0 * coverage(),
|
||||
h_bits,
|
||||
0.001 * accum_iters * test_size / accum_millis,
|
||||
accum_iters);
|
||||
}
|
||||
|
||||
int size_log2 (int slots)
|
||||
{
|
||||
int bits = bitsof<word_type>() - 1;
|
||||
int i;
|
||||
|
||||
for (i = 3; i <= bits; i += 1) {
|
||||
if (slots <= (1 << i)) {
|
||||
return i - compaction;
|
||||
}
|
||||
}
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
void new_table(int entries) {
|
||||
t_entries = entries;
|
||||
h_bits = size_log2(entries);
|
||||
|
||||
int n = 1 << h_bits;
|
||||
|
||||
s_bits = bitsof<word_type>() - h_bits;
|
||||
s_mask = n - 1;
|
||||
|
||||
hash_table = new char[n / 8];
|
||||
memset(hash_table, 0, n / 8);
|
||||
}
|
||||
|
||||
int get_table_bit(int i) {
|
||||
return hash_table[i/8] & (1 << i%8);
|
||||
}
|
||||
|
||||
int set_table_bit(int i) {
|
||||
return hash_table[i/8] |= (1 << i%8);
|
||||
}
|
||||
|
||||
void summarize_table() {
|
||||
int n = 1 << h_bits;
|
||||
int f = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (get_table_bit(i)) {
|
||||
f++;
|
||||
}
|
||||
}
|
||||
h_buckets_full = f;
|
||||
}
|
||||
|
||||
void get(const uint8_t* buf, const int buf_size, int test_iters) {
|
||||
rabin_karp<SELF> test;
|
||||
//adler32_cksum<SELF> test;
|
||||
hash_type hash;
|
||||
const uint8_t *ptr;
|
||||
const uint8_t *end;
|
||||
int last_offset;
|
||||
int periods;
|
||||
int stop;
|
||||
|
||||
test_size = buf_size;
|
||||
last_offset = buf_size - cksum_size;
|
||||
|
||||
if (last_offset < 0) {
|
||||
periods = 0;
|
||||
n_steps = 0;
|
||||
n_incrs = 0;
|
||||
stop = -cksum_size;
|
||||
} else {
|
||||
periods = last_offset / cksum_skip;
|
||||
n_steps = periods + 1;
|
||||
n_incrs = last_offset + 1;
|
||||
stop = last_offset - (periods + 1) * cksum_skip;
|
||||
}
|
||||
|
||||
// Compute file stats once.
|
||||
if (fstats.unique_values == 0) {
|
||||
if (cksum_skip == 1) {
|
||||
for (int i = 0; i <= buf_size - cksum_size; i++) {
|
||||
fstats.update(hash(test.step(buf + i), s_bits, s_mask), buf + i);
|
||||
}
|
||||
} else {
|
||||
ptr = buf + last_offset;
|
||||
end = buf + stop;
|
||||
|
||||
for (; ptr != end; ptr -= cksum_skip) {
|
||||
fstats.update(hash(test.step(ptr), s_bits, s_mask), ptr);
|
||||
}
|
||||
}
|
||||
fstats.freeze();
|
||||
}
|
||||
|
||||
long start_test = get_millisecs_now();
|
||||
|
||||
if (cksum_skip != 1) {
|
||||
new_table(n_steps);
|
||||
|
||||
for (int i = 0; i < test_iters; i++) {
|
||||
ptr = buf + last_offset;
|
||||
end = buf + stop;
|
||||
|
||||
for (; ptr != end; ptr -= cksum_skip) {
|
||||
set_table_bit(hash(test.step(ptr), s_bits, s_mask));
|
||||
}
|
||||
}
|
||||
|
||||
summarize_table();
|
||||
}
|
||||
|
||||
stop = buf_size - cksum_size + 1;
|
||||
if (stop < 0) {
|
||||
stop = 0;
|
||||
}
|
||||
|
||||
if (cksum_skip == 1) {
|
||||
|
||||
new_table(n_incrs);
|
||||
|
||||
for (int i = 0; i < test_iters; i++) {
|
||||
ptr = buf;
|
||||
end = buf + stop;
|
||||
|
||||
if (ptr != end) {
|
||||
set_table_bit(hash(test.state0(ptr++), s_bits, s_mask));
|
||||
}
|
||||
|
||||
for (; ptr != end; ptr++) {
|
||||
Word w = test.incr(ptr);
|
||||
assert(w == test.step(ptr));
|
||||
set_table_bit(hash(w, s_bits, s_mask));
|
||||
}
|
||||
}
|
||||
|
||||
summarize_table();
|
||||
}
|
||||
|
||||
accum_iters += test_iters;
|
||||
accum_millis += get_millisecs_now() - start_test;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Word>
|
||||
void print_array(const char *tname) {
|
||||
printf("static const %s hash_multiplier[64] = {\n", tname);
|
||||
Word p = 1;
|
||||
for (int i = 0; i < 64; i++) {
|
||||
printf(" %uU,\n", p);
|
||||
p *= good_word<Word>();
|
||||
}
|
||||
printf("};\n", tname);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int i;
|
||||
uint8_t *buf = NULL;
|
||||
size_t buf_len = 0;
|
||||
int ret;
|
||||
|
||||
if (argc <= 1) {
|
||||
fprintf(stderr, "usage: %s file ...\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//print_array<uint32_t>("uint32_t");
|
||||
|
||||
#define TEST(T,Z,S,P,H,C) test_result<T,Z,S,P,H<T>,C> \
|
||||
_ ## T ## _ ## Z ## _ ## S ## _ ## P ## _ ## H ## _ ## C \
|
||||
(#T "_" #Z "_" #S "_" #P "_" #H "_" #C)
|
||||
|
||||
#if 0
|
||||
|
||||
TEST(uint32_t, 4, SKIP, plain, hhash, 0); /* x */ \
|
||||
TEST(uint32_t, 4, SKIP, plain, hhash, 1); /* x */ \
|
||||
TEST(uint32_t, 4, SKIP, plain, hhash, 2); /* x */ \
|
||||
TEST(uint32_t, 4, SKIP, plain, hhash, 3); /* x */ \
|
||||
|
||||
#endif
|
||||
|
||||
#define TESTS(SKIP) \
|
||||
TEST(uint32_t, 9, SKIP, plain, hhash, 0); /* x */ \
|
||||
TEST(uint32_t, 9, SKIP, plain, hhash, 1); /* x */ \
|
||||
TEST(uint32_t, 9, SKIP, plain, hhash, 2); /* x */ \
|
||||
TEST(uint32_t, 9, SKIP, plain, hhash, 3)
|
||||
|
||||
#define TESTS_ALL(SKIP) \
|
||||
TEST(uint32_t, 3, SKIP, plain, hhash, 0); \
|
||||
TEST(uint32_t, 3, SKIP, plain, hhash, 1); \
|
||||
TEST(uint32_t, 4, SKIP, plain, hhash, 0); /* x */ \
|
||||
TEST(uint32_t, 4, SKIP, plain, hhash, 1); /* x */ \
|
||||
TEST(uint32_t, 4, SKIP, plain, hhash, 2); /* x */ \
|
||||
TEST(uint32_t, 4, SKIP, plain, hhash, 3); /* x */ \
|
||||
TEST(uint32_t, 5, SKIP, plain, hhash, 0); \
|
||||
TEST(uint32_t, 5, SKIP, plain, hhash, 1); \
|
||||
TEST(uint32_t, 8, SKIP, plain, hhash, 0); \
|
||||
TEST(uint32_t, 8, SKIP, plain, hhash, 1); \
|
||||
TEST(uint32_t, 9, SKIP, plain, hhash, 0); /* x */ \
|
||||
TEST(uint32_t, 9, SKIP, plain, hhash, 1); /* x */ \
|
||||
TEST(uint32_t, 9, SKIP, plain, hhash, 2); /* x */ \
|
||||
TEST(uint32_t, 9, SKIP, plain, hhash, 3); /* x */ \
|
||||
TEST(uint32_t, 11, SKIP, plain, hhash, 0); /* x */ \
|
||||
TEST(uint32_t, 11, SKIP, plain, hhash, 1); /* x */ \
|
||||
TEST(uint32_t, 13, SKIP, plain, hhash, 0); \
|
||||
TEST(uint32_t, 13, SKIP, plain, hhash, 1); \
|
||||
TEST(uint32_t, 15, SKIP, plain, hhash, 0); /* x */ \
|
||||
TEST(uint32_t, 15, SKIP, plain, hhash, 1); /* x */ \
|
||||
TEST(uint32_t, 16, SKIP, plain, hhash, 0); /* x */ \
|
||||
TEST(uint32_t, 16, SKIP, plain, hhash, 1); /* x */ \
|
||||
TEST(uint32_t, 21, SKIP, plain, hhash, 0); \
|
||||
TEST(uint32_t, 21, SKIP, plain, hhash, 1); \
|
||||
TEST(uint32_t, 34, SKIP, plain, hhash, 0); \
|
||||
TEST(uint32_t, 34, SKIP, plain, hhash, 1); \
|
||||
TEST(uint32_t, 55, SKIP, plain, hhash, 0); \
|
||||
TEST(uint32_t, 55, SKIP, plain, hhash, 1)
|
||||
|
||||
TESTS(1); // *
|
||||
// TESTS(2); // *
|
||||
// TESTS(3); // *
|
||||
// TESTS(5); // *
|
||||
// TESTS(8); // *
|
||||
// TESTS(9);
|
||||
// TESTS(11);
|
||||
// TESTS(13); // *
|
||||
TESTS(15);
|
||||
// TESTS(16);
|
||||
// TESTS(21); // *
|
||||
// TESTS(34); // *
|
||||
// TESTS(55); // *
|
||||
// TESTS(89); // *
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if ((ret = read_whole_file(argv[i],
|
||||
& buf,
|
||||
& buf_len))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "file %s is %zu bytes\n",
|
||||
argv[i], buf_len);
|
||||
|
||||
double min_time = -1.0;
|
||||
double min_compression = 0.0;
|
||||
|
||||
for (vector<test_result_base*>::iterator i = all_tests.begin();
|
||||
i != all_tests.end(); ++i) {
|
||||
test_result_base *test = *i;
|
||||
test->reset();
|
||||
|
||||
int iters = 100;
|
||||
long start_test = get_millisecs_now();
|
||||
|
||||
do {
|
||||
test->get(buf, buf_len, iters);
|
||||
iters *= 3;
|
||||
iters /= 2;
|
||||
} while (get_millisecs_now() - start_test < 2000);
|
||||
|
||||
test->stat();
|
||||
|
||||
if (min_time < 0.0) {
|
||||
min_compression = test->compression();
|
||||
min_time = test->time();
|
||||
}
|
||||
|
||||
if (min_time > test->time()) {
|
||||
min_time = test->time();
|
||||
}
|
||||
|
||||
if (min_compression > test->compression()) {
|
||||
min_compression = test->compression();
|
||||
}
|
||||
|
||||
test->print();
|
||||
}
|
||||
|
||||
// for (vector<test_result_base*>::iterator i = all_tests.begin();
|
||||
// i != all_tests.end(); ++i) {
|
||||
// test_result_base *test = *i;
|
||||
// test->set_score(min_compression, min_time);
|
||||
// }
|
||||
|
||||
// sort(all_tests.begin(), all_tests.end(), compare_h());
|
||||
|
||||
// for (vector<test_result_base*>::iterator i = all_tests.begin();
|
||||
// i != all_tests.end(); ++i) {
|
||||
// test_result_base *test = *i;
|
||||
// test->print();
|
||||
// }
|
||||
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "xdelta3.h"
|
||||
|
||||
#define NUM (1<<20)
|
||||
#define ITERS 100
|
||||
|
||||
/* From wikipedia on RDTSC */
|
||||
inline uint64_t rdtsc() {
|
||||
uint32_t lo, hi;
|
||||
asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
|
||||
return (uint64_t)hi << 32 | lo;
|
||||
}
|
||||
|
||||
typedef int (*test_func)(const char *s1, const char *s2, int n);
|
||||
|
||||
void run_test(const char *buf1, const char *buf2,
|
||||
const char *name, test_func func) {
|
||||
uint64_t start, end;
|
||||
uint64_t accum = 0;
|
||||
int i, x;
|
||||
|
||||
for (i = 0; i < ITERS; i++) {
|
||||
start = rdtsc();
|
||||
x = func(buf1, buf2, NUM);
|
||||
end = rdtsc();
|
||||
accum += end - start;
|
||||
assert(x == NUM - 1);
|
||||
}
|
||||
|
||||
accum /= ITERS;
|
||||
|
||||
printf("%s : %qu cycles\n", name, accum);
|
||||
}
|
||||
|
||||
/* Build w/ -fno-builtin for this to be fast, this assumes that there
|
||||
* is a difference at s1[n-1] */
|
||||
int memcmp_fake(const char *s1, const char *s2, int n) {
|
||||
int x = memcmp(s1, s2, n);
|
||||
return x < 0 ? n - 1 : n + 1;
|
||||
}
|
||||
|
||||
#define UNALIGNED_OK 1
|
||||
static inline int
|
||||
test2(const char *s1c, const char *s2c, int n)
|
||||
{
|
||||
int i = 0;
|
||||
#if UNALIGNED_OK
|
||||
int nint = n / sizeof(int);
|
||||
|
||||
if (nint >> 3)
|
||||
{
|
||||
int j = 0;
|
||||
const int *s1 = (const int*)s1c;
|
||||
const int *s2 = (const int*)s2c;
|
||||
int nint_8 = nint - 8;
|
||||
|
||||
while (i <= nint_8 &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++]) { }
|
||||
|
||||
i = (i - 1) * sizeof(int);
|
||||
}
|
||||
#endif
|
||||
|
||||
while (i < n && s1c[i] == s2c[i])
|
||||
{
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline int
|
||||
test1(const char *s1c, const char *s2c, int n) {
|
||||
int i = 0;
|
||||
while (i < n && s1c[i] == s2c[i])
|
||||
{
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int main(/*int argc, char **argv*/) {
|
||||
char *buf1 = malloc(NUM+1);
|
||||
char *buf2 = malloc(NUM+1);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM; i++) {
|
||||
buf1[i] = buf2[i] = rand();
|
||||
}
|
||||
|
||||
buf2[NUM-1]++;
|
||||
|
||||
printf ("ALIGNED\n");
|
||||
|
||||
run_test(buf1, buf2, "memcmp", &memcmp_fake);
|
||||
run_test(buf1, buf2, "test1", &test1);
|
||||
run_test(buf1, buf2, "test2", &test2);
|
||||
|
||||
for (i = 0; i < NUM; i++) {
|
||||
buf1[i] = buf2[i+1] = rand();
|
||||
}
|
||||
|
||||
buf2[NUM]++;
|
||||
|
||||
printf ("UNALIGNED\n");
|
||||
|
||||
run_test(buf1, buf2+1, "memcmp", &memcmp_fake);
|
||||
run_test(buf1, buf2+1, "test1", &test1);
|
||||
run_test(buf1, buf2+1, "test2", &test2);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
//
|
||||
// Permission to distribute this example by
|
||||
// Copyright (C) 2007 Ralf Junker
|
||||
// Ralf Junker <delphi@yunqa.de>
|
||||
// http://www.yunqa.de/delphi/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include "xdelta3.h"
|
||||
#include "xdelta3.c"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int code (
|
||||
int encode,
|
||||
FILE* InFile,
|
||||
FILE* SrcFile ,
|
||||
FILE* OutFile,
|
||||
int BufSize )
|
||||
{
|
||||
int r, ret;
|
||||
struct stat statbuf;
|
||||
xd3_stream stream;
|
||||
xd3_config config;
|
||||
xd3_source source;
|
||||
void* Input_Buf;
|
||||
int Input_Buf_Read;
|
||||
|
||||
if (BufSize < XD3_ALLOCSIZE)
|
||||
BufSize = XD3_ALLOCSIZE;
|
||||
|
||||
memset (&stream, 0, sizeof (stream));
|
||||
memset (&source, 0, sizeof (source));
|
||||
|
||||
xd3_init_config(&config, XD3_ADLER32);
|
||||
config.winsize = BufSize;
|
||||
xd3_config_stream(&stream, &config);
|
||||
|
||||
if (SrcFile)
|
||||
{
|
||||
r = fstat(fileno(SrcFile), &statbuf);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
source.blksize = BufSize;
|
||||
source.curblk = malloc(source.blksize);
|
||||
|
||||
/* Load 1st block of stream. */
|
||||
r = fseek(SrcFile, 0, SEEK_SET);
|
||||
if (r)
|
||||
return r;
|
||||
source.onblk = fread((void*)source.curblk, 1, source.blksize, SrcFile);
|
||||
source.curblkno = 0;
|
||||
/* Set the stream. */
|
||||
xd3_set_source(&stream, &source);
|
||||
}
|
||||
|
||||
Input_Buf = malloc(BufSize);
|
||||
|
||||
fseek(InFile, 0, SEEK_SET);
|
||||
do
|
||||
{
|
||||
Input_Buf_Read = fread(Input_Buf, 1, BufSize, InFile);
|
||||
if (Input_Buf_Read < BufSize)
|
||||
{
|
||||
xd3_set_flags(&stream, XD3_FLUSH | stream.flags);
|
||||
}
|
||||
xd3_avail_input(&stream, Input_Buf, Input_Buf_Read);
|
||||
|
||||
process:
|
||||
if (encode)
|
||||
ret = xd3_encode_input(&stream);
|
||||
else
|
||||
ret = xd3_decode_input(&stream);
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
case XD3_INPUT:
|
||||
{
|
||||
fprintf (stderr,"XD3_INPUT\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
case XD3_OUTPUT:
|
||||
{
|
||||
fprintf (stderr,"XD3_OUTPUT\n");
|
||||
r = fwrite(stream.next_out, 1, stream.avail_out, OutFile);
|
||||
if (r != (int)stream.avail_out)
|
||||
return r;
|
||||
xd3_consume_output(&stream);
|
||||
goto process;
|
||||
}
|
||||
|
||||
case XD3_GETSRCBLK:
|
||||
{
|
||||
fprintf (stderr,"XD3_GETSRCBLK %qd\n", source.getblkno);
|
||||
if (SrcFile)
|
||||
{
|
||||
r = fseek(SrcFile, source.blksize * source.getblkno, SEEK_SET);
|
||||
if (r)
|
||||
return r;
|
||||
source.onblk = fread((void*)source.curblk, 1,
|
||||
source.blksize, SrcFile);
|
||||
source.curblkno = source.getblkno;
|
||||
}
|
||||
goto process;
|
||||
}
|
||||
|
||||
case XD3_GOTHEADER:
|
||||
{
|
||||
fprintf (stderr,"XD3_GOTHEADER\n");
|
||||
goto process;
|
||||
}
|
||||
|
||||
case XD3_WINSTART:
|
||||
{
|
||||
fprintf (stderr,"XD3_WINSTART\n");
|
||||
goto process;
|
||||
}
|
||||
|
||||
case XD3_WINFINISH:
|
||||
{
|
||||
fprintf (stderr,"XD3_WINFINISH\n");
|
||||
goto process;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
fprintf (stderr,"!!! INVALID %s %d !!!\n",
|
||||
stream.msg, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
while (Input_Buf_Read == BufSize);
|
||||
|
||||
free(Input_Buf);
|
||||
|
||||
free((void*)source.curblk);
|
||||
xd3_close_stream(&stream);
|
||||
xd3_free_stream(&stream);
|
||||
|
||||
return 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
FILE* InFile;
|
||||
FILE* SrcFile;
|
||||
FILE* OutFile;
|
||||
int r;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf (stderr, "usage: %s source input\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *input = argv[2];
|
||||
char *source = argv[1];
|
||||
const char *output = "encoded.testdata";
|
||||
const char *decoded = "decoded.testdata";
|
||||
|
||||
/* Encode */
|
||||
|
||||
InFile = fopen(input, "rb");
|
||||
SrcFile = fopen(source, "rb");
|
||||
OutFile = fopen(output, "wb");
|
||||
|
||||
r = code (1, InFile, SrcFile, OutFile, 0x1000);
|
||||
|
||||
fclose(OutFile);
|
||||
fclose(SrcFile);
|
||||
fclose(InFile);
|
||||
|
||||
if (r) {
|
||||
fprintf (stderr, "Encode error: %d\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Decode */
|
||||
|
||||
InFile = fopen(output, "rb");
|
||||
SrcFile = fopen(source, "rb");
|
||||
OutFile = fopen(decoded, "wb");
|
||||
|
||||
r = code (0, InFile, SrcFile, OutFile, 0x1000);
|
||||
|
||||
fclose(OutFile);
|
||||
fclose(SrcFile);
|
||||
fclose(InFile);
|
||||
|
||||
if (r) {
|
||||
fprintf (stderr, "Decode error: %d\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,389 +0,0 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
B9001B65158D008900B9E855 /* xdelta3.c in Sources */ = {isa = PBXBuildFile; fileRef = B9001B63158D008900B9E855 /* xdelta3.c */; };
|
||||
B9313C3C158D11BA001C1F28 /* file_v1_to_v2.bin in Resources */ = {isa = PBXBuildFile; fileRef = B9313C39158D11BA001C1F28 /* file_v1_to_v2.bin */; };
|
||||
B9313C3D158D11BA001C1F28 /* file_v1.bin in Resources */ = {isa = PBXBuildFile; fileRef = B9313C3A158D11BA001C1F28 /* file_v1.bin */; };
|
||||
B9313C3E158D11BA001C1F28 /* file_v2.bin in Resources */ = {isa = PBXBuildFile; fileRef = B9313C3B158D11BA001C1F28 /* file_v2.bin */; };
|
||||
B9ADC6BF158CFD36007EF999 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9ADC6BE158CFD36007EF999 /* UIKit.framework */; };
|
||||
B9ADC6C1158CFD36007EF999 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9ADC6C0158CFD36007EF999 /* Foundation.framework */; };
|
||||
B9ADC6C3158CFD36007EF999 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9ADC6C2158CFD36007EF999 /* CoreGraphics.framework */; };
|
||||
B9ADC6C9158CFD36007EF999 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B9ADC6C7158CFD36007EF999 /* InfoPlist.strings */; };
|
||||
B9ADC6CB158CFD36007EF999 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B9ADC6CA158CFD36007EF999 /* main.m */; };
|
||||
B9ADC6CF158CFD36007EF999 /* Xd3iOSAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B9ADC6CE158CFD36007EF999 /* Xd3iOSAppDelegate.m */; };
|
||||
B9ADC6D2158CFD36007EF999 /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9ADC6D0158CFD36007EF999 /* MainStoryboard_iPhone.storyboard */; };
|
||||
B9ADC6D5158CFD36007EF999 /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9ADC6D3158CFD36007EF999 /* MainStoryboard_iPad.storyboard */; };
|
||||
B9ADC6D8158CFD36007EF999 /* Xd3iOSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B9ADC6D7158CFD36007EF999 /* Xd3iOSViewController.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
B9001B56158D008900B9E855 /* xdelta3-blkcache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-blkcache.h"; path = "../../../../xdelta3-blkcache.h"; sourceTree = "<group>"; };
|
||||
B9001B57158D008900B9E855 /* xdelta3-cfgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-cfgs.h"; path = "../../../../xdelta3-cfgs.h"; sourceTree = "<group>"; };
|
||||
B9001B58158D008900B9E855 /* xdelta3-decode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-decode.h"; path = "../../../../xdelta3-decode.h"; sourceTree = "<group>"; };
|
||||
B9001B59158D008900B9E855 /* xdelta3-djw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-djw.h"; path = "../../../../xdelta3-djw.h"; sourceTree = "<group>"; };
|
||||
B9001B5A158D008900B9E855 /* xdelta3-fgk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-fgk.h"; path = "../../../../xdelta3-fgk.h"; sourceTree = "<group>"; };
|
||||
B9001B5B158D008900B9E855 /* xdelta3-hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-hash.h"; path = "../../../../xdelta3-hash.h"; sourceTree = "<group>"; };
|
||||
B9001B5C158D008900B9E855 /* xdelta3-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-internal.h"; path = "../../../../xdelta3-internal.h"; sourceTree = "<group>"; };
|
||||
B9001B5D158D008900B9E855 /* xdelta3-list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-list.h"; path = "../../../../xdelta3-list.h"; sourceTree = "<group>"; };
|
||||
B9001B5E158D008900B9E855 /* xdelta3-main.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-main.h"; path = "../../../../xdelta3-main.h"; sourceTree = "<group>"; };
|
||||
B9001B5F158D008900B9E855 /* xdelta3-merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-merge.h"; path = "../../../../xdelta3-merge.h"; sourceTree = "<group>"; };
|
||||
B9001B60158D008900B9E855 /* xdelta3-python.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-python.h"; path = "../../../../xdelta3-python.h"; sourceTree = "<group>"; };
|
||||
B9001B61158D008900B9E855 /* xdelta3-second.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-second.h"; path = "../../../../xdelta3-second.h"; sourceTree = "<group>"; };
|
||||
B9001B62158D008900B9E855 /* xdelta3-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-test.h"; path = "../../../../xdelta3-test.h"; sourceTree = "<group>"; };
|
||||
B9001B63158D008900B9E855 /* xdelta3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xdelta3.c; path = ../../../../xdelta3.c; sourceTree = "<group>"; };
|
||||
B9001B64158D008900B9E855 /* xdelta3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xdelta3.h; path = ../../../../xdelta3.h; sourceTree = "<group>"; };
|
||||
B9313C39158D11BA001C1F28 /* file_v1_to_v2.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = file_v1_to_v2.bin; sourceTree = "<group>"; };
|
||||
B9313C3A158D11BA001C1F28 /* file_v1.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = file_v1.bin; sourceTree = "<group>"; };
|
||||
B9313C3B158D11BA001C1F28 /* file_v2.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = file_v2.bin; sourceTree = "<group>"; };
|
||||
B9ADC6BA158CFD36007EF999 /* xdelta3-ios-test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "xdelta3-ios-test.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B9ADC6BE158CFD36007EF999 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
B9ADC6C0158CFD36007EF999 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
B9ADC6C2158CFD36007EF999 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
B9ADC6C6158CFD36007EF999 /* xdelta3-ios-test-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "xdelta3-ios-test-Info.plist"; sourceTree = "<group>"; };
|
||||
B9ADC6C8158CFD36007EF999 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
B9ADC6CA158CFD36007EF999 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
B9ADC6CC158CFD36007EF999 /* xdelta3-ios-test-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "xdelta3-ios-test-Prefix.pch"; sourceTree = "<group>"; };
|
||||
B9ADC6CD158CFD36007EF999 /* Xd3iOSAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Xd3iOSAppDelegate.h; sourceTree = "<group>"; };
|
||||
B9ADC6CE158CFD36007EF999 /* Xd3iOSAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Xd3iOSAppDelegate.m; sourceTree = "<group>"; };
|
||||
B9ADC6D1158CFD36007EF999 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = "<group>"; };
|
||||
B9ADC6D4158CFD36007EF999 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = "<group>"; };
|
||||
B9ADC6D6158CFD36007EF999 /* Xd3iOSViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Xd3iOSViewController.h; sourceTree = "<group>"; };
|
||||
B9ADC6D7158CFD36007EF999 /* Xd3iOSViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Xd3iOSViewController.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
B9ADC6B7158CFD36007EF999 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B9ADC6BF158CFD36007EF999 /* UIKit.framework in Frameworks */,
|
||||
B9ADC6C1158CFD36007EF999 /* Foundation.framework in Frameworks */,
|
||||
B9ADC6C3158CFD36007EF999 /* CoreGraphics.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
B9ADC6AF158CFD36007EF999 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9ADC6C4158CFD36007EF999 /* xdelta3-ios-test */,
|
||||
B9ADC6BD158CFD36007EF999 /* Frameworks */,
|
||||
B9ADC6BB158CFD36007EF999 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6BB158CFD36007EF999 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9ADC6BA158CFD36007EF999 /* xdelta3-ios-test.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6BD158CFD36007EF999 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9ADC6BE158CFD36007EF999 /* UIKit.framework */,
|
||||
B9ADC6C0158CFD36007EF999 /* Foundation.framework */,
|
||||
B9ADC6C2158CFD36007EF999 /* CoreGraphics.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6C4158CFD36007EF999 /* xdelta3-ios-test */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9001B56158D008900B9E855 /* xdelta3-blkcache.h */,
|
||||
B9001B57158D008900B9E855 /* xdelta3-cfgs.h */,
|
||||
B9001B58158D008900B9E855 /* xdelta3-decode.h */,
|
||||
B9001B59158D008900B9E855 /* xdelta3-djw.h */,
|
||||
B9001B5A158D008900B9E855 /* xdelta3-fgk.h */,
|
||||
B9001B5B158D008900B9E855 /* xdelta3-hash.h */,
|
||||
B9001B5C158D008900B9E855 /* xdelta3-internal.h */,
|
||||
B9001B5D158D008900B9E855 /* xdelta3-list.h */,
|
||||
B9001B5E158D008900B9E855 /* xdelta3-main.h */,
|
||||
B9001B5F158D008900B9E855 /* xdelta3-merge.h */,
|
||||
B9001B60158D008900B9E855 /* xdelta3-python.h */,
|
||||
B9001B61158D008900B9E855 /* xdelta3-second.h */,
|
||||
B9001B62158D008900B9E855 /* xdelta3-test.h */,
|
||||
B9001B63158D008900B9E855 /* xdelta3.c */,
|
||||
B9001B64158D008900B9E855 /* xdelta3.h */,
|
||||
B9ADC6CD158CFD36007EF999 /* Xd3iOSAppDelegate.h */,
|
||||
B9ADC6CE158CFD36007EF999 /* Xd3iOSAppDelegate.m */,
|
||||
B9ADC6D0158CFD36007EF999 /* MainStoryboard_iPhone.storyboard */,
|
||||
B9ADC6D3158CFD36007EF999 /* MainStoryboard_iPad.storyboard */,
|
||||
B9ADC6D6158CFD36007EF999 /* Xd3iOSViewController.h */,
|
||||
B9ADC6D7158CFD36007EF999 /* Xd3iOSViewController.m */,
|
||||
B9ADC6C5158CFD36007EF999 /* Supporting Files */,
|
||||
);
|
||||
path = "xdelta3-ios-test";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6C5158CFD36007EF999 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9313C39158D11BA001C1F28 /* file_v1_to_v2.bin */,
|
||||
B9313C3A158D11BA001C1F28 /* file_v1.bin */,
|
||||
B9313C3B158D11BA001C1F28 /* file_v2.bin */,
|
||||
B9ADC6C6158CFD36007EF999 /* xdelta3-ios-test-Info.plist */,
|
||||
B9ADC6C7158CFD36007EF999 /* InfoPlist.strings */,
|
||||
B9ADC6CA158CFD36007EF999 /* main.m */,
|
||||
B9ADC6CC158CFD36007EF999 /* xdelta3-ios-test-Prefix.pch */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
B9ADC6B9158CFD36007EF999 /* xdelta3-ios-test */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = B9ADC6DB158CFD36007EF999 /* Build configuration list for PBXNativeTarget "xdelta3-ios-test" */;
|
||||
buildPhases = (
|
||||
B9ADC6B6158CFD36007EF999 /* Sources */,
|
||||
B9ADC6B7158CFD36007EF999 /* Frameworks */,
|
||||
B9ADC6B8158CFD36007EF999 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "xdelta3-ios-test";
|
||||
productName = "xdelta3-ios-test";
|
||||
productReference = B9ADC6BA158CFD36007EF999 /* xdelta3-ios-test.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
B9ADC6B1158CFD36007EF999 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0420;
|
||||
};
|
||||
buildConfigurationList = B9ADC6B4158CFD36007EF999 /* Build configuration list for PBXProject "xdelta3-ios-test" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = B9ADC6AF158CFD36007EF999;
|
||||
productRefGroup = B9ADC6BB158CFD36007EF999 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
B9ADC6B9158CFD36007EF999 /* xdelta3-ios-test */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
B9ADC6B8158CFD36007EF999 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B9ADC6C9158CFD36007EF999 /* InfoPlist.strings in Resources */,
|
||||
B9ADC6D2158CFD36007EF999 /* MainStoryboard_iPhone.storyboard in Resources */,
|
||||
B9ADC6D5158CFD36007EF999 /* MainStoryboard_iPad.storyboard in Resources */,
|
||||
B9313C3C158D11BA001C1F28 /* file_v1_to_v2.bin in Resources */,
|
||||
B9313C3D158D11BA001C1F28 /* file_v1.bin in Resources */,
|
||||
B9313C3E158D11BA001C1F28 /* file_v2.bin in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
B9ADC6B6158CFD36007EF999 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B9ADC6CB158CFD36007EF999 /* main.m in Sources */,
|
||||
B9ADC6CF158CFD36007EF999 /* Xd3iOSAppDelegate.m in Sources */,
|
||||
B9ADC6D8158CFD36007EF999 /* Xd3iOSViewController.m in Sources */,
|
||||
B9001B65158D008900B9E855 /* xdelta3.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
B9ADC6C7158CFD36007EF999 /* InfoPlist.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
B9ADC6C8158CFD36007EF999 /* en */,
|
||||
);
|
||||
name = InfoPlist.strings;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6D0158CFD36007EF999 /* MainStoryboard_iPhone.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
B9ADC6D1158CFD36007EF999 /* en */,
|
||||
);
|
||||
name = MainStoryboard_iPhone.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6D3158CFD36007EF999 /* MainStoryboard_iPad.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
B9ADC6D4158CFD36007EF999 /* en */,
|
||||
);
|
||||
name = MainStoryboard_iPad.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
B9ADC6D9158CFD36007EF999 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_INPUT_FILETYPE = sourcecode.c.objc;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"XD3_USE_LARGEFILE64=0",
|
||||
"XD3_POSIX=1",
|
||||
"EXTERNAL_COMPRESSION=0",
|
||||
"NOT_MAIN=1",
|
||||
"XD3_MAIN=1",
|
||||
"SECONDARY_DJW=1",
|
||||
"XD3_DEBUG=1",
|
||||
"REGRESSION_TEST=1",
|
||||
"SHELL_TESTS=0",
|
||||
"SECONDARY_FGK=1",
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
OTHER_CFLAGS = (
|
||||
"-DXD3_USE_LARGEFILE64=0",
|
||||
"-DXD3_POSIX=1",
|
||||
"-DEXTERNAL_COMPRESSION=0",
|
||||
"-DNOT_MAIN=1",
|
||||
"-DXD3_MAIN=1",
|
||||
"-DSECONDARY_DJW=1",
|
||||
"-DXD3_DEBUG=1",
|
||||
"-DREGRESSION_TEST=1",
|
||||
"-DSHELL_TESTS=0",
|
||||
"-DSECONDARY_FGK=1",
|
||||
);
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
B9ADC6DA158CFD36007EF999 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_INPUT_FILETYPE = sourcecode.c.objc;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"XD3_USE_LARGEFILE64=0",
|
||||
"XD3_POSIX=1",
|
||||
"EXTERNAL_COMPRESSION=0",
|
||||
"NOT_MAIN=1",
|
||||
"XD3_MAIN=1",
|
||||
"SECONDARY_DJW=1",
|
||||
"XD3_DEBUG=1",
|
||||
"REGRESSION_TEST=1",
|
||||
"SHELL_TESTS=0",
|
||||
"SECONDARY_FGK=1",
|
||||
);
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
OTHER_CFLAGS = (
|
||||
"-DXD3_USE_LARGEFILE64=0",
|
||||
"-DXD3_POSIX=1",
|
||||
"-DEXTERNAL_COMPRESSION=0",
|
||||
"-DNOT_MAIN=1",
|
||||
"-DXD3_MAIN=1",
|
||||
"-DSECONDARY_DJW=1",
|
||||
"-DXD3_DEBUG=1",
|
||||
"-DREGRESSION_TEST=1",
|
||||
"-DSHELL_TESTS=0",
|
||||
"-DSECONDARY_FGK=1",
|
||||
);
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
B9ADC6DC158CFD36007EF999 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "xdelta3-ios-test/xdelta3-ios-test-Prefix.pch";
|
||||
INFOPLIST_FILE = "xdelta3-ios-test/xdelta3-ios-test-Info.plist";
|
||||
OTHER_CFLAGS = "";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
B9ADC6DD158CFD36007EF999 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "xdelta3-ios-test/xdelta3-ios-test-Prefix.pch";
|
||||
INFOPLIST_FILE = "xdelta3-ios-test/xdelta3-ios-test-Info.plist";
|
||||
OTHER_CFLAGS = "";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
B9ADC6B4158CFD36007EF999 /* Build configuration list for PBXProject "xdelta3-ios-test" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
B9ADC6D9158CFD36007EF999 /* Debug */,
|
||||
B9ADC6DA158CFD36007EF999 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
B9ADC6DB158CFD36007EF999 /* Build configuration list for PBXNativeTarget "xdelta3-ios-test" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
B9ADC6DC158CFD36007EF999 /* Debug */,
|
||||
B9ADC6DD158CFD36007EF999 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = B9ADC6B1158CFD36007EF999 /* Project object */;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
//
|
||||
// Xd3iOSAppDelegate.h
|
||||
// xdelta3-ios-test
|
||||
//
|
||||
// Created by Joshua MacDonald on 6/16/12.
|
||||
// Copyright (c) 2011, 2012 Joshua MacDonald. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface Xd3iOSAppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
@end
|
|
@ -1,60 +0,0 @@
|
|||
//
|
||||
// Xd3iOSAppDelegate.m
|
||||
// xdelta3-ios-test
|
||||
//
|
||||
// Created by Joshua MacDonald on 6/16/12.
|
||||
// Copyright (c) 2011, 2012 Joshua MacDonald. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Xd3iOSAppDelegate.h"
|
||||
|
||||
@implementation Xd3iOSAppDelegate
|
||||
|
||||
@synthesize window = _window;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Called when the application is about to terminate.
|
||||
Save data if appropriate.
|
||||
See also applicationDidEnterBackground:.
|
||||
*/
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,20 +0,0 @@
|
|||
//
|
||||
// Xd3iOSViewController.h
|
||||
// xdelta3-ios-test
|
||||
//
|
||||
// Created by Joshua MacDonald on 6/16/12.
|
||||
// Copyright (c) 2011, 2012 Joshua MacDonald. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface Xd3iOSViewController : UIViewController <UITextViewDelegate> {
|
||||
NSString *inputSeed;
|
||||
}
|
||||
- (IBAction)startTest:(id)sender;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *theSeed;
|
||||
@property (weak, nonatomic) IBOutlet UITextView *theView;
|
||||
@property (atomic, retain) NSMutableString *theOutput;
|
||||
@property (nonatomic) BOOL inTest;
|
||||
|
||||
@end
|
|
@ -1,169 +0,0 @@
|
|||
//
|
||||
// Xd3iOSViewController.m
|
||||
// xdelta3-ios-test
|
||||
//
|
||||
// Created by Joshua MacDonald on 6/16/12.
|
||||
// Copyright (c) 2011, 2012 Joshua MacDonald. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Xd3iOSViewController.h"
|
||||
#include "xdelta3.h"
|
||||
#include "dispatch/queue.h"
|
||||
#include "Foundation/NSBundle.h"
|
||||
|
||||
extern void (*xprintf_message_func)(const char* msg);
|
||||
void print_to_view(const char* buf);
|
||||
int xd3_main_cmdline(int argc, char **argv);
|
||||
void do_localfile_test(void);
|
||||
int compare_files(const char* file1, const char* file2);
|
||||
Xd3iOSViewController *static_ptr;
|
||||
|
||||
@implementation Xd3iOSViewController
|
||||
@synthesize theSeed = _theSeed;
|
||||
@synthesize theView = _theView;
|
||||
@synthesize theOutput = _theOutput;
|
||||
@synthesize inTest = _inTest;
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
#pragma mark - View lifecycle
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
- (void)viewDidUnload
|
||||
{
|
||||
[self setTheSeed:nil];
|
||||
[self setTheView:nil];
|
||||
[self setTheView:nil];
|
||||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewDidDisappear:animated];
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
switch (interfaceOrientation) {
|
||||
case UIInterfaceOrientationPortrait:
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
return YES;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
- (BOOL)textFieldShouldReturn:(UITextField*)theTextField {
|
||||
if (theTextField == self.theSeed) {
|
||||
[theTextField resignFirstResponder];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
- (IBAction)startTest:(id)sender {
|
||||
if (self.inTest) {
|
||||
return;
|
||||
}
|
||||
self.inTest = YES;
|
||||
NSString *seedString = self.theSeed.text;
|
||||
if ([seedString length] == 0) {
|
||||
seedString = @"RFC3284";
|
||||
}
|
||||
static_ptr = self;
|
||||
xprintf_message_func = &print_to_view;
|
||||
self.theOutput = [[NSMutableString alloc] initWithFormat:@"Starting test (seed=%@)\n", seedString];
|
||||
self.theView.text = self.theOutput;
|
||||
dispatch_queue_t mq = dispatch_get_main_queue();
|
||||
dispatch_queue_t dq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_async(dq, ^{
|
||||
do_localfile_test();
|
||||
char *argv[] = { "xdelta3", "test", NULL };
|
||||
xd3_main_cmdline(2, argv);
|
||||
print_to_view("Finished unittest: success");
|
||||
dispatch_async(mq, ^{
|
||||
self.inTest = NO;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void printns_to_view(NSString* ns);
|
||||
void printns_to_view(NSString* ns) {
|
||||
dispatch_queue_t mq = dispatch_get_main_queue();
|
||||
dispatch_async(mq, ^{
|
||||
if ([static_ptr.theOutput length] < 25000) {
|
||||
[static_ptr.theOutput appendString:ns];
|
||||
} else {
|
||||
static_ptr.theOutput = [[NSMutableString alloc] initWithString:ns];
|
||||
}
|
||||
static_ptr.theView.text = static_ptr.theOutput;
|
||||
CGSize size = static_ptr.theView.contentSize;
|
||||
[static_ptr.theView scrollRectToVisible:CGRectMake(0, size.height - 1, 1, 1) animated:NO];
|
||||
});
|
||||
}
|
||||
|
||||
void print_to_view(const char* buf) {
|
||||
NSString *ns = [NSString stringWithCString:buf encoding:NSASCIIStringEncoding];
|
||||
printns_to_view(ns);
|
||||
}
|
||||
|
||||
void do_localfile_test(void) {
|
||||
NSBundle *bundle;
|
||||
bundle = [NSBundle mainBundle];
|
||||
NSString *localfile1 = [bundle pathForResource:@"file_v1" ofType:@"bin"];
|
||||
NSString *localfile2 = [bundle pathForResource:@"file_v2" ofType:@"bin"];
|
||||
NSString *localfiled = [bundle pathForResource:@"file_v1_to_v2" ofType:@"bin"];
|
||||
printns_to_view([localfile1 stringByAppendingString:@"\n"]);
|
||||
printns_to_view([localfile2 stringByAppendingString:@"\n"]);
|
||||
printns_to_view([localfiled stringByAppendingString:@"\n"]);
|
||||
NSString *tmpdir = NSTemporaryDirectory();
|
||||
NSString *tmpfile = [tmpdir stringByAppendingPathComponent:@"delta.tmp"];
|
||||
printns_to_view([tmpfile stringByAppendingString:@"\n"]);
|
||||
char *argv[] = {
|
||||
"xdelta3", "-dfvv", "-s",
|
||||
(char*)[localfile1 UTF8String],
|
||||
(char*)[localfiled UTF8String],
|
||||
(char*)[tmpfile UTF8String] };
|
||||
xd3_main_cmdline(6, argv);
|
||||
|
||||
NSFileManager *filemgr;
|
||||
|
||||
filemgr = [NSFileManager defaultManager];
|
||||
|
||||
if ([filemgr contentsEqualAtPath: localfile2 andPath: tmpfile] == YES) {
|
||||
printns_to_view(@"File contents match\n");
|
||||
} else {
|
||||
NSError *err1 = NULL;
|
||||
NSDictionary *d1 = [filemgr attributesOfItemAtPath: tmpfile error: &err1];
|
||||
if (err1 != NULL) {
|
||||
printns_to_view([@"File localfile2 could not stat %s\n" stringByAppendingString: tmpfile]);
|
||||
} else {
|
||||
printns_to_view([@"File contents do not match!!!! tmpfile size=" stringByAppendingString:
|
||||
[[NSMutableString alloc] initWithFormat:@"%llu\n", [d1 fileSize]]]);
|
||||
}
|
||||
compare_files([localfile2 UTF8String], [tmpfile UTF8String]);
|
||||
}
|
||||
print_to_view("Finished localfile test.\n");
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,2 +0,0 @@
|
|||
/* Localized versions of Info.plist keys */
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1938" systemVersion="11C74" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="2">
|
||||
<dependencies>
|
||||
<development defaultVersion="4200" identifier="xcode"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="933"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<scene sceneID="4">
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
|
||||
<viewController id="2" customClass="Xd3iOSViewController" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="5">
|
||||
<rect key="frame" x="0.0" y="20" width="768" height="1004"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="d7Y-KS-zOa">
|
||||
<rect key="frame" x="258" y="28" width="197" height="37"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
|
||||
<state key="normal" title="Start test">
|
||||
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<state key="highlighted">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="startTest:" destination="2" eventType="touchUpInside" id="f4X-jg-ZsU"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Random seed" minimumFontSize="17" id="TZ8-OW-wjf">
|
||||
<rect key="frame" x="27" y="28" width="197" height="31"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="2" id="hjY-Ym-Fcw"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" editable="NO" id="LHz-h6-ZBC">
|
||||
<rect key="frame" x="27" y="88" width="721" height="887"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="2" id="fwY-fT-bCV"/>
|
||||
</connections>
|
||||
</textView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.13337372065218178" green="0.1801924475036723" blue="0.21739130434782605" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="theSeed" destination="TZ8-OW-wjf" id="QuA-uT-5IR"/>
|
||||
<outlet property="theView" destination="LHz-h6-ZBC" id="s64-32-fBA"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-601" y="-1021"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<classes>
|
||||
<class className="Xd3iOSViewController" superclassName="UIViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/Xd3iOSViewController.h"/>
|
||||
<relationships>
|
||||
<relationship kind="action" name="startTest:"/>
|
||||
<relationship kind="outlet" name="theSeed" candidateClass="UITextField"/>
|
||||
<relationship kind="outlet" name="theView" candidateClass="UITextView"/>
|
||||
</relationships>
|
||||
</class>
|
||||
</classes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
|
@ -1,27 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1906" systemVersion="11A511" targetRuntime="iOS.CocoaTouch" nextObjectID="6" propertyAccessControl="none" initialViewController="2">
|
||||
<dependencies>
|
||||
<development defaultVersion="4200" identifier="xcode"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="902"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<scene sceneID="5">
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4" sceneMemberID="firstResponder"/>
|
||||
<viewController id="2" customClass="Xd3iOSViewController" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="3">
|
||||
<rect key="frame" x="0.0" y="20" width="320" height="460"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</viewController>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +0,0 @@
|
|||
//
|
||||
// main.m
|
||||
// xdelta3-ios-test
|
||||
//
|
||||
// Created by Joshua MacDonald on 6/16/12.
|
||||
// Copyright (c) 2011, 2012 Joshua MacDonald. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "Xd3iOSAppDelegate.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([Xd3iOSAppDelegate class]));
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array/>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>Joshua-MacDonald.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>MainStoryboard_iPhone</string>
|
||||
<key>UIMainStoryboardFile~ipad</key>
|
||||
<string>MainStoryboard_iPad</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -1,201 +0,0 @@
|
|||
/* Copyright (C) 2007 Josh MacDonald */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
#define SPACE_MAX 131072 // how much memory per process
|
||||
#define OUTPUT_MAX 1024 // max size for output
|
||||
#define XD3_ALLOCSIZE 256 // internal size for various buffers
|
||||
#define IOPT_SIZE 128 // instruction buffer
|
||||
|
||||
// SPACE_MAX of 32K is sufficient for most inputs with XD3_COMPLEVEL_1
|
||||
// XD3_COMPLEVEL_9 requires about 4x more space than XD3_COMPLEVEL_1
|
||||
|
||||
#include "xdelta3.h"
|
||||
#include "xdelta3.c"
|
||||
|
||||
typedef struct _context {
|
||||
uint8_t *buffer;
|
||||
int allocated;
|
||||
} context_t;
|
||||
|
||||
static int max_allocated = 0;
|
||||
|
||||
void*
|
||||
process_alloc (void* opaque, usize_t items, usize_t size)
|
||||
{
|
||||
context_t *ctx = (context_t*) opaque;
|
||||
usize_t t = items * size;
|
||||
void *ret;
|
||||
|
||||
if (ctx->allocated + t > SPACE_MAX)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = ctx->buffer + ctx->allocated;
|
||||
ctx->allocated += t;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
process_free (void* opaque, void *ptr)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
process_page (int is_encode,
|
||||
int (*func) (xd3_stream *),
|
||||
const uint8_t *input,
|
||||
usize_t input_size,
|
||||
const uint8_t *source,
|
||||
uint8_t *output,
|
||||
usize_t *output_size,
|
||||
usize_t output_size_max,
|
||||
int flags) {
|
||||
|
||||
/* On my x86 this is 1072 of objects on the stack */
|
||||
xd3_stream stream;
|
||||
xd3_config config;
|
||||
xd3_source src;
|
||||
context_t *ctx = calloc(SPACE_MAX, 1);
|
||||
int ret;
|
||||
|
||||
memset (&config, 0, sizeof(config));
|
||||
|
||||
if (ctx == NULL)
|
||||
{
|
||||
printf("calloc failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->buffer = (uint8_t*)ctx;
|
||||
ctx->allocated = sizeof(*ctx);
|
||||
|
||||
config.flags = flags;
|
||||
config.winsize = PAGE_SIZE;
|
||||
config.sprevsz = PAGE_SIZE;
|
||||
config.srcwin_maxsz = PAGE_SIZE;
|
||||
config.iopt_size = IOPT_SIZE;
|
||||
config.alloc = &process_alloc;
|
||||
config.freef = &process_free;
|
||||
config.opaque = (void*) ctx;
|
||||
|
||||
src.blksize = PAGE_SIZE;
|
||||
src.onblk = PAGE_SIZE;
|
||||
src.curblk = source;
|
||||
src.curblkno = 0;
|
||||
|
||||
if ((ret = xd3_config_stream (&stream, &config)) != 0 ||
|
||||
(ret = xd3_set_source_and_size (&stream, &src, PAGE_SIZE)) != 0 ||
|
||||
(ret = xd3_process_stream (is_encode,
|
||||
&stream,
|
||||
func, 1,
|
||||
input, input_size,
|
||||
output, output_size,
|
||||
output_size_max)) != 0)
|
||||
{
|
||||
if (stream.msg != NULL)
|
||||
{
|
||||
fprintf(stderr, "stream message: %s\n", stream.msg);
|
||||
}
|
||||
}
|
||||
|
||||
xd3_free_stream (&stream);
|
||||
if (max_allocated < ctx->allocated)
|
||||
{
|
||||
max_allocated = ctx->allocated;
|
||||
fprintf(stderr, "max allocated %d\n", max_allocated);
|
||||
}
|
||||
|
||||
free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test(int stride, int encode_flags)
|
||||
{
|
||||
uint8_t frompg[PAGE_SIZE];
|
||||
uint8_t topg[PAGE_SIZE];
|
||||
uint8_t output[OUTPUT_MAX];
|
||||
uint8_t reout[PAGE_SIZE];
|
||||
usize_t output_size;
|
||||
usize_t re_size;
|
||||
int i, j, ret;
|
||||
|
||||
for (i = 0; i < PAGE_SIZE; i++)
|
||||
{
|
||||
topg[i] = frompg[i] = (rand() >> 3 ^ rand() >> 6 ^ rand() >> 9);
|
||||
}
|
||||
|
||||
// change 1 byte every stride
|
||||
if (stride > 0)
|
||||
{
|
||||
for (j = stride; j <= PAGE_SIZE; j += stride)
|
||||
{
|
||||
topg[j - 1] ^= 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ret = process_page (1, xd3_encode_input,
|
||||
topg, PAGE_SIZE,
|
||||
frompg, output,
|
||||
&output_size, OUTPUT_MAX,
|
||||
encode_flags)) != 0)
|
||||
{
|
||||
fprintf (stderr, "encode failed: stride %u flags 0x%x\n",
|
||||
stride, encode_flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = process_page (0, xd3_decode_input,
|
||||
output, output_size,
|
||||
frompg, reout,
|
||||
&re_size, PAGE_SIZE,
|
||||
0)) != 0)
|
||||
{
|
||||
fprintf (stderr, "decode failed: stride %u output_size %u flags 0x%x\n",
|
||||
stride, output_size, encode_flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (output_size > OUTPUT_MAX || re_size != PAGE_SIZE)
|
||||
{
|
||||
fprintf (stderr, "internal error: %u != %u\n", output_size, re_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < PAGE_SIZE; i++)
|
||||
{
|
||||
if (reout[i] != topg[i])
|
||||
{
|
||||
fprintf (stderr, "encode-decode error: position %d\n", i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "stride %d flags 0x%x size %u ",
|
||||
stride, encode_flags, output_size);
|
||||
fprintf(stderr, "%s\n", (ret == 0) ? "OK" : "FAIL");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int stride;
|
||||
int level;
|
||||
|
||||
for (level = 1; level < 10; level = (level == 1 ? 3 : level + 3))
|
||||
{
|
||||
int lflag = level << XD3_COMPLEVEL_SHIFT;
|
||||
|
||||
for (stride = 2; stride <= PAGE_SIZE; stride += 2)
|
||||
{
|
||||
test(stride, lflag);
|
||||
test(stride, lflag | XD3_SEC_DJW);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
/* Copyright (C) 2007 Josh MacDonald */
|
||||
|
||||
#include "test.h"
|
||||
|
||||
usize_t bench_speed(const uint8_t *from_buf, const size_t from_len,
|
||||
const uint8_t *to_buf, const size_t to_len,
|
||||
uint8_t *delta_buf, const size_t delta_alloc,
|
||||
int flags) {
|
||||
usize_t delta_size;
|
||||
int ret = xd3_encode_memory(to_buf, to_len, from_buf, from_len,
|
||||
delta_buf, &delta_size, delta_alloc, flags);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "encode failure: %d: %s\n", ret, xd3_strerror(ret));
|
||||
abort();
|
||||
}
|
||||
return delta_size;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int repeat, level;
|
||||
char *from, *to;
|
||||
uint8_t *from_buf = NULL, *to_buf = NULL, *delta_buf = NULL;
|
||||
size_t from_len = 0, to_len, delta_alloc, delta_size = 0;
|
||||
long start, finish;
|
||||
int i, ret;
|
||||
int flags;
|
||||
|
||||
if (argc != 5) {
|
||||
fprintf(stderr, "usage: speed_test LEVEL COUNT FROM TO\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
level = atoi(argv[1]);
|
||||
repeat = atoi(argv[2]);
|
||||
from = argv[3];
|
||||
to = argv[4];
|
||||
flags = (level << XD3_COMPLEVEL_SHIFT) & XD3_COMPLEVEL_MASK;
|
||||
|
||||
if ((strcmp(from, "null") != 0 &&
|
||||
(ret = read_whole_file(from, &from_buf, &from_len))) ||
|
||||
(ret = read_whole_file(to, &to_buf, &to_len))) {
|
||||
fprintf(stderr, "read_whole_file error\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
delta_alloc = to_len * 11 / 10;
|
||||
delta_buf = main_malloc(delta_alloc);
|
||||
|
||||
start = get_millisecs_now();
|
||||
|
||||
for (i = 0; i < repeat; ++i) {
|
||||
delta_size = bench_speed(from_buf, from_len,
|
||||
to_buf, to_len, delta_buf, delta_alloc, flags);
|
||||
}
|
||||
|
||||
finish = get_millisecs_now();
|
||||
|
||||
fprintf(stderr,
|
||||
"STAT: encode %3.2f ms from %s to %s repeat %d %zdbit delta %zd\n",
|
||||
(double)(finish - start) / repeat, from, to, repeat, sizeof (xoff_t) * 8, delta_size);
|
||||
|
||||
ret = 0;
|
||||
|
||||
if (0) {
|
||||
exit:
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
main_free(to_buf);
|
||||
main_free(from_buf);
|
||||
main_free(delta_buf);
|
||||
return ret;
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/* Copyright (C) 2007 Josh MacDonald */
|
||||
|
||||
#define NOT_MAIN 1
|
||||
|
||||
#include "xdelta3.h"
|
||||
#include "xdelta3.c"
|
||||
|
||||
static int read_whole_file(const char *name,
|
||||
uint8_t **buf_ptr,
|
||||
size_t *buf_len) {
|
||||
main_file file;
|
||||
int ret;
|
||||
xoff_t len;
|
||||
usize_t nread;
|
||||
main_file_init(&file);
|
||||
file.filename = name;
|
||||
ret = main_file_open(&file, name, XO_READ);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "open failed\n");
|
||||
goto exit;
|
||||
}
|
||||
ret = main_file_stat(&file, &len);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "stat failed\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
(*buf_len) = (size_t)len;
|
||||
(*buf_ptr) = (uint8_t*) main_malloc(*buf_len);
|
||||
ret = main_file_read(&file, *buf_ptr, *buf_len, &nread,
|
||||
"read failed");
|
||||
if (ret == 0 && *buf_len == nread) {
|
||||
ret = 0;
|
||||
} else {
|
||||
fprintf(stderr, "invalid read\n");
|
||||
ret = XD3_INTERNAL;
|
||||
}
|
||||
exit:
|
||||
main_file_cleanup(&file);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,501 +0,0 @@
|
|||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2013-12-25.23; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
tab=' '
|
||||
nl='
|
||||
'
|
||||
IFS=" $tab$nl"
|
||||
|
||||
# Set DOITPROG to "echo" to test this script.
|
||||
|
||||
doit=${DOITPROG-}
|
||||
doit_exec=${doit:-exec}
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
is_target_a_directory=possibly
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t)
|
||||
is_target_a_directory=always
|
||||
dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) is_target_a_directory=never;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# We allow the use of options -d and -T together, by making -d
|
||||
# take the precedence; this is for compatibility with GNU install.
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
if test -n "$dst_arg"; then
|
||||
echo "$0: target directory not allowed when installing a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||
if test ! -d "$dst_arg"; then
|
||||
echo "$0: $dst_arg: Is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test "$is_target_a_directory" = never; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
dstdir=`dirname "$dst"`
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
set +f &&
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
File diff suppressed because it is too large
Load Diff
|
@ -1,84 +0,0 @@
|
|||
# ====================================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_check_aligned_access_required.html
|
||||
# ====================================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AC_CHECK_ALIGNED_ACCESS_REQUIRED
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# While the x86 CPUs allow access to memory objects to be unaligned it
|
||||
# happens that most of the modern designs require objects to be aligned -
|
||||
# or they will fail with a buserror. That mode is quite known by
|
||||
# big-endian machines (sparc, etc) however the alpha cpu is little-
|
||||
# endian.
|
||||
#
|
||||
# The following function will test for aligned access to be required and
|
||||
# set a config.h define HAVE_ALIGNED_ACCESS_REQUIRED (name derived by
|
||||
# standard usage). Structures loaded from a file (or mmapped to memory)
|
||||
# should be accessed per-byte in that case to avoid segfault type errors.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 7
|
||||
|
||||
AC_DEFUN([AX_CHECK_ALIGNED_ACCESS_REQUIRED],
|
||||
[AC_CACHE_CHECK([if pointers to integers require aligned access],
|
||||
[ax_cv_have_aligned_access_required],
|
||||
[AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char* string = malloc(40);
|
||||
int i;
|
||||
for (i=0; i < 40; i++) string[[i]] = i;
|
||||
{
|
||||
void* s = string;
|
||||
int* p = s+1;
|
||||
int* q = s+2;
|
||||
|
||||
if (*p == *q) { return 1; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
],
|
||||
[ax_cv_have_aligned_access_required=yes],
|
||||
[ax_cv_have_aligned_access_required=no],
|
||||
[ax_cv_have_aligned_access_required=no])
|
||||
])
|
||||
if test "$ax_cv_have_aligned_access_required" = yes ; then
|
||||
AC_DEFINE([HAVE_ALIGNED_ACCESS_REQUIRED], [1],
|
||||
[Define if pointers to integers require aligned access])
|
||||
fi
|
||||
])
|
File diff suppressed because it is too large
Load Diff
|
@ -1,437 +0,0 @@
|
|||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
|
||||
# Foundation, Inc.
|
||||
# Written by Gary V. Vaughan, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 8 ltoptions.m4
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
|
||||
|
||||
|
||||
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
|
||||
# ------------------------------------------
|
||||
m4_define([_LT_MANGLE_OPTION],
|
||||
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
|
||||
|
||||
|
||||
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
|
||||
# ---------------------------------------
|
||||
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
|
||||
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
|
||||
# saved as a flag.
|
||||
m4_define([_LT_SET_OPTION],
|
||||
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
|
||||
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
|
||||
_LT_MANGLE_DEFUN([$1], [$2]),
|
||||
[m4_warning([Unknown $1 option '$2'])])[]dnl
|
||||
])
|
||||
|
||||
|
||||
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
|
||||
# ------------------------------------------------------------
|
||||
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||
m4_define([_LT_IF_OPTION],
|
||||
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
|
||||
|
||||
|
||||
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
|
||||
# -------------------------------------------------------
|
||||
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
|
||||
# are set.
|
||||
m4_define([_LT_UNLESS_OPTIONS],
|
||||
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
|
||||
[m4_define([$0_found])])])[]dnl
|
||||
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
|
||||
])[]dnl
|
||||
])
|
||||
|
||||
|
||||
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
|
||||
# ----------------------------------------
|
||||
# OPTION-LIST is a space-separated list of Libtool options associated
|
||||
# with MACRO-NAME. If any OPTION has a matching handler declared with
|
||||
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
|
||||
# the unknown option and exit.
|
||||
m4_defun([_LT_SET_OPTIONS],
|
||||
[# Set options
|
||||
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||
[_LT_SET_OPTION([$1], _LT_Option)])
|
||||
|
||||
m4_if([$1],[LT_INIT],[
|
||||
dnl
|
||||
dnl Simply set some default values (i.e off) if boolean options were not
|
||||
dnl specified:
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
|
||||
])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
|
||||
])
|
||||
dnl
|
||||
dnl If no reference was made to various pairs of opposing options, then
|
||||
dnl we run the default mode handler for the pair. For example, if neither
|
||||
dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
|
||||
dnl archives by default:
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
|
||||
[_LT_ENABLE_FAST_INSTALL])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
|
||||
[_LT_WITH_AIX_SONAME([aix])])
|
||||
])
|
||||
])# _LT_SET_OPTIONS
|
||||
|
||||
|
||||
## --------------------------------- ##
|
||||
## Macros to handle LT_INIT options. ##
|
||||
## --------------------------------- ##
|
||||
|
||||
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
|
||||
# -----------------------------------------
|
||||
m4_define([_LT_MANGLE_DEFUN],
|
||||
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
|
||||
|
||||
|
||||
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
|
||||
# -----------------------------------------------
|
||||
m4_define([LT_OPTION_DEFINE],
|
||||
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
|
||||
])# LT_OPTION_DEFINE
|
||||
|
||||
|
||||
# dlopen
|
||||
# ------
|
||||
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
|
||||
])
|
||||
|
||||
AU_DEFUN([AC_LIBTOOL_DLOPEN],
|
||||
[_LT_SET_OPTION([LT_INIT], [dlopen])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the 'dlopen' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
|
||||
|
||||
|
||||
# win32-dll
|
||||
# ---------
|
||||
# Declare package support for building win32 dll's.
|
||||
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
|
||||
[enable_win32_dll=yes
|
||||
|
||||
case $host in
|
||||
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
|
||||
AC_CHECK_TOOL(AS, as, false)
|
||||
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
|
||||
AC_CHECK_TOOL(OBJDUMP, objdump, false)
|
||||
;;
|
||||
esac
|
||||
|
||||
test -z "$AS" && AS=as
|
||||
_LT_DECL([], [AS], [1], [Assembler program])dnl
|
||||
|
||||
test -z "$DLLTOOL" && DLLTOOL=dlltool
|
||||
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
|
||||
|
||||
test -z "$OBJDUMP" && OBJDUMP=objdump
|
||||
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
|
||||
])# win32-dll
|
||||
|
||||
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
_LT_SET_OPTION([LT_INIT], [win32-dll])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the 'win32-dll' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
|
||||
|
||||
|
||||
# _LT_ENABLE_SHARED([DEFAULT])
|
||||
# ----------------------------
|
||||
# implement the --enable-shared flag, and supports the 'shared' and
|
||||
# 'disable-shared' LT_INIT options.
|
||||
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
|
||||
m4_define([_LT_ENABLE_SHARED],
|
||||
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([shared],
|
||||
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
|
||||
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_shared=yes ;;
|
||||
no) enable_shared=no ;;
|
||||
*)
|
||||
enable_shared=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
|
||||
for pkg in $enableval; do
|
||||
IFS=$lt_save_ifs
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_shared=yes
|
||||
fi
|
||||
done
|
||||
IFS=$lt_save_ifs
|
||||
;;
|
||||
esac],
|
||||
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
|
||||
|
||||
_LT_DECL([build_libtool_libs], [enable_shared], [0],
|
||||
[Whether or not to build shared libraries])
|
||||
])# _LT_ENABLE_SHARED
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
|
||||
|
||||
# Old names:
|
||||
AC_DEFUN([AC_ENABLE_SHARED],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_DISABLE_SHARED],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-shared])
|
||||
])
|
||||
|
||||
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
|
||||
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
|
||||
|
||||
|
||||
|
||||
# _LT_ENABLE_STATIC([DEFAULT])
|
||||
# ----------------------------
|
||||
# implement the --enable-static flag, and support the 'static' and
|
||||
# 'disable-static' LT_INIT options.
|
||||
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
|
||||
m4_define([_LT_ENABLE_STATIC],
|
||||
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([static],
|
||||
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
|
||||
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_static=yes ;;
|
||||
no) enable_static=no ;;
|
||||
*)
|
||||
enable_static=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
|
||||
for pkg in $enableval; do
|
||||
IFS=$lt_save_ifs
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_static=yes
|
||||
fi
|
||||
done
|
||||
IFS=$lt_save_ifs
|
||||
;;
|
||||
esac],
|
||||
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
|
||||
|
||||
_LT_DECL([build_old_libs], [enable_static], [0],
|
||||
[Whether or not to build static libraries])
|
||||
])# _LT_ENABLE_STATIC
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
|
||||
|
||||
# Old names:
|
||||
AC_DEFUN([AC_ENABLE_STATIC],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_DISABLE_STATIC],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-static])
|
||||
])
|
||||
|
||||
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
|
||||
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
|
||||
|
||||
|
||||
|
||||
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
|
||||
# ----------------------------------
|
||||
# implement the --enable-fast-install flag, and support the 'fast-install'
|
||||
# and 'disable-fast-install' LT_INIT options.
|
||||
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
|
||||
m4_define([_LT_ENABLE_FAST_INSTALL],
|
||||
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([fast-install],
|
||||
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
|
||||
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_fast_install=yes ;;
|
||||
no) enable_fast_install=no ;;
|
||||
*)
|
||||
enable_fast_install=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
|
||||
for pkg in $enableval; do
|
||||
IFS=$lt_save_ifs
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_fast_install=yes
|
||||
fi
|
||||
done
|
||||
IFS=$lt_save_ifs
|
||||
;;
|
||||
esac],
|
||||
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
|
||||
|
||||
_LT_DECL([fast_install], [enable_fast_install], [0],
|
||||
[Whether or not to optimize for fast installation])dnl
|
||||
])# _LT_ENABLE_FAST_INSTALL
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
|
||||
|
||||
# Old names:
|
||||
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||
the 'fast-install' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||
the 'disable-fast-install' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
|
||||
|
||||
|
||||
# _LT_WITH_AIX_SONAME([DEFAULT])
|
||||
# ----------------------------------
|
||||
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
|
||||
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
|
||||
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
|
||||
m4_define([_LT_WITH_AIX_SONAME],
|
||||
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
|
||||
shared_archive_member_spec=
|
||||
case $host,$enable_shared in
|
||||
power*-*-aix[[5-9]]*,yes)
|
||||
AC_MSG_CHECKING([which variant of shared library versioning to provide])
|
||||
AC_ARG_WITH([aix-soname],
|
||||
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
|
||||
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
|
||||
[case $withval in
|
||||
aix|svr4|both)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
|
||||
;;
|
||||
esac
|
||||
lt_cv_with_aix_soname=$with_aix_soname],
|
||||
[AC_CACHE_VAL([lt_cv_with_aix_soname],
|
||||
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
|
||||
with_aix_soname=$lt_cv_with_aix_soname])
|
||||
AC_MSG_RESULT([$with_aix_soname])
|
||||
if test aix != "$with_aix_soname"; then
|
||||
# For the AIX way of multilib, we name the shared archive member
|
||||
# based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
|
||||
# and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
|
||||
# Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
|
||||
# the AIX toolchain works better with OBJECT_MODE set (default 32).
|
||||
if test 64 = "${OBJECT_MODE-32}"; then
|
||||
shared_archive_member_spec=shr_64
|
||||
else
|
||||
shared_archive_member_spec=shr
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
with_aix_soname=aix
|
||||
;;
|
||||
esac
|
||||
|
||||
_LT_DECL([], [shared_archive_member_spec], [0],
|
||||
[Shared archive member basename, for filename based shared library versioning on AIX])dnl
|
||||
])# _LT_WITH_AIX_SONAME
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
|
||||
|
||||
|
||||
# _LT_WITH_PIC([MODE])
|
||||
# --------------------
|
||||
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
|
||||
# LT_INIT options.
|
||||
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
|
||||
m4_define([_LT_WITH_PIC],
|
||||
[AC_ARG_WITH([pic],
|
||||
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
|
||||
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
|
||||
[lt_p=${PACKAGE-default}
|
||||
case $withval in
|
||||
yes|no) pic_mode=$withval ;;
|
||||
*)
|
||||
pic_mode=default
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
|
||||
for lt_pkg in $withval; do
|
||||
IFS=$lt_save_ifs
|
||||
if test "X$lt_pkg" = "X$lt_p"; then
|
||||
pic_mode=yes
|
||||
fi
|
||||
done
|
||||
IFS=$lt_save_ifs
|
||||
;;
|
||||
esac],
|
||||
[pic_mode=m4_default([$1], [default])])
|
||||
|
||||
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
|
||||
])# _LT_WITH_PIC
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
|
||||
|
||||
# Old name:
|
||||
AU_DEFUN([AC_LIBTOOL_PICMODE],
|
||||
[_LT_SET_OPTION([LT_INIT], [pic-only])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the 'pic-only' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
|
||||
|
||||
## ----------------- ##
|
||||
## LTDL_INIT Options ##
|
||||
## ----------------- ##
|
||||
|
||||
m4_define([_LTDL_MODE], [])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
|
||||
[m4_define([_LTDL_MODE], [nonrecursive])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
|
||||
[m4_define([_LTDL_MODE], [recursive])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
|
||||
[m4_define([_LTDL_MODE], [subproject])])
|
||||
|
||||
m4_define([_LTDL_TYPE], [])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [installable],
|
||||
[m4_define([_LTDL_TYPE], [installable])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
|
||||
[m4_define([_LTDL_TYPE], [convenience])])
|
|
@ -1,124 +0,0 @@
|
|||
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
|
||||
# Foundation, Inc.
|
||||
# Written by Gary V. Vaughan, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 6 ltsugar.m4
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
|
||||
|
||||
|
||||
# lt_join(SEP, ARG1, [ARG2...])
|
||||
# -----------------------------
|
||||
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
|
||||
# associated separator.
|
||||
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
|
||||
# versions in m4sugar had bugs.
|
||||
m4_define([lt_join],
|
||||
[m4_if([$#], [1], [],
|
||||
[$#], [2], [[$2]],
|
||||
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
|
||||
m4_define([_lt_join],
|
||||
[m4_if([$#$2], [2], [],
|
||||
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
|
||||
|
||||
|
||||
# lt_car(LIST)
|
||||
# lt_cdr(LIST)
|
||||
# ------------
|
||||
# Manipulate m4 lists.
|
||||
# These macros are necessary as long as will still need to support
|
||||
# Autoconf-2.59, which quotes differently.
|
||||
m4_define([lt_car], [[$1]])
|
||||
m4_define([lt_cdr],
|
||||
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
|
||||
[$#], 1, [],
|
||||
[m4_dquote(m4_shift($@))])])
|
||||
m4_define([lt_unquote], $1)
|
||||
|
||||
|
||||
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
|
||||
# ------------------------------------------
|
||||
# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
|
||||
# Note that neither SEPARATOR nor STRING are expanded; they are appended
|
||||
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
|
||||
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
|
||||
# than defined and empty).
|
||||
#
|
||||
# This macro is needed until we can rely on Autoconf 2.62, since earlier
|
||||
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
|
||||
m4_define([lt_append],
|
||||
[m4_define([$1],
|
||||
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
|
||||
|
||||
|
||||
|
||||
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
|
||||
# ----------------------------------------------------------
|
||||
# Produce a SEP delimited list of all paired combinations of elements of
|
||||
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
|
||||
# has the form PREFIXmINFIXSUFFIXn.
|
||||
# Needed until we can rely on m4_combine added in Autoconf 2.62.
|
||||
m4_define([lt_combine],
|
||||
[m4_if(m4_eval([$# > 3]), [1],
|
||||
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
|
||||
[[m4_foreach([_Lt_prefix], [$2],
|
||||
[m4_foreach([_Lt_suffix],
|
||||
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
|
||||
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
|
||||
|
||||
|
||||
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
|
||||
# -----------------------------------------------------------------------
|
||||
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
|
||||
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
|
||||
m4_define([lt_if_append_uniq],
|
||||
[m4_ifdef([$1],
|
||||
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
|
||||
[lt_append([$1], [$2], [$3])$4],
|
||||
[$5])],
|
||||
[lt_append([$1], [$2], [$3])$4])])
|
||||
|
||||
|
||||
# lt_dict_add(DICT, KEY, VALUE)
|
||||
# -----------------------------
|
||||
m4_define([lt_dict_add],
|
||||
[m4_define([$1($2)], [$3])])
|
||||
|
||||
|
||||
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
|
||||
# --------------------------------------------
|
||||
m4_define([lt_dict_add_subkey],
|
||||
[m4_define([$1($2:$3)], [$4])])
|
||||
|
||||
|
||||
# lt_dict_fetch(DICT, KEY, [SUBKEY])
|
||||
# ----------------------------------
|
||||
m4_define([lt_dict_fetch],
|
||||
[m4_ifval([$3],
|
||||
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
|
||||
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
|
||||
|
||||
|
||||
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
|
||||
# -----------------------------------------------------------------
|
||||
m4_define([lt_if_dict_fetch],
|
||||
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
|
||||
[$5],
|
||||
[$6])])
|
||||
|
||||
|
||||
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
|
||||
# --------------------------------------------------------------
|
||||
m4_define([lt_dict_filter],
|
||||
[m4_if([$5], [], [],
|
||||
[lt_join(m4_quote(m4_default([$4], [[, ]])),
|
||||
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
|
||||
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
|
||||
])
|
|
@ -1,23 +0,0 @@
|
|||
# ltversion.m4 -- version numbers -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
|
||||
# Written by Scott James Remnant, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# @configure_input@
|
||||
|
||||
# serial 4179 ltversion.m4
|
||||
# This file is part of GNU Libtool
|
||||
|
||||
m4_define([LT_PACKAGE_VERSION], [2.4.6])
|
||||
m4_define([LT_PACKAGE_REVISION], [2.4.6])
|
||||
|
||||
AC_DEFUN([LTVERSION_VERSION],
|
||||
[macro_version='2.4.6'
|
||||
macro_revision='2.4.6'
|
||||
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
|
||||
_LT_DECL(, macro_revision, 0)
|
||||
])
|
|
@ -1,99 +0,0 @@
|
|||
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
|
||||
# Foundation, Inc.
|
||||
# Written by Scott James Remnant, 2004.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 5 lt~obsolete.m4
|
||||
|
||||
# These exist entirely to fool aclocal when bootstrapping libtool.
|
||||
#
|
||||
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
|
||||
# which have later been changed to m4_define as they aren't part of the
|
||||
# exported API, or moved to Autoconf or Automake where they belong.
|
||||
#
|
||||
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
|
||||
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
|
||||
# using a macro with the same name in our local m4/libtool.m4 it'll
|
||||
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
|
||||
# and doesn't know about Autoconf macros at all.)
|
||||
#
|
||||
# So we provide this file, which has a silly filename so it's always
|
||||
# included after everything else. This provides aclocal with the
|
||||
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
|
||||
# because those macros already exist, or will be overwritten later.
|
||||
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
||||
#
|
||||
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
|
||||
# Yes, that means every name once taken will need to remain here until
|
||||
# we give up compatibility with versions before 1.7, at which point
|
||||
# we need to keep only those names which we still refer to.
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
|
||||
|
||||
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
|
||||
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
|
||||
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
|
||||
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
|
||||
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
|
||||
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
|
||||
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
|
||||
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
|
||||
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
|
||||
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
|
||||
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
|
||||
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
|
||||
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
|
||||
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
|
||||
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
|
||||
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
|
||||
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
|
||||
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
|
||||
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
|
||||
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
|
||||
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
|
||||
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
|
||||
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
|
||||
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
|
||||
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
|
||||
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
|
||||
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
|
||||
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
|
||||
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
|
||||
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
|
||||
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
|
||||
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
|
||||
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
|
||||
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
|
||||
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
|
||||
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
|
||||
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
|
||||
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
|
||||
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
|
||||
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
|
|
@ -1,215 +0,0 @@
|
|||
#! /bin/sh
|
||||
# Common wrapper for a few potentially missing GNU programs.
|
||||
|
||||
scriptversion=2013-10-28.13; # UTC
|
||||
|
||||
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
|
||||
--is-lightweight)
|
||||
# Used by our autoconf macros to check whether the available missing
|
||||
# script is modern enough.
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--run)
|
||||
# Back-compat with the calling convention used by older automake.
|
||||
shift
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
|
||||
to PROGRAM being missing or too old.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal autoconf autoheader autom4te automake makeinfo
|
||||
bison yacc flex lex help2man
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
|
||||
'g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: unknown '$1' option"
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# Run the given program, remember its exit status.
|
||||
"$@"; st=$?
|
||||
|
||||
# If it succeeded, we are done.
|
||||
test $st -eq 0 && exit 0
|
||||
|
||||
# Also exit now if we it failed (or wasn't found), and '--version' was
|
||||
# passed; such an option is passed most likely to detect whether the
|
||||
# program is present and works.
|
||||
case $2 in --version|--help) exit $st;; esac
|
||||
|
||||
# Exit code 63 means version mismatch. This often happens when the user
|
||||
# tries to use an ancient version of a tool on a file that requires a
|
||||
# minimum version.
|
||||
if test $st -eq 63; then
|
||||
msg="probably too old"
|
||||
elif test $st -eq 127; then
|
||||
# Program was missing.
|
||||
msg="missing on your system"
|
||||
else
|
||||
# Program was found and executed, but failed. Give up.
|
||||
exit $st
|
||||
fi
|
||||
|
||||
perl_URL=http://www.perl.org/
|
||||
flex_URL=http://flex.sourceforge.net/
|
||||
gnu_software_URL=http://www.gnu.org/software
|
||||
|
||||
program_details ()
|
||||
{
|
||||
case $1 in
|
||||
aclocal|automake)
|
||||
echo "The '$1' program is part of the GNU Automake package:"
|
||||
echo "<$gnu_software_URL/automake>"
|
||||
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/autoconf>"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
autoconf|autom4te|autoheader)
|
||||
echo "The '$1' program is part of the GNU Autoconf package:"
|
||||
echo "<$gnu_software_URL/autoconf/>"
|
||||
echo "It also requires GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
give_advice ()
|
||||
{
|
||||
# Normalize program name to check for.
|
||||
normalized_program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
printf '%s\n' "'$1' is $msg."
|
||||
|
||||
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
|
||||
case $normalized_program in
|
||||
autoconf*)
|
||||
echo "You should only need it if you modified 'configure.ac',"
|
||||
echo "or m4 files included by it."
|
||||
program_details 'autoconf'
|
||||
;;
|
||||
autoheader*)
|
||||
echo "You should only need it if you modified 'acconfig.h' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'autoheader'
|
||||
;;
|
||||
automake*)
|
||||
echo "You should only need it if you modified 'Makefile.am' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'automake'
|
||||
;;
|
||||
aclocal*)
|
||||
echo "You should only need it if you modified 'acinclude.m4' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'aclocal'
|
||||
;;
|
||||
autom4te*)
|
||||
echo "You might have modified some maintainer files that require"
|
||||
echo "the 'autom4te' program to be rebuilt."
|
||||
program_details 'autom4te'
|
||||
;;
|
||||
bison*|yacc*)
|
||||
echo "You should only need it if you modified a '.y' file."
|
||||
echo "You may want to install the GNU Bison package:"
|
||||
echo "<$gnu_software_URL/bison/>"
|
||||
;;
|
||||
lex*|flex*)
|
||||
echo "You should only need it if you modified a '.l' file."
|
||||
echo "You may want to install the Fast Lexical Analyzer package:"
|
||||
echo "<$flex_URL>"
|
||||
;;
|
||||
help2man*)
|
||||
echo "You should only need it if you modified a dependency" \
|
||||
"of a man page."
|
||||
echo "You may want to install the GNU Help2man package:"
|
||||
echo "<$gnu_software_URL/help2man/>"
|
||||
;;
|
||||
makeinfo*)
|
||||
echo "You should only need it if you modified a '.texi' file, or"
|
||||
echo "any other file indirectly affecting the aspect of the manual."
|
||||
echo "You might want to install the Texinfo package:"
|
||||
echo "<$gnu_software_URL/texinfo/>"
|
||||
echo "The spurious makeinfo call might also be the consequence of"
|
||||
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
|
||||
echo "want to install GNU make:"
|
||||
echo "<$gnu_software_URL/make/>"
|
||||
;;
|
||||
*)
|
||||
echo "You might have modified some files without having the proper"
|
||||
echo "tools for further handling them. Check the 'README' file, it"
|
||||
echo "often tells you about the needed prerequisites for installing"
|
||||
echo "this package. You may also peek at any GNU archive site, in"
|
||||
echo "case some other package contains this missing '$1' program."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
give_advice "$1" | sed -e '1s/^/WARNING: /' \
|
||||
-e '2,$s/^/ /' >&2
|
||||
|
||||
# Propagate the correct exit status (expected to be 127 for a program
|
||||
# not found, 63 for a program that failed due to version mismatch).
|
||||
exit $st
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
|
@ -1,265 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run from the source dir.
|
||||
SRCDIR=${PWD}
|
||||
|
||||
# TODO replace w/ wget
|
||||
LZMA="xz-5.2.1"
|
||||
LZMA_FILE="${SRCDIR}/../${LZMA}.tar.xz"
|
||||
|
||||
MAKEFLAGS="-j 10"
|
||||
|
||||
BUILDDIR=${SRCDIR}/build
|
||||
LZMASRC=${BUILDDIR}/${LZMA}
|
||||
|
||||
NONWIN_CFLAGS=""
|
||||
MINGW_CFLAGS="-DEXTERNAL_COMPRESSION=0 -DXD3_WIN32=1 -DSHELL_TESTS=0"
|
||||
|
||||
MYOS=`uname`
|
||||
DATE=`date`
|
||||
|
||||
CLEAN=""
|
||||
|
||||
LINUXTGTS=""
|
||||
LINUXTEST1=""
|
||||
LINUXTEST2=""
|
||||
|
||||
WINTGTS=""
|
||||
WINTEST1=""
|
||||
WINTEST2=""
|
||||
|
||||
OSXTGTS=""
|
||||
OSXTEST1=""
|
||||
OSXTEST2=""
|
||||
|
||||
XTMP="/tmp"
|
||||
if [ "${TMP}" != "" ]; then
|
||||
XTMP="${TMP}"
|
||||
fi
|
||||
if [ "${TMPDIR}" != "" ]; then
|
||||
XTMP="${TMPDIR}"
|
||||
fi
|
||||
|
||||
find build -type f 2> /dev/null | xargs rm -f
|
||||
|
||||
function setup {
|
||||
libtoolize
|
||||
automake --add-missing
|
||||
aclocal -I m4
|
||||
automake
|
||||
autoheader
|
||||
autoconf
|
||||
}
|
||||
|
||||
function try {
|
||||
local w=$1
|
||||
shift
|
||||
local dir=$1
|
||||
shift
|
||||
echo -n " ${w} ... "
|
||||
(cd "${dir}" && "$@" >${w}.stdout 2>${w}.stderr)
|
||||
local s=$?
|
||||
if [ ${s} -eq 0 ]; then
|
||||
echo " success"
|
||||
else
|
||||
echo " failed!"
|
||||
echo "Error $1 in ${dir}" >&2
|
||||
fi
|
||||
return ${s}
|
||||
}
|
||||
|
||||
function buildlzma {
|
||||
host=$1
|
||||
march=$2
|
||||
local target="${BUILDDIR}/lib-${host}${march}"
|
||||
|
||||
echo " ... liblzma"
|
||||
|
||||
mkdir -p ${target}
|
||||
|
||||
try configure-lzma ${target} ${LZMASRC}/configure \
|
||||
--host=${host} \
|
||||
--prefix=${target} \
|
||||
--disable-shared \
|
||||
"CFLAGS=${march}" \
|
||||
"CXXFLAGS=${march}" \
|
||||
"LDFLAGS=${march}"
|
||||
if [ $? -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
try build-lzma ${target} make ${MAKEFLAGS}
|
||||
if [ $? -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
try install-lzma ${target} make install
|
||||
if [ $? -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
function buildit {
|
||||
local host=$1
|
||||
local march=$2
|
||||
local offsetbits=$3
|
||||
local cargs=$4
|
||||
local afl=$5
|
||||
local BM="${host}${march}"
|
||||
local USECC="${CC}"
|
||||
local USECXX="${CXX}"
|
||||
local LIBBM="${BM}"
|
||||
|
||||
if [ "${afl}" = "1" ]; then
|
||||
USECC="afl-gcc"
|
||||
USECXX="afl-g++"
|
||||
BM="${BM}-afl"
|
||||
fi
|
||||
|
||||
local D="build/${BM}/xoff${offsetbits}"
|
||||
local BMD="${BM}-${offsetbits}"
|
||||
local FULLD="${SRCDIR}/${D}"
|
||||
local CFLAGS="${march} ${cargs} -I${SRCDIR}/build/lib-${LIBBM}/include"
|
||||
local CXXFLAGS="${march} ${cargs} -I${SRCDIR}/build/lib-${LIBBM}/include"
|
||||
local CPPFLAGS="-I${SRCDIR}/build/lib-${LIBBM}/include"
|
||||
local LDFLAGS="${march} -L${SRCDIR}/build/lib-${LIBBM}/lib"
|
||||
|
||||
mkdir -p ${D}
|
||||
|
||||
echo " ... ${BMD}"
|
||||
|
||||
cat >> Makefile.test <<EOF
|
||||
|
||||
# ${BMD}
|
||||
# ${CFLAGS}
|
||||
.PHONY: build-${BMD}
|
||||
build-${BMD}:
|
||||
(cd ${D} && make all && make install)
|
||||
|
||||
.PHONY: clean-${BMD}
|
||||
clean-${BMD}:
|
||||
(cd ${D} && make clean)
|
||||
|
||||
.PHONY: regtest-${BMD}
|
||||
regtest-${BMD}:
|
||||
(cd ${D} && ./xdelta3regtest 1> \${TMP}/regtest.${BMD}.stdout 2> \${TMP}/regtest.${BMD}.stderr)
|
||||
|
||||
.PHONY: selftest-${BMD}
|
||||
selftest-${BMD}:
|
||||
(cd ${D} && ./bin/xdelta3 test 1> \${TMP}/selftest.${BMD}.stdout 2> \${TMP}/selftest.${BMD}.stderr)
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
case ${host} in
|
||||
*linux*)
|
||||
LINUXTGTS="${LINUXTGTS} build-${BMD}"
|
||||
LINUXTEST1="${LINUXTEST1} selftest-${BMD}"
|
||||
LINUXTEST2="${LINUXTEST2} regtest-${BMD}"
|
||||
;;
|
||||
*mingw*)
|
||||
WINTGTS="${WINTGTS} build-${BMD}"
|
||||
WINTEST1="${WINTEST1} selftest-${BMD}"
|
||||
WINTEST2="${WINTEST2} regtest-${BMD}"
|
||||
;;
|
||||
*apple*)
|
||||
OSXTGTS="${OSXTGTS} build-${BMD}"
|
||||
OSXTEST1="${OSXTEST1} selftest-${BMD}"
|
||||
OSXTEST2="${OSXTEST2} regtest-${BMD}"
|
||||
;;
|
||||
esac
|
||||
CLEAN="${CLEAN} clean-${BMD}"
|
||||
|
||||
try configure-xdelta ${FULLD} ${SRCDIR}/configure \
|
||||
--host=${host} \
|
||||
--prefix=${FULLD} \
|
||||
--enable-static \
|
||||
--disable-shared \
|
||||
--enable-debug-symbols \
|
||||
"CFLAGS=${CFLAGS}" \
|
||||
"CXXFLAGS=${CXXFLAGS}" \
|
||||
"CPPFLAGS=${CPPFLAGS}" \
|
||||
"LDFLAGS=${LDFLAGS}" \
|
||||
"CC=${USECC}" \
|
||||
"CXX=${USECXX}"
|
||||
if [ $? -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# try build-xdelta ${FULLD} make ${MAKEFLAGS} all
|
||||
# if [ $? -ne 0 ]; then
|
||||
# return
|
||||
# fi
|
||||
|
||||
# try install-xdelta ${FULLD} make install
|
||||
}
|
||||
|
||||
function buildall {
|
||||
echo ""
|
||||
echo "Host $1$2 afl=$4"
|
||||
echo ""
|
||||
|
||||
buildlzma "$1" "$2"
|
||||
buildit "$1" "$2" 32 "-DXD3_USE_LARGEFILE64=0 $3" "$4"
|
||||
buildit "$1" "$2" 64 "-DXD3_USE_LARGEFILE64=1 $3" "$4"
|
||||
}
|
||||
|
||||
setup
|
||||
|
||||
try untar-lzma ${BUILDDIR} tar -xvf "${LZMA_FILE}"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $?
|
||||
fi
|
||||
|
||||
cat > Makefile.test <<EOF
|
||||
# Auto-generated ${DATE} -*- Mode: Makefile -*-
|
||||
TMP = ${XTMP}
|
||||
|
||||
all: linux windows apple
|
||||
|
||||
EOF
|
||||
|
||||
# Native compiles
|
||||
if [ "${MYOS}" == "Linux" ]; then
|
||||
# Linux
|
||||
buildall x86_64-pc-linux-gnu -m32 "${NONWIN_CFLAGS}" "0"
|
||||
buildall x86_64-pc-linux-gnu -m32 "${NONWIN_CFLAGS}" "1"
|
||||
buildall x86_64-pc-linux-gnu -m64 "${NONWIN_CFLAGS}" "0"
|
||||
buildall x86_64-pc-linux-gnu -m64 "${NONWIN_CFLAGS}" "1"
|
||||
fi
|
||||
|
||||
if [ "${MYOS}" == "Darwin" ]; then
|
||||
# OS X
|
||||
buildall x86_64-apple-darwin -m32 "${NONWIN_CFLAGS}" "0"
|
||||
buildall x86_64-apple-darwin -m64 "${NONWIN_CFLAGS}" "0"
|
||||
fi
|
||||
|
||||
# Cross compile
|
||||
buildall i686-w64-mingw32 -mconsole "${MINGW_CFLAGS}" "0"
|
||||
buildall x86_64-w64-mingw32 -mconsole "${MINGW_CFLAGS}" "0"
|
||||
|
||||
cat >> Makefile.test <<EOF
|
||||
|
||||
clean: ${CLEAN}
|
||||
|
||||
.PHONY: linux windows apple
|
||||
.PHONY: linux-build windows-build apple-build
|
||||
.PHONY: linux-selftest windows-selftest apple-selftest
|
||||
.PHONY: linux-regtest windows-regtest apple-regtest
|
||||
|
||||
linux: linux-build linux-selftest linux-regtest
|
||||
windows: windows-build windows-selftest windows-regtest
|
||||
apple: apple-build apple-selftest apple-regtest
|
||||
|
||||
linux-build: ${LINUXTGTS}
|
||||
linux-selftest: ${LINUXTEST1}
|
||||
linux-regtest: ${LINUXTEST2}
|
||||
|
||||
windows-build: ${WINTGTS}
|
||||
windows-selftest: ${WINTEST1}
|
||||
windows-regtest: ${WINTEST2}
|
||||
|
||||
apple-build: ${OSXTGTS}
|
||||
apple-selftest: ${OSXTEST1}
|
||||
apple-regtest: ${OSXTEST2}
|
||||
|
||||
EOF
|
|
@ -1,561 +0,0 @@
|
|||
/* xdelta 3 - delta compression tools and library
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||
* 2008, 2009, 2010
|
||||
* Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* TODO: This code is heavily revised from 3.0z but still needs major
|
||||
* refactoring. */
|
||||
|
||||
#include "xdelta3-internal.h"
|
||||
|
||||
typedef struct _main_blklru main_blklru;
|
||||
typedef struct _main_blklru_list main_blklru_list;
|
||||
|
||||
struct _main_blklru_list
|
||||
{
|
||||
main_blklru_list *next;
|
||||
main_blklru_list *prev;
|
||||
};
|
||||
|
||||
struct _main_blklru
|
||||
{
|
||||
uint8_t *blk;
|
||||
xoff_t blkno;
|
||||
usize_t size;
|
||||
main_blklru_list link;
|
||||
};
|
||||
|
||||
XD3_MAKELIST(main_blklru_list,main_blklru,link);
|
||||
|
||||
static usize_t lru_size = 0;
|
||||
static main_blklru *lru = NULL; /* array of lru_size elts */
|
||||
static main_blklru_list lru_list;
|
||||
static int do_src_fifo = 0; /* set to avoid lru */
|
||||
|
||||
static int lru_hits = 0;
|
||||
static int lru_misses = 0;
|
||||
static int lru_filled = 0;
|
||||
|
||||
static void main_lru_reset (void)
|
||||
{
|
||||
lru_size = 0;
|
||||
lru = NULL;
|
||||
do_src_fifo = 0;
|
||||
lru_hits = 0;
|
||||
lru_misses = 0;
|
||||
lru_filled = 0;
|
||||
}
|
||||
|
||||
static void main_lru_cleanup (void)
|
||||
{
|
||||
if (lru != NULL)
|
||||
{
|
||||
main_buffree (lru[0].blk);
|
||||
}
|
||||
|
||||
main_free (lru);
|
||||
lru = NULL;
|
||||
|
||||
lru_hits = 0;
|
||||
lru_misses = 0;
|
||||
lru_filled = 0;
|
||||
}
|
||||
|
||||
/* This is called at different times for encoding and decoding. The
|
||||
* encoder calls it immediately, the decoder delays until the
|
||||
* application header is received. */
|
||||
static int
|
||||
main_set_source (xd3_stream *stream, xd3_cmd cmd,
|
||||
main_file *sfile, xd3_source *source)
|
||||
{
|
||||
int ret = 0;
|
||||
usize_t i;
|
||||
xoff_t source_size = 0;
|
||||
usize_t blksize;
|
||||
|
||||
XD3_ASSERT (lru == NULL);
|
||||
XD3_ASSERT (stream->src == NULL);
|
||||
XD3_ASSERT (option_srcwinsz >= XD3_MINSRCWINSZ);
|
||||
|
||||
/* TODO: this code needs refactoring into FIFO, LRU, FAKE. Yuck!
|
||||
* This is simplified from 3.0z which had issues with sizing the
|
||||
* source buffer memory allocation and the source blocksize. */
|
||||
|
||||
/* LRU-specific */
|
||||
main_blklru_list_init (& lru_list);
|
||||
|
||||
if (allow_fake_source)
|
||||
{
|
||||
/* TODO: refactor
|
||||
* TOOLS/recode-specific: Check "allow_fake_source" mode looks
|
||||
* broken now. */
|
||||
sfile->mode = XO_READ;
|
||||
sfile->realname = sfile->filename;
|
||||
sfile->nread = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Either a regular file (possibly compressed) or a FIFO
|
||||
* (possibly compressed). */
|
||||
if ((ret = main_file_open (sfile, sfile->filename, XO_READ)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* If the file is regular we know it's size. If the file turns
|
||||
* out to be externally compressed, size_known may change. */
|
||||
sfile->size_known = (main_file_stat (sfile, &source_size) == 0);
|
||||
}
|
||||
|
||||
/* Note: The API requires a power-of-two blocksize and srcwinsz
|
||||
* (-B). The logic here will use a single block if the entire file
|
||||
* is known to fit into srcwinsz. */
|
||||
option_srcwinsz = xd3_pow2_roundup (option_srcwinsz);
|
||||
|
||||
/* Though called "lru", it is not LRU-specific. We always allocate
|
||||
* a maximum number of source block buffers. If the entire file
|
||||
* fits into srcwinsz, this buffer will stay as the only
|
||||
* (lru_size==1) source block. Otherwise, we know that at least
|
||||
* option_srcwinsz bytes are available. Split the source window
|
||||
* into buffers. */
|
||||
if ((lru = (main_blklru*) main_malloc (MAX_LRU_SIZE *
|
||||
sizeof (main_blklru))) == NULL)
|
||||
{
|
||||
ret = ENOMEM;
|
||||
return ret;
|
||||
}
|
||||
|
||||
memset (lru, 0, sizeof(lru[0]) * MAX_LRU_SIZE);
|
||||
|
||||
/* Allocate the entire buffer. */
|
||||
if ((lru[0].blk = (uint8_t*) main_bufalloc (option_srcwinsz)) == NULL)
|
||||
{
|
||||
ret = ENOMEM;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Main calls main_getblk_func() once before xd3_set_source(). This
|
||||
* is the point at which external decompression may begin. Set the
|
||||
* system for a single block. */
|
||||
lru_size = 1;
|
||||
lru[0].blkno = (xoff_t) -1;
|
||||
blksize = option_srcwinsz;
|
||||
main_blklru_list_push_back (& lru_list, & lru[0]);
|
||||
XD3_ASSERT (blksize != 0);
|
||||
|
||||
/* Initialize xd3_source. */
|
||||
source->blksize = blksize;
|
||||
source->name = sfile->filename;
|
||||
source->ioh = sfile;
|
||||
source->curblkno = (xoff_t) -1;
|
||||
source->curblk = NULL;
|
||||
source->max_winsize = option_srcwinsz;
|
||||
|
||||
if ((ret = main_getblk_func (stream, source, 0)) != 0)
|
||||
{
|
||||
XPR(NT "error reading source: %s: %s\n",
|
||||
sfile->filename,
|
||||
xd3_mainerror (ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
source->onblk = lru[0].size; /* xd3 sets onblk */
|
||||
|
||||
/* If the file is smaller than a block, size is known. */
|
||||
if (!sfile->size_known && source->onblk < blksize)
|
||||
{
|
||||
source_size = source->onblk;
|
||||
source->onlastblk = source_size;
|
||||
sfile->size_known = 1;
|
||||
}
|
||||
|
||||
/* If the size is not known or is greater than the buffer size, we
|
||||
* split the buffer across MAX_LRU_SIZE blocks (already allocated in
|
||||
* "lru"). */
|
||||
if (!sfile->size_known || source_size > option_srcwinsz)
|
||||
{
|
||||
/* Modify block 0, change blocksize. */
|
||||
blksize = option_srcwinsz / MAX_LRU_SIZE;
|
||||
source->blksize = blksize;
|
||||
source->onblk = blksize;
|
||||
source->onlastblk = blksize;
|
||||
source->max_blkno = MAX_LRU_SIZE - 1;
|
||||
|
||||
lru[0].size = blksize;
|
||||
lru_size = MAX_LRU_SIZE;
|
||||
|
||||
/* Setup rest of blocks. */
|
||||
for (i = 1; i < lru_size; i += 1)
|
||||
{
|
||||
lru[i].blk = lru[0].blk + (blksize * i);
|
||||
lru[i].blkno = i;
|
||||
lru[i].size = blksize;
|
||||
main_blklru_list_push_back (& lru_list, & lru[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (! sfile->size_known)
|
||||
{
|
||||
/* If the size is not know, we must use FIFO discipline. */
|
||||
do_src_fifo = 1;
|
||||
}
|
||||
|
||||
/* Call the appropriate set_source method, handle errors, print
|
||||
* verbose message, etc. */
|
||||
if (sfile->size_known)
|
||||
{
|
||||
ret = xd3_set_source_and_size (stream, source, source_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = xd3_set_source (stream, source);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
XPR(NT XD3_LIB_ERRMSG (stream, ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
XD3_ASSERT (stream->src == source);
|
||||
XD3_ASSERT (source->blksize == blksize);
|
||||
|
||||
if (option_verbose)
|
||||
{
|
||||
static shortbuf srcszbuf;
|
||||
static shortbuf srccntbuf;
|
||||
static shortbuf winszbuf;
|
||||
static shortbuf blkszbuf;
|
||||
static shortbuf nbufs;
|
||||
|
||||
if (sfile->size_known)
|
||||
{
|
||||
short_sprintf (srcszbuf, "source size %s [%"Q"u]",
|
||||
main_format_bcnt (source_size, &srccntbuf),
|
||||
source_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
short_sprintf (srcszbuf, "%s", "source size unknown");
|
||||
}
|
||||
|
||||
nbufs.buf[0] = 0;
|
||||
|
||||
if (option_verbose > 1)
|
||||
{
|
||||
short_sprintf (nbufs, " #bufs %u", lru_size);
|
||||
}
|
||||
|
||||
XPR(NT "source %s %s blksize %s window %s%s%s\n",
|
||||
sfile->filename,
|
||||
srcszbuf.buf,
|
||||
main_format_bcnt (blksize, &blkszbuf),
|
||||
main_format_bcnt (option_srcwinsz, &winszbuf),
|
||||
nbufs.buf,
|
||||
do_src_fifo ? " (FIFO)" : "");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
main_getblk_lru (xd3_source *source, xoff_t blkno,
|
||||
main_blklru** blrup, int *is_new)
|
||||
{
|
||||
main_blklru *blru = NULL;
|
||||
usize_t i;
|
||||
|
||||
(*is_new) = 0;
|
||||
|
||||
if (do_src_fifo)
|
||||
{
|
||||
/* Direct lookup assumes sequential scan w/o skipping blocks. */
|
||||
int idx = blkno % lru_size;
|
||||
blru = & lru[idx];
|
||||
if (blru->blkno == blkno)
|
||||
{
|
||||
(*blrup) = blru;
|
||||
return 0;
|
||||
}
|
||||
/* No going backwards in a sequential scan. */
|
||||
if (blru->blkno != (xoff_t) -1 && blru->blkno > blkno)
|
||||
{
|
||||
return XD3_TOOFARBACK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Sequential search through LRU. */
|
||||
for (i = 0; i < lru_size; i += 1)
|
||||
{
|
||||
blru = & lru[i];
|
||||
if (blru->blkno == blkno)
|
||||
{
|
||||
main_blklru_list_remove (blru);
|
||||
main_blklru_list_push_back (& lru_list, blru);
|
||||
(*blrup) = blru;
|
||||
IF_DEBUG1 (DP(RINT "[getblk_lru] HIT blkno = %"Z"u lru_size=%d\n",
|
||||
blkno, lru_size));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
IF_DEBUG1 (DP(RINT "[getblk_lru] MISS blkno = %"Z"u lru_size=%d\n",
|
||||
blkno, lru_size));
|
||||
}
|
||||
|
||||
if (do_src_fifo)
|
||||
{
|
||||
int idx = blkno % lru_size;
|
||||
blru = & lru[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
XD3_ASSERT (! main_blklru_list_empty (& lru_list));
|
||||
blru = main_blklru_list_pop_front (& lru_list);
|
||||
main_blklru_list_push_back (& lru_list, blru);
|
||||
}
|
||||
|
||||
lru_filled += 1;
|
||||
(*is_new) = 1;
|
||||
(*blrup) = blru;
|
||||
blru->blkno = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
main_read_seek_source (xd3_stream *stream,
|
||||
xd3_source *source,
|
||||
xoff_t blkno) {
|
||||
xoff_t pos = blkno * source->blksize;
|
||||
main_file *sfile = (main_file*) source->ioh;
|
||||
main_blklru *blru;
|
||||
int is_new;
|
||||
size_t nread = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (!sfile->seek_failed)
|
||||
{
|
||||
ret = main_file_seek (sfile, pos);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
sfile->source_position = pos;
|
||||
}
|
||||
}
|
||||
|
||||
if (sfile->seek_failed || ret != 0)
|
||||
{
|
||||
/* For an unseekable file (or other seek error, does it
|
||||
* matter?) */
|
||||
if (sfile->source_position > pos)
|
||||
{
|
||||
/* Could assert !IS_ENCODE(), this shouldn't happen
|
||||
* because of do_src_fifo during encode. */
|
||||
if (!option_quiet)
|
||||
{
|
||||
XPR(NT "source can't seek backwards; requested block offset "
|
||||
"%"Q"u source position is %"Q"u\n",
|
||||
pos, sfile->source_position);
|
||||
}
|
||||
|
||||
sfile->seek_failed = 1;
|
||||
stream->msg = "non-seekable source: "
|
||||
"copy is too far back (try raising -B)";
|
||||
return XD3_TOOFARBACK;
|
||||
}
|
||||
|
||||
/* There's a chance here, that an genuine lseek error will cause
|
||||
* xdelta3 to shift into non-seekable mode, entering a degraded
|
||||
* condition. */
|
||||
if (!sfile->seek_failed && option_verbose)
|
||||
{
|
||||
XPR(NT "source can't seek, will use FIFO for %s\n",
|
||||
sfile->filename);
|
||||
|
||||
if (option_verbose > 1)
|
||||
{
|
||||
XPR(NT "seek error at offset %"Q"u: %s\n",
|
||||
pos, xd3_mainerror (ret));
|
||||
}
|
||||
}
|
||||
|
||||
sfile->seek_failed = 1;
|
||||
|
||||
if (option_verbose > 1 && pos != sfile->source_position)
|
||||
{
|
||||
XPR(NT "non-seekable source skipping %"Q"u bytes @ %"Q"u\n",
|
||||
pos - sfile->source_position,
|
||||
sfile->source_position);
|
||||
}
|
||||
|
||||
while (sfile->source_position < pos)
|
||||
{
|
||||
xoff_t skip_blkno;
|
||||
usize_t skip_offset;
|
||||
|
||||
xd3_blksize_div (sfile->source_position, source,
|
||||
&skip_blkno, &skip_offset);
|
||||
|
||||
/* Read past unused data */
|
||||
XD3_ASSERT (pos - sfile->source_position >= source->blksize);
|
||||
XD3_ASSERT (skip_offset == 0);
|
||||
|
||||
if ((ret = main_getblk_lru (source, skip_blkno,
|
||||
& blru, & is_new)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
XD3_ASSERT (is_new);
|
||||
blru->blkno = skip_blkno;
|
||||
|
||||
if ((ret = main_read_primary_input (sfile,
|
||||
(uint8_t*) blru->blk,
|
||||
source->blksize,
|
||||
& nread)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (nread != source->blksize)
|
||||
{
|
||||
IF_DEBUG1 (DP(RINT "[getblk] short skip block nread = %"Z"u\n",
|
||||
nread));
|
||||
stream->msg = "non-seekable input is short";
|
||||
return XD3_INVALID_INPUT;
|
||||
}
|
||||
|
||||
sfile->source_position += nread;
|
||||
blru->size = nread;
|
||||
|
||||
IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q"u size %u\n",
|
||||
skip_blkno, blru->size));
|
||||
|
||||
XD3_ASSERT (sfile->source_position <= pos);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is the callback for reading a block of source. This function
|
||||
* is blocking and it implements a small LRU.
|
||||
*
|
||||
* Note that it is possible for main_input() to handle getblk requests
|
||||
* in a non-blocking manner. If the callback is NULL then the caller
|
||||
* of xd3_*_input() must handle the XD3_GETSRCBLK return value and
|
||||
* fill the source in the same way. See xd3_getblk for details. To
|
||||
* see an example of non-blocking getblk, see xdelta-test.h. */
|
||||
static int
|
||||
main_getblk_func (xd3_stream *stream,
|
||||
xd3_source *source,
|
||||
xoff_t blkno)
|
||||
{
|
||||
int ret = 0;
|
||||
xoff_t pos = blkno * source->blksize;
|
||||
main_file *sfile = (main_file*) source->ioh;
|
||||
main_blklru *blru;
|
||||
int is_new;
|
||||
size_t nread = 0;
|
||||
|
||||
if (allow_fake_source)
|
||||
{
|
||||
source->curblkno = blkno;
|
||||
source->onblk = 0;
|
||||
source->curblk = lru[0].blk;
|
||||
lru[0].size = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((ret = main_getblk_lru (source, blkno, & blru, & is_new)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!is_new)
|
||||
{
|
||||
source->curblkno = blkno;
|
||||
source->onblk = blru->size;
|
||||
source->curblk = blru->blk;
|
||||
lru_hits++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
lru_misses += 1;
|
||||
|
||||
if (pos != sfile->source_position)
|
||||
{
|
||||
/* Only try to seek when the position is wrong. This means the
|
||||
* decoder will fail when the source buffer is too small, but
|
||||
* only when the input is non-seekable. */
|
||||
if ((ret = main_read_seek_source (stream, source, blkno)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
XD3_ASSERT (sfile->source_position == pos);
|
||||
|
||||
if ((ret = main_read_primary_input (sfile,
|
||||
(uint8_t*) blru->blk,
|
||||
source->blksize,
|
||||
& nread)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Save the last block read, used to handle non-seekable files. */
|
||||
sfile->source_position = pos + nread;
|
||||
|
||||
if (option_verbose > 3)
|
||||
{
|
||||
if (blru->blkno != (xoff_t)-1)
|
||||
{
|
||||
if (blru->blkno != blkno)
|
||||
{
|
||||
XPR(NT "source block %"Q"u read %"Z"u ejects %"Q"u (lru_hits=%u, "
|
||||
"lru_misses=%u, lru_filled=%u)\n",
|
||||
blkno, nread, blru->blkno, lru_hits, lru_misses, lru_filled);
|
||||
}
|
||||
else
|
||||
{
|
||||
XPR(NT "source block %"Q"u read %"Z"u (lru_hits=%u, "
|
||||
"lru_misses=%u, lru_filled=%u)\n",
|
||||
blkno, nread, lru_hits, lru_misses, lru_filled);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XPR(NT "source block %"Q"u read %"Z"u (lru_hits=%u, lru_misses=%u, "
|
||||
"lru_filled=%u)\n", blkno, nread,
|
||||
lru_hits, lru_misses, lru_filled);
|
||||
}
|
||||
}
|
||||
|
||||
source->curblk = blru->blk;
|
||||
source->curblkno = blkno;
|
||||
source->onblk = nread;
|
||||
blru->size = nread;
|
||||
blru->blkno = blkno;
|
||||
|
||||
IF_DEBUG1 (DP(RINT "[main_getblk] blkno %"Q"u onblk %"Z"u pos %"Q"u "
|
||||
"srcpos %"Q"u\n",
|
||||
blkno, nread, pos, sfile->source_position));
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
/* xdelta 3 - delta compression tools and library
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007. Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/******************************************************************
|
||||
SOFT string matcher
|
||||
******************************************************************/
|
||||
|
||||
#if XD3_BUILD_SOFT
|
||||
|
||||
#define TEMPLATE soft
|
||||
#define LLOOK stream->smatcher.large_look
|
||||
#define LSTEP stream->smatcher.large_step
|
||||
#define SLOOK stream->smatcher.small_look
|
||||
#define SCHAIN stream->smatcher.small_chain
|
||||
#define SLCHAIN stream->smatcher.small_lchain
|
||||
#define MAXLAZY stream->smatcher.max_lazy
|
||||
#define LONGENOUGH stream->smatcher.long_enough
|
||||
|
||||
#define SOFTCFG 1
|
||||
#include "xdelta3.c"
|
||||
#undef SOFTCFG
|
||||
|
||||
#undef TEMPLATE
|
||||
#undef LLOOK
|
||||
#undef SLOOK
|
||||
#undef LSTEP
|
||||
#undef SCHAIN
|
||||
#undef SLCHAIN
|
||||
#undef MAXLAZY
|
||||
#undef LONGENOUGH
|
||||
#endif
|
||||
|
||||
#define SOFTCFG 0
|
||||
|
||||
/************************************************************
|
||||
FASTEST string matcher
|
||||
**********************************************************/
|
||||
#if XD3_BUILD_FASTEST
|
||||
#define TEMPLATE fastest
|
||||
#define LLOOK 9
|
||||
#define LSTEP 26
|
||||
#define SLOOK 4U
|
||||
#define SCHAIN 1
|
||||
#define SLCHAIN 1
|
||||
#define MAXLAZY 6
|
||||
#define LONGENOUGH 6
|
||||
|
||||
#include "xdelta3.c"
|
||||
|
||||
#undef TEMPLATE
|
||||
#undef LLOOK
|
||||
#undef SLOOK
|
||||
#undef LSTEP
|
||||
#undef SCHAIN
|
||||
#undef SLCHAIN
|
||||
#undef MAXLAZY
|
||||
#undef LONGENOUGH
|
||||
#endif
|
||||
|
||||
/************************************************************
|
||||
FASTER string matcher
|
||||
**********************************************************/
|
||||
#if XD3_BUILD_FASTER
|
||||
#define TEMPLATE faster
|
||||
#define LLOOK 9
|
||||
#define LSTEP 15
|
||||
#define SLOOK 4U
|
||||
#define SCHAIN 1
|
||||
#define SLCHAIN 1
|
||||
#define MAXLAZY 18
|
||||
#define LONGENOUGH 18
|
||||
|
||||
#include "xdelta3.c"
|
||||
|
||||
#undef TEMPLATE
|
||||
#undef LLOOK
|
||||
#undef SLOOK
|
||||
#undef LSTEP
|
||||
#undef SCHAIN
|
||||
#undef SLCHAIN
|
||||
#undef MAXLAZY
|
||||
#undef LONGENOUGH
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
FAST string matcher
|
||||
********************************************************/
|
||||
#if XD3_BUILD_FAST
|
||||
#define TEMPLATE fast
|
||||
#define LLOOK 9
|
||||
#define LSTEP 8
|
||||
#define SLOOK 4U
|
||||
#define SCHAIN 4
|
||||
#define SLCHAIN 1
|
||||
#define MAXLAZY 18
|
||||
#define LONGENOUGH 35
|
||||
|
||||
#include "xdelta3.c"
|
||||
|
||||
#undef TEMPLATE
|
||||
#undef LLOOK
|
||||
#undef SLOOK
|
||||
#undef LSTEP
|
||||
#undef SCHAIN
|
||||
#undef SLCHAIN
|
||||
#undef MAXLAZY
|
||||
#undef LONGENOUGH
|
||||
#endif
|
||||
|
||||
/**************************************************
|
||||
SLOW string matcher
|
||||
**************************************************************/
|
||||
#if XD3_BUILD_SLOW
|
||||
#define TEMPLATE slow
|
||||
#define LLOOK 9
|
||||
#define LSTEP 2
|
||||
#define SLOOK 4U
|
||||
#define SCHAIN 44
|
||||
#define SLCHAIN 13
|
||||
#define MAXLAZY 90
|
||||
#define LONGENOUGH 70
|
||||
|
||||
#include "xdelta3.c"
|
||||
|
||||
#undef TEMPLATE
|
||||
#undef LLOOK
|
||||
#undef SLOOK
|
||||
#undef LSTEP
|
||||
#undef SCHAIN
|
||||
#undef SLCHAIN
|
||||
#undef MAXLAZY
|
||||
#undef LONGENOUGH
|
||||
#endif
|
||||
|
||||
/********************************************************
|
||||
DEFAULT string matcher
|
||||
************************************************************/
|
||||
#if XD3_BUILD_DEFAULT
|
||||
#define TEMPLATE default
|
||||
#define LLOOK 9
|
||||
#define LSTEP 3
|
||||
#define SLOOK 4U
|
||||
#define SCHAIN 8
|
||||
#define SLCHAIN 2
|
||||
#define MAXLAZY 36
|
||||
#define LONGENOUGH 70
|
||||
|
||||
#include "xdelta3.c"
|
||||
|
||||
#undef TEMPLATE
|
||||
#undef LLOOK
|
||||
#undef SLOOK
|
||||
#undef LSTEP
|
||||
#undef SCHAIN
|
||||
#undef SLCHAIN
|
||||
#undef MAXLAZY
|
||||
#undef LONGENOUGH
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,860 +0,0 @@
|
|||
/* xdelta 3 - delta compression tools and library
|
||||
* Copyright (C) 2002, 2006, 2007. Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* For demonstration purposes only.
|
||||
*/
|
||||
|
||||
#ifndef _XDELTA3_FGK_h_
|
||||
#define _XDELTA3_FGK_h_
|
||||
|
||||
/* An implementation of the FGK algorithm described by D.E. Knuth in
|
||||
* "Dynamic Huffman Coding" in Journal of Algorithms 6. */
|
||||
|
||||
/* A 32bit counter (fgk_weight) is used as the frequency counter for
|
||||
* nodes in the huffman tree. TODO: Need oto test for overflow and/or
|
||||
* reset stats. */
|
||||
|
||||
typedef struct _fgk_stream fgk_stream;
|
||||
typedef struct _fgk_node fgk_node;
|
||||
typedef struct _fgk_block fgk_block;
|
||||
typedef unsigned int fgk_bit;
|
||||
typedef uint32_t fgk_weight;
|
||||
|
||||
struct _fgk_block {
|
||||
union {
|
||||
fgk_node *un_leader;
|
||||
fgk_block *un_freeptr;
|
||||
} un;
|
||||
};
|
||||
|
||||
#define block_leader un.un_leader
|
||||
#define block_freeptr un.un_freeptr
|
||||
|
||||
/* The code can also support fixed huffman encoding/decoding. */
|
||||
#define IS_ADAPTIVE 1
|
||||
|
||||
/* weight is a count of the number of times this element has been seen
|
||||
* in the current encoding/decoding. parent, right_child, and
|
||||
* left_child are pointers defining the tree structure. right and
|
||||
* left point to neighbors in an ordered sequence of weights. The
|
||||
* left child of a node is always guaranteed to have weight not
|
||||
* greater than its sibling. fgk_blockLeader points to the element
|
||||
* with the same weight as itself which is closest to the next
|
||||
* increasing weight block. */
|
||||
struct _fgk_node
|
||||
{
|
||||
fgk_weight weight;
|
||||
fgk_node *parent;
|
||||
fgk_node *left_child;
|
||||
fgk_node *right_child;
|
||||
fgk_node *left;
|
||||
fgk_node *right;
|
||||
fgk_block *my_block;
|
||||
};
|
||||
|
||||
/* alphabet_size is the a count of the number of possible leaves in
|
||||
* the huffman tree. The number of total nodes counting internal
|
||||
* nodes is ((2 * alphabet_size) - 1). zero_freq_count is the number
|
||||
* of elements remaining which have zero frequency. zero_freq_exp and
|
||||
* zero_freq_rem satisfy the equation zero_freq_count =
|
||||
* 2^zero_freq_exp + zero_freq_rem. root_node is the root of the
|
||||
* tree, which is initialized to a node with zero frequency and
|
||||
* contains the 0th such element. free_node contains a pointer to the
|
||||
* next available fgk_node space. alphabet contains all the elements
|
||||
* and is indexed by N. remaining_zeros points to the head of the
|
||||
* list of zeros. */
|
||||
struct _fgk_stream
|
||||
{
|
||||
usize_t alphabet_size;
|
||||
usize_t zero_freq_count;
|
||||
usize_t zero_freq_exp;
|
||||
usize_t zero_freq_rem;
|
||||
usize_t coded_depth;
|
||||
|
||||
usize_t total_nodes;
|
||||
usize_t total_blocks;
|
||||
|
||||
fgk_bit *coded_bits;
|
||||
|
||||
fgk_block *block_array;
|
||||
fgk_block *free_block;
|
||||
|
||||
fgk_node *decode_ptr;
|
||||
fgk_node *remaining_zeros;
|
||||
fgk_node *alphabet;
|
||||
fgk_node *root_node;
|
||||
fgk_node *free_node;
|
||||
};
|
||||
|
||||
/*********************************************************************/
|
||||
/* Encoder */
|
||||
/*********************************************************************/
|
||||
|
||||
static fgk_stream* fgk_alloc (xd3_stream *stream /*, usize_t alphabet_size */);
|
||||
static int fgk_init (xd3_stream *stream,
|
||||
fgk_stream *h,
|
||||
int is_encode);
|
||||
static int fgk_encode_data (fgk_stream *h,
|
||||
usize_t n);
|
||||
static inline fgk_bit fgk_get_encoded_bit (fgk_stream *h);
|
||||
|
||||
static int xd3_encode_fgk (xd3_stream *stream,
|
||||
fgk_stream *sec_stream,
|
||||
xd3_output *input,
|
||||
xd3_output *output,
|
||||
xd3_sec_cfg *cfg);
|
||||
|
||||
/*********************************************************************/
|
||||
/* Decoder */
|
||||
/*********************************************************************/
|
||||
|
||||
static inline int fgk_decode_bit (fgk_stream *h,
|
||||
fgk_bit b);
|
||||
static int fgk_decode_data (fgk_stream *h);
|
||||
static void fgk_destroy (xd3_stream *stream,
|
||||
fgk_stream *h);
|
||||
|
||||
static int xd3_decode_fgk (xd3_stream *stream,
|
||||
fgk_stream *sec_stream,
|
||||
const uint8_t **input,
|
||||
const uint8_t *const input_end,
|
||||
uint8_t **output,
|
||||
const uint8_t *const output_end);
|
||||
|
||||
/*********************************************************************/
|
||||
/* Private */
|
||||
/*********************************************************************/
|
||||
|
||||
static unsigned int fgk_find_nth_zero (fgk_stream *h, usize_t n);
|
||||
static usize_t fgk_nth_zero (fgk_stream *h, usize_t n);
|
||||
static void fgk_update_tree (fgk_stream *h, usize_t n);
|
||||
static fgk_node* fgk_increase_zero_weight (fgk_stream *h, usize_t n);
|
||||
static void fgk_eliminate_zero (fgk_stream* h, fgk_node *node);
|
||||
static void fgk_move_right (fgk_stream *h, fgk_node *node);
|
||||
static void fgk_promote (fgk_stream *h, fgk_node *node);
|
||||
static void fgk_init_node (fgk_node *node, usize_t i, usize_t size);
|
||||
static fgk_block* fgk_make_block (fgk_stream *h, fgk_node *l);
|
||||
static void fgk_free_block (fgk_stream *h, fgk_block *b);
|
||||
static void fgk_factor_remaining (fgk_stream *h);
|
||||
static inline void fgk_swap_ptrs (fgk_node **one, fgk_node **two);
|
||||
|
||||
/*********************************************************************/
|
||||
/* Basic Routines */
|
||||
/*********************************************************************/
|
||||
|
||||
/* returns an initialized huffman encoder for an alphabet with the
|
||||
* given size. returns NULL if enough memory cannot be allocated */
|
||||
static fgk_stream* fgk_alloc (xd3_stream *stream /*, int alphabet_size0 */)
|
||||
{
|
||||
usize_t alphabet_size0 = ALPHABET_SIZE;
|
||||
fgk_stream *h;
|
||||
|
||||
if ((h = (fgk_stream*) xd3_alloc (stream, 1, sizeof (fgk_stream))) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
h->total_nodes = (2 * alphabet_size0) - 1;
|
||||
h->total_blocks = (2 * h->total_nodes);
|
||||
h->alphabet = (fgk_node*) xd3_alloc (stream, h->total_nodes, sizeof (fgk_node));
|
||||
h->block_array = (fgk_block*) xd3_alloc (stream, h->total_blocks, sizeof (fgk_block));
|
||||
h->coded_bits = (fgk_bit*) xd3_alloc (stream, alphabet_size0, sizeof (fgk_bit));
|
||||
|
||||
if (h->coded_bits == NULL ||
|
||||
h->alphabet == NULL ||
|
||||
h->block_array == NULL)
|
||||
{
|
||||
fgk_destroy (stream, h);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
h->alphabet_size = alphabet_size0;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
static int fgk_init (xd3_stream *stream, fgk_stream *h, int is_encode)
|
||||
{
|
||||
usize_t ui;
|
||||
ssize_t si;
|
||||
|
||||
h->root_node = h->alphabet;
|
||||
h->decode_ptr = h->root_node;
|
||||
h->free_node = h->alphabet + h->alphabet_size;
|
||||
h->remaining_zeros = h->alphabet;
|
||||
h->coded_depth = 0;
|
||||
h->zero_freq_count = h->alphabet_size + 2;
|
||||
|
||||
/* after two calls to factor_remaining, zero_freq_count == alphabet_size */
|
||||
fgk_factor_remaining(h); /* set ZFE and ZFR */
|
||||
fgk_factor_remaining(h); /* set ZFDB according to prev state */
|
||||
|
||||
IF_DEBUG (memset (h->alphabet, 0, sizeof (h->alphabet[0]) * h->total_nodes));
|
||||
|
||||
for (ui = 0; ui < h->total_blocks-1; ui += 1)
|
||||
{
|
||||
h->block_array[ui].block_freeptr = &h->block_array[ui + 1];
|
||||
}
|
||||
|
||||
h->block_array[h->total_blocks - 1].block_freeptr = NULL;
|
||||
h->free_block = h->block_array;
|
||||
|
||||
/* Zero frequency nodes are inserted in the first alphabet_size
|
||||
* positions, with Value, weight, and a pointer to the next zero
|
||||
* frequency node. */
|
||||
for (si = h->alphabet_size - 1; si >= 0; si -= 1)
|
||||
{
|
||||
fgk_init_node (h->alphabet + si, (usize_t) si, h->alphabet_size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fgk_swap_ptrs(fgk_node **one, fgk_node **two)
|
||||
{
|
||||
fgk_node *tmp = *one;
|
||||
*one = *two;
|
||||
*two = tmp;
|
||||
}
|
||||
|
||||
/* Takes huffman transmitter h and n, the nth elt in the alphabet, and
|
||||
* returns the number of required to encode n. */
|
||||
static int fgk_encode_data (fgk_stream* h, usize_t n)
|
||||
{
|
||||
fgk_node *target_ptr = h->alphabet + n;
|
||||
|
||||
XD3_ASSERT (n < h->alphabet_size);
|
||||
|
||||
h->coded_depth = 0;
|
||||
|
||||
/* First encode the binary representation of the nth remaining
|
||||
* zero frequency element in reverse such that bit, which will be
|
||||
* encoded from h->coded_depth down to 0 will arrive in increasing
|
||||
* order following the tree path. If there is only one left, it
|
||||
* is not neccesary to encode these bits. */
|
||||
if (IS_ADAPTIVE && target_ptr->weight == 0)
|
||||
{
|
||||
unsigned int where, shift;
|
||||
int bits;
|
||||
|
||||
where = fgk_find_nth_zero(h, n);
|
||||
shift = 1;
|
||||
|
||||
if (h->zero_freq_rem == 0)
|
||||
{
|
||||
bits = h->zero_freq_exp;
|
||||
}
|
||||
else
|
||||
{
|
||||
bits = h->zero_freq_exp + 1;
|
||||
}
|
||||
|
||||
while (bits > 0)
|
||||
{
|
||||
h->coded_bits[h->coded_depth++] = (shift & where) && 1;
|
||||
|
||||
bits -= 1;
|
||||
shift <<= 1;
|
||||
};
|
||||
|
||||
target_ptr = h->remaining_zeros;
|
||||
}
|
||||
|
||||
/* The path from root to node is filled into coded_bits in reverse so
|
||||
* that it is encoded in the right order */
|
||||
while (target_ptr != h->root_node)
|
||||
{
|
||||
h->coded_bits[h->coded_depth++] = (target_ptr->parent->right_child == target_ptr);
|
||||
|
||||
target_ptr = target_ptr->parent;
|
||||
}
|
||||
|
||||
if (IS_ADAPTIVE)
|
||||
{
|
||||
fgk_update_tree(h, n);
|
||||
}
|
||||
|
||||
return h->coded_depth;
|
||||
}
|
||||
|
||||
/* Should be called as many times as fgk_encode_data returns.
|
||||
*/
|
||||
static inline fgk_bit fgk_get_encoded_bit (fgk_stream *h)
|
||||
{
|
||||
XD3_ASSERT (h->coded_depth > 0);
|
||||
|
||||
return h->coded_bits[--h->coded_depth];
|
||||
}
|
||||
|
||||
/* This procedure updates the tree after alphabet[n] has been encoded
|
||||
* or decoded.
|
||||
*/
|
||||
static void fgk_update_tree (fgk_stream *h, usize_t n)
|
||||
{
|
||||
fgk_node *incr_node;
|
||||
|
||||
if (h->alphabet[n].weight == 0)
|
||||
{
|
||||
incr_node = fgk_increase_zero_weight (h, n);
|
||||
}
|
||||
else
|
||||
{
|
||||
incr_node = h->alphabet + n;
|
||||
}
|
||||
|
||||
while (incr_node != h->root_node)
|
||||
{
|
||||
fgk_move_right (h, incr_node);
|
||||
fgk_promote (h, incr_node);
|
||||
incr_node->weight += 1; /* incr the parent */
|
||||
incr_node = incr_node->parent; /* repeat */
|
||||
}
|
||||
|
||||
h->root_node->weight += 1;
|
||||
}
|
||||
|
||||
static void fgk_move_right (fgk_stream *h, fgk_node *move_fwd)
|
||||
{
|
||||
fgk_node **fwd_par_ptr, **back_par_ptr;
|
||||
fgk_node *move_back, *tmp;
|
||||
|
||||
move_back = move_fwd->my_block->block_leader;
|
||||
|
||||
if (move_fwd == move_back ||
|
||||
move_fwd->parent == move_back ||
|
||||
move_fwd->weight == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
move_back->right->left = move_fwd;
|
||||
|
||||
if (move_fwd->left)
|
||||
{
|
||||
move_fwd->left->right = move_back;
|
||||
}
|
||||
|
||||
tmp = move_fwd->right;
|
||||
move_fwd->right = move_back->right;
|
||||
|
||||
if (tmp == move_back)
|
||||
{
|
||||
move_back->right = move_fwd;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp->left = move_back;
|
||||
move_back->right = tmp;
|
||||
}
|
||||
|
||||
tmp = move_back->left;
|
||||
move_back->left = move_fwd->left;
|
||||
|
||||
if (tmp == move_fwd)
|
||||
{
|
||||
move_fwd->left = move_back;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp->right = move_fwd;
|
||||
move_fwd->left = tmp;
|
||||
}
|
||||
|
||||
if (move_fwd->parent->right_child == move_fwd)
|
||||
{
|
||||
fwd_par_ptr = &move_fwd->parent->right_child;
|
||||
}
|
||||
else
|
||||
{
|
||||
fwd_par_ptr = &move_fwd->parent->left_child;
|
||||
}
|
||||
|
||||
if (move_back->parent->right_child == move_back)
|
||||
{
|
||||
back_par_ptr = &move_back->parent->right_child;
|
||||
}
|
||||
else
|
||||
{
|
||||
back_par_ptr = &move_back->parent->left_child;
|
||||
}
|
||||
|
||||
fgk_swap_ptrs (&move_fwd->parent, &move_back->parent);
|
||||
fgk_swap_ptrs (fwd_par_ptr, back_par_ptr);
|
||||
|
||||
move_fwd->my_block->block_leader = move_fwd;
|
||||
}
|
||||
|
||||
/* Shifts node, the leader of its block, into the next block. */
|
||||
static void fgk_promote (fgk_stream *h, fgk_node *node)
|
||||
{
|
||||
fgk_node *my_left, *my_right;
|
||||
fgk_block *cur_block;
|
||||
|
||||
my_right = node->right;
|
||||
my_left = node->left;
|
||||
cur_block = node->my_block;
|
||||
|
||||
if (node->weight == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* if left is right child, parent of remaining zeros case (?), means parent
|
||||
* has same weight as right child. */
|
||||
if (my_left == node->right_child &&
|
||||
node->left_child &&
|
||||
node->left_child->weight == 0)
|
||||
{
|
||||
XD3_ASSERT (node->left_child == h->remaining_zeros);
|
||||
XD3_ASSERT (node->right_child->weight == (node->weight+1)); /* child weight was already incremented */
|
||||
|
||||
if (node->weight == (my_right->weight - 1) && my_right != h->root_node)
|
||||
{
|
||||
fgk_free_block (h, cur_block);
|
||||
node->my_block = my_right->my_block;
|
||||
my_left->my_block = my_right->my_block;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (my_left == h->remaining_zeros)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* true if not the leftmost node */
|
||||
if (my_left->my_block == cur_block)
|
||||
{
|
||||
my_left->my_block->block_leader = my_left;
|
||||
}
|
||||
else
|
||||
{
|
||||
fgk_free_block (h, cur_block);
|
||||
}
|
||||
|
||||
/* node->parent != my_right */
|
||||
if ((node->weight == (my_right->weight - 1)) && (my_right != h->root_node))
|
||||
{
|
||||
node->my_block = my_right->my_block;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->my_block = fgk_make_block (h, node);
|
||||
}
|
||||
}
|
||||
|
||||
/* When an element is seen the first time this is called to remove it from the list of
|
||||
* zero weight elements and introduce a new internal node to the tree. */
|
||||
static fgk_node* fgk_increase_zero_weight (fgk_stream *h, usize_t n)
|
||||
{
|
||||
fgk_node *this_zero, *new_internal, *zero_ptr;
|
||||
|
||||
this_zero = h->alphabet + n;
|
||||
|
||||
if (h->zero_freq_count == 1)
|
||||
{
|
||||
/* this is the last one */
|
||||
this_zero->right_child = NULL;
|
||||
|
||||
if (this_zero->right->weight == 1)
|
||||
{
|
||||
this_zero->my_block = this_zero->right->my_block;
|
||||
}
|
||||
else
|
||||
{
|
||||
this_zero->my_block = fgk_make_block (h, this_zero);
|
||||
}
|
||||
|
||||
h->remaining_zeros = NULL;
|
||||
|
||||
return this_zero;
|
||||
}
|
||||
|
||||
zero_ptr = h->remaining_zeros;
|
||||
|
||||
new_internal = h->free_node++;
|
||||
|
||||
new_internal->parent = zero_ptr->parent;
|
||||
new_internal->right = zero_ptr->right;
|
||||
new_internal->weight = 0;
|
||||
new_internal->right_child = this_zero;
|
||||
new_internal->left = this_zero;
|
||||
|
||||
if (h->remaining_zeros == h->root_node)
|
||||
{
|
||||
/* This is the first element to be coded */
|
||||
h->root_node = new_internal;
|
||||
this_zero->my_block = fgk_make_block (h, this_zero);
|
||||
new_internal->my_block = fgk_make_block (h, new_internal);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_internal->right->left = new_internal;
|
||||
|
||||
if (zero_ptr->parent->right_child == zero_ptr)
|
||||
{
|
||||
zero_ptr->parent->right_child = new_internal;
|
||||
}
|
||||
else
|
||||
{
|
||||
zero_ptr->parent->left_child = new_internal;
|
||||
}
|
||||
|
||||
if (new_internal->right->weight == 1)
|
||||
{
|
||||
new_internal->my_block = new_internal->right->my_block;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_internal->my_block = fgk_make_block (h, new_internal);
|
||||
}
|
||||
|
||||
this_zero->my_block = new_internal->my_block;
|
||||
}
|
||||
|
||||
fgk_eliminate_zero (h, this_zero);
|
||||
|
||||
new_internal->left_child = h->remaining_zeros;
|
||||
|
||||
this_zero->right = new_internal;
|
||||
this_zero->left = h->remaining_zeros;
|
||||
this_zero->parent = new_internal;
|
||||
this_zero->left_child = NULL;
|
||||
this_zero->right_child = NULL;
|
||||
|
||||
h->remaining_zeros->parent = new_internal;
|
||||
h->remaining_zeros->right = this_zero;
|
||||
|
||||
return this_zero;
|
||||
}
|
||||
|
||||
/* When a zero frequency element is encoded, it is followed by the
|
||||
* binary representation of the index into the remaining elements.
|
||||
* Sets a cache to the element before it so that it can be removed
|
||||
* without calling this procedure again. */
|
||||
static unsigned int fgk_find_nth_zero (fgk_stream* h, usize_t n)
|
||||
{
|
||||
fgk_node *target_ptr = h->alphabet + n;
|
||||
fgk_node *head_ptr = h->remaining_zeros;
|
||||
unsigned int idx = 0;
|
||||
|
||||
while (target_ptr != head_ptr)
|
||||
{
|
||||
head_ptr = head_ptr->right_child;
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
/* Splices node out of the list of zeros. */
|
||||
static void fgk_eliminate_zero (fgk_stream* h, fgk_node *node)
|
||||
{
|
||||
if (h->zero_freq_count == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fgk_factor_remaining(h);
|
||||
|
||||
if (node->left_child == NULL)
|
||||
{
|
||||
h->remaining_zeros = h->remaining_zeros->right_child;
|
||||
h->remaining_zeros->left_child = NULL;
|
||||
}
|
||||
else if (node->right_child == NULL)
|
||||
{
|
||||
node->left_child->right_child = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->right_child->left_child = node->left_child;
|
||||
node->left_child->right_child = node->right_child;
|
||||
}
|
||||
}
|
||||
|
||||
static void fgk_init_node (fgk_node *node, usize_t i, usize_t size)
|
||||
{
|
||||
if (i < size - 1)
|
||||
{
|
||||
node->right_child = node + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->right_child = NULL;
|
||||
}
|
||||
|
||||
if (i >= 1)
|
||||
{
|
||||
node->left_child = node - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->left_child = NULL;
|
||||
}
|
||||
|
||||
node->weight = 0;
|
||||
node->parent = NULL;
|
||||
node->right = NULL;
|
||||
node->left = NULL;
|
||||
node->my_block = NULL;
|
||||
}
|
||||
|
||||
/* The data structure used is an array of blocks, which are unions of
|
||||
* free pointers and huffnode pointers. free blocks are a linked list
|
||||
* of free blocks, the front of which is h->free_block. The used
|
||||
* blocks are pointers to the head of each block. */
|
||||
static fgk_block* fgk_make_block (fgk_stream *h, fgk_node* lead)
|
||||
{
|
||||
fgk_block *ret = h->free_block;
|
||||
|
||||
XD3_ASSERT (h->free_block != NULL);
|
||||
|
||||
h->free_block = h->free_block->block_freeptr;
|
||||
|
||||
ret->block_leader = lead;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Restores the block to the front of the free list. */
|
||||
static void fgk_free_block (fgk_stream *h, fgk_block *b)
|
||||
{
|
||||
b->block_freeptr = h->free_block;
|
||||
h->free_block = b;
|
||||
}
|
||||
|
||||
/* sets zero_freq_count, zero_freq_rem, and zero_freq_exp to satsity
|
||||
* the equation given above. */
|
||||
static void fgk_factor_remaining (fgk_stream *h)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = (--h->zero_freq_count);
|
||||
h->zero_freq_exp = 0;
|
||||
|
||||
while (i > 1)
|
||||
{
|
||||
h->zero_freq_exp += 1;
|
||||
i >>= 1;
|
||||
}
|
||||
|
||||
i = 1 << h->zero_freq_exp;
|
||||
|
||||
h->zero_freq_rem = h->zero_freq_count - i;
|
||||
}
|
||||
|
||||
/* receives a bit at a time and returns true when a complete code has
|
||||
* been received.
|
||||
*/
|
||||
static inline int fgk_decode_bit (fgk_stream* h, fgk_bit b)
|
||||
{
|
||||
XD3_ASSERT (b == 1 || b == 0);
|
||||
|
||||
if (IS_ADAPTIVE && h->decode_ptr->weight == 0)
|
||||
{
|
||||
usize_t bitsreq;
|
||||
|
||||
if (h->zero_freq_rem == 0)
|
||||
{
|
||||
bitsreq = h->zero_freq_exp;
|
||||
}
|
||||
else
|
||||
{
|
||||
bitsreq = h->zero_freq_exp + 1;
|
||||
}
|
||||
|
||||
h->coded_bits[h->coded_depth] = b;
|
||||
h->coded_depth += 1;
|
||||
|
||||
return h->coded_depth >= bitsreq;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
h->decode_ptr = h->decode_ptr->right_child;
|
||||
}
|
||||
else
|
||||
{
|
||||
h->decode_ptr = h->decode_ptr->left_child;
|
||||
}
|
||||
|
||||
if (h->decode_ptr->left_child == NULL)
|
||||
{
|
||||
/* If the weight is non-zero, finished. */
|
||||
if (h->decode_ptr->weight != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* zero_freq_count is dropping to 0, finished. */
|
||||
return h->zero_freq_count == 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static usize_t fgk_nth_zero (fgk_stream* h, usize_t n)
|
||||
{
|
||||
fgk_node *ret = h->remaining_zeros;
|
||||
|
||||
/* ERROR: if during this loop (ret->right_child == NULL) then the
|
||||
* encoder's zero count is too high. Could return an error code
|
||||
* now, but is probably unnecessary overhead, since the caller
|
||||
* should check integrity anyway. */
|
||||
for (; n != 0 && ret->right_child != NULL; n -= 1)
|
||||
{
|
||||
ret = ret->right_child;
|
||||
}
|
||||
|
||||
return (usize_t)(ret - h->alphabet);
|
||||
}
|
||||
|
||||
/* once fgk_decode_bit returns 1, this retrieves an index into the
|
||||
* alphabet otherwise this returns 0, indicating more bits are
|
||||
* required.
|
||||
*/
|
||||
static int fgk_decode_data (fgk_stream* h)
|
||||
{
|
||||
usize_t elt = (usize_t)(h->decode_ptr - h->alphabet);
|
||||
|
||||
if (IS_ADAPTIVE && h->decode_ptr->weight == 0) {
|
||||
usize_t i = 0;
|
||||
usize_t n = 0;
|
||||
|
||||
if (h->coded_depth > 0)
|
||||
{
|
||||
for (; i < h->coded_depth - 1; i += 1)
|
||||
{
|
||||
n |= h->coded_bits[i];
|
||||
n <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
n |= h->coded_bits[i];
|
||||
elt = fgk_nth_zero(h, n);
|
||||
}
|
||||
|
||||
h->coded_depth = 0;
|
||||
|
||||
if (IS_ADAPTIVE)
|
||||
{
|
||||
fgk_update_tree(h, elt);
|
||||
}
|
||||
|
||||
h->decode_ptr = h->root_node;
|
||||
|
||||
return elt;
|
||||
}
|
||||
|
||||
static void fgk_destroy (xd3_stream *stream,
|
||||
fgk_stream *h)
|
||||
{
|
||||
if (h != NULL)
|
||||
{
|
||||
xd3_free (stream, h->alphabet);
|
||||
xd3_free (stream, h->coded_bits);
|
||||
xd3_free (stream, h->block_array);
|
||||
xd3_free (stream, h);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************/
|
||||
/* Xdelta */
|
||||
/*********************************************************************/
|
||||
|
||||
static int
|
||||
xd3_encode_fgk (xd3_stream *stream, fgk_stream *sec_stream, xd3_output *input, xd3_output *output, xd3_sec_cfg *cfg)
|
||||
{
|
||||
bit_state bstate = BIT_STATE_ENCODE_INIT;
|
||||
xd3_output *cur_page;
|
||||
int ret;
|
||||
|
||||
/* OPT: quit compression early if it looks bad */
|
||||
for (cur_page = input; cur_page; cur_page = cur_page->next_page)
|
||||
{
|
||||
const uint8_t *inp = cur_page->base;
|
||||
const uint8_t *inp_max = inp + cur_page->next;
|
||||
|
||||
while (inp < inp_max)
|
||||
{
|
||||
usize_t bits = fgk_encode_data (sec_stream, *inp++);
|
||||
|
||||
while (bits--)
|
||||
{
|
||||
if ((ret = xd3_encode_bit (stream, & output, & bstate, fgk_get_encoded_bit (sec_stream)))) { return ret; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return xd3_flush_bits (stream, & output, & bstate);
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_decode_fgk (xd3_stream *stream,
|
||||
fgk_stream *sec_stream,
|
||||
const uint8_t **input_pos,
|
||||
const uint8_t *const input_max,
|
||||
uint8_t **output_pos,
|
||||
const uint8_t *const output_max)
|
||||
{
|
||||
bit_state bstate;
|
||||
uint8_t *output = *output_pos;
|
||||
const uint8_t *input = *input_pos;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (input == input_max)
|
||||
{
|
||||
stream->msg = "secondary decoder end of input";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
|
||||
bstate.cur_byte = *input++;
|
||||
|
||||
for (bstate.cur_mask = 1; bstate.cur_mask != 0x100; bstate.cur_mask <<= 1)
|
||||
{
|
||||
int done = fgk_decode_bit (sec_stream, (bstate.cur_byte & bstate.cur_mask) ? 1U : 0U);
|
||||
|
||||
if (! done) { continue; }
|
||||
|
||||
*output++ = fgk_decode_data (sec_stream);
|
||||
|
||||
if (output == output_max)
|
||||
{
|
||||
/* During regression testing: */
|
||||
IF_REGRESSION ({
|
||||
int ret;
|
||||
bstate.cur_mask <<= 1;
|
||||
if ((ret = xd3_test_clean_bits (stream, & bstate))) { return ret; }
|
||||
});
|
||||
|
||||
(*output_pos) = output;
|
||||
(*input_pos) = input;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _XDELTA3_FGK_ */
|
|
@ -1,170 +0,0 @@
|
|||
/* xdelta 3 - delta compression tools and library
|
||||
* Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007. Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _XDELTA3_HASH_H_
|
||||
#define _XDELTA3_HASH_H_
|
||||
|
||||
#if XD3_DEBUG
|
||||
#define SMALL_HASH_DEBUG1(s,inp) \
|
||||
uint32_t debug_state; \
|
||||
uint32_t debug_hval = xd3_checksum_hash (& (s)->small_hash, \
|
||||
xd3_scksum (&debug_state, (inp), (s)->smatcher.small_look))
|
||||
#define SMALL_HASH_DEBUG2(s,inp) \
|
||||
XD3_ASSERT (debug_hval == xd3_checksum_hash (& (s)->small_hash, \
|
||||
xd3_scksum (&debug_state, (inp), (s)->smatcher.small_look)))
|
||||
#else
|
||||
#define SMALL_HASH_DEBUG1(s,inp)
|
||||
#define SMALL_HASH_DEBUG2(s,inp)
|
||||
#endif /* XD3_DEBUG */
|
||||
|
||||
/* This is a good hash multiplier for 32-bit LCGs: see "linear
|
||||
* congruential generators of different sizes and good lattice
|
||||
* structure" */
|
||||
static const uint32_t hash_multiplier = 1597334677U;
|
||||
|
||||
/***********************************************************************
|
||||
Permute stuff
|
||||
***********************************************************************/
|
||||
|
||||
#if HASH_PERMUTE == 0
|
||||
#define PERMUTE(x) (x)
|
||||
#else
|
||||
#define PERMUTE(x) (__single_hash[(uint32_t)x])
|
||||
|
||||
extern const uint16_t __single_hash[256];
|
||||
#endif
|
||||
|
||||
/* Update the checksum state. */
|
||||
#if ADLER_LARGE_CKSUM
|
||||
inline uint32_t
|
||||
xd3_large_cksum_update (uint32_t cksum,
|
||||
const uint8_t *base,
|
||||
usize_t look) {
|
||||
uint32_t old_c = PERMUTE(base[0]);
|
||||
uint32_t new_c = PERMUTE(base[look]);
|
||||
uint32_t low = ((cksum & 0xffff) - old_c + new_c) & 0xffff;
|
||||
uint32_t high = ((cksum >> 16) - (old_c * look) + low) & 0xffff;
|
||||
return (high << 16) | low;
|
||||
}
|
||||
#else
|
||||
/* TODO: revisit this topic */
|
||||
#endif
|
||||
|
||||
#if UNALIGNED_OK
|
||||
#define UNALIGNED_READ32(dest,src) (*(dest)) = (*(uint32_t*)(src))
|
||||
#else
|
||||
#define UNALIGNED_READ32(dest,src) memcpy((dest), (src), 4);
|
||||
#endif
|
||||
|
||||
/* TODO: small cksum is hard-coded for 4 bytes (i.e., "look" is unused) */
|
||||
static inline uint32_t
|
||||
xd3_scksum (uint32_t *state,
|
||||
const uint8_t *base,
|
||||
const usize_t look)
|
||||
{
|
||||
UNALIGNED_READ32(state, base);
|
||||
return (*state) * hash_multiplier;
|
||||
}
|
||||
static inline uint32_t
|
||||
xd3_small_cksum_update (uint32_t *state,
|
||||
const uint8_t *base,
|
||||
usize_t look)
|
||||
{
|
||||
UNALIGNED_READ32(state, base+1);
|
||||
return (*state) * hash_multiplier;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
Ctable stuff
|
||||
***********************************************************************/
|
||||
|
||||
static inline usize_t
|
||||
xd3_checksum_hash (const xd3_hash_cfg *cfg, const usize_t cksum)
|
||||
{
|
||||
return (cksum >> cfg->shift) ^ (cksum & cfg->mask);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
Cksum function
|
||||
***********************************************************************/
|
||||
|
||||
#if ADLER_LARGE_CKSUM
|
||||
static inline uint32_t
|
||||
xd3_lcksum (const uint8_t *seg, const usize_t ln)
|
||||
{
|
||||
usize_t i = 0;
|
||||
uint32_t low = 0;
|
||||
uint32_t high = 0;
|
||||
|
||||
for (; i < ln; i += 1)
|
||||
{
|
||||
low += PERMUTE(*seg++);
|
||||
high += low;
|
||||
}
|
||||
|
||||
return ((high & 0xffff) << 16) | (low & 0xffff);
|
||||
}
|
||||
#else
|
||||
static inline uint32_t
|
||||
xd3_lcksum (const uint8_t *seg, const usize_t ln)
|
||||
{
|
||||
usize_t i, j;
|
||||
uint32_t h = 0;
|
||||
for (i = 0, j = ln - 1; i < ln; ++i, --j) {
|
||||
h += PERMUTE(seg[i]) * hash_multiplier_powers[j];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if XD3_ENCODER
|
||||
static usize_t
|
||||
xd3_size_log2 (usize_t slots)
|
||||
{
|
||||
int bits = 28; /* This should not be an unreasonable limit. */
|
||||
int i;
|
||||
|
||||
for (i = 3; i <= bits; i += 1)
|
||||
{
|
||||
if (slots < (1U << i))
|
||||
{
|
||||
/* TODO: this is compaction=1 in checksum_test.cc and maybe should
|
||||
* not be fixed at -1. */
|
||||
bits = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
static void
|
||||
xd3_size_hashtable (xd3_stream *stream,
|
||||
usize_t slots,
|
||||
xd3_hash_cfg *cfg)
|
||||
{
|
||||
int bits = xd3_size_log2 (slots);
|
||||
|
||||
/* TODO: there's a 32-bit assumption here */
|
||||
cfg->size = (1 << bits);
|
||||
cfg->mask = (cfg->size - 1);
|
||||
cfg->shift = 32 - bits;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,372 +0,0 @@
|
|||
/* xdelta3 - delta compression tools and library
|
||||
* Copyright (C) 2011, 2012, 2013, 2014, 2015 Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef XDELTA3_INTERNAL_H__
|
||||
#define XDELTA3_INTERNAL_H__
|
||||
|
||||
#include "xdelta3.h"
|
||||
|
||||
typedef struct _main_file main_file;
|
||||
typedef struct _main_extcomp main_extcomp;
|
||||
|
||||
void main_buffree (void *ptr);
|
||||
void* main_bufalloc (size_t size);
|
||||
void main_file_init (main_file *xfile);
|
||||
int main_file_close (main_file *xfile);
|
||||
void main_file_cleanup (main_file *xfile);
|
||||
int main_file_isopen (main_file *xfile);
|
||||
int main_file_open (main_file *xfile, const char* name, int mode);
|
||||
int main_file_exists (main_file *xfile);
|
||||
int xd3_whole_append_window (xd3_stream *stream);
|
||||
int xd3_main_cmdline (int argc, char **argv);
|
||||
int main_file_read (main_file *ifile,
|
||||
uint8_t *buf,
|
||||
size_t size,
|
||||
size_t *nread,
|
||||
const char *msg);
|
||||
int main_file_write (main_file *ofile, uint8_t *buf,
|
||||
usize_t size, const char *msg);
|
||||
int test_compare_files (const char* f0, const char* f1);
|
||||
usize_t xd3_bytes_on_srcblk (xd3_source *src, xoff_t blkno);
|
||||
xoff_t xd3_source_eof(const xd3_source *src);
|
||||
uint32_t xd3_large_cksum_update (uint32_t cksum,
|
||||
const uint8_t *base,
|
||||
usize_t look);
|
||||
int xd3_emit_byte (xd3_stream *stream,
|
||||
xd3_output **outputp,
|
||||
uint8_t code);
|
||||
|
||||
int xd3_emit_bytes (xd3_stream *stream,
|
||||
xd3_output **outputp,
|
||||
const uint8_t *base,
|
||||
usize_t size);
|
||||
xd3_output* xd3_alloc_output (xd3_stream *stream,
|
||||
xd3_output *old_output);
|
||||
|
||||
int xd3_encode_init_full (xd3_stream *stream);
|
||||
size_t xd3_pow2_roundup (size_t x);
|
||||
int xd3_process_stream (int is_encode,
|
||||
xd3_stream *stream,
|
||||
int (*func) (xd3_stream *),
|
||||
int close_stream,
|
||||
const uint8_t *input,
|
||||
usize_t input_size,
|
||||
uint8_t *output,
|
||||
usize_t *output_size,
|
||||
usize_t output_size_max);
|
||||
|
||||
#if PYTHON_MODULE || SWIG_MODULE || NOT_MAIN
|
||||
int xd3_main_cmdline (int argc, char **argv);
|
||||
#endif
|
||||
|
||||
/* main_file->mode values */
|
||||
typedef enum
|
||||
{
|
||||
XO_READ = 0,
|
||||
XO_WRITE = 1
|
||||
} main_file_modes;
|
||||
|
||||
#ifndef XD3_POSIX
|
||||
#define XD3_POSIX 0
|
||||
#endif
|
||||
#ifndef XD3_STDIO
|
||||
#define XD3_STDIO 0
|
||||
#endif
|
||||
#ifndef XD3_WIN32
|
||||
#define XD3_WIN32 0
|
||||
#endif
|
||||
#ifndef NOT_MAIN
|
||||
#define NOT_MAIN 0
|
||||
#endif
|
||||
|
||||
/* If none are set, default to posix. */
|
||||
#if (XD3_POSIX + XD3_STDIO + XD3_WIN32) == 0
|
||||
#undef XD3_POSIX
|
||||
#define XD3_POSIX 1
|
||||
#endif
|
||||
|
||||
struct _main_file
|
||||
{
|
||||
#if XD3_WIN32
|
||||
HANDLE file;
|
||||
#elif XD3_STDIO
|
||||
FILE *file;
|
||||
#elif XD3_POSIX
|
||||
int file;
|
||||
#endif
|
||||
|
||||
int mode; /* XO_READ and XO_WRITE */
|
||||
const char *filename; /* File name or /dev/stdin,
|
||||
* /dev/stdout, /dev/stderr. */
|
||||
char *filename_copy; /* File name or /dev/stdin,
|
||||
* /dev/stdout, /dev/stderr. */
|
||||
const char *realname; /* File name or /dev/stdin,
|
||||
* /dev/stdout, /dev/stderr. */
|
||||
const main_extcomp *compressor; /* External compression struct. */
|
||||
int flags; /* RD_FIRST, RD_NONEXTERNAL, ... */
|
||||
xoff_t nread; /* for input position */
|
||||
xoff_t nwrite; /* for output position */
|
||||
uint8_t *snprintf_buf; /* internal snprintf() use */
|
||||
int size_known; /* Set by main_set_souze */
|
||||
xoff_t source_position; /* for avoiding seek in getblk_func */
|
||||
int seek_failed; /* after seek fails once, try FIFO */
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#define vsnprintf_func _vsnprintf
|
||||
#define snprintf_func _snprintf
|
||||
#else
|
||||
#define vsnprintf_func vsnprintf
|
||||
#define snprintf_func snprintf
|
||||
#endif
|
||||
#define short_sprintf(sb,fmt,...) \
|
||||
snprintf_func((sb).buf,sizeof((sb).buf),fmt,__VA_ARGS__)
|
||||
|
||||
/* Type used for short snprintf calls. */
|
||||
typedef struct {
|
||||
char buf[48];
|
||||
} shortbuf;
|
||||
|
||||
/* Prior to SVN 303 this function was only defined in DJGPP and WIN32
|
||||
* environments and other platforms would use the builtin snprintf()
|
||||
* with an arrangement of macros below. In OS X 10.6, Apply made
|
||||
* snprintf() a macro, which defeated those macros (since snprintf
|
||||
* would be evaluated before its argument macros were expanded,
|
||||
* therefore always define xsnprintf_func. */
|
||||
#undef PRINTF_ATTRIBUTE
|
||||
#ifdef __GNUC__
|
||||
/* Let's just assume no one uses gcc 2.x! */
|
||||
#define PRINTF_ATTRIBUTE(x,y) __attribute__ ((__format__ (__printf__, x, y)))
|
||||
#else
|
||||
#define PRINTF_ATTRIBUTE(x,y)
|
||||
#endif
|
||||
|
||||
/* Underlying xprintf() */
|
||||
int xsnprintf_func (char *str, int n, const char *fmt, ...)
|
||||
PRINTF_ATTRIBUTE(3,4);
|
||||
|
||||
/* XPR(NT "", ...) (used by main) prefixes an "xdelta3: " to the output. */
|
||||
void xprintf(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
|
||||
#define XPR xprintf
|
||||
#define NT "xdelta3: "
|
||||
#define NTR ""
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX 4294967295U
|
||||
#endif
|
||||
|
||||
#ifndef UINT64_MAX
|
||||
#define UINT64_MAX 18446744073709551615ULL
|
||||
#endif
|
||||
|
||||
#define UINT32_OFLOW_MASK 0xfe000000U
|
||||
#define UINT64_OFLOW_MASK 0xfe00000000000000ULL
|
||||
|
||||
/*********************************************************************
|
||||
Integer encoder/decoder functions
|
||||
**********************************************************************/
|
||||
|
||||
/* Consume N bytes of input, only used by the decoder. */
|
||||
#define DECODE_INPUT(n) \
|
||||
do { \
|
||||
stream->total_in += (xoff_t) (n); \
|
||||
stream->avail_in -= (n); \
|
||||
stream->next_in += (n); \
|
||||
} while (0)
|
||||
|
||||
#define DECODE_INTEGER_TYPE(PART,OFLOW) \
|
||||
while (stream->avail_in != 0) \
|
||||
{ \
|
||||
usize_t next = stream->next_in[0]; \
|
||||
\
|
||||
DECODE_INPUT(1); \
|
||||
\
|
||||
if (PART & OFLOW) \
|
||||
{ \
|
||||
stream->msg = "overflow in decode_integer"; \
|
||||
return XD3_INVALID_INPUT; \
|
||||
} \
|
||||
\
|
||||
PART = (PART << 7) | (next & 127); \
|
||||
\
|
||||
if ((next & 128) == 0) \
|
||||
{ \
|
||||
(*val) = PART; \
|
||||
PART = 0; \
|
||||
return 0; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
stream->msg = "further input required"; \
|
||||
return XD3_INPUT
|
||||
|
||||
#define READ_INTEGER_TYPE(TYPE, OFLOW) \
|
||||
TYPE val = 0; \
|
||||
const uint8_t *inp = (*inpp); \
|
||||
usize_t next; \
|
||||
\
|
||||
do \
|
||||
{ \
|
||||
if (inp == maxp) \
|
||||
{ \
|
||||
stream->msg = "end-of-input in read_integer"; \
|
||||
return XD3_INVALID_INPUT; \
|
||||
} \
|
||||
\
|
||||
if (val & OFLOW) \
|
||||
{ \
|
||||
stream->msg = "overflow in read_intger"; \
|
||||
return XD3_INVALID_INPUT; \
|
||||
} \
|
||||
\
|
||||
next = (*inp++); \
|
||||
val = (val << 7) | (next & 127); \
|
||||
} \
|
||||
while (next & 128); \
|
||||
\
|
||||
(*valp) = val; \
|
||||
(*inpp) = inp; \
|
||||
\
|
||||
return 0
|
||||
|
||||
#define EMIT_INTEGER_TYPE() \
|
||||
/* max 64-bit value in base-7 encoding is 9.1 bytes */ \
|
||||
uint8_t buf[10]; \
|
||||
usize_t bufi = 10; \
|
||||
\
|
||||
/* This loop performs division and turns on all MSBs. */ \
|
||||
do \
|
||||
{ \
|
||||
buf[--bufi] = (num & 127) | 128; \
|
||||
num >>= 7U; \
|
||||
} \
|
||||
while (num != 0); \
|
||||
\
|
||||
/* Turn off MSB of the last byte. */ \
|
||||
buf[9] &= 127; \
|
||||
\
|
||||
return xd3_emit_bytes (stream, output, buf + bufi, 10 - bufi)
|
||||
|
||||
#define IF_SIZEOF32(x) if (num < (1U << (7 * (x)))) return (x);
|
||||
#define IF_SIZEOF64(x) if (num < (1ULL << (7 * (x)))) return (x);
|
||||
|
||||
#if USE_UINT32
|
||||
static inline uint32_t
|
||||
xd3_sizeof_uint32_t (uint32_t num)
|
||||
{
|
||||
IF_SIZEOF32(1);
|
||||
IF_SIZEOF32(2);
|
||||
IF_SIZEOF32(3);
|
||||
IF_SIZEOF32(4);
|
||||
return 5;
|
||||
}
|
||||
|
||||
static inline int
|
||||
xd3_decode_uint32_t (xd3_stream *stream, uint32_t *val)
|
||||
{ DECODE_INTEGER_TYPE (stream->dec_32part, UINT32_OFLOW_MASK); }
|
||||
|
||||
static inline int
|
||||
xd3_read_uint32_t (xd3_stream *stream, const uint8_t **inpp,
|
||||
const uint8_t *maxp, uint32_t *valp)
|
||||
{ READ_INTEGER_TYPE (uint32_t, UINT32_OFLOW_MASK); }
|
||||
|
||||
#if XD3_ENCODER
|
||||
static inline int
|
||||
xd3_emit_uint32_t (xd3_stream *stream, xd3_output **output, uint32_t num)
|
||||
{ EMIT_INTEGER_TYPE (); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_UINT64
|
||||
static inline int
|
||||
xd3_decode_uint64_t (xd3_stream *stream, uint64_t *val)
|
||||
{ DECODE_INTEGER_TYPE (stream->dec_64part, UINT64_OFLOW_MASK); }
|
||||
|
||||
#if XD3_ENCODER
|
||||
static inline int
|
||||
xd3_emit_uint64_t (xd3_stream *stream, xd3_output **output, uint64_t num)
|
||||
{ EMIT_INTEGER_TYPE (); }
|
||||
#endif
|
||||
|
||||
/* These are tested but not used */
|
||||
#if REGRESSION_TEST
|
||||
static int
|
||||
xd3_read_uint64_t (xd3_stream *stream, const uint8_t **inpp,
|
||||
const uint8_t *maxp, uint64_t *valp)
|
||||
{ READ_INTEGER_TYPE (uint64_t, UINT64_OFLOW_MASK); }
|
||||
|
||||
static uint32_t
|
||||
xd3_sizeof_uint64_t (uint64_t num)
|
||||
{
|
||||
IF_SIZEOF64(1);
|
||||
IF_SIZEOF64(2);
|
||||
IF_SIZEOF64(3);
|
||||
IF_SIZEOF64(4);
|
||||
IF_SIZEOF64(5);
|
||||
IF_SIZEOF64(6);
|
||||
IF_SIZEOF64(7);
|
||||
IF_SIZEOF64(8);
|
||||
IF_SIZEOF64(9);
|
||||
|
||||
return 10;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if SIZEOF_USIZE_T == 4
|
||||
#define USIZE_T_MAX UINT32_MAX
|
||||
#define USIZE_T_MAXBLKSZ 0x80000000U
|
||||
#define xd3_decode_size xd3_decode_uint32_t
|
||||
#define xd3_emit_size xd3_emit_uint32_t
|
||||
#define xd3_sizeof_size xd3_sizeof_uint32_t
|
||||
#define xd3_read_size xd3_read_uint32_t
|
||||
#elif SIZEOF_USIZE_T == 8
|
||||
#define USIZE_T_MAX UINT64_MAX
|
||||
#define USIZE_T_MAXBLKSZ 0x8000000000000000ULL
|
||||
#define xd3_decode_size xd3_decode_uint64_t
|
||||
#define xd3_emit_size xd3_emit_uint64_t
|
||||
#define xd3_sizeof_size xd3_sizeof_uint64_t
|
||||
#define xd3_read_size xd3_read_uint64_t
|
||||
#endif
|
||||
|
||||
#if SIZEOF_XOFF_T == 4
|
||||
#define XOFF_T_MAX UINT32_MAX
|
||||
#define xd3_emit_offset xd3_emit_uint32_t
|
||||
static inline int
|
||||
xd3_decode_offset (xd3_stream *stream, xoff_t *val)
|
||||
{
|
||||
return xd3_decode_uint32_t (stream, (uint32_t*) val);
|
||||
}
|
||||
#elif SIZEOF_XOFF_T == 8
|
||||
#define XOFF_T_MAX UINT64_MAX
|
||||
#define xd3_emit_offset xd3_emit_uint64_t
|
||||
static inline int
|
||||
xd3_decode_offset (xd3_stream *stream, xoff_t *val)
|
||||
{
|
||||
return xd3_decode_uint64_t (stream, (uint64_t*) val);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define USIZE_T_OVERFLOW(a,b) ((USIZE_T_MAX - (usize_t) (a)) < (usize_t) (b))
|
||||
#define XOFF_T_OVERFLOW(a,b) ((XOFF_T_MAX - (xoff_t) (a)) < (xoff_t) (b))
|
||||
|
||||
#define MAX_LRU_SIZE 32U
|
||||
#define XD3_MINSRCWINSZ (XD3_ALLOCSIZE * MAX_LRU_SIZE)
|
||||
#define XD3_MAXSRCWINSZ (1ULL << 31)
|
||||
|
||||
#endif // XDELTA3_INTERNAL_H__
|
|
@ -1,130 +0,0 @@
|
|||
/* xdelta 3 - delta compression tools and library
|
||||
* Copyright (C) 2002, 2006, 2007. Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __XDELTA3_LIST__
|
||||
#define __XDELTA3_LIST__
|
||||
|
||||
#define XD3_MAKELIST(LTYPE,ETYPE,LNAME) \
|
||||
\
|
||||
static inline ETYPE* \
|
||||
LTYPE ## _entry (LTYPE* l) \
|
||||
{ \
|
||||
return (ETYPE*) ((char*) l - (ptrdiff_t) &((ETYPE*) 0)->LNAME); \
|
||||
} \
|
||||
\
|
||||
static inline void \
|
||||
LTYPE ## _init (LTYPE *l) \
|
||||
{ \
|
||||
l->next = l; \
|
||||
l->prev = l; \
|
||||
} \
|
||||
\
|
||||
static inline void \
|
||||
LTYPE ## _add (LTYPE *prev, LTYPE *next, LTYPE *ins) \
|
||||
{ \
|
||||
next->prev = ins; \
|
||||
prev->next = ins; \
|
||||
ins->next = next; \
|
||||
ins->prev = prev; \
|
||||
} \
|
||||
\
|
||||
static inline void \
|
||||
LTYPE ## _push_back (LTYPE *l, ETYPE *i) \
|
||||
{ \
|
||||
LTYPE ## _add (l->prev, l, & i->LNAME); \
|
||||
} \
|
||||
\
|
||||
static inline void \
|
||||
LTYPE ## _del (LTYPE *next, \
|
||||
LTYPE *prev) \
|
||||
{ \
|
||||
next->prev = prev; \
|
||||
prev->next = next; \
|
||||
} \
|
||||
\
|
||||
static inline ETYPE* \
|
||||
LTYPE ## _remove (ETYPE *f) \
|
||||
{ \
|
||||
LTYPE *i = f->LNAME.next; \
|
||||
LTYPE ## _del (f->LNAME.next, f->LNAME.prev); \
|
||||
return LTYPE ## _entry (i); \
|
||||
} \
|
||||
\
|
||||
static inline ETYPE* \
|
||||
LTYPE ## _pop_back (LTYPE *l) \
|
||||
{ \
|
||||
LTYPE *i = l->prev; \
|
||||
LTYPE ## _del (i->next, i->prev); \
|
||||
return LTYPE ## _entry (i); \
|
||||
} \
|
||||
\
|
||||
static inline ETYPE* \
|
||||
LTYPE ## _pop_front (LTYPE *l) \
|
||||
{ \
|
||||
LTYPE *i = l->next; \
|
||||
LTYPE ## _del (i->next, i->prev); \
|
||||
return LTYPE ## _entry (i); \
|
||||
} \
|
||||
\
|
||||
static inline int \
|
||||
LTYPE ## _empty (LTYPE *l) \
|
||||
{ \
|
||||
return l == l->next; \
|
||||
} \
|
||||
\
|
||||
static inline ETYPE* \
|
||||
LTYPE ## _front (LTYPE *f) \
|
||||
{ \
|
||||
return LTYPE ## _entry (f->next); \
|
||||
} \
|
||||
\
|
||||
static inline ETYPE* \
|
||||
LTYPE ## _back (LTYPE *f) \
|
||||
{ \
|
||||
return LTYPE ## _entry (f->prev); \
|
||||
} \
|
||||
\
|
||||
static inline int \
|
||||
LTYPE ## _end (LTYPE *f, ETYPE *i) \
|
||||
{ \
|
||||
return f == & i->LNAME; \
|
||||
} \
|
||||
\
|
||||
static inline ETYPE* \
|
||||
LTYPE ## _next (ETYPE *f) \
|
||||
{ \
|
||||
return LTYPE ## _entry (f->LNAME.next); \
|
||||
} \
|
||||
\
|
||||
static inline usize_t \
|
||||
LTYPE ## _length (LTYPE *l) \
|
||||
{ \
|
||||
LTYPE *p; \
|
||||
int c = 0; \
|
||||
\
|
||||
for (p = l->next; p != l; p = p->next) \
|
||||
{ \
|
||||
c += 1; \
|
||||
} \
|
||||
\
|
||||
return c; \
|
||||
} \
|
||||
\
|
||||
typedef int unused_ ## LTYPE
|
||||
|
||||
#endif
|
|
@ -1,196 +0,0 @@
|
|||
/* xdelta 3 - delta compression tools and library
|
||||
* Copyright (C) 2012, 2013, 2014, 2015. Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Note: The use of the _easy_ decoder means we're not calling the
|
||||
* xd3_stream malloc hooks. TODO(jmacd) Fix if anyone cares. */
|
||||
|
||||
#ifndef _XDELTA3_LZMA_H_
|
||||
#define _XDELTA3_LZMA_H_
|
||||
|
||||
#include <lzma.h>
|
||||
|
||||
typedef struct _xd3_lzma_stream xd3_lzma_stream;
|
||||
|
||||
struct _xd3_lzma_stream {
|
||||
lzma_stream lzma;
|
||||
lzma_options_lzma options;
|
||||
lzma_filter filters[2];
|
||||
};
|
||||
|
||||
xd3_sec_stream*
|
||||
xd3_lzma_alloc (xd3_stream *stream)
|
||||
{
|
||||
return (xd3_sec_stream*) xd3_alloc (stream, sizeof (xd3_lzma_stream), 1);
|
||||
}
|
||||
|
||||
void
|
||||
xd3_lzma_destroy (xd3_stream *stream, xd3_sec_stream *sec_stream)
|
||||
{
|
||||
xd3_lzma_stream *ls = (xd3_lzma_stream*) sec_stream;
|
||||
lzma_end (&ls->lzma);
|
||||
xd3_free (stream, ls);
|
||||
}
|
||||
|
||||
int
|
||||
xd3_lzma_init (xd3_stream *stream, xd3_lzma_stream *sec, int is_encode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
memset (&sec->lzma, 0, sizeof(sec->lzma));
|
||||
|
||||
if (is_encode)
|
||||
{
|
||||
int preset = (stream->flags & XD3_COMPLEVEL_MASK) >> XD3_COMPLEVEL_SHIFT;
|
||||
|
||||
if (lzma_lzma_preset(&sec->options, preset))
|
||||
{
|
||||
stream->msg = "invalid lzma preset";
|
||||
return XD3_INVALID;
|
||||
}
|
||||
|
||||
sec->filters[0].id = LZMA_FILTER_LZMA2;
|
||||
sec->filters[0].options = &sec->options;
|
||||
sec->filters[1].id = LZMA_VLI_UNKNOWN;
|
||||
|
||||
ret = lzma_stream_encoder (&sec->lzma, &sec->filters[0], LZMA_CHECK_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = lzma_stream_decoder (&sec->lzma, UINT64_MAX, LZMA_TELL_NO_CHECK);
|
||||
}
|
||||
|
||||
if (ret != LZMA_OK)
|
||||
{
|
||||
stream->msg = "lzma stream init failed";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xd3_decode_lzma (xd3_stream *stream, xd3_lzma_stream *sec,
|
||||
const uint8_t **input_pos,
|
||||
const uint8_t *const input_end,
|
||||
uint8_t **output_pos,
|
||||
const uint8_t *const output_end)
|
||||
{
|
||||
uint8_t *output = *output_pos;
|
||||
const uint8_t *input = *input_pos;
|
||||
size_t avail_in = input_end - input;
|
||||
size_t avail_out = output_end - output;
|
||||
|
||||
sec->lzma.avail_in = avail_in;
|
||||
sec->lzma.next_in = input;
|
||||
sec->lzma.avail_out = avail_out;
|
||||
sec->lzma.next_out = output;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int lret = lzma_code (&sec->lzma, LZMA_RUN);
|
||||
|
||||
switch (lret)
|
||||
{
|
||||
case LZMA_NO_CHECK:
|
||||
case LZMA_OK:
|
||||
if (sec->lzma.avail_out == 0)
|
||||
{
|
||||
(*output_pos) = sec->lzma.next_out;
|
||||
(*input_pos) = sec->lzma.next_in;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
stream->msg = "lzma decoding error";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if XD3_ENCODER
|
||||
|
||||
int xd3_encode_lzma (xd3_stream *stream,
|
||||
xd3_lzma_stream *sec,
|
||||
xd3_output *input,
|
||||
xd3_output *output,
|
||||
xd3_sec_cfg *cfg)
|
||||
|
||||
{
|
||||
lzma_action action = LZMA_RUN;
|
||||
|
||||
cfg->inefficient = 1; /* Can't skip windows */
|
||||
sec->lzma.next_in = NULL;
|
||||
sec->lzma.avail_in = 0;
|
||||
sec->lzma.next_out = (output->base + output->next);
|
||||
sec->lzma.avail_out = (output->avail - output->next);
|
||||
|
||||
while (1)
|
||||
{
|
||||
int lret;
|
||||
size_t nwrite;
|
||||
if (sec->lzma.avail_in == 0 && input != NULL)
|
||||
{
|
||||
sec->lzma.avail_in = input->next;
|
||||
sec->lzma.next_in = input->base;
|
||||
|
||||
if ((input = input->next_page) == NULL)
|
||||
{
|
||||
action = LZMA_SYNC_FLUSH;
|
||||
}
|
||||
}
|
||||
|
||||
lret = lzma_code (&sec->lzma, action);
|
||||
|
||||
nwrite = (output->avail - output->next) - sec->lzma.avail_out;
|
||||
|
||||
if (nwrite != 0)
|
||||
{
|
||||
output->next += nwrite;
|
||||
|
||||
if (output->next == output->avail)
|
||||
{
|
||||
if ((output = xd3_alloc_output (stream, output)) == NULL)
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
sec->lzma.next_out = output->base;
|
||||
sec->lzma.avail_out = output->avail;
|
||||
}
|
||||
}
|
||||
|
||||
switch (lret)
|
||||
{
|
||||
case LZMA_OK:
|
||||
break;
|
||||
|
||||
case LZMA_STREAM_END:
|
||||
return 0;
|
||||
|
||||
default:
|
||||
stream->msg = "lzma encoding error";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* XD3_ENCODER */
|
||||
|
||||
#endif /* _XDELTA3_LZMA_H_ */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,586 +0,0 @@
|
|||
/* xdelta 3 - delta compression tools and library
|
||||
* Copyright (C) 2007. Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _XDELTA3_MERGE_H_
|
||||
#define _XDELTA3_MERGE_H_
|
||||
|
||||
int xd3_merge_inputs (xd3_stream *stream,
|
||||
xd3_whole_state *source,
|
||||
xd3_whole_state *input);
|
||||
|
||||
static int
|
||||
xd3_whole_state_init (xd3_stream *stream)
|
||||
{
|
||||
XD3_ASSERT (stream->whole_target.adds == NULL);
|
||||
XD3_ASSERT (stream->whole_target.inst == NULL);
|
||||
XD3_ASSERT (stream->whole_target.wininfo == NULL);
|
||||
XD3_ASSERT (stream->whole_target.length == 0);
|
||||
|
||||
stream->whole_target.adds_alloc = XD3_ALLOCSIZE;
|
||||
stream->whole_target.inst_alloc = XD3_ALLOCSIZE;
|
||||
stream->whole_target.wininfo_alloc = XD3_ALLOCSIZE;
|
||||
|
||||
if ((stream->whole_target.adds = (uint8_t*)
|
||||
xd3_alloc (stream, stream->whole_target.adds_alloc, 1)) == NULL ||
|
||||
(stream->whole_target.inst = (xd3_winst*)
|
||||
xd3_alloc (stream, stream->whole_target.inst_alloc, 1)) == NULL ||
|
||||
(stream->whole_target.wininfo = (xd3_wininfo*)
|
||||
xd3_alloc (stream, stream->whole_target.wininfo_alloc, 1)) == NULL)
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
xd3_swap_whole_state (xd3_whole_state *a,
|
||||
xd3_whole_state *b)
|
||||
{
|
||||
xd3_whole_state tmp;
|
||||
XD3_ASSERT (a->inst != NULL && a->adds != NULL);
|
||||
XD3_ASSERT (b->inst != NULL && b->adds != NULL);
|
||||
XD3_ASSERT (b->wininfo != NULL && b->wininfo != NULL);
|
||||
memcpy (&tmp, a, sizeof (xd3_whole_state));
|
||||
memcpy (a, b, sizeof (xd3_whole_state));
|
||||
memcpy (b, &tmp, sizeof (xd3_whole_state));
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_realloc_buffer (xd3_stream *stream,
|
||||
usize_t current_units,
|
||||
usize_t unit_size,
|
||||
usize_t new_units,
|
||||
usize_t *alloc_size,
|
||||
void **alloc_ptr)
|
||||
{
|
||||
usize_t needed;
|
||||
usize_t new_alloc;
|
||||
usize_t cur_size;
|
||||
uint8_t *new_buf;
|
||||
|
||||
needed = (current_units + new_units) * unit_size;
|
||||
|
||||
if (needed <= *alloc_size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cur_size = current_units * unit_size;
|
||||
new_alloc = xd3_round_blksize (needed * 2, XD3_ALLOCSIZE);
|
||||
|
||||
if ((new_buf = (uint8_t*) xd3_alloc (stream, new_alloc, 1)) == NULL)
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (cur_size != 0)
|
||||
{
|
||||
memcpy (new_buf, *alloc_ptr, cur_size);
|
||||
}
|
||||
|
||||
if (*alloc_ptr != NULL)
|
||||
{
|
||||
xd3_free (stream, *alloc_ptr);
|
||||
}
|
||||
|
||||
*alloc_size = new_alloc;
|
||||
*alloc_ptr = new_buf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* allocate one new output instruction */
|
||||
static int
|
||||
xd3_whole_alloc_winst (xd3_stream *stream,
|
||||
xd3_winst **winstp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((ret = xd3_realloc_buffer (stream,
|
||||
stream->whole_target.instlen,
|
||||
sizeof (xd3_winst),
|
||||
1,
|
||||
& stream->whole_target.inst_alloc,
|
||||
(void**) & stream->whole_target.inst)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
*winstp = &stream->whole_target.inst[stream->whole_target.instlen++];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_whole_alloc_adds (xd3_stream *stream,
|
||||
usize_t count)
|
||||
{
|
||||
return xd3_realloc_buffer (stream,
|
||||
stream->whole_target.addslen,
|
||||
1,
|
||||
count,
|
||||
& stream->whole_target.adds_alloc,
|
||||
(void**) & stream->whole_target.adds);
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_whole_alloc_wininfo (xd3_stream *stream,
|
||||
xd3_wininfo **wininfop)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((ret = xd3_realloc_buffer (stream,
|
||||
stream->whole_target.wininfolen,
|
||||
sizeof (xd3_wininfo),
|
||||
1,
|
||||
& stream->whole_target.wininfo_alloc,
|
||||
(void**) & stream->whole_target.wininfo)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
*wininfop = &stream->whole_target.wininfo[stream->whole_target.wininfolen++];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_whole_append_inst (xd3_stream *stream,
|
||||
xd3_hinst *inst)
|
||||
{
|
||||
int ret;
|
||||
xd3_winst *winst;
|
||||
|
||||
if ((ret = xd3_whole_alloc_winst (stream, &winst)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
winst->type = inst->type;
|
||||
winst->mode = 0;
|
||||
winst->size = inst->size;
|
||||
winst->position = stream->whole_target.length;
|
||||
stream->whole_target.length += inst->size;
|
||||
|
||||
if (((inst->type == XD3_ADD) || (inst->type == XD3_RUN)) &&
|
||||
(ret = xd3_whole_alloc_adds (stream,
|
||||
(inst->type == XD3_RUN ? 1 : inst->size))))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (inst->type)
|
||||
{
|
||||
case XD3_RUN:
|
||||
winst->addr = stream->whole_target.addslen;
|
||||
stream->whole_target.adds[stream->whole_target.addslen++] =
|
||||
*stream->data_sect.buf++;
|
||||
break;
|
||||
|
||||
case XD3_ADD:
|
||||
winst->addr = stream->whole_target.addslen;
|
||||
memcpy (stream->whole_target.adds + stream->whole_target.addslen,
|
||||
stream->data_sect.buf,
|
||||
inst->size);
|
||||
stream->data_sect.buf += inst->size;
|
||||
stream->whole_target.addslen += inst->size;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (inst->addr < stream->dec_cpylen)
|
||||
{
|
||||
winst->mode = SRCORTGT (stream->dec_win_ind);
|
||||
winst->addr = stream->dec_cpyoff + inst->addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
winst->addr = (stream->dec_winstart +
|
||||
inst->addr -
|
||||
stream->dec_cpylen);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
xd3_whole_append_window (xd3_stream *stream)
|
||||
{
|
||||
int ret;
|
||||
xd3_wininfo *wininfo;
|
||||
|
||||
if ((ret = xd3_whole_alloc_wininfo (stream, &wininfo))) { return ret; }
|
||||
|
||||
wininfo->length = stream->dec_tgtlen;
|
||||
wininfo->offset = stream->dec_winstart;
|
||||
wininfo->adler32 = stream->dec_adler32;
|
||||
|
||||
while (stream->inst_sect.buf < stream->inst_sect.buf_max)
|
||||
{
|
||||
if ((ret = xd3_decode_instruction (stream)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((stream->dec_current1.type != XD3_NOOP) &&
|
||||
(ret = xd3_whole_append_inst (stream,
|
||||
& stream->dec_current1)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((stream->dec_current2.type != XD3_NOOP) &&
|
||||
(ret = xd3_whole_append_inst (stream,
|
||||
& stream->dec_current2)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* xd3_merge_input_output applies *source to *stream, returns the
|
||||
* result in stream. */
|
||||
int xd3_merge_input_output (xd3_stream *stream,
|
||||
xd3_whole_state *source)
|
||||
{
|
||||
int ret;
|
||||
xd3_stream tmp_stream;
|
||||
memset (& tmp_stream, 0, sizeof (tmp_stream));
|
||||
if ((ret = xd3_config_stream (& tmp_stream, NULL)) ||
|
||||
(ret = xd3_whole_state_init (& tmp_stream)) ||
|
||||
(ret = xd3_merge_inputs (& tmp_stream,
|
||||
source,
|
||||
& stream->whole_target)))
|
||||
{
|
||||
XPR(NT XD3_LIB_ERRMSG (&tmp_stream, ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* the output is in tmp_stream.whole_state, swap into input */
|
||||
xd3_swap_whole_state (& stream->whole_target,
|
||||
& tmp_stream.whole_target);
|
||||
/* total allocation counts are preserved */
|
||||
xd3_free_stream (& tmp_stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_merge_run (xd3_stream *stream,
|
||||
xd3_whole_state *target,
|
||||
xd3_winst *iinst)
|
||||
{
|
||||
int ret;
|
||||
xd3_winst *oinst;
|
||||
|
||||
if ((ret = xd3_whole_alloc_winst (stream, &oinst)) ||
|
||||
(ret = xd3_whole_alloc_adds (stream, 1)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
oinst->type = iinst->type;
|
||||
oinst->mode = iinst->mode;
|
||||
oinst->size = iinst->size;
|
||||
oinst->addr = stream->whole_target.addslen;
|
||||
|
||||
XD3_ASSERT (stream->whole_target.length == iinst->position);
|
||||
oinst->position = stream->whole_target.length;
|
||||
stream->whole_target.length += iinst->size;
|
||||
|
||||
stream->whole_target.adds[stream->whole_target.addslen++] =
|
||||
target->adds[iinst->addr];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_merge_add (xd3_stream *stream,
|
||||
xd3_whole_state *target,
|
||||
xd3_winst *iinst)
|
||||
{
|
||||
int ret;
|
||||
xd3_winst *oinst;
|
||||
|
||||
if ((ret = xd3_whole_alloc_winst (stream, &oinst)) ||
|
||||
(ret = xd3_whole_alloc_adds (stream, iinst->size)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
oinst->type = iinst->type;
|
||||
oinst->mode = iinst->mode;
|
||||
oinst->size = iinst->size;
|
||||
oinst->addr = stream->whole_target.addslen;
|
||||
|
||||
XD3_ASSERT (stream->whole_target.length == iinst->position);
|
||||
oinst->position = stream->whole_target.length;
|
||||
stream->whole_target.length += iinst->size;
|
||||
|
||||
memcpy(stream->whole_target.adds + stream->whole_target.addslen,
|
||||
target->adds + iinst->addr,
|
||||
iinst->size);
|
||||
|
||||
stream->whole_target.addslen += iinst->size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_merge_target_copy (xd3_stream *stream,
|
||||
xd3_winst *iinst)
|
||||
{
|
||||
int ret;
|
||||
xd3_winst *oinst;
|
||||
|
||||
if ((ret = xd3_whole_alloc_winst (stream, &oinst)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
XD3_ASSERT (stream->whole_target.length == iinst->position);
|
||||
|
||||
memcpy (oinst, iinst, sizeof (*oinst));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_merge_find_position (xd3_stream *stream,
|
||||
xd3_whole_state *source,
|
||||
xoff_t address,
|
||||
usize_t *inst_num)
|
||||
{
|
||||
usize_t low;
|
||||
usize_t high;
|
||||
|
||||
if (address >= source->length)
|
||||
{
|
||||
stream->msg = "Invalid copy offset in merge";
|
||||
return XD3_INVALID_INPUT;
|
||||
}
|
||||
|
||||
low = 0;
|
||||
high = source->instlen;
|
||||
|
||||
while (low != high)
|
||||
{
|
||||
xoff_t mid_lpos;
|
||||
xoff_t mid_hpos;
|
||||
usize_t mid = low + (high - low) / 2;
|
||||
mid_lpos = source->inst[mid].position;
|
||||
|
||||
if (address < mid_lpos)
|
||||
{
|
||||
high = mid;
|
||||
continue;
|
||||
}
|
||||
|
||||
mid_hpos = mid_lpos + source->inst[mid].size;
|
||||
|
||||
if (address >= mid_hpos)
|
||||
{
|
||||
low = mid + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
*inst_num = mid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
stream->msg = "Internal error in merge";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_merge_source_copy (xd3_stream *stream,
|
||||
xd3_whole_state *source,
|
||||
const xd3_winst *iinst_orig)
|
||||
{
|
||||
int ret;
|
||||
xd3_winst iinst;
|
||||
usize_t sinst_num;
|
||||
|
||||
memcpy (& iinst, iinst_orig, sizeof (iinst));
|
||||
|
||||
XD3_ASSERT (iinst.mode == VCD_SOURCE);
|
||||
|
||||
if ((ret = xd3_merge_find_position (stream, source,
|
||||
iinst.addr, &sinst_num)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
while (iinst.size > 0)
|
||||
{
|
||||
xd3_winst *sinst;
|
||||
xd3_winst *minst;
|
||||
usize_t sinst_offset;
|
||||
usize_t sinst_left;
|
||||
usize_t this_take;
|
||||
|
||||
XD3_ASSERT (sinst_num < source->instlen);
|
||||
|
||||
sinst = &source->inst[sinst_num];
|
||||
|
||||
XD3_ASSERT (iinst.addr >= sinst->position);
|
||||
|
||||
sinst_offset = (usize_t)(iinst.addr - sinst->position);
|
||||
|
||||
XD3_ASSERT (sinst->size > sinst_offset);
|
||||
|
||||
sinst_left = sinst->size - sinst_offset;
|
||||
this_take = xd3_min (iinst.size, sinst_left);
|
||||
|
||||
XD3_ASSERT (this_take > 0);
|
||||
|
||||
if ((ret = xd3_whole_alloc_winst (stream, &minst)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
minst->size = this_take;
|
||||
minst->type = sinst->type;
|
||||
minst->position = iinst.position;
|
||||
minst->mode = 0;
|
||||
|
||||
switch (sinst->type)
|
||||
{
|
||||
case XD3_RUN:
|
||||
if ((ret = xd3_whole_alloc_adds (stream, 1)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
minst->addr = stream->whole_target.addslen;
|
||||
stream->whole_target.adds[stream->whole_target.addslen++] =
|
||||
source->adds[sinst->addr];
|
||||
break;
|
||||
case XD3_ADD:
|
||||
if ((ret = xd3_whole_alloc_adds (stream, this_take)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
minst->addr = stream->whole_target.addslen;
|
||||
memcpy(stream->whole_target.adds + stream->whole_target.addslen,
|
||||
source->adds + sinst->addr + sinst_offset,
|
||||
this_take);
|
||||
stream->whole_target.addslen += this_take;
|
||||
break;
|
||||
default:
|
||||
if (sinst->mode != 0)
|
||||
{
|
||||
minst->mode = sinst->mode;
|
||||
minst->addr = sinst->addr + sinst_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Note: A better implementation will construct the
|
||||
// mapping of output ranges, starting from the input
|
||||
// range, applying deltas in forward order, using an
|
||||
// interval tree. This code uses recursion to construct
|
||||
// each copied range, recursively (using binary search
|
||||
// in xd3_merge_find_position).
|
||||
//
|
||||
// TODO: This code can cause stack overflow. Fix as
|
||||
// described above.
|
||||
xd3_winst tinst;
|
||||
tinst.type = XD3_CPY;
|
||||
tinst.mode = iinst.mode;
|
||||
tinst.addr = sinst->addr + sinst_offset;
|
||||
tinst.size = this_take;
|
||||
tinst.position = iinst.position;
|
||||
|
||||
// The instruction allocated in this frame will not be used.
|
||||
stream->whole_target.instlen -= 1;
|
||||
|
||||
if ((ret = xd3_merge_source_copy (stream, source, &tinst)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
iinst.position += this_take;
|
||||
iinst.addr += this_take;
|
||||
iinst.size -= this_take;
|
||||
sinst_num += 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* xd3_merge_inputs() applies *input to *source, returns its result in
|
||||
* stream. */
|
||||
int xd3_merge_inputs (xd3_stream *stream,
|
||||
xd3_whole_state *source,
|
||||
xd3_whole_state *input)
|
||||
{
|
||||
int ret = 0;
|
||||
usize_t i;
|
||||
size_t input_i;
|
||||
|
||||
for (i = 0; i < input->wininfolen; ++i) {
|
||||
xd3_wininfo *copyinfo;
|
||||
|
||||
if ((ret = xd3_whole_alloc_wininfo (stream, ©info))) { return ret; }
|
||||
|
||||
*copyinfo = input->wininfo[i];
|
||||
}
|
||||
|
||||
/* iterate over each instruction. */
|
||||
for (input_i = 0; ret == 0 && input_i < input->instlen; ++input_i)
|
||||
{
|
||||
xd3_winst *iinst = &input->inst[input_i];
|
||||
|
||||
switch (iinst->type)
|
||||
{
|
||||
case XD3_RUN:
|
||||
ret = xd3_merge_run (stream, input, iinst);
|
||||
break;
|
||||
case XD3_ADD:
|
||||
ret = xd3_merge_add (stream, input, iinst);
|
||||
break;
|
||||
default:
|
||||
if (iinst->mode == 0)
|
||||
{
|
||||
ret = xd3_merge_target_copy (stream, iinst);
|
||||
}
|
||||
else if (iinst->mode == VCD_TARGET)
|
||||
{
|
||||
ret = XD3_INVALID_INPUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = xd3_merge_source_copy (stream, source, iinst);
|
||||
}
|
||||
|
||||
/* The whole_target.length is not updated in the xd3_merge*copy
|
||||
* routine because of recursion in xd3_merge_source_copy. */
|
||||
stream->whole_target.length += iinst->size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,324 +0,0 @@
|
|||
/* xdelta 3 - delta compression tools and library
|
||||
* Copyright (C) 2002, 2003, 2006, 2007, 2013. Joshua P. MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _XDELTA3_SECOND_H_
|
||||
#define _XDELTA3_SECOND_H_
|
||||
|
||||
static inline void xd3_bit_state_encode_init (bit_state *bits)
|
||||
{
|
||||
bits->cur_byte = 0;
|
||||
bits->cur_mask = 1;
|
||||
}
|
||||
|
||||
static inline int xd3_decode_bits (xd3_stream *stream,
|
||||
bit_state *bits,
|
||||
const uint8_t **input,
|
||||
const uint8_t *input_max,
|
||||
usize_t nbits,
|
||||
usize_t *valuep)
|
||||
{
|
||||
usize_t value = 0;
|
||||
usize_t vmask = 1 << nbits;
|
||||
|
||||
if (bits->cur_mask == 0x100) { goto next_byte; }
|
||||
|
||||
for (;;)
|
||||
{
|
||||
do
|
||||
{
|
||||
vmask >>= 1;
|
||||
|
||||
if (bits->cur_byte & bits->cur_mask)
|
||||
{
|
||||
value |= vmask;
|
||||
}
|
||||
|
||||
bits->cur_mask <<= 1;
|
||||
|
||||
if (vmask == 1) { goto done; }
|
||||
}
|
||||
while (bits->cur_mask != 0x100);
|
||||
|
||||
next_byte:
|
||||
|
||||
if (*input == input_max)
|
||||
{
|
||||
stream->msg = "secondary decoder end of input";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
|
||||
bits->cur_byte = *(*input)++;
|
||||
bits->cur_mask = 1;
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
IF_DEBUG2 (DP(RINT "(d) %u ", value));
|
||||
|
||||
(*valuep) = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if REGRESSION_TEST
|
||||
/* There may be extra bits at the end of secondary decompression, this macro
|
||||
* checks for non-zero bits. This is overly strict, but helps pass the
|
||||
* single-bit-error regression test. */
|
||||
static int
|
||||
xd3_test_clean_bits (xd3_stream *stream, bit_state *bits)
|
||||
{
|
||||
for (; bits->cur_mask != 0x100; bits->cur_mask <<= 1)
|
||||
{
|
||||
if (bits->cur_byte & bits->cur_mask)
|
||||
{
|
||||
stream->msg = "secondary decoder garbage";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
xd3_get_secondary (xd3_stream *stream, xd3_sec_stream **sec_streamp,
|
||||
int is_encode)
|
||||
{
|
||||
if (*sec_streamp == NULL)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((*sec_streamp = stream->sec_type->alloc (stream)) == NULL)
|
||||
{
|
||||
stream->msg = "error initializing secondary stream";
|
||||
return XD3_INVALID;
|
||||
}
|
||||
|
||||
if ((ret = stream->sec_type->init (stream, *sec_streamp, is_encode)) != 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_decode_secondary (xd3_stream *stream,
|
||||
xd3_desect *sect,
|
||||
xd3_sec_stream **sec_streamp)
|
||||
{
|
||||
uint32_t dec_size;
|
||||
uint8_t *out_used;
|
||||
int ret;
|
||||
|
||||
if ((ret = xd3_get_secondary (stream, sec_streamp, 0)) != 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Decode the size, allocate the buffer. */
|
||||
if ((ret = xd3_read_size (stream, & sect->buf,
|
||||
sect->buf_max, & dec_size)) ||
|
||||
(ret = xd3_decode_allocate (stream, dec_size,
|
||||
& sect->copied2, & sect->alloc2)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (dec_size == 0)
|
||||
{
|
||||
stream->msg = "secondary decoder invalid output size";
|
||||
return XD3_INVALID_INPUT;
|
||||
}
|
||||
|
||||
out_used = sect->copied2;
|
||||
|
||||
if ((ret = stream->sec_type->decode (stream, *sec_streamp,
|
||||
& sect->buf, sect->buf_max,
|
||||
& out_used, out_used + dec_size)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (sect->buf != sect->buf_max)
|
||||
{
|
||||
stream->msg = "secondary decoder finished with unused input";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
|
||||
if (out_used != sect->copied2 + dec_size)
|
||||
{
|
||||
stream->msg = "secondary decoder short output";
|
||||
return XD3_INTERNAL;
|
||||
}
|
||||
|
||||
sect->buf = sect->copied2;
|
||||
sect->buf_max = sect->copied2 + dec_size;
|
||||
sect->size = dec_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if XD3_ENCODER
|
||||
static inline int xd3_encode_bit (xd3_stream *stream,
|
||||
xd3_output **output,
|
||||
bit_state *bits,
|
||||
usize_t bit)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (bit)
|
||||
{
|
||||
bits->cur_byte |= bits->cur_mask;
|
||||
}
|
||||
|
||||
/* OPT: Might help to buffer more than 8 bits at once. */
|
||||
if (bits->cur_mask == 0x80)
|
||||
{
|
||||
if ((ret = xd3_emit_byte (stream, output, bits->cur_byte)) != 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
bits->cur_mask = 1;
|
||||
bits->cur_byte = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bits->cur_mask <<= 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int xd3_flush_bits (xd3_stream *stream,
|
||||
xd3_output **output,
|
||||
bit_state *bits)
|
||||
{
|
||||
return (bits->cur_mask == 1) ? 0 :
|
||||
xd3_emit_byte (stream, output, bits->cur_byte);
|
||||
}
|
||||
|
||||
static inline int xd3_encode_bits (xd3_stream *stream,
|
||||
xd3_output **output,
|
||||
bit_state *bits,
|
||||
usize_t nbits,
|
||||
usize_t value)
|
||||
{
|
||||
int ret;
|
||||
usize_t mask = 1 << nbits;
|
||||
|
||||
XD3_ASSERT (nbits > 0);
|
||||
XD3_ASSERT (nbits < sizeof (usize_t) * 8);
|
||||
XD3_ASSERT (value < mask);
|
||||
|
||||
do
|
||||
{
|
||||
mask >>= 1;
|
||||
|
||||
if ((ret = xd3_encode_bit (stream, output, bits, value & mask)))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
while (mask != 1);
|
||||
|
||||
IF_DEBUG2 (DP(RINT "(e) %u ", value));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xd3_encode_secondary (xd3_stream *stream,
|
||||
xd3_output **head,
|
||||
xd3_output **tail,
|
||||
xd3_sec_stream **sec_streamp,
|
||||
xd3_sec_cfg *cfg,
|
||||
int *did_it)
|
||||
{
|
||||
xd3_output *tmp_head;
|
||||
xd3_output *tmp_tail;
|
||||
|
||||
usize_t comp_size;
|
||||
usize_t orig_size;
|
||||
|
||||
int ret;
|
||||
|
||||
orig_size = xd3_sizeof_output (*head);
|
||||
|
||||
if (orig_size < SECONDARY_MIN_INPUT) { return 0; }
|
||||
|
||||
if ((ret = xd3_get_secondary (stream, sec_streamp, 1)) != 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
tmp_head = xd3_alloc_output (stream, NULL);
|
||||
|
||||
/* Encode the size, encode the data. Encoding the size makes it
|
||||
* simpler, but is a little gross. Should not need the entire
|
||||
* section in contiguous memory, but it is much easier this way. */
|
||||
if ((ret = xd3_emit_size (stream, & tmp_head, orig_size)) ||
|
||||
(ret = stream->sec_type->encode (stream, *sec_streamp, *head,
|
||||
tmp_head, cfg)))
|
||||
{
|
||||
goto getout;
|
||||
}
|
||||
|
||||
/* If the secondary compressor determines it's no good, it returns
|
||||
* XD3_NOSECOND. */
|
||||
|
||||
/* Setup tmp_tail, comp_size */
|
||||
tmp_tail = tmp_head;
|
||||
comp_size = tmp_head->next;
|
||||
|
||||
while (tmp_tail->next_page != NULL)
|
||||
{
|
||||
tmp_tail = tmp_tail->next_page;
|
||||
comp_size += tmp_tail->next;
|
||||
}
|
||||
|
||||
XD3_ASSERT (comp_size == xd3_sizeof_output (tmp_head));
|
||||
XD3_ASSERT (tmp_tail != NULL);
|
||||
|
||||
if (comp_size < (orig_size - SECONDARY_MIN_SAVINGS) || cfg->inefficient)
|
||||
{
|
||||
if (comp_size < orig_size)
|
||||
{
|
||||
IF_DEBUG1(DP(RINT "[encode_secondary] saved %u bytes: %u -> %u (%0.2f%%)\n",
|
||||
orig_size - comp_size, orig_size, comp_size,
|
||||
100.0 * (double) comp_size / (double) orig_size));
|
||||
}
|
||||
|
||||
xd3_free_output (stream, *head);
|
||||
|
||||
*head = tmp_head;
|
||||
*tail = tmp_tail;
|
||||
*did_it = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
getout:
|
||||
if (ret == XD3_NOSECOND) { ret = 0; }
|
||||
xd3_free_output (stream, tmp_head);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* XD3_ENCODER */
|
||||
#endif /* _XDELTA3_SECOND_H_ */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,153 +0,0 @@
|
|||
.TH XDELTA3 "1" "August 2009" "Xdelta3"
|
||||
.SH NAME
|
||||
xdelta3 \- VCDIFF (RFC 3284) binary diff tool
|
||||
.SH SYNOPSIS
|
||||
.B xdelta3
|
||||
.RI [ command ]
|
||||
.RI [ options ]
|
||||
.RI [ input
|
||||
.RI [ output ]]
|
||||
.SH DESCRIPTION
|
||||
.B xdelta3
|
||||
is a binary diff tool that uses the VCDIFF (RFC 3284) format and compression.
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
.BI config
|
||||
prints xdelta3 configuration
|
||||
.TP
|
||||
.BI decode
|
||||
decompress the input, also set by -d
|
||||
.TP
|
||||
.BI encode
|
||||
compress the input, also set by -e (default)
|
||||
.TP
|
||||
.BI test
|
||||
run the builtin tests
|
||||
.TP
|
||||
.BI printdelta
|
||||
print information about the entire delta
|
||||
.TP
|
||||
.BI printhdr
|
||||
print information about the first window
|
||||
.TP
|
||||
.BI printhdrs
|
||||
print information about all windows
|
||||
.TP
|
||||
.BI recode
|
||||
encode with new application/secondary settings
|
||||
|
||||
.SH OPTIONS
|
||||
standard options:
|
||||
.TP
|
||||
.BI "\-0 .. \-9"
|
||||
compression level
|
||||
.TP
|
||||
.BI "\-c"
|
||||
use stdout
|
||||
.TP
|
||||
.BI "\-d"
|
||||
decompress
|
||||
.TP
|
||||
.BI \-e
|
||||
compress
|
||||
.TP
|
||||
.BI \-f
|
||||
force overwrite
|
||||
.TP
|
||||
.BI \-h
|
||||
show help
|
||||
.TP
|
||||
.BI \-q
|
||||
be quiet
|
||||
.TP
|
||||
.BI \-v
|
||||
be verbose (max 2)
|
||||
.TP
|
||||
.BI \-V
|
||||
show version
|
||||
|
||||
.TP
|
||||
memory options:
|
||||
.TP
|
||||
.BI \-B
|
||||
.RI bytes
|
||||
source window size
|
||||
.TP
|
||||
.BI \-W
|
||||
.RI bytes
|
||||
input window size
|
||||
.TP
|
||||
.BI \-P
|
||||
.RI size
|
||||
compression duplicates window
|
||||
.TP
|
||||
.BI \-I
|
||||
.RI size
|
||||
instruction buffer size (0 = unlimited)
|
||||
|
||||
.TP
|
||||
compression options:
|
||||
.TP
|
||||
.BI \-s
|
||||
.RI source
|
||||
source file to copy from (if any)
|
||||
.TP
|
||||
.BI "\-S " [djw|fgk]
|
||||
enable/disable secondary compression
|
||||
.TP
|
||||
.BI \-N
|
||||
disable small string-matching compression
|
||||
.TP
|
||||
.BI \-D
|
||||
disable external decompression (encode/decode)
|
||||
.TP
|
||||
.BI \-R
|
||||
disable external recompression (decode)
|
||||
.TP
|
||||
.BI \-n
|
||||
disable checksum (encode/decode)
|
||||
.TP
|
||||
.BI \-C
|
||||
soft config (encode, undocumented)
|
||||
.TP
|
||||
.BI "\-A " [apphead]
|
||||
disable/provide application header (encode)
|
||||
.TP
|
||||
.BI \-J
|
||||
disable output (check/compute only)
|
||||
.TP
|
||||
.BI \-T
|
||||
use alternate code table (test)
|
||||
|
||||
.SH NOTES
|
||||
The
|
||||
.B XDELTA
|
||||
environment variable may contain extra args:
|
||||
|
||||
.RS
|
||||
XDELTA="-s source-x.y.tar.gz" \\
|
||||
.br
|
||||
tar --use-compress-program=xdelta3 -cf \\
|
||||
.br
|
||||
target-x.z.tar.gz.vcdiff target-x.y/
|
||||
|
||||
.SH EXAMPLES
|
||||
|
||||
Compress the differences between SOURCE and TARGET, yielding OUT,
|
||||
using "djw" secondary compression:
|
||||
|
||||
xdelta3 -S djw -s SOURCE TARGET OUT
|
||||
|
||||
Do the same, using standard input and output:
|
||||
|
||||
xdelta3 -S djw -s SOURCE < TARGET > OUT
|
||||
|
||||
To decompress OUT, using SOURCE, yielding TARGET:
|
||||
|
||||
xdelta3 -d -s SOURCE OUT TARGET
|
||||
|
||||
.SH AUTHOR
|
||||
xdelta3 was written by Josh MacDonald <josh.macdonald@gmail.com>.
|
||||
.PP
|
||||
This manual page was written by Leo 'costela' Antunes <costela@debian.org>
|
||||
for the Debian project (but may be used by others).
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,85 +0,0 @@
|
|||
%module xdelta3
|
||||
%import cstring.i
|
||||
%import argcargv.i
|
||||
%{
|
||||
#include "xdelta3.h"
|
||||
|
||||
int xd3_main_cmdline (int ARGC, char **ARGV);
|
||||
%}
|
||||
|
||||
%cstring_input_binary(const char *input, unsigned int input_size);
|
||||
%cstring_input_binary(const char *source, unsigned int source_size);
|
||||
|
||||
%define %max_output_withsize(TYPEMAP, SIZE, MAXSIZE)
|
||||
%typemap(in) MAXSIZE (unsigned int alloc_size) {
|
||||
$1 = alloc_size = PyInt_AsLong(obj2);
|
||||
}
|
||||
%typemap(in,numinputs=0) (TYPEMAP, SIZE) {
|
||||
}
|
||||
%typemap(check) (TYPEMAP, SIZE) {
|
||||
// alloc_size input is #7th position in xd3_xxcode_memory()
|
||||
$1 = malloc(alloc_size7);
|
||||
$2 = &alloc_size7;
|
||||
}
|
||||
%typemap(argout,fragment="t_output_helper") (TYPEMAP, SIZE) {
|
||||
if (result == 0) {
|
||||
PyObject *o;
|
||||
// alloc_size7 now carries actual size
|
||||
o = PyString_FromStringAndSize($1,alloc_size7);
|
||||
$result = t_output_helper($result,o);
|
||||
} else {
|
||||
$result = t_output_helper($result,Py_None);
|
||||
}
|
||||
free($1);
|
||||
}
|
||||
%typemap(default) int flags {
|
||||
$1 = 0;
|
||||
}
|
||||
%enddef
|
||||
|
||||
%max_output_withsize(char *output_buf, unsigned int *output_size, unsigned int max_output);
|
||||
|
||||
int xd3_encode_memory (const uint8_t *input,
|
||||
usize_t input_size,
|
||||
const uint8_t *source,
|
||||
usize_t source_size,
|
||||
uint8_t *output_buffer,
|
||||
usize_t *output_size,
|
||||
usize_t avail_output,
|
||||
int flags);
|
||||
|
||||
int xd3_decode_memory (const uint8_t *input,
|
||||
usize_t input_size,
|
||||
const uint8_t *source,
|
||||
usize_t source_size,
|
||||
uint8_t *output_buf,
|
||||
usize_t *output_size,
|
||||
usize_t avail_output,
|
||||
int flags);
|
||||
|
||||
int xd3_main_cmdline (int ARGC, char **ARGV);
|
||||
|
||||
/* Is this the right way? */
|
||||
enum {
|
||||
/*XD3_JUST_HDR,*/
|
||||
/*XD3_SKIP_WINDOW,*/
|
||||
/*XD3_SKIP_EMIT,*/
|
||||
/*XD3_FLUSH,*/
|
||||
XD3_SEC_DJW,
|
||||
XD3_SEC_FGK,
|
||||
/*XD3_SEC_TYPE,*/
|
||||
XD3_SEC_NODATA,
|
||||
XD3_SEC_NOINST,
|
||||
XD3_SEC_NOADDR,
|
||||
/*XD3_SEC_OTHER,*/
|
||||
XD3_ADLER32,
|
||||
XD3_ADLER32_NOVER,
|
||||
XD3_NOCOMPRESS,
|
||||
XD3_BEGREEDY,
|
||||
XD3_COMPLEVEL_SHIFT,
|
||||
XD3_COMPLEVEL_MASK,
|
||||
XD3_COMPLEVEL_1,
|
||||
XD3_COMPLEVEL_3,
|
||||
XD3_COMPLEVEL_6,
|
||||
XD3_COMPLEVEL_9,
|
||||
};
|
|
@ -1,339 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Itanium">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Itanium</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Itanium">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Itanium</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="xdelta3-64|Itanium">
|
||||
<Configuration>xdelta3-64</Configuration>
|
||||
<Platform>Itanium</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="xdelta3-64|Win32">
|
||||
<Configuration>xdelta3-64</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="xdelta3-64|x64">
|
||||
<Configuration>xdelta3-64</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="xdelta3.c">
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">/DXD3_DEBUG=0 /DXD3_USE_LARGEFILE64=1 /DREGRESSION_TEST=1 /DSECONDARY_DJW=1 /DSECONDARY_FGK=1 /DXD3_MAIN=1 /DXD3_WIN32=1 /DEXTERNAL_COMPRESSION=0 /DXD3_STDIO=0 /DXD3_POSIX=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">/DXD3_DEBUG=0 /DXD3_USE_LARGEFILE64=1 /DREGRESSION_TEST=1 /DSECONDARY_DJW=1 /DSECONDARY_FGK=1 /DXD3_MAIN=1 /DXD3_WIN32=1 /DEXTERNAL_COMPRESSION=0 /DXD3_STDIO=0 /DXD3_POSIX=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/DXD3_DEBUG=0 /DXD3_USE_LARGEFILE64=1 /DREGRESSION_TEST=1 /DSECONDARY_DJW=1 /DSECONDARY_FGK=1 /DXD3_MAIN=1 /DXD3_WIN32=1 /DEXTERNAL_COMPRESSION=0 /DXD3_STDIO=0 /DXD3_POSIX=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Win32'">/DXD3_DEBUG=0 /DXD3_USE_LARGEFILE64=1 /DREGRESSION_TEST=1 /DSECONDARY_DJW=1 /DSECONDARY_FGK=1 /DXD3_MAIN=1 /DXD3_WIN32=1 /DEXTERNAL_COMPRESSION=0 /DXD3_STDIO=0 /DXD3_POSIX=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Itanium'">/DXD3_DEBUG=0 /DXD3_USE_LARGEFILE64=1 /DREGRESSION_TEST=1 /DSECONDARY_DJW=1 /DSECONDARY_FGK=1 /DXD3_MAIN=1 /DXD3_WIN32=1 /DEXTERNAL_COMPRESSION=0 /DXD3_STDIO=0 /DXD3_POSIX=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|x64'">/DXD3_DEBUG=0 /DXD3_USE_LARGEFILE64=1 /DREGRESSION_TEST=1 /DSECONDARY_DJW=1 /DSECONDARY_FGK=1 /DXD3_MAIN=1 /DXD3_WIN32=1 /DEXTERNAL_COMPRESSION=0 /DXD3_STDIO=0 /DXD3_POSIX=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="xdelta3-blkcache.h" />
|
||||
<ClInclude Include="xdelta3-cfgs.h" />
|
||||
<ClInclude Include="xdelta3-decode.h" />
|
||||
<ClInclude Include="xdelta3-djw.h" />
|
||||
<ClInclude Include="xdelta3-fgk.h" />
|
||||
<ClInclude Include="xdelta3-hash.h" />
|
||||
<ClInclude Include="xdelta3-internal.h" />
|
||||
<ClInclude Include="xdelta3-list.h" />
|
||||
<ClInclude Include="xdelta3-lzma.h" />
|
||||
<ClInclude Include="xdelta3-main.h" />
|
||||
<ClInclude Include="xdelta3-merge.h" />
|
||||
<ClInclude Include="xdelta3-second.h" />
|
||||
<ClInclude Include="xdelta3-test.h" />
|
||||
<ClInclude Include="xdelta3.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{8F9D37B5-B78E-4816-BE61-AEF679DBF3BC}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>xdelta3</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>Windows7.1SDK</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Itanium'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Itanium'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(WindowsSdkDir)\include;$(VCInstallDir)include;..\xz\include</IncludePath>
|
||||
<LibraryPath>$(LibraryPath);$(VSInstallDir);$(VSInstallDir)lib\amd64;..\xz\bin_x86-64</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Itanium'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;SECONDARY_LZMA=1;LZMA_API_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>../xz/include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;..\..\..\..\src\xz\bin_i486\liblzma_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;..\..\..\..\src\xz\bin_x86-64\liblzma_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;SECONDARY_LZMA=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;LZMA_API_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\src\xz\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;..\..\..\..\src\xz\bin_i486\liblzma_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;SECONDARY_LZMA=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;LZMA_API_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\src\xz\include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);..\..\..\..\src\xz\bin_x86-64\liblzma_static.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|Itanium'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='xdelta3-64|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;XD3_MAIN=1;XD3_DEBUG=0;XD3_USE_LARGEFILE64=1;REGRESSION_TEST=1;SECONDARY_DJW=1;SECONDARY_FGK=1;XD3_WIN32=1;EXTERNAL_COMPRESSION=0;SHELL_TESTS=0;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,7 +0,0 @@
|
|||
<Include>
|
||||
<?define PRODUCT_ID=60131be5-be4d-4975-9108-dd0be735890d ?>
|
||||
<?define PACKAGE_ID=82bf21ca-ee08-4701-ab78-37210dac82ce ?>
|
||||
<?define COMPONENT_ID=85bc3206-05f8-41f8-b500-6ea32e5d6a8f ?>
|
||||
<?define MANUAL_ID=07f387bc-a0c5-4af9-88db-1a84443f1fc5 ?>
|
||||
<?define SOURCE_ID=4e1503a9-3ed1-4e06-b0c0-890462b1a4fd ?>
|
||||
</Include>
|
|
@ -1,131 +0,0 @@
|
|||
<?xml version='1.0'?>
|
||||
<?include $(sys.SOURCEFILEDIR)\xdelta3.wxi ?>
|
||||
|
||||
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
|
||||
<Product Id='$(var.PRODUCT_ID)'
|
||||
Name='Xdelta 3.0u'
|
||||
Language='1033'
|
||||
Codepage='1252'
|
||||
Version='3.0.1.1'
|
||||
Manufacturer='Josh.MacDonald@Gmail.Com'>
|
||||
|
||||
<Package Id='$(var.PACKAGE_ID)'
|
||||
Keywords='Installer'
|
||||
Description='Xdelta 3.0u'
|
||||
Comments='http://xdelta.org'
|
||||
Manufacturer='Josh.MacDonald@Gmail.Com'
|
||||
InstallerVersion='300'
|
||||
Languages='1033'
|
||||
Compressed='yes' />
|
||||
|
||||
<Media Id='1'
|
||||
Cabinet='xdelta30t.cab'
|
||||
EmbedCab='yes' />
|
||||
|
||||
<Directory Id='TARGETDIR' Name='SourceDir'>
|
||||
<Directory Id='ProgramFilesFolder' Name='PFiles'>
|
||||
<Directory Id='Xdelta'
|
||||
Name='Xdelta'>
|
||||
|
||||
<Component Id='Main'
|
||||
Guid='$(var.COMPONENT_ID)'>
|
||||
<File Id='XdeltaEXE'
|
||||
Name='xdelt30t'
|
||||
LongName='xdelta30t.exe'
|
||||
DiskId='1'
|
||||
Source='G:\jmacd\svn\xdelta3\Release\xdelta3.exe'
|
||||
Vital='yes'>
|
||||
</File>
|
||||
</Component>
|
||||
|
||||
<Component Id='Readme'
|
||||
Guid='$(var.MANUAL_ID)'>
|
||||
<File Id='Readme'
|
||||
Name='readme.txt'
|
||||
LongName='readme.txt'
|
||||
DiskId='1'
|
||||
Source='G:\jmacd\svn\xdelta3\readme.txt'
|
||||
Vital='yes'>
|
||||
<Shortcut Id="startupmenuReadme"
|
||||
Directory="ProgramMenuDir"
|
||||
Name="readme.txt"
|
||||
LongName="Xdelta3 readme.txt"
|
||||
/>
|
||||
</File>
|
||||
</Component>
|
||||
|
||||
<Component Id='Copyright'
|
||||
Guid='$(var.MANUAL_ID)'>
|
||||
<File Id='Copyright'
|
||||
Name='COPYING'
|
||||
LongName='COPYING'
|
||||
DiskId='1'
|
||||
Source='G:\jmacd\svn\xdelta3\COPYING'
|
||||
Vital='yes'>
|
||||
<Shortcut Id="startupmenuCopyright"
|
||||
Directory="ProgramMenuDir"
|
||||
Name="COPYING"
|
||||
LongName="GNU Public License"
|
||||
/>
|
||||
</File>
|
||||
</Component>
|
||||
|
||||
<Component Id='Source'
|
||||
Guid='$(var.SOURCE_ID)'>
|
||||
<File Id='Source'
|
||||
Name='xdelt30t.zip'
|
||||
LongName='xdelta3.0u.zip'
|
||||
DiskId='1'
|
||||
Source='G:\jmacd\svn\xdelta3\xdelta3.0u.zip'
|
||||
Vital='yes'>
|
||||
<Shortcut Id="startupmenuSource"
|
||||
Directory="ProgramMenuDir"
|
||||
Name="xdelt30t.zip"
|
||||
LongName="xdelta3.0u.zip"
|
||||
/>
|
||||
</File>
|
||||
</Component>
|
||||
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
||||
<Directory Id="ProgramMenuFolder" Name="PMenu" LongName="Programs">
|
||||
<Directory Id="ProgramMenuDir"
|
||||
Name="xdelt30t"
|
||||
LongName="Xdelta 3.0u">
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
||||
<!-- <Merge Id='CRT' -->
|
||||
<!-- Language='0' -->
|
||||
<!-- DiskId='1' -->
|
||||
<!-- src='C:\Program Files\Common Files\Merge Modules\microsoft_vc80_crt_x86.msm' -->
|
||||
<!-- /> -->
|
||||
<!-- <Merge Id='CRT Policy' -->
|
||||
<!-- Language='0' -->
|
||||
<!-- DiskId='1' -->
|
||||
<!-- src='C:\Program Files\Common Files\Merge Modules\policy_8_0_Microsoft_VC80_CRT_x86.msm' -->
|
||||
<!-- /> -->
|
||||
</Directory>
|
||||
|
||||
<Feature Id='Complete'
|
||||
Level='1'>
|
||||
<ComponentRef Id='Main' />
|
||||
<ComponentRef Id='Readme' />
|
||||
<ComponentRef Id='Copyright' />
|
||||
<ComponentRef Id='Source' />
|
||||
</Feature>
|
||||
|
||||
<!-- <Feature Id='CRT_WinSXS' Title='CRT WinSXS' Level='1'> -->
|
||||
<!-- <MergeRef Id='CRT' /> -->
|
||||
<!-- <MergeRef Id='CRT Policy' /> -->
|
||||
<!-- </Feature> -->
|
||||
|
||||
<InstallExecuteSequence>
|
||||
<RemoveRegistryValues/>
|
||||
<RemoveFiles/>
|
||||
<InstallFiles/>
|
||||
<WriteRegistryValues/>
|
||||
</InstallExecuteSequence>
|
||||
</Product>
|
||||
</Wix>
|
|
@ -29,7 +29,6 @@ if meson.is_subproject() == false
|
|||
'source/player.cpp',
|
||||
cpp_args : [ commonCompileArgs, '-DNCURSES' ],
|
||||
dependencies : [ quickerNESDependency, toolDependency, dependency('sdl2'), dependency('SDL2_image') ],
|
||||
include_directories : include_directories(['source']),
|
||||
link_args : [ '-lncurses' ],
|
||||
sources : quickerNESPlayerSrc
|
||||
)
|
||||
|
@ -41,7 +40,6 @@ if meson.is_subproject() == false
|
|||
'source/tester.cpp',
|
||||
cpp_args : [ commonCompileArgs, '-Werror' ],
|
||||
dependencies : [ quickerNESDependency, toolDependency ],
|
||||
include_directories : include_directories(['../extern/json'])
|
||||
)
|
||||
|
||||
# Building tester tool for the original QuickNES
|
||||
|
@ -50,7 +48,6 @@ if meson.is_subproject() == false
|
|||
'source/tester.cpp',
|
||||
cpp_args : [ commonCompileArgs, '-w', '-DDISABLE_AUTO_FILE', '-D__LIBRETRO__', '-DNDEBUG', '-DBLARGG_NONPORTABLE' ],
|
||||
dependencies : [ quickNESDependency, toolDependency ],
|
||||
include_directories : include_directories(['../extern/json'])
|
||||
)
|
||||
|
||||
# Building tests
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdexcept>
|
||||
#include <stdio.h>
|
||||
|
||||
// If we use NCurses, we need to use the appropriate printing function
|
||||
#ifndef LOG
|
||||
#ifdef NCURSES
|
||||
#include <ncurses.h>
|
||||
#define LOG printw
|
||||
#else
|
||||
#define LOG printf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EXIT_WITH_ERROR
|
||||
#define EXIT_WITH_ERROR(...) exitWithError(__FILE__, __LINE__, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
inline void exitWithError [[noreturn]] (const char *fileName, const int lineNumber, const char *format, ...)
|
||||
{
|
||||
char *outstr = 0;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
int ret = vasprintf(&outstr, format, ap);
|
||||
if (ret < 0) exit(-1);
|
||||
|
||||
std::string outString = outstr;
|
||||
free(outstr);
|
||||
|
||||
char info[1024];
|
||||
|
||||
snprintf(info, sizeof(info) - 1, " + From %s:%d\n", fileName, lineNumber);
|
||||
outString += info;
|
||||
|
||||
throw std::runtime_error(outString.c_str());
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ subdir('quickerNES')
|
|||
toolDependency = declare_dependency(
|
||||
include_directories : include_directories(['.', '../extern']),
|
||||
sources : [
|
||||
'../extern/metrohash128/metrohash128.cpp',
|
||||
'../extern/xdelta3/xdelta3.c',
|
||||
'../extern/jaffarCommon/extern/metrohash128/metrohash128.cpp',
|
||||
'../extern/jaffarCommon/extern/xdelta3/xdelta3.c',
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "jaffarCommon/include/logger.hpp"
|
||||
#include "controller.hpp"
|
||||
|
||||
// Size of image generated in graphics buffer
|
||||
|
@ -98,8 +98,24 @@ class NESInstanceBase
|
|||
virtual void deserializeState(const uint8_t *state) = 0;
|
||||
virtual size_t getStateSize() const = 0;
|
||||
|
||||
virtual void serializeDifferentialState(uint8_t *differentialData, size_t* differentialDataPos, const uint8_t* referenceData, size_t* referenceDataPos, const size_t maxSize, const bool useZlib) const = 0;
|
||||
virtual void deserializeDifferentialState(const uint8_t *differentialData, size_t* differentialDataPos, const uint8_t* referenceData, size_t* referenceDataPos, const bool useZlib) = 0;
|
||||
virtual void serializeDifferentialState(
|
||||
uint8_t *outputData,
|
||||
size_t* outputDataPos,
|
||||
const size_t outputDataMaxSize,
|
||||
const uint8_t* referenceData,
|
||||
size_t* referenceDataPos,
|
||||
const size_t referenceDataMaxSize,
|
||||
const bool useZlib) const = 0;
|
||||
|
||||
virtual void deserializeDifferentialState(
|
||||
const uint8_t *inputData,
|
||||
size_t* inputDataPos,
|
||||
const size_t inputDataMaxSize,
|
||||
const uint8_t* referenceData,
|
||||
size_t* referenceDataPos,
|
||||
const size_t referenceDataMaxSize,
|
||||
const bool useZlib) = 0;
|
||||
|
||||
virtual size_t getDifferentialStateSize() const = 0;
|
||||
|
||||
virtual void doSoftReset() = 0;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "nesInstance.hpp"
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
#include <hqn/hqn.h>
|
||||
#include <hqn/hqn_gui_controller.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <utils.hpp>
|
||||
#include <jaffarCommon/include/hash.hpp>
|
||||
#include "nesInstance.hpp"
|
||||
|
||||
#define _INVERSE_FRAME_RATE 16667
|
||||
|
||||
|
@ -15,7 +15,7 @@ struct stepData_t
|
|||
{
|
||||
std::string input;
|
||||
uint8_t *stateData;
|
||||
hash_t hash;
|
||||
jaffarCommon::hash_t hash;
|
||||
};
|
||||
|
||||
class PlaybackInstance
|
||||
|
@ -30,7 +30,7 @@ class PlaybackInstance
|
|||
step.input = input;
|
||||
step.stateData = (uint8_t *)malloc(_emu->getStateSize());
|
||||
_emu->serializeState(step.stateData);
|
||||
step.hash = calculateStateHash(_emu);
|
||||
step.hash = jaffarCommon::calculateMetroHash(_emu->getLowMem(), _emu->getLowMemSize());
|
||||
|
||||
// Adding the step into the sequence
|
||||
_stepSequence.push_back(step);
|
||||
|
@ -205,7 +205,7 @@ class PlaybackInstance
|
|||
return step.stateData;
|
||||
}
|
||||
|
||||
const hash_t getStateHash(const size_t stepId) const
|
||||
const jaffarCommon::hash_t getStateHash(const size_t stepId) const
|
||||
{
|
||||
// Checking the required step id does not exceed contents of the sequence
|
||||
if (stepId > _stepSequence.size()) EXIT_WITH_ERROR("[Error] Attempting to render a step larger than the step sequence");
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "argparse/argparse.hpp"
|
||||
#include <cstdlib>
|
||||
#include "jaffarCommon/extern/argparse/argparse.hpp"
|
||||
#include "jaffarCommon/include/file.hpp"
|
||||
#include "jaffarCommon/include/logger.hpp"
|
||||
#include "jaffarCommon/include/string.hpp"
|
||||
#include "nesInstance.hpp"
|
||||
#include "playbackInstance.hpp"
|
||||
#include "utils.hpp"
|
||||
#include <cstdlib>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -72,14 +74,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Loading sequence file
|
||||
std::string inputSequence;
|
||||
auto status = loadStringFromFile(inputSequence, sequenceFilePath.c_str());
|
||||
auto status = jaffarCommon::loadStringFromFile(inputSequence, sequenceFilePath.c_str());
|
||||
if (status == false) EXIT_WITH_ERROR("[ERROR] Could not find or read from sequence file: %s\n", sequenceFilePath.c_str());
|
||||
|
||||
// Building sequence information
|
||||
const auto sequence = split(inputSequence, ' ');
|
||||
const auto sequence = jaffarCommon::split(inputSequence, ' ');
|
||||
|
||||
// Initializing terminal
|
||||
initializeTerminal();
|
||||
jaffarCommon::initializeTerminal();
|
||||
|
||||
// Printing provided parameters
|
||||
printw("[] Rom File Path: '%s'\n", romFilePath.c_str());
|
||||
|
@ -88,7 +90,7 @@ int main(int argc, char *argv[])
|
|||
printw("[] State File Path: '%s'\n", stateFilePath.empty() ? "<Boot Start>" : stateFilePath.c_str());
|
||||
printw("[] Generating Sequence...\n");
|
||||
|
||||
refreshTerminal();
|
||||
jaffarCommon::refreshTerminal();
|
||||
|
||||
// Creating emulator instance
|
||||
NESInstance e;
|
||||
|
@ -99,14 +101,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Loading ROM File
|
||||
std::string romFileData;
|
||||
if (loadStringFromFile(romFileData, romFilePath) == false) EXIT_WITH_ERROR("Could not rom file: %s\n", romFilePath.c_str());
|
||||
if (jaffarCommon::loadStringFromFile(romFileData, romFilePath) == false) EXIT_WITH_ERROR("Could not rom file: %s\n", romFilePath.c_str());
|
||||
e.loadROM((uint8_t*)romFileData.data(), romFileData.size());
|
||||
|
||||
// If an initial state is provided, load it now
|
||||
if (stateFilePath != "")
|
||||
{
|
||||
std::string stateFileData;
|
||||
if (loadStringFromFile(stateFileData, stateFilePath) == false) EXIT_WITH_ERROR("Could not initial state file: %s\n", stateFilePath.c_str());
|
||||
if (jaffarCommon::loadStringFromFile(stateFileData, stateFilePath) == false) EXIT_WITH_ERROR("Could not initial state file: %s\n", stateFilePath.c_str());
|
||||
e.deserializeState((uint8_t*)stateFileData.data());
|
||||
}
|
||||
|
||||
|
@ -144,7 +146,7 @@ int main(int argc, char *argv[])
|
|||
// Printing data and commands
|
||||
if (showFrameInfo)
|
||||
{
|
||||
clearTerminal();
|
||||
jaffarCommon::clearTerminal();
|
||||
|
||||
printw("[] ----------------------------------------------------------------\n");
|
||||
printw("[] Current Step #: %lu / %lu\n", currentStep + 1, sequenceLength);
|
||||
|
@ -154,14 +156,14 @@ int main(int argc, char *argv[])
|
|||
// Only print commands if not in reproduce mode
|
||||
if (isReproduce == false) printw("[] Commands: n: -1 m: +1 | h: -10 | j: +10 | y: -100 | u: +100 | k: -1000 | i: +1000 | s: quicksave | p: play | q: quit\n");
|
||||
|
||||
refreshTerminal();
|
||||
jaffarCommon::refreshTerminal();
|
||||
}
|
||||
|
||||
// Resetting show frame info flag
|
||||
showFrameInfo = true;
|
||||
|
||||
// Get command
|
||||
auto command = getKeyPress();
|
||||
auto command = jaffarCommon::getKeyPress();
|
||||
|
||||
// Advance/Rewind commands
|
||||
if (command == 'n') currentStep = currentStep - 1;
|
||||
|
@ -186,7 +188,7 @@ int main(int argc, char *argv[])
|
|||
std::string saveData;
|
||||
saveData.resize(stateSize);
|
||||
memcpy(saveData.data(), stateData, stateSize);
|
||||
if (saveStringToFile(saveData, saveFileName.c_str()) == false) EXIT_WITH_ERROR("[ERROR] Could not save state file: %s\n", saveFileName.c_str());
|
||||
if (jaffarCommon::saveStringToFile(saveData, saveFileName.c_str()) == false) EXIT_WITH_ERROR("[ERROR] Could not save state file: %s\n", saveFileName.c_str());
|
||||
printw("[] Saved state to %s\n", saveFileName.c_str());
|
||||
|
||||
// Do no show frame info again after this action
|
||||
|
@ -201,5 +203,5 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
// Ending ncurses window
|
||||
finalizeTerminal();
|
||||
jaffarCommon::finalizeTerminal();
|
||||
}
|
||||
|
|
|
@ -50,11 +50,25 @@ class NESInstance final : public NESInstanceBase
|
|||
return w.size();
|
||||
}
|
||||
|
||||
void serializeDifferentialState(uint8_t *differentialData, size_t* differentialDataPos, const uint8_t* referenceData, size_t* referenceDataPos, const size_t maxSize, const bool useZlib) const override
|
||||
{ serializeState(differentialData); }
|
||||
void serializeDifferentialState(
|
||||
uint8_t *outputData,
|
||||
size_t* outputDataPos,
|
||||
const size_t outputDataMaxSize,
|
||||
const uint8_t* referenceData,
|
||||
size_t* referenceDataPos,
|
||||
const size_t maxSize,
|
||||
const bool useZlib) const override
|
||||
{ serializeState(outputData); }
|
||||
|
||||
void deserializeDifferentialState(const uint8_t *differentialData, size_t* differentialDataPos, const uint8_t* referenceData, size_t* referenceDataPos, const bool useZlib) override
|
||||
{ deserializeState(differentialData); }
|
||||
void deserializeDifferentialState(
|
||||
const uint8_t *inputData,
|
||||
size_t* inputDataPos,
|
||||
const size_t inputDataMaxSize,
|
||||
const uint8_t* referenceData,
|
||||
size_t* referenceDataPos,
|
||||
const size_t referenceDataMaxSize,
|
||||
const bool useZlib) override
|
||||
{ deserializeState(inputData); }
|
||||
|
||||
size_t getDifferentialStateSize() const override
|
||||
{ return getStateSize(); }
|
||||
|
|
|
@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|||
#include "ppu/ppu.hpp"
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <xdelta3/xdelta3.h>
|
||||
#include <jaffarCommon/include/diff.hpp>
|
||||
|
||||
namespace quickerNES
|
||||
{
|
||||
|
@ -153,26 +153,6 @@ class Core : private Cpu
|
|||
reset(true, true);
|
||||
}
|
||||
|
||||
static inline void serializeContiguousData(const uint8_t* __restrict__ inputData, const size_t inputDataSize, uint8_t* __restrict__ outputData, size_t* outputDataPos, size_t* referenceDataPos)
|
||||
{
|
||||
// Only perform memcpy if the input block is not null
|
||||
if (outputData != nullptr) memcpy(&outputData[*outputDataPos], inputData, inputDataSize);
|
||||
|
||||
// Moving pointer positions
|
||||
*outputDataPos += inputDataSize;
|
||||
if (referenceDataPos != nullptr) *referenceDataPos += inputDataSize;
|
||||
}
|
||||
|
||||
static inline void deserializeContiguousData(uint8_t* __restrict__ outputData, const size_t outputDataSize, const uint8_t* __restrict__ inputData, size_t* inputDataPos, size_t* referenceDataPos)
|
||||
{
|
||||
// Only perform memcpy if the input block is not null
|
||||
if (outputData != nullptr) memcpy(outputData, &inputData[*inputDataPos], outputDataSize);
|
||||
|
||||
// Moving pointer positions
|
||||
*inputDataPos += outputDataSize;
|
||||
if (referenceDataPos != nullptr) *referenceDataPos += outputDataSize;
|
||||
}
|
||||
|
||||
static inline void serializeBlockHead(
|
||||
uint8_t* __restrict__ outputData,
|
||||
size_t* outputDataPos,
|
||||
|
@ -197,125 +177,21 @@ class Core : private Cpu
|
|||
if (referenceDataPos != nullptr) *referenceDataPos += 8;
|
||||
}
|
||||
|
||||
static inline void serializeDifferentialData(
|
||||
const uint8_t* __restrict__ inputData,
|
||||
const size_t inputDataSize,
|
||||
uint8_t* __restrict__ outputData,
|
||||
size_t* outputDataPos,
|
||||
const uint8_t* __restrict__ referenceData = nullptr,
|
||||
size_t* referenceDataPos = 0,
|
||||
const size_t outputMaxSize = 0,
|
||||
const bool useZlib = false
|
||||
)
|
||||
{
|
||||
// Only perform compression if input is not null
|
||||
if (outputData != nullptr)
|
||||
{
|
||||
// Variable to store difference count
|
||||
auto diffCount = (usize_t*)&outputData[*outputDataPos];
|
||||
|
||||
// Advancing position pointer to store the difference counter
|
||||
*outputDataPos += sizeof(usize_t);
|
||||
|
||||
// If we reached maximum output, stop here
|
||||
if (*outputDataPos >= outputMaxSize)
|
||||
{
|
||||
fprintf(stderr, "[Error] Maximum output data position reached before differential encode (%lu)\n", outputMaxSize);
|
||||
std::runtime_error("Error while serializing");
|
||||
}
|
||||
|
||||
// Encoding differential
|
||||
int ret = xd3_encode_memory(
|
||||
inputData,
|
||||
inputDataSize,
|
||||
&referenceData[*referenceDataPos],
|
||||
inputDataSize,
|
||||
&outputData[*outputDataPos],
|
||||
diffCount,
|
||||
outputMaxSize - *outputDataPos,
|
||||
useZlib ? 0 : XD3_NOCOMPRESS
|
||||
);
|
||||
|
||||
// If an error happened, print it here
|
||||
if (ret != 0)
|
||||
{
|
||||
fprintf(stderr, "[Error] unexpected error while encoding differential compression. Diff count: %u\n", *diffCount);
|
||||
std::runtime_error("Error while serializing");
|
||||
}
|
||||
|
||||
// Increasing output data position pointer
|
||||
*outputDataPos += *diffCount;
|
||||
|
||||
// If exceeded size, report it
|
||||
if ((usize_t)*outputDataPos > outputMaxSize)
|
||||
{
|
||||
fprintf(stderr, "[Error] Differential compression size (%u) exceeded output maximum size (%lu).\n", *diffCount, outputMaxSize);
|
||||
std::runtime_error("Error while serializing");
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, increasing reference data position pointer
|
||||
*referenceDataPos += inputDataSize;
|
||||
}
|
||||
|
||||
static inline void deserializeDifferentialData(
|
||||
uint8_t* __restrict__ outputData,
|
||||
const size_t outputDataSize,
|
||||
const uint8_t* __restrict__ inputData,
|
||||
size_t* inputDataPos,
|
||||
const uint8_t* __restrict__ referenceData = nullptr,
|
||||
size_t* referenceDataPos = 0,
|
||||
const bool useZlib = false
|
||||
)
|
||||
{
|
||||
// Reading differential count
|
||||
usize_t diffCount;
|
||||
memcpy(&diffCount, &inputData[*inputDataPos], sizeof(usize_t));
|
||||
|
||||
// Advancing position pointer to store the difference counter
|
||||
*inputDataPos += sizeof(usize_t);
|
||||
|
||||
// Encoding differential
|
||||
usize_t output_size;
|
||||
int ret = xd3_decode_memory(
|
||||
&inputData[*inputDataPos],
|
||||
diffCount,
|
||||
&referenceData[*referenceDataPos],
|
||||
outputDataSize,
|
||||
outputData,
|
||||
&output_size,
|
||||
outputDataSize,
|
||||
useZlib ? 0 : XD3_NOCOMPRESS
|
||||
);
|
||||
|
||||
// If an error happened, print it here
|
||||
if (ret != 0)
|
||||
{
|
||||
fprintf(stderr, "[Error] unexpected error while decoding differential compression. Diff count: %u\n", diffCount);
|
||||
std::runtime_error("Error while deserializing");
|
||||
}
|
||||
|
||||
// Increasing output data position pointer
|
||||
*inputDataPos += diffCount;
|
||||
|
||||
// Finally, increasing reference data position pointer
|
||||
*referenceDataPos += outputDataSize;
|
||||
}
|
||||
|
||||
|
||||
inline void serializeState(
|
||||
uint8_t* __restrict__ outputData,
|
||||
size_t* outputDataPos = nullptr,
|
||||
size_t* outputDataPos,
|
||||
const size_t outputDataMaxSize,
|
||||
const uint8_t* __restrict__ referenceData = nullptr,
|
||||
size_t* referenceDataPos = nullptr,
|
||||
const size_t outputMaxSize = 0,
|
||||
const size_t referenceDataMaxSize = 0,
|
||||
const bool useZlib = false) const
|
||||
{
|
||||
size_t tmpIOutputDataPos = 0;
|
||||
if (outputDataPos == nullptr) outputDataPos = &tmpIOutputDataPos;
|
||||
|
||||
// NESS Block
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "NESS", 0xFFFFFFFF, referenceDataPos);
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "NESS", 0xFFFFFFFF, referenceDataPos);
|
||||
|
||||
// TIME Block
|
||||
if (TIMEBlockEnabled == true)
|
||||
|
@ -326,8 +202,8 @@ class Core : private Cpu
|
|||
const auto inputDataSize = sizeof(nes_state_t);
|
||||
const auto inputData = (uint8_t *)&state;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "TIME", inputDataSize, referenceDataPos);
|
||||
serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "TIME", inputDataSize, referenceDataPos);
|
||||
jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
}
|
||||
|
||||
// CPUR Block
|
||||
|
@ -346,7 +222,7 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)&s;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "CPUR", inputDataSize, referenceDataPos);
|
||||
serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
}
|
||||
|
||||
if (PPURBlockEnabled == true)
|
||||
|
@ -355,7 +231,7 @@ class Core : private Cpu
|
|||
const auto inputData = (const uint8_t *)&ppu;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "PPUR", inputDataSize, referenceDataPos);
|
||||
serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
}
|
||||
|
||||
// APUR Block
|
||||
|
@ -368,7 +244,7 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)&apuState;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "APUR", inputDataSize, referenceDataPos);
|
||||
serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
}
|
||||
|
||||
// CTRL Block
|
||||
|
@ -378,7 +254,7 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)&joypad;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "CTRL", inputDataSize, referenceDataPos);
|
||||
serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
}
|
||||
|
||||
// MAPR Block
|
||||
|
@ -388,7 +264,7 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)mapper->state;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "MAPR", inputDataSize, referenceDataPos);
|
||||
serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
}
|
||||
|
||||
// LRAM Block
|
||||
|
@ -398,8 +274,8 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)low_mem;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "LRAM", inputDataSize, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, referenceData, referenceDataPos, outputMaxSize, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize,useZlib);
|
||||
}
|
||||
|
||||
// SPRT Block
|
||||
|
@ -409,8 +285,8 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)ppu.spr_ram;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "SPRT", inputDataSize, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, referenceData, referenceDataPos, outputMaxSize, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize,useZlib);
|
||||
}
|
||||
|
||||
// NTAB Block
|
||||
|
@ -423,8 +299,8 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)ppu.impl->nt_ram;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "NTAB", inputDataSize, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, referenceData, referenceDataPos, outputMaxSize, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize,useZlib);
|
||||
}
|
||||
|
||||
// CHRR Block
|
||||
|
@ -436,8 +312,8 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)ppu.impl->chr_ram;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "CHRR", inputDataSize, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, referenceData, referenceDataPos, outputMaxSize, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize,useZlib);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,8 +326,8 @@ class Core : private Cpu
|
|||
const auto inputData = (uint8_t *)impl->sram;
|
||||
|
||||
if (HEADBlockEnabled == true) serializeBlockHead(outputData, outputDataPos, "SRAM", inputDataSize, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, referenceData, referenceDataPos, outputMaxSize, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::serializeContiguousData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::serializeDifferentialData(inputData, inputDataSize, outputData, outputDataPos, outputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize,useZlib);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,9 +337,11 @@ class Core : private Cpu
|
|||
|
||||
inline void deserializeState(
|
||||
const uint8_t* __restrict__ inputData,
|
||||
size_t* inputDataPos = nullptr,
|
||||
size_t* inputDataPos,
|
||||
const size_t inputDataMaxSize,
|
||||
const uint8_t* __restrict__ referenceData = nullptr,
|
||||
size_t* referenceDataPos = nullptr,
|
||||
const size_t referenceDataMaxSize = 0,
|
||||
const bool useZlib = false)
|
||||
{
|
||||
disable_rendering();
|
||||
|
@ -485,7 +363,7 @@ class Core : private Cpu
|
|||
const auto inputDataSize = sizeof(nes_state_t);
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
|
||||
nes = nesState;
|
||||
nes.timestamp /= 5;
|
||||
|
@ -500,7 +378,7 @@ class Core : private Cpu
|
|||
const auto inputDataSize = sizeof(cpu_state_t);
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
|
||||
r.pc = s.pc;
|
||||
r.sp = s.s;
|
||||
|
@ -517,7 +395,7 @@ class Core : private Cpu
|
|||
const auto inputDataSize = sizeof(ppu_state_t);
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
}
|
||||
|
||||
// APUR Block
|
||||
|
@ -529,7 +407,7 @@ class Core : private Cpu
|
|||
const auto inputDataSize = sizeof(Apu::apu_state_t);
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
|
||||
impl->apu.load_state(apuState);
|
||||
impl->apu.end_frame(-(int)nes.timestamp / ppu_overclock);
|
||||
|
@ -542,7 +420,7 @@ class Core : private Cpu
|
|||
const auto inputDataSize = sizeof(joypad_state_t);
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
}
|
||||
|
||||
// MAPR Block
|
||||
|
@ -554,7 +432,7 @@ class Core : private Cpu
|
|||
const auto inputDataSize = mapper->state_size;
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
|
||||
mapper->apply_mapping();
|
||||
}
|
||||
|
@ -566,8 +444,8 @@ class Core : private Cpu
|
|||
const auto inputDataSize = low_ram_size;
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, referenceData, referenceDataPos, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib);
|
||||
}
|
||||
|
||||
// SPRT Block
|
||||
|
@ -577,8 +455,8 @@ class Core : private Cpu
|
|||
const auto inputDataSize = Ppu::spr_ram_size;
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, referenceData, referenceDataPos, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib);
|
||||
}
|
||||
|
||||
// NTAB Block
|
||||
|
@ -591,8 +469,8 @@ class Core : private Cpu
|
|||
const auto inputDataSize = nametable_size;
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, referenceData, referenceDataPos, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib);
|
||||
}
|
||||
|
||||
// CHRR Block
|
||||
|
@ -604,8 +482,8 @@ class Core : private Cpu
|
|||
const auto inputDataSize = ppu.chr_size;
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, referenceData, referenceDataPos, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib);
|
||||
|
||||
ppu.all_tiles_modified();
|
||||
}
|
||||
|
@ -620,8 +498,8 @@ class Core : private Cpu
|
|||
const auto inputDataSize = impl->sram_size;
|
||||
|
||||
if (HEADBlockEnabled == true) deserializeBlockHead(inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos == nullptr) deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, referenceDataPos);
|
||||
if (referenceDataPos != nullptr) deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, referenceData, referenceDataPos, useZlib);
|
||||
if (referenceDataPos == nullptr) jaffarCommon::deserializeContiguousData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceDataPos, referenceDataMaxSize);
|
||||
if (referenceDataPos != nullptr) jaffarCommon::deserializeDifferentialData(outputData, inputDataSize, inputData, inputDataPos, inputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
// Emu 0.7.0
|
||||
|
||||
#include <limits>
|
||||
#include "cart.hpp"
|
||||
#include "core.hpp"
|
||||
#include "apu/multiBuffer.hpp"
|
||||
|
@ -45,25 +46,44 @@ class Emu
|
|||
const uint8_t *getHostPixels() const { return emu.ppu.host_pixels; }
|
||||
|
||||
// Save emulator state variants
|
||||
void serializeState(uint8_t *buffer) const { emu.serializeState(buffer); }
|
||||
void deserializeState(const uint8_t *buffer) { emu.deserializeState(buffer); }
|
||||
size_t getStateSize() const { size_t outputDataPos = 0; emu.serializeState(nullptr, &outputDataPos); return outputDataPos; }
|
||||
void serializeState(uint8_t *buffer) const { emu.serializeState(buffer, nullptr, std::numeric_limits<uint32_t>::max()); }
|
||||
void deserializeState(const uint8_t *buffer) { emu.deserializeState(buffer, nullptr, std::numeric_limits<uint32_t>::max()); }
|
||||
size_t getStateSize() const { size_t outputDataPos = 0; emu.serializeState(nullptr, &outputDataPos, std::numeric_limits<uint32_t>::max()); return outputDataPos; }
|
||||
|
||||
void serializeDifferentialState(uint8_t* __restrict__ outputData, size_t* outputDataPos, const uint8_t* __restrict__ referenceData, size_t* referenceDataPos, const size_t outputMaxSize, const bool useZlib) const
|
||||
void serializeDifferentialState(
|
||||
uint8_t* __restrict__ outputData,
|
||||
size_t* outputDataPos,
|
||||
const size_t outputDataMaxSize,
|
||||
const uint8_t* __restrict__ referenceData,
|
||||
size_t* referenceDataPos,
|
||||
const size_t referenceDataMaxSize,
|
||||
const bool useZlib) const
|
||||
{
|
||||
emu.serializeState(outputData, outputDataPos, referenceData, referenceDataPos, outputMaxSize, useZlib);
|
||||
emu.serializeState(outputData, outputDataPos, outputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib);
|
||||
}
|
||||
|
||||
void deserializeDifferentialState(const uint8_t* __restrict__ inputData, size_t* inputDataPos, const uint8_t* __restrict__ referenceData, size_t* referenceDataPos, const bool useZlib)
|
||||
void deserializeDifferentialState(
|
||||
const uint8_t* __restrict__ inputData,
|
||||
size_t* inputDataPos,
|
||||
const size_t inputDataMaxSize,
|
||||
const uint8_t* __restrict__ referenceData,
|
||||
size_t* referenceDataPos,
|
||||
const size_t referenceDataMaxSize,
|
||||
const bool useZlib)
|
||||
{
|
||||
emu.deserializeState(inputData, inputDataPos, referenceData, referenceDataPos, useZlib);
|
||||
emu.deserializeState(inputData, inputDataPos, inputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib);
|
||||
}
|
||||
|
||||
size_t getDifferentialStateSize() const
|
||||
{
|
||||
uint8_t* outputDataPtr = nullptr;
|
||||
size_t outputDataPos = 0;
|
||||
uint8_t* referenceDataPtr = nullptr;
|
||||
size_t referenceDataPos = 0;
|
||||
emu.serializeState(nullptr, &outputDataPos, nullptr, &referenceDataPos, 0, false);
|
||||
uint32_t outputDataMaxSize = std::numeric_limits<uint32_t>::max();
|
||||
uint32_t referenceDataMaxSize = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
emu.serializeState(outputDataPtr, &outputDataPos, outputDataMaxSize, referenceDataPtr, &referenceDataPos, referenceDataMaxSize, false);
|
||||
return outputDataPos;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,26 @@ class NESInstance final : public NESInstanceBase
|
|||
void deserializeState(const uint8_t *state) override { _nes.deserializeState(state); }
|
||||
size_t getStateSize() const override { return _nes.getStateSize(); }
|
||||
|
||||
void serializeDifferentialState(uint8_t *differentialData, size_t* differentialDataPos, const uint8_t* referenceData, size_t* referenceDataPos, const size_t maxSize, const bool useZlib) const override
|
||||
{ _nes.serializeDifferentialState(differentialData, differentialDataPos, referenceData, referenceDataPos, maxSize, useZlib); }
|
||||
void serializeDifferentialState(
|
||||
uint8_t *outputData,
|
||||
size_t* outputDataPos,
|
||||
const size_t outputDataMaxSize,
|
||||
const uint8_t* referenceData,
|
||||
size_t* referenceDataPos,
|
||||
const size_t referenceDataMaxSize,
|
||||
const bool useZlib) const override
|
||||
{ _nes.serializeDifferentialState(outputData, outputDataPos, outputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib); }
|
||||
|
||||
void deserializeDifferentialState(const uint8_t *differentialData, size_t* differentialDataPos, const uint8_t* referenceData, size_t* referenceDataPos, const bool useZlib) override
|
||||
{ _nes.deserializeDifferentialState(differentialData, differentialDataPos, referenceData, referenceDataPos, useZlib); }
|
||||
void deserializeDifferentialState(
|
||||
const uint8_t *inputData,
|
||||
size_t* inputDataPos,
|
||||
const size_t inputDataMaxSize,
|
||||
const uint8_t* referenceData,
|
||||
size_t* referenceDataPos,
|
||||
const size_t referenceDataMaxSize,
|
||||
const bool useZlib
|
||||
) override
|
||||
{ _nes.deserializeDifferentialState(inputData, inputDataPos, inputDataMaxSize, referenceData, referenceDataPos, referenceDataMaxSize, useZlib); }
|
||||
|
||||
size_t getDifferentialStateSize() const override
|
||||
{ return _nes.getDifferentialStateSize(); }
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "argparse/argparse.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "sha1/sha1.hpp"
|
||||
#include "utils.hpp"
|
||||
#include <jaffarCommon/extern/argparse/argparse.hpp>
|
||||
#include <jaffarCommon/include/json.hpp>
|
||||
#include <jaffarCommon/include/hash.hpp>
|
||||
#include <jaffarCommon/include/string.hpp>
|
||||
#include <jaffarCommon/include/file.hpp>
|
||||
#include "nesInstance.hpp"
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
|
@ -46,7 +47,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Loading script file
|
||||
std::string scriptJsonRaw;
|
||||
if (loadStringFromFile(scriptJsonRaw, scriptFilePath) == false) EXIT_WITH_ERROR("Could not find/read script file: %s\n", scriptFilePath.c_str());
|
||||
if (jaffarCommon::loadStringFromFile(scriptJsonRaw, scriptFilePath) == false) EXIT_WITH_ERROR("Could not find/read script file: %s\n", scriptFilePath.c_str());
|
||||
|
||||
// Parsing script
|
||||
const auto scriptJson = nlohmann::json::parse(scriptJsonRaw);
|
||||
|
@ -119,7 +120,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Loading ROM File
|
||||
std::string romFileData;
|
||||
if (loadStringFromFile(romFileData, romFilePath) == false) EXIT_WITH_ERROR("Could not rom file: %s\n", romFilePath.c_str());
|
||||
if (jaffarCommon::loadStringFromFile(romFileData, romFilePath) == false) EXIT_WITH_ERROR("Could not rom file: %s\n", romFilePath.c_str());
|
||||
e.loadROM((uint8_t*)romFileData.data(), romFileData.size());
|
||||
|
||||
// Calculating ROM SHA1
|
||||
|
@ -129,7 +130,7 @@ int main(int argc, char *argv[])
|
|||
if (initialStateFilePath != "")
|
||||
{
|
||||
std::string stateFileData;
|
||||
if (loadStringFromFile(stateFileData, initialStateFilePath) == false) EXIT_WITH_ERROR("Could not initial state file: %s\n", initialStateFilePath.c_str());
|
||||
if (jaffarCommon::loadStringFromFile(stateFileData, initialStateFilePath) == false) EXIT_WITH_ERROR("Could not initial state file: %s\n", initialStateFilePath.c_str());
|
||||
e.deserializeState((uint8_t*)stateFileData.data());
|
||||
}
|
||||
|
||||
|
@ -151,10 +152,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Loading sequence file
|
||||
std::string sequenceRaw;
|
||||
if (loadStringFromFile(sequenceRaw, sequenceFilePath) == false) EXIT_WITH_ERROR("[ERROR] Could not find or read from input sequence file: %s\n", sequenceFilePath.c_str());
|
||||
if (jaffarCommon::loadStringFromFile(sequenceRaw, sequenceFilePath) == false) EXIT_WITH_ERROR("[ERROR] Could not find or read from input sequence file: %s\n", sequenceFilePath.c_str());
|
||||
|
||||
// Building sequence information
|
||||
const auto sequence = split(sequenceRaw, ' ');
|
||||
const auto sequence = jaffarCommon::split(sequenceRaw, ' ');
|
||||
|
||||
// Getting sequence lenght
|
||||
const auto sequenceLength = sequence.size();
|
||||
|
@ -172,7 +173,7 @@ int main(int argc, char *argv[])
|
|||
printf("[] ROM Hash: 'SHA1: %s'\n", romSHA1.c_str());
|
||||
printf("[] Sequence File: '%s'\n", sequenceFilePath.c_str());
|
||||
printf("[] Sequence Length: %lu\n", sequenceLength);
|
||||
printf("[] State Size: %lu bytes - Disabled Blocks: [ %s ]\n", e.getStateSize(), stateDisabledBlocksOutput.c_str());
|
||||
printf("[] State Size: %lu bytes - Disabled Blocks: [ %s ]\n", stateSize, stateDisabledBlocksOutput.c_str());
|
||||
printf("[] Use Differential Compression: %s\n", differentialCompressionEnabled ? "true" : "false");
|
||||
if (differentialCompressionEnabled == true)
|
||||
{
|
||||
|
@ -197,7 +198,7 @@ int main(int argc, char *argv[])
|
|||
differentialStateData = (uint8_t *)malloc(fullDifferentialStateSize);
|
||||
size_t differentialDataPos = 0;
|
||||
size_t referenceDataPos = 0;
|
||||
e.serializeDifferentialState(differentialStateData, &differentialDataPos, currentState, &referenceDataPos, fullDifferentialStateSize, differentialCompressionUseZlib);
|
||||
e.serializeDifferentialState(differentialStateData, &differentialDataPos, fullDifferentialStateSize, currentState, &referenceDataPos, stateSize, differentialCompressionUseZlib);
|
||||
differentialStateMaxSizeDetected = differentialDataPos;
|
||||
}
|
||||
|
||||
|
@ -218,7 +219,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
size_t differentialDataPos = 0;
|
||||
size_t referenceDataPos = 0;
|
||||
e.deserializeDifferentialState(differentialStateData, &differentialDataPos, currentState, &referenceDataPos, differentialCompressionUseZlib);
|
||||
e.deserializeDifferentialState(differentialStateData, &differentialDataPos, fullDifferentialStateSize, currentState, &referenceDataPos, stateSize, differentialCompressionUseZlib);
|
||||
}
|
||||
|
||||
if (differentialCompressionEnabled == false) e.deserializeState(currentState);
|
||||
|
@ -232,7 +233,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
size_t differentialDataPos = 0;
|
||||
size_t referenceDataPos = 0;
|
||||
e.serializeDifferentialState(differentialStateData, &differentialDataPos, currentState, &referenceDataPos, fullDifferentialStateSize, differentialCompressionUseZlib);
|
||||
e.serializeDifferentialState(differentialStateData, &differentialDataPos, fullDifferentialStateSize, currentState, &referenceDataPos, stateSize, differentialCompressionUseZlib);
|
||||
differentialStateMaxSizeDetected = std::max(differentialStateMaxSizeDetected, differentialDataPos);
|
||||
}
|
||||
|
||||
|
@ -246,7 +247,7 @@ int main(int argc, char *argv[])
|
|||
double elapsedTimeSeconds = (double)dt * 1.0e-9;
|
||||
|
||||
// Calculating final state hash
|
||||
auto result = calculateStateHash(&e);
|
||||
auto result = jaffarCommon::calculateMetroHash(e.getLowMem(), e.getLowMemSize());
|
||||
|
||||
// Creating hash string
|
||||
char hashStringBuffer[256];
|
||||
|
@ -261,7 +262,7 @@ int main(int argc, char *argv[])
|
|||
printf("[] Differential State Max Size Detected: %lu\n", differentialStateMaxSizeDetected);
|
||||
}
|
||||
// If saving hash, do it now
|
||||
if (hashOutputFile != "") saveStringToFile(std::string(hashStringBuffer), hashOutputFile.c_str());
|
||||
if (hashOutputFile != "") jaffarCommon::saveStringToFile(std::string(hashStringBuffer), hashOutputFile.c_str());
|
||||
|
||||
// If reached this point, everything ran ok
|
||||
return 0;
|
||||
|
|
173
source/utils.hpp
173
source/utils.hpp
|
@ -1,173 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include <stdexcept>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include <metrohash128/metrohash128.h>
|
||||
#include "nesInstance.hpp"
|
||||
|
||||
// If we use NCurses, define the following useful functions
|
||||
#ifdef NCURSES
|
||||
|
||||
#include <ncurses.h>
|
||||
|
||||
// Function to check for keypress taken from https://github.com/ajpaulson/learning-ncurses/blob/master/kbhit.c
|
||||
inline int kbhit()
|
||||
{
|
||||
int ch, r;
|
||||
|
||||
// turn off getch() blocking and echo
|
||||
nodelay(stdscr, TRUE);
|
||||
noecho();
|
||||
|
||||
// check for input
|
||||
ch = getch();
|
||||
if (ch == ERR) // no input
|
||||
r = FALSE;
|
||||
else // input
|
||||
{
|
||||
r = TRUE;
|
||||
ungetch(ch);
|
||||
}
|
||||
|
||||
// restore block and echo
|
||||
echo();
|
||||
nodelay(stdscr, FALSE);
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
inline int getKeyPress()
|
||||
{
|
||||
while (!kbhit())
|
||||
{
|
||||
usleep(100000ul);
|
||||
refresh();
|
||||
}
|
||||
return getch();
|
||||
}
|
||||
|
||||
inline void initializeTerminal()
|
||||
{
|
||||
// Initializing ncurses screen
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
nodelay(stdscr, TRUE);
|
||||
scrollok(stdscr, TRUE);
|
||||
}
|
||||
|
||||
inline void clearTerminal()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
inline void finalizeTerminal()
|
||||
{
|
||||
endwin();
|
||||
}
|
||||
|
||||
inline void refreshTerminal()
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
|
||||
#endif // NCURSES
|
||||
|
||||
// Function to split a string into a sub-strings delimited by a character
|
||||
// Taken from stack overflow answer to https://stackoverflow.com/questions/236129/how-do-i-iterate-over-the-words-of-a-string
|
||||
// By Evan Teran
|
||||
|
||||
template <typename Out>
|
||||
inline void split(const std::string &s, char delim, Out result)
|
||||
{
|
||||
std::istringstream iss(s);
|
||||
std::string item;
|
||||
while (std::getline(iss, item, delim))
|
||||
{
|
||||
*result++ = item;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::vector<std::string> split(const std::string &s, char delim)
|
||||
{
|
||||
std::string newString = s;
|
||||
std::replace(newString.begin(), newString.end(), '\n', ' ');
|
||||
std::vector<std::string> elems;
|
||||
split(newString, delim, std::back_inserter(elems));
|
||||
return elems;
|
||||
}
|
||||
|
||||
// Taken from https://stackoverflow.com/questions/116038/how-do-i-read-an-entire-file-into-a-stdstring-in-c/116220#116220
|
||||
inline std::string slurp(std::ifstream &in)
|
||||
{
|
||||
std::ostringstream sstr;
|
||||
sstr << in.rdbuf();
|
||||
return sstr.str();
|
||||
}
|
||||
|
||||
// Loads a string from a given file
|
||||
inline bool loadStringFromFile(std::string &dst, const std::string path)
|
||||
{
|
||||
std::ifstream fi(path);
|
||||
|
||||
// If file not found or open, return false
|
||||
if (fi.good() == false) return false;
|
||||
|
||||
// Reading entire file
|
||||
dst = slurp(fi);
|
||||
|
||||
// Closing file
|
||||
fi.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Save string to a file
|
||||
inline bool saveStringToFile(const std::string &src, const char *fileName)
|
||||
{
|
||||
FILE *fid = fopen(fileName, "w");
|
||||
if (fid != NULL)
|
||||
{
|
||||
fwrite(src.c_str(), 1, src.size(), fid);
|
||||
fclose(fid);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Function to split a vector into n mostly fair chunks
|
||||
template <typename T>
|
||||
inline std::vector<T> splitVector(const T size, const T n)
|
||||
{
|
||||
std::vector<T> subSizes(n);
|
||||
|
||||
T length = size / n;
|
||||
T remain = size % n;
|
||||
|
||||
for (T i = 0; i < n; i++)
|
||||
subSizes[i] = i < remain ? length + 1 : length;
|
||||
|
||||
return subSizes;
|
||||
}
|
||||
|
||||
typedef _uint128_t hash_t;
|
||||
|
||||
inline hash_t calculateMetroHash(uint8_t *data, size_t size)
|
||||
{
|
||||
MetroHash128 hash;
|
||||
hash.Update(data, size);
|
||||
hash_t result;
|
||||
hash.Finalize(reinterpret_cast<uint8_t *>(&result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline hash_t calculateStateHash(NESInstance* nes)
|
||||
{
|
||||
return calculateMetroHash(nes->getLowMem(), nes->getLowMemSize());
|
||||
}
|
Loading…
Reference in New Issue