Commit Graph

7969 Commits (537443d959984163040907d6287ac6ec3cbdc781)

Author SHA1 Message Date
Ori Bernstein f860f25f05 Add stdbool.h to ape
in accordance with c99:7.16. Used by perl, trivial enough
that I feel ok with adding it before the port is fully done.
2020-05-17 08:18:49 -07:00
cinap_lenrek 8550a2adb5 7l: fix mistake 2020-05-16 16:26:09 +02:00
Ori Bernstein bd4b6bda9b #pragma ref no longer exists
It appears to be an antiquated form of 'USED(x)'
2020-05-15 16:56:59 -07:00
Ori Bernstein 78aec6d5c6 Fix scans of more than one character in %[]
This got broken in d8e877a89dae, where we returned 0 on the
first mismatch; we want to return 0 only when we consumed no
characters.
2020-05-15 16:46:20 -07:00
Ori Bernstein ed4645979c stop fiddling with path construction.
There's fd2path, which gives back the full path directly.
This makes the code even simpler.
2020-05-13 18:50:01 -07:00
Ori Bernstein d332f8a9b5 fix yacc crash with absolute paths
When passing an absolute file path to yacc, we would skip
initializing inpath, leaving it null. This would cause Bopen
to die. We would similarly fail to report an error if we tried
to get the current working directory, and then die when
constructing inpath.

This fixes both cases.
2020-05-13 08:42:00 -07:00
cinap_lenrek 1c4c82277e ape: fix name clash, have to use _SLEEP syscall instead of ape sleep in plan9 code (thanks jamos)
this fixes etimer() from ape built libdraw as posix sleep() uses
seconds while plan9 uses miliseconds.
2020-05-13 00:17:07 +02:00
cinap_lenrek 8ca102d42e cc: dont export gethunk(), hunk, nhunk and thunk 2020-05-12 23:18:48 +02:00
cinap_lenrek 34cf2725d2 cc: get rid of hunk pointer fiddling and just use alloc() 2020-05-12 22:45:05 +02:00
cinap_lenrek ecdf3f921e ?l: remove direct hunk manipulation from linkers, just call malloc()
as with recent changes, cc's malloc() could make the hunk pointer
misaligned. in the the compilers, the hunk pointer is used directly
by the lexer with no effort to to keep the hunk pointer aligned.

alloc/malloc still return aligned pointers, but hunk itself can
be on a odd address after allocation of a odd sized amount of bytes.

however, in the linkers, this assumption appears to be differnet. as
most allocations mostly allocate padded structures. however, symbol
lookup allocates strings on byte-size ganularity and the cc's malloc
would misalign the hunk pointer after the malloc() call. while the
rest of the code assumed hunk pointer was always aligned.

this change removes all the hunk pointer fiddling from the linker,
and we just call malloc() (which will use the fast implmenentation
of cc, and should not really make much of a performance difference).
2020-05-12 22:04:30 +02:00
Ori Bernstein 73f38fc546 [ape] add missing conversion flags for scanf
We're missing type flags for:

	hh: char
	ll: vlong
	z:  size_t
	t:  ptrdiff_t
	j:  intmax_t

The lack of '%lld' was causing us to fail when parsing
timezone files. This brings us in line with the specifiers
in the C99 standard, section 7.19.6.2p11
2020-05-12 10:48:33 -07:00
cinap_lenrek 27fc79b04b devip: fix ifc recursive rlock() deadlock
ipiput4() and ipiput6() are called with the incoming interface rlocked
while ipoput4() and ipoput6() also rlock() the outgoing interface once
a route has been found. it is common that the incoming and outgoing
interfaces are the same recusive rlocking().

the deadlock happens when a reader holds the rlock for the incoming interface,
then ip/ipconfig tries to add a new address, trying to wlock the interface.
as there are still active readers on the ifc, ip/ipconfig process gets queued
on the inteface RWlock.

now the reader finds the outgoing route which has the same interface as the
incoming packet and tries to rlock the ifc again. but now theres a writer
queued, so we also go to sleep waiting four outselfs to release the lock.

the solution is to never wait for the outgoing interface rlock, but instead
use non-queueing canrlock() and if it cannot be acquired, discard the packet.
2020-05-10 22:51:40 +02:00
cinap_lenrek dbfec06bf1 kernel: fix checkpages() and segflush() on SG_PHYSICAL type segments
do not touch s->map on SG_PHYSICAL type segments as they do
not have a pte map (s->mapsize == 0 && s->map == nil).

