Annotation of Gnu-Mach/i386/i386at/kd_queue.c, revision 1.1.1.1

1.1       root        1: /* 
                      2:  * Mach Operating System
                      3:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
                      4:  * All Rights Reserved.
                      5:  * 
                      6:  * Permission to use, copy, modify and distribute this software and its
                      7:  * documentation is hereby granted, provided that both the copyright
                      8:  * notice and this permission notice appear in all copies of the
                      9:  * software, derivative works or modified versions, and any portions
                     10:  * thereof, and that both notices appear in supporting documentation.
                     11:  * 
                     12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     15:  * 
                     16:  * Carnegie Mellon requests users of this software to return to
                     17:  * 
                     18:  *  Software Distribution Coordinator  or  [email protected]
                     19:  *  School of Computer Science
                     20:  *  Carnegie Mellon University
                     21:  *  Pittsburgh PA 15213-3890
                     22:  * 
                     23:  * any improvements or extensions that they make and grant Carnegie Mellon
                     24:  * the rights to redistribute these changes.
                     25:  */
                     26: /* **********************************************************************
                     27:  File:         kd_queue.c
                     28:  Description:  Event queue code for keyboard/display (and mouse) driver.
                     29: 
                     30:  $ Header: $
                     31: 
                     32:  Copyright Ing. C. Olivetti & C. S.p.A. 1989.
                     33:  All rights reserved.
                     34: ********************************************************************** */
                     35: /*
                     36:   Copyright 1988, 1989 by Olivetti Advanced Technology Center, Inc.,
                     37: Cupertino, California.
                     38: 
                     39:                All Rights Reserved
                     40: 
                     41:   Permission to use, copy, modify, and distribute this software and
                     42: its documentation for any purpose and without fee is hereby
                     43: granted, provided that the above copyright notice appears in all
                     44: copies and that both the copyright notice and this permission notice
                     45: appear in supporting documentation, and that the name of Olivetti
                     46: not be used in advertising or publicity pertaining to distribution
                     47: of the software without specific, written prior permission.
                     48: 
                     49:   OLIVETTI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
                     50: INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
                     51: IN NO EVENT SHALL OLIVETTI BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
                     52: CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
                     53: LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
                     54: NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUR OF OR IN CONNECTION
                     55: WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     56: */
                     57: 
                     58: 
                     59: #include <i386at/kd_queue.h>
                     60: 
                     61: /*
                     62:  * Notice that when adding an entry to the queue, the caller provides 
                     63:  * its own storage, which is copied into the queue.  However, when 
                     64:  * removing an entry from the queue, the caller is given a pointer to a 
                     65:  * queue element.  This means that the caller must either process the 
                     66:  * element or copy it into its own storage before unlocking the queue.
                     67:  *
                     68:  * These routines should be called only at a protected SPL.
                     69:  */
                     70: 
                     71: #define q_next(index)  (((index)+1) % KDQSIZE)
                     72: 
                     73: boolean_t
                     74: kdq_empty(q)
                     75:        kd_event_queue *q;
                     76: {
                     77:        return(q->firstfree == q->firstout);
                     78: }
                     79: 
                     80: boolean_t
                     81: kdq_full(q)
                     82:        kd_event_queue *q;
                     83: {
                     84:        return(q_next(q->firstfree) == q->firstout);
                     85: }
                     86: 
                     87: void
                     88: kdq_put(q, ev)
                     89:        kd_event_queue *q;
                     90:        kd_event *ev;
                     91: {
                     92:        kd_event *qp = q->events + q->firstfree;
                     93: 
                     94:        qp->type = ev->type;
                     95:        qp->time = ev->time;
                     96:        qp->value = ev->value;
                     97:        q->firstfree = q_next(q->firstfree);
                     98: }
                     99: 
                    100: kd_event *
                    101: kdq_get(q)
                    102:        kd_event_queue *q;
                    103: {
                    104:        kd_event *result = q->events + q->firstout;
                    105: 
                    106:        q->firstout = q_next(q->firstout);
                    107:        return(result);
                    108: }
                    109: 
                    110: void
                    111: kdq_reset(q)
                    112:        kd_event_queue *q;
                    113: {
                    114:        q->firstout = q->firstfree = 0;
                    115: }

unix.superglobalmegacorp.com

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