Skip to content

Commit

Permalink
Merge pull request #322 from davidgiven/dtrg-minixst
Browse files Browse the repository at this point in the history
Make the old minixST plat work, or at least build.
  • Loading branch information
davidgiven authored Jan 11, 2025
2 parents 26511fe + 64836c7 commit d73e696
Show file tree
Hide file tree
Showing 277 changed files with 3,619 additions and 3,236 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: true
AllowShortFunctionsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: false
Expand Down
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ linux386 produces ELF executables for PC Linux systems
linux68k produces ELF executables for m68020 Linux systems
linuxppc produces ELF executables for PowerPC Linux systems
linuxmips produces ELF executables for little-endian MIPS32r2 Linux systems
minix68k produces Minix executables for m68000 Minix systems
cpm produces i80 CP/M .COM files
rpi produces Raspberry Pi GPU binaries
pdpv7 produces PDP/11 V7 Unix binaries
Expand Down
1 change: 1 addition & 0 deletions build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ vars.plats = {
"linux68k",
"linuxppc",
"linuxmips",
"minix68k",
"msdos86",
"msdos386",
"osx386",
Expand Down
1 change: 1 addition & 0 deletions lang/cem/libcc.ansi/core/misc/raise.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>

#if ACKCONF_WANT_EMULATED_RAISE

Expand Down
8 changes: 8 additions & 0 deletions lang/cem/libcc.ansi/headers/ack/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
#define ACKCONF_WANT_STANDARD_SIGNALS 1
#endif

#ifndef ACKCONF_WANT_STANDARD_LIMITS
#define ACKCONF_WANT_STANDARD_LIMITS 1
#endif

#ifndef ACKCONF_WANT_SYS_ERRNO_H
#define ACKCONF_WANT_SYS_ERRNO_H 0
#endif

#ifndef ACKCONF_WANT_TERMIOS
/* Don't compile termios-using functions unless the plat explicitly asks for it. */
#define ACKCONF_WANT_TERMIOS 0
Expand Down
6 changes: 6 additions & 0 deletions lang/cem/libcc.ansi/headers/errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#ifndef _ERRNO_H
#define _ERRNO_H

#if ACKCONF_WANT_SYS_ERRNO_H
#include <sys/errno.h>
#else

/* These values are defined by the ANSI standard. */

#define EDOM 33
Expand Down Expand Up @@ -51,3 +55,5 @@
extern int errno;

#endif

#endif
6 changes: 6 additions & 0 deletions lang/cem/libcc.ansi/headers/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#if !defined(_LIMITS_H)
#define _LIMITS_H

#include <ack/config.h>

#define CHAR_BIT 8
#define SCHAR_MIN -128
#define SCHAR_MAX 127
Expand Down Expand Up @@ -34,4 +36,8 @@
#define UINT_MAX 4294967295U
#endif

#if !ACKCONF_WANT_STANDARD_LIMITS
#include <ack/limits.h>
#endif

#endif /* _LIMITS_H */
5 changes: 3 additions & 2 deletions lang/cem/libcc.ansi/headers/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ struct timezone

extern char** environ;

/* Implemented system calls */
/* System calls (not all of which are implemented) */

extern int access(const char* pathname, int mode);
extern int brk(void* ptr);
extern int chdir(const char* path);
extern int close(int d);
extern int creat(const char* path, mode_t mode);
extern int dup(int oldfd);
Expand All @@ -111,7 +112,7 @@ extern unsigned int alarm(unsigned int seconds);
extern pid_t wait(int* wstatus);
extern sighandler_t signal(int signum, sighandler_t handler);
extern ssize_t read(int fd, void* buffer, size_t count);
extern ssize_t write(int fd, void* buffer, size_t count);
extern ssize_t write(int fd, const void* buffer, size_t count);
extern void _exit(int);
extern void* sbrk(int increment);

Expand Down
22 changes: 11 additions & 11 deletions lang/cem/libcc.ansi/sys/malloc/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

#if ACKCONF_WANT_MALLOC

block_t __mem_root = { &__mem_root, 0 };
block_t* __mem_freelist = &__mem_root;
memblock_t __mem_root = { &__mem_root, 0 };
memblock_t* __mem_freelist = &__mem_root;

/* Pulls more memory from the system. */

static block_t* brkmore(size_t nb)
static memblock_t* brkmore(size_t nb)
{
uintptr_t bytes;
block_t* p;
memblock_t* p;

if (nb < BRKSIZE)
nb = BRKSIZE;
bytes = nb * sizeof(block_t);
bytes = nb * sizeof(memblock_t);

/* Danger, will robinson! sbrk's parameter is *signed*... but malloc() takes a
* size_t. */
Expand All @@ -26,7 +26,7 @@ static block_t* brkmore(size_t nb)
return NULL;

p = sbrk(bytes);
if (p == (block_t*)-1)
if (p == (memblock_t*)-1)
return NULL;

/* Add it to the free list by pretending it's a used block and freeing it. */
Expand All @@ -38,16 +38,16 @@ static block_t* brkmore(size_t nb)

void* malloc(size_t size)
{
block_t* p;
block_t* prev;
memblock_t* p;
memblock_t* prev;
size_t nblocks;

/* Add on space for the header; make sure we allocate a round number
* of blocks; avoid overflow. */
nblocks = BLOCKCOUNT(size);
if (nblocks < size)
return NULL;
nblocks /= sizeof(block_t);
nblocks /= sizeof(memblock_t);

prev = __mem_freelist;
p = prev->next;
Expand Down Expand Up @@ -88,8 +88,8 @@ void* malloc(size_t size)

void free(void* ptr)
{
block_t* h = BLOCKOF(ptr);
block_t* p;
memblock_t* h = BLOCKOF(ptr);
memblock_t* p;

if (!ptr)
return;
Expand Down
14 changes: 7 additions & 7 deletions lang/cem/libcc.ansi/sys/malloc/malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

typedef struct block_s {
struct block_s* next;
size_t size; /* in sizeof(block_t) units */
} block_t;
size_t size; /* in sizeof(memblock_t) units */
} memblock_t;

extern block_t __mem_root;
extern block_t* __mem_first_free;
extern memblock_t __mem_root;
extern memblock_t* __mem_first_free;

#define BLOCKOF(p) (((block_t*)(p)) - 1)
#define BLOCKOF(p) (((memblock_t*)(p)) - 1)

/* Smallest amount to allocate from brk */
#define BRKSIZE (512 / sizeof(block_t))
#define BRKSIZE (512 / sizeof(memblock_t))

#define BLOCKCOUNT(bytes) \
(bytes + sizeof(block_t) + sizeof(block_t) - 1)
(bytes + sizeof(memblock_t) + sizeof(memblock_t) - 1)

#endif

4 changes: 2 additions & 2 deletions lang/cem/libcc.ansi/sys/malloc/realloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

void* realloc(void* ptr, size_t size)
{
block_t* h;
memblock_t* h;
size_t nblocks;
void* newptr;

Expand Down Expand Up @@ -37,7 +37,7 @@ void* realloc(void* ptr, size_t size)
newptr = malloc(size);
if (!newptr)
return NULL;
memcpy(newptr, ptr, h->size * sizeof(block_t));
memcpy(newptr, ptr, h->size * sizeof(memblock_t));
free(ptr);
return newptr;
}
Expand Down
4 changes: 2 additions & 2 deletions lang/cem/libcc.ansi/sys/misc/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ alfun(int sig)
longjmp(setjmpbuf, 1);
} /* used with sleep() below */

void sleep(int n)
unsigned int sleep(int n)
{
/* sleep(n) pauses for 'n' seconds by scheduling an alarm interrupt. */
unsigned oldalarm = 0;
Expand All @@ -30,7 +30,7 @@ void sleep(int n)
{
signal(SIGALRM, oldsig);
alarm(oldalarm);
return;
return 0;
}
oldalarm = alarm(5000); /* Who cares how long, as long
* as it is long enough
Expand Down
68 changes: 0 additions & 68 deletions lib/minix/include/fcntl.h

This file was deleted.

41 changes: 0 additions & 41 deletions lib/minix/include/lib.h

This file was deleted.

Loading

0 comments on commit d73e696

Please sign in to comment.