Commit a66eebf5 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-21981 Replace arithmetic + with bitwise OR when possible

Several macros such as sint2korr() and uint4korr() are using the
arithmetic + operator while a bitwise or operator would suffice.

GCC 5 and clang 5 and later can detect patterns consisting of
bitwise or and shifts by multiples of 8 bits, such as those used
in the InnoDB function mach_read_from_4(). They actually translate
that verbose low-level code into high-level machine language
(i486 bswap instruction or fused into the Haswell movbe instruction).

We should do the same for MariaDB Server code that is outside InnoDB.

Note: The Microsoft C compiler is lacking this optimization.
There, we might consider using _byteswap_ushort(), _byteswap_ulong(),
_byteswap_uint64(). But, those would lead to unaligned reads, which are
bad for reasons stated in MDEV-20277. Besides, outside InnoDB,
most data is already being stored in the native little-endian format
of that compiler.
parent 6960e9ed
/* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -17,7 +18,7 @@ ...@@ -17,7 +18,7 @@
Endianness-independent definitions for architectures other Endianness-independent definitions for architectures other
than the x86 architecture. than the x86 architecture.
*/ */
#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\ #define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) |\
((int16) ((int16) (A)[1]) << 8)) ((int16) ((int16) (A)[1]) << 8))
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ #define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
(((uint32) 255L << 24) | \ (((uint32) 255L << 24) | \
...@@ -27,38 +28,38 @@ ...@@ -27,38 +28,38 @@
(((uint32) (uchar) (A)[2]) << 16) |\ (((uint32) (uchar) (A)[2]) << 16) |\
(((uint32) (uchar) (A)[1]) << 8) | \ (((uint32) (uchar) (A)[1]) << 8) | \
((uint32) (uchar) (A)[0]))) ((uint32) (uchar) (A)[0])))
#define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\ #define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) |\
(((int32) ((uchar) (A)[1]) << 8)) +\ (((int32) ((uchar) (A)[1]) << 8)) |\
(((int32) ((uchar) (A)[2]) << 16)) +\ (((int32) ((uchar) (A)[2]) << 16)) |\
(((int32) ((int16) (A)[3]) << 24))) (((int32) ((int16) (A)[3]) << 24)))
#define sint8korr(A) (longlong) uint8korr(A) #define sint8korr(A) (longlong) uint8korr(A)
#define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\ #define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) |\
((uint16) ((uchar) (A)[1]) << 8)) ((uint16) ((uchar) (A)[1]) << 8))
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ #define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) |\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) |\
(((uint32) ((uchar) (A)[2])) << 16)) (((uint32) ((uchar) (A)[2])) << 16))
#define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ #define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) |\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) |\
(((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32) ((uchar) (A)[2])) << 16) |\
(((uint32) ((uchar) (A)[3])) << 24)) (((uint32) ((uchar) (A)[3])) << 24))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) |\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) |\
(((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32) ((uchar) (A)[2])) << 16) |\
(((uint32) ((uchar) (A)[3])) << 24)) +\ (((uint32) ((uchar) (A)[3])) << 24)) |\
(((ulonglong) ((uchar) (A)[4])) << 32)) (((ulonglong) ((uchar) (A)[4])) << 32))
#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \ #define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) | \
(((uint32) ((uchar) (A)[1])) << 8) + \ (((uint32) ((uchar) (A)[1])) << 8) | \
(((uint32) ((uchar) (A)[2])) << 16) + \ (((uint32) ((uchar) (A)[2])) << 16) | \
(((uint32) ((uchar) (A)[3])) << 24)) + \ (((uint32) ((uchar) (A)[3])) << 24)) | \
(((ulonglong) ((uchar) (A)[4])) << 32) + \ (((ulonglong) ((uchar) (A)[4])) << 32) | \
(((ulonglong) ((uchar) (A)[5])) << 40)) (((ulonglong) ((uchar) (A)[5])) << 40))
#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ #define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) |\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) |\
(((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32) ((uchar) (A)[2])) << 16) |\
(((uint32) ((uchar) (A)[3])) << 24)) +\ (((uint32) ((uchar) (A)[3])) << 24)) |\
(((ulonglong) (((uint32) ((uchar) (A)[4])) +\ (((ulonglong) (((uint32) ((uchar) (A)[4])) |\
(((uint32) ((uchar) (A)[5])) << 8) +\ (((uint32) ((uchar) (A)[5])) << 8) |\
(((uint32) ((uchar) (A)[6])) << 16) +\ (((uint32) ((uchar) (A)[6])) << 16) |\
(((uint32) ((uchar) (A)[7])) << 24))) <<\ (((uint32) ((uchar) (A)[7])) << 24))) <<\
32)) 32))
#define int2store(T,A) do { uint def_temp= (uint) (A) ;\ #define int2store(T,A) do { uint def_temp= (uint) (A) ;\
......
/* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -27,20 +28,20 @@ ...@@ -27,20 +28,20 @@
((uint32) (uchar) (A)[0]))) ((uint32) (uchar) (A)[0])))
#define sint4korr(A) (*((const long *) (A))) #define sint4korr(A) (*((const long *) (A)))
#define uint2korr(A) (*((const uint16 *) (A))) #define uint2korr(A) (*((const uint16 *) (A)))
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ #define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) |\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) |\
(((uint32) ((uchar) (A)[2])) << 16)) (((uint32) ((uchar) (A)[2])) << 16))
#define uint4korr(A) (*((const uint32 *) (A))) #define uint4korr(A) (*((const uint32 *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) |\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) |\
(((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32) ((uchar) (A)[2])) << 16) |\
(((uint32) ((uchar) (A)[3])) << 24)) +\ (((uint32) ((uchar) (A)[3])) << 24)) |\
(((ulonglong) ((uchar) (A)[4])) << 32)) (((ulonglong) ((uchar) (A)[4])) << 32))
#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \ #define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) | \
(((uint32) ((uchar) (A)[1])) << 8) + \ (((uint32) ((uchar) (A)[1])) << 8) | \
(((uint32) ((uchar) (A)[2])) << 16) + \ (((uint32) ((uchar) (A)[2])) << 16) | \
(((uint32) ((uchar) (A)[3])) << 24)) + \ (((uint32) ((uchar) (A)[3])) << 24)) | \
(((ulonglong) ((uchar) (A)[4])) << 32) + \ (((ulonglong) ((uchar) (A)[4])) << 32) | \
(((ulonglong) ((uchar) (A)[5])) << 40)) (((ulonglong) ((uchar) (A)[5])) << 40))
#define uint8korr(A) (*((const ulonglong *) (A))) #define uint8korr(A) (*((const ulonglong *) (A)))
#define sint8korr(A) (*((const longlong *) (A))) #define sint8korr(A) (*((const longlong *) (A)))
......
/* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -28,8 +29,8 @@ ...@@ -28,8 +29,8 @@
((uint32) (uchar) (A)[0]))) ((uint32) (uchar) (A)[0])))
#define sint4korr(A) (int32) (*((int32 *) (A))) #define sint4korr(A) (int32) (*((int32 *) (A)))
#define uint2korr(A) (uint16) (*((uint16 *) (A))) #define uint2korr(A) (uint16) (*((uint16 *) (A)))
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ #define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) |\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) |\
(((uint32) ((uchar) (A)[2])) << 16)) (((uint32) ((uchar) (A)[2])) << 16))
#define uint4korr(A) (uint32) (*((uint32 *) (A))) #define uint4korr(A) (uint32) (*((uint32 *) (A)))
...@@ -53,7 +54,7 @@ static inline ulonglong uint6korr(const void *p) ...@@ -53,7 +54,7 @@ static inline ulonglong uint6korr(const void *p)
#define int2store(T,A) do { uchar *pT= (uchar*)(T);\ #define int2store(T,A) do { uchar *pT= (uchar*)(T);\
*((uint16*)(pT))= (uint16) (A);\ *((uint16*)(pT))= (uint16) (A);\
} while (0) } while (0)
#define int3store(T,A) do { *(T)= (uchar) ((A));\ #define int3store(T,A) do { *(T)= (uchar) ((A));\
*(T+1)=(uchar) (((uint) (A) >> 8));\ *(T+1)=(uchar) (((uint) (A) >> 8));\
*(T+2)=(uchar) (((A) >> 16));\ *(T+2)=(uchar) (((A) >> 16));\
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define MYISAMPACK_INCLUDED #define MYISAMPACK_INCLUDED
/* Copyright (c) 2000-2002, 2004 MySQL AB, 2009 Sun Microsystems, Inc. /* Copyright (c) 2000-2002, 2004 MySQL AB, 2009 Sun Microsystems, Inc.
Copyright (c) 2020, MariaDB Corporation.
Use is subject to license terms. Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
...@@ -28,7 +29,7 @@ ...@@ -28,7 +29,7 @@
#define mi_sint1korr(A) ((int8)(*A)) #define mi_sint1korr(A) ((int8)(*A))
#define mi_uint1korr(A) ((uint8)(*A)) #define mi_uint1korr(A) ((uint8)(*A))
#define mi_sint2korr(A) ((int16) (((int16) (((const uchar*) (A))[1])) +\ #define mi_sint2korr(A) ((int16) (((int16) (((const uchar*) (A))[1])) |\
((int16) ((int16) ((const char*) (A))[0]) << 8))) ((int16) ((int16) ((const char*) (A))[0]) << 8)))
#define mi_sint3korr(A) ((int32) (((((const uchar*) (A))[0]) & 128) ? \ #define mi_sint3korr(A) ((int32) (((((const uchar*) (A))[0]) & 128) ? \
(((uint32) 255L << 24) | \ (((uint32) 255L << 24) | \
...@@ -38,58 +39,58 @@ ...@@ -38,58 +39,58 @@
(((uint32) ((const uchar*) (A))[0]) << 16) |\ (((uint32) ((const uchar*) (A))[0]) << 16) |\
(((uint32) ((const uchar*) (A))[1]) << 8) | \ (((uint32) ((const uchar*) (A))[1]) << 8) | \
((uint32) ((const uchar*) (A))[2]))) ((uint32) ((const uchar*) (A))[2])))
#define mi_sint4korr(A) ((int32) (((int32) (((const uchar*) (A))[3])) +\ #define mi_sint4korr(A) ((int32) (((int32) (((const uchar*) (A))[3])) |\
((int32) (((const uchar*) (A))[2]) << 8) +\ ((int32) (((const uchar*) (A))[2]) << 8) |\
((int32) (((const uchar*) (A))[1]) << 16) +\ ((int32) (((const uchar*) (A))[1]) << 16) |\
((int32) ((int16) ((const char*) (A))[0]) << 24))) ((int32) ((int16) ((const char*) (A))[0]) << 24)))
#define mi_sint8korr(A) ((longlong) mi_uint8korr(A)) #define mi_sint8korr(A) ((longlong) mi_uint8korr(A))
#define mi_uint2korr(A) ((uint16) (((uint16) (((const uchar*) (A))[1])) +\ #define mi_uint2korr(A) ((uint16) (((uint16) (((const uchar*) (A))[1])) |\
((uint16) (((const uchar*) (A))[0]) << 8))) ((uint16) (((const uchar*) (A))[0]) << 8)))
#define mi_uint3korr(A) ((uint32) (((uint32) (((const uchar*) (A))[2])) +\ #define mi_uint3korr(A) ((uint32) (((uint32) (((const uchar*) (A))[2])) |\
(((uint32) (((const uchar*) (A))[1])) << 8) +\ (((uint32) (((const uchar*) (A))[1])) << 8) |\
(((uint32) (((const uchar*) (A))[0])) << 16))) (((uint32) (((const uchar*) (A))[0])) << 16)))
#define mi_uint4korr(A) ((uint32) (((uint32) (((const uchar*) (A))[3])) +\ #define mi_uint4korr(A) ((uint32) (((uint32) (((const uchar*) (A))[3])) |\
(((uint32) (((const uchar*) (A))[2])) << 8) +\ (((uint32) (((const uchar*) (A))[2])) << 8) |\
(((uint32) (((const uchar*) (A))[1])) << 16) +\ (((uint32) (((const uchar*) (A))[1])) << 16) |\
(((uint32) (((const uchar*) (A))[0])) << 24))) (((uint32) (((const uchar*) (A))[0])) << 24)))
#ifndef HAVE_mi_uint5korr #ifndef HAVE_mi_uint5korr
#define mi_uint5korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[4])) +\ #define mi_uint5korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[4])) |\
(((uint32) (((const uchar*) (A))[3])) << 8) +\ (((uint32) (((const uchar*) (A))[3])) << 8) |\
(((uint32) (((const uchar*) (A))[2])) << 16) +\ (((uint32) (((const uchar*) (A))[2])) << 16) |\
(((uint32) (((const uchar*) (A))[1])) << 24)) +\ (((uint32) (((const uchar*) (A))[1])) << 24)) |\
(((ulonglong) (((const uchar*) (A))[0])) << 32)) (((ulonglong) (((const uchar*) (A))[0])) << 32))
#endif /* HAVE_mi_uint5korr */ #endif /* HAVE_mi_uint5korr */
#ifndef HAVE_mi_uint6korr #ifndef HAVE_mi_uint6korr
#define mi_uint6korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[5])) +\ #define mi_uint6korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[5])) |\
(((uint32) (((const uchar*) (A))[4])) << 8) +\ (((uint32) (((const uchar*) (A))[4])) << 8) |\
(((uint32) (((const uchar*) (A))[3])) << 16) +\ (((uint32) (((const uchar*) (A))[3])) << 16) |\
(((uint32) (((const uchar*) (A))[2])) << 24)) +\ (((uint32) (((const uchar*) (A))[2])) << 24)) |\
(((ulonglong) (((uint32) (((const uchar*) (A))[1])) +\ (((ulonglong) (((uint32) (((const uchar*) (A))[1])) |\
(((uint32) (((const uchar*) (A))[0]) << 8)))) <<\ (((uint32) (((const uchar*) (A))[0]) << 8)))) <<\
32)) 32))
#endif /* HAVE_mi_uint6korr */ #endif /* HAVE_mi_uint6korr */
#ifndef HAVE_mi_uint7korr #ifndef HAVE_mi_uint7korr
#define mi_uint7korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[6])) +\ #define mi_uint7korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[6])) |\
(((uint32) (((const uchar*) (A))[5])) << 8) +\ (((uint32) (((const uchar*) (A))[5])) << 8) |\
(((uint32) (((const uchar*) (A))[4])) << 16) +\ (((uint32) (((const uchar*) (A))[4])) << 16) |\
(((uint32) (((const uchar*) (A))[3])) << 24)) +\ (((uint32) (((const uchar*) (A))[3])) << 24)) |\
(((ulonglong) (((uint32) (((const uchar*) (A))[2])) +\ (((ulonglong) (((uint32) (((const uchar*) (A))[2])) |\
(((uint32) (((const uchar*) (A))[1])) << 8) +\ (((uint32) (((const uchar*) (A))[1])) << 8) |\
(((uint32) (((const uchar*) (A))[0])) << 16))) <<\ (((uint32) (((const uchar*) (A))[0])) << 16))) <<\
32)) 32))
#endif /* HAVE_mi_uint7korr */ #endif /* HAVE_mi_uint7korr */
#ifndef HAVE_mi_uint8korr #ifndef HAVE_mi_uint8korr
#define mi_uint8korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[7])) +\ #define mi_uint8korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[7])) |\
(((uint32) (((const uchar*) (A))[6])) << 8) +\ (((uint32) (((const uchar*) (A))[6])) << 8) |\
(((uint32) (((const uchar*) (A))[5])) << 16) +\ (((uint32) (((const uchar*) (A))[5])) << 16) |\
(((uint32) (((const uchar*) (A))[4])) << 24)) +\ (((uint32) (((const uchar*) (A))[4])) << 24)) |\
(((ulonglong) (((uint32) (((const uchar*) (A))[3])) +\ (((ulonglong) (((uint32) (((const uchar*) (A))[3])) |\
(((uint32) (((const uchar*) (A))[2])) << 8) +\ (((uint32) (((const uchar*) (A))[2])) << 8) |\
(((uint32) (((const uchar*) (A))[1])) << 16) +\ (((uint32) (((const uchar*) (A))[1])) << 16) |\
(((uint32) (((const uchar*) (A))[0])) << 24))) <<\ (((uint32) (((const uchar*) (A))[0])) << 24))) <<\
32)) 32))
#endif /* HAVE_mi_uint8korr */ #endif /* HAVE_mi_uint8korr */
......
/* Copyright (C) 2007 MySQL AB & Sanja Belkin. 2010 Monty Program Ab. /* Copyright (C) 2007 MySQL AB & Sanja Belkin. 2010 Monty Program Ab.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -5440,15 +5441,15 @@ static uchar *translog_get_LSN_from_diff(LSN base_lsn, uchar *src, uchar *dst) ...@@ -5440,15 +5441,15 @@ static uchar *translog_get_LSN_from_diff(LSN base_lsn, uchar *src, uchar *dst)
src + 1 + LSN_STORE_SIZE)); src + 1 + LSN_STORE_SIZE));
DBUG_RETURN(src + 1 + LSN_STORE_SIZE); DBUG_RETURN(src + 1 + LSN_STORE_SIZE);
} }
rec_offset= LSN_OFFSET(base_lsn) - ((first_byte << 8) + *((uint8*)src)); rec_offset= LSN_OFFSET(base_lsn) - ((first_byte << 8) | *((uint8*)src));
break; break;
case 1: case 1:
diff= uint2korr(src); diff= uint2korr(src);
rec_offset= LSN_OFFSET(base_lsn) - ((first_byte << 16) + diff); rec_offset= LSN_OFFSET(base_lsn) - ((first_byte << 16) | diff);
break; break;
case 2: case 2:
diff= uint3korr(src); diff= uint3korr(src);
rec_offset= LSN_OFFSET(base_lsn) - ((first_byte << 24) + diff); rec_offset= LSN_OFFSET(base_lsn) - ((first_byte << 24) | diff);
break; break;
case 3: case 3:
{ {
......
/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -1157,10 +1158,10 @@ static void decode_bytes(MARIA_COLUMNDEF *rec,MARIA_BIT_BUFF *bit_buff, ...@@ -1157,10 +1158,10 @@ static void decode_bytes(MARIA_COLUMNDEF *rec,MARIA_BIT_BUFF *bit_buff,
bit_buff->error=1; bit_buff->error=1;
return; /* Can't be right */ return; /* Can't be right */
} }
bit_buff->current_byte= (bit_buff->current_byte << 32) + bit_buff->current_byte= (bit_buff->current_byte << 32) |
((((uint) bit_buff->pos[3])) + ((((uint) bit_buff->pos[3])) |
(((uint) bit_buff->pos[2]) << 8) + (((uint) bit_buff->pos[2]) << 8) |
(((uint) bit_buff->pos[1]) << 16) + (((uint) bit_buff->pos[1]) << 16) |
(((uint) bit_buff->pos[0]) << 24)); (((uint) bit_buff->pos[0]) << 24));
bit_buff->pos+=4; bit_buff->pos+=4;
bits+=32; bits+=32;
...@@ -1251,23 +1252,23 @@ static void decode_bytes(MARIA_COLUMNDEF *rec, MARIA_BIT_BUFF *bit_buff, ...@@ -1251,23 +1252,23 @@ static void decode_bytes(MARIA_COLUMNDEF *rec, MARIA_BIT_BUFF *bit_buff,
return; /* Can't be right */ return; /* Can't be right */
} }
#if BITS_SAVED == 32 #if BITS_SAVED == 32
bit_buff->current_byte= (bit_buff->current_byte << 24) + bit_buff->current_byte= (bit_buff->current_byte << 24) |
(((uint) ((uchar) bit_buff->pos[2]))) + (((uint) ((uchar) bit_buff->pos[2]))) |
(((uint) ((uchar) bit_buff->pos[1])) << 8) + (((uint) ((uchar) bit_buff->pos[1])) << 8) |
(((uint) ((uchar) bit_buff->pos[0])) << 16); (((uint) ((uchar) bit_buff->pos[0])) << 16);
bit_buff->pos+=3; bit_buff->pos+=3;
bits+=24; bits+=24;
#else #else
if (bits) /* We must have at leasts 9 bits */ if (bits) /* We must have at leasts 9 bits */
{ {
bit_buff->current_byte= (bit_buff->current_byte << 8) + bit_buff->current_byte= (bit_buff->current_byte << 8) |
(uint) ((uchar) bit_buff->pos[0]); (uint) ((uchar) bit_buff->pos[0]);
bit_buff->pos++; bit_buff->pos++;
bits+=8; bits+=8;
} }
else else
{ {
bit_buff->current_byte= ((uint) ((uchar) bit_buff->pos[0]) << 8) + bit_buff->current_byte= ((uint) ((uchar) bit_buff->pos[0]) << 8) |
((uint) ((uchar) bit_buff->pos[1])); ((uint) ((uchar) bit_buff->pos[1]));
bit_buff->pos+=2; bit_buff->pos+=2;
bits+=16; bits+=16;
...@@ -1291,14 +1292,14 @@ static void decode_bytes(MARIA_COLUMNDEF *rec, MARIA_BIT_BUFF *bit_buff, ...@@ -1291,14 +1292,14 @@ static void decode_bytes(MARIA_COLUMNDEF *rec, MARIA_BIT_BUFF *bit_buff,
if (bits < 8) if (bits < 8)
{ /* We don't need to check end */ { /* We don't need to check end */
#if BITS_SAVED == 32 #if BITS_SAVED == 32
bit_buff->current_byte= (bit_buff->current_byte << 24) + bit_buff->current_byte= (bit_buff->current_byte << 24) |
(((uint) ((uchar) bit_buff->pos[2]))) + (((uint) ((uchar) bit_buff->pos[2]))) |
(((uint) ((uchar) bit_buff->pos[1])) << 8) + (((uint) ((uchar) bit_buff->pos[1])) << 8) |
(((uint) ((uchar) bit_buff->pos[0])) << 16); (((uint) ((uchar) bit_buff->pos[0])) << 16);
bit_buff->pos+=3; bit_buff->pos+=3;
bits+=24; bits+=24;
#else #else
bit_buff->current_byte= (bit_buff->current_byte << 8) + bit_buff->current_byte= (bit_buff->current_byte << 8) |
(uint) ((uchar) bit_buff->pos[0]); (uint) ((uchar) bit_buff->pos[0]);
bit_buff->pos+=1; bit_buff->pos+=1;
bits+=8; bits+=8;
...@@ -1488,25 +1489,25 @@ static void fill_buffer(MARIA_BIT_BUFF *bit_buff) ...@@ -1488,25 +1489,25 @@ static void fill_buffer(MARIA_BIT_BUFF *bit_buff)
return; return;
} }
#if BITS_SAVED == 64 #if BITS_SAVED == 64
bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) + bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) |
(((uint) ((uchar) bit_buff->pos[6])) << 8) + (((uint) ((uchar) bit_buff->pos[6])) << 8) |
(((uint) ((uchar) bit_buff->pos[5])) << 16) + (((uint) ((uchar) bit_buff->pos[5])) << 16) |
(((uint) ((uchar) bit_buff->pos[4])) << 24) + (((uint) ((uchar) bit_buff->pos[4])) << 24) |
((ulonglong) ((ulonglong)
((((uint) ((uchar) bit_buff->pos[3]))) + ((((uint) ((uchar) bit_buff->pos[3]))) |
(((uint) ((uchar) bit_buff->pos[2])) << 8) + (((uint) ((uchar) bit_buff->pos[2])) << 8) |
(((uint) ((uchar) bit_buff->pos[1])) << 16) + (((uint) ((uchar) bit_buff->pos[1])) << 16) |
(((uint) ((uchar) bit_buff->pos[0])) << 24)) << 32)); (((uint) ((uchar) bit_buff->pos[0])) << 24)) << 32));
bit_buff->pos+=8; bit_buff->pos+=8;
#else #else
#if BITS_SAVED == 32 #if BITS_SAVED == 32
bit_buff->current_byte= (((uint) ((uchar) bit_buff->pos[3])) + bit_buff->current_byte= (((uint) ((uchar) bit_buff->pos[3])) |
(((uint) ((uchar) bit_buff->pos[2])) << 8) + (((uint) ((uchar) bit_buff->pos[2])) << 8) |
(((uint) ((uchar) bit_buff->pos[1])) << 16) + (((uint) ((uchar) bit_buff->pos[1])) << 16) |
(((uint) ((uchar) bit_buff->pos[0])) << 24)); (((uint) ((uchar) bit_buff->pos[0])) << 24));
bit_buff->pos+=4; bit_buff->pos+=4;
#else #else
bit_buff->current_byte= (uint) (((uint) ((uchar) bit_buff->pos[1]))+ bit_buff->current_byte= (uint) (((uint) ((uchar) bit_buff->pos[1])) |
(((uint) ((uchar) bit_buff->pos[0])) << 8)); (((uint) ((uchar) bit_buff->pos[0])) << 8));
bit_buff->pos+=2; bit_buff->pos+=2;
#endif #endif
......
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -1111,10 +1112,10 @@ static void decode_bytes(MI_COLUMNDEF *rec,MI_BIT_BUFF *bit_buff,uchar *to, ...@@ -1111,10 +1112,10 @@ static void decode_bytes(MI_COLUMNDEF *rec,MI_BIT_BUFF *bit_buff,uchar *to,
bit_buff->error=1; bit_buff->error=1;
return; /* Can't be right */ return; /* Can't be right */
} }
bit_buff->current_byte= (bit_buff->current_byte << 32) + bit_buff->current_byte= (bit_buff->current_byte << 32) |
((((uint) bit_buff->pos[3])) + ((((uint) bit_buff->pos[3])) |
(((uint) bit_buff->pos[2]) << 8) + (((uint) bit_buff->pos[2]) << 8) |
(((uint) bit_buff->pos[1]) << 16) + (((uint) bit_buff->pos[1]) << 16) |
(((uint) bit_buff->pos[0]) << 24)); (((uint) bit_buff->pos[0]) << 24));
bit_buff->pos+=4; bit_buff->pos+=4;
bits+=32; bits+=32;
...@@ -1205,23 +1206,23 @@ static void decode_bytes(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, ...@@ -1205,23 +1206,23 @@ static void decode_bytes(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to,
return; /* Can't be right */ return; /* Can't be right */
} }
#if BITS_SAVED == 32 #if BITS_SAVED == 32
bit_buff->current_byte= (bit_buff->current_byte << 24) + bit_buff->current_byte= (bit_buff->current_byte << 24) |
(((uint) ((uchar) bit_buff->pos[2]))) + (((uint) ((uchar) bit_buff->pos[2]))) |
(((uint) ((uchar) bit_buff->pos[1])) << 8) + (((uint) ((uchar) bit_buff->pos[1])) << 8) |
(((uint) ((uchar) bit_buff->pos[0])) << 16); (((uint) ((uchar) bit_buff->pos[0])) << 16);
bit_buff->pos+=3; bit_buff->pos+=3;
bits+=24; bits+=24;
#else #else
if (bits) /* We must have at leasts 9 bits */ if (bits) /* We must have at leasts 9 bits */
{ {
bit_buff->current_byte= (bit_buff->current_byte << 8) + bit_buff->current_byte= (bit_buff->current_byte << 8) |
(uint) ((uchar) bit_buff->pos[0]); (uint) ((uchar) bit_buff->pos[0]);
bit_buff->pos++; bit_buff->pos++;
bits+=8; bits+=8;
} }
else else
{ {
bit_buff->current_byte= ((uint) ((uchar) bit_buff->pos[0]) << 8) + bit_buff->current_byte= ((uint) ((uchar) bit_buff->pos[0]) << 8) |
((uint) ((uchar) bit_buff->pos[1])); ((uint) ((uchar) bit_buff->pos[1]));
bit_buff->pos+=2; bit_buff->pos+=2;
bits+=16; bits+=16;
...@@ -1245,14 +1246,14 @@ static void decode_bytes(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, ...@@ -1245,14 +1246,14 @@ static void decode_bytes(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to,
if (bits < 8) if (bits < 8)
{ /* We don't need to check end */ { /* We don't need to check end */
#if BITS_SAVED == 32 #if BITS_SAVED == 32
bit_buff->current_byte= (bit_buff->current_byte << 24) + bit_buff->current_byte= (bit_buff->current_byte << 24) |
(((uint) ((uchar) bit_buff->pos[2]))) + (((uint) ((uchar) bit_buff->pos[2]))) |
(((uint) ((uchar) bit_buff->pos[1])) << 8) + (((uint) ((uchar) bit_buff->pos[1])) << 8) |
(((uint) ((uchar) bit_buff->pos[0])) << 16); (((uint) ((uchar) bit_buff->pos[0])) << 16);
bit_buff->pos+=3; bit_buff->pos+=3;
bits+=24; bits+=24;
#else #else
bit_buff->current_byte= (bit_buff->current_byte << 8) + bit_buff->current_byte= (bit_buff->current_byte << 8) |
(uint) ((uchar) bit_buff->pos[0]); (uint) ((uchar) bit_buff->pos[0]);
bit_buff->pos+=1; bit_buff->pos+=1;
bits+=8; bits+=8;
...@@ -1439,25 +1440,25 @@ static void fill_buffer(MI_BIT_BUFF *bit_buff) ...@@ -1439,25 +1440,25 @@ static void fill_buffer(MI_BIT_BUFF *bit_buff)
} }
#if BITS_SAVED == 64 #if BITS_SAVED == 64
bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) + bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) |
(((uint) ((uchar) bit_buff->pos[6])) << 8) + (((uint) ((uchar) bit_buff->pos[6])) << 8) |
(((uint) ((uchar) bit_buff->pos[5])) << 16) + (((uint) ((uchar) bit_buff->pos[5])) << 16) |
(((uint) ((uchar) bit_buff->pos[4])) << 24) + (((uint) ((uchar) bit_buff->pos[4])) << 24) |
((ulonglong) ((ulonglong)
((((uint) ((uchar) bit_buff->pos[3]))) + ((((uint) ((uchar) bit_buff->pos[3]))) |
(((uint) ((uchar) bit_buff->pos[2])) << 8) + (((uint) ((uchar) bit_buff->pos[2])) << 8) |
(((uint) ((uchar) bit_buff->pos[1])) << 16) + (((uint) ((uchar) bit_buff->pos[1])) << 16) |
(((uint) ((uchar) bit_buff->pos[0])) << 24)) << 32)); (((uint) ((uchar) bit_buff->pos[0])) << 24)) << 32));
bit_buff->pos+=8; bit_buff->pos+=8;
#else #else
#if BITS_SAVED == 32 #if BITS_SAVED == 32
bit_buff->current_byte= (((uint) ((uchar) bit_buff->pos[3])) + bit_buff->current_byte= (((uint) ((uchar) bit_buff->pos[3])) |
(((uint) ((uchar) bit_buff->pos[2])) << 8) + (((uint) ((uchar) bit_buff->pos[2])) << 8) |
(((uint) ((uchar) bit_buff->pos[1])) << 16) + (((uint) ((uchar) bit_buff->pos[1])) << 16) |
(((uint) ((uchar) bit_buff->pos[0])) << 24)); (((uint) ((uchar) bit_buff->pos[0])) << 24));
bit_buff->pos+=4; bit_buff->pos+=4;
#else #else
bit_buff->current_byte= (uint) (((uint) ((uchar) bit_buff->pos[1]))+ bit_buff->current_byte= (uint) (((uint) ((uchar) bit_buff->pos[1])) |
(((uint) ((uchar) bit_buff->pos[0])) << 8)); (((uint) ((uchar) bit_buff->pos[0])) << 8));
bit_buff->pos+=2; bit_buff->pos+=2;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment