bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new module 'stdalign'


From: Bruno Haible
Subject: new module 'stdalign'
Date: Tue, 12 Jul 2011 18:33:45 +0200
User-agent: KMail/1.9.9

Hi,

ISO C1X and C++0X also specify a header file <stdalign.h>. Here's a proposal.
For the moment, no system and no GCC version supports this header natively.


================================ lib/stdalign.h ================================
/* Determine alignment of types.
   Copyright (C) 2011 Free Software Foundation, Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#ifndef _GL_STDALIGN_H
#define _GL_STDALIGN_H

/* ISO C1X <stdalign.h> for platforms that lack it.

   References:
   ISO C1X <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>
   sections 6.5.3.4, 6.7.5, 7.15.
   C++0X <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>
   section 18.10.
 */

/* Get offsetof.  */
#include <stddef.h>

#if !defined __cplusplus
# if defined __GNUC__
#  define _Alignas(a) __attribute__ ((__aligned__ (a)))
# endif
# ifdef _Alignas
#  define alignas _Alignas
#  define __alignas_is_defined 1
# endif
#endif

#ifndef _Alignof
# if defined __GNUC__
#  define _Alignof __alignof__
# else
#  if defined __cplusplus
    template <class type> struct _Alignof_helper { char __slot1; type __slot2; 
};
#   define _Alignof(type) offsetof (_Alignof_helper<type>, __slot2)
#  else
#   define _Alignof(type) offsetof (struct { char __slot1; type __slot2; }, 
__slot2)
#  endif
# endif
#endif
#define alignof _Alignof
#define __alignof_is_defined 1

#endif /* _GL_STDALIGN_H */
=============================== modules/stdalign ===============================
Description:
An <stdalign.h> that nearly conforms to ISO C1X and C++0X.

Files:
lib/stdalign.h

Depends-on:

configure.ac:

Makefile.am:

Include:
<stdalign.h>

License:
LGPLv2+

Maintainer:
Bruno Haible
================================================================================
-- 
In memoriam Cesare Battisti 
<http://en.wikipedia.org/wiki/Cesare_Battisti_(politician)>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]