Procházet zdrojové kódy

libdpkg: Add PURE, MALLOC, NONNULL and REQRET compiler attributes

Guillem Jover před 15 roky
rodič
revize
7d4d1007c4
1 změnil soubory, kde provedl 13 přidání a 0 odebrání
  1. 13 0
      lib/dpkg/macros.h

+ 13 - 0
lib/dpkg/macros.h

@@ -30,17 +30,30 @@
 #if defined(__GNUC__) && (__GNUC__ >= 3)
 #define DPKG_ATTR_UNUSED	__attribute__((unused))
 #define DPKG_ATTR_CONST		__attribute__((const))
+#define DPKG_ATTR_PURE		__attribute__((pure))
+#define DPKG_ATTR_MALLOC	__attribute__((malloc))
 #define DPKG_ATTR_NORET		__attribute__((noreturn))
 #define DPKG_ATTR_PRINTF(n)	__attribute__((format(printf, n, n + 1)))
 #define DPKG_ATTR_VPRINTF(n)	__attribute__((format(printf, n, 0)))
 #else
 #define DPKG_ATTR_UNUSED
 #define DPKG_ATTR_CONST
+#define DPKG_ATTR_PURE
+#define DPKG_ATTR_MALLOC
 #define DPKG_ATTR_NORET
 #define DPKG_ATTR_PRINTF(n)
 #define DPKG_ATTR_VPRINTF(n)
 #endif
 
+#if defined(__GNUC__) && \
+    ((__GNUC__ == 3 && __GNUC_MINOR__ > 2) || __GNUC__ >= 4)
+#define DPKG_ATTR_NONNULL(...)	__attribute__((nonnull(__VA_ARGS__)))
+#define DPKG_ATTR_REQRET	__attribute__((warn_unused_result))
+#else
+#define DPKG_ATTR_NONNULL(...)
+#define DPKG_ATTR_REQRET
+#endif
+
 #if defined(__GNUC__) && (__GNUC__ >= 4)
 #define DPKG_ATTR_SENTINEL	__attribute__((sentinel))
 #else