Logo Search packages:      
Sourcecode: lbzip2 version File versions  Download package

main.h

/* main.h,v 1.11 2009-10-19 22:49:23 lacos Exp */

#ifndef MAIN_H
#  define MAIN_H

#  include <limits.h>  /* CHAR_BIT */
#  include <stddef.h>  /* size_t */
#  include <pthread.h> /* pthread_mutex_t */

#  if 8 != CHAR_BIT
#    error "Environments where 8 != CHAR_BIT are not supported."
#  endif


extern const char *pname;
extern void *(*mallocf)(size_t size);
extern void (*freef)(void *ptr);
extern void *(*lbzallocf)(void *ignored, int n, int m);
extern void (*lbzfreef)(void *ignored, void *ptr);


struct cond
{
  pthread_mutex_t lock; /* Lock this to protect shared resource. */
  pthread_cond_t cond;  /* Trigger this if predicate becomes true. */
  long unsigned ccount, /* Increment this when checking predicate. */
      wcount;           /* Increment this when waiting is necessary. */
};


/* Terminate the process with EXIT_FAILURE. */
void
fatal(void);

/* Format operation and append resolved error, then call fatal(). */
void
fail(const char *fmt, int err, ...)
#ifdef __GNUC__
__attribute__((format(printf, 1, 3)))
#endif
;

/* If these primitives fail, they call fail(), which in turn calls fatal(). */
void *
xalloc(size_t size);

void
xinit(struct cond *cond);

void
xdestroy(struct cond *cond);

void
xlock(struct cond *cond);

void
xlock_pred(struct cond *cond);

void
xunlock(struct cond *cond);

void
xwait(struct cond *cond);

void
xsignal(struct cond *cond);

void
xbroadcast(struct cond *cond);

void
xcreate(pthread_t *thread, void *(*routine)(void *), void *arg);

void
xjoin(pthread_t thread);

void
xraise(int sig);

#endif

Generated by  Doxygen 1.6.0   Back to index