Page MenuHomeFreeBSD

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

Authored by jhb on Mon, Nov 24, 3:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 7, 2:07 AM
Unknown Object (File)
Mon, Dec 1, 7:15 AM
Unknown Object (File)
Mon, Dec 1, 5:23 AM
Unknown Object (File)
Sun, Nov 30, 6:20 AM
Unknown Object (File)
Sat, Nov 29, 12:41 AM
Unknown Object (File)
Thu, Nov 27, 3:39 AM
Unknown Object (File)
Wed, Nov 26, 11:34 PM
Unknown Object (File)
Wed, Nov 26, 9:45 PM
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.Mon, Nov 24, 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[].Wed, Dec 10, 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.