looking for the platform info file in the working directory and load platform specific information. If not found, use info from the platform that Csmith is running, and output them to the file */
| 331 | to the file |
| 332 | */ |
| 333 | void |
| 334 | CGOptions::set_platform_specific_options(void) |
| 335 | { |
| 336 | const char* int_str = "integer size = "; |
| 337 | const char* ptr_str = "pointer size = "; |
| 338 | ifstream conf(PLATFORM_CONFIG_FILE); |
| 339 | if (conf.fail()) { |
| 340 | ofstream conf(PLATFORM_CONFIG_FILE); |
| 341 | conf << int_str << sizeof(int) << endl; |
| 342 | conf << ptr_str << sizeof(int*) << endl; |
| 343 | int_size(sizeof(int)); |
| 344 | pointer_size(sizeof(int*)); |
| 345 | conf.close(); |
| 346 | } |
| 347 | else { |
| 348 | string line; |
| 349 | while(!conf.eof()) { |
| 350 | getline(conf, line); |
| 351 | if (line.substr(0, strlen(int_str)) == int_str) { |
| 352 | string s = line.substr(strlen(int_str)); |
| 353 | StringUtils::chop(s); |
| 354 | int_size(StringUtils::str2int(s)); |
| 355 | } |
| 356 | if (line.substr(0, strlen(ptr_str)) == ptr_str) { |
| 357 | string s = line.substr(strlen(ptr_str)); |
| 358 | StringUtils::chop(s); |
| 359 | pointer_size(StringUtils::str2int(s)); |
| 360 | } |
| 361 | } |
| 362 | if (!int_size_) { |
| 363 | cout << "please specify integer size in " << PLATFORM_CONFIG_FILE << endl; |
| 364 | exit(-1); |
| 365 | } |
| 366 | if (!pointer_size_) { |
| 367 | cout << "please specify pointer size in " << PLATFORM_CONFIG_FILE << endl; |
| 368 | exit(-1); |
| 369 | } |
| 370 | conf.close(); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | int |
| 375 | CGOptions::int_size(void) |
nothing calls this directly
no outgoing calls
no test coverage detected