Annotation of Gnu-Mach/i386/util/anno.c, revision 1.1

1.1     ! root        1: /* 
        !             2:  * Copyright (c) 1995 The University of Utah and
        !             3:  * the Computer Systems Laboratory at the University of Utah (CSL).
        !             4:  * All rights reserved.
        !             5:  *
        !             6:  * Permission to use, copy, modify and distribute this software is hereby
        !             7:  * granted provided that (1) source code retains these copyright, permission,
        !             8:  * and disclaimer notices, and (2) redistributions including binaries
        !             9:  * reproduce the notices in supporting documentation, and (3) all advertising
        !            10:  * materials mentioning features or use of this software display the following
        !            11:  * acknowledgement: ``This product includes software developed by the
        !            12:  * Computer Systems Laboratory at the University of Utah.''
        !            13:  *
        !            14:  * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
        !            15:  * IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
        !            16:  * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            17:  *
        !            18:  * CSL requests users of this software to return to [email protected] any
        !            19:  * improvements that they make and grant CSL redistribution rights.
        !            20:  *
        !            21:  *      Author: Bryan Ford, University of Utah CSL
        !            22:  */
        !            23: 
        !            24: #include "anno.h"
        !            25: #include "debug.h"
        !            26: 
        !            27: #ifdef ENABLE_ANNO
        !            28: 
        !            29: void anno_init()
        !            30: {
        !            31:        extern struct anno_entry __ANNO_START__[], __ANNO_END__[];
        !            32:        struct anno_entry *base;
        !            33: 
        !            34:        /* Sort the tables using a slow, simple selection sort;
        !            35:           it only needs to be done once.  */
        !            36:        for (base = __ANNO_START__; base < __ANNO_END__; base++)
        !            37:        {
        !            38:                struct anno_entry *cur, *low, tmp;
        !            39: 
        !            40:                /* Select the lowermost remaining entry,
        !            41:                   and swap it into the base slot.
        !            42:                   Sort by table first, then by val1, val2, val3.  */
        !            43:                low = base;
        !            44:                for (cur = base+1; cur < __ANNO_END__; cur++)
        !            45:                        if ((cur->table < low->table)
        !            46:                            || ((cur->table == low->table)
        !            47:                                && ((cur->val1 < low->val1)
        !            48:                                    || ((cur->val1 == low->val1)
        !            49:                                        && ((cur->val2 < low->val2)
        !            50:                                            || ((cur->val2 == low->val2)
        !            51:                                                && (cur->val3 < low->val3)))))))
        !            52:                                low = cur;
        !            53:                tmp = *base;
        !            54:                *base = *low;
        !            55:                *low = tmp;
        !            56:        }
        !            57: 
        !            58:        /* Initialize each anno_table structure with entries in the array.  */
        !            59:        for (base = __ANNO_START__; base < __ANNO_END__; )
        !            60:        {
        !            61:                struct anno_entry *end;
        !            62: 
        !            63:                for (end = base;
        !            64:                     (end < __ANNO_END__) && (end->table == base->table);
        !            65:                     end++);
        !            66:                base->table->start = base;
        !            67:                base->table->end = end;
        !            68: 
        !            69:                base = end;
        !            70:        }
        !            71: 
        !            72: #if 0 /* debugging code */
        !            73:        {
        !            74:                struct anno_table *t = 0;
        !            75: 
        !            76:                for (base = __ANNO_START__; base < __ANNO_END__; base++)
        !            77:                {
        !            78:                        if (t != base->table)
        !            79:                        {
        !            80:                                t = base->table;
        !            81:                                printf("table %08x: %08x-%08x (%d entries)\n",
        !            82:                                        t, t->start, t->end, t->end - t->start);
        !            83:                                assert(t->start == base);
        !            84:                        }
        !            85:                        printf("  vals %08x %08x %08x\n",
        !            86:                                base->table, base->val1, base->val2, base->val3);
        !            87:                }
        !            88:        }
        !            89: #endif
        !            90: }
        !            91: 
        !            92: #endif ENABLE_ANNO

unix.superglobalmegacorp.com

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