Add S2US macro
This commit is contained in:
		
							parent
							
								
									9b45a111f1
								
							
						
					
					
						commit
						ed341dfca3
					
				
							
								
								
									
										2
									
								
								config.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								config.h
									
									
									
									
									
								
							| @ -12,7 +12,7 @@ struct settings defaults = { | ||||
| .lowfgcolor = "#000000", | ||||
| .format = "%s %b",         /* default format */ | ||||
| 
 | ||||
| .timeouts = { 10*G_USEC_PER_SEC, 10*G_USEC_PER_SEC, 0 }, /* low, normal, critical */ | ||||
| .timeouts = { S2US(10), S2US(10), S2US(0) }, /* low, normal, critical */ | ||||
| .icons = { "dialog-information", "dialog-information", "dialog-warning" }, /* low, normal, critical */ | ||||
| 
 | ||||
| .transparency = 0,           /* transparency */ | ||||
|  | ||||
| @ -156,7 +156,7 @@ int dunst_main(int argc, char *argv[]) | ||||
|                 n->summary = g_strdup("startup"); | ||||
|                 n->body = g_strdup("dunst is up and running"); | ||||
|                 n->progress = -1; | ||||
|                 n->timeout = 10 * G_USEC_PER_SEC; | ||||
|                 n->timeout = S2US(10); | ||||
|                 n->markup = MARKUP_NO; | ||||
|                 n->urgency = URG_LOW; | ||||
|                 notification_init(n); | ||||
|  | ||||
| @ -490,7 +490,7 @@ gint64 queues_get_next_datachange(gint64 time) | ||||
| 
 | ||||
|                         if (age > settings.show_age_threshold) | ||||
|                                 // sleep exactly until the next shift of the second happens
 | ||||
|                                 sleep = MIN(sleep, ((G_USEC_PER_SEC) - (age % (G_USEC_PER_SEC)))); | ||||
|                                 sleep = MIN(sleep, (S2US(1) - (age % S2US(1)))); | ||||
|                         else if (n->timeout == 0 || ttl > settings.show_age_threshold) | ||||
|                                 sleep = MIN(sleep, settings.show_age_threshold); | ||||
|                 } | ||||
|  | ||||
							
								
								
									
										13
									
								
								src/utils.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/utils.c
									
									
									
									
									
								
							| @ -170,7 +170,7 @@ gint64 string_to_time(const char *string) | ||||
|                 LOG_W("Time: '%s': Unknown error.", string); | ||||
|                 return 0; | ||||
|         } else if (errno == 0 && !*endptr) { | ||||
|                 return val * G_USEC_PER_SEC; | ||||
|                 return S2US(val); | ||||
|         } | ||||
| 
 | ||||
|         // endptr may point to a separating space
 | ||||
| @ -180,13 +180,13 @@ gint64 string_to_time(const char *string) | ||||
|         if (STRN_EQ(endptr, "ms", 2)) | ||||
|                 return val * 1000; | ||||
|         else if (STRN_EQ(endptr, "s", 1)) | ||||
|                 return val * G_USEC_PER_SEC; | ||||
|                 return S2US(val); | ||||
|         else if (STRN_EQ(endptr, "m", 1)) | ||||
|                 return val * G_USEC_PER_SEC * 60; | ||||
|                 return S2US(val) * 60; | ||||
|         else if (STRN_EQ(endptr, "h", 1)) | ||||
|                 return val * G_USEC_PER_SEC * 60 * 60; | ||||
|                 return S2US(val) * 60 * 60; | ||||
|         else if (STRN_EQ(endptr, "d", 1)) | ||||
|                 return val * G_USEC_PER_SEC * 60 * 60 * 24; | ||||
|                 return S2US(val) * 60 * 60 * 24; | ||||
|         else | ||||
|                 return 0; | ||||
| } | ||||
| @ -205,7 +205,6 @@ gint64 time_monotonic_now(void) | ||||
| #else | ||||
|         clock_gettime(CLOCK_MONOTONIC, &tv_now); | ||||
| #endif | ||||
|         return (gint64)tv_now.tv_sec  * G_USEC_PER_SEC | ||||
|                      + tv_now.tv_nsec / 1000; | ||||
|         return S2US(tv_now.tv_sec) + tv_now.tv_nsec / 1000; | ||||
| } | ||||
| /* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */ | ||||
|  | ||||
| @ -16,6 +16,9 @@ | ||||
| //! Test if string a and b are the same case-insensitively
 | ||||
| #define STR_CASEQ(a, b) (strcasecmp(a, b) == 0) | ||||
| 
 | ||||
| //! Convert a second into the internal time representation
 | ||||
| #define S2US(s) (((gint64)(s)) * 1000 * 1000) | ||||
| 
 | ||||
| /**
 | ||||
|  * Replaces all occurrences of the char \p needle with the char \p replacement in \p haystack. | ||||
|  * | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine