xflouris / libpll

Phylogenetic Likelihood Library
GNU Affero General Public License v3.0
27 stars 6 forks source link

Re-entrant cross-platform random number generator #133

Closed xflouris closed 7 years ago

xflouris commented 7 years ago

Implement random_r and and srandom_r since MAC does not have these functions. Use the version from the GNU libc.

xflouris commented 7 years ago

Imported code from glibc 2.23 to have the re-entrant pseudo-random number generator functions available for MAC and Windows.

@amkozlov : from now on, use the pll_ prefixed functions (srandom_r,random_r,initstate_r,setstate_r). They have the exact same behaviour as the GNUC calls (imported code).

For an example see stepwise.c or the attached example source code, where I use pll_{s}random_r to simulate the non-reentrant random().

amkozlov commented 7 years ago

thanks Tomas! Does it mean that libpll now compiles on Mac?

On 22.03.2017 15:44, Tomas Flouri wrote:

Imported code from glibc 2.23 to have the re-entrant pseudo-random number generator functions available for MAC and Windows.

@amkozlov https://github.com/amkozlov : from now on, use the pll_ prefixed functions (srandom_r,random_r,initstate_r,setstate_r). They have the exact same behaviour as the GNUC calls (imported code).

For an example see stepwise.c https://github.com/xflouris/libpll/blob/dev/src/stepwise.c or the attached example source code, where I use pll_{s}random_r to simulate the non-reentrant random().

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xflouris/libpll/issues/133#issuecomment-288421149, or mute the thread https://github.com/notifications/unsubscribe-auth/AFXS0hu08n7pLg_3evbIWiEn4p3TJcwIks5roTPhgaJpZM4Mjtlj.

xflouris commented 7 years ago

Yes,it compiles fine. There are still some portability issues with the testing framework, but library code and examples work perfectly.

amkozlov commented 7 years ago

great, thanks!

On 22.03.2017 17:31, Tomas Flouri wrote:

Yes,it compiles fine. There are still some portability issues with the testing framework, but library code and examples work perfectly.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xflouris/libpll/issues/133#issuecomment-288457738, or mute the thread https://github.com/notifications/unsubscribe-auth/AFXS0uzdg4_yaNP59c8ZITwaPqFNjdksks5roUzXgaJpZM4Mjtlj.