1111846Sphantom/* 2111846Sphantom * Copyright (c) 2002,2003 Alexey Zelkin <phantom@FreeBSD.org> 3111846Sphantom * All rights reserved. 4111846Sphantom * 5111846Sphantom * Redistribution and use in source and binary forms, with or without 6111846Sphantom * modification, are permitted provided that the following conditions 7111846Sphantom * are met: 8111846Sphantom * 1. Redistributions of source code must retain the above copyright 9111846Sphantom * notice, this list of conditions and the following disclaimer. 10111846Sphantom * 2. Redistributions in binary form must reproduce the above copyright 11111846Sphantom * notice, this list of conditions and the following disclaimer in the 12111846Sphantom * documentation and/or other materials provided with the distribution. 13111846Sphantom * 14111846Sphantom * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15111846Sphantom * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16111846Sphantom * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17111846Sphantom * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18111846Sphantom * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19111846Sphantom * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20111846Sphantom * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21111846Sphantom * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22111846Sphantom * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23111846Sphantom * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24111846Sphantom * SUCH DAMAGE. 25111846Sphantom * 26111846Sphantom * $FreeBSD$ 27111846Sphantom */ 28174112Sdeischen 29174112Sdeischen#include "namespace.h" 30111846Sphantom#include <errno.h> 31111846Sphantom#include <string.h> 32111846Sphantom#include <pthread.h> 33111846Sphantom#include <pthread_np.h> 34174112Sdeischen#include "un-namespace.h" 35111928Sphantom#include "thr_private.h" 36111846Sphantom 37111846Sphantom__weak_reference(_pthread_attr_get_np, pthread_attr_get_np); 38111846Sphantom 39111846Sphantomint 40111846Sphantom_pthread_attr_get_np(pthread_t pid, pthread_attr_t *dst) 41111846Sphantom{ 42113658Sdeischen struct pthread *curthread; 43117300Sdavidxu struct pthread_attr attr; 44111846Sphantom int ret; 45111846Sphantom 46111846Sphantom if (pid == NULL || dst == NULL || *dst == NULL) 47111846Sphantom return (EINVAL); 48111846Sphantom 49113658Sdeischen curthread = _get_curthread(); 50113658Sdeischen if ((ret = _thr_ref_add(curthread, pid, /*include dead*/0)) != 0) 51111846Sphantom return (ret); 52117300Sdavidxu attr = pid->attr; 53113658Sdeischen _thr_ref_delete(curthread, pid); 54117300Sdavidxu memcpy(*dst, &attr, sizeof(struct pthread_attr)); 55111846Sphantom 56111846Sphantom return (0); 57111846Sphantom} 58