Re: byte alignment/dynamic memory from heap x64



Mike L <MikeL@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

My IM driver uses SLIST_ENTRY and SLIST_HEADER(s) and they are declared in a
struct and when my driver is loaded I dynamically allocate memory using these
structs.

for example(not my real struct...)

struct X {

int y;
PNDIS_BUFFER pBuf;
....
SLIST_HEADER ListHeader;
SLIST_ENTRY ListEntry;
...
};

The documention for x64 states that SLIST_ENTRY and SLIST_HEADER must be 16
byte aligned.

How do I force this to happen ?

You don't have to. A few minutes browsing through the include files will
show that SLIST_HEADER and SLIST_ENTRY are already declared with 16-byte
alignment. As long as your structure starts on a 16-byte boundary, the
header and entry structures will be so aligned.

Any advice is appreciated, I might have a bug in my code for one of the
above methods, so I really just need someone to tell me how this is normally
done and I can figure out the details. I saw another function
_align_memory, but did not want to link an NDIS driver to the c runtime for
memory management, but maybe that is another alternative.

You're sure you are compiling for x64? In the 32-bit build environments,
they aren't 16-byte aligned because they don't need to be.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.



Relevant Pages

  • [PATCH v2] v4l2_device/v4l2_subdev: final (?) version
    ... +Overview of the V4L2 driver framework ... +1) A struct for each device instance containing the device state. ... +of which only a handful of ops are commonly implemented, ... +may be NULL if the subdev driver does not support anything from that category. ...
    (Linux-Kernel)
  • [PATCH] [TRIVIAL] Fixing occurrences of "the the "
    ... Registering a driver using platform_driver_probeworks just like ... Free all pages associated with DMA buffers, the buffers and pages lists, and ... * hw - Struct containing variables accessed by shared code ... * This option is used to tune the the maximum retransmission attempts ...
    (Linux-Kernel)
  • Re: [PATCH] [TRIVIAL] Fixing occurrences of "the the "
    ... Registering a driver using platform_driver_probeworks just like ... Free all pages associated with DMA buffers, the buffers and pages lists, and ... * hw - Struct containing variables accessed by shared code ... * This option is used to tune the the maximum retransmission attempts ...
    (Linux-Kernel)
  • Re: v4l2_device/v4l2_subdev: please review (PATCH 1/3)
    ... changes are just boring i2c driver conversions. ... +1) A struct for each device instance containing the device state. ... +of which only a handful of ops are commonly implemented, ... +may be NULL if the subdev driver does not support anything from that category. ...
    (Linux-Kernel)
  • Re: [PATCH V2] ipwireless_cs driver for 4G PC Card
    ... +IPWIRELESS DRIVER ... +static struct timing_stats { ... +static void end_read_timing ... +/* Number of bytes in NL packet header (can not do ...
    (Linux-Kernel)