also remove the SG_PHYSICAL switch in freepte(), this is never
reached.
2020-05-10 16:54:42 +02:00
kvik 0099db7b5b merge 2020-05-10 03:24:19 +02:00
kvik 1c3a6fc67e acme: add missed error checks 2020-05-10 03:18:57 +02:00
cinap_lenrek 662aff21a8 merge 2020-05-10 02:44:37 +02:00
cinap_lenrek c474179f9a usbxhci: fix wrong control endpoint 0 output device context address
the calculation for the control endpoint0 output device context
missed the context size scaling shift, resulting in botched
stall handling as we would not read the correct endpoint status
value.

note, this calculation only affected control endpoint 0, which
was handled separately from all other endpoints.
2020-05-10 02:43:39 +02:00
Ori Bernstein bfc8cdfff5 fix '%[]' specifiers and '%n' (thanks phil9)
When a match() fails, we need to unget the character we
tried to match against, rather than leaving it consumed.

Also, we can't break out of a conversion before we reach
the end of a format string, because things like the '%n'
conversion do not consume anything, and should still be
handled.
2020-05-09 15:10:39 -07:00
kvik 758edf2b14 nusb/kb: add quirks for Elecom HUGE trackball
As said in the code comment:

	Elecom trackball report descriptor lies by
	omission, failing to mention all its buttons.
	We patch the descriptor with a correct count
	which lets us parse full reports. Tested with:
		Elecom HUGE (M-HT1DRBK, M-HT1URBK)

The descriptor fixup is adapted from Linux kernel:
	drivers/hid/hid-elecom.c
in which a more detailed account of why and how this
works may be found.

A followup change to nusb/kb will be needed to expose
these additional events for potential remapping.
2020-05-08 20:49:11 +02:00
cinap_lenrek 2c3e60d95b merge 2020-05-07 23:28:55 +02:00
cinap_lenrek 04066fe973 bcm64: fix kernels cmpswap() function
spectacular bug. cmpswap() had a sign extension bug
using sign extending MOV to load the old compare
value and LDXRW using zero extension while the CMP
instruction compared 64 bit registers.

this caused cmpswap with negative old value always
to fail.

interestingly, libc's version of this function was
fine.
2020-05-07 23:27:27 +02:00
Ori Bernstein ec4011acf7 fix typo: mouse->xy, not w->mc.xy 2020-05-07 13:23:15 -07:00
kvik 6d25e194e2 aux/getflags: remove rogue debug print 2020-05-07 18:37:08 +02:00
Ori Bernstein 5749900573 bring stdint.h closer to spec
C99 requires that if intXX_t types are defined, int_fastxx_t and
int_leastxx_t types are defined as well. We define all three to
be identical (intXX_t == int_fastXX_t == int_leastXX_t).
2020-05-06 15:39:12 -07:00
kvik ccf5d3fb9d aux/getflags: improve flagfmt parser
This makes the flagfmt parser more robust and accepting
a looser input language — namely by allowing whitespace
around specifier fields and ignoring any empty fields.

Long flagfmts can thus be pleasingly displayed:

	flagfmt='
		a, b, c, C:cache,
		m:mtpt mountpoint,
		s:srvn srvname'
2020-05-07 00:10:09 +02:00
Ori Bernstein 0dc9c8d019 Reset click count on mouse motion. 2020-05-06 13:38:39 -07:00
Sigrid 7de7414e88 tmac.eai: wrapper around -me: auto indexing sections, .TC macro (thanks sirjofri) 2020-05-04 11:57:24 +02:00
Sigrid 5e7959182a add missing /sys/lib/tmac/me files (thanks sirjofri) 2020-05-04 11:55:29 +02:00
cinap_lenrek ac88ce4f7f make bind(2) error handling consistent
The mount() and bind() syscalls return -1 on error,
and the mountid sequence number on success.

The manpage states that the mountid sequence number
is a positive integer, but the kernels implementation
currently uses a unsigned 32-bit integer and does not
guarantee that the mountid will not become negative.

