From nobody Wed Jan 03 13:43:08 2024 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T4rWx0RT6z55tqn; Wed, 3 Jan 2024 13:43:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T4rWw67lqz4KkG; Wed, 3 Jan 2024 13:43:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704289388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2DIncz4b1BrpXePXWPjVYeWDWRGLPxPpXdEIdvBzXeg=; b=d2sZjv9VUZ0Xvw4X52E4vzIXYbRV+gcL1qdUMVFMIaY2iwubIRDoB8Nj6AqPEQ27yMZPsg OVD6EYFuKVef58zfbU9Exk3Ac+ODGi2wrvRMWXP5B0SQXRWDabE95VatDz8gfQVU6OQLHG dsjWpspHAmF0tW4GBE5JZcEKjrP5va7jI/8XbhC+PG50Y91ltCym4bkh59YDcng3toKoth 7O/a6jzXNMyPrLxevivBGhCnUAdtt/jfMEL5EQednJAA/iegptEtIp0qF/zvx++XohDKOG UzWdZknoWr/Ml7fpg+EAr5cXsPRcfnP/ml1aHMjK2BUvHODJuVs2dJV48cb4FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704289388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2DIncz4b1BrpXePXWPjVYeWDWRGLPxPpXdEIdvBzXeg=; b=G834TttM3UlyVG2tRYoGQAtdVPuTOhTJ30MrqHNTNO6wWfDzToWO0LtuG0UD3V++/kiQEI D9FEJL6OQb3v3RIcDVmQbqXwnH3Ipj9IrfAl1DMbbIij5+nnEbPJPa4HMH8mVP/zm7mdHt iAc8qWOKoj/eWrs/B/bASBALyqIN0fftn1OvJuDHr6oQP/icx3qEAGFyqpENNajQ8gO+5w NPR0C1XjeoWfjjG3OFI9/jVwwpu4B1EQrfEl5RBj+IGQYH2nflmT8KrXAGBgFqOO3Ajf0B sa9xyvRye6nYk7SKX705AWxGm/TF/kaMG9KgklJdF1Y4X3/nOSxlXiD5ww+KsQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704289388; a=rsa-sha256; cv=none; b=bxEetDwv0dZDGNVyL9g9bm32SA4BjbbOVRP9BMRLMcGXdunxIPanhqKvdPRzAD0/yRQ3Ct T2hEMKHNFUhS4e+qD3+zIQdzIpcmlpZoqQ5diByVzYgWPh+mve/Uyr7Sy82iszFnkibngS 9O44tZoT8S7hGUwL0dVQzuGw6Pf0zpN5xCXIRGXM8DDW0Q+dSGe7lT/8xtDDvQa7QApwV8 nQI6ouBTVdZG84M2bUk/tRabs/kBCgpMJLlq4OYFQsMQA5fjg3+eIO1dajilPGKqqlcNxy 5cKCq6on6vlWzRlPm2AlllACiTP+Vrl9iWbzwLduzcK8Vbnp3c4erlyxnInHIA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T4rWw5DgfznCX; Wed, 3 Jan 2024 13:43:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 403Dh84V029319; Wed, 3 Jan 2024 13:43:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 403Dh8Rh029315; Wed, 3 Jan 2024 13:43:08 GMT (envelope-from git) Date: Wed, 3 Jan 2024 13:43:08 GMT Message-Id: <202401031343.403Dh8Rh029315@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Jan Beich Subject: git: 345f32d6dea1 - main - games/openbor7144: add new port List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jbeich X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 345f32d6dea1477e59c50faffb1d8f4444bbb464 Auto-Submitted: auto-generated The branch main has been updated by jbeich: URL: https://cgit.FreeBSD.org/ports/commit/?id=345f32d6dea1477e59c50faffb1d8f4444bbb464 commit 345f32d6dea1477e59c50faffb1d8f4444bbb464 Author: Jan Beich AuthorDate: 2023-11-02 03:00:32 +0000 Commit: Jan Beich CommitDate: 2024-01-03 13:42:53 +0000 games/openbor7144: add new port An old version tested with ASan before global_beta merge. --- games/Makefile | 1 + games/openbor7144/Makefile | 11 ++ games/openbor7144/distinfo | 3 + games/openbor7144/files/patch-openbor.c | 65 ++++++++ games/openbor7144/files/patch-sdl_menu.c | 13 ++ games/openbor7144/files/patch-sdl_sdlport.c | 30 ++++ games/openbor7144/files/patch-source_ramlib_ram.c | 189 ++++++++++++++++++++++ games/openbor7144/files/patch-source_utils.c | 19 +++ 8 files changed, 331 insertions(+) diff --git a/games/Makefile b/games/Makefile index a31c1abe97f8..dc50fd87e107 100644 --- a/games/Makefile +++ b/games/Makefile @@ -703,6 +703,7 @@ SUBDIR += openbor3711 SUBDIR += openbor3979 SUBDIR += openbor4432 + SUBDIR += openbor7144 SUBDIR += openbubbles SUBDIR += openbve SUBDIR += opencity diff --git a/games/openbor7144/Makefile b/games/openbor7144/Makefile new file mode 100644 index 000000000000..2143d59faa9f --- /dev/null +++ b/games/openbor7144/Makefile @@ -0,0 +1,11 @@ +PORTVERSION= 7144 +PORTREVISION= 0 +PKGNAMESUFFIX= ${PORTVERSION} + +MASTERDIR= ${.CURDIR}/../openbor +PATCHDIR= ${.CURDIR}/files +DISTINFO_FILE= ${.CURDIR}/distinfo + +GH_TAGNAME= b8303cce + +.include "${MASTERDIR}/Makefile" diff --git a/games/openbor7144/distinfo b/games/openbor7144/distinfo new file mode 100644 index 000000000000..159ae24c4263 --- /dev/null +++ b/games/openbor7144/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1698894032 +SHA256 (DCurrent-openbor-7144-b8303cce_GH0.tar.gz) = 1fdd30b64c009fbe03809d04fa6276cf386bef59696fedb0e3a05b12374c3e8d +SIZE (DCurrent-openbor-7144-b8303cce_GH0.tar.gz) = 26901256 diff --git a/games/openbor7144/files/patch-openbor.c b/games/openbor7144/files/patch-openbor.c new file mode 100644 index 000000000000..cec69bb2ff6e --- /dev/null +++ b/games/openbor7144/files/patch-openbor.c @@ -0,0 +1,65 @@ +Fix potential crashes found by ASan/Clang/GCC +Fix an infinite loop in lcmScriptDeleteMain() + +--- openbor.c.orig 2018-07-06 15:13:16 UTC ++++ openbor.c +@@ -6259,17 +6259,17 @@ s_collision_attack *collision_alloc_attack_instance(s_ + // + // Allocate an empty collision attack list. + s_collision_attack **collision_alloc_attack_list() + { + s_collision_attack **result; + size_t alloc_size; + + // Get amount of memory we'll need. +- alloc_size = sizeof(*result); ++ alloc_size = max_collisons * sizeof(*result); + + // Allocate memory and get pointer. + result = malloc(alloc_size); + + // Make sure the list is blank. + memset(result, 0, alloc_size); + + // return result. +@@ -6308,17 +6308,17 @@ s_collision_body *collision_alloc_body_instance(s_coll + // + // Allocate an empty collision attack list. + s_collision_body **collision_alloc_body_list() + { + s_collision_body **result; + size_t alloc_size; + + // Get amount of memory we'll need. +- alloc_size = sizeof(*result); ++ alloc_size = max_collisons * sizeof(*result); + + // Allocate memory and get pointer. + result = malloc(alloc_size); + + // Make sure the list is blank. + memset(result, 0, alloc_size); + + // return result. +@@ -8743,7 +8743,8 @@ size_t lcmScriptCopyBuffer(ArgList *arglist, char *buf + + size_t lcmScriptDeleteMain(char **buf) + { +- size_t len = 0, i = 0; ++ size_t len = 0; ++ long i = 0; + ptrdiff_t pos = 0; + char *newbuf = NULL; + +@@ -15920,6 +15921,11 @@ void bar(int x, int y, int value, int maxvalue, s_bars + else + { + return; ++ } ++ ++ if (value < 0) ++ { ++ value = 0; + } + + if (value > maxvalue) diff --git a/games/openbor7144/files/patch-sdl_menu.c b/games/openbor7144/files/patch-sdl_menu.c new file mode 100644 index 000000000000..1fe1fd9529f3 --- /dev/null +++ b/games/openbor7144/files/patch-sdl_menu.c @@ -0,0 +1,13 @@ +Don't crash with empty Paks/ directory. + +--- sdl/menu.c.orig 2018-07-06 15:13:16 UTC ++++ sdl/menu.c +@@ -753,7 +753,7 @@ void Menu() + } + freeAllLogs(); + termMenu(); +- if(ctrl == 2) ++ if(dListTotal == 0 || ctrl == 2) + { + if (filelist) + { diff --git a/games/openbor7144/files/patch-sdl_sdlport.c b/games/openbor7144/files/patch-sdl_sdlport.c new file mode 100644 index 000000000000..3a6b42660515 --- /dev/null +++ b/games/openbor7144/files/patch-sdl_sdlport.c @@ -0,0 +1,30 @@ +Store settings under ~/.openbor instead of current directory + +--- sdl/sdlport.c.orig 2018-07-06 15:13:16 UTC ++++ sdl/sdlport.c +@@ -11,6 +11,8 @@ + #include "ram.h" + #include "video.h" + #include "menu.h" ++#include ++#include + #include + #include + +@@ -135,6 +137,16 @@ int main(int argc, char *argv[]) + } + dirExists(rootDir, 1); + chdir(rootDir); ++#else ++ if(!getenv("OPENBOR_USE_CURDIR")) ++ { ++ if (chdir(getenv("HOME")) != 0) ++ err(1, "cannot cd to $HOME"); ++ if (mkdir(".openbor", 0755) != 0 && errno != EEXIST) ++ err(1, "cannot mkdir $HOME/.openbor"); ++ if (chdir(".openbor") != 0) ++ err(1, "cannot cd to $HOME/.openbor"); ++ } + #endif + + dirExists(paksDir, 1); diff --git a/games/openbor7144/files/patch-source_ramlib_ram.c b/games/openbor7144/files/patch-source_ramlib_ram.c new file mode 100644 index 000000000000..f37ceae0bb48 --- /dev/null +++ b/games/openbor7144/files/patch-source_ramlib_ram.c @@ -0,0 +1,189 @@ +Implement Linux-like memory stats for BSDs + +--- source/ramlib/ram.c.orig 2018-07-06 15:13:16 UTC ++++ source/ramlib/ram.c +@@ -25,6 +25,21 @@ + #include + #include + #include ++#elif defined(__DragonFly__) || defined(__FreeBSD__) || \ ++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) ++#include ++#include ++#include ++# if defined(__DragonFly__) ++#include // struct kinfo_proc ++#include // struct vmstats ++# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ++#include // struct kinfo_proc ++# elif defined(__NetBSD__) ++#include // struct uvmexp_sysctl ++# elif defined(__OpenBSD__) ++#include // struct uvmexp ++# endif + #elif LINUX + #include + #include +@@ -48,7 +63,10 @@ + + static u64 systemRam = 0x00000000; + +-#if !(defined(WIN) || defined(LINUX) || defined(DARWIN)) ++#if !(defined(WIN) || defined(LINUX) || defined(DARWIN) || \ ++ defined(__DragonFly__) || defined(__FreeBSD__) || \ ++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || \ ++ defined(__OpenBSD__)) + static unsigned long elfOffset = 0x00000000; + static unsigned long stackSize = 0x00000000; + #endif +@@ -56,7 +74,10 @@ static unsigned long stackSize = 0x00000000; + ///////////////////////////////////////////////////////////////////////////// + // Symbols + +-#if !(defined(WIN) || defined(LINUX) || defined(DARWIN)) ++#if !(defined(WIN) || defined(LINUX) || defined(DARWIN) || \ ++ defined(__DragonFly__) || defined(__FreeBSD__) || \ ++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || \ ++ defined(__OpenBSD__)) + #if (__GNUC__ > 3) + extern unsigned long _end; + extern unsigned long _start; +@@ -93,6 +114,48 @@ u64 getFreeRam(int byte_size) + return 0; + } + return (u64)(((vms.inactive_count + vms.free_count) * size) / byte_size); ++#elif defined(__DragonFly__) ++ struct vmstats vms; ++ size_t sz = sizeof(vms); ++ if (sysctlbyname("vm.vmstats", &vms, &sz, NULL, 0)) ++ { ++ return 0; ++ } ++ return (u64)(vms.v_free_count + vms.v_inactive_count ++ + vms.v_cache_count) * getpagesize() / byte_size; ++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ++ u_int v_free_count = 0, v_inactive_count = 0, v_cache_count = 0; ++ size_t sz = sizeof(u_int); ++ sysctlbyname("vm.stats.vm.v_free_count", ++ &v_free_count, &sz, NULL, 0); ++ sysctlbyname("vm.stats.vm.v_inactive_count", ++ &v_inactive_count, &sz, NULL, 0); ++ sysctlbyname("vm.stats.vm.v_cache_count", ++ &v_cache_count, &sz, NULL, 0); ++ return (u64)(v_free_count + v_inactive_count ++ + v_cache_count) * getpagesize() / byte_size; ++#elif defined(__NetBSD__) || defined(__OpenBSD__) ++# if defined(__NetBSD__) ++#undef VM_UVMEXP ++#define VM_UVMEXP VM_UVMEXP2 ++#define uvmexp uvmexp_sysctl ++# else ++#define filepages vnodepages ++#define execpages vtextpages ++# endif ++ int mib[] = { ++ CTL_VM, ++ VM_UVMEXP, ++ }; ++ u_int miblen = sizeof(mib) / sizeof(mib[0]); ++ struct uvmexp uvmexp; ++ size_t sz = sizeof(uvmexp); ++ if (sysctl(mib, miblen, &uvmexp, &sz, NULL, 0)) ++ { ++ return 0; ++ } ++ return (u64)(uvmexp.free + uvmexp.inactive + uvmexp.filepages ++ + uvmexp.execpages) * uvmexp.pagesize / byte_size; + #elif LINUX + struct sysinfo info; + sysinfo(&info); +@@ -133,11 +196,29 @@ void setSystemRam() + stat.dwLength = sizeof(MEMORYSTATUSEX); + GlobalMemoryStatusEx(&stat); + systemRam = stat.ullTotalPhys; +-#elif DARWIN +- u64 mem; +- size_t len = sizeof(mem); +- sysctlbyname("hw.memsize", &mem, &len, NULL, 0); +- systemRam = mem; ++#elif defined(DARWIN) || defined(__DragonFly__) || defined(__FreeBSD__) || \ ++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) ++# if defined(HW_MEMSIZE) || defined(HW_PHYSMEM64) ++ uint64_t physmem; ++# else ++ u_long physmem; ++# endif ++ int mib[] = { ++ CTL_HW, ++# if defined(HW_MEMSIZE) ++ HW_MEMSIZE, ++# elif defined(HW_PHYSMEM64) ++ HW_PHYSMEM64, ++# else ++ HW_PHYSMEM, ++# endif ++ }; ++ size_t sz = sizeof(physmem); ++ if (sysctl(mib, 2, &physmem, &sz, NULL, 0)) ++ { ++ physmem = 0; ++ } ++ systemRam = physmem; + #elif LINUX + struct sysinfo info; + sysinfo(&info); +@@ -183,7 +264,10 @@ void setSystemRam() + stackSize = 0x00000000; + systemRam = getFreeRam(BYTES); + #endif +-#if !(defined(WIN) || defined(LINUX) || defined(DARWIN) || defined(SYMBIAN) || defined(VITA)) ++#if !(defined(WIN) || defined(LINUX) || defined(DARWIN) || defined(SYMBIAN) || defined(VITA) || \ ++ defined(__DragonFly__) || defined(__FreeBSD__) || \ ++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || \ ++ defined(__OpenBSD__)) + stackSize = (int)&_end - (int)&_start + ((int)&_start - elfOffset); + #endif + getRamStatus(BYTES); +@@ -215,6 +299,42 @@ u64 getUsedRam(int byte_size) + return 0; + } + return info.resident_size / byte_size; ++#elif defined(__DragonFly__) || defined(__FreeBSD__) || \ ++ defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) ++# if defined(__NetBSD__) ++#undef KERN_PROC ++#define KERN_PROC KERN_PROC2 ++#define KINFO_PROC struct kinfo_proc2 ++# else ++#define KINFO_PROC struct kinfo_proc ++# endif ++# if defined(__DragonFly__) ++#define KP_RSS(kp) (kp.kp_vm_rssize * getpagesize()) ++# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ++#define KP_RSS(kp) (kp.ki_rssize * getpagesize()) ++# elif defined(__NetBSD__) ++#define KP_RSS(kp) (kp.p_vm_rssize * getpagesize()) ++# elif defined(__OpenBSD__) ++#define KP_RSS(kp) (kp.p_vm_rssize * getpagesize()) ++# endif ++ int mib[] = { ++ CTL_KERN, ++ KERN_PROC, ++ KERN_PROC_PID, ++ getpid(), ++# if defined(__NetBSD__) || defined(__OpenBSD__) ++ sizeof(KINFO_PROC), ++ 1, ++# endif ++ }; ++ u_int miblen = sizeof(mib) / sizeof(mib[0]); ++ KINFO_PROC kp; ++ size_t sz = sizeof(KINFO_PROC); ++ if (sysctl(mib, miblen, &kp, &sz, NULL, 0)) ++ { ++ return 0; ++ } ++ return (u64)KP_RSS(kp) / byte_size; + #elif LINUX + unsigned long vm = 0; + FILE *file = fopen("/proc/self/statm", "r"); diff --git a/games/openbor7144/files/patch-source_utils.c b/games/openbor7144/files/patch-source_utils.c new file mode 100644 index 000000000000..65fb72c0c7ed --- /dev/null +++ b/games/openbor7144/files/patch-source_utils.c @@ -0,0 +1,19 @@ +source/utils.c:303:54: error: implicit declaration of function 'mallinfo' is invalid in C99 + [-Werror,-Wimplicit-function-declaration] + writeToLogFile("Memory usage at exit: %u\n", mallinfo().arena); + ^ +source/utils.c:303:64: error: member reference base type 'int' is not a structure or union + writeToLogFile("Memory usage at exit: %u\n", mallinfo().arena); + ~~~~~~~~~~^~~~~~ + +--- source/utils.c.orig 2018-07-06 15:13:16 UTC ++++ source/utils.c +@@ -303,7 +303,7 @@ void *checkAlloc(void *ptr, size_t size, const char *f + "\n* Shutting Down *\n\n"); + writeToLogFile("Out of memory!\n"); + writeToLogFile("Allocation of size %i failed in function '%s' at %s:%i.\n", size, func, file, line); +-#ifndef WIN ++#if defined(__GLIBC__) || defined(ANDROID) || defined(VITA) + writeToLogFile("Memory usage at exit: %u\n", mallinfo().arena); + #endif + borExit(2);