citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 9787c826078da609b2a0e80540e5a35fffa2d504
parent bd690b586706f6c2005dcc58d4be3a7227ff5ef7
Author: Kyle Milz <kyle@cyan.krwm.net>
Date:   Sun,  3 Jul 2016 12:14:10 -0600

let modules using strlcpy compile on linux

Diffstat:
MJamrules | 2+-
Mlib/runtime.c | 6++++--
Msrc/af_unix.cc | 5++++-
3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Jamrules b/Jamrules @@ -67,7 +67,7 @@ if $(OS) = LINUX { PKG_CONFIG_LIBS = gl glew freetype2 ; # Link directly against libestdc++ from ports - LINKLIBS on citrun-gl = -lstdc++ -lm -lglut ; + LINKLIBS on citrun-gl = -lbsd -lstdc++ -lm -lglut ; LINKLIBS on citrun-inst = -Wl,--start-group diff --git a/lib/runtime.c b/lib/runtime.c @@ -3,7 +3,7 @@ #include <limits.h> /* PATH_MAX */ #include <pthread.h> /* pthread_create */ #include <stdlib.h> /* getenv */ -#include <string.h> /* strlcpy */ +#include <string.h> /* strncpy */ #include <unistd.h> /* access, get{pid,ppid,pgrp}, read, write */ #include <sys/socket.h> /* socket */ @@ -209,7 +209,9 @@ relay_thread(void *arg) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - strlcpy(addr.sun_path, viewer_sock, sizeof(addr.sun_path)); + /* Avoid strlcpy here because Linux needs -lbsd in that case. */ + strncpy(addr.sun_path, viewer_sock, sizeof(addr.sun_path)); + addr.sun_path[sizeof(addr.sun_path) - 1] = '\0'; while (1) { if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) { diff --git a/src/af_unix.cc b/src/af_unix.cc @@ -1,7 +1,10 @@ +#if __gnu_linux__ +#include <bsd/string.h> // strlcpy +#endif #include <err.h> // err #include <errno.h> // EWOULDBLOCK #include <fcntl.h> -#include <string.h> // memset +#include <string.h> // memset, strlcpy #include <sys/socket.h> // socket #include <sys/un.h> // sockaddr_un #include <unistd.h> // close