Skip to content

Commit 110141b

Browse files
vadikp-intelVadim Paretsky
and
Vadim Paretsky
authored
[OpenMP] fix endianness dependent definitions in OMP headers for MSVC (#84540)
MSVC does not define __BYTE_ORDER__ making the check for BigEndian erroneously evaluate to true and breaking the struct definitions in MSVC compiled builds correspondingly. The fix adds an additional check for whether __BYTE_ORDER__ is defined by the compiler to fix these. --------- Co-authored-by: Vadim Paretsky <[email protected]>
1 parent b4001e3 commit 110141b

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

openmp/runtime/src/kmp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,7 @@ typedef struct kmp_depend_info {
25072507
union {
25082508
kmp_uint8 flag; // flag as an unsigned char
25092509
struct { // flag as a set of 8 bits
2510-
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
2510+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
25112511
/* Same fields as in the #else branch, but in reverse order */
25122512
unsigned all : 1;
25132513
unsigned unused : 3;
@@ -2672,7 +2672,7 @@ typedef struct kmp_task_stack {
26722672
#endif // BUILD_TIED_TASK_STACK
26732673

26742674
typedef struct kmp_tasking_flags { /* Total struct must be exactly 32 bits */
2675-
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
2675+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
26762676
/* Same fields as in the #else branch, but in reverse order */
26772677
#if OMPX_TASKGRAPH
26782678
unsigned reserved31 : 6;

openmp/runtime/src/kmp_lock.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ extern void __kmp_validate_locks(void);
120120

121121
struct kmp_base_tas_lock {
122122
// KMP_LOCK_FREE(tas) => unlocked; locked: (gtid+1) of owning thread
123-
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ && __LP64__
123+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) && \
124+
__LP64__
124125
// Flip the ordering of the high and low 32-bit member to be consistent
125126
// with the memory layout of the address in 64-bit big-endian.
126127
kmp_int32 depth_locked; // depth locked, for nested locks only

openmp/runtime/test/tasking/bug_nested_proxy_task.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef struct kmp_depend_info {
5050
union {
5151
kmp_uint8 flag; // flag as an unsigned char
5252
struct { // flag as a set of 8 bits
53-
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
53+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
5454
unsigned all : 1;
5555
unsigned unused : 3;
5656
unsigned set : 1;

openmp/runtime/test/tasking/bug_proxy_task_dep_waiting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ typedef struct kmp_depend_info {
4747
union {
4848
kmp_uint8 flag; // flag as an unsigned char
4949
struct { // flag as a set of 8 bits
50-
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
50+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
5151
unsigned all : 1;
5252
unsigned unused : 3;
5353
unsigned set : 1;

openmp/runtime/test/tasking/hidden_helper_task/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef struct kmp_depend_info {
1717
union {
1818
unsigned char flag;
1919
struct {
20-
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
20+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
2121
unsigned all : 1;
2222
unsigned unused : 3;
2323
unsigned set : 1;

0 commit comments

Comments
 (0)