PATH:
usr
/
include
/
mysql
/
server
/
private
/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef MY_BIT_INCLUDED #define MY_BIT_INCLUDED /* Some useful bit functions */ C_MODE_START extern const uchar _my_bits_reverse_table[256]; /* my_bit_log2_xxx() In the given value, find the highest bit set, which is the smallest X that satisfies the condition: (2^X >= value). Can be used as a reverse operation for (1<<X), to find X. Examples: - returns 0 for (1<<0) - returns 1 for (1<<1) - returns 2 for (1<<2) - returns 2 for 3, which has (1<<2) as the highest bit set. Note, the behaviour of log2(0) is not defined. Let's return 0 for the input 0, for the code simplicity. See the 000x branch. It covers both (1<<0) and 0. */ static inline CONSTEXPR uint my_bit_log2_hex_digit(uint8 value) { return value & 0x0C ? /*1100*/ (value & 0x08 ? /*1000*/ 3 : /*0100*/ 2) : /*0010*/ (value & 0x02 ? /*0010*/ 1 : /*000x*/ 0); } static inline CONSTEXPR uint my_bit_log2_uint8(uint8 value) { return value & 0xF0 ? my_bit_log2_hex_digit((uint8) (value >> 4)) + 4: my_bit_log2_hex_digit(value); } static inline CONSTEXPR uint my_bit_log2_uint16(uint16 value) { return value & 0xFF00 ? my_bit_log2_uint8((uint8) (value >> 8)) + 8 : my_bit_log2_uint8((uint8) value); } static inline CONSTEXPR uint my_bit_log2_uint32(uint32 value) { return value & 0xFFFF0000UL ? my_bit_log2_uint16((uint16) (value >> 16)) + 16 : my_bit_log2_uint16((uint16) value); } static inline CONSTEXPR uint my_bit_log2_uint64(ulonglong value) { return value & 0xFFFFFFFF00000000ULL ? my_bit_log2_uint32((uint32) (value >> 32)) + 32 : my_bit_log2_uint32((uint32) value); } static inline CONSTEXPR uint my_bit_log2_size_t(size_t value) { #ifdef __cplusplus static_assert(sizeof(size_t) <= sizeof(ulonglong), "size_t <= ulonglong is an assumption that needs to be fixed " "for this architecture. Please create an issue on " "https://jira.mariadb.org"); #endif return my_bit_log2_uint64((ulonglong) value); } /* Count bits in 32bit integer Algorithm by Sean Anderson, according to: http://graphics.stanford.edu/~seander/bithacks.html under "Counting bits set, in parallel" (Original code public domain). */ static inline uint my_count_bits_uint32(uint32 v) { v = v - ((v >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); return (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; } static inline uint my_count_bits(ulonglong x) { return my_count_bits_uint32((uint32)x) + my_count_bits_uint32((uint32)(x >> 32)); } /* Next highest power of two SYNOPSIS my_round_up_to_next_power() v Value to check RETURN Next or equal power of 2 Note: 0 will return 0 NOTES Algorithm by Sean Anderson, according to: http://graphics.stanford.edu/~seander/bithacks.html (Original code public domain) Comments shows how this works with 01100000000000000000000000001011 */ static inline uint32 my_round_up_to_next_power(uint32 v) { v--; /* 01100000000000000000000000001010 */ v|= v >> 1; /* 01110000000000000000000000001111 */ v|= v >> 2; /* 01111100000000000000000000001111 */ v|= v >> 4; /* 01111111110000000000000000001111 */ v|= v >> 8; /* 01111111111111111100000000001111 */ v|= v >> 16; /* 01111111111111111111111111111111 */ return v+1; /* 10000000000000000000000000000000 */ } static inline uint32 my_clear_highest_bit(uint32 v) { uint32 w=v >> 1; w|= w >> 1; w|= w >> 2; w|= w >> 4; w|= w >> 8; w|= w >> 16; return v & w; } static inline uint32 my_reverse_bits(uint32 key) { return ((uint32)_my_bits_reverse_table[ key & 255] << 24) | ((uint32)_my_bits_reverse_table[(key>> 8) & 255] << 16) | ((uint32)_my_bits_reverse_table[(key>>16) & 255] << 8) | (uint32)_my_bits_reverse_table[(key>>24) ]; } /* a number with the n lowest bits set an overflow-safe version of (1 << n) - 1 */ static inline uint64 my_set_bits(int n) { return (((1ULL << (n - 1)) - 1) << 1) | 1; } /* Create a mask of the significant bits for the last byte (1,3,7,..255) */ static inline uchar last_byte_mask(uint bits) { /* Get the number of used bits-1 (0..7) in the last byte */ unsigned int const used = (bits - 1U) & 7U; /* Return bitmask for the significant bits */ return (uchar) ((2U << used) - 1); } static inline uint my_bits_in_bytes(uint n) { return ((n + 7) / 8); } #ifdef _MSC_VER #include <intrin.h> #endif /* Find the position of the first(least significant) bit set in the argument. Returns 64 if the argument was 0. */ static inline uint my_find_first_bit(ulonglong n) { if(!n) return 64; #if defined(__GNUC__) return __builtin_ctzll(n); #elif defined(_MSC_VER) #if defined(_M_IX86) unsigned long bit; if( _BitScanForward(&bit, (uint)n)) return bit; _BitScanForward(&bit, (uint)(n>>32)); return bit + 32; #else unsigned long bit; _BitScanForward64(&bit, n); return bit; #endif #else /* Generic case */ uint shift= 0; static const uchar last_bit[16] = { 32, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0}; uint bit; while ((bit = last_bit[(n >> shift) & 0xF]) == 32) shift+= 4; return shift+bit; #endif } C_MODE_END #endif /* MY_BIT_INCLUDED */
[+]
..
[-] sql_manager.h
[open]
[-] create_tmp_table.h
[open]
[-] lex_ident.h
[open]
[-] semisync_slave.h
[open]
[-] sql_cache.h
[open]
[-] events.h
[open]
[-] my_rnd.h
[open]
[-] lex_hash.h
[open]
[-] discover.h
[open]
[-] item_geofunc.h
[open]
[-] wsrep_applier.h
[open]
[-] my_apc.h
[open]
[-] log_event.h
[open]
[-] wsrep_thd.h
[open]
[-] threadpool_generic.h
[open]
[-] my_json_writer.h
[open]
[-] mysys_err.h
[open]
[-] semisync_master_ack_receiver.h
[open]
[-] sql_udf.h
[open]
[-] opt_trace_context.h
[open]
[-] violite.h
[open]
[-] rpl_mi.h
[open]
[-] thr_timer.h
[open]
[-] bounded_queue.h
[open]
[-] item_sum.h
[open]
[-] cset_narrowing.h
[open]
[-] wsrep_xid.h
[open]
[-] my_bitmap.h
[open]
[-] table_cache.h
[open]
[-] sql_locale.h
[open]
[-] sql_plugin.h
[open]
[-] handle_connections_win.h
[open]
[-] sql_array.h
[open]
[-] sql_expression_cache.h
[open]
[-] password.h
[open]
[-] waiting_threads.h
[open]
[-] my_virtual_mem.h
[open]
[-] privilege.h
[open]
[-] rpl_filter.h
[open]
[-] event_db_repository.h
[open]
[-] thr_malloc.h
[open]
[-] rpl_injector.h
[open]
[-] sql_const.h
[open]
[-] lex_charset.h
[open]
[-] my_cpu.h
[open]
[-] sql_rename.h
[open]
[-] sp_cache.h
[open]
[-] sql_prepare.h
[open]
[-] mdl.h
[open]
[-] event_scheduler.h
[open]
[-] my_md5.h
[open]
[-] probes_mysql.h
[open]
[-] item_subselect.h
[open]
[-] sql_type_geom.h
[open]
[-] sql_sequence.h
[open]
[-] sql_type_fixedbin.h
[open]
[-] wsrep_storage_service.h
[open]
[-] item_windowfunc.h
[open]
[-] sql_command.h
[open]
[-] uniques.h
[open]
[-] rpl_record.h
[open]
[-] sql_priv.h
[open]
[-] sql_digest_stream.h
[open]
[-] sql_callback.h
[open]
[-] item_row.h
[open]
[-] table.h
[open]
[-] sql_profile.h
[open]
[-] item_create.h
[open]
[-] item_jsonfunc.h
[open]
[-] sys_vars_shared.h
[open]
[-] opt_trace.h
[open]
[-] wsrep_types.h
[open]
[-] sql_help.h
[open]
[-] wsrep_on.h
[open]
[-] myisamchk.h
[open]
[-] my_compare.h
[open]
[-] item_strfunc.h
[open]
[-] proxy_protocol.h
[open]
[-] wsrep.h
[open]
[-] my_stack_alloc.h
[open]
[-] my_nosys.h
[open]
[-] sql_analyze_stmt.h
[open]
[-] datadict.h
[open]
[-] wqueue.h
[open]
[-] mysqld_suffix.h
[open]
[-] protocol.h
[open]
[-] wsrep_allowlist_service.h
[open]
[-] my_user.h
[open]
[-] myisam.h
[open]
[-] sql_trigger.h
[open]
[-] json_table.h
[open]
[-] sql_signal.h
[open]
[-] filesort.h
[open]
[-] embedded_priv.h
[open]
[-] sql_type_json.h
[open]
[-] sql_alter.h
[open]
[-] heap.h
[open]
[-] sql_delete.h
[open]
[-] partition_info.h
[open]
[-] message.h
[open]
[-] sql_sort.h
[open]
[-] wsrep_utils.h
[open]
[-] rijndael.h
[open]
[-] set_var.h
[open]
[-] my_minidump.h
[open]
[-] compat56.h
[open]
[-] client_settings.h
[open]
[-] thr_alarm.h
[open]
[-] xa.h
[open]
[-] assume_aligned.h
[open]
[-] my_libwrap.h
[open]
[+]
atomic
[-] wsrep_status.h
[open]
[-] innodb_priv.h
[open]
[-] sql_load.h
[open]
[-] sql_plugin_compat.h
[open]
[-] sp_rcontext.h
[open]
[-] wsrep_sst.h
[open]
[-] sql_acl.h
[open]
[-] procedure.h
[open]
[-] pfs_transaction_provider.h
[open]
[-] my_atomic.h
[open]
[-] item_vers.h
[open]
[-] sql_repl.h
[open]
[-] sql_do.h
[open]
[-] hash_filo.h
[open]
[-] pfs_statement_provider.h
[open]
[-] service_versions.h
[open]
[-] sql_cmd.h
[open]
[-] sql_type_string.h
[open]
[-] item_timefunc.h
[open]
[-] my_handler_errors.h
[open]
[-] sql_crypt.h
[open]
[-] scheduler.h
[open]
[-] pfs_socket_provider.h
[open]
[-] tzfile.h
[open]
[-] rpl_rli.h
[open]
[-] wsrep_mutex.h
[open]
[-] keycaches.h
[open]
[-] my_time.h
[open]
[-] rpl_record_old.h
[open]
[-] welcome_copyright_notice.h
[open]
[-] item.h
[open]
[-] wsrep_server_service.h
[open]
[-] t_ctype.h
[open]
[-] sql_debug.h
[open]
[-] mysqld.h
[open]
[-] item_xmlfunc.h
[open]
[-] pfs_metadata_provider.h
[open]
[-] gstream.h
[open]
[-] sql_reload.h
[open]
[-] session_tracker.h
[open]
[-] config.h
[open]
[-] multi_range_read.h
[open]
[-] ha_handler_stats.h
[open]
[-] my_counter.h
[open]
[-] sql_type.h
[open]
[-] probes_mysql_nodtrace.h
[open]
[-] my_base.h
[open]
[-] opt_subselect.h
[open]
[-] repl_failsafe.h
[open]
[-] handler.h
[open]
[-] wsrep_mysqld_c.h
[open]
[-] records.h
[open]
[-] backup.h
[open]
[-] sql_bitmap.h
[open]
[-] sql_binlog.h
[open]
[-] log_event_data_type.h
[open]
[-] wsrep_client_service.h
[open]
[-] lex_symbol.h
[open]
[-] sql_lex.h
[open]
[-] ddl_log.h
[open]
[-] create_options.h
[open]
[-] group_by_handler.h
[open]
[-] strfunc.h
[open]
[-] my_service_manager.h
[open]
[-] semisync_master.h
[open]
[-] sql_db.h
[open]
[-] sql_insert.h
[open]
[-] my_stacktrace.h
[open]
[-] lex.h
[open]
[-] item_cmpfunc.h
[open]
[-] sql_type_int.h
[open]
[-] wsrep_var.h
[open]
[-] maria.h
[open]
[-] event_data_objects.h
[open]
[-] sql_handler.h
[open]
[-] source_revision.h
[open]
[-] debug.h
[open]
[-] rpl_gtid.h
[open]
[-] key.h
[open]
[-] sql_servers.h
[open]
[-] lex_string.h
[open]
[-] myisampack.h
[open]
[-] rpl_tblmap.h
[open]
[-] sql_type_fixedbin_storage.h
[open]
[-] my_crypt.h
[open]
[-] structs.h
[open]
[-] sql_table.h
[open]
[-] field.h
[open]
[-] sql_plist.h
[open]
[-] replication.h
[open]
[-] select_handler.h
[open]
[-] winservice.h
[open]
[-] win_tzname_data.h
[open]
[-] slave.h
[open]
[-] init.h
[open]
[-] sql_get_diagnostics.h
[open]
[-] sp_head.h
[open]
[-] custom_conf.h
[open]
[-] sql_join_cache.h
[open]
[-] sql_audit.h
[open]
[-] sql_connect.h
[open]
[-] wsrep_server_state.h
[open]
[+]
data
[-] sql_update.h
[open]
[-] transaction.h
[open]
[-] log_event_old.h
[open]
[-] pfs_stage_provider.h
[open]
[-] mariadb.h
[open]
[-] item_func.h
[open]
[-] my_tree.h
[open]
[-] sql_tvc.h
[open]
[-] rpl_reporting.h
[open]
[-] derror.h
[open]
[-] sql_schema.h
[open]
[-] sql_parse.h
[open]
[-] sql_type_real.h
[open]
[-] pfs_thread_provider.h
[open]
[-] my_check_opt.h
[open]
[-] rowid_filter.h
[open]
[-] sql_base.h
[open]
[-] sql_test.h
[open]
[-] sp.h
[open]
[-] my_uctype.h
[open]
[-] myisammrg.h
[open]
[-] sp_pcontext.h
[open]
[-] my_bit.h
[open]
[-] wsrep_client_state.h
[open]
[-] event_queue.h
[open]
[-] sql_window.h
[open]
[-] sql_limit.h
[open]
[-] my_rdtsc.h
[open]
[-] sql_list.h
[open]
[-] pfs_file_provider.h
[open]
[-] rpl_constants.h
[open]
[-] sql_explain.h
[open]
[-] sql_class.h
[open]
[-] sql_i_s.h
[open]
[-] sql_lifo_buffer.h
[open]
[-] pfs_memory_provider.h
[open]
[-] ssl_compat.h
[open]
[-] wsrep_mysqld.h
[open]
[-] dur_prop.h
[open]
[-] sql_union.h
[open]
[-] field_comp.h
[open]
[-] contributors.h
[open]
[-] pfs_table_provider.h
[open]
[-] wsrep_condition_variable.h
[open]
[-] wsrep_trans_observer.h
[open]
[-] rpl_parallel.h
[open]
[-] parse_file.h
[open]
[-] my_atomic_wrapper.h
[open]
[-] sql_alloc.h
[open]
[-] threadpool_winsockets.h
[open]
[-] sql_show.h
[open]
[-] sql_mode.h
[open]
[-] gcalc_tools.h
[open]
[-] hash.h
[open]
[-] sql_partition.h
[open]
[-] mysqld_default_groups.h
[open]
[-] sql_truncate.h
[open]
[-] mem_root_array.h
[open]
[-] sql_basic_types.h
[open]
[-] socketpair.h
[open]
[-] lex_token.h
[open]
[-] thr_lock.h
[open]
[+]
providers
[-] authors.h
[open]
[-] sql_error.h
[open]
[-] threadpool.h
[open]
[-] opt_range.h
[open]
[-] log_slow.h
[open]
[-] debug_sync.h
[open]
[-] ha_partition.h
[open]
[-] sql_derived.h
[open]
[-] sql_bootstrap.h
[open]
[-] gcalc_slicescan.h
[open]
[-] queues.h
[open]
[-] aria_backup.h
[open]
[-] aligned.h
[open]
[-] partition_element.h
[open]
[-] spatial.h
[open]
[-] semisync.h
[open]
[-] my_default.h
[open]
[-] sql_hset.h
[open]
[-] sql_cte.h
[open]
[-] opt_histogram_json.h
[open]
[-] scope.h
[open]
[-] event_parse_data.h
[open]
[-] ilist.h
[open]
[-] sql_view.h
[open]
[-] wsrep_schema.h
[open]
[-] lock.h
[open]
[-] sql_admin.h
[open]
[-] sql_partition_admin.h
[open]
[-] vers_string.h
[open]
[-] ha_sequence.h
[open]
[-] sql_cursor.h
[open]
[-] sql_string.h
[open]
[-] sql_statistics.h
[open]
[-] tztime.h
[open]
[-] my_alarm.h
[open]
[-] my_decimal.h
[open]
[-] sql_analyse.h
[open]
[-] sql_digest.h
[open]
[-] unireg.h
[open]
[-] hostname.h
[open]
[-] ft_global.h
[open]
[-] grant.h
[open]
[-] wsrep_priv.h
[open]
[-] log.h
[open]
[-] filesort_utils.h
[open]
[-] sql_time.h
[open]
[-] sql_select.h
[open]
[-] wsrep_binlog.h
[open]
[-] wsrep_high_priority_service.h
[open]
[-] pfs_idle_provider.h
[open]
[-] derived_handler.h
[open]
[-] thread_cache.h
[open]
[-] lf.h
[open]
[-] des_key_file.h
[open]
[-] span.h
[open]
[-] rpl_utility.h
[open]