stds.h: introduce AFS_NONNULL
[openafs.git] / src / config / stds.h
index 8fbd509..53badff 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -59,7 +59,6 @@ pragma Off(Prototype_override_warnings);
 
 typedef short afs_int16;
 typedef unsigned short afs_uint16;
-#ifdef  AFS_64BIT_ENV
 typedef int afs_int32;
 typedef unsigned int afs_uint32;
 #if defined(AFS_NT40_ENV) && defined(_MSC_VER)
@@ -70,7 +69,7 @@ typedef long long afs_int64;
 typedef unsigned long long afs_uint64;
 #endif
 #define ZeroInt64(a)       (a = 0)
-#define AssignInt64(a, b) *(b) = (a) 
+#define AssignInt64(a, b) *(b) = (a)
 #define IncInt64(a) (*(a))++
 #define IncUInt64(a) (*(a))++
 #define DecInt64(a) (*(a))--
@@ -91,46 +90,6 @@ typedef unsigned long long afs_uint64;
 #define SplitInt64(t,h,l) (h) = ((afs_int64)t) >> 32; (l) = (t) & MAX_AFS_UINT32;
 #define RoundInt64ToInt32(a)    (a > MAX_AFS_UINT32) ? MAX_AFS_UINT32 : a;
 #define RoundInt64ToInt31(a)    (a > MAX_AFS_INT32) ? MAX_AFS_INT32 : a;
-#else /* AFS_64BIT_ENV */
-typedef long afs_int32;
-typedef unsigned long afs_uint32;
-
-struct Int64 {
-    afs_int32 high;
-    afs_uint32 low;
-};
-typedef struct Int64 afs_int64;
-
-struct u_Int64 {
-    afs_uint32 high;
-    afs_uint32 low;
-};
-typedef struct u_Int64 afs_uint64;
-#define ZeroInt64(a) ((a).high = (a).low = 0)
-#define AssignInt64(a, b) (b)->high = (a).high; (b)->low = (a).low
-#define IncInt64(a) ((++((a)->low)) ? 0 : (a)->high++ )
-#define IncUInt64(a) ((++((a)->low)) ? 0 : (a)->high++ )
-#define DecInt64(a) (((a)->low)-- ? 0 : (a)->high-- )
-#define DecUInt64(a) (((a)->low)-- ? 0 : (a)->high-- )
-#define GTInt64(a,b) (((a).high > (b).high) || (((a).high == (b).high) && ((a).low > (b).low)))
-#define GEInt64(a,b) (((a).high > (b).high) || (((a).high == (b).high) && ((a).low >= (b).low)))
-#define LEInt64(a,b) (((a).high < (b).high) || (((a).high == (b).high) && ((a).low <= (b).low)))
-#define LTInt64(a,b) (((a).high < (b).high) || (((a).high == (b).high) && ((a).low < (b).low)))
-#define CompareInt64(a,b) (((afs_int32)(a).high - (afs_int32)(b).high) || (((a).high == (b).high) && ((a).low - (b).low))) 
-#define AddInt64(a, b, c) {  afs_int64 _a, _b; _a = a; _b = b; (c)->low = _a.low + _b.low; (c)->high = _a.high + _b.high + ((c)->low < _b.low); } 
-#define SubtractInt64(a, b, c) { afs_int64 _a, _b; _a = a; _b = b; (c)->low = _a.low - _b.low;  (c)->high = _a.high - _b.high - (_a.low < _b.low); } 
-#define CompareUInt64(a,b) (((afs_uint32)(a).high - (afs_uint32)(b).high) || (((a).high == (b).high) && ((a).low - (b).low))) 
-#define AddUInt64(a, b, c) {  afs_uint64 _a, _b; _a = a; _b = b; (c)->low = _a.low + _b.low; (c)->high = _a.high + _b.high + ((c)->low < _b.low); } 
-#define SubtractUInt64(a, b, c) { afs_uint64 _a, _b; _a = a; _b = b; (c)->low = _a.low - _b.low;  (c)->high = _a.high - _b.high - (_a.low < _b.low); } 
-#define NonZeroInt64(a)   (a).low || (a).high
-#define Int64ToInt32(a)    (a).low
-#define FillInt64(t,h,l) (t).high = (h); (t).low = (l);
-#define SplitInt64(t,h,l) (h) = (t).high; (l) = (t).low;
-#define RoundInt64ToInt32(a)    (a.high > 0) ? MAX_AFS_UINT32 : a.low;
-#define RoundInt64ToInt31(a)    (a.high > 0) ? MAX_AFS_INT32 : a.low;
-#endif /* AFS_64BIT_ENV */
-
-/* AFS_64BIT_CLIENT should presently be set only for AFS_64BIT_ENV systems */
 
 #ifdef AFS_64BIT_CLIENT
 typedef afs_int64 afs_size_t;
