From 10f6a232d008b24c6fe0f45f5d0d731c99583189 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Wed, 21 Mar 2012 21:10:59 +0000 Subject: [PATCH] Move GetTimeMs/Us() to time.c. SVN revision: 69545 --- src/Makefile.am | 1 + src/groups.c | 1 - src/icccm.c | 3 +-- src/misc.c | 3 +-- src/time.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ src/timers.c | 43 +------------------------------- src/timers.h | 5 +--- src/util.h | 5 +++- 8 files changed, 74 insertions(+), 52 deletions(-) create mode 100644 src/time.c diff --git a/src/Makefile.am b/src/Makefile.am index 7fc43b1d..bee4e702 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,6 +104,7 @@ e16_SOURCES = \ tclass.c tclass.h \ text.c \ theme.c \ + time.c \ timers.c timers.h \ tooltips.c tooltips.h \ user.c user.h \ diff --git a/src/groups.c b/src/groups.c index 2bb9adb6..5adb8c8c 100644 --- a/src/groups.c +++ b/src/groups.c @@ -30,7 +30,6 @@ #include "groups.h" #include "settings.h" #include "snaps.h" -#include "timers.h" #define DEBUG_GROUPS 0 #if DEBUG_GROUPS diff --git a/src/icccm.c b/src/icccm.c index 7066645d..a7d4ab1b 100644 --- a/src/icccm.c +++ b/src/icccm.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2011 Kim Woelders + * Copyright (C) 2004-2012 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -30,7 +30,6 @@ #include "xwin.h" #include #if USE_XSYNC -#include "timers.h" #include #endif diff --git a/src/misc.c b/src/misc.c index a0a0d219..53b835bb 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2011 Kim Woelders + * Copyright (C) 2004-2012 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -24,7 +24,6 @@ #include "E.h" #include "eobj.h" #include "xwin.h" -#include "timers.h" #include #include diff --git a/src/time.c b/src/time.c new file mode 100644 index 00000000..f83a9860 --- /dev/null +++ b/src/time.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011-2012 Kim Woelders + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include "config.h" +#if USE_MONOTONIC_CLOCK +#include +#else +#include +#endif +#include "util.h" + +unsigned int +GetTimeMs(void) +{ +#if USE_MONOTONIC_CLOCK + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC, &ts); + + return (unsigned int)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000); +#else + struct timeval timev; + + gettimeofday(&timev, NULL); + + return (unsigned int)(timev.tv_sec * 1000 + timev.tv_usec / 1000); +#endif +} + +unsigned int +GetTimeUs(void) +{ +#if USE_MONOTONIC_CLOCK + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC, &ts); + + return (unsigned int)(ts.tv_sec * 1000000 + ts.tv_nsec / 1000); +#else + struct timeval timev; + + gettimeofday(&timev, NULL); + + return (unsigned int)(timev.tv_sec * 1000000 + timev.tv_usec); +#endif +} diff --git a/src/timers.c b/src/timers.c index 12ce7d2d..c6a40c1d 100644 --- a/src/timers.c +++ b/src/timers.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2006-2011 Kim Woelders + * Copyright (C) 2006-2012 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -24,11 +24,6 @@ #include "E.h" #include "e16-ecore_list.h" #include "timers.h" -#if USE_MONOTONIC_CLOCK -#include -#else -#include -#endif #define DEBUG_TIMERS 0 @@ -41,42 +36,6 @@ struct _timer { char again; }; -unsigned int -GetTimeMs(void) -{ -#if USE_MONOTONIC_CLOCK - struct timespec ts; - - clock_gettime(CLOCK_MONOTONIC, &ts); - - return (unsigned int)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000); -#else - struct timeval timev; - - gettimeofday(&timev, NULL); - - return (unsigned int)(timev.tv_sec * 1000 + timev.tv_usec / 1000); -#endif -} - -unsigned int -GetTimeUs(void) -{ -#if USE_MONOTONIC_CLOCK - struct timespec ts; - - clock_gettime(CLOCK_MONOTONIC, &ts); - - return (unsigned int)(ts.tv_sec * 1000000 + ts.tv_nsec / 1000); -#else - struct timeval timev; - - gettimeofday(&timev, NULL); - - return (unsigned int)(timev.tv_sec * 1000000 + timev.tv_usec); -#endif -} - static int tdiff(unsigned int t1, unsigned int t2) { diff --git a/src/timers.h b/src/timers.h index 9fa16fcc..20d81670 100644 --- a/src/timers.h +++ b/src/timers.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2011 Kim Woelders + * Copyright (C) 2004-2012 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -26,9 +26,6 @@ #include "etypes.h" -unsigned int GetTimeMs(void); -unsigned int GetTimeUs(void); - Timer *TimerAdd(int dt_ms, int (*func) (void *data), void *data); void TimerDel(Timer * timer); void TimerSetInterval(Timer * timer, int dt_ms); diff --git a/src/util.h b/src/util.h index d0b2303c..8ace7aa8 100644 --- a/src/util.h +++ b/src/util.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2008 Kim Woelders + * Copyright (C) 2004-2012 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -131,4 +131,7 @@ const void *ModLoadSym(const char *lib, const char *sym, const char *name); #endif +unsigned int GetTimeMs(void); +unsigned int GetTimeUs(void); + #endif /* _UTIL_H_ */