vknulldrv: Fix 64-bit build

Change-Id: I5dad7520ab513d230ba4af0ce2a4feb18b43bc82
(cherry picked from commit 1eb7f719d235708420898cdf4c18bc4cd46e19be)
diff --git a/vulkan/nulldrv/null_driver.cpp b/vulkan/nulldrv/null_driver.cpp
index 4fd0103..8e654f1 100644
--- a/vulkan/nulldrv/null_driver.cpp
+++ b/vulkan/nulldrv/null_driver.cpp
@@ -188,12 +188,14 @@
         offsetof(VkInstance_T, physical_device));
 }
 
-uint64_t AllocHandle(VkDevice device, HandleType::Enum type) {
+template <class Handle>
+Handle AllocHandle(VkDevice device, HandleType::Enum type) {
     const uint64_t kHandleMask = (UINT64_C(1) << 56) - 1;
     ALOGE_IF(device->next_handle[type] == kHandleMask,
              "non-dispatchable handles of type=%u are about to overflow", type);
-    return (UINT64_C(1) << 63) | ((uint64_t(type) & 0x7) << 56) |
-           (device->next_handle[type]++ & kHandleMask);
+    return reinterpret_cast<Handle>(
+        (UINT64_C(1) << 63) | ((uint64_t(type) & 0x7) << 56) |
+        (device->next_handle[type]++ & kHandleMask));
 }
 
 }  // namespace
@@ -578,7 +580,7 @@
                           const VkBufferViewCreateInfo*,
                           const VkAllocationCallbacks* /*allocator*/,
                           VkBufferView* view) {
-    *view = AllocHandle(device, HandleType::kBufferView);
+    *view = AllocHandle<VkBufferView>(device, HandleType::kBufferView);
     return VK_SUCCESS;
 }
 
@@ -586,7 +588,7 @@
                               const VkDescriptorPoolCreateInfo*,
                               const VkAllocationCallbacks* /*allocator*/,
                               VkDescriptorPool* pool) {
-    *pool = AllocHandle(device, HandleType::kDescriptorPool);
+    *pool = AllocHandle<VkDescriptorPool>(device, HandleType::kDescriptorPool);
     return VK_SUCCESS;
 }
 
@@ -594,7 +596,8 @@
                                 const VkDescriptorSetAllocateInfo* alloc_info,
                                 VkDescriptorSet* descriptor_sets) {
     for (uint32_t i = 0; i < alloc_info->setLayoutCount; i++)
-        descriptor_sets[i] = AllocHandle(device, HandleType::kDescriptorSet);
+        descriptor_sets[i] =
+            AllocHandle<VkDescriptorSet>(device, HandleType::kDescriptorSet);
     return VK_SUCCESS;
 }
 
@@ -602,7 +605,8 @@
                                    const VkDescriptorSetLayoutCreateInfo*,
                                    const VkAllocationCallbacks* /*allocator*/,
                                    VkDescriptorSetLayout* layout) {
-    *layout = AllocHandle(device, HandleType::kDescriptorSetLayout);
+    *layout = AllocHandle<VkDescriptorSetLayout>(
+        device, HandleType::kDescriptorSetLayout);
     return VK_SUCCESS;
 }
 
@@ -610,7 +614,7 @@
                      const VkEventCreateInfo*,
                      const VkAllocationCallbacks* /*allocator*/,
                      VkEvent* event) {
-    *event = AllocHandle(device, HandleType::kEvent);
+    *event = AllocHandle<VkEvent>(device, HandleType::kEvent);
     return VK_SUCCESS;
 }
 
@@ -618,7 +622,7 @@
                      const VkFenceCreateInfo*,
                      const VkAllocationCallbacks* /*allocator*/,
                      VkFence* fence) {
-    *fence = AllocHandle(device, HandleType::kFence);
+    *fence = AllocHandle<VkFence>(device, HandleType::kFence);
     return VK_SUCCESS;
 }
 
@@ -626,7 +630,7 @@
                            const VkFramebufferCreateInfo*,
                            const VkAllocationCallbacks* /*allocator*/,
                            VkFramebuffer* framebuffer) {
-    *framebuffer = AllocHandle(device, HandleType::kFramebuffer);
+    *framebuffer = AllocHandle<VkFramebuffer>(device, HandleType::kFramebuffer);
     return VK_SUCCESS;
 }
 
