Merge pull request #59 from harshavardhana/pr_out_no_caps_for_stdint

No caps for stdint
master
Harshavardhana 10 years ago
commit 0c16744e2c
  1. 40
      pkgs/erasure/ctypes.go
  2. 20
      pkgs/erasure/stdint.go

@ -24,35 +24,35 @@ import (
// Integer to Int conversion // Integer to Int conversion
func int2cInt(src_err_list []int) *C.int { func int2cInt(src_err_list []int) *C.int {
var SrcErrInt = int(unsafe.Sizeof(src_err_list[0])) var sizeErrInt = int(unsafe.Sizeof(src_err_list[0]))
switch SizeInt { switch sizeInt {
case SrcErrInt: case sizeErrInt:
return (*C.int)(unsafe.Pointer(&src_err_list[0])) return (*C.int)(unsafe.Pointer(&src_err_list[0]))
case SizeInt8: case sizeInt8:
Int8Array := make([]int8, len(src_err_list)) int8Array := make([]int8, len(src_err_list))
for i, v := range src_err_list { for i, v := range src_err_list {
Int8Array[i] = int8(v) int8Array[i] = int8(v)
} }
return (*C.int)(unsafe.Pointer(&Int8Array[0])) return (*C.int)(unsafe.Pointer(&int8Array[0]))
case SizeInt16: case sizeInt16:
Int16Array := make([]int16, len(src_err_list)) int16Array := make([]int16, len(src_err_list))
for i, v := range src_err_list { for i, v := range src_err_list {
Int16Array[i] = int16(v) int16Array[i] = int16(v)
} }
return (*C.int)(unsafe.Pointer(&Int16Array[0])) return (*C.int)(unsafe.Pointer(&int16Array[0]))
case SizeInt32: case sizeInt32:
Int32Array := make([]int32, len(src_err_list)) int32Array := make([]int32, len(src_err_list))
for i, v := range src_err_list { for i, v := range src_err_list {
Int32Array[i] = int32(v) int32Array[i] = int32(v)
} }
return (*C.int)(unsafe.Pointer(&Int32Array[0])) return (*C.int)(unsafe.Pointer(&int32Array[0]))
case SizeInt64: case sizeInt64:
Int64Array := make([]int64, len(src_err_list)) int64Array := make([]int64, len(src_err_list))
for i, v := range src_err_list { for i, v := range src_err_list {
Int64Array[i] = int64(v) int64Array[i] = int64(v)
} }
return (*C.int)(unsafe.Pointer(&Int64Array[0])) return (*C.int)(unsafe.Pointer(&int64Array[0]))
default: default:
panic(fmt.Sprintf("Unsupported: %d", SizeInt)) panic(fmt.Sprintf("Unsupported: %d", sizeInt))
} }
} }

@ -17,7 +17,7 @@
package erasure package erasure
// //
// int SizeInt() // int sizeInt()
// { // {
// return sizeof(int); // return sizeof(int);
// } // }
@ -28,21 +28,21 @@ var (
// See http://golang.org/ref/spec#Numeric_types // See http://golang.org/ref/spec#Numeric_types
// SizeUint8 is the byte size of a uint8. // SizeUint8 is the byte size of a uint8.
SizeUint8 = int(unsafe.Sizeof(uint8(0))) sizeUint8 = int(unsafe.Sizeof(uint8(0)))
// SizeUint16 is the byte size of a uint16. // SizeUint16 is the byte size of a uint16.
SizeUint16 = int(unsafe.Sizeof(uint16(0))) sizeUint16 = int(unsafe.Sizeof(uint16(0)))
// SizeUint32 is the byte size of a uint32. // SizeUint32 is the byte size of a uint32.
SizeUint32 = int(unsafe.Sizeof(uint32(0))) sizeUint32 = int(unsafe.Sizeof(uint32(0)))
// SizeUint64 is the byte size of a uint64. // SizeUint64 is the byte size of a uint64.
SizeUint64 = int(unsafe.Sizeof(uint64(0))) sizeUint64 = int(unsafe.Sizeof(uint64(0)))
SizeInt = int(C.SizeInt()) sizeInt = int(C.sizeInt())
// SizeInt8 is the byte size of a int8. // SizeInt8 is the byte size of a int8.
SizeInt8 = int(unsafe.Sizeof(int8(0))) sizeInt8 = int(unsafe.Sizeof(int8(0)))
// SizeInt16 is the byte size of a int16. // SizeInt16 is the byte size of a int16.
SizeInt16 = int(unsafe.Sizeof(int16(0))) sizeInt16 = int(unsafe.Sizeof(int16(0)))
// SizeInt32 is the byte size of a int32. // SizeInt32 is the byte size of a int32.
SizeInt32 = int(unsafe.Sizeof(int32(0))) sizeInt32 = int(unsafe.Sizeof(int32(0)))
// SizeInt64 is the byte size of a int64. // SizeInt64 is the byte size of a int64.
SizeInt64 = int(unsafe.Sizeof(int64(0))) sizeInt64 = int(unsafe.Sizeof(int64(0)))
) )

Loading…
Cancel
Save