mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
892a6138ff
Windows to call CreateFileMapping() with correct arguments, and propogating the introduction of query_id_t to everywhere query ids are passed around. (Bug #8826) libmysql/libmysql.c: Make implicit cast explicit myisam/mi_open.c: Make cast of value to smaller data size explicit myisam/mi_packrec.c: Cast file size (my_off_t) to size_t for mmap mysys/my_mmap.c: Fix Windows version of my_mmap() to use the right parameters for call to CreateFileMapping() sql/field.cc: Use temporary value of correct type sql/field.h: Use query_id_t for query_id value sql/ha_berkeley.cc: Fix flag check sql/ha_innodb.h: Use query_id_t for query_id value sql/handler.cc: Explain opt_using_transactions calculation, and add cast sql/handler.h: Fix forward declaration of COND sql/item.cc: Fix val_bool() tests of val_int() to avoid implicit cast sql/item_cmpfunc.cc: Fix typo in switch label sql/item_func.cc: Make implicit cast explicit sql/item_strfunc.cc: Now that query_id is a query_id_t, need to cast it to a ulong here sql/item_subselect.cc: Fix test of value sql/log.cc: Cast my_off_t used for file size to size_t for memory allocation Also cast my_off_t when using it to calculate the number of pages for TC log Cast total_ha_2pc to uchar when saving it sql/mysql_priv.h: Move up query_id definition so it can be used more widely sql/opt_range.cc: Add unused delete operator to prevent compiler warning sql/set_var.cc: Cast value for max_user_connections sql/sql_cache.cc: Remove unused label sql/sql_class.h: Fix query id values to be of type query_id_t sql/sql_db.cc: Move variable only used inside #ifdef within the #ifdef sql/sql_help.cc: Remove unused label sql/sql_insert.cc: Use query_id_t for query id values sql/sql_lex.h: Add unused delete operator to prevent compiler warning sql/sql_select.cc: Remove unused variable Make cast of value explicit sql/sql_select.h: Use query_id_t for query id values sql/sql_table.cc: Make comparison to function pointer explicit sql/sql_update.cc: Use query_id_t for query id values sql/table.h: Use query_id_t for query id values strings/ctype-simple.c: Add cast of long value to (char) in expression strings/ctype-ucs2.c: Add cast of long value to (char) in expression strings/ctype-utf8.c: Make cast to smaller size explicit
91 lines
2.4 KiB
C
91 lines
2.4 KiB
C
/* Copyright (C) 2000-2003 MySQL AB
|
|
|
|
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; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#include "mysys_priv.h"
|
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
|
|
|
/*
|
|
system msync() only syncs mmap'ed area to fs cache.
|
|
fsync() is required to really sync to disc
|
|
*/
|
|
int my_msync(int fd, void *addr, size_t len, int flags)
|
|
{
|
|
msync(addr, len, flags);
|
|
return my_sync(fd, MYF(0));
|
|
}
|
|
|
|
#elif defined(__WIN__)
|
|
|
|
static SECURITY_ATTRIBUTES mmap_security_attributes=
|
|
{sizeof(SECURITY_ATTRIBUTES), 0, TRUE};
|
|
|
|
int my_getpagesize(void)
|
|
{
|
|
SYSTEM_INFO si;
|
|
GetSystemInfo(&si);
|
|
return si.dwPageSize;
|
|
}
|
|
|
|
void *my_mmap(void *addr, size_t len, int prot,
|
|
int flags, int fd, my_off_t offset)
|
|
{
|
|
DWORD flProtect=0;
|
|
HANDLE hFileMap;
|
|
LPVOID ptr;
|
|
HANDLE hFile= (HANDLE)_get_osfhandle(fd);
|
|
if (hFile == INVALID_HANDLE_VALUE)
|
|
return MAP_FAILED;
|
|
|
|
flProtect|=SEC_COMMIT;
|
|
|
|
hFileMap=CreateFileMapping(hFile, &mmap_security_attributes,
|
|
PAGE_READWRITE, 0, len, NULL);
|
|
if (hFileMap == 0)
|
|
return MAP_FAILED;
|
|
|
|
ptr=MapViewOfFile(hFileMap,
|
|
flags & PROT_WRITE ? FILE_MAP_WRITE : FILE_MAP_READ,
|
|
(DWORD)(offset >> 32), (DWORD)offset, len);
|
|
|
|
/*
|
|
MSDN explicitly states that it's possible to close File Mapping Object
|
|
even when a view is not unmapped - then the object will be held open
|
|
implicitly until unmap, as every view stores internally a handler of
|
|
a corresponding File Mapping Object
|
|
*/
|
|
CloseHandle(hFileMap);
|
|
|
|
if (ptr)
|
|
return ptr;
|
|
|
|
return MAP_FAILED;
|
|
}
|
|
|
|
int my_munmap(void *addr, size_t len)
|
|
{
|
|
return UnmapViewOfFile(addr) ? 0 : -1;
|
|
}
|
|
|
|
int my_msync(int fd, void *addr, size_t len, int flags)
|
|
{
|
|
return FlushViewOfFile(addr, len) ? 0 : -1;
|
|
}
|
|
|
|
#else
|
|
#warning "no mmap!"
|
|
#endif
|
|
|