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.
		
		
		
		
		
			
		
			
				
	
	
		
			155 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C
		
	
			
		
		
	
	
			155 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C
		
	
| /*************************************************
 | |
|   Copyright (C), 2023--
 | |
|   文件名:     typedef.h
 | |
|   作      者:     wangbo
 | |
|   日      期:     2023-08-24
 | |
| 
 | |
|   描      叙:   本文件主要提供基本的 类型申明
 | |
|   函数列表: 无
 | |
|   历史记录:
 | |
|   1:
 | |
|     日期 : 2023-08-24
 | |
|         作者 : wangbo
 | |
|     描叙 : 新创建文件
 | |
| 
 | |
| 
 | |
| *************************************************/
 | |
| #ifndef _TPYEDEF_H
 | |
| #define _TPYEDEF_H
 | |
| #ifdef __cplusplus
 | |
| #if __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| #endif /* __cplusplus */
 | |
| 
 | |
| #include <pthread.h>
 | |
| #include <stdio.h>
 | |
| #include <stdlib.h>
 | |
| #include <string.h>
 | |
| #include <errno.h>
 | |
| #include <assert.h>
 | |
| #include <fcntl.h>
 | |
| //#include <stdint.h>
 | |
| #include <sys/stat.h>
 | |
| #include <stdarg.h>
 | |
| #include <time.h>
 | |
| #include <signal.h>
 | |
| #include <limits.h>
 | |
| #include <sys/types.h>
 | |
| #include <sys/wait.h>
 | |
| #include <ctype.h>
 | |
| #include <math.h>
 | |
| #include <fnmatch.h>
 | |
| 
 | |
| #include <unistd.h>
 | |
| #include <dirent.h>
 | |
| #include <sys/file.h> // flock函数
 | |
| 
 | |
| /************************************************************************
 | |
| 网络相关
 | |
| ************************************************************************/
 | |
| #include <sys/types.h>
 | |
| #include <sys/socket.h>
 | |
| #include <netinet/in.h>
 | |
| #include <arpa/inet.h>
 | |
| #include <sys/time.h>
 | |
| #include <netdb.h>
 | |
| #include <sys/ioctl.h>
 | |
| #include <net/if.h>
 | |
| #include <sys/utsname.h>
 | |
| #include <netinet/in.h>
 | |
| #include <netinet/ip.h>
 | |
| #include <netinet/tcp.h> // tcp keepalive
 | |
| #include <netinet/ip_icmp.h>
 | |
| #include <netpacket/packet.h>
 | |
| #include <net/ethernet.h>
 | |
| #include <net/if_arp.h>
 | |
| #include <netdb.h>
 | |
| #include <arpa/inet.h>
 | |
| 
 | |
| #define ZERO_INIT {}
 | |
| #define NFDS_FOR_SELECT(sock) ((sock) + 1)
 | |
| 
 | |
| #ifndef  TRUE
 | |
| #define  TRUE                       1
 | |
| #endif
 | |
| 
 | |
| #ifndef  FALSE
 | |
| #define  FALSE                      0
 | |
| #endif
 | |
| 
 | |
| #ifndef SUCCESS
 | |
| #define SUCCESS                     0
 | |
| #endif
 | |
| 
 | |
| #ifndef FAILURE
 | |
| #define FAILURE                     -1
 | |
| #endif
 | |
| 
 | |
| // 整型环境, 内核使用的类型
 | |
| typedef char                s8;
 | |
| typedef unsigned char       u8;
 | |
| typedef short               s16;
 | |
| typedef unsigned short      u16;
 | |
| typedef int                 s32;
 | |
| typedef unsigned int        u32;
 | |
| #if defined WIN32
 | |
| typedef __int64             s64;
 | |
| typedef unsigned __int64    u64;
 | |
| #else
 | |
| typedef long long           s64;
 | |
| typedef unsigned long long  u64;
 | |
| #endif
 | |
| 
 | |
| typedef int         TIMER_T;
 | |
| typedef int         socket_t;
 | |
| typedef pid_t       ThreadId_T;
 | |
| typedef pid_t       ProcessId_T;                                  /// < 进程id
 | |
| typedef pthread_t   Thread_T;
 | |
| typedef pid_t       Process_T;
 | |
| typedef void *      ThreadResult_T;
 | |
| typedef void *      ThreadParam_T;
 | |
| typedef unsigned int  TimeTick_T;
 | |
| typedef int DevHandle_T;
 | |
| typedef int Semaphore_T;
 | |
| 
 | |
| #define ThreadProcSpec
 | |
| #define INVALID_THREAD (Thread_T)(~0)
 | |
| #define INVALID_SOCKET (~0)
 | |
| #define INVALID_TIMER   (-1)
 | |
| 
 | |
| typedef pthread_mutex_t     Mutex_T;
 | |
| 
 | |
| 
 | |
| /// @brief 线程函数指针类型
 | |
| typedef ThreadResult_T (ThreadProcSpec* ThreadProc_T)(ThreadParam_T param);
 | |
| 
 | |
| // max / min
 | |
| #ifndef MAX
 | |
| #define MAX(a,b) ((a) > (b) ? (a) : (b))
 | |
| #endif
 | |
| #ifndef MIN
 | |
| #define MIN(a,b) ((a) > (b) ? (b) : (a))
 | |
| #endif
 | |
| 
 | |
| 
 | |
| #ifndef setbitEx
 | |
| #ifndef NBBYTE          //the BSD family defines NBBY
 | |
| #define NBBYTE  8       //8 bits per byte
 | |
| #endif
 | |
| #define setbit(a, i)    (((unsigned char *)a)[(i)/NBBYTE] |= 1<<((i)%NBBYTE))
 | |
| #define clrbit(a, i)    (((unsigned char *)a)[(i)/NBBYTE] &= ~(1<<((i)%NBBYTE)))
 | |
| #define isset(a, i) (((const unsigned char *)a)[(i)/NBBYTE] & (1<<((i)%NBBYTE)))
 | |
| #define isclr(a, i) ((((const unsigned char *)a)[(i)/NBBYTE] & (1<<((i)%NBBYTE))) == 0)
 | |
| #endif
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| #if __cplusplus
 | |
| }
 | |
| #endif
 | |
| #endif /* __cplusplus */
 | |
| 
 | |
| #endif /*_TPYEDEF_H*/
 | |
| 
 | |
| 
 |