~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/System/Errno.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- Errno.cpp - errno support --------------------------------*- C++ -*-===//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This file implements the errno wrappers.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#include "llvm/System/Errno.h"
 
15
#include "llvm/Config/config.h"     // Get autoconf configuration settings
 
16
 
 
17
#if HAVE_STRING_H
 
18
#include <string.h>
 
19
 
 
20
#if HAVE_ERRNO_H
 
21
#include <errno.h>
 
22
#endif
 
23
 
 
24
//===----------------------------------------------------------------------===//
 
25
//=== WARNING: Implementation here must contain only TRULY operating system
 
26
//===          independent code.
 
27
//===----------------------------------------------------------------------===//
 
28
 
 
29
namespace llvm {
 
30
namespace sys {
 
31
 
 
32
#if HAVE_ERRNO_H
 
33
std::string StrError() {
 
34
  return StrError(errno);
 
35
}
 
36
#endif  // HAVE_ERRNO_H
 
37
 
 
38
std::string StrError(int errnum) {
 
39
  const int MaxErrStrLen = 2000;
 
40
  char buffer[MaxErrStrLen];
 
41
  buffer[0] = '\0';
 
42
  char* str = buffer;
 
43
#ifdef HAVE_STRERROR_R
 
44
  // strerror_r is thread-safe.
 
45
  if (errnum)
 
46
# if defined(__GLIBC__) && defined(_GNU_SOURCE)
 
47
    // glibc defines its own incompatible version of strerror_r
 
48
    // which may not use the buffer supplied.
 
49
    str = strerror_r(errnum,buffer,MaxErrStrLen-1);
 
50
# else
 
51
    strerror_r(errnum,buffer,MaxErrStrLen-1);
 
52
# endif
 
53
#elif defined(HAVE_STRERROR_S)  // Windows.
 
54
    if (errnum)
 
55
      strerror_s(buffer, errnum);
 
56
#elif defined(HAVE_STRERROR)
 
57
  // Copy the thread un-safe result of strerror into
 
58
  // the buffer as fast as possible to minimize impact
 
59
  // of collision of strerror in multiple threads.
 
60
  if (errnum)
 
61
    strncpy(buffer,strerror(errnum),MaxErrStrLen-1);
 
62
  buffer[MaxErrStrLen-1] = '\0';
 
63
#else
 
64
  // Strange that this system doesn't even have strerror
 
65
  // but, oh well, just use a generic message
 
66
  sprintf(buffer, "Error #%d", errnum);
 
67
#endif
 
68
  return str;
 
69
}
 
70
 
 
71
}  // namespace sys
 
72
}  // namespace llvm
 
73
 
 
74
#endif  // HAVE_STRING_H