Skip to content

Commit

Permalink
Fixes for GUI and build warnings on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Nov 7, 2023
1 parent 45e1e61 commit 093c562
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
mkdir build && cd build
../configure --enable-gcov --enable-asan \
--with-llvm=/usr/bin/llvm-config --enable-debug \
--enable-verilog --enable-tcl
--enable-verilog --enable-tcl --enable-gui
- name: Build
run: ASAN_OPTIONS=detect_leaks=0 make -C build
- name: Test
Expand Down
1 change: 0 additions & 1 deletion contrib/gui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ module.exports = {
],
"ignorePatterns": ["node_modules/", "dist/"],
"rules": {
"linebreak-style": [ "error", "unix"],
"@typescript-eslint/no-explicit-any": [ "off" ],
"@stylistic/indent": [
"error", 2, {
Expand Down
12 changes: 5 additions & 7 deletions contrib/gui/component/WaveView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function WaveView(props: IProps) {
const viewportHeight = size[1] - toolbarHeight;
const viewportWidth = size[0];
const visibleTime = BigInt(Math.ceil(viewportWidth)) * scale;
const leftTime = BigInt(scrollLeft) * scale;
const leftTime = BigInt(Math.round(scrollLeft)) * scale;
const rightTime = leftTime + visibleTime;

const handleResize = (entries: ResizeEntry[]) => {
Expand Down Expand Up @@ -201,16 +201,14 @@ function WaveView(props: IProps) {
const s = props.model.signal(path);
const points: React.ReactElement[] = [];

const start = BigInt(scrollLeft) * scale;
const end = start + visibleTime > props.model.now
? props.model.now : start + visibleTime;
const end = rightTime > props.model.now ? props.model.now : rightTime;
const dataType = s.trace.dataType;
const starWidth = measureText.getTextWidth("*");

let last = s.trace.valueAt(start);
let last = s.trace.valueAt(leftTime);

s.trace.mapWaveform(start, end, (when, next, value, i) => {
const leftClip = start - 600n * scale;
s.trace.mapWaveform(leftTime, end, (when, next, value, i) => {
const leftClip = leftTime - 600n * scale;
const clipWhen = when < leftClip ? leftClip : when;
const width = Math.ceil(Number((next - clipWhen)) / Number(scale));
const xPos = clipWhen / scale;
Expand Down
12 changes: 6 additions & 6 deletions src/jit/jit-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ void pack_writer_string_table(pack_writer_t *pw, const char **tab,
size_t *size);
void pack_writer_free(pack_writer_t *pw);

void __nvc_do_exit(jit_exit_t which, jit_anchor_t *anchor, jit_scalar_t *args,
tlab_t *tlab);
void __nvc_do_fficall(jit_foreign_t *ff, jit_anchor_t *anchor,
jit_scalar_t *args);
void *__nvc_mspace_alloc(uintptr_t size, jit_anchor_t *anchor);
void _debug_out(intptr_t val, int32_t reg);
DLLEXPORT void __nvc_do_exit(jit_exit_t which, jit_anchor_t *anchor,
jit_scalar_t *args, tlab_t *tlab);
DLLEXPORT void __nvc_do_fficall(jit_foreign_t *ff, jit_anchor_t *anchor,
jit_scalar_t *args);
DLLEXPORT void *__nvc_mspace_alloc(uintptr_t size, jit_anchor_t *anchor);
DLLEXPORT void _debug_out(intptr_t val, int32_t reg);

#endif // _JIT_PRIV_H
27 changes: 19 additions & 8 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
#define PORT 8888
#define MAX_HTTP_REQUEST 1024

#ifndef __MINGW32__
#define closesocket close
#endif

typedef struct _web_socket {
int sock;
bool mask;
Expand Down Expand Up @@ -201,7 +205,7 @@ void ws_flush(web_socket_t *ws)
while (ws->tx_wptr != ws->tx_rptr) {
const size_t chunksz = ws->tx_wptr - ws->tx_rptr;
const ssize_t nbytes =
send(ws->sock, ws->tx_buf + ws->tx_rptr, chunksz, 0);
send(ws->sock, (char *)ws->tx_buf + ws->tx_rptr, chunksz, 0);

if (nbytes == 0)
break;
Expand Down Expand Up @@ -276,6 +280,7 @@ void ws_poll(web_socket_t *ws)
goto read_more; // Not enough for full frame

assert(fin);
(void)fin;

if (mask) {
for (int i = 0; i < flength; i++)
Expand Down Expand Up @@ -569,7 +574,7 @@ static void kill_connection(web_server_t *server)
{
diag_set_consumer(NULL, NULL);

close(server->websocket->sock);
closesocket(server->websocket->sock);

ws_free(server->websocket);
server->websocket = NULL;
Expand Down Expand Up @@ -789,7 +794,7 @@ static void websocket_upgrade(web_server_t *server, int fd, const char *method,
return; // Socket left open

out_close:
close(fd);
closesocket(fd);
}

static bool is_websocket_request(shash_t *headers)
Expand Down Expand Up @@ -859,7 +864,7 @@ static void handle_http_request(web_server_t *server, int fd,
#endif

out_close:
close(fd);
closesocket(fd);
}

static void handle_new_connection(web_server_t *server)
Expand Down Expand Up @@ -978,7 +983,7 @@ static void handle_new_connection(web_server_t *server)
server_log(LOG_ERROR, "malformed HTTP request");

out_close:
close(fd);
closesocket(fd);
}

static void tunnel_output(const char *buf, size_t nchars, void *user)
Expand All @@ -989,7 +994,13 @@ static void tunnel_output(const char *buf, size_t nchars, void *user)

static int open_server_socket(void)
{
int sock = socket(AF_INET, SOCK_STREAM, 0);
#ifdef __MINGW32__
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData))
fatal_errno("WSAStartup failed");
#endif

int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock < 0)
fatal_errno("socket");

Expand All @@ -1005,7 +1016,7 @@ static int open_server_socket(void)
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
fatal_errno("bind");

if (listen(sock, 10) < 0)
if (listen(sock, SOMAXCONN) < 0)
fatal_errno("listen");

server_log(LOG_INFO, "listening on 127.0.0.1:%d", PORT);
Expand Down Expand Up @@ -1091,7 +1102,7 @@ void start_server(jit_factory_t make_jit, tree_t top,
if (server->shutdown && server->sock != -1) {
server_log(LOG_INFO, "stopping server");

close(server->sock);
closesocket(server->sock);
server->sock = -1;

if (server->websocket != NULL)
Expand Down
4 changes: 2 additions & 2 deletions src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ STATIC_ASSERT(sizeof(lock_stats_t) == 64)
workq_stats[my_thread->id].what += (n); \
} while (0)
#else
#define LOCK_EVENT(what, n)
#define WORKQ_EVENT(what, n)
#define LOCK_EVENT(what, n) (void)(n)
#define WORKQ_EVENT(what, n) (void)(n)
#endif

#ifdef __SANITIZE_THREAD__
Expand Down

0 comments on commit 093c562

Please sign in to comment.