ARB
Classes | Macros | Functions | Variables
admap.cxx File Reference
#include "gb_key.h"
#include "gb_map.h"
#include "gb_index.h"
#include <arb_file.h>
Include dependency graph for admap.cxx:

Go to the source code of this file.

Classes

struct  gbdata_offset
 
struct  gbdByKey
 

Macros

#define ADMAP_BYTE_ORDER   0x01020304
 
#define GB_MAX_MAPPED_FILES   10
 
#define ALIGN_BITS   2
 
#define ALIGN(size)   (((((size)-1)>>ALIGN_BITS)+1)<<ALIGN_BITS)
 
#define PTR_DIFF(p1, p2)   ((char*)(p1)-(char*)(p2))
 
#define cmp(h1, h2)   ((long)(h1).gbd - (long)(h2).gbd)
 
#define swap(h1, h2)
 

Functions

long MAKEREL (long rel_to, long offset)
 
static void downheap (gbdata_offset *heap, int idx, int num)
 
static void sort_gbdata_offsets (gbdata_offset *gbdo, int num)
 
static gbdata_offsetfind_gbdata_offset (GBQUARK quark, GBDATA *gbd)
 
static long getrel_GBDATA (long rel_to, GBDATA *gbd)
 
static void ftwrite_aligned (const void *ptr, size_t ali_siz, FILE *fil)
 
static size_t ftwrite_unaligned (const void *ptr, size_t unali_siz, FILE *fil)
 
static long write_IE (gb_if_entries *ie, FILE *out, long *offset)
 
static long write_IFS (gb_index_files *ifs, FILE *out, long *offset)
 
static void convertFlags4Save (gb_flag_types *flags, gb_flag_types2 *flags2, gb_flag_types3 *)
 
static long write_GBDATA (GB_MAIN_TYPE *, GBDATA *gbd, GBQUARK quark, FILE *out, long *offset, GB_MAIN_IDX main_idx)
 
static long writeGbdByKey (GB_MAIN_TYPE *Main, gbdByKey *gbk, FILE *out, GB_MAIN_IDX main_idx)
 
static long calcGbdOffsets (GB_MAIN_TYPE *Main, gbdByKey *gbk)
 
static void scanGbdByKey (GB_MAIN_TYPE *Main, GBDATA *gbd, gbdByKey *gbk)
 
static gbdByKeycreateGbdByKey (GB_MAIN_TYPE *Main)
 
static void freeGbdByKey (GB_MAIN_TYPE *Main, gbdByKey *gbk)
 
GB_ERROR gb_save_mapfile (GB_MAIN_TYPE *Main, GB_CSTR path)
 
bool GB_supports_mapfile ()
 
int gb_is_valid_mapfile (const char *path, gb_map_header *mheader, int verbose)
 
GBDATAgb_map_mapfile (const char *path)
 
int gb_isMappedMemory (void *mem)
 

Variables

static gbdByKeygb_gbk = NULp
 
static bool writeError
 
static char alignment_bytes [ALIGN(1)] = { 0 }
 
static charfileMappedTo [GB_MAX_MAPPED_FILES]
 
static long fileLen [GB_MAX_MAPPED_FILES]
 
static int mappedFiles = 0
 

Macro Definition Documentation

#define ADMAP_BYTE_ORDER   0x01020304

Definition at line 16 of file admap.cxx.

Referenced by gb_is_valid_mapfile(), and gb_save_mapfile().

#define GB_MAX_MAPPED_FILES   10

Definition at line 17 of file admap.cxx.

Referenced by gb_map_mapfile().

#define ALIGN_BITS   2

Definition at line 22 of file admap.cxx.

#define ALIGN (   size)    (((((size)-1)>>ALIGN_BITS)+1)<<ALIGN_BITS)
#define PTR_DIFF (   p1,
  p2 
)    ((char*)(p1)-(char*)(p2))

Definition at line 26 of file admap.cxx.

Referenced by write_GBDATA().

#define cmp (   h1,
  h2 
)    ((long)(h1).gbd - (long)(h2).gbd)
#define swap (   h1,
  h2 
)
Value:
do { \
gbdata_offset xxx = (h1); \
(h1) = (h2); \
(h2) = xxx; \
} while (0)

Definition at line 52 of file admap.cxx.

Referenced by downheap().

Function Documentation

long MAKEREL ( long  rel_to,
long  offset 
)
inline

Definition at line 42 of file admap.cxx.

