Skip to content

Commit

Permalink
Merge branch 'main' into feature/hdf5
Browse files Browse the repository at this point in the history
  • Loading branch information
JDanielSmith committed Jan 25, 2023
2 parents 88ca9fc + aabc581 commit 146e0be
Show file tree
Hide file tree
Showing 60 changed files with 93 additions and 235 deletions.
3 changes: 2 additions & 1 deletion modules/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ set(CXX_STANDARD_REQUIRED true)
if (MSVC)
add_compile_options(/WX /W4)
elseif (UNIX)
add_compile_options(-Werror)
# still building with older GCC :-(
#add_compile_options(-Werror)
add_compile_options(-Wall)
#add_compile_options(-Wpedantic -Wextra)
add_compile_options(-Wno-deprecated-copy)
Expand Down
10 changes: 0 additions & 10 deletions modules/c++/coda_oss/include/coda_oss/CPlusPlus.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@
#endif // __INTEL_COMPILER
#endif // CODA_OSS_cplusplus

#if CODA_OSS_cplusplus < 201402L
// oops ... try to fix
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER_BUILD_DATE >= 20151021)
// __cplusplus is 201300, not 201402L
// Enough C++14, at least with our std/ work-arounds
#undef CODA_OSS_cplusplus
#define CODA_OSS_cplusplus 201402L
#endif
#endif // CODA_OSS_cplusplus

#if CODA_OSS_cplusplus < 202002L
// oops ... try to fix
#if defined(__GNUC__) && (__cplusplus >= 201709L) // note > C++ 17 of 201703L
Expand Down
30 changes: 10 additions & 20 deletions modules/c++/coda_oss/include/coda_oss/optional_.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,21 @@ class optional final
using value_type = T;

