Skip to content

Commit 8df7a44

Browse files
committed
Fixed some CmakeLists shenanigans on OSX
1 parent 2d9518d commit 8df7a44

File tree

11 files changed

+24
-42
lines changed

11 files changed

+24
-42
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ set(LICENSE "BSD2 license")
2222
add_executable(sol ${SOURCES})
2323
add_executable(sol_test ${TEST})
2424

25+
if (APPLE)
26+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/opt/homebrew/opt/openssl@3/include")
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/opt/homebrew/opt/openssl@3/include")
28+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/openssl@3/lib")
29+
endif (APPLE)
30+
2531
if (DEBUG)
2632
message(STATUS "Configuring build for debug")
2733
TARGET_LINK_LIBRARIES(sol pthread ssl crypto crypt)
@@ -31,10 +37,16 @@ if (DEBUG)
3137
-fsanitize=undefined -fno-omit-frame-pointer -pg")
3238
else (DEBUG)
3339
message(STATUS "Configuring build for production")
40+
if (APPLE)
41+
TARGET_LINK_LIBRARIES(sol pthread ssl crypto)
42+
TARGET_LINK_LIBRARIES(sol_test pthread ssl crypto)
43+
else (APPLE)
3444
TARGET_LINK_LIBRARIES(sol pthread ssl crypto crypt)
3545
TARGET_LINK_LIBRARIES(sol_test pthread ssl crypto crypt)
46+
endif (APPLE)
3647
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wunused -Werror -pedantic \
3748
-Wno-unused-result -std=c11 -O3")
49+
3850
endif (DEBUG)
3951

4052
add_custom_command(

src/config.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,12 @@ bool config_read_passwd_file(const char *path, struct authentication **auth_map)
442442
}
443443

444444
char line[0xFFF], username[0xFF], password[0xFFF];
445-
int linenr = 0;
446445
char *pline, *puname;
447446

448447
while (fgets(line, 0xFFF, fh) != NULL) {
449448
memset(username, 0x00, 0xFF);
450449
memset(password, 0x00, 0xFFF);
451450

452-
linenr++;
453-
454451
pline = line;
455452
if (*pline == '\0')
456453
continue;

src/memorypool.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#ifndef MEMORYPOOL_H
3030
#define MEMORYPOOL_H
3131

32+
#include <stdlib.h>
33+
3234
/*
3335
* Simple memory object-pool, the purpose is to allow for fixed size objects to
3436
* be pre-allocated and re-use of memory blocks, so no size have to be

src/network.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
#include "network.h"
3030
#include "config.h"
3131
#include "memory.h"
32-
#include "server.h"
33-
#include "util.h"
3432
#include <fcntl.h>
3533
#include <netdb.h>
3634
#include <netinet/tcp.h>
@@ -294,17 +292,17 @@ ssize_t recv_bytes(int fd, unsigned char *buf, size_t bufsize)
294292
return -1;
295293
}
296294

297-
void openssl_init()
295+
void openssl_init(void)
298296
{
299297
SSL_library_init();
300298
ERR_load_crypto_strings();
301299
SSL_load_error_strings();
302300
OpenSSL_add_ssl_algorithms();
303301
}
304302

305-
void openssl_cleanup() { EVP_cleanup(); }
303+
void openssl_cleanup(void) { EVP_cleanup(); }
306304

307-
SSL_CTX *create_ssl_context()
305+
SSL_CTX *create_ssl_context(void)
308306
{
309307

310308
SSL_CTX *ctx;

src/pack.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,10 @@
2727

2828
#include "pack.h"
2929
#include "memory.h"
30-
#include "util.h"
3130
#include <ctype.h>
3231
#include <stdarg.h>
3332
#include <string.h>
3433

35-
/* Host-to-network (native endian to big endian) */
36-
void htonll(u8 *block, u64 num)
37-
{
38-
block[0] = num >> 56 & 0xFF;
39-
block[1] = num >> 48 & 0xFF;
40-
block[2] = num >> 40 & 0xFF;
41-
block[3] = num >> 32 & 0xFF;
42-
block[4] = num >> 24 & 0xFF;
43-
block[5] = num >> 16 & 0xFF;
44-
block[6] = num >> 8 & 0xFF;
45-
block[7] = num >> 0 & 0xFF;
46-
}
47-
48-
/* Network-to-host (big endian to native endian) */
49-
u64 ntohll(const u8 *block)
50-
{
51-
return (u64)block[0] << 56 | (u64)block[1] << 48 | (u64)block[2] << 40 |
52-
(u64)block[3] << 32 | (u64)block[4] << 24 | (u64)block[5] << 16 |
53-
(u64)block[6] << 8 | (u64)block[7] << 0;
54-
}
55-
5634
// Beej'us network guide functions
5735

5836
/*

src/pack.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030

3131
#include "types.h"
3232

33-
void htonll(u8 *, u64);
34-
35-
u64 ntohll(const u8 *);
36-
3733
/* Reading data on const u8 pointer */
3834

3935
// bytes -> int16_t

src/server.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
#define SERVER_H
3030

3131
#include "mqtt.h"
32-
#include "network.h"
33-
#include "pack.h"
34-
#include "trie.h"
32+
#include <openssl/ssl.h>
3533

3634
/*
3735
* Number of worker threads to be created. Each one will host his own ev_ctx

src/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define TYPES_H
2929

3030
#include <stdint.h>
31+
#include <stdio.h>
3132
#include <stdlib.h>
3233

3334
// Unsigned integer types

src/util.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@
2626
*/
2727

2828
#include "util.h"
29-
#include "config.h"
3029
#include "memory.h"
3130
#include "mqtt.h"
3231
#include <assert.h>
33-
#include <crypt.h>
32+
#include <string.h>
33+
// #include <crypt.h>
3434
#include <ctype.h>
3535
#include <stdarg.h>
3636
#include <stdatomic.h>
3737
#include <stdlib.h>
3838
#include <sys/resource.h>
3939
#include <sys/time.h>
4040
#include <time.h>
41+
#include <unistd.h>
4142

4243
#define SOL_PREFIX "sol"
4344

tests/structures_test.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "../src/list.h"
3232
#include "../src/memory.h"
3333
#include "../src/trie.h"
34-
#include "../src/util.h"
3534
#include "unit.h"
3635
#include <stdlib.h>
3736
#include <string.h>
@@ -286,7 +285,7 @@ static char *test_trie_prefix_count(void)
286285
/*
287286
* All datastructure tests
288287
*/
289-
char *structures_test()
288+
char *structures_test(void)
290289
{
291290

292291
RUN_TEST(test_list_new);

0 commit comments

Comments
 (0)