ref: fe54357c8428219c5a27c4cbbebc8d49cc29bdf7
parent: 446c14eaf9e886016e86a574e5cb7685f39ff851
author: halfwit <michaelmisch1985@gmail.com>
date: Sun Nov 23 19:31:04 EST 2025
For now use a modified Tos struct to get our offsets as expected
--- a/Make.osx-cocoa
+++ b/Make.osx-cocoa
@@ -1,10 +1,10 @@
# Mac OS X
-PTHREAD= # for Mac
+PTHREAD=-pthread # for Mac
AR=ar
AS=as
RANLIB=ranlib
-CC=gcc
-CFLAGS=-Wall -Wno-missing-braces -ggdb -I$(ROOT) -I$(ROOT)/include -I$(ROOT)/kern -c -D_THREAD_SAFE $(PTHREAD) -O2
+CC=clang
+CFLAGS=-Wall -Wno-missing-braces -I$(ROOT) -I$(ROOT)/include -I$(ROOT)/kern -c -D_THREAD_SAFE $(PTHREAD) -O2 -march=native
O=o
OS=posix
GUI=cocoa
--- a/include/lib.h
+++ b/include/lib.h
@@ -229,7 +229,6 @@
ulong flags;
};
-#pragma pack(push, 1)
typedef struct Tos Tos;
typedef struct Plink Plink;
@@ -243,6 +242,7 @@
vlong time;
};
+// We need a better way to pack these down reliably
struct Tos {struct /* Per process profiling */
{@@ -250,10 +250,10 @@
Plink *next; /* known to be 4(ptr) */
Plink *last;
Plink *first;
- ulong pid;
- ulong what;
+ //ulong pid;
+ //ulong what;
} prof;
- uvlong cyclefreq; /* cycle clock frequency if there is one, 0 otherwise */
+ //uvlong cyclefreq; /* cycle clock frequency if there is one, 0 otherwise */
vlong kcycles; /* cycles spent in kernel */
vlong pcycles; /* cycles spent in process (kernel + user) */
ulong pid; /* might as well put the pid here */
@@ -260,7 +260,6 @@
ulong clock;
/* top of stack is here */
};
-#pragma pack(pop)
enum{FmtWidth = 1,
--- a/kern/sysproc.c
+++ b/kern/sysproc.c
@@ -16,8 +16,6 @@
#define pgsize 0x1000
/* Use sizes from arm32 */
-#undef USTKTOP
-#undef USTKSIZE
#define USTKTOP 0x3FFFFFFFULL
#define USTKSIZE 0x100000
--- a/posix-386/mem.h
+++ b/posix-386/mem.h
@@ -43,10 +43,6 @@
#define KMAPSIZE BY2XPG
#define VMAP (KMAP-VMAPSIZE)
#define VMAPSIZE (0x10000000-VPTSIZE-KMAPSIZE)
-#define UZERO 0 /* base of user address space */
-#define UTZERO (UZERO+BY2PG) /* first address in user text */
-#define USTKTOP (VMAP-BY2PG) /* byte just beyond user stack */
-#define USTKSIZE (16*1024*1024) /* size of user stack */
/*
* Fundamental addresses
--- a/posix-amd64/mem.h
+++ b/posix-amd64/mem.h
@@ -42,10 +42,7 @@
/*
* Address spaces. User:
*/
-#define UTZERO (0x0000000000200000ull) /* first address in user text */
#define UADDRMASK (0x00007fffffffffffull) /* canonical address mask */
-#define USTKTOP (0x00007ffffffff000ull)
-#define USTKSIZE (16*MiB) /* size of user stack */
/*
* Address spaces. Kernel, sorted by address.
--- a/posix-arm/mem.h
+++ b/posix-arm/mem.h
@@ -54,11 +54,6 @@
#define VGPIO (ARMLOCAL+MiB) /* virtual gpio for pi3 ACT LED */
#define FRAMEBUFFER 0xC0000000 /* video framebuffer */
-#define UZERO 0 /* user segment */
-#define UTZERO (UZERO+BY2PG) /* user text start */
-#define USTKTOP 0x40000000 /* user segment end +1 */
-#define USTKSIZE (8*1024*1024) /* user stack size */
-
/*
* Legacy...
*/
--- a/posix-arm64/mem.h
+++ b/posix-arm64/mem.h
@@ -77,11 +77,6 @@
#define REBOOTADDR (VDRAM-KZERO + 0x20000) /* 0x40020000 */
-#define UZERO 0ULL /* user segment */
-#define UTZERO (UZERO+0x10000) /* user text start */
-#define USTKTOP ((EVAMASK>>1)-0xFFFF) /* user segment end +1 */
-#define USTKSIZE (16*1024*1024) /* user stack size */
-
#define _NSYS 53
#define BLOCKALIGN 64 /* only used in allocb.c */
#define TRAMPSIZE 232 /* Size of the trampoline, padded */
--
⑨