options: Change ast_options from ast_flags to ast_flags64.

DeveloperNote: The 32-bit ast_options has no room left to accomodate new
options and so has been converted to an ast_flags64 structure. All internal
references to ast_options have been updated to use the 64-bit flag
manipulation macros.  External module references to the 32-bit ast_options
should continue to work on little-endian systems because the
least-significant bytes of a 64 bit integer will be in the same location as a
32-bit integer.  Because that's not the case on big-endian systems, we've
swapped the bytes in the flags manupulation macros on big-endian systems
so external modules should still work however you are encouraged to test.
This commit is contained in:
George Joseph
2025-07-21 13:12:40 -06:00
committed by github-actions[bot]
parent 3e178dcfd6
commit 43bf8a4ded
13 changed files with 167 additions and 140 deletions

View File

@@ -101,42 +101,51 @@ enum ast_option_flags {
AST_OPT_FLAG_GENERIC_PLC = (1 << 30),
/*! Generic PLC onm equal codecs */
AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS = (1 << 31),
/*!
* ast_options is now an ast_flags64 structure so if you add more
* options, make sure to use (1ULL << <bits>) to ensure that the
* enum itself is allocated as a uint64_t instead of the default
* uint32_t. Attmpting to simply shift a 1 by more than 31 bits
* will result in a "shift-count-overflow" compile failure.
* Example:
* AST_OPT_FLAG_NEW_OPTION = (1ULL << 32),
*/
};
/*! These are the options that set by default when Asterisk starts */
#define AST_DEFAULT_OPTIONS (AST_OPT_FLAG_TRANSCODE_VIA_SLIN | AST_OPT_FLAG_CACHE_MEDIA_FRAMES)
#define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
#define ast_opt_no_fork ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)
#define ast_opt_quiet ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)
#define ast_opt_console ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)
#define ast_opt_high_priority ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
#define ast_opt_init_keys ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)
#define ast_opt_remote ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)
#define ast_opt_exec ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)
#define ast_opt_no_color ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)
#define ast_fully_booted ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
#define ast_opt_transcode_via_slin ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
#define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)
#define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
#define ast_opt_cache_media_frames ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_MEDIA_FRAMES)
#define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)
#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
#define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
#define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)
#define ast_opt_dbg_module ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_MODULE)
#define ast_opt_trace_module ast_test_flag(&ast_options, AST_OPT_FLAG_TRACE_MODULE)
#define ast_opt_light_background ast_test_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND)
#define ast_opt_force_black_background ast_test_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND)
#define ast_opt_hide_connect ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT)
#define ast_opt_lock_confdir ast_test_flag(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR)
#define ast_opt_generic_plc ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC)
#define ast_opt_ref_debug ast_test_flag(&ast_options, AST_OPT_FLAG_REF_DEBUG)
#define ast_opt_generic_plc_on_equal_codecs ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)
#define ast_opt_hide_messaging_ami_events ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS)
#define ast_opt_sounds_search_custom ast_test_flag(&ast_options, AST_OPT_FLAG_SOUNDS_SEARCH_CUSTOM)
#define ast_opt_exec_includes ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
#define ast_opt_no_fork ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_FORK)
#define ast_opt_quiet ast_test_flag64(&ast_options, AST_OPT_FLAG_QUIET)
#define ast_opt_console ast_test_flag64(&ast_options, AST_OPT_FLAG_CONSOLE)
#define ast_opt_high_priority ast_test_flag64(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
#define ast_opt_init_keys ast_test_flag64(&ast_options, AST_OPT_FLAG_INIT_KEYS)
#define ast_opt_remote ast_test_flag64(&ast_options, AST_OPT_FLAG_REMOTE)
#define ast_opt_exec ast_test_flag64(&ast_options, AST_OPT_FLAG_EXEC)
#define ast_opt_no_color ast_test_flag64(&ast_options, AST_OPT_FLAG_NO_COLOR)
#define ast_fully_booted ast_test_flag64(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
#define ast_opt_transcode_via_slin ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
#define ast_opt_dump_core ast_test_flag64(&ast_options, AST_OPT_FLAG_DUMP_CORE)
#define ast_opt_cache_record_files ast_test_flag64(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
#define ast_opt_cache_media_frames ast_test_flag64(&ast_options, AST_OPT_FLAG_CACHE_MEDIA_FRAMES)
#define ast_opt_timestamp ast_test_flag64(&ast_options, AST_OPT_FLAG_TIMESTAMP)
#define ast_opt_reconnect ast_test_flag64(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_transmit_silence ast_test_flag64(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_opt_dont_warn ast_test_flag64(&ast_options, AST_OPT_FLAG_DONT_WARN)
#define ast_opt_always_fork ast_test_flag64(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
#define ast_opt_mute ast_test_flag64(&ast_options, AST_OPT_FLAG_MUTE)
#define ast_opt_dbg_module ast_test_flag64(&ast_options, AST_OPT_FLAG_DEBUG_MODULE)
#define ast_opt_trace_module ast_test_flag64(&ast_options, AST_OPT_FLAG_TRACE_MODULE)
#define ast_opt_light_background ast_test_flag64(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND)
#define ast_opt_force_black_background ast_test_flag64(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND)
#define ast_opt_hide_connect ast_test_flag64(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT)
#define ast_opt_lock_confdir ast_test_flag64(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR)
#define ast_opt_generic_plc ast_test_flag64(&ast_options, AST_OPT_FLAG_GENERIC_PLC)
#define ast_opt_ref_debug ast_test_flag64(&ast_options, AST_OPT_FLAG_REF_DEBUG)
#define ast_opt_generic_plc_on_equal_codecs ast_test_flag64(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)
#define ast_opt_hide_messaging_ami_events ast_test_flag64(&ast_options, AST_OPT_FLAG_HIDE_MESSAGING_AMI_EVENTS)
#define ast_opt_sounds_search_custom ast_test_flag64(&ast_options, AST_OPT_FLAG_SOUNDS_SEARCH_CUSTOM)
/*! Maximum log level defined by PJPROJECT. */
#define MAX_PJ_LOG_MAX_LEVEL 6
@@ -184,7 +193,7 @@ extern int ast_option_pjproject_cache_pools;
/*! Current pjproject logging level */
extern int ast_option_pjproject_log_level;
extern struct ast_flags ast_options;
extern struct ast_flags64 ast_options;
extern int option_verbose;
extern int ast_option_maxfiles; /*!< Max number of open file handles (files, sockets) */

