diff --git a/container/intsets/popcnt_gccgo.go b/container/intsets/popcnt_gccgo.go new file mode 100644 index 0000000000..82a8875c85 --- /dev/null +++ b/container/intsets/popcnt_gccgo.go @@ -0,0 +1,9 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build gccgo + +package intsets + +func popcount(x word) int diff --git a/container/intsets/popcnt_gccgo_c.c b/container/intsets/popcnt_gccgo_c.c new file mode 100644 index 0000000000..08abb32ec4 --- /dev/null +++ b/container/intsets/popcnt_gccgo_c.c @@ -0,0 +1,19 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build gccgo + +#include +#include +#include + +#define _STRINGIFY2_(x) #x +#define _STRINGIFY_(x) _STRINGIFY2_(x) +#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) + +extern intptr_t popcount(uintptr_t x) __asm__(GOSYM_PREFIX GOPKGPATH ".popcount"); + +intptr_t popcount(uintptr_t x) { + return __builtin_popcountl((unsigned long)(x)); +} diff --git a/container/intsets/popcnt_generic.go b/container/intsets/popcnt_generic.go index 682e2f53a4..3985a1da1a 100644 --- a/container/intsets/popcnt_generic.go +++ b/container/intsets/popcnt_generic.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !amd64 appengine gccgo +// +build !amd64 appengine +// +build !gccgo package intsets