File: makedbh

package info (click to toggle)
irsim 9.7.104-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,964 kB
  • sloc: ansic: 24,763; sh: 7,499; makefile: 418; csh: 269; tcl: 88
file content (187 lines) | stat: -rwxr-xr-x 4,418 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/csh -f
#
# makes the "database.h" (1st argument, $1) file from "database.h.in"
# (2nd argument, $2), setting various mask operation definitions
# according to the number of words implied by the value of TT_MAXTYPES

# The following mess grabs the value of TT_MAXTYPES from database.h.in
#
set maxtypes=`sed -n -e '/^#define[[:space:]]*TT_MAXTYPES/s/#define[[:space:]]*TT_MAXTYPES[[:space:]]*//p' < $1 | sed -e 's/\/\*[[:print:]]*\*\/[[:space:]]*//g' `
#
# Alternative method works with outdated versions of sed/ed.
#
if ($maxtypes == "") then
   set maxtypes=`sed -n -e '/^#define[ 	]*TT_MAXTYPES/s/#define[ 	]*TT_MAXTYPES[ 	]*//p' < $1 | sed -e 's/\/\*.*\*\/[ 	]*//g' `
endif
#
# If we can't generate database.h correctly, nothing is going to compile.
#
if ($maxtypes == "") then
   echo "Bad sed script in scripts/makedbh:  Cannot generate database/database.h!"
   exit
endif

# Find derived values from bits per word
# Note that bits-per-word should be determined from the compiler, but
# 32 bits per word has always been hardwired into magic.
#
set bpw = 32

# @ wordmask=$bpw - 1
# set wordshift=`echo "c=l($bpw); d=l(2); scale=0; c/d" | bc -l`
# @ maskwords=$maxtypes + $bpw - 1
# @ maskwords/=$bpw

@ maskwords=$maxtypes + $bpw - 1
@ maskwords/=$bpw


# Generate the main part of the database.h file from database.h.in
cat $1 > $2

# Generate a list of integers from 0 to the value of "maskwords" - 1
set count=""
@ maskwords--
while (${maskwords} >= 0)
   set count=`echo ${count} ${maskwords}`
   @ maskwords--
end

# Definitions

echo "#define TTMaskZero(m) ( \" >> $2
foreach i (${count})
   echo -n "	(m)->tt_words[$i] = 0" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "#define TTMaskIsZero(m) ( \" >> $2
foreach i (${count})
   echo -n "	(m)->tt_words[$i] == 0" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo " && \" >> $2
   endif
end

echo "#define TTMaskEqual(m, n) ( \" >> $2
foreach i (${count})
   echo -n "	(m)->tt_words[$i] == (n)->tt_words[$i]" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo " && \" >> $2
   endif
end

echo "#define TTMaskIntersect(m, n) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] & (n)->tt_words[$i])" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo " || \" >> $2
   endif
end

echo "#define TTMaskCom(m) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] = ~(m)->tt_words[$i])" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "#define TTMaskCom2(m, n) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] = ~(n)->tt_words[$i])" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "#define TTMaskSetMask(m, n) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] |= (n)->tt_words[$i])" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "#define TTMaskSetMask3(m, n, o) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] |= (n)->tt_words[$i] | (o)->tt_words[$i])" \
	>> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "#define TTMaskAndMask(m, n) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] &= (n)->tt_words[$i])" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "#define TTMaskAndMask3(m, n, o) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] = (n)->tt_words[$i] & (o)->tt_words[$i])" \
	>> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "#define TTMaskClearMask(m, n) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] &= ~(n)->tt_words[$i])" >> $2
   if ($i == 0) then
      echo ")" >> $2
      echo "" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "#define TTMaskClearMask3(m, n, o) ( \" >> $2
foreach i (${count})
   echo -n "	((m)->tt_words[$i] = (n)->tt_words[$i] & ~(o)->tt_words[$i])" \
	>> $2
   if ($i == 0) then
      echo ")" >> $2
   else
      echo ", \" >> $2
   endif
end

echo "" >> $2
echo "#endif /* _DATABASE_H */" >> $2