Skip to content

Commit d73e696

Browse files
authored
Merge pull request #322 from davidgiven/dtrg-minixst
Make the old minixST plat work, or at least build.
2 parents 26511fe + 64836c7 commit d73e696

File tree

277 files changed

+3619
-3236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+3619
-3236
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
AlignAfterOpenBracket: AlwaysBreak
3+
AlignConsecutiveMacros: true
34
AllowShortFunctionsOnASingleLine: false
45
AllowShortLoopsOnASingleLine: false
56
AlwaysBreakAfterDefinitionReturnType: false

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ linux386 produces ELF executables for PC Linux systems
3434
linux68k produces ELF executables for m68020 Linux systems
3535
linuxppc produces ELF executables for PowerPC Linux systems
3636
linuxmips produces ELF executables for little-endian MIPS32r2 Linux systems
37+
minix68k produces Minix executables for m68000 Minix systems
3738
cpm produces i80 CP/M .COM files
3839
rpi produces Raspberry Pi GPU binaries
3940
pdpv7 produces PDP/11 V7 Unix binaries

build.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ vars.plats = {
1111
"linux68k",
1212
"linuxppc",
1313
"linuxmips",
14+
"minix68k",
1415
"msdos86",
1516
"msdos386",
1617
"osx386",

lang/cem/libcc.ansi/core/misc/raise.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <stdlib.h>
88
#include <sys/types.h>
99
#include <signal.h>
10+
#include <unistd.h>
1011

1112
#if ACKCONF_WANT_EMULATED_RAISE
1213

lang/cem/libcc.ansi/headers/ack/config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
#define ACKCONF_WANT_STANDARD_SIGNALS 1
2424
#endif
2525

26+
#ifndef ACKCONF_WANT_STANDARD_LIMITS
27+
#define ACKCONF_WANT_STANDARD_LIMITS 1
28+
#endif
29+
30+
#ifndef ACKCONF_WANT_SYS_ERRNO_H
31+
#define ACKCONF_WANT_SYS_ERRNO_H 0
32+
#endif
33+
2634
#ifndef ACKCONF_WANT_TERMIOS
2735
/* Don't compile termios-using functions unless the plat explicitly asks for it. */
2836
#define ACKCONF_WANT_TERMIOS 0

lang/cem/libcc.ansi/headers/errno.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#ifndef _ERRNO_H
77
#define _ERRNO_H
88

9+
#if ACKCONF_WANT_SYS_ERRNO_H
10+
#include <sys/errno.h>
11+
#else
12+
913
/* These values are defined by the ANSI standard. */
1014

1115
#define EDOM 33
@@ -51,3 +55,5 @@
5155
extern int errno;
5256

5357
#endif
58+
59+
#endif

lang/cem/libcc.ansi/headers/limits.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#if !defined(_LIMITS_H)
77
#define _LIMITS_H
88

9+
#include <ack/config.h>
10+
911
#define CHAR_BIT 8
1012
#define SCHAR_MIN -128
1113
#define SCHAR_MAX 127
@@ -34,4 +36,8 @@
3436
#define UINT_MAX 4294967295U
3537
#endif
3638

39+
#if !ACKCONF_WANT_STANDARD_LIMITS
40+
#include <ack/limits.h>
41+
#endif
42+
3743
#endif /* _LIMITS_H */

lang/cem/libcc.ansi/headers/unistd.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ struct timezone
8181

8282
extern char** environ;
8383

84-
/* Implemented system calls */
84+
/* System calls (not all of which are implemented) */
8585

8686
extern int access(const char* pathname, int mode);
8787
extern int brk(void* ptr);
88+
extern int chdir(const char* path);
8889
extern int close(int d);
8990
extern int creat(const char* path, mode_t mode);
9091
extern int dup(int oldfd);
@@ -111,7 +112,7 @@ extern unsigned int alarm(unsigned int seconds);
111112
extern pid_t wait(int* wstatus);
112113
extern sighandler_t signal(int signum, sighandler_t handler);
113114
extern ssize_t read(int fd, void* buffer, size_t count);
114-
extern ssize_t write(int fd, void* buffer, size_t count);
115+
extern ssize_t write(int fd, const void* buffer, size_t count);
115116
extern void _exit(int);
116117
extern void* sbrk(int increment);
117118

lang/cem/libcc.ansi/sys/malloc/malloc.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
#if ACKCONF_WANT_MALLOC
77

8-
block_t __mem_root = { &__mem_root, 0 };
9-
block_t* __mem_freelist = &__mem_root;
8+
memblock_t __mem_root = { &__mem_root, 0 };
9+
memblock_t* __mem_freelist = &__mem_root;
1010

1111
/* Pulls more memory from the system. */
1212

13-
static block_t* brkmore(size_t nb)
13+
static memblock_t* brkmore(size_t nb)
1414
{
1515
uintptr_t bytes;
16-
block_t* p;
16+
memblock_t* p;
1717

1818
if (nb < BRKSIZE)
1919
nb = BRKSIZE;
20-
bytes = nb * sizeof(block_t);
20+
bytes = nb * sizeof(memblock_t);
2121

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

2828
p = sbrk(bytes);
29-
if (p == (block_t*)-1)
29+
if (p == (memblock_t*)-1)
3030
return NULL;
3131

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

3939
void* malloc(size_t size)
4040
{
41-
block_t* p;
42-
block_t* prev;
41+
memblock_t* p;
42+
memblock_t* prev;
4343
size_t nblocks;
4444

4545
/* Add on space for the header; make sure we allocate a round number
4646
* of blocks; avoid overflow. */
4747
nblocks = BLOCKCOUNT(size);
4848
if (nblocks < size)
4949
return NULL;
50-
nblocks /= sizeof(block_t);
50+
nblocks /= sizeof(memblock_t);
5151

5252
prev = __mem_freelist;
5353
p = prev->next;
@@ -88,8 +88,8 @@ void* malloc(size_t size)
8888

8989
void free(void* ptr)
9090
{
91-
block_t* h = BLOCKOF(ptr);
92-
block_t* p;
91+
memblock_t* h = BLOCKOF(ptr);
92+
memblock_t* p;
9393

9494
if (!ptr)
9595
return;

lang/cem/libcc.ansi/sys/malloc/malloc.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77

88
typedef struct block_s {
99
struct block_s* next;
10-
size_t size; /* in sizeof(block_t) units */
11-
} block_t;
10+
size_t size; /* in sizeof(memblock_t) units */
11+
} memblock_t;
1212

13-
extern block_t __mem_root;
14-
extern block_t* __mem_first_free;
13+
extern memblock_t __mem_root;
14+
extern memblock_t* __mem_first_free;
1515

16-
#define BLOCKOF(p) (((block_t*)(p)) - 1)
16+
#define BLOCKOF(p) (((memblock_t*)(p)) - 1)
1717

1818
/* Smallest amount to allocate from brk */
19-
#define BRKSIZE (512 / sizeof(block_t))
19+
#define BRKSIZE (512 / sizeof(memblock_t))
2020

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

2424
#endif
2525

0 commit comments

Comments
 (0)