summaryrefslogtreecommitdiff
path: root/storage/innobase/include/mach0data.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/mach0data.ic')
-rw-r--r--storage/innobase/include/mach0data.ic62
1 files changed, 29 insertions, 33 deletions
diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic
index 31cb873cdf6..6c879b38354 100644
--- a/storage/innobase/include/mach0data.ic
+++ b/storage/innobase/include/mach0data.ic
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
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
@@ -62,30 +63,28 @@ mach_write_to_2(
b[1] = (byte)(n);
}
-/********************************************************//**
-The following function is used to fetch data from one byte.
+/** The following function is used to fetch data from one byte.
+@param[in] b pointer to a byte to read
@return ulint integer, >= 0, < 256 */
UNIV_INLINE
-ulint
+uint8_t
mach_read_from_1(
-/*=============*/
- const byte* b) /*!< in: pointer to byte */
+ const byte* b)
{
ut_ad(b);
- return((ulint)(b[0]));
+ return(uint8_t(*b));
}
-/********************************************************//**
-The following function is used to fetch data from 2 consecutive
+/** The following function is used to fetch data from 2 consecutive
bytes. The most significant byte is at the lowest address.
-@return ulint integer */
+@param[in] b pointer to 2 bytes to read
+@return 2-byte integer, >= 0, < 64k */
UNIV_INLINE
-ulint
+uint16_t
mach_read_from_2(
-/*=============*/
- const byte* b) /*!< in: pointer to 2 bytes */
+ const byte* b)
{
- return(((ulint)(b[0]) << 8) | (ulint)(b[1]));
+ return(uint16_t(uint16_t(b[0]) << 8 | b[1]));
}
#ifndef UNIV_INNOCHECKSUM
@@ -139,23 +138,21 @@ mach_write_to_3(
b[2] = (byte)(n);
}
-/********************************************************//**
-The following function is used to fetch data from 3 consecutive
+/** The following function is used to fetch data from 3 consecutive
bytes. The most significant byte is at the lowest address.
-@return ulint integer */
+@param[in] b pointer to 3 bytes to read
+@return uint32_t integer */
UNIV_INLINE
-ulint
+uint32_t
mach_read_from_3(
-/*=============*/
- const byte* b) /*!< in: pointer to 3 bytes */
+ const byte* b)
{
ut_ad(b);
- return( ((ulint)(b[0]) << 16)
- | ((ulint)(b[1]) << 8)
- | (ulint)(b[2])
+ return( (static_cast<uint32_t>(b[0]) << 16)
+ | (static_cast<uint32_t>(b[1]) << 8)
+ | static_cast<uint32_t>(b[2])
);
}
-
#endif /* !UNIV_INNOCHECKSUM */
/*******************************************************//**
@@ -176,21 +173,20 @@ mach_write_to_4(
b[3] = (byte) n;
}
-/********************************************************//**
-The following function is used to fetch data from 4 consecutive
+/** The following function is used to fetch data from 4 consecutive
bytes. The most significant byte is at the lowest address.
-@return ulint integer */
+@param[in] b pointer to 4 bytes to read
+@return 32 bit integer */
UNIV_INLINE
-ulint
+uint32_t
mach_read_from_4(
-/*=============*/
- const byte* b) /*!< in: pointer to four bytes */
+ const byte* b)
{
ut_ad(b);
- return( ((ulint)(b[0]) << 24)
- | ((ulint)(b[1]) << 16)
- | ((ulint)(b[2]) << 8)
- | (ulint)(b[3])
+ return( (static_cast<uint32_t>(b[0]) << 24)
+ | (static_cast<uint32_t>(b[1]) << 16)
+ | (static_cast<uint32_t>(b[2]) << 8)
+ | static_cast<uint32_t>(b[3])
);
}