pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

plan9port: update to plan9port-20220912



Module Name:	pkgsrc-wip
Committed By:	Paolo Vincenzo Olivo <vms%retrobsd.ddns.net@localhost>
Pushed By:	vms
Date:		Mon Nov 21 14:41:26 2022 +0100
Changeset:	11cbb9c5c12c70d2129032552e8b210466cd8f69

Modified Files:
	plan9port/MESSAGE
	plan9port/Makefile
	plan9port/PLIST
	plan9port/distinfo
	plan9port/patches/patch-INSTALL
	plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh
Added Files:
	plan9port/files/acme.desktop
	plan9port/files/acme.sh
	plan9port/files/plan9.sh
	plan9port/options.mk
	plan9port/patches/patch-bin_9c
	plan9port/patches/patch-bin_9l
Removed Files:
	plan9port/TODO
	plan9port/patches/patch-include_u.h
	plan9port/patches/patch-src_libthread_NetBSD-386-asm.s
	plan9port/patches/patch-src_libthread_NetBSD-power-asm.s
	plan9port/patches/patch-src_libthread_NetBSD.c
	plan9port/patches/patch-src_libthread_sysofiles.sh

Log Message:
plan9port: update to plan9port-20220912

- package update to latest github commit.
- license changed to MIT (some fonts may still not be redistributed
  separately).
