git: 9front

Download patch

ref: 1f4b48a86c42ca0b34657b5166e8f4c6db1eba81
parent: 22f6a61b0c841b9a045f50eae7c331c25665d1a1
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jan 3 17:15:07 EST 2026

9/*: move definition of Lock into portable code

the implementation is portable, why is the struct
not portable?

--- a/sys/src/9/arm64/dat.h
+++ b/sys/src/9/arm64/dat.h
@@ -25,7 +25,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Memcache	Memcache;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -50,16 +49,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(R_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/bcm/dat.h
+++ b/sys/src/9/bcm/dat.h
@@ -19,7 +19,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Memcache	Memcache;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -41,16 +40,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(E_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/bcm64/dat.h
+++ b/sys/src/9/bcm64/dat.h
@@ -19,7 +19,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Memcache	Memcache;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -44,16 +43,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(R_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/cycv/dat.h
+++ b/sys/src/9/cycv/dat.h
@@ -4,7 +4,6 @@
 typedef struct PFPU	PFPU;
 typedef struct L1	L1;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct KMap	KMap;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -21,16 +20,6 @@
 #define MAXSYSARG	5	/* for mount(fd, mpt, flag, arg, srv) */
 
 #define AOUT_MAGIC	(E_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/imx8/dat.h
+++ b/sys/src/9/imx8/dat.h
@@ -25,7 +25,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Memcache	Memcache;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -50,16 +49,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(R_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/kw/dat.h
+++ b/sys/src/9/kw/dat.h
@@ -4,7 +4,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Memcache	Memcache;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -28,16 +27,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(E_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/lx2k/dat.h
+++ b/sys/src/9/lx2k/dat.h
@@ -25,7 +25,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Memcache	Memcache;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -50,16 +49,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(R_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/mt7688/dat.h
+++ b/sys/src/9/mt7688/dat.h
@@ -6,7 +6,6 @@
 typedef struct Lance	Lance;
 typedef struct Lancemem	Lancemem;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Mach	Mach;
 typedef struct MMU	MMU;
 typedef struct PMMU	PMMU;
@@ -32,16 +31,6 @@
 /*
  *  machine dependent definitions used by ../port/dat.h
  */
-
-struct Lock
-{
-	ulong	key;			/* semaphore (non-zero = locked) */
-	ulong	sr;
-	ulong	pc;
-	Proc	*p;
-	Mach	*m;
-	ushort	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/mtx/dat.h
+++ b/sys/src/9/mtx/dat.h
@@ -4,7 +4,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Mach	Mach;
 typedef struct Page	Page;
 typedef struct PCArch	PCArch;
@@ -28,16 +27,6 @@
 /*
  *  machine dependent definitions used by ../port/dat.h
  */
-
-struct Lock
-{
-	ulong	key;
-	ulong	sr;
-	ulong	pc;
-	Proc	*p;
-	Mach	*m;
-	ushort	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/omap/dat.h
+++ b/sys/src/9/omap/dat.h
@@ -24,7 +24,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Memcache	Memcache;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -46,16 +45,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(E_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/pc/dat.h
+++ b/sys/src/9/pc/dat.h
@@ -9,7 +9,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct MMU	MMU;
 typedef struct Mach	Mach;
 typedef struct PCArch	PCArch;
@@ -34,17 +33,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(I_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	ulong	sr;
-	uintptr	pc;
-	Proc	*p;
-	Mach	*m;
-	ushort	isilock;
-	long	lockcycles;
-};
 
 struct Label
 {
--- a/sys/src/9/pc64/dat.h
+++ b/sys/src/9/pc64/dat.h
@@ -7,7 +7,6 @@
 typedef struct PFPU	PFPU;
 typedef struct ISAConf	ISAConf;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct MMU	MMU;
 typedef struct Mach	Mach;
 typedef struct PCArch	PCArch;
@@ -31,17 +30,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(S_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	ulong	sr;
-	uintptr	pc;
-	Proc	*p;
-	Mach	*m;
-	ushort	isilock;
-	long	lockcycles;
-};
 
 struct Label
 {
--- a/sys/src/9/port/portdat.h
+++ b/sys/src/9/port/portdat.h
@@ -13,6 +13,7 @@
 typedef struct Fgrp	Fgrp;
 typedef struct DevConf	DevConf;
 typedef struct Image	Image;
+typedef struct Lock	Lock;
 typedef struct Log	Log;
 typedef struct Logflag	Logflag;
 typedef struct Mntcache Mntcache;
@@ -64,6 +65,16 @@
 #pragma incomplete Tos
 
 #include <fcall.h>
+
+struct Lock
+{
+	ulong	key;
+	ulong	sr;
+	uintptr	pc;
+	Proc	*p;
+	Mach	*m;
+	ushort	isilock;
+};
 
 struct Ref
 {
--- a/sys/src/9/ppc/dat.h
+++ b/sys/src/9/ppc/dat.h
@@ -5,7 +5,6 @@
 typedef struct ISAConf	ISAConf;
 typedef struct Imap	Imap;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Mach	Mach;
 typedef struct PCArch	PCArch;
 typedef struct PMMU	PMMU;
@@ -30,16 +29,6 @@
 /*
  *  machine dependent definitions used by ../port/dat.h
  */
-
-struct Lock
-{
-	ulong	key;			/* semaphore (non-zero = locked) */
-	ulong	sr;
-	ulong	pc;
-	Proc	*p;
-	ulong	pid;
-	ushort	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/sgi/dat.h
+++ b/sys/src/9/sgi/dat.h
@@ -6,7 +6,6 @@
 typedef struct Lance	Lance;
 typedef struct Lancemem	Lancemem;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Mach	Mach;
 typedef struct MMU	MMU;
 typedef struct PMMU	PMMU;
@@ -28,16 +27,6 @@
 /*
  *  machine dependent definitions used by ../port/dat.h
  */
-
-struct Lock
-{
-	ulong	key;			/* semaphore (non-zero = locked) */
-	ulong	sr;
-	ulong	pc;
-	Proc	*p;
-	Mach	*m;
-	ushort	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/teg2/dat.h
+++ b/sys/src/9/teg2/dat.h
@@ -27,7 +27,6 @@
 typedef struct ISAConf	ISAConf;
 typedef struct Isolated Isolated;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct Lowmemcache Lowmemcache;
 typedef struct Memcache	Memcache;
 typedef struct MMMU	MMMU;
@@ -54,16 +53,6 @@
  *  parameters for sysproc.c
  */
 #define AOUT_MAGIC	(E_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--- a/sys/src/9/zynq/dat.h
+++ b/sys/src/9/zynq/dat.h
@@ -4,7 +4,6 @@
 typedef struct PFPU	PFPU;
 typedef struct L1	L1;
 typedef struct Label	Label;
-typedef struct Lock	Lock;
 typedef struct KMap	KMap;
 typedef struct MMMU	MMMU;
 typedef struct Mach	Mach;
@@ -20,16 +19,6 @@
 #define MAXSYSARG	5	/* for mount(fd, mpt, flag, arg, srv) */
 
 #define AOUT_MAGIC	(E_MAGIC)
-
-struct Lock
-{
-	ulong	key;
-	u32int	sr;
-	uintptr	pc;
-	Proc*	p;
-	Mach*	m;
-	int	isilock;
-};
 
 struct Label
 {
--