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

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