55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
#ifndef __GLOBMEM__
|
|
#define __GLOBMEM__
|
|
|
|
#ifndef _WIN32
|
|
#include <sys/mman.h>
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#else
|
|
#include <windows.h>
|
|
#include <stdio.h>
|
|
#include <tchar.h>
|
|
#endif
|
|
|
|
#include <assert.h>
|
|
#include <string>
|
|
#include <map>
|
|
|
|
#include "glob/SingletonTemplate.h"
|
|
#include "glob/HSConfig.h"
|
|
#include "glob/ConfigMag.h"
|
|
|
|
using namespace std;
|
|
|
|
class GlobMem : public SingletonTemplate<GlobMem>
|
|
{
|
|
friend class SingletonTemplate<GlobMem>;
|
|
|
|
protected:
|
|
GlobMem();
|
|
virtual ~GlobMem();
|
|
|
|
private:
|
|
// static map<std::string, void*> tablemap;
|
|
// static map<std::string, void*> blockmap;
|
|
map<std::string, void *> m_tablemap;
|
|
map<std::string, void *> m_blockmap;
|
|
void *globmmap_ix_g;
|
|
size_t globmmap_size;
|
|
|
|
public:
|
|
void *GetTablePtr(const string &);
|
|
|
|
private:
|
|
size_t OpenMap(int *fd, const string &path, size_t size);
|
|
size_t ResizeMap(int *fd, size_t size);
|
|
void *CreateMmap(int fd, size_t size);
|
|
void *OpenMap(const string &path, const string &mapname, size_t size);
|
|
};
|
|
|
|
#endif
|