- libthread related dropped, changes merged upstream.
- build/install targets partially reworked.
- compiler definitions are no more hardcoded (defaulting to pkgsrc's).
- introduced wrapper to use acme as a standalone application.
- removed executable bit from non-executable files.
- introduced a 'x11' build option (enabled by default) to install rio wm
  and related X11 utilities, as per TODO.
- taking maintainership.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=11cbb9c5c12c70d2129032552e8b210466cd8f69

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 plan9port/MESSAGE                                  |  11 +-
 plan9port/Makefile                                 | 123 +++++-
 plan9port/PLIST                                    | 103 ++---
 plan9port/TODO                                     |   3 -
 plan9port/distinfo                                 |  17 +-
 plan9port/files/acme.desktop                       |  11 +
 plan9port/files/acme.sh                            |   3 +
 plan9port/files/plan9.sh                           |  39 ++
 plan9port/options.mk                               |  17 +
 plan9port/patches/patch-INSTALL                    |  29 +-
 plan9port/patches/patch-bin_9c                     |  84 ++++
 plan9port/patches/patch-bin_9l                     |  47 +++
 plan9port/patches/patch-include_u.h                |  19 -
 .../patches/patch-src_cmd_devdraw_mkwsysrules.sh   |  26 +-
 .../patches/patch-src_libthread_NetBSD-386-asm.s   |  18 -
 .../patches/patch-src_libthread_NetBSD-power-asm.s |  27 --
 plan9port/patches/patch-src_libthread_NetBSD.c     | 448 ---------------------
 plan9port/patches/patch-src_libthread_sysofiles.sh |  20 -
 18 files changed, 377 insertions(+), 668 deletions(-)

diffs:
diff --git a/plan9port/MESSAGE b/plan9port/MESSAGE
index 6c027938cc..d939e9e519 100644
--- a/plan9port/MESSAGE
+++ b/plan9port/MESSAGE
@@ -1,9 +1,18 @@
 ===========================================================================
 $NetBSD$
 
-To use plan9port PLAN9 and PATH environment variables needs to be set to:
+To use plan9port, set the PLAN9 and PATH environmental variables as below:
 
  export PLAN9=${PREFIX}/plan9
  export PATH=${PATH}:${PLAN9}/bin
 
+Or source plan9.sh within your shell startup script.
+
+  . ${PKG_SYSCONFDIR}/profile.d/plan9.sh
+
+To execute plan9 specific apps, run them as arguments to the '9' script,
+i.e. '9 date'.
+
+Run '9 man 1 intro | less' to begin
+
 ===========================================================================
diff --git a/plan9port/Makefile b/plan9port/Makefile
index e6e3546b3e..b42970c09f 100644
--- a/plan9port/Makefile
+++ b/plan9port/Makefile
@@ -1,20 +1,24 @@
 # $NetBSD$
 
-DISTNAME=	plan9port-20200622
-CATEGORIES=	misc
+DISTNAME=	plan9port-20220912
+CATEGORIES=	misc plan9
 MASTER_SITES=	${MASTER_SITE_GITHUB:=9fans/}
-GITHUB_TAG=	95ab1308b410ad8547e38e47ec4a36f560dcece5
+GITHUB_TAG=	ffbdd1aa20c8a20a8e9dcd3cec644b6dfa3c6acb
 
-MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+MAINTAINER=	vms%retrobsd.ddns.net@localhost
 HOMEPAGE=	https://9fans.github.io/plan9port/
 COMMENT=	Plan 9 from User Space
-LICENSE=	lucent
+# mostly MIT (see LICENSE)
+# certain fonts may NOT be redistributed separately.
+LICENSE=	mit AND zlib
 
 USE_LANGUAGES=	c c++
-USE_TOOLS+=	bash:run perl
+USE_TOOLS+=	bash:run perl pax
+
+MKPIE_SUPPORTED=	no
+RELRO_SUPPORTED=	no
 
 REPLACE_BASH+=	bin/macedit
-REPLACE_BASH+=	bin/wintext
 REPLACE_BASH+=	mac/9term.app/Contents/MacOS/9term
 REPLACE_BASH+=	mac/Plumb.app/Contents/MacOS/plumb
 REPLACE_BASH+=	src/cmd/rc/checkparse
@@ -26,6 +30,7 @@ REPLACE_PERL+=	unix/man/fixurls
 REPLACE_INTERPRETER+=	rc
 REPLACE.rc.old=		.*/bin/rc
 REPLACE.rc.new=		${PREFIX}/plan9/bin/rc
+REPLACE_FILES.rc+=	bin/wintext
 REPLACE_FILES.rc+=	acid/transcript
 REPLACE_FILES.rc+=	acid/window
 REPLACE_FILES.rc+=	src/cmd/9660/mk9660.rc
@@ -49,32 +54,106 @@ REPLACE_FILES.rc+=	src/cmd/upas/misc/remotemail
 REPLACE_FILES.rc+=	src/cmd/venti/srv/conf.rc
 REPLACE_FILES.rc+=	src/cmd/venti/srv/tester
 
-INSTALL_ENV+=	PLAN9_TARGET=${PREFIX}/plan9 
+EGDIR=		${PREFIX}/share/examples/profile.d
+CONF_FILES+=	${EGDIR}/plan9.sh \
+		${PKG_SYSCONFDIR}/profile.d/plan9.sh
+
+SUBST_CLASSES+=		cc
+SUBST_STAGE.cc=		pre-configure
+SUBST_FILES.cc+=	INSTALL
+SUBST_FILES.cc+=	bin/9c bin/9l
+SUBST_VARS.cc=		CC
+SUBST_MESSAGE.cc=	Defining preferred compiler.
+
+SUBST_CLASSES+=		prefix
+SUBST_STAGE.prefix=	pre-build
+SUBST_FILES.prefix+=	src/cmd/devdraw/mkwsysrules.sh
+SUBST_FILES.prefix+=	plan9.sh acme.sh
+SUBST_VARS.prefix=	PREFIX
+SUBST_MESSAGE.prefix=	Replacing PREFIX placeholders.
+
+PLAN9_BUILD=		${DESTDIR}${PREFIX}/plan9
+INSTALL_ENV+=		PLAN9_TARGET=${PREFIX}/plan9
+
+MAKE_DIRS+=		${PKG_SYSCONFDIR}/profile.d
 
-pre-build:
-	${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/plan9
-	${MV} ${WRKSRC}/* ${DESTDIR}${PREFIX}/plan9
+INSTALLATION_DIRS+=	bin plan9 ${EGDIR}
+INSTALLATION_DIRS+=	share/doc/plan9
+INSTALLATION_DIRS+=	share/applications
+INSTALLATION_DIRS+=	share/pixmaps
+
+.include "options.mk"
 
 do-configure:
-	echo "CFLAGS='${CFLAGS}'" >> ${WRKSRC}/LOCAL.config
-	echo "LDFLAGS='${LDFLAGS}'" >> ${WRKSRC}/LOCAL.config
-	echo "FONTSRV=fontsrv" >> ${WRKSRC}/LOCAL.config
+	${RUN}${ECHO} "CC9='${CC}'" >> ${WRKSRC}/LOCAL.config
+	${RUN}${ECHO} "CC9FLAGS='${CFLAGS:S,-I${PREFIX}/include,,}'" \
+	  >> ${WRKSRC}/LOCAL.config
+	${RUN}${ECHO} "LDFLAGS='${LDFLAGS}'" >> ${WRKSRC}/LOCAL.config
+	${RUN}${ECHO} "FONTSRV=fontsrv"	>> ${WRKSRC}/LOCAL.config
+.if !empty(PKG_OPTIONS:Mx11)
+	${RUN}${ECHO} "WSYSTYPE='x11'" >> ${WRKSRC}/LOCAL.config
+.else
+	${RUN}${ECHO} "WSYSTYPE='nowsys'" >> ${WRKSRC}/LOCAL.config
+.endif
+
+post-configure:
+.for s in acme.sh plan9.sh
+	${RUN}${CP} ${FILESDIR}/${s} ${WRKSRC}
+.endfor
 
 do-build:
-	${RUN} cd ${DESTDIR}${PREFIX}/plan9 && \
-	    ${PKGSRC_SETENV} ${MAKE_ENV} ./INSTALL -b
+	${RUN}cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${SH} ./INSTALL -b
 
 post-build:
-	${RUN} ${FIND} ${DESTDIR}${PREFIX}/plan9 -type f -name '*.orig' | \
-	    ${XARGS} ${RM} -f
+.for h in *.orig .gitignore .gitkeep .travis.yml
+	${RUN}${FIND} ${WRKSRC} -type f -name "${h}" -delete
+.endfor
 
 do-install:
-	${RUN} cd ${DESTDIR}${PREFIX}/plan9 && \
-	    ${PKGSRC_SETENV} ${INSTALL_ENV} ${MAKE_ENV} ./INSTALL -c
+	# Move everything to the PLAN9 target.
+	${RUN}cd ${WRKSRC} && ${PAX} -rw -pm . ${PLAN9_BUILD}
+	# Rename hard-coded paths and builds mans.
+	${RUN}cd ${PLAN9_BUILD} &&			\
+	  ${SETENV} ${MAKE_ENV} ${INSTALL_ENV} ./INSTALL -c
+.for f in CHANGES LICENSE README.md
+	${RUN}cd ${PLAN9_BUILD} &&			\
+	  ${PAX} -rw -pm ${f} ${DESTDIR}${PREFIX}/share/doc/plan9
+.endfor
+	${INSTALL_SCRIPT} ${PLAN9_BUILD}/plan9.sh	\
+	  ${DESTDIR}${PREFIX}/share/examples/profile.d
+	# Delete installation files and other leftovers.
+	${RUN}${FIND} ${PLAN9_BUILD} -maxdepth 1 -type f ! -name rcmain -delete
+	# Avoid 'executable bit is set on non-executable file'
+.for x in bclib mimetype
+	${RUN}${FIND} ${PLAN9_BUILD}/lib 		\
+	  -type f -name ${x} -exec ${CHMOD} -x '{}' \;
+.endfor
+.for x in ignore namefiles names.local rewrite
+	${RUN}${FIND} ${PLAN9_BUILD}/mail/lib 		\
+	  -type f -name ${x} -exec ${CHMOD} -x '{}' \;
+.endfor
+.for x in resample.1 soelim.1 ssam.1
+	${RUN}${FIND} ${PLAN9_BUILD}/man/man1		\
+	  -type f -name ${x} -exec ${CHMOD} -x '{}' \;
+.endfor
+.for x in compress.c filter.y mkfile
+	${RUN}${FIND} ${PLAN9_BUILD}/src		\
+	  -type f -name ${x} -exec ${CHMOD} -x '{}' \;
+.endfor
+	${RUN}${CHMOD} -x ${PLAN9_BUILD}/font/MAP
+	${RUN}${CHMOD} -x ${PLAN9_BUILD}/man/fonts
+
+post-install:
+	${INSTALL_SCRIPT} ${WRKSRC}/acme.sh		\
+	  ${DESTDIR}${PREFIX}/bin/acme
+	${INSTALL_DATA} ${FILESDIR}/acme.desktop	\
+	  ${DESTDIR}${PREFIX}/share/applications
+	${INSTALL_DATA} ${WRKSRC}/dist/glendacircle.png	\
+	  ${DESTDIR}${PREFIX}/share/pixmaps/acme.png
 
 .include "../../fonts/fontconfig/buildlink3.mk"
+.include "../../graphics/freetype2/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
 PTHREAD_AUTO_VARS=	yes
 .include "../../mk/pthread.buildlink3.mk"
-.include "../../graphics/freetype2/buildlink3.mk"
-.include "../../x11/libX11/buildlink3.mk"
 .include "../../mk/bsd.pkg.mk"
diff --git a/plan9port/PLIST b/plan9port/PLIST
index b65970b9bb..b9eed1616c 100644
--- a/plan9port/PLIST
+++ b/plan9port/PLIST
@@ -1,4 +1,5 @@
 @comment $NetBSD$
+bin/acme
 plan9/acid/386
 plan9/acid/68020
 plan9/acid/acme
@@ -28,7 +29,6 @@ plan9/bin/""
 plan9/bin/9
 plan9/bin/9.rc
 plan9/bin/9660srv
-plan9/bin/9a
 plan9/bin/9ar
 plan9/bin/9c
 plan9/bin/9fs
@@ -111,7 +111,6 @@ plan9/bin/file
 plan9/bin/fmt
 plan9/bin/fontsrv
 plan9/bin/fortune
-plan9/bin/fossil/.gitkeep
 plan9/bin/fossil/conf
 plan9/bin/fossil/flchk
 plan9/bin/fossil/flfmt
@@ -119,7 +118,6 @@ plan9/bin/fossil/fossil
 plan9/bin/fossil/last
 plan9/bin/fossil/view
 plan9/bin/freq
-plan9/bin/fs/.gitkeep
 plan9/bin/fs/32vfs
 plan9/bin/fs/cpiofs
 plan9/bin/fs/tapfs
@@ -213,7 +211,7 @@ plan9/bin/rc
 plan9/bin/read
 plan9/bin/readcons
 plan9/bin/resample
-plan9/bin/rio
+${PLIST.x11}plan9/bin/rio
 plan9/bin/rm
 plan9/bin/rsa2csr
 plan9/bin/rsa2pub
@@ -294,7 +292,6 @@ plan9/bin/vac
 plan9/bin/vacfs
 plan9/bin/vbackup
 plan9/bin/vcat
-plan9/bin/venti/.gitkeep
 plan9/bin/venti/buildindex
 plan9/bin/venti/checkarenas
 plan9/bin/venti/checkindex
@@ -328,18 +325,16 @@ plan9/bin/wc
 plan9/bin/web
 plan9/bin/win
 plan9/bin/wintext
-plan9/bin/winwatch
+${PLIST.x11}plan9/bin/winwatch
 plan9/bin/wmail
 plan9/bin/xd
-plan9/bin/xshove
+${PLIST.x11}plan9/bin/xshove
 plan9/bin/yacc
 plan9/bin/yesterday
 plan9/bin/yuv
 plan9/bin/zcat
 plan9/bin/zerotrunc
 plan9/bin/zip
-plan9/config
-plan9/configure
 plan9/dict/README
 plan9/dist/README
 plan9/dist/addsrclinks
@@ -4096,7 +4091,6 @@ plan9/include/thread.h
 plan9/include/u.h
 plan9/include/utf.h
 plan9/include/venti.h
-plan9/install.txt
 plan9/lib/CVS.IEXIST
 plan9/lib/acme.rc
 plan9/lib/amspell
@@ -5332,6 +5326,7 @@ plan9/postscript/troff/H
 plan9/postscript/troff/HB
 plan9/postscript/troff/HI
 plan9/postscript/troff/HL
+plan9/postscript/troff/HX
 plan9/postscript/troff/Helvetica-Narrow-BoldOblique
 plan9/postscript/troff/I
 plan9/postscript/troff/Jp
@@ -5612,7 +5607,6 @@ plan9/src/cmd/auxstats/SunOS.c
 plan9/src/cmd/auxstats/dat.h
 plan9/src/cmd/auxstats/main.c
 plan9/src/cmd/auxstats/mkfile
-plan9/src/cmd/awk/README
 plan9/src/cmd/awk/awk.h
 plan9/src/cmd/awk/awkgram.y
 plan9/src/cmd/awk/lex.c
@@ -6461,13 +6455,10 @@ plan9/src/cmd/rio/winwatch.c
 plan9/src/cmd/rio/xevents.c
 plan9/src/cmd/rio/xshove.c
 plan9/src/cmd/rm.c
-plan9/src/cmd/sam/README
-plan9/src/cmd/sam/_libc.h
 plan9/src/cmd/sam/address.c
 plan9/src/cmd/sam/buff.c
 plan9/src/cmd/sam/cmd.c
 plan9/src/cmd/sam/disk.c
-plan9/src/cmd/sam/err
 plan9/src/cmd/sam/error.c
 plan9/src/cmd/sam/errors.h
 plan9/src/cmd/sam/file.c
@@ -6479,7 +6470,6 @@ plan9/src/cmd/sam/mkfile
 plan9/src/cmd/sam/moveto.c
 plan9/src/cmd/sam/multi.c
 plan9/src/cmd/sam/parse.h
-plan9/src/cmd/sam/plan9.c
 plan9/src/cmd/sam/plumb.h
 plan9/src/cmd/sam/rasp.c
 plan9/src/cmd/sam/regexp.c
@@ -7031,7 +7021,6 @@ plan9/src/lib9/execl.c
 plan9/src/lib9/exitcode.c
 plan9/src/lib9/fcallfmt.c
 plan9/src/lib9/fmt/LICENSE
-plan9/src/lib9/fmt/NOTICE
 plan9/src/lib9/fmt/README
 plan9/src/lib9/fmt/charstod.c
 plan9/src/lib9/fmt/dofmt.c
@@ -7145,7 +7134,6 @@ plan9/src/lib9/u64.c
 plan9/src/lib9/udp.c
 plan9/src/lib9/unsharp.c
 plan9/src/lib9/utf/LICENSE
-plan9/src/lib9/utf/NOTICE
 plan9/src/lib9/utf/README
 plan9/src/lib9/utf/lib9.h
 plan9/src/lib9/utf/plan9.h
@@ -7176,7 +7164,6 @@ plan9/src/lib9/waitpid.c
 plan9/src/lib9/write.c
 plan9/src/lib9/zoneinfo.c
 plan9/src/lib9/zoneinfo.h
-plan9/src/lib9p/_post.c
 plan9/src/lib9p/dirread.c
 plan9/src/lib9p/fid.c
 plan9/src/lib9p/file.c
@@ -7186,8 +7173,6 @@ plan9/src/lib9p/mem.c
 plan9/src/lib9p/mkfile
 plan9/src/lib9p/parse.c
 plan9/src/lib9p/portdate
-plan9/src/lib9p/post.c
-plan9/src/lib9p/post.h
 plan9/src/lib9p/ramfs.c
 plan9/src/lib9p/req.c
 plan9/src/lib9p/srv.c
@@ -7591,21 +7576,6 @@ plan9/src/libmemlayer/ltofront.c
 plan9/src/libmemlayer/ltorear.c
 plan9/src/libmemlayer/mkfile
 plan9/src/libmemlayer/unload.c
-plan9/src/libmp/386/mkfile
-plan9/src/libmp/386/mpdigdiv-Darwin.s
-plan9/src/libmp/386/mpdigdiv.s
-plan9/src/libmp/386/mpvecadd-Darwin.s
-plan9/src/libmp/386/mpvecadd.s
-plan9/src/libmp/386/mpvecdigmuladd-Darwin.s
-plan9/src/libmp/386/mpvecdigmuladd.s
-plan9/src/libmp/386/mpvecdigmulsub-Darwin.s
-plan9/src/libmp/386/mpvecdigmulsub.s
-plan9/src/libmp/386/mpvecsub-Darwin.s
-plan9/src/libmp/386/mpvecsub.s
-plan9/src/libmp/PowerMacintosh/mkfile
-plan9/src/libmp/arm/mkfile
-plan9/src/libmp/arm64/mkfile
-plan9/src/libmp/mips/mkfile
 plan9/src/libmp/mkfile
 plan9/src/libmp/port/betomp.c
 plan9/src/libmp/port/crt.c
@@ -7644,10 +7614,6 @@ plan9/src/libmp/port/os.h
 plan9/src/libmp/port/portdate
 plan9/src/libmp/port/reduce
 plan9/src/libmp/port/strtomp.c
-plan9/src/libmp/power/mkfile
-plan9/src/libmp/sparc64/mkfile
-plan9/src/libmp/sun4u/mkfile
-plan9/src/libmp/x86_64/mkfile
 plan9/src/libmux/COPYRIGHT
 plan9/src/libmux/io.c
 plan9/src/libmux/mkfile
@@ -7698,13 +7664,6 @@ plan9/src/libregexp/rregexec.c
 plan9/src/libregexp/rregsub.c
 plan9/src/libregexp/test.c
 plan9/src/libregexp/test2.c
-plan9/src/libsec/386/md5block.spp
-plan9/src/libsec/386/mkfile
-plan9/src/libsec/386/sha1block.spp
-plan9/src/libsec/PowerMacintosh/mkfile
-plan9/src/libsec/arm/mkfile
-plan9/src/libsec/arm64/mkfile
-plan9/src/libsec/mips/mkfile
 plan9/src/libsec/mkfile
 plan9/src/libsec/port/aes.c
 plan9/src/libsec/port/blowfish.c
@@ -7766,10 +7725,6 @@ plan9/src/libsec/port/smallprimetest.c
 plan9/src/libsec/port/thumb.c
 plan9/src/libsec/port/tlshand.c
 plan9/src/libsec/port/x509.c
-plan9/src/libsec/power/mkfile
-plan9/src/libsec/sparc64/mkfile
-plan9/src/libsec/sun4u/mkfile
-plan9/src/libsec/x86_64/mkfile
 plan9/src/libsunrpc/COPYING
 plan9/src/libsunrpc/authunix.c
 plan9/src/libsunrpc/client.c
@@ -7787,16 +7742,8 @@ plan9/src/libsunrpc/rpc.c
 plan9/src/libsunrpc/server.c
 plan9/src/libsunrpc/suncall.c
 plan9/src/libsunrpc/udp.c
-plan9/src/libthread/386-ucontext.c
-plan9/src/libthread/386-ucontext.h
-plan9/src/libthread/COPYING.SPARC64-CONTEXT
 plan9/src/libthread/COPYRIGHT
-plan9/src/libthread/Linux-arm-asm.s
-plan9/src/libthread/Linux-sparc64-context.S
-plan9/src/libthread/OpenBSD-386-asm.s
-plan9/src/libthread/OpenBSD-power-asm.S
-plan9/src/libthread/OpenBSD-x86_64-asm.S
-plan9/src/libthread/arm-ucontext.c
+plan9/src/libthread/bg.c
 plan9/src/libthread/channel.c
 plan9/src/libthread/daemonize.c
 plan9/src/libthread/exec.c
@@ -7804,14 +7751,8 @@ plan9/src/libthread/ioproc.c
 plan9/src/libthread/ioproc.h
 plan9/src/libthread/iorw.c
 plan9/src/libthread/mkfile
-plan9/src/libthread/power-ucontext.c
-plan9/src/libthread/power-ucontext.h
 plan9/src/libthread/pthread.c
 plan9/src/libthread/ref.c
-plan9/src/libthread/sparc64-ucontext.c
-plan9/src/libthread/stkmalloc.c
-plan9/src/libthread/stkmmap.c
-plan9/src/libthread/sysofiles.sh
 plan9/src/libthread/test/mkfile
 plan9/src/libthread/test/pthreadloop.c
 plan9/src/libthread/test/rdaemon.c
@@ -7825,8 +7766,6 @@ plan9/src/libthread/test/tspawnloop.c
 plan9/src/libthread/thread.c
 plan9/src/libthread/threadimpl.h
 plan9/src/libthread/wait.c
-plan9/src/libthread/x86_64-ucontext.c
-plan9/src/libthread/x86_64-ucontext.h
 plan9/src/libventi/cache.acid
 plan9/src/libventi/cache.c
 plan9/src/libventi/client.c
@@ -8067,19 +8006,16 @@ plan9/unix/NOTICE.utf
 plan9/unix/README
 plan9/unix/README.dot
 plan9/unix/fmt.h
-plan9/unix/make/Make.Darwin-386
-plan9/unix/make/Make.Darwin-PowerMacintosh
-plan9/unix/make/Make.FreeBSD-386
-plan9/unix/make/Make.HP-UX-9000
-plan9/unix/make/Make.Linux-386
-plan9/unix/make/Make.Linux-power
-plan9/unix/make/Make.Linux-x86_64
-plan9/unix/make/Make.NetBSD-386
-plan9/unix/make/Make.OSF1-alpha
-plan9/unix/make/Make.OpenBSD-386
-plan9/unix/make/Make.SunOS-sun4u
-plan9/unix/make/Make.SunOS-sun4u-cc
-plan9/unix/make/Make.SunOS-sun4u-gcc
+plan9/unix/make/Make.Darwin
+plan9/unix/make/Make.FreeBSD
+plan9/unix/make/Make.HP-UX
+plan9/unix/make/Make.Linux
+plan9/unix/make/Make.NetBSD
+plan9/unix/make/Make.OSF1
+plan9/unix/make/Make.OpenBSD
+plan9/unix/make/Make.SunOS
+plan9/unix/make/Make.SunOS-cc
+plan9/unix/make/Make.SunOS-gcc
 plan9/unix/make/Makefile.BOT
 plan9/unix/make/Makefile.CMD
 plan9/unix/make/Makefile.LIB
@@ -8115,3 +8051,10 @@ plan9/unix/mkfile.regexp
 plan9/unix/mkfile.utf
 plan9/unix/mkfile.what
 plan9/unix/utf.h
+share/applications/acme.desktop
+share/doc/plan9/CHANGES
+share/doc/plan9/LICENSE
+share/doc/plan9/README.md
+share/examples/profile.d/plan9.sh
+share/pixmaps/acme.png
+@pkgdir share/doc/plan9
diff --git a/plan9port/TODO b/plan9port/TODO
deleted file mode 100644
index c3ce453f61..0000000000
--- a/plan9port/TODO
+++ /dev/null
@@ -1,3 +0,0 @@
-- Address possible further hardcoded assumptions
-- Add possible `x11' option - enabled by default - in order to disable
-  building of all x11 tools
diff --git a/plan9port/distinfo b/plan9port/distinfo
index f474ebec16..31c71106f5 100644
--- a/plan9port/distinfo
+++ b/plan9port/distinfo
@@ -1,13 +1,10 @@
 $NetBSD$
 
-RMD160 (plan9port-20200622-95ab1308b410ad8547e38e47ec4a36f560dcece5.tar.gz) = dcd35a7564d1c0569383a6d9782a6c64de10ccac
-SHA512 (plan9port-20200622-95ab1308b410ad8547e38e47ec4a36f560dcece5.tar.gz) = e3e2f66c854304702f10568a3ae8990f62b6b66872f0bb6b9e3f629ff5616e82ce2c88331ec58f27d1c9cf9fda6c7d0cb072e7a746ed0ce94dc600918efda964
-Size (plan9port-20200622-95ab1308b410ad8547e38e47ec4a36f560dcece5.tar.gz) = 23445330 bytes
-SHA1 (patch-INSTALL) = 677acd580efcd7c5e6d75e3c43d41a384e291918
-SHA1 (patch-include_u.h) = d8681e7c663f9dd6da46d0af2eb33a8e1b014fbd
-SHA1 (patch-src_cmd_devdraw_mkwsysrules.sh) = 7418cfbedafa74145c4c3395fe11b2bb3b6b50ef
+BLAKE2s (plan9port-20220912-ffbdd1aa20c8a20a8e9dcd3cec644b6dfa3c6acb.tar.gz) = bea5a32cd2108acca093437e3afe346b6d82eed652fa067a42c444157c9c84ce
+SHA512 (plan9port-20220912-ffbdd1aa20c8a20a8e9dcd3cec644b6dfa3c6acb.tar.gz) = 12889ca91d04cb623d44efb39196dca7591b4fb81f06e6b47bb07aae7aeff054191353ff44c8fd75c56505a42102c1ad7eb058e428b59c0d098c76df0ce6b7d4
+Size (plan9port-20220912-ffbdd1aa20c8a20a8e9dcd3cec644b6dfa3c6acb.tar.gz) = 23407448 bytes
+SHA1 (patch-INSTALL) = c57b8248b52f4f2143c6b2d67226fb3e0ccfe8a1
+SHA1 (patch-bin_9c) = d446c161e23621c2002f4c6b098b31eb0c4f5e4a
+SHA1 (patch-bin_9l) = e6daeac87657ed3e25e0f0db403d973f60d544d2
+SHA1 (patch-src_cmd_devdraw_mkwsysrules.sh) = b81252ff054868622e07e743e436ddaad540b9e0
 SHA1 (patch-src_cmd_rio_mkfile) = b2584bf14a71efb7af4bebba763035d21b38a194
-SHA1 (patch-src_libthread_NetBSD-386-asm.s) = 474ee6eaf11115b31b1abf4e1536eceab4b5e0c7
-SHA1 (patch-src_libthread_NetBSD-power-asm.s) = 516705bd9d87e4c4010b7eff2add38a9ec1abbda
-SHA1 (patch-src_libthread_NetBSD.c) = 88a67788c005fd0bb7df3a6b205577f6a7377949
-SHA1 (patch-src_libthread_sysofiles.sh) = 3ec847f2ab77bfc44d6ed679b62eb035dc5b19ea
diff --git a/plan9port/files/acme.desktop b/plan9port/files/acme.desktop
new file mode 100644
index 0000000000..6d132d8943
--- /dev/null
+++ b/plan9port/files/acme.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Application
+Name=Acme
+GenericName=Editor
+Comment=Editor from Plan9
+Exec=acme
+Icon=acme
+Terminal=false
+StartupNotify=false
+Categories=Application;Development;TextEditor;
diff --git a/plan9port/files/acme.sh b/plan9port/files/acme.sh
new file mode 100644
index 0000000000..2ea3eb270c
--- /dev/null
+++ b/plan9port/files/acme.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+. @PREFIX@/etc/profile.d/plan9.sh
+9 acme "$@"
diff --git a/plan9port/files/plan9.sh b/plan9port/files/plan9.sh
new file mode 100644
index 0000000000..a3336919ec
--- /dev/null
+++ b/plan9port/files/plan9.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Define plan9 environment.
+PLAN9=@PREFIX@/plan9
+PATH="$PATH:$PLAN9/bin"
+
+home=$HOME
+user=$USER
+
+# Set rc(1) prompt.
+H=`hostname | sed 's/\..*//'`
+prompt="$H-;  "
+
+# get rid of ANSI color codes.
+#TERM=dumb
+
+# Default font for Plan 9 programs.
+#font=${PLAN9}/font/lucm/unicode.9.font
+font=${PLAN9}/font/pelm/unicode.8.font
+
+# Preferred plan9 editor.
+editor=acme
+
+# Sane text paging.
+#MANPAGER='9 p'
+#PAGER='col -b'
+
+export \
+H\
+MANPAGER\
+PAGER\
+PATH\
+PLAN9\
+TERM\
+editor\
+font\
+home\
+prompt\
+user\
diff --git a/plan9port/options.mk b/plan9port/options.mk
new file mode 100644
index 0000000000..c4c998fe42
--- /dev/null
+++ b/plan9port/options.mk
@@ -0,0 +1,17 @@
+# $NetBSD$
+PKG_OPTIONS_VAR=	PKG_OPTIONS.plan9port
+PKG_SUPPORTED_OPTIONS=	x11
+PKG_SUGGESTED_OPTIONS=	x11
+PLIST_VARS+=		x11
+
+.include "../../mk/bsd.options.mk"
+
+# Build rio and related X11 tools.
+.if !empty(PKG_OPTIONS:Mx11)
+
+.include "../../x11/libXt/buildlink3.mk"
+.include "../../x11/libXext/buildlink3.mk"
+.include "../../x11/libX11/buildlink3.mk"
+
+PLIST.x11=		yes
+.endif
diff --git a/plan9port/patches/patch-INSTALL b/plan9port/patches/patch-INSTALL
index b83a4acbf9..3616131120 100644
--- a/plan9port/patches/patch-INSTALL
+++ b/plan9port/patches/patch-INSTALL
@@ -1,12 +1,31 @@
 $NetBSD$
 
-Silent is gold, ability to debug possible errors as the user wishes
-is much more precious (do not filter/redirect stdout/stderr to files
-making possible debugging harder).
+Do not filter/redirect stdout/stderr to files making possible
+debugging harder.
 
---- INSTALL.orig	2020-06-22 15:22:27.000000000 +0000
+Properly honor $CC.
+
+--- INSTALL.orig	2022-09-12 14:35:36.000000000 +0000
 +++ INSTALL
-@@ -211,5 +211,5 @@ if $doinstall; then
+@@ -113,7 +113,7 @@ fi
+ if [ `uname` != Darwin ]; then
+ 	# Determine whether fontsrv X11 files are available.
+ 	rm -f a.out
+-	cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
++	@CC@ -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
+ 	    -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \
+ 	    -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
+ 	if [ -f a.out ]; then
+@@ -139,7 +139,7 @@ echo "* Compiler version:"
+ cd src
+ if $dobuild; then
+ 	echo "* Building mk..."
+-	../dist/buildmk 2>&1 | sed 's/^[+] //'
++	../dist/buildmk 2>&1
+ 
+ 	if [ ! -x ../bin/mk ]; then
+ 		echo "* Error: mk failed to build."
+@@ -206,5 +206,5 @@ if $doinstall; then
  	echo "	PLAN9=$PLAN9 export PLAN9"
  	echo '	PATH=$PATH:$PLAN9/bin export PATH'
  fi
diff --git a/plan9port/patches/patch-bin_9c b/plan9port/patches/patch-bin_9c
new file mode 100644
index 0000000000..9e02a34942
--- /dev/null
+++ b/plan9port/patches/patch-bin_9c
@@ -0,0 +1,84 @@
+$NetBSD$
+
+Let pkgsrc define its own compiler.
+
+--- bin/9c.orig	2022-09-12 14:35:36.000000000 +0000
++++ bin/9c
+@@ -3,7 +3,7 @@
+ test -f $PLAN9/config && . $PLAN9/config
+ usegcc()
+ {
+-	cc=${CC9:-gcc}
++	cc=${CC9:-@CC@}
+ 	cflags=" \
+ 		-O2 \
+ 		-c \
+@@ -60,7 +60,7 @@ quiet()
+ 
+ useclang()
+ {
+-	cc=${CC9:-clang}
++	cc=${CC9:-@CC@}
+ 	cflags=" \
+ 		-O2 \
+ 		-c \
+@@ -87,7 +87,7 @@ useclang()
+ 
+ usexlc()
+ {
+-	cc=${CC9:-xlc_r}
++	cc=${CC9:-@CC@}
+ 	cflags=" \
+ 		-c \
+ 		-O2 \
+@@ -103,15 +103,34 @@ usexlc()
+ 	cflags="$cflags $CC9FLAGS"
+ }
+ 
+-tag="${SYSNAME:-`uname`}-${CC9:-cc}"
++usesunpro()
++{
++    cc=${CC9:-@CC@} 
++	cflags=" \
++		-mt \
++		-g \
++		-c \
++		-xO3 \
++		-xCC \
++		-fast \
++		-errfmt \
++		-erroff=none \
++	"
++}
++
++
++
++tag="${SYSNAME:-`uname`}-${CC9:-@CC@}"
+ case "$tag" in
+ *DragonFly*gcc*|*BSD*gcc*)	usegcc ;;
+ *DragonFly*clang|*BSD*clang*)	useclang ;;
++*NetBSD*cc*|DragonFly*cc*)	usegcc ;;
++*OpenBSD*cc*|FreeBSD*cc*)	useclang ;;
+ *Darwin*)
+ 		useclang
+ 		cflags="$cflags -g3 -m64"
+ 		;;
+-*HP-UX*)	cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
++*HP-UX*)	cc=${CC9:-@CC@}; cflags="-g -O -c -Ae" ;;
+ *Linux*)	usegcc
+ 		case "${CC9:-gcc}" in
+ 		tcc)
+@@ -120,9 +139,10 @@ case "$tag" in
+ 			;;
+ 		esac
+ 		;;
+-*OSF1*)		cc=${CC9:-cc}; cflags="-g -O -c" ;;
+-*SunOS*-cc)	cc=cc;
+-		cflags="-mt -g -O -c -xCC -D__sun__"
++*OSF1*)		cc=${CC9:-@CC@}; cflags="-g -O -c" ;;
++*SunOS*-cc)
++		usesunpro
++		cflags="$cflags -D__sun__"
+ 		u=`uname`
+ 		v=`uname -r`
+ 		s=`echo $u$v | tr '. ' '__'`
diff --git a/plan9port/patches/patch-bin_9l b/plan9port/patches/patch-bin_9l
new file mode 100644
index 0000000000..d02b2c7254
--- /dev/null
+++ b/plan9port/patches/patch-bin_9l
@@ -0,0 +1,47 @@
+$NetBSD$
+
+Let pkgsrc define its own compiler.
+
+--- bin/9l.orig	2022-09-12 14:35:36.000000000 +0000
++++ bin/9l
+@@ -14,26 +14,26 @@ extralibs="-lm"
+ tag="${SYSNAME:-`uname`}"
+ case "$tag" in
+ *DragonFly*|*BSD*)
+-	ld="${CC9:-gcc} $CC9FLAGS"
++	ld="${CC9:-@CC@} $CC9FLAGS"
+ 	userpath=true
+ 	extralibs="$extralibs -lutil"
+ 	;;
+ *OSF1*)
+-	ld="${CC9:-cc} $CC9FLAGS"
++	ld="${CC9:-@CC@} $CC9FLAGS"
+ 	userpath=true
+ 	extralibs="$extralibs -lutil"
+ 	nmflags="-B"
+ 	;;
+ *Linux*)
+-	ld="${CC9:-gcc} $CC9FLAGS"
++	ld="${CC9:-@CC@} $CC9FLAGS"
+ 	userpath=true
+ 	extralibs="$extralibs -lutil -lresolv -lpthread"
+ 	;;
+ *Darwin*)
+-	ld="${CC9:-gcc} -m64 $CC9FLAGS"
++	ld="${CC9:-@CC@} -m64 $CC9FLAGS"
+ 	;;
+ *SunOS*)
+-	ld="${CC9:-cc} -g $CC9FLAGS"
++	ld="${CC9:-@CC@} -g $CC9FLAGS"
+ 	extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
+ 	# Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
+ 	for i in "$libsl $@"
+@@ -60,7 +60,7 @@ case "$tag" in
+ 	esac
+ 	;;
+ *AIX*)
+-	ld="${CC9:-xlc_r} $CC9FLAGS"
++	ld="${CC9:-@CC@} $CC9FLAGS"
+ 	nmflags="-A -B"
+ 	;;
+ *)
diff --git a/plan9port/patches/patch-include_u.h b/plan9port/patches/patch-include_u.h
deleted file mode 100644
index 6f3f30a5b9..0000000000
--- a/plan9port/patches/patch-include_u.h
+++ /dev/null
@@ -1,19 +0,0 @@
-$NetBSD$
-
-Use pthreads on NetBSD.
-
-From upstream pull request #355:
-
- <https://github.com/9fans/plan9port/pull/355>
-
---- include/u.h.orig	2020-06-22 15:22:27.000000000 +0000
-+++ include/u.h
-@@ -108,6 +108,8 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf
- #elif defined(__NetBSD__)
- #	include <sched.h>
- #	include <sys/types.h>
-+#	include <pthread.h>
-+#	define PLAN9PORT_USING_PTHREADS 1
- #	undef _NEEDUSHORT
- #	undef _NEEDUINT
- #	undef _NEEDULONG
diff --git a/plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh b/plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh
index f8eb90b9ab..147d6eb8a7 100644
--- a/plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh
+++ b/plan9port/patches/patch-src_cmd_devdraw_mkwsysrules.sh
@@ -1,19 +1,15 @@
 $NetBSD$
 
