Skip to content

Commit f8ecd19

Browse files
committed
OPAL_ALIGN_PAD_AMOUNT: safely allow passing zero byte alignment
Signed-off-by: Joseph Schuchart <schuchart@hlrs.de> (cherry picked from commit 67baec6)
1 parent d095139 commit f8ecd19

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

opal/include/opal/align.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Copyright (c) 2004-2005 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
8-
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
8+
* Copyright (c) 2004-2020 High Performance Computing Center Stuttgart,
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
@@ -22,11 +22,11 @@
2222
#ifndef OPAL_ALIGN_H
2323
#define OPAL_ALIGN_H
2424

25-
#define OPAL_DOWN_ALIGN(x, a, t) ((x) & ~(((t)(a) -1)))
26-
#define OPAL_DOWN_ALIGN_PTR(x, a, t) ((t) OPAL_DOWN_ALIGN((uintptr_t) x, a, uintptr_t))
27-
#define OPAL_ALIGN(x, a, t) (((x) + ((t)(a) -1)) & ~(((t)(a) -1)))
28-
#define OPAL_ALIGN_PTR(x, a, t) ((t) OPAL_ALIGN((uintptr_t) x, a, uintptr_t))
29-
#define OPAL_ALIGN_PAD_AMOUNT(x, s) ((~((uintptr_t)(x)) + 1) & ((uintptr_t)(s) -1))
25+
#define OPAL_DOWN_ALIGN(x,a,t) ((x) & ~(((t)(a)-1)))
26+
#define OPAL_DOWN_ALIGN_PTR(x,a,t) ((t)OPAL_DOWN_ALIGN((uintptr_t)x, a, uintptr_t))
27+
#define OPAL_ALIGN(x,a,t) (((x)+((t)(a)-1)) & ~(((t)(a)-1)))
28+
#define OPAL_ALIGN_PTR(x,a,t) ((t)OPAL_ALIGN((uintptr_t)x, a, uintptr_t))
29+
#define OPAL_ALIGN_PAD_AMOUNT(x,s) ((~((uintptr_t)(x))+1) & ((uintptr_t)(s)+(!(uintptr_t)(s))-1))
3030

3131
#if __STDC_VERSION__ >= 201101L
3232
# include <stddef.h>

0 commit comments

Comments
 (0)