diff --git a/libgomp/loop.c b/libgomp/loop.c index 682df39a4ed4..be85162bb1ec 100644 --- a/libgomp/loop.c +++ b/libgomp/loop.c @@ -270,8 +270,11 @@ GOMP_loop_start (long start, long end, long incr, long sched, #define INLINE_ORDERED_TEAM_IDS_OFF \ ((offsetof (struct gomp_work_share, inline_ordered_team_ids) \ + __alignof__ (long long) - 1) & ~(__alignof__ (long long) - 1)) - if (size > (sizeof (struct gomp_work_share) - - INLINE_ORDERED_TEAM_IDS_OFF)) + if (sizeof (struct gomp_work_share) + <= INLINE_ORDERED_TEAM_IDS_OFF + || __alignof__ (struct gomp_work_share) < __alignof__ (long long) + || size > (sizeof (struct gomp_work_share) + - INLINE_ORDERED_TEAM_IDS_OFF)) *mem = (void *) (thr->ts.work_share->ordered_team_ids = gomp_malloc_cleared (size)); diff --git a/libgomp/loop_ull.c b/libgomp/loop_ull.c index 2aaa34e3bca6..602737296d40 100644 --- a/libgomp/loop_ull.c +++ b/libgomp/loop_ull.c @@ -269,8 +269,11 @@ GOMP_loop_ull_start (bool up, gomp_ull start, gomp_ull end, #define INLINE_ORDERED_TEAM_IDS_OFF \ ((offsetof (struct gomp_work_share, inline_ordered_team_ids) \ + __alignof__ (long long) - 1) & ~(__alignof__ (long long) - 1)) - if (size > (sizeof (struct gomp_work_share) - - INLINE_ORDERED_TEAM_IDS_OFF)) + if (sizeof (struct gomp_work_share) + <= INLINE_ORDERED_TEAM_IDS_OFF + || __alignof__ (struct gomp_work_share) < __alignof__ (long long) + || size > (sizeof (struct gomp_work_share) + - INLINE_ORDERED_TEAM_IDS_OFF)) *mem = (void *) (thr->ts.work_share->ordered_team_ids = gomp_malloc_cleared (size)); diff --git a/libgomp/sections.c b/libgomp/sections.c index e9d99e434ac5..7751d5aac830 100644 --- a/libgomp/sections.c +++ b/libgomp/sections.c @@ -121,8 +121,11 @@ GOMP_sections2_start (unsigned count, uintptr_t *reductions, void **mem) #define INLINE_ORDERED_TEAM_IDS_OFF \ ((offsetof (struct gomp_work_share, inline_ordered_team_ids) \ + __alignof__ (long long) - 1) & ~(__alignof__ (long long) - 1)) - if (size > (sizeof (struct gomp_work_share) - - INLINE_ORDERED_TEAM_IDS_OFF)) + if (sizeof (struct gomp_work_share) + <= INLINE_ORDERED_TEAM_IDS_OFF + || __alignof__ (struct gomp_work_share) < __alignof__ (long long) + || size > (sizeof (struct gomp_work_share) + - INLINE_ORDERED_TEAM_IDS_OFF)) *mem = (void *) (thr->ts.work_share->ordered_team_ids = gomp_malloc_cleared (size)); diff --git a/libgomp/work.c b/libgomp/work.c index a88409dc78b0..c53625afe2c6 100644 --- a/libgomp/work.c +++ b/libgomp/work.c @@ -113,7 +113,9 @@ gomp_init_work_share (struct gomp_work_share *ws, size_t ordered, size_t o = nthreads * sizeof (*ws->ordered_team_ids); o += __alignof__ (long long) - 1; if ((offsetof (struct gomp_work_share, inline_ordered_team_ids) - & (__alignof__ (long long) - 1)) == 0) + & (__alignof__ (long long) - 1)) == 0 + && __alignof__ (struct gomp_work_share) + >= __alignof__ (long long)) o &= ~(__alignof__ (long long) - 1); ordered += o - 1; }