9 Star 36 Fork 13

Josin/mbinlogmq

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
endian.h 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
liqiongfan 提交于 2019-07-25 17:23 . 增加了double、float类型解析
/**
* Copyright @2019 Josin All Rights Reserved.
* Author: Josin
* Email : [email protected]
*/
#ifndef MYSQL_BINLOG_ENDIAN_H
#define MYSQL_BINLOG_ENDIAN_H
/**
* @brief NOTICE
* Some macro for generate the value from little to big endian or for another
*/
#include <fc_string.h>
#define GLOBAL_VARS
GLOBAL_VARS int IS_BIGENDIAN;
#define int32_cbit(i) ( ((i) & 0x000000ffu) << 24 | ( (i) & 0x0000ff00u ) << 8 | ( ((i) & 0x00ff0000u) >> 8) | ( (i) & 0xff000000u ) >> 24 )
#define int64_cbit(i) ( int32_cbit((i) & 0x0ffffffffu) << 32 | int32_cbit( ((i) >> 32) & 0x0ffffffffu) )
static
int big_endian() {
union {
short a:2;
char b[2];
} ua;
ua.b[0] = 0x11;
ua.b[1] = 0x22;
if ( (ua.a & 0x0ff) == 0x11 ) {
return 1; /* Big endian */
} else {
return 0; /* Little endian */
}
}
long long exchange_copy_data_from_little(char *little_memory, int num); /* Only used for MySQL DATE type */
long long copy_data_from_little(char *little_memory, int num);
/**
* @brief NOTICE
* Machine except.
*/
long copy_number_from_little_stream(char *src, int num);
long copy_number_from_big_stream(char *src, int num);
double copy_double_from_little_stream(char *src, int num);
float copy_float_from_little_stream(char *src, int num);
long copy_number_from_bit( long num, int numbit, int begin_pos, int length );
long bitsets_in_var( int num );
#endif /* MYSQL_BINLOG_ENDIAN_H */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/josinli/mbinlogmq.git
[email protected]:josinli/mbinlogmq.git
josinli
mbinlogmq
mbinlogmq
release

搜索帮助