-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete old /dev/urandom backend for arc4random
HaikuOS doesn't need it anymore.
- Loading branch information
Showing
4 changed files
with
20 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!-- | ||
Copyright (c) 2022-2023 Guilherme Janczak <[email protected]> | ||
Copyright (c) 2022-2024 Guilherme Janczak <[email protected]> | ||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -39,8 +39,7 @@ Every subdirectory under *src/* is named after a header. *stdlib/* for | |
subdirectory belong to that header. Instead of piling up `#ifdef`s, I've chosen | ||
to split each "backend" that implements a function into its own file. | ||
|
||
Feature detection is used unless something is impossible to detect. For | ||
instance, there is some manual checking for Haiku. | ||
Feature detection is used unless something is impossible to detect. | ||
|
||
I don't intend to implement deprecated functions like `rindex()`, or silly | ||
functions like `getbsize()`. I trust the underlying platform, if it is buggy, fix | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2022 Guilherme Janczak <[email protected]> | ||
# Copyright (c) 2022, 2024 Guilherme Janczak <[email protected]> | ||
# | ||
# Permission to use, copy, modify, and distribute this software for any | ||
# purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -39,33 +39,23 @@ foreach func, info : stdlib | |
endforeach | ||
|
||
if stdlib['arc4random_buf'][2] | ||
arc4random_backends = { | ||
'getrandom': ['arc4random_buf_getrandom.c', '#include <sys/random.h>'], | ||
'BCryptGenRandom': ['arc4random_buf_BCryptGenRandom.c', | ||
'''#include <windows.h> | ||
#include <bcrypt.h>'''], | ||
|
||
} | ||
|
||
if host_machine.system() == 'emscripten' | ||
stdlib += {'arc4random_buf': ['arc4random_buf_emscripten.c', | ||
'arc4random.3', true]} | ||
elif host_machine.system() == 'haiku' | ||
stdlib += {'arc4random_buf': ['arc4random_buf_dev_urandom.c', | ||
'arc4random.3', true]} | ||
endif | ||
|
||
bcrypt_dep = cc.find_library('bcrypt', required: false) | ||
if bcrypt_dep.found() | ||
bcrypt_pref = '''#include <windows.h>\n#include <bcrypt.h>''' | ||
impl = '' | ||
if bcrypt_dep.found() and cc.has_function('BCryptGenRandom', | ||
prefix: bcrypt_pref, | ||
deps: bcrypt_dep) | ||
deps += bcrypt_dep | ||
impl = 'arc4random_buf_BCryptGenRandom.c' | ||
elif host_machine.system() == 'emscripten' | ||
impl = 'arc4random_buf_emscripten.c' | ||
elif cc.has_function('getrandom', args: args, | ||
prefix: '#include <sys/random.h>') | ||
impl = 'arc4random_buf_getrandom.c' | ||
endif | ||
if impl.length() != 0 | ||
stdlib += {'arc4random_buf': [impl, 'arc4random.3', true]} | ||
endif | ||
foreach func, info : arc4random_backends | ||
if cc.has_function(func, args: args, prefix: info[1], | ||
dependencies: deps) | ||
stdlib += {'arc4random_buf': [info[0], 'arc4random.3', true]} | ||
break | ||
endif | ||
endforeach | ||
endif | ||
|
||
stdlib_pragma = [] # daemon() needs stdlib_pragma early | ||
|