Commit d29a734a authored by Petri Hintukainen's avatar Petri Hintukainen

Add pread() replacement

parent 2a10ff31
/*
* This file is part of libudfread
* Copyright (C) 2014-2015 VLC authors and VideoLAN
* Copyright (C) 2014-2017 VLC authors and VideoLAN
*
* Authors: Petri Hintukainen <phintuka@users.sourceforge.net>
*
......@@ -70,7 +70,30 @@ static ssize_t pread(int fd, void *buf, size_t count, off_t offset)
}
return got;
}
#endif
#elif defined (NEED_PREAD_IMPL)
#include <pthread.h>
static ssize_t pread_impl(int fd, void *buf, size_t count, off_t offset)
{
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
ssize_t result;
pthread_mutex_lock(&lock);
if (lseek(fd, offset, SEEK_SET) != offset) {
result = -1;
} else {
result = read(fd, buf, count);
}
pthread_mutex_unlock(&lock);
return result;
}
#define pread(a,b,c,d) pread_impl(a,b,c,d)
#endif /* _WIN32 || NEED_PREAD_IMPL */
typedef struct default_block_input {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment