Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #162219
| From | BGB <cr88192@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Padding between char array/VLA in struct? |
| Date | 2021-08-03 12:52 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <sebvpf$bfs$1@dont-email.me> (permalink) |
| References | (1 earlier) <se9cfv$uta$1@dont-email.me> <875ywnaehw.fsf@nosuchdomain.example.com> <se9htr$5ll$1@dont-email.me> <sebo28$ig7$1@dont-email.me> <sebpqf$utm$1@dont-email.me> |
On 8/3/2021 11:10 AM, Andrey Tarasevich wrote:
> On 8/3/2021 8:40 AM, BGB wrote:
>>
>> FWIW: My compiler (BGBCC) also supports VLAs, though only for local
>> variables and similar. In these contexts, they effectively decay into
>> pointers, and are transformed into an "alloca()" call.
>> ...
>> But, as can be noted, my compiler doesn't do anything too fancy to
>> support "alloca()"; in effect this gets turned by the compiler into a
>> special runtime call for "call malloc() and then add the returned
>> pointer to a linked list", and then in the epilog a function call is
>> added to free anything that was added to the list.
>>
>> I also make no claim that multidimensional VLAs "actually work"...
>> ...
>
> It appears that the amount of effort you spent implementing your
> pseudo-VLA would be quite sufficient to implement the standard-compliant
> VLA. You just needed to channel that effort slightly differently. Which
> makes one wonder why you decided to eschew the standard semantics...
>
Partly it was because this was what seemed easier, and also allowed
doing pretty much all of the VLA stuff to be handled in the front-end
(things like lambdas are also handled in the frontend, as are many
operations involving "variant" types, *1, ...).
With the ABI design, variable-sized stack frames would have added more
complexity relative to fixed-size stack frames (there is no frame
pointer or similar in this case, and everything on-stack is referenced
using fixed displacements relative to the stack pointer, and
prolog/epilog adjustments use fixed offsets, ...).
Note that this is generally for a target where:
I am using 128K as the default stack size;
(Except for interrupt handlers, which use an 8K stack).
The target is (or assumes) No-MMU operation;
The RAM space is typically measured in MB.
Using malloc ends up preferable for larger memory allocations (VLAs or
large stack arrays), since it isn't bound by the stack-size limit, and
doesn't assume spending inordinate amounts of RAM on the program stacks.
Though, a few cases exist where the total RAM is measured in KB (and the
heap is just sorta wedged between ".bss" and the stack).
*1: The variant types are a non-standard extension which add dynamic
type-checking via tagged pointers; and turns pretty much every operation
on these types into a function call into the runtime.
...
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Padding between char array/VLA in struct? Ian Pilcher <arequipeno@gmail.com> - 2021-08-02 12:48 -0500
Re: Padding between char array/VLA in struct? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-08-02 14:07 -0400
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-02 11:25 -0700
Re: Padding between char array/VLA in struct? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-08-02 19:21 -0400
Re: Padding between char array/VLA in struct? Bart <bc@freeuk.com> - 2021-08-02 19:11 +0100
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-02 11:27 -0700
Re: Padding between char array/VLA in struct? Bart <bc@freeuk.com> - 2021-08-02 20:43 +0100
Re: Padding between char array/VLA in struct? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-08-02 13:11 -0700
Re: Padding between char array/VLA in struct? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-08-02 13:18 -0700
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-02 13:31 -0700
Re: Padding between char array/VLA in struct? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-08-02 19:50 -0700
Re: Padding between char array/VLA in struct? David Brown <david.brown@hesbynett.no> - 2021-08-04 14:01 +0200
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-02 13:19 -0700
Re: Padding between char array/VLA in struct? BGB <cr88192@gmail.com> - 2021-08-03 10:40 -0500
Re: Padding between char array/VLA in struct? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-08-03 09:10 -0700
Re: Padding between char array/VLA in struct? BGB <cr88192@gmail.com> - 2021-08-03 12:52 -0500
Re: Padding between char array/VLA in struct? BGB <cr88192@gmail.com> - 2021-08-04 12:05 -0500
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-02 11:12 -0700
Re: Padding between char array/VLA in struct? Bart <bc@freeuk.com> - 2021-08-02 19:23 +0100
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-02 13:15 -0700
Re: Padding between char array/VLA in struct? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-08-02 11:32 -0700
Re: Padding between char array/VLA in struct? Ian Pilcher <arequipeno@gmail.com> - 2021-08-02 13:59 -0500
Re: Padding between char array/VLA in struct? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-08-02 12:47 -0700
Re: Padding between char array/VLA in struct? Ian Pilcher <arequipeno@gmail.com> - 2021-08-02 15:27 -0500
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-02 13:36 -0700
Re: Padding between char array/VLA in struct? antispam@math.uni.wroc.pl - 2021-08-02 21:52 +0000
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-02 13:22 -0700
Re: Padding between char array/VLA in struct? Manfred <noname@add.invalid> - 2021-08-04 17:01 +0200
Re: Padding between char array/VLA in struct? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-08-04 10:11 -0700
csiph-web