📄 types.h
字号:
/*-
* Copyright (C) 2002
* Robert Jiang(XIAOHUA JIANG). All rights reserved.
* All or some portions of this file are derived from material lisenced
* to Robert Jiang(XIAOHUA JIANG).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the XHlib Project by
* Robert Jiang(XIAOHUA JIANG).
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @(#)types.h 1.1 (Robert.J) 4/15/2002
*/
/*
* types used in XHlib
*/
#ifndef __TYPES_H__
#define __TYPES_H__
#ifndef _MSC_VER
#include <sys/types.h>
#if defined(linux) || defined(_WIN32)
#include <stdint.h>
#endif
#endif
#if defined(__TCS__)
#include <ops/custom_defs.h>
#endif
#if defined(_MSC_VER)
#define __inline__ __inline
#elif defined(__TCS__)
#define __inline__ inline
#elif !defined(__GNUC__)
#define __inline__
#endif
/* base types */
#if defined(_MSC_VER) || defined(__TCS__)
typedef char int8_t;
typedef short int16_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
#endif
#if defined(__TCS__)
typedef long int32_t;
typedef u_long uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif
#ifdef _MSC_VER
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef long off_t;
typedef long ssize_t;
#if _MSC_VER < 1400
typedef unsigned long time_t;
#endif
#ifndef _SIZE_T_DEFINED
typedef unsigned long size_t;
#define _SIZE_T_DEFINED
#endif
#if defined(_WIN32) && !defined(_WIN64)
typedef int int32_t;
typedef u_int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#elif defined(_WIN64)
typedef int int32_t;
typedef u_int uint32_t;
typedef long int64_t;
typedef u_long uint64_t;
#else
typedef long int32_t;
typedef unsigned long uint32_t;
#endif /* _WIN32*/
#endif /* _MSC_VER*/
typedef int32_t index_t;
#ifndef __cplusplus
typedef enum {
false = 0,
true = 1
} bool;
#endif
#ifndef NULL
#define NULL (void*)0
#endif
/*
#if !defined(_WIN32) && !defined(_WIN64)
typedef int fd_t;
#define INVALID_FD -1
#else
typedef HANDLE fd_t;
#define INVALID_FD INVALID_HANDLE
#endif
*/
#define INT_MAXBITS (sizeof(long)*8)
#ifndef MAX_INT
#define MAX_INT ((0x1 << INT_MAXBITS) - 1)
#endif
#ifdef __TCS__
#define EQQ(x, y) (ieql((x), (y)))
#define MAX(x, y) (imax((x), (y)))
#define MIN(x, y) (imin((x), (y)))
#define abs(x, y) (iabs((x), (y)))
#else
#define EQQ(x,y) (~((((x)-(y))>>(INT_MAXBITS-1))^(((y)-(x))>>(INT_MAXBITS-1)))&(x))
#ifndef MAX
#define MAX(x,y) (((((x)-(y))>>(INT_MAXBITS-1))&(y))|((((y)-(x))>>(INT_MAXBITS-1))&(x))|EQQ(x,y))
#endif
#ifndef MIN
#define MIN(x,y) (((((x)-(y))>>(INT_MAXBITS-1))&(x))|((((y)-(x))>>(INT_MAXBITS-1))&(y))|EQQ(x,y))
#endif
#define abs(x) (((x)^((x)>>(INT_MAXBITS-1)))-((x)>>(INT_MAXBITS-1)))
#endif // __TCS__
#define MAX3(x,y,z) MAX(MAX((x),(y)), (z))
#define MIN3(x,y,z) MIN(MIN((x),(y)), (z))
#define MEDIAN(x,y,z) ((x)+(y)+(z)-MAX3(x,y,z)-MIN3(x,y,z))
#define AVG(x, y) (((x)+(y))/2)
#ifdef __GNUC__
#define ATTR_ALIGN(a) __attribute__ ((__aligned__ (a)))
#elif defined(_MSC_VER)
#define ATTR_ALIGN(a) __declspec(align(a))
#elif defined(__TCS__)
#define ATTR_ALIGN(a)
#endif
typedef struct cmsp_uint64 {
uint32_t low;
uint32_t high;
} cmsp_uint64_t;
#define cmsp_uint64_sub(x, y) (0-(((x).high - (y).high)) + (x).low - (y).low)
#define cmsp_uint64_assign(d,x,y) ((d).low = (x), (d).high = (y))
#define cmsp_uint64_assign2(d,s) ((d).low = (s)->low, (d).high = (s)->high)
#ifdef DLL
#define DLLAPI __declspec(dllexport)
#else
#define DLLAPI
#endif
#endif /* __TYPES_H__*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -