From patchwork Mon Nov 5 17:36:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 197253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 744402C008E for ; Tue, 6 Nov 2012 04:36:58 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352741820; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=75uOzP5 wp181droGafczZfLlQb0=; b=qBqULOO9UBVUgYCQ0mfK2ZNTRacPhmj0IScRnQ2 MGYah/zqbUVbhpyMq9QyAGiYzfph/PHPej/sPOi/T7zoW7u9el8navVtSd5aECOf 9iicdIu8bX/sy5f+pq4Cw6Eea3b+lB3oyHvXkiMJDYFV77t5q0GZvve5VpLfNSW+ ORlI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=q5SkKvGZdrO67nWnstL0B/Av/8qTvyOWaWTRTL/vg0LQv128PeDfu4kF7Cwzgb I+pJ+KDt3ePSvohi1hyXoCwZ4lLwSOSCa1Caj6053+iEZm9JQOxk5bgDWpVCYCjs tg4EO5jhpiOsehLz/J6j+E6vaa0OKKUsWUyUVlM6UWLoE=; Received: (qmail 23112 invoked by alias); 5 Nov 2012 17:36:52 -0000 Received: (qmail 22970 invoked by uid 22791); 5 Nov 2012 17:36:50 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Nov 2012 17:36:46 +0000 Received: by mail-pb0-f47.google.com with SMTP id ro12so3872091pbb.20 for ; Mon, 05 Nov 2012 09:36:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=dizW5AS4anvEOVWl6AAM6OWQMK6nGQCGZ/LOxzFpjuw=; b=oiePp+2K41h9M+cdm0rSPXW9JsckF1MI1fKdixoE0NEorFHXSGtVRUBYidYHw88bTV j1pg72+rU3eE59zAwBUSOY49/WXQfwqpHryCR7gZTNnkIj4fEiwoyFIn3ztTc1/EFt3P xIpFomcIAa1kBVo96/vC8ro2krx5LZ1pS4xGvpVobxo8Oqq0gLBvxNWEG+YpF5t6lXPE kLPeLX8faRIejWNsoz4LC4pSjBsbOUeOLMcQEAG1/nyQx4/RYEgR1ZCYBuHGlI5Ubw98 pQK2QUamMcpyDYlGBwisZS25TEBz+gxPX1jzZ7HYdS2XQUa/RMHGg3Udq0rwCJb+B/78 csJw== Received: by 10.68.193.163 with SMTP id hp3mr32125640pbc.21.1352137005344; Mon, 05 Nov 2012 09:36:45 -0800 (PST) Received: from coign.google.com ([172.19.244.148]) by mx.google.com with ESMTPS id se4sm10868622pbb.13.2012.11.05.09.36.44 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Nov 2012 09:36:44 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed Date: Mon, 05 Nov 2012 09:36:43 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlbWe/AceqdPef8onyfS5+JhQIuxxKfSlZxduduYWi/+DS96xxdhSagGNOPInNHuNRg2QCmkkdGfxV0h1Twml+uqxnsG03W0Owvu2nw892vkcLKfSOgqvCnHe2/fC7hbPuci4uqwuEm0FChdoIiETJ4K29t8beCw+6M7dOL/j5ajgobHT6zikXxMGWjiR6yKlFuuh/L X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch from Shenghou Ma supports the os.Stat function on some more operating systems. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 5d8ca2f79dba libgo/Makefile.am --- a/libgo/Makefile.am Fri Nov 02 16:37:20 2012 -0700 +++ b/libgo/Makefile.am Mon Nov 05 09:33:12 2012 -0800 @@ -829,8 +829,28 @@ if LIBGO_IS_SOLARIS go_os_stat_file = go/os/stat_solaris.go else +if LIBGO_IS_LINUX +go_os_stat_file = go/os/stat_atim.go +else +if LIBGO_IS_OPENBSD +go_os_stat_file = go/os/stat_atim.go +else +if LIBGO_IS_DARWIN +go_os_stat_file = go/os/stat_atimspec.go +else +if LIBGO_IS_FREEBSD +go_os_stat_file = go/os/stat_atimspec.go +else +if LIBGO_IS_NETBSD +go_os_stat_file = go/os/stat_atimspec.go +else go_os_stat_file = go/os/stat.go endif +endif +endif +endif +endif +endif go_os_files = \ $(go_os_dir_file) \ diff -r 5d8ca2f79dba libgo/go/os/stat_atim.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/go/os/stat_atim.go Mon Nov 05 09:33:12 2012 -0800 @@ -0,0 +1,61 @@ +// Copyright 2009 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. + +package os + +import ( + "syscall" + "time" +) + +func sameFile(sys1, sys2 interface{}) bool { + stat1 := sys1.(*syscall.Stat_t) + stat2 := sys2.(*syscall.Stat_t) + return stat1.Dev == stat2.Dev && stat1.Ino == stat2.Ino +} + +func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo { + fs := &fileStat{ + name: basename(name), + size: int64(st.Size), + modTime: timespecToTime(st.Mtim), + sys: st, + } + fs.mode = FileMode(st.Mode & 0777) + switch st.Mode & syscall.S_IFMT { + case syscall.S_IFBLK: + fs.mode |= ModeDevice + case syscall.S_IFCHR: + fs.mode |= ModeDevice | ModeCharDevice + case syscall.S_IFDIR: + fs.mode |= ModeDir + case syscall.S_IFIFO: + fs.mode |= ModeNamedPipe + case syscall.S_IFLNK: + fs.mode |= ModeSymlink + case syscall.S_IFREG: + // nothing to do + case syscall.S_IFSOCK: + fs.mode |= ModeSocket + } + if st.Mode&syscall.S_ISGID != 0 { + fs.mode |= ModeSetgid + } + if st.Mode&syscall.S_ISUID != 0 { + fs.mode |= ModeSetuid + } + if st.Mode&syscall.S_ISVTX != 0 { + fs.mode |= ModeSticky + } + return fs +} + +func timespecToTime(ts syscall.Timespec) time.Time { + return time.Unix(int64(ts.Sec), int64(ts.Nsec)) +} + +// For testing. +func atime(fi FileInfo) time.Time { + return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) +} diff -r 5d8ca2f79dba libgo/go/os/stat_atimespec.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/go/os/stat_atimespec.go Mon Nov 05 09:33:12 2012 -0800 @@ -0,0 +1,61 @@ +// Copyright 2009 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. + +package os + +import ( + "syscall" + "time" +) + +func sameFile(sys1, sys2 interface{}) bool { + stat1 := sys1.(*syscall.Stat_t) + stat2 := sys2.(*syscall.Stat_t) + return stat1.Dev == stat2.Dev && stat1.Ino == stat2.Ino +} + +func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo { + fs := &fileStat{ + name: basename(name), + size: int64(st.Size), + modTime: timespecToTime(st.Mtimspec), + sys: st, + } + fs.mode = FileMode(st.Mode & 0777) + switch st.Mode & syscall.S_IFMT { + case syscall.S_IFBLK: + fs.mode |= ModeDevice + case syscall.S_IFCHR: + fs.mode |= ModeDevice | ModeCharDevice + case syscall.S_IFDIR: + fs.mode |= ModeDir + case syscall.S_IFIFO: + fs.mode |= ModeNamedPipe + case syscall.S_IFLNK: + fs.mode |= ModeSymlink + case syscall.S_IFREG: + // nothing to do + case syscall.S_IFSOCK: + fs.mode |= ModeSocket + } + if st.Mode&syscall.S_ISGID != 0 { + fs.mode |= ModeSetgid + } + if st.Mode&syscall.S_ISUID != 0 { + fs.mode |= ModeSetuid + } + if st.Mode&syscall.S_ISVTX != 0 { + fs.mode |= ModeSticky + } + return fs +} + +func timespecToTime(ts syscall.Timespec) time.Time { + return time.Unix(int64(ts.Sec), int64(ts.Nsec)) +} + +// For testing. +func atime(fi FileInfo) time.Time { + return timespecToTime(fi.Sys().(*syscall.Stat_t).Atimspec) +} diff -r 5d8ca2f79dba libgo/go/os/stat_openbsd.go --- a/libgo/go/os/stat_openbsd.go Fri Nov 02 16:37:20 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -// Copyright 2009 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. - -package os - -import ( - "syscall" - "time" -) - -func sameFile(sys1, sys2 interface{}) bool { - stat1 := sys1.(*syscall.Stat_t) - stat2 := sys2.(*syscall.Stat_t) - return stat1.Dev == stat2.Dev && stat1.Ino == stat2.Ino -} - -func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo { - fs := &fileStat{ - name: basename(name), - size: int64(st.Size), - modTime: timespecToTime(st.Mtim), - sys: st, - } - fs.mode = FileMode(st.Mode & 0777) - switch st.Mode & syscall.S_IFMT { - case syscall.S_IFBLK: - fs.mode |= ModeDevice - case syscall.S_IFCHR: - fs.mode |= ModeDevice | ModeCharDevice - case syscall.S_IFDIR: - fs.mode |= ModeDir - case syscall.S_IFIFO: - fs.mode |= ModeNamedPipe - case syscall.S_IFLNK: - fs.mode |= ModeSymlink - case syscall.S_IFREG: - // nothing to do - case syscall.S_IFSOCK: - fs.mode |= ModeSocket - } - if st.Mode&syscall.S_ISGID != 0 { - fs.mode |= ModeSetgid - } - if st.Mode&syscall.S_ISUID != 0 { - fs.mode |= ModeSetuid - } - if st.Mode&syscall.S_ISVTX != 0 { - fs.mode |= ModeSticky - } - return fs -} - -func timespecToTime(ts syscall.Timespec) time.Time { - return time.Unix(int64(ts.Sec), int64(ts.Nsec)) -} - -// For testing. -func atime(fi FileInfo) time.Time { - return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) -}