Miscellaneous refactoring.
Add some headers for OSX.
This commit is contained in:
parent
a6676698fa
commit
0433452b37
7 changed files with 34 additions and 11 deletions
|
@ -408,6 +408,7 @@ clean:
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) Makefile
|
$(RM) Makefile
|
||||||
(cd $(LIBBSCDIR); make clean)
|
(cd $(LIBBSCDIR); make clean)
|
||||||
|
$(RM_RF) buildtmp
|
||||||
|
|
||||||
install: $(PROG)
|
install: $(PROG)
|
||||||
@mkdir -p $(DESTDIR)$(PREFIX)/bin
|
@mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||||
|
|
2
main.c
2
main.c
|
@ -35,7 +35,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <pcompress.h>
|
#include "pcompress.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <utils.h>
|
#include <utils.h>
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ typedef struct {
|
||||||
struct seg_map_fd *seg_fd_r; // One read-only fd per thread for mapping in portions of the
|
struct seg_map_fd *seg_fd_r; // One read-only fd per thread for mapping in portions of the
|
||||||
// segment metadata cache.
|
// segment metadata cache.
|
||||||
int valid;
|
int valid;
|
||||||
void *dbdata;
|
void *db_index;
|
||||||
} archive_config_t;
|
} archive_config_t;
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
|
@ -31,12 +31,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <utils.h>
|
|
||||||
#include <allocator.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <xxhash.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include "utils/utils.h"
|
||||||
|
#include "allocator.h"
|
||||||
|
#include "utils/xxhash.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -51,6 +51,7 @@ typedef struct {
|
||||||
uint64_t memlimit;
|
uint64_t memlimit;
|
||||||
uint64_t memused;
|
uint64_t memused;
|
||||||
int hash_entry_size, intervals, hash_slots;
|
int hash_entry_size, intervals, hash_slots;
|
||||||
|
char *index_file;
|
||||||
} index_t;
|
} index_t;
|
||||||
|
|
||||||
archive_config_t *
|
archive_config_t *
|
||||||
|
@ -72,6 +73,14 @@ init_global_db(char *configfile)
|
||||||
return (cfg);
|
return (cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
init_on_disk_index(archive_config_t *cfg)
|
||||||
|
{
|
||||||
|
if (file_exists()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
static cleanup_indx(index_t *indx)
|
static cleanup_indx(index_t *indx)
|
||||||
{
|
{
|
||||||
|
@ -307,7 +316,7 @@ init_global_db_s(char *path, char *tmppath, uint32_t chunksize, uint64_t user_ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cfg->segcache_pos = 0;
|
cfg->segcache_pos = 0;
|
||||||
cfg->dbdata = indx;
|
cfg->db_index = indx;
|
||||||
return (cfg);
|
return (cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +484,7 @@ db_lookup_insert_s(archive_config_t *cfg, uchar_t *sim_cksum, int interval,
|
||||||
uint64_t item_offset, uint32_t item_size, int do_insert)
|
uint64_t item_offset, uint32_t item_size, int do_insert)
|
||||||
{
|
{
|
||||||
uint32_t htab_entry;
|
uint32_t htab_entry;
|
||||||
index_t *indx = (index_t *)(cfg->dbdata);
|
index_t *indx = (index_t *)(cfg->db_index);
|
||||||
hash_entry_t **htab, *ent, **pent;
|
hash_entry_t **htab, *ent, **pent;
|
||||||
|
|
||||||
assert((cfg->similarity_cksum_sz & (sizeof (size_t) - 1)) == 0);
|
assert((cfg->similarity_cksum_sz & (sizeof (size_t) - 1)) == 0);
|
||||||
|
@ -549,7 +558,7 @@ void
|
||||||
destroy_global_db_s(archive_config_t *cfg)
|
destroy_global_db_s(archive_config_t *cfg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
index_t *indx = (index_t *)(cfg->dbdata);
|
index_t *indx = (index_t *)(cfg->db_index);
|
||||||
|
|
||||||
cleanup_indx(indx);
|
cleanup_indx(indx);
|
||||||
if (cfg->pct_interval > 0) {
|
if (cfg->pct_interval > 0) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ typedef struct _hash_entry {
|
||||||
uchar_t cksum[1];
|
uchar_t cksum[1];
|
||||||
} hash_entry_t;
|
} hash_entry_t;
|
||||||
|
|
||||||
|
|
||||||
archive_config_t *init_global_db(char *configfile);
|
archive_config_t *init_global_db(char *configfile);
|
||||||
int setup_db_config_s(archive_config_t *cfg, uint32_t chunksize, uint64_t *user_chunk_sz,
|
int setup_db_config_s(archive_config_t *cfg, uint32_t chunksize, uint64_t *user_chunk_sz,
|
||||||
int *pct_interval, const char *algo, cksum_t ck, cksum_t ck_sim,
|
int *pct_interval, const char *algo, cksum_t ck, cksum_t ck_sim,
|
||||||
|
|
|
@ -45,15 +45,15 @@
|
||||||
#include <xxhash.h>
|
#include <xxhash.h>
|
||||||
#include <pc_archive.h>
|
#include <pc_archive.h>
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <sys/sysinfo.h>
|
|
||||||
#else
|
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#include <mach/mach_host.h>
|
#include <mach/mach_host.h>
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
|
|
||||||
static mach_timebase_info_data_t sTimebaseInfo;
|
static mach_timebase_info_data_t sTimebaseInfo;
|
||||||
|
#else
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _IN_UTILS_
|
#define _IN_UTILS_
|
||||||
|
@ -637,6 +637,17 @@ is_incompressible(int type)
|
||||||
return (ic);
|
return (ic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
file_exists(char *path)
|
||||||
|
{
|
||||||
|
FILE *fh = fopen(path, "r");
|
||||||
|
if (fh != NULL) {
|
||||||
|
fclose(fh);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* Portability wrappers for synchronization primitives.
|
* Portability wrappers for synchronization primitives.
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
|
|
|
@ -348,6 +348,7 @@ extern int chk_dir(char *dir);
|
||||||
extern void init_algo_props(algo_props_t *props);
|
extern void init_algo_props(algo_props_t *props);
|
||||||
extern void init_pcompress();
|
extern void init_pcompress();
|
||||||
extern char *get_temp_dir();
|
extern char *get_temp_dir();
|
||||||
|
extern int file_exists(char *path);
|
||||||
|
|
||||||
/* Pointer type for compress and decompress functions. */
|
/* Pointer type for compress and decompress functions. */
|
||||||
typedef int (*compress_func_ptr)(void *src, uint64_t srclen, void *dst,
|
typedef int (*compress_func_ptr)(void *src, uint64_t srclen, void *dst,
|
||||||
|
|
Loading…
Reference in a new issue