clang instead of gcc

This commit is contained in:
aiden 2022-07-16 18:11:28 +01:00
parent d327629ce1
commit ec02bed8a2
No known key found for this signature in database
GPG Key ID: 0D87FF3415416DB1
7 changed files with 46 additions and 29 deletions

View File

@ -37,17 +37,11 @@ struct bdd_settings settings = {
};
#define PASTE(x, y) x##y
#define sto(sign, w, t) \
#define stos(w, t) \
bool PASTE(sto, w)(t * dest, char *str) { \
sign long long int v; \
if (strcmp(#sign, "signed") == 0) { \
if (!strtolls(str, strlen(str), &(v))) { \
return false; \
} \
} else { \
if (!strtollu(str, strlen(str), &(v))) { \
return false; \
} \
signed long long int v; \
if (!strtolls(str, strlen(str), &(v))) { \
return false; \
} \
if (v == (t)v) { \
*dest = (t)v; \
@ -55,13 +49,25 @@ struct bdd_settings settings = {
} \
return false; \
}
sto(signed, i, int);
sto(unsigned, ui, unsigned int);
sto(unsigned, usi, unsigned short int);
sto(signed, uid, uid_t);
sto(signed, gid, gid_t);
sto(unsigned, sz, size_t);
sto(unsigned, rlim, rlim_t);
#define stou(w, t) \
bool PASTE(sto, w)(t * dest, char *str) { \
unsigned long long int v; \
if (!strtollu(str, strlen(str), &(v))) { \
return false; \
} \
if (v == (t)v) { \
*dest = (t)v; \
return true; \
} \
return false; \
}
stos(i, int);
stou(ui, unsigned int);
stou(usi, unsigned short int);
stos(uid, uid_t);
stos(gid, gid_t);
stou(sz, size_t);
stou(rlim, rlim_t);
// main
#ifndef HASHMAP_MAIN
@ -78,8 +84,8 @@ int main(int argc, char *argv[], char *env[]) {
int *sockfds = NULL;
size_t fuck_idx = 0; // to-do: rename that variable
struct sockaddr_un input_addr = {
0,
.sun_family = AF_UNIX,
0,
};
int sig_fd = -1;

View File

@ -2,8 +2,10 @@
import os, subprocess, sys
file_dirname = os.path.dirname(__file__)
gcc = [
"/usr/bin/gcc",
"/usr/bin/clang",
"-fuse-ld=lld", # to-do: mold?
"-O2",
"-lpthread", "-lssl", "-lcrypto",
"-o", os.path.join(file_dirname, "output", "bidirectiond"),

View File

@ -55,7 +55,7 @@ int bdd_hello_cb(SSL *client_ssl, int *alert, struct bdd_conversation *conversat
}
size_t name_sz = (size_t)ntohs(*(unsigned short int *)(&(extension[3])));
const unsigned char *name = (char *)&(extension[5]);
const unsigned char *name = (const unsigned char *)&(extension[5]);
bdd_name_trim(name, &(name_sz));
@ -140,7 +140,7 @@ int bdd_hello_cb(SSL *client_ssl, int *alert, struct bdd_conversation *conversat
for (size_t sp_idx = 0; sp[sp_idx] != NULL; ++sp_idx) {
if (
strncmp(
&(alpn[alpn_idx + 1 /* length byte */]),
(const char *)&(alpn[alpn_idx + 1 /* length byte */]),
sp[sp_idx],
alpn_len
) == 0

View File

@ -15,6 +15,6 @@ struct bdd_name_desc {
struct bdd_service_instance *service_instances;
};
void bdd_name_trim(const char *name, size_t *name_sz);
void bdd_name_trim(const unsigned char *name, size_t *name_sz);
#endif

View File

@ -569,6 +569,9 @@ enum bdd_cont bdd_io_connect(
}
return bdd_cont_established;
}
default: {
abort();
}
}
}
if (errno == EINPROGRESS) {

View File

@ -95,7 +95,7 @@ void bdd_name_desc_destroy_hm(struct bdd_name_desc *name_desc, enum hashmap_drop
// name_descs hashmap
void bdd_name_trim(const char *name, size_t *name_sz) {
void bdd_name_trim(const unsigned char *name, size_t *name_sz) {
if ((*name_sz) >= 1 && name[(*name_sz) - 1] == '.') { \
(*name_sz) -= 1;
}
@ -113,7 +113,7 @@ void bdd_name_trim(const char *name, size_t *name_sz) {
scope_sz -= 1; \
} \
struct hashmap_key key = HASHMAP_KEY_INITIALIZER; \
hashmap_key_obtain(name_descs, &(key), (char *)scope, scope_sz); \
hashmap_key_obtain(name_descs, &(key), scope, scope_sz); \
struct bdd_name_desc *name_desc; \
bool created_name_desc; \
if (!hashmap_get(name_descs, &(key), (void *)&(name_desc))) { \
@ -134,7 +134,7 @@ void bdd_name_trim(const char *name, size_t *name_sz) {
// it may only add service instances.
bool bdd_name_descs_add_service_instance(
struct bdd_name_descs *bdd_name_descs,
const char *scope,
const unsigned char *scope,
size_t scope_sz,
const struct bdd_service *service,
const void **instance_info
@ -175,7 +175,7 @@ bool bdd_name_descs_add_service_instance(
// internal function
bool bdd_name_descs_set_cert_pkey(
struct bdd_name_descs *bdd_name_descs,
const char *scope,
const unsigned char *scope,
size_t scope_sz,
X509 *x509,
EVP_PKEY *pkey
@ -222,7 +222,7 @@ bool bdd_name_descs_use_cert_pkey(
int data_length = asn1_str->length;
bool s = bdd_name_descs_set_cert_pkey(
bdd_name_descs,
(char *)asn1_str->data,
(const unsigned char *)asn1_str->data,
data_length,
x509,
pkey
@ -257,7 +257,7 @@ bool bdd_name_descs_use_cert_pkey(
int data_length = asn1_str->length;
bool s = bdd_name_descs_set_cert_pkey(
bdd_name_descs,
(char *)asn1_str->data,
(const unsigned char *)asn1_str->data,
data_length,
x509,
pkey

View File

@ -87,6 +87,9 @@ void *bdd_serve(struct bdd_worker_data *worker_data) {
process_link(&(process_list), conversation);
break;
}
default: {
abort();
}
}
}
@ -119,6 +122,9 @@ void *bdd_serve(struct bdd_worker_data *worker_data) {
}
break;
}
default: {
abort();
}
}
goto remove_event;
} else if (ev->events & bdd_ev_err) {