Alignment qualifier

M

Michael N. Moran

I work on embedded systems using C++ and frequently
need to create an interface that requires a pointer
to memory that is aligned to cache and/or page boundaries.
This is a typical requirement for DMA transfers.

What I think I would like, is a means to qualify a pointer
such that the compile-time type checking could ensure that
the client programs pass an appropriately aligned
argument to the interface.

Obviously, such a feature would require the programmer
to give the cache line size and page size to the compiler.

Has this been discussed before? References? Thoughts?

As this is my first posting to comp.lang.c++, I'm not
even certain that this is the appropriate forum.

--
Michael N. Moran (h) 770 516 7918
5009 Old Field Ct. (c) 678 521 5460
Kennesaw, GA 30144

"... abstractions save us time working, but they don't
save us time learning."
Joel Spolsky, The Law of Leaky Abstractions

The Beatles were wrong: 1 & 1 & 1 is 1
 
W

White Wolf

Michael said:
I work on embedded systems using C++ and frequently
need to create an interface that requires a pointer
to memory that is aligned to cache and/or page boundaries.
This is a typical requirement for DMA transfers.

What I think I would like, is a means to qualify a pointer
such that the compile-time type checking could ensure that
the client programs pass an appropriately aligned
argument to the interface.

Obviously, such a feature would require the programmer
to give the cache line size and page size to the compiler.

Has this been discussed before? References? Thoughts?

As this is my first posting to comp.lang.c++, I'm not
even certain that this is the appropriate forum.

I have started such a proposal for the standard by the encouragement of Herb
Sutter. However I am unaware of involvement of cache lines and pages sizes.
My proposal migth already be able to handle them (IMHO I have covered all
possibilities) but I may be wrong. If you don't mind please contact me on
this address or on attila dot f dot feher at ericsson dot com.

BTW I hope it is obvious from my previous words that standard C++ does not
support alignment specifications.
 
A

Andre Kostur

I work on embedded systems using C++ and frequently
need to create an interface that requires a pointer
to memory that is aligned to cache and/or page boundaries.
This is a typical requirement for DMA transfers.

What I think I would like, is a means to qualify a pointer
such that the compile-time type checking could ensure that
the client programs pass an appropriately aligned
argument to the interface.

Obviously, such a feature would require the programmer
to give the cache line size and page size to the compiler.

Has this been discussed before? References? Thoughts?

As this is my first posting to comp.lang.c++, I'm not
even certain that this is the appropriate forum.

I'm afraid you're out of luck here. comp.lang.c++ is for Standard C++
discussions. Functions which will check for proper memory alignment are
necessarily plaform and/or implementation specific. You'll have to check
the documentation that came with your compiler, or find another newsgroup
specific to your particular target platform. Developers in those forums
will have likely encountered your specific problem before, and thus will be
able to give you much better advice than the people here (on this topic).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,814
Members
47,359
Latest member
Claim Bitcoin Earnings. $

Latest Threads

Top