Skip to content

Commit

Permalink
Remove fixed-size ints from Yuni (#1622)
Browse files Browse the repository at this point in the history
* Remove fixed-size ints from Yuni, use cstdint instead

* uint64

* Remove forgotten uint8

* Remove forgotten uint8 (bis)

* Restore magic macro from Yuni

The code compiles fine without it, but CString::to(out& T) doesn't
work well at all for uint (possibly others).
  • Loading branch information
flomnes authored Sep 14, 2023
1 parent 81fc9c4 commit 4b7a9a8
Show file tree
Hide file tree
Showing 243 changed files with 979 additions and 1,726 deletions.
10 changes: 5 additions & 5 deletions src/analyzer/atsp/atsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ class ATSP final
double pLowerBound;
bool pUseUpperBound;
bool pUseLowerBound;
yuint64 pRoundingCount;
yuint64 pRounding80percentCount;
yuint64 pRoundingCountTotal;
uint64_t pRoundingCount;
uint64_t pRounding80percentCount;
uint64_t pRoundingCountTotal;
Yuni::ShortString16 tsName;

uint pEnabledAreaCount;
Expand Down Expand Up @@ -286,8 +286,8 @@ class ATSP final
durjour = 24
};

yuint64 pLimitMemory;
yuint64 pCacheMemoryUsed;
uint64_t pLimitMemory;
uint64_t pCacheMemoryUsed;
uint pCacheLastValidIndex;
Matrix<>* pCacheMatrix;

Expand Down
2 changes: 2 additions & 0 deletions src/cmake/common-settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(CMAKE_CXX_STANDARD 17)

set(COMMON_GCC_FLAGS "-Wall -W -Wextra -Wfatal-errors")
if (NOT WIN32)
# These flags are incompatible with non-x86 architectures (e.g ARM)
# TODO remove
set(COMMON_GCC_FLAGS "${COMMON_GCC_FLAGS} -pipe -msse -msse2 -Wunused-but-set-variable -Wunused-but-set-parameter")
set(COMMON_GCC_FLAGS "${COMMON_GCC_FLAGS} -Werror=return-type")
endif()
Expand Down
5 changes: 0 additions & 5 deletions src/ext/yuni/src/yuni/cmake/core/check-includes.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@


# stdint.h
check_include_file(stdint.h YUNI_HAS_STDINT_H)

# stdio.h
check_include_file(stdio.h YUNI_HAS_STDIO_H)

Expand Down
2 changes: 0 additions & 2 deletions src/ext/yuni/src/yuni/cmake/core/core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ if (MSVC)
set(yuni_additional_os_specific
core/system/gettimeofday.cpp
core/system/username.cpp
core/system/windows/msinttypes/inttypes.h
core/system/windows/msinttypes/stdint.h
core/system/windows.hdr.h)
else()
set(yuni_additional_os_specific "")
Expand Down
3 changes: 0 additions & 3 deletions src/ext/yuni/src/yuni/cmake/net.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ set(SRC_PRIVATE_NET_MESSAGE_TRANSPORT_REST
)
source_group("Private\\Net\\Messaging\\Transport\\REST" FILES ${SRC_PRIVATE_NET_MESSAGE_TRANSPORT_REST})

if (YUNI_HAS_STDINT_H)
set_source_files_properties(private/net/messaging/transport/rest/mongoose.c PROPERTIES COMPILE_FLAGS -DHAVE_STDINT)
endif()
if (YUNI_HAS_GCC_NOWARNING)
set_source_files_properties(private/net/messaging/transport/rest/mongoose.c PROPERTIES COMPILE_FLAGS -w)
endif()
Expand Down
4 changes: 0 additions & 4 deletions src/ext/yuni/src/yuni/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

/* This file is generated by CMake */


/* stdint.h */
#cmakedefine YUNI_HAS_STDINT_H

/* stdio.h */
#cmakedefine YUNI_HAS_STDIO_H

Expand Down
8 changes: 4 additions & 4 deletions src/ext/yuni/src/yuni/core/atomic/int.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ class YUNI_DECL Int final YUNI_ATOMIC_INHERITS
/*!
** \brief Constructor with an initial value (int16)
*/
Int(sint16 v);
Int(int16_t v);
/*!
** \brief Constructor with an initial value (int32)
** \brief Constructor with an initial value (int32_t)
*/
Int(sint32 v);
Int(int32_t v);
/*!
** \brief Constructor with an initial value (int64)
*/
Int(sint64 v);
Int(int64_t v);