-Also look in /usr/X11R7.
+Add modular-xorg support for rio.
 
-From upstream pull request #362:
-
- <https://github.com/9fans/plan9port/pull/362>
-
---- src/cmd/devdraw/mkwsysrules.sh.orig	2020-06-22 15:22:27.000000000 +0000
+--- src/cmd/devdraw/mkwsysrules.sh.orig	2022-09-12 14:35:36.000000000 +0000
 +++ src/cmd/devdraw/mkwsysrules.sh
-@@ -7,6 +7,8 @@ if [ "x$X11" = "x" ]; then 
- 		X11=/usr/X11R6
- 	elif [ -d /usr/local/X11R6 ]; then
- 		X11=/usr/local/X11R6
-+	elif [ -d /usr/X11R7 ]; then
-+		X11=/usr/X11R7
- 	elif [ -d /usr/X ]; then
- 		X11=/usr/X
- 	elif [ -d /usr/openwin ]; then	# for Sun
+@@ -17,6 +17,8 @@ if [ "x$X11" = "x" ]; then 
+ 		X11=/usr
+ 	elif [ -d /usr/local/include/X11 ]; then
+ 		X11=/usr/local
++	elif [ -d @PREFIX@/include/X11 ]; then
++		X11=@PREFIX@
+ 	else
+ 		X11=noX11dir
+ 	fi
diff --git a/plan9port/patches/patch-src_libthread_NetBSD-386-asm.s b/plan9port/patches/patch-src_libthread_NetBSD-386-asm.s
deleted file mode 100644
index 2e6e2773a0..0000000000
--- a/plan9port/patches/patch-src_libthread_NetBSD-386-asm.s
+++ /dev/null
@@ -1,18 +0,0 @@
-$NetBSD$
-
-Use pthreads on NetBSD.
-
-From upstream pull request #355:
-
- <https://github.com/9fans/plan9port/pull/355>
-
---- src/libthread/NetBSD-386-asm.s.orig	2020-06-22 15:22:27.000000000 +0000
-+++ src/libthread/NetBSD-386-asm.s
-@@ -1,7 +0,0 @@
--.globl _tas
--_tas:
--	movl $0xCAFEBABE, %eax
--	movl 4(%esp), %ecx
--	xchgl %eax, 0(%ecx)
--	ret
--
diff --git a/plan9port/patches/patch-src_libthread_NetBSD-power-asm.s b/plan9port/patches/patch-src_libthread_NetBSD-power-asm.s
deleted file mode 100644
index eda7d01a9c..0000000000
--- a/plan9port/patches/patch-src_libthread_NetBSD-power-asm.s
+++ /dev/null
@@ -1,27 +0,0 @@
-$NetBSD$
-
-Use pthreads on NetBSD.
-
-From upstream pull request #355:
-
- <https://github.com/9fans/plan9port/pull/355>
-
---- src/libthread/NetBSD-power-asm.s.orig	2020-06-22 15:22:27.000000000 +0000
-+++ src/libthread/NetBSD-power-asm.s
-@@ -1,16 +0,0 @@
--	.globl	_tas
--_tas:
--	li	%r0, 0
--	mr	%r4, %r3
--	lis	%r5, 0xcafe
--	ori	%r5, %r5, 0xbabe
--1:
--	lwarx	%r3, %r0, %r4
--	cmpwi	%r3, 0
--	bne	2f
--	stwcx.	%r5, %r0, %r4
--	bne-	1b
--2:
--	sync
--	blr
--
diff --git a/plan9port/patches/patch-src_libthread_NetBSD.c b/plan9port/patches/patch-src_libthread_NetBSD.c
deleted file mode 100644
index 655e0cfa63..0000000000
--- a/plan9port/patches/patch-src_libthread_NetBSD.c
+++ /dev/null
@@ -1,448 +0,0 @@
-$NetBSD$
-
-Use pthreads on NetBSD.
-
-From upstream pull request #355:
-
- <https://github.com/9fans/plan9port/pull/355>
-
---- src/libthread/NetBSD.c.orig	2020-06-22 15:22:27.000000000 +0000
-+++ src/libthread/NetBSD.c
-@@ -1,437 +0,0 @@
--#include "threadimpl.h"
--
--#undef exits
--#undef _exits
--
--static int
--timefmt(Fmt *fmt)
--{
--	static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
--		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
--	vlong ns;
--	Tm tm;
--	ns = nsec();
--	tm = *localtime(time(0));
--	return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d",
--		mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec,
--		(int)(ns%1000000000)/1000000);
--}
--
--/*
-- * spin locks
-- */
--extern int _tas(int*);
--
--void
--_threadunlock(Lock *l, ulong pc)
--{
--	USED(pc);
--
--	l->held = 0;
--}
--
--int
--_threadlock(Lock *l, int block, ulong pc)
--{
--	int i;
--static int first=1;
--if(first) {first=0; fmtinstall('\001', timefmt);}
--
--	USED(pc);
--
--	/* once fast */
--	if(!_tas(&l->held))
--		return 1;
--	if(!block)
--		return 0;
--
--	/* a thousand times pretty fast */
--	for(i=0; i<1000; i++){
--		if(!_tas(&l->held))
--			return 1;
--		sched_yield();
--	}
--	/* now increasingly slow */
--	for(i=0; i<10; i++){
--		if(!_tas(&l->held))
--			return 1;
--		usleep(1);
--	}
--fprint(2, "%\001 %s: lock loop1 %p from %lux\n", argv0, l, pc);
--	for(i=0; i<10; i++){
--		if(!_tas(&l->held))
--			return 1;
--		usleep(10);
--	}
--fprint(2, "%\001 %s: lock loop2 %p from %lux\n", argv0, l, pc);
--	for(i=0; i<10; i++){
--		if(!_tas(&l->held))
--			return 1;
--		usleep(100);
--	}
--fprint(2, "%\001 %s: lock loop3 %p from %lux\n", argv0, l, pc);
--	for(i=0; i<10; i++){
--		if(!_tas(&l->held))
--			return 1;
--		usleep(1000);
--	}
--fprint(2, "%\001 %s: lock loop4 %p from %lux\n", argv0, l, pc);
--	for(i=0; i<10; i++){
--		if(!_tas(&l->held))
--			return 1;
--		usleep(10*1000);
--	}
--fprint(2, "%\001 %s: lock loop5 %p from %lux\n", argv0, l, pc);
--	for(i=0; i<1000; i++){
--		if(!_tas(&l->held))
--			return 1;
--		usleep(100*1000);
--	}
--fprint(2, "%\001 %s: lock loop6 %p from %lux\n", argv0, l, pc);
--	/* take your time */
--	while(_tas(&l->held))
--		usleep(1000*1000);
--	return 1;
--}
--
--/*
-- * sleep and wakeup
-- */
--static void
--ign(int x)
--{
--	USED(x);
--}
--
--static void /*__attribute__((constructor))*/
--ignusr1(int restart)
--{
--	struct sigaction sa;
--
--	memset(&sa, 0, sizeof sa);
--	sa.sa_handler = ign;
--	sigemptyset(&sa.sa_mask);
--	sigaddset(&sa.sa_mask, SIGUSR1);
--	if(restart)
--		sa.sa_flags = SA_RESTART;
--	sigaction(SIGUSR1, &sa, nil);
--}
--
--void
--_procsleep(_Procrendez *r)
--{
--	sigset_t mask;
--
--	/*
--	 * Go to sleep.
--	 *
--	 * Block USR1, set the handler to interrupt system calls,
--	 * unlock the vouslock so our waker can wake us,
--	 * and then suspend.
--	 */
--again:
--	r->asleep = 1;
--	r->pid = getpid();
--
--	sigprocmask(SIG_SETMASK, nil, &mask);
--	sigaddset(&mask, SIGUSR1);
--	sigprocmask(SIG_SETMASK, &mask, nil);
--	ignusr1(0);
--	unlock(r->l);
--	sigdelset(&mask, SIGUSR1);
--	sigsuspend(&mask);
--
--	/*
--	 * We're awake.  Make USR1 not interrupt system calls.
--	 */
--	lock(r->l);
--	ignusr1(1);
--	if(r->asleep && r->pid == getpid()){
--		/* Didn't really wake up - signal from something else */
--		goto again;
--	}
--}
--
--void
--_procwakeupandunlock(_Procrendez *r)
--{
--	int pid;
--
--	pid = 0;
--	if(r->asleep){
--		r->asleep = 0;
--		assert(r->pid >= 1);
--		pid = r->pid;
--	}
--	assert(r->l);
--	unlock(r->l);
--	if(pid)
--		kill(pid, SIGUSR1);
--}
--
--/*
-- * process creation and exit
-- */
--typedef struct Stackfree Stackfree;
--struct Stackfree
--{
--	Stackfree	*next;
--	int	pid;
--	int	pid1;
--};
--static Lock stacklock;
--static Stackfree *stackfree;
--
--static void
--delayfreestack(uchar *stk, int pid, int pid1)
--{
--	Stackfree *sf;
--
--	sf = (Stackfree*)stk;
--	sf->pid = pid;
--	sf->pid1 = pid1;
--	lock(&stacklock);
--	sf->next = stackfree;
--	stackfree = sf;
--	unlock(&stacklock);
--}
--
--static void
--dofreestacks(void)
--{
--	Stackfree *sf, *last, *next;
--
--	if(stackfree==nil || !canlock(&stacklock))
--		return;
--
--	for(last=nil,sf=stackfree; sf; last=sf,sf=next){
--		next = sf->next;
--		if(sf->pid >= 1 && kill(sf->pid, 0) < 0 && errno == ESRCH)
--		if(sf->pid1 >= 1 && kill(sf->pid1, 0) < 0 && errno == ESRCH){
--			free(sf);
--			if(last)
--				last->next = next;
--			else
--				stackfree = next;
--			sf = last;
--		}
--	}
--	unlock(&stacklock);
--}
--
--static int
--startprocfn(void *v)
--{
--	void **a;
--	uchar *stk;
--	void (*fn)(void*);
--	Proc *p;
--	int pid0, pid1;
--
--	a = (void**)v;
--	fn = a[0];
--	p = a[1];
--	stk = a[2];
--	pid0 = (int)a[4];
--	pid1 = getpid();
--	free(a);
--	p->osprocid = pid1;
--
--	(*fn)(p);
--
--	delayfreestack(stk, pid0, pid1);
--	_exit(0);
--	return 0;
--}
--
--/*
-- * indirect through here so that parent need not wait for child zombie
-- *
-- * slight race - if child exits and then another process starts before we
-- * manage to exit, we'll be running on a freed stack.
-- */
--static int
--trampnowait(void *v)
--{
--	void **a;
--	int *kidpid;
--
--	a = (void*)v;
--	kidpid = a[3];
--	a[4] = (void*)getpid();
--	*kidpid = clone(startprocfn, a[2]+65536-512, CLONE_VM|CLONE_FILES, a);
--	_exit(0);
--	return 0;
--}
--
--void
--_procstart(Proc *p, void (*fn)(Proc*))
--{
--	void **a;
--	uchar *stk;
--	int pid, kidpid, status;
--
--	dofreestacks();
--	a = malloc(5*sizeof a[0]);
--	if(a == nil)
--		sysfatal("_procstart malloc: %r");
--	stk = malloc(65536);
--	if(stk == nil)
--		sysfatal("_procstart malloc stack: %r");
--
--	a[0] = fn;
--	a[1] = p;
--	a[2] = stk;
--	a[3] = &kidpid;
--	kidpid = -1;
--
--	pid = clone(trampnowait, stk+65536-16, CLONE_VM|CLONE_FILES, a);
--	if(pid > 0)
--		if(wait4(pid, &status, __WALL, 0) < 0)
--			fprint(2, "ffork wait4: %r\n");
--	if(pid < 0 || kidpid < 0){
--		fprint(2, "_procstart clone: %r\n");
--		abort();
--	}
--}
--
--static char *threadexitsmsg;
--void
--sigusr2handler(int s)
--{
--/*	fprint(2, "%d usr2 %d\n", time(0), getpid()); */
--	if(threadexitsmsg)
--		_exits(threadexitsmsg);
--}
--
--void
--threadexitsall(char *msg)
--{
--	static int pid[1024];
--	int i, npid, mypid;
--	Proc *p;
--
--	if(msg == nil)
--		msg = "";
--
--	/*
--	 * Only one guy, ever, gets to run this.
--	 * If two guys do it, inevitably they end up
--	 * tripping over each other in the underlying
--	 * C library exit() implementation, which is
--	 * trying to run the atexit handlers and apparently
--	 * not thread safe.  This has been observed on
--	 * both Linux and OpenBSD.  Sigh.
--	 */
--	{
--		static Lock onelock;
--		if(!canlock(&onelock))
--			_exits(threadexitsmsg);
--		threadexitsmsg = msg;
--	}
--
--	mypid = getpid();
--	lock(&_threadprocslock);
--	npid = 0;
--	for(p=_threadprocs; p; p=p->next)
--		if(p->osprocid != mypid && p->osprocid >= 1)
--			pid[npid++] = p->osprocid;
--	for(i=0; i<npid; i++)
--		kill(pid[i], SIGUSR2);
--	unlock(&_threadprocslock);
--	exits(msg);
--}
--
--/*
-- * per-process data, indexed by pid
-- *
-- * could use modify_ldt and a segment register
-- * to avoid the many calls to getpid(), but i don't
-- * care -- this is compatibility code.  linux 2.6 with
-- * nptl is a good enough pthreads to avoid this whole file.
-- */
--typedef struct Perproc Perproc;
--struct Perproc
--{
--	int		pid;
--	Proc	*proc;
--};
--
--static Lock perlock;
--static Perproc perproc[1024];
--#define P ((Proc*)-1)
--
--static Perproc*
--myperproc(void)
--{
--	int i, pid, h;
--	Perproc *p;
--
--	pid = getpid();
--	h = pid%nelem(perproc);
--	for(i=0; i<nelem(perproc); i++){
--		p = &perproc[(i+h)%nelem(perproc)];
--		if(p->pid == pid)
--			return p;
--		if(p->pid == 0){
--			print("found 0 at %d (h=%d)\n", (i+h)%nelem(perproc), h);
--			break;
--		}
--	}
--	fprint(2, "myperproc %d (%s): cannot find self\n", pid, argv0);
--	abort();
--	return nil;
--}
--
--static Perproc*
--newperproc(void)
--{
--	int i, pid, h;
--	Perproc *p;
--
--	lock(&perlock);
--	pid = getpid();
--	h = pid%nelem(perproc);
--	for(i=0; i<nelem(perproc); i++){
--		p = &perproc[(i+h)%nelem(perproc)];
--		if(p->pid == pid || p->pid == -1 || p->pid == 0){
--			p->pid = pid;
--			unlock(&perlock);
--			return p;
--		}
--	}
--	fprint(2, "newperproc %d: out of procs\n", pid);
--	abort();
--	return nil;
--}
--
--Proc*
--_threadproc(void)
--{
--	return myperproc()->proc;
--}
--
--void
--_threadsetproc(Proc *p)
--{
--	Perproc *pp;
--
--	if(p)
--		p->osprocid = getpid();
--	pp = newperproc();
--	pp->proc = p;
--	if(p == nil)
--		pp->pid = -1;
--}
--
--void
--_pthreadinit(void)
--{
--	signal(SIGUSR2, sigusr2handler);
--}
--
--void
--_threadpexit(void)
--{
--	_exit(0);
--}
diff --git a/plan9port/patches/patch-src_libthread_sysofiles.sh b/plan9port/patches/patch-src_libthread_sysofiles.sh
deleted file mode 100644
index d88cd7cf42..0000000000
--- a/plan9port/patches/patch-src_libthread_sysofiles.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-$NetBSD$
-
-Use pthreads on NetBSD.
-
-From upstream pull request #355:
-
- <https://github.com/9fans/plan9port/pull/355>
-
---- src/libthread/sysofiles.sh.orig	2020-06-22 15:22:27.000000000 +0000
-+++ src/libthread/sysofiles.sh
-@@ -3,9 +3,6 @@
- test -f $PLAN9/config && . $PLAN9/config
- 
- case "$SYSNAME" in
--NetBSD)
--	echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o
--	;;
- OpenBSD)
- 	echo pthread.o stkmmap.o
- 	;;



Home | Main Index | Thread Index | Old Index