summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc46
-rw-r--r--native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h9
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_handle.cc6
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_handle.h2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/node.cc2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/node.h2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/osinttypes.h3
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc2
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc4
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc2
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc6
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mock_node.h2
17 files changed, 51 insertions, 47 deletions
diff --git a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc
index d251d91..5eaf8e1 100644
--- a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.cc
@@ -257,7 +257,7 @@ Error FuseFsNode::Tcsetattr(int optional_actions,
return ENOSYS;
}
-Error FuseFsNode::GetSize(size_t* out_size) {
+Error FuseFsNode::GetSize(off_t* out_size) {
struct stat statbuf;
Error error = GetStat(&statbuf);
if (error)
diff --git a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h
index 707fcae..2c41e3f 100644
--- a/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h
+++ b/native_client_sdk/src/libraries/nacl_io/fusefs/fuse_fs.h
@@ -53,7 +53,7 @@ class FuseFsNode : public Node {
virtual Error Tcgetattr(struct termios* termios_p);
virtual Error Tcsetattr(int optional_actions,
const struct termios* termios_p);
- virtual Error GetSize(size_t* out_size);
+ virtual Error GetSize(off_t* out_size);
protected:
struct fuse_operations* fuse_ops_;
diff --git a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
index 31a1d3c..1f0e843 100644
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
@@ -229,7 +229,7 @@ Error Html5FsNode::Write(const HandleAttr& attr,
int Html5FsNode::GetType() { return fileio_resource_ ? S_IFREG : S_IFDIR; }
-Error Html5FsNode::GetSize(size_t* out_size) {
+Error Html5FsNode::GetSize(off_t* out_size) {
*out_size = 0;
if (IsaDir())
@@ -243,7 +243,7 @@ Error Html5FsNode::GetSize(size_t* out_size) {
if (result != PP_OK)
return PPErrorToErrno(result);
- *out_size = static_cast<size_t>(info.size);
+ *out_size = info.size;
return 0;
}
diff --git a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h
index 7339aac..f6555f9 100644
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.h
@@ -34,7 +34,7 @@ class Html5FsNode : public Node {
int* out_bytes);
virtual int GetType();
- virtual Error GetSize(size_t* out_size);
+ virtual Error GetSize(off_t* out_size);
virtual bool IsaDir();
virtual bool IsaFile();
diff --git a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc
index f5f8089..ee5e5f3 100644
--- a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc
@@ -390,7 +390,7 @@ Error HttpFs::LoadManifest(const std::string& manifest_name,
if (error)
return error;
- size_t size;
+ off_t size;
error = manifest_node->GetSize(&size);
if (error)
return error;
diff --git a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc
index b02c0af..6a4815b 100644
--- a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc
@@ -83,30 +83,30 @@ StringMap_t ParseHeaders(const char* headers, int32_t headers_length) {
return result;
}
-bool ParseContentLength(const StringMap_t& headers, size_t* content_length) {
+bool ParseContentLength(const StringMap_t& headers, off_t* content_length) {
StringMap_t::const_iterator iter = headers.find("Content-Length");
if (iter == headers.end())
return false;
- *content_length = strtoul(iter->second.c_str(), NULL, 10);
+ *content_length = strtoull(iter->second.c_str(), NULL, 10);
return true;
}
bool ParseContentRange(const StringMap_t& headers,
- size_t* read_start,
- size_t* read_end,
- size_t* entity_length) {
+ off_t* read_start,
+ off_t* read_end,
+ off_t* entity_length) {
StringMap_t::const_iterator iter = headers.find("Content-Range");
if (iter == headers.end())
return false;
// The key should look like "bytes ##-##/##" or "bytes ##-##/*". The last
// value is the entity length, which can potentially be * (i.e. unknown).
- size_t read_start_int;
- size_t read_end_int;
- size_t entity_length_int;
+ off_t read_start_int;
+ off_t read_end_int;
+ off_t entity_length_int;
int result = sscanf(iter->second.c_str(),
- "bytes %" SCNuS "-%" SCNuS "/%" SCNuS,
+ "bytes %" SCNi64 "-%" SCNi64 "/%" SCNi64,
&read_start_int,
&read_end_int,
&entity_length_int);
@@ -198,7 +198,7 @@ Error HttpFsNode::Write(const HandleAttr& attr,
return EACCES;
}
-Error HttpFsNode::GetSize(size_t* out_size) {
+Error HttpFsNode::GetSize(off_t* out_size) {
*out_size = 0;
// TODO(binji): This value should be cached properly; i.e. obey the caching
@@ -244,7 +244,7 @@ Error HttpFsNode::GetStat_Locked(struct stat* stat) {
if (error)
return error;
- size_t entity_length;
+ off_t entity_length;
if (ParseContentLength(response_headers, &entity_length)) {
SetCachedSize(static_cast<off_t>(entity_length));
} else if (cache_content_) {
@@ -258,7 +258,7 @@ Error HttpFsNode::GetStat_Locked(struct stat* stat) {
// "Content-Length" header. Read the entire entity, and throw it away.
// Don't use DownloadToCache, as that will still allocate enough memory
// for the entire entity.
- int bytes_read;
+ off_t bytes_read;
error = DownloadToTemp(&bytes_read);
if (error)
return error;
@@ -367,7 +367,7 @@ Error HttpFsNode::DownloadToCache() {
if (error)
return error;
- size_t content_length = 0;
+ off_t content_length = 0;
if (ParseContentLength(response_headers, &content_length)) {
cached_data_.resize(content_length);
int real_size;
@@ -395,7 +395,7 @@ Error HttpFsNode::ReadPartialFromCache(const HandleAttr& attr,
int count,
int* out_bytes) {
*out_bytes = 0;
- size_t size = cached_data_.size();
+ off_t size = cached_data_.size();
if (attr.offs + count > size)
count = size - attr.offs;
@@ -410,7 +410,7 @@ Error HttpFsNode::ReadPartialFromCache(const HandleAttr& attr,
Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
void* buf,
- size_t count,
+ off_t count,
int* out_bytes) {
*out_bytes = 0;
@@ -420,7 +420,7 @@ Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
// Range request is inclusive: 0-99 returns 100 bytes.
snprintf(&buffer[0],
sizeof(buffer),
- "bytes=%" PRIuS "-%" PRIuS,
+ "bytes=%" PRIi64 "-%" PRIi64,
attr.offs,
attr.offs + count - 1);
headers["Range"] = buffer;
@@ -447,10 +447,10 @@ Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
return error;
}
- size_t read_start = 0;
+ off_t read_start = 0;
if (statuscode == STATUSCODE_OK) {
// No partial result, read everything starting from the part we care about.
- size_t content_length;
+ off_t content_length;
if (ParseContentLength(response_headers, &content_length)) {
if (attr.offs >= content_length)
return EINVAL;
@@ -462,8 +462,8 @@ Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
}
} else if (statuscode == STATUSCODE_PARTIAL_CONTENT) {
// Determine from the headers where we are reading.
- size_t read_end;
- size_t entity_length;
+ off_t read_end;
+ off_t entity_length;
if (ParseContentRange(
response_headers, &read_start, &read_end, &entity_length)) {
if (read_start > attr.offs || read_start > read_end) {
@@ -501,7 +501,7 @@ Error HttpFsNode::DownloadPartial(const HandleAttr& attr,
return ReadResponseToBuffer(loader, buf, count, out_bytes);
}
-Error HttpFsNode::DownloadToTemp(int* out_bytes) {
+Error HttpFsNode::DownloadToTemp(off_t* out_bytes) {
StringMap_t headers;
ScopedResource loader(filesystem_->ppapi());
ScopedResource request(filesystem_->ppapi());
@@ -518,7 +518,7 @@ Error HttpFsNode::DownloadToTemp(int* out_bytes) {
if (error)
return error;
- size_t content_length = 0;
+ off_t content_length = 0;
if (ParseContentLength(response_headers, &content_length)) {
*out_bytes = content_length;
return 0;
@@ -528,7 +528,7 @@ Error HttpFsNode::DownloadToTemp(int* out_bytes) {
}
Error HttpFsNode::ReadEntireResponseToTemp(const ScopedResource& loader,
- int* out_bytes) {
+ off_t* out_bytes) {
*out_bytes = 0;
const int kBytesToRead = MAX_READ_BUFFER_SIZE;
diff --git a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h
index d63ce0b..a779995 100644
--- a/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h
@@ -34,7 +34,7 @@ class HttpFsNode : public Node {
const void* buf,
size_t count,
int* out_bytes);
- virtual Error GetSize(size_t* out_size);
+ virtual Error GetSize(off_t* out_size);
void SetCachedSize(off_t size);
void SetMode(int mode);
@@ -61,13 +61,14 @@ class HttpFsNode : public Node {
int* out_bytes);
Error DownloadPartial(const HandleAttr& attr,
void* buf,
- size_t count,
+ off_t count,
int* out_bytes);
- Error DownloadToTemp(int* out_bytes);
+ Error DownloadToTemp(off_t* out_bytes);
// Read as much as possible from |loader|, using |buffer_| as a scratch area.
- Error ReadEntireResponseToTemp(const ScopedResource& loader, int* out_bytes);
+ Error ReadEntireResponseToTemp(const ScopedResource& loader,
+ off_t* out_bytes);
// Read as much as possible from |loader|, storing the result in
// |cached_data_|.
Error ReadEntireResponseToCache(const ScopedResource& loader, int* out_bytes);
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
index 8f56e67..9ad4605 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
@@ -54,8 +54,8 @@ Error KernelHandle::Init(int open_flags) {
Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) {
// By default, don't move the offset.
*out_offset = offset;
- ssize_t base;
- size_t node_size;
+ off_t base;
+ off_t node_size;
AUTO_LOCK(handle_lock_);
Error error = node_->GetSize(&node_size);
@@ -79,7 +79,7 @@ Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) {
if (base + offset < 0)
return EINVAL;
- size_t new_offset = base + offset;
+ off_t new_offset = base + offset;
// Seeking past the end of the file will zero out the space between the old
// end and the new end.
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_handle.h b/native_client_sdk/src/libraries/nacl_io/kernel_handle.h
index 5f6fc5c..d385eb3 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_handle.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_handle.h
@@ -31,7 +31,7 @@ struct HandleAttr {
HandleAttr() : offs(0), flags(0) {}
bool IsBlocking() const { return !(flags & O_NONBLOCK); }
- size_t offs;
+ off_t offs;
int flags;
};
diff --git a/native_client_sdk/src/libraries/nacl_io/node.cc b/native_client_sdk/src/libraries/nacl_io/node.cc
index b8876ed..fc30867 100644
--- a/native_client_sdk/src/libraries/nacl_io/node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/node.cc
@@ -165,7 +165,7 @@ int Node::GetLinks() { return stat_.st_nlink; }
int Node::GetMode() { return stat_.st_mode & ~S_IFMT; }
-Error Node::GetSize(size_t* out_size) {
+Error Node::GetSize(off_t* out_size) {
*out_size = stat_.st_size;
return 0;
}
diff --git a/native_client_sdk/src/libraries/nacl_io/node.h b/native_client_sdk/src/libraries/nacl_io/node.h
index 4e4420c..70d0940 100644
--- a/native_client_sdk/src/libraries/nacl_io/node.h
+++ b/native_client_sdk/src/libraries/nacl_io/node.h
@@ -94,7 +94,7 @@ class Node : public sdk_util::RefObject {
virtual int GetType();
virtual void SetType(int type);
// Assume that |out_size| is non-NULL.
- virtual Error GetSize(size_t* out_size);
+ virtual Error GetSize(off_t* out_size);
// Returns 0 if node is a TTY
virtual Error Isatty();
diff --git a/native_client_sdk/src/libraries/nacl_io/osinttypes.h b/native_client_sdk/src/libraries/nacl_io/osinttypes.h
index 1c907a3..491922c 100644
--- a/native_client_sdk/src/libraries/nacl_io/osinttypes.h
+++ b/native_client_sdk/src/libraries/nacl_io/osinttypes.h
@@ -19,6 +19,9 @@
#else
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS 1
+#endif
#include <inttypes.h>
#if !defined(PRIuS)
diff --git a/native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc b/native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc
index 1e6ece1..bfbd172 100644
--- a/native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc
@@ -40,7 +40,7 @@ TEST(FilesystemTest, Sanity) {
ScopedNode root;
ScopedNode result_node;
- size_t result_size = 0;
+ off_t result_size = 0;
int result_bytes = 0;
char buf1[1024];
diff --git a/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
index 3acbaa8..8ea7c07 100644
--- a/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
@@ -223,7 +223,7 @@ TEST_F(Html5FsTest, OpenForCreate) {
ASSERT_EQ(0, fs->Open(path, O_CREAT, &node));
// Check that the file still has data.
- size_t size;
+ off_t size;
EXPECT_EQ(0, node->GetSize(&size));
EXPECT_EQ(strlen(contents), size);
@@ -359,7 +359,7 @@ TEST_F(Html5FsTest, GetStat) {
EXPECT_EQ(modified_time, statbuf.st_mtime);
// Test Get* and Isa* methods.
- size_t size;
+ off_t size;
EXPECT_EQ(0, node->GetSize(&size));
EXPECT_EQ(strlen(contents), size);
EXPECT_FALSE(node->IsaDir());
diff --git a/native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc
index 1168d68..6f6c51d 100644
--- a/native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/http_fs_test.cc
@@ -254,7 +254,7 @@ TEST(HttpFsDirTest, Remove) {
TEST(HttpFsDirTest, ParseManifest) {
StringMap_t args;
- size_t result_size = 0;
+ off_t result_size = 0;
HttpFsForTesting fs(args, NULL);
diff --git a/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc b/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
index d6d8c18..dc521c6 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
@@ -68,7 +68,7 @@ class DirNodeForTesting : public DirNode {
TEST(MemFsNodeTest, File) {
MemFsNodeForTesting file;
ScopedNode result_node;
- size_t result_size = 0;
+ off_t result_size = 0;
int result_bytes = 0;
EXPECT_EQ(0, file.Init(0));
@@ -120,7 +120,7 @@ TEST(MemFsNodeTest, File) {
TEST(MemFsNodeTest, FTruncate) {
MemFsNodeForTesting file;
- size_t result_size = 0;
+ off_t result_size = 0;
int result_bytes = 0;
char data[1024];
@@ -197,7 +197,7 @@ TEST(MemFsNodeTest, Directory) {
s_alloc_num = 0;
DirNodeForTesting root;
ScopedNode result_node;
- size_t result_size = 0;
+ off_t result_size = 0;
int result_bytes = 0;
root.Init(0);
diff --git a/native_client_sdk/src/tests/nacl_io_test/mock_node.h b/native_client_sdk/src/tests/nacl_io_test/mock_node.h
index 8286e3a..307ee2e 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mock_node.h
+++ b/native_client_sdk/src/tests/nacl_io_test/mock_node.h
@@ -32,7 +32,7 @@ class MockNode : public nacl_io::Node {
MOCK_METHOD0(GetLinks, int());
MOCK_METHOD0(GetMode, int());
MOCK_METHOD0(GetType, int());
- MOCK_METHOD1(GetSize, Error(size_t*));
+ MOCK_METHOD1(GetSize, Error(off_t*));
MOCK_METHOD0(IsaDir, bool());
MOCK_METHOD0(IsaFile, bool());
MOCK_METHOD0(Isatty, Error());