From: Duncan Bowring Date: Fri, 3 Apr 2026 14:50:07 +0000 (+0000) Subject: patch 9.2.0290: Amiga: no support for AmigaOS 3.x X-Git-Tag: v9.2.0290^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b7205b64261e4a65cdba8aa3682c4ca295fb9e0f;p=thirdparty%2Fvim.git patch 9.2.0290: Amiga: no support for AmigaOS 3.x Problem: Amiga: no support for AmigaOS 3.x Solution: Add support for building Vim on classic AmigaOS 3.x with the bebbo cross-compiler and libnix (-noixemul) runtime (Duncan Bowring). The existing Make_ami.mak targets AmigaOS 4 (clib2), AROS, and MorphOS. This patch adds a fourth target for classic 68k AmigaOS 3.x systems (A1200, A4000, accelerated A500/A2000) using: ``` make -f Make_ami.mak UNM=AmigaOS3 BUILD=normal ``` Changes: os_amiga.c: - Add 256 KiB __stack cookie for OS3 (conservative for limited RAM) - Add safe_Lock() wrapper to suppress "Please insert volume" system requesters during path probing (benefits all Amiga targets) - Suppress system requesters globally in mch_init() via pr_WindowPtr=-1 (Vim probes many paths at startup; Lock()/Open() on non-existent volume names triggers blocking system requesters) - Fix mch_get_host_name() for OS3 (libnix has no gethostname) - Fix Delay() prototype for non-LATTICE compilers - Fix nilfh file handle leak on error exit in mch_check_win() os_amiga.h: - Add fchown/fchmod/ftruncate no-op stubs for OS3/libnix os_amiga_stubs.c (new): - IM function stubs (referenced by optiondefs.h, no X11 on Amiga) - mch_rmdir() via AmigaDOS DeleteFile() - getpwuid()/getgrgid()/getuid() stubs (single-user system) Make_ami.mak: - Add AmigaOS3 target with -noixemul, -std=gnu99, -DWORDS_BIGENDIAN blowfish.c: - Accept WORDS_BIGENDIAN or AMIGA without requiring HAVE_CONFIG_H xdiff/xmacros.h: - Make SIZE_MAX fallback unconditional (not just hpux/VMS) All OS3-specific changes are guarded by: #if defined(__GNUC__) && defined(AMIGA) && !defined(__amigaos4__) Tested on FS-UAE with Workbench 3.1: 23 automated tests passing. Binary size: 2.2 MiB with -Os -m68020 -DFEAT_NORMAL. This is the first modern Vim build for classic 68k AmigaOS since Vim 5.8 circa 1998. Vim was originally released on the Amiga (Fred Fish Disk 591, 1991). closes: #19840 Signed-off-by: Duncan Bowring Signed-off-by: Christian Brabandt --- diff --git a/Filelist b/Filelist index 82329c700c..6a21157647 100644 --- a/Filelist +++ b/Filelist @@ -678,6 +678,7 @@ SRC_AMI = \ src/Make_ami.mak \ src/os_amiga.c \ src/os_amiga.h \ + src/os_amiga_stubs.c \ src/proto/os_amiga.pro \ src/testdir/Make_amiga.mak \ src/testdir/util/amiga.vim \ diff --git a/src/Make_ami.mak b/src/Make_ami.mak index e9d73df39f..5211e6559c 100644 --- a/src/Make_ami.mak +++ b/src/Make_ami.mak @@ -1,5 +1,5 @@ # -# Makefile for AROS, AmigaOS4 and MorphOS. +# Makefile for AROS, AmigaOS 3.x, AmigaOS 4 and MorphOS. # BIN = vim CC ?= gcc @@ -52,6 +52,7 @@ endif # OS specific compiler flags ifeq ($(UNM),AmigaOS) +# AmigaOS 4 (PowerPC) LDFLAGS = -lauto CFLAGS += -DHAVE_FSYNC -D__USE_INLINE__ else @@ -61,6 +62,12 @@ else ifeq ($(UNM),MorphOS) CFLAGS += -noixemul LDFLAGS = -ldebug -lm -noixemul +else +# Classic AmigaOS 3.x (68k) with bebbo-gcc and libnix. +# Build: make -f Make_ami.mak UNM=AmigaOS3 CC=m68k-amigaos-gcc BUILD=normal +CFLAGS += -noixemul -std=gnu99 -DWORDS_BIGENDIAN -DHAVE_ERRNO_H +LDFLAGS = -noixemul -lm +endif endif endif endif @@ -150,6 +157,7 @@ SRC += \ option.c \ optionstr.c \ os_amiga.c \ + os_amiga_stubs.c \ popupmenu.c \ popupwin.c \ quickfix.c \ diff --git a/src/blowfish.c b/src/blowfish.c index 0309e63070..649618a162 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -36,8 +36,9 @@ typedef union { #if defined(MSWIN) // MS-Windows is always little endian #else -# ifdef HAVE_CONFIG_H - // in configure.ac AC_C_BIGENDIAN() defines WORDS_BIGENDIAN when needed +# if defined(HAVE_CONFIG_H) || defined(WORDS_BIGENDIAN) || defined(AMIGA) + // Endianness determined by configure, explicit define, or known platform. + // Amiga (68k) is always big-endian. # else # error Please change this code to define WORDS_BIGENDIAN for big-endian machines. # endif diff --git a/src/os_amiga.c b/src/os_amiga.c index db433e4442..1e362853e2 100644 --- a/src/os_amiga.c +++ b/src/os_amiga.c @@ -55,14 +55,17 @@ #endif /* - * Set stack size to 1 MiB on NG systems. This should be enough even for - * hungry syntax HL / plugin combinations. Leave the stack alone on OS 3 - * and below, those systems might be low on memory. + * Set stack size on startup. 1 MiB on NG systems (OS4, AROS, MorphOS) + * which have plenty of RAM. 256 KiB on classic OS 3 -- enough for syntax + * highlighting and Vim9 execution but conservative for systems with as + * little as 2 MiB of Fast RAM. */ #if defined(__amigaos4__) static const char* __attribute__((used)) stackcookie = "$STACK: 1048576"; #elif defined(__AROS__) || defined(__MORPHOS__) unsigned long __stack = 1048576; +#elif defined(__GNUC__) && defined(AMIGA) +unsigned long __stack = 262144; #endif /* @@ -83,6 +86,26 @@ static void out_num(long n); static struct FileInfoBlock *get_fib(char_u *); static int sortcmp(const void *a, const void *b); +/* + * Lock() wrapper that suppresses "Please insert volume" system requesters. + * AmigaDOS pops a requester when Lock() is called with a name that matches a + * non-mounted volume (e.g., a bare name like "vim" becomes "vim:" -> volume + * request). Setting pr_WindowPtr to -1 suppresses the requester and makes + * Lock() return NULL immediately. See dos.library/ErrorReport. + */ + static BPTR +safe_Lock(UBYTE *name, long mode) +{ + struct Process *me = (struct Process *)FindTask(NULL); + APTR oldwin = me->pr_WindowPtr; + BPTR flock; + + me->pr_WindowPtr = (APTR)-1L; + flock = Lock(name, mode); + me->pr_WindowPtr = oldwin; + return flock; +} + static BPTR raw_in = (BPTR)NULL; static BPTR raw_out = (BPTR)NULL; static int close_win = FALSE; // set if Vim opened the window @@ -225,7 +248,9 @@ mch_avail_mem(int special) void mch_delay(long msec, int flags) { -#ifndef LATTICE // SAS declares void Delay(ULONG) + // Delay() is declared in for GCC; the local prototype is + // only needed for the LATTICE/SAS toolchains. +#ifdef LATTICE void Delay(long); #endif @@ -261,6 +286,17 @@ mch_init(void) #ifdef AZTEC_C Enable_Abort = 0; // disallow vim to be aborted #endif + + // Suppress "Please insert volume" system requesters. Vim probes many + // paths at startup ($VIM, $VIMRUNTIME, defaults.vim, vimrc, etc.) and + // Lock()/Open() calls on non-existent paths can trigger requesters from + // AmigaDOS (and from the C runtime library which calls Lock() internally). + // A CLI editor should handle missing files gracefully, not pop up dialogs. + { + struct Process *me = (struct Process *)FindTask(NULL); + me->pr_WindowPtr = (APTR)-1L; + } + Columns = 80; Rows = 24; @@ -536,6 +572,8 @@ mch_check_win(int argc, char **argv) exitval = 0; // The Execute succeeded: exit this program exit: + if (nilfh) + Close(nilfh); #ifdef FEAT_ARP if (ArpBase) CloseLibrary((struct Library *) ArpBase); @@ -605,7 +643,7 @@ get_fib(char_u *fname) if (fib == NULL) return; - flock = Lock((UBYTE *)fname, (long)ACCESS_READ); + flock = safe_Lock((UBYTE *)fname, (long)ACCESS_READ); if (flock == (BPTR)NULL || !Examine(flock, fib)) { free_fib(fib); // in case of an error the memory is freed here @@ -684,10 +722,11 @@ mch_get_user_name(char_u *s, int len) void mch_get_host_name(char_u *s, int len) { -#if !defined(__AROS__) - gethostname(s, len); +#if defined(__amigaos4__) || defined(__MORPHOS__) + gethostname((char *)s, len); #else - vim_strncpy(s, "Amiga", len - 1); + // AROS and classic OS 3 (libnix) do not have gethostname(). + vim_strncpy(s, (char_u *)"amiga", len - 1); #endif } @@ -735,7 +774,7 @@ mch_FullName( int i; // Lock the file. If it exists, we can get the exact name. - if ((l = Lock((UBYTE *)fname, (long)ACCESS_READ)) != (BPTR)0) + if ((l = safe_Lock((UBYTE *)fname, (long)ACCESS_READ)) != (BPTR)0) { retval = lock2name(l, buf, (long)len - 1); UnLock(l); diff --git a/src/os_amiga.h b/src/os_amiga.h index 799bdd52d3..1407613744 100644 --- a/src/os_amiga.h +++ b/src/os_amiga.h @@ -90,6 +90,16 @@ typedef long off_t; # include #endif +// Classic AmigaOS 3.x with GCC/libnix does not provide fchown, fchmod, or +// ftruncate. Stub them as no-ops. (OS4 has these via clib2; MorphOS and +// AROS provide them in their respective C libraries.) +#if defined(__GNUC__) && defined(AMIGA) && !defined(__amigaos4__) \ + && !defined(__AROS__) && !defined(__MORPHOS__) +# define fchown(fd, uid, gid) (0) +# define fchmod(fd, mode) (0) +# define ftruncate(fd, len) (0) +#endif + #include // for strftime() and others /* diff --git a/src/os_amiga_stubs.c b/src/os_amiga_stubs.c new file mode 100644 index 0000000000..fc08b6e9fa --- /dev/null +++ b/src/os_amiga_stubs.c @@ -0,0 +1,97 @@ +/* vi:set ts=8 sts=4 sw=4 noet: + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. + */ + +/* + * os_amiga_stubs.c + * + * Stubs for functions referenced by Vim but not available on AmigaOS. + * Split into a separate file to keep os_amiga.c clean. + */ + +#include "vim.h" + +#ifndef PROTO + +#include + +/* + * Input Method (IM) stubs. + * These are referenced unconditionally from optiondefs.h function pointer + * tables, but AmigaOS has no X11 input method framework. + */ + int +im_get_status(void) +{ + return FALSE; +} + + void +im_set_active(int active UNUSED) +{ +} + + int +set_ref_in_im_funcs(int copyID UNUSED) +{ + return 0; +} + + char * +did_set_imactivatefunc(optset_T *args UNUSED) +{ + return NULL; +} + + char * +did_set_imstatusfunc(optset_T *args UNUSED) +{ + return NULL; +} + +/* + * Remove a directory. + * os_amiga.c provides most mch_* functions but mch_rmdir() was missing. + * AmigaDOS DeleteFile() works for empty directories. + */ + int +mch_rmdir(char_u *name) +{ + if (DeleteFile((STRPTR)name)) + return 0; + return -1; +} + +/* + * POSIX user/group database stubs. + * AmigaOS is a single-user system with no passwd/group database. + * The struct declarations exist in the NDK headers but the functions + * are not implemented in libnix. + */ +#include +#include + + struct passwd * +getpwuid(uid_t uid UNUSED) +{ + return NULL; +} + + struct group * +getgrgid(gid_t gid UNUSED) +{ + return NULL; +} + + uid_t +getuid(void) +{ + return 0; +} + +#endif // PROTO diff --git a/src/version.c b/src/version.c index 64db5b8842..caa45fe38e 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 290, /**/ 289, /**/ diff --git a/src/xdiff/xmacros.h b/src/xdiff/xmacros.h index 028ca6e417..4afc4a1601 100644 --- a/src/xdiff/xmacros.h +++ b/src/xdiff/xmacros.h @@ -24,10 +24,9 @@ #define XMACROS_H -#if defined(__hpux) || defined(VMS) -# ifndef SIZE_MAX -# define SIZE_MAX ((size_t)(-1)) -# endif +// SIZE_MAX may not be defined on older platforms without . +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t)(-1)) #endif #define XDL_MIN(a, b) ((a) < (b) ? (a): (b))