/*!
** \brief Copy constructor
Expand Down
6 changes: 3 additions & 3 deletions src/ext/yuni/src/yuni/core/atomic/int.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ inline Int<Size, TP>::Int() :
}

template<int Size, template<class> class TP>
inline Int<Size, TP>::Int(sint16 v) :
inline Int<Size, TP>::Int(int16_t v) :
#if YUNI_ATOMIC_MUST_USE_MUTEX != 1
pValue(static_cast<ScalarType>(v))
#else
Expand All @@ -36,7 +36,7 @@ inline Int<Size, TP>::Int(sint16 v) :
}

template<int Size, template<class> class TP>
inline Int<Size, TP>::Int(sint32 v) :
inline Int<Size, TP>::Int(int32_t v) :
#if YUNI_ATOMIC_MUST_USE_MUTEX != 1
pValue(static_cast<ScalarType>(v))
#else
Expand All @@ -46,7 +46,7 @@ inline Int<Size, TP>::Int(sint32 v) :
}

template<int Size, template<class> class TP>
inline Int<Size, TP>::Int(sint64 v) :
inline Int<Size, TP>::Int(int64_t v) :
#if YUNI_ATOMIC_MUST_USE_MUTEX != 1
pValue(static_cast<ScalarType>(v))
#else
Expand Down
14 changes: 7 additions & 7 deletions src/ext/yuni/src/yuni/core/atomic/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ struct TypeFromSize<1> final
{
size = 32
};
typedef sint32 Type;
typedef int32_t Type;
};

// Int16
Expand All @@ -104,12 +104,12 @@ struct TypeFromSize<16> final
{
// On OS X, there are only routines for int32_t and int64_t
// With MinGW, it simply does not exist
// It seems that the best solution is to use int32 everywhere
// It seems that the best solution is to use int32_t everywhere
enum
{
size = 32
};
typedef sint32 Type;
typedef int32_t Type;
};

// Int32
Expand All @@ -120,7 +120,7 @@ struct TypeFromSize<32> final
{
size = 32
};
typedef sint32 Type;
typedef int32_t Type;
};

// Int64
Expand All @@ -131,7 +131,7 @@ struct TypeFromSize<64> final
{
size = 64
};
typedef sint64 Type;
typedef int64_t Type;
};

// Thread-safe operations
Expand Down Expand Up @@ -224,7 +224,7 @@ struct Operator<32, TP> final
}

template<class T>
static void Set(T& t, sint32 newvalue)
static void Set(T& t, int32_t newvalue)
{
#ifdef YUNI_OS_WINDOWS
::InterlockedExchange((LONG*)&t.pValue, newvalue);
Expand Down Expand Up @@ -341,7 +341,7 @@ struct Operator<64, TP> final
}

template<class T>
static void Set(T& t, sint64 newvalue)
static void Set(T& t, int64_t newvalue)
{
#ifdef YUNI_OS_WINDOWS
#ifdef YUNI_OS_MINGW32
Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/core/bit/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Bit
*/
template<class T>
uint Count(T data);
yuint32 Count(yuint32 data);
uint32_t Count(uint32_t data);

