1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-03-21 16:42:35 +00:00

Compare commits

...

15 Commits

Author SHA1 Message Date
Nick Briggs
3a4a94344a Merge branch 'master' into nhb-pcap-ethernet 2026-03-19 17:06:05 -07:00
Nick Briggs
9259716e9a Merge pull request #544 from Interlisp/fgh_redo-linux-makefiles
Consolidate PRs 542 and 543 and slightly update:  Redo linux makefiles to include libbsd where necessary and to abstract out common parts and share them across all linux-y makefiles
2026-03-19 14:47:23 -07:00
Nick Briggs
519c13891b Fixes missing quoting for sh -c 2026-03-19 12:33:02 -07:00
Nick Briggs
ee21e482a7 Invoke "command" with /bin/sh -c from makefile to avoid not-found errors 2026-03-19 11:16:16 -07:00
Frank Halasz
bbe011c583 Take geminis suggestion on getting glibc version number in linux-common.mk 2026-03-18 01:27:16 -07:00
Frank Halasz
54c81a3762 Fixed comment in linux-compiler.mk 2026-03-18 01:15:21 -07:00
Frank Halasz
6c20a5c635 Fixed comment in linux-compiler.mk 2026-03-18 01:03:32 -07:00
Frank Halasz
1195048b1b Ooops. Took out debugging code. 2026-03-18 00:51:03 -07:00
Frank Halasz
7a286a8f1f Fix sed script in linux-common.mk 2026-03-18 00:50:14 -07:00
Frank Halasz
034c52b86f In CMakelists, limit use of libbsd for linux to cases where libc does not include strlcat 2026-03-18 00:25:28 -07:00
Frank Halasz
a26cafcbda Change USE_GCC=T/USE_CLANG=T to USE_COMPILER=clang/gcc for linux-y makefiles 2026-03-18 00:01:24 -07:00
Nick Briggs
5432d73819 Adds generation of SIGIO on X11 connection if O_ASYNC defined 2025-12-11 09:18:40 -08:00
Nick Briggs
a074c4a3c0 Adds required include of <string.h> for strncpy in non-BYTESWAP compilations. 2025-12-07 21:11:39 -08:00
Nick Briggs
cdaa7b6889 Cleans up the interrupt state structure to match Lisp naming
Adds names for individual interrupt-in-progress bits in the
struct interrupt_state to match the structure defined in Lisp.

Adjusts the base datatype to DLword to make clear the size and
alignment of interrupt bits in the structure.
2025-12-07 18:39:59 -08:00
Nick Briggs
eedc8a504a Uses endian independent structure layouts to access returned ethernet packet length field 2025-10-31 15:38:54 -07:00
8 changed files with 82 additions and 54 deletions

View File

@@ -37,9 +37,12 @@ IF(NEED_LIB_M)
ENDIF()
IF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBBSD-OVERLAY REQUIRED IMPORTED_TARGET "libbsd-overlay")
SET(MAIKO_LIBRARIES ${MAIKO_LIBRARIES} PkgConfig::LIBBSD-OVERLAY)
CHECK_LIBRARY_EXISTS(c strlcat "" NO_NEED_FOR_LIBBSD)
IF(NOT NO_NEED_FOR_LIBBSD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBBSD-OVERLAY REQUIRED IMPORTED_TARGET "libbsd-overlay")
SET(MAIKO_LIBRARIES ${MAIKO_LIBRARIES} PkgConfig::LIBBSD-OVERLAY)
ENDIF()
ENDIF()
SET (MAIKO_RELEASE 351 CACHE STRING "Release version to build. Release: 115, 200, 201, 210, 300, 350, 351")
@@ -559,7 +562,9 @@ if(NOT res EQUAL 0)
message(FATAL_ERROR "machinetype script failed")
endif()
set(release_dir "${os_ver}.${machine_type}")INSTALL(TARGETS lde DESTINATION ${release_dir})
set(release_dir "${os_ver}.${machine_type}")
INSTALL(TARGETS lde DESTINATION ${release_dir})
IF(MAIKO_DISPLAY_X11)
INSTALL(TARGETS ldex ldeinit DESTINATION ${release_dir})

View File

@@ -8,8 +8,11 @@ ifeq ($(USE_LIBBSD),T)
# Use LIBBSD - but only if glibc < 2.38
# Because we only need strlcat, strlcpy and friends from libbsd
# and they are included in glibc from 2.38 on.
GLIBC_VERSION := $(shell ldd --version | head -1 | sed -e "s/^.*\([0-9]\.[0-9][0-9]\)/\\1/")
GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc)
GLIBC_VERSION := $(shell getconf GNU_LIBC_VERSION | sed 's/glibc //')
GLIBC_CHECK := 0
ifneq ($(GLIBC_VERSION),)
GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc)
endif
ifneq ($(GLIBC_CHECK),1)
include linux-libbsd.mk
endif

