Commit Graph

294655 Commits

Author SHA1 Message Date
rillig bcceabb713 indent: replace bitmasking code with struct
The struct directly represents the properties of a pair of parentheses,
without forcing the human reader to decode any bitset.  This makes it
easier to find the remaining bugs in the heuristic for determining the
kind of parentheses.

No functional change outside debug mode.
2022-02-13 12:20:09 +00:00
rillig 553571d1de indent: change parser_state.cast_mask to 0-based indexing
Having 1-based indexing was completely unexpected, and it didn't match
the 0-based indexing of parser_state.paren_indents.

No functional change.
2022-02-13 12:09:19 +00:00
rillig 32b7a7ce5c tests/indent: test token '('
There are already some tests in token_lparen.c that need to be merged.
2022-02-13 12:04:37 +00:00
rillig dc5fc49783 tests/indent: demonstrate the poor handling of compound literals 2022-02-13 11:07:48 +00:00
andvar b0284bb158 s/Errorrs/Errors/ 2022-02-13 00:39:45 +00:00
andvar 474f1bbcdf s/mahine/machine/ 2022-02-13 00:30:10 +00:00
andvar 0f1edf6b40 s/Expceted/Expected/ in log message and s/attribtues/attributes/ in comment. 2022-02-12 23:50:14 +00:00
andvar 7bf69543cc s/epxected/expected/ 2022-02-12 23:30:30 +00:00
rillig 6800db9a1f script: declare dooutput as __dead
This fixes the Clang build, which failed with:

usr.bin/script/script.c:255:1: error:
    function 'dooutput' could be declared with attribute 'noreturn'
    [-Werror,-Wmissing-noreturn]
2022-02-12 23:03:52 +00:00
rillig 00e52ceab0 tests/make: clean up comments in test for indirect -k failures
See PR#49720.
2022-02-12 20:05:36 +00:00
rillig 74bde70120 indent: fix indentation of enum constants in typedef (since 2019-04-04)
The solution is not elegant since it adds a small state machine inside
the parser state, but at least these states only depend on the sequence
of token types and not on any other part of the parser state.

Reported in PR#55453.
2022-02-12 19:56:52 +00:00
rillig 3f3aed2ecb tests/indent: add another test for indentation of enum constants
To prevent an overzealous quick hack for indenting enum constants in a
typedef, as part of fixing PR#55453.
2022-02-12 19:46:56 +00:00
riastradh 2b25048cdd __cpu_simple_lock(9): Omit needless barriers in init.
It is, and always has been, the caller's responsibility to ensure the
lock is initialized before it can be used -- otherwise the memory
could hold garbage; it is nonsensical to even attempt locking
operations on it before initialization.

So there's no need to issue explicit barriers here.  The barrier
seems to have been introduced in sys/arch/alpha/alpha/lock_machdep.c
rev. 1.1 (since moved to inline asm in alpha/include/lock.h) and then
copied & pasted into several other architectures.
2022-02-12 17:17:53 +00:00
riastradh 59e18dd467 __cpu_simple_lock(9): New man page.
This doesn't mean you should use it!  Mostly it's to document the
semantics to help understand existing uses, which should not
proliferate, and audit definitions.
2022-02-12 17:10:20 +00:00
riastradh e35e7b15e2 mips: Brush up __cpu_simple_lock.
- Eradicate last vestiges of mb_* barriers.

- In __cpu_simple_lock_init, omit needless barrier.  It is the
  caller's responsibility to ensure __cpu_simple_lock_init happens
  before other operations on it anyway, so there was never any need
  for a barrier here.

- In __cpu_simple_lock_try, leave comments about memory ordering
  guarantees of the kernel's _atomic_cas_uint, which are inexplicably
  different from the non-underscored atomic_cas_uint.