/*!
** \brief Get if the bit at a given index
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/core/bit/bit.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ namespace Yuni
{
namespace Bit
{
inline yuint32 Count(yuint32 i)
inline uint32_t Count(uint32_t i)
{
#ifdef YUNI_HAS_GCC_BUILTIN_POPCOUNT
return static_cast<yuint32>(__builtin_popcount(i));
return static_cast<uint32_t>(__builtin_popcount(i));
#else
// variable-precision SWAR algorithm
i = i - ((i >> 1) & 0x55555555);
Expand Down
32 changes: 16 additions & 16 deletions src/ext/yuni/src/yuni/core/color/rgb.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -805,28 +805,28 @@ inline Yuni::Color::RGB<typename Yuni::Color::template RGB<U>::template Calculat
return r; \
}

YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(Yuni::sint8)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(Yuni::sint16)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(Yuni::sint32)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(Yuni::sint64)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(Yuni::uint8)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(Yuni::uint16)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(Yuni::uint32)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(Yuni::uint64)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(int8_t)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(int16_t)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(int32_t)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(int64_t)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(uint8_t)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(uint16_t)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(uint32_t)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(uint64_t)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(float)
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(double)
#ifdef YUNI_HAS_LONG_DOUBLE
YUNI_COLOR_RGB_OPERATOR_TYPE_RGB(long double)
#endif

YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(Yuni::sint8)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(Yuni::sint16)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(Yuni::sint32)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(Yuni::sint64)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(Yuni::uint8)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(Yuni::uint16)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(Yuni::uint32)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(Yuni::uint64)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(int8_t)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(int16_t)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(int32_t)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(int64_t)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(uint8_t)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(uint16_t)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(uint32_t)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(uint64_t)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(float)
YUNI_COLOR_RGB_OPERATOR_RGB_TYPE(double)
#ifdef YUNI_HAS_LONG_DOUBLE
Expand Down
32 changes: 16 additions & 16 deletions src/ext/yuni/src/yuni/core/color/rgba.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -869,28 +869,28 @@ inline Yuni::Color::RGBA<typename Yuni::Color::template RGBA<U>::template Calcul
return r; \
}

YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(Yuni::sint8)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(Yuni::sint16)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(Yuni::sint32)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(Yuni::sint64)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(Yuni::uint8)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(Yuni::uint16)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(Yuni::uint32)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(Yuni::uint64)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(int8_t)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(int16_t)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(int32_t)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(int64_t)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(uint8_t)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(uint16_t)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(uint32_t)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(uint64_t)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(float)
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(double)
#ifdef YUNI_HAS_LONG_DOUBLE
YUNI_COLOR_RGBA_OPERATOR_TYPE_RGBA(long double)
#endif

YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(Yuni::sint8)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(Yuni::sint16)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(Yuni::sint32)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(Yuni::sint64)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(Yuni::uint8)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(Yuni::uint16)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(Yuni::uint32)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(Yuni::uint64)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(int8_t)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(int16_t)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(int32_t)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(int64_t)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(uint8_t)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(uint16_t)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(uint32_t)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(uint64_t)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(float)
YUNI_COLOR_RGBA_OPERATOR_RGBA_TYPE(double)
#ifdef YUNI_HAS_LONG_DOUBLE
Expand Down
20 changes: 10 additions & 10 deletions src/ext/yuni/src/yuni/core/getopt/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,30 @@ class Flag<bool>
};

template<>
class Flag<sint16>
class Flag<int16_t>
{
public:
static void Enable(sint16& out)
static void Enable(int16_t& out)
{
out = 1;
}
};

template<>
class Flag<sint32>
class Flag<int32_t>
{
public:
static void Enable(sint32& out)
static void Enable(int32_t& out)
{
out = 1;
}
};

template<>
class Flag<sint64>
class Flag<int64_t>
{
public:
static void Enable(sint64& out)
static void Enable(int64_t& out)
{
out = 1;
}
Expand All @@ -162,20 +162,20 @@ class Flag<uint16>
};

template<>
class Flag<uint32>
class Flag<uint32_t>
{
public:
static void Enable(uint32& out)
static void Enable(uint32_t& out)
{
out = 1u;
}
};

template<>
class Flag<uint64>
class Flag<uint64_t>
{
public:
static void Enable(uint64& out)
static void Enable(uint64_t& out)
{
out = 1u;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/core/hash/checksum/checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class YUNI_DECL IChecksum
*length
** \return The hash value
*/
virtual const String& fromRawData(const void* rawdata, uint64 size = AutoDetectNullChar) = 0;
virtual const String& fromRawData(const void* rawdata, uint64_t size = AutoDetectNullChar) = 0;

/*!
** \brief Compute the hash of a given file
Expand Down
6 changes: 3 additions & 3 deletions src/ext/yuni/src/yuni/core/hash/checksum/md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace Checksum
namespace // anonymous
{
typedef unsigned char MD5TypeByte; // 8-bit byte
typedef uint32 MD5TypeUInt32; // 32-bit word
typedef uint32_t MD5TypeUInt32; // 32-bit word

/*!
* \brief Define the state of the MD5 Algorithm
Expand Down Expand Up @@ -376,7 +376,7 @@ void md5DigestToString(String& s, MD5TypeByte digest[16])

} // anonymous namespace

const String& MD5::fromRawData(const void* rawdata, uint64 size)
const String& MD5::fromRawData(const void* rawdata, uint64_t size)
{
pValue.clear();
if (!rawdata)
Expand Down Expand Up @@ -408,7 +408,7 @@ const String& MD5::fromFile(const String& filename)
md5ImplInit(&state);

char buffer[1024];
uint64 len = 0u;
uint64_t len = 0u;

while (0 != (len = stream.read((char*)buffer, 1024u)))
md5ImplAppend(
Expand Down
Loading

0 comments on commit 4b7a9a8

Please sign in to comment.