References gb_assert.

Referenced by getrel_GBDATA(), write_GBDATA(), and write_IFS().

static void downheap ( gbdata_offset heap,
int  idx,
int  num 
)
static

Definition at line 59 of file admap.cxx.

References cmp, gb_assert, and swap.

Referenced by sort_gbdata_offsets().

static void sort_gbdata_offsets ( gbdata_offset gbdo,
int  num 
)
static

Definition at line 87 of file admap.cxx.

References cmp, downheap(), and gb_assert.

Referenced by createGbdByKey().

static gbdata_offset* find_gbdata_offset ( GBQUARK  quark,
GBDATA gbd 
)
static

Definition at line 116 of file admap.cxx.

References gbdByKey::cnt, gb_assert, gbdata_offset::gbd, gbdByKey::gbdoff, long, and NULp.

Referenced by write_GBDATA().

static long getrel_GBDATA ( long  rel_to,
GBDATA gbd 
)
static
static void ftwrite_aligned ( const void *  ptr,
size_t  ali_siz,
FILE *  fil 
)
static

Definition at line 192 of file admap.cxx.

References ALIGN, gb_assert, and writeError.

Referenced by write_GBDATA(), and write_IFS().

static size_t ftwrite_unaligned ( const void *  ptr,
size_t  unali_siz,
FILE *  fil 
)
static

Definition at line 201 of file admap.cxx.

References ALIGN, and writeError.

Referenced by gb_save_mapfile(), write_GBDATA(), write_IE(), and write_IFS().

static long write_IE ( gb_if_entries ie,
FILE *  out,
long offset 
)
static
static long write_IFS ( gb_index_files ifs,
FILE *  out,
long offset 
)
static
static void convertFlags4Save ( gb_flag_types flags,
gb_flag_types2 flags2,
gb_flag_types3  
)
static
static long write_GBDATA ( GB_MAIN_TYPE ,
GBDATA gbd,
GBQUARK  quark,
FILE *  out,
long offset,
GB_MAIN_IDX  main_idx 
)
static
static long writeGbdByKey ( GB_MAIN_TYPE Main,
gbdByKey gbk,
FILE *  out,
GB_MAIN_IDX  main_idx 
)
static

Definition at line 492 of file admap.cxx.

References ALIGN, gbdByKey::cnt, gb_assert, IF_ASSERTION_USED, GB_MAIN_TYPE::keycnt, offset, and write_GBDATA().

Referenced by gb_save_mapfile().

static long calcGbdOffsets ( GB_MAIN_TYPE Main,
gbdByKey gbk 
)
static
static void scanGbdByKey ( GB_MAIN_TYPE Main,
GBDATA gbd,
gbdByKey gbk 
)
static
static gbdByKey* createGbdByKey ( GB_MAIN_TYPE Main)
static
static void freeGbdByKey ( GB_MAIN_TYPE Main,
gbdByKey gbk 
)
static

Definition at line 576 of file admap.cxx.

References GB_MAIN_TYPE::keycnt.

Referenced by gb_save_mapfile().

GB_ERROR gb_save_mapfile ( GB_MAIN_TYPE Main,
GB_CSTR  path 
)
bool GB_supports_mapfile ( void  )

Definition at line 644 of file admap.cxx.

Referenced by pd_export_pt_server(), and run_command().

int gb_is_valid_mapfile ( const char path,
gb_map_header mheader,
int  verbose 
)
GBDATA* gb_map_mapfile ( const char path)
int gb_isMappedMemory ( void *  mem)

Definition at line 725 of file admap.cxx.

References fileLen.

Referenced by gbmFreeMemImpl().

Variable Documentation

gbdByKey* gb_gbk = NULp
static

Definition at line 39 of file admap.cxx.

bool writeError
static

Definition at line 190 of file admap.cxx.

Referenced by ftwrite_aligned(), ftwrite_unaligned(), and gb_save_mapfile().

char alignment_bytes[ALIGN(1)] = { 0 }
static

Definition at line 199 of file admap.cxx.

char* fileMappedTo[GB_MAX_MAPPED_FILES]
static

Definition at line 702 of file admap.cxx.

long fileLen[GB_MAX_MAPPED_FILES]
static

Definition at line 703 of file admap.cxx.

Referenced by gb_isMappedMemory(), and gb_map_mapfile().

int mappedFiles = 0
static

Definition at line 704 of file admap.cxx.

Referenced by gb_map_mapfile().