@@ -14,17 +14,18 @@ dnl Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
14
14
dnl Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
15
15
dnl Copyright (c) 2015 Research Organization for Information Science
16
16
dnl and Technology (RIST). All rights reserved.
17
+ dnl Copyright (c) 2021 Cisco Systems, Inc. All rights reserved.
17
18
dnl $COPYRIGHT $
18
19
dnl
19
20
dnl Additional copyrights may follow
20
21
dnl
21
22
dnl $HEADER $
22
23
dnl
23
24
24
- # OPAL_C_GET_ALIGN(type, config_var )
25
+ # OPAL_C_GET_ALIGNMENT(c_type, c_macro_name )
25
26
# ----------------------------------
26
27
# Determine datatype alignment.
27
- # First arg is type, 2nd arg is config var to define.
28
+ # First arg is type, 2nd arg is macro name to define.
28
29
# Now that we require C99 compilers, we include stdbool.h
29
30
# in the alignment test so that we can find the definition
30
31
# of "bool" when we test for its alignment. We might be able
33
34
# what we use. Yes, they should be the same - but "should" and
34
35
# "are" frequently differ
35
36
AC_DEFUN([OPAL_C_GET_ALIGNMENT],[
36
- AC_CACHE_CHECK([alignment of $1 ],
37
- [AS_TR_SH([opal_cv_c_align_$1 ])],
38
- [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
39
- # include <stdbool.h> ],
40
- [[
41
- struct foo { char c; $1 x; };
42
- struct foo * p = (struct foo * ) malloc(sizeof(struct foo));
43
- int diff;
44
- FILE * f= fopen(" conftestval" , " w" );
45
- if (! f) exit(1);
46
- diff = (( char * )& p-> x) - ((char * )& p-> c);
47
- free(p);
48
- fprintf(f, "%d\n", (diff >= 0 ) ? diff : -diff);
49
- ]])], [AS_TR_SH([opal_cv_c_align_$1 ])=`cat conftestval`],
50
- [AC_MSG_WARN([*** Problem running configure test!])
51
- AC_MSG_WARN([*** See config.log for details.])
52
- AC_MSG_ERROR([*** Cannot continue.])],
53
- [ # cross compile - do a non-executable test. Trick
54
- # taken from the Autoconf 2 .59 c. Switch to using
55
- # AC_CHECK_ALIGNOF when we can require Autoconf 2 .60 .
56
- _AC_COMPUTE_INT([(long int) offsetof (opal__type_alignof_, y)],
57
- [AS_TR_SH([opal_cv_c_align_$1 ])],
58
- [AC_INCLUDES_DEFAULT
59
- #include <stdbool.h>
37
+ OPAL_VAR_SCOPE_PUSH([opal_align_value])
38
+ AC_LANG_PUSH([C])
60
39
61
- #ifndef offsetof
62
- # define offsetof(type, member) ((char *) &((type *) 0 )->member - (char *) 0 )
63
- #endif
64
- typedef struct { char x; $1 y; } opal__type_alignof_;
65
- ],
66
- [AC_MSG_WARN([*** Problem running configure test!])
67
- AC_MSG_WARN([*** See config.log for details.])
68
- AC_MSG_ERROR([*** Cannot continue.])])])])
40
+ AC_CHECK_ALIGNOF([$1 ], [AC_INCLUDES_DEFAULT
41
+ # include <stdbool.h>
42
+ ])
69
43
70
- AC_DEFINE_UNQUOTED([$2 ], [$AS_TR_SH ([opal_cv_c_align_$1 ])], [Alignment of type $1 ])
71
- eval "$2 =$AS_TR_SH ([opal_cv_c_align_$1 ])"
44
+ # Put the value determined from AC CHECK_ALIGNOF into an
45
+ # easy-to-access shell variable.
46
+ AS_VAR_COPY([opal_align_value],
47
+ [ac_cv_alignof_]AS_TR_SH([$1 ]))
72
48
73
- rm -rf conftest* ]) dnl
49
+ # This $opal_cv_c_align_* shell variable is used elsewhere in
50
+ # configure.ac
51
+ AS_VAR_COPY([opal_cv_c_align_]AS_TR_SH([$1 ]),
52
+ [opal_align_value])
53
+
54
+ # This #define is used in C code.
55
+ AC_DEFINE_UNQUOTED([$2 ], [$opal_align_value ], [Alignment of $1 ])
56
+
57
+ AC_LANG_POP([C])
58
+ OPAL_VAR_SCOPE_POP
59
+ ])
0 commit comments