[llvm] r210635 - Uses generic_category instead of system_category.

Rafael Espindola rafael.espindola at gmail.com
Tue Jun 10 21:34:42 PDT 2014


Author: rafael
Date: Tue Jun 10 23:34:41 2014
New Revision: 210635

URL: http://llvm.org/viewvc/llvm-project?rev=210635&view=rev
Log:
Uses generic_category instead of system_category.

Some c++ libraries (libstdc++ at least) don't seem to map to the generic
category in in the system_category's default_error_condition.

Modified:
    llvm/trunk/lib/Support/Unix/Memory.inc
    llvm/trunk/lib/Support/Unix/Path.inc

Modified: llvm/trunk/lib/Support/Unix/Memory.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Memory.inc?rev=210635&r1=210634&r2=210635&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Memory.inc (original)
+++ llvm/trunk/lib/Support/Unix/Memory.inc Tue Jun 10 23:34:41 2014
@@ -95,7 +95,7 @@ Memory::allocateMappedMemory(size_t NumB
 #ifdef NEED_DEV_ZERO_FOR_MMAP
   static int zero_fd = open("/dev/zero", O_RDWR);
   if (zero_fd == -1) {
-    EC = error_code(errno, system_category());
+    EC = error_code(errno, generic_category());
     return MemoryBlock();
   }
   fd = zero_fd;
@@ -123,7 +123,7 @@ Memory::allocateMappedMemory(size_t NumB
     if (NearBlock) //Try again without a near hint
       return allocateMappedMemory(NumBytes, nullptr, PFlags, EC);
 
-    EC = error_code(errno, system_category());
+    EC = error_code(errno, generic_category());
     return MemoryBlock();
   }
 
@@ -143,7 +143,7 @@ Memory::releaseMappedMemory(MemoryBlock
     return error_code();
 
   if (0 != ::munmap(M.Address, M.Size))
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
 
   M.Address = nullptr;
   M.Size = 0;
@@ -163,7 +163,7 @@ Memory::protectMappedMemory(const Memory
 
   int Result = ::mprotect(M.Address, M.Size, Protect);
   if (Result != 0)
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
 
   if (Flags & MF_EXEC)
     Memory::InvalidateInstructionCache(M.Address, M.Size);

Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=210635&r1=210634&r2=210635&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Tue Jun 10 23:34:41 2014
@@ -249,7 +249,7 @@ error_code current_path(SmallVectorImpl<
     if (::getcwd(result.data(), result.capacity()) == nullptr) {
       // See if there was a real error.
       if (errno != ENOMEM)
-        return error_code(errno, system_category());
+        return error_code(errno, generic_category());
       // Otherwise there just wasn't enough space.
       result.reserve(result.capacity() * 2);
     } else
@@ -266,7 +266,7 @@ error_code create_directory(const Twine
 
   if (::mkdir(p.begin(), S_IRWXU | S_IRWXG) == -1) {
     if (errno != EEXIST || !IgnoreExisting)
-      return error_code(errno, system_category());
+      return error_code(errno, generic_category());
   }
 
   return error_code();
@@ -295,7 +295,7 @@ error_code create_link(const Twine &to,
   StringRef t = to.toNullTerminatedStringRef(to_storage);
 
   if (::symlink(t.begin(), f.begin()) == -1)
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
 
   return error_code();
 }
@@ -307,7 +307,7 @@ error_code remove(const Twine &path, boo
   struct stat buf;
   if (lstat(p.begin(), &buf) != 0) {
     if (errno != ENOENT || !IgnoreNonExisting)
-      return error_code(errno, system_category());
+      return error_code(errno, generic_category());
     return error_code();
   }
 
@@ -321,7 +321,7 @@ error_code remove(const Twine &path, boo
 
   if (::remove(p.begin()) == -1) {
     if (errno != ENOENT || !IgnoreNonExisting)
-      return error_code(errno, system_category());
+      return error_code(errno, generic_category());
   }
 
   return error_code();
@@ -335,7 +335,7 @@ error_code rename(const Twine &from, con
   StringRef t = to.toNullTerminatedStringRef(to_storage);
 
   if (::rename(f.begin(), t.begin()) == -1)
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
 
   return error_code();
 }
@@ -345,7 +345,7 @@ error_code resize_file(const Twine &path
   StringRef p = path.toNullTerminatedStringRef(path_storage);
 
   if (::truncate(p.begin(), size) == -1)
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
 
   return error_code();
 }
@@ -356,7 +356,7 @@ error_code exists(const Twine &path, boo
 
   if (::access(p.begin(), F_OK) == -1) {
     if (errno != ENOENT)
-      return error_code(errno, system_category());
+      return error_code(errno, generic_category());
     result = false;
   } else
     result = true;
@@ -401,7 +401,7 @@ error_code equivalent(const Twine &A, co
 static error_code fillStatus(int StatRet, const struct stat &Status,
                              file_status &Result) {
   if (StatRet != 0) {
-    error_code ec(errno, system_category());
+    error_code ec(errno, generic_category());
     if (ec == errc::no_such_file_or_directory)
       Result = file_status(file_type::file_not_found);
     else
@@ -454,7 +454,7 @@ error_code setLastModificationAndAccessT
   Times[0].tv_nsec = 0;
   Times[1] = Times[0];
   if (::futimens(FD, Times))
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
   return error_code();
 #elif defined(HAVE_FUTIMES)
   timeval Times[2];
@@ -462,7 +462,7 @@ error_code setLastModificationAndAccessT
   Times[0].tv_usec = 0;
   Times[1] = Times[0];
   if (::futimes(FD, Times))
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
   return error_code();
 #else
 #warning Missing futimes() and futimens()
@@ -478,7 +478,7 @@ error_code mapped_file_region::init(int
   // Figure out how large the file is.
   struct stat FileInfo;
   if (fstat(FD, &FileInfo) == -1)
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
   uint64_t FileSize = FileInfo.st_size;
 
   if (Size == 0)
@@ -486,7 +486,7 @@ error_code mapped_file_region::init(int
   else if (FileSize < Size) {
     // We need to grow the file.
     if (ftruncate(FD, Size) == -1)
-      return error_code(errno, system_category());
+      return error_code(errno, generic_category());
   }
 
   int flags = (Mode == readwrite) ? MAP_SHARED : MAP_PRIVATE;
@@ -496,7 +496,7 @@ error_code mapped_file_region::init(int
 #endif
   Mapping = ::mmap(nullptr, Size, prot, flags, FD, Offset);
   if (Mapping == MAP_FAILED)
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
   return error_code();
 }
 
@@ -519,7 +519,7 @@ mapped_file_region::mapped_file_region(c
   int oflags = (mode == readonly) ? O_RDONLY : O_RDWR;
   int ofd = ::open(name.begin(), oflags);
   if (ofd == -1) {
-    ec = error_code(errno, system_category());
+    ec = error_code(errno, generic_category());
     return;
   }
 
@@ -588,7 +588,7 @@ error_code detail::directory_iterator_co
   SmallString<128> path_null(path);
   DIR *directory = ::opendir(path_null.c_str());
   if (!directory)
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
 
   it.IterationHandle = reinterpret_cast<intptr_t>(directory);
   // Add something for replace_filename to replace.
@@ -609,7 +609,7 @@ error_code detail::directory_iterator_in
   errno = 0;
   dirent *cur_dir = ::readdir(reinterpret_cast<DIR *>(it.IterationHandle));
   if (cur_dir == nullptr && errno != 0) {
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
   } else if (cur_dir != nullptr) {
     StringRef name(cur_dir->d_name, NAMLEN(cur_dir));
     if ((name.size() == 1 && name[0] == '.') ||
@@ -631,7 +631,7 @@ error_code get_magic(const Twine &path,
   // Open path.
   std::FILE *file = std::fopen(Path.data(), "rb");
   if (!file)
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
 
   // Reserve storage.
   result.reserve(len);
@@ -640,7 +640,7 @@ error_code get_magic(const Twine &path,
   size_t size = std::fread(result.data(), 1, len, file);
   if (std::ferror(file) != 0) {
     std::fclose(file);
-    return error_code(errno, system_category());
+    return error_code(errno, generic_category());
   } else if (size != len) {
     if (std::feof(file) != 0) {
       std::fclose(file);
@@ -658,7 +658,7 @@ error_code openFileForRead(const Twine &
   StringRef P = Name.toNullTerminatedStringRef(Storage);
   while ((ResultFD = open(P.begin(), O_RDONLY)) < 0) {
     if (errno != EINTR)
-      return error_code(errno, system_category());
+      return error_code(errno, generic_category());
   }
   return error_code();
 }
@@ -688,7 +688,7 @@ error_code openFileForWrite(const Twine
   StringRef P = Name.toNullTerminatedStringRef(Storage);
   while ((ResultFD = open(P.begin(), OpenFlags, Mode)) < 0) {
     if (errno != EINTR)
-      return error_code(errno, system_category());
+      return error_code(errno, generic_category());
   }
   return error_code();
 }





More information about the llvm-commits mailing list