mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-02-16 02:21:07 +00:00
Add vita environment (#22)
* vita: initial port * vita: implement events, enable input thread * vita: gethostbyname * vita: Enable audio * vita: Fix thread crash on discoonect process * vita: Handle cannot create thread * vita: now use newlib's socket apis * vita: Refactoring for moonlight-stream/moonlight-common-c * Fix review things https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2436093 - vita may not support IPv6; so add LC_ASSERT them. - define inet_ntop to sceNetInetNtop - guard about failure of sceKernelCreateMutex or sceKernelCreateCond - remove meanless macros https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2444677 - !*mutex to *mutex - remove useless LC_ASSERT then change to use inet_ntop in vita system not defined `sockaddr_in6`, so just use `sockaddr_in` instead this. https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2445642 - define sin6_addr
This commit is contained in:
committed by
Cameron Gutman
parent
293c6a7274
commit
ba27e97698
@@ -14,6 +14,16 @@
|
||||
typedef int SOCK_RET;
|
||||
typedef int SOCKADDR_LEN;
|
||||
|
||||
#else
|
||||
#if defined(__vita__)
|
||||
#include <psp2/net/net.h>
|
||||
#include <enet/enet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -24,6 +34,7 @@ typedef int SOCKADDR_LEN;
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#define ioctlsocket ioctl
|
||||
#define LastSocketError() errno
|
||||
@@ -36,6 +47,17 @@ typedef ssize_t SOCK_RET;
|
||||
typedef socklen_t SOCKADDR_LEN;
|
||||
#endif
|
||||
|
||||
#if defined(__vita__)
|
||||
#define TCP_NODELAY SCE_NET_TCP_NODELAY
|
||||
#define INADDR_ANY SCE_NET_INADDR_ANY
|
||||
|
||||
#define sockaddr_in6 sockaddr_in
|
||||
#define sin6_addr sin_addr
|
||||
#define sin6_port sin_port
|
||||
#define INET6_ADDRSTRLEN 128
|
||||
#define inet_ntop sceNetInetNtop
|
||||
#endif
|
||||
|
||||
#define LastSocketFail() ((LastSocketError() != 0) ? LastSocketError() : -1)
|
||||
|
||||
// IPv6 addresses have 2 extra characters for URL escaping
|
||||
@@ -48,4 +70,4 @@ int enableNoDelay(SOCKET s);
|
||||
int recvUdpSocket(SOCKET s, char* buffer, int size);
|
||||
void shutdownTcpSocket(SOCKET s);
|
||||
void setRecvTimeout(SOCKET s, int timeoutSec);
|
||||
void closeSocket(SOCKET s);
|
||||
void closeSocket(SOCKET s);
|
||||
|
||||
Reference in New Issue
Block a user