Commit 7ff256d3 authored by unknown's avatar unknown

Fix compile failures and warnings on Windows from XtraDB "shm buffer pool" patch.

(It is not legal C to do pointer arithmetics on void *).
parent c507c028
...@@ -452,6 +452,8 @@ buf_buddy_relocate( ...@@ -452,6 +452,8 @@ buf_buddy_relocate(
buf_page_t* bpage; buf_page_t* bpage;
const ulint size = BUF_BUDDY_LOW << i; const ulint size = BUF_BUDDY_LOW << i;
ullint usec = ut_time_us(NULL); ullint usec = ut_time_us(NULL);
ulint space;
ulint page_no;
//ut_ad(buf_pool_mutex_own()); //ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&zip_free_mutex)); ut_ad(mutex_own(&zip_free_mutex));
...@@ -490,9 +492,9 @@ buf_buddy_relocate( ...@@ -490,9 +492,9 @@ buf_buddy_relocate(
pool), so there is nothing wrong about this. The pool), so there is nothing wrong about this. The
mach_read_from_4() calls here will only trigger bogus mach_read_from_4() calls here will only trigger bogus
Valgrind memcheck warnings in UNIV_DEBUG_VALGRIND builds. */ Valgrind memcheck warnings in UNIV_DEBUG_VALGRIND builds. */
ulint space = mach_read_from_4( space = mach_read_from_4(
(const byte*) src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); (const byte*) src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
ulint page_no = mach_read_from_4( page_no = mach_read_from_4(
(const byte*) src + FIL_PAGE_OFFSET); (const byte*) src + FIL_PAGE_OFFSET);
/* Suppress Valgrind warnings about conditional jump /* Suppress Valgrind warnings about conditional jump
on uninitialized value. */ on uninitialized value. */
......
...@@ -792,7 +792,7 @@ buf_block_reuse( ...@@ -792,7 +792,7 @@ buf_block_reuse(
ptrdiff_t frame_offset) ptrdiff_t frame_offset)
{ {
/* block_init */ /* block_init */
block->frame = ((void*)(block->frame) + frame_offset); block->frame = ((char*)(block->frame) + frame_offset);
UNIV_MEM_DESC(block->frame, UNIV_PAGE_SIZE, block); UNIV_MEM_DESC(block->frame, UNIV_PAGE_SIZE, block);
...@@ -809,7 +809,7 @@ buf_block_reuse( ...@@ -809,7 +809,7 @@ buf_block_reuse(
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
if (block->page.zip.data) if (block->page.zip.data)
block->page.zip.data = ((void*)(block->page.zip.data) + frame_offset); block->page.zip.data = ((char*)(block->page.zip.data) + frame_offset);
block->is_hashed = FALSE; block->is_hashed = FALSE;
...@@ -876,17 +876,17 @@ buf_chunk_init( ...@@ -876,17 +876,17 @@ buf_chunk_init(
"InnoDB: You should ensure no change of InnoDB files while using innodb_buffer_pool_shm_key.\n"); "InnoDB: You should ensure no change of InnoDB files while using innodb_buffer_pool_shm_key.\n");
/* FIXME: This is vague id still */ /* FIXME: This is vague id still */
binary_id = (ulint) ((void*)mtr_commit - (void*)btr_root_get) binary_id = (ulint) ((char*)mtr_commit - (char *)btr_root_get)
+ (ulint) ((void*)os_get_os_version - (void*)buf_calc_page_new_checksum) + (ulint) ((char *)os_get_os_version - (char *)buf_calc_page_new_checksum)
+ (ulint) ((void*)page_dir_find_owner_slot - (void*)dfield_data_is_binary_equal) + (ulint) ((char *)page_dir_find_owner_slot - (char *)dfield_data_is_binary_equal)
+ (ulint) ((void*)que_graph_publish - (void*)dict_casedn_str) + (ulint) ((char *)que_graph_publish - (char *)dict_casedn_str)
+ (ulint) ((void*)read_view_oldest_copy_or_open_new - (void*)fil_space_get_version) + (ulint) ((char *)read_view_oldest_copy_or_open_new - (char *)fil_space_get_version)
+ (ulint) ((void*)rec_get_n_extern_new - (void*)fsp_get_size_low) + (ulint) ((char *)rec_get_n_extern_new - (char *)fsp_get_size_low)
+ (ulint) ((void*)row_get_trx_id_offset - (void*)ha_create_func) + (ulint) ((char *)row_get_trx_id_offset - (char *)ha_create_func)
+ (ulint) ((void*)srv_set_io_thread_op_info - (void*)thd_is_replication_slave_thread) + (ulint) ((char *)srv_set_io_thread_op_info - (char *)thd_is_replication_slave_thread)
+ (ulint) ((void*)mutex_create_func - (void*)ibuf_inside) + (ulint) ((char *)mutex_create_func - (char *)ibuf_inside)
+ (ulint) ((void*)trx_set_detailed_error - (void*)lock_check_trx_id_sanity) + (ulint) ((char *)trx_set_detailed_error - (char *)lock_check_trx_id_sanity)
+ (ulint) ((void*)ut_time - (void*)mem_heap_strdup); + (ulint) ((char *)ut_time - (char *)mem_heap_strdup);
chunk->mem = os_shm_alloc(&chunk->mem_size, srv_buffer_pool_shm_key, &is_new); chunk->mem = os_shm_alloc(&chunk->mem_size, srv_buffer_pool_shm_key, &is_new);
...@@ -902,7 +902,7 @@ buf_chunk_init( ...@@ -902,7 +902,7 @@ buf_chunk_init(
shm_info = chunk->mem; shm_info = chunk->mem;
zip_hash_tmp = (hash_table_t*)((void*)chunk->mem + chunk->mem_size - zip_hash_mem_size); zip_hash_tmp = (hash_table_t*)((char *)chunk->mem + chunk->mem_size - zip_hash_mem_size);
if (is_new) { if (is_new) {
strncpy(shm_info->head_str, BUF_SHM_INFO_HEAD, 8); strncpy(shm_info->head_str, BUF_SHM_INFO_HEAD, 8);
...@@ -959,7 +959,7 @@ buf_chunk_init( ...@@ -959,7 +959,7 @@ buf_chunk_init(
ut_a(shm_info->zip_hash_n == zip_hash_n); ut_a(shm_info->zip_hash_n == zip_hash_n);
/* check checksum */ /* check checksum */
checksum = ut_fold_binary(chunk->mem + sizeof(buf_shm_info_t), checksum = ut_fold_binary((byte*)chunk->mem + sizeof(buf_shm_info_t),
chunk->mem_size - sizeof(buf_shm_info_t)); chunk->mem_size - sizeof(buf_shm_info_t));
if (shm_info->checksum != checksum) { if (shm_info->checksum != checksum) {
fprintf(stderr, fprintf(stderr,
...@@ -992,7 +992,7 @@ buf_chunk_init( ...@@ -992,7 +992,7 @@ buf_chunk_init(
/* Allocate the block descriptors from /* Allocate the block descriptors from
the start of the memory block. */ the start of the memory block. */
if (srv_buffer_pool_shm_key) { if (srv_buffer_pool_shm_key) {
chunk->blocks = chunk->mem + sizeof(buf_shm_info_t); chunk->blocks = (buf_block_t*)((char*)chunk->mem + sizeof(buf_shm_info_t));
} else { } else {
chunk->blocks = chunk->mem; chunk->blocks = chunk->mem;
} }
...@@ -1028,7 +1028,7 @@ buf_chunk_init( ...@@ -1028,7 +1028,7 @@ buf_chunk_init(
ptrdiff_t phys_offset; ptrdiff_t phys_offset;
ptrdiff_t logi_offset; ptrdiff_t logi_offset;
ptrdiff_t blocks_offset; ptrdiff_t blocks_offset;
void* previous_frame_address; byte* previous_frame_address;
if (chunk->size < shm_info->chunk_backup.size) { if (chunk->size < shm_info->chunk_backup.size) {
fprintf(stderr, fprintf(stderr,
...@@ -1039,10 +1039,10 @@ buf_chunk_init( ...@@ -1039,10 +1039,10 @@ buf_chunk_init(
} }
chunk->size = shm_info->chunk_backup.size; chunk->size = shm_info->chunk_backup.size;
phys_offset = (void*)frame - (void*)((void*)chunk->mem + shm_info->frame_offset); phys_offset = (char*)frame - ((char*)chunk->mem + shm_info->frame_offset);
logi_offset = (void*)frame - (void*)chunk->blocks[0].frame; logi_offset = (char *)frame - (char *)chunk->blocks[0].frame;
previous_frame_address = chunk->blocks[0].frame; previous_frame_address = chunk->blocks[0].frame;
blocks_offset = (void*)chunk->blocks - (void*)shm_info->chunk_backup.blocks; blocks_offset = (char *)chunk->blocks - (char *)shm_info->chunk_backup.blocks;
if (phys_offset || logi_offset || blocks_offset) { if (phys_offset || logi_offset || blocks_offset) {
fprintf(stderr, fprintf(stderr,
...@@ -1053,8 +1053,8 @@ buf_chunk_init( ...@@ -1053,8 +1053,8 @@ buf_chunk_init(
"InnoDB: Pysical offset : %ld (%#lx)\n" "InnoDB: Pysical offset : %ld (%#lx)\n"
"InnoDB: Logical offset (frames) : %ld (%#lx)\n" "InnoDB: Logical offset (frames) : %ld (%#lx)\n"
"InnoDB: Logical offset (blocks) : %ld (%#lx)\n", "InnoDB: Logical offset (blocks) : %ld (%#lx)\n",
(void*)((void*)chunk->mem + shm_info->frame_offset), (char *)chunk->mem + shm_info->frame_offset,
(void*)chunk->blocks[0].frame, (void*)frame, chunk->blocks[0].frame, frame,
(ulong) phys_offset, (ulong) phys_offset, (ulong) logi_offset, (ulong) logi_offset, (ulong) phys_offset, (ulong) phys_offset, (ulong) logi_offset, (ulong) logi_offset,
(ulong) blocks_offset, (ulong) blocks_offset); (ulong) blocks_offset, (ulong) blocks_offset);
} else { } else {
...@@ -1066,7 +1066,7 @@ buf_chunk_init( ...@@ -1066,7 +1066,7 @@ buf_chunk_init(
fprintf(stderr, fprintf(stderr,
"InnoDB: Aligning physical offset..."); "InnoDB: Aligning physical offset...");
memmove((void*)frame, (void*)((void*)chunk->mem + shm_info->frame_offset), memmove(frame, ((char*)chunk->mem + shm_info->frame_offset),
chunk->size * UNIV_PAGE_SIZE); chunk->size * UNIV_PAGE_SIZE);
fprintf(stderr, fprintf(stderr,
...@@ -1094,8 +1094,8 @@ buf_chunk_init( ...@@ -1094,8 +1094,8 @@ buf_chunk_init(
previous_frame_address, logi_offset, blocks_offset); previous_frame_address, logi_offset, blocks_offset);
if (shm_info->buf_pool_backup.LRU_old) if (shm_info->buf_pool_backup.LRU_old)
shm_info->buf_pool_backup.LRU_old = shm_info->buf_pool_backup.LRU_old =
((void*)(shm_info->buf_pool_backup.LRU_old) (buf_page_t*)((char*)(shm_info->buf_pool_backup.LRU_old)
+ (((void*)shm_info->buf_pool_backup.LRU_old > previous_frame_address) + (((byte*)shm_info->buf_pool_backup.LRU_old > previous_frame_address)
? logi_offset : blocks_offset)); ? logi_offset : blocks_offset));
UT_LIST_OFFSET(unzip_LRU, buf_block_t, shm_info->buf_pool_backup.unzip_LRU, UT_LIST_OFFSET(unzip_LRU, buf_block_t, shm_info->buf_pool_backup.unzip_LRU,
...@@ -1141,7 +1141,7 @@ buf_chunk_init( ...@@ -1141,7 +1141,7 @@ buf_chunk_init(
} }
if (shm_info) { if (shm_info) {
shm_info->frame_offset = (void*)chunk->blocks[0].frame - (void*)chunk->mem; shm_info->frame_offset = (char*)chunk->blocks[0].frame - (char*)chunk->mem;
} }
return(chunk); return(chunk);
...@@ -1396,10 +1396,10 @@ buf_pool_init(void) ...@@ -1396,10 +1396,10 @@ buf_pool_init(void)
if (srv_buffer_pool_shm_key) { if (srv_buffer_pool_shm_key) {
buf_shm_info_t* shm_info; buf_shm_info_t* shm_info;
ut_a(chunk->blocks == chunk->mem + sizeof(buf_shm_info_t)); ut_a((char*)chunk->blocks == (char*)chunk->mem + sizeof(buf_shm_info_t));
shm_info = chunk->mem; shm_info = chunk->mem;
buf_pool->zip_hash = (hash_table_t*)((void*)chunk->mem + shm_info->zip_hash_offset); buf_pool->zip_hash = (hash_table_t*)((char*)chunk->mem + shm_info->zip_hash_offset);
if(shm_info->is_new) { if(shm_info->is_new) {
shm_info->is_new = FALSE; /* initialization was finished */ shm_info->is_new = FALSE; /* initialization was finished */
...@@ -1504,7 +1504,7 @@ buf_pool_free(void) ...@@ -1504,7 +1504,7 @@ buf_pool_free(void)
chunk = buf_pool->chunks; chunk = buf_pool->chunks;
shm_info = chunk->mem; shm_info = chunk->mem;
ut_a(chunk->blocks == chunk->mem + sizeof(buf_shm_info_t)); ut_a((char*)chunk->blocks == (char*)chunk->mem + sizeof(buf_shm_info_t));
/* validation the shared memory segment doesn't have unrecoverable contents. */ /* validation the shared memory segment doesn't have unrecoverable contents. */
/* Currently, validation became not needed */ /* Currently, validation became not needed */
...@@ -1514,7 +1514,7 @@ buf_pool_free(void) ...@@ -1514,7 +1514,7 @@ buf_pool_free(void)
memcpy(&(shm_info->chunk_backup), chunk, sizeof(buf_chunk_t)); memcpy(&(shm_info->chunk_backup), chunk, sizeof(buf_chunk_t));
if (srv_fast_shutdown < 2) { if (srv_fast_shutdown < 2) {
shm_info->checksum = ut_fold_binary(chunk->mem + sizeof(buf_shm_info_t), shm_info->checksum = ut_fold_binary((byte*)chunk->mem + sizeof(buf_shm_info_t),
chunk->mem_size - sizeof(buf_shm_info_t)); chunk->mem_size - sizeof(buf_shm_info_t));
shm_info->clean = TRUE; shm_info->clean = TRUE;
} }
......
...@@ -161,7 +161,7 @@ hash_create_init( ...@@ -161,7 +161,7 @@ hash_create_init(
offset = (sizeof(hash_table_t) + 7) / 8; offset = (sizeof(hash_table_t) + 7) / 8;
offset *= 8; offset *= 8;
table->array = (hash_cell_t*)(((void*)table) + offset); table->array = (hash_cell_t*)(((char*)table) + offset);
table->n_cells = prime; table->n_cells = prime;
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG # if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
table->adaptive = FALSE; table->adaptive = FALSE;
...@@ -187,7 +187,7 @@ hash_create_reuse( ...@@ -187,7 +187,7 @@ hash_create_reuse(
offset = (sizeof(hash_table_t) + 7) / 8; offset = (sizeof(hash_table_t) + 7) / 8;
offset *= 8; offset *= 8;
table->array = (hash_cell_t*)(((void*)table) + offset); table->array = (hash_cell_t*)(((char*)table) + offset);
ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
} }
......
...@@ -1305,7 +1305,7 @@ Compute the hash fold value for blocks in buf_pool->zip_hash. */ ...@@ -1305,7 +1305,7 @@ Compute the hash fold value for blocks in buf_pool->zip_hash. */
/* the fold should be relative when srv_buffer_pool_shm_key is enabled */ /* the fold should be relative when srv_buffer_pool_shm_key is enabled */
#define BUF_POOL_ZIP_FOLD_PTR(ptr) (!srv_buffer_pool_shm_key\ #define BUF_POOL_ZIP_FOLD_PTR(ptr) (!srv_buffer_pool_shm_key\
?((ulint) (ptr) / UNIV_PAGE_SIZE)\ ?((ulint) (ptr) / UNIV_PAGE_SIZE)\
:((ulint) ((void*)ptr - (void*)(buf_pool->chunks->blocks->frame)) / UNIV_PAGE_SIZE)) :((ulint) ((char*)ptr - (char*)(buf_pool->chunks->blocks->frame)) / UNIV_PAGE_SIZE))
#define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame) #define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
#define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b)) #define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
/* @} */ /* @} */
......
...@@ -363,14 +363,14 @@ do {\ ...@@ -363,14 +363,14 @@ do {\
NODE_TYPE* node2222;\ NODE_TYPE* node2222;\
\ \
if ((TABLE)->array[i2222].node) \ if ((TABLE)->array[i2222].node) \
(TABLE)->array[i2222].node \ (TABLE)->array[i2222].node = (void*)((char*)(TABLE)->array[i2222].node \
+= (((TABLE)->array[i2222].node > (void*)FADDR)?FOFFSET:BOFFSET);\ + (((TABLE)->array[i2222].node > (void*)FADDR)?FOFFSET:BOFFSET));\
node2222 = HASH_GET_FIRST((TABLE), i2222);\ node2222 = HASH_GET_FIRST((TABLE), i2222);\
\ \
while (node2222) {\ while (node2222) {\
if (node2222->PTR_NAME) \ if (node2222->PTR_NAME) \
node2222->PTR_NAME = ((void*)node2222->PTR_NAME) \ node2222->PTR_NAME = (void*)((char*)node2222->PTR_NAME \
+ ((((void*)node2222->PTR_NAME) > (void*)FADDR)?FOFFSET:BOFFSET);\ + ((((void*)node2222->PTR_NAME) > (void*)FADDR)?FOFFSET:BOFFSET));\
\ \
node2222 = node2222->PTR_NAME;\ node2222 = node2222->PTR_NAME;\
}\ }\
......
...@@ -269,10 +269,10 @@ do { \ ...@@ -269,10 +269,10 @@ do { \
TYPE* ut_list_node_313; \ TYPE* ut_list_node_313; \
\ \
if ((BASE).start) \ if ((BASE).start) \
(BASE).start = ((void*)((BASE).start) \ (BASE).start = (void*)((char*)((BASE).start) \
+ (((void*)((BASE).start) > (void*)FADDR)?FOFFSET:BOFFSET));\ + (((void*)((BASE).start) > (void*)FADDR)?FOFFSET:BOFFSET));\
if ((BASE).end) \ if ((BASE).end) \
(BASE).end = ((void*)((BASE).end) \ (BASE).end = (void*)((char*)((BASE).end) \
+ (((void*)((BASE).end) > (void*)FADDR)?FOFFSET:BOFFSET));\ + (((void*)((BASE).end) > (void*)FADDR)?FOFFSET:BOFFSET));\
\ \
ut_list_node_313 = (BASE).start; \ ut_list_node_313 = (BASE).start; \
...@@ -280,10 +280,10 @@ do { \ ...@@ -280,10 +280,10 @@ do { \
for (ut_list_i_313 = (BASE).count; ut_list_i_313--; ) { \ for (ut_list_i_313 = (BASE).count; ut_list_i_313--; ) { \
ut_a(ut_list_node_313); \ ut_a(ut_list_node_313); \
if ((ut_list_node_313->NAME).prev) \ if ((ut_list_node_313->NAME).prev) \
(ut_list_node_313->NAME).prev = ((void*)((ut_list_node_313->NAME).prev)\ (ut_list_node_313->NAME).prev = (void*)((char*)((ut_list_node_313->NAME).prev) \
+ (((void*)((ut_list_node_313->NAME).prev) > (void*)FADDR)?FOFFSET:BOFFSET));\ + (((void*)((ut_list_node_313->NAME).prev) > (void*)FADDR)?FOFFSET:BOFFSET));\
if ((ut_list_node_313->NAME).next) \ if ((ut_list_node_313->NAME).next) \
(ut_list_node_313->NAME).next = ((void*)((ut_list_node_313->NAME).next)\ (ut_list_node_313->NAME).next = (void *)((char*)((ut_list_node_313->NAME).next) \
+ (((void*)((ut_list_node_313->NAME).next)> (void*)FADDR)?FOFFSET:BOFFSET));\ + (((void*)((ut_list_node_313->NAME).next)> (void*)FADDR)?FOFFSET:BOFFSET));\
ut_list_node_313 = (ut_list_node_313->NAME).next; \ ut_list_node_313 = (ut_list_node_313->NAME).next; \
} \ } \
......
...@@ -243,8 +243,10 @@ os_shm_alloc( ...@@ -243,8 +243,10 @@ os_shm_alloc(
ibool* is_new) ibool* is_new)
{ {
void* ptr; void* ptr;
#if defined HAVE_SYS_IPC_H && HAVE_SYS_SHM_H
ulint size; ulint size;
int shmid; int shmid;
#endif
*is_new = FALSE; *is_new = FALSE;
#if defined HAVE_SYS_IPC_H && HAVE_SYS_SHM_H #if defined HAVE_SYS_IPC_H && HAVE_SYS_SHM_H
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment