Merge branch 'master' of github.com:urbit/urbit

This commit is contained in:
C. Guy Yarvin 2013-10-02 09:41:15 -07:00
commit 3e0fe1bd0e
13 changed files with 381 additions and 8 deletions

View File

@ -10,6 +10,8 @@ ifeq ($(UNAME),Darwin)
OS=osx
else ifeq ($(UNAME),Linux)
OS=linux
else ifeq ($(UNAME),FreeBSD)
OS=freebsd
else
$(error unknown unix)
endif
@ -41,6 +43,9 @@ endif
ifeq ($(OS),linux)
OSLIBS=-lcrypto -lpthread -lrt -lcurses
endif
ifeq ($(OS),freebsd)
OSLIBS=-lcrypto -lpthread -lncurses -lkvm
endif
LIBS=-lgmp -ltermcap -lsigsegv $(OSLIBS)
@ -250,7 +255,7 @@ LIBUV=outside/libuv/libuv.a
all: $(BIN)/vere
$(LIBUV):
make -C outside/libuv
$(MAKE) -C outside/libuv
$(BIN)/vere: $(VERE_OFILES) $(LIBUV)
mkdir -p $(BIN)
@ -264,5 +269,5 @@ etags:
clean:
$(RM) $(VERE_OFILES) $(BIN)/vere $(BIN)/eyre
make -C outside/libuv clean
$(MAKE) -C outside/libuv clean

3
extras/extras_README Normal file
View File

@ -0,0 +1,3 @@
Extras Readme
This folder is for all the useful, but not strictly essential, stuff for developers.

View File

