On 2/13/23 14:27, Warner Losh wrote:
+#ifdef TARGET_ABI32
+/*
+ * Limit the amount of available memory to be most of the 32-bit address
+ * space. 0x100c000 was arrived at through trial and error as a good
+ * definition of 'most'.
+ */
+static const abi_ulong target_max_mem = UINT32_MAX - 0x100c000 + 1;
+
+static abi_ulong G_GNUC_UNUSED cap_memory(uint64_t mem)
+{
+ if (((unsigned long)target_max_mem) < mem) {
+ mem = target_max_mem;
+ }
+
+ return mem;
+}
+#endif
Identity function for ABI64?
+static unsigned long host_page_size;
+
+static abi_ulong G_GNUC_UNUSED scale_to_target_pages(uint64_t pages)
+{
+ if (host_page_size == 0) {
+ host_page_size = getpagesize();
+ }
qemu_real_host_page_size()
+
+ pages = muldiv64(pages, host_page_size, TARGET_PAGE_SIZE);
+#ifdef TARGET_ABI32
+ abi_ulong maxpages = target_max_mem / (abi_ulong)TARGET_PAGE_SIZE;
+
+ if (((unsigned long)maxpages) < pages) {
+ pages = maxpages;
+ }
+#endif
No need for either cast. Just use MIN().
+#ifdef TARGET_ABI32
+static abi_long G_GNUC_UNUSED h2t_long_sat(long l)
h2g.
+{
+ if (l > INT32_MAX) {
+ l = INT32_MAX;
+ } else if (l < INT32_MIN) {
+ l = INT32_MIN;
+ }
+ return l;
+}
+
+static abi_ulong G_GNUC_UNUSED h2t_ulong_sat(u_long ul)
+{
+ if (ul > UINT32_MAX) {
+ ul = UINT32_MAX;
+ }
+ return ul;
+}
+#endif
Anyway, identity functions for ABI64?
r~