#if defined(_MSC_VER) && _PREFAST_ // Visual Studio /analyze
__pragma(warning(push)) __pragma(warning(
disable : 26495)) // Variable '...' is uninitialized. Always
// initialize a member variable(type.6).
__pragma(warning(push)) __pragma(warning(disable : 26495)) // Variable '...' is uninitialized. Always initialize a member variable(type.6).
#endif
optional() noexcept
optional() noexcept
{
}
#if defined(_MSC_VER) && _PREFAST_
__pragma(warning(pop))
#endif
optional(const value_type& v) :
value_(v), has_value_(true)
optional(const value_type& v) : value_(v), has_value_(true)
{
}
#if defined(_MSC_VER) && _PREFAST_ // Visual Studio /analyze
__pragma(warning(push)) __pragma(warning(
disable : 26495)) // Variable '...' is uninitialized. Always
// initialize a member variable(type.6).
__pragma(warning(push)) __pragma(warning(disable : 26495)) // Variable '...' is uninitialized. Always initialize a member variable(type.6).
#endif
optional(const optional& other) :
has_value_(other.has_value_)
optional(const optional& other) : has_value_(other.has_value_)
{
if (has_value())
{
Expand All @@ -94,18 +88,15 @@ class optional final
__pragma(warning(pop))
#endif

template <
typename... Args> // https://en.cppreference.com/w/cpp/utility/Optional/emplace
T& emplace(Args&&... args)
template <typename... Args> // https://en.cppreference.com/w/cpp/utility/Optional/emplace
T& emplace(Args&&... args)
{
value_ = value_type(std::forward<Args>(args)...);
has_value_ = true;
return value_;
}

template <
typename U =
T> // https://en.cppreference.com/w/cpp/utility/optional/operator%3D
template <typename U = T> // https://en.cppreference.com/w/cpp/utility/optional/operator%3D
optional& operator=(U&& value) noexcept
{
value_ = std::forward<U>(value);
Expand Down Expand Up @@ -163,11 +154,10 @@ class optional final
// contains a value!"
}

const T& operator*() const&
const T& operator*() const& noexcept
{
assert(has_value());
return value_; // "This operator does not check whether the optional
// contains a value!"
return value_; // "This operator does not check whether the optional contains a value!"
}
T& operator*() &
{
Expand Down
14 changes: 0 additions & 14 deletions modules/c++/coda_oss/include/coda_oss/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,7 @@
#include "coda_oss/namespace_.h"
namespace coda_oss
{
// workaround missing "is_trivially_copyable" in g++ < 5.0
// https://stackoverflow.com/a/31798726/8877
#if defined(__GNUC__) && (__GNUC__ < 5)
template <typename T>
struct is_trivially_copyable final
{
// This old Intel compiler has enough C++14 for our needs; see CPlusPlus.h
#if !(defined(__INTEL_COMPILER) && (__INTEL_COMPILER_BUILD_DATE <= 20151021))
static_assert(CODA_OSS_cplusplus < 201402L, "C++14 must have is_trivially_copyable.");
#endif
static constexpr bool value = __has_trivial_copy(T);
};
#else
using std::is_trivially_copyable;
#endif
}

#endif // CODA_OSS_coda_oss_type_traits_h_INCLUDED_
10 changes: 0 additions & 10 deletions modules/c++/io/source/FileInputStreamIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,8 @@ sys::SSize_T io::FileInputStreamIOS::readImpl(void* buffer, size_t len)
if (avail > 0)
{
sys::SSize_T bytesRead(0);
// There is a 'huge-gantic' bug in Forte 6.2
// in which 'read()' reads the first character twice
#if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x530)

while (bytesRead < avail && mFStream.good())
{
bufferPtr[bytesRead++] = mFStream.get();
}
#else
mFStream.read(bufferPtr, avail);
bytesRead = mFStream.gcount();
#endif
return bytesRead;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/c++/io/source/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
void copyPermissions(const std::string& src,
const std::string& dest)
{
#if !(defined(WIN32) || defined(_WIN32))
#ifndef _WIN32
// set up permissions on unix --
// copy the source's permissions
struct stat statBuf;
Expand Down
9 changes: 0 additions & 9 deletions modules/c++/io/source/StringStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,7 @@
//
// if (len <= 0) return 0;
//
//#if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x530)
// sys::SSize_T bytesRead(0);
// while (bytesRead < len && mData.good())
// {
// b[bytesRead++] = mData.get();
// }
// len = bytesRead;
//#else
// mData.read((char *)buffer, len);
//#endif
// // Could be problem if streams are broken
// // alternately could return gcount in else
// // case above
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/mt/include/mt/CPUAffinityInitializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <mt/AbstractCPUAffinityInitializer.h>

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32
#include <mt/CPUAffinityInitializerWin32.h>
namespace mt
{
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/mt/include/mt/CPUAffinityInitializerWin32.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef __MT_CPU_AFFINITY_INITIALIZER_WIN32_H__
#define __MT_CPU_AFFINITY_INITIALIZER_WIN32_H__

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32

#include <mt/AbstractCPUAffinityInitializer.h>
#include <mt/CPUAffinityThreadInitializerWin32.h>
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/mt/include/mt/CPUAffinityThreadInitializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <mt/AbstractCPUAffinityThreadInitializer.h>

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32
#include <mt/CPUAffinityThreadInitializerWin32.h>
namespace mt
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef __MT_CPU_AFFINITY_THREAD_INITIALIZER_WIN32_H__
#define __MT_CPU_AFFINITY_THREAD_INITIALIZER_WIN32_H__

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32

#include <mt/AbstractCPUAffinityThreadInitializer.h>

Expand Down
2 changes: 1 addition & 1 deletion modules/c++/net/include/net/Daemon.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __NET_DAEMON_H__
#define __NET_DAEMON_H__

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32
# include "net/DaemonWin32.h"
namespace net
{
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/net/include/net/DaemonUnix.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __NET_DAEMON_UNIX_H__
#define __NET_DAEMON_UNIX_H__

#if !(defined(WIN32) || defined(_WIN32))
#ifndef _WIN32

#include "net/DaemonInterface.h"
#include <import/sys.h>
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/net/include/net/DaemonWin32.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __NET_DAEMON_WIN32_H__
#define __NET_DAEMON_WIN32_H__

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32

#include "net/DaemonInterface.h"
#include <import/except.h>
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/net/include/net/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Socket
// capture the error
sys::SocketErr err;

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32

/* Wrapper for setsockopt dealing with Windows specific issues :-
*
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/net/include/net/SocketAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "net/Sockets.h"

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32
# include <winsock2.h>
#else
# include <arpa/inet.h>
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/net/include/net/Sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


# include "sys/Conf.h"
# if defined(WIN32) || defined(_WIN32)
# ifdef _WIN32
# include "net/SocketsWin32.h"
# else
# include "net/SocketsUnix.h"
Expand Down
21 changes: 0 additions & 21 deletions modules/c++/net/include/net/SocketsUnix.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,10 @@ typedef struct hostent HostEnt_T;
typedef int Socket_T;
typedef struct sockaddr SockAddr_T;
typedef struct sockaddr_in SockAddrIn_T;
#if defined(__sun) || defined(__sun__) || defined(__sparc) || defined(__sparc__)
typedef SockAddr_T ConnParam2_T;
#else
typedef const SockAddr_T ConnParam2_T;
#endif

#if defined(__linux) || defined(__linux__)
typedef socklen_t SockLen_T;
#elif defined(__sun) || defined(__sun__) || defined(__sparc) || defined(__sparc__)
# if defined(__SunOS_5_6)
typedef int SockLen_T;
# elif defined(__sparcv9) && defined(__arch64__) && defined(__GNUC__)
typedef socklen_t SockLen_T;
# else
typedef size_t SockLen_T;
# endif
#elif defined(_AIX) || defined(__aix) || defined(__aix__)
# if defined(__GNUC__)
typedef socklen_t SockLen_T;
# else
// 64-bit AIX uses socklen_t but I don't know the flags
// typedef unsigned int SockLen_T;
// The new(er) AIX machine uses socklen_t...
typedef socklen_t SockLen_T;
# endif
#elif defined(__APPLE_CC__)
typedef socklen_t SockLen_T;
#else
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/net/source/DaemonUnix.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !(defined(WIN32) || defined(_WIN32))
#ifndef _WIN32
#include "net/DaemonUnix.h"

#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/net/source/SocketAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void SocketAddress::setHost(const std::string& host)
}
else
{
#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32
struct sockaddr saddr;
int slen = sizeof(saddr);
struct sockaddr_in *paddr = (struct sockaddr_in *)&saddr;
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/plugin/include/plugin/PluginDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/* #define PLUGIN_DESTRUCTOR_NAME "DestroyPlugin" */
#define GET_PLUGIN_IDENT "GetPluginIdentity"

#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32
# define PLUGIN_DSO_EXTENSION ".dll"
#else
# define PLUGIN_DSO_EXTENSION ".so"
Expand All @@ -48,7 +48,7 @@
#define PLUGIN_API_MINOR_VERSION 0


#if defined(WIN32) || defined(_WIN32)
#ifdef _WIN32
# if defined(PLUGIN_MODULE_EXPORTS)
# define PLUGIN_HOOK extern "C" __declspec(dllexport)
# else
Expand Down
10 changes: 3 additions & 7 deletions modules/c++/str/include/str/EncodedStringView.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CODA_OSS_API EncodedStringView final
explicit EncodedStringView(coda_oss::span<const coda_oss::u8string::value_type>);
explicit EncodedStringView(coda_oss::span<const str::W1252string::value_type>);

#if _WIN32
#ifdef _WIN32
static constexpr bool mNativeIsUtf8 = false; // Windows-1252
#else
static constexpr bool mNativeIsUtf8 = true; // !_WIN32, assume Linux
Expand Down Expand Up @@ -109,12 +109,8 @@ class CODA_OSS_API EncodedStringView final
// is WCHAR (char* is converted to UTF-16).
std::wstring wstring() const; // UTF-16 on Windows, UTF-32 on Linux

// With some older C++ compilers, uint16_t may be used instead of char16_t :-(
// Using this routine can avoid an extra copy.
str::ui16string ui16string_() const; // use sparingly!

// These are for "advanced" use, most "normal" code should use the routines above.
std::string::const_pointer c_str() const
std::string::const_pointer c_str() const noexcept
{
return mString.data();
}
Expand All @@ -126,7 +122,7 @@ class CODA_OSS_API EncodedStringView final
{
return mIsUtf8 ? nullptr : cast<str::W1252string::const_pointer>(c_str());
}
size_t size() const
size_t size() const noexcept
{
return mString.size();
}
Expand Down
5 changes: 0 additions & 5 deletions modules/c++/str/include/str/Encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ inline typename TBasicStringT::const_pointer c_str(const std::basic_string<TChar
enum class Windows1252_T : unsigned char { }; // https://en.cppreference.com/w/cpp/language/types
using W1252string = std::basic_string<Windows1252_T>; // https://en.cppreference.com/w/cpp/string

// With some older C++ compilers, uint16_t may be used instead of char16_t :-(
using ui16string = std::basic_string<uint16_t>; // ui = UInt16_t

//////////////////////////////////////////////////////////////////////////////////////////

// We'll get strange errors, possibibly at link-time, if wchar_t is not a wchar_t type.
Expand All @@ -88,9 +85,7 @@ inline coda_oss::u8string to_u8string(coda_oss::u8string::const_pointer s, size_
CODA_OSS_API coda_oss::u8string to_u8string(std::u16string::const_pointer, size_t);

CODA_OSS_API std::u16string to_u16string(coda_oss::u8string::const_pointer, size_t);
str::ui16string to_ui16string(coda_oss::u8string::const_pointer, size_t);
std::u16string to_u16string(str::W1252string::const_pointer, size_t);
str::ui16string to_ui16string(str::W1252string::const_pointer, size_t);

// UTF-32 is convenient because each code-point is a single 32-bit integer.
// It's typically std::wstring::value_type on Linux, but NOT Windows.
Expand Down
Loading

0 comments on commit 146e0be

Please sign in to comment.