Merge "libnfc-nxp: fix build for 64-bit"
diff --git a/Android.mk b/Android.mk
index 36f6e15..e8676a7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -132,6 +132,8 @@
 LOCAL_CFLAGS += -I$(LOCAL_PATH)/Linux_x86
 LOCAL_CFLAGS += -I$(LOCAL_PATH)/src
 
+LOCAL_CFLAGS += -Wno-unused-parameter
+
 LOCAL_MODULE:= libnfc
 LOCAL_MODULE_TAGS := optional
 LOCAL_SHARED_LIBRARIES := libcutils libnfc_ndef libdl libhardware liblog
diff --git a/Linux_x86/phDal4Nfc_i2c.c b/Linux_x86/phDal4Nfc_i2c.c
index 72edb22..8e83a73 100644
--- a/Linux_x86/phDal4Nfc_i2c.c
+++ b/Linux_x86/phDal4Nfc_i2c.c
@@ -82,7 +82,7 @@
 
 void phDal4Nfc_i2c_set_open_from_handle(phHal_sHwReference_t * pDalHwContext)
 {
-   gI2cPortContext.nHandle = (int) pDalHwContext->p_board_driver;
+   gI2cPortContext.nHandle = (int)(intptr_t) pDalHwContext->p_board_driver;
    DAL_ASSERT_STR(gI2cPortContext.nHandle >= 0, "Bad passed com port handle");
    gI2cPortContext.nOpened = 1;
 }
@@ -156,7 +156,7 @@
    }
 
    gI2cPortContext.nOpened = 1;
-   *pLinkHandle = (void*)gI2cPortContext.nHandle;
+   *pLinkHandle = (void*)(intptr_t)gI2cPortContext.nHandle;
 
    DAL_PRINT("Open succeed\n");
 
diff --git a/Linux_x86/phDal4Nfc_messageQueueLib.c b/Linux_x86/phDal4Nfc_messageQueueLib.c
index 30d389b..3b288ba 100644
--- a/Linux_x86/phDal4Nfc_messageQueueLib.c
+++ b/Linux_x86/phDal4Nfc_messageQueueLib.c
@@ -67,7 +67,7 @@
  * \retval -1                                   Can not allocate memory or can not init mutex.
 *  \retval handle                               The handle on the message queue.
  */
-int phDal4Nfc_msgget ( key_t key, int msgflg )
+intptr_t phDal4Nfc_msgget ( key_t key, int msgflg )
 {
    phDal4Nfc_message_queue_t * pQueue;
    pQueue = (phDal4Nfc_message_queue_t *) phOsalNfc_GetMemory(sizeof(phDal4Nfc_message_queue_t));
@@ -78,7 +78,7 @@
       return -1;
    if (sem_init (&pQueue->nProcessSemaphore, 0, 0) == -1)
       return -1;
-   return ((int)pQueue);
+   return ((intptr_t)pQueue);
 }
 
 /**
@@ -93,7 +93,7 @@
  * \retval 0                                    If success.
  * \retval -1                                   Bad passed parameter
  */
-int phDal4Nfc_msgctl ( int msqid, int cmd, void *buf )
+int phDal4Nfc_msgctl ( intptr_t msqid, int cmd, void *buf )
 {
    phDal4Nfc_message_queue_t * pQueue;
    phDal4Nfc_message_queue_item_t * p;
@@ -136,7 +136,7 @@
  * \retval 0                                    If success.
  * \retval -1                                   Bad passed parameter, or can not allocate memory
  */
-int phDal4Nfc_msgsnd (int msqid, void * msgp, size_t msgsz, int msgflg)
+int phDal4Nfc_msgsnd (intptr_t msqid, void * msgp, size_t msgsz, int msgflg)
 {
    phDal4Nfc_message_queue_t * pQueue;
    phDal4Nfc_message_queue_item_t * p;
@@ -187,7 +187,7 @@
  * \retval 0                                    If success.
  * \retval -1                                   Bad passed parameter.
  */
-int phDal4Nfc_msgrcv (int msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg)
+int phDal4Nfc_msgrcv (intptr_t msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg)
 {
    phDal4Nfc_message_queue_t * pQueue;
    phDal4Nfc_message_queue_item_t * p;
diff --git a/Linux_x86/phDal4Nfc_uart.c b/Linux_x86/phDal4Nfc_uart.c
index 520ab9c..657dc80 100644
--- a/Linux_x86/phDal4Nfc_uart.c
+++ b/Linux_x86/phDal4Nfc_uart.c
@@ -97,7 +97,7 @@
 
 void phDal4Nfc_uart_set_open_from_handle(phHal_sHwReference_t * pDalHwContext)
 {
-   gComPortContext.nHandle = (int) pDalHwContext->p_board_driver;
+   gComPortContext.nHandle = (int)(intptr_t) pDalHwContext->p_board_driver;
    DAL_ASSERT_STR(gComPortContext.nHandle >= 0, "Bad passed com port handle");
    gComPortContext.nOpened = 1;
 }
@@ -176,7 +176,7 @@
    }
 
    gComPortContext.nOpened = 1;
-   *pLinkHandle = (void*)gComPortContext.nHandle;
+   *pLinkHandle = (void*)(intptr_t)gComPortContext.nHandle;
 
    /*
     *  Now configure the com port
diff --git a/inc/phNfcTypes.h b/inc/phNfcTypes.h
index 914ae07..79d12aa 100644
--- a/inc/phNfcTypes.h
+++ b/inc/phNfcTypes.h
@@ -232,7 +232,7 @@
    /** Device node of the controller */
    const char*               deviceNode;
    /** The client ID (thread ID or message queue ID) */
-   unsigned int              nClientId;
+   intptr_t                  nClientId;
 } phLibNfc_sConfig_t, *pphLibNfc_sConfig_t;
 
 
diff --git a/src/phDal4Nfc_messageQueueLib.h b/src/phDal4Nfc_messageQueueLib.h
index 0bf2ba4..b13823b 100644
--- a/src/phDal4Nfc_messageQueueLib.h
+++ b/src/phDal4Nfc_messageQueueLib.h
@@ -41,10 +41,10 @@
    phLibNfc_Message_t msg;
 } phDal4Nfc_Message_Wrapper_t;
 
-int phDal4Nfc_msgget(key_t key, int msgflg);
-int phDal4Nfc_msgctl(int msqid, int cmd, void *buf);
-int phDal4Nfc_msgsnd(int msqid, void * msgp, size_t msgsz, int msgflg);
-int phDal4Nfc_msgrcv (int msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg);
+intptr_t phDal4Nfc_msgget(key_t key, int msgflg);
+int phDal4Nfc_msgctl(intptr_t msqid, int cmd, void *buf);
+int phDal4Nfc_msgsnd(intptr_t msqid, void * msgp, size_t msgsz, int msgflg);
+int phDal4Nfc_msgrcv(intptr_t msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg);
 #endif
 
 #endif /*  PHDAL4NFC_MESSAGEQUEUE_H  */
diff --git a/src/phLibNfc.h b/src/phLibNfc.h
index 6111a93..ddce262 100644
--- a/src/phLibNfc.h
+++ b/src/phLibNfc.h
@@ -49,7 +49,7 @@
 #define LIBNFC_READONLY_NDEF
 #define PHLIBNFC_MAXNO_OF_SE        (0x02)
 
-typedef uint32_t    phLibNfc_Handle;
+typedef uintptr_t phLibNfc_Handle;
 
 extern const unsigned char *nxp_nfc_full_version;
 
diff --git a/src/phLibNfc_Internal.h b/src/phLibNfc_Internal.h
index c136032..368c6c9 100644
--- a/src/phLibNfc_Internal.h
+++ b/src/phLibNfc_Internal.h
@@ -222,11 +222,11 @@
 
     /*To re configure the discovery wheel*/
     phLibNfc_sADD_Cfg_t          sADDconfig;
-    uint32_t                     Connected_handle,
+    uintptr_t                    Connected_handle,
                                  Discov_handle[MAX_REMOTE_DEVICES];
 
     /* To store the previous connected handle in case of Multiple protocol tags */
