mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 01:37:31 +03:00 
			
		
		
		
	Win32 *time_r fix
Fixed the thread safetyness of the Windows *time_r functions.
This commit is contained in:
		
							parent
							
								
									d601ab8239
								
							
						
					
					
						commit
						c79d20855a
					
				| 
						 | 
					@ -119,16 +119,9 @@ static int pthread_mutex_init(pthread_mutex_t *mutex, void* fake)
 | 
				
			||||||
/* to work around the fact that Windows does not have a gmtime_r function, or
 | 
					/* to work around the fact that Windows does not have a gmtime_r function, or
 | 
				
			||||||
   a proper gmtime function */
 | 
					   a proper gmtime function */
 | 
				
			||||||
#ifdef _WIN32
 | 
					#ifdef _WIN32
 | 
				
			||||||
static struct tm *gmtime_r(time_t *t, struct tm *tm)
 | 
					#define gmtime_r(t, tm) (gmtime(t)?memcpy((tm), gmtime(t), sizeof(*(tm))):NULL)
 | 
				
			||||||
{
 | 
					#define localtime_r(t, tm) (localtime(t)?memcpy((tm), localtime(t), sizeof(*(tm))):NULL)
 | 
				
			||||||
  tm = gmtime(t);
 | 
					
 | 
				
			||||||
  return tm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
static struct tm *localtime_r(time_t *t, struct tm *tm)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  tm = localtime(t);
 | 
					 | 
				
			||||||
  return tm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/* remove the inline keyword, since it doesn't work unless C++ file */
 | 
					/* remove the inline keyword, since it doesn't work unless C++ file */
 | 
				
			||||||
#define inline
 | 
					#define inline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user