00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2 of the GNU General Public License as 00011 published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with this program; if not, write the Free Software Foundation, Inc., 59 00026 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00027 00028 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00029 Mountain View, CA 94043, or: 00030 00031 http://www.sgi.com 00032 00033 For further information regarding this notice, see: 00034 00035 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00036 00037 */ 00038 00039 00040 #define __STDC_LIMIT_MACROS 00041 #include <stdint.h> 00042 #include <sys/types.h> 00043 #if defined(BUILD_OS_DARWIN) 00044 #include <darwin_elf.h> 00045 #else /* defined(BUILD_OS_DARWIN) */ 00046 #include <elf.h> 00047 #endif /* defined(BUILD_OS_DARWIN) */ 00048 #include <ctype.h> 00049 #include "wn.h" 00050 #include "wn_map.h" 00051 #include "wn_util.h" 00052 #include <stdio.h> 00053 #include "wb_util.h" 00054 #include "cgb_carray.h" 00055 00056 CGB_CARRAY CGB_carray; 00057 00058 //----------------------------------------------------------------------- 00059 // NAME: CGB_CARRAY::Enter_This_Pair 00060 // FUNCTION: Enter the node 'ipan' into the saved node array '_nodes', 00061 // and the vertex 'v' into into the saved vertex array '_vertices'. 00062 // Update the value of '_next_index', the index of the next available 00063 // entry in '_carray'. 00064 // NOTE: The 'wn' is not entered into the 'carray' if it is already full. 00065 //----------------------------------------------------------------------- 00066 00067 void CGB_CARRAY::Enter_This_Pair(IPA_NODE* ipan, 00068 NODE_INDEX v) 00069 { 00070 if (_next_index < CGB_MAX_SAVED_NODES) { 00071 _nodes[_next_index] = ipan; 00072 _vertices[_next_index] = v; 00073 } 00074 _next_index++; 00075 } 00076 00077 //----------------------------------------------------------------------- 00078 // NAME: CGB_CARRAY::Enter_This_Node_Unique 00079 // FUNCTION: Same as 'enter_this_node', except the 'ipan' and 'v' are not 00080 // entered if it is already there. 00081 //----------------------------------------------------------------------- 00082 00083 INT CGB_CARRAY::Enter_This_Pair_Unique(IPA_NODE* ipan, 00084 NODE_INDEX v) 00085 { 00086 INT i; 00087 00088 for (i = 0; i < _next_index; i++) 00089 if (ipan == _nodes[i] && v == _vertices[i]) 00090 break; 00091 if (i < _next_index) 00092 return i; 00093 if (_next_index < CGB_MAX_SAVED_NODES) { 00094 _nodes[_next_index] = ipan; 00095 _vertices[_next_index] = v; 00096 } 00097 00098 _next_index++; 00099 return _next_index - 1; 00100 } 00101 00102 //----------------------------------------------------------------------- 00103 // NAME: CGB_CARRAY::Find_This_Pair 00104 // FUNCTION: Return the index of the carray entry which contains the given 00105 // 'ipan' and 'v' entries, if such an entry exists. Otherwise, return -1. 00106 //----------------------------------------------------------------------- 00107 00108 INT CGB_CARRAY::Find_This_Pair(IPA_NODE* ipan, 00109 NODE_INDEX v) 00110 { 00111 for (INT i = 0; i < _next_index; i++) 00112 if (ipan == _nodes[i] && v == _vertices[i]) 00113 return i; 00114 return -1; 00115 } 00116 00117 //----------------------------------------------------------------------- 00118 // NAME: CGB_CARRAY::List_All_Pairs 00119 // FUNCTION: List all of the pairs of nodes and vertices in the 00120 // CGB_CARRAY on the file 'fp'. 00121 //----------------------------------------------------------------------- 00122 00123 void CGB_CARRAY::List_All_Pairs(FILE* fp) 00124 { 00125 for (INT i = 0; i < _next_index; i++) 00126 fprintf(fp, "[%d] %p V#%d\n", i, _nodes[i], _vertices[i]); 00127 } 00128
1.5.6