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