1 #!/bin/ksh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 27 # 28 # Create dummy functions for each of the functions in the module API. We can 29 # then link a module against an object file created from the output of this 30 # script to determine whether or not that module restricts itself to the API. 31 # If the module uses functions outside of the module API, then it cannot be 32 # used as a kmdb module. 33 # 34 /usr/xpg4/bin/awk ' 35 /^[ ]*global:[ ]*$/ { 36 printing = 1; 37 next; 38 } 39 40 /^[ ]*local:[ ]*$/ { 41 printing = 0; 42 next; 43 } 44 45 # Skip blank lines and comments 46 /^$/ { next; } 47 /^[ ]*#/ { next;} 48 49 # Print globals only 50 printing == 0 { next; } 51 52 # Symbols beginning with "kmdb_" are not in the module API - they are 53 # private to kmdb. 54 $1 ~ /^kmdb_/ { next; } 55 56 # Symbols which have the token "variable" are seen as an int 57 $3 ~ /variable/ { 58 if (seen[$1]) { 59 next; 60 } 61 62 seen[$1] = 1; 63 64 printf("int %s = 0;\n", substr($1, 1, length($1) - 1)); 65 next; 66 } 67 68 $1 !~ /;$/ { next; } 69 70 # Print everything else that we have not already seen as a function 71 # definition so we can create our filter. 72 { 73 if (seen[$1]) { 74 next; 75 } 76 77 seen[$1] = 1; 78 79 printf("void %s(void) {}\n", substr($1, 1, length($1) - 1)); 80 } 81 ' 82 83 # 84 # kmdb modules cannot have their own _init, _fini, or _info routines. By 85 # creating dummies for them here, a link against an object file created from 86 # the output of this script will fail if the module defines one of them. 87 # 88 echo "void _init(void) {}" 89 echo "void _info(void) {}" 90 echo "void _fini(void) {}" 91 # 92 # The SunStudio compiler may generate calls to _memcpy and so we 93 # need to make sure that the correct symbol exists for these calls. 94 # 95 echo "void _memcpy(void) {}"