Skip to content

Commit 65e34c9

Browse files
committed
fixes to handle count/offset/aint in abi.h
Signed-off-by: Howard Pritchard <[email protected]>
1 parent efe6b00 commit 65e34c9

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

ompi/mpi/bindings/c_header.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,28 @@ def output_constant(const, use_enum: bool, mangle_name: bool):
220220
output.append(f"{binding[0]} P{' '.join(binding[1:])};\n")
221221

222222
# ================================ Final Output ================================
223-
output.append("#endif /* _ABI_INTERNAL_ */")
223+
output.append("#if defined(__cplusplus)\n")
224+
output.append("}\n")
225+
output.append("#endif\n")
226+
output.append("#endif /* MPI_H_ABI */")
224227
# === some compilers are finicky about not having empy line at end of include file =====
225228
output.append("\n")
226229

230+
#replacements = {'MPI_COUNT':'MPI_Count_ABI_INTERNAL',
231+
# 'MPI_AINT':'MPI_Aint_ABI_INTERNAL',
232+
# 'MPI_OFFSET':'MPI_Offset_ABI_INTERNAL'}
233+
replacements = {'MPI_COUNT':'MPI_Count',
234+
'MPI_AINT':'MPI_Aint',
235+
'MPI_OFFSET':'MPI_Offset'}
236+
227237
for i, line in enumerate(output):
228238
line = line.replace(r"\ldots", "...")
239+
for key, value in replacements.items():
240+
if MANGLE_NAMES:
241+
value = value+'_ABI_INTERNAL'
242+
line = line.replace(f'@{key}@', value)
229243
if MANGLE_NAMES:
244+
230245
# Replace datatypes with their internal ABI counterparts
231246
for datatype in INTERNAL_DATATYPES:
232247
# Need to include the extra space here or else we'll edit functions

ompi/mpi/c/abi.h.in

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
/*
2-
* $COPYRIGHT$
3-
*
4-
* Additional copyrights may follow
5-
*
6-
* $HEADER$
7-
*/
1+
#ifndef MPI_H_ABI
2+
#define MPI_H_ABI
83

9-
#ifndef _ABI_INTERNAL_
10-
#define _ABI_INTERNAL_
4+
#include <stddef.h>
5+
#include <stdint.h>
116

12-
/* TODO: figure out which includes we need, change to <> instead of "" */
13-
#include "stddef.h"
14-
#include "stdint.h"
7+
#if defined(__cplusplus)
8+
extern "C" {
9+
#endif
1510

1611
#undef MPI_VERSION
1712
#define MPI_VERSION 5
@@ -39,23 +34,23 @@ typedef struct MPI_ABI_Win * MPI_Win;
3934
#if !defined(MPI_ABI_Aint)
4035
#define MPI_ABI_Aint intptr_t
4136
#endif
42-
typedef MPI_ABI_Aint MPI_Aint;
37+
typedef MPI_ABI_Aint @MPI_AINT@;
4338
#undef MPI_ABI_Aint
4439

4540
/* MPI_Offset will be 64b on all relevant systems.
4641
* We allow for MPI implementations supporting for 128b filesystems. */
4742
#if !defined(MPI_ABI_Offset)
4843
#define MPI_ABI_Offset int64_t
4944
#endif
50-
typedef MPI_ABI_Offset MPI_Offset;
45+
typedef MPI_ABI_Offset @MPI_OFFSET@;
5146
#undef MPI_ABI_Offset
5247

5348
/* MPI_Count must be large enough to hold the larger of MPI_Aint and MPI_Offset.
5449
* Platforms where MPI_Aint is larger than MPI_Offset are extremely rare. */
5550
#if !defined(MPI_ABI_Count)
5651
#define MPI_ABI_Count MPI_Offset
5752
#endif
58-
typedef MPI_ABI_Count MPI_Count;
53+
typedef MPI_ABI_Count @MPI_COUNT@;
5954
#undef MPI_ABI_Count
6055

6156
typedef struct {

0 commit comments

Comments
 (0)