Annotation of kernel/machdep/i386/pc_support/PCmiscInline.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /*
                     26:  * Copyright (c) 1993 NeXT Computer, Inc.
                     27:  *
                     28:  * Miscellaneous inline functions.
                     29:  *
                     30:  * HISTORY
                     31:  *
                     32:  * 15 Mar 1993 ? at NeXT
                     33:  *     Created.
                     34:  */
                     35: 
                     36: #if    KERNEL_PRIVATE
                     37: 
                     38: #import <mach/mach_types.h>
                     39: 
                     40: #import "PCprivate.h"
                     41: 
                     42: static __inline__
                     43: boolean_t
                     44: maskIsSet(
                     45:     void *             mask,
                     46:     int                        n
                     47: )
                     48: {
                     49: #define cmask          ((unsigned char *)mask)
                     50: 
                     51:     if (n < (sizeof (unsigned int) * BYTE_SIZE))
                     52:        return ((*(unsigned int *)cmask & (1 << n)) != 0);
                     53:        
                     54:     return ((*(cmask + (n / BYTE_SIZE)) & (1 << (n % BYTE_SIZE))) != 0);
                     55: #undef cmask
                     56: }
                     57: 
                     58: static __inline__
                     59: PCcontext_t
                     60: currentContext(
                     61:     PCshared_t         shared
                     62: )
                     63: {    
                     64:     if (shared->currentContext >= 0 &&
                     65:            shared->currentContext < PCMAXCONTEXT)
                     66:        return (&shared->contexts[shared->currentContext]);
                     67:     else
                     68:        return ((PCcontext_t) 0);
                     69: }
                     70: 
                     71: static __inline__
                     72: PCshared_t
                     73: threadPCShared(
                     74:     thread_t           thread
                     75: )
                     76: {
                     77:     if (thread->pcb->PCpriv)
                     78:        return ((PCshared_t)thread->pcb->PCpriv->shared);
                     79:     else
                     80:        return ((PCshared_t) 0);
                     81: }
                     82: 
                     83: static __inline__
                     84: PCcontext_t
                     85: threadPCContext(
                     86:     thread_t           thread
                     87: )
                     88: {
                     89:     PCshared_t         shared = threadPCShared(thread);
                     90: 
                     91:     if (shared)
                     92:        return (currentContext(shared));
                     93:     else
                     94:        return ((PCcontext_t) 0);
                     95: }
                     96: 
                     97: static __inline__
                     98: boolean_t
                     99: threadPCException(
                    100:     thread_t                   thread,
                    101:     thread_saved_state_t       *state
                    102: )
                    103: {
                    104:     PCshared_t         shared = threadPCShared(thread);
                    105:     
                    106:     if (shared && !maskIsSet(&shared->machMask, state->trapno))
                    107:        return (PCexception(thread, state));
                    108:     else
                    109:        return (FALSE);
                    110: }
                    111: 
                    112: static __inline__
                    113: void
                    114: threadPCInterrupt(
                    115:     thread_t                   thread,
                    116:     thread_saved_state_t       *state
                    117: )
                    118: {
                    119:     PCcontext_t                context = threadPCContext(thread);
                    120:     
                    121:     if (context &&
                    122:        (context->pendingTimers || context->pendingCallbacks) &&
                    123:                                                        context->running) {
                    124:        PCcallMonitor(thread, state);
                    125:        /* NOTREACHED */
                    126:     }
                    127: }
                    128: 
                    129: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.