]> mj.ucw.cz Git - libucw.git/blobdiff - lib/profile.h
Another thing about the C standard I didn't know: passing a va_list to
[libucw.git] / lib / profile.h
index 8acb34abc30eefd4eff1c426775fbde630f526c7..c3c29df1faf6a7e2377813fd93b43a62c86b5da1 100644 (file)
@@ -1,7 +1,10 @@
 /*
- *     Sherlock Library -- Poor Man's Profiler
+ *     UCW Library -- Poor Man's Profiler
  *
  *     (c) 2001 Martin Mares <mj@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
 /*
  *             prof_start(&cnt);
  *             ...
  *             prof_stop(&cnt);
- *             printf("%s\n", PROF_STRING(&cnt));
+ *             printf("%s\n", PROF_STR(cnt));
  */
 
-#include <string.h>
-
 /* PROFILE_TOD: gettimeofday() profiler */
 
 struct prof_tod {
@@ -122,7 +123,7 @@ typedef struct prof_ktsc prof_t;
 static inline void prof_start(prof_t *c) { prof_switch(NULL, c); }
 static inline void prof_stop(prof_t *c) { prof_switch(c, NULL); }
 #endif
-#define PROF_STR(c) ({ static byte _x[PROF_STR_SIZE]; prof_format(_x, &(C)); _x })
+#define PROF_STR(C) ({ static byte _x[PROF_STR_SIZE]; prof_format(_x, &(C)); _x; })
 
 #else
 
@@ -132,7 +133,8 @@ static inline void prof_init(prof_t *c UNUSED) { }
 static inline void prof_start(prof_t *c UNUSED) { }
 static inline void prof_stop(prof_t *c UNUSED) { }
 static inline void prof_switch(prof_t *c UNUSED, prof_t *d UNUSED) { }
-static inline void prof_format(char *b, prof_t *c UNUSED) { strcpy(b, "?"); }
+static inline void prof_format(char *b, prof_t *c UNUSED) { b[0]='?'; b[1]=0; }
 #define PROF_STR_SIZE 2
+#define PROF_STR(C) "?"
 
 #endif