1*907281d1SSepherosa Ziehau /* 2*907281d1SSepherosa Ziehau * Copyright (c) 2017 The DragonFly Project. All rights reserved. 3*907281d1SSepherosa Ziehau * 4*907281d1SSepherosa Ziehau * This code is derived from software contributed to The DragonFly Project 5*907281d1SSepherosa Ziehau * by Sepherosa Ziehau <sepherosa@gmail.com> 6*907281d1SSepherosa Ziehau * 7*907281d1SSepherosa Ziehau * Redistribution and use in source and binary forms, with or without 8*907281d1SSepherosa Ziehau * modification, are permitted provided that the following conditions 9*907281d1SSepherosa Ziehau * are met: 10*907281d1SSepherosa Ziehau * 11*907281d1SSepherosa Ziehau * 1. Redistributions of source code must retain the above copyright 12*907281d1SSepherosa Ziehau * notice, this list of conditions and the following disclaimer. 13*907281d1SSepherosa Ziehau * 2. Redistributions in binary form must reproduce the above copyright 14*907281d1SSepherosa Ziehau * notice, this list of conditions and the following disclaimer in 15*907281d1SSepherosa Ziehau * the documentation and/or other materials provided with the 16*907281d1SSepherosa Ziehau * distribution. 17*907281d1SSepherosa Ziehau * 3. Neither the name of The DragonFly Project nor the names of its 18*907281d1SSepherosa Ziehau * contributors may be used to endorse or promote products derived 19*907281d1SSepherosa Ziehau * from this software without specific, prior written permission. 20*907281d1SSepherosa Ziehau * 21*907281d1SSepherosa Ziehau * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22*907281d1SSepherosa Ziehau * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23*907281d1SSepherosa Ziehau * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24*907281d1SSepherosa Ziehau * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25*907281d1SSepherosa Ziehau * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26*907281d1SSepherosa Ziehau * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 27*907281d1SSepherosa Ziehau * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28*907281d1SSepherosa Ziehau * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29*907281d1SSepherosa Ziehau * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30*907281d1SSepherosa Ziehau * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31*907281d1SSepherosa Ziehau * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*907281d1SSepherosa Ziehau * SUCH DAMAGE. 33*907281d1SSepherosa Ziehau */ 34*907281d1SSepherosa Ziehau 35*907281d1SSepherosa Ziehau #include <sys/types.h> 36*907281d1SSepherosa Ziehau #include <sys/usched.h> 37*907281d1SSepherosa Ziehau #include <sched.h> 38*907281d1SSepherosa Ziehau #include <string.h> 39*907281d1SSepherosa Ziehau 40*907281d1SSepherosa Ziehau int 41*907281d1SSepherosa Ziehau sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask) 42*907281d1SSepherosa Ziehau { 43*907281d1SSepherosa Ziehau 44*907281d1SSepherosa Ziehau memset(mask, 0, cpusetsize); 45*907281d1SSepherosa Ziehau return (lwp_getaffinity(pid, -1, mask)); 46*907281d1SSepherosa Ziehau } 47