Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
Loading...
Searching...
No Matches
system.c File Reference
#include "system.h"
#include <sys/stat.h>
#include <string.h>
#include <execinfo.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pwd.h>
#include <fcntl.h>
#include <sys/mman.h>
+ Include dependency graph for system.c:

Go to the source code of this file.

Macros

#define FMT   "%*s%*s"
 
#define MID(LEN, STR)
 

Functions

size_t system_total_memory ()
 
char * system_home_path ()
 
const char * system_env_var (const char *var)
 
int system_mmap (void **base, int *fd, const char *file, size_t shm_size, size_t shm_off, int truncate)
 
off_t system_file_size (const char *file)
 
const char * system_exec_name ()
 
int system_process_id ()
 
int system_thread_id ()
 
char * formatStackLine (const char *bt_sym, int *cwidths, char *dest)
 
const char * system_backtrace (unsigned int skip)
 

Variables

static char __backtraceStr [32768]
 

Macro Definition Documentation

◆ FMT

#define FMT   "%*s%*s"

Definition at line 149 of file system.c.

Referenced by system_backtrace().

◆ MID

#define MID ( LEN,
STR )
Value:
(int) (LEN / 2 + strlen(STR)), STR, (int) (LEN / 2 - strlen(STR)), " "

Definition at line 150 of file system.c.

Referenced by system_backtrace().

Function Documentation

◆ formatStackLine()

char * formatStackLine ( const char * bt_sym,
int * cwidths,
char * dest )

Definition at line 101 of file system.c.

Referenced by system_backtrace().

+ Here is the caller graph for this function:

◆ system_backtrace()

const char * system_backtrace ( unsigned int skip)

Get stack backtrace for calling thread. Returned string does not end with a new line.

Note
Do not free or modify returned value
Parameters
skipNumber of functions to skip from trace.0 will show up to the caller.
Returns
formated acktrace

Definition at line 154 of file system.c.

References __backtraceStr, FMT, formatStackLine(), and MID.

Referenced by _arax_assert().

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

◆ system_env_var()

const char * system_env_var ( const char * var)

Get value of enviroment variable var. NULL if variable not set.

Note
Do NOT free returned pointer.
Returns
NULL terminated string with enviroment variable value.

Definition at line 32 of file system.c.

Referenced by conf_get(), and utils_config_get_source().

+ Here is the caller graph for this function:

◆ system_exec_name()

const char * system_exec_name ( )

Get current executable name

Definition at line 78 of file system.c.

◆ system_file_size()

off_t system_file_size ( const char * file)

Get size of file in bytes.

Returns
File size in bytes, 0 on failure.

Definition at line 68 of file system.c.

Referenced by conf_get(), and system_mmap().

+ Here is the caller graph for this function:

◆ system_home_path()

char * system_home_path ( )

Get current users home directory.

Note
Do NOT free returned pointer.
Returns
NULL terminated string with home path.

Definition at line 21 of file system.c.

Referenced by utils_config_alloc_path().

+ Here is the caller graph for this function:

◆ system_mmap()

int system_mmap ( void ** base,
int * fd,
const char * file,
size_t shm_size,
size_t shm_off,
int truncate )

Type to mmap file of size shm_size.

Parameters
baseIf succesfull will return mmap location, null otherwise. Initial value is used as a hint.
fdFile descriptor. If succesfull will be positive.Negative on failure.
fileLocation of mmap backing file.
shm_sizeSize of resulting mmap and file.
shm_offSkip bytes from the mmap of file.
truncateTruncate file to shm_size bytes.
Returns
0 on success, check base and fd to figure error.

Definition at line 37 of file system.c.

References fd, and system_file_size().

Referenced by _arax_init().

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

◆ system_process_id()

int system_process_id ( )

Get PID of current process

Definition at line 91 of file system.c.

Referenced by _arax_init(), and arax_exit().

+ Here is the caller graph for this function:

◆ system_thread_id()

int system_thread_id ( )

Get thread id of current process thread

Definition at line 96 of file system.c.

◆ system_total_memory()

size_t system_total_memory ( )

Return total memory in bytes.

Returns
Total memory in bytes.

Definition at line 13 of file system.c.

Referenced by _arax_init().

+ Here is the caller graph for this function:

Variable Documentation

◆ __backtraceStr

char __backtraceStr[32768]
static

Definition at line 152 of file system.c.

Referenced by system_backtrace().