Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #28839 > unrolled thread
| Started by | fir <profesor.fir@gmail.com> |
|---|---|
| First post | 2012-11-30 01:25 -0800 |
| Last post | 2012-11-30 09:33 -0800 |
| Articles | 15 — 5 participants |
Back to article view | Back to comp.lang.c
alignment shame (?) fir <profesor.fir@gmail.com> - 2012-11-30 01:25 -0800
Re: alignment shame (?) Noob <root@127.0.0.1> - 2012-11-30 10:46 +0100
Re: alignment shame (?) fir <profesor.fir@gmail.com> - 2012-11-30 03:24 -0800
Re: alignment shame (?) Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-30 05:22 -0800
Re: alignment shame (?) James Kuyper <jameskuyper@verizon.net> - 2012-11-30 08:52 -0500
Re: alignment shame (?) fir <profesor.fir@gmail.com> - 2012-11-30 06:55 -0800
Re: alignment shame (?) ImpalerCore <jadill33@gmail.com> - 2012-11-30 06:56 -0800
Re: alignment shame (?) fir <profesor.fir@gmail.com> - 2012-11-30 07:17 -0800
Re: alignment shame (?) ImpalerCore <jadill33@gmail.com> - 2012-11-30 07:42 -0800
Re: alignment shame (?) James Kuyper <jameskuyper@verizon.net> - 2012-11-30 11:45 -0500
Re: alignment shame (?) fir <profesor.fir@gmail.com> - 2012-11-30 09:42 -0800
Re: alignment shame (?) ImpalerCore <jadill33@gmail.com> - 2012-11-30 10:57 -0800
Re: alignment shame (?) James Kuyper <jameskuyper@verizon.net> - 2012-11-30 14:07 -0500
Re: alignment shame (?) fir <profesor.fir@gmail.com> - 2012-11-30 11:38 -0800
Re: alignment shame (?) fir <profesor.fir@gmail.com> - 2012-11-30 09:33 -0800
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2012-11-30 01:25 -0800 |
| Subject | alignment shame (?) |
| Message-ID | <d2e6ec85-00bb-400a-a1b1-24f8711a2c2a@googlegroups.com> |
I am not sure how it is in c, but alignment seem to be mess in the world of c and c++ Is it standarized as to today state of these languages? (to include such solution to language seem to be easy for me, just some thing like align(4096) int table[4096]; or some better looking modifier that could be used for any thing needed to be define aligned)
[toc] | [next] | [standalone]
| From | Noob <root@127.0.0.1> |
|---|---|
| Date | 2012-11-30 10:46 +0100 |
| Message-ID | <k99v32$3um$1@dont-email.me> |
| In reply to | #28839 |
fir wrote: > I am not sure how it is in c, but alignment seem > to be mess in the world of c and c++ You're not sure for C, but you know for C? > Is it standarized as to today state of these languages? As far as C is concerned, yes. https://en.wikipedia.org/wiki/C11_%28C_standard_revision%29 _Alignas specifier, alignof operator, aligned_alloc function, <stdalign.h> header file C++ is obviously off-topic in comp.lang.c > (to include such solution to language seem to be > easy for me, just some thing like > > align(4096) int table[4096]; > > or some better looking modifier that could be > used for any thing needed to be define aligned) Why don't you define your own language, or write your own compiler with extensions, and stop trolling this newsgroup, then?
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2012-11-30 03:24 -0800 |
| Message-ID | <385be323-661e-4fef-91f4-832c64dcfff5@googlegroups.com> |
| In reply to | #28840 |
W dniu piątek, 30 listopada 2012 10:46:23 UTC+1 użytkownik Noob napisał: > fir wrote: > > > I am not sure how it is in c, but alignment seem > > > to be mess in the world of c and c++ > > > > You're not sure for C, but you know for C? > > > > > Is it standarized as to today state of these languages? > > > > As far as C is concerned, yes. > > https://en.wikipedia.org/wiki/C11_%28C_standard_revision%29 > > _Alignas specifier, > > alignof operator, > > aligned_alloc function, > > <stdalign.h> header file > > > > C++ is obviously off-topic in comp.lang.c > > > > > (to include such solution to language seem to be > > > easy for me, just some thing like > > > > > > align(4096) int table[4096]; > > > > > > or some better looking modifier that could be > > > used for any thing needed to be define aligned) > > > > Why don't you define your own language, or write your own > > compiler with extensions, and stop trolling this newsgroup, > > then? man youre agressive, if it is your psychical need youre welcome to do it if you must, but not to much (for my personal taste it do not qualify to talk on such level) personally I do not know to much about present standards, though it do not exclude some deep 'involveness' on some other area of thinking about c language (I am involved in spirit of it as I call it and also do some amount of 'theory' of some paradigms; standards are less known to me so I found it is some place to ask about it here, maybe)
[toc] | [prev] | [next] | [standalone]
| From | Malcolm McLean <malcolm.mclean5@btinternet.com> |
|---|---|
| Date | 2012-11-30 05:22 -0800 |
| Message-ID | <62d533a4-5bc4-4ee3-af8d-92f1e783fe98@googlegroups.com> |
| In reply to | #28839 |
On Friday, November 30, 2012 9:25:27 AM UTC, fir wrote: > I am not sure how it is in c, but alignment seem > to be mess in the world of c and c++ > Is it standarized as to today state of these > languages? > I think something was broguht in in C99. But the problem is that if you want to do this unsigned char pool[1000000]; /* allocate memory from pool */ void *mymalloc(int size) there's no fully portable way in c89 of ensuring that the meory blocks are suitably aligned for any purpose. For virtually all real platforms you can achieve this by aligning to double, but nothing guarantees it. It's a minor glitch. It means that a few routines may need care in porting, in sanely written code. -- Visit Malcolm's website http://www.malcolmmclean.site11.com/www
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2012-11-30 08:52 -0500 |
| Message-ID | <k9admh$fnj$1@dont-email.me> |
| In reply to | #28843 |
On 11/30/2012 08:22 AM, Malcolm McLean wrote: > On Friday, November 30, 2012 9:25:27 AM UTC, fir wrote: >> I am not sure how it is in c, but alignment seem >> to be mess in the world of c and c++ >> Is it standarized as to today state of these >> languages? >> > I think something was broguht in in C99. No, that didn't happen until C2011 > But the problem is that if you want to do this > > unsigned char pool[1000000]; > > /* allocate memory from pool */ > void *mymalloc(int size) > > there's no fully portable way in c89 of ensuring that the meory blocks are > suitably aligned for any purpose. For virtually all real platforms you can > achieve this by aligning to double, but nothing guarantees it. Whereas, in C2011, it can be done using #include <stddef.h> _Alignas(max_align_t) unsigned char pool[1000000]; You'd probably want to use _Alignof(max_align_t) somewhere in the computation of the pool's size. -- James Kuyper
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2012-11-30 06:55 -0800 |
| Message-ID | <495c35e7-c230-4c26-8afc-a204deaba74f@googlegroups.com> |
| In reply to | #28845 |
W dniu piątek, 30 listopada 2012 14:52:16 UTC+1 użytkownik James Kuyper napisał: > On 11/30/2012 08:22 AM, Malcolm McLean wrote: > > On Friday, November 30, 2012 9:25:27 AM UTC, fir wrote: > >> I am not sure how it is in c, but alignment seem > >> to be mess in the world of c and c++ > >> Is it standarized as to today state of these > >> languages? > >> > > I think something was broguht in in C99. > > No, that didn't happen until C2011 > > But the problem is that if you want to do this > > unsigned char pool[1000000]; > > /* allocate memory from pool */ > > void *mymalloc(int size) > > there's no fully portable way in c89 of ensuring that the meory blocks are > > suitably aligned for any purpose. For virtually all real platforms you can > > achieve this by aligning to double, but nothing guarantees it. > > > > Whereas, in C2011, it can be done using > #include <stddef.h> > _Alignas(max_align_t) unsigned char pool[1000000]; > > You'd probably want to use _Alignof(max_align_t) somewhere in the > computation of the pool's size. > can I use it to align 2-dim array such way? : _Alignas(4096) char table[100][4096]; (I would expect here that each row will fit one 4KB ram page (in quest for searching for some speed maybe) ?
[toc] | [prev] | [next] | [standalone]
| From | ImpalerCore <jadill33@gmail.com> |
|---|---|
| Date | 2012-11-30 06:56 -0800 |
| Message-ID | <b3e27010-7bd9-49c9-af6c-6b7c8b3511cf@bx4g2000vbb.googlegroups.com> |
| In reply to | #28839 |
On Nov 30, 4:25 am, fir <profesor....@gmail.com> wrote:
> I am not sure how it is in c, but alignment seem
> to be mess in the world of c and c++
> Is it standarized as to today state of these
> languages?
>
> (to include such solution to language seem to be
> easy for me, just some thing like
>
> align(4096) int table[4096];
>
> or some better looking modifier that could be
> used for any thing needed to be define aligned)
You can create a macro that leverages either C11 alignas or a compiler
extension to align an array. This is an excerpt from the library I'm
working on.
\code
/* The symbol 'stdalign_alignof_defined' is temporarily used to
record whether or not the 'alignof' macro is available. */
#undef stdalign_alignof_defined
/* The symbol 'stdalign_alignas_defined' is temporarily used to
record whether or not the 'alignas' macro is available. */
#undef stdalign_alignas_defined
/*
* If C11 standard support is available, then 'alignof' is directly
* available, and the declaration syntax for a typed variable with
* aligned storage can be defined directly in terms of 'alignas'.
*/
#if defined(__STDC__) && defined(__STDC_VERSION__)
# if (__STDC__ && __STDC_VERSION__ >= 201112L)
# include <stdalign.h>
# if defined(__alignof_is_defined)
# define stdalign_alignof_defined
# endif
# if defined(__alignas_is_defined)
# define stdalign_alignas_defined
# endif
# endif
#endif
/*!
* \brief Determine the alignment of the type in bytes.
* \param type A type.
*
* The number of bytes returned is not guaranteed to be the smallest
* alignment allowed by the platform if \c alignof is not natively
* available from the compiler. Without \c alignof, the \c offsetof
* operator can determine a compatible alignment for the given type.
*
* \usage
* \include align/alignof_example.c
*
* The example above should display something similar to the
* following.
*
* \code
* alignof example
* -------------------------------------
* | type | sizeof | alignof |
* -------------------------------------
* char 1 1
* short int 2 2
* int 4 4
* long int 4 4
* long long int 8 8
* float 4 4
* double 8 8
* long double 12 4
* size_t 4 4
* ptrdiff_t 4 4
* void* 4 4
* enum align_e 4 4
* struct align_s 16 8
* align_func 4 4
*
* ALIGN_MAX = 8
* \endcode
*/
#if !defined(stdalign_alignof_defined)
# define alignof(type) (offsetof (struct { char c; type t; }, t))
#endif
#undef stdalign_alignof_defined
/*!
* \brief Declare a variable with aligned storage.
* \param type The type.
* \param alignment The alignment constraint.
*
* This macro depends on the availability of \c alignas in C11 or
* compiler extensions such as \c __attribute__ or \c __declspec to
* specify an alignment constraint. An alignment constraint can be
* specified when declaring variables with static or automatic
* storage or for variables declared in \c struct definitions.
*
* \usage
* \include align/c_aligned_storage_example.c
*
* The example above should display something similar to the
* following.
*
* \code
* fv1 0022ff60 = [1,2,3,4]
* fv2 0022ff50 = [5,6,7,8]
*
* dot product = 70
* \endcode
*
* The key to using the aligned intrinsic \c _mm_load_ps in the
* dot product function is to ensure that the vectors \c fv1 and
* \c fv2 are aligned to an address on a 16-byte boundary.
*
* The alignment of variables with static storage is dependent on
* the capabilities of the linker. If the linker is only able to
* align variables up to a maximum of 16 bytes, then requesting a
* buffer with a stricter alignment is not possible. Often the
* compiler will generate a warning if an alignment constraint
* cannot be met.
*/
#if defined(stdalign_alignas_defined)
# define c_aligned_storage(type, alignment) alignas(alignment) type
#else
# if defined(__GNUC__)
# define c_aligned_storage(type, alignment) type
__attribute__((aligned (alignment)))
# elif defined(_MSC_VER) && (_MSC_VER >= 1310)
# define c_aligned_storage(type, alignment) __declspec(align
(alignment)) type
# else
# define c_aligned_storage(type, alignment) type
# endif
#endif
#undef stdalign_alignas_defined
\endcode
Then you can use it like the following
\code
#include <stdio.h>
#include <xmmintrin.h>
#include <clover/constraint.h>
#include <clover/align.h>
/* SSE Intrinsics support must be enabled by adding '-msse' to
gcc or '/arch:SSE' to cl. */
static inline void sse_v4sf_dot( float* dot,
const float* v1,
const float* v2 )
{
__m128 mv1, mv2, mbuf1, mbuf2;
mv1 = _mm_load_ps( v1 );
mv2 = _mm_load_ps( v2 );
mbuf1 = _mm_mul_ps( mv1, mv2 );
mbuf2 = _mm_shuffle_ps( mbuf1, mbuf1, _MM_SHUFFLE( 3, 2, 3, 2 ) );
mbuf1 = _mm_add_ps( mbuf1, mbuf2 );
mbuf2 = _mm_shuffle_ps( mbuf1, mbuf1, _MM_SHUFFLE( 0, 1, 0, 1 ) );
mbuf1 = _mm_add_ss( mbuf1, mbuf2 );
_mm_store_ss( dot, mbuf1 );
}
int main( void )
{
float dot_product;
c_aligned_storage(float, 16) fv1[4] = { 1, 2, 3, 4 };
c_aligned_storage(float, 16) fv2[4] = { 5, 6, 7, 8 };
printf( "fv1 %p = [%.0f,%.0f,%.0f,%.0f]\n",
fv1, fv1[0], fv1[1], fv1[2], fv1[3] );
printf( "fv2 %p = [%.0f,%.0f,%.0f,%.0f]\n",
fv2, fv2[0], fv2[1], fv2[2], fv2[3] );
printf( "\n" );
c_exit_if_fail( c_is_aligned_ptr( fv1, 16 ),
"Vector not properly aligned for SSE" );
c_exit_if_fail( c_is_aligned_ptr( fv2, 16 ),
"Vector not properly aligned for SSE" );
sse_v4sf_dot( &dot_product, fv1, fv2 );
printf( "dot product = %.0f\n", dot_product );
return 0;
}
\endcode
Best regards,
John D.
P.S. I have not actually tested it on a C11 compiler yet ... will get
there eventually
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2012-11-30 07:17 -0800 |
| Message-ID | <9f3f3acc-d396-4ad6-9f64-378ede00aefc@googlegroups.com> |
| In reply to | #28848 |
W dniu piątek, 30 listopada 2012 15:56:48 UTC+1 użytkownik ImpalerCore napisał: > On Nov 30, 4:25 am, fir <profesor....@gmail.com> wrote: > > I am not sure how it is in c, but alignment seem > > to be mess in the world of c and c++ > (...) > \endcode > > John D. > This is much trouble. I need simple modifier to align anything to any boundary, Standarized one would be the best. Simple Alignas_(value) would be good if it will work in broad scope and good
[toc] | [prev] | [next] | [standalone]
| From | ImpalerCore <jadill33@gmail.com> |
|---|---|
| Date | 2012-11-30 07:42 -0800 |
| Message-ID | <9af3e529-5e44-4ac0-8b3b-696ebfd60940@n5g2000vbk.googlegroups.com> |
| In reply to | #28850 |
On Nov 30, 10:17 am, fir <profesor....@gmail.com> wrote: > W dniu piątek, 30 listopada 2012 15:56:48 UTC+1 użytkownik ImpalerCore napisał:> On Nov 30, 4:25 am, fir <profesor....@gmail.com> wrote: > > > I am not sure how it is in c, but alignment seem > > > to be mess in the world of c and c++ > > (...) > > > \endcode > > > John D. > > This is much trouble. I need simple > modifier to align anything to any > boundary, Standarized one would be > the best. Simple Alignas_(value) would be > good if it will work in broad scope and good If you want simple, you'll have to restrict yourself to a single platform and compiler that does what you want, which is often good enough for applications, but less so for libraries. If you want to support multiple platforms/compilers with varying feature support, simple goes out the door. Even so, although defining 'c_aligned_storage' is not simple, using it is. c_aligned_storage(int, 4096) table[4096 / sizeof (int)]; Not all linkers support page sized alignments. An alternative to using automatic storage is that most platforms do have some kind of 'aligned_malloc' that can allocate and return page-aligned blocks of memory if you really need it. Windows: _aligned_malloc, _aligned_free POSIX: posix_memalign, free Best regards, John D.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2012-11-30 11:45 -0500 |
| Message-ID | <50B8E2C0.1090401@verizon.net> |
| In reply to | #28851 |
On 11/30/2012 10:42 AM, ImpalerCore wrote: ... >> This is much trouble. I need simple >> modifier to align anything to any >> boundary, Standarized one would be >> the best. Simple Alignas_(value) would be >> good if it will work in broad scope and good > > If you want simple, you'll have to restrict yourself to a single > platform and compiler that does what you want, which is often good > enough for applications, but less so for libraries. Isn't _Alignas() adequate? It's a brand new feature of C2011, but it already works on far more than one platform and one compiler, and will probably be much more widely implemented in the near future.
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2012-11-30 09:42 -0800 |
| Message-ID | <86345def-db4a-4dc8-a330-89ea18400ae3@googlegroups.com> |
| In reply to | #28853 |
W dniu piątek, 30 listopada 2012 17:45:52 UTC+1 użytkownik James Kuyper napisał: > On 11/30/2012 10:42 AM, ImpalerCore wrote: > > ... > > >> This is much trouble. I need simple > >> modifier to align anything to any > >> boundary, Standarized one would be > >> the best. Simple Alignas_(value) would be > >> good if it will work in broad scope and good > > > > > > If you want simple, you'll have to restrict yourself to a single > > platform and compiler that does what you want, which is often good > > enough for applications, but less so for libraries. > > > > Isn't _Alignas() adequate? It's a brand new feature of C2011, but it > already works on far more than one platform and one compiler, and will > probably be much more widely implemented in the near future. If it works ok, it would be quite good and important (as to solution without judging the syntax subtlities) (but does it working good? can I align anything with any boundary with that ?) What with 'padded' bytes are they filled with zeroes?
[toc] | [prev] | [next] | [standalone]
| From | ImpalerCore <jadill33@gmail.com> |
|---|---|
| Date | 2012-11-30 10:57 -0800 |
| Message-ID | <40d5aeb3-2e87-4272-be89-98194af21a1f@bx4g2000vbb.googlegroups.com> |
| In reply to | #28853 |
On Nov 30, 11:45 am, James Kuyper <jameskuy...@verizon.net> wrote: > On 11/30/2012 10:42 AM, ImpalerCore wrote: > ... > > >> This is much trouble. I need simple > >> modifier to align anything to any > >> boundary, Standarized one would be > >> the best. Simple Alignas_(value) would be > >> good if it will work in broad scope and good > > > If you want simple, you'll have to restrict yourself to a single > > platform and compiler that does what you want, which is often good > > enough for applications, but less so for libraries. > > Isn't _Alignas() adequate? It's a brand new feature of C2011, but it > already works on far more than one platform and one compiler, and will > probably be much more widely implemented in the near future. From your post on Sept. 20, 2012: My project is still governed by a 1997 agreement with our client which requires us to write code which "conforms" to C90 plus the two Technical Corrigenda. I'm curious how you would apply _Alignas in your scenario if you had a need to use it. I'm not saying that using _Alignas is wrong. It's just unfortunate that the C landscape is so varied, and projects tend to become entrenched within their language and coding standard choices. I've had to write my own <stdint.h> wrappers because the embedded compiler I was using didn't support them. I would love to use "zu" instead of my own PRIuSIZE modifier but Windows compatibility is important to me. Best regards, John D.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2012-11-30 14:07 -0500 |
| Message-ID | <50B903F6.5000503@verizon.net> |
| In reply to | #28859 |
On 11/30/2012 01:57 PM, ImpalerCore wrote: > On Nov 30, 11:45 am, James Kuyper <jameskuy...@verizon.net> wrote: >> On 11/30/2012 10:42 AM, ImpalerCore wrote: >> ... >> >>>> This is much trouble. I need simple >>>> modifier to align anything to any >>>> boundary, Standarized one would be >>>> the best. Simple Alignas_(value) would be >>>> good if it will work in broad scope and good >> >>> If you want simple, you'll have to restrict yourself to a single >>> platform and compiler that does what you want, which is often good >>> enough for applications, but less so for libraries. >> >> Isn't _Alignas() adequate? It's a brand new feature of C2011, but it >> already works on far more than one platform and one compiler, and will >> probably be much more widely implemented in the near future. > > From your post on Sept. 20, 2012: > > My project is still governed by a 1997 agreement with our client which > requires us to write code which "conforms" to C90 plus the two > Technical > Corrigenda. > > I'm curious how you would apply _Alignas in your scenario if you had a > need to use it. I can't - but the OP only said that he would prefer a standardized feature, which _Alignas() is. He didn't specify a particular version of the standard that had to support the feature. The fact that he's willing to even consider a non-standardized feature implies he's much less strictly bound by coding standards than I am.
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2012-11-30 11:38 -0800 |
| Message-ID | <e1663fe5-6fa8-48b0-b66e-7544e4e03df5@googlegroups.com> |
| In reply to | #28860 |
W dniu piątek, 30 listopada 2012 20:07:34 UTC+1 użytkownik James Kuyper napisał: > On 11/30/2012 01:57 PM, ImpalerCore wrote: > > > On Nov 30, 11:45 am, James Kuyper <jameskuy...@verizon.net> wrote: > > >> On 11/30/2012 10:42 AM, ImpalerCore wrote: > > >> ... > > >> > (...) > > I can't - but the OP only said that he would prefer a standardized > feature, which _Alignas() is. He didn't specify a particular version of > the standard that had to support the feature. The fact that he's willing > to even consider a non-standardized feature implies he's much less > strictly bound by coding standards than I am. I would like to try some alignments searching for possible speedups. By now I do not used other than defaults, but would like to try if 4096-alignments of arrays would speed up and so. I do not even know by now how this alignments things in distinct compilers look like and also how standarisation of it looks like also *. (Now I know it partially: must check up compiler specyfic opts or possibly search for _Alignas implementations (if it can allign to as much as 4096)
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2012-11-30 09:33 -0800 |
| Message-ID | <15b2bd3a-49dc-42c0-b5a4-79002a5398aa@googlegroups.com> |
| In reply to | #28851 |
W dniu piątek, 30 listopada 2012 16:42:54 UTC+1 użytkownik ImpalerCore napisał: > On Nov 30, 10:17 am, fir <profesor....@gmail.com> wrote: > > > W dniu piątek, 30 listopada 2012 15:56:48 UTC+1 użytkownik ImpalerCore napisał:> On Nov 30, 4:25 am, fir <profesor....@gmail.com> wrote: > > > > > I am not sure how it is in c, but alignment seem > > > > > to be mess in the world of c and c++ > > > > > > (...) > > > > > > > \endcode > > > > > > > John D. > > > > > > This is much trouble. I need simple > > > modifier to align anything to any > > > boundary, Standarized one would be > > > the best. Simple Alignas_(value) would be > > > good if it will work in broad scope and good > > > > If you want simple, you'll have to restrict yourself to a single > > platform and compiler that does what you want, which is often good > > enough for applications, but less so for libraries. If you want to > > support multiple platforms/compilers with varying feature support, > > simple goes out the door. Even so, although defining > > 'c_aligned_storage' is not simple, using it is. > > > > c_aligned_storage(int, 4096) table[4096 / sizeof (int)]; > > > > Not all linkers support page sized alignments. An alternative to > > using automatic storage is that most platforms do have some kind of > > 'aligned_malloc' that can allocate and return page-aligned blocks of > > memory if you really need it. > > > > Windows: _aligned_malloc, _aligned_free > > POSIX: posix_memalign, free > > alright, does you or any other person know which are the linkers that do not support such 4k-aligns and why? (it is interesting) I complain here to the mess in this alignment area (so I even called it a shame, couse alignment is a topic for over 10 years and it is still such unstandarized mess with that :( )
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web