ref: 5c185d0fad931e47299d282edfa834d10c28142e
parent: b678c30f4fea6f5fcb208b23cc24ea4945ec9ec8
author: akoshibe <[email protected]>
date: Mon Aug 11 15:34:35 EDT 2014
more modifications for FreeBSD port
--- a/6/isel.c
+++ b/6/isel.c
@@ -951,7 +951,7 @@
{
size_t i, j;
- if (fn->isexport || !strcmp(fn->name, Symprefix "main"))
+ if (fn->isexport || !strcmp(fn->name, symprefix "main"))
fprintf(fd, ".globl %s\n", fn->name);
fprintf(fd, "%s:\n", fn->name);
for (j = 0; j < s->cfg->nbb; j++) {
--- a/6/simp.c
+++ b/6/simp.c
@@ -292,7 +292,7 @@
char *s;
int len;
- len = strlen(Symprefix);
+ len = strlen(symprefix);
if (n->name.ns)
len += strlen(n->name.ns) + 1; /* +1 for separator */
len += strlen(n->name.name) + 1;
@@ -300,11 +300,11 @@
s = xalloc(len + 1);
s[0] = '\0';
if (n->name.ns)
- snprintf(s, len, "%s%s$%s", Symprefix, n->name.ns, n->name.name);
+ snprintf(s, len, "%s%s$%s", symprefix, n->name.ns, n->name.name);
else if (n->name.name[0] == '.')
snprintf(s, len, "%s", n->name.name);
else
- snprintf(s, len, "%s%s", Symprefix, n->name.name);
+ snprintf(s, len, "%s%s", symprefix, n->name.name);
return s;
}
--- a/Makefile
+++ b/Makefile
@@ -10,4 +10,4 @@
include config.mk
check: all
- make -C test check
+ $(MAKE) -C test check
--- a/configure
+++ b/configure
@@ -37,17 +37,17 @@
case $OS in
*Linux*)
echo '#define Asmcmd "as -g -o %s %s"' >> config.h
- echo '#define Symprefix ""' >> config.h
+ echo '#define symprefix ""' >> config.h
echo 'export SYS=linux' >> config.mk
;;
*Darwin*)
echo '#define Asmcmd "as -g -o %s %s"' >> config.h
- echo '#define Symprefix "_"' >> config.h
+ echo '#define symprefix "_"' >> config.h
echo 'export SYS=osx' >> config.mk
;;
*FreeBSD*)
echo '#define Asmcmd "as -g -o %s %s"' >> config.h
- echo '#define Fprefix ""' >> config.h
+ echo '#define symprefix ""' >> config.h
echo 'export SYS=freebsd' >> config.mk
;;
*)
--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -92,4 +92,4 @@
rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr/std)
../6/6m:
- cd ..; make
+ cd ..; $(MAKE)
--- a/libstd/start-freebsd.s
+++ b/libstd/start-freebsd.s
@@ -115,7 +115,7 @@
pushq %rdx
/* enter the main program */
- call xmain
+ call main
/* exit(0) */
xorq %rdi,%rdi
movq $1,%rax
--- a/libstd/sys-freebsd.myr
+++ b/libstd/sys-freebsd.myr
@@ -78,11 +78,11 @@
;;
type utsname = struct
- sysname : byte[256]
- nodename : byte[256]
- release : byte[256]
- version : byte[256]
- machine : byte[256]
+ system : byte[256]
+ node : byte[256]
+ release : byte[256]
+ version : byte[256]
+ machine : byte[256]
;;
type sockaddr = struct
@@ -95,7 +95,7 @@
len : byte
fam : sockfam
port : uint16
- addr : uint32 /* should this be byte[4]? */
+ addr : byte[4]
zero : byte[8]
;;
@@ -740,7 +740,7 @@
const clock_settime = {clk, ts; -> syscall(Sysclock_settime, clockid(clk), ts) castto(int32)}
/* system information */
-const uname = {buf; -> syscall(Sysuname, buf) castto(int)}
+const uname = {buf; -> syscall(Sysfreebsd4_uname, buf) castto(int)}
const sysctl = {mib, old, new
var mibp
@@ -764,4 +764,22 @@
old# = o[:oldsz]
-> ret
+}
+
+const clockid = {clk
+ match clk
+ | `Clockrealtime: -> 0
+ | `Clockvirtual: -> 1
+ | `Clockprof: -> 2
+ | `Clockmonotonic: -> 4
+ | `Clockuptime: -> 5
+ | `Clockuptime_precise: -> 7
+ | `Clockuptime_fast: -> 8
+ | `Clockrealtime_precise: -> 9
+ | `Clockrealtime_fast: -> 10
+ | `Clockmonotonic_precise: -> 11
+ | `Clockmonotonic_fast: -> 12
+ | `Clocksecond: -> 13
+ ;;
+ -> -1
}
--- /dev/null
+++ b/libstd/syscall-freebsd.s
@@ -1,0 +1,39 @@
+.globl std$syscall
+std$syscall:
+ pushq %rbp
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %r10
+ pushq %r8
+ pushq %r9
+ pushq %rcx
+ pushq %r11
+ /*
+ hack: We load 6 args regardless of
+ how many we actually have. This may
+ load junk values, but if the syscall
+ doesn't use them, it's going to be
+ harmless.
+ */
+ movq 80 (%rsp),%rax
+ movq 88 (%rsp),%rdi
+ movq 96 (%rsp),%rsi
+ movq 104(%rsp),%rdx
+ movq 112(%rsp),%r10
+ movq 120(%rsp),%r8
+ movq 128(%rsp),%r9
+
+ syscall
+
+ popq %r11
+ popq %rcx
+ popq %r9
+ popq %r8
+ popq %r10
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ popq %rbp
+ ret
+
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
export PATH=.:$PATH
export MC=../6/6m
export MU=../muse/muse