pcsc-lite 2.3.0
sys_unix.c File Reference

This handles abstract system level calls. More...

#include "config.h"
#include <sys/time.h>
#include <limits.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include "misc.h"
#include "sys_generic.h"
#include "debuglog.h"

Go to the source code of this file.

Macros

#define _GNU_SOURCE   /* for secure_getenv(3) */
 

Functions

INTERNAL int SYS_Sleep (int iTimeVal)
 Makes the current process sleep for some seconds.
 
INTERNAL int SYS_USleep (int iTimeVal)
 Makes the current process sleep for some microseconds.
 
INTERNAL int SYS_RandomInt (void)
 Generate a pseudo random number.
 
INTERNAL void SYS_InitRandom (void)
 Initialize the random generator.
 
INTERNAL const char * SYS_GetEnv (const char *name)
 (More) secure version of getenv(3)
 

Detailed Description

This handles abstract system level calls.

Definition in file sys_unix.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE   /* for secure_getenv(3) */

Definition at line 41 of file sys_unix.c.

Function Documentation

◆ SYS_GetEnv()

INTERNAL const char * SYS_GetEnv ( const char * name)

(More) secure version of getenv(3)

Parameters
[in]namevariable environment name
Returns
value of the environment variable called "name"

Definition at line 168 of file sys_unix.c.

◆ SYS_InitRandom()

INTERNAL void SYS_InitRandom ( void )

Initialize the random generator.

Definition at line 140 of file sys_unix.c.

◆ SYS_RandomInt()

INTERNAL int SYS_RandomInt ( void )

Generate a pseudo random number.

Returns
a non-negative random number
Remarks
the range is at least up to 2^31.
this is a CSPRNG when getrandom() is available, LCG otherwise.
Warning
SYS_InitRandom() should be called (once) before using this function.
not thread safe when system lacks getrandom() syscall.
not cryptographically secure when system lacks getrandom() syscall.
if interrupted by a signal, this function may return 0.

Definition at line 108 of file sys_unix.c.

◆ SYS_Sleep()

INTERNAL int SYS_Sleep ( int iTimeVal)

Makes the current process sleep for some seconds.

Parameters
[in]iTimeValNumber of seconds to sleep.

Definition at line 62 of file sys_unix.c.

◆ SYS_USleep()

INTERNAL int SYS_USleep ( int iTimeVal)

Makes the current process sleep for some microseconds.

Parameters
[in]iTimeValNumber of microseconds to sleep.

Definition at line 80 of file sys_unix.c.