mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-09 20:43:34 -04:00
Reformat
This commit is contained in:
parent
19c9d44690
commit
09c6002bc1
@ -8,11 +8,13 @@
|
||||
#include "tlib/net.hpp"
|
||||
#include "tlib/malloc.hpp"
|
||||
|
||||
tlib::packet::packet() : fd(0), payload(nullptr), index(0) {
|
||||
tlib::packet::packet()
|
||||
: fd(0), payload(nullptr), index(0) {
|
||||
//Nothing else to init
|
||||
}
|
||||
|
||||
tlib::packet::packet(packet&& rhs) : fd(rhs.fd), payload(rhs.payload), index(rhs.index) {
|
||||
tlib::packet::packet(packet&& rhs)
|
||||
: fd(rhs.fd), payload(rhs.payload), index(rhs.index) {
|
||||
rhs.payload = nullptr;
|
||||
}
|
||||
|
||||
@ -125,7 +127,7 @@ std::expected<size_t> tlib::connect(size_t socket_fd, tlib::ip::address server,
|
||||
int64_t code;
|
||||
asm volatile("mov rax, 0x3008; mov rbx, %[socket]; mov rcx, %[ip]; mov rdx, %[port]; int 50; mov %[code], rax"
|
||||
: [code] "=m"(code)
|
||||
: [socket] "g" (socket_fd), [ip] "g" (size_t(server.raw_address)), [port] "g" (port)
|
||||
: [socket] "g"(socket_fd), [ip] "g"(size_t(server.raw_address)), [port] "g"(port)
|
||||
: "rax", "rbx", "rcx", "rdx");
|
||||
|
||||
if (code < 0) {
|
||||
@ -139,7 +141,7 @@ std::expected<void> tlib::disconnect(size_t socket_fd) {
|
||||
int64_t code;
|
||||
asm volatile("mov rax, 0x3009; mov rbx, %[socket]; int 50; mov %[code], rax"
|
||||
: [code] "=m"(code)
|
||||
: [socket] "g" (socket_fd)
|
||||
: [socket] "g"(socket_fd)
|
||||
: "rax", "rbx");
|
||||
|
||||
if (code < 0) {
|
||||
@ -192,7 +194,7 @@ std::expected<tlib::packet> tlib::wait_for_packet(size_t socket_fd, size_t ms) {
|
||||
}
|
||||
|
||||
tlib::socket::socket(socket_domain domain, socket_type type, socket_protocol protocol)
|
||||
: domain(domain), type(type), protocol(protocol), fd(0), error_code(0) {
|
||||
: domain(domain), type(type), protocol(protocol), fd(0), error_code(0) {
|
||||
auto open_status = tlib::socket_open(domain, type, protocol);
|
||||
|
||||
if (open_status.valid()) {
|
||||
@ -205,7 +207,7 @@ tlib::socket::socket(socket_domain domain, socket_type type, socket_protocol pro
|
||||
}
|
||||
|
||||
tlib::socket::~socket() {
|
||||
if(connected()){
|
||||
if (connected()) {
|
||||
disconnect();
|
||||
}
|
||||
|
||||
@ -281,13 +283,13 @@ void tlib::socket::disconnect() {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!connected()){
|
||||
if (!connected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto status = tlib::disconnect(fd);
|
||||
|
||||
if(status){
|
||||
if (status) {
|
||||
_connected = false;
|
||||
} else {
|
||||
error_code = status.error();
|
||||
|
Loading…
x
Reference in New Issue
Block a user