(svn r12599) -Codechange: force AllocateSafeRaw() to be linked to simplify compiler's decisions about inlining
authorsmatz
Sun, 06 Apr 2008 23:49:45 +0000
changeset 9343 c30fd350dd8c
parent 9342 ca61cbfca47a
child 9344 1be7ac6bd504
(svn r12599) -Codechange: force AllocateSafeRaw() to be linked to simplify compiler's decisions about inlining
projects/openttd_vs80.vcproj
projects/openttd_vs90.vcproj
source.list
src/cargopacket.cpp
src/depot.cpp
src/engine.cpp
src/group_cmd.cpp
src/industry_cmd.cpp
src/oldpool.h
src/oldpool_func.h
src/order_cmd.cpp
src/signs.cpp
src/station_cmd.cpp
src/town_cmd.cpp
src/vehicle.cpp
src/waypoint.cpp
--- a/projects/openttd_vs80.vcproj	Sun Apr 06 22:32:20 2008 +0000
+++ b/projects/openttd_vs80.vcproj	Sun Apr 06 23:49:45 2008 +0000
@@ -1188,6 +1188,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\oldpool_func.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\openttd.h"
 				>
 			</File>
--- a/projects/openttd_vs90.vcproj	Sun Apr 06 22:32:20 2008 +0000
+++ b/projects/openttd_vs90.vcproj	Sun Apr 06 23:49:45 2008 +0000
@@ -1185,6 +1185,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\oldpool_func.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\openttd.h"
 				>
 			</File>
--- a/source.list	Sun Apr 06 22:32:20 2008 +0000
+++ b/source.list	Sun Apr 06 23:49:45 2008 +0000
@@ -205,6 +205,7 @@
 sound/null_s.h
 video/null_v.h
 oldpool.h
+oldpool_func.h
 openttd.h
 order_base.h
 order_func.h
--- a/src/cargopacket.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/cargopacket.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -7,6 +7,7 @@
 #include "station_base.h"
 #include "cargopacket.h"
 #include "saveload.h"
+#include "oldpool_func.h"
 
 /* Initialize the cargopacket-pool */
 DEFINE_OLD_POOL_GENERIC(CargoPacket, CargoPacket)
--- a/src/depot.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/depot.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -9,6 +9,7 @@
 #include "saveload.h"
 #include "order_func.h"
 #include "window_func.h"
+#include "oldpool_func.h"
 
 #include "table/strings.h"
 
--- a/src/engine.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/engine.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -25,6 +25,7 @@
 #include "autoreplace_gui.h"
 #include "string_func.h"
 #include "settings_type.h"
+#include "oldpool_func.h"
 
 #include "table/strings.h"
 #include "table/engines.h"
--- a/src/group_cmd.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/group_cmd.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -22,6 +22,7 @@
 #include "string_func.h"
 #include "player_func.h"
 #include "order_func.h"
+#include "oldpool_func.h"
 
 #include "table/strings.h"
 
--- a/src/industry_cmd.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/industry_cmd.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -37,6 +37,7 @@
 #include "vehicle_func.h"
 #include "sound_func.h"
 #include "station_base.h"
+#include "oldpool_func.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
--- a/src/oldpool.h	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/oldpool.h	Sun Apr 06 23:49:45 2008 +0000
@@ -260,32 +260,7 @@
 	}
 
 private:
-	/**
-	 * Allocate a pool item; possibly allocate a new block in the pool.
-	 * @param first the first pool item to start searching
-	 * @pre first <= Tpool->GetSize()
-	 * @return the allocated pool item (or NULL when the pool is full).
-	 */
-	static inline T *AllocateSafeRaw(uint &first)
-	{
-		uint last_minus_one = Tpool->GetSize() - 1;
-
-		for (T *t = Tpool->Get(first); t != NULL; t = (t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) {
-			if (!t->IsValid()) {
-				first = t->index;
-				Tid index = t->index;
-
-				memset(t, 0, Tpool->item_size);
-				t->index = index;
-				return t;
-			}
-		}
-
-		/* Check if we can add a block to the pool */
-		if (Tpool->AddBlockToPool()) return AllocateRaw(first);
-
-		return NULL;
-	}
+	static T *AllocateSafeRaw(uint &first);
 
 protected:
 	/**
@@ -346,7 +321,8 @@
 #define DEFINE_OLD_POOL_GENERIC(name, type) \
 	OldMemoryPool<type> _##name##_pool( \
 		#name, name##_POOL_MAX_BLOCKS, name##_POOL_BLOCK_SIZE_BITS, sizeof(type), \
-		PoolNewBlock<type, &_##name##_pool>, PoolCleanBlock<type, &_##name##_pool>);
+		PoolNewBlock<type, &_##name##_pool>, PoolCleanBlock<type, &_##name##_pool>); \
+		template type *PoolItem<type, type##ID, &_##name##_pool>::AllocateSafeRaw(uint &first);
 
 
 #define STATIC_OLD_POOL(name, type, block_size_bits, max_blocks, new_block_proc, clean_block_proc) \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/oldpool_func.h	Sun Apr 06 23:49:45 2008 +0000
@@ -0,0 +1,34 @@
+/* $Id$ */
+
+#ifndef OLDPOOL_FUNC_H
+
+#include "oldpool.h"
+
+/**
+ * Allocate a pool item; possibly allocate a new block in the pool.
+ * @param first the first pool item to start searching
+ * @pre first <= Tpool->GetSize()
+ * @return the allocated pool item (or NULL when the pool is full).
+ */
+template<typename T, typename Tid, OldMemoryPool<T> *Tpool> T *PoolItem<T, Tid, Tpool>::AllocateSafeRaw(uint &first)
+{
+	uint last_minus_one = Tpool->GetSize() - 1;
+
+	for (T *t = Tpool->Get(first); t != NULL; t = (t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) {
+		if (!t->IsValid()) {
+			first = t->index;
+			Tid index = t->index;
+
+			memset(t, 0, Tpool->item_size);
+			t->index = index;
+			return t;
+		}
+	}
+
+	/* Check if we can add a block to the pool */
+	if (Tpool->AddBlockToPool()) return AllocateRaw(first);
+
+	return NULL;
+}
+
+#endif /* OLDPOOL_FUNC_H */
--- a/src/order_cmd.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/order_cmd.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -25,6 +25,7 @@
 #include "newgrf_cargo.h"
 #include "timetable.h"
 #include "vehicle_func.h"
+#include "oldpool_func.h"
 
 #include "table/strings.h"
 
--- a/src/signs.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/signs.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -19,6 +19,7 @@
 #include "window_func.h"
 #include "map_func.h"
 #include "string_func.h"
+#include "oldpool_func.h"
 
 #include "table/strings.h"
 
--- a/src/station_cmd.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/station_cmd.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -42,6 +42,7 @@
 #include "vehicle_func.h"
 #include "string_func.h"
 #include "signal_func.h"
+#include "oldpool_func.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
--- a/src/town_cmd.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/town_cmd.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -40,6 +40,7 @@
 #include "window_func.h"
 #include "string_func.h"
 #include "newgrf_cargo.h"
+#include "oldpool_func.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
--- a/src/vehicle.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/vehicle.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -46,6 +46,7 @@
 #include "autoreplace_gui.h"
 #include "string_func.h"
 #include "settings_type.h"
+#include "oldpool_func.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
--- a/src/waypoint.cpp	Sun Apr 06 22:32:20 2008 +0000
+++ b/src/waypoint.cpp	Sun Apr 06 23:49:45 2008 +0000
@@ -32,6 +32,7 @@
 #include "player_func.h"
 #include "settings_type.h"
 #include "newgrf_station.h"
+#include "oldpool_func.h"
 
 #include "table/strings.h"