View File

@@ -1,36 +1,33 @@
# Select whether to use clang or gcc
# Priority
# 1. If -DUSE_GCC or -DUSE_CLANG on command line (but not both) use the requested compiler.
# 2. If one compiler is installed but not the other, use the installed compiler.
# 3. Use clang
# 1. If USE_COMPILER=gcc or USE_COMPILER=clang on make command line use the requested compiler.
# 2. If clang is installed use it.
# 3. Use gcc
EXISTS_GCC := $(shell command -v gcc)
EXISTS_CLANG := $(shell command -v clang)
EXISTS_GCC := $(shell /bin/sh -c "command -v gcc")
EXISTS_CLANG := $(shell /bin/sh -c "command -v clang")
ifeq ($(or $(EXISTS_GCC),$(EXISTS_CLANG)),)
$(error "Cannot find compiler: neither gcc nor clang. Exiting.")
endif
ifneq ($(and $(USE_CLANG),$(USE_GCC)),)
$(error "Cannot use both USE_CLANG=T and USE_GCC=T. Exiting.")
endif
COMPILER :=
ifdef USE_CLANG
ifeq ($(USE_COMPILER),clang)
ifeq ($(EXISTS_CLANG),)
$(error "USE_CLANG=T given, but cannot find the clang compiler. Exiting")
$(error "USE_COMPILER=clang, but cannot find the clang compiler. Exiting")
endif
COMPILER := clang
endif
ifdef USE_GCC
else ifeq ($(USE_COMPILER),gcc)
ifeq ($(EXISTS_GCC),)
$(error "USE_GCC=T given, but cannot find the gcc compiler. Exiting")
$(error "USE_COMPILER=gcc given, but cannot find the gcc compiler. Exiting")
endif
COMPILER := gcc
else ifneq ($(EXISTS_CLANG),)
COMPILER := clang
else
COMPILER := gcc
endif
ifeq ($(COMPILER),)
ifneq ($(EXISTS_CLANG),)
COMPILER := clang
else
COMPILER := gcc
endif
$(error "Oops. Trying to select gcc or clang but should never get here")
endif
ifeq ($(COMPILER),gcc)

View File