@@ -634,7 +638,7 @@
                          const VkImageViewCreateInfo*,
                          const VkAllocationCallbacks* /*allocator*/,
                          VkImageView* view) {
-    *view = AllocHandle(device, HandleType::kImageView);
+    *view = AllocHandle<VkImageView>(device, HandleType::kImageView);
     return VK_SUCCESS;
 }
 
@@ -645,7 +649,7 @@
                                  const VkAllocationCallbacks* /*allocator*/,
                                  VkPipeline* pipelines) {
     for (uint32_t i = 0; i < count; i++)
-        pipelines[i] = AllocHandle(device, HandleType::kPipeline);
+        pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
     return VK_SUCCESS;
 }
 
@@ -656,7 +660,7 @@
                                 const VkAllocationCallbacks* /*allocator*/,
                                 VkPipeline* pipelines) {
     for (uint32_t i = 0; i < count; i++)
-        pipelines[i] = AllocHandle(device, HandleType::kPipeline);
+        pipelines[i] = AllocHandle<VkPipeline>(device, HandleType::kPipeline);
     return VK_SUCCESS;
 }
 
@@ -664,7 +668,7 @@
                              const VkPipelineCacheCreateInfo*,
                              const VkAllocationCallbacks* /*allocator*/,
                              VkPipelineCache* cache) {
-    *cache = AllocHandle(device, HandleType::kPipelineCache);
+    *cache = AllocHandle<VkPipelineCache>(device, HandleType::kPipelineCache);
     return VK_SUCCESS;
 }
 
@@ -672,7 +676,8 @@
                               const VkPipelineLayoutCreateInfo*,
                               const VkAllocationCallbacks* /*allocator*/,
                               VkPipelineLayout* layout) {
-    *layout = AllocHandle(device, HandleType::kPipelineLayout);
+    *layout =
+        AllocHandle<VkPipelineLayout>(device, HandleType::kPipelineLayout);
     return VK_SUCCESS;
 }
 
@@ -680,7 +685,7 @@
                          const VkQueryPoolCreateInfo*,
                          const VkAllocationCallbacks* /*allocator*/,
                          VkQueryPool* pool) {
-    *pool = AllocHandle(device, HandleType::kQueryPool);
+    *pool = AllocHandle<VkQueryPool>(device, HandleType::kQueryPool);
     return VK_SUCCESS;
 }
 
@@ -688,7 +693,7 @@
                           const VkRenderPassCreateInfo*,
                           const VkAllocationCallbacks* /*allocator*/,
                           VkRenderPass* renderpass) {
-    *renderpass = AllocHandle(device, HandleType::kRenderPass);
+    *renderpass = AllocHandle<VkRenderPass>(device, HandleType::kRenderPass);
     return VK_SUCCESS;
 }
 
@@ -696,7 +701,7 @@
                        const VkSamplerCreateInfo*,
                        const VkAllocationCallbacks* /*allocator*/,
                        VkSampler* sampler) {
-    *sampler = AllocHandle(device, HandleType::kSampler);
+    *sampler = AllocHandle<VkSampler>(device, HandleType::kSampler);
     return VK_SUCCESS;
 }
 
@@ -704,7 +709,7 @@
                          const VkSemaphoreCreateInfo*,
                          const VkAllocationCallbacks* /*allocator*/,
                          VkSemaphore* semaphore) {
-    *semaphore = AllocHandle(device, HandleType::kSemaphore);
+    *semaphore = AllocHandle<VkSemaphore>(device, HandleType::kSemaphore);
     return VK_SUCCESS;
 }
 
@@ -712,7 +717,7 @@
                             const VkShaderModuleCreateInfo*,
                             const VkAllocationCallbacks* /*allocator*/,
                             VkShaderModule* module) {
-    *module = AllocHandle(device, HandleType::kShaderModule);
+    *module = AllocHandle<VkShaderModule>(device, HandleType::kShaderModule);
     return VK_SUCCESS;
 }