]> git.proxmox.com Git - libgit2.git/blobdiff - src/common.h
New upstream version 1.3.0+dfsg.1
[libgit2.git] / src / common.h
index 2b1a4a4569c7981bc348b294a729d341432e2cce..9bb1116b53149192793f6b64c8eab9a1a04c21ad 100644 (file)
@@ -19,6 +19,8 @@
 # define GIT_INLINE(type) static __inline type
 #elif defined(__GNUC__)
 # define GIT_INLINE(type) static __inline__ type
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+# define GIT_INLINE(type) static inline type
 #else
 # define GIT_INLINE(type) static type
 #endif
 # define __has_builtin(x) 0
 #endif
 
+/**
+ * Declare that a function's return value must be used.
+ *
+ * Used mostly to guard against potential silent bugs at runtime. This is
+ * recommended to be added to functions that:
+ *
+ * - Allocate / reallocate memory. This prevents memory leaks or errors where
+ *   buffers are expected to have grown to a certain size, but could not be
+ *   resized.
+ * - Acquire locks. When a lock cannot be acquired, that will almost certainly
+ *   cause a data race / undefined behavior.
+ */
+#if defined(__GNUC__)
+# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+# define GIT_WARN_UNUSED_RESULT
+#endif
+
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
@@ -63,7 +83,9 @@
 #      include <pthread.h>
 #      include <sched.h>
 # endif
-#define GIT_STDLIB_CALL
+
+#define GIT_LIBGIT2_CALL
+#define GIT_SYSTEM_CALL
 
 #ifdef GIT_USE_STAT_ATIMESPEC
 # define st_atim st_atimespec
 #include "git2/types.h"
 #include "git2/errors.h"
 #include "errors.h"
-#include "thread-utils.h"
+#include "thread.h"
 #include "integer.h"
 #include "assert_safe.h"
+#include "utf8.h"
 
 /*
  * Include the declarations for deprecated functions; this ensures