View File

@@ -110,10 +110,27 @@ extern unsigned int __unsigned_int_flags_dummy;
} while (0)
/* The following 64-bit flag code can most likely be erased after app_dial
is reorganized to either reduce the large number of options, or handle
them in some other way. At the time of this writing, app_dial would be
the only user of 64-bit option flags */
/*!
* \brief Swap the upper and lower 32 bits of a big-endian 64-bit integer
*
* This macro is needed to preserve ABI compatability on big-endian systems
* after changing from a 32 bit flags to a 64 bit flags. It ensures that a
* new 64-bit flag field will still work with a function that expects a
* 32-bit flag field. On a little-endian system, nothing is needed, since
* the 64-bit flags are already in the correct order.
*
* \note This macro is different than a standard byte swap, as it
* doesn't reverse the byte order, it just swaps the upper 4 bytes with
* the lower 4 bytes.
*
* \param flags The 64-bit flags to swap
* \retval The flags with the upper and lower 32 bits swapped if the system is big-endian,
*/
#if __BYTE_ORDER == __BIG_ENDIAN
#define SWAP64_32(flags) (((uint64_t)flags << 32) | ((uint64_t)flags >> 32))
#else
#define SWAP64_32(flags) (flags)
#endif
extern uint64_t __unsigned_int_flags_dummy64;
@@ -121,21 +138,21 @@ extern uint64_t __unsigned_int_flags_dummy64;
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags & (flag)); \
((p)->flags & SWAP64_32(flag)); \
})
#define ast_set_flag64(p,flag) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags |= (flag)); \
((p)->flags |= SWAP64_32(flag)); \
} while(0)
#define ast_clear_flag64(p,flag) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags &= ~(flag)); \
((p)->flags &= ~SWAP64_32(flag)); \
} while(0)
#define ast_copy_flags64(dest,src,flagz) do { \
@@ -144,8 +161,8 @@ extern uint64_t __unsigned_int_flags_dummy64;
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__d == &__x); \
(void) (&__s == &__x); \
(dest)->flags &= ~(flagz); \
(dest)->flags |= ((src)->flags & (flagz)); \
(dest)->flags &= ~SWAP64_32(flagz); \
(dest)->flags |= ((src)->flags & SWAP64_32(flagz)); \
} while (0)
#define ast_set2_flag64(p,value,flag) do { \
@@ -153,19 +170,20 @@ extern uint64_t __unsigned_int_flags_dummy64;
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
if (value) \
(p)->flags |= (flag); \
(p)->flags |= SWAP64_32(flag); \
else \
(p)->flags &= ~(flag); \
(p)->flags &= ~SWAP64_32(flag); \
} while (0)
#define ast_set_flags_to64(p,flag,value) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
(p)->flags &= ~(flag); \
(p)->flags |= (value); \
(p)->flags &= ~SWAP64_32(flag); \
(p)->flags |= SWAP64_32(value); \
} while (0)
#define AST_FLAGS64_ALL ULONG_MAX
/* Non-type checking variations for non-unsigned int flags. You
should only use non-unsigned int flags where required by