~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/mach0data.ic

  • Committer: Monty Taylor
  • Date: 2010-12-03 19:56:07 UTC
  • mto: (1975.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1976.
  • Revision ID: mordred@inaugust.com-20101203195607-yw50aynlw04dt5k6
All protocol stuff except for the buffer_length. WTF?

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
280
280
void
281
281
mach_write_to_8(
282
282
/*============*/
 
283
        byte*   b,      /*!< in: pointer to 8 bytes where to store */
 
284
        dulint  n)      /*!< in: dulint integer to be stored */
 
285
{
 
286
        ut_ad(b);
 
287
 
 
288
        mach_write_to_4(b, ut_dulint_get_high(n));
 
289
        mach_write_to_4(b + 4, ut_dulint_get_low(n));
 
290
}
 
291
 
 
292
/*******************************************************//**
 
293
The following function is used to store data in 8 consecutive
 
294
bytes. We store the most significant byte to the lowest address. */
 
295
UNIV_INLINE
 
296
void
 
297
mach_write_ull(
 
298
/*===========*/
283
299
        byte*           b,      /*!< in: pointer to 8 bytes where to store */
284
300
        ib_uint64_t     n)      /*!< in: 64-bit integer to be stored */
285
301
{
292
308
/********************************************************//**
293
309
The following function is used to fetch data from 8 consecutive
294
310
bytes. The most significant byte is at the lowest address.
 
311
@return dulint integer */
 
312
UNIV_INLINE
 
313
dulint
 
314
mach_read_from_8(
 
315
/*=============*/
 
316
        const byte*     b)      /*!< in: pointer to 8 bytes */
 
317
{
 
318
        ulint   high;
 
319
        ulint   low;
 
320
 
 
321
        ut_ad(b);
 
322
 
 
323
        high = mach_read_from_4(b);
 
324
        low = mach_read_from_4(b + 4);
 
325
 
 
326
        return(ut_dulint_create(high, low));
 
327
}
 
328
 
 
329
/********************************************************//**
 
330
The following function is used to fetch data from 8 consecutive
 
331
bytes. The most significant byte is at the lowest address.
295
332
@return 64-bit integer */
296
333
UNIV_INLINE
297
334
ib_uint64_t
298
 
mach_read_from_8(
299
 
/*=============*/
 
335
mach_read_ull(
 
336
/*==========*/
300
337
        const byte*     b)      /*!< in: pointer to 8 bytes */
301
338
{
302
339
        ib_uint64_t     ull;
314
351
void
315
352
mach_write_to_7(
316
353
/*============*/
317
 
        byte*           b,      /*!< in: pointer to 7 bytes where to store */
318
 
        ib_uint64_t     n)      /*!< in: 56-bit integer */
 
354
        byte*   b,      /*!< in: pointer to 7 bytes where to store */
 
355
        dulint  n)      /*!< in: dulint integer to be stored */
319
356
{
320
357
        ut_ad(b);
321
358
 
322
 
        mach_write_to_3(b, (ulint) (n >> 32));
323
 
        mach_write_to_4(b + 3, (ulint) n);
 
359
        mach_write_to_3(b, ut_dulint_get_high(n));
 
360
        mach_write_to_4(b + 3, ut_dulint_get_low(n));
324
361
}
325
362
 
326
363
/********************************************************//**
327
364
The following function is used to fetch data from 7 consecutive
328
365
bytes. The most significant byte is at the lowest address.
329
 
@return 56-bit integer */
 
366
@return dulint integer */
330
367
UNIV_INLINE
331
 
ib_uint64_t
 
368
dulint
332
369
mach_read_from_7(
333
370
/*=============*/
334
371
        const byte*     b)      /*!< in: pointer to 7 bytes */
335
372
{
 
373
        ulint   high;
 
374
        ulint   low;
 
375
 
336
376
        ut_ad(b);
337
377
 
338
 
        return(ut_ull_create(mach_read_from_3(b), mach_read_from_4(b + 3)));
 
378
        high = mach_read_from_3(b);
 
379
        low = mach_read_from_4(b + 3);
 
380
 
 
381
        return(ut_dulint_create(high, low));
339
382
}
340
383
 
341
384
/*******************************************************//**
345
388
void
346
389
mach_write_to_6(
347
390
/*============*/
348
 
        byte*           b,      /*!< in: pointer to 6 bytes where to store */
349
 
        ib_uint64_t     n)      /*!< in: 48-bit integer */
 
391
        byte*   b,      /*!< in: pointer to 6 bytes where to store */
 
392
        dulint  n)      /*!< in: dulint integer to be stored */
350
393
{
351
394
        ut_ad(b);
352
395
 
353
 
        mach_write_to_2(b, (ulint) (n >> 32));
354
 
        mach_write_to_4(b + 2, (ulint) n);
 
396
        mach_write_to_2(b, ut_dulint_get_high(n));
 
397
        mach_write_to_4(b + 2, ut_dulint_get_low(n));
355
398
}
356
399
 
357
400
/********************************************************//**
358
401
The following function is used to fetch data from 6 consecutive
359
402
bytes. The most significant byte is at the lowest address.
360
 
@return 48-bit integer */
 
403
@return dulint integer */
361
404
UNIV_INLINE
362
 
ib_uint64_t
 
405
dulint
363
406
mach_read_from_6(
364
407
/*=============*/
365
408
        const byte*     b)      /*!< in: pointer to 6 bytes */
366
409
{
 
410
        ulint   high;
 
411
        ulint   low;
 
412
 
367
413
        ut_ad(b);
368
414
 
369
 
        return(ut_ull_create(mach_read_from_2(b), mach_read_from_4(b + 2)));
 
415
        high = mach_read_from_2(b);
 
416
        low = mach_read_from_4(b + 2);
 
417
 
 
418
        return(ut_dulint_create(high, low));
370
419
}
371
420
 
372
421
/*********************************************************//**
373
 
Writes a 64-bit integer in a compressed form (5..9 bytes).
 
422
Writes a dulint in a compressed form (5..9 bytes).
374
423
@return size in bytes */
375
424
UNIV_INLINE
376
425
ulint
377
 
mach_ull_write_compressed(
378
 
/*======================*/
379
 
        byte*           b,      /*!< in: pointer to memory where to store */
380
 
        ib_uint64_t     n)      /*!< in: 64-bit integer to be stored */
 
426
mach_dulint_write_compressed(
 
427
/*=========================*/
 
428
        byte*   b,      /*!< in: pointer to memory where to store */
 
429
        dulint  n)      /*!< in: dulint integer to be stored */
381
430
{
382
431
        ulint   size;
383
432
 
384
433
        ut_ad(b);
385
434
 
386
 
        size = mach_write_compressed(b, (ulint) (n >> 32));
387
 
        mach_write_to_4(b + size, (ulint) n);
 
435
        size = mach_write_compressed(b, ut_dulint_get_high(n));
 
436
        mach_write_to_4(b + size, ut_dulint_get_low(n));
388
437
 
389
438
        return(size + 4);
390
439
}
391
440
 
392
441
/*********************************************************//**
393
 
Returns the size of a 64-bit integer when written in the compressed form.
 
442
Returns the size of a dulint when written in the compressed form.
394
443
@return compressed size in bytes */
395
444
UNIV_INLINE
396
445
ulint
397
 
mach_ull_get_compressed_size(
398
 
/*=========================*/
399
 
        ib_uint64_t     n)      /*!< in: 64-bit integer to be stored */
 
446
mach_dulint_get_compressed_size(
 
447
/*============================*/
 
448
        dulint   n)     /*!< in: dulint integer to be stored */
400
449
{
401
 
        return(4 + mach_get_compressed_size((ulint) (n >> 32)));
 
450
        return(4 + mach_get_compressed_size(ut_dulint_get_high(n)));
402
451
}
403
452
 
404
453
/*********************************************************//**
405
 
Reads a 64-bit integer in a compressed form.
406
 
@return the value read */
 
454
Reads a dulint in a compressed form.
 
455
@return read dulint */
407
456
UNIV_INLINE
408
 
ib_uint64_t
409
 
mach_ull_read_compressed(
410
 
/*=====================*/
 
457
dulint
 
458
mach_dulint_read_compressed(
 
459
/*========================*/
411
460
        const byte*     b)      /*!< in: pointer to memory from where to read */
412
461
{
413
 
        ib_uint64_t     n;
414
 
        ulint           size;
 
462
        ulint   high;
 
463
        ulint   low;
 
464
        ulint   size;
415
465
 
416
466
        ut_ad(b);
417
467
 
418
 
        n = (ib_uint64_t) mach_read_compressed(b);
419
 
 
420
 
        size = mach_get_compressed_size((ulint) n);
421
 
 
422
 
        n <<= 32;
423
 
        n |= (ib_uint64_t) mach_read_from_4(b + size);
424
 
 
425
 
        return(n);
 
468
        high = mach_read_compressed(b);
 
469
 
 
470
        size = mach_get_compressed_size(high);
 
471
 
 
472
        low = mach_read_from_4(b + size);
 
473
 
 
474
        return(ut_dulint_create(high, low));
426
475
}
427
476
 
428
477
/*********************************************************//**
429
 
Writes a 64-bit integer in a compressed form (1..11 bytes).
 
478
Writes a dulint in a compressed form (1..11 bytes).
430
479
@return size in bytes */
431
480
UNIV_INLINE
432
481
ulint
433
 
mach_ull_write_much_compressed(
434
 
/*===========================*/
435
 
        byte*           b,      /*!< in: pointer to memory where to store */
436
 
        ib_uint64_t     n)      /*!< in: 64-bit integer to be stored */
 
482
mach_dulint_write_much_compressed(
 
483
/*==============================*/
 
484
        byte*   b,      /*!< in: pointer to memory where to store */
 
485
        dulint  n)      /*!< in: dulint integer to be stored */
437
486
{
438
487
        ulint   size;
439
488
 
440
489
        ut_ad(b);
441
490
 
442
 
        if (!(n >> 32)) {
443
 
                return(mach_write_compressed(b, (ulint) n));
 
491
        if (ut_dulint_get_high(n) == 0) {
 
492
                return(mach_write_compressed(b, ut_dulint_get_low(n)));
444
493
        }
445
494
 
446
495
        *b = (byte)0xFF;
447
 
        size = 1 + mach_write_compressed(b + 1, (ulint) (n >> 32));
 
496
        size = 1 + mach_write_compressed(b + 1, ut_dulint_get_high(n));
448
497
 
449
 
        size += mach_write_compressed(b + size, (ulint) n & 0xFFFFFFFF);
 
498
        size += mach_write_compressed(b + size, ut_dulint_get_low(n));
450
499
 
451
500
        return(size);
452
501
}
453
502
 
454
503
/*********************************************************//**
455
 
Returns the size of a 64-bit integer when written in the compressed form.
 
504
Returns the size of a dulint when written in the compressed form.
456
505
@return compressed size in bytes */
457
506
UNIV_INLINE
458
507
ulint
459
 
mach_ull_get_much_compressed_size(
460
 
/*==============================*/
461
 
        ib_uint64_t     n)      /*!< in: 64-bit integer to be stored */
 
508
mach_dulint_get_much_compressed_size(
 
509
/*=================================*/
 
510
        dulint   n)     /*!< in: dulint integer to be stored */
462
511
{
463
 
        if (!(n >> 32)) {
464
 
                return(mach_get_compressed_size((ulint) n));
 
512
        if (0 == ut_dulint_get_high(n)) {
 
513
                return(mach_get_compressed_size(ut_dulint_get_low(n)));
465
514
        }
466
515
 
467
 
        return(1 + mach_get_compressed_size((ulint) (n >> 32))
468
 
               + mach_get_compressed_size((ulint) n & ULINT32_MASK));
 
516
        return(1 + mach_get_compressed_size(ut_dulint_get_high(n))
 
517
               + mach_get_compressed_size(ut_dulint_get_low(n)));
469
518
}
470
519
 
471
520
/*********************************************************//**
472
 
Reads a 64-bit integer in a compressed form.
473
 
@return the value read */
 
521
Reads a dulint in a compressed form.
 
522
@return read dulint */
474
523
UNIV_INLINE
475
 
ib_uint64_t
476
 
mach_ull_read_much_compressed(
477
 
/*==========================*/
 
524
dulint
 
525
mach_dulint_read_much_compressed(
 
526
/*=============================*/
478
527
        const byte*     b)      /*!< in: pointer to memory from where to read */
479
528
{
480
 
        ib_uint64_t     n;
481
 
        ulint           size;
 
529
        ulint   high;
 
530
        ulint   low;
 
531
        ulint   size;
482
532
 
483
533
        ut_ad(b);
484
534
 
485
535
        if (*b != (byte)0xFF) {
486
 
                n = 0;
 
536
                high = 0;
487
537
                size = 0;
488
538
        } else {
489
 
                n = (ib_uint64_t) mach_read_compressed(b + 1);
490
 
 
491
 
                size = 1 + mach_get_compressed_size((ulint) n);
492
 
                n <<= 32;
493
 
        }
494
 
 
495
 
        n |= mach_read_compressed(b + size);
496
 
 
497
 
        return(n);
498
 
}
499
 
 
500
 
/*********************************************************//**
501
 
Reads a 64-bit integer in a compressed form
502
 
if the log record fully contains it.
503
 
@return pointer to end of the stored field, NULL if not complete */
504
 
UNIV_INLINE
505
 
byte*
506
 
mach_ull_parse_compressed(
507
 
/*======================*/
508
 
        byte*           ptr,    /* in: pointer to buffer from where to read */
509
 
        byte*           end_ptr,/* in: pointer to end of the buffer */
510
 
        ib_uint64_t*    val)    /* out: read value */
511
 
{
512
 
        ulint           size;
513
 
 
514
 
        ut_ad(ptr);
515
 
        ut_ad(end_ptr);
516
 
        ut_ad(val);
517
 
 
518
 
        if (end_ptr < ptr + 5) {
519
 
 
520
 
                return(NULL);
521
 
        }
522
 
 
523
 
        *val = mach_read_compressed(ptr);
524
 
 
525
 
        size = mach_get_compressed_size((ulint) *val);
526
 
 
527
 
        ptr += size;
528
 
 
529
 
        if (end_ptr < ptr + 4) {
530
 
 
531
 
                return(NULL);
532
 
        }
533
 
 
534
 
        *val <<= 32;
535
 
        *val |= mach_read_from_4(ptr);
536
 
 
537
 
        return(ptr + 4);
 
539
                high = mach_read_compressed(b + 1);
 
540
 
 
541
                size = 1 + mach_get_compressed_size(high);
 
542
        }
 
543
 
 
544
        low = mach_read_compressed(b + size);
 
545
 
 
546
        return(ut_dulint_create(high, low));
538
547
}
539
548
#ifndef UNIV_HOTBACKUP
540
549
/*********************************************************//**