Changeset - r27176:1ede36282270
[Not reviewed]
master
0 3 0
PeterN - 14 months ago 2023-04-27 08:04:18
peter1138@openttd.org
Change: Use cstdint instead of rolling our own types. (#10651)
3 files changed with 15 insertions and 72 deletions:
0 comments (0 inline, 0 general)
src/3rdparty/squirrel/include/squirrel.h
Show inline comments
 
@@ -29,25 +29,25 @@
 
 */
 
#ifndef _SQUIRREL_H_
 
#define _SQUIRREL_H_
 

	
 
#include "../../../string_type.h"
 

	
 
typedef __int64 SQInteger;
 
typedef unsigned __int64 SQUnsignedInteger;
 
typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
 
typedef int64_t SQInteger;
 
typedef uint64_t SQUnsignedInteger;
 
typedef uint64_t SQHash; /*should be the same size of a pointer*/
 
typedef int SQInt32;
 

	
 

	
 
#ifdef SQUSEDOUBLE
 
typedef double SQFloat;
 
#else
 
typedef float SQFloat;
 
#endif
 

	
 
typedef __int64 SQRawObjectVal; //must be 64bits
 
typedef int64_t SQRawObjectVal; //must be 64bits
 
#define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; }
 

	
 
typedef void* SQUserPointer;
 
typedef SQUnsignedInteger SQBool;
 
typedef SQInteger SQRESULT;
 

	
src/linkgraph/linkgraph.cpp
Show inline comments
 
@@ -71,13 +71,13 @@ void LinkGraph::Compress()
 
		for (BaseEdge &edge : this->nodes[node1].edges) {
 
			if (edge.capacity > 0) {
 
				uint new_capacity = std::max(1U, edge.capacity / 2);
 
				if (edge.capacity < (1 << 16)) {
 
					edge.travel_time_sum = edge.travel_time_sum * new_capacity / edge.capacity;
 
				} else if (edge.travel_time_sum != 0) {
 
					edge.travel_time_sum = std::max(1ULL, edge.travel_time_sum / 2);
 
					edge.travel_time_sum = std::max<uint64>(1, edge.travel_time_sum / 2);
 
				}
 
				edge.capacity = new_capacity;
 
				edge.usage /= 2;
 
			}
 
		}
 
	}
src/stdafx.h
Show inline comments
 
@@ -32,13 +32,12 @@
 

	
 
#if defined(__HAIKU__)
 
#	include <SupportDefs.h>
 
#	include <unistd.h>
 
#	define _DEFAULT_SOURCE
 
#	define _GNU_SOURCE
 
#	define TROUBLED_INTS
 
#endif
 

	
 
#if defined(__HAIKU__) || defined(__CYGWIN__)
 
#	include <strings.h> /* strncasecmp */
 
#endif
 

	
 
@@ -54,64 +53,23 @@
 
#	else
 
#		define __STDC_LIMIT_MACROS
 
#		include <stdint.h>
 
#	endif
 
#endif
 

	
 
/* The conditions for these constants to be available are way too messy; so check them one by one */
 
#if !defined(UINT64_MAX)
 
#	define UINT64_MAX (18446744073709551615ULL)
 
#endif
 
#if !defined(INT64_MAX)
 
#	define INT64_MAX  (9223372036854775807LL)
 
#endif
 
#if !defined(INT64_MIN)
 
#	define INT64_MIN  (-INT64_MAX - 1)
 
#endif
 
#if !defined(UINT32_MAX)
 
#	define UINT32_MAX (4294967295U)
 
#endif
 
#if !defined(INT32_MAX)
 
#	define INT32_MAX  (2147483647)
 
#endif
 
#if !defined(INT32_MIN)
 
#	define INT32_MIN  (-INT32_MAX - 1)
 
#endif
 
#if !defined(UINT16_MAX)
 
#	define UINT16_MAX (65535U)
 
#endif
 
#if !defined(INT16_MAX)
 
#	define INT16_MAX  (32767)
 
#endif
 
#if !defined(INT16_MIN)
 
#	define INT16_MIN  (-INT16_MAX - 1)
 
#endif
 
#if !defined(UINT8_MAX)
 
#	define UINT8_MAX  (255)
 
#endif
 
#if !defined(INT8_MAX)
 
#	define INT8_MAX   (127)
 
#endif
 
#if !defined(INT8_MIN)
 
#	define INT8_MIN   (-INT8_MAX - 1)
 
#endif
 

	
 
#include <algorithm>
 
#include <cstdio>
 
#include <cstdint>
 
#include <cstddef>
 
#include <cstring>
 
#include <cstdlib>
 
#include <climits>
 
#include <cassert>
 
#include <memory>
 
#include <string>
 

	
 
#ifndef SIZE_MAX
 
#	define SIZE_MAX ((size_t)-1)
 
#endif
 

	
 
#if defined(UNIX) || defined(__MINGW32__)
 
#	include <sys/types.h>
 
#endif
 

	
 
#if defined(__OS2__)
 
#	include <types.h>
 
@@ -340,42 +298,27 @@
 
 * so __forceinline makes no difference compared to inline. Other unknown
 
 * compilers can also just fallback to a normal inline.
 
 */
 
#define debug_inline inline
 
#endif
 

	
 
typedef unsigned char byte;
 
typedef uint8_t byte;
 

	
 
/* This is already defined in unix, but not in QNX Neutrino (6.x) or Cygwin. */
 
#if (!defined(UNIX) && !defined(__HAIKU__)) || defined(__QNXNTO__) || defined(__CYGWIN__)
 
	typedef unsigned int uint;
 
#endif
 

	
 
#if defined(TROUBLED_INTS)
 
	/* Haiku's types for uint32/int32/uint64/int64 are different than what
 
	 * they are on other platforms; not in length, but how to print them.
 
	 * So make them more like the other platforms, to make printf() etc a
 
	 * little bit easier. */
 
#	define uint32 uint32_ugly_hack
 
#	define int32 int32_ugly_hack
 
#	define uint64 uint64_ugly_hack
 
#	define int64 int64_ugly_hack
 
	typedef unsigned int uint32_ugly_hack;
 
	typedef signed int int32_ugly_hack;
 
	typedef unsigned __int64 uint64_ugly_hack;
 
	typedef signed __int64 int64_ugly_hack;
 
#else
 
	typedef unsigned char    uint8;
 
	typedef   signed char     int8;
 
	typedef unsigned short   uint16;
 
	typedef   signed short    int16;
 
	typedef unsigned int     uint32;
 
	typedef   signed int      int32;
 
	typedef unsigned __int64 uint64;
 
	typedef   signed __int64  int64;
 
#endif /* !TROUBLED_INTS */
 
typedef uint8_t  uint8;
 
typedef  int8_t   int8;
 
typedef uint16_t uint16;
 
typedef  int16_t  int16;
 
typedef uint32_t uint32;
 
typedef  int32_t  int32;
 
typedef uint64_t uint64;
 
typedef  int64_t  int64;
 

	
 
#if !defined(WITH_PERSONAL_DIR)
 
#	define PERSONAL_DIR ""
 
#endif
 

	
 
/* Define the the platforms that use XDG */
0 comments (0 inline, 0 general)