<commit_before>/*
 * Open-MX
 * Copyright © INRIA, CNRS 2007-2009 (see AUTHORS file)
 *
 * The development of this software has been funded by Myricom, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
 */

/* load MX specific types */
#include "omx__mx_compat.h"

/* load Open-MX specific types */
#include "open-mx.h"
#include "omx_lib.h"

/**************************************
 * Non-inlined ABI conversion routines
 */

/*
 * These functions convert non-success return values and status codes.
 * The whole functions supporting success are inlined in the header.
 */

__pure mx_return_t
omx_unlikely_return_to_mx(omx_return_t omxret, int strict)
{
  switch (omxret) {
  case OMX_BAD_ERROR:
    return MX_BAD_BAD_BAD;
  case OMX_ALREADY_INITIALIZED:
    return MX_ALREADY_INITIALIZED;
  case OMX_NOT_INITIALIZED:
    return MX_NOT_INITIALIZED;
  case OMX_NO_DEVICE_FILE:
    return MX_NO_DEV;
  case OMX_NO_DRIVER:
    return MX_NO_DRIVER;
  case OMX_ACCESS_DENIED:
    return MX_NO_PERM;
  case OMX_BOARD_NOT_FOUND:
    return MX_BOARD_UNKNOWN;
  case OMX_BAD_ENDPOINT:
    return MX_BAD_ENDPOINT;
  case OMX_SEGMENTS_BAD_COUNT:
    return MX_BAD_SEG_CNT;
  case OMX_BAD_REQUEST:
    return MX_BAD_REQUEST; /* can be MX_CANCEL_NOT_SUPPORTED as well */
  case OMX_BAD_MATCH_MASK:
    return MX_BAD_MATCH_MASK;
  case OMX_NO_RESOURCES:
    return MX_NO_RESOURCES;
  case OMX_BUSY:
    return MX_BUSY;
  case OMX_BAD_INFO_KEY:
    return MX_BAD_INFO_KEY;
  case OMX_BAD_INFO_ADDRESS:
    return MX_BAD_INFO_VAL;
  case OMX_ENDPOINT_PARAMS_BAD_LIST:
    return MX_BAD_PARAM_LIST;
  case OMX_ENDPOINT_PARAM_BAD_KEY:
    return MX_BAD_PARAM_NAME;
  case OMX_ENDPOINT_PARAM_BAD_VALUE:
    return MX_BAD_PARAM_VAL;
  case OMX_PEER_NOT_FOUND:
    return MX_HOST_NOT_FOUND;
  case OMX_TIMEOUT:
    return MX_TIMEOUT;
  case OMX_REMOTE_ENDPOINT_BAD_ID:
    return MX_BAD_ENDPOINT_ID;
  case OMX_REMOTE_ENDPOINT_CLOSED:
    return MX_CONNECTION_FAILED;
  case OMX_REMOTE_ENDPOINT_BAD_CONNECTION_KEY:
    return MX_BAD_CONNECTION_KEY;
  case OMX_BAD_INFO_LENGTH:
    return MX_BAD_INFO_LENGTH;
  case OMX_NIC_ID_NOT_FOUND:
    return MX_NIC_NOT_FOUND;
  case OMX_BAD_KERNEL_ABI:
    return MX_BAD_KERNEL_VERSION;
  case OMX_BAD_LIB_ABI:
    return MX_BAD_LIB_VERSION;
  case OMX_NOT_SUPPORTED_IN_HANDLER:
    return MX_CLOSE_IN_HANDLER;
  case OMX_BAD_MATCHING_FOR_CONTEXT_ID_MASK:
    return MX_BAD_MATCHING_FOR_CONTEXT_ID_MASK;

  case OMX_CANCELLED:
  case OMX_REMOTE_RDMA_WINDOW_BAD_ID:
  case OMX_REMOTE_ENDPOINT_UNREACHABLE:
  case OMX_REMOTE_ENDPOINT_BAD_SESSION:
  case OMX_MESSAGE_ABORTED:
  case OMX_MESSAGE_TRUNCATED:
  case OMX_NO_SYSTEM_RESOURCES:
  case OMX_NOT_IMPLEMENTED:
    if (!strict)
      /* just return the original code since the MX error handler code mixes return and status code */
      return (mx_return_t) omxret;
    /* fallthrough */

  default:
    omx__abort(NULL, "Unexpected Open-MX return code %d to translate into MX\n", omxret);
  }
}

