Added mongoose library

This commit is contained in:
Casey 2022-09-13 20:19:48 +03:00
parent cbbdcbaf78
commit 25da00b91e
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
4 changed files with 8788 additions and 2 deletions

View File

@ -1,7 +1,10 @@
main: main:
$(CC) main.c -o main -lmongoose -O2 $(CFLAGS) $(CC) main.c mongoose.c -o main -I. -O2 $(CFLAGS)
anarchy:
$(CC) main.c mongoose.c -o main -I. -O2 -DALLOCATE_EVERYTHING=1 $(CFLAGS)
clean: clean:
$(RM) main $(RM) main

3
main.c
View File

@ -66,13 +66,14 @@ uint64_t next_block_number = 0;
void api_handler(struct mg_connection *c, int ev, void *evd, void *fnd); void api_handler(struct mg_connection *c, int ev, void *evd, void *fnd);
int main(void) { int main(int argc, char **argv) {
struct mg_mgr manager; struct mg_mgr manager;
mg_mgr_init(&manager); mg_mgr_init(&manager);
mg_http_listen(&manager, "0.0.0.0:8080", api_handler, NULL); mg_http_listen(&manager, "0.0.0.0:8080", api_handler, NULL);
#if ALLOCATE_EVERYTHING #if ALLOCATE_EVERYTHING
int n_threads = 4; int n_threads = 4;
if (argc >= 2) n_threads = atoi(argv[1]);
pthread_t *threads = calloc(n_threads, sizeof(pthread_t)); pthread_t *threads = calloc(n_threads, sizeof(pthread_t));
for (int i = 0; i < n_threads; i++) for (int i = 0; i < n_threads; i++)
pthread_create(&threads[i], NULL, allocation_thread, NULL); pthread_create(&threads[i], NULL, allocation_thread, NULL);

7288
mongoose.c Normal file

File diff suppressed because it is too large Load Diff

1494
mongoose.h Normal file

File diff suppressed because it is too large Load Diff