1113729Sjdp/*
2113729Sjdp * Copyright (c) 2003 Sergey Osokin <osa@FreeBSD.org.ru>.
3113729Sjdp * All rights reserved.
4113729Sjdp *
5113729Sjdp * Redistribution and use in source and binary forms, with or without
6113729Sjdp * modification, are permitted provided that the following conditions
7113729Sjdp * are met:
8113729Sjdp * 1. Redistributions of source code must retain the above copyright
9113729Sjdp *    notice, this list of conditions and the following disclaimer.
10113729Sjdp * 2. Redistributions in binary form must reproduce the above copyright
11113729Sjdp *    notice, this list of conditions and the following disclaimer in the
12113729Sjdp *    documentation and/or other materials provided with the distribution.
13113729Sjdp * 3. All advertising materials mentioning features or use of this software
14113729Sjdp *    must display the following acknowledgement:
15113729Sjdp *      This product includes software developed by Sergey Osokin.
16113729Sjdp * 4. Neither the name of the author nor the names of any co-contributors
17113729Sjdp *    may be used to endorse or promote products derived from this software
18113729Sjdp *    without specific prior written permission.
19113729Sjdp *
20113729Sjdp * THIS SOFTWARE IS PROVIDED BY SERGEY OSOKIN AND CONTRIBUTORS ``AS IS'' AND
21113729Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22113729Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23113729Sjdp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24113729Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25113729Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26113729Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27113729Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28113729Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29113729Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30113729Sjdp * SUCH DAMAGE.
31113729Sjdp */
32113729Sjdp
33297706Skib#include <sys/cdefs.h>
34297706Skib__FBSDID("$FreeBSD: releng/11.0/lib/libthr/thread/thr_concurrency.c 297706 2016-04-08 11:15:26Z kib $");
35297706Skib
36157457Sdavidxu#include "namespace.h"
37113729Sjdp#include <errno.h>
38144518Sdavidxu#include <pthread.h>
39157457Sdavidxu#include "un-namespace.h"
40113729Sjdp
41144518Sdavidxu#include "thr_private.h"
42144518Sdavidxu
43113729Sjdpstatic int current_concurrency = 0;
44113729Sjdp
45113729Sjdp__weak_reference(_pthread_getconcurrency, pthread_getconcurrency);
46113729Sjdp__weak_reference(_pthread_setconcurrency, pthread_setconcurrency);
47113729Sjdp
48113729Sjdpint
49113729Sjdp_pthread_getconcurrency(void)
50113729Sjdp{
51113729Sjdp	return current_concurrency;
52113729Sjdp}
53113729Sjdp
54113729Sjdpint
55113729Sjdp_pthread_setconcurrency(int new_level)
56113729Sjdp{
57113729Sjdp	int ret;
58113729Sjdp
59113729Sjdp	if (new_level < 0) {
60113729Sjdp		ret = EINVAL;
61113729Sjdp	} else {
62113729Sjdp		current_concurrency = new_level;
63113729Sjdp		ret = 0;
64113729Sjdp	}
65113729Sjdp	return (ret);
66113729Sjdp}
67