From 1d16531f62d21316c5f414651d61444ffac0bd0c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 13 Aug 2020 22:40:49 -0700 Subject: [PATCH] serialconsole: fix compilation with uClibc-ng Signed-off-by: Rosen Penev --- utils/serialconsole/Makefile | 2 +- .../patches/010-deprecated.patch | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 utils/serialconsole/patches/010-deprecated.patch diff --git a/utils/serialconsole/Makefile b/utils/serialconsole/Makefile index 2b787686c..58baf464d 100644 --- a/utils/serialconsole/Makefile +++ b/utils/serialconsole/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sc PKG_VERSION:=0.95 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/serialconsole/sc diff --git a/utils/serialconsole/patches/010-deprecated.patch b/utils/serialconsole/patches/010-deprecated.patch new file mode 100644 index 000000000..13dce879b --- /dev/null +++ b/utils/serialconsole/patches/010-deprecated.patch @@ -0,0 +1,70 @@ +--- a/sc.c ++++ b/sc.c +@@ -34,6 +34,7 @@ static const char __rcsid[] = + #include + #include + #include ++#include + + + #if !defined(SC_VERSION) +@@ -344,7 +345,7 @@ loop(int sfd, int escchr, int msdelay) + FD_SET(STDIN_FILENO, fds+1); + FD_SET(sfd, fds+1); + while (scrunning) { +- bcopy(fds+1, fds, sizeof(*fds)); ++ memcpy(fds, fds+1, sizeof(*fds)); + if ((i = select(sfd+1, fds, NULL, NULL, NULL)) < 0 + && errno != EINTR) { + warn("select()"); +@@ -353,7 +354,7 @@ loop(int sfd, int escchr, int msdelay) + #else + struct pollfd pfds[2]; + +- bzero(pfds, sizeof(pfds)); ++ memset(pfds, 0, sizeof(pfds)); + pfds[0].fd = STDIN_FILENO; + pfds[0].events = POLLIN; + pfds[1].fd = sfd; +@@ -453,8 +454,10 @@ loop(int sfd, int escchr, int msdelay) + continue; + } + i = write(sfd, &c, 1); +- if(c == '\n' && msdelay > 0) +- usleep(msdelay*1000); ++ if(c == '\n' && msdelay > 0) {\ ++ struct timespec d = {msdelay / 1000, (msdelay % 1000 ) * 1000 * 1000}; ++ nanosleep(&d, NULL); ++ } + } + if (i < 0) { + warn("read/write"); +@@ -603,8 +606,8 @@ main(int argc, char **argv) + if (strlen(path_dev) + strlen(tty) > PATH_MAX) { + errx(EX_USAGE, "Device name \"%s\" is too long.", tty); + } +- bcopy(path_dev, buffer, strlen(path_dev)+1); +- bcopy(tty, buffer+strlen(path_dev), strlen(tty)+1); ++ memcpy(buffer, path_dev, strlen(path_dev)+1); ++ memcpy(buffer+strlen(path_dev), tty, strlen(tty)+1); + tty = buffer; + } + sfd = open(tty, O_RDWR); +@@ -622,7 +625,7 @@ main(int argc, char **argv) + err(EX_OSERR, "tcgetattr(%s)", tty); + } + /* configure serial port */ +- bcopy(&serialti, &tempti, sizeof(tempti)); ++ memcpy(&tempti, &serialti, sizeof(tempti)); + cfmakeraw(&tempti); + tempti.c_cc[VMIN] = 1; + tempti.c_cc[VTIME] = 0; +@@ -660,7 +663,7 @@ main(int argc, char **argv) + close(sfd); + err(EX_OSERR, "fcntl() tty"); + } +- bcopy(&consoleti, &tempti, sizeof(tempti)); ++ memcpy(&tempti, &consoleti, sizeof(tempti)); + cfmakeraw(&tempti); + if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &tempti)) { + ec = EX_OSERR;