Commit graph

3931 commits

Author SHA1 Message Date
Ben Huntsman
53bf1f1ccf 9l: xlc_r automatically adds -lpthread. 2020-05-18 22:36:53 -04:00
Ben Huntsman
7a371bf936 lib9: use __builtin_return_address on IBM XL/C 2020-05-18 22:36:17 -04:00
Russ Cox
20c841bac1 rc: avoid problematic internal names "var", "thread"
For AIX.
2020-05-18 22:35:17 -04:00
Russ Cox
dea4dbdba6 acme: avoid global named "class"
For AIX.
2020-05-18 22:35:17 -04:00
Russ Cox
079f5e9445 libdiskfs: avoid problematic internal constant names
AIX defines some of these constants in its C header files.
2020-05-18 22:35:17 -04:00
Russ Cox
d4a4b66a40 diff: rename class to fix AIX
math.h defines a function named class on AIX.
2020-05-18 21:41:35 -04:00
Gabriel Diaz
84167be4ad devdraw: use indirect impl interface in x11 2020-05-18 17:07:25 -04:00
Russ Cox
c53ad837a7 lib9: avoid unportable use of d_namlen in dirread
Fixes #395.
2020-05-18 17:04:36 -04:00
Russ Cox
587933c161 devdraw: use global drawlk instead of per-client
Setting up for a real window system.
2020-05-17 23:24:29 -04:00
Russ Cox
94d381ec9d devdraw: use indirect impl interface
Setting up for a real window system.
2020-05-17 23:19:24 -04:00
Russ Cox
162d0d5cd9 libthread: handle spurious _procsleep wakeups, fix $LIBTHREAD handling 2020-05-17 23:18:33 -04:00
Russ Cox
baef953da2 libthread: add pthreadperthread mode and use under ASAN
ASAN can't deal with the coroutine stacks.
In theory we can call into ASAN runtime to let it know about them,
but ASAN still has problems with fork or exit happening from a
non-system stack. Bypass all possible problems by just having
a full OS thread for each libthread thread. The threads are still
cooperatively scheduled within a proc (in thos mode, a group of OS threads).

Setting the environment variable LIBTHREAD=pthreadperthread
will enable the pthreadperthread mode, as will building with
CC9FLAGS='-fsanitize=address' in $PLAN9/config.

This solution is much more general than ASAN - for example if
you are trying to find all the thread stacks in a reproducible crash
you can use pthreadperthread mode with any debugger that
knows only about OS threads.
2020-05-17 20:15:41 -04:00
Russ Cox
06687f70ba INSTALL: build mk all the time
If mk gets into a bad state, it's not obvious that you can
remove the binary to force the rebuild. Also, not rebuilding
means that bugs in mkmk.sh are not noticed.
Just rebuild from scratch every time. It doesn't take too long
compared to the rest of INSTALL.
2020-05-17 20:15:41 -04:00
Russ Cox
9444b8e4bc 9c, 9l: accept CC9FLAGS from config
Also, if CC9FLAGS includes -fsanitize=address (ASAN),
predefine PLAN9PORT_ASAN for use by programs that need
to know (mainly libthread).

The 9c script used to have a variable called ngflags, which
was ccflags except -g (ng stood for "no g"), but nothing needs
it split out anymore, so simplify to just ccflags.
2020-05-17 20:15:41 -04:00
Russ Cox
154140a22b mk: replace overlapping strcpy with memmove
Found by ASAN.
2020-05-17 20:15:41 -04:00
Russ Cox
8cb7308f3a lib9: use opendir/readdir to read directories
getdirentries(2) has been deprecated on macOS since 10.5 (ten releases ago).
Using it requires disabling 64-bit inodes, but that in turn makes binaries
incompatible with some dynamic libraries, most notably ASAN.

At some point getdirentries(2) will actually be removed.