- In __cpu_simple_unlock, use membar_exit instead of mb_memory, and do
  it unconditionally.

  This ensures that in __cpu_simple_lock/.../__cpu_simple_unlock, all
  memory operations in the ellipsis happen before the store that
  releases the lock.

  - On Octeon, the barrier was omitted altogether, which is a bug --
    it needs to be there or else there is no happens-before relation
    and whoever takes the lock next might see stale values stored or
    even stomp over the unlocking CPU's delayed loads.

  - On non-Octeon, the mb_memory was sync.  Using membar_exit
    preserves this.

  XXX On Octeon, membar_exit only issues syncw -- this seems wrong,
  only store-before-store and not load/store-before-store, unless the
  CNMIPS architecture guarantees it is sufficient here like
  SPARCv8/v9 PSO (`Partial Store Order').

- Leave an essay with citations about why we have an apparently
  pointless syncw _after_ releasing a lock, to work around a design
  bug^W^Wquirk in cnmips which sometimes buffers stores for hundreds
  of thousands of cycles for fun unless you issue syncw.
2022-02-12 17:10:02 +00:00
riastradh 94af175da5 sys: Omit vestigial struct devices in softcs after device_t split. 2022-02-12 17:09:43 +00:00
riastradh 20f3071c6c hppa: Membar audit in ipifuncs.c. 2022-02-12 17:09:07 +00:00
macallan 7ff6f3e721 more __diagused to appease clang 2022-02-12 16:31:06 +00:00
thorpej 91b59d0f28 Don't dig into the guts of selinfo. 2022-02-12 16:21:27 +00:00
macallan d12c6428c9 initialize ntag with the old dmatag so we never end up with an invalid one
suggested by jmcneill@
2022-02-12 15:55:04 +00:00
thorpej 576702f1f9 Add inline functions to manipulate the klists that link up knotes
via kn_selnext:

- klist_init()
- klist_fini()
- klist_insert()
- klist_remove()

These provide some API insulation from the implementation details of these
lists (but not completely; see vn_knote_attach() and vn_knote_detach()).
Currently just a wrapper around SLIST(9).

This will make it significantly easier to switch kn_selnext linkage
to a different kind of list.
2022-02-12 15:51:28 +00:00
rillig 4797e58d66 indent: extend debug logging for the parser state
The member names in struct parser_state are not trustworthy, for example
in_decl does not correspond to the intuitive definition of "inside a
declaration".  To cope with this uncertainty, output the full state of
the parser state to the debug log, not only the changes.  This helps to
track the inner state for small differences in the input, such as
between 'typedef enum { TA, TB } TT' and 'enum { EA, EB } ET'.

This hopefully helps in fixing PR#55453.

No functional change outside debug mode.
2022-02-12 15:50:14 +00:00
riastradh 7adb41074d libpthread: Move namespacing include to top of .c files.
Stuff like libc's namespace.h, or atomic_op_namespace.h, which does
namespacing tricks like `#define atomic_cas_uint _atomic_cas_uint',
has to go at the top of each .c file.  If it goes in the middle, it
might be too late to affect the declarations, and result in compile
errors.

I tripped over this by including <sys/atomic.h> in mips
<machine/lock.h>.

(Maybe we should create a new pthread_namespace.h file for the
purpose, but this'll do for now.)
2022-02-12 14:59:32 +00:00
rillig 3bb21ee83b tests/indent: demonstrate wrong formatting of enum (since 2019-04-04)
Reported by me in PR#55453.
2022-02-12 13:38:29 +00:00
rillig d865043f3f tests/make: document the history of bugs in '-k' mode
Reported in PR#49720 in 2015, fixed independently in compat.c 1.199 from
2020-12-07.
2022-02-12 13:17:57 +00:00
rillig 084616387f make: fix echoing of command with '-' in silent target in jobs mode
Since job.c 1.83 from 2003-12-20, the command had been echoed even if
the target had the attribute '.SILENT'.

In sh-flags.exp, each removed 'echo' command is below a target name
matching the pattern 'opt-?j????-tgt-??s-cmd-?i?', which means that the
target was marked as silent, either through a global '.SILENT'
declaration or the command line option '-s' or the attribute '.SILENT'
on the target.

Reported by Alan Barrett in PR#45356.
2022-02-12 11:14:48 +00:00
riastradh 3aa5a3ae30 sys: Fix various abuse of struct device internals.
Will help to make struct device opaque later.
2022-02-12 03:24:34 +00:00
riastradh b8e6b89d9f ips(4): Missed a couple spots in device_t/softc split. 2022-02-12 02:58:50 +00:00
riastradh 5804b1251e veriexec(4): Omit needless device crud in veriexec.c. 2022-02-12 02:40:48 +00:00
riastradh 902a329835 ips(4): device_t/softc split 2022-02-12 02:40:39 +00:00
riastradh 383e9a645d evbppc/wdc(4) at obio: Stop fabricating bogus struct device.
Nothing uses this.
2022-02-12 02:40:28 +00:00
riastradh 1741d0c7fd ts(4): Skip fabricating bogus struct device in tsmatch.
Doesn't appear to be used anywhere in tsmatch.  Let's not invent
bogus autoconf guts here.
2022-02-12 02:40:20 +00:00
rillig 08650bcabe tests/lint: document where some C99 tests come from
These tests were added due to PR#45417.
2022-02-12 01:23:44 +00:00
riastradh 3fe7de7a3a ipi(9): Document memory ordering guarantees. 2022-02-12 01:21:11 +00:00
rillig b048c4e49a tests/make: demonstrate bug for .SILENT in jobs mode (since 2003)
Reported 2011 in PR#45356.
2022-02-12 01:15:17 +00:00
riastradh efd62f8c64 sparc64/vnet(4): device_t/softc split 2022-02-11 23:49:28 +00:00
riastradh 1e2880f2bd playstation2: Somewhat belated device_t/softc split. 2022-02-11 23:49:19 +00:00
riastradh 61169b39c6 arm/samsung: Don't abuse child's dv_private for the parent's uses.
dv_private belongs to the device itself, i.e., the child here.

This overwrote the child's softc pointer, causing all kinds of havoc;
if this worked it was by an amazing accident.
2022-02-11 23:48:50 +00:00
riastradh 50ad56276c exyopctl(4): Don't leak a duplicate softc on attach. 2022-02-11 23:48:41 +00:00
riastradh 8b02738a37 arm/ti: Omit needless dv_private assignment in omap2icu_attach. 2022-02-11 23:48:33 +00:00
rillig de563b6775 tests/make: reproduce filesystem lookup of .PHONY nodes
As described in PR toolchain/15164.
2022-02-11 23:44:18 +00:00
riastradh 948b235910 ccd(4): Fix typo in comment. 2022-02-11 23:20:09 +00:00
riastradh 09a682aa33 acpi(9): No need to test dv_locators.
It is always initialized by config_devalloc before config_devlink
makes it visible to device iteration.  No need to reach into private
autoconf internals.
2022-02-11 23:19:59 +00:00
riastradh 9ac840f3fa driver(9): Correct paragraph about the driver activate function. 2022-02-11 23:19:43 +00:00
riastradh 4e8ac629c4 driver(9): Delete outdated info about softc and struct device. 2022-02-11 23:19:34 +00:00
rillig 0c4d2fbc8c make: remove comment about environment variable with empty name
At least on NetBSD, make cannot be fooled with an environment variable
having an empty name.  When running '/usr/bin/env =undefined make', the
argument is parsed as a variable assignment, but putenv(3) refuses to
process an empty variable name.  Calling execve(2) directly got a step
further, the kernel didn't filter '=undefined' from the environment
variables.  But getenv(3) always returns NULL when querying the
environment variable with the empty name.

On other operating systems, things may be different.  Trying to set an
environment variable with an empty name may cause errors in env(1),
putenv(3), execve(2), getenv(3) or other places, so don't add an
automatic test for now.
2022-02-11 21:44:10 +00:00
riastradh 63f70f5223 libpthread: Fix membars around rwlocks.
1. After loading self->pt_rwlocked, membar_enter() must not be
   conditional on PTHREAD__ATOMIC_IS_MEMBAR because there is no
   atomic r/m/w operation here which could imply the acquire barrier.

   (This should maybe just be a load-acquire operation, but we don't
   have atomic_load_acquire in userland at the moment -- TBD.)

2. Before storing thread->pt_rwlocked, must issue membar_exit() so
   that this is a store-release operation -- except if we had just
   done an atomic r/m/w and PTHREAD__ATOMIC_IS_MEMBAR is set, in
   which case it can be elided.

   The second membar_exit() added here might be safely hoisted out of
   the loop but I'm not sure -- needs more analysis to prove that
   would be safe.
2022-02-11 21:40:58 +00:00
rillig 6600de342a libc/getenv: remove trailing whitespace
No binary change.
2022-02-11 21:36:46 +00:00
rillig 58e6b25658 make: simplify control flow in CondParser_Comparison
No functional change.
2022-02-11 21:18:09 +00:00
christos c3c5452ebd PR/56254: RVP: Don't call non-async-signal-safe functions from signal handlers.
Establish a non-restart signal handler to avoid blocking in long I/Os.
2022-02-11 21:15:25 +00:00