Merge "Move libdex off safe-iop."
diff --git a/libdex/DexDataMap.cpp b/libdex/DexDataMap.cpp
index 65da14c..18e4a45 100644
--- a/libdex/DexDataMap.cpp
+++ b/libdex/DexDataMap.cpp
@@ -19,7 +19,6 @@
  */
 
 #include "DexDataMap.h"
-#include <safe_iop.h>
 #include <stdlib.h>
 
 /*
@@ -27,18 +26,15 @@
  */
 DexDataMap* dexDataMapAlloc(u4 maxCount) {
     /*
-     * Allocate a single chunk for the DexDataMap per se as well as the
+     * Allocate a single chunk for the DexDataMap itself as well as the
      * two arrays.
      */
     size_t size = 0;
     DexDataMap* map = NULL;
 
-    /*
-     * Avoiding pulling in safe_iop for safe_iopf.
-     */
     const u4 sizeOfItems = (u4) (sizeof(u4) + sizeof(u2));
-    if (!safe_mul(&size, maxCount, sizeOfItems) ||
-        !safe_add(&size, size, sizeof(DexDataMap))) {
+    if (__builtin_mul_overflow(maxCount, sizeOfItems, &size) ||
+        __builtin_add_overflow(size, sizeof(DexDataMap), &size)) {
       return NULL;
     }
 
diff --git a/libdex/DexSwapVerify.cpp b/libdex/DexSwapVerify.cpp
index 8836ab2..1049bab 100644
--- a/libdex/DexSwapVerify.cpp
+++ b/libdex/DexSwapVerify.cpp
@@ -25,7 +25,6 @@
 #include "DexUtf.h"
 #include "Leb128.h"
 
-#include <safe_iop.h>
 #include <zlib.h>
 
 #include <stdlib.h>
@@ -140,7 +139,8 @@
 #define CHECK_LIST_SIZE(_ptr, _count, _elemSize) {                          \
         const u1* _start = (const u1*) (_ptr);                              \
         const u1* _end = _start + ((_count) * (_elemSize));                 \
-        if (!safe_mul(nullptr, (_count), (_elemSize)) ||                    \
+        u4 _dummy;                                                          \
+        if (__builtin_mul_overflow((_count), (_elemSize), &_dummy) ||       \
             !checkPtrRange(state, _start, _end, #_ptr)) {                   \
             return 0;                                                       \
         }                                                                   \