LiVES  3.2.0
Macros | Typedefs | Functions
machinestate.c File Reference
#include <sys/statvfs.h>
#include "main.h"
#include "callbacks.h"

Go to the source code of this file.

Macros

#define NCYCS   16
 
#define OIL_MEMCPY_MAX_BYTES   12288
 susbtitute memory functions. These must be real functions and not #defines since we need fn pointers More...
 
#define _cpy_if_nonnull(d, s, size)   (d ? lives_memcpy(d, s, size) : d)
 
#define SECS_IN_DAY   86400
 
#define DU_BLOCKSIZE   1
 
#define hasNulByte(x)   (((x) - 0x0101010101010101) & ~(x) & 0x8080808080808080)
 each byte B can be thought of as a signed char, subtracting 1 sets bit 7 if B was <= 0, then AND with ~B clears bit 7 if it was already set (i.e B was < 0), thus bit 7 only remains set if the byte started as 0. More...
 
#define getnulpos(nulmask)
 
#define getnulpos_be(nulmask)
 
#define HASHROOT   5381
 
#define get16bits(d)   (*((const uint16_t *) (d)))
 
#define FUNCSIG_VOID   0X00000000
 
#define FUNCSIG_INT   0X00000001
 
#define FUNCSIG_DOUBLE   0X00000002
 
#define FUNCSIG_STRING   0X00000004
 
#define FUNCSIG_VOIDP   0X0000000D
 
#define FUNCSIG_INT_INT64   0X00000015
 
#define FUNCSIG_STRING_INT   0X00000041
 
#define FUNCSIG_STRING_BOOL   0X00000043
 
#define FUNCSIG_VOIDP_VOIDP   0X000000DD
 
#define FUNCSIG_VOIDP_DOUBLE   0X000000D2
 
#define FUNCSIG_PLANTP_BOOL   0X000000E3
 
#define FUNCSIG_VOIDP_VOIDP_VOIDP   0X00000DDD
 
#define FUNCSIG_PLANTP_VOIDP_INT64   0X00000ED5
 
#define FUNCSIG_STRING_STRING_VOIDP_INT   0X000044D1
 
#define FUNCSIG_INT_INT_BOOL_VOIDP   0X0000113D
 
#define FUNCSIG_INT_INT_INT_BOOL_VOIDP   0X0001113D
 
#define FUNCSIG_VOIDP_STRING_STRING_INT64_INT   0X000D4451
 
#define FUNCSIG_STRING_STRING_VOIDP_INT_STRING_VOIDP   0X0044D14D
 
#define _join(stype)
 
#define MINPOOLTHREADS   8
 
#define XTEMP   "XXXXXXXXXX"
 
#define DISK_STATS_FILE   "/proc/diskstats"
 
#define CPU_STATS_FILE   "/proc/stat"
 

Typedefs

typedef weed_plantptr_t lives_proc_thread_t
 lives proc_threads API More...
 

Functions

LIVES_LOCAL_INLINE char * mini_popen (char *cmd)
 
LIVES_GLOBAL_INLINE uint64_t fastrand (void)
 
LIVES_GLOBAL_INLINE void fastrand_add (uint64_t entropy)
 
LIVES_GLOBAL_INLINE double fastrand_dbl (double range)
 
LIVES_GLOBAL_INLINE uint32_t fastrand_int (uint32_t range)
 pick a pseudo random uint between 0 and range (inclusive) More...
 
LIVES_GLOBAL_INLINE void lives_srandom (unsigned int seed)
 
LIVES_GLOBAL_INLINE uint64_t lives_random (void)
 
void lives_get_randbytes (void *ptr, size_t size)
 
uint64_t gen_unique_id (void)
 
void init_random ()
 
void make_nxttab (void)
 
void autotune_u64 (weed_plant_t *tuner, uint64_t min, uint64_t max, int ntrials, double cost)
 
uint64_t nxtval (uint64_t val, uint64_t lim, boolean less)
 
uint64_t autotune_u64_end (weed_plant_t **tuner, uint64_t val)
 
void * _ext_malloc (size_t n)
 
void * _ext_malloc_and_copy (size_t bsize, const void *block)
 
void _ext_unmalloc_and_copy (size_t bsize, void *p)
 
void _ext_free (void *p)
 
void * _ext_free_and_return (void *p)
 
void * _ext_memcpy (void *dest, const void *src, size_t n)
 
int _ext_memcmp (const void *s1, const void *s2, size_t n)
 
void * _ext_memset (void *p, int i, size_t n)
 
void * _ext_memmove (void *dest, const void *src, size_t n)
 
void * _ext_realloc (void *p, size_t n)
 
void * _ext_calloc (size_t nmemb, size_t msize)
 
LIVES_GLOBAL_INLINE void * lives_free_and_return (void *p)
 TODO: this file should be split into at least: memory functions, thread functions, file utils. More...
 
LIVES_GLOBAL_INLINE size_t get_max_align (size_t req_size, size_t align_max)
 
LIVES_GLOBAL_INLINE void * lives_calloc_safety (size_t nmemb, size_t xsize)
 
LIVES_GLOBAL_INLINE void * lives_recalloc (void *p, size_t nmemb, size_t omemb, size_t xsize)
 
void quick_free (void *p)
 
void * quick_calloc (size_t n, size_t s)
 
boolean init_memfuncs (void)
 
boolean init_thread_memfuncs (void)
 
char * get_md5sum (const char *filename)
 
char * lives_format_storage_space_string (uint64_t space)
 
lives_storage_status_t get_storage_status (const char *dir, uint64_t warn_level, int64_t *dsval, int64_t ds_resvd)
 
boolean disk_monitor_running (const char *dir)
 
lives_proc_thread_t disk_monitor_start (const char *dir)
 
int64_t disk_monitor_check_result (const char *dir)
 
LIVES_GLOBAL_INLINE int64_t disk_monitor_wait_result (const char *dir, ticks_t timeout)
 
void disk_monitor_forget (void)
 
uint64_t get_ds_free (const char *dir)
 
LIVES_GLOBAL_INLINE ticks_t lives_get_relative_ticks (ticks_t origsecs, ticks_t orignsecs)
 
LIVES_GLOBAL_INLINE ticks_t lives_get_current_ticks (void)
 
char * lives_datetime_rel (const char *datetime)
 
char * lives_datetime (uint64_t secs, boolean use_local)
 
boolean check_dev_busy (char *devstr)
 
boolean compress_files_in_dir (const char *dir, int method, void *data)
 
off_t get_file_size (int fd)
 
off_t sget_file_size (const char *name)
 
void reget_afilesize (int fileno)
 
off_t reget_afilesize_inner (int fileno)
 
boolean is_empty_dir (const char *dirname)
 
char * get_mountpoint_for (const char *dir)
 
off_t get_dir_size (const char *dirname)
 
void free_fdets_list (LiVESList **listp)
 
int stat_to_file_dets (const char *fname, lives_file_dets_t *fdets)
 
void * _item_to_file_details (LiVESList **listp, const char *item, const char *orig_loc, uint64_t extra, int type)
 create a list from a (sub)directory '. More...
 
lives_proc_thread_t dir_to_file_details (LiVESList **listp, const char *dir, const char *orig_loc, uint64_t extra)
 create a list from a (sub)directory '. More...
 
lives_proc_thread_t ordfile_to_file_details (LiVESList **listp, const char *ofname, const char *orig_loc, uint64_t extra)
 
int check_for_bad_ffmpeg (void)
 
LIVES_GLOBAL_INLINE char * lives_concat_sep (char *st, const char *sep, char *x)
 
LIVES_GLOBAL_INLINE char * lives_concat (char *st, char *x)
 
LIVES_GLOBAL_INLINE int lives_strappend (const char *string, int len, const char *xnew)
 
LIVES_GLOBAL_INLINE const char * lives_strappendf (const char *string, int len, const char *fmt,...)
 
LIVES_GLOBAL_INLINE size_t lives_strlen (const char *s)
 
LIVES_GLOBAL_INLINE char * lives_strdup_quick (const char *s)
 
LIVES_GLOBAL_INLINE boolean lives_strcmp (const char *st1, const char *st2)
 returns FALSE if strings match More...
 
LIVES_GLOBAL_INLINE int lives_strcmp_ordered (const char *st1, const char *st2)
 
LIVES_GLOBAL_INLINE boolean lives_strncmp (const char *st1, const char *st2, size_t len)
 returns FALSE if strings match More...
 
LIVES_GLOBAL_INLINE uint32_t lives_string_hash (const char *st)
 
LIVES_GLOBAL_INLINE uint32_t fast_hash (const char *key)
 
LIVES_GLOBAL_INLINE char * lives_strstop (char *st, const char term)
 
LIVES_GLOBAL_INLINE char * lives_chomp (char *buff)
 
LIVES_GLOBAL_INLINE char * lives_strtrim (const char *buff)
 
LIVES_GLOBAL_INLINE void lives_proc_thread_free (lives_proc_thread_t lpt)
 
lives_proc_thread_t lives_proc_thread_create (lives_thread_attr_t attr, lives_funcptr_t func, int return_type, const char *args_fmt,...)
 create the specific plant which defines a background task to be run More...
 
void * main_thread_execute (lives_funcptr_t func, int return_type, void *retval, const char *args_fmt,...)
 
LIVES_GLOBAL_INLINE void lives_proc_thread_sync_ready (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE boolean lives_proc_thread_check (lives_proc_thread_t tinfo)
 returns FALSE while the thread is running, TRUE once it has finished More...
 
LIVES_GLOBAL_INLINE int lives_proc_thread_signalled (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE int64_t lives_proc_thread_signalled_idx (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE void lives_proc_thread_set_cancellable (lives_proc_thread_t tinfo)
 only threads with no return value can possibly be cancellable. For threads with a value, use lives_proc_thread_dontcare() More...
 
LIVES_GLOBAL_INLINE boolean lives_proc_thread_get_cancellable (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE boolean lives_proc_thread_cancel (lives_proc_thread_t tinfo)
 
boolean lives_proc_thread_dontcare (lives_proc_thread_t tinfo)
 tell a threead with return value that we no longer need the value so it can free itself More...
 
LIVES_GLOBAL_INLINE boolean lives_proc_thread_cancelled (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE void lives_proc_thread_join (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE int lives_proc_thread_join_int (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE double lives_proc_thread_join_double (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE int lives_proc_thread_join_boolean (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE int64_t lives_proc_thread_join_int64 (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE char * lives_proc_thread_join_string (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE weed_funcptr_t lives_proc_thread_join_funcptr (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE void * lives_proc_thread_join_voidptr (lives_proc_thread_t tinfo)
 
LIVES_GLOBAL_INLINE weed_plantptr_t lives_proc_thread_join_plantptr (lives_proc_thread_t tinfo)
 
void * fg_run_func (lives_proc_thread_t lpt, void *retval)
 
void resubmit_proc_thread (lives_proc_thread_t thread_info, lives_thread_attr_t attr)
 (re)submission point, the function call is added to the threadpool tasklist if we have sufficient threads the task will be run at once, if all threads are busy then MINPOOLTHREADS new threads will be created and added to the pool More...
 
lives_thread_data_t * get_thread_data (void)
 
LIVES_GLOBAL_INLINE lives_threadvars_tget_threadvars (void)
 
lives_thread_data_t * lives_thread_data_create (uint64_t idx)
 
boolean do_something_useful (lives_thread_data_t *tdata)
 
LIVES_GLOBAL_INLINE weed_plant_t * lives_plant_new (int subtype)
 
LIVES_GLOBAL_INLINE weed_plant_t * lives_plant_new_with_index (int subtype, int64_t index)
 
void lives_threadpool_init (void)
 
void lives_threadpool_finish (void)
 
int lives_thread_create (lives_thread_t *thread, lives_thread_attr_t attr, lives_funcptr_t func, void *arg)
 
uint64_t lives_thread_join (lives_thread_t work, void **retval)
 
LIVES_GLOBAL_INLINE pid_t lives_getpid (void)
 
LIVES_GLOBAL_INLINE int lives_getuid (void)
 
LIVES_GLOBAL_INLINE int lives_getgid (void)
 
LIVES_GLOBAL_INLINE void swab2 (const void *from, const void *to, size_t gran)
 
LIVES_GLOBAL_INLINE void swab4 (const void *from, const void *to, size_t gran)
 
LIVES_GLOBAL_INLINE void swab8 (const void *from, const void *to, size_t gran)
 
LIVES_GLOBAL_INLINE void reverse_bytes (char *buff, size_t count, size_t gran)
 
boolean reverse_buffer (uint8_t *buff, size_t count, size_t chunk)
 
void reset_effort (void)
 
void update_effort (int nthings, boolean badthings)
 
char * grep_in_cmd (const char *cmd, int mstart, int npieces, const char *mphrase, int ridx, int rlen)
 
LIVES_LOCAL_INLINE boolean mini_run (char *cmd)
 
LiVESResponseType send_to_trash (const char *item)
 
char * get_wid_for_name (const char *wname)
 x11 stuff More...
 
boolean hide_x11_window (const char *wid)
 
boolean unhide_x11_window (const char *wid)
 
boolean activate_x11_window (const char *wid)
 
boolean get_wm_caps (void)
 
int get_window_stack_level (LiVESXWindow *xwin, int *nwins)
 
boolean show_desktop_panel (void)
 
boolean hide_desktop_panel (void)
 
boolean get_x11_visible (const char *wname)
 
char * get_systmp (const char *suff, boolean is_dir)
 
char * get_worktmp (const char *prefix)
 
char * get_worktmpfile (const char *prefix)
 
boolean check_snap (const char *prog)
 
boolean get_distro_dets (void)
 
int get_num_cpus (void)
 
boolean get_machine_dets (void)
 
double get_disk_load (const char *mp)
 
int64_t get_cpu_load (int cpun)
 percent * 1 million More...
 

Macro Definition Documentation

◆ _cpy_if_nonnull

#define _cpy_if_nonnull (   d,
  s,
  size 
)    (d ? lives_memcpy(d, s, size) : d)

Definition at line 527 of file machinestate.c.

◆ _join

#define _join (   stype)
Value:
lives_nanosleep_until_nonzero(weed_leaf_num_elements(tinfo, _RV_)); \
return weed_get_##stype##_value(tinfo, _RV_, NULL);

Definition at line 1976 of file machinestate.c.

◆ CPU_STATS_FILE

#define CPU_STATS_FILE   "/proc/stat"

Definition at line 3394 of file machinestate.c.

◆ DISK_STATS_FILE

#define DISK_STATS_FILE   "/proc/diskstats"

Definition at line 3357 of file machinestate.c.

◆ DU_BLOCKSIZE

#define DU_BLOCKSIZE   1

Definition at line 1066 of file machinestate.c.

◆ FUNCSIG_DOUBLE

#define FUNCSIG_DOUBLE   0X00000002

◆ FUNCSIG_INT

#define FUNCSIG_INT   0X00000001

◆ FUNCSIG_INT_INT64

#define FUNCSIG_INT_INT64   0X00000015

◆ FUNCSIG_INT_INT_BOOL_VOIDP

#define FUNCSIG_INT_INT_BOOL_VOIDP   0X0000113D

◆ FUNCSIG_INT_INT_INT_BOOL_VOIDP

#define FUNCSIG_INT_INT_INT_BOOL_VOIDP   0X0001113D

◆ FUNCSIG_PLANTP_BOOL

#define FUNCSIG_PLANTP_BOOL   0X000000E3

◆ FUNCSIG_PLANTP_VOIDP_INT64

#define FUNCSIG_PLANTP_VOIDP_INT64   0X00000ED5

◆ FUNCSIG_STRING

#define FUNCSIG_STRING   0X00000004

◆ FUNCSIG_STRING_BOOL

#define FUNCSIG_STRING_BOOL   0X00000043

◆ FUNCSIG_STRING_INT

#define FUNCSIG_STRING_INT   0X00000041

◆ FUNCSIG_STRING_STRING_VOIDP_INT

#define FUNCSIG_STRING_STRING_VOIDP_INT   0X000044D1

◆ FUNCSIG_STRING_STRING_VOIDP_INT_STRING_VOIDP

#define FUNCSIG_STRING_STRING_VOIDP_INT_STRING_VOIDP   0X0044D14D

◆ FUNCSIG_VOID

#define FUNCSIG_VOID   0X00000000

◆ FUNCSIG_VOIDP

#define FUNCSIG_VOIDP   0X0000000D

◆ FUNCSIG_VOIDP_DOUBLE

#define FUNCSIG_VOIDP_DOUBLE   0X000000D2

◆ FUNCSIG_VOIDP_STRING_STRING_INT64_INT

#define FUNCSIG_VOIDP_STRING_STRING_INT64_INT   0X000D4451

◆ FUNCSIG_VOIDP_VOIDP

#define FUNCSIG_VOIDP_VOIDP   0X000000DD

◆ FUNCSIG_VOIDP_VOIDP_VOIDP

#define FUNCSIG_VOIDP_VOIDP_VOIDP   0X00000DDD

◆ get16bits

#define get16bits (   d)    (*((const uint16_t *) (d)))

Definition at line 1594 of file machinestate.c.

◆ getnulpos

#define getnulpos (   nulmask)
Value:
((nulmask & 2155905152ul) ? ((nulmask & 32896ul) ? ((nulmask & 128ul) ? 0 : 1) : \
((nulmask & 8388608ul) ? 2 : 3)) : (nulmask & 141287244169216ul) ? \
((nulmask & 549755813888ul) ? 4 : 5) : ((nulmask & 36028797018963968ul) ? 6 : 7))

Definition at line 1460 of file machinestate.c.

◆ getnulpos_be

#define getnulpos_be (   nulmask)
Value:
((nulmask & 9259542121117908992ul) ? ((nulmask & 9259400833873739776ul) ? \
((nulmask & 9223372036854775808ul) ? 0 : 1) : ((nulmask & 140737488355328ul) ? 2 : 3)) \
: (nulmask & 2155872256ul) ? ((nulmask & 2147483648ul) ? 4 : 5) : ((nulmask & 32768ul) ? 6 : 7))

Definition at line 1464 of file machinestate.c.

◆ HASHROOT

#define HASHROOT   5381

Definition at line 1584 of file machinestate.c.

◆ hasNulByte

#define hasNulByte (   x)    (((x) - 0x0101010101010101) & ~(x) & 0x8080808080808080)

each byte B can be thought of as a signed char, subtracting 1 sets bit 7 if B was <= 0, then AND with ~B clears bit 7 if it was already set (i.e B was < 0), thus bit 7 only remains set if the byte started as 0.

Definition at line 1459 of file machinestate.c.

◆ MINPOOLTHREADS

#define MINPOOLTHREADS   8

Definition at line 2128 of file machinestate.c.

◆ NCYCS

#define NCYCS   16

Definition at line 196 of file machinestate.c.

◆ OIL_MEMCPY_MAX_BYTES

#define OIL_MEMCPY_MAX_BYTES   12288

susbtitute memory functions. These must be real functions and not #defines since we need fn pointers

Definition at line 430 of file machinestate.c.

◆ SECS_IN_DAY

#define SECS_IN_DAY   86400

Definition at line 841 of file machinestate.c.

◆ XTEMP

#define XTEMP   "XXXXXXXXXX"

Definition at line 3170 of file machinestate.c.

Typedef Documentation

◆ lives_proc_thread_t

typedef weed_plantptr_t lives_proc_thread_t

lives proc_threads API

  • the only requirements are to call lives_proc_thread_create() which will generate a lives_proc_thread_t and run it, and then (depending on the return_type parameter, call one of the lives_proc_thread_join_*() functions

(see that function for more comments)

Definition at line 1670 of file machinestate.c.

Function Documentation

◆ _ext_calloc()

void* _ext_calloc ( size_t  nmemb,
size_t  msize 
)

Definition at line 584 of file machinestate.c.

◆ _ext_free()

void _ext_free ( void *  p)

Definition at line 556 of file machinestate.c.

Referenced by _ext_free_and_return(), and _ext_unmalloc_and_copy().

◆ _ext_free_and_return()

void* _ext_free_and_return ( void *  p)

Definition at line 565 of file machinestate.c.

◆ _ext_malloc()

void* _ext_malloc ( size_t  n)

Definition at line 530 of file machinestate.c.

◆ _ext_malloc_and_copy()

void* _ext_malloc_and_copy ( size_t  bsize,
const void *  block 
)

Definition at line 539 of file machinestate.c.

◆ _ext_memcmp()

int _ext_memcmp ( const void *  s1,
const void *  s2,
size_t  n 
)

Definition at line 569 of file machinestate.c.

◆ _ext_memcpy()

void* _ext_memcpy ( void *  dest,
const void *  src,
size_t  n 
)

Definition at line 567 of file machinestate.c.

◆ _ext_memmove()

void* _ext_memmove ( void *  dest,
const void *  src,
size_t  n 
)

Definition at line 573 of file machinestate.c.

◆ _ext_memset()

void* _ext_memset ( void *  p,
int  i,
size_t  n 
)

Definition at line 571 of file machinestate.c.

◆ _ext_realloc()

void* _ext_realloc ( void *  p,
size_t  n 
)

Definition at line 575 of file machinestate.c.

◆ _ext_unmalloc_and_copy()

void _ext_unmalloc_and_copy ( size_t  bsize,
void *  p 
)

Definition at line 547 of file machinestate.c.

◆ _item_to_file_details()

void* _item_to_file_details ( LiVESList **  listp,
const char *  item,
const char *  orig_loc,
uint64_t  extra,
int  type 
)

create a list from a (sub)directory '.

' and '..' are ignored subdir can be NULL

Definition at line 1227 of file machinestate.c.

Referenced by dir_to_file_details(), and ordfile_to_file_details().

◆ activate_x11_window()

boolean activate_x11_window ( const char *  wid)

Definition at line 2998 of file machinestate.c.

Referenced by do_startup_interface_query(), and do_workdir_query().

◆ autotune_u64()

void autotune_u64 ( weed_plant_t *  tuner,
uint64_t  min,
uint64_t  max,
int  ntrials,
double  cost 
)

Definition at line 182 of file machinestate.c.

◆ autotune_u64_end()

uint64_t autotune_u64_end ( weed_plant_t **  tuner,
uint64_t  val 
)

Definition at line 259 of file machinestate.c.

◆ check_dev_busy()

boolean check_dev_busy ( char *  devstr)

Definition at line 876 of file machinestate.c.

Referenced by on_live_tvcard_activate().

◆ check_for_bad_ffmpeg()

int check_for_bad_ffmpeg ( void  )

Definition at line 1382 of file machinestate.c.

Referenced by load_frame_image().

◆ check_snap()

boolean check_snap ( const char *  prog)

Definition at line 3257 of file machinestate.c.

◆ compress_files_in_dir()

boolean compress_files_in_dir ( const char *  dir,
int  method,
void *  data 
)

compress all files in dir with gzip (directories are not compressed) gzip default action is to compress all files, replacing foo.bar with foo.bar.gz if a file already has a .gz extension then it will be left uncchanged

in future, method and data may be used to select compression method for now they are ignored

Definition at line 898 of file machinestate.c.

◆ dir_to_file_details()

lives_proc_thread_t dir_to_file_details ( LiVESList **  listp,
const char *  dir,
const char *  orig_loc,
uint64_t  extra 
)

create a list from a (sub)directory '.

' and '..' are ignored subdir can be NULL runs in a proc_htread

Definition at line 1353 of file machinestate.c.

◆ disk_monitor_check_result()

int64_t disk_monitor_check_result ( const char *  dir)

Definition at line 726 of file machinestate.c.

Referenced by check_for_disk_space(), and check_storage_space().

◆ disk_monitor_forget()

void disk_monitor_forget ( void  )

Definition at line 769 of file machinestate.c.

Referenced by disk_monitor_start().

◆ disk_monitor_running()

boolean disk_monitor_running ( const char *  dir)

◆ disk_monitor_start()

lives_proc_thread_t disk_monitor_start ( const char *  dir)

Definition at line 717 of file machinestate.c.

Referenced by disk_monitor_check_result().

◆ disk_monitor_wait_result()

LIVES_GLOBAL_INLINE int64_t disk_monitor_wait_result ( const char *  dir,
ticks_t  timeout 
)

Definition at line 742 of file machinestate.c.

◆ do_something_useful()

boolean do_something_useful ( lives_thread_data_t *  tdata)

yes, why don't you lend a hand instead of just lying around nanosleeping...

Definition at line 2194 of file machinestate.c.

◆ fast_hash()

LIVES_GLOBAL_INLINE uint32_t fast_hash ( const char *  key)

approx 5 - 10 % faster than lives_string_hash

Definition at line 1596 of file machinestate.c.

Referenced by get_val_from_cached_list().

◆ fastrand()

LIVES_GLOBAL_INLINE uint64_t fastrand ( void  )

Definition at line 40 of file machinestate.c.

Referenced by fastrand_dbl().

◆ fastrand_add()

LIVES_GLOBAL_INLINE void fastrand_add ( uint64_t  entropy)

Definition at line 47 of file machinestate.c.

◆ fastrand_dbl()

LIVES_GLOBAL_INLINE double fastrand_dbl ( double  range)

Definition at line 49 of file machinestate.c.

Referenced by fastrand_int().

◆ fastrand_int()

LIVES_GLOBAL_INLINE uint32_t fastrand_int ( uint32_t  range)

pick a pseudo random uint between 0 and range (inclusive)

Definition at line 54 of file machinestate.c.

Referenced by pick_nice_colour().

◆ fg_run_func()

void* fg_run_func ( lives_proc_thread_t  lpt,
void *  retval 
)

no funcptrs or custom...yet

Definition at line 2045 of file machinestate.c.

Referenced by lives_fg_run().

◆ free_fdets_list()

void free_fdets_list ( LiVESList **  listp)

Definition at line 1084 of file machinestate.c.

◆ gen_unique_id()

uint64_t gen_unique_id ( void  )

if we have a genuine RNG for 64 bits, then the probability of generating

Definition at line 68 of file machinestate.c.

Referenced by init_random(), lives_get_randbytes(), and open_set_file().

◆ get_cpu_load()

int64_t get_cpu_load ( int  cpun)

percent * 1 million

return reported load for CPU cpun (% * 1 million) as a bonus, if cpun == -1, returns boot time

Definition at line 3396 of file machinestate.c.

◆ get_dir_size()

off_t get_dir_size ( const char *  dirname)

Definition at line 1069 of file machinestate.c.

Referenced by on_utube_select().

◆ get_disk_load()

double get_disk_load ( const char *  mp)

Definition at line 3359 of file machinestate.c.

◆ get_distro_dets()

boolean get_distro_dets ( void  )

Definition at line 3268 of file machinestate.c.

◆ get_ds_free()

uint64_t get_ds_free ( const char *  dir)

Definition at line 776 of file machinestate.c.

Referenced by check_workdir_valid(), and get_storage_status().

◆ get_file_size()

off_t get_file_size ( int  fd)

because of padding bytes... !!!!

Definition at line 943 of file machinestate.c.

Referenced by _lives_buffered_rdonly_slurp(), and lives_buffered_orig_size().

◆ get_machine_dets()

boolean get_machine_dets ( void  )

Definition at line 3319 of file machinestate.c.

◆ get_max_align()

LIVES_GLOBAL_INLINE size_t get_max_align ( size_t  req_size,
size_t  align_max 
)

Definition at line 596 of file machinestate.c.

Referenced by insert_newlines().

◆ get_md5sum()

char* get_md5sum ( const char *  filename)

for future use

Definition at line 646 of file machinestate.c.

◆ get_mountpoint_for()

char* get_mountpoint_for ( const char *  dir)

◆ get_num_cpus()

int get_num_cpus ( void  )

Definition at line 3297 of file machinestate.c.

◆ get_storage_status()

lives_storage_status_t get_storage_status ( const char *  dir,
uint64_t  warn_level,
int64_t *  dsval,
int64_t  ds_resvd 
)

◆ get_systmp()

char* get_systmp ( const char *  suff,
boolean  is_dir 
)

Definition at line 3232 of file machinestate.c.

Referenced by on_open_utube_activate().

◆ get_thread_data()

lives_thread_data_t* get_thread_data ( void  )

Definition at line 2145 of file machinestate.c.

Referenced by get_threadvars().

◆ get_threadvars()

LIVES_GLOBAL_INLINE lives_threadvars_t* get_threadvars ( void  )

Definition at line 2156 of file machinestate.c.

◆ get_wid_for_name()

char* get_wid_for_name ( const char *  wname)

x11 stuff

x11

Definition at line 2917 of file machinestate.c.

Referenced by hide_desktop_panel(), and show_desktop_panel().

◆ get_window_stack_level()

int get_window_stack_level ( LiVESXWindow *  xwin,
int *  nwins 
)

Definition at line 3080 of file machinestate.c.

◆ get_wm_caps()

boolean get_wm_caps ( void  )

Definition at line 3018 of file machinestate.c.

◆ get_worktmp()

char* get_worktmp ( const char *  prefix)

Definition at line 3246 of file machinestate.c.

Referenced by open_ascrap_file(), and open_scrap_file().

◆ get_worktmpfile()

char* get_worktmpfile ( const char *  prefix)

Definition at line 3251 of file machinestate.c.

◆ get_x11_visible()

boolean get_x11_visible ( const char *  wname)

Definition at line 3123 of file machinestate.c.

◆ grep_in_cmd()

char* grep_in_cmd ( const char *  cmd,
int  mstart,
int  npieces,
const char *  mphrase,
int  ridx,
int  rlen 
)

Definition at line 2754 of file machinestate.c.

Referenced by check_snap(), get_wid_for_name(), and get_x11_visible().

◆ hide_desktop_panel()

boolean hide_desktop_panel ( void  )

Definition at line 3110 of file machinestate.c.

◆ hide_x11_window()

boolean hide_x11_window ( const char *  wid)

Definition at line 2973 of file machinestate.c.

Referenced by hide_desktop_panel().

◆ init_memfuncs()

boolean init_memfuncs ( void  )

Definition at line 630 of file machinestate.c.

◆ init_random()

void init_random ( void  )

Definition at line 92 of file machinestate.c.

◆ init_thread_memfuncs()

boolean init_thread_memfuncs ( void  )

Definition at line 638 of file machinestate.c.

◆ is_empty_dir()

boolean is_empty_dir ( const char *  dirname)

Definition at line 1013 of file machinestate.c.

◆ lives_calloc_safety()

LIVES_GLOBAL_INLINE void* lives_calloc_safety ( size_t  nmemb,
size_t  xsize 
)

◆ lives_chomp()

LIVES_GLOBAL_INLINE char* lives_chomp ( char *  buff)

see also lives_strchomp() which removes all whitespace

Definition at line 1641 of file machinestate.c.

Referenced by get_mountpoint_for(), lives_label_chomp(), and splash_msg().

◆ lives_concat()

LIVES_GLOBAL_INLINE char* lives_concat ( char *  st,
char *  x 
)

nb: lives strconcat

Definition at line 1426 of file machinestate.c.

Referenced by explain_missing_activate().

◆ lives_concat_sep()

LIVES_GLOBAL_INLINE char* lives_concat_sep ( char *  st,
const char *  sep,
char *  x 
)

nb: lives strconcat

Definition at line 1412 of file machinestate.c.

◆ lives_datetime()

char* lives_datetime ( uint64_t  secs,
boolean  use_local 
)

Definition at line 860 of file machinestate.c.

Referenced by lives_datetime_rel(), and lives_event_list_new().

◆ lives_datetime_rel()

char* lives_datetime_rel ( const char *  datetime)

replace date w. yesterday, today

Definition at line 842 of file machinestate.c.

◆ lives_format_storage_space_string()

char* lives_format_storage_space_string ( uint64_t  space)

Definition at line 664 of file machinestate.c.

Referenced by ds_critical_msg(), ds_warning_msg(), and on_utube_select().

◆ lives_free_and_return()

LIVES_GLOBAL_INLINE void* lives_free_and_return ( void *  p)

TODO: this file should be split into at least: memory functions, thread functions, file utils.

Definition at line 593 of file machinestate.c.

◆ lives_get_current_ticks()

LIVES_GLOBAL_INLINE ticks_t lives_get_current_ticks ( void  )

◆ lives_get_randbytes()

void lives_get_randbytes ( void *  ptr,
size_t  size 
)

Definition at line 60 of file machinestate.c.

◆ lives_get_relative_ticks()

LIVES_GLOBAL_INLINE ticks_t lives_get_relative_ticks ( ticks_t  origsecs,
ticks_t  orignsecs 
)

◆ lives_getgid()

LIVES_GLOBAL_INLINE int lives_getgid ( void  )

◆ lives_getpid()

LIVES_GLOBAL_INLINE pid_t lives_getpid ( void  )

Definition at line 2408 of file machinestate.c.

Referenced by get_capabilities().

◆ lives_getuid()

LIVES_GLOBAL_INLINE int lives_getuid ( void  )

◆ lives_plant_new()

LIVES_GLOBAL_INLINE weed_plant_t* lives_plant_new ( int  subtype)

Definition at line 2266 of file machinestate.c.

Referenced by lives_plant_new_with_index().

◆ lives_plant_new_with_index()

LIVES_GLOBAL_INLINE weed_plant_t* lives_plant_new_with_index ( int  subtype,
int64_t  index 
)

Definition at line 2273 of file machinestate.c.

◆ lives_proc_thread_cancel()

LIVES_GLOBAL_INLINE boolean lives_proc_thread_cancel ( lives_proc_thread_t  tinfo)

Definition at line 1946 of file machinestate.c.

Referenced by do_effect(), load_rfx_preview(), and render_to_clip().

◆ lives_proc_thread_cancelled()

LIVES_GLOBAL_INLINE boolean lives_proc_thread_cancelled ( lives_proc_thread_t  tinfo)

Definition at line 1971 of file machinestate.c.

Referenced by _item_to_file_details(), and virtual_to_images().

◆ lives_proc_thread_check()

LIVES_GLOBAL_INLINE boolean lives_proc_thread_check ( lives_proc_thread_t  tinfo)

returns FALSE while the thread is running, TRUE once it has finished

returns FALSE while the thread is running, TRUE once it has finished

Definition at line 1916 of file machinestate.c.

Referenced by lives_proc_thread_dontcare().

◆ lives_proc_thread_create()

lives_proc_thread_t lives_proc_thread_create ( lives_thread_attr_t  attr,
lives_funcptr_t  func,
int  return_type,
const char *  args_fmt,
  ... 
)

create the specific plant which defines a background task to be run

  • func is any function of a recognised type, with 0 - 16 parameters, and a value of type <return type> which may be retrieved by later calling the appropriate lives_proc_thread_join_*() function
  • args_fmt is a 0 terminated string describing the arguments of func, i ==int, d == double, b == boolean (int), s == string (0 terminated), I == uint64_t, int64_t, P = weed_plant_t *, V / v == (void *), F == weed_funcptr_t return_type is enumerated, e.g WEED_SEED_INT64. Return_type of 0 indicates no return value (void), then the thread will free its own resources and NULL is returned from this function (fire and forget) return_type of -1 has a special meaning, in this case no result is returned, but the thread can be monitored by calling: lives_proc_thread_check() with the return : - this function is guaranteed to return FALSE whilst the thread is running and TRUE thereafter, the proc_thread should be freed once TRUE id returned and not before. for the other return_types, the appropriate join function should be called and it will block until the thread has completed its task and return a copy of the actual return value of the func alternatively, if return_type is non-zero, then the returned value from this function may be reutlised by passing it as the parameter to run_as_thread().

Definition at line 1730 of file machinestate.c.

Referenced by dir_to_file_details(), do_effect(), lives_buffered_rdonly_slurp(), load_rfx_preview(), ordfile_to_file_details(), and render_to_clip().

◆ lives_proc_thread_dontcare()

boolean lives_proc_thread_dontcare ( lives_proc_thread_t  tinfo)

tell a threead with return value that we no longer need the value so it can free itself

if thread is running, tell it we no longer care about return value, so it can free itself if finished we just call lives_proc_thread_join() to free it a mutex is used to ensure the proc_thread does not finish between setting the flag and checking if it has ifnished

Definition at line 1953 of file machinestate.c.

Referenced by disk_monitor_forget().

◆ lives_proc_thread_free()

LIVES_GLOBAL_INLINE void lives_proc_thread_free ( lives_proc_thread_t  lpt)

Definition at line 1672 of file machinestate.c.

◆ lives_proc_thread_get_cancellable()

LIVES_GLOBAL_INLINE boolean lives_proc_thread_get_cancellable ( lives_proc_thread_t  tinfo)

Definition at line 1942 of file machinestate.c.

Referenced by lives_proc_thread_cancel().

◆ lives_proc_thread_join()

LIVES_GLOBAL_INLINE void lives_proc_thread_join ( lives_proc_thread_t  tinfo)

◆ lives_proc_thread_join_boolean()

LIVES_GLOBAL_INLINE int lives_proc_thread_join_boolean ( lives_proc_thread_t  tinfo)

Definition at line 1989 of file machinestate.c.

◆ lives_proc_thread_join_double()

LIVES_GLOBAL_INLINE double lives_proc_thread_join_double ( lives_proc_thread_t  tinfo)

Definition at line 1988 of file machinestate.c.

◆ lives_proc_thread_join_funcptr()

LIVES_GLOBAL_INLINE weed_funcptr_t lives_proc_thread_join_funcptr ( lives_proc_thread_t  tinfo)

Definition at line 1992 of file machinestate.c.

◆ lives_proc_thread_join_int()

LIVES_GLOBAL_INLINE int lives_proc_thread_join_int ( lives_proc_thread_t  tinfo)

Definition at line 1987 of file machinestate.c.

◆ lives_proc_thread_join_int64()

LIVES_GLOBAL_INLINE int64_t lives_proc_thread_join_int64 ( lives_proc_thread_t  tinfo)

Definition at line 1990 of file machinestate.c.

◆ lives_proc_thread_join_plantptr()

LIVES_GLOBAL_INLINE weed_plantptr_t lives_proc_thread_join_plantptr ( lives_proc_thread_t  tinfo)

Definition at line 1994 of file machinestate.c.

◆ lives_proc_thread_join_string()

LIVES_GLOBAL_INLINE char* lives_proc_thread_join_string ( lives_proc_thread_t  tinfo)

Definition at line 1991 of file machinestate.c.

◆ lives_proc_thread_join_voidptr()

LIVES_GLOBAL_INLINE void* lives_proc_thread_join_voidptr ( lives_proc_thread_t  tinfo)

Definition at line 1993 of file machinestate.c.

◆ lives_proc_thread_set_cancellable()

LIVES_GLOBAL_INLINE void lives_proc_thread_set_cancellable ( lives_proc_thread_t  tinfo)

only threads with no return value can possibly be cancellable. For threads with a value, use lives_proc_thread_dontcare()

Definition at line 1938 of file machinestate.c.

Referenced by _item_to_file_details(), render_to_clip(), and virtual_to_images().

◆ lives_proc_thread_signalled()

LIVES_GLOBAL_INLINE int lives_proc_thread_signalled ( lives_proc_thread_t  tinfo)

returns FALSE while the thread is running, TRUE once it has finished

Definition at line 1926 of file machinestate.c.

◆ lives_proc_thread_signalled_idx()

LIVES_GLOBAL_INLINE int64_t lives_proc_thread_signalled_idx ( lives_proc_thread_t  tinfo)

returns FALSE while the thread is running, TRUE once it has finished

Definition at line 1931 of file machinestate.c.

◆ lives_proc_thread_sync_ready()

LIVES_GLOBAL_INLINE void lives_proc_thread_sync_ready ( lives_proc_thread_t  tinfo)

Definition at line 1911 of file machinestate.c.

◆ lives_random()

LIVES_GLOBAL_INLINE uint64_t lives_random ( void  )

Definition at line 58 of file machinestate.c.

◆ lives_recalloc()

LIVES_GLOBAL_INLINE void* lives_recalloc ( void *  p,
size_t  nmemb,
size_t  omemb,
size_t  xsize 
)

realloc from omemb * size to nmemb * size memory allocated via calloc, with DEF_ALIGN alignment and EXTRA_BYTES extra padding

Definition at line 615 of file machinestate.c.

◆ lives_srandom()

LIVES_GLOBAL_INLINE void lives_srandom ( unsigned int  seed)

Definition at line 56 of file machinestate.c.

Referenced by init_random().

◆ lives_strappend()

LIVES_GLOBAL_INLINE int lives_strappend ( const char *  string,
int  len,
const char *  xnew 
)

see also: lives_concat()

Definition at line 1436 of file machinestate.c.

Referenced by get_mime_type(), handle_backend_errors(), and lives_strappendf().

◆ lives_strappendf()

LIVES_GLOBAL_INLINE const char* lives_strappendf ( const char *  string,
int  len,
const char *  fmt,
  ... 
)

Definition at line 1444 of file machinestate.c.

◆ lives_strcmp()

LIVES_GLOBAL_INLINE boolean lives_strcmp ( const char *  st1,
const char *  st2 
)

◆ lives_strcmp_ordered()

LIVES_GLOBAL_INLINE int lives_strcmp_ordered ( const char *  st1,
const char *  st2 
)

Definition at line 1531 of file machinestate.c.

Referenced by lives_utf8_strcmpfunc().

◆ lives_strdup_quick()

LIVES_GLOBAL_INLINE char* lives_strdup_quick ( const char *  s)

Definition at line 1484 of file machinestate.c.

◆ lives_string_hash()

LIVES_GLOBAL_INLINE uint32_t lives_string_hash ( const char *  st)

Definition at line 1585 of file machinestate.c.

◆ lives_strlen()

LIVES_GLOBAL_INLINE size_t lives_strlen ( const char *  s)

◆ lives_strncmp()

LIVES_GLOBAL_INLINE boolean lives_strncmp ( const char *  st1,
const char *  st2,
size_t  len 
)

◆ lives_strstop()

LIVES_GLOBAL_INLINE char* lives_strstop ( char *  st,
const char  term 
)

truncate st, replacing term with \0

Definition at line 1634 of file machinestate.c.

Referenced by get_distro_dets(), get_filename(), and lives_get_filename().

◆ lives_strtrim()

LIVES_GLOBAL_INLINE char* lives_strtrim ( const char *  buff)

return string with start and end newlines stripped see also lives_strstrip() which removes all whitespace

Definition at line 1651 of file machinestate.c.

◆ lives_thread_create()

int lives_thread_create ( lives_thread_t thread,
lives_thread_attr_t  attr,
lives_funcptr_t  func,
void *  arg 
)

Definition at line 2318 of file machinestate.c.

Referenced by resubmit_proc_thread().

◆ lives_thread_data_create()

lives_thread_data_t* lives_thread_data_create ( uint64_t  idx)

Definition at line 2174 of file machinestate.c.

◆ lives_thread_join()

uint64_t lives_thread_join ( lives_thread_t  work,
void **  retval 
)

Definition at line 2376 of file machinestate.c.

Referenced by check_layer_ready().

◆ lives_threadpool_finish()

void lives_threadpool_finish ( void  )

Definition at line 2295 of file machinestate.c.

◆ lives_threadpool_init()

void lives_threadpool_init ( void  )

Definition at line 2280 of file machinestate.c.

◆ main_thread_execute()

void* main_thread_execute ( lives_funcptr_t  func,
int  return_type,
void *  retval,
const char *  args_fmt,
  ... 
)

◆ make_nxttab()

void make_nxttab ( void  )

Definition at line 120 of file machinestate.c.

◆ mini_popen()

LIVES_LOCAL_INLINE char * mini_popen ( char *  cmd)

◆ mini_run()

LIVES_LOCAL_INLINE boolean mini_run ( char *  cmd)

◆ nxtval()

uint64_t nxtval ( uint64_t  val,
uint64_t  lim,
boolean  less 
)

decompose val into i, j divide by 6 until val mod 6 is non zero

divide by 2 until we reach 1; if the result of a division is odd we add or subtract 1

Definition at line 198 of file machinestate.c.

Referenced by autotune_u64_end().

◆ ordfile_to_file_details()

lives_proc_thread_t ordfile_to_file_details ( LiVESList **  listp,
const char *  ofname,
const char *  orig_loc,
uint64_t  extra 
)

Definition at line 1360 of file machinestate.c.

◆ quick_calloc()

void* quick_calloc ( size_t  n,
size_t  s 
)

Definition at line 628 of file machinestate.c.

Referenced by _ext_calloc().

◆ quick_free()

void quick_free ( void *  p)

Definition at line 626 of file machinestate.c.

◆ reget_afilesize()

void reget_afilesize ( int  fileno)

◆ reget_afilesize_inner()

off_t reget_afilesize_inner ( int  fileno)

Definition at line 1001 of file machinestate.c.

Referenced by on_effects_paused(), and reget_afilesize().

◆ reset_effort()

void reset_effort ( void  )

Definition at line 2642 of file machinestate.c.

◆ resubmit_proc_thread()

void resubmit_proc_thread ( lives_proc_thread_t  thread_info,
lives_thread_attr_t  attr 
)

(re)submission point, the function call is added to the threadpool tasklist if we have sufficient threads the task will be run at once, if all threads are busy then MINPOOLTHREADS new threads will be created and added to the pool

run any function as a lives_thread

tell the thread to clean up after itself [but it won't delete thread_info]

Definition at line 2106 of file machinestate.c.

◆ reverse_buffer()

boolean reverse_buffer ( uint8_t *  buff,
size_t  count,
size_t  chunk 
)

halve the number of bytes, since we will work forwards and back to meet in the middle

swap 8 bytes at a time from start and end

remainder should be only 6, 4, or 2 bytes in the middle

swap 4 bytes at a time from start and end

remainder should be only 6 or 2 bytes in the middle, with a chunk size of 4 or 2 or 1

swap 2 bytes at a time from start and end

swap single bytes

Definition at line 2509 of file machinestate.c.

◆ reverse_bytes()

LIVES_GLOBAL_INLINE void reverse_bytes ( char *  buff,
size_t  count,
size_t  gran 
)

◆ send_to_trash()

LiVESResponseType send_to_trash ( const char *  item)

Definition at line 2827 of file machinestate.c.

◆ sget_file_size()

off_t sget_file_size ( const char *  name)

◆ show_desktop_panel()

boolean show_desktop_panel ( void  )

Definition at line 3098 of file machinestate.c.

Referenced by catch_sigint(), and on_sepwin_activate().

◆ stat_to_file_dets()

int stat_to_file_dets ( const char *  fname,
lives_file_dets_t fdets 
)

Definition at line 1099 of file machinestate.c.

◆ swab2()

LIVES_GLOBAL_INLINE void swab2 ( const void *  from,
const void *  to,
size_t  gran 
)

Definition at line 2448 of file machinestate.c.

Referenced by swab4().

◆ swab4()

LIVES_GLOBAL_INLINE void swab4 ( const void *  from,
const void *  to,
size_t  gran 
)

Definition at line 2462 of file machinestate.c.

Referenced by LEFloat_to_BEFloat(), and swab8().

◆ swab8()

LIVES_GLOBAL_INLINE void swab8 ( const void *  from,
const void *  to,
size_t  gran 
)

Definition at line 2483 of file machinestate.c.

◆ unhide_x11_window()

boolean unhide_x11_window ( const char *  wid)

Definition at line 2987 of file machinestate.c.

Referenced by show_desktop_panel().

◆ update_effort()

void update_effort ( int  nthings,
boolean  badthings 
)

+1 for each badthing, so when it pops out we subtract it

  • all the good things, so when it pops out we add it (i.e subtract the value)

no badthings, good

Definition at line 2656 of file machinestate.c.

_RV_
#define _RV_
Definition: machinestate.h:451
lives_nanosleep_until_nonzero
#define lives_nanosleep_until_nonzero(condition)
Definition: machinestate.h:310