summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2015-01-28 15:55:18 -0500
committerNat Goodspeed <nat@lindenlab.com>2015-01-28 15:55:18 -0500
commitae6440eecc4d6c018a3634c2c06052757bde962f (patch)
tree991ee24e622568238d65a6428878399a539bc1cc /indra/llcommon
parent198046e21d08f7af67287c0ea7260163c424fe0d (diff)
MAINT-4744: Eliminate viewer dependency on (old) GNU libstdc++.
To be more accurate, this changeset doesn't actually eliminate the dependency: it eliminates the use cases for the llifstream / llofstream feature that requires it. Currently you can construct an llifstream or llofstream from an open LLFILE* file handle (or, except on Windows, an int file descriptor). But rather than containing a streambuf implementation based on FILE*, llfile.h relies on the fact that the Windows std::filebuf happens to support that as a nonstandard extension; also on a nonstandard GNU extension __gnu_cxx::stdio_filebuf<char>. To move from GNU libstdc++ to clang's libc++ (the direction on Mac), we could code a streambuf that supports FILE*. But before doing that, it's worth asking whether anyone actually uses this questionable feature. In fact there were only two methods: LLWearable::exportFile() and importFile() -- and only one call to either, in LLViewerWearable::saveNewAsset(). The code in saveNewAsset() opened the LLFILE* immediately before calling exportFile(), meaning we could reasonably push the open operation down into exportFile(). That logic was complex anyway due to the need for the caller to close the LLFILE* regardless of the success of the exportFile(). Change LLWearable::exportFile() and importFile() to accept a std::string filename rather than an open LLFILE*. Change LLViewerWearable::saveNewAsset() to simply call exportFile(filename) rather than horsing around with an LLFILE* handle. (This improves the code in another way too: it encapsulates the need to open the relevant file in binary mode. Previously, each caller had to remember to do that.) To prevent inadvertent reintroduction of ll[io]fstream(LLFILE*) code, add llstream_LLFILE preprocessor macro (default 0) to control access to the relevant constructors. Also suppress rdbuf() override, the only method whose signature references llstdio_filebuf.
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-xindra/llcommon/llfile.cpp4
-rwxr-xr-xindra/llcommon/llfile.h14
2 files changed, 18 insertions, 0 deletions
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index aabc195ba8..304d702979 100755
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -919,6 +919,7 @@ llifstream::llifstream(const char* _Filename,
#endif
+#if llstream_LLFILE
// explicit
llifstream::llifstream(_Filet *_File,
ios_base::openmode _Mode, size_t _Size) :
@@ -942,6 +943,7 @@ llifstream::llifstream(int __fd,
this->init(&_M_filebuf);
}
#endif
+#endif // llstream_LLFILE
bool llifstream::is_open() const
{ // test if C stream has been opened
@@ -1039,6 +1041,7 @@ llofstream::llofstream(const char* _Filename,
}
#endif
+#if llstream_LLFILE
// explicit
llofstream::llofstream(_Filet *_File,
ios_base::openmode _Mode, size_t _Size) :
@@ -1062,6 +1065,7 @@ llofstream::llofstream(int __fd,
this->init(&_M_filebuf);
}
#endif
+#endif // llstream_LLFILE
bool llofstream::is_open() const
{ // test if C stream has been opened
diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h
index 0612071d67..44a1e42fa5 100755
--- a/indra/llcommon/llfile.h
+++ b/indra/llcommon/llfile.h
@@ -86,6 +86,12 @@ public:
static const char * tmpdir();
};
+// Remove ll[io]fstream support for [LL]FILE*, preparing to remove dependency
+// on GNU's standard library.
+#if ! defined(llstream_LLFILE)
+#define llstream_LLFILE 0
+#endif
+
/**
* @brief Provides a layer of compatibility for C/POSIX.
*
@@ -228,6 +234,7 @@ public:
explicit llifstream(const char* _Filename,
ios_base::openmode _Mode = ios_base::in);
+#if llstream_LLFILE
/**
* @brief Create a stream using an open c file stream.
* @param File An open @c FILE*.
@@ -253,6 +260,7 @@ public:
//size_t _Size = static_cast<size_t>(BUFSIZ));
size_t _Size = static_cast<size_t>(1));
#endif
+#endif // llstream_LLFILE
/**
* @brief The destructor does nothing.
@@ -263,6 +271,7 @@ public:
virtual ~llifstream() {}
// Members:
+#if llstream_LLFILE
/**
* @brief Accessing the underlying buffer.
* @return The current basic_filebuf buffer.
@@ -271,6 +280,7 @@ public:
*/
llstdio_filebuf* rdbuf() const
{ return const_cast<llstdio_filebuf*>(&_M_filebuf); }
+#endif // llstream_LLFILE
/**
* @brief Wrapper to test for an open file.
@@ -340,6 +350,7 @@ public:
explicit llofstream(const char* _Filename,
ios_base::openmode _Mode = ios_base::out|ios_base::trunc);
+#if llstream_LLFILE
/**
* @brief Create a stream using an open c file stream.
* @param File An open @c FILE*.
@@ -365,6 +376,7 @@ public:
//size_t _Size = static_cast<size_t>(BUFSIZ));
size_t _Size = static_cast<size_t>(1));
#endif
+#endif // llstream_LLFILE
/**
* @brief The destructor does nothing.
@@ -375,6 +387,7 @@ public:
virtual ~llofstream() {}
// Members:
+#if llstream_LLFILE
/**
* @brief Accessing the underlying buffer.
* @return The current basic_filebuf buffer.
@@ -383,6 +396,7 @@ public:
*/
llstdio_filebuf* rdbuf() const
{ return const_cast<llstdio_filebuf*>(&_M_filebuf); }
+#endif // llstream_LLFILE
/**
* @brief Wrapper to test for an open file.