Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doing some #ifdef cleanup for drand48() #22962

Open
wants to merge 7 commits into
base: blead
Choose a base branch
from

Conversation

scottchiefbaker
Copy link
Contributor

The code for random initialization in util.c is riddled with a lot of exceptions in the form of #ifdefs. The code is actually quite complicated to read because of all the ifdefs. This pull request removes ifdefs for Plan9 and AmigaOS 4.x. This should simplify the code, and make it more readable.

This PR also removes support for RAND_BITS < 16 which, from what I can tell is only appropriate on Plan9? It is probably safe to remove as well? That section could be removed from the PR if we still need it. As far as I know we don't actively support any 16 bit platforms anymore.

@scottchiefbaker
Copy link
Contributor Author

I added a simple fix from the discussion in #22968. If it should be in a separate PR let me know.

@scottchiefbaker
Copy link
Contributor Author

Anything else I can do on this? Is this something we want to move forward on?

@@ -4693,26 +4693,13 @@ Perl_seed(pTHX)
* value from (tv_sec * SEED_C1 + tv_usec). The multipliers should
* probably be bigger too.
*/
#if RANDBITS > 16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see this check replaced by something like

STATIC_ASSERT_DECL(RANDBITS == 48); /* hardcoded in Configure */

so we don't silently get garbage if someone changes it.

Comment on lines -4724 to -4728
# ifdef __amigaos4__
# define PERL_RANDOM_DEVICE "RANDOM:SIZE=4"
# else
# define PERL_RANDOM_DEVICE "/dev/urandom"
# endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this change. If we don't support AmigaOS 4 anymore (is there an official platform list somewhere?), we should rip out all #ifdef __amigaos4__ code in this file (as well as the amigaos4/ subdirectory, and the hints/amigaos.sh file, and README.amiga, and pod/perlamiga.pod, and ext/Amiga-ARexx, and ext/Amiga-Exec).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pretty easy to revert (and harmless). When I checked the list of supported platforms I didn't see AmigaOS in the list. Worst case scenario if we remove this, then AmigaOS would just get it's seed like all the other platforms without /dev/urandom/

I think we just need guidance on what platforms are officially supported or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants