Changeset 138 for trunk/include
- Timestamp:
- Oct 28, 2007, 4:55:19 PM (17 years ago)
- Location:
- trunk/include
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/samhain.h
r133 r138 43 43 #define SH_PATHBUF 256 44 44 45 #define SH_GRBUF_SIZE 409646 #define SH_PWBUF_SIZE 409647 45 #define SH_ERRBUF_SIZE 64 48 46 -
trunk/include/sh_files.h
r131 r138 30 30 void kill_sh_dirlist (struct sh_dirent * dirlist); 31 31 32 #ifdef NEED_ADD_DIRENT 32 33 /* add an entry to a directory listing 33 34 */ 34 35 struct sh_dirent * addto_sh_dirlist (struct dirent * thisEntry, 35 36 struct sh_dirent * dirlist); 37 #endif 38 36 39 /* register exceptions to hardlink check 37 40 */ -
trunk/include/sh_pthread.h
r134 r138 5 5 6 6 #include <pthread.h> 7 7 8 #define SH_MUTEX(M) pthread_mutex_t M 8 9 #define SH_MUTEX_INIT(M,I) pthread_mutex_t M = I … … 10 11 #define SH_MUTEX_EXTERN(M) extern pthread_mutex_t M 11 12 13 /* pthread_mutex_unlock() has the wrong type (returns int), so 14 * we need to wrap it in this function. 15 */ 16 extern void sh_pthread_mutex_unlock (void *arg); 17 12 18 #define SH_MUTEX_LOCK(M) \ 13 19 do { \ 14 20 int oldtype; \ 15 21 pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); \ 16 pthread_cleanup_push( pthread_mutex_unlock, (void *) &(M));\22 pthread_cleanup_push(sh_pthread_mutex_unlock, (void*)&(M));\ 17 23 pthread_mutex_lock(&(M)) 18 24 19 25 20 #define SH_MUTEX_UNLOCK(M ,C) \26 #define SH_MUTEX_UNLOCK(M) \ 21 27 pthread_cleanup_pop(1); \ 22 28 pthread_setcanceltype(oldtype, NULL); \ … … 26 32 #define SH_MUTEX_UNLOCK_UNSAFE(M) pthread_mutex_unlock(&(M)) 27 33 34 35 /* 36 * ---- Recursive mutex ---- 37 */ 38 #if defined(PTHREAD_MUTEX_RECURSIVE) 39 40 /* On GNU C, it's an enum, thus the alternative implementation 41 * below is used. 42 */ 43 #define SH_MUTEX_RECURSIVE(M) \ 44 static pthread_mutex_t M; \ 45 static void M ## _init (void) \ 46 { \ 47 pthread_mutexattr_t mta; \ 48 pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); \ 49 pthread_mutex_init(&(M), &mta); \ 50 pthread_mutexattr_destroy(&mta); \ 51 return; \ 52 } \ 53 static pthread_once_t M ## _initialized = PTHREAD_ONCE_INIT 54 55 #define SH_MUTEX_RECURSIVE_INIT(M) \ 56 (void) pthread_once(&(M ## _initialized), (M ## _init)) 57 58 #define SH_MUTEX_RECURSIVE_LOCK(M) \ 59 do { \ 60 int oldtype; \ 61 pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); \ 62 pthread_cleanup_push(sh_pthread_mutex_unlock, (void*)&(M));\ 63 pthread_mutex_lock(&(M)) 64 65 #define SH_MUTEX_RECURSIVE_UNLOCK(M) \ 66 pthread_cleanup_pop(1); \ 67 pthread_setcanceltype(oldtype, NULL); \ 68 } while (0) 69 70 #else 71 /* !defined(PTHREAD_MUTEX_RECURSIVE) */ 72 struct sh_RMutex { 73 74 pthread_mutex_t lock; 75 unsigned int held; 76 unsigned int waiters; 77 pthread_t tid; 78 pthread_cond_t cv; 79 }; 80 81 void sh_RMutexLock(struct sh_RMutex * tok); 82 void sh_RMutexUnlock(void * arg); 83 void sh_InitRMutex(struct sh_RMutex * tok); 84 85 #define SH_MUTEX_RECURSIVE(M) \ 86 static struct sh_RMutex M; \ 87 static void M ## _init (void) \ 88 { \ 89 sh_InitRMutex(&(M)); \ 90 return; \ 91 } \ 92 static pthread_once_t M ## _initialized = PTHREAD_ONCE_INIT 93 94 #define SH_MUTEX_RECURSIVE_INIT(M) \ 95 (void) pthread_once(&(M ## _initialized), (M ## _init)) 96 97 #define SH_MUTEX_RECURSIVE_LOCK(M) \ 98 do { \ 99 int oldtype; \ 100 pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); \ 101 pthread_cleanup_push(sh_RMutexUnlock, (void*)&(M)); \ 102 sh_RMutexLock(&(M)) 103 104 #define SH_MUTEX_RECURSIVE_UNLOCK(M) \ 105 pthread_cleanup_pop(1); \ 106 pthread_setcanceltype(oldtype, NULL); \ 107 } while (0) 108 109 #endif 28 110 /* 29 111 * ---- Global mutexes ---- … … 32 114 SH_MUTEX_EXTERN(mutex_resolv); 33 115 SH_MUTEX_EXTERN(mutex_pwent); 116 SH_MUTEX_EXTERN(mutex_readdir); 34 117 35 118 /* … … 49 132 #define SH_MUTEX_UNLOCK_UNSAFE(M) ((void)0) 50 133 134 #define SH_MUTEX_RECURSIVE(M) extern void *SH_MUTEX_DUMMY_ ## M 135 #define SH_MUTEX_RECURSIVE_INIT(M) ((void)0) 136 #define SH_MUTEX_RECURSIVE_LOCK(M) ((void)0) 137 #define SH_MUTEX_RECURSIVE_UNLOCK(M) ((void)0) 138 51 139 /* #ifdef HAVE_PTHREAD */ 52 140 #endif -
trunk/include/sh_tiger.h
r133 r138 9 9 typedef long int TigerType; 10 10 11 #define TIGER_FILE -1 ;12 #define TIGER_DATA -2 ;11 #define TIGER_FILE -1 12 #define TIGER_DATA -2 13 13 14 14 /**************** 15 typedef long int TigerType; 15 16 typedef enum { 16 17 TIGER_FILE, … … 24 25 /* the checksum function 25 26 */ 26 /*@owned@*/char * sh_tiger_hash (const char * filename, TigerType what,27 27 char * sh_tiger_hash (const char * filename, TigerType what, 28 UINT64 Length, char * out, size_t len); 28 29 29 30 /* NEW Thu Oct 18 19:59:08 CEST 2001 -
trunk/include/sh_utils.h
r132 r138 58 58 * generator. 59 59 */ 60 UINT32 taus_get ( void *state1, void *state2, void *state3);60 UINT32 taus_get (); 61 61 double taus_get_double (void *vstate); /* fast */ 62 62 int taus_seed (void); … … 85 85 */ 86 86 char * sh_util_siggen (char * hexkey, 87 char * text, size_t textlen); 87 char * text, size_t textlen, 88 char * sigbuf, size_t sigbuflen); 88 89 89 90 /* eval boolean input … … 112 113 int sh_util_obscure_ok (const char * str); 113 114 114 /* output a hexchar[2] 115 /* output a hexchar[2]; i2h must be char[2] 115 116 */ 116 char * sh_util_charhex( unsigned char c );117 char * sh_util_charhex( unsigned char c, char * i2h ); 117 118 118 119 /* read a hexchar, return int value (0-15) -
trunk/include/slib.h
r131 r138 60 60 #define SL_FALSE 0 61 61 62 #define SH_GRBUF_SIZE 4096 63 #define SH_PWBUF_SIZE 4096 62 64 63 65
Note:
See TracChangeset
for help on using the changeset viewer.