#include <unistd.h>
#include <glib.h>
#include <ctype.h>
-#ifdef ARCH64
#include <stdint.h>
-#endif
#include <sys/socket.h>
#include <arpa/inet.h>
#include <net/if.h>
bool __bt_gatt_client_foreach_svc_cb(int total,
int index, bt_gatt_h svc_handle, void *data)
{
-#ifdef ARCH64
- int test_id = (int)(uintptr_t) data;
-#else
- int test_id = (int)data;
-#endif
+ int test_id = GPOINTER_TO_INT(data);
int ret;
char *uuid = NULL;
char *str = NULL;
g_free(uuid);
if (test_id == BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL) {
-#ifdef ARCH64
ret = bt_gatt_service_foreach_characteristics(svc_handle,
- __bt_gatt_client_foreach_chr_cb, (void *)(uintptr_t)test_id);
-#else
- ret = bt_gatt_service_foreach_characteristics(svc_handle,
- __bt_gatt_client_foreach_chr_cb, (void *)test_id);
-#endif
+ __bt_gatt_client_foreach_chr_cb, GINT_TO_POINTER(test_id));
if (ret != BT_ERROR_NONE)
TC_PRT("bt_gatt_service_foreach_characteristics is failed : %d", ret);
}
bool __bt_hps_client_svc_cb(int total,
int index, bt_gatt_h svc_handle, void *data)
{
-#ifdef ARCH64
- int test_id = (int) (uintptr_t) data;
-#else
- int test_id = (int)data;
-#endif
+ int test_id = GPOINTER_TO_INT(data);
int ret;
char *uuid = NULL;
char *str = NULL;
str ? str : "Unknown", uuid);
if (test_id == BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL) {
-#ifdef ARCH64
- ret = bt_gatt_service_foreach_characteristics(svc_handle,
- __bt_gatt_client_foreach_chr_cb,
- (void *)(uintptr_t)test_id);
-#else
ret = bt_gatt_service_foreach_characteristics(svc_handle,
__bt_gatt_client_foreach_chr_cb,
- (void *)test_id);
-#endif
+ GINT_TO_POINTER(test_id));
if (ret != BT_ERROR_NONE)
TC_PRT("bt_gatt_service_foreach_characteristics is failed : %d", ret);
}
if (param_index == g_test_param.param_count) {
need_to_set_params = false;
-#ifdef ARCH64
- test_input_callback((void *)(uintptr_t)test_id);
-#else
- test_input_callback((void *)test_id);
-#endif
+ test_input_callback(GINT_TO_POINTER(test_id));
param_index = 0;
return 0;
}
int test_input_callback(void *data)
{
int ret = 0;
-#ifdef ARCH64
- int test_id = (uintptr_t)data;
-#else
- int test_id = (int)data;
-#endif
+ int test_id = GPOINTER_TO_INT(data);
switch (current_tc_table) {
case BT_UNIT_TEST_TABLE_MAIN: {
break;
}
case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_PRINT_ALL: {
-#ifdef ARCH64
- ret = bt_gatt_client_foreach_services(client,
- __bt_gatt_client_foreach_svc_cb,
- (void *)(uintptr_t)test_id);
-#else
ret = bt_gatt_client_foreach_services(client,
__bt_gatt_client_foreach_svc_cb,
- (void *)test_id);
-#endif
+ GINT_TO_POINTER(test_id));
if (ret != BT_ERROR_NONE)
TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
break;
}
case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_FOREACH_SERVICES: {
-#ifdef ARCH64
ret = bt_gatt_client_foreach_services(client,
- __bt_gatt_client_foreach_svc_cb, (void *)(uintptr_t)test_id);
-#else
- ret = bt_gatt_client_foreach_services(client,
- __bt_gatt_client_foreach_svc_cb, (void *)(uintptr_t)test_id);
-#endif
+ __bt_gatt_client_foreach_svc_cb, GINT_TO_POINTER(test_id));
if (ret != BT_ERROR_NONE)
TC_PRT("bt_gatt_client_foreach_services_by_uuid is failed");
break;
break;
}
case BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES: {
-#ifdef ARCH64
- ret = bt_gatt_server_foreach_services(server,
- __bt_gatt_server_foreach_svc_cb, (void *)(uintptr_t)test_id);
-#else
ret = bt_gatt_server_foreach_services(server,
- __bt_gatt_server_foreach_svc_cb, (void *)test_id);
-#endif
+ __bt_gatt_server_foreach_svc_cb, GINT_TO_POINTER(test_id));
TC_PRT("bt_gatt_server_foreach_services: %s\n", __bt_get_error_message(ret));
break;
}
break;
}
case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_PRINT_ALL: {
-#ifdef ARCH64
- ret = bt_gatt_client_foreach_services(hps_client,
- __bt_hps_client_svc_cb, (void *)(uintptr_t)test_id);
-#else
ret = bt_gatt_client_foreach_services(hps_client,
- __bt_hps_client_svc_cb, (void *)test_id);
-#endif
+ __bt_hps_client_svc_cb, GINT_TO_POINTER(test_id));
if (ret != BT_ERROR_NONE)
TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
gpointer data)
{
char buf[BUFFER_LEN] = { 0 };
-
-#ifdef ARCH64
- unsigned long len = 0;
-#else
- unsigned int len = 0;
-#endif
+ gsize len = 0;
int test_id;
bool is_call_api = false;
&& is_call_api == true) {
memcpy(remote_addr, buf, 17);
remote_addr[17] = 0;
- } else if (test_id && is_call_api)
-#ifdef ARCH64
- g_idle_add(test_input_callback, (void *)(uintptr_t)test_id);
-#else
- g_idle_add(test_input_callback, (void *)test_id);
-#endif
+ } else if (test_id && is_call_api) {
+ g_idle_add(test_input_callback, GINT_TO_POINTER(test_id));
+ }
return TRUE;
}