LiVES 3.2.0
machinestate.h
Go to the documentation of this file.
1// machinestate.h
2// (c) G. Finch 2019 - 2020 <salsaman+lives@gmail.com>
3// released under the GNU GPL 3 or later
4// see file ../COPYING for licensing details
5
6// functions for dealing with externalities
7
9
10#ifndef _MACHINESTATE_H_
11#define _MACHINESTATE_H_
12
13#include <sys/time.h>
14#include <time.h>
15
16#define EXTRA_BYTES DEF_ALIGN
17
18typedef void *(*malloc_f)(size_t);
19typedef void (*free_f)(void *);
20typedef void *(*free_and_return_f)(void *); // like free() but returns NULL
21typedef void *(*memcpy_f)(void *, const void *, size_t);
22typedef int (*memcmp_f)(const void *, const void *, size_t);
23typedef void *(*memset_f)(void *, int, size_t);
24typedef void *(*memmove_f)(void *, const void *, size_t);
25typedef void *(*realloc_f)(void *, size_t);
26typedef void *(*calloc_f)(size_t, size_t);
27typedef void *(*malloc_and_copy_f)(size_t, const void *);
28typedef void (*unmalloc_and_copy_f)(size_t, void *);
29
30#define USE_RPMALLOC
31
32#ifdef USE_RPMALLOC
33#include "rpmalloc.h"
34#endif
35
36boolean init_memfuncs(void);
37
38void lives_free_check(void *p);
39
40#ifdef USE_RPMALLOC
41void *quick_calloc(size_t n, size_t s);
42void quick_free(void *p);
43#endif
44
45#ifndef lives_malloc
46#define lives_malloc malloc
47#endif
48#ifndef lives_realloc
49#define lives_realloc realloc
50#endif
51#ifndef lives_free
52#define lives_free free
53#endif
54#ifndef lives_memcpy
55#define lives_memcpy memcpy
56#endif
57#ifndef lives_memcmp
58#define lives_memcmp memcmp
59#endif
60#ifndef lives_memset
61#define lives_memset memset
62#endif
63#ifndef lives_memmove
64#define lives_memmove memmove
65#endif
66#ifndef lives_calloc
67#define lives_calloc calloc
68#endif
69
70#ifdef _lives_malloc
71#undef _lives_malloc
72#endif
73#ifdef _lives_malloc_and_copy
74#undef _lives_malloc_and_copy
75#endif
76#ifdef _lives_realloc
77#undef _lives_realloc
78#endif
79#ifdef _lives_free
80#undef _lives_free
81#endif
82#ifdef _lives_memcpy
83#undef _lives_memcpy
84#endif
85#ifdef _lives_memcmp
86#undef _lives_memcmp
87#endif
88#ifdef _lives_memset
89#undef _lives_memset
90#endif
91#ifdef _lives_memmove
92#undef _lives_memmove
93#endif
94#ifdef _lives_calloc
95#undef _lives_calloc
96#endif
97
98#ifndef USE_STD_MEMFUNCS
99// here we can define optimised mem ory functions to used by setting the symbols _lives_malloc, _lives_free, etc.
100// at the end of the header we check if the values have been set and update lives_malloc from _lives_malloc, etc.
101// the same values are passed into realtime fx plugins via Weed function overloading
102#if defined (HAVE_OPENCV) || defined (HAVE_OPENCV4)
103#ifndef NO_OPENCV_MEMFUNCS
104#define _lives_malloc(sz) alignPtr(sz, DEF_ALIGN);
105#define _lives_free fastFree
106#define _lives_realloc proxy_realloc
107#endif
108#endif
109
110#ifndef __cplusplus
111
112#ifdef ENABLE_ORC
113#ifndef NO_ORC_MEMFUNCS
114#define _lives_memcpy lives_orc_memcpy
115#endif
116#endif
117
118#else
119
120#ifdef ENABLE_OIL
121#ifndef NO_OIL_MEMFUNCS
122#define _lives_memcpy(dest, src, n) {if (n >= 32 && n <= OIL_MEMCPY_MAX_BYTES) { \
123 oil_memcpy((uint8_t *)dest, (const uint8_t *)src, n); \
124 return dest;\ \
125 }
126#endif
127#endif
128
129#endif // __cplusplus
130#endif // USE_STD_MEMFUNCS
131
132#define __STDC_FORMAT_MACROS
133#include <inttypes.h>
134
135#undef PRId64
136#undef PRIu64
137
138#ifdef IS_MINGW
139#define LONGSIZE 32
140#else
141
142#ifdef __WORDSIZE
143#define LONGSIZE __WORDSIZE
144#else
145#if defined __x86_64__
146# define LONGSIZE 64
147#ifndef __WORDSIZE_COMPAT32
148# define __WORDSIZE_COMPAT32 1
149#endif
150#else
151# define LONGSIZE 32
152#endif // x86
153#endif // __WORDSIZE
154#endif // mingw
155
156#ifdef __PRI64_PREFIX
157#undef __PRI64_PREFIX
158#endif
159
160# if LONGSIZE == 64
161# define __PRI64_PREFIX "l"
162# else
163# define __PRI64_PREFIX "ll"
164# endif
165
166#undef PRId64
167#undef PRIu64
168
169# define PRId64 __PRI64_PREFIX "d"
170# define PRIu64 __PRI64_PREFIX "u"
171
173
174void *lives_free_and_return(void *p);
175void *lives_calloc_safety(size_t nmemb, size_t xsize) GNU_ALIGNED(DEF_ALIGN);
176void *lives_recalloc(void *p, size_t nmemb, size_t omemb, size_t xsize) GNU_ALIGNED(DEF_ALIGN);
177
178size_t get_max_align(size_t req_size, size_t align_max);
179
181typedef enum {
190
191//void shoatend(void);
192
193#define WEED_LEAF_MD5SUM "md5sum"
194
195// weed plants with type >= 16384 are reserved for custom use, so let's take advantage of that
196#define WEED_PLANT_LIVES 31337
197
198#define WEED_LEAF_LIVES_SUBTYPE "subtype"
199#define WEED_LEAF_LIVES_MESSAGE_STRING "message_string"
200
201#define LIVES_WEED_SUBTYPE_MESSAGE 1
202#define LIVES_WEED_SUBTYPE_WIDGET 2
203#define LIVES_WEED_SUBTYPE_TUNABLE 3
204#define LIVES_WEED_SUBTYPE_PROC_THREAD 4
205
206typedef weed_plantptr_t lives_proc_thread_t;
207
208weed_plant_t *lives_plant_new(int subtype);
209weed_plant_t *lives_plant_new_with_index(int subtype, int64_t index);
210
211void *_ext_malloc(size_t n) GNU_MALLOC;
212void *_ext_malloc_and_copy(size_t, const void *) GNU_MALLOC_SIZE(1);
213void _ext_unmalloc_and_copy(size_t, void *);
214void _ext_free(void *);
215void *_ext_free_and_return(void *);
216void *_ext_memcpy(void *, const void *, size_t);
217void *_ext_memset(void *, int, size_t);
218void *_ext_memmove(void *, const void *, size_t);
219void *_ext_realloc(void *, size_t) GNU_MALLOC_SIZE(2);
220void *_ext_calloc(size_t, size_t) GNU_MALLOC_SIZE2(1, 2) GNU_ALIGN(2);
221
222#define OVERRIDE_MEMFUNCS
223static void *(*_lsd_memcpy)(void *dest, const void *src, size_t n) = _ext_memcpy;
224static void *(*_lsd_memset)(void *s, int c, size_t n) = _ext_memset;
225static void (*_lsd_free)(void *ptr) = rpfree;
226#define OVERRIDE_CALLOC_ALIGNED
227static int _lsd_calloc_aligned_(void **memptr, size_t nmemb, size_t size) {
228 return !memptr ? 0 : (!(*memptr = (rpaligned_calloc)(64, nmemb, size))) ? ENOMEM : 0;
229}
230
231void lives_get_randbytes(void *ptr, size_t size);
232
233#if !HAVE_GETENTROPY
234#define LSD_RANDFUNC(ptr, size) (lives_get_randbytes((ptr), (size)))
235#endif
236
237#include "lsd.h"
238#undef OVERRIDE_MEMFUNCS
239
240#ifdef __GNUC__
241#define LIVES_GNU
242#define lives_malloc_auto(size) __builtin_alloc(size)
243#define lives_malloc_auto_aligned(size, align) __builtin_alloc_with_align(size, align)
244#endif
245
246size_t lives_strlen(const char *) GNU_HOT GNU_PURE;
247boolean lives_strcmp(const char *, const char *) GNU_HOT GNU_PURE;
248boolean lives_strncmp(const char *, const char *, size_t) GNU_HOT GNU_PURE;
249char *lives_strdup_quick(const char *s);
250int lives_strcmp_ordered(const char *, const char *) GNU_HOT GNU_PURE;
251char *lives_concat(char *, char *) GNU_HOT;
252char *lives_concat_sep(char *st, const char *sep, char *x);
253char *lives_strstop(char *, const char term) GNU_HOT;
254int lives_strappend(const char *string, int len, const char *xnew);
255const char *lives_strappendf(const char *string, int len, const char *fmt, ...);
256
257void swab2(const void *from, const void *to, size_t granularity) GNU_HOT;
258void swab4(const void *from, const void *to, size_t granularity) GNU_HOT;
259void swab8(const void *from, const void *to, size_t granularity) GNU_HOT;
260void reverse_bytes(char *buff, size_t count, size_t granularity) GNU_HOT GNU_FLATTEN;
261boolean reverse_buffer(uint8_t *buff, size_t count, size_t chunk) GNU_HOT;
262
263uint64_t nxtval(uint64_t val, uint64_t lim, boolean less);
264uint64_t autotune_u64_end(weed_plant_t **tuner, uint64_t val);
265void autotune_u64(weed_plant_t *tuner, uint64_t min, uint64_t max, int ntrials, double cost);
266
267void init_random(void);
268void lives_srandom(unsigned int seed);
269uint64_t lives_random(void);
270
271uint64_t fastrand(void) GNU_HOT;
272void fastrand_add(uint64_t entropy);
273double fastrand_dbl(double range);
274uint32_t fastrand_int(uint32_t range);
275
276uint64_t gen_unique_id(void);
277
278#ifdef ENABLE_ORC
279void *lives_orc_memcpy(void *dest, const void *src, size_t n);
280#endif
281
282#ifdef ENABLE_OIL
283void *lives_oil_memcpy(void *dest, const void *src, size_t n);
284#endif
285
286void *proxy_realloc(void *ptr, size_t new_size);
287
288char *get_md5sum(const char *filename);
289
290char *lives_format_storage_space_string(uint64_t space);
291lives_storage_status_t get_storage_status(const char *dir, uint64_t warn_level, int64_t *dsval, int64_t resvd);
292uint64_t get_ds_free(const char *dir);
293
295boolean disk_monitor_running(const char *dir);
296int64_t disk_monitor_check_result(const char *dir);
297int64_t disk_monitor_wait_result(const char *dir, ticks_t timeout);
298void disk_monitor_forget(void);
299
300char *get_mountpoint_for(const char *dir);
301
304char *lives_datetime(uint64_t secs, boolean use_local);
305char *lives_datetime_rel(const char *datetime);
306
307#define lives_nanosleep(nanosec) {struct timespec ts; ts.tv_sec = (uint64_t)nanosec / ONE_BILLION; \
308 ts.tv_nsec = (uint64_t)nanosec - ts.tv_sec * ONE_BILLION; while (nanosleep(&ts, &ts) == -1 && \
309 errno != ETIMEDOUT);}
310#define lives_nanosleep_until_nonzero(condition) {while (!(condition)) lives_nanosleep(1000);}
311
312int check_dev_busy(char *devstr);
313
314off_t get_file_size(int fd);
315off_t sget_file_size(const char *name);
316
317void reget_afilesize(int fileno);
318off_t reget_afilesize_inner(int fileno);
319
320off_t get_dir_size(const char *dirname);
321
322boolean compress_files_in_dir(const char *dir, int method, void *data);
323LiVESResponseType send_to_trash(const char *item);
324
326#define EXTRA_DETAILS_CHECK_MISSING (1ul << 0)
327#define EXTRA_DETAILS_DIRSIZE (1ul << 1)
328#define EXTRA_DETAILS_EMPTY_DIRS (1ul << 2)
329#define EXTRA_DETAILS_SYMLINK (1ul << 3)
330#define EXTRA_DETAILS_ACCESSIBLE (1ul << 4)
331#define EXTRA_DETAILS_WRITEABLE (1ul << 5)
332#define EXTRA_DETAILS_EXECUTABLE (1ul << 6)
333#define EXTRA_DETAILS_CLIPHDR (1ul << 7)
334
336#define EXTRA_DETAILS_MD5SUM (1ul << 33)
337
338typedef struct {
341 uint64_t uniq;
343 char *name;
344 uint64_t type;
345 off_t size; // -1 not checked, -2 unreadable
346 uint64_t mode;
347 uint64_t uid;
348 uint64_t gid;
349 uint64_t blk_size;
350 uint64_t atime_sec;
351 uint64_t atime_nsec;
352 uint64_t mtime_sec;
353 uint64_t mtime_nsec;
354 uint64_t ctime_sec;
355 uint64_t ctime_nsec;
356 char *md5sum;
358 LiVESWidget *widgets[16];
360
361#ifdef PRODUCE_LOG
362// disabled by default
363void lives_log(const char *what);
364#endif
365
366uint32_t lives_string_hash(const char *string) GNU_PURE GNU_HOT;
367uint32_t fast_hash(const char *key) GNU_PURE GNU_HOT;
368char *lives_chomp(char *string);
369char *lives_strtrim(const char *buff);
370
371int check_for_bad_ffmpeg(void);
372
373void update_effort(int nthings, boolean badthings);
374void reset_effort(void);
375
377
378typedef void *(*lives_funcptr_t)(void *);
379
380typedef struct _lives_thread_data_t lives_thread_data_t;
381
382typedef struct {
384 lives_thread_data_t *var_mydata;
386 int var_write_failed, var_read_failed;
388 char *var_read_failed_file, *var_write_failed_file, *var_bad_aud_file;
389 int var_rowstride_alignment; // used to align the rowstride bytesize in create_empty_pixel_data
392 boolean var_no_gui;
394
396 LiVESWidgetContext *ctx;
397 int64_t idx;
399};
400
401typedef struct {
403 void *arg;
404 uint64_t flags;
405 volatile uint64_t busy;
406 volatile uint64_t done;
407 void *ret;
408 volatile boolean sync_ready;
410
411#define WEED_LEAF_NOTIFY "notify"
412#define WEED_LEAF_DONE "done"
413#define WEED_LEAF_THREADFUNC "tfunction"
414#define WEED_LEAF_THREAD_PROCESSING "t_processing"
415#define WEED_LEAF_THREAD_CANCELLABLE "t_can_cancel"
416#define WEED_LEAF_THREAD_CANCELLED "t_cancelled"
417#define WEED_LEAF_RETURN_VALUE "return_value"
418#define WEED_LEAF_DONTCARE "dontcare"
419#define WEED_LEAF_DONTCARE_MUTEX "dontcare_mutex"
420
421#define WEED_LEAF_SIGNALLED "signalled"
422#define WEED_LEAF_SIGNAL_DATA "signal_data"
423
424#define WEED_LEAF_THREAD_PARAM "thrd_param"
425#define _WEED_LEAF_THREAD_PARAM(n) WEED_LEAF_THREAD_PARAM n
426#define WEED_LEAF_THREAD_PARAM0 _WEED_LEAF_THREAD_PARAM("0")
427#define WEED_LEAF_THREAD_PARAM1 _WEED_LEAF_THREAD_PARAM("1")
428#define WEED_LEAF_THREAD_PARAM2 _WEED_LEAF_THREAD_PARAM("2")
429
430#define LIVES_THRDFLAG_AUTODELETE (1 << 0)
431#define LIVES_THRDFLAG_TUNING (1 << 1)
432#define LIVES_THRDFLAG_WAIT_SYNC (1 << 2)
433
434typedef LiVESList lives_thread_t;
435typedef uint64_t lives_thread_attr_t;
436
437#define LIVES_THRDATTR_NONE 0
438#define LIVES_THRDATTR_AUTODELETE (1 << 0)
439#define LIVES_THRDATTR_PRIORITY (1 << 1)
440#define LIVES_THRDATTR_WAIT_SYNC (1 << 2)
441#define LIVES_THRDATTR_FG_THREAD (1 << 3)
442#define LIVES_THRDATTR_NO_GUI (1 << 4)
443
444void lives_threadpool_init(void);
445void lives_threadpool_finish(void);
447uint64_t lives_thread_join(lives_thread_t work, void **retval);
448
449// lives_proc_thread_t //////////////////////////////////////////////////////////////////////////////////////////////////////////
450
451#define _RV_ WEED_LEAF_RETURN_VALUE
452
453typedef uint64_t funcsig_t;
454
455typedef int(*funcptr_int_t)();
456typedef double(*funcptr_dbl_t)();
457typedef int(*funcptr_bool_t)();
458typedef char *(*funcptr_string_t)();
459typedef int64_t(*funcptr_int64_t)();
460typedef weed_funcptr_t(*funcptr_funcptr_t)();
461typedef void *(*funcptr_voidptr_t)();
462typedef weed_plant_t(*funcptr_plantptr_t)();
463
464#define GETARG(type, n) WEED_LEAF_GET(info, _WEED_LEAF_THREAD_PARAM(n), type)
465
466#define ARGS1(t1) GETARG(t1, "0")
467#define ARGS2(t1, t2) ARGS1(t1), GETARG(t2, "1")
468#define ARGS3(t1, t2, t3) ARGS2(t1, t2), GETARG(t3, "2")
469#define ARGS4(t1, t2, t3, t4) ARGS3(t1, t2, t3), GETARG(t4, "3")
470#define ARGS5(t1, t2, t3, t4, t5) ARGS4(t1, t2, t3, t4), GETARG(t5, "4")
471#define ARGS6(t1, t2, t3, t4, t5, t6) ARGS5(t1, t2, t3, t4, t5), GETARG(t6, "5")
472#define ARGS7(t1, t2, t3, t4, t5, t6, t7) ARGS6(t1, t2, t3, t4, t5, t6), GETARG(t7, "6")
473#define ARGS8(t1, t2, t3, t4, t5, t6, t7, t8) ARGS7(t1, t2, t3, t4, t5, t6, t7), GETARG(t8, "7")
474#define ARGS9(t1, t2, t3, t4, t5, t6, t7, t8, t9) ARGS8(t1, t2, t3, t4, t5, t6, t7. t8), GETARG(t9, "8")
475#define ARGS10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) ARGS9(t1, t2, t3, t4, t5, t6, t7, t8, t9), GETARG(t10, "9")
476
477#define CALL_VOID_10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) (*thefunc->func)(ARGS10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
478#define CALL_VOID_9(t1, t2, t3, t4, t5, t6, t7, t8, t9) (*thefunc->func)(ARGS9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
479#define CALL_VOID_8(t1, t2, t3, t4, t5, t6, t7, t8) (*thefunc->func)(ARGS8(t1, t2, t3, t4, t5, t6, t7, t8))
480#define CALL_VOID_7(t1, t2, t3, t4, t5, t6, t7) (*thefunc->func)(ARGS7(t1, t2, t3, t4, t5, t6, t7))
481#define CALL_VOID_6(t1, t2, t3, t4, t5, t6) (*thefunc->func)(ARGS6(t1, t2, t3, t4, t5, t6))
482#define CALL_VOID_5(t1, t2, t3, t4, t5) (*thefunc->func)(ARGS5(t1, t2, t3, t4, t5))
483#define CALL_VOID_4(t1, t2, t3, t4) (*thefunc->func)(ARGS4(t1, t2, t3, t4))
484#define CALL_VOID_3(t1, t2, t3) (*thefunc->func)(ARGS3(t1, t2, t3))
485#define CALL_VOID_2(t1, t2) (*thefunc->func)(ARGS2(t1, t2))
486#define CALL_VOID_1(t1) (*thefunc->func)(ARGS1(t1))
487#define CALL_VOID_0() (*thefunc->func)()
488
489#define CALL_10(ret, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) weed_set_##ret##_value(info, _RV_, \
490 (*thefunc->func##ret)(ARGS10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t19)))
491#define CALL_9(ret, t1, t2, t3, t4, t5, t6, t7, t8, t9) weed_set_##ret##_value(info, _RV_, \
492 (*thefunc->func##ret)(ARGS9(t1, t2, t3, t4, t5, t6, t7, t8, t9)))
493#define CALL_8(ret, t1, t2, t3, t4, t5, t6, t7, t8) weed_set_##ret##_value(info, _RV_, \
494 (*thefunc->func##ret)(ARGS8(t1, t2, t3, t4, t5, t6, t7, t7)))
495#define CALL_7(ret, t1, t2, t3, t4, t5, t6, t7) weed_set_##ret##_value(info, _RV_, \
496 (*thefunc->func##ret)(ARGS7(t1, t2, t3, t4, t5, t6, t7)))
497#define CALL_6(ret, t1, t2, t3, t4, t5, t6) weed_set_##ret##_value(info, _RV_, (*thefunc->func##ret)(ARGS6(t1, t2, t3, t4, t5, t6)))
498#define CALL_5(ret, t1, t2, t3, t4, t5) weed_set_##ret##_value(info, _RV_, (*thefunc->func##ret)(ARGS5(t1, t2, t3, t4, t5)))
499#define CALL_4(ret, t1, t2, t3, t4) weed_set_##ret##_value(info, _RV_, (*thefunc->func##ret)(ARGS4(t1, t2, t3, t4)))
500#define CALL_3(ret, t1, t2, t3) weed_set_##ret##_value(info, _RV_, (*thefunc->func##ret)(ARGS3(t1, t2, t3)))
501#define CALL_2(ret, t1, t2) weed_set_##ret##_value(info, _RV_, (*thefunc->func##ret)(ARGS2(t1, t2)))
502#define CALL_1(ret, t1) weed_set_##ret##_value(info, _RV_, (*thefunc->func##ret)(ARGS1(t1)))
503#define CALL_0(ret) weed_set_##ret##_value(info, _RV_, (*thefunc->func##ret)())
504
505typedef union {
506 weed_funcptr_t func;
515} allfunc_t;
516
518 ...);
519
521
526
527lives_thread_data_t *get_thread_data(void);
529lives_thread_data_t *lives_thread_data_create(uint64_t idx);
530
531#define THREADVAR(var) (get_threadvars()->var_##var)
532
539
542
544
545// WARNING !! version without a return value will free tinfo !
547
548// with return value should free proc_thread
557
559
560void *fg_run_func(lives_proc_thread_t lpt, void *retval);
561void *main_thread_execute(lives_funcptr_t func, int return_type, void *retval, const char *args_fmt, ...);
562
563void free_fdets_list(LiVESList **);
564lives_proc_thread_t dir_to_file_details(LiVESList **, const char *dir,
565 const char *orig_loc, uint64_t extra);
566lives_proc_thread_t ordfile_to_file_details(LiVESList **listp, const char *ofname,
567 const char *orig_loc, uint64_t extra);
568
570char *grep_in_cmd(const char *cmd, int mstart, int npieces, const char *mphrase, int ridx, int rlen);
571
573char *get_wid_for_name(const char *wname);
574boolean hide_x11_window(const char *wid);
575boolean unhide_x11_window(const char *wid);
576boolean activate_x11_window(const char *wid);
577boolean show_desktop_panel(void);
578boolean hide_desktop_panel(void);
579boolean get_x11_visible(const char *wname);
580
581int get_window_stack_level(LiVESXWindow *, int *nwins);
582
583#define WM_XFWM4 "Xfwm4"
584#define WM_XFCE4_PANEL "xfce4-panel"
585#define WM_XFCE4_SSAVE "xfce4-ssave"
586#define WM_XFCE4_COLOR "xfce4-color-settings"
587#define WM_XFCE4_DISP "xfce4-display-settings"
588#define WM_XFCE4_POW "xfce4-power-manager-settings"
589#define WM_XFCE4_SETTINGS "xfce4-settings-manager"
590#define WM_XFCE4_TERMINAL "xfce4-terminal"
591#define WM_XFCE4_TASKMGR "xfce4-taskmanager"
592#define WM_XFCE4_SSHOT "xfce4-screenshooter"
593
594#define WM_KWIN "KWin"
595#define WM_KWIN_PANEL ""
596#define WM_KWIN_SSAVE ""
597#define WM_KWIN_COLOR ""
598#define WM_KWIN_DISP ""
599#define WM_KWIN_POW ""
600#define WM_KWIN_SETTINGS "systemseettings5"
601#define WM_KWIN_TERMINAL "Konsole"
602#define WM_KWIN_TASKMGR "systemmonitor"
603#define WM_KWIN_SSHOT ""
604
605#define XDG_CURRENT_DESKTOP "XDG_CURRENT_DESKTOP"
606#define XDG_SESSION_TYPE "XDG_SESSION_TYPE"
607
608boolean get_wm_caps(void);
609boolean get_distro_dets(void);
610boolean get_machine_dets(void);
611int get_num_cpus(void);
612double get_disk_load(const char *mp);
613int64_t get_cpu_load(int cpun);
614
615char *get_systmp(const char *suff, boolean is_dir);
616char *get_worktmp(const char *prefix);
617char *get_worktmpfile(const char *prefix);
618
619boolean check_snap(const char *prog);
620
621#endif
weed_plantptr_t lives_proc_thread_t
lives proc_threads API
weed_plant_t * lives_plant_new(int subtype)
void * quick_calloc(size_t n, size_t s)
Definition: machinestate.c:628
int get_window_stack_level(LiVESXWindow *, int *nwins)
weed_plantptr_t lives_proc_thread_join_plantptr(lives_proc_thread_t)
boolean show_desktop_panel(void)
uint32_t fastrand_int(uint32_t range)
pick a pseudo random uint between 0 and range (inclusive)
Definition: machinestate.c:54
boolean lives_proc_thread_cancel(lives_proc_thread_t)
lives_proc_thread_t dir_to_file_details(LiVESList **, const char *dir, const char *orig_loc, uint64_t extra)
create a list from a (sub)directory '.
char * lives_datetime(uint64_t secs, boolean use_local)
Definition: machinestate.c:860
boolean hide_desktop_panel(void)
boolean get_x11_visible(const char *wname)
void lives_srandom(unsigned int seed)
Definition: machinestate.c:56
boolean get_distro_dets(void)
boolean reverse_buffer(uint8_t *buff, size_t count, size_t chunk) GNU_HOT
LiVESList lives_thread_t
Definition: machinestate.h:434
char * get_md5sum(const char *filename)
Definition: machinestate.c:646
size_t lives_strlen(const char *) GNU_HOT GNU_PURE
void swab2(const void *from, const void *to, size_t granularity) GNU_HOT
off_t get_dir_size(const char *dirname)
weed_plantptr_t lives_proc_thread_t
Definition: machinestate.h:206
boolean unhide_x11_window(const char *wid)
char * get_worktmpfile(const char *prefix)
uint32_t fast_hash(const char *key) GNU_PURE GNU_HOT
void lives_proc_thread_join(lives_proc_thread_t)
char * get_mountpoint_for(const char *dir)
lives_thread_data_t * lives_thread_data_create(uint64_t idx)
uint64_t get_ds_free(const char *dir)
Definition: machinestate.c:776
boolean activate_x11_window(const char *wid)
weed_funcptr_t lives_proc_thread_join_funcptr(lives_proc_thread_t)
off_t get_file_size(int fd)
Definition: machinestate.c:943
boolean lives_proc_thread_dontcare(lives_proc_thread_t)
tell a threead with return value that we no longer need the value so it can free itself
void _ext_unmalloc_and_copy(size_t, void *)
Definition: machinestate.c:547
lives_proc_thread_t disk_monitor_start(const char *dir)
Definition: machinestate.c:717
weed_plant_t(* funcptr_plantptr_t)()
Definition: machinestate.h:462
weed_plant_t * lives_plant_new_with_index(int subtype, int64_t index)
lives_storage_status_t
disk/storage status values
Definition: machinestate.h:181
@ LIVES_STORAGE_STATUS_CRITICAL
Definition: machinestate.h:185
@ LIVES_STORAGE_STATUS_NORMAL
Definition: machinestate.h:183
@ LIVES_STORAGE_STATUS_WARNING
Definition: machinestate.h:184
@ LIVES_STORAGE_STATUS_OFFLINE
Definition: machinestate.h:188
@ LIVES_STORAGE_STATUS_UNKNOWN
Definition: machinestate.h:182
@ LIVES_STORAGE_STATUS_OVER_QUOTA
Definition: machinestate.h:187
@ LIVES_STORAGE_STATUS_OVERFLOW
Definition: machinestate.h:186
boolean init_memfuncs(void)
Definition: machinestate.c:630
void fastrand_add(uint64_t entropy)
Definition: machinestate.c:47
void * _ext_memset(void *, int, size_t)
Definition: machinestate.c:571
off_t sget_file_size(const char *name)
Definition: machinestate.c:962
double lives_proc_thread_join_double(lives_proc_thread_t)
void * lives_free_and_return(void *p)
TODO: this file should be split into at least: memory functions, thread functions,...
Definition: machinestate.c:593
void(* unmalloc_and_copy_f)(size_t, void *)
Definition: machinestate.h:28
boolean lives_strncmp(const char *, const char *, size_t) GNU_HOT GNU_PURE
returns FALSE if strings match
void swab8(const void *from, const void *to, size_t granularity) GNU_HOT
boolean lives_proc_thread_check(lives_proc_thread_t)
returns FALSE while the thread is running, TRUE once it has finished
void lives_free_check(void *p)
void * proxy_realloc(void *ptr, size_t new_size)
boolean lives_strcmp(const char *, const char *) GNU_HOT GNU_PURE
returns FALSE if strings match
weed_funcptr_t(* funcptr_funcptr_t)()
Definition: machinestate.h:460
uint64_t lives_random(void)
Definition: machinestate.c:58
void lives_proc_thread_free(lives_proc_thread_t lpt)
void autotune_u64(weed_plant_t *tuner, uint64_t min, uint64_t max, int ntrials, double cost)
Definition: machinestate.c:182
ticks_t lives_get_current_ticks(void)
Definition: machinestate.c:835
LiVESResponseType send_to_trash(const char *item)
int lives_proc_thread_signalled(lives_proc_thread_t tinfo)
void * fg_run_func(lives_proc_thread_t lpt, void *retval)
void lives_threadpool_init(void)
char * lives_proc_thread_join_string(lives_proc_thread_t)
boolean lives_proc_thread_cancelled(lives_proc_thread_t)
char * lives_chomp(char *string)
void init_random(void)
Definition: machinestate.c:92
void disk_monitor_forget(void)
Definition: machinestate.c:769
lives_thread_data_t * get_thread_data(void)
int64_t disk_monitor_wait_result(const char *dir, ticks_t timeout)
Definition: machinestate.c:742
void * _ext_calloc(size_t, size_t) GNU_MALLOC_SIZE2(1
void _ext_free(void *)
Definition: machinestate.c:556
lives_threadvars_t * get_threadvars(void)
void GNU_ALIGN(2)
lives_proc_thread_t lives_proc_thread_create(lives_thread_attr_t, lives_funcptr_t, int return_type, const char *args_fmt,...)
create the specific plant which defines a background task to be run
int lives_proc_thread_join_int(lives_proc_thread_t)
ticks_t lives_get_relative_ticks(ticks_t origsecs, ticks_t orignsecs)
Definition: machinestate.c:813
char *(* funcptr_string_t)()
Definition: machinestate.h:458
char * lives_strstop(char *, const char term) GNU_HOT
void * _ext_malloc(size_t n) GNU_MALLOC
Definition: machinestate.c:530
void update_effort(int nthings, boolean badthings)
int get_num_cpus(void)
boolean disk_monitor_running(const char *dir)
Definition: machinestate.c:715
char * lives_strtrim(const char *buff)
const char * lives_strappendf(const char *string, int len, const char *fmt,...)
int lives_strappend(const char *string, int len, const char *xnew)
boolean lives_proc_thread_get_cancellable(lives_proc_thread_t)
int64_t lives_proc_thread_join_int64(lives_proc_thread_t)
boolean get_machine_dets(void)
int64_t disk_monitor_check_result(const char *dir)
Definition: machinestate.c:726
boolean hide_x11_window(const char *wid)
boolean compress_files_in_dir(const char *dir, int method, void *data)
Definition: machinestate.c:898
uint64_t funcsig_t
Definition: machinestate.h:453
double get_disk_load(const char *mp)
void quick_free(void *p)
Definition: machinestate.c:626
char * lives_strdup_quick(const char *s)
uint64_t nxtval(uint64_t val, uint64_t lim, boolean less)
Definition: machinestate.c:198
void * _ext_realloc(void *, size_t) GNU_MALLOC_SIZE(2)
Definition: machinestate.c:575
boolean check_snap(const char *prog)
uint32_t lives_string_hash(const char *string) GNU_PURE GNU_HOT
int lives_proc_thread_join_boolean(lives_proc_thread_t)
char * lives_concat(char *, char *) GNU_HOT
uint64_t lives_thread_attr_t
Definition: machinestate.h:435
void lives_threadpool_finish(void)
double fastrand_dbl(double range)
Definition: machinestate.c:49
char * get_wid_for_name(const char *wname)
x11
char * lives_format_storage_space_string(uint64_t space)
Definition: machinestate.c:664
char * lives_concat_sep(char *st, const char *sep, char *x)
uint64_t autotune_u64_end(weed_plant_t **tuner, uint64_t val)
Definition: machinestate.c:259
void lives_proc_thread_set_cancellable(lives_proc_thread_t)
only threads with no return value can possibly be cancellable. For threads with a value,...
uint64_t gen_unique_id(void)
Definition: machinestate.c:68
off_t reget_afilesize_inner(int fileno)
void * _ext_memmove(void *, const void *, size_t)
Definition: machinestate.c:573
void * lives_recalloc(void *p, size_t nmemb, size_t omemb, size_t xsize) GNU_ALIGNED(DEF_ALIGN)
Definition: machinestate.c:615
void * lives_calloc_safety(size_t nmemb, size_t xsize) GNU_ALIGNED(DEF_ALIGN)
Definition: machinestate.c:603
double(* funcptr_dbl_t)()
Definition: machinestate.h:456
size_t get_max_align(size_t req_size, size_t align_max)
Definition: machinestate.c:596
uint64_t fastrand(void) GNU_HOT
Definition: machinestate.c:40
void reverse_bytes(char *buff, size_t count, size_t granularity) GNU_HOT GNU_FLATTEN
char * get_worktmp(const char *prefix)
void lives_proc_thread_sync_ready(lives_proc_thread_t)
void reset_effort(void)
lives_storage_status_t get_storage_status(const char *dir, uint64_t warn_level, int64_t *dsval, int64_t resvd)
Definition: machinestate.c:693
int64_t get_cpu_load(int cpun)
percent * 1 million
void * _ext_malloc_and_copy(size_t, const void *) GNU_MALLOC_SIZE(1)
Definition: machinestate.c:539
void *(* funcptr_voidptr_t)()
Definition: machinestate.h:461
void free_fdets_list(LiVESList **)
int(* funcptr_bool_t)()
Definition: machinestate.h:457
void * _ext_free_and_return(void *)
Definition: machinestate.c:565
void * main_thread_execute(lives_funcptr_t func, int return_type, void *retval, const char *args_fmt,...)
uint64_t lives_thread_join(lives_thread_t work, void **retval)
int64_t lives_proc_thread_signalled_idx(lives_proc_thread_t tinfo)
boolean get_wm_caps(void)
int check_dev_busy(char *devstr)
Definition: machinestate.c:876
void *(* lives_funcptr_t)(void *)
Definition: machinestate.h:378
int check_for_bad_ffmpeg(void)
void(* free_f)(void *)
Definition: machinestate.h:19
int lives_strcmp_ordered(const char *, const char *) GNU_HOT GNU_PURE
void swab4(const void *from, const void *to, size_t granularity) GNU_HOT
void * lives_proc_thread_join_voidptr(lives_proc_thread_t)
int lives_thread_create(lives_thread_t *thread, lives_thread_attr_t attr, lives_funcptr_t func, void *arg)
char * get_systmp(const char *suff, boolean is_dir)
int(* memcmp_f)(const void *, const void *, size_t)
Definition: machinestate.h:22
void lives_get_randbytes(void *ptr, size_t size)
Definition: machinestate.c:60
char * lives_datetime_rel(const char *datetime)
Definition: machinestate.c:842
void * _ext_memcpy(void *, const void *, size_t)
Definition: machinestate.c:567
void resubmit_proc_thread(lives_proc_thread_t, lives_thread_attr_t)
(re)submission point, the function call is added to the threadpool tasklist if we have sufficient thr...
void reget_afilesize(int fileno)
Definition: machinestate.c:972
int64_t(* funcptr_int64_t)()
Definition: machinestate.h:459
int(* funcptr_int_t)()
Definition: machinestate.h:455
lives_proc_thread_t ordfile_to_file_details(LiVESList **listp, const char *ofname, const char *orig_loc, uint64_t extra)
char * grep_in_cmd(const char *cmd, int mstart, int npieces, const char *mphrase, int ridx, int rlen)
#define GNU_HOT
Definition: main.h:88
#define GNU_MALLOC
Definition: main.h:80
#define GNU_MALLOC_SIZE(x)
Definition: main.h:81
#define DEF_ALIGN
Definition: main.h:629
#define GNU_ALIGNED(x)
Definition: main.h:85
int64_t ticks_t
Definition: main.h:97
#define GNU_FLATTEN
Definition: main.h:87
#define GNU_MALLOC_SIZE2(x, y)
Definition: main.h:82
#define GNU_PURE
Definition: main.h:78
void rpfree(void *ptr)
Free the given memory block.
Definition: rpmalloc.c:2612
RPMALLOC_ALLOCATOR void * rpaligned_calloc(size_t alignment, size_t num, size_t size)
Definition: rpmalloc.c:2675
lives_threadvars_t vars
Definition: machinestate.h:398
LiVESWidgetContext * ctx
Definition: machinestate.h:396
uint64_t uniq
< if we can retrieve some kind of uinque id, we set it here may be useful in future for dictionary lo...
Definition: machinestate.h:341
char * extra_details
only filled if EXTRA_DETAILS_MD5 is set, otherwis NULL
Definition: machinestate.h:357
uint64_t gid
userid as uint64_t
Definition: machinestate.h:348
lives_struct_def_t * lsd
Definition: machinestate.h:342
off_t size
e.g. LIVES_FILE_TYPE_FILE
Definition: machinestate.h:345
112 bytes
Definition: lsd.h:241
int var_rowstride_alignment_hint
Definition: machinestate.h:390
lives_thread_data_t * var_mydata
Definition: machinestate.h:384
boolean var_chdir_failed
Definition: machinestate.h:387
lives_proc_thread_t var_tinfo
Definition: machinestate.h:383
volatile boolean sync_ready
Definition: machinestate.h:408
volatile uint64_t done
Definition: machinestate.h:406
uint64_t flags
Definition: machinestate.h:404
volatile uint64_t busy
Definition: machinestate.h:405
lives_funcptr_t func
Definition: machinestate.h:402
weed_funcptr_t func
Definition: machinestate.h:506
funcptr_int64_t funcint64
Definition: machinestate.h:510
funcptr_dbl_t funcdouble
Definition: machinestate.h:508
funcptr_int_t funcint
Definition: machinestate.h:507
funcptr_string_t funcstring
Definition: machinestate.h:511
funcptr_bool_t funcboolean
Definition: machinestate.h:509
funcptr_voidptr_t funcvoidptr
Definition: machinestate.h:513
funcptr_funcptr_t funcfuncptr
Definition: machinestate.h:512
funcptr_plantptr_t funcplantptr
Definition: machinestate.h:514