Changes in tools/autotool.py [9539be6:a4125fb1] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
r9539be6 ra4125fb1 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, name, 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" name "\\t%[val]\\n" \\ 59 59 : \\ 60 60 : [val] "n" (value) \\ 61 61 ) 62 62 63 #define DECLARE_INTSIZE(t ag, type) \\64 AUTOTOOL_DECLARE("intsize", "unsigned", tag,#type, sizeof(unsigned type)); \\65 AUTOTOOL_DECLARE("intsize", "signed", tag,#type, sizeof(signed type))63 #define DECLARE_INTSIZE(type) \\ 64 AUTOTOOL_DECLARE("intsize", "unsigned", #type, sizeof(unsigned type)); \\ 65 AUTOTOOL_DECLARE("intsize", "signed", #type, 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);\n" % typedef) 198 198 199 199 outf.write(PROBE_TAIL) … … 228 228 signed_sizes = {} 229 229 230 unsigned_tags = {}231 signed_tags = {}232 233 230 for j in range(len(lines)): 234 231 tokens = lines[j].strip().split("\t") … … 241 238 category = tokens[1] 242 239 subcategory = tokens[2] 243 tag = tokens[3] 244 name = tokens[4] 245 value = tokens[5] 240 name = tokens[3] 241 value = tokens[4] 246 242 247 243 if (category == "intsize"): … … 262 258 if (subcategory == "unsigned"): 263 259 unsigned_sizes[name] = value_int 264 unsigned_tags[tag] = value_int265 260 elif (subcategory == "signed"): 266 261 signed_sizes[name] = value_int 267 signed_tags[tag] = value_int268 262 else: 269 263 print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL]) 270 264 271 return {'unsigned_sizes' : unsigned_sizes, 'signed_sizes' : signed_sizes , 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags}272 273 def detect_uints( probe, bytes):265 return {'unsigned_sizes' : unsigned_sizes, 'signed_sizes' : signed_sizes} 266 267 def detect_uints(unsigned_sizes, signed_sizes, bytes): 274 268 "Detect correct types for fixed-size integer types" 275 269 276 macros = []277 270 typedefs = [] 278 271 … … 281 274 newtype = "uint%s_t" % (b * 8) 282 275 283 for name, value in probe['unsigned_sizes'].items():276 for name, value in unsigned_sizes.items(): 284 277 if (value == b): 285 278 oldtype = "unsigned %s" % name … … 296 289 newtype = "int%s_t" % (b * 8) 297 290 298 for name, value in probe['signed_sizes'].items():291 for name, value in signed_sizes.items(): 299 292 if (value == b): 300 293 oldtype = "signed %s" % name … … 307 300 COMPILER_FAIL]) 308 301 309 for tag in ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG']: 310 fnd = False; 311 newmacro = "U%s" % tag 312 313 for name, value in probe['unsigned_tags'].items(): 314 if (name == tag): 315 oldmacro = "UINT%s" % (value * 8) 316 macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro}) 317 macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro}) 318 fnd = True 319 break 320 321 if (not fnd): 322 print_error(['Unable to find appropriate size macro for %s' % newmacro, 323 COMPILER_FAIL]) 324 325 fnd = False; 326 newmacro = tag 327 328 for name, value in probe['signed_tags'].items(): 329 if (name == tag): 330 oldmacro = "INT%s" % (value * 8) 331 macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro}) 332 macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro}) 333 fnd = True 334 break 335 336 if (not fnd): 337 print_error(['Unable to find appropriate size macro for %s' % newmacro, 338 COMPILER_FAIL]) 339 340 return {'macros': macros, 'typedefs': typedefs} 302 return typedefs 341 303 342 304 def create_makefile(mkname, common): … … 354 316 outmk.close() 355 317 356 def create_header(hdname, maps):318 def create_header(hdname, typedefs): 357 319 "Create header output" 358 320 … … 366 328 outhd.write('#define %s\n\n' % GUARD) 367 329 368 for macro in maps['macros']: 369 outhd.write('#define %s %s\n' % (macro['newmacro'], macro['oldmacro'])) 370 371 outhd.write('\n') 372 373 for typedef in maps['typedefs']: 330 for typedef in typedefs: 374 331 outhd.write('typedef %s %s;\n' % (typedef['oldtype'], typedef['newtype'])) 375 332 … … 508 465 probe = probe_compiler(common, 509 466 [ 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'}467 "char", 468 "short int", 469 "int", 470 "long int", 471 "long long int", 515 472 ] 516 473 ) 517 474 518 maps = detect_uints(probe, [1, 2, 4, 8])475 typedefs = detect_uints(probe['unsigned_sizes'], probe['signed_sizes'], [1, 2, 4, 8]) 519 476 520 477 finally: … … 522 479 523 480 create_makefile(MAKEFILE, common) 524 create_header(HEADER, maps)481 create_header(HEADER, typedefs) 525 482 526 483 return 0
Note:
See TracChangeset
for help on using the changeset viewer.