__pure omx_return_t
omx_unlikely_return_from_mx(mx_return_t mxret, int strict)
{
  switch (mxret) {
  case MX_BAD_BAD_BAD:
    return OMX_BAD_ERROR;
  case MX_ALREADY_INITIALIZED:
    return OMX_ALREADY_INITIALIZED;
  case MX_NOT_INITIALIZED:
    return OMX_NOT_INITIALIZED;
  case MX_NO_DEV:
    return OMX_NO_DEVICE_FILE;
  case MX_NO_DRIVER:
    return OMX_NO_DRIVER;
  case MX_NO_PERM:
    return OMX_ACCESS_DENIED;
  case MX_BOARD_UNKNOWN:
    return OMX_BOARD_NOT_FOUND;
  case MX_BAD_ENDPOINT:
    return OMX_BAD_ENDPOINT;
  case MX_BAD_SEG_CNT:
    return OMX_SEGMENTS_BAD_COUNT;
  case MX_BAD_REQUEST:
    return OMX_BAD_REQUEST;
  case MX_BAD_MATCH_MASK:
    return OMX_BAD_MATCH_MASK;
  case MX_NO_RESOURCES:
    return OMX_NO_RESOURCES;
  case MX_BUSY:
    return OMX_BUSY;
  case MX_BAD_INFO_KEY:
    return OMX_BAD_INFO_KEY;
  case MX_BAD_INFO_VAL:
    return OMX_BAD_INFO_ADDRESS;
  case MX_BAD_PARAM_LIST:
    return OMX_ENDPOINT_PARAMS_BAD_LIST;
  case MX_BAD_PARAM_NAME:
    return OMX_ENDPOINT_PARAM_BAD_KEY;
  case MX_BAD_PARAM_VAL:
    return OMX_ENDPOINT_PARAM_BAD_VALUE;
  case MX_HOST_NOT_FOUND:
    return OMX_PEER_NOT_FOUND;
  case MX_TIMEOUT:
    return OMX_TIMEOUT;
  case MX_BAD_ENDPOINT_ID:
    return OMX_REMOTE_ENDPOINT_BAD_ID;
  case MX_CONNECTION_FAILED:
    return OMX_REMOTE_ENDPOINT_CLOSED;
  case MX_BAD_CONNECTION_KEY:
    return OMX_REMOTE_ENDPOINT_BAD_CONNECTION_KEY;
  case MX_BAD_INFO_LENGTH:
    return OMX_BAD_INFO_LENGTH;
  case MX_NIC_NOT_FOUND:
    return OMX_NIC_ID_NOT_FOUND;
  case MX_BAD_KERNEL_VERSION:
    return OMX_BAD_KERNEL_ABI;
  case MX_BAD_LIB_VERSION:
    return OMX_BAD_LIB_ABI;
  case MX_CANCEL_NOT_SUPPORTED:
    return OMX_BAD_REQUEST;
  case MX_CLOSE_IN_HANDLER:
    return OMX_NOT_SUPPORTED_IN_HANDLER;
  case MX_BAD_MATCHING_FOR_CONTEXT_ID_MASK:
    return OMX_BAD_MATCHING_FOR_CONTEXT_ID_MASK;

  case OMX_CANCELLED:
  case OMX_REMOTE_RDMA_WINDOW_BAD_ID:
  case OMX_REMOTE_ENDPOINT_UNREACHABLE:
  case OMX_REMOTE_ENDPOINT_BAD_SESSION:
  case OMX_MESSAGE_ABORTED:
  case OMX_MESSAGE_TRUNCATED:
  case OMX_NO_SYSTEM_RESOURCES:
  case OMX_NOT_IMPLEMENTED:
    if (!strict)
      /* just return the original code since the MX error handler code mixes return and status code */
      return (omx_return_t) mxret;
    /* fallthrough */

  default:
    omx__abort(NULL, "Unexpected MX return code %d to translate into Open-MX\n", mxret);
  }
}

