mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	util/time: use int64_t return value for get_current_time_msec()
0xFFFFFFFF milliseconds is 4,294,967,295 ms so about 50 days. A little bit too close for comfort. Use int64_t instead of uint64_t to avoid C's implicit conversion footguns in computations.
This commit is contained in:
		
							parent
							
								
									fb4fb3bac2
								
							
						
					
					
						commit
						769cabbadf
					
				
					 2 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -6,7 +6,7 @@
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Get the current time, in milliseconds.
 | 
					 * Get the current time, in milliseconds.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
uint32_t get_current_time_msec(void);
 | 
					int64_t get_current_time_msec(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Convert a timespec to milliseconds.
 | 
					 * Convert a timespec to milliseconds.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,7 @@ void timespec_from_nsec(struct timespec *r, int64_t nsec) {
 | 
				
			||||||
	r->tv_nsec = nsec % NSEC_PER_SEC;
 | 
						r->tv_nsec = nsec % NSEC_PER_SEC;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t get_current_time_msec(void) {
 | 
					int64_t get_current_time_msec(void) {
 | 
				
			||||||
	struct timespec now;
 | 
						struct timespec now;
 | 
				
			||||||
	clock_gettime(CLOCK_MONOTONIC, &now);
 | 
						clock_gettime(CLOCK_MONOTONIC, &now);
 | 
				
			||||||
	return timespec_to_msec(&now);
 | 
						return timespec_to_msec(&now);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue