git-svn: trunk@3643
Török Edvin authored on 2008/02/16 05:45:51... | ... |
@@ -1,3 +1,10 @@ |
1 |
+Fri Feb 15 22:31:57 EET 2008 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * libclamav/others.[ch]: replace cli_dbgmsg with a macro that avoids calling |
|
4 |
+ the real function if we're not debugging. Statically |
|
5 |
+ predict this branch as untaken. |
|
6 |
+ * libclamav/upack.c, libclamav.map: update due to above change |
|
7 |
+ |
|
1 | 8 |
Fri Feb 15 18:24:22 CET 2008 (tk) |
2 | 9 |
--------------------------------- |
3 | 10 |
* clamd: delay the call to daemonize() (bb#839) |
... | ... |
@@ -117,11 +117,9 @@ void cli_errmsg(const char *str, ...) |
117 | 117 |
MSGCODE("LibClamAV Error: "); |
118 | 118 |
} |
119 | 119 |
|
120 |
-void cli_dbgmsg(const char *str, ...) |
|
120 |
+void cli_dbgmsg_internal(const char *str, ...) |
|
121 | 121 |
{ |
122 |
- if(cli_debug_flag) { |
|
123 |
- MSGCODE("LibClamAV debug: "); |
|
124 |
- } |
|
122 |
+ MSGCODE("LibClamAV debug: "); |
|
125 | 123 |
} |
126 | 124 |
|
127 | 125 |
#ifndef CLI_MEMFUNSONLY |
... | ... |
@@ -209,10 +209,20 @@ void cli_errmsg(const char *str, ...) __attribute__((format(printf, 1, 2))); |
209 | 209 |
void cli_errmsg(const char *str, ...); |
210 | 210 |
#endif |
211 | 211 |
|
212 |
+/* tell compiler about branches that are very rarely taken, |
|
213 |
+ * such as debug paths, and error paths */ |
|
214 |
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2) |
|
215 |
+#define UNLIKELY(cond) __builtin_expect(!!(cond), 0) |
|
216 |
+#else |
|
217 |
+#define UNLIKELY(cond) (cond) |
|
218 |
+#endif |
|
219 |
+ |
|
220 |
+#define cli_dbgmsg if(UNLIKELY(cli_debug_flag)) cli_dbgmsg_internal |
|
221 |
+ |
|
212 | 222 |
#ifdef __GNUC__ |
213 |
-void cli_dbgmsg(const char *str, ...) __attribute__((format(printf, 1, 2))); |
|
223 |
+void cli_dbgmsg_internal(const char *str, ...) __attribute__((format(printf, 1, 2))); |
|
214 | 224 |
#else |
215 |
-void cli_dbgmsg(const char *str, ...); |
|
225 |
+void cli_dbgmsg_internal(const char *str, ...); |
|
216 | 226 |
#endif |
217 | 227 |
|
218 | 228 |
void *cli_malloc(size_t nmemb); |
... | ... |
@@ -446,9 +446,10 @@ int unupack399(char *bs, uint32_t bl, uint32_t init_eax, char *init_ebx, uint32_ |
446 | 446 |
p.p2 = cli_readint32(init_ebx + 4); |
447 | 447 |
|
448 | 448 |
cli_dbgmsg("\n\tp0: %p\n\tp1: %08x\n\tp2: %08x\n", p.p0, p.p1, p.p2); |
449 |
- for (i = 0; i<6; i++) |
|
450 |
- state[i] = cli_readint32(loc_ebx + (i<<2)), |
|
449 |
+ for (i = 0; i<6; i++) { |
|
450 |
+ state[i] = cli_readint32(loc_ebx + (i<<2)); |
|
451 | 451 |
cli_dbgmsg("state[%d] = %08x\n", i, state[i]); |
452 |
+ } |
|
452 | 453 |
do { |
453 | 454 |
loc_eax = eax_copy; |
454 | 455 |
loc_edx = loc_ebx + (loc_eax<<2) + 0x58; |