Example #1
0
func (c *Encoder) encodeVideo(f *Frame) *Packet {
	f.avframe.pts = C.int64_t(f.Pts.Time)
	for i := 0; i < f.frame_count; i++ {
		f.avframe.pts = C.int64_t(c.last_dts)
		esize := avcodec_encode_video(&c.Ctx, c.buffer, &c.buffer_size, f)
		c.last_dts++
		if esize > 0 {
			var result Packet //=new(Packet)
			av_init_packet(&result)
			result.Size = esize
			result.Data = make([]byte, esize+8)
			for i := 0; i < esize; i++ {
				result.Data[i] = c.buffer[i]
			}

			result.Stream = c.stream_index
			result.Duration = Timestamp{int64(c.Ctx.ctx.ticks_per_frame), Rational{int(c.Ctx.ctx.time_base.num), int(c.Ctx.ctx.time_base.den)}}
			result.Flags = 0
			if c.Ctx.ctx.coded_frame != nil {
				if c.Ctx.ctx.coded_frame.key_frame == 1 {
					result.Flags |= 0x0001
				}
				result.Pts = Timestamp{int64(c.Ctx.ctx.coded_frame.pts), Rational{int(c.Ctx.ctx.time_base.num), int(c.Ctx.ctx.time_base.den)}}
				result.Dts = Timestamp{int64(c.last_dts), Rational{int(c.Ctx.ctx.time_base.num), int(c.Ctx.ctx.time_base.den)}}
				if c.Track != nil {
					c.Track.WritePacket(&result)
				}
			}
		}
	}
	return nil
}
Example #2
0
func (this *FmtCtx) SeekFile(ist *Stream, minTs, maxTs int64, flag int) error {
	if ret := int(C.avformat_seek_file(this.avCtx, C.int(ist.Index()), C.int64_t(0), C.int64_t(minTs), C.int64_t(maxTs), C.int(flag))); ret < 0 {
		return errors.New(fmt.Sprintf("Error creating output context: %s", AvError(ret)))
	}

	return nil
}
Example #3
0
// Open creates options and opens the database. If the database
// doesn't yet exist at the specified directory, one is initialized
// from scratch. The RocksDB Open and Close methods are reference
// counted such that subsequent Open calls to an already opened
// RocksDB instance only bump the reference count. The RocksDB is only
// closed when a sufficient number of Close calls are performed to
// bring the reference count down to 0.
func (r *RocksDB) Open() error {
	if r.rdb != nil {
		return nil
	}

	if len(r.dir) != 0 {
		log.Infof("opening rocksdb instance at %q", r.dir)
	}
	status := C.DBOpen(&r.rdb, goToCSlice([]byte(r.dir)),
		C.DBOptions{
			cache_size:      C.int64_t(r.cacheSize),
			memtable_budget: C.int64_t(r.memtableBudget),
			allow_os_buffer: C.bool(true),
			logging_enabled: C.bool(log.V(3)),
		})
	err := statusToError(status)
	if err != nil {
		return util.Errorf("could not open rocksdb instance: %s", err)
	}

	// Start a gorountine that will finish when the underlying handle
	// is deallocated. This is used to check a leak in tests.
	go func() {
		<-r.deallocated
	}()
	r.stopper.AddCloser(r)
	return nil
}
Example #4
0
func (m *Muxer) routine() {
	vFrame := C.alloc_video_frame(m.videoStream.stream.codec)
	if vFrame == (*C.AVFrame)(null) {
		m.done <- true
		return
	}
	aFrame := C.alloc_audio_frame(m.audioStream.stream.codec)
	if aFrame == (*C.AVFrame)(null) {
		m.done <- true
		return
	}
	for m.loop {
		if C.av_compare_ts(C.int64_t(m.videoStream.ts), m.videoStream.stream.codec.time_base,
			C.int64_t(m.audioStream.ts), m.audioStream.stream.codec.time_base) <= 0 {
			m.writeVideoFrame(vFrame)
		} else {
			m.writeAudioFrame(aFrame)
		}
		time.Sleep(time.Millisecond * 30)
	}
	if vFrame != (*C.AVFrame)(null) {
		C.av_frame_free(&vFrame)
	}
	if aFrame != (*C.AVFrame)(null) {
		C.av_frame_free(&aFrame)
	}
	m.done <- true
}
Example #5
0
//export myseek
func myseek(archive *C.struct_archive, client_data unsafe.Pointer, request C.int64_t, whence C.int) C.int64_t {
	reader := (*Reader)(client_data)
	offset, err := reader.reader.Seek(int64(request), int(whence))
	if err != nil {
		return C.int64_t(0)
	}
	return C.int64_t(offset)
}
Example #6
0
// valueToXpc converts a go Value to an xpc object
//
// note that not all the types are supported, but only the subset required for Blued
func valueToXpc(val r.Value) C.xpc_object_t {
	if !val.IsValid() {
		return nil
	}

	var xv C.xpc_object_t

	switch val.Kind() {
	case r.Int, r.Int8, r.Int16, r.Int32, r.Int64:
		xv = C.xpc_int64_create(C.int64_t(val.Int()))

	case r.Uint, r.Uint8, r.Uint16, r.Uint32:
		xv = C.xpc_int64_create(C.int64_t(val.Uint()))

	case r.String:
		xv = C.xpc_string_create(C.CString(val.String()))

	case r.Map:
		xv = C.xpc_dictionary_create(nil, nil, 0)
		for _, k := range val.MapKeys() {
			v := valueToXpc(val.MapIndex(k))
			C.xpc_dictionary_set_value(xv, C.CString(k.String()), v)
			if v != nil {
				C.xpc_release(v)
			}
		}

	case r.Array, r.Slice:
		if val.Type() == TYPE_OF_UUID {
			// array of bytes
			var uuid [16]byte
			r.Copy(r.ValueOf(uuid[:]), val)
			xv = C.xpc_uuid_create(C.ptr_to_uuid(unsafe.Pointer(&uuid[0])))
		} else if val.Type() == TYPE_OF_BYTES {
			// slice of bytes
			xv = C.xpc_data_create(unsafe.Pointer(val.Pointer()), C.size_t(val.Len()))
		} else {
			xv = C.xpc_array_create(nil, 0)
			l := val.Len()

			for i := 0; i < l; i++ {
				v := valueToXpc(val.Index(i))
				C.xpc_array_append_value(xv, v)
				if v != nil {
					C.xpc_release(v)
				}
			}
		}

	case r.Interface, r.Ptr:
		xv = valueToXpc(val.Elem())

	default:
		log.Fatalf("unsupported %#v", val.String())
	}

	return xv
}
Example #7
0
func (client *Client) convertSet(set interface{}) (*C.char, C.size_t, C.enum_hyperdatatype, error) {
	C_ds_set := C.hyperdex_ds_allocate_set(client.arena)
	var C_ds_status C.enum_hyperdex_ds_returncode

	switch vals := set.(type) {
	case Set:
		for _, val := range vals {
			t := reflect.TypeOf(val)
			v := reflect.ValueOf(val)
			switch t.Kind() {
			case reflect.String:
				C_string := C.CString(v.String())
				C_size_t := C.size_t(v.Len())
				C.hyperdex_ds_set_insert_string(C_ds_set,
					C_string, C_size_t, &C_ds_status)
			case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32,
				reflect.Int64:
				C.hyperdex_ds_set_insert_int(C_ds_set,
					C.int64_t(v.Int()), &C_ds_status)
			case reflect.Float32, reflect.Float64:
				C.hyperdex_ds_set_insert_float(C_ds_set,
					C.double(v.Float()), &C_ds_status)
			default:
				return nil, 0, 0, fmt.Errorf("Unsupported type within set %s", t.String())
			}
			if C_ds_status != C.HYPERDEX_DS_SUCCESS {
				return nil, 0, 0, fmt.Errorf("DS error: %d", C_ds_status)
			}
		}

	case SetStr:
		for _, val := range vals {
			C_string := C.CString(val)
			C_size_t := C.size_t(bytesOf(val))
			C.hyperdex_ds_set_insert_string(C_ds_set,
				C_string, C_size_t, &C_ds_status)
		}

	case SetI64:
		for _, val := range vals {
			C.hyperdex_ds_set_insert_int(C_ds_set,
				C.int64_t(val), &C_ds_status)
		}

	case SetF64:
		for _, val := range vals {
			C.hyperdex_ds_set_insert_float(C_ds_set,
				C.double(val), &C_ds_status)
		}
	}

	var C_string *C.char
	var C_size_t C.size_t
	var C_datatype C.enum_hyperdatatype
	C.hyperdex_ds_set_finalize(C_ds_set, &C_ds_status,
		&C_string, &C_size_t, &C_datatype)
	return C_string, C_size_t, C_datatype, nil
}
Example #8
0
File: cache.go Project: yubo/falcon
// called by rpc
func (p *cacheEntry) put(item *specs.RrdItem) {
	p.Lock()
	defer p.Unlock()
	p.e.lastTs = C.int64_t(item.TimeStemp)
	idx := p.e.dataId & CACHE_SIZE_MASK
	p.e.time[idx] = C.int64_t(item.TimeStemp)
	p.e.value[idx] = C.double(item.Value)
	p.e.dataId += 1
}
Example #9
0
func (fh *FileHandleIMP) Window(window FileWindow, offset, length int64) error {
	self := (*C.lucy_FileHandle)(clownfish.Unwrap(fh, "fh"))
	windowC := (*C.lucy_FileWindow)(clownfish.Unwrap(window, "window"))
	success := C.LUCY_FH_Window(self, windowC, C.int64_t(offset), C.int64_t(length))
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
Example #10
0
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(&parameters[0]))) != 0 {
		return c.lastError()
	}
	return nil
}
Example #11
0
func (in *InStreamIMP) Reopen(fileName string, offset int64, length int64) (InStream, error) {
	var retval InStream
	err := clownfish.TrapErr(func() {
		self := (*C.lucy_InStream)(clownfish.Unwrap(in, "in"))
		fileNameCF := (*C.cfish_String)(clownfish.GoToClownfish(fileName, unsafe.Pointer(C.CFISH_STRING), true))
		defer C.cfish_decref(unsafe.Pointer(fileNameCF))
		retvalCF := C.LUCY_InStream_Reopen(self, fileNameCF,
			C.int64_t(offset), C.int64_t(length))
		retval = WRAPInStream(unsafe.Pointer(retvalCF))
	})
	return retval, err
}
Example #12
0
func node_to_go(node *C.mpv_node) (interface{}, error) {
	switch node.format {
	case FormatFlag:
		if C.node_get_int64(node) != 0 {
			return true, nil
		} else {
			return false, nil
		}

	case FormatInt64:
		value := C.node_get_int64(node)
		return int64(value), nil

	case FormatDouble:
		value := C.node_get_double(node)
		return float64(value), nil

	case FormatString:
		value := C.node_get_string(node)
		return C.GoString(value), nil

	case FormatNodeArray:
		var value []interface{}

		for i := C.int64_t(0); i < C.node_get_map_len(node); i++ {
			cval := C.node_get_map_val(node, i)

			val, _ := node_to_go(cval)

			value = append(value, val)
		}

		return value, nil

	case FormatNodeMap:
		value := map[string]interface{}{}

		for i := C.int64_t(0); i < C.node_get_map_len(node); i++ {
			ckey := C.node_get_map_key(node, i)
			cval := C.node_get_map_val(node, i)

			key := C.GoString(ckey)
			val, _ := node_to_go(cval)

			value[key] = val
		}

		return value, nil
	}

	return nil, fmt.Errorf("Unsupported type")
}
Example #13
0
// 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
}
Example #14
0
// Open creates options and opens the database. If the database
// doesn't yet exist at the specified directory, one is initialized
// from scratch. The RocksDB Open and Close methods are reference
// counted such that subsequent Open calls to an already opened
// RocksDB instance only bump the reference count. The RocksDB is only
// closed when a sufficient number of Close calls are performed to
// bring the reference count down to 0.
func (r *RocksDB) Open() error {
	if r.rdb != nil {
		atomic.AddInt32(&r.refcount, 1)
		return nil
	}

	if len(r.dir) == 0 {
		log.Infof("opening in-memory rocksdb instance")
	} else {
		log.Infof("opening rocksdb instance at %q", r.dir)
	}
	status := C.DBOpen(&r.rdb, goToCSlice([]byte(r.dir)),
		C.DBOptions{
			cache_size:      C.int64_t(r.cacheSize),
			allow_os_buffer: C.bool(true),
			logging_enabled: C.bool(log.V(3)),
		})
	err := statusToError(status)
	if err != nil {
		return util.Errorf("could not open rocksdb instance: %s", err)
	}

	atomic.AddInt32(&r.refcount, 1)
	return nil
}
func av_rescale_q(time int64, src, trg Rational) int64 {
	var a C.AVRational = C.AVRational{C.int(src.Num), C.int(src.Den)}
	var b C.AVRational = C.AVRational{C.int(trg.Num), C.int(trg.Den)}

	cresult := C.av_rescale_q(C.int64_t(time), a, b)
	return int64(cresult)
}
Example #16
0
func goToCKey(key MVCCKey) C.DBKey {
	return C.DBKey{
		key:       goToCSlice(key.Key),
		wall_time: C.int64_t(key.Timestamp.WallTime),
		logical:   C.int32_t(key.Timestamp.Logical),
	}
}
Example #17
0
//////////////////////////
//      写入接口        //
//////////////////////////
func Store(table *Table,
	primary_key string, // key after encode
	timestamp int64,
	index_list []Index,
	data_list []string) error {
	var c_request C.mdt_store_request_t
	var c_response C.mdt_store_response_t

	// convert request
	c_request.primary_key.data = C.CString(primary_key)
	c_request.primary_key.size = C.size_t(len(primary_key))
	c_request.timestamp = C.int64_t(timestamp)

	c_request.index_list = nil
	c_request.index_list_len = C.size_t(len(index_list))
	c_request.index_list = (*C.mdt_index_t)(C.malloc(32 * c_request.index_list_len))
	c_index_list := (*[1 << 30]C.mdt_index_t)(unsafe.Pointer(c_request.index_list))
	for i := C.size_t(0); i < c_request.index_list_len; i++ {
		c_index_list[i].index_name.data = C.CString(index_list[i].IndexName)
		c_index_list[i].index_name.size = C.size_t(len(index_list[i].IndexName))
		c_index_list[i].index_key.data = C.CString(index_list[i].IndexKey)
		c_index_list[i].index_key.size = C.size_t(len(index_list[i].IndexKey))
	}

	// new vector write interface
	c_request.data_list = nil
	c_request.data_list_len = C.size_t(data_list)
	c_request.data_list = (*C.mdt_slice_t)(C.malloc(16 * c_request.data_list_len))
	c_data_list := (*[1 << 30]C.mdt_slice_t)(unsafe.Pointer(c_request.data_list))
	for i := C.size_t(0); i < c_request.data_list_len; data_i++ {
		c_data_list[i].data = C.CString(data_list[i])
		c_data_list[i].size = C.size_t(len(data_list[i]))
	}
	// old write interface
	//c_request.data.data = C.CString(data)
	//c_request.data.size = C.size_t(len(data))

	// invoke C API
	C.mdt_store(table.rep, &c_request, &c_response, nil, nil)

	// convert result
	err := int(c_response.error)

	// free request memory
	C.free(unsafe.Pointer(c_request.primary_key.data))

	for i := C.size_t(0); i < c_request.index_list_len; i++ {
		C.free(unsafe.Pointer(c_index_list[i].index_name.data))
		C.free(unsafe.Pointer(c_index_list[i].index_key.data))
	}
	C.free(unsafe.Pointer(c_request.index_list))

	for i := C.size_t(0); i < c_request.data_list_len; i++ {
		C.free(unsafe.Pointer(c_data_list[i].data))
	}
	C.free(unsafe.Pointer(c_request.data_list))
	//C.free(unsafe.Pointer(c_request.data.data))

	return GetError(err)
}
Example #18
0
func (soc *Socket) setInt64(opt C.int, value int64) error {
	val := C.int64_t(value)
	if i, err := C.zmq_setsockopt(soc.soc, opt, unsafe.Pointer(&val), C.size_t(unsafe.Sizeof(val))); i != 0 {
		return errget(err)
	}
	return nil
}
Example #19
0
// DefineVariable defines a named variable for use by the compiler.
// Boolean, int64, float64, and string types are supported.
func (r *Rules) DefineVariable(name string, value interface{}) (err error) {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	switch value.(type) {
	case bool:
		var v int
		if value.(bool) {
			v = 1
		}
		err = newError(C.yr_rules_define_boolean_variable(
			r.cptr, cname, C.int(v)))
	case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
		value := toint64(value)
		err = newError(C.yr_rules_define_integer_variable(
			r.cptr, cname, C.int64_t(value)))
	case float64:
		err = newError(C.yr_rules_define_float_variable(
			r.cptr, cname, C.double(value.(float64))))
	case string:
		cvalue := C.CString(value.(string))
		defer C.free(unsafe.Pointer(cvalue))
		err = newError(C.yr_rules_define_string_variable(
			r.cptr, cname, cvalue))
	default:
		err = errors.New("wrong value type passed to DefineVariable; bool, int64, float64, string are accepted")
	}
	return
}
Example #20
0
func (b *bitBuffer) PutBitsAt(bits int, data int64, offset int) error {
	r := C.xmmsv_bitbuffer_put_bits_at(b.data, C.int(bits), C.int64_t(data), C.int(offset))
	if int(r) == 0 {
		return fmt.Errorf("Put %d bits with %d to 0x%h, failed", bits, data, offset)
	}
	return nil
}
Example #21
0
func (this *Option) Set(ctx interface{}) {
	ckey := C.CString(this.Key)
	defer C.free(unsafe.Pointer(ckey))

	var ret int = 0

	switch t := this.Val.(type) {
	case int:
		ret = int(C.av_opt_set_int(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, C.int64_t(this.Val.(int)), 0))

	case SampleFmt:
		ret = int(C.av_opt_set_sample_fmt(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, (int32)(this.Val.(SampleFmt)), 0))

	case float64:
		ret = int(C.av_opt_set_double(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, (C.double)(this.Val.(float64)), 0))

	case AVR:
		ret = int(C.av_opt_set_q(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, C.AVRational(this.Val.(AVR).AVRational()), 0))

	case []byte:
		ret = int(C.av_opt_set_bin(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, (*C.uint8_t)(unsafe.Pointer(&this.Val.([]byte)[0])), C.int(len(ctx.([]byte))), 0))

	case *Dict:
		ret = int(C.av_opt_set_dict(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), &this.Val.(*Dict).avDict))

	default:
		log.Println("unsupported type:", t)
	}

	if ret < 0 {
		log.Printf("unable to set key '%s' value '%d', error: %s\n", this.Key, this.Val.(int), AvError(int(ret)))
	}
}
Example #22
0
func (b *bitBuffer) PutBits(bits int, data int64) error {
	r := C.xmmsv_bitbuffer_put_bits(b.data, C.int(bits), C.int64_t(data))
	if int(r) == 0 {
		return fmt.Errorf("Put %d bits with %d failed", bits, data)
	}
	return nil
}
Example #23
0
func (soc *Socket) getInt64(opt C.int) (int64, error) {
	value := C.int64_t(0)
	size := C.size_t(unsafe.Sizeof(value))
	if i, err := C.zmq_getsockopt(soc.soc, opt, unsafe.Pointer(&value), &size); i != 0 {
		return 0, errget(err)
	}
	return int64(value), nil
}
Example #24
0
func (hll *Hll) AddInt64(value int64) {
	cValue := C.int64_t(value)
	cSeed := C.int32_t(0)

	cHashKey := C.hll_hash_int64(cValue, cSeed)

	C.multiset_add(hll.ms, cHashKey)
}
Example #25
0
File: git.go Project: fsouza/gogit
// SetInt64 is used to add a int64 setting to the config file.
//
// The format of the configuration parameter is the same as in GetBool. If the
// parameter is not declared in the config file, it will be created.
func (c *Config) SetInt64(name string, value int64) error {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	if C.git_config_set_int64(c.config, cname, C.int64_t(value)) != C.GIT_OK {
		return lastErr()
	}
	return nil
}
Example #26
0
// Keep the Object alive when it refence by JS
func (v *Value) setOwner(self interface{}) {
	// the object reference by engine
	if v.fieldOwnerId == 0 {
		v.engine.fieldOwnerId += 1
		v.fieldOwnerId = v.engine.fieldOwnerId
		v.engine.fieldOwners[v.fieldOwnerId] = self
		C.V8_Value_SetFieldOwnerInfo(v.self, unsafe.Pointer(v.engine), C.int64_t(v.fieldOwnerId))
	}
}
Example #27
0
// FromInt64 returns a Quad from a int64 value.
//
// No error should occur, and context status will not change.
//
func (context *Context) FromInt64(value int64) (r Quad) {
	var result C.Ret_decQuad_t
	assert_sane(context)

	result = C.mdq_from_int64(C.int64_t(value), context.set)

	context.set = result.set
	return Quad{val: result.val}
}
Example #28
0
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
}
Example #29
0
func (cfg *Config) SetInt64(name string, value int64) error {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	cvalue := C.int64_t(value)
	ecode := C.git_config_set_int64(cfg.git_config, cname, cvalue)
	if ecode != git_SUCCESS {
		return gitError()
	}
	return nil
}
Example #30
0
func (kc *KCDB) IncrInt(key []byte, amount int64) (result int64, err error) {
	ckey := (*C.char)(unsafe.Pointer(&key[0]))
	cresult := C.kcdbincrint(kc.db, ckey, C.size_t(len(key)), C.int64_t(amount), 0.0)
	if cresult == C.INT64_MIN {
		err = kc.error()
	} else {
		result = int64(cresult)
	}
	return
}