From 8749def64f8b1360edd8b5a3fffe704ecb2e3a3d Mon Sep 17 00:00:00 2001 From: Dennis Boone Date: Tue, 5 May 2020 18:37:08 -0400 Subject: [PATCH] Changes to enable building on Solaris, FreeBSD Solaris (SmartOS) build needs alternative solutions to two termios things, plus makefile support for additional link libraries. PNC support is untested and is likely _very_ slow, since Solaris doesn't have O_ASYNC. The usual suggestion is to rewrite such code to use poll(). Incidental: utilities makefile needed tabs to make `make` happy on FreeBSD. Which make? Don't remember now. --- devamlc.h | 13 +++++++++++++ devpnc.h | 4 ++++ makefile | 14 +++++++++----- util/makefile | 4 ++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/devamlc.h b/devamlc.h index 6e7b3a7..8e772c5 100644 --- a/devamlc.h +++ b/devamlc.h @@ -650,9 +650,22 @@ int devamlc (int class, int func, int device) { break; } memset(&terminfo, 0, sizeof(terminfo)); +#ifdef __sun__ + terminfo.c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); + terminfo.c_oflag &= ~OPOST; + terminfo.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + terminfo.c_cflag &= ~(CSIZE|PARENB); + terminfo.c_cflag |= CS8; +#else cfmakeraw(&terminfo); +#endif baud = baudtable[(getcrs16(A) >> 6) & 7]; +#ifdef __sun__ + if ((cfsetispeed(&terminfo, baud) == -1) || + (cfsetospeed(&terminfo, baud) == -1)) +#else if (cfsetspeed(&terminfo, baud) == -1) +#endif perror("em: unable to set AMLC line speed"); else printf("em: AMLC line %d set to %d bps\n", dx*16 + lx, baud); diff --git a/devpnc.h b/devpnc.h index ed22e30..b10b691 100644 --- a/devpnc.h +++ b/devpnc.h @@ -406,7 +406,11 @@ void pncinitfd(int fd) { perror("unable to get ts flags for PNC"); fatal(NULL); } +#ifdef __sun__ + fdflags |= O_NONBLOCK; +#else fdflags |= O_NONBLOCK+O_ASYNC; +#endif if (fcntl(fd, F_SETFL, fdflags) == -1) { perror("unable to set fdflags for PNC"); fatal(NULL); diff --git a/makefile b/makefile index 206bfb3..2328af0 100644 --- a/makefile +++ b/makefile @@ -9,23 +9,27 @@ em_deps = \ em.c regs.h emdev.h ea64v.h ea32i.h fp.h dispatch.h geom.h \ devpnc.h devamlc.h swap.h +CFLAGS = +# Uncomment for building on SmartOS/Solaris: +# CFLAGS += -lsocket -lnsl + .PHONY: emwarn debug trace fixed # normal em: $(em_deps) $(all_deps) - $(CC) -DREV=\"${REV}\" -DNOTRACE -DFAST -O -Winline -Wno-return-type em.c -o em + $(CC) -DREV=\"${REV}\" ${CFLAGS} -DNOTRACE -DFAST -O -Winline -Wno-return-type em.c -o em # lots of compiler warnings emwarn: $(em_deps) $(all_deps) - $(CC) -DREV=\"${REV}\" -DNOTRACE -DFAST -O -Wall -Wextra -pedantic -Wconversion em.c -o em + $(CC) -DREV=\"${REV}\" ${CFLAGS} -DNOTRACE -DFAST -O -Wall -Wextra -pedantic -Wconversion em.c -o em # gdb debug: $(em_deps) $(all_deps) - $(CC) -DREV=\"${REV}\" -DNOTRACE -DFAST -g -O0 em.c -o em + $(CC) -DREV=\"${REV}\" ${CFLAGS} -DNOTRACE -DFAST -g -O0 em.c -o em # tracing trace: $(em_deps) $(all_deps) - $(CC) -DREV=\"${REV}\" -DFAST -O em.c -o em + $(CC) -DREV=\"${REV}\" ${CFLAGS} -DFAST -O em.c -o em # the fixed clock rate build is useful for making problems reproduceable. # @@ -35,7 +39,7 @@ trace: $(em_deps) $(all_deps) # fixed clock rate fixed: $(em_deps) $(all_deps) - $(CC) -DREV=\"${REV}\" -DFIXEDCLOCK -DNOIDLE -DFAST -O em.c -o em + $(CC) -DREV=\"${REV}\" ${CFLAGS} -DFIXEDCLOCK -DNOIDLE -DFAST -O em.c -o em clean: rm -f $(em_objs) diff --git a/util/makefile b/util/makefile index a48b4dd..1d1c8f2 100644 --- a/util/makefile +++ b/util/makefile @@ -2,7 +2,7 @@ default: emlink intsize magrst magsav mtread mtwrite ptextu strip8 \ untap untap16 untap_vin utextp # Unix version of Prime's magrst -magrst: magrst.c istext.c +magrst: magrst.c istext.c # Unix version of Prime's magsav -magsav: magsav.c istext.c +magsav: magsav.c istext.c