Linux build fixes
This was SVN commit r3427.
This commit is contained in:
parent
afe37d9fe2
commit
3b4295a177
@ -225,7 +225,7 @@ public:
|
||||
void add(Key key, T item, size_t size, uint cost)
|
||||
{
|
||||
typedef std::pair<CacheMapIt, bool> PairIB;
|
||||
CacheMap::value_type val = std::make_pair(key, CacheEntry(item, size, cost));
|
||||
typename CacheMap::value_type val = std::make_pair(key, CacheEntry(item, size, cost));
|
||||
PairIB ret = map.insert(val);
|
||||
debug_assert(ret.second); // must not already be in map
|
||||
}
|
||||
@ -341,7 +341,7 @@ template<class T, size_t n> class RingBuf
|
||||
{
|
||||
size_t size_; // # of entries in buffer
|
||||
size_t head; // index of first item
|
||||
size_t tail; // index of last item
|
||||
size_t tail; // index of last item
|
||||
T data[n];
|
||||
|
||||
public:
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <deque>
|
||||
|
||||
#include "lib/res/mem.h"
|
||||
#include "lib/allocators.h"
|
||||
#include "lib/timer.h"
|
||||
@ -399,11 +401,11 @@ uintptr_t comp_alloc(ContextType type, CompressionMethod method)
|
||||
c = new(c_mem) ZLibCompressor(type);
|
||||
break;
|
||||
#endif
|
||||
#include "mmgr.h"
|
||||
default:
|
||||
debug_warn("unknown compression type");
|
||||
compressor_allocator.free(c_mem);
|
||||
return 0;
|
||||
#include "mmgr.h"
|
||||
}
|
||||
|
||||
c->init();
|
||||
@ -459,5 +461,7 @@ void comp_free(uintptr_t c_)
|
||||
c->release();
|
||||
|
||||
c->~Compressor();
|
||||
#include "nommgr.h"
|
||||
compressor_allocator.free(c);
|
||||
#include "mmgr.h"
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ LibError file_make_full_portable_path(const char* n_full_path, char* path)
|
||||
// establish the root directory from <rel_path>, which is treated as
|
||||
// relative to the executable's directory (determined via argv[0]).
|
||||
// all relative file paths passed to this module will be based from
|
||||
// this root dir.
|
||||
// this root dir.
|
||||
//
|
||||
// example: executable in "$install_dir/system"; desired root dir is
|
||||
// "$install_dir/data" => rel_path = "../data".
|
||||
@ -776,8 +776,7 @@ LibError file_map(File* f, void*& p, size_t& size)
|
||||
return ERR_FAIL;
|
||||
|
||||
errno = 0;
|
||||
void* start = 0; // system picks start address
|
||||
f->mapping = mmap(start, f->fc.size, prot, MAP_PRIVATE, f->fd, (off_t)0);
|
||||
f->mapping = mmap(0, f->fc.size, prot, MAP_PRIVATE, f->fd, (off_t)0);
|
||||
if(f->mapping == MAP_FAILED)
|
||||
return LibError_from_errno();
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "lib/adts.h"
|
||||
#include "file_internal.h"
|
||||
|
||||
// strategy:
|
||||
// strategy:
|
||||
// policy:
|
||||
// - allocation: use all available mem first, then look at freelist
|
||||
// - freelist: good fit, address-ordered, always split
|
||||
@ -345,8 +345,10 @@ FileIOBuf file_buf_alloc(size_t size, const char* atom_fn)
|
||||
|
||||
size_t size;
|
||||
FileIOBuf discarded_buf = file_cache.remove_least_valuable(&size);
|
||||
#include "nommgr.h"
|
||||
if(discarded_buf)
|
||||
cache_allocator.free((u8*)discarded_buf, size);
|
||||
#include "mmgr.h"
|
||||
|
||||
if(attempts++ > 50)
|
||||
debug_warn("possible infinite loop: failed to make room in cache");
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <deque>
|
||||
|
||||
#include "lib.h"
|
||||
#include "lib/posix.h"
|
||||
#include "lib/allocators.h"
|
||||
@ -359,6 +361,7 @@ class IOManager
|
||||
{
|
||||
const off_t ofs = start_ofs+(off_t)total_issued;
|
||||
size_t issue_size;
|
||||
|
||||
// write: must not issue beyond end of data.
|
||||
if(is_write)
|
||||
issue_size = MIN(FILE_BLOCK_SIZE, size - total_issued);
|
||||
@ -371,23 +374,22 @@ class IOManager
|
||||
// check if in cache
|
||||
slot.block_id = block_cache_make_id(f->fc.atom_fn, ofs);
|
||||
slot.cached_block = block_cache_find(slot.block_id);
|
||||
if(slot.cached_block)
|
||||
goto skip_issue;
|
||||
if(!slot.cached_block)
|
||||
{
|
||||
void* buf;
|
||||
|
||||
// if using buffer, set position in it; otherwise, use temp buffer
|
||||
void* buf;
|
||||
if(pbuf == FILE_BUF_TEMP)
|
||||
buf = slot.temp_buf = block_cache_alloc(slot.block_id);
|
||||
else
|
||||
buf = (char*)*pbuf + total_issued;
|
||||
// if using buffer, set position in it; otherwise, use temp buffer
|
||||
if(pbuf == FILE_BUF_TEMP)
|
||||
buf = slot.temp_buf = block_cache_alloc(slot.block_id);
|
||||
else
|
||||
buf = (char*)*pbuf + total_issued;
|
||||
|
||||
LibError ret = file_io_issue(f, ofs, issue_size, buf, &slot.io);
|
||||
// transfer failed - loop will now terminate after
|
||||
// waiting for all pending transfers to complete.
|
||||
if(ret != ERR_OK)
|
||||
err = ret;
|
||||
|
||||
skip_issue:
|
||||
LibError ret = file_io_issue(f, ofs, issue_size, buf, &slot.io);
|
||||
// transfer failed - loop will now terminate after
|
||||
// waiting for all pending transfers to complete.
|
||||
if(ret != ERR_OK)
|
||||
err = ret;
|
||||
}
|
||||
|
||||
total_issued += issue_size;
|
||||
}
|
||||
@ -474,7 +476,7 @@ again:
|
||||
}
|
||||
// (all issued OR error) AND no pending transfers - done.
|
||||
|
||||
debug_assert(total_issued >= total_transferred && total_transferred >= user_size);
|
||||
debug_assert(total_issued >= total_transferred && total_transferred >= user_size);
|
||||
return (ssize_t)total_processed;
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
extern void file_io_shutdown();
|
||||
extern void file_io_shutdown();
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
@ -462,7 +462,7 @@ LibError vfs_load(const char* V_fn, FileIOBuf& buf, size_t& size, uint flags /*
|
||||
// only now can we report misses, since we need to know the size for
|
||||
// statistics purposes. that means vfs_load on nonexistant files will
|
||||
// not show up in cache misses, which is fine.
|
||||
stats_cache(CR_MISS, size, atom_fn);
|
||||
stats_cache(CR_MISS, size, atom_fn);
|
||||
|
||||
buf = FILE_BUF_ALLOC;
|
||||
ssize_t nread = vfs_io(hf, size, &buf);
|
||||
@ -736,7 +736,7 @@ LibError vfs_reload_changed_files()
|
||||
|
||||
// path has already been written to pending_reloads,
|
||||
// so just mark it valid.
|
||||
num_pending++;
|
||||
num_pending++;
|
||||
}
|
||||
|
||||
// rebuild VFS, in case a file that has been changed is currently
|
||||
@ -757,7 +757,7 @@ LibError vfs_reload_changed_files()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
inline void vfs_display()
|
||||
void vfs_display()
|
||||
{
|
||||
tree_display();
|
||||
}
|
||||
|
@ -240,4 +240,4 @@ document: zlib layer is ok to allocate. caller shouldnt do so from a pool:
|
||||
|
||||
zip_archive_finish(&za);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user