thr_attr_init.c revision 49439
117706Sjulian/* 217706Sjulian * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. 317706Sjulian * All rights reserved. 417706Sjulian * 517706Sjulian * Redistribution and use in source and binary forms, with or without 617706Sjulian * modification, are permitted provided that the following conditions 717706Sjulian * are met: 817706Sjulian * 1. Redistributions of source code must retain the above copyright 917706Sjulian * notice, this list of conditions and the following disclaimer. 1017706Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1117706Sjulian * notice, this list of conditions and the following disclaimer in the 1217706Sjulian * documentation and/or other materials provided with the distribution. 1317706Sjulian * 3. All advertising materials mentioning features or use of this software 1417706Sjulian * must display the following acknowledgement: 1517706Sjulian * This product includes software developed by John Birrell. 1617706Sjulian * 4. Neither the name of the author nor the names of any co-contributors 1717706Sjulian * may be used to endorse or promote products derived from this software 1817706Sjulian * without specific prior written permission. 1917706Sjulian * 2017706Sjulian * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 2117706Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2217706Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2349439Sdeischen * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2417706Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2517706Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2617706Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2717706Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2817706Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2917706Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3017706Sjulian * SUCH DAMAGE. 3117706Sjulian * 3249439Sdeischen * $Id$ 3317706Sjulian */ 3417706Sjulian#include <string.h> 3517706Sjulian#include <stdlib.h> 3617706Sjulian#include <errno.h> 3717706Sjulian#ifdef _THREAD_SAFE 3817706Sjulian#include <pthread.h> 3917706Sjulian#include "pthread_private.h" 4017706Sjulian 4117706Sjulianint pthread_attr_init(pthread_attr_t *attr) 4217706Sjulian{ 4317706Sjulian int ret; 4417706Sjulian pthread_attr_t pattr; 4522315Sjulian 4622315Sjulian /* Allocate memory for the attribute object: */ 4722315Sjulian if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL) 4822315Sjulian /* Insufficient memory: */ 4922315Sjulian ret = ENOMEM; 5022315Sjulian else { 5122315Sjulian /* Initialise the attribute object with the defaults: */ 5217706Sjulian memcpy(pattr, &pthread_attr_default, sizeof(struct pthread_attr)); 5322315Sjulian 5422315Sjulian /* Return a pointer to the attribute object: */ 5517706Sjulian *attr = pattr; 5617706Sjulian ret = 0; 5717706Sjulian } 5817706Sjulian return(ret); 5917706Sjulian} 6017706Sjulian#endif 61