#define SEEK_END 2
#endif
+#include <flexmember.h>
#include <min-max.h>
/* Files are read in chunks of this number of bytes. */
puts (name);
}
- sym = xmalloc (offsetof (struct sym, name) + strlen (name) + 1);
+ sym = xmalloc (FLEXSIZEOF (struct sym, name, strlen (name) + 1));
memset (sym, 0, offsetof (struct sym, name));
strcpy (sym->name, name);
sym->namesp = scope;
static struct member *
add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
{
- struct member *m = xmalloc (offsetof (struct member, name)
- + strlen (name) + 1);
+ struct member *m = xmalloc (FLEXSIZEOF (struct member, name,
+ strlen (name) + 1));
struct member **list;
struct member *p;
struct member *prev;
static struct sym *
make_namespace (char *name, struct sym *context)
{
- struct sym *s = xmalloc (offsetof (struct sym, name) + strlen (name) + 1);
+ struct sym *s = xmalloc (FLEXSIZEOF (struct sym, name, strlen (name) + 1));
memset (s, 0, offsetof (struct sym, name));
strcpy (s->name, name);
s->next = all_namespaces;
if (streq (new_name, al->name) && (al->namesp == current_namespace))
return;
- al = xmalloc (offsetof (struct alias, name) + strlen (new_name) + 1);
+ al = xmalloc (FLEXSIZEOF (struct alias, name, strlen (new_name) + 1));
strcpy (al->name, new_name);
al->next = namespace_alias_table[h];
al->namesp = current_namespace;
#include TERM_HEADER
#endif /* HAVE_WINDOW_SYSTEM */
+#include <flexmember.h>
#include <verify.h>
#include <execinfo.h> /* For backtrace. */
#ifdef GC_CHECK_STRING_BYTES
-#define SDATA_SIZE(NBYTES) \
- ((SDATA_DATA_OFFSET \
- + (NBYTES) + 1 \
- + sizeof (ptrdiff_t) - 1) \
- & ~(sizeof (ptrdiff_t) - 1))
+#define SDATA_SIZE(NBYTES) FLEXSIZEOF (struct sdata, data, NBYTES)
#else /* not GC_CHECK_STRING_BYTES */
/* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is
less than the size of that member. The 'max' is not needed when
- SDATA_DATA_OFFSET is a multiple of sizeof (ptrdiff_t), because then the
- alignment code reserves enough space. */
+ SDATA_DATA_OFFSET is a multiple of FLEXALIGNOF (struct sdata),
+ because then the alignment code reserves enough space. */
#define SDATA_SIZE(NBYTES) \
((SDATA_DATA_OFFSET \
- + (SDATA_DATA_OFFSET % sizeof (ptrdiff_t) == 0 \
+ + (SDATA_DATA_OFFSET % FLEXALIGNOF (struct sdata) == 0 \
? NBYTES \
- : max (NBYTES, sizeof (ptrdiff_t) - 1)) \
+ : max (NBYTES, FLEXALIGNOF (struct sdata) - 1)) \
+ 1 \
- + sizeof (ptrdiff_t) - 1) \
- & ~(sizeof (ptrdiff_t) - 1))
+ + FLEXALIGNOF (struct sdata) - 1) \
+ & ~(FLEXALIGNOF (struct sdata) - 1))
#endif /* not GC_CHECK_STRING_BYTES */
if (nbytes > LARGE_STRING_BYTES)
{
- size_t size = offsetof (struct sblock, data) + needed;
+ size_t size = FLEXSIZEOF (struct sblock, data, needed);
#ifdef DOUG_LEA_MALLOC
if (!mmap_lisp_allowed_p ())
enum
{
/* Alignment of struct Lisp_Vector objects. */
- vector_alignment = COMMON_MULTIPLE (ALIGNOF_STRUCT_LISP_VECTOR,
- GCALIGNMENT),
+ vector_alignment = COMMON_MULTIPLE (FLEXALIGNOF (struct Lisp_Vector),
+ GCALIGNMENT),
/* Vector size requests are a multiple of this. */
roundup_size = COMMON_MULTIPLE (vector_alignment, word_size)
};
/* Verify assumptions described above. */
-verify ((VECTOR_BLOCK_SIZE % roundup_size) == 0);
+verify (VECTOR_BLOCK_SIZE % roundup_size == 0);
verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS));
/* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */
#endif
#include <setjmp.h>
+
#include <c-ctype.h>
+#include <flexmember.h>
#include "lisp.h"
#include "frame.h"
if (bucket < 0)
bucket = xpm_color_bucket (color_name);
- nbytes = offsetof (struct xpm_cached_color, name) + strlen (color_name) + 1;
+ nbytes = FLEXSIZEOF (struct xpm_cached_color, name, strlen (color_name) + 1);
p = xmalloc (nbytes);
strcpy (p->name, color_name);
p->color = *color;
imagemagick_create_cache (char *signature)
{
struct animation_cache *cache
- = xmalloc (offsetof (struct animation_cache, signature)
- + strlen (signature) + 1);
+ = xmalloc (FLEXSIZEOF (struct animation_cache, signature,
+ strlen (signature) + 1));
cache->wand = 0;
cache->index = 0;
cache->next = 0;
Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER];
};
-/* C11 prohibits alignof (struct Lisp_Vector), so compute it manually. */
-enum
- {
- ALIGNOF_STRUCT_LISP_VECTOR
- = alignof (union { struct vectorlike_header a; Lisp_Object b; })
- };
-
/* A boolvector is a kind of vectorlike, with contents like a string. */
struct Lisp_Bool_Vector
#endif
#include <c-ctype.h>
+#include <flexmember.h>
#include <sig2str.h>
#include <verify.h>
struct gaicb gaicb;
struct addrinfo hints;
char str[FLEXIBLE_ARRAY_MEMBER];
- } *req = xmalloc (offsetof (struct req, str)
- + hostlen + 1 + portstringlen + 1);
+ } *req = xmalloc (FLEXSIZEOF (struct req, str,
+ hostlen + 1 + portstringlen + 1));
dns_request = &req->gaicb;
dns_request->ar_name = req->str;
dns_request->ar_service = req->str + hostlen + 1;