r3218 - in trunk/libmutil: include include/libmutil source

erik at minisip.org erik at minisip.org
Thu Feb 22 14:49:50 CET 2007


Author: erik
Date: 2007-02-22 14:49:49 +0100 (Thu, 22 Feb 2007)
New Revision: 3218

Modified:
   trunk/libmutil/include/config.h
   trunk/libmutil/include/libmutil/Thread.h
   trunk/libmutil/include/libmutil/mtypes.h
   trunk/libmutil/source/IString.cxx
   trunk/libmutil/source/TextUI.cxx
   trunk/libmutil/source/ThreadWin32.cxx
   trunk/libmutil/source/mtimeWin32.cxx
   trunk/libmutil/source/stringutils.cxx
Log:

 * Store handle in 64 bit integer instead of in 32 bit
 * Changed some _WIN32_WCE to _MSC_VER where they are
   always needed when compiling with visual c (not only
   for Windows Mobile).
 * Fixed some warnings for MSVC
  - Deprecated functions: sprintf, _ftime

Modified: trunk/libmutil/include/config.h
===================================================================
--- trunk/libmutil/include/config.h	2007-02-18 21:17:08 UTC (rev 3217)
+++ trunk/libmutil/include/config.h	2007-02-22 13:49:49 UTC (rev 3218)
@@ -24,7 +24,7 @@
 #define CONFIG_H
 
 /* Compilation time configuration */
-#ifndef _WIN32_WCE
+#ifndef _MSC_VER
 #	include"compilation_config.h"
 #else
 #	include"compilation_config_w32_wce.h"

Modified: trunk/libmutil/include/libmutil/Thread.h
===================================================================
--- trunk/libmutil/include/libmutil/Thread.h	2007-02-18 21:17:08 UTC (rev 3217)
+++ trunk/libmutil/include/libmutil/Thread.h	2007-02-22 13:49:49 UTC (rev 3218)
@@ -49,14 +49,13 @@
 		ThreadHandle(const ThreadHandle &);
 		~ThreadHandle();
 		
-		unsigned long asLongInt() const{ 
+		uint64_t asInt64() const{ 
 			//return *((unsigned long*)this->hptr); 
 			return handle;
 		};
 
 	private:
-		//void *hptr;
-		unsigned long handle;
+		uint64_t handle;
 
 		friend class Thread;
 };

Modified: trunk/libmutil/include/libmutil/mtypes.h
===================================================================
--- trunk/libmutil/include/libmutil/mtypes.h	2007-02-18 21:17:08 UTC (rev 3217)
+++ trunk/libmutil/include/libmutil/mtypes.h	2007-02-22 13:49:49 UTC (rev 3218)
@@ -38,7 +38,7 @@
 #endif
 
 #ifndef uint64_t
-	#ifdef _WIN32_WCE
+	#ifdef _MSC_VER
 		typedef unsigned __int64 uint64_t;
 	#else
 		typedef unsigned long long  uint64_t;

Modified: trunk/libmutil/source/IString.cxx
===================================================================
--- trunk/libmutil/source/IString.cxx	2007-02-18 21:17:08 UTC (rev 3217)
+++ trunk/libmutil/source/IString.cxx	2007-02-22 13:49:49 UTC (rev 3218)
@@ -29,7 +29,7 @@
 }
 
 StringAtom::StringAtom(std::string s){
-#ifdef _WIN32_WCE
+#ifdef _MSC_VER
 	buf = _strdup(s.c_str());
 #else
 	buf = strdup(s.c_str());

Modified: trunk/libmutil/source/TextUI.cxx
===================================================================
--- trunk/libmutil/source/TextUI.cxx	2007-02-18 21:17:08 UTC (rev 3217)
+++ trunk/libmutil/source/TextUI.cxx	2007-02-22 13:49:49 UTC (rev 3218)
@@ -165,7 +165,7 @@
 	MRef<QuestionDialog *> d = questionDialogs.front();
 	d->answers.push_back(answer);
 	d->nAnswered++;
-	if (d->nAnswered >= d->questions.size()){
+	if (d->nAnswered >= (int)d->questions.size()){
 		//all questions now answered
 		guiExecute(d);
 		isAskingDialogQuestion=false;

Modified: trunk/libmutil/source/ThreadWin32.cxx
===================================================================
--- trunk/libmutil/source/ThreadWin32.cxx	2007-02-18 21:17:08 UTC (rev 3217)
+++ trunk/libmutil/source/ThreadWin32.cxx	2007-02-22 13:49:49 UTC (rev 3218)
@@ -161,7 +161,7 @@
 		throw ThreadException("Could not create thread.");
         }
 	//*((HANDLE*)handle.hptr) = h;
-	handle.handle = (unsigned long)h;
+	handle.handle = (uint64_t)h;
 
 }
 
@@ -187,7 +187,7 @@
 		throw ThreadException("Could not create thread.");
 	}
 	//*((HANDLE*)handle.hptr) = h;
-	handle.handle = (unsigned long)h;
+	handle.handle = (uint64_t)h;
 
 	return handle;
 }
@@ -222,7 +222,7 @@
 		throw ThreadException("Could not create thread.");
 	}
 	//*((HANDLE*)handle.hptr) = h;
-	handle.handle=(unsigned long)h;
+	handle.handle=(uint64_t)h;
 	return handle;
 }
 
@@ -268,7 +268,7 @@
 ThreadHandle Thread::getCurrent() {
 	ThreadHandle th;
 // 	*((HANDLE*)th.hptr) = GetCurrentProcess();
-	th.handle = (unsigned long)GetCurrentProcess();
+	th.handle = (uint64_t)GetCurrentProcess();
         return th;
 }
 

Modified: trunk/libmutil/source/mtimeWin32.cxx
===================================================================
--- trunk/libmutil/source/mtimeWin32.cxx	2007-02-18 21:17:08 UTC (rev 3217)
+++ trunk/libmutil/source/mtimeWin32.cxx	2007-02-22 13:49:49 UTC (rev 3218)
@@ -34,10 +34,11 @@
 LIBMUTIL_API uint64_t mtime(){
 	#ifdef _WIN32_WCE
 		struct timeb tb;
+		_ftime (&tb);
 	#else
 		struct _timeb tb;
+		_ftime64_s (&tb);
 	#endif
-		_ftime (&tb);
 
 	return ((uint64_t)tb.time) * (int64_t)1000 + ((uint64_t)tb.millitm);
 }
@@ -48,12 +49,13 @@
 	void gettimeofday (struct timeval *tv, struct timezone *tz){
 		#ifdef _WIN32_WCE
 		struct timeb tb;
+		_ftime (&tb);
 		#else
 		struct _timeb tb;
+		_ftime64_s (&tb);
 		#endif
-		_ftime (&tb);
 
-		tv->tv_sec = tb.time;
+		tv->tv_sec = (long)tb.time; // Fix: tv_sec wraps year 2038 (tv.time is ok though)
 		tv->tv_usec = tb.millitm * 1000L;
 		if( tz ){
 			tz->tz_minuteswest = tb.timezone;	/* minutes west of Greenwich  */

Modified: trunk/libmutil/source/stringutils.cxx
===================================================================
--- trunk/libmutil/source/stringutils.cxx	2007-02-18 21:17:08 UTC (rev 3217)
+++ trunk/libmutil/source/stringutils.cxx	2007-02-22 13:49:49 UTC (rev 3218)
@@ -185,7 +185,11 @@
 	char hex_number[3];
 	
 	for( int i = 0; i < length; i++ ){
-		sprintf( hex_number, "%02x", *(data+i) );
+#ifdef _MSC_VER
+		_snprintf_s( hex_number, 3, 2, "%02x", *(data+i) );		
+#else
+		snprintf( hex_number, 3, "%02x", *(data+i) );
+#endif
 		result += hex_number;
 	}
 	
@@ -197,7 +201,11 @@
 	char buf[30]; //should be enough for a 64 bit integer ...
 	for (int j=0; j<16; j++)
 		buf[j]=0;
-	sprintf(buf,"%lld",i);
+#ifdef _MSC_VER
+	_snprintf_s( buf, 30, 29, "%11d", i);
+#else
+	snprintf(buf, 30, "%lld",i);
+#endif
 	return string(buf);
 }
 



More information about the Minisip-devel mailing list