comparison src/lisp.h @ 5894:23178aa71f8b

Define ALIGNOF using C11 and C++11 operators. See <CAHCOHQmG51R61KwGUNY7T5t9tXxzbyg=aGijUKYstbE+wL2-6Q@mail.gmail.com> in xemacs-patches for more information.
author Jerry James <james@xemacs.org>
date Mon, 20 Apr 2015 15:09:11 -0600
parents a0e751d6c3ad
children ee27ca517e90
comparison
equal deleted inserted replaced
5893:d3d073aceaea 5894:23178aa71f8b
1152 1152
1153 #include "compiler.h" 1153 #include "compiler.h"
1154 1154
1155 /* ------------------------ alignment definitions ------------------- */ 1155 /* ------------------------ alignment definitions ------------------- */
1156 1156
1157 #if (!defined (__STDC_VERSION__) || __STDC_VERSION__ < 201112L) && \
1158 (!defined (__cplusplus) || __cplusplus < 201103L)
1157 /* No type has a greater alignment requirement than max_align_t. 1159 /* No type has a greater alignment requirement than max_align_t.
1158 (except perhaps for types we don't use, like long double) */ 1160 (except perhaps for types we don't use, like long double) */
1159 typedef union 1161 typedef union
1160 { 1162 {
1161 struct { long l; } l; 1163 struct { long l; } l;
1162 struct { void *p; } p; 1164 struct { void *p; } p;
1163 struct { void (*f)(void); } f; 1165 struct { void (*f)(void); } f;
1164 struct { double d; } d; 1166 struct { double d; } d;
1165 } max_align_t; 1167 } max_align_t;
1168 #endif
1166 1169
1167 /* ALIGNOF returns the required alignment of a type -- i.e. a value such 1170 /* ALIGNOF returns the required alignment of a type -- i.e. a value such
1168 that data of this type must begin at a memory address which is a 1171 that data of this type must begin at a memory address which is a
1169 multiple of that value. For simple types, this is often the same size 1172 multiple of that value. For simple types, this is often the same size
1170 as the type itself. */ 1173 as the type itself. */
1171 1174
1172 #ifndef ALIGNOF 1175 #ifndef ALIGNOF
1173 # if defined (__GNUC__) && (__GNUC__ >= 2) 1176 # if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1177 # define ALIGNOF(type) _Alignof(type)
1178 # elif defined (__cplusplus) && __cplusplus >= 201103L
1179 # define ALIGNOF(type) alignof(type)
1180 # elif defined (__GNUC__) && (__GNUC__ >= 2)
1174 /* gcc has an extension that gives us exactly what we want. */ 1181 /* gcc has an extension that gives us exactly what we want. */
1175 # define ALIGNOF(type) __alignof__ (type) 1182 # define ALIGNOF(type) __alignof__ (type)
1176 # elif ! defined (__cplusplus) 1183 # elif ! defined (__cplusplus)
1177 /* The following is mostly portable, except that: 1184 /* The following is mostly portable, except that:
1178 - it doesn't work for inside out declarations like void (*) (void). 1185 - it doesn't work for inside out declarations like void (*) (void).