Skip to content

Commit

Permalink
Delete old /dev/urandom backend for arc4random
Browse files Browse the repository at this point in the history
HaikuOS doesn't need it anymore.
  • Loading branch information
guijan committed Jan 30, 2024
1 parent 28ce7bf commit 5102dd4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 88 deletions.
4 changes: 3 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Changes in libobsd master:
- Add closefrom()
- Include io.h in unistd.h on Windows to expose io.h's POSIX functions
- Add C++ support
- add timespeccmp(), timespecsub(), and other timeval/timespec macros from
- Add timespeccmp(), timespecsub(), and other timeval/timespec macros from
sys/time.h
- Delete old /dev/urandom backend for arc4random now that HaikuOS doesn't need
it anymore

5 changes: 2 additions & 3 deletions docs/CONTRIBUTING.md
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
Expand Down Expand Up @@ -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
Expand Down
59 changes: 0 additions & 59 deletions src/stdlib/arc4random_buf_dev_urandom.c

This file was deleted.

40 changes: 15 additions & 25 deletions src/stdlib/meson.build
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5102dd4

Please sign in to comment.