Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Side by Side Diff: go/src/infra/gae/libs/wrapper/unsafe/memcache.go

Issue 1240573002: Reland: Refactor current GAE abstraction library to be free of the SDK* (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: expand coverage range to fit 32bit test expectations Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package unsafe
6
7 import (
8 "time"
9
10 "unsafe"
11
12 "appengine/memcache"
13 )
14
15 // Item is duplicated from appengine/memcache.
16 type Item struct {
17 Key string
18 Value []byte
19 Object interface{}
20 Flags uint32
21 Expiration time.Duration
22 CasID uint64
23 }
24
25 func init() {
26 // we can't actually refer to casID by name, but we can refer to everyth ing
27 // else, and ensure that everything lines up. This should catch an api c hange,
28 // but wouldn't catch something like uint64 -> int64.
29 if unsafe.Sizeof(memcache.Item{}) != unsafe.Sizeof(Item{}) {
30 panic("memcache.Item and Item mismatch sizes")
31 }
32 if unsafe.Offsetof(memcache.Item{}.Key) != unsafe.Offsetof(Item{}.Key) {
33 panic("memcache.Item and Item mismatch Key")
34 }
35 if unsafe.Offsetof(memcache.Item{}.Value) != unsafe.Offsetof(Item{}.Valu e) {
36 panic("memcache.Item and Item mismatch Value")
37 }
38 if unsafe.Offsetof(memcache.Item{}.Object) != unsafe.Offsetof(Item{}.Obj ect) {
39 panic("memcache.Item and Item mismatch Object")
40 }
41 if unsafe.Offsetof(memcache.Item{}.Flags) != unsafe.Offsetof(Item{}.Flag s) {
42 panic("memcache.Item and Item mismatch Flags")
43 }
44 if unsafe.Offsetof(memcache.Item{}.Expiration) != unsafe.Offsetof(Item{} .Expiration) {
45 panic("memcache.Item and Item mismatch Expiration")
46 }
47 }
48
49 // MCSetCasID sets the private .casID field of memcache.Item.
50 func MCSetCasID(i *memcache.Item, val uint64) {
51 mci := (*Item)(unsafe.Pointer(i))
52 mci.CasID = val
53 }
54
55 // MCGetCasID retrieves the private .casID field of memcache.Item.
56 func MCGetCasID(i *memcache.Item) uint64 {
57 return (*Item)(unsafe.Pointer(i)).CasID
58 }
OLDNEW
« no previous file with comments | « go/src/infra/gae/libs/wrapper/unsafe/doc.go ('k') | go/src/infra/gae/libs/wrapper/unsafe/memcache_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698