My Project
programmer's documentation
Macros | Functions
cs_base.c File Reference
#include "cs_defs.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#include <unistd.h>
#include <dlfcn.h>
#include <ple_defs.h>
#include <ple_coupling.h>
#include "bft_backtrace.h"
#include "bft_mem_usage.h"
#include "bft_mem.h"
#include "bft_printf.h"
#include "cs_file.h"
#include "cs_fp_exception.h"
#include "cs_log.h"
#include "cs_timer.h"
#include "cs_base.h"
Include dependency graph for cs_base.c:

Macros

#define _CS_EXIT_DEPLIB_CRASH_WORKAROUND   0
 

Functions

char * cs_base_get_app_name (int argc, const char *argv[])
 
void cs_base_logfile_head (int argc, char *argv[])
 
void cs_base_mpi_init (int *argc, char **argv[])
 
void cs_exit (int status)
 
void cs_base_error_init (bool signal_defaults)
 
void cs_base_mem_init (void)
 
void cs_base_mem_finalize (void)
 
void cs_base_time_summary (void)
 
void cs_base_update_status (const char *format,...)
 Update status file. More...
 
void cs_base_trace_set (bool trace)
 
void cs_base_bft_printf_init (const char *log_name, bool rn_log_flag)
 
void cs_base_bft_printf_set (const char *log_name, bool rn_log_flag)
 
const char * cs_base_bft_printf_name (void)
 
bool cs_base_bft_printf_suppressed (void)
 
void cs_base_warn (const char *file_name, int line_num)
 
void cs_base_atexit_set (cs_base_atexit_t *const fct)
 
char * cs_base_string_f_to_c_create (const char *f_str, int f_len)
 
void cs_base_string_f_to_c_free (char **c_str)
 
void cs_base_option_string_clean (char *s)
 
const char * cs_base_get_localedir (void)
 
const char * cs_base_get_pkgdatadir (void)
 
const char * cs_base_get_pkglibdir (void)
 
void cs_base_check_bool (bool *b)
 
FILE * cs_base_open_properties_data_file (const char *base_name)
 
void * cs_base_dlopen (const char *filename)
 Load a dynamic library. More...
 
void * cs_base_dlopen_plugin (const char *name)
 Load a plugin's dynamic library. More...
 
int cs_base_dlopen_get_flags (void)
 Get flags for dlopen. More...
 
void cs_base_dlopen_set_flags (int flags)
 Set flags for dlopen. More...
 
void cs_base_dlclose (const char *filename, void *handle)
 Unload a dynamic library. More...
 
void * cs_base_get_dl_function_pointer (void *handle, const char *name, bool errors_are_fatal)
 Get a shared library function pointer. More...
 
void cs_base_backtrace_dump (FILE *f, int lv_start)
 Dump a stack trace to a file. More...
 

Macro Definition Documentation

◆ _CS_EXIT_DEPLIB_CRASH_WORKAROUND

#define _CS_EXIT_DEPLIB_CRASH_WORKAROUND   0

Function Documentation

◆ cs_base_atexit_set()

void cs_base_atexit_set ( cs_base_atexit_t *const  fct)

◆ cs_base_backtrace_dump()

void cs_base_backtrace_dump ( FILE *  f,
int  lv_start 
)

Dump a stack trace to a file.

Parameters
[in]fpointer to file in which to dump trace
[in]lv_startstart level in stack trace

◆ cs_base_bft_printf_init()

void cs_base_bft_printf_init ( const char *  log_name,
bool  rn_log_flag 
)

◆ cs_base_bft_printf_name()

const char* cs_base_bft_printf_name ( void  )

◆ cs_base_bft_printf_set()

void cs_base_bft_printf_set ( const char *  log_name,
bool  rn_log_flag 
)

◆ cs_base_bft_printf_suppressed()

bool cs_base_bft_printf_suppressed ( void  )

◆ cs_base_check_bool()

void cs_base_check_bool ( bool *  b)

◆ cs_base_dlclose()

void cs_base_dlclose ( const char *  filename,
void *  handle 
)

Unload a dynamic library.

Note that the dlopen underlying mechanism uses a reference count, so a library is really unloaded only one cs_base_dlclose has been called the same number of times as cs_base_dlopen.

Parameters
[in]filenameoptional path to shared library file name for error logging, or NULL
[in]handlehandle to shared library

◆ cs_base_dlopen()

void* cs_base_dlopen ( const char *  filename)

Load a dynamic library.

Parameters
[in]filenamepath to shared library file
Returns
handle to shared library

◆ cs_base_dlopen_get_flags()

int cs_base_dlopen_get_flags ( void  )

Get flags for dlopen.

Returns
flags used for dlopen.

◆ cs_base_dlopen_plugin()

void* cs_base_dlopen_plugin ( const char *  name)

Load a plugin's dynamic library.

This function is similar to cs_base_dlopen, execpt that only the base plugin file name (with no extension) needs to be given. It is assumed the file is available in the code's "pkglibdir" directory,

Parameters
[in]namepath to shared library file
Returns
handle to shared library

◆ cs_base_dlopen_set_flags()

void cs_base_dlopen_set_flags ( int  flags)

Set flags for dlopen.

Parameters
[in]flagsflags to set

◆ cs_base_error_init()

void cs_base_error_init ( bool  signal_defaults)

◆ cs_base_get_app_name()

char* cs_base_get_app_name ( int  argc,
const char *  argv[] 
)

◆ cs_base_get_dl_function_pointer()

void* cs_base_get_dl_function_pointer ( void *  handle,
const char *  name,
bool  errors_are_fatal 
)

Get a shared library function pointer.

Parameters
[in]handlehandle to shared library
[in]namename of function symbol in library
[in]errors_are_fatalabort if true, silently ignore if false
Returns
pointer to function in shared library

◆ cs_base_get_localedir()

const char* cs_base_get_localedir ( void  )

◆ cs_base_get_pkgdatadir()

const char* cs_base_get_pkgdatadir ( void  )

◆ cs_base_get_pkglibdir()

const char* cs_base_get_pkglibdir ( void  )

◆ cs_base_logfile_head()

void cs_base_logfile_head ( int  argc,
char *  argv[] 
)

◆ cs_base_mem_finalize()

void cs_base_mem_finalize ( void  )

◆ cs_base_mem_init()

void cs_base_mem_init ( void  )

◆ cs_base_mpi_init()

void cs_base_mpi_init ( int *  argc,
char **  argv[] 
)

◆ cs_base_open_properties_data_file()

FILE* cs_base_open_properties_data_file ( const char *  base_name)

◆ cs_base_option_string_clean()

void cs_base_option_string_clean ( char *  s)

◆ cs_base_string_f_to_c_create()

char* cs_base_string_f_to_c_create ( const char *  f_str,
int  f_len 
)

◆ cs_base_string_f_to_c_free()

void cs_base_string_f_to_c_free ( char **  c_str)

◆ cs_base_time_summary()

void cs_base_time_summary ( void  )

◆ cs_base_trace_set()

void cs_base_trace_set ( bool  trace)

◆ cs_base_update_status()

void cs_base_update_status ( const char *  format,
  ... 
)

Update status file.

If the format string is NULL, the file is removed.

Parameters
[in]formatformat string, or NULL
[in]...format arguments

◆ cs_base_warn()

void cs_base_warn ( const char *  file_name,
int  line_num 
)

◆ cs_exit()

void cs_exit ( int  status)