On Tue, 25 May 2021 09:45:39 -0700, in gmane.comp.hardware.beagleboard.user
"John Dammeyer" <johnd-5o6ditlojsohvde0pjs...@public.gmane.org> wrote:


> 
>Here's the BBB version from and you can see the code is identical for both the 
>Pi and the Beagle.
>https://github.com/derekmolloy/exploringBB/blob/version2/chp08/spi/spidev_test/spidev_test.c
>==============================================================================================
>uint8_t rx[ARRAY_SIZE(tx)] = {0, };
>    struct spi_ioc_transfer tr = {
>        .tx_buf = (unsigned long)tx,
>        .rx_buf = (unsigned long)rx,

        Somewhat confusing code -- one has to track upwards in the code... C
arrays are a synonym for pointers, so he's using unsigned long to store a
pointer to the array.

        I'm not downloading the source again to see how the buffers are
defined...
> 
>  Data.tx_buf := PtrUInt(WriteBuffer);
>  Data.rx_buf := PtrUInt(ReadBuffer);

... just notice this explicitly asks for a pointer (given my stale C
history, I'd tend to read that as a pointer to an unsigned integer of some
size... But the C version has the buffers defined as uint8_t (new in
C99/C++11) with is an 8-bit unsigned (equivalent to old unsigned char).

        Does FreePascal have size differentiation?



>It's likely the C compiler clears this structure when it's declared or extends 
>0's out on an assignment that isn't done by the FreePascal compiler.  And that 
>it was required in that Pi forum posting for C code suggests it's perhaps even 
>somewhat random.  Compiler flags maybe?

"""
-fno-zero-initialized-in-bss

    If the target supports a BSS section, GCC by default puts variables
that are initialized to zero into BSS. This can save space in the resulting
code. 
"""

is the closest GCC option I saw. The OS may do zeroing when it allocates a
block of memory to the application, but that wouldn't affect stack usage --
and the C code is allocating the structure on the stack. I presume Pascal
is doing the same (since it allows recursion). Not seeing the declaration
of "Data" means I can't be certain -- FreePascal may have keywords to force
allocation on heap..



-- 
Dennis L Bieber

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/r4cqagp6uljj4n53p65c3j4tl6ds3078uj%404ax.com.

Reply via email to