Commit 80a2d47b authored by kaa@polly.(none)'s avatar kaa@polly.(none)
Browse files

Merge polly.(none):/home/kaa/src/maint/bug5731/my50-bug5731

into  polly.(none):/home/kaa/src/maint/mysql-5.0-maint
parents 5a1284cc b794e5f2
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ typedef struct st_key_cache
  my_bool key_cache_inited;
  my_bool resize_in_flush;       /* true during flush of resize operation    */
  my_bool can_be_used;           /* usage of cache for read/write is allowed */
  ulong key_cache_mem_size;      /* specified size of the cache memory       */
  size_t key_cache_mem_size;     /* specified size of the cache memory       */
  uint key_cache_block_size;     /* size of the page buffer of a cache block */
  ulong min_warm_blocks;         /* min number of warm blocks;               */
  ulong age_threshold;           /* age threshold for hot blocks             */
@@ -101,10 +101,10 @@ typedef struct st_key_cache
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;

extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
			  ulong use_mem, uint division_limit,
                          size_t use_mem, uint division_limit,
                          uint age_threshold);
extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
			    ulong use_mem, uint division_limit,
                            size_t use_mem, uint division_limit,
                            uint age_threshold);
extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit,
				   uint age_threshold);
+0 −3
Original line number Diff line number Diff line
@@ -780,9 +780,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define DBL_MAX		1.79769313486231470e+308
#define FLT_MAX		((float)3.40282346638528860e+38)
#endif
#ifndef SSIZE_MAX
#define SSIZE_MAX ((~((size_t) 0)) / 2)
#endif

#ifndef HAVE_FINITE
#define finite(x) (1.0 / fabs(x) > 0.0)
+13 −13
Original line number Diff line number Diff line
@@ -147,13 +147,13 @@ extern ulonglong sf_malloc_mem_limit;
#define TERMINATE(A) {}
#define QUICK_SAFEMALLOC
#define NORMAL_SAFEMALLOC
extern gptr my_malloc(uint Size,myf MyFlags);
extern gptr my_malloc(size_t Size, myf MyFlags);
#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
extern void my_no_flags_free(gptr ptr);
extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
extern gptr my_memdup(const byte *from, size_t length, myf MyFlags);
extern char *my_strdup(const char *from,myf MyFlags);
extern char *my_strdup_with_length(const char *from, uint length,
extern char *my_strdup_with_length(const char *from, size_t length,
                                   myf MyFlags);
/* we do use FG (as a no-op) in below so that a typo on FG is caught */
#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR))
@@ -165,7 +165,7 @@ extern char *my_strdup_with_length(const char *from, uint length,

#ifdef HAVE_LARGE_PAGES
extern uint my_get_large_page_size(void);
extern gptr my_large_malloc(uint size, myf my_flags);
extern gptr my_large_malloc(size_t size, myf my_flags);
extern void my_large_free(gptr ptr, myf my_flags);
#else
#define my_get_large_page_size() (0)
@@ -590,18 +590,18 @@ extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count,
		      myf MyFlags);
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
extern gptr _mymalloc(uint uSize,const char *sFile,
extern gptr _mymalloc(size_t uSize, const char *sFile,
                       uint uLine, myf MyFlag);
extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
extern gptr _myrealloc(gptr pPtr, size_t uSize, const char *sFile,
                        uint uLine, myf MyFlag);
extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
extern void _myfree(gptr pPtr, const char *sFile, uint uLine, myf MyFlag);
extern int _sanity(const char *sFile,unsigned int uLine);
extern gptr _my_memdup(const byte *from,uint length,
extern gptr _my_memdup(const byte *from, size_t length,
                        const char *sFile, uint uLine, myf MyFlag);
extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
			    myf MyFlag);
extern char *_my_strdup_with_length(const char *from, uint length,
extern char *_my_strdup_with_length(const char *from, size_t length,
				    const char *sFile, uint uLine,
				    myf MyFlag);

+13 −12
Original line number Diff line number Diff line
@@ -301,10 +301,11 @@ static uint next_power(uint value)
*/

int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
		   ulong use_mem, uint division_limit,
                   size_t use_mem, uint division_limit,
                   uint age_threshold)
{
  uint blocks, hash_links, length;
  ulong blocks, hash_links;
  size_t length;
  int error;
  DBUG_ENTER("init_key_cache");
  DBUG_ASSERT(key_cache_block_size >= 512);
@@ -332,7 +333,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
  DBUG_PRINT("info", ("key_cache_block_size: %u",
		      key_cache_block_size));

  blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) +
  blocks= (ulong) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) +
                              sizeof(HASH_LINK*) * 5/4 + key_cache_block_size));
  /* It doesn't make sense to have too few blocks (less than 8) */
  if (blocks >= 8 && keycache->disk_blocks < 0)
