blob: 59cea1337f957cfe50cc020690e2e53974d7eeca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*
** Copyright 2000-2001 Double Precision, Inc. See COPYING for
** distribution information.
*/
#include "threadlib.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
typedef struct cthreadinfo cthreadinfo_t;
cthreadinfo_t *cthread_init(unsigned nthreads_, unsigned metasize,
void (*workfunc_)(void *),
void (*cleanupfunc_)(void *))
{
cthreadinfo_t *cit;
if ((cit=(cthreadinfo_t *)malloc(sizeof(cthreadinfo_t))) == 0)
return (0);
cit->cleanupfunc=cleanupfunc_;
cit->workfunc=workfunc_;
if ( (cit->metadata_buf=malloc(metasize)) == 0)
{
free( (char *)cit );
return (0);
}
return (cit);
}
void cthread_wait(cthreadinfo_t *cit)
{
free(cit->metadata_buf);
free( (char *)cit);
}
struct cthreadlock {
int dummy;
} ;
struct cthreadlock cthread_dummy;
|