Re: [Mingw-w64-public] [PATCH] Remove the Macros of the time_r functions and replace them with actual functions

2014-11-12 Thread Martell Malone
Arg I changed the old patch with including errno.h
Can someone delete the previous email from the thread
Sorry

On Wed, Nov 12, 2014 at 2:38 PM, Martell Malone martellmal...@gmail.com
wrote:

 Caching stopped me from including errno.h

 On Wed, Nov 12, 2014 at 2:34 PM, Martell Malone martellmal...@gmail.com
 wrote:

 Dongsheng Song
 Thank you for your suggested changes.

 I would like to note that my implementation was the exact same as the
 Macros apart from the _r in acrtime which I did change but somehow didn't
 end up in the attached patch due to caching or something heh
 The fact that these functions destroys the result of the previous
 calls mean that the Macros has a major bug in them.

 Should I also guard ctime_r and gmtime_r from NULL pointer arguments like
 this?

 +if (_Time == NULL || _Tm == NULL)
 +{
 +errno = EINVAL;
 +return NULL;
 +}

 Ktietz what is your take on the tread safeness of asctime_r
 I remember you recently telling me that MSDN was often incorrect
 As you implemented winpthreads you may be able to tell us :)

 If anyone needs me to address any more changes I'll be glad to
 Please Review for commit





0001-Remove-the-Macros-of-the-time_r-functions-and-replac.patch
Description: Binary data
--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Remove the Macros of the time_r functions and replace them with actual functions

2014-11-12 Thread Dongsheng Song
Pushed with delete mysterious U+200B  characters.

Unicode Character 'ZERO WIDTH SPACE' (U+200B)

+tmp = localtime(_Time);
+if (tmp != NULL)
+memcpy(_Tm, tmp, sizeof(struct tm);
+return tmp;200b200b
+200b}200b
+

On Wed, Nov 12, 2014 at 11:59 PM, Kai Tietz ktiet...@googlemail.com wrote:
 Well,

 ascitime is in msvcrt thread-save too ... anyway, from my POOV patch
 is ok.  If there are no objections by others, please apply.

 Thanks,
 Kai

 2014-11-12 15:50 GMT+01:00 Martell Malone martellmal...@gmail.com:
 Added a guard to every function and handle errno values
 Used memcpy in gmtime_r as discussed

 This version should address all concerns.
 Please commit

 On Wed, Nov 12, 2014 at 2:41 PM, Martell Malone martellmal...@gmail.com
 wrote:

 Arg I changed the old patch with including errno.h
 Can someone delete the previous email from the thread
 Sorry

 On Wed, Nov 12, 2014 at 2:38 PM, Martell Malone martellmal...@gmail.com
 wrote:

 Caching stopped me from including errno.h

 On Wed, Nov 12, 2014 at 2:34 PM, Martell Malone martellmal...@gmail.com
 wrote:

 Dongsheng Song
 Thank you for your suggested changes.

 I would like to note that my implementation was the exact same as the
 Macros apart from the _r in acrtime which I did change but somehow didn't
 end up in the attached patch due to caching or something heh
 The fact that these functions destroys the result of the previous
 calls mean that the Macros has a major bug in them.

 Should I also guard ctime_r and gmtime_r from NULL pointer arguments
 like this?

 +if (_Time == NULL || _Tm == NULL)
 +{
 +errno = EINVAL;
 +return NULL;
 +}

 Ktietz what is your take on the tread safeness of asctime_r
 I remember you recently telling me that MSDN was often incorrect
 As you implemented winpthreads you may be able to tell us :)

 If anyone needs me to address any more changes I'll be glad to
 Please Review for commit





 --
 Comprehensive Server Monitoring with Site24x7.
 Monitor 10 servers for $9/Month.
 Get alerted through email, SMS, voice calls or mobile push notifications.
 Take corrective actions from your mobile device.
 http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk
 ___
 Mingw-w64-public mailing list
 Mingw-w64-public@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


 --
 Comprehensive Server Monitoring with Site24x7.
 Monitor 10 servers for $9/Month.
 Get alerted through email, SMS, voice calls or mobile push notifications.
 Take corrective actions from your mobile device.
 http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk
 ___
 Mingw-w64-public mailing list
 Mingw-w64-public@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH] Remove the Macros of the time_r functions and replace them with actual functions

2014-11-11 Thread Martell Malone
Comments Suggestions and changes Welcome.

Kind Regards
Martell


0001-Remove-the-Macros-of-the-time_r-functions-and-replac.patch
Description: Binary data
--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Remove the Macros of the time_r functions and replace them with actual functions

2014-11-11 Thread Ray Donnelly
On Tue, Nov 11, 2014 at 2:02 PM, Dongsheng Song
dongsheng.s...@gmail.com wrote:
 I think you need add 1 line like this:

 TODO: real thread safe implementation.


Why? msvcrt is thread safe already.

 On Tue, Nov 11, 2014 at 8:15 PM, Martell Malone martellmal...@gmail.com 
 wrote:
 Comments Suggestions and changes Welcome.

 Kind Regards
 Martell

 --
 Comprehensive Server Monitoring with Site24x7.
 Monitor 10 servers for $9/Month.
 Get alerted through email, SMS, voice calls or mobile push notifications.
 Take corrective actions from your mobile device.
 http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk
 ___
 Mingw-w64-public mailing list
 Mingw-w64-public@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


 --
 Comprehensive Server Monitoring with Site24x7.
 Monitor 10 servers for $9/Month.
 Get alerted through email, SMS, voice calls or mobile push notifications.
 Take corrective actions from your mobile device.
 http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk
 ___
 Mingw-w64-public mailing list
 Mingw-w64-public@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Remove the Macros of the time_r functions and replace them with actual functions

2014-11-11 Thread Dongsheng Song
On Wed, Nov 12, 2014 at 12:24 AM, Ray Donnelly mingw.andr...@gmail.com
wrote:
 On Tue, Nov 11, 2014 at 2:02 PM, Dongsheng Song
 dongsheng.s...@gmail.com wrote:
 I think you need add 1 line like this:

 TODO: real thread safe implementation.


 Why? msvcrt is thread safe already.


MSDN not said asctime[1] is thread safe, it only said gmtime, mktime,
mkgmtime, and localtime [2] use one common tm structure per thread for the
conversion.

[1] http://msdn.microsoft.com/en-us/library/kys1801b.aspx
[2] http://msdn.microsoft.com/en-us/library/0z9czt0w.aspx

Then you can not assume asctime is thread safe.

*) typo

+char *__cdecl asctime(const struct tm *_Tm, char * _Str)
+{
+char *tmp = asctime(_Tm);
+if (tmp)
+tmp = strcpy(_Str,tmp);
+return tmp;
+}

should changed to:

+ /* TODO: thread safe implementation */
+char *__cdecl asctime_r(const struct tm *_Tm, char * _Str)
+{
+char *tmp;
+
+if (_Tm == NULL || _Str == NULL)
+{
+errno = EINVAL;
+return NULL;

+}
+
+tmp = asctime(_Tm);
+if (tmp != NULL)
+tmp = strcpy(_Str,tmp);
+
+return tmp;
+}

*) bad structure copy

+struct tm *__cdecl localtime_r(const time_t *_Time, struct tm *_Tm)
+{
+struct tm *tmp = localtime(_Time);
+if (tmp)
+*_Tm = *tmp;
+return tmp;
​​

​​
+}

should changed to:

+ /* Both the 32-bit and 64-bit versions of gmtime, mktime, mkgmtime,
+  * and localtime all use one common tm structure per thread for the
+  * conversion. Each call to one of these functions destroys the
+  * result of any previous call.
+  */
+struct tm *__cdecl localtime_r(const time_t *_Time, struct tm *_Tm)
+{
+struct tm *tmp;
+
+if (_Time == NULL || _Tm == NULL)
+{
+errno = EINVAL;
+return NULL;
+}
+
+tmp = localtime(_Time);
+if (tmp)
+memcpy(_Tm, tmp, sizeof(struct tm);
+return tmp;
​​
​+}​
--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111iu=/4140/ostg.clktrk___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public