mirror of
				https://github.com/albfan/miraclecast.git
				synced 2025-03-09 23:38:56 +00:00 
			
		
		
		
	miracle: add now() helper
This returns the current time in usec since EPOCH depending on the clock-time. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
		
							parent
							
								
									3db84c3822
								
							
						
					
					
						commit
						77aae60c52
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
					@ -31,7 +31,9 @@
 | 
				
			||||||
#include <stdbool.h>
 | 
					#include <stdbool.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
 | 
					#include <sys/time.h>
 | 
				
			||||||
#include <systemd/sd-bus.h>
 | 
					#include <systemd/sd-bus.h>
 | 
				
			||||||
 | 
					#include <time.h>
 | 
				
			||||||
#include "shl_log.h"
 | 
					#include "shl_log.h"
 | 
				
			||||||
#include "shl_macro.h"
 | 
					#include "shl_macro.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -116,4 +118,14 @@ static inline int bus_message_read_basic_variant(sd_bus_message *m,
 | 
				
			||||||
		_l; \
 | 
							_l; \
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline int64_t now(clockid_t clock_id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct timespec ts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						clock_gettime(clock_id, &ts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return (int64_t)ts.tv_sec * 1000000LL +
 | 
				
			||||||
 | 
						       (int64_t)ts.tv_nsec / 1000LL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* MIRACLE_H */
 | 
					#endif /* MIRACLE_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue