Bug 848270 - Various fixups for Android builds on OSX after bug 847479. r=nfroyd

This commit is contained in:
Mike Hommey 2013-03-06 17:01:56 +01:00
parent 9798c87e1e
commit 51a7a6e6e7
2 changed files with 7 additions and 9 deletions

View File

@ -49,12 +49,6 @@ struct SeekableZStreamHeader: public Zip::SignedEntity<SeekableZStreamHeader>
/* Filter Id */
unsigned char filter;
/* Maximum supported size for chunkSize */
/* Can't use std::min here because it's not constexpr */
static const size_t maxChunkSize =
1 << ((sizeof(chunkSize) < sizeof(lastChunkSize) ?
sizeof(chunkSize) : sizeof(lastChunkSize)) - 1);
};
#pragma pack()

View File

@ -16,13 +16,18 @@
#include "Utils.h"
#include "Logging.h"
/* Maximum supported size for chunkSize */
static const size_t maxChunkSize =
1 << (8 * std::min(sizeof(((SeekableZStreamHeader *)NULL)->chunkSize),
sizeof(((SeekableZStreamHeader *)NULL)->lastChunkSize)) - 1);
class Buffer: public MappedPtr
{
public:
virtual bool Resize(size_t size)
{
void *buf = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
MAP_PRIVATE | MAP_ANON, -1, 0);
if (buf == MAP_FAILED)
return false;
if (*this != MAP_FAILED)
@ -334,8 +339,7 @@ int main(int argc, char* argv[])
if (!firstArg[0])
break;
if (!GetSize(firstArg[0], &chunkSize) || !chunkSize ||
(chunkSize % 4096) ||
(chunkSize > SeekableZStreamHeader::maxChunkSize)) {
(chunkSize % 4096) || (chunkSize > maxChunkSize)) {
log("Invalid chunk size");
return 1;
}