@@ -167,7 +126,7 @@ typedef afs_uint32 afs_uintmax_t;
  * some assistence in this matter.  The hyper type is supposed to be compatible
  * with the afsHyper type: the same macros will work on both. */
 
-#if    defined(AFS_64BIT_ENV) && 0
+#if 0
 
 typedef unsigned long afs_hyper_t;
 
@@ -189,7 +148,7 @@ typedef unsigned long afs_hyper_t;
 #define        hadd32(a,b)     ((a) += (b))
 #define hshlft(a,n)     ((a)<<(n))
 
-#else /* AFS_64BIT_ENV */
+#else /* 0*/
 
 typedef struct afs_hyper_t {   /* unsigned 64 bit integers */
     unsigned int high;
@@ -238,7 +197,7 @@ typedef struct afs_hyper_t {        /* unsigned 64 bit integers */
      (a).low += (int)(i))
 
 #define hadd(a,b) (hadd32(a,(b).low), (a).high += (b).high)
-#endif /* AFS_64BIT_ENV */
+#endif /* 0 */
 
 #if !defined(KERNEL) || defined(UKERNEL)
 #ifndef AFS_NT40_ENV
@@ -277,7 +236,7 @@ typedef struct afsUUID afsUUID;
 #define AFS_DEMAND_ATTACH_FS 1
 #endif
 
-/* A macro that can be used when printf'ing 64 bit integers, as Unix and 
+/* A macro that can be used when printf'ing 64 bit integers, as Unix and
  * windows use a different format string
  */
 #ifdef AFS_NT40_ENV
@@ -296,7 +255,7 @@ typedef struct afsUUID afsUUID;
 # endif /* PRINTF_TAKES_Z_LEN */
 #endif /* AFS_NT40_ENV */
 
-/* Functions to safely cast afs_int32 and afs_uint32 so they can be used in 
+/* Functions to safely cast afs_int32 and afs_uint32 so they can be used in
  * printf statemements with %ld and %lu
  */
 #ifdef AFS_NT40_ENV
@@ -313,7 +272,7 @@ typedef struct afsUUID afsUUID;
 #elif defined(AFS_SGI_ENV) || defined(AFS_USR_SGI_ENV)
 #define static_inline static
 #define hdr_static_inline(x) x
-#elif defined(AFS_NBSD_ENV)
+#elif defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV)
 #define static_inline static __inline __attribute__((always_inline))
 #define hdr_static_inline(x) static __inline __attribute__((always_inline)) x
 #else
@@ -337,14 +296,17 @@ hdr_static_inline(unsigned long) afs_printable_uint32_lu(afs_uint32 d) { return
 #define AFS_UNUSED __attribute__((unused))
 #define AFS_ATTRIBUTE_FORMAT(style,x,y) __attribute__((format(style, x, y)))
 #define AFS_NORETURN __attribute__((__noreturn__))
+#define AFS_NONNULL(x) __attribute__((__nonnull x))
 #elif defined (__clang__)
 #define AFS_UNUSED __attribute__((unused))
 #define AFS_ATTRIBUTE_FORMAT(style,x,y) __attribute__((format(style, x, y)))
 #define AFS_NORETURN __attribute__((__noreturn__))
+#define AFS_NONNULL(x) __attribute__((__nonnull x))
 #else
 #define AFS_UNUSED
 #define AFS_ATTRIBUTE_FORMAT(style,x,y)
 #define AFS_NORETURN
+#define AFS_NONNULL(x)
 #endif
 
 #endif /* OPENAFS_CONFIG_AFS_STDS_H */