CAEN Utility  2.0.2
Utilities for CAEN projects
CAENMultiplatform.c File Reference

Generic wrappers to platform-dependent functions. More...

#include <CAENMultiplatform.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <CAENLogger.h>
#include <CAENMap.h>
#include <dlfcn.h>
#include <malloc.h>
#include <signal.h>
#include <spawn.h>
#include <strings.h>
#include <termios.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
Include dependency graph for CAENMultiplatform.c:

Go to the source code of this file.

Macros

#define KILL_BUFSIZE   (128)
 
#define _gcc_builtin(function, value)   __builtin_##function(value)
 
#define _gcc_builtin_64(function, value)   __builtin_##function(value)
 

Functions

static void _decodeError (const char *functName, int32_t resCode)
 
void * c_malloc (size_t size)
 
void * c_realloc (void *ptr, size_t size)
 
void * c_calloc (size_t nmemb, size_t size)
 
void c_free (void *ptr)
 
size_t c_malloc_size (void *ptr)
 
static char * _strndup (const char *str, size_t size)
 
char * c_strdup (const char *str)
 Wrapper to strdup(str), with check for NULL arguments. To be freed with c_free(). More...
 
char * c_strndup (const char *str, size_t size)
 Wrapper to strndup(str, size), with check for NULL arguments. To be freed with c_free(). More...
 
uint64_t c_get_time (void)
 Get time in milliseconds since 00:00:00 UTC, January 1, 1970. More...
 
int c_getch (void)
 
int c_kbhit (void)
 
int c_access (const char *pathname, int mode)
 
char * c_getcwd (char *buf, size_t size)
 
int c_chdir (const char *path)
 
int c_rmdir (const char *path)
 
int64_t c_getpid (void)
 
int c_strcasecmp (const char *s1, const char *s2)
 
int c_strncasecmp (const char *s1, const char *s2, size_t n)
 
char * c_getExpandedString (const char *filename)
 
int32_t c_getDirName (char *dest, const char *source)
 
int32_t c_getBaseName (char *dest, const char *source)
 
static bool _isProcValid (c_Process_t *proc)
 
int32_t c_getCurrentEnvironment (c_environment_t *dest)
 
c_Process_tc_newProc (void)
 
int32_t c_setProcExec (const char *exec, c_Process_t *proc)
 
int32_t c_addProcArg (const char *arg, c_Process_t *proc)
 
int32_t c_addProcEnv (const char *varname, const char *varvalue, c_Process_t *proc)
 
static void _freePointersArray (char **arr, size_t size)
 
static int32_t _mapToStringArray (c_environment_t *map, char ***dest, size_t *count)
 
static int32_t _startProcessLin (c_Process_t *proc)
 
static int32_t _endProcessLin (c_Process_t *proc)
 
static int32_t _getNCPULin (void)
 
DIR * c_opendir (const char *name)
 Not marked CAEN_UTILITY_API (meaningful only on 32-bit Windows), likely an original sin more than a choice. More...
 
int c_closedir (DIR *dir)
 
struct dirent * c_readdir (DIR *dir)
 Not marked CAEN_UTILITY_API (meaningful only on 32-bit Windows), likely an original sin more than a choice. More...
 
void c_rewinddir (DIR *dir)
 
int32_t c_startProcess (c_Process_t *proc)
 
int32_t c_endProcess (c_Process_t *proc)
 
void c_freeProc (c_Process_t *proc)
 
int32_t c_getNCPU (void)
 
int32_t c_pause (void)
 
int32_t c_mkdir (const char *path)
 
int32_t c_mkdirp (const char *dir)
 Same of c_mkdir() but creates also intermediate directories. More...
 
int32_t c_dlload (const char *libName, c_libhandle_t *libHandle)
 
int32_t c_dfload (c_libhandle_t hLib, const char *fcnName, c_fcnhandle_t *funcPtr)
 
int32_t c_dlclose (c_libhandle_t hLib)
 
static void _tmToSystemtime (const struct tm *src, c_systemtime_t *dest, uint16_t millis)
 
static void _systemtimeToTm (const c_systemtime_t *src, struct tm *dest)
 
void c_GetLocalTime (c_systemtime_t *now)
 
void c_GetSystemTime (c_systemtime_t *t)
 
double c_DiffSystemTime_sec (const c_systemtime_t *s1, const c_systemtime_t *s2)
 
uint32_t c_ctz (uint32_t value)
 
uint32_t c_clz (uint32_t value)
 
uint32_t c_popcount (uint32_t value)
 
uint32_t c_ctz64 (uint64_t value)
 
uint32_t c_clz64 (uint64_t value)
 
uint32_t c_popcount64 (uint64_t value)
 
int64_t c_frexp (double value, int16_t *exponent, int8_t *classification)
 
double c_ldexp (int64_t mantissa, int16_t exponent, int8_t classification)
 
bool c_checkFileExists (const char *fname)
 
uint64_t c_getCurrentTimeRepresentation (void)
 
int32_t c_remAllFiles (const char *dir)
 
int32_t c_killProcess (const char *procName)
 

Variables

static const c_locallogger_t __locallogger = { ( "CAENMultiplatformLog.txt" ), ( "CAENMultiplatform.c" ) }
 
static const double twop60 = 1.152921504606846976e+18
 
static const double twom60 = 8.673617379884035472e-19
 

Detailed Description

Generic wrappers to platform-dependent functions.

Author

Definition in file CAENMultiplatform.c.

Macro Definition Documentation

◆ KILL_BUFSIZE

#define KILL_BUFSIZE   (128)

Definition at line 86 of file CAENMultiplatform.c.

◆ _gcc_builtin

#define _gcc_builtin (   function,
  value 
)    __builtin_##function(value)

Definition at line 1348 of file CAENMultiplatform.c.

◆ _gcc_builtin_64

#define _gcc_builtin_64 (   function,
  value 
)    __builtin_##function(value)

Definition at line 1358 of file CAENMultiplatform.c.

Function Documentation

◆ _decodeError()

static void _decodeError ( const char *  functName,
int32_t  resCode 
)
static

Definition at line 91 of file CAENMultiplatform.c.

Here is the caller graph for this function:

◆ _strndup()

static char* _strndup ( const char *  str,
size_t  size 
)
static

Definition at line 194 of file CAENMultiplatform.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_getExpandedString()

char* c_getExpandedString ( const char *  filename)

Definition at line 395 of file CAENMultiplatform.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_getDirName()

int32_t c_getDirName ( char *  dest,
const char *  source 
)

Definition at line 448 of file CAENMultiplatform.c.

◆ c_getBaseName()

int32_t c_getBaseName ( char *  dest,
const char *  source 
)

Definition at line 472 of file CAENMultiplatform.c.

Here is the caller graph for this function:

◆ _isProcValid()

static bool _isProcValid ( c_Process_t proc)
static

Definition at line 497 of file CAENMultiplatform.c.

Here is the caller graph for this function:

◆ _freePointersArray()

static void _freePointersArray ( char **  arr,
size_t  size 
)
static

Definition at line 653 of file CAENMultiplatform.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _mapToStringArray()

static int32_t _mapToStringArray ( c_environment_t map,
char ***  dest,
size_t *  count 
)
static

Definition at line 661 of file CAENMultiplatform.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _startProcessLin()

static int32_t _startProcessLin ( c_Process_t proc)
static

Definition at line 896 of file CAENMultiplatform.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _endProcessLin()

static int32_t _endProcessLin ( c_Process_t proc)
static

Definition at line 952 of file CAENMultiplatform.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _getNCPULin()

static int32_t _getNCPULin ( void  )
static

Definition at line 962 of file CAENMultiplatform.c.

Here is the caller graph for this function:

◆ c_mkdir()

int32_t c_mkdir ( const char *  path)

Definition at line 1114 of file CAENMultiplatform.c.

Here is the caller graph for this function:

◆ c_mkdirp()

int32_t c_mkdirp ( const char *  dir)

Same of c_mkdir() but creates also intermediate directories.

Definition at line 1123 of file CAENMultiplatform.c.

Here is the call graph for this function:

◆ _tmToSystemtime()

static void _tmToSystemtime ( const struct tm *  src,
c_systemtime_t dest,
uint16_t  millis 
)
static

Definition at line 1226 of file CAENMultiplatform.c.

Here is the caller graph for this function:

◆ _systemtimeToTm()

static void _systemtimeToTm ( const c_systemtime_t src,
struct tm *  dest 
)
static

Definition at line 1244 of file CAENMultiplatform.c.

Here is the caller graph for this function:

◆ c_checkFileExists()

bool c_checkFileExists ( const char *  fname)

Definition at line 1654 of file CAENMultiplatform.c.

◆ c_remAllFiles()

int32_t c_remAllFiles ( const char *  dir)

Definition at line 1689 of file CAENMultiplatform.c.

Here is the call graph for this function:

Variable Documentation

◆ __locallogger

const c_locallogger_t __locallogger = { ( "CAENMultiplatformLog.txt" ), ( "CAENMultiplatform.c" ) }
static

Definition at line 88 of file CAENMultiplatform.c.

◆ twop60

const double twop60 = 1.152921504606846976e+18
static

Definition at line 1494 of file CAENMultiplatform.c.

◆ twom60

const double twom60 = 8.673617379884035472e-19
static

Definition at line 1495 of file CAENMultiplatform.c.