1 #ifndef COMPAT56_H_INCLUDED
2 #define COMPAT56_H_INCLUDED
3 /*
4    Copyright (c) 2004, 2012, Oracle and/or its affiliates.
5    Copyright (c) 2013  MariaDB Foundation.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; version 2 of the License.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335  USA */
19 
20 
21 /** MySQL56 routines and macros **/
22 
23 /*
24   Buffer size for a native TIMESTAMP representation, for use with NativBuffer.
25   4 bytes for seconds
26   3 bytes for microseconds
27   1 byte for the trailing '\0' (class Native reserves extra 1 byte for '\0')
28 */
29 #define STRING_BUFFER_TIMESTAMP_BINARY_SIZE    8 /* 4 + 3 + 1 */
30 
31 #define MY_PACKED_TIME_GET_INT_PART(x)     ((x) >> 24)
32 #define MY_PACKED_TIME_GET_FRAC_PART(x)    ((x) % (1LL << 24))
33 #define MY_PACKED_TIME_MAKE(i, f)          ((((ulonglong) (i)) << 24) + (f))
34 #define MY_PACKED_TIME_MAKE_INT(i)         ((((ulonglong) (i)) << 24))
35 
36 longlong TIME_to_longlong_datetime_packed(const MYSQL_TIME *);
37 longlong TIME_to_longlong_time_packed(const MYSQL_TIME *);
38 
39 void TIME_from_longlong_datetime_packed(MYSQL_TIME *ltime, longlong nr);
40 void TIME_from_longlong_time_packed(MYSQL_TIME *ltime, longlong nr);
41 
42 void my_datetime_packed_to_binary(longlong nr, uchar *ptr, uint dec);
43 longlong my_datetime_packed_from_binary(const uchar *ptr, uint dec);
44 uint my_datetime_binary_length(uint dec);
45 
46 void my_time_packed_to_binary(longlong nr, uchar *ptr, uint dec);
47 longlong my_time_packed_from_binary(const uchar *ptr, uint dec);
48 uint my_time_binary_length(uint dec);
49 
50 void my_timestamp_to_binary(const struct timeval *tm, uchar *ptr, uint dec);
51 void my_timestamp_from_binary(struct timeval *tm, const uchar *ptr, uint dec);
52 uint my_timestamp_binary_length(uint dec);
53 /** End of MySQL routines and macros **/
54 
55 #endif /* COMPAT56_H_INCLUDED */
56