For both these reasons, switch to opendir/readdir.
A little clunky since we have to keep the DIR* hidden away
to preserve the int fd interfaces, but it lets us remove a bunch
of OS-specific code too.
2020-05-17 20:15:41 -04:00
Russ Cox
16f60479e1 lib9: move seek into open.c
More preparation for opendir.
2020-05-17 20:15:41 -04:00
Russ Cox
6fd4e901ce lib9: add close
More preparation for opendir.
2020-05-17 20:15:41 -04:00
Russ Cox
58fdc083ad lib9: merge create, open, dirread into open.c
Preparation for using opendir.
2020-05-17 20:15:41 -04:00
Kurt H Maier
bd6f12068b fmt: adjust GCC version check
atomics were added in GCC 4.9:  https://gcc.gnu.org/gcc-4.9/changes.html
2020-05-08 10:36:29 -04:00
Ben Huntsman
5802b09e9d all: fix #includes for AIX, add a few AIX "implementation" files 2020-05-07 20:36:03 -04:00
Ben Huntsman
f84d54a033 mk: support Big Archive Format under AIX 2020-05-07 20:36:03 -04:00
Ben Huntsman
4982d4ebc3 all: update build scripts to fix AIX XL/C compatibility 2020-05-07 20:36:03 -04:00
Russ Cox
c3c9c7b6ae fmt: disable use of stdatomic on AIX XL C and old GCC
C11 is apparently too new for these systems.

Fixes #55.
2020-05-07 20:17:53 -04:00
Russ Cox
acffdcb6ee 9term.app: respect user-set shell instead of forcing bash 2020-05-05 09:30:39 -04:00
Russ Cox
b962b25eca rc(1): mention /etc/shells in BUGS section 2020-05-05 08:35:56 -04:00
Russ Cox
601e07b636 rc: clean up parser levels, disallow free carats on lists 2020-05-05 08:30:14 -04:00
Russ Cox
ff74f7cdda rc: allow unquoted = in command arguments
dd fans rejoice!

Also helps with commands like go test -run=x.
2020-05-04 23:41:15 -04:00
Russ Cox
7d6a248f2c rc: move free carat handling into parser
This fixes at least one shell script (printfont) that expected

	'x'`{y}'z'

to mean

	'x'^`{y}^'z'

