| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifndef eslSTACK_INCLUDED |
| 9 |
#define eslSTACK_INCLUDED |
| 10 |
#include <esl_config.h> |
| 11 |
|
| 12 |
#define ESL_STACK_INITALLOC 128 |
| 13 |
|
| 14 |
#ifdef HAVE_PTHREAD |
| 15 |
#include <pthread.h> |
| 16 |
#endif |
| 17 |
|
| 18 |
#include "esl_random.h" |
| 19 |
|
| 20 |
typedef struct esl_stack_s { |
| 21 |
int *idata; |
| 22 |
void **pdata; |
| 23 |
char *cdata; |
| 24 |
|
| 25 |
int n; |
| 26 |
int nalloc; |
| 27 |
|
| 28 |
#ifdef HAVE_PTHREAD |
| 29 |
int do_mutex; |
| 30 |
int do_cond; |
| 31 |
pthread_mutex_t *mutex; |
| 32 |
pthread_cond_t *cond; |
| 33 |
#endif |
| 34 |
} ESL_STACK; |
| 35 |
|
| 36 |
extern ESL_STACK *esl_stack_ICreate(void); |
| 37 |
extern ESL_STACK *esl_stack_CCreate(void); |
| 38 |
extern ESL_STACK *esl_stack_PCreate(void); |
| 39 |
|
| 40 |
extern int esl_stack_Reuse(ESL_STACK *s); |
| 41 |
extern void esl_stack_Destroy(ESL_STACK *s); |
| 42 |
|
| 43 |
extern int esl_stack_IPush(ESL_STACK *ns, int x); |
| 44 |
extern int esl_stack_CPush(ESL_STACK *cs, char c); |
| 45 |
extern int esl_stack_PPush(ESL_STACK *ps, void *p); |
| 46 |
|
| 47 |
extern int esl_stack_IPop(ESL_STACK *ns, int *ret_x); |
| 48 |
extern int esl_stack_CPop(ESL_STACK *cs, char *ret_c); |
| 49 |
extern int esl_stack_PPop(ESL_STACK *ps, void **ret_p); |
| 50 |
|
| 51 |
extern int esl_stack_ObjectCount(ESL_STACK *s); |
| 52 |
|
| 53 |
extern char *esl_stack_Convert2String(ESL_STACK *cs); |
| 54 |
extern int esl_stack_DiscardTopN(ESL_STACK *s, int n); |
| 55 |
extern int esl_stack_DiscardSelected(ESL_STACK *s, int (*discard_func)(void *, void *), void *param); |
| 56 |
|
| 57 |
extern int esl_stack_Shuffle(ESL_RANDOMNESS *r, ESL_STACK *s); |
| 58 |
|
| 59 |
#ifdef HAVE_PTHREAD |
| 60 |
extern int esl_stack_UseMutex (ESL_STACK *s); |
| 61 |
extern int esl_stack_UseCond (ESL_STACK *s); |
| 62 |
extern int esl_stack_ReleaseCond(ESL_STACK *s); |
| 63 |
#endif |
| 64 |
#endif |