CPN
Computational Process Networks
Macros | Functions
MirrorBufferSet.cc File Reference
#include "common_priv.h"
#include "MirrorBufferSet.h"
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <assert.h>
#include <stdexcept>
#include <sys/mman.h>
#include <string.h>
#include <string>
#include <vector>
+ Include dependency graph for MirrorBufferSet.cc:

Go to the source code of this file.

Macros

#define MirrorBufferSet_SUPPORTED   1
 
#define MBS_USE_POSIX_SHM   0
 
#define MAP_FAILED   ((void*)-1)
 
#define MAP_NORESERVE   (0)
 
#define MirrorBufferSet_VERBOSITY   0
 
#define fprintf1(p)
 
#define fprintf2(p)
 

Functions

std::string StrError (int error)
 

Macro Definition Documentation

#define fprintf1 (   p)

Definition at line 129 of file MirrorBufferSet.cc.

Referenced by MirrorBufferSet::MirrorBufferSet().

#define fprintf2 (   p)
#define MAP_FAILED   ((void*)-1)

Definition at line 60 of file MirrorBufferSet.cc.

Referenced by MirrorBufferSet::MirrorBufferSet().

#define MAP_NORESERVE   (0)

Definition at line 65 of file MirrorBufferSet.cc.

Referenced by MirrorBufferSet::MirrorBufferSet().

#define MBS_USE_POSIX_SHM   0

Definition at line 22 of file MirrorBufferSet.cc.

#define MirrorBufferSet_SUPPORTED   1

Definition at line 10 of file MirrorBufferSet.cc.

#define MirrorBufferSet_VERBOSITY   0

Definition at line 123 of file MirrorBufferSet.cc.

Function Documentation

std::string StrError ( int  error)

Definition at line 68 of file MirrorBufferSet.cc.

References UNKNOWN_ERROR.

Referenced by MirrorBufferSet::MirrorBufferSet().

68  {
69  static const char UNKNOWN_ERROR[] = "Unknown error";
70  std::vector<char> errstr(256, '\0');
71  do {
72 #if defined(__APPLE__)
73  // if __APPLE__ strerror_r is declared to return an int
74  int err = strerror_r(error, &errstr[0], errstr.size());
75  if (err == 0) {
76  return &errstr[0];
77  } else {
78  if (errno == ERANGE) {
79  errstr.resize(2*errstr.size(), '\0');
80  } else {
81  return UNKNOWN_ERROR;
82  }
83  }
84 #else
85  char *str = strerror_r(error, &errstr[0], errstr.size());
86 
87  // Wierdness with different versions of strerror... From the man page:
88  //
89  // The strerror() and strerror_r() functions return the appropriate
90  // error description string, or an "Unknown error nnn" message if the
91  // error number is unknown.
92  //
93  // The XSI-compliant strerror_r() function returns 0 on success; on
94  // error, -1 is returned and errno is set to indicate the error.
95  //
96  // So str can be ether an error code OR a pointer to the error
97  // string... wierdness.
98 
99  if (str == (char*)-1) {
100  if (errno == ERANGE) {
101  errstr.resize(2*errstr.size(), '\0');
102  } else {
103  return UNKNOWN_ERROR;
104  }
105  } else if (str == 0) {
106  return &errstr[0];
107  } else {
108  return str;
109  }
110 #endif
111  } while (true);
112 }
static const char UNKNOWN_ERROR[]

+ Here is the caller graph for this function: