Imgtool: Eliminated Imgtool-specific rand() function

This commit is contained in:
Nathan Woods 2017-07-30 07:22:25 -04:00 committed by Vas Crabb
parent a547f50134
commit c04cc60702
3 changed files with 5 additions and 19 deletions

View File

@ -542,22 +542,6 @@ void *imgtool::image::malloc(size_t size)
}
//-------------------------------------------------
// imgtool::image::rand - returns a random number
//-------------------------------------------------
uint64_t imgtool::image::rand()
{
// we can't use mame_rand() here
#ifdef rand
#undef rand
#endif
return ((uint64_t) std::rand()) << 32
| ((uint64_t)std::rand()) << 0;
}
/***************************************************************************
Imgtool partition management

View File

@ -104,7 +104,6 @@ namespace imgtool
static imgtoolerr_t create(const std::string &modulename, const std::string &filename, util::option_resolution *opts, ptr &image);
static imgtoolerr_t create(const imgtool_module *module, const std::string &filename, util::option_resolution *opts);
static imgtoolerr_t create(const std::string &modulename, const std::string &filename, util::option_resolution *opts);
static uint64_t rand();
std::string info();
imgtoolerr_t get_geometry(uint32_t *tracks, uint32_t *heads, uint32_t *sectors);

View File

@ -534,7 +534,10 @@ static imgtoolerr_t fat_partition_create(imgtool::image &image, uint64_t first_b
place_integer_le(header, 32, 4, (uint32_t) (block_count >> 16));
place_integer_le(header, 36, 1, 0xFF);
place_integer_le(header, 38, 1, 0x28);
place_integer_le(header, 39, 4, imgtool::image::rand());
place_integer_le(header, 39, 1, std::rand());
place_integer_le(header, 40, 1, std::rand());
place_integer_le(header, 41, 1, std::rand());
place_integer_le(header, 42, 1, std::rand());
memcpy(&header[43], " ", 11);
memcpy(&header[54], fat_bits_string, 8);
@ -1635,7 +1638,7 @@ static void fat_bump_dirent(imgtool::partition &partition, uint8_t *entry, size_
{
/* extreme degenerate case; simply randomize the filename */
for (i = 0; i < 6; i++)
sfn_entry[i] = 'A' + (imgtool::image::rand() % 26);
sfn_entry[i] = 'A' + (std::rand() % 26);
sfn_entry[6] = '~';
sfn_entry[7] = '0';
}