+#endif /* _NFS_XDR_SUBS_FUNCS_ */
+
+
+/*
+ * macros for building XDR data
+ */
+
+/* finalize the data that has been added to the buffer */
+#define xb_build_done(E, XB) \
+ do { \
+ if (E) break; \
+ xb_set_cur_buf_len(XB); \
+ } while (0)
+
+/* add a 32-bit value */
+#define xb_add_32(E, XB, VAL) \
+ do { \
+ uint32_t __tmp; \
+ if (E) break; \
+ __tmp = txdr_unsigned(VAL); \
+ (E) = xb_add_bytes((XB), (void*)&__tmp, XDRWORD, 0); \
+ } while (0)
+
+/* add a 64-bit value */
+#define xb_add_64(E, XB, VAL) \
+ do { \
+ uint64_t __tmp1, __tmp2; \
+ if (E) break; \
+ __tmp1 = (VAL); \
+ txdr_hyper(&__tmp1, &__tmp2); \
+ (E) = xb_add_bytes((XB), (char*)&__tmp2, 2 * XDRWORD, 0); \
+ } while (0)
+
+/* add an array of XDR words */
+#define xb_add_word_array(E, XB, A, LEN) \
+ do { \
+ uint32_t __i; \
+ xb_add_32((E), (XB), (LEN)); \
+ for (__i=0; __i < (uint32_t)(LEN); __i++) \
+ xb_add_32((E), (XB), (A)[__i]); \
+ } while (0)
+#define xb_add_bitmap(E, XB, B, LEN) xb_add_word_array((E), (XB), (B), (LEN))
+
+/* add a file handle */
+#define xb_add_fh(E, XB, FHP, FHLEN) \
+ do { \
+ xb_add_32((E), (XB), (FHLEN)); \
+ if (E) break; \
+ (E) = xb_add_bytes((XB), (char*)(FHP), (FHLEN), 0); \
+ } while (0)
+
+/* add a string */
+#define xb_add_string(E, XB, S, LEN) \
+ do { \
+ xb_add_32((E), (XB), (LEN)); \
+ if (E) break; \
+ (E) = xb_add_bytes((XB), (const char*)(S), (LEN), 0); \
+ } while (0)
+
+
+/*
+ * macros for decoding XDR data
+ */
+
+/* skip past data in the buffer */
+#define xb_skip(E, XB, LEN) \
+ do { \
+ if (E) break; \
+ (E) = xb_advance((XB), (LEN)); \
+ } while (0)
+
+/* get a 32-bit value */
+#define xb_get_32(E, XB, LVAL) \
+ do { \
+ uint32_t __tmp; \
+ if (E) break; \
+ (E) = xb_get_bytes((XB), (char*)&__tmp, XDRWORD, 0); \
+ if (E) break; \
+ (LVAL) = fxdr_unsigned(uint32_t, __tmp); \
+ } while (0)
+
+/* get a 64-bit value */
+#define xb_get_64(E, XB, LVAL) \
+ do { \
+ uint64_t __tmp; \
+ if (E) break; \
+ (E) = xb_get_bytes((XB), (char*)&__tmp, 2 * XDRWORD, 0); \
+ if (E) break; \
+ fxdr_hyper(&__tmp, &(LVAL)); \
+ } while (0)
+
+/* get an array of XDR words (of a given expected/maximum length) */
+#define xb_get_word_array(E, XB, A, LEN) \
+ do { \
+ uint32_t __len = 0, __i; \
+ xb_get_32((E), (XB), __len); \
+ if (E) break; \
+ for (__i=0; __i < MIN(__len, (uint32_t)(LEN)); __i++) \
+ xb_get_32((E), (XB), (A)[__i]); \
+ if (E) break; \
+ for (; __i < __len; __i++) \
+ xb_skip((E), (XB), XDRWORD); \
+ for (; __i < (uint32_t)(LEN); __i++) \
+ (A)[__i] = 0; \
+ (LEN) = __len; \
+ } while (0)
+#define xb_get_bitmap(E, XB, B, LEN) xb_get_word_array((E), (XB), (B), (LEN))
+