Merge pull request #3 from lioncash/include

General: Amend includes where applicable
This commit is contained in:
Phillip Stephens 2019-09-03 00:36:09 -07:00 committed by GitHub
commit dff87c2c6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 19 deletions

View File

@ -1,10 +1,13 @@
#pragma once #pragma once
#include "Common.hpp"
#include "Socket.hpp"
#include <thread>
#include <mutex>
#include <condition_variable> #include <condition_variable>
#include <cstddef>
#include <functional>
#include <mutex>
#include <thread>
#include "jbus/Common.hpp"
#include "jbus/Socket.hpp"
namespace jbus { namespace jbus {

View File

@ -1,12 +1,15 @@
#pragma once #pragma once
#include "Common.hpp" #include <cstdint>
#include "Socket.hpp" #include <memory>
#include <thread>
#include <queue>
#include <mutex> #include <mutex>
#include <queue>
#include <thread>
#include "jbus/Socket.hpp"
namespace jbus { namespace jbus {
class Endpoint;
/** Server interface for accepting incoming connections from GBA emulator instances. */ /** Server interface for accepting incoming connections from GBA emulator instances. */
class Listener { class Listener {
@ -33,6 +36,7 @@ public:
* @return Endpoint instance, ready to issue commands. */ * @return Endpoint instance, ready to issue commands. */
std::unique_ptr<Endpoint> accept(); std::unique_ptr<Endpoint> accept();
Listener();
~Listener(); ~Listener();
}; };

View File

@ -1,17 +1,14 @@
#pragma once #pragma once
#include <sys/types.h> #include <cstddef>
#include <fcntl.h> #include <cstdint>
#include <string> #include <string>
#include <memory.h>
#ifdef _WIN32 #ifdef _WIN32
#include <BaseTsd.h> #include <BaseTsd.h>
typedef UINT_PTR SOCKET; using SOCKET = UINT_PTR;
#endif #endif
#include "Common.hpp"
struct sockaddr_in; struct sockaddr_in;
namespace jbus::net { namespace jbus::net {

View File

@ -1,7 +1,13 @@
#include "jbus/Endpoint.hpp" #include "jbus/Endpoint.hpp"
#include <cstring>
#define LOG_TRANSFER 0 #define LOG_TRANSFER 0
#if LOG_TRANSFER
#include <cstdio>
#endif
namespace jbus { namespace jbus {
#define ROUND_UP_8(val) (((val) + 7) & ~7) #define ROUND_UP_8(val) (((val) + 7) & ~7)

View File

@ -1,8 +1,14 @@
#include "jbus/Listener.hpp" #include "jbus/Listener.hpp"
#include "jbus/Common.hpp"
#include "jbus/Endpoint.hpp" #include "jbus/Endpoint.hpp"
#define LOG_LISTENER 0 #define LOG_LISTENER 0
#if LOG_LISTENER
#include <cstdio>
#endif
namespace jbus { namespace jbus {
void Listener::listenerProc() { void Listener::listenerProc() {
@ -94,6 +100,8 @@ std::unique_ptr<Endpoint> Listener::accept() {
return {}; return {};
} }
Listener::Listener() = default;
Listener::~Listener() { stop(); } Listener::~Listener() { stop(); }
} // namespace jbus } // namespace jbus

View File

@ -1,13 +1,19 @@
#include "jbus/Socket.hpp" #include "jbus/Socket.hpp"
#include <cstdio>
#include <cstring>
#ifndef _WIN32 #ifndef _WIN32
#include <sys/socket.h> #include <cerrno>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <arpa/inet.h> #include <sys/socket.h>
#include <netdb.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <cerrno>
#else #else
#include <WinSock2.h> #include <WinSock2.h>
#include <Ws2tcpip.h> #include <Ws2tcpip.h>
@ -100,7 +106,7 @@ void Socket::setRemoteSocket(int remSocket) noexcept {
} }
#ifdef _WIN32 #ifdef _WIN32
Socket::EResult Socket::LastWSAError() { Socket::EResult Socket::LastWSAError() noexcept {
switch (WSAGetLastError()) { switch (WSAGetLastError()) {
case WSAEWOULDBLOCK: case WSAEWOULDBLOCK:
case WSAEALREADY: case WSAEALREADY: