~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to include/big_endian.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
15
 
 
16
/*
 
17
  Data in big-endian format.
 
18
*/
 
19
#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
 
20
                              *((T)+1)=(char) ((uchar *) &A)[2];\
 
21
                              *((T)+2)=(char) ((uchar *) &A)[1];\
 
22
                              *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
 
23
 
 
24
#define float4get(V,M)   do { float def_temp;\
 
25
                              ((uchar*) &def_temp)[0]=(M)[3];\
 
26
                              ((uchar*) &def_temp)[1]=(M)[2];\
 
27
                              ((uchar*) &def_temp)[2]=(M)[1];\
 
28
                              ((uchar*) &def_temp)[3]=(M)[0];\
 
29
                              (V)=def_temp; } while(0)
 
30
 
 
31
#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
 
32
                              *((T)+1)=(char) ((uchar *) &V)[6];\
 
33
                              *((T)+2)=(char) ((uchar *) &V)[5];\
 
34
                              *((T)+3)=(char) ((uchar *) &V)[4];\
 
35
                              *((T)+4)=(char) ((uchar *) &V)[3];\
 
36
                              *((T)+5)=(char) ((uchar *) &V)[2];\
 
37
                              *((T)+6)=(char) ((uchar *) &V)[1];\
 
38
                              *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
 
39
 
 
40
#define float8get(V,M)   do { double def_temp;\
 
41
                              ((uchar*) &def_temp)[0]=(M)[7];\
 
42
                              ((uchar*) &def_temp)[1]=(M)[6];\
 
43
                              ((uchar*) &def_temp)[2]=(M)[5];\
 
44
                              ((uchar*) &def_temp)[3]=(M)[4];\
 
45
                              ((uchar*) &def_temp)[4]=(M)[3];\
 
46
                              ((uchar*) &def_temp)[5]=(M)[2];\
 
47
                              ((uchar*) &def_temp)[6]=(M)[1];\
 
48
                              ((uchar*) &def_temp)[7]=(M)[0];\
 
49
                              (V) = def_temp; } while(0)
 
50
 
 
51
#define ushortget(V,M)  do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
 
52
                                 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
 
53
#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
 
54
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
 
55
#define longget(V,M)    do { int32 def_temp;\
 
56
                             ((uchar*) &def_temp)[0]=(M)[0];\
 
57
                             ((uchar*) &def_temp)[1]=(M)[1];\
 
58
                             ((uchar*) &def_temp)[2]=(M)[2];\
 
59
                             ((uchar*) &def_temp)[3]=(M)[3];\
 
60
                             (V)=def_temp; } while(0)
 
61
#define ulongget(V,M)   do { uint32 def_temp;\
 
62
                            ((uchar*) &def_temp)[0]=(M)[0];\
 
63
                            ((uchar*) &def_temp)[1]=(M)[1];\
 
64
                            ((uchar*) &def_temp)[2]=(M)[2];\
 
65
                            ((uchar*) &def_temp)[3]=(M)[3];\
 
66
                            (V)=def_temp; } while(0)
 
67
#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
 
68
                             *(((char*)T)+1)=(char)(def_temp); \
 
69
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
 
70
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
 
71
                             *(((char*)T)+2)=(((A) >> 8));\
 
72
                             *(((char*)T)+1)=(((A) >> 16));\
 
73
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
 
74
 
 
75
#define floatget(V,M)      memcpy(&V, (M), sizeof(float))
 
76
/* Cast away type qualifiers (necessary as macro takes argument by value). */
 
77
#define floatstore(T,V)    memcpy((T), (void*) (&V), sizeof(float))
 
78
#define doubleget(V,M)     memcpy(&V, (M), sizeof(double))
 
79
/* Cast away type qualifiers (necessary as macro takes argument by value). */
 
80
#define doublestore(T,V)   memcpy((T), (void*) &V, sizeof(double))
 
81
#define longlongget(V,M)   memcpy(&V, (M), sizeof(ulonglong))
 
82
#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))