MantisBT - VCMI
View Issue Details
0000719VCMIOtherpublic2011-03-31 13:252014-05-30 17:40
plush 
Tow 
normalminoralways
closedfixed 
AMD64FreeBSD8.2
0.84 
0.85 
0000719: [PATCH] Make VCMI work under FreeBSD
VMCI compiles and installs under FreeBSD 8.2 but crashes upon start-up with a floating point exception. The problem lies in timeHandler.h, line 21:

return ret/(CLOCKS_PER_SEC/1000);

This code assumes that CLOCKS_PER_SEC > 1000. Under Linux, clocks() has microsecond resolution so that CLOCKS_PER_SEC = 1000000 and the code works as desired. Under FreeBSD, CLOCKS_PER_SEC = 128, leading to a division by zero.
Compile, install and attempt to run under FreeBSD.
A clock with microsecond resolution is available under FreeBSD via the getrusage() system call. The attached patch introduces a private method clock() that returns a timestamp with microsecond resolution, mimicking the Linux function. The getDif() method is adjusted to divide by the correct number.

Additionally, the fields start, last, mem are made private so that no other class can access them and misinterpret the resolution of these timestamps.
No tags attached.
? patch_freebsd (1,550) 2011-03-31 13:25
https://bugs.vcmi.eu/file_download.php?file_id=703&type=bug
Issue History
2011-03-31 13:25plushNew Issue
2011-03-31 13:25plushFile Added: patch_freebsd
2011-04-02 23:49TowNote Added: 0001673
2011-04-02 23:49TowStatusnew => resolved
2011-04-02 23:49TowFixed in Version => 0.89
2011-04-02 23:49TowResolutionopen => fixed
2011-04-02 23:49TowAssigned To => Tow
2011-04-02 23:51plushNote Added: 0001674
2014-05-30 17:40beegeeStatusresolved => closed

Notes
(0001673)
Tow   
2011-04-02 23:49   
Hi, thanks for the detailed report and the patch! :)
I've committed a fix based on it (without whole class duplication, when the difference is in one method) in r2058.
Please check, if it solves your problem.
(0001674)
plush   
2011-04-02 23:51   
Thanks, that's a nice clean-up of my patch.