# vim: set ft=c:

MPI_Abi_get_fortran_booleans:
    .desc: Get the size of Fortran logical type and the .TRUE. and .FALSE. value
    .seealso: MPI_Abi_set_fortran_booleans

MPI_Abi_get_fortran_info:
    .desc: Return an info object that provides information related to the Fortran ABI
    .seealso: MPI_Abi_set_fortran_info

MPI_Abi_get_info:
    .desc: Return an info object that provides information related to the ABI
    .seealso: MPI_Abi_get_version, MPI_Abi_get_fortran_info
    .skip: initcheck
{
    MPIR_Info *info_ptr;
    mpi_errno = MPIR_Info_alloc(&info_ptr);
    MPIR_ERR_CHECK(mpi_errno);

    char str[8];
#define PUSH_TYPE_INFO(type, keyname) \
    do { \
        snprintf(str, sizeof(str), "%d", (int) sizeof(type)); \
        MPIR_Info_push(info_ptr, keyname, str); \
    } while (0)
    PUSH_TYPE_INFO(MPI_Aint, "mpi_aint_size");
    PUSH_TYPE_INFO(MPI_Count, "mpi_count_size");
    PUSH_TYPE_INFO(MPI_Offset, "mpi_offset_size");
#undef PUSH_TYPE_INFO
    *info = info_ptr->handle;
}

MPI_Abi_get_version:
    .desc: Return the standard ABI version
    .seealso: MPI_Abi_get_info
    .skip: initcheck
{
    *abi_major = -1;
    *abi_minor = -1;
    if (mpi_errno != MPI_SUCCESS)
        goto fn_fail;
}
{ -- is_abi --
    *abi_major = MPI_ABI_VERSION;
    *abi_minor = MPI_ABI_SUBVERSION;
    if (mpi_errno != MPI_SUCCESS)
        goto fn_fail;
}

MPI_Abi_set_fortran_booleans:
    .desc: Set Fortran logical type size and the value for .TRUE. and .FALSE.
    .seealso: MPI_Abi_get_fortran_booleans

MPI_Abi_set_fortran_info:
    .desc: Set Fortran datatype sizes and whether optional Fortran types are supported
    .seealso: MPI_Abi_get_fortran_info

MPI_Comm_toint:
    .return: INTEGER
    comm: COMMUNICATOR
    .desc: converts MPI_Comm to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) comm;
}

MPI_Comm_fromint:
    .return: COMMUNICATOR
    comm: INTEGER
    .desc: converts an integer handle to MPI_Comm
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Comm) comm;
}

MPI_Errhandler_toint:
    .return: INTEGER
    errhandler: ERRHANDLER
    .desc: converts MPI_Errhandler to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) errhandler;
}

MPI_Errhandler_fromint:
    .return: ERRHANDLER
    errhandler: INTEGER
    .desc: converts an integer handle to MPI_Errhandler
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Errhandler) errhandler;
}

# MPI_File_fromint and MPI_File_toint are defined in io_api.txt

MPI_Group_toint:
    .return: INTEGER
    group: GROUP
    .desc: converts MPI_Group to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) group;
}

MPI_Group_fromint:
    .return: GROUP
    group: INTEGER
    .desc: converts an integer handle to MPI_Group
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Group) group;
}

MPI_Info_toint:
    .return: INTEGER
    info: INFO
    .desc: converts MPI_Info to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) info;
}

MPI_Info_fromint:
    .return: INFO
    info: INTEGER
    .desc: converts an integer handle to MPI_Info
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Info) info;
}

MPI_Message_toint:
    .return: INTEGER
    message: MESSAGE
    .desc: converts MPI_Message to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) message;
}

MPI_Message_fromint:
    .return: MESSAGE
    message: INTEGER
    .desc: converts an integer handle to MPI_Message
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Message) message;
}

MPI_Op_toint:
    .return: INTEGER
    op: OPERATION
    .desc: converts MPI_Op to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) op;
}

MPI_Op_fromint:
    .return: OPERATION
    op: INTEGER
    .desc: converts an integer handle to MPI_Op
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Op) op;
}

MPI_Request_toint:
    .return: INTEGER
    request: REQUEST
    .desc: converts MPI_Request to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) request;
}

MPI_Request_fromint:
    .return: REQUEST
    request: INTEGER
    .desc: converts an integer handle to MPI_Request
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Request) request;
}

MPI_Session_toint:
    .request: INTEGER
    session: SESSION
    .desc: converts MPI_Session to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) session;
}

MPI_Session_fromint:
    .return: SESSION
    session: INTEGER
    .desc: converts an integer handle to MPI_Session
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Session) session;
}

MPI_Type_toint:
    .return: INTEGER
    datatype: DATATYPE
    .desc: converts MPI_Type to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) datatype;
}

MPI_Type_fromint:
    .return: DATATYPE
    datatype: INTEGER
    .desc: converts an integer handle to MPI_Type
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Datatype) datatype;
}

MPI_Win_toint:
    .return: INTEGER
    win: WINDOW
    .desc: converts MPI_Win to an integer handle
    .impl: direct
    .skip: Fortran, Errors
{
    return (int) win;
}

MPI_Win_fromint:
    .return: WINDOW
    win: INTEGER
    .desc: converts an integer handle to MPI_Win
    .impl: direct
    .skip: Fortran, Errors
{
    return (MPI_Win) win;
}
