]> Cypherpunks.ru repositories - gostls13.git/blob - src/cmd/cgo/internal/testcshared/testdata/libgo5/libgo5.go
misc/cgo: move easy tests to cmd/cgo/internal
[gostls13.git] / src / cmd / cgo / internal / testcshared / testdata / libgo5 / libgo5.go
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package main
6
7 import "C"
8
9 import (
10         "os"
11         "os/signal"
12         "syscall"
13         "time"
14 )
15
16 // The channel used to read SIGIO signals.
17 var sigioChan chan os.Signal
18
19 // CatchSIGIO starts catching SIGIO signals.
20 //
21 //export CatchSIGIO
22 func CatchSIGIO() {
23         sigioChan = make(chan os.Signal, 1)
24         signal.Notify(sigioChan, syscall.SIGIO)
25 }
26
27 // ResetSIGIO stops catching SIGIO signals.
28 //
29 //export ResetSIGIO
30 func ResetSIGIO() {
31         signal.Reset(syscall.SIGIO)
32 }
33
34 // SawSIGIO returns whether we saw a SIGIO within a brief pause.
35 //
36 //export SawSIGIO
37 func SawSIGIO() C.int {
38         select {
39         case <-sigioChan:
40                 return 1
41         case <-time.After(100 * time.Millisecond):
42                 return 0
43         }
44 }
45
46 func main() {
47 }