[libbdplus-devel] util,file: merge changes from other libs

anonymous git at videolan.org
Tue Mar 20 09:05:36 CET 2018


libbdplus | branch: master | anonymous <anonymous at anonymous.org> | Tue Mar 20 09:37:58 2018 +0200| [2360945ffa8da08f76c2f07753e02bdc7ff3dd54] | committer: anonymous

util,file: merge changes from other libs

> http://git.videolan.org/gitweb.cgi/libbdplus.git/?a=commit;h=2360945ffa8da08f76c2f07753e02bdc7ff3dd54
---

 src/file/file.h       | 22 +++++++++++++++++++---
 src/util/attributes.h |  6 ++++++
 src/util/logging.c    |  4 ++++
 src/util/macro.h      |  1 +
 4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/file/file.h b/src/file/file.h
index f4dbb37..d9f3665 100644
--- a/src/file/file.h
+++ b/src/file/file.h
@@ -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))
 
diff --git a/src/util/attributes.h b/src/util/attributes.h
index 9aa84d8..1cc611c 100644
--- a/src/util/attributes.h
+++ b/src/util/attributes.h
@@ -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_ */
diff --git a/src/util/logging.c b/src/util/logging.c
index 47a9616..3c826d9 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -19,6 +19,10 @@
  * <http://www.gnu.org/licenses/>.
  */
 
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "logging.h"
 
 #include "file/file.h"
diff --git a/src/util/macro.h b/src/util/macro.h
index fcbc2e6..c27b312 100644
--- a/src/util/macro.h
+++ b/src/util/macro.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)



More information about the libbdplus-devel mailing list