as it now does. Before it meant:

	'x'^`{y} 'z'

One surprise is that adjacent lists get a free carat:

	(x y z)(1 2 3)

is

	(x1 y2 z3)

This doesn't affect any rc script in Plan 9 or plan9port.
2020-05-04 23:41:15 -04:00
Russ Cox
3caf5c238a rc: move newline handling into parser 2020-05-04 23:41:15 -04:00
Russ Cox
47d4646eeb rc: add recursive descent parser
The old yacc-based parser is available with the -Y flag,
which will probably be removed at some point.

The new -D flag dumps a parse tree of the input,
without executing it. This allows comparing the output
of rc -D and rc -DY on different scripts to see that the
two parsers behave the same.

The rc paper ends by saying:

	It is remarkable that in the four most recent editions of the UNIX
	system programmer’s manual the Bourne shell grammar described in the
	manual page does not admit the command who|wc. This is surely an
	oversight, but it suggests something darker: nobody really knows what
	the Bourne shell’s grammar is. Even examination of the source code is
	little help. The parser is implemented by recursive descent, but the
	routines corresponding to the syntactic categories all have a flag
	argument that subtly changes their operation depending on the context.
	Rc’s parser is implemented using yacc, so I can say precisely what the
	grammar is.

The new recursive descent parser here has no such flags.
It is a straightforward translation of the yacc.

The new parser will make it easier to handle free carats
in more generality as well as potentially allow the use of
unquoted = as a word character.

Going through this exercise has highlighted a few
dark corners here as well. For example, I was surprised to
find that

	x >f | y
	>f x | y

are different commands (the latter redirects y's output).

It is similarly surprising that

	a=b x | y

sets a during the execution of y.

It is also a bit counter-intuitive

	x | y | z
	x | if(c) y | z

are not both 3-phase pipelines.

These are certainly not things we should change, but they
are not entirely obvious from the man page description,
undercutting the quoted claim a bit.

On the other hand, who | wc is clearly accepted by the grammar
in the manual page, and the new parser still handles that test case.
2020-05-04 23:41:15 -04:00
sean
c1c1b5267f 9c: added explicit -fcommon to gcc defaults.
Version 10 of gcc enforces -fno-common which breaks a lot of things.

This fix reverts to the pre-10 behaviour. The real fix is to clean up
stray redefinitions which should be declarations.
2020-04-30 20:51:47 +02:00
Russ Cox
4650064aa7 acme: scale window bodies on resize, not including tag space
This avoids reopening collapsed windows after a large vertical resize.
2020-03-30 09:56:50 -04:00
Larkin Nickle
92aa0e13ad Fix broken references to plan9.bell-labs.com/plan9
Fixes #357
2020-02-22 20:09:40 -05:00
Neven Sajko
0237dec768 libthread: fix ARM build by renaming file
Fixes #363

Change-Id: Ic8ad5ccce3935fdf00732d78d3024b535db90447
2020-02-11 06:58:26 -05:00
Martin Palma
f66f0a587b
devdraw: fix cmd-r to toggle retina vs. non-retina mode on macOS (#361)
and not unexpectedly quitting an application.

Fixes #360
2020-02-03 14:59:58 -05:00
Russ Cox
4197af4122 libthread: comment stack border a bit more 2020-01-24 13:09:55 -05:00
Russ Cox
93e2e820a5 acme: report close failure in Put, this time for sure
Missed in 0b349f6f that Bterm is not closing fd.
2020-01-24 13:09:11 -05:00
Russ Cox
f6c9f7b14c libthread: fix test deps, cleanup in mkfile 2020-01-19 23:04:58 -05:00
Russ Cox
4698bde236 libthread: clean up sysofiles.sh a bit more 2020-01-19 23:04:58 -05:00
Russ Cox
37e7d24c0c libthread: rm OpenBSD tas implementations
OpenBSD is using pthreads now, so no need for tas.
2020-01-19 23:04:58 -05:00
Russ Cox
41b3e8b989 libthread: use consistent stack calculation code in makecontext
Also reduce duplication: makecontext is per-arch not per-os-arch.

May fix #353.
2020-01-19 23:04:58 -05:00
Russ Cox
ac8042dfa9 libthread: rm NetBSD pthread reference in sysofiles.sh
It may be that pthreads on NetBSD is now good enough,
but the build as written (introduced in 23a2368 at my suggestion)
is certainly broken, since both NetBSD.c and pthread.c define
the same functions.

If NetBSD does support pthreads now, then a few things
should happen together:

 - libthread/sysofiles.sh should drop its top NetBSD case entirely
 - libthread/NetBSD.c should be deleted
 - libthread/NetBSD-*-asm.s should be deleted
 - include/u.h's NetBSD case should define PLAN9PORT_USING_PTHREADS
   and #include <pthread.h>

For now, restore to less clearly broken build.
2020-01-19 23:04:58 -05:00
Russ Cox
cb8f735786 all: remove Linux 2.4 vs 2.6 detection
Linux 2.4 is dead.
(The libthread code hasn't worked for Linux 2.4 for a long time.)
2020-01-19 23:04:58 -05:00
Russ Cox
8d82ccefd2 libthread: remove Linux 2.4 code
Linux.c was for Linux 2.4 and is no longer used directly,
only indirectly because NetBSD.c was a 1-line file #including Linux.c.
So mv Linux.c NetBSD.c.

Also rm Linux-*-asm.s which was for Linux 2.4 as well.
2020-01-19 23:04:58 -05:00
Russ Cox
c181e39eea libthread: rm unused sparc-ucontext.h
More dead code.
2020-01-19 21:26:30 -05:00
Russ Cox
52397aaf2b libthread: rm Darwin pre-11.0.0 support
Darwin 11.0.0 was Mac OS X 10.7.0 aka Lion.
The previous version was Snow Leopard, which
has been unsupported by Apple since February 2014.
2020-01-19 21:26:30 -05:00
Russ Cox
8dcb18f71b libthread: rm FreeBSD 4 code
Pretty sure FreeBSD 4 is gone now. :-)
2020-01-19 21:26:23 -05:00
Russ Cox
d15607b9dd libthread: rm OpenBSD.c
This should have been deleted in 20f5692b (2012-07-14),
which removed the mkfile and sysofiles.sh references to it.
2020-01-19 20:52:35 -05:00
Neven Sajko
57157d856e libthread: rm unused ARM (get|set)mcontext (#354)
They were just a duplicate of my(get|set)mcontext from the other
assembly file, and unused from threadimpl.h.

Change-Id: Id8003e5177ed9d37a7f0210037acbe55bbf7f708
2020-01-19 20:43:55 -05:00