File: testentropy.cpp

package info (click to toggle)
python-auditwheel 5.3.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 816 kB
  • sloc: python: 4,270; ansic: 205; cpp: 58; makefile: 20; f90: 12
file content (28 lines) | stat: -rw-r--r-- 636 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <Python.h>
#include <random>

static PyObject *
run(PyObject *self, PyObject *args)
{
    (void)self;
    (void)args;
    std::random_device rd;
    return PyLong_FromLong(rd.entropy() >= 0.0 ? 0 : -1);
}

/* Module initialization */
PyMODINIT_FUNC PyInit_testentropy(void)
{
    static PyMethodDef module_methods[] = {
        {"run", (PyCFunction)run, METH_NOARGS, "run."},
        {NULL}  /* Sentinel */
    };
    static struct PyModuleDef moduledef = {
        PyModuleDef_HEAD_INIT,
        "testentropy",
        "testentropy module",
        -1,
        module_methods,
    };
    return PyModule_Create(&moduledef);
}