You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

373 lines
8.5 KiB
C

/*************************************************************************************
*
* Copyright (C) 1999-2000 SCADA Technology Control Co., Ltd. All rights reserved.
*
* 作者: 杨小波
*
* 日期: 2001/08/07
*
* 说明:
* 最基本的类型定义.
* 1: 基本类型的长度(字节单位)
* 2: 定义可移植类型
*
*************************************************************************************/
#ifndef __TYPEDEF_H__DFJGLWREPUEPISXVCMAFGLJHQEWPYRPEOAJLKGZNCNALDHFPQEWUPOQRJSJHGAQ
#define __TYPEDEF_H__DFJGLWREPUEPISXVCMAFGLJHQEWPYRPEOAJLKGZNCNALDHFPQEWUPOQRJSJHGAQ
/*!
* \if developer_doc
* \file
*
* \brief 最基本的类型定义
*
* id: $Id: typedef.h,v 1.2 2006/08/04 03:37:33 zhuzhenhua Exp $
*
* \author 杨小波 prcharold@sina.com.cn develop1@szscada.com
* \endif
*/
#include <sys/types.h>
/*!
* 定义最基本的类型, 这些类型可以在不同的操作系统中保持字节长度不变,
* 便于在不同的操作系统环境中, PGC系列软件之间交换数据和文件
*
* 单字节数据类型 //(SIZE_OF_CHAR = sizeof(char))
*/
#define SIZE_OF_CHAR 1
#if SIZE_OF_CHAR == 1
typedef char pgcchar;
typedef char pgc8;
typedef signed char int8;
typedef signed char i_8;
typedef unsigned char u_char;
typedef unsigned char pgcu_char;
typedef unsigned char pgcbyte;
typedef unsigned char PGCBYTE;
typedef unsigned char pgcu8;
typedef unsigned char u_8;
typedef unsigned char BYTE;
#else
#error "Please choose a 1 byte data type to redefine pgcchar."
#endif /* SIZE_OF_CHAR == 1 */
#define SIZE_OF_SHORT 2
/*!
* 双字节 //(SIZE_OF_SHORT = sizeof(short))
*/
#if SIZE_OF_SHORT == 2
typedef short pgc16;
typedef short int16;
typedef short i_16;
typedef unsigned short pgcu16;
typedef unsigned short pgcword;
typedef unsigned short PGCWORD;
typedef unsigned short u_16;
typedef unsigned short u_short;
typedef unsigned short WORD;
#else
#error "Please choose a 2 byte data type to redefine pgc16."
#endif //SIZE_OF_SHORT == 2
#define SIZE_OF_LONG 4
#define SIZE_OF_INT 4
/*!
* 双字节 (SIZE_OF_LONG = sizeof(long))
*/
#if SIZE_OF_LONG == 4 && SIZE_OF_INT == 4
typedef int pgc32;
typedef int int32;
typedef unsigned int pgcu32;
typedef unsigned int pgcdword;
typedef unsigned int PGCDWORD;
typedef unsigned int u32;
/*#if OS_WINDOWS
typedef unsigned int DWORD;
#endif //OS_WINDOWS*/
#elif SIZE_OF_LONG == 4
typedef long pgc32;
typedef long int32;
typedef long i_32;
typedef unsigned long pgcu32;
typedef unsigned long pgcdword;
typedef unsigned long PGCDWORD;
typedef unsigned long u_32;
typedef unsigned long DWORD;
#elif SIZE_OF_INT == 4 //(SIZE_OF_INT = sizeof(ing))
#ifndef _INTEGER_32BIT
#define _INTEGER_32BIT
typedef int pgc32;
typedef int int32;
typedef int i_32;
typedef unsigned int pgcu32;
typedef unsigned int pgcdword;
typedef unsigned int PGCDWORD;
typedef unsigned int u_32;
typedef unsigned int DWORD;
# endif
#else
#error "Please choose a 4 byte data type to redefine pgc32."
#endif //SIZE_OF_LONG == 4 and SIZE_OF_INT == 4
#define SIZE_OF_LONG 8
/*!
* 8字节 (SIZE_OF_LONG == sizeof(long))
*/
#if SIZE_OF_LONG == 8
typedef long pgc64;
typedef long int64;
typedef long i_64;
typedef unsigned long pgcu64;
typedef unsigned long pgcddword;
typedef unsigned long PGCDDWORD;
typedef unsigned long u_64;
typedef unsigned long DDWORD;
#elif OS_WINDOWS
typedef __int64 pgc64;
typedef __int64 int64;
typedef __int64 i_64;
typedef unsigned __int64 pgcu64;
typedef unsigned __int64 pgcddword;
typedef unsigned __int64 PGCDDWORD;
typedef unsigned __int64 u_64;
typedef unsigned __int64 DDWORD;
#else
typedef int64_t pgc64;
typedef int64_t int64;
typedef int64_t i_64;
typedef u_int64_t pgcu64;
typedef u_int64_t pgcddword;
typedef u_int64_t PGCDDWORD;
typedef u_int64_t u_64;
typedef u_int64_t DDWORD;
#endif //SIZE_OF_LONG == 8
#define SIZE_OF_PTR 4
/*!
* 指针 (SIZE_OF_PTR == sizeof(void *))
*/
#if SIZE_OF_PTR == 4
typedef pgc32 PGCPTR;
typedef pgc32 PTR;
typedef pgcu32 PGCUPTR;
typedef pgcu32 UPTR;
#elif SIZE_OF_PTR == 8
typedef pgc64 PGCPTR;
typedef pgc64 PTR;
typedef pgcu64 PGCUPTR;
typedef pgcu64 UPTR;
#else
#error "Please choose a data type, which size is acturally the size of pointer, to present PGCPTR"
#endif
/*!
* PGCBOOL自定义类型 -- 表达SCADA布尔量
*/
//#ifndef __PGCBOOL_DEF__
//#define __PGCBOOL_DEF__
typedef pgcu8 PGCBOOL;
#define PGCTRUE ((PGCBOOL)1)
#define PGCFALSE ((PGCBOOL)0)
//#endif //__PGCBOOL_DEF__
//#if OS_WINDOWS
//# ifndef key_t
typedef int key_t;
//# endif
//#endif // OS_WINDOWS
/*!
* ipc别名定义.
*
* 共享内存键值, 共享内存id, 信号量键值, 信号量id, 消息队列键值, 消息队列id
*
*/
typedef key_t shmkey_t, SHMKEY_t; // 共享内存键值
typedef int shmid_t, SHMID_t; // 共享内存id
typedef key_t semkey_t, SEMKEY_t; // 信号量键值
typedef int semid_t, SEMID_t; // 信号量id
typedef key_t msgkey_t, MSGKEY_t; // 消息队列键值
typedef int msgid_t, MSGID_t; // 消息队列id
/*!
* 无效的共享内存映射地址(-1)
*/
#define SHM_ADDR_INVALID ((void *)(-1))
/*!
* 和windows兼容的布尔类型定义BOOL
*/
typedef int BOOL;
/*! CAUTIOUS
* 如果, 以后站号, 点号类型的数据类型定义发生变化, 则需要修改该行
*
* 站号, 点号类型定义
*/
typedef int32 stn_no_t;
typedef int32 pnt_no_t;
/*!
* 历史数据采样类型定义
*/
typedef i_8 sampling_type_t;
/*!
* 在TRU64上, pthread_t的长度等于8, 而在linux(intel)上, pthread_t的长度
* 等于4, 所以为了兼容, 定义thd_id_t的长度为8个字节, 因此, 在非64位平台
* 上, 使用一个结构来代替
*
* 线程标识符(id)类型定义
*/
#if defined(OS_LINUX) // unix平台(肯定使用posix线程库)
#if SIZE_OF_PTHREAD_T == 8
typedef pthread_t thd_id_t;
#elif SIZE_OF_PTHREAD_T == 4
typedef struct
{
//! 低32位上定义thd_id
pthread_t thd_id;
//! 高32位保留
i_32 reserved;
} thd_id_t;
#endif
#else
#if SIZE_OF_PTHREAD_T == 8
typedef long thd_id_t;
#elif SIZE_OF_PTHREAD_T == 4
typedef struct
{
//! 低32位上定义thd_id
u_32 thd_id;
//! 高32位保留
i_32 reserved;
} thd_id_t;
#endif
#endif
/*!
* 便于移植和修改的数据类型定义.
*
* 网络套接字类型
*/
typedef int socket_t, SOCKET_t;
#define SOCKET_INVALID ((socket_t)-1)
#if defined(OS_LINUX)
#ifndef INVALID_SOCKET
#define INVALID_SOCKET (SOCKET_INVALID)
#endif //end of INVALID_SOCKET
#endif //end of defined(__unix)
/*!
* ip地址定义
*/
//typedef u_32 ip_addr_t;
#endif //__TYPEDEF_H__DFJGLWREPUEPISXVCMAFGLJHQEWPYRPEOAJLKGZNCNALDHFPQEWUPOQRJSJHGAQ
/*************************************************************************************
*
* $Revision: 1.2 $
*
* $Date: 2006/08/04 03:37:33 $
*
* $State: Exp $
*
* $Log: typedef.h,v $
* Revision 1.2 2006/08/04 03:37:33 zhuzhenhua
* no message
*
* Revision 1.11 2003/09/19 07:55:15 scada
* no message
*
* Revision 1.10 2003/08/01 06:36:19 scada
* 在Win32平台上借用__int64定义64bit的整数
*
* Revision 1.9 2003/07/01 01:31:01 scada
* no message
*
* Revision 1.8 2003/06/05 03:56:15 jehu
* 将注释修改为符合doxgen工具提取开发文档
*
* Revision 1.7 2003/01/10 10:38:40 scada
* no message
*
* Revision 1.6 2003/01/02 03:14:32 scada
* trim substitution line
*
* Revision 1.5 2002/12/04 07:47:36 scada
* for NT
*
* Revision 1.4 2002/10/07 05:37:59 harold
* cvs up -d
*
* Revision 1.3 2002/09/18 09:13:38 harold
* revised errors and warning under solaris/CC environment
*
* Revision 1.2 2002/08/26 02:07:32 harold
* 重新定义stn_no_t, pnt_no_t, sampling_type_t, 由无符号整数-->有符号整数
*
* Revision 1.1.1.1 2002/08/21 07:16:36 harold
* temporarily import
*
* Revision 1.9 2002/03/20 03:39:57 harold
* no message
*
* Revision 1.2 2002/03/17 15:33:52 harold
* changed for iccp v0.9
*
* Revision 1.1.1.1 2002/03/15 13:43:17 harold
* no message
*
* Revision 1.1.1.1 2002/03/15 08:17:07 harold
* no message
*
* Revision 1.8 2002/03/05 03:01:34 harold
* *** empty log message ***
*
* Revision 1.7 2002/03/04 14:04:39 harold
* *** empty log message ***
*
* Revision 1.6 2002/01/15 10:37:07 harold
* no message
*
* Revision 1.5 2002/01/15 10:25:42 harold
* no message
*
* Revision 1.4 2002/01/15 10:20:11 harold
* no message
*
* Revision 1.3 2002/01/15 09:55:29 harold
* no message
*
* Revision 1.2 2002/01/15 08:44:34 harold
* 添加线程id类型定义thd_id_t
*
* Revision 1.1.1.1 2001/12/24 09:33:23 harold
* no message
*
* Revision 1.2 2001/12/24 06:39:57 harold
* 为了适应不同的操作系统, 不同的CPU类型, 及不同的编译器,
* 对头文件做了相应的修改, 同时添加了一些宏定义, 如:
* HAVE__FUNCTION__, __OS__, __PLATFORM__,__TIMEZONE__等等.
*
*
*
************************************************************************************/