Merge commit '13412ca164f715e89e0eb156599ce5f6e978205c' as 'contrib/linenoise'

master
Harshavardhana 10 years ago
commit be262e7539
  1. 0
      contrib/erasure/.gitignore
  2. 0
      contrib/erasure/LICENSE
  3. 0
      contrib/erasure/LICENSE.INTEL
  4. 0
      contrib/erasure/Makefile
  5. 0
      contrib/erasure/Makefile.nmake
  6. 0
      contrib/erasure/README.md
  7. 0
      contrib/erasure/RELEASE-NOTES.INTEL
  8. 0
      contrib/erasure/docs/isa-l_open_src_2.10.pdf
  9. 0
      contrib/erasure/include/ec-base.h
  10. 0
      contrib/erasure/include/erasure-code.h
  11. 0
      contrib/erasure/include/erasure/tests.h
  12. 0
      contrib/erasure/include/erasure/types.h
  13. 0
      contrib/erasure/include/gf-vect-mul.h
  14. 0
      contrib/erasure/include/reg-sizes.asm
  15. 0
      contrib/erasure/make.inc
  16. 0
      contrib/erasure/src/Makefile
  17. 0
      contrib/erasure/src/ec-base.c
  18. 0
      contrib/erasure/src/ec-highlevel-func.c
  19. 0
      contrib/erasure/src/ec-multibinary.asm
  20. 0
      contrib/erasure/src/erasure-code-base-perf.c
  21. 0
      contrib/erasure/src/erasure-code-base-test.c
  22. 0
      contrib/erasure/src/erasure-code-perf.c
  23. 0
      contrib/erasure/src/erasure-code-sse-perf.c
  24. 0
      contrib/erasure/src/erasure-code-sse-test.c
  25. 0
      contrib/erasure/src/erasure-code-test.c
  26. 0
      contrib/erasure/src/gf-2vect-dot-prod-avx.asm
  27. 0
      contrib/erasure/src/gf-2vect-dot-prod-avx2.asm
  28. 0
      contrib/erasure/src/gf-2vect-dot-prod-sse-perf.c
  29. 0
      contrib/erasure/src/gf-2vect-dot-prod-sse-test.c
  30. 0
      contrib/erasure/src/gf-2vect-dot-prod-sse.asm
  31. 0
      contrib/erasure/src/gf-3vect-dot-prod-avx.asm
  32. 0
      contrib/erasure/src/gf-3vect-dot-prod-avx2.asm
  33. 0
      contrib/erasure/src/gf-3vect-dot-prod-sse-perf.c
  34. 0
      contrib/erasure/src/gf-3vect-dot-prod-sse-test.c
  35. 0
      contrib/erasure/src/gf-3vect-dot-prod-sse.asm
  36. 0
      contrib/erasure/src/gf-4vect-dot-prod-avx.asm
  37. 0
      contrib/erasure/src/gf-4vect-dot-prod-avx2.asm
  38. 0
      contrib/erasure/src/gf-4vect-dot-prod-sse-perf.c
  39. 0
      contrib/erasure/src/gf-4vect-dot-prod-sse-test.c
  40. 0
      contrib/erasure/src/gf-4vect-dot-prod-sse.asm
  41. 0
      contrib/erasure/src/gf-5vect-dot-prod-avx.asm
  42. 0
      contrib/erasure/src/gf-5vect-dot-prod-avx2.asm
  43. 0
      contrib/erasure/src/gf-5vect-dot-prod-sse-perf.c
  44. 0
      contrib/erasure/src/gf-5vect-dot-prod-sse-test.c
  45. 0
      contrib/erasure/src/gf-5vect-dot-prod-sse.asm
  46. 0
      contrib/erasure/src/gf-6vect-dot-prod-avx.asm
  47. 0
      contrib/erasure/src/gf-6vect-dot-prod-avx2.asm
  48. 0
      contrib/erasure/src/gf-6vect-dot-prod-sse-perf.c
  49. 0
      contrib/erasure/src/gf-6vect-dot-prod-sse-test.c
  50. 0
      contrib/erasure/src/gf-6vect-dot-prod-sse.asm
  51. 0
      contrib/erasure/src/gf-inverse-test.c
  52. 0
      contrib/erasure/src/gf-vect-dot-prod-1tbl.c
  53. 0
      contrib/erasure/src/gf-vect-dot-prod-avx-perf.c
  54. 0
      contrib/erasure/src/gf-vect-dot-prod-avx-test.c
  55. 0
      contrib/erasure/src/gf-vect-dot-prod-avx.asm
  56. 0
      contrib/erasure/src/gf-vect-dot-prod-avx2.asm
  57. 0
      contrib/erasure/src/gf-vect-dot-prod-base-test.c
  58. 0
      contrib/erasure/src/gf-vect-dot-prod-perf.c
  59. 0
      contrib/erasure/src/gf-vect-dot-prod-sse-perf.c
  60. 0
      contrib/erasure/src/gf-vect-dot-prod-sse-test.c
  61. 0
      contrib/erasure/src/gf-vect-dot-prod-sse.asm
  62. 0
      contrib/erasure/src/gf-vect-dot-prod-test.c
  63. 0
      contrib/erasure/src/gf-vect-mul-avx-perf.c
  64. 0
      contrib/erasure/src/gf-vect-mul-avx-test.c
  65. 0
      contrib/erasure/src/gf-vect-mul-avx.asm
  66. 0
      contrib/erasure/src/gf-vect-mul-base-test.c
  67. 0
      contrib/erasure/src/gf-vect-mul-perf.c
  68. 0
      contrib/erasure/src/gf-vect-mul-sse-perf.c
  69. 0
      contrib/erasure/src/gf-vect-mul-sse-test.c
  70. 0
      contrib/erasure/src/gf-vect-mul-sse.asm
  71. 0
      contrib/erasure/src/gf-vect-mul-test.c
  72. 2
      contrib/linenoise/.gitignore
  73. 22
      contrib/linenoise/LICENSE
  74. 14
      contrib/linenoise/README.md
  75. 11
      contrib/linenoise/doc.go
  76. 112
      contrib/linenoise/examplenoise/examplenoise.go
  77. 1105
      contrib/linenoise/linenoise.c
  78. 142
      contrib/linenoise/linenoise.go
  79. 66
      contrib/linenoise/linenoise.h
  80. 8
      contrib/linenoise/linenoiseCompletionCallbackHook.c
  81. 5
      contrib/linenoise/linenoiseCompletionCallbackHook.h
  82. 8
      contrib/linenoise/windows.go

@ -0,0 +1,2 @@
*sublime*
/examplenoise/examplenoise

@ -0,0 +1,22 @@
Copyright (c) 2013, Geert-Johan Riemer
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@ -0,0 +1,14 @@
## go.linenoise
go.linenoise is a [go](http://golang.org) package wrapping the [linenoise](https://github.com/antirez/linenoise) C library.
This package does not compile on windows.
### Documentation
Documentation can be found at [godoc.org/github.com/GeertJohan/go.linenoise](http://godoc.org/github.com/GeertJohan/go.linenoise).
An example is located in the folder [examplenoise](examplenoise).
### License
All code in this repository is licensed under a BSD license.
This project wraps [linenoise](https://github.com/antirez/linenoise) which is written by Salvatore Sanfilippo and Pieter Noordhuis. The license for linenoise is included in the files `linenoise.c` and `linenoise.h`.
For all other files please read the [LICENSE](LICENSE) file.

@ -0,0 +1,11 @@
// Package linenoise wraps the linenoise library (https://github.com/antirez/linenoise).
//
// The package is imported with "go." prefix
// import "github.com/GeertJohan/go.linenoise"
//
// Simple readline usage:
// linenoise.Line("prompt> ")
//
// Adding lines to history, you could simply do this for every line you read.
// linenoise.AddHistory("This will be displayed in prompt when arrow-up is pressed")
package linenoise

@ -0,0 +1,112 @@
package main
import (
"fmt"
"github.com/GeertJohan/go.linenoise"
"os"
"strings"
)
func main() {
fmt.Println("Welcome to go.linenoise example.")
writeHelp()
for {
str, err := linenoise.Line("prompt> ")
if err != nil {
if err == linenoise.KillSignalError {
quit()
}
fmt.Println("Unexpected error: %s", err)
quit()
}
fields := strings.Fields(str)
// check if there is any valid input at all
if len(fields) == 0 {
writeUnrecognized()
continue
}
// switch on the command
switch fields[0] {
case "help":
writeHelp()
case "echo":
fmt.Printf("echo: %s\n\n", str[5:])
case "clear":
linenoise.Clear()
case "multiline":
fmt.Println("Setting linenoise to multiline")
linenoise.SetMultiline(true)
case "singleline":
fmt.Println("Setting linenoise to singleline")
linenoise.SetMultiline(false)
case "complete":
fmt.Println("Setting arguments as completion values for linenoise.")
fmt.Printf("%d arguments: %s\n", len(fields)-1, fields[1:])
completionHandler := func(in string) []string {
return fields[1:]
}
linenoise.SetCompletionHandler(completionHandler)
case "printKeyCodes":
linenoise.PrintKeyCodes()
case "addHistory":
if len(str) < 12 {
fmt.Println("No argument given.")
}
err := linenoise.AddHistory(str[11:])
if err != nil {
fmt.Printf("Error: %s\n", err)
}
case "save":
if len(fields) != 2 {
fmt.Println("Error. Expecting 'save <filename>'.")
continue
}
err := linenoise.SaveHistory(fields[1])
if err != nil {
fmt.Printf("Error on save: %s\n", err)
}
case "load":
if len(fields) != 2 {
fmt.Println("Error. Expecting 'load <filename>'.")
continue
}
err := linenoise.LoadHistory(fields[1])
if err != nil {
fmt.Printf("Error on load: %s\n", err)
}
case "quit":
quit()
default:
writeUnrecognized()
}
}
}
func quit() {
fmt.Println("Thanks for running the go.linenoise example.")
fmt.Println("")
os.Exit(0)
}
func writeHelp() {
fmt.Println("help write this message")
fmt.Println("echo ... echo the arguments")
fmt.Println("clear clear the screen")
fmt.Println("multiline set linenoise to multiline")
fmt.Println("singleline set linenoise to singleline")
fmt.Println("complete ... set arguments as completion values")
fmt.Println("addHistory ... add arguments to linenoise history")
fmt.Println("save <filename> save the history to file")
fmt.Println("load <filename> load the history from file")
fmt.Println("quit stop the program")
fmt.Println("")
fmt.Println("Use the arrow up and down keys to walk through history.")
fmt.Println("Note that you have to use addHistory to create history entries. Commands are not added to history in this example.")
fmt.Println("")
}
func writeUnrecognized() {
fmt.Println("Unrecognized command. Use 'help'.")
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,142 @@
package linenoise
// -windows
// #include <stdlib.h>
// #include "linenoise.h"
// #include "linenoiseCompletionCallbackHook.h"
import "C"
import (
"errors"
"unsafe"
)
// KillSignalError is returned returned by Line() when a user quits from prompt.
// This occurs when the user enters ctrl+C or ctrl+D.
var KillSignalError = errors.New("prompt was quited with a killsignal")
func init() {
C.linenoiseSetupCompletionCallbackHook()
}
// Line displays given string and returns line from user input.
func Line(prompt string) (string, error) { // char *linenoise(const char *prompt);
promptCString := C.CString(prompt)
resultCString := C.linenoise(promptCString)
C.free(unsafe.Pointer(promptCString))
defer C.free(unsafe.Pointer(resultCString))
if resultCString == nil {
return "", KillSignalError
}
result := C.GoString(resultCString)
return result, nil
}
// AddHistory adds a line to history. Returns non-nil error on fail.
func AddHistory(line string) error { // int linenoiseHistoryAdd(const char *line);
lineCString := C.CString(line)
res := C.linenoiseHistoryAdd(lineCString)
C.free(unsafe.Pointer(lineCString))
if res != 1 {
return errors.New("Could not add line to history.")
}
return nil
}
// SetHistoryCapacity changes the maximum length of history. Returns non-nil error on fail.
func SetHistoryCapacity(capacity int) error { // int linenoiseHistorySetMaxLen(int len);
res := C.linenoiseHistorySetMaxLen(C.int(capacity))
if res != 1 {
return errors.New("Could not set history max len.")
}
return nil
}
// SaveHistory saves from file with given filename. Returns non-nil error on fail.
func SaveHistory(filename string) error { // int linenoiseHistorySave(char *filename);
filenameCString := C.CString(filename)
res := C.linenoiseHistorySave(filenameCString)
C.free(unsafe.Pointer(filenameCString))
if res != 0 {
return errors.New("Could not save history to file.")
}
return nil
}
// LoadHistory loads from file with given filename. Returns non-nil error on fail.
func LoadHistory(filename string) error { // int linenoiseHistoryLoad(char *filename);
filenameCString := C.CString(filename)
res := C.linenoiseHistoryLoad(filenameCString)
C.free(unsafe.Pointer(filenameCString))
if res != 0 {
return errors.New("Could not load history from file.")
}
return nil
}
// Clear clears the screen.
func Clear() { // void linenoiseClearScreen(void);
C.linenoiseClearScreen()
}
// SetMultiline sets linenoise to multiline or single line.
// In multiline mode the user input will be wrapped to a new line when the length exceeds the amount of available rows in the terminal.
func SetMultiline(ml bool) { // void linenoiseSetMultiLine(int ml);
if ml {
C.linenoiseSetMultiLine(1)
} else {
C.linenoiseSetMultiLine(0)
}
}
// CompletionHandler provides possible completions for given input
type CompletionHandler func(input string) []string
// DefaultCompletionHandler simply returns an empty slice.
var DefaultCompletionHandler = func(input string) []string {
return make([]string, 0)
}
var complHandler = DefaultCompletionHandler
// SetCompletionHandler sets the CompletionHandler to be used for completion
func SetCompletionHandler(c CompletionHandler) {
complHandler = c
}
// typedef struct linenoiseCompletions {
// size_t len;
// char **cvec;
// } linenoiseCompletions;
// typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
// void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
// void linenoiseAddCompletion(linenoiseCompletions *, char *);
//export linenoiseGoCompletionCallbackHook
func linenoiseGoCompletionCallbackHook(input *C.char, completions *C.linenoiseCompletions) {
completionsSlice := complHandler(C.GoString(input))
completionsLen := len(completionsSlice)
completions.len = C.size_t(completionsLen)
if completionsLen > 0 {
cvec := C.malloc(C.size_t(int(unsafe.Sizeof(*(**C.char)(nil))) * completionsLen))
cvecSlice := (*(*[999999]*C.char)(cvec))[:completionsLen]
for i, str := range completionsSlice {
cvecSlice[i] = C.CString(str)
}
completions.cvec = (**C.char)(cvec)
}
}
// PrintKeyCodes puts linenoise in key codes debugging mode.
// Press keys and key combinations to see key codes. Type 'quit' at any time to exit.
// PrintKeyCodes blocks until user enters 'quit'.
func PrintKeyCodes() { // void linenoisePrintKeyCodes(void);
C.linenoisePrintKeyCodes()
}

@ -0,0 +1,66 @@
/* linenoise.h -- guerrilla line editing library against the idea that a
* line editing lib needs to be 20,000 lines of C code.
*
* See linenoise.c for more information.
*
* ------------------------------------------------------------------------
*
* Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
* Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __LINENOISE_H
#define __LINENOISE_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct linenoiseCompletions {
size_t len;
char **cvec;
} linenoiseCompletions;
typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
void linenoiseAddCompletion(linenoiseCompletions *, const char *);
char *linenoise(const char *prompt);
int linenoiseHistoryAdd(const char *line);
int linenoiseHistorySetMaxLen(int len);
int linenoiseHistorySave(const char *filename);
int linenoiseHistoryLoad(const char *filename);
void linenoiseClearScreen(void);
void linenoiseSetMultiLine(int ml);
void linenoisePrintKeyCodes(void);
#ifdef __cplusplus
}
#endif
#endif /* __LINENOISE_H */

@ -0,0 +1,8 @@
#include "linenoiseCompletionCallbackHook.h"
extern void linenoiseGoCompletionCallbackHook(const char *, linenoiseCompletions *);
void linenoiseSetupCompletionCallbackHook() {
linenoiseSetCompletionCallback(linenoiseGoCompletionCallbackHook);
}

@ -0,0 +1,5 @@
#include <stdlib.h>
#include "linenoise.h"
void linenoiseSetupCompletionCallbackHook();

@ -0,0 +1,8 @@
package linenoise
// #include <stdlib.h>
// #include "linenoise.h"
import "C"
// this will break a go build on windows and display the string on console
"go.linenoise does not support windows."
Loading…
Cancel
Save