Skip to content

Commit 1a767ed

Browse files
author
rhc54
committed
Merge pull request #654 from rhc54/topic/config
Remove internal bool type definitions
2 parents 0bb3fd0 + 536faf3 commit 1a767ed

File tree

5 files changed

+17
-114
lines changed

5 files changed

+17
-114
lines changed

config/c_get_alignment.m4

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dnl University of Stuttgart. All rights reserved.
1111
dnl Copyright (c) 2004-2005 The Regents of the University of California.
1212
dnl All rights reserved.
1313
dnl Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
14-
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
14+
dnl Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
1515
dnl $COPYRIGHT$
1616
dnl
1717
dnl Additional copyrights may follow
@@ -23,10 +23,18 @@ dnl
2323
# ----------------------------------
2424
# Determine datatype alignment.
2525
# First arg is type, 2nd arg is config var to define.
26+
# Now that we require C99 compilers, we include stdbool.h
27+
# in the alignment test so that we can find the definition
28+
# of "bool" when we test for its alignment. We might be able
29+
# to avoid this if we test for alignemtn of _Bool, but
30+
# since we use "bool" in the code, let's be safe and check
31+
# what we use. Yes, they should be the same - but "should" and
32+
# "are" frequently differ
2633
AC_DEFUN([OPAL_C_GET_ALIGNMENT],[
2734
AC_CACHE_CHECK([alignment of $1],
2835
[AS_TR_SH([opal_cv_c_align_$1])],
29-
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
36+
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
37+
#include <stdbool.h> ],
3038
[[
3139
struct foo { char c; $1 x; };
3240
struct foo *p = (struct foo *) malloc(sizeof(struct foo));

configure.ac

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ AC_CHECK_SIZEOF(pid_t)
419419
# Check for type alignments
420420
#
421421

422-
OPAL_C_GET_ALIGNMENT(_Bool, OPAL_ALIGNMENT_BOOL)
422+
OPAL_C_GET_ALIGNMENT(bool, OPAL_ALIGNMENT_BOOL)
423423
OPAL_C_GET_ALIGNMENT(int8_t, OPAL_ALIGNMENT_INT8)
424424
OPAL_C_GET_ALIGNMENT(int16_t, OPAL_ALIGNMENT_INT16)
425425
OPAL_C_GET_ALIGNMENT(int32_t, OPAL_ALIGNMENT_INT32)
@@ -460,23 +460,6 @@ fi
460460
OPAL_C_GET_ALIGNMENT(void *, OPAL_ALIGNMENT_VOID_P)
461461
OPAL_C_GET_ALIGNMENT(size_t, OPAL_ALIGNMENT_SIZE_T)
462462

463-
#
464-
# Does the C compiler native support "bool"? (i.e., without
465-
# <stdbool.h> or any other help)
466-
#
467-
468-
OPAL_VAR_SCOPE_PUSH([MSG])
469-
AC_MSG_CHECKING(for C bool type)
470-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
471-
AC_INCLUDES_DEFAULT],
472-
[[bool bar, foo = true; bar = foo;]])],
473-
[OPAL_NEED_C_BOOL=0 MSG=yes],[OPAL_NEED_C_BOOL=1 MSG=no])
474-
AC_DEFINE_UNQUOTED(OPAL_NEED_C_BOOL, $OPAL_NEED_C_BOOL,
475-
[Whether the C compiler supports "bool" without any other help (such as <stdbool.h>)])
476-
AC_MSG_RESULT([$MSG])
477-
AC_CHECK_SIZEOF(_Bool)
478-
OPAL_VAR_SCOPE_POP
479-
480463
#
481464
# Check for other compiler characteristics
482465
#
@@ -636,37 +619,6 @@ AC_CHECK_HEADERS([net/if.h], [], [],
636619
#endif
637620
])
638621

639-
# Note that sometimes we have <stdbool.h>, but it doesn't work (e.g.,
640-
# have both Portland and GNU installed; using pgcc will find GNU's
641-
# <stdbool.h>, which all it does -- by standard -- is define "bool" to
642-
# "_Bool" [see
643-
# http://www.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html],
644-
# and Portland has no idea what to do with _Bool).
645-
646-
# So first figure out if we have <stdbool.h> (i.e., check the value of
647-
# the macro HAVE_STDBOOL_H from the result of AC_CHECK_HEADERS,
648-
# above). If we do have it, then check to see if it actually works.
649-
# Define OPAL_USE_STDBOOL_H as approrpaite.
650-
AC_CHECK_HEADERS([stdbool.h], [have_stdbool_h=1], [have_stdbool_h=0])
651-
OPAL_VAR_SCOPE_PUSH([MSG])
652-
AC_MSG_CHECKING([if <stdbool.h> works])
653-
if test "$have_stdbool_h" = "1"; then
654-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
655-
AC_INCLUDES_DEFAULT[
656-
#if HAVE_STDBOOL_H
657-
#include <stdbool.h>
658-
#endif]],
659-
[[bool bar, foo = true; bar = foo;]])],
660-
[OPAL_USE_STDBOOL_H=1 MSG=yes],[OPAL_USE_STDBOOL_H=0 MSG=no])
661-
else
662-
OPAL_USE_STDBOOL_H=0
663-
MSG="no (do not have <stdbool.h>)"
664-
fi
665-
AC_DEFINE_UNQUOTED(OPAL_USE_STDBOOL_H, $OPAL_USE_STDBOOL_H,
666-
[Whether to use <stdbool.h> or not])
667-
AC_MSG_RESULT([$MSG])
668-
OPAL_VAR_SCOPE_POP
669-
670622
# checkpoint results
671623
AC_CACHE_SAVE
672624

