Back to index

courier  0.68.2
nopthread.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2000-2001 Double Precision, Inc.  See COPYING for
00003 ** distribution information.
00004 */
00005 
00006 
00007 #include      "threadlib.h"
00008 
00009 #include      <stdio.h>
00010 #include      <errno.h>
00011 #include      <stdlib.h>
00012 #include      <unistd.h>
00013 
00014 typedef struct cthreadinfo cthreadinfo_t;
00015 
00016 
00017 cthreadinfo_t *cthread_init(unsigned nthreads_, unsigned metasize,
00018        void (*workfunc_)(void *),
00019        void (*cleanupfunc_)(void *))
00020 {
00021 cthreadinfo_t *cit;
00022 
00023        if ((cit=(cthreadinfo_t *)malloc(sizeof(cthreadinfo_t))) == 0)
00024               return (0);
00025 
00026        cit->cleanupfunc=cleanupfunc_;
00027        cit->workfunc=workfunc_;
00028 
00029        if ( (cit->metadata_buf=malloc(metasize)) == 0)
00030        {
00031               free( (char *)cit );
00032               return (0);
00033        }
00034        return (cit);
00035 }
00036 
00037 void cthread_wait(cthreadinfo_t *cit)
00038 {
00039        free(cit->metadata_buf);
00040        free( (char *)cit);
00041 }
00042 
00043 
00044 struct cthreadlock {
00045        int dummy;
00046        } ;
00047 
00048 struct cthreadlock cthread_dummy;