File: nopthread.c

package info (click to toggle)
courier 0.47-4sarge5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 32,680 kB
  • ctags: 12,265
  • sloc: ansic: 164,045; cpp: 23,863; sh: 19,569; perl: 7,225; makefile: 4,192; yacc: 316; sed: 16
file content (49 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (5)
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
49
/*
** Copyright 2000-2001 Double Precision, Inc.  See COPYING for
** distribution information.
*/

static const char rcsid[]="$Id: nopthread.c,v 1.2 2001/07/30 00:06:09 mrsam Exp $";

#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;