Changeset dc0b964 in mainline for tools/autotool.py
- Timestamp:
- 2010-11-24T14:23:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 85369b1, b89e1d3
- Parents:
- 8b3bff5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
r8b3bff5 rdc0b964 49 49 50 50 PACKAGE_BINUTILS = "usually part of binutils" 51 PACKAGE_GCC = "preferably version 4. 4.3or newer"51 PACKAGE_GCC = "preferably version 4.5.1 or newer" 52 52 PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain" 53 53 54 54 COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS." 55 55 56 PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, value) \\56 PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\ 57 57 asm volatile ( \\ 58 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t %[val]\\n" \\58 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\ 59 59 : \\ 60 60 : [val] "n" (value) \\ 61 61 ) 62 62 63 #define DECLARE_INTSIZE(tag, type ) \\64 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, s izeof(unsigned type)); \\65 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, s izeof(signed type))63 #define DECLARE_INTSIZE(tag, type, strc, conc) \\ 64 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\ 65 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, strc, conc, sizeof(signed type)); 66 66 67 67 int main(int argc, char *argv[]) … … 195 195 196 196 for typedef in sizes: 197 outf.write("\tDECLARE_INTSIZE(\"%s\", %s );\n" % (typedef['tag'], typedef['type']))197 outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc'])) 198 198 199 199 outf.write(PROBE_TAIL) … … 231 231 signed_tags = {} 232 232 233 unsigned_strcs = {} 234 signed_strcs = {} 235 236 unsigned_concs = {} 237 signed_concs = {} 238 233 239 for j in range(len(lines)): 234 240 tokens = lines[j].strip().split("\t") … … 236 242 if (len(tokens) > 0): 237 243 if (tokens[0] == "AUTOTOOL_DECLARE"): 238 if (len(tokens) < 5):244 if (len(tokens) < 7): 239 245 print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 240 246 … … 243 249 tag = tokens[3] 244 250 name = tokens[4] 245 value = tokens[5] 251 strc = tokens[5] 252 conc = tokens[6] 253 value = tokens[7] 246 254 247 255 if (category == "intsize"): … … 263 271 unsigned_sizes[name] = value_int 264 272 unsigned_tags[tag] = value_int 273 if (strc != ""): 274 unsigned_strcs[strc] = value_int 275 if (conc != ""): 276 unsigned_concs[conc] = value_int 265 277 elif (subcategory == "signed"): 266 278 signed_sizes[name] = value_int 267 279 signed_tags[tag] = value_int 280 if (strc != ""): 281 signed_strcs[strc] = value_int 282 if (conc != ""): 283 signed_concs[conc] = value_int 268 284 else: 269 285 print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL]) 270 286 271 return {'unsigned_sizes' : unsigned_sizes, 'signed_sizes' : signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags}287 return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs} 272 288 273 289 def detect_uints(probe, bytes): … … 279 295 for b in bytes: 280 296 fnd = False 281 newtype = "uint%s_t" % (b * 8)282 283 297 for name, value in probe['unsigned_sizes'].items(): 284 298 if (value == b): 285 oldtype = "unsigned %s" % name 286 typedefs.append({'oldtype' : oldtype, 'newtype' : newtype}) 287 fnd = True 288 break 289 290 if (not fnd): 291 print_error(['Unable to find appropriate integer type for %s' % newtype, 299 typedefs.append({'oldtype': "unsigned %s" % name, 'newtype': "uint%u_t" % (b * 8)}) 300 fnd = True 301 break 302 303 if (not fnd): 304 print_error(['Unable to find appropriate unsigned integer type for %u bytes' % b, 292 305 COMPILER_FAIL]) 293 306 294 307 295 308 fnd = False 296 newtype = "int%s_t" % (b * 8)297 298 309 for name, value in probe['signed_sizes'].items(): 299 310 if (value == b): 300 oldtype = "signed %s" % name 301 typedefs.append({'oldtype' : oldtype, 'newtype' : newtype}) 302 fnd = True 303 break 304 305 if (not fnd): 306 print_error(['Unable to find appropriate integer type for %s' % newtype, 311 typedefs.append({'oldtype': "signed %s" % name, 'newtype': "int%u_t" % (b * 8)}) 312 fnd = True 313 break 314 315 if (not fnd): 316 print_error(['Unable to find appropriate signed integer type for %u bytes' % b, 307 317 COMPILER_FAIL]) 318 319 320 fnd = False 321 for name, value in probe['unsigned_strcs'].items(): 322 if (value == b): 323 macros.append({'oldmacro': "\"%so\"" % name, 'newmacro': "PRIo%u" % (b * 8)}) 324 macros.append({'oldmacro': "\"%su\"" % name, 'newmacro': "PRIu%u" % (b * 8)}) 325 macros.append({'oldmacro': "\"%sx\"" % name, 'newmacro': "PRIx%u" % (b * 8)}) 326 macros.append({'oldmacro': "\"%sX\"" % name, 'newmacro': "PRIX%u" % (b * 8)}) 327 fnd = True 328 break 329 330 if (not fnd): 331 macros.append({'oldmacro': "\"o\"", 'newmacro': "PRIo%u" % (b * 8)}) 332 macros.append({'oldmacro': "\"u\"", 'newmacro': "PRIu%u" % (b * 8)}) 333 macros.append({'oldmacro': "\"x\"", 'newmacro': "PRIx%u" % (b * 8)}) 334 macros.append({'oldmacro': "\"X\"", 'newmacro': "PRIX%u" % (b * 8)}) 335 336 337 fnd = False 338 for name, value in probe['signed_strcs'].items(): 339 if (value == b): 340 macros.append({'oldmacro': "\"%sd\"" % name, 'newmacro': "PRId%u" % (b * 8)}) 341 fnd = True 342 break 343 344 if (not fnd): 345 macros.append({'oldmacro': "\"d\"", 'newmacro': "PRId%u" % (b * 8)}) 346 347 348 fnd = False 349 for name, value in probe['unsigned_concs'].items(): 350 if (value == b): 351 macros.append({'oldmacro': "c ## U%s" % name, 'newmacro': "UINT%u_C(c)" % (b * 8)}) 352 fnd = True 353 break 354 355 if (not fnd): 356 macros.append({'oldmacro': "c ## U", 'newmacro': "UINT%u_C(c)" % (b * 8)}) 357 358 359 fnd = False 360 for name, value in probe['signed_concs'].items(): 361 if (value == b): 362 macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)}) 363 fnd = True 364 break 365 366 if (not fnd): 367 macros.append({'oldmacro': "c", 'newmacro': "INT%u_C(c)" % (b * 8)}) 308 368 309 369 for tag in ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG']: … … 508 568 probe = probe_compiler(common, 509 569 [ 510 {'type': 'char', 'tag': 'CHAR' },511 {'type': 'short int', 'tag': 'SHORT' },512 {'type': 'int', 'tag': 'INT' },513 {'type': 'long int', 'tag': 'LONG' },514 {'type': 'long long int', 'tag': 'LLONG' }570 {'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '""'}, 571 {'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '""'}, 572 {'type': 'int', 'tag': 'INT', 'strc': '""', 'conc': '""'}, 573 {'type': 'long int', 'tag': 'LONG', 'strc': '"l"', 'conc': '"L"'}, 574 {'type': 'long long int', 'tag': 'LLONG', 'strc': '"ll"', 'conc': '"LL"'} 515 575 ] 516 576 )
Note:
See TracChangeset
for help on using the changeset viewer.