Skip to content

Commit a809902

Browse files
author
Ralph Castain
committed
Now that we require C99, and stdbool.h is part of C99, we no longer need to define our own bool types. Since bool is commonly used in a lot of places, just include stdbool.h in opal_config_bottom.h
1 parent 5ce91b0 commit a809902

File tree

1 file changed

+4
-55
lines changed

1 file changed

+4
-55
lines changed

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.

0 commit comments

Comments
 (0)