thr_condattr_init.c revision 49439
1275970Scy/*
2275970Scy * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>
3275970Scy * All rights reserved.
4275970Scy *
5275970Scy * Redistribution and use in source and binary forms, with or without
6275970Scy * modification, are permitted provided that the following conditions
7275970Scy * are met:
8275970Scy * 1. Redistributions of source code must retain the above copyright
9275970Scy *    notice, this list of conditions and the following disclaimer.
10275970Scy * 2. Redistributions in binary form must reproduce the above copyright
11275970Scy *    notice, this list of conditions and the following disclaimer in the
12275970Scy *    documentation and/or other materials provided with the distribution.
13275970Scy * 3. All advertising materials mentioning features or use of this software
14275970Scy *    must display the following acknowledgement:
15275970Scy *	This product includes software developed by John Birrell.
16275970Scy * 4. Neither the name of the author nor the names of any co-contributors
17275970Scy *    may be used to endorse or promote products derived from this software
18275970Scy *    without specific prior written permission.
19275970Scy *
20275970Scy * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
21275970Scy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22275970Scy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23275970Scy * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24275970Scy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25275970Scy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26275970Scy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27275970Scy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28275970Scy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29275970Scy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30275970Scy * SUCH DAMAGE.
31275970Scy *
32275970Scy * $Id$
33275970Scy */
34275970Scy#include <string.h>
35275970Scy#include <stdlib.h>
36275970Scy#include <errno.h>
37275970Scy#ifdef _THREAD_SAFE
38275970Scy#include <pthread.h>
39275970Scy#include "pthread_private.h"
40275970Scy
41275970Scyint
42275970Scypthread_condattr_init(pthread_condattr_t *attr)
43275970Scy{
44275970Scy	int ret;
45275970Scy	pthread_condattr_t pattr;
46275970Scy
47275970Scy	if ((pattr = (pthread_condattr_t)
48275970Scy			malloc(sizeof(struct pthread_cond_attr))) == NULL) {
49275970Scy		ret = ENOMEM;
50275970Scy	} else {
51275970Scy		memcpy(pattr, &pthread_condattr_default,
52275970Scy				sizeof(struct pthread_cond_attr));
53275970Scy		*attr = pattr;
54275970Scy		ret = 0;
55275970Scy	}
56275970Scy	return(ret);
57275970Scy}
58275970Scy#endif
59275970Scy