Annotation of OSKit-Mach/gensym.awk, revision 1.1.1.1

1.1       root        1: #
                      2: # Copyright (c) 1994 The University of Utah and
                      3: # the Computer Systems Laboratory (CSL).  All rights reserved.
                      4: #
                      5: # Permission to use, copy, modify and distribute this software and its
                      6: # documentation is hereby granted, provided that both the copyright
                      7: # notice and this permission notice appear in all copies of the
                      8: # software, derivative works or modified versions, and any portions
                      9: # thereof, and that both notices appear in supporting documentation.
                     10: #
                     11: # THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
                     12: # IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
                     13: # ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     14: #
                     15: # CSL requests users of this software to return to [email protected] any
                     16: # improvements that they make and grant CSL redistribution rights.
                     17: #
                     18: #      Author: Bryan Ford, University of Utah CSL
                     19: #
                     20: 
                     21: BEGIN {
                     22:        bogus_printed = "no"
                     23: }
                     24: 
                     25: # Start the bogus function just before the first sym directive,
                     26: # so that any #includes higher in the file don't get stuffed inside it.
                     27: /^[a-z]/ {
                     28:        if (bogus_printed == "no")
                     29:        {
                     30:                print "void bogus() {";
                     31:                bogus_printed = "yes";
                     32:        }
                     33: }
                     34: 
                     35: # Take an arbitrarily complex C symbol or expression and constantize it.
                     36: /^expr/ {
                     37:        print "__asm (\"\\n\\";
                     38:        if ($3 == "")
                     39:                printf "* %s mAgIc%%0\" : : \"i\" (%s));\n", $2, $2;
                     40:        else
                     41:                printf "* %s mAgIc%%0\" : : \"i\" (%s));\n", $3, $2;
                     42: }
                     43: 
                     44: # Output a symbol defining the size of a C structure.
                     45: /^size/ {
                     46:        print "__asm (\"\\n\\";
                     47:        if ($4 == "")
                     48:                printf "* %s_SIZE mAgIc%%0\" : : \"i\" (sizeof(struct %s)));\n",
                     49:                        toupper($3), $2;
                     50:        else
                     51:                printf "* %s mAgIc%%0\" : : \"i\" (sizeof(struct %s)));\n",
                     52:                        $4, $2;
                     53: }
                     54: 
                     55: # Output a symbol defining the byte offset of an element of a C structure.
                     56: /^offset/ {
                     57:        print "__asm (\"\\n\\";
                     58:        if ($5 == "")
                     59:        {
                     60:                printf "* %s_%s mAgIc%%0\" : : \"i\" (&((struct %s*)0)->%s));\n",
                     61:                        toupper($3), toupper($4), $2, $4;
                     62:        }
                     63:        else
                     64:        {
                     65:                printf "* %s mAgIc%%0\" : : \"i\" (&((struct %s*)0)->%s));\n",
                     66:                        toupper($5), $2, $4;
                     67:        }
                     68: }
                     69: 
                     70: # Copy through all preprocessor directives.
                     71: /^#/ {
                     72:        print
                     73: }
                     74: 
                     75: END {
                     76:        print "}"
                     77: }

unix.superglobalmegacorp.com

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