00001
#ifndef MNTHREAD_H
00002
#define MNTHREAD_H
00003
00004
#include <config.h>
00005
#include <sys/types.h>
00006
#include <unistd.h>
00007
00008
#ifdef HAVE_LIBPTH
00009
#include <pth.h>
00010 typedef pth_t
mnthread_t;
00011 typedef pth_attr_t
mnthread_attr_t;
00012 typedef pth_mutex_t
mnthread_mutex_t;
00013 typedef int mnthread_mutexattr_t;
00014 typedef pth_cond_t
mnthread_cond_t;
00015 typedef int mnthread_condattr_t;
00016
#else
00017
#include <pthread.h>
00018
typedef pthread_t
mnthread_t;
00019
typedef pthread_attr_t
mnthread_attr_t;
00020
typedef pthread_mutex_t
mnthread_mutex_t;
00021
typedef pthread_mutexattr_t
mnthread_mutexattr_t;
00022
typedef pthread_cond_t
mnthread_cond_t;
00023
typedef pthread_condattr_t
mnthread_condattr_t;
00024
#endif
00025
00026
void mnthread_lib_init( );
00027
00028
00029
00030
00031
00032 pid_t
mn_fork();
00033
00034
00035
00036
00037
00038
int mnthread_create( mnthread_t* th,
00039 mnthread_attr_t *attr,
00040
void* (*start_routine)(
void*),
00041
void* arg );
00042
void mnthread_exit(
void* value );
00043
int mnthread_join( mnthread_t th,
void** value );
00044
mnthread_t mnthread_self( );
00045
bool mnthread_equal( mnthread_t thl, mnthread_t thr );
00046
00047
00048
00049
00050
00051
int mnthread_attr_init( mnthread_attr_t* attr );
00052
int mnthread_attr_set_detach( mnthread_attr_t* attr );
00053
int mnthread_attr_destroy( mnthread_attr_t* attr );
00054
00055
00056
00057
00058
00059
int mnthread_mutex_init( mnthread_mutex_t* mx, mnthread_mutexattr_t* attr );
00060
int mnthread_mutex_lock( mnthread_mutex_t *mx );
00061
int mnthread_mutex_trylock( mnthread_mutex_t *mx );
00062
int mnthread_mutex_unlock( mnthread_mutex_t *mx );
00063
int mnthread_mutex_destroy( mnthread_mutex_t *mx );
00064
int mnthread_mutexattr_init( mnthread_mutexattr_t *attr );
00065
int mnthread_mutexattr_destroy( mnthread_mutexattr_t *attr );
00066
00067
00068
00069
00070
00071
int mnthread_cond_init( mnthread_cond_t *cond, mnthread_condattr_t *cond_attr );
00072
int mnthread_cond_signal( mnthread_cond_t *cond );
00073
int mnthread_cond_broadcast( mnthread_cond_t *cond );
00074
int mnthread_cond_wait( mnthread_cond_t *cond, mnthread_mutex_t *mutex );
00075
int mnthread_cond_timedwait( mnthread_cond_t *cond,
00076 mnthread_mutex_t *mutex,
00077
const struct timespec *abstime );
00078
int mnthread_cond_destroy( mnthread_cond_t *cond );
00079
int mnthread_condattr_init( mnthread_condattr_t *attr );
00080
int mnthread_condattr_destroy( mnthread_condattr_t *attr );
00081
00082
#endif
00083