@@ -65,21 +65,28 @@ typedef struct closure_type {
#endif /* BIGVM */
typedef struct interrupt_state { /* Interrupt-request mask to communicate with INTERRUPTED */
unsigned LogFileIO : 1; /* console msg arrived to print */
unsigned ETHERInterrupt : 1; /* 10MB activity happened */
unsigned IOInterrupt : 1; /* I/O happened (not used yet) */
unsigned gcdisabled : 1;
unsigned vmemfull : 1;
unsigned stackoverflow : 1;
unsigned storagefull : 1;
unsigned waitinginterrupt : 1;
unsigned nil : 8; /* mask of ints being processed */
DLword LogFileIO : 1; /* console msg arrived to print */
DLword ETHERInterrupt : 1; /* 10MB activity happened */
DLword IOInterrupt : 1; /* I/O happened (not used yet) */
DLword gcdisabled : 1;
DLword vmemfull : 1;
DLword stackoverflow : 1;
DLword storagefull : 1;
DLword waitinginterrupt : 1;
DLword P_LogFileIO : 1; /* interrupts awaiting processing, cleared by Lisp */
DLword P_ETHERInterrupt : 1;
DLword P_IOInterrupt : 1;
DLword P_gcdisabled : 1;
DLword P_vmemfull : 1;
DLword P_stackoverflow : 1;
DLword P_storagefull : 1;
DLword P_waitinginterrupt : 1;
DLword intcharcode;
} INTSTAT;
typedef struct interrupt_state_2 { /* alternate view of the interrupt state */
unsigned pendingmask : 8;
unsigned handledmask : 8;
DLword pendingmask : 8;
DLword handledmask : 8;
DLword nil;
} INTSTAT2;
@@ -204,21 +211,28 @@ typedef struct closure_type {
typedef struct interrupt_state { /* Interrupt-request mask to communicate with INTERRUPTED */
DLword intcharcode;
unsigned nil : 8;
unsigned waitinginterrupt : 1;
unsigned storagefull : 1;
unsigned stackoverflow : 1;
unsigned vmemfull : 1;
unsigned gcdisabled : 1;
unsigned IOInterrupt : 1; /* I/O happened (not used yet) */
unsigned ETHERInterrupt : 1; /* 10MB activity happened */
unsigned LogFileIO : 1; /* console msg arrived to print */
DLword P_waitinginterrupt : 1; /* interrupts awaiting processing, cleared by Lisp */
DLword P_storagefull : 1;
DLword P_stackoverflow : 1;
DLword P_vmemfull : 1;
DLword P_gcdisabled : 1;
DLword P_IOInterrupt : 1;
DLword P_ETHERInterrupt : 1;
DLword P_LogFileIO : 1;
DLword waitinginterrupt : 1;
DLword storagefull : 1;
DLword stackoverflow : 1;
DLword vmemfull : 1;
DLword gcdisabled : 1;
DLword IOInterrupt : 1; /* I/O happened (not used yet) */
DLword ETHERInterrupt : 1; /* 10MB activity happened */
DLword LogFileIO : 1; /* console msg arrived to print */
} INTSTAT;
typedef struct interrupt_state_2 { /* alternate view of the interrupt state */
DLword nil;
unsigned handledmask : 8;
unsigned pendingmask : 8;
DLword handledmask : 8;
DLword pendingmask : 8;
} INTSTAT2;
struct state {

View File

@@ -11,6 +11,7 @@
#include <errno.h>
#include <limits.h> /* for NAME_MAX */
#include <dirent.h> /* for MAXNAMLEN */
#include <string.h> /* for strncpy in non-BYTESWAP case */
#include "lispemul.h" /* for DLword */
#include "commondefs.h" /* for error */

View File

@@ -297,12 +297,10 @@ static int recvPacket(void) {
#if defined(BYTESWAP)
log_debug((" recvPacket() :: byte-swapping %d bytes at %p\n", bLen, (void *)ether_buf));
dblwordsSwap(ether_buf, bLen);
IOPage->dlethernet[2] = bLen;
#else
log_debug((" recvPacket() :: %d bytes at %p\n", bLen, (void *)ether_buf));
IOPage->dlethernet[3] = bLen;
#endif
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = blen;
ether_bsize = 0;

View File

@@ -477,7 +477,7 @@ int *ether_debug(void) {
estat[0] = 0;
if (ether_fd < 0) return (NIL);
printf("fd %d bsize %d buf %p icb %X in %d out %d\n ", ether_fd, ether_bsize, (void *)ether_buf,
IOPage->dlethernet[3], ether_in, ether_out);
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB, ether_in, ether_out);
#endif /* MAIKO_ENABLE_ETHERNET */
return (estat);
@@ -542,7 +542,7 @@ LispPTR check_ether(void) {
memcpy(&ether_buf[0], &nit_buf[nitpos], fromlen);
ether_bsize = 0; /* deactivate receiver */
ether_in++;
IOPage->dlethernet[3] = fromlen;
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = fromlen;
DBPRINT(
("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen));
nitpos += fromlen;
@@ -586,7 +586,7 @@ LispPTR check_ether(void) {
memcpy(&ether_buf[0], nit_buf, data.len);
ether_bsize = 0;
ether_in++;
IOPage->dlethernet[3] = data.len;
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = data.len;
((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->ETHERInterrupt = 1;
ETHEREventCount++;
Irq_Stk_Check = Irq_Stk_End = 0;
@@ -649,7 +649,7 @@ LispPTR get_packet(void) {
memcpy(&ether_buf[0], &nit_buf[nitpos], fromlen);
ether_bsize = 0; /* deactivate receiver */
ether_in++;
IOPage->dlethernet[3] = fromlen;
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = fromlen;
DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen));
nitpos += fromlen;
return (ATOM_T);
@@ -683,7 +683,7 @@ LispPTR get_packet(void) {
memcpy(&ether_buf[0], nit_buf, data.len);
ether_bsize = 0;
ether_in++;
IOPage->dlethernet[3] = data.len;
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = data.len;
return (ATOM_T);
}
} else if (errno != EWOULDBLOCK)

View File

@@ -17,6 +17,8 @@
#include <stdbool.h> // for false, bool, true
#include <stdio.h> // for NULL
#include <stdlib.h> // for exit
#include <fcntl.h> // for fcntl, O_ASYNC, ...
#include <unistd.h> // for getpid
#include "adr68k.h" // for NativeAligned4FromLAddr
#include "dbprint.h" // for TPRINT
#include "devif.h" // for (anonymous), MRegion, DspInterface, OUTER_S...
@@ -248,6 +250,7 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, unsigned width_hint, u
unsigned depth_hint)
{
Screen *Xscreen;
int xfd;
dsp->identifier = Display_Name; /* This is a hack. The display name */
/* has to dealt with in a more */
@@ -360,5 +363,12 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, unsigned width_hint, u
break;
}
XInitImage(&dsp->ScreenBitmap);
#if defined(O_ASYNC)
xfd = ConnectionNumber(dsp->display_id);
if (fcntl(xfd, F_SETOWN, getpid()) == -1) perror("X_init: fcntl F_SETOWN error");
if (fcntl(xfd, F_SETFL, fcntl(xfd, F_GETFL, 0) | O_ASYNC) == -1) perror("X_init: fcntl F_SETFL O_ASYNC error");
#endif
return (dsp);
}