]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0290: Amiga: no support for AmigaOS 3.x v9.2.0290
authorDuncan Bowring <duncan@bowring.us>
Fri, 3 Apr 2026 14:50:07 +0000 (14:50 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 3 Apr 2026 14:50:07 +0000 (14:50 +0000)
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 <duncan@bowring.us>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Filelist
src/Make_ami.mak
src/blowfish.c
src/os_amiga.c
src/os_amiga.h
src/os_amiga_stubs.c [new file with mode: 0644]
src/version.c
src/xdiff/xmacros.h

index 82329c700c8b4c229bed98591750489fd6bc38ba..6a21157647c1cbd58dd142066691727d8a3b7f4e 100644 (file)
--- 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 \
index e9d73df39f69f318f1694102964a1369f7dd824a..5211e6559cf1281aa2790dd69f2a3c40c92826e7 100644 (file)
@@ -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 \
index 0309e63070d7f3a651de27864d39d29f9769b5ea..649618a162b6d3c64692bba7bc427dec4ff3bb4c 100644 (file)
@@ -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
index db433e4442977142145482dc752ae92e6b396d75..1e362853e2faae347b950a70de14515e1aea8d6f 100644 (file)
 #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 <proto/dos.h> 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);
index 799bdd52d3780d415f9026bbf97915e8c265f6f0..14076137445fd4a28ea220056fdc76521f8edc5a 100644 (file)
@@ -90,6 +90,16 @@ typedef long off_t;
 # include <dirent.h>
 #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 <time.h>      // for strftime() and others
 
 /*
diff --git a/src/os_amiga_stubs.c b/src/os_amiga_stubs.c
new file mode 100644 (file)
index 0000000..fc08b6e
--- /dev/null
@@ -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 <proto/dos.h>
+
+/*
+ * 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 <pwd.h>
+#include <grp.h>
+
+    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
index 64db5b8842556c44754f5d9a25b7cfe08f97302d..caa45fe38eff46ecda59a0a13ca9e87e7a607d29 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    290,
 /**/
     289,
 /**/
index 028ca6e417a9f85ed731770207dceb6c1bce66a2..4afc4a1601056acd0acc2bd3abe9625ea5f30270 100644 (file)
 #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 <stdint.h>.
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t)(-1))
 #endif
 
 #define XDL_MIN(a, b) ((a) < (b) ? (a): (b))