mirror of
https://github.com/glebarez/go-sqlite.git
synced 2025-10-10 18:20:24 +08:00
Regenerate Linux/amd64 using latest CCGO.
modified: generator.go modified: internal/bin/bin_linux_amd64.go modified: internal/mptest/mptest_linux_amd64.go modified: internal/threadtest1/threadtest1_linux_amd64.go modified: internal/threadtest2/threadtest2_linux_amd64.go modified: internal/threadtest3/threadtest3_linux_amd64.go modified: internal/threadtest4/threadtest4_linux_amd64.go
This commit is contained in:
44
generator.go
44
generator.go
@@ -56,8 +56,9 @@ const (
|
||||
%s
|
||||
*/
|
||||
|
||||
// Package sqlite is an in-process implementation of a self-contained,
|
||||
// serverless, zero-configuration, transactional SQL database engine. (Work In Progress)
|
||||
%s
|
||||
|
||||
package bin
|
||||
|
||||
import (
|
||||
@@ -82,8 +83,8 @@ func Xsqlite3PendingByte() int32 { return _sqlite3PendingByte }
|
||||
|
||||
prologueTest = `// Code generated by ccgo. DO NOT EDIT.
|
||||
|
||||
// %s
|
||||
%s
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -356,7 +357,6 @@ func header(f string) []byte {
|
||||
var s scanner.Scanner
|
||||
s.Init(token.NewFileSet().AddFile(f, -1, len(b)), b, nil, scanner.ScanComments)
|
||||
var buf buffer.Bytes
|
||||
fmt.Fprintf(&buf, "/* %s */", filepath.Base(f))
|
||||
for {
|
||||
_, tok, lit := s.Scan()
|
||||
switch tok {
|
||||
@@ -370,24 +370,18 @@ func header(f string) []byte {
|
||||
}
|
||||
|
||||
func tidyComment(s string) string {
|
||||
if strings.HasPrefix(s, "/*") {
|
||||
s = s[len("/*") : len(s)-len("*/")]
|
||||
}
|
||||
a := strings.Split(strings.TrimSpace(s), "\n")
|
||||
for i, v := range a {
|
||||
if strings.HasPrefix(v, "** ") {
|
||||
a[i] = a[i][len("** "):]
|
||||
continue
|
||||
}
|
||||
|
||||
if v == "**" {
|
||||
a[i] = ""
|
||||
switch {
|
||||
case strings.HasPrefix(s, "/*"):
|
||||
a := strings.Split("/"+s[1:len(s)-1], "\n")
|
||||
for i, v := range a {
|
||||
a[i] = "// " + v
|
||||
}
|
||||
return strings.Join(a, "\n") + "/\n"
|
||||
case strings.HasPrefix(s, "//"):
|
||||
return "// " + s[2:] + "\n"
|
||||
default:
|
||||
panic("internal error")
|
||||
}
|
||||
for i, v := range a {
|
||||
a[i] = strings.TrimSpace(v)
|
||||
}
|
||||
return "// " + strings.Join(a, "\n// ") + "\n"
|
||||
}
|
||||
|
||||
func tidyComments(b []byte) string {
|
||||
@@ -430,7 +424,7 @@ func sqlite() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(&b, prologueSqlite, lic, tidyComments(header(sqlite3)))
|
||||
fmt.Fprintf(&b, prologueSqlite, lic, strings.TrimSpace(tidyComments(header(sqlite3))))
|
||||
macros(&b, asta[0])
|
||||
b.Write(src)
|
||||
b2, err := format.Source(b.Bytes())
|
||||
@@ -472,7 +466,7 @@ func mpTest() {
|
||||
)
|
||||
|
||||
var b bytes.Buffer
|
||||
fmt.Fprintf(&b, prologueTest, tidyComments(header(test)))
|
||||
fmt.Fprintf(&b, prologueTest, tag, strings.TrimSpace(tidyComments(header(test))))
|
||||
b.Write(src)
|
||||
b2, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
@@ -518,7 +512,7 @@ func threadTest1() {
|
||||
)
|
||||
|
||||
var b bytes.Buffer
|
||||
fmt.Fprintf(&b, prologueTest, tidyComments(header(test)))
|
||||
fmt.Fprintf(&b, prologueTest, tag, strings.TrimSpace(tidyComments(header(test))))
|
||||
b.Write(src)
|
||||
b2, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
@@ -563,7 +557,7 @@ func threadTest2() {
|
||||
)
|
||||
|
||||
var b bytes.Buffer
|
||||
fmt.Fprintf(&b, prologueTest, tidyComments(header(test)))
|
||||
fmt.Fprintf(&b, prologueTest, tag, strings.TrimSpace(tidyComments(header(test))))
|
||||
b.Write(src)
|
||||
b2, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
@@ -610,7 +604,7 @@ func threadTest3() {
|
||||
)
|
||||
|
||||
var b bytes.Buffer
|
||||
fmt.Fprintf(&b, prologueTest, tidyComments(header(test)))
|
||||
fmt.Fprintf(&b, prologueTest, tag, strings.TrimSpace(tidyComments(header(test))))
|
||||
b.Write(src)
|
||||
b2, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
@@ -655,7 +649,7 @@ func threadTest4() {
|
||||
)
|
||||
|
||||
var b bytes.Buffer
|
||||
fmt.Fprintf(&b, prologueTest, tidyComments(header(test)))
|
||||
fmt.Fprintf(&b, prologueTest, tag, strings.TrimSpace(tidyComments(header(test))))
|
||||
b.Write(src)
|
||||
b2, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,29 @@
|
||||
// Code generated by ccgo. DO NOT EDIT.
|
||||
|
||||
// threadtest1.c
|
||||
|
||||
// 2002 January 15
|
||||
//
|
||||
// The author disclaims copyright to this source code. In place of
|
||||
// a legal notice, here is a blessing:
|
||||
//
|
||||
// May you do good and not evil.
|
||||
// May you find forgiveness for yourself and forgive others.
|
||||
// May you share freely, never taking more than you give.
|
||||
//
|
||||
// *************************************************************************
|
||||
// This file implements a simple standalone program used to test whether
|
||||
// or not the SQLite library is threadsafe.
|
||||
//
|
||||
// Testing the thread safety of SQLite is difficult because there are very
|
||||
// few places in the code that are even potentially unsafe, and those
|
||||
// places execute for very short periods of time. So even if the library
|
||||
// is compiled with its mutexes disabled, it is likely to work correctly
|
||||
// in a multi-threaded program most of the time.
|
||||
//
|
||||
// This file is NOT part of the standard SQLite library. It is used for
|
||||
// testing only.
|
||||
|
||||
// threadtest1
|
||||
// /*
|
||||
// ** 2002 January 15
|
||||
// **
|
||||
// ** The author disclaims copyright to this source code. In place of
|
||||
// ** a legal notice, here is a blessing:
|
||||
// **
|
||||
// ** May you do good and not evil.
|
||||
// ** May you find forgiveness for yourself and forgive others.
|
||||
// ** May you share freely, never taking more than you give.
|
||||
// **
|
||||
// *************************************************************************
|
||||
// ** This file implements a simple standalone program used to test whether
|
||||
// ** or not the SQLite library is threadsafe.
|
||||
// **
|
||||
// ** Testing the thread safety of SQLite is difficult because there are very
|
||||
// ** few places in the code that are even potentially unsafe, and those
|
||||
// ** places execute for very short periods of time. So even if the library
|
||||
// ** is compiled with its mutexes disabled, it is likely to work correctly
|
||||
// ** in a multi-threaded program most of the time.
|
||||
// **
|
||||
// ** This file is NOT part of the standard SQLite library. It is used for
|
||||
// ** testing only.
|
||||
// */
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -61,13 +61,13 @@ var X__stdfiles [3]unsafe.Pointer
|
||||
var Xstdout unsafe.Pointer
|
||||
|
||||
func init() {
|
||||
Xstdout = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
|
||||
Xstdout = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
|
||||
}
|
||||
|
||||
var Xstderr unsafe.Pointer
|
||||
|
||||
func init() {
|
||||
Xstderr = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 16)
|
||||
Xstderr = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 16)
|
||||
}
|
||||
|
||||
func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
|
||||
@@ -76,13 +76,13 @@ func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
|
||||
var _zFile, _4_zDb, _4_zJournal *int8
|
||||
var _2_zBuf, _6_zBuf [200]int8
|
||||
r0 = i32(0)
|
||||
if (_argc > i32(2)) && (crt.Xstrcmp(tls, *(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 8*uintptr(i32(1)))), str(0)) == i32(0)) {
|
||||
if (_argc > i32(2)) && (crt.Xstrcmp(tls, *(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_argv)) + 8*uintptr(i32(1)))), str(0)) == i32(0)) {
|
||||
_verbose = i32(1)
|
||||
bug20530(_verbose)
|
||||
_argc -= 1
|
||||
*(*uintptr)(unsafe.Pointer(&_argv)) += uintptr(8)
|
||||
}
|
||||
if (_argc < i32(2)) || (store0(&_n, crt.Xatoi(tls, *(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 8*uintptr(i32(1)))))) < i32(1)) {
|
||||
if (_argc < i32(2)) || (store0(&_n, crt.Xatoi(tls, *(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_argv)) + 8*uintptr(i32(1)))))) < i32(1)) {
|
||||
_n = i32(10)
|
||||
}
|
||||
_i = i32(0)
|
||||
@@ -102,13 +102,13 @@ _8:
|
||||
}
|
||||
_zFile = bin.Xsqlite3_mprintf(tls, str(13), (_i%i32(2))+i32(1), (_i+i32(2))/i32(2))
|
||||
if (_i % i32(2)) == i32(0) {
|
||||
_4_zDb = (*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_zFile)) + 1*uintptr(i32(2))))
|
||||
_4_zDb = (*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_zFile)) + 1*uintptr(i32(2))))
|
||||
_4_zJournal = bin.Xsqlite3_mprintf(tls, str(26), unsafe.Pointer(_4_zDb))
|
||||
crt.Xunlink(tls, _4_zDb)
|
||||
crt.Xunlink(tls, _4_zJournal)
|
||||
crt.Xfree(tls, (unsafe.Pointer)(_4_zJournal))
|
||||
crt.Xfree(tls, unsafe.Pointer(_4_zJournal))
|
||||
}
|
||||
crt.Xpthread_create(tls, &_id, nil, _worker_bee, (unsafe.Pointer)(_zFile))
|
||||
crt.Xpthread_create(tls, &_id, nil, _worker_bee, unsafe.Pointer(_zFile))
|
||||
crt.Xpthread_detach(tls, _id)
|
||||
_i += 1
|
||||
goto _8
|
||||
@@ -157,12 +157,12 @@ _0:
|
||||
if _cnt >= i32(10) {
|
||||
goto _3
|
||||
}
|
||||
bin.Xsqlite3_open(tls, (*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_zFilename))+1*uintptr(i32(2)))), (**bin.Xsqlite3)(unsafe.Pointer(&_db)))
|
||||
bin.Xsqlite3_open(tls, (*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_zFilename))+1*uintptr(i32(2)))), (**bin.Xsqlite3)(unsafe.Pointer(&_db)))
|
||||
if _db == nil {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(48), unsafe.Pointer(_zFilename))
|
||||
_Exit(tls, i32(1))
|
||||
}
|
||||
bin.Xsqlite3_busy_handler(tls, (*bin.Xsqlite3)(_db), _db_is_locked, (unsafe.Pointer)(_zFilename))
|
||||
bin.Xsqlite3_busy_handler(tls, (*bin.Xsqlite3)(_db), _db_is_locked, unsafe.Pointer(_zFilename))
|
||||
Xdb_execute(tls, _db, _zFilename, str(64), _t)
|
||||
_i = i32(1)
|
||||
_5:
|
||||
@@ -217,12 +217,18 @@ var Xlock crt.Xpthread_mutex_t
|
||||
|
||||
var Xthread_cnt int32
|
||||
|
||||
// Come here to die.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Come here to die.
|
||||
// */
|
||||
func _Exit(tls *crt.TLS, _rc int32) {
|
||||
crt.Xexit(tls, _rc)
|
||||
}
|
||||
|
||||
// When a lock occurs, yield.
|
||||
// C comment
|
||||
// /*
|
||||
// ** When a lock occurs, yield.
|
||||
// */
|
||||
func _db_is_locked(tls *crt.TLS, _NotUsed unsafe.Pointer, _iCount int32) (r0 int32) {
|
||||
if _verbose != 0 {
|
||||
crt.Xprintf(tls, str(305), unsafe.Pointer((*int8)(_NotUsed)), _iCount)
|
||||
@@ -231,7 +237,10 @@ func _db_is_locked(tls *crt.TLS, _NotUsed unsafe.Pointer, _iCount int32) (r0 int
|
||||
return bool2int(_iCount < i32(40000))
|
||||
}
|
||||
|
||||
// Execute an SQL statement.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Execute an SQL statement.
|
||||
// */
|
||||
func Xdb_execute(tls *crt.TLS, _db unsafe.Pointer, _zFile *int8, _zFormat *int8, args ...interface{}) {
|
||||
var _rc int32
|
||||
var _zSql, _zErrMsg *int8
|
||||
@@ -253,15 +262,18 @@ _0:
|
||||
}
|
||||
if _zErrMsg != nil {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(344), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql), unsafe.Pointer(_zErrMsg))
|
||||
crt.Xfree(tls, (unsafe.Pointer)(_zErrMsg))
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql))
|
||||
crt.Xfree(tls, unsafe.Pointer(_zErrMsg))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
|
||||
_Exit(tls, i32(1))
|
||||
}
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
|
||||
}
|
||||
|
||||
// Execute a query against the database. NULL values are returned
|
||||
// as an empty string. The list is terminated by a single NULL pointer.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Execute a query against the database. NULL values are returned
|
||||
// ** as an empty string. The list is terminated by a single NULL pointer.
|
||||
// */
|
||||
func Xdb_query(tls *crt.TLS, _db unsafe.Pointer, _zFile *int8, _zFormat *int8, args ...interface{}) (r0 **int8) {
|
||||
var _rc int32
|
||||
var _zSql, _zErrMsg *int8
|
||||
@@ -271,56 +283,59 @@ func Xdb_query(tls *crt.TLS, _db unsafe.Pointer, _zFile *int8, _zFormat *int8, a
|
||||
_ap = args
|
||||
_zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
|
||||
_ap = nil
|
||||
crt.Xmemset(tls, (unsafe.Pointer)(&_sResult), i32(0), u64(24))
|
||||
*(**int8)(unsafe.Pointer(&(_sResult.X0))) = _zFile
|
||||
crt.Xmemset(tls, unsafe.Pointer(&_sResult), i32(0), u64(24))
|
||||
*(**int8)(unsafe.Pointer(&_sResult.X0)) = _zFile
|
||||
if _verbose != 0 {
|
||||
crt.Xprintf(tls, str(373), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql))
|
||||
}
|
||||
_rc = bin.Xsqlite3_exec(tls, (*bin.Xsqlite3)(_db), _zSql, _db_query_callback, (unsafe.Pointer)(&_sResult), &_zErrMsg)
|
||||
_rc = bin.Xsqlite3_exec(tls, (*bin.Xsqlite3)(_db), _zSql, _db_query_callback, unsafe.Pointer(&_sResult), &_zErrMsg)
|
||||
if _rc != i32(17) {
|
||||
goto _1
|
||||
}
|
||||
if _zErrMsg != nil {
|
||||
crt.Xfree(tls, (unsafe.Pointer)(_zErrMsg))
|
||||
crt.Xfree(tls, unsafe.Pointer(_zErrMsg))
|
||||
}
|
||||
_rc = bin.Xsqlite3_exec(tls, (*bin.Xsqlite3)(_db), _zSql, _db_query_callback, (unsafe.Pointer)(&_sResult), &_zErrMsg)
|
||||
_rc = bin.Xsqlite3_exec(tls, (*bin.Xsqlite3)(_db), _zSql, _db_query_callback, unsafe.Pointer(&_sResult), &_zErrMsg)
|
||||
_1:
|
||||
if _verbose != 0 {
|
||||
crt.Xprintf(tls, str(387), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql))
|
||||
}
|
||||
if _zErrMsg != nil {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(399), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql), unsafe.Pointer(_zErrMsg))
|
||||
crt.Xfree(tls, (unsafe.Pointer)(_zErrMsg))
|
||||
crt.Xfree(tls, (unsafe.Pointer)(_zSql))
|
||||
crt.Xfree(tls, unsafe.Pointer(_zErrMsg))
|
||||
crt.Xfree(tls, unsafe.Pointer(_zSql))
|
||||
_Exit(tls, i32(1))
|
||||
}
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql))
|
||||
if (_sResult.X3) == nil {
|
||||
_db_query_callback(tls, (unsafe.Pointer)(&_sResult), i32(0), nil, nil)
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
|
||||
if _sResult.X3 == nil {
|
||||
_db_query_callback(tls, unsafe.Pointer(&_sResult), i32(0), nil, nil)
|
||||
}
|
||||
*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_sResult.X3)) + 8*uintptr(_sResult.X1))) = nil
|
||||
*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_sResult.X3)) + 8*uintptr(_sResult.X1))) = nil
|
||||
return _sResult.X3
|
||||
|
||||
_ = _sResult
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// The callback function for db_query
|
||||
// C comment
|
||||
// /*
|
||||
// ** The callback function for db_query
|
||||
// */
|
||||
func _db_query_callback(tls *crt.TLS, _pUser unsafe.Pointer, _nArg int32, _azArg **int8, _NotUsed **int8) (r0 int32) {
|
||||
var _i int32
|
||||
var _pResult *TQueryResult
|
||||
_pResult = (*TQueryResult)(_pUser)
|
||||
if ((_pResult.X1) + _nArg) < (_pResult.X2) {
|
||||
if (_pResult.X1 + _nArg) < _pResult.X2 {
|
||||
goto _0
|
||||
}
|
||||
if (_pResult.X2) == i32(0) {
|
||||
*(*int32)(unsafe.Pointer(&(_pResult.X2))) = _nArg + i32(1)
|
||||
if _pResult.X2 == i32(0) {
|
||||
*(*int32)(unsafe.Pointer(&_pResult.X2)) = _nArg + i32(1)
|
||||
goto _2
|
||||
}
|
||||
*(*int32)(unsafe.Pointer(&(_pResult.X2))) = (((_pResult.X2) * i32(2)) + _nArg) + i32(1)
|
||||
*(*int32)(unsafe.Pointer(&_pResult.X2)) = ((_pResult.X2 * i32(2)) + _nArg) + i32(1)
|
||||
_2:
|
||||
*(***int8)(unsafe.Pointer(&(_pResult.X3))) = (**int8)(crt.Xrealloc(tls, (unsafe.Pointer)(_pResult.X3), uint64(_pResult.X2)*u64(8)))
|
||||
if (_pResult.X3) == nil {
|
||||
*(***int8)(unsafe.Pointer(&_pResult.X3)) = (**int8)(crt.Xrealloc(tls, unsafe.Pointer(_pResult.X3), uint64(_pResult.X2)*u64(8)))
|
||||
if _pResult.X3 == nil {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(426), unsafe.Pointer(_pResult.X0))
|
||||
return i32(1)
|
||||
}
|
||||
@@ -333,9 +348,9 @@ _5:
|
||||
if _i >= _nArg {
|
||||
goto _8
|
||||
}
|
||||
*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_pResult.X3)) + 8*uintptr(postInc0((*int32)(unsafe.Pointer(&(_pResult.X1))), int32(1))))) = bin.Xsqlite3_mprintf(tls, str(445), unsafe.Pointer(func() *int8 {
|
||||
if (*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_azArg)) + 8*uintptr(_i)))) != nil {
|
||||
return (*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_azArg)) + 8*uintptr(_i))))
|
||||
*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_pResult.X3)) + 8*uintptr(postInc0((*int32)(unsafe.Pointer(&_pResult.X1)), 1)))) = bin.Xsqlite3_mprintf(tls, str(445), unsafe.Pointer(func() *int8 {
|
||||
if (*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_azArg)) + 8*uintptr(_i)))) != nil {
|
||||
return (*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_azArg)) + 8*uintptr(_i))))
|
||||
}
|
||||
return str(448)
|
||||
}()))
|
||||
@@ -345,7 +360,10 @@ _8:
|
||||
return i32(0)
|
||||
}
|
||||
|
||||
// Check results
|
||||
// C comment
|
||||
// /*
|
||||
// ** Check results
|
||||
// */
|
||||
func Xdb_check(tls *crt.TLS, _zFile *int8, _zMsg *int8, _az **int8, args ...interface{}) {
|
||||
var _i int32
|
||||
var _z *int8
|
||||
@@ -356,8 +374,8 @@ _0:
|
||||
if store1(&_z, (*int8)(crt.VAPointer(&_ap))) == nil {
|
||||
goto _3
|
||||
}
|
||||
if ((*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 8*uintptr(_i)))) == nil) || (crt.Xstrcmp(tls, *(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 8*uintptr(_i))), _z) != i32(0)) {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(449), unsafe.Pointer(_zFile), unsafe.Pointer(_zMsg), _i+i32(1), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 8*uintptr(_i)))))
|
||||
if ((*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_az)) + 8*uintptr(_i)))) == nil) || (crt.Xstrcmp(tls, *(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_az)) + 8*uintptr(_i))), _z) != i32(0)) {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(449), unsafe.Pointer(_zFile), unsafe.Pointer(_zMsg), _i+i32(1), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_az)) + 8*uintptr(_i)))))
|
||||
Xdb_query_free(tls, _az)
|
||||
_Exit(tls, i32(1))
|
||||
}
|
||||
@@ -368,19 +386,22 @@ _3:
|
||||
Xdb_query_free(tls, _az)
|
||||
}
|
||||
|
||||
// Free the results of a db_query() call.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Free the results of a db_query() call.
|
||||
// */
|
||||
func Xdb_query_free(tls *crt.TLS, _az **int8) {
|
||||
var _i int32
|
||||
_i = i32(0)
|
||||
_0:
|
||||
if (*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 8*uintptr(_i)))) == nil {
|
||||
if (*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_az)) + 8*uintptr(_i)))) == nil {
|
||||
goto _3
|
||||
}
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 8*uintptr(_i)))))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_az)) + 8*uintptr(_i)))))
|
||||
_i += 1
|
||||
goto _0
|
||||
_3:
|
||||
crt.Xfree(tls, (unsafe.Pointer)(_az))
|
||||
crt.Xfree(tls, unsafe.Pointer(_az))
|
||||
}
|
||||
|
||||
var Xsig crt.Xpthread_cond_t
|
||||
|
@@ -1,23 +1,23 @@
|
||||
// Code generated by ccgo. DO NOT EDIT.
|
||||
|
||||
// threadtest2.c
|
||||
|
||||
// 2004 January 13
|
||||
//
|
||||
// The author disclaims copyright to this source code. In place of
|
||||
// a legal notice, here is a blessing:
|
||||
//
|
||||
// May you do good and not evil.
|
||||
// May you find forgiveness for yourself and forgive others.
|
||||
// May you share freely, never taking more than you give.
|
||||
//
|
||||
// *************************************************************************
|
||||
// This file implements a simple standalone program used to test whether
|
||||
// or not the SQLite library is threadsafe.
|
||||
//
|
||||
// This file is NOT part of the standard SQLite library. It is used for
|
||||
// testing only.
|
||||
|
||||
// threadtest2
|
||||
// /*
|
||||
// ** 2004 January 13
|
||||
// **
|
||||
// ** The author disclaims copyright to this source code. In place of
|
||||
// ** a legal notice, here is a blessing:
|
||||
// **
|
||||
// ** May you do good and not evil.
|
||||
// ** May you find forgiveness for yourself and forgive others.
|
||||
// ** May you share freely, never taking more than you give.
|
||||
// **
|
||||
// *************************************************************************
|
||||
// ** This file implements a simple standalone program used to test whether
|
||||
// ** or not the SQLite library is threadsafe.
|
||||
// **
|
||||
// ** This file is NOT part of the standard SQLite library. It is used for
|
||||
// ** testing only.
|
||||
// */
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -55,16 +55,19 @@ var X__stdfiles [3]unsafe.Pointer
|
||||
var Xstdout unsafe.Pointer
|
||||
|
||||
func init() {
|
||||
Xstdout = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
|
||||
Xstdout = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
|
||||
}
|
||||
|
||||
var Xstderr unsafe.Pointer
|
||||
|
||||
func init() {
|
||||
Xstderr = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 16)
|
||||
Xstderr = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 16)
|
||||
}
|
||||
|
||||
// Initialize the database and start the threads
|
||||
// C comment
|
||||
// /*
|
||||
// ** Initialize the database and start the threads
|
||||
// */
|
||||
func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
|
||||
var _i, _rc int32
|
||||
var _1_zJournal *int8
|
||||
@@ -75,7 +78,7 @@ func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
|
||||
_1_zJournal = bin.Xsqlite3_mprintf(tls, str(17), unsafe.Pointer(str(0)))
|
||||
crt.Xunlink(tls, str(0))
|
||||
crt.Xunlink(tls, _1_zJournal)
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_1_zJournal))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_1_zJournal))
|
||||
}
|
||||
bin.Xsqlite3_open(tls, str(0), (**bin.Xsqlite3)(unsafe.Pointer(&_db)))
|
||||
if _db == nil {
|
||||
@@ -93,7 +96,7 @@ _3:
|
||||
if uint64(_i) >= u64(5) {
|
||||
goto _6
|
||||
}
|
||||
crt.Xpthread_create(tls, (*uint64)(unsafe.Pointer(uintptr((unsafe.Pointer)(&_aThread))+8*uintptr(_i))), nil, Xworker, crt.U2P(uintptr(_i)))
|
||||
crt.Xpthread_create(tls, (*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(&_aThread))+8*uintptr(_i))), nil, Xworker, crt.U2P(uintptr(_i)))
|
||||
_i += 1
|
||||
goto _3
|
||||
_6:
|
||||
@@ -102,7 +105,7 @@ _7:
|
||||
if uint64(_i) >= u64(5) {
|
||||
goto _10
|
||||
}
|
||||
crt.Xpthread_join(tls, *(*uint64)(unsafe.Pointer(uintptr((unsafe.Pointer)(&_aThread)) + 8*uintptr(_i))), nil)
|
||||
crt.Xpthread_join(tls, *(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(&_aThread)) + 8*uintptr(_i))), nil)
|
||||
_i += 1
|
||||
goto _7
|
||||
_10:
|
||||
@@ -117,7 +120,10 @@ _10:
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// This is the worker thread
|
||||
// C comment
|
||||
// /*
|
||||
// ** This is the worker thread
|
||||
// */
|
||||
func Xworker(tls *crt.TLS, _workerArg unsafe.Pointer) (r0 unsafe.Pointer) {
|
||||
var _id, _rc, _cnt int32
|
||||
var _db unsafe.Pointer
|
||||
@@ -125,7 +131,7 @@ func Xworker(tls *crt.TLS, _workerArg unsafe.Pointer) (r0 unsafe.Pointer) {
|
||||
_cnt = i32(0)
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(147), _id)
|
||||
_0:
|
||||
if Xall_stop != 0 || postInc0(&_cnt, int32(1)) >= i32(10000) {
|
||||
if Xall_stop != 0 || postInc0(&_cnt, 1) >= i32(10000) {
|
||||
goto _1
|
||||
}
|
||||
if (_cnt % i32(100)) == i32(0) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,36 +1,36 @@
|
||||
// Code generated by ccgo. DO NOT EDIT.
|
||||
|
||||
// threadtest4.c
|
||||
|
||||
// 2014-12-11
|
||||
//
|
||||
// The author disclaims copyright to this source code. In place of
|
||||
// a legal notice, here is a blessing:
|
||||
//
|
||||
// May you do good and not evil.
|
||||
// May you find forgiveness for yourself and forgive others.
|
||||
// May you share freely, never taking more than you give.
|
||||
//
|
||||
// *************************************************************************
|
||||
// This file implements a simple standalone program used to stress the
|
||||
// SQLite library when accessing the same set of databases simultaneously
|
||||
// from multiple threads in shared-cache mode.
|
||||
//
|
||||
// This test program runs on unix-like systems only. It uses pthreads.
|
||||
// To compile:
|
||||
//
|
||||
// gcc -g -Wall -I. threadtest4.c sqlite3.c -ldl -lpthread
|
||||
//
|
||||
// To run:
|
||||
//
|
||||
// ./a.out 10
|
||||
//
|
||||
// The argument is the number of threads. There are also options, such
|
||||
// as -wal and -multithread and -serialized.
|
||||
//
|
||||
// Consider also compiling with clang instead of gcc and adding the
|
||||
// -fsanitize=thread option.
|
||||
|
||||
// threadtest4
|
||||
// /*
|
||||
// ** 2014-12-11
|
||||
// **
|
||||
// ** The author disclaims copyright to this source code. In place of
|
||||
// ** a legal notice, here is a blessing:
|
||||
// **
|
||||
// ** May you do good and not evil.
|
||||
// ** May you find forgiveness for yourself and forgive others.
|
||||
// ** May you share freely, never taking more than you give.
|
||||
// **
|
||||
// *************************************************************************
|
||||
// ** This file implements a simple standalone program used to stress the
|
||||
// ** SQLite library when accessing the same set of databases simultaneously
|
||||
// ** from multiple threads in shared-cache mode.
|
||||
// **
|
||||
// ** This test program runs on unix-like systems only. It uses pthreads.
|
||||
// ** To compile:
|
||||
// **
|
||||
// ** gcc -g -Wall -I. threadtest4.c sqlite3.c -ldl -lpthread
|
||||
// **
|
||||
// ** To run:
|
||||
// **
|
||||
// ** ./a.out 10
|
||||
// **
|
||||
// ** The argument is the number of threads. There are also options, such
|
||||
// ** as -wal and -multithread and -serialized.
|
||||
// **
|
||||
// ** Consider also compiling with clang instead of gcc and adding the
|
||||
// ** -fsanitize=thread option.
|
||||
// */
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -68,13 +68,13 @@ var X__stdfiles [3]unsafe.Pointer
|
||||
var Xstdout unsafe.Pointer
|
||||
|
||||
func init() {
|
||||
Xstdout = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
|
||||
Xstdout = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
|
||||
}
|
||||
|
||||
var Xstderr unsafe.Pointer
|
||||
|
||||
func init() {
|
||||
Xstderr = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 16)
|
||||
Xstderr = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 16)
|
||||
}
|
||||
|
||||
func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
|
||||
@@ -97,11 +97,11 @@ _0:
|
||||
if _i >= _argc {
|
||||
goto _3
|
||||
}
|
||||
_1_z = *(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 8*uintptr(_i)))
|
||||
if int32(*(*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_1_z)) + 1*uintptr(i32(0))))) != i32(45) {
|
||||
_1_z = *(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_argv)) + 8*uintptr(_i)))
|
||||
if int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_1_z)) + 1*uintptr(i32(0))))) != i32(45) {
|
||||
goto _4
|
||||
}
|
||||
if (int32(*(*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_1_z)) + 1*uintptr(i32(1))))) == i32(45)) && (int32(*(*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_1_z)) + 1*uintptr(i32(2))))) != i32(0)) {
|
||||
if (int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_1_z)) + 1*uintptr(i32(1))))) == i32(45)) && (int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_1_z)) + 1*uintptr(i32(2))))) != i32(0)) {
|
||||
*(*uintptr)(unsafe.Pointer(&_1_z)) += uintptr(1)
|
||||
}
|
||||
if crt.Xstrcmp(tls, _1_z, str(0)) == i32(0) {
|
||||
@@ -138,12 +138,12 @@ _0:
|
||||
}
|
||||
goto _14
|
||||
}
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(37), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 8*uintptr(_i)))))
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(37), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_argv)) + 8*uintptr(_i)))))
|
||||
crt.Xexit(tls, i32(1))
|
||||
_14:
|
||||
goto _20
|
||||
_4:
|
||||
if int32(*(*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_1_z)) + 1*uintptr(i32(0))))) < i32(49) || int32(*(*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_1_z)) + 1*uintptr(i32(0))))) > i32(57) || _nWorker != i32(0) {
|
||||
if int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_1_z)) + 1*uintptr(i32(0))))) < i32(49) || int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_1_z)) + 1*uintptr(i32(0))))) > i32(57) || _nWorker != i32(0) {
|
||||
goto _18
|
||||
}
|
||||
_nWorker = crt.Xatoi(tls, _1_z)
|
||||
@@ -153,14 +153,14 @@ _4:
|
||||
}
|
||||
goto _20
|
||||
_18:
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(92), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 8*uintptr(_i)))))
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(92), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_argv)) + 8*uintptr(_i)))))
|
||||
crt.Xexit(tls, i32(1))
|
||||
_20:
|
||||
_i += 1
|
||||
goto _0
|
||||
_3:
|
||||
if _nWorker == i32(0) {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(127), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 8*uintptr(i32(0))))))
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(127), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(_argv)) + 8*uintptr(i32(0))))))
|
||||
crt.Xexit(tls, i32(1))
|
||||
}
|
||||
if bin.Xsqlite3_threadsafe(tls) == 0 {
|
||||
@@ -178,9 +178,9 @@ _3:
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(338))
|
||||
crt.Xexit(tls, i32(1))
|
||||
}
|
||||
crt.Xmemset(tls, (unsafe.Pointer)(&_infoTop), i32(0), u64(64))
|
||||
*(*unsafe.Pointer)(unsafe.Pointer(&(_infoTop.X4))) = _db
|
||||
*(*uint32)(unsafe.Pointer(&(_infoTop.X2))) = _wkrFlags
|
||||
crt.Xmemset(tls, unsafe.Pointer(&_infoTop), i32(0), u64(64))
|
||||
*(*unsafe.Pointer)(unsafe.Pointer(&_infoTop.X4)) = _db
|
||||
*(*uint32)(unsafe.Pointer(&_infoTop.X2)) = _wkrFlags
|
||||
_p = &_infoTop
|
||||
if (_wkrFlags & uint32(i32(2))) != 0 {
|
||||
_run_sql(tls, _p, str(382))
|
||||
@@ -198,18 +198,18 @@ _3:
|
||||
_run_sql(tls, _p, str(805))
|
||||
_run_sql(tls, _p, str(841))
|
||||
_aInfo = (*XWorkerInfo)(_safe_malloc(tls, int32(u64(64)*uint64(_nWorker))))
|
||||
crt.Xmemset(tls, (unsafe.Pointer)(_aInfo), i32(0), u64(64)*uint64(_nWorker))
|
||||
crt.Xmemset(tls, unsafe.Pointer(_aInfo), i32(0), u64(64)*uint64(_nWorker))
|
||||
_i = i32(0)
|
||||
_25:
|
||||
if _i >= _nWorker {
|
||||
goto _28
|
||||
}
|
||||
*(*int32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X0))) = _i + i32(1)
|
||||
*(*int32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X1))) = _nWorker
|
||||
*(*uint32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X2))) = _wkrFlags
|
||||
*(*unsafe.Pointer)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X3))) = _db
|
||||
*(**crt.Xpthread_mutex_t)(unsafe.Pointer((*unsafe.Pointer)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X9))))) = &_wrMutex
|
||||
_rc = crt.Xpthread_create(tls, (*uint64)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X8))), nil, _worker_thread, (unsafe.Pointer)((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+64*uintptr(_i)))))
|
||||
*(*int32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X0))) = _i + i32(1)
|
||||
*(*int32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X1))) = _nWorker
|
||||
*(*uint32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X2))) = _wkrFlags
|
||||
*(*unsafe.Pointer)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X3))) = _db
|
||||
*(**crt.Xpthread_mutex_t)(unsafe.Pointer((*unsafe.Pointer)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X9))))) = &_wrMutex
|
||||
_rc = crt.Xpthread_create(tls, (*uint64)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X8))), nil, _worker_thread, unsafe.Pointer((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo))+64*uintptr(_i)))))
|
||||
if _rc != i32(0) {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(876), _i+i32(1))
|
||||
crt.Xexit(tls, i32(1))
|
||||
@@ -223,22 +223,22 @@ _30:
|
||||
if _i >= _nWorker {
|
||||
goto _33
|
||||
}
|
||||
crt.Xpthread_join(tls, (*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+64*uintptr(_i))).X8, nil)
|
||||
crt.Xprintf(tls, str(914), (*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+64*uintptr(_i))).X0, (*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+64*uintptr(_i))).X5, (*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+64*uintptr(_i))).X6)
|
||||
if ((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X7) != nil {
|
||||
crt.Xprintf(tls, str(954), unsafe.Pointer((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+64*uintptr(_i))).X7))
|
||||
crt.Xpthread_join(tls, (*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo))+64*uintptr(_i))).X8, nil)
|
||||
crt.Xprintf(tls, str(914), (*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo))+64*uintptr(_i))).X0, (*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo))+64*uintptr(_i))).X5, (*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo))+64*uintptr(_i))).X6)
|
||||
if ((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X7) != nil {
|
||||
crt.Xprintf(tls, str(954), unsafe.Pointer((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo))+64*uintptr(_i))).X7))
|
||||
goto _35
|
||||
}
|
||||
crt.Xprintf(tls, str(960))
|
||||
_35:
|
||||
{
|
||||
p := &_nErr
|
||||
*p = (*p) + ((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X5)
|
||||
*p = (*p) + ((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X5)
|
||||
sink1(*p)
|
||||
}
|
||||
{
|
||||
p := &_nTest
|
||||
*p = (*p) + ((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 64*uintptr(_i))).X6)
|
||||
*p = (*p) + ((*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(_aInfo)) + 64*uintptr(_i))).X6)
|
||||
sink1(*p)
|
||||
}
|
||||
crt.Xfflush(tls, (*crt.XFILE)(Xstdout))
|
||||
@@ -246,7 +246,7 @@ _35:
|
||||
goto _30
|
||||
_33:
|
||||
bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_db))
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_aInfo))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_aInfo))
|
||||
crt.Xprintf(tls, str(962), _nErr, _nTest)
|
||||
return _nErr
|
||||
|
||||
@@ -255,7 +255,10 @@ _33:
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// Run a SQL statements. Panic if unable.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Run a SQL statements. Panic if unable.
|
||||
// */
|
||||
func _run_sql(tls *crt.TLS, _p *XWorkerInfo, _zFormat *int8, args ...interface{}) {
|
||||
var _rc, _i, _nRetry int32
|
||||
var _zSql *int8
|
||||
@@ -266,7 +269,7 @@ func _run_sql(tls *crt.TLS, _p *XWorkerInfo, _zFormat *int8, args ...interface{}
|
||||
_ap = args
|
||||
_zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
|
||||
_ap = nil
|
||||
_check_oom(tls, (unsafe.Pointer)(_zSql))
|
||||
_check_oom(tls, unsafe.Pointer(_zSql))
|
||||
_i = i32(0)
|
||||
_0:
|
||||
if _i >= i32(1000) {
|
||||
@@ -307,11 +310,14 @@ _9:
|
||||
}
|
||||
goto _6
|
||||
_7:
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
|
||||
bin.Xsqlite3_finalize(tls, _pStmt)
|
||||
}
|
||||
|
||||
// Report an OOM error and die if the argument is NULL
|
||||
// C comment
|
||||
// /*
|
||||
// ** Report an OOM error and die if the argument is NULL
|
||||
// */
|
||||
func _check_oom(tls *crt.TLS, _x unsafe.Pointer) {
|
||||
if _x == nil {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1151))
|
||||
@@ -319,23 +325,29 @@ func _check_oom(tls *crt.TLS, _x unsafe.Pointer) {
|
||||
}
|
||||
}
|
||||
|
||||
// Print a trace message for a worker
|
||||
// C comment
|
||||
// /*
|
||||
// ** Print a trace message for a worker
|
||||
// */
|
||||
func _worker_trace(tls *crt.TLS, _p *XWorkerInfo, _zFormat *int8, args ...interface{}) {
|
||||
var _zMsg *int8
|
||||
var _ap []interface{}
|
||||
if ((_p.X2) & uint32(i32(4))) == uint32(i32(0)) {
|
||||
if (_p.X2 & uint32(i32(4))) == uint32(i32(0)) {
|
||||
return
|
||||
}
|
||||
_ap = args
|
||||
_zMsg = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
|
||||
_check_oom(tls, (unsafe.Pointer)(_zMsg))
|
||||
_check_oom(tls, unsafe.Pointer(_zMsg))
|
||||
_ap = nil
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1166), _p.X0, unsafe.Pointer(_zMsg))
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zMsg))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_zMsg))
|
||||
}
|
||||
|
||||
// Allocate memory. If the allocation fails, print an error message and
|
||||
// kill the process.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Allocate memory. If the allocation fails, print an error message and
|
||||
// ** kill the process.
|
||||
// */
|
||||
func _safe_malloc(tls *crt.TLS, _sz int32) (r0 unsafe.Pointer) {
|
||||
var _x unsafe.Pointer
|
||||
_x = bin.Xsqlite3_malloc(tls, func() int32 {
|
||||
@@ -348,7 +360,10 @@ func _safe_malloc(tls *crt.TLS, _sz int32) (r0 unsafe.Pointer) {
|
||||
return _x
|
||||
}
|
||||
|
||||
// Each thread runs the following function.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Each thread runs the following function.
|
||||
// */
|
||||
func _worker_thread(tls *crt.TLS, _pArg unsafe.Pointer) (r0 unsafe.Pointer) {
|
||||
var _iOuter, _i, _rc int32
|
||||
var _pStmt unsafe.Pointer
|
||||
@@ -358,7 +373,7 @@ func _worker_thread(tls *crt.TLS, _pArg unsafe.Pointer) (r0 unsafe.Pointer) {
|
||||
crt.Xfflush(tls, (*crt.XFILE)(Xstdout))
|
||||
_iOuter = i32(1)
|
||||
_0:
|
||||
if _iOuter > (_p.X1) {
|
||||
if _iOuter > _p.X1 {
|
||||
goto _3
|
||||
}
|
||||
_worker_open_connection(tls, _p, _iOuter)
|
||||
@@ -367,9 +382,9 @@ _4:
|
||||
if _i >= i32(4) {
|
||||
goto _7
|
||||
}
|
||||
_worker_add_content(tls, _p, (_i*i32(100))+i32(1), (_i+i32(1))*i32(100), (((_p.X0)+_iOuter)%i32(3))+i32(1))
|
||||
_worker_add_content(tls, _p, (_i*i32(100))+i32(1), (_i+i32(1))*i32(100), ((((_p.X0)+_iOuter)+i32(1))%i32(3))+i32(1))
|
||||
_worker_add_content(tls, _p, (_i*i32(100))+i32(1), (_i+i32(1))*i32(100), ((((_p.X0)+_iOuter)+i32(2))%i32(3))+i32(1))
|
||||
_worker_add_content(tls, _p, (_i*i32(100))+i32(1), (_i+i32(1))*i32(100), ((_p.X0+_iOuter)%i32(3))+i32(1))
|
||||
_worker_add_content(tls, _p, (_i*i32(100))+i32(1), (_i+i32(1))*i32(100), (((_p.X0+_iOuter)+i32(1))%i32(3))+i32(1))
|
||||
_worker_add_content(tls, _p, (_i*i32(100))+i32(1), (_i+i32(1))*i32(100), (((_p.X0+_iOuter)+i32(2))%i32(3))+i32(1))
|
||||
_i += 1
|
||||
goto _4
|
||||
_7:
|
||||
@@ -385,12 +400,12 @@ _7:
|
||||
}
|
||||
_10:
|
||||
bin.Xsqlite3_finalize(tls, _pStmt)
|
||||
if (_p.X5) != 0 {
|
||||
if _p.X5 != 0 {
|
||||
goto _3
|
||||
}
|
||||
if ((_iOuter + (_p.X0)) % i32(3)) == i32(0) {
|
||||
if ((_iOuter + _p.X0) % i32(3)) == i32(0) {
|
||||
bin.Xsqlite3_db_release_memory(tls, (*bin.Xsqlite3)(_p.X4))
|
||||
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1
|
||||
*(*int32)(unsafe.Pointer(&_p.X6)) += 1
|
||||
}
|
||||
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
_run_sql(tls, _p, str(1286))
|
||||
@@ -398,9 +413,9 @@ _10:
|
||||
_run_sql(tls, _p, str(1325))
|
||||
_run_sql(tls, _p, str(1357))
|
||||
_run_sql(tls, _p, str(1389))
|
||||
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1
|
||||
*(*int32)(unsafe.Pointer(&_p.X6)) += 1
|
||||
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
if _iOuter == (_p.X0) {
|
||||
if _iOuter == _p.X0 {
|
||||
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
_run_sql(tls, _p, str(1399))
|
||||
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
@@ -409,7 +424,7 @@ _10:
|
||||
_worker_trace(tls, _p, str(1239), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt)))
|
||||
_i = i32(0)
|
||||
_14:
|
||||
if _i >= (_p.X1) {
|
||||
if _i >= _p.X1 {
|
||||
goto _17
|
||||
}
|
||||
_rc = bin.Xsqlite3_step(tls, _pStmt)
|
||||
@@ -422,12 +437,12 @@ _14:
|
||||
goto _14
|
||||
_17:
|
||||
bin.Xsqlite3_finalize(tls, _pStmt)
|
||||
if (_p.X5) != 0 {
|
||||
if _p.X5 != 0 {
|
||||
goto _3
|
||||
}
|
||||
_worker_delete_all_content(tls, _p, ((_p.X0)+_iOuter)%i32(2))
|
||||
_worker_delete_all_content(tls, _p, (_p.X0+_iOuter)%i32(2))
|
||||
_worker_close_connection(tls, _p)
|
||||
*(*unsafe.Pointer)(unsafe.Pointer(&(_p.X4))) = nil
|
||||
*(*unsafe.Pointer)(unsafe.Pointer(&_p.X4)) = nil
|
||||
_iOuter += 1
|
||||
goto _0
|
||||
_3:
|
||||
@@ -437,26 +452,29 @@ _3:
|
||||
return nil
|
||||
}
|
||||
|
||||
// Open the database connection for WorkerInfo. The order in which
|
||||
// the files are opened is a function of the tid value.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Open the database connection for WorkerInfo. The order in which
|
||||
// ** the files are opened is a function of the tid value.
|
||||
// */
|
||||
func _worker_open_connection(tls *crt.TLS, _p *XWorkerInfo, _iCnt int32) {
|
||||
var _x, _rc int32
|
||||
var _zFile *int8
|
||||
_x = ((_p.X0) + _iCnt) % i32(6)
|
||||
_zFile = bin.Xsqlite3_mprintf(tls, str(1572), int32(*(*uint8)(unsafe.Pointer(uintptr((unsafe.Pointer)((*[3]uint8)(unsafe.Pointer(uintptr((unsafe.Pointer)(&_worker_open_connectionØ00aOrderØ001))+3*uintptr(_x))))) + 1*uintptr(i32(0))))))
|
||||
_check_oom(tls, (unsafe.Pointer)(_zFile))
|
||||
_x = (_p.X0 + _iCnt) % i32(6)
|
||||
_zFile = bin.Xsqlite3_mprintf(tls, str(1572), int32(*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer((*[3]uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(&_worker_open_connectionØ00aOrderØ001))+3*uintptr(_x))))) + 1*uintptr(i32(0))))))
|
||||
_check_oom(tls, unsafe.Pointer(_zFile))
|
||||
_worker_trace(tls, _p, str(1586), unsafe.Pointer(_zFile))
|
||||
_rc = bin.Xsqlite3_open_v2(tls, _zFile, (**bin.Xsqlite3)(unsafe.Pointer((*unsafe.Pointer)(unsafe.Pointer(&(_p.X4))))), i32(131074), nil)
|
||||
_rc = bin.Xsqlite3_open_v2(tls, _zFile, (**bin.Xsqlite3)(unsafe.Pointer((*unsafe.Pointer)(unsafe.Pointer(&_p.X4)))), i32(131074), nil)
|
||||
if _rc != i32(0) {
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1594), unsafe.Pointer(_zFile), _p.X0)
|
||||
crt.Xexit(tls, i32(1))
|
||||
}
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zFile))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_zFile))
|
||||
_run_sql(tls, _p, str(1634))
|
||||
bin.Xsqlite3_busy_timeout(tls, (*bin.Xsqlite3)(_p.X4), i32(10000))
|
||||
_run_sql(tls, _p, str(1662))
|
||||
_run_sql(tls, _p, str(1686), int32(*(*uint8)(unsafe.Pointer(uintptr((unsafe.Pointer)((*[3]uint8)(unsafe.Pointer(uintptr((unsafe.Pointer)(&_worker_open_connectionØ00aOrderØ001))+3*uintptr(_x))))) + 1*uintptr(i32(1))))))
|
||||
_run_sql(tls, _p, str(1717), int32(*(*uint8)(unsafe.Pointer(uintptr((unsafe.Pointer)((*[3]uint8)(unsafe.Pointer(uintptr((unsafe.Pointer)(&_worker_open_connectionØ00aOrderØ001))+3*uintptr(_x))))) + 1*uintptr(i32(2))))))
|
||||
_run_sql(tls, _p, str(1686), int32(*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer((*[3]uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(&_worker_open_connectionØ00aOrderØ001))+3*uintptr(_x))))) + 1*uintptr(i32(1))))))
|
||||
_run_sql(tls, _p, str(1717), int32(*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer((*[3]uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(&_worker_open_connectionØ00aOrderØ001))+3*uintptr(_x))))) + 1*uintptr(i32(2))))))
|
||||
}
|
||||
|
||||
var _worker_open_connectionØ00aOrderØ001 [6][3]uint8
|
||||
@@ -465,7 +483,10 @@ func init() {
|
||||
_worker_open_connectionØ00aOrderØ001 = [6][3]uint8{[3]uint8{u8(1), u8(2), u8(3)}, [3]uint8{u8(1), u8(3), u8(2)}, [3]uint8{u8(2), u8(1), u8(3)}, [3]uint8{u8(2), u8(3), u8(1)}, [3]uint8{u8(3), u8(1), u8(2)}, [3]uint8{u8(3), u8(2), u8(1)}}
|
||||
}
|
||||
|
||||
// Create rows mn through mx in table iTab for the given worker
|
||||
// C comment
|
||||
// /*
|
||||
// ** Create rows mn through mx in table iTab for the given worker
|
||||
// */
|
||||
func _worker_add_content(tls *crt.TLS, _p *XWorkerInfo, _mn int32, _mx int32, _iTab int32) {
|
||||
var _zTabDef *int8
|
||||
switch _iTab {
|
||||
@@ -492,10 +513,13 @@ _4:
|
||||
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
_run_sql(tls, _p, str(1799), _mn, _mx, unsafe.Pointer(_zTabDef), _p.X0)
|
||||
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1
|
||||
*(*int32)(unsafe.Pointer(&_p.X6)) += 1
|
||||
}
|
||||
|
||||
// Prepare a single SQL query
|
||||
// C comment
|
||||
// /*
|
||||
// ** Prepare a single SQL query
|
||||
// */
|
||||
func _prep_sql(tls *crt.TLS, _db unsafe.Pointer, _zFormat *int8, args ...interface{}) (r0 unsafe.Pointer) {
|
||||
var _rc, _i int32
|
||||
var _zSql *int8
|
||||
@@ -505,7 +529,7 @@ func _prep_sql(tls *crt.TLS, _db unsafe.Pointer, _zFormat *int8, args ...interfa
|
||||
_ap = args
|
||||
_zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
|
||||
_ap = nil
|
||||
_check_oom(tls, (unsafe.Pointer)(_zSql))
|
||||
_check_oom(tls, unsafe.Pointer(_zSql))
|
||||
_i = i32(0)
|
||||
_0:
|
||||
if _i >= i32(1000) {
|
||||
@@ -522,24 +546,30 @@ _3:
|
||||
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(991), _rc, bin.Xsqlite3_extended_errcode(tls, (*bin.Xsqlite3)(_db)), unsafe.Pointer(bin.Xsqlite3_errmsg(tls, (*bin.Xsqlite3)(_db))), unsafe.Pointer(_zSql))
|
||||
crt.Xexit(tls, i32(1))
|
||||
}
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql))
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
|
||||
return _pStmt
|
||||
}
|
||||
|
||||
// Set an error message on a worker
|
||||
// C comment
|
||||
// /*
|
||||
// ** Set an error message on a worker
|
||||
// */
|
||||
func _worker_error(tls *crt.TLS, _p *XWorkerInfo, _zFormat *int8, args ...interface{}) {
|
||||
var _ap []interface{}
|
||||
*(*int32)(unsafe.Pointer(&(_p.X5))) += 1
|
||||
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_p.X7))
|
||||
*(*int32)(unsafe.Pointer(&_p.X5)) += 1
|
||||
bin.Xsqlite3_free(tls, unsafe.Pointer(_p.X7))
|
||||
_ap = args
|
||||
*(**int8)(unsafe.Pointer(&(_p.X7))) = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
|
||||
*(**int8)(unsafe.Pointer(&_p.X7)) = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
|
||||
_ap = nil
|
||||
}
|
||||
|
||||
// Delete all content in the three databases associated with a
|
||||
// single thread. Make this happen all in a single transaction if
|
||||
// inTrans is true, or separately for each database if inTrans is
|
||||
// false.
|
||||
// C comment
|
||||
// /*
|
||||
// ** Delete all content in the three databases associated with a
|
||||
// ** single thread. Make this happen all in a single transaction if
|
||||
// ** inTrans is true, or separately for each database if inTrans is
|
||||
// ** false.
|
||||
// */
|
||||
func _worker_delete_all_content(tls *crt.TLS, _p *XWorkerInfo, _inTrans int32) {
|
||||
if _inTrans != 0 {
|
||||
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
@@ -549,30 +579,33 @@ func _worker_delete_all_content(tls *crt.TLS, _p *XWorkerInfo, _inTrans int32) {
|
||||
_run_sql(tls, _p, str(2009), _p.X0)
|
||||
_run_sql(tls, _p, str(2037))
|
||||
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1
|
||||
*(*int32)(unsafe.Pointer(&_p.X6)) += 1
|
||||
goto _1
|
||||
}
|
||||
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
_run_sql(tls, _p, str(1953), _p.X0)
|
||||
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1
|
||||
*(*int32)(unsafe.Pointer(&_p.X6)) += 1
|
||||
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
_run_sql(tls, _p, str(1981), _p.X0)
|
||||
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1
|
||||
*(*int32)(unsafe.Pointer(&_p.X6)) += 1
|
||||
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
_run_sql(tls, _p, str(2009), _p.X0)
|
||||
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9))
|
||||
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1
|
||||
*(*int32)(unsafe.Pointer(&_p.X6)) += 1
|
||||
_1:
|
||||
}
|
||||
|
||||
// Close the worker database connection
|
||||
// C comment
|
||||
// /*
|
||||
// ** Close the worker database connection
|
||||
// */
|
||||
func _worker_close_connection(tls *crt.TLS, _p *XWorkerInfo) {
|
||||
if (_p.X4) != nil {
|
||||
if _p.X4 != nil {
|
||||
_worker_trace(tls, _p, str(2044))
|
||||
bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_p.X4))
|
||||
*(*unsafe.Pointer)(unsafe.Pointer(&(_p.X4))) = nil
|
||||
*(*unsafe.Pointer)(unsafe.Pointer(&_p.X4)) = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user