Commit 2360945f authored by anonymous's avatar anonymous
Browse files

util,file: merge changes from other libs

parent 795a9e43
......@@ -20,8 +20,13 @@
#ifndef FILE_H_
#define FILE_H_
#include "util/attributes.h"
#include "filesystem.h"
#include <stdint.h>
#include <stddef.h>
#ifdef _WIN32
# define DIR_SEP "\\"
# define DIR_SEP_CHAR '\\'
......@@ -34,9 +39,20 @@
* file access
*/
#define file_close(X) X->close(X)
#define file_seek(X,Y,Z) X->seek(X,Y,Z)
#define file_read(X,Y,Z) X->read(X,Y,Z)
static inline void file_close(BDPLUS_FILE_H *fp)
{
fp->close(fp);
}
static inline BD_USED int64_t file_seek(BDPLUS_FILE_H *fp, int64_t offset, int32_t origin)
{
return fp->seek(fp, offset, origin);
}
static inline BD_USED size_t file_read(BDPLUS_FILE_H *fp, uint8_t *buf, size_t size)
{
return (size_t)fp->read(fp, buf, (int64_t)size);
}
#define file_open(cfg, fname) (cfg->fopen(cfg->fopen_handle, fname))
......
......@@ -58,4 +58,10 @@
# define BD_UNLIKELY(x) __builtin_expect((x),0)
#endif
#if defined(__GNUC__) && __GNUC__ > 3
# define BD_USED __attribute__((warn_unused_result))
#else
# define BD_USED
#endif
#endif /* LIBBLURAY_ATTRIBUTES_H_ */
......@@ -19,6 +19,10 @@
* <http://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "logging.h"
#include "file/file.h"
......
......@@ -74,6 +74,7 @@ static inline void STORE8(void *pv, uint64_t v) {
STORE4(p, v >> 32);
}
#define BD_MAX_SSIZE ((int64_t)(((size_t)-1)>>1))
/*
* automatic cast from void* (malloc/calloc/realloc)
......
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