Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(325)

Delta Between Two Patch Sets: misc/cgo/testtls/tls.go

Issue 7578043: cgo: Add test for TLS in -hostobj mode (Closed)
Left Patch Set: Created 11 years ago
Right Patch Set: diff -r fa13899da667 https://go.googlecode.com/hg/ Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | misc/cgo/testtls/tls_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2013 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 cgotlstest
6
7 // #include <pthread.h>
8 // extern void setTLS(int);
9 // extern int getTLS();
10 import "C"
11
12 import (
13 "runtime"
14 "testing"
15 )
16
17 func testTLS(t *testing.T) {
18 var keyVal C.int = 1234
19
20 runtime.LockOSThread()
21 defer runtime.UnlockOSThread()
22 C.setTLS(C.int(keyVal))
23 storedVal := C.getTLS()
24
25 if storedVal != keyVal {
26 t.Fatalf("stored %d want %d", storedVal, keyVal)
27 }
28 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b