拆分文件
This commit is contained in:
parent
9d77446f68
commit
2a2ae674e6
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,6 +3,8 @@
|
|||||||
!README.txt
|
!README.txt
|
||||||
!version.txt
|
!version.txt
|
||||||
!ssocket.h
|
!ssocket.h
|
||||||
|
!tthread.h
|
||||||
|
!sysenv.h
|
||||||
!*/
|
!*/
|
||||||
!test/client/client.c
|
!test/client/client.c
|
||||||
!test/client/CMakeLists.txt
|
!test/client/CMakeLists.txt
|
||||||
|
44
ssocket.h
44
ssocket.h
@ -7,47 +7,7 @@
|
|||||||
#define SSOCKET_VERSION_MAJOR 1
|
#define SSOCKET_VERSION_MAJOR 1
|
||||||
#define SSOCKET_VERSION_MINOR 0
|
#define SSOCKET_VERSION_MINOR 0
|
||||||
#define SSOCKET_VERSION_PATCH 2
|
#define SSOCKET_VERSION_PATCH 2
|
||||||
|
#include "sysenv.h"
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
|
||||||
#define _OS_WIN 1
|
|
||||||
//define something for Windows (32-bit and 64-bit, this part is common)
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define _OS_WIN64 1
|
|
||||||
//define something for Windows (64-bit only)
|
|
||||||
#else
|
|
||||||
#define _OS_WIN32 1
|
|
||||||
//define something for Windows (32-bit only)
|
|
||||||
#endif
|
|
||||||
#elif __APPLE__
|
|
||||||
#define _OS_APPLE 1
|
|
||||||
#include <TargetConditionals.h>
|
|
||||||
#if TARGET_IPHONE_SIMULATOR
|
|
||||||
#define _OS_APPLE_SIM 1
|
|
||||||
// iOS, tvOS, or watchOS Simulator
|
|
||||||
#elif TARGET_OS_MACCATALYST
|
|
||||||
#define _OS_APPLE_CATA 1
|
|
||||||
// Mac's Catalyst (ports iOS API into Mac, like UIKit).
|
|
||||||
#elif TARGET_OS_IPHONE
|
|
||||||
#define _OS_APPLE_PHO 1
|
|
||||||
// iOS, tvOS, or watchOS device
|
|
||||||
#elif TARGET_OS_MAC
|
|
||||||
#define _OS_APPLE_MAC 1
|
|
||||||
// Other kinds of Apple platforms
|
|
||||||
#else
|
|
||||||
# error "Unknown Apple platform"
|
|
||||||
#endif
|
|
||||||
#elif __linux__
|
|
||||||
#define _OS_LINUX 1
|
|
||||||
// linux
|
|
||||||
#elif __unix__ // all unices not caught above
|
|
||||||
#define _OS_UNIX 1
|
|
||||||
// Unix
|
|
||||||
#elif defined(_POSIX_VERSION)
|
|
||||||
#define _OS_POSIX 1
|
|
||||||
// POSIX
|
|
||||||
#else
|
|
||||||
# error "Unknown compiler"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if _OS_WIN
|
#if _OS_WIN
|
||||||
#define WIN_PART 1
|
#define WIN_PART 1
|
||||||
@ -73,6 +33,8 @@
|
|||||||
//#define INVALID_SOCKET (SOCKET)(~0)
|
//#define INVALID_SOCKET (SOCKET)(~0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "tthread.h"
|
||||||
|
|
||||||
#ifndef ZZY_SLEEP
|
#ifndef ZZY_SLEEP
|
||||||
#define ZZY_SLEEP
|
#define ZZY_SLEEP
|
||||||
#if WIN_PART
|
#if WIN_PART
|
||||||
|
45
sysenv.h
Normal file
45
sysenv.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#ifndef _SYSENV_H_
|
||||||
|
#define _SYSENV_H_
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||||
|
#define _OS_WIN 1
|
||||||
|
//define something for Windows (32-bit and 64-bit, this part is common)
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define _OS_WIN64 1
|
||||||
|
//define something for Windows (64-bit only)
|
||||||
|
#else
|
||||||
|
#define _OS_WIN32 1
|
||||||
|
//define something for Windows (32-bit only)
|
||||||
|
#endif
|
||||||
|
#elif __APPLE__
|
||||||
|
#define _OS_APPLE 1
|
||||||
|
#include <TargetConditionals.h>
|
||||||
|
#if TARGET_IPHONE_SIMULATOR
|
||||||
|
#define _OS_APPLE_SIM 1
|
||||||
|
// iOS, tvOS, or watchOS Simulator
|
||||||
|
#elif TARGET_OS_MACCATALYST
|
||||||
|
#define _OS_APPLE_CATA 1
|
||||||
|
// Mac's Catalyst (ports iOS API into Mac, like UIKit).
|
||||||
|
#elif TARGET_OS_IPHONE
|
||||||
|
#define _OS_APPLE_PHO 1
|
||||||
|
// iOS, tvOS, or watchOS device
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
#define _OS_APPLE_MAC 1
|
||||||
|
// Other kinds of Apple platforms
|
||||||
|
#else
|
||||||
|
# error "Unknown Apple platform"
|
||||||
|
#endif
|
||||||
|
#elif __linux__
|
||||||
|
#define _OS_LINUX 1
|
||||||
|
// linux
|
||||||
|
#elif __unix__ // all unices not caught above
|
||||||
|
#define _OS_UNIX 1
|
||||||
|
// Unix
|
||||||
|
#elif defined(_POSIX_VERSION)
|
||||||
|
#define _OS_POSIX 1
|
||||||
|
// POSIX
|
||||||
|
#else
|
||||||
|
# error "Unknown compiler"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //_SYSENV_H_
|
36
tthread.h
Normal file
36
tthread.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef _TTHERAD_H_
|
||||||
|
#define _TTHREAD_H_
|
||||||
|
|
||||||
|
#include "sysenv.h"
|
||||||
|
#if _OS_WIN
|
||||||
|
#include <windows.h>
|
||||||
|
#define TID LPDWORD
|
||||||
|
|
||||||
|
#elif _OS_LINUX
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#define TID pthread_t
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Not Supported Operator System"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static inline void tthread_create(TID* tid,void(*thread_func)(void*), void* data) {
|
||||||
|
#if _OS_WIN
|
||||||
|
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_func, data, 0, tid);
|
||||||
|
#elif _OS_LINUX
|
||||||
|
pthread_create(tid, 0, (void*(*)(void*))thread_func, data);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //_TTHREAD_H_
|
@ -5,3 +5,6 @@ v1.0.2 ssocket
|
|||||||
添加make_sock,make_sock_tcp4,make_sock_tcp6,make_sock_udp4,make_sock_udp6函数
|
添加make_sock,make_sock_tcp4,make_sock_tcp6,make_sock_udp4,make_sock_udp6函数
|
||||||
添加若干内置函数(以_func形式)
|
添加若干内置函数(以_func形式)
|
||||||
兼容老版本
|
兼容老版本
|
||||||
|
v1.0.3 ssocket
|
||||||
|
使用多头文件分离的方法将系统环境,线程,套接字分成三个文档
|
||||||
|
暂时兼容老版本,将在下个版本取消对前版本的兼容性
|
Loading…
x
Reference in New Issue
Block a user