1*a9643ea8Slogwang /* 2*a9643ea8Slogwang * Copyright (c) 2010 Kip Macy All rights reserved. 3*a9643ea8Slogwang * Copyright (C) 2017 THL A29 Limited, a Tencent company. 4*a9643ea8Slogwang * All rights reserved. 5*a9643ea8Slogwang * 6*a9643ea8Slogwang * Redistribution and use in source and binary forms, with or without 7*a9643ea8Slogwang * modification, are permitted provided that the following conditions are met: 8*a9643ea8Slogwang * 9*a9643ea8Slogwang * 1. Redistributions of source code must retain the above copyright notice, this 10*a9643ea8Slogwang * list of conditions and the following disclaimer. 11*a9643ea8Slogwang * 2. Redistributions in binary form must reproduce the above copyright notice, 12*a9643ea8Slogwang * this list of conditions and the following disclaimer in the documentation 13*a9643ea8Slogwang * and/or other materials provided with the distribution. 14*a9643ea8Slogwang * 15*a9643ea8Slogwang * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16*a9643ea8Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17*a9643ea8Slogwang * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18*a9643ea8Slogwang * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19*a9643ea8Slogwang * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20*a9643ea8Slogwang * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21*a9643ea8Slogwang * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22*a9643ea8Slogwang * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23*a9643ea8Slogwang * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24*a9643ea8Slogwang * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*a9643ea8Slogwang * 26*a9643ea8Slogwang */ 27*a9643ea8Slogwang 28*a9643ea8Slogwang #ifndef _FSTACK_MACHINE_PCPU_H_ 29*a9643ea8Slogwang #define _FSTACK_MACHINE_PCPU_H_ 30*a9643ea8Slogwang 31*a9643ea8Slogwang #include_next <machine/pcpu.h> 32*a9643ea8Slogwang 33*a9643ea8Slogwang #undef __curthread 34*a9643ea8Slogwang #undef PCPU_GET 35*a9643ea8Slogwang #undef PCPU_ADD 36*a9643ea8Slogwang #undef PCPU_INC 37*a9643ea8Slogwang #undef PCPU_PTR 38*a9643ea8Slogwang #undef PCPU_SET 39*a9643ea8Slogwang 40*a9643ea8Slogwang extern __thread struct thread *pcurthread; 41*a9643ea8Slogwang extern struct pcpu *pcpup; 42*a9643ea8Slogwang 43*a9643ea8Slogwang #define PCPU_GET(member) (pcpup->pc_ ## member) 44*a9643ea8Slogwang #define PCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) 45*a9643ea8Slogwang #define PCPU_INC(member) PCPU_ADD(member, 1) 46*a9643ea8Slogwang #define PCPU_PTR(member) (&pcpup->pc_ ## member) 47*a9643ea8Slogwang #define PCPU_SET(member, val) (pcpup->pc_ ## member = (val)) 48*a9643ea8Slogwang 49*a9643ea8Slogwang static __inline struct thread * 50*a9643ea8Slogwang __curthread_ff(void) 51*a9643ea8Slogwang { 52*a9643ea8Slogwang return (pcurthread); 53*a9643ea8Slogwang } 54*a9643ea8Slogwang 55*a9643ea8Slogwang 56*a9643ea8Slogwang #define __curthread __curthread_ff 57*a9643ea8Slogwang 58*a9643ea8Slogwang #ifndef curthread 59*a9643ea8Slogwang #define curthread __curthread_ff() 60*a9643ea8Slogwang #endif 61*a9643ea8Slogwang #endif /* _FSTACK_MACHINE_PCPU_H_ */ 62