From 01d15ca3b256246e91d27aa1bfd933035017a82c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 23 Jan 2015 19:33:37 -0800 Subject: [PATCH] Implement crc32c for Darwin, update documentation --- BUILDDEPS.md | 5 ++- Makefile | 7 ---- README.md | 2 +- pkg/utils/checksum/crc32c/crc32c_darwin.go | 35 +++++++++++++++++++ .../crc32c/{crc32c.go => crc32c_linux.go} | 0 .../{crc32c_amd64.S => crc32c_linux_amd64.S} | 0 6 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 pkg/utils/checksum/crc32c/crc32c_darwin.go rename pkg/utils/checksum/crc32c/{crc32c.go => crc32c_linux.go} (100%) rename pkg/utils/checksum/crc32c/{crc32c_amd64.S => crc32c_linux_amd64.S} (100%) diff --git a/BUILDDEPS.md b/BUILDDEPS.md index b243ae355..1935aec57 100644 --- a/BUILDDEPS.md +++ b/BUILDDEPS.md @@ -50,9 +50,9 @@ This installation document assumes Mac OSX Yosemite 10.10 or later on x86-64 pla $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ``` -##### Install Git and GCC +##### Install Git ```sh -$ brew install git gcc +$ brew install git ``` ##### Install YASM @@ -64,7 +64,6 @@ $ brew install yasm ``` ##### Install Go 1.4+ - On MacOSX ``brew.sh`` is the best way to install golang For example: diff --git a/Makefile b/Makefile index 80ab9e08c..524d83516 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ #GOPATH := $(CURDIR)/tmp/gopath MAKE_OPTIONS := -s ARCH := $(shell uname -s) -GCCVERSIONGTEQ4 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 4) all: getdeps install @@ -20,13 +19,7 @@ build-utils: @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/utils/crypto/sha1 @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/utils/crypto/sha256 @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/utils/crypto/sha512 -ifeq ($(ARCH), Darwin) -ifeq ($(GCCVERSIONGTEQ4), "1") @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/utils/checksum/crc32c -endif -else - @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/utils/checksum/crc32c -endif #build-os: # @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/os/scsi diff --git a/README.md b/README.md index 903ae6d20..4ec628572 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Minio's design is inspired by Amazon's S3 for its API and Facebook's Haystack fo | ------------- | ------------- | | Linux | Yes | | Windows | Not yet | -| Mac OSX | Yes(with GCC) | +| Mac OSX | Yes | ### Supported architectures diff --git a/pkg/utils/checksum/crc32c/crc32c_darwin.go b/pkg/utils/checksum/crc32c/crc32c_darwin.go new file mode 100644 index 000000000..a1e706e92 --- /dev/null +++ b/pkg/utils/checksum/crc32c/crc32c_darwin.go @@ -0,0 +1,35 @@ +/* + * Mini Object Storage, (C) 2014 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +build amd64 + +package crc32c + +import ( + "errors" + "hash/crc32" +) + +var castanagoliTable = crc32.MakeTable(crc32.Castagnoli) + +func Crc32c(buffer []byte) (uint32, error) { + crc := crc32.New(castanagoliTable) + if len(buffer) <= 0 { + return 0, errors.New("input buffer cannot be null") + } + crc.Write(buffer) + return crc.Sum32(), nil +} diff --git a/pkg/utils/checksum/crc32c/crc32c.go b/pkg/utils/checksum/crc32c/crc32c_linux.go similarity index 100% rename from pkg/utils/checksum/crc32c/crc32c.go rename to pkg/utils/checksum/crc32c/crc32c_linux.go diff --git a/pkg/utils/checksum/crc32c/crc32c_amd64.S b/pkg/utils/checksum/crc32c/crc32c_linux_amd64.S similarity index 100% rename from pkg/utils/checksum/crc32c/crc32c_amd64.S rename to pkg/utils/checksum/crc32c/crc32c_linux_amd64.S