Most code just cares about the error, so test for
the -1 error value only.
2020-05-02 17:32:01 +02:00
cinap_lenrek 7ff6ea0f70 libdraw: fix mount() error handling in newwindow() 2020-05-02 17:05:17 +02:00
cinap_lenrek 19cc46bc5e sed: accept and ignore -E and -r flags for unix compatibility 2020-05-02 16:56:52 +02:00
cinap_lenrek d0c87bada6 ip/cifsd: implement primitive per-share unix id mapping for wstat() 2020-05-02 16:53:52 +02:00
cinap_lenrek badbf50b0c merge 2020-05-02 15:34:00 +02:00
cinap_lenrek 8e2cfc0464 ether82543gc, ether82557, ethervirtio: do kproc() call ouside of spinlock 2020-05-02 15:32:19 +02:00
Ori Bernstein d935bb25d2 use #error when missing define
This makes it easier to figure out what's going wrong when
we forget to define _POSIX_SOURCE.
2020-05-01 13:29:08 -07:00
Ori Bernstein eb73718c25 merge 2020-04-28 20:51:19 -07:00
Ori Bernstein 9b8af27299 facelift for mothra: flat ui is in.
Remove false 3d, add borders for visual separation between
content area and navigation area.
2020-04-28 20:50:10 -07:00
Sigrid 3bdf242555 libsec/base58enc: null-terminate the result 2020-04-28 12:49:05 +02:00
Ori Bernstein dcf96a006d missing headers rate a FATAL. 2020-04-27 20:13:16 -07:00
cinap_lenrek 39c3fd117a lib9p: reject reads on closed fids and writes on directories
mischief provided the following test that shows the issue:

ramfs -S crash

aux/9pcon /srv/crash <<EOF
Tversion 8192 9P2000
Tattach 0 -1 $user ''
Tcreate 0 dir 020000000777 0
Tattach 5 -1 $user ''
Twalk 5 6 dir
Tread 6 0 512
EOF

the problem is that lib9p wrongly allowed reads on closed fids,
due to the permission check only considering the lower 2 bits.
a closed fid has fid->omode == -1 and it would pass on read for:

(-1 & 3) == 3 == OEXEC

the following change explicitely checks for for the closed case
and also rejects writes on directories (they are rejected on
open/create, but a broken 9p client could still issue the request).
2020-04-27 19:55:42 +02:00
cinap_lenrek 00bfe3ec2b merge 2020-04-26 19:55:53 +02:00
cinap_lenrek 61a062ee9f kernel: improve page reclaimation strategy and locking
when reclaiming pages from an image, always reclaim all
the hash chains equally. that way, we avoid being biased
towards the chains at the start of the Image.pghash[] array.

images can be in two states: active or inactive. inactive
images are the ones which are not used by program while
active ones aare.

when reclaiming pages, we should try to reclaim pages
from inactive images first and only if that set becomes
exhausted attempt to release text pages and attempt to
reclaim pages from active images.

when we run out of Image structures, it makes only sense
to reclaim pages from inactive images, as reclaiming pages
from active ones will never free any Image structures.

change putimage() to require a image already locked and
make it unlock the image. this avoids many pointless
unlock()/lock() sequences as all callers of putimage()
already had the image locked.
2020-04-26 19:54:46 +02:00
qwx 0fc1abc73d mothra: fix a few errors in previous patch
- nil check pl_blue allocation, and don't do it every time pl_rtdraw is called
- fix re-adding previously removed flushimage calls
- correct format for pointer
- sysfatal in pl_drawinit on error
2020-04-26 19:43:10 +02:00
Ori Bernstein c6f7989176 copy all the tokens from the tokenrows with a paste.
if we do 'CAT(foo bar, baz quux)', the resulting token row
should have 3 tokens: 'foo', 'barbaz', 'quux'.

tested by jonasa, rebuilding /sys/src, perl, netsurf, and nuklear.
2020-04-26 09:32:42 -07:00
Ori Bernstein 8ebe958ddf add missing header change (thanks qwx) 2020-04-26 09:03:42 -07:00
Ori Bernstein d6598a2a31 Support for neo2 keyboard layout
Modify aux/kbdfs to work with neo2 layout.
- add new modifier, increase limit on layers.
- Add Kaltgr for mod3
- Add mod4

This change only implements the alphanumeric
block of the keyboard in the kbmap, as neo2
is mainly used for blind typing and is not
needed that much anywhere else, this leaves
the numpad like it is.

(Thanks, jstsmthrgk@jstsmthrgk.eu)
2020-04-25 20:46:45 -07:00
stanley lieber 2614fa02f7 mothra: make user interface monochrome 2020-04-25 21:55:43 -04:00
stanley lieber 9a7c5d5653 mothra: remove extraneous lines and decoration (fake 3d). patch extracted from my forked mess by Ori_B. 2020-04-25 21:53:54 -04:00
Ori Bernstein 60c34ebb2d tweak selection criteria
grow selection from point of click, not start of selection region.
starting at the beginning of the selection region causes the match
logic to kick in, which is confusing.
2020-04-25 15:18:04 -07:00
cinap_lenrek 7feab4dc59 cc: simplify macexpand() and off-by-one error
the caller of macexpand() needs one more byte in
the buffer to append peekc.

make macexpand() actually check for buffer overflow.

just use strdup() to duplicate include file name
instead of the hunk dance.

move GETC() macro in cc.h
2020-04-25 22:16:44 +02:00