opal/include/opal_config_bottom.h

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* All rights reserved.
1616
* Copyright (c) 2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2015 Intel, Inc. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -270,61 +271,6 @@
270271
typedef OPAL_PTRDIFF_TYPE ptrdiff_t;
271272
#endif
272273

273-
/*
274-
* If we're in C, we may need to bring in the bool type and true/false
275-
* constants. OPAL_NEED_C_BOOL will be true if the compiler either
276-
* needs <stdbool.h> or doesn't define the bool type at all.
277-
*/
278-
#if !(defined(c_plusplus) || defined(__cplusplus))
279-
# if OPAL_NEED_C_BOOL
280-
# if OPAL_USE_STDBOOL_H
281-
/* If we're using <stdbool.h>, there is an implicit
282-
assumption that the C++ bool is the same size and has
283-
the same alignment. However, configure may have
284-
disabled the MPI C++ bindings, so if "_Bool" exists,
285-
then use that sizeof. */
286-
# include <stdbool.h>
287-
/* This section exists because AC_SIZEOF(bool) may not be
288-
run in configure if we're not building the MPI C++
289-
bindings. */
290-
# undef SIZEOF_BOOL
291-
# if SIZEOF__BOOL > 0
292-
# define SIZEOF_BOOL SIZEOF__BOOL
293-
# else
294-
/* If all else fails, assume it's 1 */
295-
# define SIZEOF_BOOL 1
296-
# endif
297-
# else
298-
/* We need to create a bool type and ensure that it's the
299-
same size / alignment as the C++ bool size /
300-
alignment */
301-
# define false 0
302-
# define true 1
303-
# if SIZEOF_BOOL == SIZEOF_CHAR && OPAL_ALIGNMENT_CXX_BOOL == OPAL_ALIGNMENT_CHAR
304-
typedef unsigned char bool;
305-
# elif SIZEOF_BOOL == SIZEOF_SHORT && OPAL_ALIGNMENT_CXX_BOOL == OPAL_ALIGNMENT_SHORT
306-
typedef short bool;
307-
# elif SIZEOF_BOOL == SIZEOF_INT && OPAL_ALIGNMENT_CXX_BOOL == OPAL_ALIGNMENT_INT
308-
typedef int bool;
309-
# elif SIZEOF_BOOL == SIZEOF_LONG && OPAL_ALIGNMENT_CXX_BOOL == OPAL_ALIGNMENT_LONG
310-
typedef long bool;
311-
# elif defined(SIZEOF_LONG_LONG) && defined(OPAL_ALIGNMENT_LONG) && SIZEOF_BOOL == SIZEOF_LONG && OPAL_ALIGNMENT_CXX_BOOL == OPAL_ALIGNMENT_LONG
312-
typedef long long bool;
313-
/* If we have _Bool, use that */
314-
# elif SIZEOF__BOOL > 0
315-
# undef SIZEOF_BOOL
316-
# define bool _Bool
317-
# define SIZEOF_BOOL SIZEOF__BOOL
318-
# else
319-
/* If all else fails, just make bool be an unsigned char
320-
and size of 1 */
321-
typedef unsigned char bool;
322-
# define SIZEOF_BOOL 1
323-
# endif
324-
# endif /* OPAL_USE_STDBOOL_H */
325-
# endif /* OPAL_NEED_C_BOOL */
326-
#endif
327-
328274
/*
329275
* Maximum size of a filename path.
330276
*/
@@ -468,6 +414,9 @@ static inline uint16_t ntohs(uint16_t netvar) { return netvar; }
468414

469415
#define IOVBASE_TYPE void
470416

417+
/* ensure the bool type is defined as it is used everywhere */
418+
#include <stdbool.h>
419+
471420
/**
472421
* If we generate our own bool type, we need a special way to cast the result
473422
* in such a way to keep the compilers silent.

test/datatype/position.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* of Tennessee Research Foundation. All rights
55
* reserved.
66
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
7-
* Copyright (c) 2014 Intel, Inc. All rights reserved.
7+
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
88
* $COPYRIGHT$
99
*
1010
* Additional copyrights may follow
@@ -15,9 +15,6 @@
1515
#include "ompi_config.h"
1616
#include <stdio.h>
1717
#include <string.h>
18-
#if OPAL_USE_STDBOOL_H
19-
#include <stdbool.h>
20-
#endif
2118

2219
#include "opal/datatype/opal_convertor.h"
2320
#include "ompi/datatype/ompi_datatype.h"

test/datatype/position_noncontig.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* of Tennessee Research Foundation. All rights
55
* reserved.
66
* Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved.
7-
* Copyright (c) 2014 Intel, Inc. All rights reserved.
7+
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
88
* $COPYRIGHT$
99
*
1010
* Additional copyrights may follow
@@ -15,9 +15,6 @@
1515
#include "ompi_config.h"
1616
#include <stdio.h>
1717
#include <string.h>
18-
#if OPAL_USE_STDBOOL_H
19-
#include <stdbool.h>
20-
#endif
2118

2219
#include "opal/datatype/opal_convertor.h"
2320
#include "ompi/datatype/ompi_datatype.h"

0 commit comments

Comments
 (0)