Bug 848270 - Various fixups for Android builds on OSX after
bug 847479. r=nfroyd
--- a/mozglue/linker/SeekableZStream.h
+++ b/mozglue/linker/SeekableZStream.h
@@ -44,22 +44,16 @@ struct SeekableZStreamHeader: public Zip
/* Size of last chunk (> 0, <= Chunk size) */
le_uint16 lastChunkSize;
/* windowBits value used when deflating */
signed char windowBits;
/* 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()
MOZ_STATIC_ASSERT(sizeof(SeekableZStreamHeader) == 5 * 4,
"SeekableZStreamHeader should be 5 32-bits words");
/**
* Helper class used to decompress Seekable ZStreams.
--- a/mozglue/linker/szip.cpp
+++ b/mozglue/linker/szip.cpp
@@ -11,23 +11,28 @@
#include <fcntl.h>
#include <errno.h>
#include "mozilla/Assertions.h"
#include "mozilla/Scoped.h"
#include "SeekableZStream.h"
#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)
memcpy(buf, *this, std::min(size, GetLength()));
Assign(buf, size);
return true;
}
};
@@ -329,18 +334,17 @@ int main(int argc, char* argv[])
if (strcmp(firstArg[0], "-d") == 0) {
compress = false;
} else if (strcmp(firstArg[0], "-c") == 0) {
firstArg++;
argc--;
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;
}
} else if (strcmp(firstArg[0], "-f") == 0) {
firstArg++;
argc--;
if (!firstArg[0])
break;