~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mf_keycache.c

  • Committer: Monty Taylor
  • Date: 2008-08-02 01:03:15 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080802010315-65h5938pymg9d99z
Moved m4 macros to top-level m4 dir, per GNU standards (and where gettext wanted it :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
353
353
    keycache->hash_link_root= (HASH_LINK*) ((char*) keycache->hash_root +
354
354
                                            ALIGN_SIZE((sizeof(HASH_LINK*) *
355
355
                                                        keycache->hash_entries)));
356
 
    memset(keycache->block_root, 0,
 
356
    memset((uchar*) keycache->block_root, 0,
357
357
           keycache->disk_blocks * sizeof(BLOCK_LINK));
358
 
    memset(keycache->hash_root, 0,
 
358
    memset((uchar*) keycache->hash_root, 0,
359
359
           keycache->hash_entries * sizeof(HASH_LINK*));
360
 
    memset(keycache->hash_link_root, 0,
 
360
    memset((uchar*) keycache->hash_link_root, 0,
361
361
           keycache->hash_links * sizeof(HASH_LINK));
362
362
    keycache->hash_links_used= 0;
363
363
    keycache->free_hash_list= NULL;
383
383
 
384
384
    keycache->waiting_for_hash_link.last_thread= NULL;
385
385
    keycache->waiting_for_block.last_thread= NULL;
386
 
    memset(keycache->changed_blocks, 0,
 
386
    memset((uchar*) keycache->changed_blocks, 0,
387
387
           sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH);
388
 
    memset(keycache->file_blocks, 0,
 
388
    memset((uchar*) keycache->file_blocks, 0,
389
389
           sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH);
390
390
  }
391
391
  else
607
607
    none
608
608
*/
609
609
 
610
 
void end_key_cache(KEY_CACHE *keycache, bool cleanup)
 
610
void end_key_cache(KEY_CACHE *keycache, my_bool cleanup)
611
611
{
612
612
  if (!keycache->key_cache_inited)
613
613
    return;
861
861
 
862
862
static void link_to_file_list(KEY_CACHE *keycache,
863
863
                              BLOCK_LINK *block, int file,
864
 
                              bool unlink_block)
 
864
                              my_bool unlink_block)
865
865
{
866
866
  assert(block->status & BLOCK_IN_USE);
867
867
  assert(block->hash_link && block->hash_link->block == block);
955
955
    not linked in the LRU ring.
956
956
*/
957
957
 
958
 
static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, bool hot,
959
 
                       bool at_end)
 
958
static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, my_bool hot,
 
959
                       my_bool at_end)
960
960
{
961
961
  BLOCK_LINK *ins;
962
962
  BLOCK_LINK **pins;
1149
1149
  assert(!block->prev_used);
1150
1150
  if (! --block->requests)
1151
1151
  {
1152
 
    bool hot;
 
1152
    my_bool hot;
1153
1153
    if (block->hits_left)
1154
1154
      block->hits_left--;
1155
1155
    hot= !block->hits_left && at_end &&
1160
1160
        keycache->warm_blocks--;
1161
1161
      block->temperature= BLOCK_HOT;
1162
1162
    }
1163
 
    link_block(keycache, block, hot, (bool)at_end);
 
1163
    link_block(keycache, block, hot, (my_bool)at_end);
1164
1164
    block->last_hit_time= keycache->keycache_time;
1165
1165
    keycache->keycache_time++;
1166
1166
    /*
2099
2099
 
2100
2100
static void read_block(KEY_CACHE *keycache,
2101
2101
                       BLOCK_LINK *block, uint read_length,
2102
 
                       uint min_length, bool primary)
 
2102
                       uint min_length, my_bool primary)
2103
2103
{
2104
2104
  uint got_length;
2105
2105
 
2203
2203
                      uint block_length __attribute__((unused)),
2204
2204
                      int return_buffer __attribute__((unused)))
2205
2205
{
2206
 
  bool locked_and_incremented= false;
 
2206
  my_bool locked_and_incremented= false;
2207
2207
  int error=0;
2208
2208
  uchar *start= buff;
2209
2209
 
2281
2281
          /* The requested page is to be read into the block buffer */
2282
2282
          read_block(keycache, block,
2283
2283
                     keycache->key_cache_block_size, read_length+offset,
2284
 
                     (bool)(page_st == PAGE_TO_BE_READ));
 
2284
                     (my_bool)(page_st == PAGE_TO_BE_READ));
2285
2285
          /*
2286
2286
            A secondary request must now have the block assigned to the
2287
2287
            requested file block. It does not hurt to check it for
2314
2314
#endif
2315
2315
 
2316
2316
          /* Copy data from the cache buffer */
2317
 
          memcpy(buff, block->buffer+offset, (size_t) read_length);
 
2317
          if (!(read_length & 511))
 
2318
            bmove512(buff, block->buffer+offset, read_length);
 
2319
          else
 
2320
            memcpy(buff, block->buffer+offset, (size_t) read_length);
2318
2321
 
2319
2322
#if !defined(SERIALIZED_READ_FROM_CACHE)
2320
2323
          keycache_pthread_mutex_lock(&keycache->cache_lock);
2402
2405
    uint read_length;
2403
2406
    uint offset;
2404
2407
    int page_st;
2405
 
    bool locked_and_incremented= false;
 
2408
    my_bool locked_and_incremented= false;
2406
2409
 
2407
2410
    /*
2408
2411
      When the keycache is once initialized, we use the cache_lock to
2514
2517
#endif
2515
2518
 
2516
2519
          /* Copy data from buff */
2517
 
          memcpy(block->buffer+offset, buff, (size_t) read_length);
 
2520
          if (!(read_length & 511))
 
2521
            bmove512(block->buffer+offset, buff, read_length);
 
2522
          else
 
2523
            memcpy(block->buffer+offset, buff, (size_t) read_length);
2518
2524
 
2519
2525
#if !defined(SERIALIZED_READ_FROM_CACHE)
2520
2526
          keycache_pthread_mutex_lock(&keycache->cache_lock);
2629
2635
                    uint block_length  __attribute__((unused)),
2630
2636
                    int dont_write)
2631
2637
{
2632
 
  bool locked_and_incremented= false;
 
2638
  my_bool locked_and_incremented= false;
2633
2639
  int error=0;
2634
2640
 
2635
2641
  if (!dont_write)
2804
2810
#if !defined(SERIALIZED_READ_FROM_CACHE)
2805
2811
        keycache_pthread_mutex_unlock(&keycache->cache_lock);
2806
2812
#endif
2807
 
        memcpy(block->buffer+offset, buff, (size_t) read_length);
 
2813
        if (!(read_length & 511))
 
2814
          bmove512(block->buffer+offset, buff, read_length);
 
2815
        else
 
2816
          memcpy(block->buffer+offset, buff, (size_t) read_length);
2808
2817
 
2809
2818
#if !defined(SERIALIZED_READ_FROM_CACHE)
2810
2819
        keycache_pthread_mutex_lock(&keycache->cache_lock);