// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. //go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) package sqlite3 import ( "unsafe" "modernc.org/libc" ) // C documentation // // /* // ** Functions to converts degrees to radians and radians to degrees. // */ func _degToRad(tls *libc.TLS, x float64) (r float64) { return float64(x * (libc.Float64FromFloat64(3.141592653589793) / libc.Float64FromFloat64(180))) } // C documentation // // /* // ** Compute the area enclosed by the polygon. // ** // ** This routine can also be used to detect polygons that rotate in // ** the wrong direction. Polygons are suppose to be counter-clockwise (CCW). // ** This routine returns a negative value for clockwise (CW) polygons. // */ func _geopolyArea(tls *libc.TLS, p uintptr) (r float64) { var ii int32 var rArea float64 _, _ = ii, rArea rArea = float64(0) ii = 0 for { if !(ii < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex-int32(1)) { break } rArea = rArea + float64(float64((**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4))-**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr((ii+int32(1))*int32(2))*4)))*(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4))+**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr((ii+int32(1))*int32(2)+int32(1))*4))))*float64(0.5)) goto _1 _1: ; ii = ii + 1 } rArea = rArea + float64(float64((**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4))-**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4)))*(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4))+**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4))))*float64(0.5)) return rArea } // C documentation // // /* Fast approximation for sine(X) for X between -0.5*pi and 2*pi // */ func _geopolySine(tls *libc.TLS, r float64) (r1 float64) { var r2, r3, r5 float64 _, _, _ = r2, r3, r5 if r >= float64(libc.Float64FromFloat64(1.5)*libc.Float64FromFloat64(3.141592653589793)) { r = r - float64(libc.Float64FromFloat64(2)*libc.Float64FromFloat64(3.141592653589793)) } if r >= float64(libc.Float64FromFloat64(0.5)*libc.Float64FromFloat64(3.141592653589793)) { return -_geopolySine(tls, r-float64(3.141592653589793)) } else { r2 = float64(r * r) r3 = float64(r2 * r) r5 = float64(r3 * r2) return float64(float64(0.9996949)*r) - float64(float64(0.16567)*r3) + float64(float64(0.0075134)*r5) } return r1 } // C documentation // // /* // ** Determine if point (x0,y0) is beneath line segment (x1,y1)->(x2,y2). // ** Returns: // ** // ** +2 x0,y0 is on the line segment // ** // ** +1 x0,y0 is beneath line segment // ** // ** 0 x0,y0 is not on or beneath the line segment or the line segment // ** is vertical and x0,y0 is not on the line segment // ** // ** The left-most coordinate min(x1,x2) is not considered to be part of // ** the line segment for the purposes of this analysis. // */ func _pointBeneathLine(tls *libc.TLS, x0 float64, y0 float64, x1 float64, y1 float64, x2 float64, y2 float64) (r int32) { var y float64 _ = y if x0 == x1 && y0 == y1 { return int32(2) } if x1 < x2 { if x0 <= x1 || x0 > x2 { return 0 } } else { if x1 > x2 { if x0 <= x2 || x0 > x1 { return 0 } } else { /* Vertical line segment */ if x0 != x1 { return 0 } if y0 < y1 && y0 < y2 { return 0 } if y0 > y1 && y0 > y2 { return 0 } return int32(2) } } y = y1 + float64((y2-y1)*(x0-x1))/(x2-x1) if y0 == y { return int32(2) } if y0 < y { return int32(1) } return 0 } func _radToDeg(tls *libc.TLS, x float64) (r float64) { return float64(x * (libc.Float64FromFloat64(180) / libc.Float64FromFloat64(3.141592653589793))) } // C documentation // // /* // ** Convert an sqlite3_value into an RtreeValue (presumably a float) // ** while taking care to round toward negative or positive, respectively. // */ func _rtreeValueDown(tls *libc.TLS, v uintptr) (r TRtreeValue) { var d, v1 float64 var f float32 _, _, _ = d, f, v1 d = Xsqlite3_value_double(tls, v) f = float32(d) if float64(f) > d { if d < libc.Float64FromInt32(0) { v1 = libc.Float64FromFloat64(1) + libc.Float64FromFloat64(1)/libc.Float64FromFloat64(8.388608e+06) } else { v1 = libc.Float64FromFloat64(1) - libc.Float64FromFloat64(1)/libc.Float64FromFloat64(8.388608e+06) } f = float32(float64(d * v1)) } return f } func _rtreeValueUp(tls *libc.TLS, v uintptr) (r TRtreeValue) { var d, v1 float64 var f float32 _, _, _ = d, f, v1 d = Xsqlite3_value_double(tls, v) f = float32(d) if float64(f) < d { if d < libc.Float64FromInt32(0) { v1 = libc.Float64FromFloat64(1) - libc.Float64FromFloat64(1)/libc.Float64FromFloat64(8.388608e+06) } else { v1 = libc.Float64FromFloat64(1) + libc.Float64FromFloat64(1)/libc.Float64FromFloat64(8.388608e+06) } f = float32(float64(d * v1)) } return f } func _sqlite3OsCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) (r int32) { bp := tls.Alloc(16) defer tls.Free(16) var rc int32 var _ /* r at bp+0 */ float64 _ = rc /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64() ** method to get the current date and time if that method is available ** (if iVersion is 2 or greater and the function pointer is not NULL) and ** will fall back to xCurrentTime() if xCurrentTimeInt64() is ** unavailable. */ if (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion >= int32(2) && (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTimeInt64 != 0 { rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTimeInt64})))(tls, pVfs, pTimeOut) } else { rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTime})))(tls, pVfs, bp) **(**Tsqlite3_int64)(__ccgo_up(pTimeOut)) = int64(float64(**(**float64)(__ccgo_up(bp)) * libc.Float64FromFloat64(8.64e+07))) } return rc }