Commit ca60544b authored by Ghislain MARY's avatar Ghislain MARY

Do not use gettimeofday().

parent ea61cf38
......@@ -44,10 +44,6 @@
#define BELLESIP_EXPORT extern
#endif
#ifdef _MSC_VER
BELLESIP_EXPORT int gettimeofday (struct timeval *tv, void* tz);
#endif
#define BELLESIP_UNUSED(a) a;
#endif
......@@ -240,7 +240,7 @@ belle_sip_list_t *belle_sip_list_delete_custom(belle_sip_list_t *list, belle_sip
char * belle_sip_concat (const char *str, ...);
uint64_t belle_sip_time_ms(void);
BELLESIP_INTERNAL_EXPORT uint64_t belle_sip_time_ms(void);
unsigned int belle_sip_random(void);
......
......@@ -68,18 +68,6 @@ const char *belle_sip_get_socket_error_string_from_code(int code){
return (const char *)msgBuf;
}
int gettimeofday (struct timeval *tv, void* tz) {
union {
__int64 ns100; /*time since 1 Jan 1601 in 100ns units */
FILETIME fileTime;
} now;
GetSystemTimeAsFileTime (&now.fileTime);
tv->tv_usec = (long) ((now.ns100 / 10LL) % 1000000LL);
tv->tv_sec = (long) ((now.ns100 - 116444736000000000LL) / 10000000LL);
return (0);
}
#else
int belle_sip_init_sockets(){
......
......@@ -270,8 +270,8 @@ static void register_test_with_param(unsigned char expire_in_contact,auth_mode_t
belle_sip_header_contact_t* contact=belle_sip_header_contact_new();
belle_sip_uri_t *dest_uri;
endpoint_t* client,*server;
struct timeval begin;
struct timeval end;
uint64_t begin;
uint64_t end;
memset(&client_callbacks,0,sizeof(belle_sip_listener_callbacks_t));
memset(&server_callbacks,0,sizeof(belle_sip_listener_callbacks_t));
......@@ -326,11 +326,11 @@ static void register_test_with_param(unsigned char expire_in_contact,auth_mode_t
belle_sip_object_unref(trans);
belle_sip_refresher_set_listener(refresher,belle_sip_refresher_listener,client);
gettimeofday(&begin, NULL);
begin = belle_sip_time_ms();
CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,3,4000));
gettimeofday(&end, NULL);
CU_ASSERT_TRUE(end.tv_sec-begin.tv_sec>=3);
CU_ASSERT_TRUE(end.tv_sec-begin.tv_sec<5);
end = belle_sip_time_ms();
CU_ASSERT_TRUE(end-begin>=3000);
CU_ASSERT_TRUE(end-begin<5000);
/*unregister*/
belle_sip_refresher_refresh(refresher,0);
CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,4,1000));
......@@ -352,8 +352,8 @@ static void subscribe_test(void) {
belle_sip_uri_t *dest_uri;
belle_sip_refresher_t* refresher;
belle_sip_header_contact_t* contact=belle_sip_header_contact_new();
struct timeval begin;
struct timeval end;
uint64_t begin;
uint64_t end;
memset(&client_callbacks,0,sizeof(belle_sip_listener_callbacks_t));
memset(&server_callbacks,0,sizeof(belle_sip_listener_callbacks_t));
......@@ -404,11 +404,11 @@ static void subscribe_test(void) {
belle_sip_object_unref(trans);
belle_sip_refresher_set_listener(refresher,belle_sip_refresher_listener,client);
gettimeofday(&begin, NULL);
begin = belle_sip_time_ms();
CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,3,4000));
gettimeofday(&end, NULL);
CU_ASSERT_TRUE(end.tv_sec-begin.tv_sec>=3);
CU_ASSERT_TRUE(end.tv_sec-begin.tv_sec<5);
end = belle_sip_time_ms();
CU_ASSERT_TRUE(end-begin>=3000);
CU_ASSERT_TRUE(end-begin<5000);
belle_sip_refresher_stop(refresher);
belle_sip_object_unref(refresher);
destroy_endpoint(client);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment