#ifndef __THREAD_MACROS_LOADED #define __THREAD_MACROS_LOADED 1 /* IDENT X-13 */ /***************************************************************************** * * * COPYRIGHT (c) 1993 BY * * DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. * * ALL RIGHTS RESERVED. * * * * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED * * ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE * * INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER * * COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY * * OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY * * TRANSFERRED. * * * * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE * * AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT * * CORPORATION. * * * * DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS * * SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL. * * * *****************************************************************************/ /* *++ * FACILITY: * * VMS Executive (LIB) * * ABSTRACT: * * This header file provides macros and functions that are used * for kernel thread support. * * AUTHOR: * * Ellen M. Batbouta * * CREATION DATE: 09-Mar-1995 * * MODIFICATION HISTORY: * * X-13 KLN3096 Karen L. Noel 2-Oct-2002 * o Port get_curktb to IA64. * o Fix ident. * * X-11 DJM Dennis Mattoon 20-MAR-02 * Replaced call_pal asm statement with an equivalent call * to the __PAL_LDQP builtin. * * X-10 KLN2085 Karen L. Noel 11-Jun-1998 * Fix some more DEC C level4 informationals. * * X-9 KLN2075 Karen L. Noel 12-May-1998 * The compiler doesn't like upper cased externs compiled * with lower cased externs of the same name. Most code * uses lower case, so just switch this case to lower. * * X-8 Dave Bernardo 07-Mar-1998 * Fix return in get_curktb. Cleanup pointer size madness. * * X-7 DMB Dave Bernardo 04-Nov-1996 * Add new WTAMI algorithm * * X-6 MAS Mary A. Sullivan 17-May-1996 * Use more standard '__int64' rather than 'int64' in * our casts (from X-3) since we don't explicitly include * ints.h, and besides it makes the latest C compiler * happy. * * X-5 PKW355 Paul K. M. Weiss 17-May-1996 * Define pktadef for PKW353 * * X-4 PKW353 Paul K. M. Weiss 15-May-1996 * Add get_curpkta caller's mode routine * * X-3 MAS Mary A. Sullivan 17-Jan-1996 * Declare 'pcbb' as a 64-bit pointer and use 64-bit * arithmetic on my_id calculation. * * X-2 JCH703 John C. Hallyburton, Jr. 17-Apr-1995 * Change logical "&&" to bitwise "&" in my_id calculation, so * the correct KTB pointer will be returned instead of PCB. * Rework code slightly. Note the compiler could do a little * better by realizing it was SEXTL-ing pcbb then masking off * only the low 9 bits, so why SEXTL in the first place? * *-- */ /* Include any header files we need to make these macros work */ #include #include #include #include #include #pragma __required_pointer_size __save /* Save the previously-defined required ptr size */ #pragma __required_pointer_size __short /* And set ptr size default to 32-bit pointers */ /* Define function to get the address of the current kernel thread block (KTB) */ #pragma inline (get_curktb) static KTB * get_curktb(void) { #ifndef __ALPHA /* Verified for IA64 port - KLN */ extern int swis$get_current_kt_id(void); extern PCB * const ctl$gl_pcb; int my_id; KTB **ktbvec; /* If process has 1 execution context, ktb is pcb */ if (ctl$gl_pcb->pcb$l_kt_count <= 1) return ((KTB *)ctl$gl_pcb); /* This is a multithreaded process with more than 1 execution context. */ my_id = swis$get_current_kt_id(); ktbvec = ctl$gl_pcb->pcb$l_ktbvec; return (ktbvec[my_id]); #endif #ifdef __ALPHA /* Verified for IA64 port - KLN */ extern PCB * const ctl$gl_pcb; extern const int mmg$gl_bwp_mask; VOID_PQ pcbb; int my_id; KTB **ktbvec; /* Does process have more than 1 execution context? */ if (ctl$gl_pcb->pcb$l_kt_count <= 1) return ((KTB *)ctl$gl_pcb); else { /* This is a multithreaded process with more than 1 execution context. */ pcbb = __PAL_MFPR_PCBB(); if ( (__int64) pcbb & (__int64) (FRED$K_LENGTH - 1)) return ((KTB *)ctl$gl_pcb); if (ctl$gl_pcb->pcb$v_fredlock == 0) { /* This is a multithreaded process with 1 FRED page */ my_id = (int) (((__int64) pcbb & (__int64) mmg$gl_bwp_mask) >> FRED$K_SHIFT); ktbvec = ctl$gl_pcb->pcb$l_ktbvec; return (ktbvec[my_id]); } else { /* This is a multithreaded process with more than 1 FRED page */ return (KTB*)(__PAL_LDQP((void *)((__int64)pcbb + FRED$C_KTB_KT_ID))); } } #endif } #pragma inline (get_curpkta) static PKTA * get_curpkta(void) { int my_id; extern int sys$get_kt_id(void); extern int ctl$gl_multithread; extern PKTA ctl$a_initial_pkta; #pragma __required_pointer_size __long /* And set ptr size default to 64-bit pointers */ extern PKTA **ctl$gq_pktavec; #pragma __required_pointer_size __short /* And set ptr size default to 32-bit pointers */ if (ctl$gl_multithread <= 1) return &ctl$a_initial_pkta; else { my_id = sys$get_kt_id(); return ((PKTA *) ctl$gq_pktavec[my_id]); } } #pragma __required_pointer_size __restore /* Restore the previously-defined required ptr size */ #endif /* __THREAD_MACROS_LOADED */