Page MenuHomeFreeBSD

sys: Declare 'end' as an extern char[]
Needs ReviewPublic

Authored by jhb on Nov 24 2025, 3:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 23, 7:46 AM
Unknown Object (File)
Thu, Jan 22, 5:19 PM
Unknown Object (File)
Sun, Jan 18, 2:59 AM
Unknown Object (File)
Mon, Jan 12, 1:15 PM
Unknown Object (File)
Sat, Jan 10, 5:00 PM
Unknown Object (File)
Dec 26 2025, 11:58 PM
Unknown Object (File)
Dec 19 2025, 6:49 AM
Unknown Object (File)
Dec 7 2025, 2:07 AM
Subscribers

Details

Reviewers
jrtc27
andrew
manu
Summary

While here, remove an unused declaration.

Sponsored by: AFRL, DARPA

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68825
Build 65708: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Nov 24 2025, 3:58 PM

s/extern char/&[]/ in the subject, also &end is not char * in that case, it's char (*)[], which is an incomplete type so you can't perform pointer arithmetic on it (as sizeof(char[]) is not known). end itself decays to a char * and so pointer arithmetic on *that* works (or &end[0], but decaying is cleaner). In this case though there's an explicit cast before the arithmetic so both "work".

Ah, so you could use (char *)foo - end in place of the casts? But not &end?

jhb retitled this revision from sys: Declare 'end' as an extern char so that &end is a char * to sys: Declare 'end' as an extern char[].Dec 10 2025, 4:25 PM

Hmm, so does (vm_offset_t)&end still work after this change or should it instead drop the &?

In D53898#1237357, @jhb wrote:

Hmm, so does (vm_offset_t)&end still work after this change or should it instead drop the &?

&array and array have the same address, but different types (T (*)[] vs T *, or T [] if not decayed of course), so (vm_offset_t)&end should still work.