@ -0,0 +1,98 @@
;;; hoon-mode.el --- Major mode for editing hoon files for urbit
;; Copyright (C) 2001 Free Software Foundation, Inc.
;; Author: Adam Bliss <abliss@gmail.com>
;; Keywords: extensions
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; This is my first Major Mode, so don't expect much. It's heavily based on
;; SampleMode from the emacs wiki.
;;; Code:
(defvar hoon-mode-hook nil)
(defvar hoon-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-j" 'newline-and-indent)
map)
"Keymap for `hoon-mode'.")
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.hoon$" . hoon-mode))
(defvar hoon-mode-syntax-table
(let ((st (make-syntax-table lisp-mode-syntax-table)))
(modify-syntax-entry ?\' "\"" st)
(modify-syntax-entry ?| "." st)
(modify-syntax-entry ?; "." st)
(modify-syntax-entry ?\" "." st)
(modify-syntax-entry ?: ". 12b" st)
(modify-syntax-entry ?\n "> b" st)
st)
"Syntax table for `hoon-mode'.")
(defvar hoon-font-lock-keywords
'(
("\\+\\+ \\(\\w+\\)" (1 font-lock-function-name-face))
("\\(%\\w+\\)" (1 font-lock-keyword-face))
("\\(\\w+\\)=" (1 font-lock-variable-name-face))
("[=,]\\(\\w+\\|@\\w*\\)" (1 font-lock-type-face))
)
"Keyword highlighting specification for `hoon-mode'.")
(defvar hoon-imenu-generic-expression ".*")
(defvar hoon-outline-regexp ":::")
;;;###autoload
(define-derived-mode hoon-mode fundamental-mode "Hoon"
"A major mode for editing Hoon files."
:syntax-table hoon-mode-syntax-table
(set (make-local-variable 'comment-start) "::")
(set (make-local-variable 'comment-end) "")
(set (make-local-variable 'comment-use-syntax) nil)
(set (make-local-variable 'comment-start-skip) "\\(::+\\)\\s *")
(set (make-local-variable 'font-lock-defaults) '(hoon-font-lock-keywords))
(set (make-local-variable 'indent-line-function) 'hoon-indent-line)
(set (make-local-variable 'imenu-generic-expression)
hoon-imenu-generic-expression)
(set (make-local-variable 'outline-regexp) hoon-outline-regexp)
)
;;; Indentation
(defun hoon-indent-line ()
"Indent current line of Hoon code."
(interactive)
(let ((savep (> (current-column) (current-indentation)))
(indent (condition-case nil (max (hoon-calculate-indentation) 0)
(error 0))))
(if savep
(save-excursion (indent-line-to indent))
(indent-line-to indent))))
(defun hoon-calculate-indentation ()
"Return the column to which the current line should be indented."
0) ;;TODO
(provide 'hoon)
;;; hoon.el ends here

View File

@ -0,0 +1,2 @@
au BufNewfile,BufEnter *.hoon setf hoon

View File

@ -0,0 +1,34 @@
" Public Domain
" Credit Goes to fode
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal indentexpr=HoonIndent(v:lnum)
setlocal nolisp
setlocal autoindent
if exists("*HoonIndent")
finish
endif
function! HoonIndent(lnum)
let prevlnum = prevnonblank(a:lnum-1)
if prevlnum == 0
return 0
endif
let prevl = substitute(getline(prevlnum),'::.*$','','')
let ind = indent(prevlnum)
if prevl =~ '++\s*\w*\s*$'
" luslus operator
let ind += &sw
endif
return ind
endfunction

View File

@ -0,0 +1,170 @@
"hoon.vim: Hoon syntax file
"Credit goes to Fode
"
" With contributions from Philip C Monk
if exists("b:current_syntax")
finish
endif
syn case match
" Declarations
hi def link hoonDeclaration Define
hi def link hoonSymbol Constant
hi def link hoonAtom Identifier
hi def link hoonRune Operator
hi def link hoonIdentifier Identifier
hi def link hoonBranch Conditional
hi def link hoonType Type
hi def link hoonName Constant
hi def link hoonNumber Number
hi def link hoonComment Comment
hi def link hoonTodo Todo
hi def link hoonString String
syn match hoonDeclaration "++" nextgroup=hoonSymbolDec skipwhite
syn match hoonSymbol /%\%(\%(\%(\w\|-\)\+\)\|[|&$]\)/
syn match hoonAtom /@\w*/
syn match hoonName "\w*" contained
syn match hoonSymbolDec "\w*" contained contains=hoonName
" numbers
" Numbers are in decimal, binary, hex, base32, or base64, and they must
" contain dots (optionally followed by whitespace), as in the German manner.
syn sync linebreaks=1
syn match hoonNumber "\d\{1,3\}\%(\.\_s\?\d\{3\}\)*"
syn match hoonNumber "0x\x\{1,4\}\%(\.\_s*\x\{4\}\)*"
syn match hoonNumber "0b[01]\{1,4\}\%(\.\_s*[01]\{4\}\)*"
syn match hoonNumber "0v[0-9a-v]\{1,4\}\%(\.\_s*[0-9a-v]\{4\}\)*"
syn match hoonNumber "0w[-~0-9a-zA-Z]\{1,4\}\%(\.\_s*[-~0-9a-zA-Z]\{4\}\)*"
" comments
syn region hoonComment start="::" end="$" contains=@spell,hoonTodo
syn keyword hoonTodo contained XX XXX TODO FIXME
" strings
syn region hoonString start=+'+ skip=+\\[\\']+ end=+'+ contains=@spell
syn region hoonString start=+"+ skip=+\\[\\"]+ end=+"+ contains=@spell
" match digraphs
syn match hoonRune "||"
syn match hoonRune "|_"
syn match hoonRune "|%"
syn match hoonRune "|:"
syn match hoonRune "|\."
syn match hoonRune "|-"
syn match hoonRune "|\^"
syn match hoonRune "|+"
syn match hoonRune "|\*"
syn match hoonRune "|="
syn match hoonRune "|?"
syn match hoonRune "%_"
syn match hoonRune "%:"
syn match hoonRune "%\."
syn match hoonRune "%\^"
syn match hoonRune "%+"
syn match hoonRune "%-"
syn match hoonRune "%\~"
syn match hoonRune "%\*"
syn match hoonRune "%="
syn match hoonRune "\$|"
syn match hoonRune "\$_"
syn match hoonRune "\$:"
syn match hoonRune "\$%"
syn match hoonRune "\$,"
syn match hoonRune "\$&"
syn match hoonRune "\$?"
syn match hoonRune ":_"
syn match hoonRune ":\~"
syn match hoonRune ":/"
syn match hoonRune ":\^"
syn match hoonRune ":+"
syn match hoonRune ":-"
syn match hoonRune ":\~"
syn match hoonRune ":\*"
syn match hoonRune "\.+"
syn match hoonRune "\.\*"
syn match hoonRune "\.="
syn match hoonRune "\.?"
syn match hoonRune "\.\^"
syn match hoonRune "#<"
syn match hoonRune "#>"
syn match hoonRune "\^|"
syn match hoonRune "\^\."
syn match hoonRune "\^-"
syn match hoonRune "\^+"
syn match hoonRune "\^&"
syn match hoonRune "\^\~"
syn match hoonRune "\^="
syn match hoonRune "\^?"
syn match hoonRune "\~|"
syn match hoonRune "\~\$"
syn match hoonRune "\~%"
syn match hoonRune "\~:"
syn match hoonRune "\~/"
syn match hoonRune "\~<"
syn match hoonRune "\~>"
syn match hoonRune "\~#"
syn match hoonRune "\~\^"
syn match hoonRune "\~+"
syn match hoonRune "\~&"
syn match hoonRune "\~="
syn match hoonRune "\~!"
syn match hoonRune ";_"
syn match hoonRune ";,"
syn match hoonRune ";%"
syn match hoonRune ";:"
syn match hoonRune ";\."
syn match hoonRune ";<"
syn match hoonRune ";>"
syn match hoonRune ";-"
syn match hoonRune ";+"
syn match hoonRune ";&"
syn match hoonRune ";\~"
syn match hoonRune ";;"
syn match hoonRune ";\*"
syn match hoonRune ";="
syn match hoonRune ";?"
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=|"
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=\."
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=\^"
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=:"
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=<"
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=>"
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=-"
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=+"
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=\~"
syn match hoonRune "?|"
syn match hoonRune "?:"
syn match hoonRune "?\."
syn match hoonRune "?<"
syn match hoonRune "?>"
syn match hoonRune "?-"
syn match hoonRune "?\^"
syn match hoonRune "?="
syn match hoonRune "?+"
syn match hoonRune "?&"
syn match hoonRune "?@"
syn match hoonRune "?\~"
syn match hoonRune "?!"
syn match hoonRune "!:"
syn match hoonRune "!,"
syn match hoonRune "!;"
syn match hoonRune "!\^"
syn match hoonRune "!>"
syn match hoonRune "!="
" Not technically runes, but we highlight them like that.
syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=="
syn match hoonRune "--"
let b:current_syntax = "hoon"

View File

@ -126,6 +126,11 @@ u2_cf_flat_date(u2_noun pas)
#elif defined(U2_OS_osx)
return ( ((c3_d)pas_s.st_mtimespec.tv_sec) +
((c3_d)(pas_s.st_mtimespec.tv_nsec / 1000)) );
#elif defined(U2_OS_freebsd)
return ( ((c3_d)pas_s.st_mtim.tv_sec) +
((c3_d)(pas_s.st_mtim.tv_nsec / 1000)) );
#else
#error "port: filetime"
#endif
}
}

View File

@ -284,9 +284,14 @@ u2_loom_save(c3_w ent_w)
#if defined(U2_OS_linux)
fdatasync(ceg_u->ctl_i);
fdatasync(ceg_u->dat_i);
#else
#elif defined(U2_OS_osx)
fcntl(ceg_u->ctl_i, F_FULLFSYNC);
fcntl(ceg_u->dat_i, F_FULLFSYNC);
fcntl(ceg_u->dat_i, F_FULLFSYNC);
#elif defined(U2_OS_freebsd)
fsync(ceg_u->ctl_i);
fsync(ceg_u->dat_i);
#else
#error "port: datasync"
#endif
}

View File

@ -138,6 +138,10 @@ _tx_samp_on(u2_ray rac_r)
sig_s.sa_flags = 0;
#elif defined(U2_OS_linux)
// TODO: support profiling on linux
#elif defined(U2_OS_freebsd)
// TODO: support profiling on freebsd
#else
#error "port: profiling"
#endif
sigaction(SIGPROF, &sig_s, 0);

View File

@ -312,6 +312,12 @@ u2_ux_fresh(const c3_c* paf_c,
(nam_stat.st_mtimespec.tv_sec > nom_stat.st_mtimespec.tv_sec) ||
((nam_stat.st_mtimespec.tv_sec == (nam_stat.st_mtimespec.tv_sec)) &&
(nam_stat.st_mtimespec.tv_nsec > nom_stat.st_mtimespec.tv_nsec))
#elif defined(U2_OS_freebsd)
(nam_stat.st_mtim.tv_sec > nom_stat.st_mtim.tv_sec) ||
((nam_stat.st_mtim.tv_sec == (nom_stat.st_mtim.tv_sec)) &&
(nam_stat.st_mtim.tv_nsec > nom_stat.st_mtim.tv_nsec))
#else
#error "port: file time compare"
#endif
) {
return u2_no;

View File

@ -5,10 +5,12 @@
#include "all.h"
#include "../pit.h"
#if defined(U2_OS_linux)
#if defined(U2_OS_linux) || defined(U2_OS_freebsd)
#include <openssl/sha.h>
#elif defined(U2_OS_osx)
#include <CommonCrypto/CommonDigest.h>
#else
#error "port: sha256"
#endif
/* functions
@ -23,7 +25,7 @@
u2_bytes(0, met_w, fat_y, a);
{
c3_y dig_y[32];
#if defined(U2_OS_linux)
#if defined(U2_OS_linux) || defined(U2_OS_freebsd)
SHA256_CTX ctx_h;
SHA256_Init(&ctx_h);
@ -35,6 +37,8 @@
CC_SHA256_Init(&ctx_h);
CC_SHA256_Update(&ctx_h, fat_y, met_w);
CC_SHA256_Final(dig_y, &ctx_h);
#else
#error "port: sha256"
#endif
return u2_rl_bytes(wir_r, 32, dig_y);
}

View File

@ -47,6 +47,24 @@
# include <sys/resource.h>
# include <sys/mman.h>
# elif defined(U2_OS_freebsd)
# include <stdlib.h>
# include <string.h>
# include <stdarg.h>
# include <unistd.h>
# include <stdint.h>
# include <assert.h>
# include <machine/endian.h>
# include <setjmp.h>
# include <stdio.h>
# include <signal.h>
# include <sys/time.h>
# include <sys/resource.h>
# include <sys/mman.h>
# else
#error "port: headers"
# endif
/** Address space layout.
@ -61,6 +79,15 @@
# define U2_OS_LoomBase 0x4000000
# endif
# define U2_OS_LoomBits 28 // ie, 2^28 words == 1GB
# elif defined(U2_OS_freebsd)
# ifdef __LP64__
# define U2_OS_LoomBase 0x200000000
# else
# define U2_OS_LoomBase 0x4000000
# endif
# define U2_OS_LoomBits 28 // ie, 2^28 words == 1GB
# else
# error "port: LoomBase"
# endif
/** Global variable control.
@ -101,7 +128,7 @@
/* Byte swapping.
*/
# if defined(U2_OS_linux)
# if defined(U2_OS_linux) || defined(U2_OS_freebsd)
# define c3_bswap_16(x) bswap_16(x)
# define c3_bswap_32(x) bswap_32(x)
# define c3_bswap_64(x) bswap_64(x)
@ -110,6 +137,8 @@
# define c3_bswap_16(x) NXSwapShort(x)
# define c3_bswap_32(x) NXSwapInt(x)
# define c3_bswap_64(x) NXSwapLongLong(x)
# else
# error "port: byte swap"
# endif
/* Stat struct
@ -118,4 +147,8 @@
# define c3_stat_mtime(dp) (u2_time_t_in_ts((dp)->st_mtime))
# elif defined(U2_OS_osx)
# define c3_stat_mtime(dp) (u2_time_in_ts(&((dp)->st_mtimespec)))
# elif defined(U2_OS_freebsd)
# define c3_stat_mtime(dp) (u2_time_in_ts(&((dp)->st_mtim)))
# else
# error "port: timeconvert"
# endif

View File

@ -127,8 +127,12 @@ u2_unix_acquire(c3_c* pax_c)
c3_i fid_i = fileno(loq_u);
#if defined(U2_OS_linux)
fdatasync(fid_i);
#else
#elif defined(U2_OS_osx)
fcntl(fid_i, F_FULLFSYNC);
#elif defined(U2_OS_freebsd)
fsync(fid_i);
#else
#error "port: datasync"
#endif
}
fclose(loq_u);