Bug 1202704: Move Bluetooth IPC pack functions to generic HAL IPC, r=shuang
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 09 Sep 2015 13:40:26 +0200
changeset 294102 64bab3289232d1e464cd058829fcdaa87f97349b
parent 294101 ee015390f701973fdaa46f06f010c2a6ca2198d3
child 294103 d019cd8fc5cc3ff426129a52fe74da16cf6013a0
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs1202704
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1202704: Move Bluetooth IPC pack functions to generic HAL IPC, r=shuang
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
ipc/hal/DaemonSocketPDUHelpers.cpp
ipc/hal/DaemonSocketPDUHelpers.h
--- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp
@@ -973,22 +973,16 @@ Convert(const ConvertArray<Tin>& aIn, To
   return NS_OK;
 }
 
 //
 // Packing
 //
 
 nsresult
-PackPDU(bool aIn, DaemonSocketPDU& aPDU)
-{
-  return PackPDU(PackConversion<bool, uint8_t>(aIn), aPDU);
-}
-
-nsresult
 PackPDU(const BluetoothAddress& aIn, DaemonSocketPDU& aPDU)
 {
   return PackPDU(PackArray<uint8_t>(aIn.mAddr, sizeof(aIn.mAddr)), aPDU);
 }
 
 nsresult
 PackPDU(const BluetoothAvrcpAttributeTextPairs& aIn,
         DaemonSocketPDU& aPDU)
--- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
@@ -291,19 +291,16 @@ Convert(BluetoothGattWriteType aIn, int3
 nsresult
 Convert(nsresult aIn, BluetoothStatus& aOut);
 
 //
 // Packing
 //
 
 nsresult
-PackPDU(bool aIn, DaemonSocketPDU& aPDU);
-
-nsresult
 PackPDU(const BluetoothAddress& aIn, DaemonSocketPDU& aPDU);
 
 nsresult
 PackPDU(const BluetoothAvrcpAttributeTextPairs& aIn,
         DaemonSocketPDU& aPDU);
 
 nsresult
 PackPDU(const BluetoothAvrcpAttributeValuePairs& aIn,
@@ -397,404 +394,28 @@ nsresult
 PackPDU(BluetoothGattAuthReq aIn, DaemonSocketPDU& aPDU);
 
 nsresult
 PackPDU(BluetoothGattWriteType aIn, DaemonSocketPDU& aPDU);
 
 nsresult
 PackPDU(BluetoothTransport aIn, DaemonSocketPDU& aPDU);
 
-/* |PackConversion| is a helper for packing converted values. Pass
- * an instance of this structure to |PackPDU| to convert a value from
- * the input type to the output type and and write it to the PDU.
- */
-template<typename Tin, typename Tout>
-struct PackConversion {
-  PackConversion(const Tin& aIn)
-  : mIn(aIn)
-  { }
-
-  const Tin& mIn;
-};
-
-template<typename Tin, typename Tout>
-inline nsresult
-PackPDU(const PackConversion<Tin, Tout>& aIn, DaemonSocketPDU& aPDU)
-{
-  Tout out;
-
-  nsresult rv = Convert(aIn.mIn, out);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(out, aPDU);
-}
-
-/* |PackArray| is a helper for packing arrays. Pass an instance
- * of this structure as the first argument to |PackPDU| to pack
- * an array. The array's maximum default length is 255 elements.
- */
-template <typename T>
-struct PackArray
-{
-  PackArray(const T* aData, size_t aLength)
-  : mData(aData)
-  , mLength(aLength)
-  { }
-
-  const T* mData;
-  size_t mLength;
-};
-
-/* This implementation of |PackPDU| packs the length of an array
- * and the elements of the array one-by-one.
- */
-template<typename T>
-inline nsresult
-PackPDU(const PackArray<T>& aIn, DaemonSocketPDU& aPDU)
-{
-  for (size_t i = 0; i < aIn.mLength; ++i) {
-    nsresult rv = PackPDU(aIn.mData[i], aPDU);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-  }
-  return NS_OK;
-}
-
-template<>
-inline nsresult
-PackPDU<uint8_t>(const PackArray<uint8_t>& aIn, DaemonSocketPDU& aPDU)
-{
-  /* Write raw bytes in one pass */
-  return aPDU.Write(aIn.mData, aIn.mLength);
-}
-
-template<>
-inline nsresult
-PackPDU<char>(const PackArray<char>& aIn, DaemonSocketPDU& aPDU)
-{
-  /* Write raw bytes in one pass */
-  return aPDU.Write(aIn.mData, aIn.mLength);
-}
-
-/* |PackCString0| is a helper for packing 0-terminated C string,
- * including the \0 character. Pass an instance of this structure
- * as the first argument to |PackPDU| to pack a string.
- */
-struct PackCString0
-{
-  PackCString0(const nsCString& aString)
-  : mString(aString)
-  { }
-
-  const nsCString& mString;
-};
-
-/* This implementation of |PackPDU| packs a 0-terminated C string.
- */
-inline nsresult
-PackPDU(const PackCString0& aIn, DaemonSocketPDU& aPDU)
-{
-  return PackPDU(
-    PackArray<uint8_t>(reinterpret_cast<const uint8_t*>(aIn.mString.get()),
-                       aIn.mString.Length() + 1), aPDU);
-}
-
-/* |PackReversed| is a helper for packing data in reversed order. Pass an
- * instance of this structure as the first argument to |PackPDU| to pack data
- * in reversed order.
- */
-template<typename T>
-struct PackReversed
-{
-  PackReversed(const T& aValue)
-    : mValue(aValue)
-  { }
-
-  const T& mValue;
-};
-
-/* No general rules to pack data in reversed order. Signal a link error if the
- * type |T| of |PackReversed| is not defined explicitly.
- */
-template<typename T>
-nsresult
-PackPDU(const PackReversed<T>& aIn, DaemonSocketPDU& aPDU);
-
-/* This implementation of |PackPDU| packs elements in |PackArray| in reversed
- * order. (ex. reversed GATT UUID, see bug 1171866)
- */
-template<typename U>
-inline nsresult
-PackPDU(const PackReversed<PackArray<U>>& aIn, DaemonSocketPDU& aPDU)
-{
-  for (size_t i = 0; i < aIn.mValue.mLength; ++i) {
-    nsresult rv = PackPDU(aIn.mValue.mData[aIn.mValue.mLength - i - 1], aPDU);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-  }
-  return NS_OK;
-}
-
 /* This implementation of |PackPDU| packs |BluetoothUuid| in reversed order.
  * (ex. reversed GATT UUID, see bug 1171866)
  */
-template <>
 inline nsresult
-PackPDU<BluetoothUuid>(const PackReversed<BluetoothUuid>& aIn,
-                       DaemonSocketPDU& aPDU)
+PackPDU(const PackReversed<BluetoothUuid>& aIn, DaemonSocketPDU& aPDU)
 {
  return PackPDU(
    PackReversed<PackArray<uint8_t>>(
      PackArray<uint8_t>(aIn.mValue.mUuid, sizeof(aIn.mValue.mUuid))),
    aPDU);
 }
 
-template <typename T1, typename T2>
-inline nsresult
-PackPDU(const T1& aIn1, const T2& aIn2, DaemonSocketPDU& aPDU)
-{
-  nsresult rv = PackPDU(aIn1, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(aIn2, aPDU);
-}
-
-template <typename T1, typename T2, typename T3>
-inline nsresult
-PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
-        DaemonSocketPDU& aPDU)
-{
-  nsresult rv = PackPDU(aIn1, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn2, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(aIn3, aPDU);
-}
-
-template <typename T1, typename T2, typename T3, typename T4>
-inline nsresult
-PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3, const T4& aIn4,
-        DaemonSocketPDU& aPDU)
-{
-  nsresult rv = PackPDU(aIn1, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn2, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn3, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(aIn4, aPDU);
-}
-
-template <typename T1, typename T2, typename T3,
-          typename T4, typename T5>
-inline nsresult
-PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
-        const T4& aIn4, const T5& aIn5,
-        DaemonSocketPDU& aPDU)
-{
-  nsresult rv = PackPDU(aIn1, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn2, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn3, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn4, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(aIn5, aPDU);
-}
-
-template <typename T1, typename T2, typename T3,
-          typename T4, typename T5, typename T6>
-inline nsresult
-PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
-        const T4& aIn4, const T5& aIn5, const T6& aIn6,
-        DaemonSocketPDU& aPDU)
-{
-  nsresult rv = PackPDU(aIn1, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn2, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn3, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn4, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn5, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(aIn6, aPDU);
-}
-
-template <typename T1, typename T2, typename T3,
-          typename T4, typename T5, typename T6,
-          typename T7>
-inline nsresult
-PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
-        const T4& aIn4, const T5& aIn5, const T6& aIn6,
-        const T7& aIn7, DaemonSocketPDU& aPDU)
-{
-  nsresult rv = PackPDU(aIn1, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn2, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn3, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn4, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn5, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn6, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(aIn7, aPDU);
-}
-
-template <typename T1, typename T2, typename T3,
-          typename T4, typename T5, typename T6,
-          typename T7, typename T8>
-inline nsresult
-PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
-        const T4& aIn4, const T5& aIn5, const T6& aIn6,
-        const T7& aIn7, const T8& aIn8, DaemonSocketPDU& aPDU)
-{
-  nsresult rv = PackPDU(aIn1, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn2, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn3, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn4, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn5, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn6, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn7, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(aIn8, aPDU);
-}
-
-template <typename T1, typename T2, typename T3,
-          typename T4, typename T5, typename T6,
-          typename T7, typename T8, typename T9,
-          typename T10, typename T11, typename T12,
-          typename T13>
-inline nsresult
-PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
-        const T4& aIn4, const T5& aIn5, const T6& aIn6,
-        const T7& aIn7, const T8& aIn8, const T9& aIn9,
-        const T10& aIn10, const T11& aIn11, const T12& aIn12,
-        const T13& aIn13, DaemonSocketPDU& aPDU)
-{
-  nsresult rv = PackPDU(aIn1, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn2, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn3, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn4, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn5, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn6, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn7, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn8, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn9, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn10, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn11, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = PackPDU(aIn12, aPDU);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return PackPDU(aIn13, aPDU);
-}
-
 //
 // Unpacking
 //
 
 nsresult
 UnpackPDU(DaemonSocketPDU& aPDU, bool& aOut);
 
 nsresult
--- a/ipc/hal/DaemonSocketPDUHelpers.cpp
+++ b/ipc/hal/DaemonSocketPDUHelpers.cpp
@@ -157,16 +157,22 @@ Convert(size_t aIn, uint16_t& aOut)
   return NS_OK;
 }
 
 //
 // Packing
 //
 
 nsresult
+PackPDU(bool aIn, DaemonSocketPDU& aPDU)
+{
+  return PackPDU(PackConversion<bool, uint8_t>(aIn), aPDU);
+}
+
+nsresult
 PackPDU(const DaemonSocketPDUHeader& aIn, DaemonSocketPDU& aPDU)
 {
   nsresult rv = PackPDU(aIn.mService, aPDU);
   if (NS_FAILED(rv)) {
     return rv;
   }
   rv = PackPDU(aIn.mOpcode, aPDU);
   if (NS_FAILED(rv)) {
--- a/ipc/hal/DaemonSocketPDUHelpers.h
+++ b/ipc/hal/DaemonSocketPDUHelpers.h
@@ -84,16 +84,19 @@ Convert(size_t aIn, uint16_t& aOut);
 // Packing
 //
 
 // introduce link errors on non-handled data types
 template <typename T>
 nsresult
 PackPDU(T aIn, DaemonSocketPDU& aPDU);
 
+nsresult
+PackPDU(bool aIn, DaemonSocketPDU& aPDU);
+
 inline nsresult
 PackPDU(uint8_t aIn, DaemonSocketPDU& aPDU)
 {
   return aPDU.Write(aIn);
 }
 
 inline nsresult
 PackPDU(uint16_t aIn, DaemonSocketPDU& aPDU)
@@ -111,16 +114,390 @@ inline nsresult
 PackPDU(uint32_t aIn, DaemonSocketPDU& aPDU)
 {
   return aPDU.Write(aIn);
 }
 
 nsresult
 PackPDU(const DaemonSocketPDUHeader& aIn, DaemonSocketPDU& aPDU);
 
+/* |PackConversion| is a helper for packing converted values. Pass
+ * an instance of this structure to |PackPDU| to convert a value from
+ * the input type to the output type and and write it to the PDU.
+ */
+template<typename Tin, typename Tout>
+struct PackConversion {
+  PackConversion(const Tin& aIn)
+    : mIn(aIn)
+  { }
+
+  const Tin& mIn;
+};
+
+template<typename Tin, typename Tout>
+inline nsresult
+PackPDU(const PackConversion<Tin, Tout>& aIn, DaemonSocketPDU& aPDU)
+{
+  Tout out;
+
+  nsresult rv = Convert(aIn.mIn, out);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(out, aPDU);
+}
+
+/* |PackArray| is a helper for packing arrays. Pass an instance
+ * of this structure as the first argument to |PackPDU| to pack
+ * an array. The array's maximum default length is 255 elements.
+ */
+template <typename T>
+struct PackArray
+{
+  PackArray(const T* aData, size_t aLength)
+    : mData(aData)
+    , mLength(aLength)
+  { }
+
+  const T* mData;
+  size_t mLength;
+};
+
+/* This implementation of |PackPDU| packs the length of an array
+ * and the elements of the array one-by-one.
+ */
+template<typename T>
+inline nsresult
+PackPDU(const PackArray<T>& aIn, DaemonSocketPDU& aPDU)
+{
+  for (size_t i = 0; i < aIn.mLength; ++i) {
+    nsresult rv = PackPDU(aIn.mData[i], aPDU);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+  }
+  return NS_OK;
+}
+
+template<>
+inline nsresult
+PackPDU<uint8_t>(const PackArray<uint8_t>& aIn, DaemonSocketPDU& aPDU)
+{
+  /* Write raw bytes in one pass */
+  return aPDU.Write(aIn.mData, aIn.mLength);
+}
+
+template<>
+inline nsresult
+PackPDU<char>(const PackArray<char>& aIn, DaemonSocketPDU& aPDU)
+{
+  /* Write raw bytes in one pass */
+  return aPDU.Write(aIn.mData, aIn.mLength);
+}
+
+/* |PackCString0| is a helper for packing 0-terminated C string,
+ * including the \0 character. Pass an instance of this structure
+ * as the first argument to |PackPDU| to pack a string.
+ */
+struct PackCString0
+{
+  PackCString0(const nsCString& aString)
+    : mString(aString)
+  { }
+
+  const nsCString& mString;
+};
+
+/* This implementation of |PackPDU| packs a 0-terminated C string.
+ */
+inline nsresult
+PackPDU(const PackCString0& aIn, DaemonSocketPDU& aPDU)
+{
+  return PackPDU(
+    PackArray<uint8_t>(reinterpret_cast<const uint8_t*>(aIn.mString.get()),
+                       aIn.mString.Length() + 1), aPDU);
+}
+
+/* |PackReversed| is a helper for packing data in reversed order. Pass an
+ * instance of this structure as the first argument to |PackPDU| to pack data
+ * in reversed order.
+ */
+template<typename T>
+struct PackReversed
+{
+  PackReversed(const T& aValue)
+    : mValue(aValue)
+  { }
+
+  const T& mValue;
+};
+
+/* No general rules to pack data in reversed order. Signal a link error if the
+ * type |T| of |PackReversed| is not defined explicitly.
+ */
+template<typename T>
+nsresult
+PackPDU(const PackReversed<T>& aIn, DaemonSocketPDU& aPDU);
+
+/* This implementation of |PackPDU| packs elements in |PackArray| in reversed
+ * order. (ex. reversed GATT UUID, see bug 1171866)
+ */
+template<typename U>
+inline nsresult
+PackPDU(const PackReversed<PackArray<U>>& aIn, DaemonSocketPDU& aPDU)
+{
+  for (size_t i = 0; i < aIn.mValue.mLength; ++i) {
+    nsresult rv = PackPDU(aIn.mValue.mData[aIn.mValue.mLength - i - 1], aPDU);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+  }
+  return NS_OK;
+}
+
+template <typename T1, typename T2>
+inline nsresult
+PackPDU(const T1& aIn1, const T2& aIn2, DaemonSocketPDU& aPDU)
+{
+  nsresult rv = PackPDU(aIn1, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(aIn2, aPDU);
+}
+
+template <typename T1, typename T2, typename T3>
+inline nsresult
+PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
+        DaemonSocketPDU& aPDU)
+{
+  nsresult rv = PackPDU(aIn1, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn2, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(aIn3, aPDU);
+}
+
+template <typename T1, typename T2, typename T3, typename T4>
+inline nsresult
+PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3, const T4& aIn4,
+        DaemonSocketPDU& aPDU)
+{
+  nsresult rv = PackPDU(aIn1, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn2, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn3, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(aIn4, aPDU);
+}
+
+template <typename T1, typename T2, typename T3,
+          typename T4, typename T5>
+inline nsresult
+PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
+        const T4& aIn4, const T5& aIn5,
+        DaemonSocketPDU& aPDU)
+{
+  nsresult rv = PackPDU(aIn1, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn2, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn3, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn4, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(aIn5, aPDU);
+}
+
+template <typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6>
+inline nsresult
+PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
+        const T4& aIn4, const T5& aIn5, const T6& aIn6,
+        DaemonSocketPDU& aPDU)
+{
+  nsresult rv = PackPDU(aIn1, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn2, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn3, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn4, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn5, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(aIn6, aPDU);
+}
+
+template <typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6,
+          typename T7>
+inline nsresult
+PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
+        const T4& aIn4, const T5& aIn5, const T6& aIn6,
+        const T7& aIn7, DaemonSocketPDU& aPDU)
+{
+  nsresult rv = PackPDU(aIn1, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn2, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn3, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn4, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn5, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn6, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(aIn7, aPDU);
+}
+
+template <typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6,
+          typename T7, typename T8>
+inline nsresult
+PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
+        const T4& aIn4, const T5& aIn5, const T6& aIn6,
+        const T7& aIn7, const T8& aIn8, DaemonSocketPDU& aPDU)
+{
+  nsresult rv = PackPDU(aIn1, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn2, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn3, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn4, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn5, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn6, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn7, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(aIn8, aPDU);
+}
+
+template <typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6,
+          typename T7, typename T8, typename T9,
+          typename T10, typename T11, typename T12,
+          typename T13>
+inline nsresult
+PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
+        const T4& aIn4, const T5& aIn5, const T6& aIn6,
+        const T7& aIn7, const T8& aIn8, const T9& aIn9,
+        const T10& aIn10, const T11& aIn11, const T12& aIn12,
+        const T13& aIn13, DaemonSocketPDU& aPDU)
+{
+  nsresult rv = PackPDU(aIn1, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn2, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn3, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn4, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn5, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn6, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn7, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn8, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn9, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn10, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn11, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  rv = PackPDU(aIn12, aPDU);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  return PackPDU(aIn13, aPDU);
+}
+
 //
 // Unpacking
 //
 
 // introduce link errors on non-handled data types
 template <typename T>
 nsresult
 UnpackPDU(DaemonSocketPDU& aPDU, T& aOut);