__pure mx_status_code_t
omx_unlikely_status_code_to_mx(omx_return_t omxret)
{
  switch (omxret) {
  case OMX_TIMEOUT:
    return MX_STATUS_TIMEOUT;
  case OMX_MESSAGE_TRUNCATED:
    return MX_STATUS_TRUNCATED;
  case OMX_CANCELLED:
    return MX_STATUS_CANCELLED;
  case OMX_REMOTE_ENDPOINT_CLOSED:
    return MX_STATUS_ENDPOINT_CLOSED;
  case OMX_REMOTE_ENDPOINT_UNREACHABLE:
    return MX_STATUS_ENDPOINT_UNREACHABLE;
  case OMX_REMOTE_ENDPOINT_BAD_SESSION:
    return MX_STATUS_BAD_SESSION;
  case OMX_REMOTE_ENDPOINT_BAD_CONNECTION_KEY:
    return MX_STATUS_BAD_KEY;
  case OMX_REMOTE_ENDPOINT_BAD_ID:
    return MX_STATUS_BAD_ENDPOINT;<commit_msg>Shut up another gcc-4.5 warning by cleaning up conversion from mx_return_t to omx_return_t<commit_after>/*
 * Open-MX
 * Copyright © INRIA, CNRS 2007-2009 (see AUTHORS file)
 *
 * The development of this software has been funded by Myricom, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
 */

/* load MX specific types */
#include "omx__mx_compat.h"

/* load Open-MX specific types */
#include "open-mx.h"
#include "omx_lib.h"

/**************************************
 * Non-inlined ABI conversion routines
 */

/*
 * These functions convert non-success return values and status codes.
 * The whole functions supporting success are inlined in the header.
 */

__pure mx_return_t
omx_unlikely_return_to_mx(omx_return_t omxret, int strict)
{
  switch (omxret) {
  case OMX_BAD_ERROR:
    return MX_BAD_BAD_BAD;
  case OMX_ALREADY_INITIALIZED:
    return MX_ALREADY_INITIALIZED;
  case OMX_NOT_INITIALIZED:
    return MX_NOT_INITIALIZED;
  case OMX_NO_DEVICE_FILE:
    return MX_NO_DEV;
  case OMX_NO_DRIVER:
    return MX_NO_DRIVER;
  case OMX_ACCESS_DENIED:
    return MX_NO_PERM;
  case OMX_BOARD_NOT_FOUND:
    return MX_BOARD_UNKNOWN;
  case OMX_BAD_ENDPOINT:
    return MX_BAD_ENDPOINT;
  case OMX_SEGMENTS_BAD_COUNT:
    return MX_BAD_SEG_CNT;
  case OMX_BAD_REQUEST:
    return MX_BAD_REQUEST; /* can be MX_CANCEL_NOT_SUPPORTED as well */
  case OMX_BAD_MATCH_MASK:
    return MX_BAD_MATCH_MASK;
  case OMX_NO_RESOURCES:
    return MX_NO_RESOURCES;
  case OMX_BUSY:
    return MX_BUSY;
  case OMX_BAD_INFO_KEY:
    return MX_BAD_INFO_KEY;
  case OMX_BAD_INFO_ADDRESS:
    return MX_BAD_INFO_VAL;
  case OMX_ENDPOINT_PARAMS_BAD_LIST:
    return MX_BAD_PARAM_LIST;
  case OMX_ENDPOINT_PARAM_BAD_KEY:
    return MX_BAD_PARAM_NAME;
  case OMX_ENDPOINT_PARAM_BAD_VALUE:
    return MX_BAD_PARAM_VAL;
  case OMX_PEER_NOT_FOUND:
    return MX_HOST_NOT_FOUND;
  case OMX_TIMEOUT:
    return MX_TIMEOUT;
  case OMX_REMOTE_ENDPOINT_BAD_ID:
    return MX_BAD_ENDPOINT_ID;
  case OMX_REMOTE_ENDPOINT_CLOSED:
    return MX_CONNECTION_FAILED;
  case OMX_REMOTE_ENDPOINT_BAD_CONNECTION_KEY:
    return MX_BAD_CONNECTION_KEY;
  case OMX_BAD_INFO_LENGTH:
    return MX_BAD_INFO_LENGTH;
  case OMX_NIC_ID_NOT_FOUND:
    return MX_NIC_NOT_FOUND;
  case OMX_BAD_KERNEL_ABI:
    return MX_BAD_KERNEL_VERSION;
  case OMX_BAD_LIB_ABI:
    return MX_BAD_LIB_VERSION;
  case OMX_NOT_SUPPORTED_IN_HANDLER:
    return MX_CLOSE_IN_HANDLER;
  case OMX_BAD_MATCHING_FOR_CONTEXT_ID_MASK:
    return MX_BAD_MATCHING_FOR_CONTEXT_ID_MASK;

  case OMX_CANCELLED:
  case OMX_REMOTE_RDMA_WINDOW_BAD_ID:
  case OMX_REMOTE_ENDPOINT_UNREACHABLE:
  case OMX_REMOTE_ENDPOINT_BAD_SESSION:
  case OMX_MESSAGE_ABORTED:
  case OMX_MESSAGE_TRUNCATED:
  case OMX_NO_SYSTEM_RESOURCES:
  case OMX_NOT_IMPLEMENTED:
    if (!strict)
      /* just return the original code since the MX error handler code mixes return and status code */
      return (mx_return_t) omxret;
    /* fallthrough */

  default:
    omx__abort(NULL, "Unexpected Open-MX return code %d to translate into MX\n", omxret);
  }
}

__pure omx_return_t
omx_unlikely_return_from_mx(mx_return_t mxret, int strict)
{
  switch (mxret) {
  case MX_BAD_BAD_BAD:
    return OMX_BAD_ERROR;
  case MX_ALREADY_INITIALIZED:
    return OMX_ALREADY_INITIALIZED;
  case MX_NOT_INITIALIZED:
    return OMX_NOT_INITIALIZED;
  case MX_NO_DEV:
    return OMX_NO_DEVICE_FILE;
  case MX_NO_DRIVER:
    return OMX_NO_DRIVER;
  case MX_NO_PERM:
    return OMX_ACCESS_DENIED;
  case MX_BOARD_UNKNOWN:
    return OMX_BOARD_NOT_FOUND;
  case MX_BAD_ENDPOINT:
    return OMX_BAD_ENDPOINT;
  case MX_BAD_SEG_CNT:
    return OMX_SEGMENTS_BAD_COUNT;
  case MX_BAD_REQUEST:
    return OMX_BAD_REQUEST;
  case MX_BAD_MATCH_MASK:
    return OMX_BAD_MATCH_MASK;
  case MX_NO_RESOURCES:
    return OMX_NO_RESOURCES;
  case MX_BUSY:
    return OMX_BUSY;
  case MX_BAD_INFO_KEY:
    return OMX_BAD_INFO_KEY;
  case MX_BAD_INFO_VAL:
    return OMX_BAD_INFO_ADDRESS;
  case MX_BAD_PARAM_LIST:
    return OMX_ENDPOINT_PARAMS_BAD_LIST;
  case MX_BAD_PARAM_NAME:
    return OMX_ENDPOINT_PARAM_BAD_KEY;
  case MX_BAD_PARAM_VAL:
    return OMX_ENDPOINT_PARAM_BAD_VALUE;
  case MX_HOST_NOT_FOUND:
    return OMX_PEER_NOT_FOUND;
  case MX_TIMEOUT:
    return OMX_TIMEOUT;
  case MX_BAD_ENDPOINT_ID:
    return OMX_REMOTE_ENDPOINT_BAD_ID;
  case MX_CONNECTION_FAILED:
    return OMX_REMOTE_ENDPOINT_CLOSED;
  case MX_BAD_CONNECTION_KEY:
    return OMX_REMOTE_ENDPOINT_BAD_CONNECTION_KEY;
  case MX_BAD_INFO_LENGTH:
    return OMX_BAD_INFO_LENGTH;
  case MX_NIC_NOT_FOUND:
    return OMX_NIC_ID_NOT_FOUND;
  case MX_BAD_KERNEL_VERSION:
    return OMX_BAD_KERNEL_ABI;
  case MX_BAD_LIB_VERSION:
    return OMX_BAD_LIB_ABI;
  case MX_CANCEL_NOT_SUPPORTED:
    return OMX_BAD_REQUEST;
  case MX_CLOSE_IN_HANDLER:
    return OMX_NOT_SUPPORTED_IN_HANDLER;
  case MX_BAD_MATCHING_FOR_CONTEXT_ID_MASK:
    return OMX_BAD_MATCHING_FOR_CONTEXT_ID_MASK;

  default:
    switch ((omx_return_t) mxret) {
    case OMX_CANCELLED:
    case OMX_REMOTE_RDMA_WINDOW_BAD_ID:
    case OMX_REMOTE_ENDPOINT_UNREACHABLE:
    case OMX_REMOTE_ENDPOINT_BAD_SESSION:
    case OMX_MESSAGE_ABORTED:
    case OMX_MESSAGE_TRUNCATED:
    case OMX_NO_SYSTEM_RESOURCES:
    case OMX_NOT_IMPLEMENTED:
      if (!strict)
	/* just return the original code since the MX error handler code mixes return and status code */
	return (omx_return_t) mxret;
      /* fallthrough */

    default:
      omx__abort(NULL, "Unexpected MX return code %d to translate into Open-MX\n", mxret);
    }
  }
}

__pure mx_status_code_t
omx_unlikely_status_code_to_mx(omx_return_t omxret)
{
  switch (omxret) {
  case OMX_TIMEOUT:
    return MX_STATUS_TIMEOUT;
  case OMX_MESSAGE_TRUNCATED:
    return MX_STATUS_TRUNCATED;
  case OMX_CANCELLED:
    return MX_STATUS_CANCELLED;
  case OMX_REMOTE_ENDPOINT_CLOSED:
    return MX_STATUS_ENDPOINT_CLOSED;
  case OMX_REMOTE_ENDPOINT_UNREACHABLE:
    return MX_STATUS_ENDPOINT_UNREACHABLE;
  case OMX_REMOTE_ENDPOINT_BAD_SESSION:
    return MX_STATUS_BAD_SESSION;
  case OMX_REMOTE_ENDPOINT_BAD_CONNECTION_KEY:
    return MX_STATUS_BAD_KEY;
  case OMX_REMOTE_ENDPOINT_BAD_ID:
    return MX_STATUS_BAD_ENDPOINT;
{'fraction_non_alphanumeric': 0.053010768997421506, 'fraction_numerical': 0.001668436220233581, 'mean_word_length': 4.613878246062154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7630319', 'n_tokens_mistral': 5312, 'n_tokens_neox': 5038, 'n_words': 1087}