Allow compilation without pthread support

This commit is contained in:
Andrea Mazzoleni 2016-03-18 18:45:35 +01:00
parent fe3ad31cbb
commit 8d3cefb302
4 changed files with 37 additions and 15 deletions

View file

@ -737,7 +737,9 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir, uint64_t dev
/* ensure that the dir terminate with "/" if it isn't empty */
pathslash(disk->dir, sizeof(disk->dir));
#if HAVE_PTHREAD
thread_mutex_init(&disk->fs_mutex, 0);
#endif
disk->smartctl[0] = 0;
disk->device = dev;
@ -782,19 +784,29 @@ void disk_free(struct snapraid_disk* disk)
tommy_list_foreach(&disk->dirlist, (tommy_foreach_func*)dir_free);
tommy_hashdyn_done(&disk->dirset);
#if HAVE_PTHREAD
thread_mutex_destroy(&disk->fs_mutex);
#endif
free(disk);
}
static inline void fs_lock(struct snapraid_disk* disk)
{
#if HAVE_PTHREAD
thread_mutex_lock(&disk->fs_mutex);
#else
(void)disk;
#endif
}
static inline void fs_unlock(struct snapraid_disk* disk)
{
#if HAVE_PTHREAD
thread_mutex_unlock(&disk->fs_mutex);
#else
(void)disk;
#endif
}
struct chunk_disk_empty {