Skip to content

Commit a8e5b49

Browse files
committed
Fix cross-compiling on Unix
VS did not see a problem with building with Platform as x86/ARM/ARM64 and producing a x64 binary. Stupid. You will need the cross-compiling g++/gcc toolchains. You should have no problem finding their apt packages via googling their name inside VS project properties. Added the libcrypto/libssl libraries for each Unix arch. They're from OpenSSL 3.2.0; specifically openssl/openssl@92a25e2 . Fixed the gitignore so it won't remove the libraries. libssl-dev is no longer required on build machine. Renamed lwp_stream_flag_queueing to lwp_stream_flag_queuing. Fixed some superfluous warnings: Clarified some types as some Unix cross-compilers saw char as different to signed char. time_t + x literals were not the right size; int literals seem to make all platforms happy.
1 parent 01756e7 commit a8e5b49

File tree

18 files changed

+86
-54
lines changed

18 files changed

+86
-54
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
[Dd]ebugPublic/
1818
[Rr]elease/
1919
[Rr]eleases/
20-
x64/
21-
x86/
2220
bld/
2321
[Bb]in/
2422
[Oo]bj/

Lacewing/src/openssl/sslclient.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include "sslclient.h"
1717
#include "../stream.h"
1818

19-
#define lwp_sslclient_flag_handshook 1
20-
#define lwp_sslclient_flag_pumping 2
21-
#define lwp_sslclient_flag_dead 4
19+
#define lwp_sslclient_flag_handshook ((lw_i8)1)
20+
#define lwp_sslclient_flag_pumping ((lw_i8)2)
21+
#define lwp_sslclient_flag_dead ((lw_i8)4)
2222

