本文整理匯總了Golang中C.int32_t函數的典型用法代碼示例。如果您正苦於以下問題:Golang int32_t函數的具體用法?Golang int32_t怎麽用?Golang int32_t使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了int32_t函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newBuffer
func (w *window) newBuffer(width, height int,
format uint32) *C.struct_wl_buffer {
stride := width * 4
size := stride * height
fd := C.os_create_anonymous_file(C.off_t(size))
if fd < 0 {
panic("Could not create buffer file.")
}
data := C.mmap(nil, C.size_t(size), C.PROT_READ|C.PROT_WRITE,
C.MAP_SHARED, C.int(fd), 0)
if *(*int)(data) == -1 {
panic("mmap failed")
C.close(fd)
return nil
}
pool := C.wl_shm_create_pool(w.display.shm,
C.int32_t(fd), C.int32_t(size))
buffer := C.wl_shm_pool_create_buffer(pool, 0,
C.int32_t(width), C.int32_t(height),
C.int32_t(stride), C.uint32_t(format))
C.wl_shm_pool_destroy(pool)
C.close(fd)
w.shmData = data
return buffer
}
示例2: Open
func (s *SystemPort) Open() error {
if s.isOpen && s.stream == nil {
return errors.New("Underlying portmidi port is already opened, " +
"but stream is not connected to this SystemPort.")
}
if s.id == -1 || s.isOpen { // Fake port or opened already, ignore.
return nil
}
var errNum C.PmError
if s.IsInputPort {
// The input / output naming LOOKS backwards, but we're opening a
// portmidi "output stream" for input Ports and vice versa.
errNum = C.Pm_OpenOutput(&(s.stream), C.PmDeviceID(s.id),
nil, C.int32_t(512), nil, nil, 0)
} else {
errNum = C.Pm_OpenInput(&(s.stream), C.PmDeviceID(s.id),
nil, C.int32_t(512), nil, nil)
}
if errNum == 0 {
s.isOpen = true
s.stop = make(chan bool, 1)
s.noteOns = make(chan Note, BufferSize)
s.noteOffs = make(chan Note, BufferSize)
s.controlChanges = make(chan ControlChange, BufferSize)
}
return makePortMidiError(errNum)
}
示例3: AddInt32
func (hll *Hll) AddInt32(value int32) {
cValue := C.int32_t(value)
cSeed := C.int32_t(0)
cHashKey := C.hll_hash_int32(cValue, cSeed)
C.multiset_add(hll.ms, cHashKey)
}
示例4: c
func (g *Geometry) c() *C.struct_wlc_geometry {
return C.init_geometry(
C.int32_t(g.Origin.X),
C.int32_t(g.Origin.Y),
C.uint32_t(g.Size.W),
C.uint32_t(g.Size.H),
)
}
示例5: New
func New(log2m int, regwidth int, expthresh int64, sparseon int) (*Hll, error) {
cLog2m := C.int32_t(log2m)
cRegwidth := C.int32_t(regwidth)
cExpthresh := C.int64_t(expthresh)
cSparseon := C.int32_t(sparseon)
hll := &Hll{ms: C.hll_empty4(cLog2m, cRegwidth, cExpthresh, cSparseon)}
return hll, nil
}
示例6: redraw
func redraw(data unsafe.Pointer, callback *C.struct_wl_callback,
time C.uint32_t) {
win := (*window)(data)
win.paintPixels(uint32(time))
C.wl_surface_attach(win.surface, win.buffer, 0, 0)
C.wl_surface_damage(win.surface, 0, 0,
C.int32_t(win.width), C.int32_t(win.height))
}
示例7: NewOutputStream
// Initializes a new output stream.
func NewOutputStream(deviceId DeviceId, bufferSize int64, latency int64) (stream *Stream, err error) {
var str *C.PmStream
errCode := C.Pm_OpenOutput(
(*unsafe.Pointer)(unsafe.Pointer(&str)),
C.PmDeviceID(deviceId), nil, C.int32_t(bufferSize), nil, nil, C.int32_t(latency))
if errCode != 0 {
return nil, convertToError(errCode)
}
return &Stream{deviceId: deviceId, pmStream: str}, nil
}
示例8: doICU
func doICU(tag, caser, input string) string {
err := C.UErrorCode(0)
loc := C.CString(tag)
cm := C.ucasemap_open(loc, C.uint32_t(0), &err)
buf := make([]byte, len(input)*4)
dst := (*C.char)(unsafe.Pointer(&buf[0]))
src := C.CString(input)
cn := C.int32_t(0)
switch caser {
case "fold":
cn = C.ucasemap_utf8FoldCase(cm,
dst, C.int32_t(len(buf)),
src, C.int32_t(len(input)),
&err)
case "lower":
cn = C.ucasemap_utf8ToLower(cm,
dst, C.int32_t(len(buf)),
src, C.int32_t(len(input)),
&err)
case "upper":
cn = C.ucasemap_utf8ToUpper(cm,
dst, C.int32_t(len(buf)),
src, C.int32_t(len(input)),
&err)
case "title":
cn = C.ucasemap_utf8ToTitle(cm,
dst, C.int32_t(len(buf)),
src, C.int32_t(len(input)),
&err)
}
return string(buf[:cn])
}
示例9: bind
func (stmt *Stmt) bind(args []driver.Value) error {
c := stmt.c
parameterCount := int(stmt.parameterCount)
if parameterCount == 0 || len(args) == 0 {
return nil
}
parameters := make([]C.struct_nuodb_value, parameterCount)
for i, v := range args {
if i >= parameterCount {
break // go1.0.3 allowed extra args; ignore
}
var vt C.enum_nuodb_value_type
var i32 C.int32_t
var i64 C.int64_t
switch v := v.(type) {
case int64:
vt = C.NUODB_TYPE_INT64
i64 = C.int64_t(v)
case float64:
vt = C.NUODB_TYPE_FLOAT64
i64 = *(*C.int64_t)(unsafe.Pointer(&v))
case bool:
vt = C.NUODB_TYPE_BOOL
if v {
i64 = 1
} else {
i64 = 0
}
case string:
vt = C.NUODB_TYPE_STRING
b := []byte(v)
args[i] = b // ensure the b is not GC'ed before the _bind
i32 = C.int32_t(len(v))
i64 = C.int64_t(uintptr(unsafe.Pointer(&b[0])))
case []byte:
vt = C.NUODB_TYPE_BYTES
i32 = C.int32_t(len(v))
i64 = C.int64_t(uintptr(unsafe.Pointer(&v[0])))
case time.Time:
vt = C.NUODB_TYPE_TIME
i32 = C.int32_t(v.Nanosecond())
i64 = C.int64_t(v.Unix()) // seconds
default:
vt = C.NUODB_TYPE_NULL
}
parameters[i].i64 = i64
parameters[i].i32 = i32
parameters[i].vt = vt
}
if C.nuodb_statement_bind(c.db, stmt.st,
(*C.struct_nuodb_value)(unsafe.Pointer(¶meters[0]))) != 0 {
return c.lastError()
}
return nil
}
示例10: populateCIndexEntry
func populateCIndexEntry(source *IndexEntry, dest *C.git_index_entry) {
dest.ctime.seconds = C.int32_t(source.Ctime.seconds)
dest.ctime.nanoseconds = C.uint32_t(source.Ctime.nanoseconds)
dest.mtime.seconds = C.int32_t(source.Mtime.seconds)
dest.mtime.nanoseconds = C.uint32_t(source.Mtime.nanoseconds)
dest.mode = C.uint32_t(source.Mode)
dest.uid = C.uint32_t(source.Uid)
dest.gid = C.uint32_t(source.Gid)
dest.file_size = C.uint32_t(source.Size)
dest.id = *source.Id.toC()
dest.path = C.CString(source.Path)
}
示例11: Recv
// Recv is called by Java in a loop and blocks until Go requests a callback
// be executed by the JVM. Then a request object is returned, along with a
// handle for the host to respond via RecvRes.
//export Recv
func Recv(in **C.uint8_t, inlen *C.size_t) (ref, code, handle C.int32_t) {
recv.Lock()
for len(recv.req) == 0 {
recv.cond.Wait()
}
req := recv.req[0]
recv.req = recv.req[1:]
seqToBuf(in, inlen, req.in)
recv.Unlock()
return C.int32_t(req.ref.Num), C.int32_t(req.code), C.int32_t(req.handle)
}
示例12: NewOutputStream
// NewOutputStream initializes a new output stream.
func NewOutputStream(id DeviceID, bufferSize int64, latency int64) (stream *Stream, err error) {
var str *C.PmStream
errCode := C.Pm_OpenOutput(
(*unsafe.Pointer)(unsafe.Pointer(&str)),
C.PmDeviceID(id), nil, C.int32_t(bufferSize), nil, nil, C.int32_t(latency))
if errCode != 0 {
return nil, convertToError(errCode)
}
if info := Info(id); !info.IsOutputAvailable {
return nil, ErrOutputUnavailable
}
return &Stream{deviceID: id, pmStream: str}, nil
}
示例13: addInvertedDoc
func (d *DataWriterIMP) addInvertedDoc(inverter Inverter, docId int32) error {
return clownfish.TrapErr(func() {
self := (*C.lucy_DataWriter)(clownfish.Unwrap(d, "d"))
inverterCF := (*C.lucy_Inverter)(clownfish.Unwrap(inverter, "inverter"))
C.LUCY_DataWriter_Add_Inverted_Doc(self, inverterCF, C.int32_t(docId))
})
}
示例14: CreateCloneParams
func CreateCloneParams(filename string, args []string, env *[]string, cwd *string, suid int, stdhandles StdHandles) (*CloneParams, error) {
result := &CloneParams{}
var err error
result.CommReader, result.CommWriter, err = os.Pipe()
if err != nil {
return nil, err
}
result.tls = tools.AlignedBuffer(4096, 16)
result.stack = tools.AlignedBuffer(4096, 16)
result.repr.tls = (*C.char)(unsafe.Pointer(&result.tls[0]))
result.repr.stack = (*C.char)(unsafe.Pointer(&result.stack[len(result.stack)-1]))
result.repr.commfd = C.int32_t(result.CommWriter.Fd())
result.repr.filename = C.CString(filename)
if cwd != nil {
result.repr.cwd = C.CString(*cwd)
}
if args != nil {
result.args = stringsToCchars(args)
result.repr.argv = &result.args[0]
}
if env != nil {
result.env = stringsToCchars(*env)
result.repr.envp = &result.env[0]
}
result.repr.suid = C.uint32_t(suid)
result.stdhandles = stdhandles
result.repr.stdhandles[0] = getFd(result.stdhandles.StdIn)
result.repr.stdhandles[1] = getFd(result.stdhandles.StdOut)
result.repr.stdhandles[2] = getFd(result.stdhandles.StdErr)
runtime.SetFinalizer(result, freeCloneParams)
return result, nil
}
示例15: Serialize
// Serializes a message to OSC wire format.
// If a unsupported type is encountered, serialization
// will be stopped.
func Serialize(m *Message) ([]byte, error) {
msg := C.lo_message_new()
for i, param := range m.Params {
switch x := param.(type) {
case int32:
C.lo_message_add_int32(msg, C.int32_t(x))
case int64:
C.lo_message_add_int64(msg, C.int64_t(x))
case float32:
C.lo_message_add_float(msg, C.float(x))
case float64:
C.lo_message_add_double(msg, C.double(x))
case string:
cstr := C.CString(x)
defer C.free(unsafe.Pointer(cstr))
C.lo_message_add_string(msg, cstr)
default:
return nil, fmt.Errorf("Parameter %d has invalid type", i)
}
}
cpath := C.CString(m.Path)
defer C.free(unsafe.Pointer(cpath))
var size int
tmpbuffer := C.lo_message_serialise(msg, cpath, unsafe.Pointer(nil), (*C.size_t)(unsafe.Pointer((&size))))
defer C.free(unsafe.Pointer(tmpbuffer))
longbuffer := C.GoBytes(tmpbuffer, C.int(size))
shortbuffer := make([]byte, size)
copy(shortbuffer, longbuffer)
return shortbuffer, nil
}