@@ -351,18 +352,18 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
		       ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) +
		       ALIGN_SIZE(sizeof(HASH_LINK*) *
                                  keycache->hash_entries))) +
	     ((ulong) blocks * keycache->key_cache_block_size) > use_mem)
	     ((size_t) blocks * keycache->key_cache_block_size) > use_mem)
        blocks--;
      /* Allocate memory for cache page buffers */
      if ((keycache->block_mem=
	   my_large_malloc((ulong) blocks * keycache->key_cache_block_size,
           my_large_malloc((size_t) blocks * keycache->key_cache_block_size,
                           MYF(MY_WME))))
      {
        /*
	  Allocate memory for blocks, hash_links and hash entries;
	  For each block 2 hash links are allocated
        */
        if ((keycache->block_root= (BLOCK_LINK*) my_malloc((uint) length,
        if ((keycache->block_root= (BLOCK_LINK*) my_malloc(length,
                                                           MYF(0))))
          break;
        my_large_free(keycache->block_mem, MYF(0));
@@ -375,7 +376,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
      }
      blocks= blocks / 4*3;
    }
    keycache->blocks_unused= (ulong) blocks;
    keycache->blocks_unused= blocks;
    keycache->disk_blocks= (int) blocks;
    keycache->hash_links= hash_links;
    keycache->hash_root= (HASH_LINK**) ((char*) keycache->block_root +
@@ -480,7 +481,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
*/

int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
		     ulong use_mem, uint division_limit,
                     size_t use_mem, uint division_limit,
                     uint age_threshold)
{
  int blocks;
+6 −6
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
#endif

static uint my_get_large_page_size_int(void);
static gptr my_large_malloc_int(uint size, myf my_flags);
static gptr my_large_malloc_int(size_t size, myf my_flags);
static my_bool my_large_free_int(gptr ptr, myf my_flags);

/* Gets the size of large pages from the OS */
@@ -48,7 +48,7 @@ uint my_get_large_page_size(void)
  my_malloc_lock() in case of failure
*/

gptr my_large_malloc(uint size, myf my_flags)
gptr my_large_malloc(size_t size, myf my_flags)
{
  gptr ptr;
  DBUG_ENTER("my_large_malloc");
@@ -113,7 +113,7 @@ uint my_get_large_page_size_int(void)
#if HAVE_DECL_SHM_HUGETLB
/* Linux-specific large pages allocator  */
    
gptr my_large_malloc_int(uint size, myf my_flags)
gptr my_large_malloc_int(size_t size, myf my_flags)
{
  int shmid;
  gptr ptr;
@@ -123,13 +123,13 @@ gptr my_large_malloc_int(uint size, myf my_flags)
  /* Align block size to my_large_page_size */
  size = ((size - 1) & ~(my_large_page_size - 1)) + my_large_page_size;
  
  shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W);
  shmid = shmget(IPC_PRIVATE, size, SHM_HUGETLB | SHM_R | SHM_W);
  if (shmid < 0)
  {
    if (my_flags & MY_WME)
      fprintf(stderr,
              "Warning: Failed to allocate %d bytes from HugeTLB memory."
              " errno %d\n", size, errno);
              "Warning: Failed to allocate %lu bytesx from HugeTLB memory."
              " errno %d\n", (ulong) size, errno);

    DBUG_RETURN(NULL);
  }
Loading