348
byte* b, /*!< in: pointer to 6 bytes where to store */
349
ib_uint64_t n) /*!< in: 48-bit integer */
394
byte* b, /*!< in: pointer to 6 bytes where to store */
395
dulint n) /*!< in: dulint integer to be stored */
353
mach_write_to_2(b, (ulint) (n >> 32));
354
mach_write_to_4(b + 2, (ulint) n);
399
mach_write_to_2(b, ut_dulint_get_high(n));
400
mach_write_to_4(b + 2, ut_dulint_get_low(n));
357
403
/********************************************************//**
358
404
The following function is used to fetch data from 6 consecutive
359
405
bytes. The most significant byte is at the lowest address.
360
@return 48-bit integer */
406
@return dulint integer */
363
409
mach_read_from_6(
364
410
/*=============*/
365
411
const byte* b) /*!< in: pointer to 6 bytes */
369
return(ut_ull_create(mach_read_from_2(b), mach_read_from_4(b + 2)));
418
high = mach_read_from_2(b);
419
low = mach_read_from_4(b + 2);
421
return(ut_dulint_create(high, low));
372
424
/*********************************************************//**
373
Writes a 64-bit integer in a compressed form (5..9 bytes).
425
Writes a dulint in a compressed form (5..9 bytes).
374
426
@return size in bytes */
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 */
429
mach_dulint_write_compressed(
430
/*=========================*/
431
byte* b, /*!< in: pointer to memory where to store */
432
dulint n) /*!< in: dulint integer to be stored */
386
size = mach_write_compressed(b, (ulint) (n >> 32));
387
mach_write_to_4(b + size, (ulint) n);
438
size = mach_write_compressed(b, ut_dulint_get_high(n));
439
mach_write_to_4(b + size, ut_dulint_get_low(n));
389
441
return(size + 4);
392
444
/*********************************************************//**
393
Returns the size of a 64-bit integer when written in the compressed form.
445
Returns the size of a dulint when written in the compressed form.
394
446
@return compressed size in bytes */
397
mach_ull_get_compressed_size(
398
/*=========================*/
399
ib_uint64_t n) /*!< in: 64-bit integer to be stored */
449
mach_dulint_get_compressed_size(
450
/*============================*/
451
dulint n) /*!< in: dulint integer to be stored */
401
return(4 + mach_get_compressed_size((ulint) (n >> 32)));
453
return(4 + mach_get_compressed_size(ut_dulint_get_high(n)));
404
456
/*********************************************************//**
405
Reads a 64-bit integer in a compressed form.
406
@return the value read */
457
Reads a dulint in a compressed form.
458
@return read dulint */
409
mach_ull_read_compressed(
410
/*=====================*/
461
mach_dulint_read_compressed(
462
/*========================*/
411
463
const byte* b) /*!< in: pointer to memory from where to read */
418
n = (ib_uint64_t) mach_read_compressed(b);
420
size = mach_get_compressed_size((ulint) n);
423
n |= (ib_uint64_t) mach_read_from_4(b + size);
471
high = mach_read_compressed(b);
473
size = mach_get_compressed_size(high);
475
low = mach_read_from_4(b + size);
477
return(ut_dulint_create(high, low));
428
480
/*********************************************************//**
429
Writes a 64-bit integer in a compressed form (1..11 bytes).
481
Writes a dulint in a compressed form (1..11 bytes).
430
482
@return size in bytes */
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 */
485
mach_dulint_write_much_compressed(
486
/*==============================*/
487
byte* b, /*!< in: pointer to memory where to store */
488
dulint n) /*!< in: dulint integer to be stored */
443
return(mach_write_compressed(b, (ulint) n));
494
if (ut_dulint_get_high(n) == 0) {
495
return(mach_write_compressed(b, ut_dulint_get_low(n)));
447
size = 1 + mach_write_compressed(b + 1, (ulint) (n >> 32));
499
size = 1 + mach_write_compressed(b + 1, ut_dulint_get_high(n));
449
size += mach_write_compressed(b + size, (ulint) n & 0xFFFFFFFF);
501
size += mach_write_compressed(b + size, ut_dulint_get_low(n));
454
506
/*********************************************************//**
455
Returns the size of a 64-bit integer when written in the compressed form.
507
Returns the size of a dulint when written in the compressed form.
456
508
@return compressed size in bytes */
459
mach_ull_get_much_compressed_size(
460
/*==============================*/
461
ib_uint64_t n) /*!< in: 64-bit integer to be stored */
511
mach_dulint_get_much_compressed_size(
512
/*=================================*/
513
dulint n) /*!< in: dulint integer to be stored */
464
return(mach_get_compressed_size((ulint) n));
515
if (0 == ut_dulint_get_high(n)) {
516
return(mach_get_compressed_size(ut_dulint_get_low(n)));
467
return(1 + mach_get_compressed_size((ulint) (n >> 32))
468
+ mach_get_compressed_size((ulint) n & ULINT32_MASK));
519
return(1 + mach_get_compressed_size(ut_dulint_get_high(n))
520
+ mach_get_compressed_size(ut_dulint_get_low(n)));
471
523
/*********************************************************//**
472
Reads a 64-bit integer in a compressed form.
473
@return the value read */
524
Reads a dulint in a compressed form.
525
@return read dulint */
476
mach_ull_read_much_compressed(
477
/*==========================*/
528
mach_dulint_read_much_compressed(
529
/*=============================*/
478
530
const byte* b) /*!< in: pointer to memory from where to read */
485
538
if (*b != (byte)0xFF) {
489
n = (ib_uint64_t) mach_read_compressed(b + 1);
491
size = 1 + mach_get_compressed_size((ulint) n);
495
n |= mach_read_compressed(b + size);
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 */
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 */
518
if (end_ptr < ptr + 5) {
523
*val = mach_read_compressed(ptr);
525
size = mach_get_compressed_size((ulint) *val);
529
if (end_ptr < ptr + 4) {
535
*val |= mach_read_from_4(ptr);
542
high = mach_read_compressed(b + 1);
544
size = 1 + mach_get_compressed_size(high);
547
low = mach_read_compressed(b + size);
549
return(ut_dulint_create(high, low));
539
551
#ifndef UNIV_HOTBACKUP
540
552
/*********************************************************//**