mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
* feat: FuriThread stdin * ci: fix f18 * feat: stdio callback context * feat: FuriPipe * POTENTIALLY EXPLOSIVE pipe welding * fix: non-explosive welding * Revert welding * docs: furi_pipe * feat: pipe event loop integration * update f18 sdk * f18 * docs: make doxygen happy * fix: event loop not triggering when pipe attached to stdio * fix: partial stdout in pipe * allow simultaneous in and out subscription in event loop * feat: vcp i/o * feat: cli ansi stuffs and history * feat: more line editing * working but slow cli rewrite * restore previous speed after 4 days of debugging 🥲 * fix: cli_app_should_stop * fix: cli and event_loop memory leaks * style: remove commented out code * ci: fix pvs warnings * fix: unit tests, event_loop crash * ci: fix build * ci: silence pvs warning * feat: cli gpio * ci: fix formatting * Fix memory leak during event loop unsubscription * Event better memory leak fix * feat: cli completions * Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads * merge fixups * temporarily exclude speaker_debug app * pvs and unit tests fixups * feat: commands in fals * move commands out of flash, code cleanup * ci: fix errors * fix: run commands in buffer when stopping session * speedup cli file transfer * fix f18 * separate cli_shell into modules * fix pvs warning * fix qflipper refusing to connect * remove temp debug logs * remove erroneous conclusion * Fix memory leak during event loop unsubscription * Event better memory leak fix * unit test for the fix * improve thread stdio callback signatures * pipe stdout timeout * update api symbols * fix f18, formatting * fix pvs warnings * increase stack size, hope to fix unit tests * cli: revert flag changes * cli: fix formatting * cli, fbt: loopback perf benchmark * thread, event_loop: subscribing to thread flags * cli: signal internal events using thread flags, improve performance * fix f18, formatting * event_loop: fix crash * storage_cli: increase write_chunk buffer size again * cli: explanation for order=0 * thread, event_loop: thread flags callback refactor * cli: increase stack size * cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char * cli: use plain array instead of mlib for history * cli: prepend file name to static fns * cli: fix formatting * cli_shell: increase stack size * cli: fix rpc lockup * cli: better lockup fix * cli: fix f18 * fix merge --------- Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com> Co-authored-by: あく <alleteam@gmail.com>
127 lines
2.7 KiB
C
127 lines
2.7 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define FURI_RETURNS_NONNULL __attribute__((returns_nonnull))
|
|
|
|
#ifndef MAX
|
|
#define MAX(a, b) \
|
|
({ \
|
|
__typeof__(a) _a = (a); \
|
|
__typeof__(b) _b = (b); \
|
|
_a > _b ? _a : _b; \
|
|
})
|
|
#endif
|
|
|
|
#ifndef MIN
|
|
#define MIN(a, b) \
|
|
({ \
|
|
__typeof__(a) _a = (a); \
|
|
__typeof__(b) _b = (b); \
|
|
_a < _b ? _a : _b; \
|
|
})
|
|
#endif
|
|
|
|
#ifndef ABS
|
|
#define ABS(a) ({ (a) < 0 ? -(a) : (a); })
|
|
#endif
|
|
|
|
#ifndef ROUND_UP_TO
|
|
#define ROUND_UP_TO(a, b) \
|
|
({ \
|
|
__typeof__(a) _a = (a); \
|
|
__typeof__(b) _b = (b); \
|
|
_a / _b + !!(_a % _b); \
|
|
})
|
|
#endif
|
|
|
|
#ifndef CLAMP
|
|
#define CLAMP(x, upper, lower) (MIN(upper, MAX(x, lower)))
|
|
#endif
|
|
|
|
#ifndef CLAMP_WRAPAROUND
|
|
#define CLAMP_WRAPAROUND(x, upper, lower) \
|
|
({ \
|
|
__typeof__(x) _x = (x); \
|
|
__typeof__(upper) _upper = (upper); \
|
|
__typeof__(lower) _lower = (lower); \
|
|
(_x > _upper) ? _lower : ((_x < _lower) ? _upper : _x); \
|
|
})
|
|
#endif
|
|
|
|
#ifndef COUNT_OF
|
|
#define COUNT_OF(x) (sizeof(x) / sizeof(x[0]))
|
|
#endif
|
|
|
|
#ifndef FURI_SWAP
|
|
#define FURI_SWAP(x, y) \
|
|
do { \
|
|
typeof(x) SWAP = x; \
|
|
x = y; \
|
|
y = SWAP; \
|
|
} while(0)
|
|
#endif
|
|
|
|
#ifndef PLACE_IN_SECTION
|
|
#define PLACE_IN_SECTION(x) __attribute__((section(x)))
|
|
#endif
|
|
|
|
#ifndef ALIGN
|
|
#define ALIGN(n) __attribute__((aligned(n)))
|
|
#endif
|
|
|
|
#ifndef __weak
|
|
#define __weak __attribute__((weak))
|
|
#endif
|
|
|
|
#ifndef UNUSED
|
|
#define UNUSED(X) (void)(X)
|
|
#endif
|
|
|
|
#ifndef STRINGIFY
|
|
#define STRINGIFY(x) #x
|
|
#endif
|
|
|
|
#ifndef TOSTRING
|
|
#define TOSTRING(x) STRINGIFY(x)
|
|
#endif
|
|
|
|
#ifndef CONCATENATE
|
|
#define CONCATENATE(a, b) CONCATENATE_(a, b)
|
|
#define CONCATENATE_(a, b) a##b
|
|
#endif
|
|
|
|
#ifndef REVERSE_BYTES_U32
|
|
#define REVERSE_BYTES_U32(x) \
|
|
((((x) & 0x000000FF) << 24) | (((x) & 0x0000FF00) << 8) | (((x) & 0x00FF0000) >> 8) | \
|
|
(((x) & 0xFF000000) >> 24))
|
|
#endif
|
|
|
|
#ifndef FURI_BIT
|
|
#define FURI_BIT(x, n) (((x) >> (n)) & 1)
|
|
#endif
|
|
|
|
#ifndef FURI_BIT_SET
|
|
#define FURI_BIT_SET(x, n) \
|
|
({ \
|
|
__typeof__(x) _x = (1); \
|
|
(x) |= (_x << (n)); \
|
|
})
|
|
#endif
|
|
|
|
#ifndef FURI_BIT_CLEAR
|
|
#define FURI_BIT_CLEAR(x, n) \
|
|
({ \
|
|
__typeof__(x) _x = (1); \
|
|
(x) &= ~(_x << (n)); \
|
|
})
|
|
#endif
|
|
|
|
#define FURI_SW_MEMBARRIER() asm volatile("" : : : "memory")
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|