2323
struct _lwp_sslclient
2424
{
@@ -29,7 +29,7 @@ struct _lwp_sslclient
2929

3030
int write_condition;
3131

32-
char flags;
32+
lw_i8 flags;
3333

3434
void * tag;
3535
lwp_sslclient_on_handshook on_handshook;

Lacewing/src/stream.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ size_t lwp_stream_write (lw_stream ctx, const char * buffer, size_t size, int fl
288288
&& list_length (ctx->front_queue) > 0)
289289
{
290290
lwp_trace ("%p : Adding to front queue (queueing = %d, front queue length = %zu)",
291-
ctx, (int) ( (ctx->flags & lwp_stream_flag_queueing) != 0),
291+
ctx, (int) ( (ctx->flags & lwp_stream_flag_queuing) != 0),
292292
list_length (ctx->front_queue));
293293

294294
if (flags & lwp_stream_write_partial)
@@ -324,10 +324,10 @@ size_t lwp_stream_write (lw_stream ctx, const char * buffer, size_t size, int fl
324324
}
325325

326326
if ( (! (flags & lwp_stream_write_ignore_queue)) &&
327-
( (ctx->flags & lwp_stream_flag_queueing) || list_length (ctx->back_queue) > 0))
327+
( (ctx->flags & lwp_stream_flag_queuing) || list_length (ctx->back_queue) > 0))
328328
{
329329
lwp_trace ("%p : Adding to back queue (queueing = %d, front queue length = %zu)",
330-
ctx, (int) ( (ctx->flags & lwp_stream_flag_queueing) != 0),
330+
ctx, (int) ( (ctx->flags & lwp_stream_flag_queuing) != 0),
331331
list_length (ctx->front_queue));
332332

333333
if (flags & lwp_stream_write_partial)
@@ -410,7 +410,7 @@ void lwp_stream_write_stream (lw_stream ctx, lw_stream source,
410410
if (! (flags & lwp_stream_write_ignore_queue))
411411
{
412412
if (list_length (ctx->back_queue) > 0
413-
|| ctx->flags & lwp_stream_flag_queueing)
413+
|| ctx->flags & lwp_stream_flag_queuing)
414414
{
415415
should_queue = lw_true;
416416
}
@@ -758,7 +758,7 @@ list_type (struct _lwp_stream_queued) lwp_stream_write_queue(lw_stream ctx,
758758
if (queued->type == lwp_stream_queued_begin_marker)
759759
{
760760
list_elem_remove (queued);
761-
ctx->flags |= lwp_stream_flag_queueing;
761+
ctx->flags |= lwp_stream_flag_queuing;
762762

763763
break;
764764
}
@@ -816,7 +816,7 @@ list_type (struct _lwp_stream_queued) lwp_stream_write_queue(lw_stream ctx,
816816

817817
void lwp_stream_write_queued (lw_stream ctx)
818818
{
819-
if (ctx->flags & lwp_stream_flag_queueing)
819+
if (ctx->flags & lwp_stream_flag_queuing)
820820
return;
821821

822822
if (ctx->flags & lwp_stream_flag_draining_queues)
@@ -1066,7 +1066,7 @@ void lw_stream_begin_queue (lw_stream stream)
10661066
}
10671067
else
10681068
{
1069-
stream->flags |= lwp_stream_flag_queueing;
1069+
stream->flags |= lwp_stream_flag_queuing;
10701070
}
10711071
}
10721072

@@ -1123,9 +1123,9 @@ void lw_stream_end_queue (lw_stream ctx)
11231123

11241124
// TODO : Look for a queued item w/ Flag_BeginQueue if Queueing is false?
11251125

1126-
assert (ctx->flags & lwp_stream_flag_queueing);
1126+
assert (ctx->flags & lwp_stream_flag_queuing);
11271127

1128-
ctx->flags &= ~ lwp_stream_flag_queueing;
1128+
ctx->flags &= ~ lwp_stream_flag_queuing;
11291129

11301130
lwp_stream_write_queued (ctx);
11311131
}
@@ -1143,7 +1143,7 @@ lw_bool lwp_stream_is_transparent (lw_stream ctx)
11431143
return lw_false;
11441144
}
11451145

1146-
if (ctx->flags & lwp_stream_flag_queueing)
1146+
if (ctx->flags & lwp_stream_flag_queuing)
11471147
return lw_false;
11481148

11491149
return ctx->def->is_transparent && ctx->def->is_transparent (ctx);

Lacewing/src/stream.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
#include "streamgraph.h"
1515

1616
/* BeginQueue has been called */
17-
#define lwp_stream_flag_queueing 1
17+
#define lwp_stream_flag_queuing ((lw_i8)1)
1818

1919
/* Close was called with immediately = false, stream was busy */
20-
#define lwp_stream_flag_closeASAP 2
20+
#define lwp_stream_flag_closeASAP ((lw_i8)2)
2121

2222
/* Currently in the process of an immediate Close (this is just to prevent
2323
* re-entrance to the Close routine)
2424
*/
25-
#define lwp_stream_flag_closing 4
25+
#define lwp_stream_flag_closing ((lw_i8)4)
2626

2727
/* Deleted when user count was > 0 - waiting to be freed */
28-
#define lwp_stream_flag_dead 8
28+
#define lwp_stream_flag_dead ((lw_i8)8)
2929

3030
/* Currently attempting to drain the queues. Because draining the queues
3131
* might cause another retry, this flag prevents re-entrance to the
3232
* write_queued proc.
3333
*/
34-
#define lwp_stream_flag_draining_queues 16
34+
#define lwp_stream_flag_draining_queues ((lw_i8)16)
3535

3636
typedef struct _lwp_stream_data_hook
3737
{
@@ -91,7 +91,7 @@ struct _lw_stream
9191
lw_pump pump;
9292
lw_pump_watch watch;
9393

94-
char flags;
94+
lw_i8 flags;
9595

9696
void * tag;
9797

Lacewing/src/unix/client.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include "../address.h"
1313
#include "fdstream.h"
1414

15-
#define lw_client_flag_connecting 1
16-
#define lw_client_flag_connected 2
15+
#define lw_client_flag_connecting ((lw_i8)1)
16+
#define lw_client_flag_connected ((lw_i8)2)
1717

1818
// 3 second timeout
1919
static const int lw_client_timeout_ms = 3 * 1000;
@@ -27,7 +27,7 @@ struct _lw_client
2727
lw_client_hook_data on_data;
2828
lw_client_hook_error on_error;
2929

30-
char flags;
30+
lw_i8 flags;
3131

3232
lw_addr address;
3333

Lacewing/src/unix/fdstream.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ struct _lw_fdstream
2121

2222
int fd;
2323

24-
char flags;
24+
lw_i8 flags;
2525

2626
size_t size;
2727
size_t reading_size;
2828
};
2929

30-
#define lwp_fdstream_flag_nagle 1
31-
#define lwp_fdstream_flag_is_socket 2
32-
#define lwp_fdstream_flag_autoclose 4
33-
#define lwp_fdstream_flag_reading 8
30+
#define lwp_fdstream_flag_nagle ((lw_i8)1)
31+
#define lwp_fdstream_flag_is_socket ((lw_i8)2)
32+
#define lwp_fdstream_flag_autoclose ((lw_i8)4)
33+
#define lwp_fdstream_flag_reading ((lw_i8)8)
3434

3535
void lwp_fdstream_init (lw_fdstream, lw_pump);
3636

Lacewing/src/webserver/request.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void lw_ws_req_disconnect (lw_ws_req ctx, unsigned int websocket_exit_reason)
496496

497497
lw_ui8 opcode = 0b10001000; // fin, connection close
498498
lw_ui16 exit_reason = htons((lw_ui16)websocket_exit_reason);
499-
lw_i8 maskAndLen = (lw_i8)sizeof(exit_reason);
499+
char maskAndLen = (char)sizeof(exit_reason);
500500
char close_msg[] = { *(char*)&opcode, maskAndLen, ((char*)&exit_reason)[0], ((char*)&exit_reason)[1] };
501501
lwp_stream_write((lw_stream)ctx->client->socket, close_msg, sizeof(close_msg), lwp_stream_write_ignore_busy);
502502

Lacewing/src/webserver/webserver.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ size_t lw_webserver_sink_websocket(lw_ws webserver, lwp_ws_httpclient client, co
179179
// Unmask the packet
180180
unmaskedData = (char *)malloc(size);
181181
for (size_t i = 0; i < size; i++)
182-
unmaskedData[i] = data[i] ^ ((lw_i8 *)&mask)[i % 4];
182+
unmaskedData[i] = data[i] ^ ((char *)&mask)[i % 4];
183183
data = unmaskedData;
184184

185185
// If we've started a disconnect (!= -1), we'll ignore everything except an acknowledging close response.
@@ -196,8 +196,8 @@ size_t lw_webserver_sink_websocket(lw_ws webserver, lwp_ws_httpclient client, co
196196
// However, the browser could send its own pings, so we'll respond as expected.
197197
else if (opcode == 9)
198198
{
199-
error2[0] = (lw_i8)0b10001010; // fin + pong
200-
error2[1] = (lw_i8)size; // msg size (no mask); note control frames like ping are hard-capped to < 125 bytes
199+
error2[0] = (char)0b10001010; // fin + pong
200+
error2[1] = (char)size; // msg size (no mask); note control frames like ping are hard-capped to < 125 bytes
201201
memcpy(error2 + 2, unmaskedData, size);
202202
lwp_stream_write(&client->client.stream, error2, 2 + size, lwp_stream_write_ignore_busy);
203203
}

Linux/ARM/libcrypto.a

5.87 MB
Binary file not shown.

Linux/ARM/libssl.a

841 KB
Binary file not shown.

0 commit comments

Comments
 (0)