mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 14:03:11 -07:00
Minor Style Fixes
This commit is contained in:
parent
042e02eb3e
commit
49d65ad14a
32 changed files with 248 additions and 304 deletions
|
@ -23,7 +23,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_audio_receiver_init(ChiakiAudioReceiver *au
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT void chiaki_audio_receiver_fini(ChiakiAudioReceiver *audio_receiver)
|
||||
{
|
||||
#ifdef CHIAKI_LIB_ENABLE_OPUS
|
||||
|
@ -32,7 +31,6 @@ CHIAKI_EXPORT void chiaki_audio_receiver_fini(ChiakiAudioReceiver *audio_receive
|
|||
chiaki_mutex_fini(&audio_receiver->mutex);
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT void chiaki_audio_receiver_stream_info(ChiakiAudioReceiver *audio_receiver, ChiakiAudioHeader *audio_header)
|
||||
{
|
||||
chiaki_mutex_lock(&audio_receiver->mutex);
|
||||
|
@ -79,15 +77,15 @@ CHIAKI_EXPORT void chiaki_audio_receiver_av_packet(ChiakiAudioReceiver *audio_re
|
|||
if(packet->data_size != (size_t)unit_size * (size_t)packet->units_in_frame_total)
|
||||
{
|
||||
CHIAKI_LOGE(audio_receiver->log, "Audio AV Packet size mismatch %#llx vs %#llx",
|
||||
(unsigned long long)packet->data_size,
|
||||
(unsigned long long)(unit_size * packet->units_in_frame_total));
|
||||
(unsigned long long)packet->data_size,
|
||||
(unsigned long long)(unit_size * packet->units_in_frame_total));
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet->frame_index > (1 << 15))
|
||||
audio_receiver->frame_index_startup = false;
|
||||
|
||||
for(size_t i=0; i<source_units_count+fec_units_count; i++)
|
||||
for(size_t i = 0; i < source_units_count + fec_units_count; i++)
|
||||
{
|
||||
ChiakiSeqNum16 frame_index;
|
||||
if(i < source_units_count)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
// Implementations taken from
|
||||
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_size, char *out, size_t out_size)
|
||||
{
|
||||
const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
@ -23,11 +22,11 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
|
|||
// these three 8-bit (ASCII) characters become one 24-bit number
|
||||
n = ((uint32_t)in[x]) << 16;
|
||||
|
||||
if((x+1) < in_size)
|
||||
n += ((uint32_t)in[x+1]) << 8;
|
||||
if((x + 1) < in_size)
|
||||
n += ((uint32_t)in[x + 1]) << 8;
|
||||
|
||||
if((x+2) < in_size)
|
||||
n += in[x+2];
|
||||
if((x + 2) < in_size)
|
||||
n += in[x + 2];
|
||||
|
||||
// this 24-bit number gets separated into four 6-bit numbers
|
||||
n0 = (uint8_t)(n >> 18) & 63;
|
||||
|
@ -46,7 +45,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
|
|||
|
||||
// if we have only two bytes available, then their encoding is
|
||||
// spread out over three chars
|
||||
if((x+1) < in_size)
|
||||
if((x + 1) < in_size)
|
||||
{
|
||||
if(result_index >= out_size)
|
||||
return CHIAKI_ERR_BUF_TOO_SMALL;
|
||||
|
@ -55,7 +54,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
|
|||
|
||||
// if we have all three bytes available, then their encoding is spread
|
||||
// out over four characters
|
||||
if((x+2) < in_size)
|
||||
if((x + 2) < in_size)
|
||||
{
|
||||
if(result_index >= out_size)
|
||||
return CHIAKI_ERR_BUF_TOO_SMALL;
|
||||
|
@ -65,9 +64,9 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
|
|||
|
||||
// create and add padding that is required if we did not have a multiple of 3
|
||||
// number of characters available
|
||||
if (pad_count > 0)
|
||||
if(pad_count > 0)
|
||||
{
|
||||
for (; pad_count < 3; pad_count++)
|
||||
for(; pad_count < 3; pad_count++)
|
||||
{
|
||||
if(result_index >= out_size)
|
||||
return CHIAKI_ERR_BUF_TOO_SMALL;
|
||||
|
@ -80,25 +79,22 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define WHITESPACE 64
|
||||
#define EQUALS 65
|
||||
#define INVALID 66
|
||||
#define EQUALS 65
|
||||
#define INVALID 66
|
||||
|
||||
static const unsigned char d[] = {
|
||||
66,66,66,66,66,66,66,66,66,66,64,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
|
||||
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,62,66,66,66,63,52,53,
|
||||
54,55,56,57,58,59,60,61,66,66,66,65,66,66,66, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,66,66,66,66,66,66,26,27,28,
|
||||
29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,66,66,
|
||||
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
|
||||
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
|
||||
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
|
||||
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
|
||||
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
|
||||
66,66,66,66,66,66
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 64, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 62, 66, 66, 66, 63, 52, 53,
|
||||
54, 55, 56, 57, 58, 59, 60, 61, 66, 66, 66, 65, 66, 66, 66, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 66, 66, 66, 66, 66, 66, 26, 27, 28,
|
||||
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66
|
||||
};
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_decode(const char *in, size_t in_size, uint8_t *out, size_t *out_size)
|
||||
|
@ -108,17 +104,17 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_decode(const char *in, size_t in_siz
|
|||
uint32_t buf = 0;
|
||||
size_t len = 0;
|
||||
|
||||
while (in < end)
|
||||
while(in < end)
|
||||
{
|
||||
unsigned char c = d[(size_t)(*in++)];
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case WHITESPACE:
|
||||
continue; // skip whitespace
|
||||
continue; // skip whitespace
|
||||
case INVALID:
|
||||
return CHIAKI_ERR_INVALID_DATA; // invalid input
|
||||
case EQUALS: // pad character, end of data
|
||||
return CHIAKI_ERR_INVALID_DATA; // invalid input
|
||||
case EQUALS: // pad character, end of data
|
||||
in = end;
|
||||
continue;
|
||||
default:
|
||||
|
@ -132,7 +128,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_decode(const char *in, size_t in_siz
|
|||
*(out++) = (unsigned char)((buf >> 16) & 0xff);
|
||||
*(out++) = (unsigned char)((buf >> 8) & 0xff);
|
||||
*(out++) = (unsigned char)(buf & 0xff);
|
||||
buf = 0; iter = 0;
|
||||
buf = 0;
|
||||
iter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
|
||||
|
||||
#include <chiaki/common.h>
|
||||
#include <chiaki/random.h>
|
||||
#include <chiaki/fec.h>
|
||||
#include <chiaki/random.h>
|
||||
|
||||
#include <galois.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
|
@ -98,7 +98,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_lib_init()
|
|||
WORD wsa_version = MAKEWORD(2, 2);
|
||||
WSADATA wsa_data;
|
||||
int err = WSAStartup(wsa_version, &wsa_data);
|
||||
if (err != 0)
|
||||
if(err != 0)
|
||||
return CHIAKI_ERR_NETWORK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,7 @@ static void *congestion_control_thread_func(void *user)
|
|||
packet.received = (uint16_t)received;
|
||||
packet.lost = (uint16_t)lost;
|
||||
CHIAKI_LOGV(control->takion->log, "Sending Congestion Control Packet, received: %u, lost: %u",
|
||||
(unsigned int)packet.received, (unsigned int)packet.lost);
|
||||
(unsigned int)packet.received, (unsigned int)packet.lost);
|
||||
chiaki_takion_send_congestion(control->takion, &packet);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ CHIAKI_EXPORT void chiaki_controller_state_set_idle(ChiakiControllerState *state
|
|||
state->right_x = 0;
|
||||
state->right_y = 0;
|
||||
state->touch_id_next = 0;
|
||||
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
{
|
||||
state->touches[i].id = -1;
|
||||
state->touches[i].x = 0;
|
||||
|
@ -24,7 +24,7 @@ CHIAKI_EXPORT void chiaki_controller_state_set_idle(ChiakiControllerState *state
|
|||
|
||||
CHIAKI_EXPORT int8_t chiaki_controller_state_start_touch(ChiakiControllerState *state, uint16_t x, uint16_t y)
|
||||
{
|
||||
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
{
|
||||
if(state->touches[i].id < 0)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ CHIAKI_EXPORT int8_t chiaki_controller_state_start_touch(ChiakiControllerState *
|
|||
|
||||
CHIAKI_EXPORT void chiaki_controller_state_stop_touch(ChiakiControllerState *state, uint8_t id)
|
||||
{
|
||||
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
{
|
||||
if(state->touches[i].id == id)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ CHIAKI_EXPORT void chiaki_controller_state_stop_touch(ChiakiControllerState *sta
|
|||
CHIAKI_EXPORT void chiaki_controller_state_set_touch_pos(ChiakiControllerState *state, uint8_t id, uint16_t x, uint16_t y)
|
||||
{
|
||||
id &= TOUCH_ID_MASK;
|
||||
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
{
|
||||
if(state->touches[i].id == id)
|
||||
{
|
||||
|
@ -64,8 +64,8 @@ CHIAKI_EXPORT void chiaki_controller_state_set_touch_pos(ChiakiControllerState *
|
|||
}
|
||||
}
|
||||
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define ABS(a) ((a) > 0 ? (a) : -(a))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define ABS(a) ((a) > 0 ? (a) : -(a))
|
||||
#define MAX_ABS(a, b) (ABS(a) > ABS(b) ? (a) : (b))
|
||||
|
||||
CHIAKI_EXPORT void chiaki_controller_state_or(ChiakiControllerState *out, ChiakiControllerState *a, ChiakiControllerState *b)
|
||||
|
@ -79,7 +79,7 @@ CHIAKI_EXPORT void chiaki_controller_state_or(ChiakiControllerState *out, Chiaki
|
|||
out->right_y = MAX_ABS(a->right_y, b->right_y);
|
||||
|
||||
out->touch_id_next = 0;
|
||||
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
|
||||
{
|
||||
ChiakiControllerTouch *touch = a->touches[i].id >= 0 ? &a->touches[i] : (b->touches[i].id >= 0 ? &b->touches[i] : NULL);
|
||||
if(!touch)
|
||||
|
|
|
@ -501,7 +501,6 @@ static void ctrl_enable_optional_features(ChiakiCtrl *ctrl)
|
|||
ctrl_message_send(ctrl, 0x36, pre_enable, 4);
|
||||
}
|
||||
|
||||
|
||||
static void ctrl_message_received_session_id(ChiakiCtrl *ctrl, uint8_t *payload, size_t payload_size)
|
||||
{
|
||||
if(ctrl->session->ctrl_session_id_received)
|
||||
|
@ -652,7 +651,7 @@ static void ctrl_message_received_keyboard_close(ChiakiCtrl *ctrl, uint8_t *payl
|
|||
chiaki_session_send_event(ctrl->session, &keyboard_event);
|
||||
}
|
||||
|
||||
static void ctrl_message_received_keyboard_text_change(ChiakiCtrl* ctrl, uint8_t* payload, size_t payload_size)
|
||||
static void ctrl_message_received_keyboard_text_change(ChiakiCtrl *ctrl, uint8_t *payload, size_t payload_size)
|
||||
{
|
||||
assert(payload_size >= sizeof(CtrlKeyboardTextResponseMessage));
|
||||
|
||||
|
@ -676,7 +675,8 @@ static void ctrl_message_received_keyboard_text_change(ChiakiCtrl* ctrl, uint8_t
|
|||
free(buffer);
|
||||
}
|
||||
|
||||
typedef struct ctrl_response_t {
|
||||
typedef struct ctrl_response_t
|
||||
{
|
||||
bool server_type_valid;
|
||||
uint8_t rp_server_type[0x10];
|
||||
bool success;
|
||||
|
@ -742,7 +742,6 @@ static ChiakiErrorCode ctrl_connect(ChiakiCtrl *ctrl)
|
|||
if(err != CHIAKI_ERR_SUCCESS)
|
||||
CHIAKI_LOGE(session->log, "Failed to set ctrl socket to non-blocking: %s", chiaki_error_string(err));
|
||||
|
||||
|
||||
chiaki_mutex_unlock(&ctrl->notif_mutex);
|
||||
err = chiaki_stop_pipe_connect(&ctrl->notif_pipe, sock, sa, addr->ai_addrlen);
|
||||
chiaki_mutex_lock(&ctrl->notif_mutex);
|
||||
|
|
|
@ -79,7 +79,6 @@ CHIAKI_EXPORT void chiaki_ecdh_fini(ChiakiECDH *ecdh)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_set_local_key(ChiakiECDH *ecdh, const uint8_t *private_key, size_t private_key_size, const uint8_t *public_key, size_t public_key_size)
|
||||
{
|
||||
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
|
||||
|
@ -89,24 +88,19 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_set_local_key(ChiakiECDH *ecdh, const
|
|||
|
||||
// public
|
||||
int r = 0;
|
||||
r = mbedtls_ecp_point_read_binary(&ecdh->ctx.grp, &ecdh->ctx.Q,
|
||||
public_key, public_key_size);
|
||||
if(r != 0 ){
|
||||
r = mbedtls_ecp_point_read_binary(&ecdh->ctx.grp, &ecdh->ctx.Q, public_key, public_key_size);
|
||||
if(r != 0)
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
// secret
|
||||
r = mbedtls_mpi_read_binary(&ecdh->ctx.d, private_key, private_key_size);
|
||||
if(r != 0 ){
|
||||
if(r != 0)
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
// regen key
|
||||
r = mbedtls_ecdh_gen_public(&ecdh->ctx.grp, &ecdh->ctx.d,
|
||||
&ecdh->ctx.Q, mbedtls_ctr_drbg_random, &ecdh->drbg);
|
||||
if(r != 0 ){
|
||||
r = mbedtls_ecdh_gen_public(&ecdh->ctx.grp, &ecdh->ctx.d, &ecdh->ctx.Q, mbedtls_ctr_drbg_random, &ecdh->drbg);
|
||||
if(r != 0)
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
#else
|
||||
|
|
|
@ -150,7 +150,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_frame_processor_put_unit(ChiakiFrameProcess
|
|||
CHIAKI_LOGE(frame_processor->log, "Packet's unit index is too high");
|
||||
return CHIAKI_ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
|
||||
if(!packet->data_size)
|
||||
{
|
||||
CHIAKI_LOGW(frame_processor->log, "Unit is empty");
|
||||
|
@ -162,7 +162,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_frame_processor_put_unit(ChiakiFrameProcess
|
|||
CHIAKI_LOGW(frame_processor->log, "Unit is bigger than pre-calculated size!");
|
||||
return CHIAKI_ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
|
||||
ChiakiFrameUnit *unit = frame_processor->unit_slots + packet->unit_index;
|
||||
if(unit->data_size)
|
||||
{
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
#define KEY_BUF_CHUNK_SIZE 0x1000
|
||||
|
||||
|
||||
static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index, const uint8_t *handshake_key, const uint8_t *ecdh_secret);
|
||||
|
||||
static void *gkcrypt_thread_func(void *user);
|
||||
|
@ -110,7 +108,6 @@ CHIAKI_EXPORT void chiaki_gkcrypt_fini(ChiakiGKCrypt *gkcrypt)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index, const uint8_t *handshake_key, const uint8_t *ecdh_secret)
|
||||
{
|
||||
uint8_t data[3 + CHIAKI_HANDSHAKE_KEY_SIZE + 2];
|
||||
|
@ -123,37 +120,41 @@ static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index,
|
|||
|
||||
uint8_t hmac[CHIAKI_GKCRYPT_BLOCK_SIZE*2];
|
||||
size_t hmac_size = sizeof(hmac);
|
||||
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
|
||||
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
|
||||
mbedtls_md_context_t ctx;
|
||||
mbedtls_md_init(&ctx);
|
||||
|
||||
if(mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256) , 1) != 0){
|
||||
if(mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), 1) != 0)
|
||||
{
|
||||
mbedtls_md_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
if(mbedtls_md_hmac_starts(&ctx, ecdh_secret, CHIAKI_ECDH_SECRET_SIZE) != 0){
|
||||
if(mbedtls_md_hmac_starts(&ctx, ecdh_secret, CHIAKI_ECDH_SECRET_SIZE) != 0)
|
||||
{
|
||||
mbedtls_md_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
if(mbedtls_md_hmac_update(&ctx, data, sizeof(data)) != 0){
|
||||
if(mbedtls_md_hmac_update(&ctx, data, sizeof(data)) != 0)
|
||||
{
|
||||
mbedtls_md_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
if(mbedtls_md_hmac_finish(&ctx, hmac) != 0){
|
||||
if(mbedtls_md_hmac_finish(&ctx, hmac) != 0)
|
||||
{
|
||||
mbedtls_md_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
mbedtls_md_free(&ctx);
|
||||
|
||||
#else
|
||||
#else
|
||||
if(!HMAC(EVP_sha256(), ecdh_secret, CHIAKI_ECDH_SECRET_SIZE, data, sizeof(data), hmac, (unsigned int *)&hmac_size))
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
assert(hmac_size == sizeof(hmac));
|
||||
|
||||
memcpy(gkcrypt->key_base, hmac, CHIAKI_GKCRYPT_BLOCK_SIZE);
|
||||
|
@ -220,7 +221,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gen_key_stream(ChiakiGKCrypt *gkcry
|
|||
mbedtls_aes_context ctx;
|
||||
mbedtls_aes_init(&ctx);
|
||||
|
||||
if(mbedtls_aes_setkey_enc(&ctx, gkcrypt->key_base, 128) != 0){
|
||||
if(mbedtls_aes_setkey_enc(&ctx, gkcrypt->key_base, 128) != 0)
|
||||
{
|
||||
mbedtls_aes_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
@ -248,9 +250,11 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gen_key_stream(ChiakiGKCrypt *gkcry
|
|||
counter_add(cur, gkcrypt->iv, counter_offset++);
|
||||
|
||||
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
|
||||
for(int i=0; i<buf_size; i=i+16){
|
||||
for(int i = 0; i < buf_size; i = i + 16)
|
||||
{
|
||||
// loop over all blocks of 16 bytes (128 bits)
|
||||
if(mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, buf+i, buf+i) != 0){
|
||||
if(mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, buf + i, buf + i) != 0)
|
||||
{
|
||||
mbedtls_aes_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
@ -373,13 +377,15 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gmac(ChiakiGKCrypt *gkcrypt, uint64
|
|||
mbedtls_gcm_context actx;
|
||||
mbedtls_gcm_init(&actx);
|
||||
// set gmac_key 128 bits key
|
||||
if(mbedtls_gcm_setkey(&actx, MBEDTLS_CIPHER_ID_AES, gmac_key, CHIAKI_GKCRYPT_BLOCK_SIZE*8) != 0){
|
||||
if(mbedtls_gcm_setkey(&actx, MBEDTLS_CIPHER_ID_AES, gmac_key, CHIAKI_GKCRYPT_BLOCK_SIZE * 8) != 0)
|
||||
{
|
||||
mbedtls_gcm_free(&actx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
// encrypt without additional data
|
||||
if(mbedtls_gcm_starts(&actx, MBEDTLS_GCM_ENCRYPT, iv, CHIAKI_GKCRYPT_BLOCK_SIZE, NULL, 0) != 0){
|
||||
if(mbedtls_gcm_starts(&actx, MBEDTLS_GCM_ENCRYPT, iv, CHIAKI_GKCRYPT_BLOCK_SIZE, NULL, 0) != 0)
|
||||
{
|
||||
mbedtls_gcm_free(&actx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
@ -387,9 +393,10 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gmac(ChiakiGKCrypt *gkcrypt, uint64
|
|||
// to get the same result as:
|
||||
// EVP_EncryptUpdate(ctx, NULL, &len, buf, (int)buf_size)
|
||||
if(mbedtls_gcm_crypt_and_tag(&actx, MBEDTLS_GCM_ENCRYPT,
|
||||
0, iv, CHIAKI_GKCRYPT_BLOCK_SIZE,
|
||||
buf, buf_size, NULL, NULL,
|
||||
CHIAKI_GKCRYPT_GMAC_SIZE, gmac_out) != 0){
|
||||
0, iv, CHIAKI_GKCRYPT_BLOCK_SIZE,
|
||||
buf, buf_size, NULL, NULL,
|
||||
CHIAKI_GKCRYPT_GMAC_SIZE, gmac_out) != 0)
|
||||
{
|
||||
|
||||
mbedtls_gcm_free(&actx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
|
||||
CHIAKI_EXPORT void chiaki_http_header_free(ChiakiHttpHeader *header)
|
||||
{
|
||||
while(header)
|
||||
|
|
|
@ -74,4 +74,3 @@ CHIAKI_EXPORT void chiaki_packet_stats_get(ChiakiPacketStats *stats, bool reset,
|
|||
reset_stats(stats);
|
||||
chiaki_mutex_unlock(&stats->mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,12 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_random_bytes_crypt(uint8_t *buf, size_t buf
|
|||
mbedtls_entropy_init(&entropy);
|
||||
|
||||
mbedtls_ctr_drbg_set_prediction_resistance(&ctr_drbg, MBEDTLS_CTR_DRBG_PR_OFF);
|
||||
if(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *) "RANDOM_GEN", 10 ) != 0 ){
|
||||
if(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *)"RANDOM_GEN", 10) != 0)
|
||||
{
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
if(mbedtls_ctr_drbg_random(&ctr_drbg, buf, buf_size) != 0){
|
||||
if(mbedtls_ctr_drbg_random(&ctr_drbg, buf, buf_size) != 0)
|
||||
{
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,6 @@ static int request_header_format(char *buf, size_t buf_size, size_t payload_size
|
|||
return cur;
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_regist_request_payload_format(ChiakiTarget target, const uint8_t *ambassador, uint8_t *buf, size_t *buf_size, ChiakiRPCrypt *crypt, const char *psn_online_id, const uint8_t *psn_account_id, uint32_t pin)
|
||||
{
|
||||
size_t buf_size_val = *buf_size;
|
||||
|
|
|
@ -1488,7 +1488,7 @@ static ChiakiErrorCode bright_ambassador(ChiakiTarget target, uint8_t *bright, u
|
|||
0x20, 0x98, 0xfd, 0x34, 0xca, 0x7a, 0x66, 0x20, 0x58, 0xd2,
|
||||
0x36, 0x7f, 0x2b, 0xa7, 0xd1, 0xde, 0x6f, 0x36, 0xb4, 0xf2,
|
||||
0x3b, 0x20, 0x5d, 0x02
|
||||
};
|
||||
};
|
||||
|
||||
if(target < CHIAKI_TARGET_PS4_10)
|
||||
return CHIAKI_ERR_INVALID_DATA;
|
||||
|
@ -1865,7 +1865,6 @@ static const uint8_t *rpcrypt_hmac_key(ChiakiRPCrypt *rpcrypt)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_generate_iv(ChiakiRPCrypt *rpcrypt, uint8_t *iv, uint64_t counter)
|
||||
{
|
||||
|
@ -1968,7 +1967,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_generate_iv(ChiakiRPCrypt *rpcrypt,
|
|||
buf[CHIAKI_RPCRYPT_KEY_SIZE + 6] = (uint8_t)((counter >> 0x08) & 0xff);
|
||||
buf[CHIAKI_RPCRYPT_KEY_SIZE + 7] = (uint8_t)((counter >> 0x00) & 0xff);
|
||||
|
||||
|
||||
uint8_t hmac[32];
|
||||
unsigned int hmac_len = 0;
|
||||
if(!HMAC(EVP_sha256(), hmac_key, CHIAKI_RPCRYPT_KEY_SIZE, buf, sizeof(buf), hmac, &hmac_len))
|
||||
|
|
|
@ -645,7 +645,6 @@ static void senkusha_takion_data(ChiakiSenkusha *senkusha, ChiakiTakionMessageDa
|
|||
senkusha->state_finished = true;
|
||||
chiaki_cond_signal(&senkusha->state_cond);
|
||||
}
|
||||
|
||||
}
|
||||
chiaki_mutex_unlock(&senkusha->state_mutex);
|
||||
}
|
||||
|
@ -878,4 +877,3 @@ static ChiakiErrorCode senkusha_send_data_wait_for_ack(ChiakiSenkusha *senkusha,
|
|||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -540,10 +540,8 @@ quit:
|
|||
#undef QUIT
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct session_response_t {
|
||||
typedef struct session_response_t
|
||||
{
|
||||
uint32_t error_code;
|
||||
const char *nonce;
|
||||
const char *rp_version;
|
||||
|
@ -652,7 +650,6 @@ static ChiakiErrorCode session_thread_request_session(ChiakiSession *session, Ch
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
if(CHIAKI_SOCKET_IS_INVALID(session_sock))
|
||||
{
|
||||
CHIAKI_LOGE(session->log, "Session request connect failed eventually.");
|
||||
|
|
|
@ -27,9 +27,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_stop_pipe_init(ChiakiStopPipe *stop_pipe)
|
|||
int addr_size = sizeof(stop_pipe->addr);
|
||||
|
||||
stop_pipe->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if(stop_pipe->fd < 0){
|
||||
if(stop_pipe->fd < 0)
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
stop_pipe->addr.sin_family = AF_INET;
|
||||
// bind to localhost
|
||||
stop_pipe->addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
|
|
|
@ -56,7 +56,6 @@ static ChiakiErrorCode stream_connection_send_streaminfo_ack(ChiakiStreamConnect
|
|||
static void stream_connection_takion_av(ChiakiStreamConnection *stream_connection, ChiakiTakionAVPacket *packet);
|
||||
static ChiakiErrorCode stream_connection_send_heartbeat(ChiakiStreamConnection *stream_connection);
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_stream_connection_init(ChiakiStreamConnection *stream_connection, ChiakiSession *session)
|
||||
{
|
||||
stream_connection->session = session;
|
||||
|
@ -121,7 +120,6 @@ CHIAKI_EXPORT void chiaki_stream_connection_fini(ChiakiStreamConnection *stream_
|
|||
chiaki_mutex_fini(&stream_connection->state_mutex);
|
||||
}
|
||||
|
||||
|
||||
static bool state_finished_cond_check(void *user)
|
||||
{
|
||||
ChiakiStreamConnection *stream_connection = user;
|
||||
|
@ -399,7 +397,6 @@ static void stream_connection_takion_data_protobuf(ChiakiStreamConnection *strea
|
|||
break;
|
||||
}
|
||||
chiaki_mutex_unlock(&stream_connection->state_mutex);
|
||||
|
||||
}
|
||||
|
||||
static void stream_connection_takion_data_rumble(ChiakiStreamConnection *stream_connection, uint8_t *buf, size_t buf_size)
|
||||
|
@ -640,7 +637,6 @@ static bool pb_decode_resolution(pb_istream_t *stream, const pb_field_t *field,
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void stream_connection_takion_data_expect_streaminfo(ChiakiStreamConnection *stream_connection, uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
tkproto_TakionMessage msg;
|
||||
|
@ -709,11 +705,9 @@ error:
|
|||
chiaki_cond_signal(&stream_connection->state_cond);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool chiaki_pb_encode_zero_encrypted_key(pb_ostream_t *stream, const pb_field_t *field, void *const *arg)
|
||||
{
|
||||
if (!pb_encode_tag_for_field(stream, field))
|
||||
if(!pb_encode_tag_for_field(stream, field))
|
||||
return false;
|
||||
uint8_t data[] = { 0, 0, 0, 0 };
|
||||
return pb_encode_string(stream, data, sizeof(data));
|
||||
|
@ -867,7 +861,6 @@ static ChiakiErrorCode stream_connection_send_disconnect(ChiakiStreamConnection
|
|||
return err;
|
||||
}
|
||||
|
||||
|
||||
static void stream_connection_takion_av(ChiakiStreamConnection *stream_connection, ChiakiTakionAVPacket *packet)
|
||||
{
|
||||
chiaki_gkcrypt_decrypt(stream_connection->gkcrypt_remote, packet->key_pos + CHIAKI_GKCRYPT_BLOCK_SIZE, packet->data, packet->data_size);
|
||||
|
@ -878,7 +871,6 @@ static void stream_connection_takion_av(ChiakiStreamConnection *stream_connectio
|
|||
chiaki_audio_receiver_av_packet(stream_connection->audio_receiver, packet);
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode stream_connection_send_heartbeat(ChiakiStreamConnection *stream_connection)
|
||||
{
|
||||
tkproto_TakionMessage msg = { 0 };
|
||||
|
|
|
@ -107,7 +107,6 @@ typedef enum takion_chunk_type_t {
|
|||
TAKION_CHUNK_TYPE_COOKIE_ACK = 0xb,
|
||||
} TakionChunkType;
|
||||
|
||||
|
||||
typedef struct takion_message_t
|
||||
{
|
||||
uint32_t tag;
|
||||
|
@ -120,7 +119,6 @@ typedef struct takion_message_t
|
|||
uint8_t *payload;
|
||||
} TakionMessage;
|
||||
|
||||
|
||||
typedef struct takion_message_payload_init_t
|
||||
{
|
||||
uint32_t tag;
|
||||
|
@ -152,14 +150,12 @@ typedef struct
|
|||
uint16_t channel;
|
||||
} TakionDataPacketEntry;
|
||||
|
||||
|
||||
typedef struct chiaki_takion_postponed_packet_t
|
||||
{
|
||||
uint8_t *buf;
|
||||
size_t buf_size;
|
||||
} ChiakiTakionPostponedPacket;
|
||||
|
||||
|
||||
static void *takion_thread_func(void *user);
|
||||
static void takion_handle_packet(ChiakiTakion *takion, uint8_t *buf, size_t buf_size);
|
||||
static ChiakiErrorCode takion_handle_packet_mac(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size);
|
||||
|
@ -507,7 +503,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_congestion(ChiakiTakion *takion
|
|||
return err;
|
||||
|
||||
uint8_t buf[CHIAKI_TAKION_CONGESTION_PACKET_SIZE];
|
||||
chiaki_takion_format_congestion(buf, packet, key_pos);
|
||||
chiaki_takion_format_congestion(buf, packet, key_pos);
|
||||
return chiaki_takion_send(takion, buf, sizeof(buf), key_pos);
|
||||
}
|
||||
|
||||
|
@ -603,7 +599,6 @@ static ChiakiErrorCode takion_handshake(ChiakiTakion *takion, uint32_t *seq_num_
|
|||
|
||||
CHIAKI_LOGI(takion->log, "Takion sent init");
|
||||
|
||||
|
||||
// INIT_ACK <-
|
||||
|
||||
TakionMessagePayloadInitAck init_ack_payload;
|
||||
|
@ -621,20 +616,17 @@ static ChiakiErrorCode takion_handshake(ChiakiTakion *takion, uint32_t *seq_num_
|
|||
}
|
||||
|
||||
CHIAKI_LOGI(takion->log, "Takion received init ack with remote tag %#x, outbound streams: %#x, inbound streams: %#x",
|
||||
init_ack_payload.tag, init_ack_payload.outbound_streams, init_ack_payload.inbound_streams);
|
||||
init_ack_payload.tag, init_ack_payload.outbound_streams, init_ack_payload.inbound_streams);
|
||||
|
||||
takion->tag_remote = init_ack_payload.tag;
|
||||
*seq_num_remote_initial = takion->tag_remote; //init_ack_payload.initial_seq_num;
|
||||
|
||||
if(init_ack_payload.outbound_streams == 0 || init_ack_payload.inbound_streams == 0
|
||||
|| init_ack_payload.outbound_streams > TAKION_INBOUND_STREAMS
|
||||
|| init_ack_payload.inbound_streams < TAKION_OUTBOUND_STREAMS)
|
||||
if(init_ack_payload.outbound_streams == 0 || init_ack_payload.inbound_streams == 0 || init_ack_payload.outbound_streams > TAKION_INBOUND_STREAMS || init_ack_payload.inbound_streams < TAKION_OUTBOUND_STREAMS)
|
||||
{
|
||||
CHIAKI_LOGE(takion->log, "Takion min/max check failed");
|
||||
return CHIAKI_ERR_INVALID_RESPONSE;
|
||||
}
|
||||
|
||||
|
||||
// COOKIE ->
|
||||
|
||||
err = takion_send_message_cookie(takion, init_ack_payload.cookie);
|
||||
|
@ -780,7 +772,6 @@ beach:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_recv(ChiakiTakion *takion, uint8_t *buf, size_t *buf_size, uint64_t timeout_ms)
|
||||
{
|
||||
ChiakiErrorCode err = chiaki_stop_pipe_select_single(&takion->stop_pipe, takion->sock, false, timeout_ms);
|
||||
|
@ -805,7 +796,6 @@ static ChiakiErrorCode takion_recv(ChiakiTakion *takion, uint8_t *buf, size_t *b
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_handle_packet_mac(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
if(!takion->gkcrypt_remote)
|
||||
|
@ -866,7 +856,6 @@ static void takion_postpone_packet(ChiakiTakion *takion, uint8_t *buf, size_t bu
|
|||
packet->buf_size = buf_size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param buf ownership of this buf is taken.
|
||||
*/
|
||||
|
@ -934,7 +923,6 @@ static void takion_handle_packet_message(ChiakiTakion *takion, uint8_t *buf, siz
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void takion_flush_data_queue(ChiakiTakion *takion)
|
||||
{
|
||||
uint64_t seq_num = 0;
|
||||
|
@ -1104,7 +1092,6 @@ static ChiakiErrorCode takion_parse_message(ChiakiTakion *takion, uint8_t *buf,
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_send_message_init(ChiakiTakion *takion, TakionMessagePayloadInit *payload)
|
||||
{
|
||||
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + 0x10];
|
||||
|
@ -1121,8 +1108,6 @@ static ChiakiErrorCode takion_send_message_init(ChiakiTakion *takion, TakionMess
|
|||
return chiaki_takion_send_raw(takion, message, sizeof(message));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_send_message_cookie(ChiakiTakion *takion, uint8_t *cookie)
|
||||
{
|
||||
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + TAKION_COOKIE_SIZE];
|
||||
|
@ -1132,8 +1117,6 @@ static ChiakiErrorCode takion_send_message_cookie(ChiakiTakion *takion, uint8_t
|
|||
return chiaki_takion_send_raw(takion, message, sizeof(message));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_recv_message_init_ack(ChiakiTakion *takion, TakionMessagePayloadInitAck *payload)
|
||||
{
|
||||
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + 0x10 + TAKION_COOKIE_SIZE];
|
||||
|
@ -1181,7 +1164,6 @@ static ChiakiErrorCode takion_recv_message_init_ack(ChiakiTakion *takion, Takion
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_recv_message_cookie_ack(ChiakiTakion *takion)
|
||||
{
|
||||
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE];
|
||||
|
@ -1221,7 +1203,6 @@ static ChiakiErrorCode takion_recv_message_cookie_ack(ChiakiTakion *takion)
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void takion_handle_packet_av(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
// HHIxIIx
|
||||
|
@ -1453,5 +1434,4 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_v7_av_packet_parse(ChiakiTakionAVPac
|
|||
packet->data_size = buf_size;
|
||||
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ static DWORD WINAPI win32_thread_func(LPVOID param)
|
|||
#endif
|
||||
|
||||
#ifdef __SWITCH__
|
||||
int64_t get_thread_limit(){
|
||||
int64_t get_thread_limit()
|
||||
{
|
||||
uint64_t resource_limit_handle_value = INVALID_HANDLE;
|
||||
svcGetInfo(&resource_limit_handle_value, InfoType_ResourceLimit, INVALID_HANDLE, 0);
|
||||
int64_t thread_cur_value = 0, thread_lim_value = 0;
|
||||
|
@ -45,9 +46,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_thread_create(ChiakiThread *thread, ChiakiT
|
|||
return CHIAKI_ERR_THREAD;
|
||||
#else
|
||||
#ifdef __SWITCH__
|
||||
if(get_thread_limit() <= 1){
|
||||
if(get_thread_limit() <= 1)
|
||||
return CHIAKI_ERR_THREAD;
|
||||
}
|
||||
#endif
|
||||
int r = pthread_create(&thread->thread, NULL, func, arg);
|
||||
if(r != 0)
|
||||
|
@ -90,13 +90,13 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_thread_set_name(ChiakiThread *thread, const
|
|||
if(r != 0)
|
||||
return CHIAKI_ERR_THREAD;
|
||||
#else
|
||||
(void)thread; (void)name;
|
||||
(void)thread;
|
||||
(void)name;
|
||||
#endif
|
||||
#endif
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_mutex_init(ChiakiMutex *mutex, bool rec)
|
||||
{
|
||||
#if _WIN32
|
||||
|
@ -172,9 +172,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_mutex_unlock(ChiakiMutex *mutex)
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_init(ChiakiCond *cond)
|
||||
{
|
||||
#if _WIN32
|
||||
|
@ -214,8 +211,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_fini(ChiakiCond *cond)
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_wait(ChiakiCond *cond, ChiakiMutex *mutex)
|
||||
{
|
||||
#if _WIN32
|
||||
|
@ -323,7 +318,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_timedwait_pred(ChiakiCond *cond, Chiak
|
|||
#endif
|
||||
}
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_signal(ChiakiCond *cond)
|
||||
|
@ -350,9 +344,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_broadcast(ChiakiCond *cond)
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_init(ChiakiBoolPredCond *cond)
|
||||
{
|
||||
cond->pred = false;
|
||||
|
@ -384,7 +375,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_fini(ChiakiBoolPredCond *con
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_lock(ChiakiBoolPredCond *cond)
|
||||
{
|
||||
return chiaki_mutex_lock(&cond->mutex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue