darling-xnu/libsyscall/mach/thread_act.c
2023-05-16 21:41:14 -07:00

78 lines
2.6 KiB
C

/*
* Copyright (c) 2011 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#undef _thread_act_user_
#include <mach/thread_act_internal.h>
extern void _pthread_clear_qos_tsd(mach_port_t port);
kern_return_t
thread_policy(thread_act_t thr_act, policy_t policy, policy_base_t base, mach_msg_type_number_t baseCnt, boolean_t set_limit)
{
kern_return_t kr;
kr = _kernelrpc_thread_policy(thr_act, policy, base, baseCnt, set_limit);
if (kr == KERN_SUCCESS) {
_pthread_clear_qos_tsd(thr_act);
} else if (kr == KERN_POLICY_STATIC) {
kr = KERN_SUCCESS;
}
return kr;
}
kern_return_t
thread_policy_set(thread_act_t thread, thread_policy_flavor_t flavor, thread_policy_t policy_info, mach_msg_type_number_t policy_infoCnt)
{
kern_return_t kr;
kr = _kernelrpc_thread_policy_set(thread, flavor, policy_info, policy_infoCnt);
if (kr == KERN_SUCCESS) {
_pthread_clear_qos_tsd(thread);
} else if (kr == KERN_POLICY_STATIC) {
kr = KERN_SUCCESS;
}
return kr;
}
kern_return_t
thread_set_policy(thread_act_t thr_act, processor_set_t pset, policy_t policy, policy_base_t base, mach_msg_type_number_t baseCnt, policy_limit_t limit, mach_msg_type_number_t limitCnt)
{
kern_return_t kr;
kr = _kernelrpc_thread_set_policy(thr_act, pset, policy, base, baseCnt, limit, limitCnt);
if (kr == KERN_SUCCESS) {
_pthread_clear_qos_tsd(thr_act);
} else if (kr == KERN_POLICY_STATIC) {
kr = KERN_SUCCESS;
}
return kr;
}