Browse code

support building without pthreads (#1897).

Török Edvin authored on 2010/05/07 16:07:48
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri May  7 10:07:24 EEST 2010 (edwin)
2
+-------------------------------------
3
+ * libclamav/cache.c: support building without pthreads (bb #1897).
4
+
1 5
 Fri May  7 09:56:57 EEST 2010 (edwin)
2 6
 -------------------------------------
3 7
  * libclamav/bytecode*: add match_offsets support.
... ...
@@ -158,7 +158,14 @@ static inline void lru_addtail(struct cache_set *map, struct cache_key *newkey)
158 158
     map->lru_tail = newkey;
159 159
 }
160 160
 
161
+#ifdef CL_THREAD_SAFE
161 162
 static pthread_mutex_t pool_mutex = PTHREAD_MUTEX_INITIALIZER;
163
+#else
164
+#define pthread_mutex_lock(x) 0
165
+#define pthread_mutex_unlock(x)
166
+#define pthread_mutex_init(a, b) 0
167
+#define pthread_mutex_destroy do { } while(0)
168
+#endif
162 169
 
163 170
 static void cacheset_add(struct cache_set *map, unsigned char *md5, size_t size, mpool_t *mempool);
164 171
 static int cacheset_init(struct cache_set *map, mpool_t *mempool);
... ...
@@ -575,7 +582,9 @@ static inline void cacheset_add(struct cache_set *cs, unsigned char *md5, size_t
575 575
 
576 576
 struct CACHE {
577 577
     struct cache_set cacheset;
578
+#ifdef CL_THREAD_SAFE
578 579
     pthread_mutex_t mutex;
580
+#endif
579 581
 };
580 582
 
581 583
 /* Allocates the trees for the engine cache */