Commit 098f7122 authored by Jens Gustedt's avatar Jens Gustedt
Browse files

icc correctly complains that alignof can only be applied to types, not

expressions
parent 50bef5ab
......@@ -305,6 +305,7 @@ signed p00_trailing_comma_in_initializer__(void) {
# define p00_has_builtin___sync_fetch_and_and 1
# define p00_has_builtin___sync_fetch_and_xor 1
# endif
# define P99_TYPEOF(X) __typeof__(X)
# if P99_GCC_VERSION >= 30000UL
# define p00_has_builtin___builtin_expect 1
# endif
......@@ -325,7 +326,6 @@ signed p00_trailing_comma_in_initializer__(void) {
# define p00_has_feature_gnu_alignof 1
# define p00_has_feature_statement_expression 1
# define p00_has_feature_tgmath_h 1
# define P99_TYPEOF(X) __typeof__(X)
# if (P99_GCC_VERSION >= 40700UL) && (P99_GCC_VERSION < 40900UL)
# define p00_has_feature_stdnoreturn_h 1
# define p00_has_feature_stdalign_h 1
......
......@@ -366,6 +366,69 @@ errno_t p00_qsort_s(void *p00_base,
return p00_qsort_generic(p00_base, p00_n, p00_a, p00_s, p00_comp, p00_ctx);
}
#ifdef P99_TYPEOF
# define P99_ALIGNOF(B) alignof(P99_TYPEOF(B))
#else
# ifdef __STDC_NO_COMPLEX__
# define P99_ALIGNOF(B) \
P99_GENERIC(&((B)[0]), \
sizeof((B)[0]), \
(void_ptr*, 1), \
/* */ \
(float*, alignof(float)), \
(double*, alignof(double)), \
(double*, alignof(cdouble)), \
/* */ \
(_Bool*, alignof(_Bool)), \
(char*, alignof(char)), \
(uchar*, alignof(uchar)), \
(schar*, alignof(schar)), \
/* */ \
(ushort*, alignof(ushort)), \
(short*, alignof(short)), \
/* */ \
(unsigned*, alignof(unsigned)), \
(signed*, alignof(signed)), \
/* */ \
(long*, alignof(long)), \
(ulong*, alignof(ulong)), \
/* */ \
(llong*, alignof(llong)), \
(ullong*, alignof(ullong)) \
)
# else
# define P99_ALIGNOF(B) \
P99_GENERIC(&((B)[0]), \
sizeof((B)[0]), \
(void_ptr*, 1), \
/* */ \
(float*, alignof(float)), \
(double*, alignof(double)), \
(ldouble*, alignof(ldouble)), \
/* */ \
(cfloat*, alignof(cfloat)), \
(cdouble*, alignof(cdouble)), \
(cldouble*, alignof(cldouble)), \
/* */ \
(_Bool*, alignof(_Bool)), \
(char*, alignof(char)), \
(uchar*, alignof(uchar)), \
(schar*, alignof(schar)), \
/* */ \
(ushort*, alignof(ushort)), \
(short*, alignof(short)), \
/* */ \
(unsigned*, alignof(unsigned)), \
(signed*, alignof(signed)), \
/* */ \
(long*, alignof(long)), \
(ulong*, alignof(ulong)), \
/* */ \
(llong*, alignof(llong)), \
(ullong*, alignof(ullong)) \
)
# endif
#endif
/**
** @brief A generic sorting routine.
......@@ -420,7 +483,7 @@ errno_t p00_qsort_s(void *p00_base,
/* */ \
(llong*, p00_qsort_llong), \
(ullong*, p00_qsort_ullong) \
)((B), (N), alignof(*(B)), (S), (CMP), (CTX)), \
)((B), (N), P99_ALIGNOF((B)[0]), (S), (CMP), (CTX)), \
"qsort_s runtime constraint violation")
#else
#define qsort_s(B, N, S, CMP, CTX) \
......@@ -453,7 +516,7 @@ errno_t p00_qsort_s(void *p00_base,
/* */ \
(llong*, p00_qsort_llong), \
(ullong*, p00_qsort_ullong) \
)((B), (N), alignof(*(B)), (S), (CMP), (CTX)), \
)((B), (N), P99_ALIGNOF((B)[0]), (S), (CMP), (CTX)), \
"qsort_s runtime constraint violation")
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment