ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.67 by root, Fri Apr 11 21:09:53 2008 UTC vs.
Revision 1.68 by root, Tue Apr 15 03:16:02 2008 UTC

21 21
22#ifndef UTIL_H__ 22#ifndef UTIL_H__
23#define UTIL_H__ 23#define UTIL_H__
24 24
25#define DEBUG_SALLOC 0 25#define DEBUG_SALLOC 0
26#define PREFER_MALLOC 0 26#define PREFER_MALLOC 1
27 27
28#if __GNUC__ >= 3 28#if __GNUC__ >= 3
29# define is_constant(c) __builtin_constant_p (c) 29# define is_constant(c) __builtin_constant_p (c)
30# define expect(expr,value) __builtin_expect ((expr),(value)) 30# define expect(expr,value) __builtin_expect ((expr),(value))
31# define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) 31# define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality)
65void *g_slice_alloc0 (unsigned long size); 65void *g_slice_alloc0 (unsigned long size);
66void g_slice_free1 (unsigned long size, void *ptr); 66void g_slice_free1 (unsigned long size, void *ptr);
67#elif PREFER_MALLOC 67#elif PREFER_MALLOC
68# define g_slice_alloc0(s) calloc (1, (s)) 68# define g_slice_alloc0(s) calloc (1, (s))
69# define g_slice_alloc(s) malloc ((s)) 69# define g_slice_alloc(s) malloc ((s))
70# define g_slice_free1(s,p) free ((s)) 70# define g_slice_free1(s,p) free ((p))
71#endif 71#endif
72 72
73// use C0X decltype for auto declarations until ISO C++ sanctifies them (if ever) 73// use C0X decltype for auto declarations until ISO C++ sanctifies them (if ever)
74#define auto(var,expr) decltype(expr) var = (expr) 74#define auto(var,expr) decltype(expr) var = (expr)
75 75
606#else 606#else
607 #define SMUTEX_INITIALISER PTHREAD_MUTEX_INITIALIZER 607 #define SMUTEX_INITIALISER PTHREAD_MUTEX_INITIALIZER
608#endif 608#endif
609 609
610#define SMUTEX(name) smutex name = SMUTEX_INITIALISER 610#define SMUTEX(name) smutex name = SMUTEX_INITIALISER
611#define SMUTEX_LOCK(name) pthread_mutex_lock (&(name)) 611#define SMUTEX_LOCK(name) pthread_mutex_lock (&(name))
612#define SMUTEX_UNLOCK(name) pthread_mutex_unlock (&(name)) 612#define SMUTEX_UNLOCK(name) pthread_mutex_unlock (&(name))
613 613
614typedef pthread_cond_t scond;
615
616#define SCOND(name) scond name = PTHREAD_COND_INITIALIZER
617#define SCOND_SIGNAL(name) pthread_cond_signal (&(name))
618#define SCOND_BROADCAST(name) pthread_cond_broadcast (&(name))
619#define SCOND_WAIT(name,mutex) pthread_cond_wait (&(name), &(mutex))
620
614#endif 621#endif
615 622

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines