GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/librthread/rthread_rwlockattr.c Lines: 0 15 0.0 %
Date: 2017-11-13 Branches: 0 4 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: rthread_rwlockattr.c,v 1.2 2012/02/15 04:58:42 guenther Exp $ */
2
/*
3
 * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
4
 * All Rights Reserved.
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 */
18
/*
19
 * rwlock attributes
20
 */
21
22
23
#include <stdlib.h>
24
#include <unistd.h>
25
#include <errno.h>
26
27
#include <pthread.h>
28
29
#include "rthread.h"
30
31
int
32
pthread_rwlockattr_init(pthread_rwlockattr_t *attrp)
33
{
34
	pthread_rwlockattr_t attr;
35
36
	attr = calloc(1, sizeof(*attr));
37
	if (!attr)
38
		return (errno);
39
	attr->pshared = PTHREAD_PROCESS_PRIVATE;
40
	*attrp = attr;
41
42
	return (0);
43
}
44
45
int
46
pthread_rwlockattr_destroy(pthread_rwlockattr_t *attrp)
47
{
48
	free(*attrp);
49
	*attrp = NULL;
50
51
	return (0);
52
}
53
54
int
55
pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attrp, int *pshared)
56
{
57
	*pshared = (*attrp)->pshared;
58
59
	return (0);
60
}
61
62
int
63
pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attrp, int pshared)
64
{
65
	/* only PTHREAD_PROCESS_PRIVATE is supported */
66
	if (pshared != PTHREAD_PROCESS_PRIVATE)
67
		return (EINVAL);
68
69
	(*attrp)->pshared = pshared;
70
71
	return (0);
72
}