<commit_before>
/*
 * checks.h
 *
 *  Created on: Jun 11, 2012
 *      Author: wozniak
 *
 *  Various macros for easier error checking and reporting
 *
 *  The CHECK macros never report an error message in a correct
 *  program: thus, they may be disabled by NDEBUG for performance
 * */

#ifndef CHECKS_H
#define CHECKS_H

#ifndef NDEBUG

/**
  Asserts that condition is true, else returns given error code.
  Note: This is disabled if NDEBUG is defined
*/
#define CHECK_MSG(rc, args...)                  \
  { if (!(rc)) {                                             \
      printf("CHECK FAILED: %s:%i\n", __FILE__, __LINE__);   \
      printf(args);                                          \
      printf("\n");                                          \
      return ADLB_ERROR; }}

/**
   Checks that an MPI return code is MPI_SUCCESS
   Note: This is disabled if NDEBUG is defined
 */
#define MPI_CHECK(rc)  \
  { if (rc != MPI_SUCCESS) { \
    printf("MPI_CHECK FAILED: %s:%i\n", __FILE__, __LINE__);\
    return ADLB_ERROR; }}

/**
   Checks that an ADLB return code is ADLB_SUCCESS
   Note: This is disabled if NDEBUG is defined
   If used in nested functions that all return adlb_code, can
   create something like a stack trace
 */
#define ADLB_CHECK(rc) { \
  if (!(rc == ADLB_SUCCESS || rc == ADLB_NOTHING)) { \
    printf("ADLB_CHECK FAILED: %s:%i\n", __FILE__, __LINE__); \
    return rc; }}

/**
   Checks that an ADLB data return code is ADLB_DATA_SUCCESS
   Note: This is disabled if NDEBUG is defined
 */
#define ADLB_DATA_CHECK(dc) { \
  if (dc != ADLB_DATA_SUCCESS) { \
    printf("ADLB_DATA_CHECK FAILED: %s:%i\n", __FILE__, __LINE__); \
    return ADLB_ERROR; }}

#else

// Make these noops for performance
#define CHECK_MSG(rc, args...)
#define MPI_CHECK(rc)
#define ADLB_CHECK(rc)
#define ADLB_DATA_CHECK(rc)
#endif

#endif
<commit_msg>ADLB_CHECK() now gives function names in stack trace<commit_after>
/*
 * checks.h
 *
 *  Created on: Jun 11, 2012
 *      Author: wozniak
 *
 *  Various macros for easier error checking and reporting
 *
 *  The CHECK macros never report an error message in a correct
 *  program: thus, they may be disabled by NDEBUG for performance
 * */

#ifndef CHECKS_H
#define CHECKS_H

#ifndef NDEBUG

/**
  Asserts that condition is true, else returns given error code.
  Note: This is disabled if NDEBUG is defined
*/
#define CHECK_MSG(rc, args...)                  \
  { if (!(rc)) {                                             \
      printf("CHECK FAILED: %s:%i\n", __FILE__, __LINE__);   \
      printf(args);                                          \
      printf("\n");                                          \
      return ADLB_ERROR; }}

/**
   Checks that an MPI return code is MPI_SUCCESS
   Note: This is disabled if NDEBUG is defined
 */
#define MPI_CHECK(rc)  \
  { if (rc != MPI_SUCCESS) { \
    printf("MPI_CHECK FAILED: %s:%i\n", __FILE__, __LINE__);\
    return ADLB_ERROR; }}

/**
   Checks that an ADLB return code is ADLB_SUCCESS
   Note: This is disabled if NDEBUG is defined
   If used in nested functions that all return adlb_code, can
   create something like a stack trace
 */
#define ADLB_CHECK(rc) { \
  if (!(rc == ADLB_SUCCESS || rc == ADLB_NOTHING)) { \
    printf("ADLB_CHECK FAILED: %s:%s():%i\n", \
           __FILE__, __func__, __LINE__); \
    return rc; }}

/**
   Checks that an ADLB data return code is ADLB_DATA_SUCCESS
   Note: This is disabled if NDEBUG is defined
 */
#define ADLB_DATA_CHECK(dc) { \
  if (dc != ADLB_DATA_SUCCESS) { \
    printf("ADLB_DATA_CHECK FAILED: %s:%i\n", __FILE__, __LINE__); \
    return ADLB_ERROR; }}

#else

// Make these noops for performance
#define CHECK_MSG(rc, args...)
#define MPI_CHECK(rc)
#define ADLB_CHECK(rc)
#define ADLB_DATA_CHECK(rc)
#endif

#endif

{'fraction_non_alphanumeric': 0.11020300553651463, 'fraction_numerical': 0.0031637226469812814, 'mean_word_length': 2.399641577060932, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3345740', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1180, 'n_words': 400}