FFL_Core.h 2.6 KB
Newer Older
L
libb 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
/*
*  This file is part of FFL project.
*
*  The MIT License (MIT)
*  Copyright (C) 2017-2018 zhufeifei All rights reserved.
*
*  FFL_Core   
*  Created by zhufeifei(34008081@qq.com) on 2017/07/10 
*  https://github.com/zhenfei2016/FFLv2-lib.git
*
*
*/
#ifndef _FFL_CORE_H_
#define _FFL_CORE_H_

/*  字符串操作 */
#include <string.h>
#include <FFL_Config.h>
#include <FFL_Platform.h>
#include <FFL_Stdint.h>
#include <FFL_Error.h>
#include <FFL_Assert.h>
#include <FFL_Memory.h>
#include <FFL_String.h>
#include <FFL_Time.h>
#include <FFL_Log.h>
#include <FFL_LogConfig.h>

/*
*  函数调用方式
*/
#ifndef FFL_CALL
#if (defined(WIN32))
#define FFL_CALL __cdecl
#elif (defined(MACOSX))
#define FFL_CALL
#else
#define FFL_CALL
#endif
#endif

/*
* 内联函数
*/
#define FFL_INLINE 


/*  最大值 */
#ifndef FFL_MAX
#define FFL_MAX(a, b)    ((a) > (b) ? (a) : (b))
#endif

/*  最小值 */
#ifndef FFL_MIN
#define FFL_MIN(a, b)    ((a) < (b) ? (a) : (b))
#endif

/*  align字节对齐 */
#ifndef FFL_ALIGN
#define FFL_ALIGN(x, align) ((( x ) + (align) - 1) / (align) * (align))
#endif

/* 数组元素个数 */
#ifndef FFL_ARRAY_ELEMS
#define FFL_ARRAY_ELEMS(x) ((int) (sizeof(x) / sizeof((x)[0])))
#endif

/* 交换2个数值 */
#ifndef FFL_SWAP
#define FFL_SWAP(type,a,b) do{type tmp= b; b= a; a= tmp;}while(0)
#endif

/*
*  转换到字符串类型
*/
#ifndef FFL_TOSTRING
#define FFL_TOSTRING(s) #s
#endif

#ifndef FFL_INT32_HIGHT_16
#define FFL_INT32_HIGHT_16(a) ((((int)(a))>>16) & 0xFFFF)
#endif

#ifndef FFL_INT32_LOW_16
#define FFL_INT32_LOW_16(a) ((((int)(a))) & 0xFFFF)
#endif

#ifndef FFL_MAKE_INT32
#define FFL_MAKE_INT32(high,low) (((low)& 0xFFFF) | (((high)& 0xFFFF)<<16))
#endif


#ifndef FFL_INT64_HIGHT_32
#define FFL_INT64_HIGHT_32(a) ((int32_t)( ((a) >> 32) & 0xFFFFFFFF))
#endif

#ifndef FFL_INT64_LOW_32
#define FFL_INT64_LOW_32(a) ((int32_t)( (a) & 0xFFFFFFFF ))
#endif

#ifndef FFL_MAKE_INT64
#define FFL_MAKE_INT64(high,low) (((int64_t)(low)& 0xFFFFFFFF) | (((int64_t)(high)& 0xFFFFFFFF)<<32))
#endif

/*
*打印64位整形
* print("hi%"lld64, 123445 );
*/
#if defined(WIN32)
#define lld64 "I64d"
#else
#define lld64 "lld"
#endif

/*
*  socket句柄
*/
typedef int NetFD;
#define INVALID_NetFD 0

#ifdef  __cplusplus
extern "C"{
#endif
/*
*  初始化函数
*
* */
FFLIB_API_IMPORT_EXPORT void FFL_CALL FFL_initialize();

/*
*  结束FFL库的使用,调用后就不要再使用FFL的函数了
*
* */
FFLIB_API_IMPORT_EXPORT void FFL_CALL FFL_terminate();

#ifdef  __cplusplus
}
#endif

#endif

#ifdef  __cplusplus
#ifndef _FFL_CORE_HPP_
#define _FFL_CORE_HPP_
#include <FFL_Utils.hpp>
#endif
#endif