mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:32:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			697 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			697 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| namespace AK {
 | |
| 
 | |
| template<typename TimevalType>
 | |
| inline void timeval_sub(const TimevalType& a, const TimevalType& b, TimevalType& result)
 | |
| {
 | |
|     result.tv_sec = a.tv_sec - b.tv_sec;
 | |
|     result.tv_usec = a.tv_usec - b.tv_usec;
 | |
|     if (result.tv_usec < 0) {
 | |
|         --result.tv_sec;
 | |
|         result.tv_usec += 1000000;
 | |
|     }
 | |
| }
 | |
| 
 | |
| template<typename TimevalType>
 | |
| inline void timeval_add(const TimevalType& a, const TimevalType& b, TimevalType& result)
 | |
| {
 | |
|     result.tv_sec = a.tv_sec + b.tv_sec;
 | |
|     result.tv_usec = a.tv_usec + b.tv_usec;
 | |
|     if (result.tv_usec > 1000000) {
 | |
|         ++result.tv_sec;
 | |
|         result.tv_usec -= 1000000;
 | |
|     }
 | |
| }
 | |
| 
 | |
| }
 | |
| 
 | |
| using AK::timeval_add;
 | |
| using AK::timeval_sub;
 | 
