Skip to content

Commit

Permalink
common/compat: add strerror_r
Browse files Browse the repository at this point in the history
Signed-off-by: luo.runbing <[email protected]>
  • Loading branch information
runsisi committed Oct 22, 2019
1 parent c7e3b42 commit 157bd36
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/common/compat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,14 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize,
}
#endif

char *ceph_strerror_r(int errnum, char *buf, size_t buflen)
{
#ifdef STRERROR_R_CHAR_P
return strerror_r(errnum, buf, buflen);
#else
if (strerror_r(errnum, buf, buflen)) {
snprintf(buf, buflen, "Unknown error %d", errnum);
}
return buf;
#endif
}
10 changes: 10 additions & 0 deletions src/include/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,14 @@ int ceph_posix_fallocate(int fd, off_t offset, off_t len);

int pipe_cloexec(int pipefd[2], int flags);

#ifdef __cplusplus
extern "C" {
#endif

char *ceph_strerror_r(int errnum, char *buf, size_t buflen);

#ifdef __cplusplus
}
#endif

#endif /* !CEPH_COMPAT_H */

0 comments on commit 157bd36

Please sign in to comment.