mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-20 05:11:46 +03:00
Initial
This commit is contained in:
commit
aa7e4cce8e
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
||||
libent is a simple cross-platform entropy gathering library. It tries
|
||||
to use the best available source of randomness, and is meant to be used
|
||||
in applications that need high-quality entropy, e.g. for generating
|
||||
cryptographic keys.
|
26
include/ent/detail.h
Normal file
26
include/ent/detail.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef _LIBENT_DETAIL_H
|
||||
#define _LIBENT_DETAIL_H
|
||||
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
# ifdef WIN_EXPORT
|
||||
# ifdef __GNUC__
|
||||
# define ENT_EXPORT __attribute__ ((dllexport))
|
||||
# else
|
||||
# define ENT_EXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# ifdef __GNUC__
|
||||
# define ENT_EXPORT __attribute__ ((dllimport))
|
||||
# else
|
||||
# define ENT_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# if __GNUC__ >= 4
|
||||
# define ENT_EXPORT __attribute__ ((visibility ("default")))
|
||||
# else
|
||||
# define ENT_EXPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _LIBENT_DETAIL_H */
|
12
include/ent/ent.h
Normal file
12
include/ent/ent.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef _LIBENT_ENT_H
|
||||
#define _LIBENT_ENT_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <ent/detail.h>
|
||||
|
||||
ENT_EXPORT
|
||||
int
|
||||
ent_getentropy(void *buf, size_t buflen);
|
||||
|
||||
#endif /* _LIBENT_ENT_H */
|
21
meson.build
Normal file
21
meson.build
Normal file
@ -0,0 +1,21 @@
|
||||
project('libent', 'c', 'cpp',
|
||||
default_options : ['c_std=c99', 'cpp_std=c++11'],
|
||||
version : '0.0.1',
|
||||
license : 'MIT')
|
||||
|
||||
inc = include_directories('include')
|
||||
|
||||
install_headers('include/ent/ent.h', subdir : 'ent')
|
||||
|
||||
ent_sources = ['src/ent.c']
|
||||
libent = shared_library('ent',
|
||||
ent_sources,
|
||||
include_directories : inc,
|
||||
install : true)
|
||||
|
||||
pkg_mod = import('pkgconfig')
|
||||
pkg_mod.generate(libraries : libent,
|
||||
version : '0.0',
|
||||
name : 'libent',
|
||||
filebase : 'ent',
|
||||
description : 'A library to get entropy.')
|
17
src/ent.c
Normal file
17
src/ent.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <ent/ent.h>
|
||||
|
||||
#if defined __OPENBSD__ || (defined __linux__ && defined _DEFAULT_SOURCE)
|
||||
# include <unistd.h>
|
||||
# define getentropy_impl getentropy
|
||||
#elif defined __APPLE__ && defined __MACH__
|
||||
# include <sys/random.h>
|
||||
# define getentropy_impl getentropy
|
||||
#else
|
||||
# error "Port: getentropy unimplemented"
|
||||
#endif
|
||||
|
||||
int
|
||||
ent_getentropy(void *buf, size_t buflen)
|
||||
{
|
||||
return getentropy_impl(buf, buflen);
|
||||
}
|
Loading…
Reference in New Issue
Block a user