-    uint32_t Prev_Connected_handle;
+    uintptr_t                    Prev_Connected_handle;
 
     /*Call back function pointers */
 
diff --git a/src/phLibNfc_initiator.c b/src/phLibNfc_initiator.c
index 6bd48b8..ab4d766 100644
--- a/src/phLibNfc_initiator.c
+++ b/src/phLibNfc_initiator.c
@@ -155,7 +155,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 							info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-							(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+							(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1] = 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -170,7 +170,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 							info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-							(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+							(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1]= 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -187,7 +187,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 								info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-								(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+								(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1] = 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -203,7 +203,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 								info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-								(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+								(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1] = 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -219,7 +219,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 								info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-								(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+								(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1] = 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -235,7 +235,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 								info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-								(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+								(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1] = 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -251,7 +251,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 								info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-								(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+								(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1] = 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -268,7 +268,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 								info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-								(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+								(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1] = 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -283,7 +283,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 								info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-								(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
+								(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo;
 						gpphLibContext->Discov_handle[DeviceIndx1] = 
 							gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -299,7 +299,7 @@
 						gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo=
 								info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx];
 						gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev =
-								(uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo;
+								(phLibNfc_Handle)gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo;
 						gpphLibContext->sNfcIp_Context.Rem_Initiator_Handle=
 								gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev;
 						DeviceIndx1++;
@@ -756,7 +756,7 @@
         else if(PHNFCSTATUS(status)==NFCSTATUS_SUCCESS)
         {
             /* Copy the Remote device address as connected handle*/
-            gpphLibContext->Connected_handle =(uint32_t) pRmtdev_info;
+            gpphLibContext->Connected_handle = (uintptr_t)pRmtdev_info;
             /* Update the state to connected and return status as SUCCESS*/
             gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect;
             Connect_status = NFCSTATUS_SUCCESS;
@@ -774,7 +774,7 @@
         /* Call the upper layer callback*/      
         gpphLibContext->CBInfo.pClientConnectCb(
                     gpphLibContext->CBInfo.pClientConCntx,
-                    (uint32_t)pRmtdev_info,
+                    (phLibNfc_Handle)pRmtdev_info,
                     (phLibNfc_sRemoteDevInformation_t*)pRmtdev_info,
                     Connect_status);
     }
@@ -948,7 +948,7 @@
     }
     /* Call the upper layer Callback */
     (*pUpper_NtfCb)(pUpper_Context,
-                    (uint32_t)reg_handle,
+                    (phLibNfc_Handle)reg_handle,
                     DisCnct_status);
     return;
 }
@@ -1197,7 +1197,7 @@
                     PHDBG_INFO("LibNfc:Transceive Complete");
                     /* Notify the Transceive Completion to upper layer */
                     gpphLibContext->CBInfo.pClientTransceiveCb(pUpper_Context,
-                                (uint32_t)pRmtdev_info,  
+                                (phLibNfc_Handle)pRmtdev_info,
                                 trans_resp,
                                 trans_status);
                 }
@@ -1210,7 +1210,7 @@
                     PHDBG_INFO("LibNfc:Transceive Complete");
                     /* Notify the Transceive Completion to upper layer */
                     gpphLibContext->CBInfo.pClientTransceiveCb(pUpper_Context,
-                                (uint32_t)pRmtdev_info,  
+                                (phLibNfc_Handle)pRmtdev_info,
                                 trans_resp,
                                 trans_status);
                 }
diff --git a/src/phLibNfc_ndef_raw.c b/src/phLibNfc_ndef_raw.c
index 31dbbac..4b87d31 100644
--- a/src/phLibNfc_ndef_raw.c
+++ b/src/phLibNfc_ndef_raw.c
@@ -1228,7 +1228,7 @@
                         NFCSTATUS_FAILED:NFCSTATUS_TARGET_LOST);             
                 /* call the upper transceive callback */
                 pClientCb(pUpperLayerContext,
-                        (uint32_t)psRemoteDevInfo,
+                        (phLibNfc_Handle)psRemoteDevInfo,
                         & trans_resp,
                         status);                
             }