Regenerate Linux/386 using lates CCGO.

modified:   internal/bin/bin_linux_386.go
	modified:   internal/mptest/mptest_linux_386.go
	modified:   internal/threadtest1/threadtest1_linux_386.go
	modified:   internal/threadtest2/threadtest2_linux_386.go
	modified:   internal/threadtest3/threadtest3_linux_386.go
	modified:   internal/threadtest4/threadtest4_linux_386.go
This commit is contained in:
Jan Mercl
2017-07-15 22:00:16 +02:00
parent 43512da125
commit 1b11dbb188
6 changed files with 61770 additions and 60361 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +1,29 @@
// Code generated by ccgo. DO NOT EDIT. // Code generated by ccgo. DO NOT EDIT.
// threadtest1.c // threadtest1
// /*
// 2002 January 15 // ** 2002 January 15
// // **
// The author disclaims copyright to this source code. In place of // ** The author disclaims copyright to this source code. In place of
// a legal notice, here is a blessing: // ** a legal notice, here is a blessing:
// // **
// May you do good and not evil. // ** May you do good and not evil.
// May you find forgiveness for yourself and forgive others. // ** May you find forgiveness for yourself and forgive others.
// May you share freely, never taking more than you give. // ** May you share freely, never taking more than you give.
// // **
// ************************************************************************* // *************************************************************************
// This file implements a simple standalone program used to test whether // ** This file implements a simple standalone program used to test whether
// or not the SQLite library is threadsafe. // ** or not the SQLite library is threadsafe.
// // **
// Testing the thread safety of SQLite is difficult because there are very // ** Testing the thread safety of SQLite is difficult because there are very
// few places in the code that are even potentially unsafe, and those // ** 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 // ** 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 // ** is compiled with its mutexes disabled, it is likely to work correctly
// in a multi-threaded program most of the time. // ** in a multi-threaded program most of the time.
// // **
// This file is NOT part of the standard SQLite library. It is used for // ** This file is NOT part of the standard SQLite library. It is used for
// testing only. // ** testing only.
// */
package main package main
import ( import (
@@ -61,13 +61,13 @@ var X__stdfiles [3]unsafe.Pointer
var Xstdout unsafe.Pointer var Xstdout unsafe.Pointer
func init() { func init() {
Xstdout = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 4) Xstdout = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 4)
} }
var Xstderr unsafe.Pointer var Xstderr unsafe.Pointer
func init() { func init() {
Xstderr = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 8) Xstderr = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
} }
func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) { func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
@@ -75,68 +75,72 @@ func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
var _id uint32 var _id uint32
var _zFile, _4_zDb, _4_zJournal *int8 var _zFile, _4_zDb, _4_zJournal *int8
var _2_zBuf, _6_zBuf [200]int8 var _2_zBuf, _6_zBuf [200]int8
r0 = i32(0) r0 = int32(0)
if (_argc > i32(2)) && (crt.Xstrcmp(tls, *(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 4*uintptr(i32(1)))), str(0)) == i32(0)) { if (_argc > int32(2)) && (crt.Xstrcmp(tls, *elem0(_argv, uintptr(1)), str(0)) == int32(0)) {
_verbose = i32(1) _verbose = int32(1)
bug20530(_verbose) bug20530(_verbose)
_argc -= 1 _argc -= 1
*(*uintptr)(unsafe.Pointer(&_argv)) += uintptr(4) *(*uintptr)(unsafe.Pointer(&_argv)) += uintptr(4)
} }
if (_argc < i32(2)) || (store0(&_n, crt.Xatoi(tls, *(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 4*uintptr(i32(1)))))) < i32(1)) { if (_argc < int32(2)) || (store1(&_n, crt.Xatoi(tls, *elem0(_argv, uintptr(1)))) < int32(1)) {
_n = i32(10) _n = int32(10)
} }
_i = i32(0) _i = int32(0)
_4: _4:
if _i >= _n { if _i >= _n {
goto _7 goto _7
} }
crt.Xsprintf(tls, (*int8)(unsafe.Pointer(&_2_zBuf)), str(3), (_i+i32(1))/i32(2)) crt.Xsprintf(tls, (*int8)(unsafe.Pointer(&_2_zBuf)), str(3), (_i+int32(1))/int32(2))
crt.Xunlink(tls, (*int8)(unsafe.Pointer(&_2_zBuf))) crt.Xunlink(tls, (*int8)(unsafe.Pointer(&_2_zBuf)))
_i += 1 _i += 1
goto _4 goto _4
_7: _7:
_i = i32(0) _i = int32(0)
_8: _8:
if _i >= _n { if _i >= _n {
goto _11 goto _11
} }
_zFile = bin.Xsqlite3_mprintf(tls, str(13), (_i%i32(2))+i32(1), (_i+i32(2))/i32(2)) _zFile = bin.Xsqlite3_mprintf(tls, str(13), (_i%int32(2))+int32(1), (_i+int32(2))/int32(2))
if (_i % i32(2)) == i32(0) { if (_i % int32(2)) == int32(0) {
_4_zDb = (*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_zFile)) + 1*uintptr(i32(2)))) _4_zDb = elem2(_zFile, uintptr(2))
_4_zJournal = bin.Xsqlite3_mprintf(tls, str(26), unsafe.Pointer(_4_zDb)) _4_zJournal = bin.Xsqlite3_mprintf(tls, str(26), unsafe.Pointer(_4_zDb))
crt.Xunlink(tls, _4_zDb) crt.Xunlink(tls, _4_zDb)
crt.Xunlink(tls, _4_zJournal) 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) crt.Xpthread_detach(tls, _id)
_i += 1 _i += 1
goto _8 goto _8
_11: _11:
crt.Xpthread_mutex_lock(tls, &Xlock) crt.Xpthread_mutex_lock(tls, &Xlock)
_13: _13:
if Xthread_cnt > i32(0) { if Xthread_cnt > int32(0) {
crt.Xpthread_cond_wait(tls, &Xsig, &Xlock) crt.Xpthread_cond_wait(tls, &Xsig, &Xlock)
goto _13 goto _13
} }
crt.Xpthread_mutex_unlock(tls, &Xlock) crt.Xpthread_mutex_unlock(tls, &Xlock)
_i = i32(0) _i = int32(0)
_15: _15:
if _i >= _n { if _i >= _n {
goto _18 goto _18
} }
crt.Xsprintf(tls, (*int8)(unsafe.Pointer(&_6_zBuf)), str(3), (_i+i32(1))/i32(2)) crt.Xsprintf(tls, (*int8)(unsafe.Pointer(&_6_zBuf)), str(3), (_i+int32(1))/int32(2))
crt.Xunlink(tls, (*int8)(unsafe.Pointer(&_6_zBuf))) crt.Xunlink(tls, (*int8)(unsafe.Pointer(&_6_zBuf)))
_i += 1 _i += 1
goto _15 goto _15
_18: _18:
return i32(0) return int32(0)
_ = _2_zBuf _ = _2_zBuf
_ = _6_zBuf _ = _6_zBuf
panic(0) panic(0)
} }
// C comment
// /*
// ** Enable for tracing
// */
var _verbose int32 var _verbose int32
func _worker_bee(tls *crt.TLS, _pArg unsafe.Pointer) (r0 unsafe.Pointer) { func _worker_bee(tls *crt.TLS, _pArg unsafe.Pointer) (r0 unsafe.Pointer) {
@@ -152,56 +156,56 @@ func _worker_bee(tls *crt.TLS, _pArg unsafe.Pointer) (r0 unsafe.Pointer) {
crt.Xpthread_mutex_unlock(tls, &Xlock) crt.Xpthread_mutex_unlock(tls, &Xlock)
crt.Xprintf(tls, str(37), unsafe.Pointer(_zFilename)) crt.Xprintf(tls, str(37), unsafe.Pointer(_zFilename))
crt.Xfflush(tls, (*crt.XFILE)(Xstdout)) crt.Xfflush(tls, (*crt.XFILE)(Xstdout))
_cnt = i32(0) _cnt = int32(0)
_0: _0:
if _cnt >= i32(10) { if _cnt >= int32(10) {
goto _3 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, elem2(_zFilename, uintptr(2)), (**bin.Xsqlite3)(unsafe.Pointer(&_db)))
if _db == nil { if _db == nil {
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(48), unsafe.Pointer(_zFilename)) crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(48), unsafe.Pointer(_zFilename))
_Exit(tls, i32(1)) _Exit(tls, int32(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) Xdb_execute(tls, _db, _zFilename, str(64), _t)
_i = i32(1) _i = int32(1)
_5: _5:
if _i > i32(100) { if _i > int32(100) {
goto _8 goto _8
} }
Xdb_execute(tls, _db, _zFilename, str(89), _t, _i, _i*i32(2), _i*_i) Xdb_execute(tls, _db, _zFilename, str(89), _t, _i, _i*int32(2), _i*_i)
_i += 1 _i += 1
goto _5 goto _5
_8: _8:
_az = Xdb_query(tls, _db, _zFilename, str(123), _t) _az = Xdb_query(tls, _db, _zFilename, str(123), _t)
Xdb_check(tls, _zFilename, str(148), _az, unsafe.Pointer(str(156)), i32(0)) Xdb_check(tls, _zFilename, str(148), _az, unsafe.Pointer(str(156)), int32(0))
_az = Xdb_query(tls, _db, _zFilename, str(160), _t) _az = Xdb_query(tls, _db, _zFilename, str(160), _t)
Xdb_check(tls, _zFilename, str(183), _az, unsafe.Pointer(str(190)), i32(0)) Xdb_check(tls, _zFilename, str(183), _az, unsafe.Pointer(str(190)), int32(0))
Xdb_execute(tls, _db, _zFilename, str(194), _t) Xdb_execute(tls, _db, _zFilename, str(196), _t)
_az = Xdb_query(tls, _db, _zFilename, str(160), _t) _az = Xdb_query(tls, _db, _zFilename, str(160), _t)
Xdb_check(tls, _zFilename, str(221), _az, unsafe.Pointer(str(229)), i32(0)) Xdb_check(tls, _zFilename, str(223), _az, unsafe.Pointer(str(231)), int32(0))
_i = i32(1) _i = int32(1)
_9: _9:
if _i > i32(50) { if _i > int32(50) {
goto _12 goto _12
} }
_az = Xdb_query(tls, _db, _zFilename, str(232), _t, _i) _az = Xdb_query(tls, _db, _zFilename, str(236), _t, _i)
crt.Xsprintf(tls, (*int8)(unsafe.Pointer(&_4_z1)), str(264), _i*i32(2)) crt.Xsprintf(tls, (*int8)(unsafe.Pointer(&_4_z1)), str(268), _i*int32(2))
crt.Xsprintf(tls, (*int8)(unsafe.Pointer(&_4_z2)), str(264), _i*_i) crt.Xsprintf(tls, (*int8)(unsafe.Pointer(&_4_z2)), str(268), _i*_i)
Xdb_check(tls, _zFilename, str(267), _az, unsafe.Pointer((*int8)(unsafe.Pointer(&_4_z1))), unsafe.Pointer((*int8)(unsafe.Pointer(&_4_z2))), i32(0)) Xdb_check(tls, _zFilename, str(271), _az, unsafe.Pointer(&_4_z1), unsafe.Pointer(&_4_z2), int32(0))
_i += 1 _i += 1
goto _9 goto _9
_12: _12:
Xdb_execute(tls, _db, _zFilename, str(276), _t) Xdb_execute(tls, _db, _zFilename, str(280), _t)
bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_db)) bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_db))
_cnt += 1 _cnt += 1
goto _0 goto _0
_3: _3:
crt.Xprintf(tls, str(292), unsafe.Pointer(_zFilename)) crt.Xprintf(tls, str(296), unsafe.Pointer(_zFilename))
crt.Xfflush(tls, (*crt.XFILE)(Xstdout)) crt.Xfflush(tls, (*crt.XFILE)(Xstdout))
crt.Xpthread_mutex_lock(tls, &Xlock) crt.Xpthread_mutex_lock(tls, &Xlock)
Xthread_cnt -= 1 Xthread_cnt -= 1
if Xthread_cnt <= i32(0) { if Xthread_cnt <= int32(0) {
crt.Xpthread_cond_signal(tls, &Xsig) crt.Xpthread_cond_signal(tls, &Xsig)
} }
crt.Xpthread_mutex_unlock(tls, &Xlock) crt.Xpthread_mutex_unlock(tls, &Xlock)
@@ -217,21 +221,30 @@ var Xlock crt.Xpthread_mutex_t
var Xthread_cnt int32 var Xthread_cnt int32
// Come here to die. // C comment
// /*
// ** Come here to die.
// */
func _Exit(tls *crt.TLS, _rc int32) { func _Exit(tls *crt.TLS, _rc int32) {
crt.Xexit(tls, _rc) 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) { func _db_is_locked(tls *crt.TLS, _NotUsed unsafe.Pointer, _iCount int32) (r0 int32) {
if _verbose != 0 { if _verbose != 0 {
crt.Xprintf(tls, str(301), unsafe.Pointer((*int8)(_NotUsed)), _iCount) crt.Xprintf(tls, str(305), _NotUsed, _iCount)
} }
crt.Xusleep(tls, uint32(i32(100))) crt.Xusleep(tls, uint32(100))
return bool2int(_iCount < i32(25)) return bool2int(_iCount < int32(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{}) { func Xdb_execute(tls *crt.TLS, _db unsafe.Pointer, _zFile *int8, _zFormat *int8, args ...interface{}) {
var _rc int32 var _rc int32
var _zSql, _zErrMsg *int8 var _zSql, _zErrMsg *int8
@@ -241,27 +254,30 @@ func Xdb_execute(tls *crt.TLS, _db unsafe.Pointer, _zFile *int8, _zFormat *int8,
_zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap) _zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
_ap = nil _ap = nil
if _verbose != 0 { if _verbose != 0 {
crt.Xprintf(tls, str(314), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql)) crt.Xprintf(tls, str(318), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql))
} }
_0: _0:
_rc = bin.Xsqlite3_exec(tls, (*bin.Xsqlite3)(_db), _zSql, nil, nil, &_zErrMsg) _rc = bin.Xsqlite3_exec(tls, (*bin.Xsqlite3)(_db), _zSql, nil, nil, &_zErrMsg)
if _rc == i32(5) { if _rc == int32(5) {
goto _0 goto _0
} }
if _verbose != 0 { if _verbose != 0 {
crt.Xprintf(tls, str(327), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql)) crt.Xprintf(tls, str(331), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql))
} }
if _zErrMsg != nil { if _zErrMsg != nil {
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(340), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql), unsafe.Pointer(_zErrMsg)) crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(344), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql), unsafe.Pointer(_zErrMsg))
crt.Xfree(tls, (unsafe.Pointer)(_zErrMsg)) crt.Xfree(tls, unsafe.Pointer(_zErrMsg))
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql)) bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
_Exit(tls, i32(1)) _Exit(tls, int32(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 // C comment
// as an empty string. The list is terminated by a single NULL pointer. // /*
// ** 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) { func Xdb_query(tls *crt.TLS, _db unsafe.Pointer, _zFile *int8, _zFormat *int8, args ...interface{}) (r0 **int8) {
var _rc int32 var _rc int32
var _zSql, _zErrMsg *int8 var _zSql, _zErrMsg *int8
@@ -271,95 +287,98 @@ func Xdb_query(tls *crt.TLS, _db unsafe.Pointer, _zFile *int8, _zFormat *int8, a
_ap = args _ap = args
_zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap) _zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
_ap = nil _ap = nil
crt.Xmemset(tls, (unsafe.Pointer)(&_sResult), i32(0), u32(16)) crt.Xmemset(tls, unsafe.Pointer(&_sResult), int32(0), uint32(16))
*(**int8)(unsafe.Pointer(&(_sResult.X0))) = _zFile _sResult.XzFile = _zFile
if _verbose != 0 { if _verbose != 0 {
crt.Xprintf(tls, str(369), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql)) 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) { if _rc != int32(17) {
goto _1 goto _1
} }
if _zErrMsg != nil { 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: _1:
if _verbose != 0 { if _verbose != 0 {
crt.Xprintf(tls, str(383), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql)) crt.Xprintf(tls, str(387), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql))
} }
if _zErrMsg != nil { if _zErrMsg != nil {
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(395), unsafe.Pointer(_zFile), unsafe.Pointer(_zSql), unsafe.Pointer(_zErrMsg)) 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(_zErrMsg))
crt.Xfree(tls, (unsafe.Pointer)(_zSql)) crt.Xfree(tls, unsafe.Pointer(_zSql))
_Exit(tls, i32(1)) _Exit(tls, int32(1))
} }
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql)) bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
if (_sResult.X3) == nil { if _sResult.XazElem == nil {
_db_query_callback(tls, (unsafe.Pointer)(&_sResult), i32(0), nil, nil) _db_query_callback(tls, unsafe.Pointer(&_sResult), int32(0), nil, nil)
} }
*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_sResult.X3)) + 4*uintptr(_sResult.X1))) = nil *elem0(_sResult.XazElem, uintptr(_sResult.XnElem)) = nil
return _sResult.X3 return _sResult.XazElem
_ = _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) { func _db_query_callback(tls *crt.TLS, _pUser unsafe.Pointer, _nArg int32, _azArg **int8, _NotUsed **int8) (r0 int32) {
var _i int32 var _i int32
var _pResult *TQueryResult var _pResult *TQueryResult
_pResult = (*TQueryResult)(_pUser) _pResult = (*TQueryResult)(_pUser)
if ((_pResult.X1) + _nArg) < (_pResult.X2) { if (_pResult.XnElem + _nArg) < _pResult.XnAlloc {
goto _0 goto _0
} }
if (_pResult.X2) == i32(0) { if _pResult.XnAlloc == int32(0) {
*(*int32)(unsafe.Pointer(&(_pResult.X2))) = _nArg + i32(1) _pResult.XnAlloc = _nArg + int32(1)
goto _2 goto _2
} }
*(*int32)(unsafe.Pointer(&(_pResult.X2))) = (((_pResult.X2) * i32(2)) + _nArg) + i32(1) _pResult.XnAlloc = ((_pResult.XnAlloc * int32(2)) + _nArg) + int32(1)
_2: _2:
*(***int8)(unsafe.Pointer(&(_pResult.X3))) = (**int8)(crt.Xrealloc(tls, (unsafe.Pointer)(_pResult.X3), uint32(_pResult.X2)*u32(4))) _pResult.XazElem = (**int8)(crt.Xrealloc(tls, unsafe.Pointer(_pResult.XazElem), uint32(_pResult.XnAlloc)*uint32(4)))
if (_pResult.X3) == nil { if _pResult.XazElem == nil {
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(422), unsafe.Pointer(_pResult.X0)) crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(426), unsafe.Pointer(_pResult.XzFile))
return i32(1) return int32(1)
} }
_0: _0:
if _azArg == nil { if _azArg == nil {
return i32(0) return int32(0)
} }
_i = i32(0) _i = int32(0)
_5: _5:
if _i >= _nArg { if _i >= _nArg {
goto _8 goto _8
} }
*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_pResult.X3)) + 4*uintptr(postInc0((*int32)(unsafe.Pointer(&(_pResult.X1))), int32(1))))) = bin.Xsqlite3_mprintf(tls, str(441), unsafe.Pointer(func() *int8 { *elem0(_pResult.XazElem, uintptr(postInc1(&_pResult.XnElem, 1))) = bin.Xsqlite3_mprintf(tls, str(445), unsafe.Pointer(func() *int8 {
if (*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_azArg)) + 4*uintptr(_i)))) != nil { if (*elem0(_azArg, uintptr(_i))) != nil {
return (*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_azArg)) + 4*uintptr(_i)))) return (*elem0(_azArg, uintptr(_i)))
} }
return str(444) return str(448)
}())) }()))
_i += 1 _i += 1
goto _5 goto _5
_8: _8:
return i32(0) return int32(0)
} }
// Check results // C comment
// /*
// ** Check results
// */
func Xdb_check(tls *crt.TLS, _zFile *int8, _zMsg *int8, _az **int8, args ...interface{}) { func Xdb_check(tls *crt.TLS, _zFile *int8, _zMsg *int8, _az **int8, args ...interface{}) {
var _i int32 var _i int32
var _z *int8 var _z *int8
var _ap []interface{} var _ap []interface{}
_ap = args _ap = args
_i = i32(0) _i = int32(0)
_0: _0:
if store1(&_z, (*int8)(crt.VAPointer(&_ap))) == nil { if store2(&_z, (*int8)(crt.VAPointer(&_ap))) == nil {
goto _3 goto _3
} }
if ((*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 4*uintptr(_i)))) == nil) || (crt.Xstrcmp(tls, *(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 4*uintptr(_i))), _z) != i32(0)) { if ((*elem0(_az, uintptr(_i))) == nil) || (crt.Xstrcmp(tls, *elem0(_az, uintptr(_i)), _z) != int32(0)) {
crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(445), unsafe.Pointer(_zFile), unsafe.Pointer(_zMsg), _i+i32(1), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 4*uintptr(_i))))) crt.Xfprintf(tls, (*crt.XFILE)(Xstdout), str(449), unsafe.Pointer(_zFile), unsafe.Pointer(_zMsg), _i+int32(1), unsafe.Pointer(*elem0(_az, uintptr(_i))))
Xdb_query_free(tls, _az) Xdb_query_free(tls, _az)
_Exit(tls, i32(1)) _Exit(tls, int32(1))
} }
_i += 1 _i += 1
goto _0 goto _0
@@ -368,19 +387,22 @@ _3:
Xdb_query_free(tls, _az) 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) { func Xdb_query_free(tls *crt.TLS, _az **int8) {
var _i int32 var _i int32
_i = i32(0) _i = int32(0)
_0: _0:
if (*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 4*uintptr(_i)))) == nil { if (*elem0(_az, uintptr(_i))) == nil {
goto _3 goto _3
} }
bin.Xsqlite3_free(tls, (unsafe.Pointer)(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_az)) + 4*uintptr(_i))))) bin.Xsqlite3_free(tls, unsafe.Pointer(*elem0(_az, uintptr(_i))))
_i += 1 _i += 1
goto _0 goto _0
_3: _3:
crt.Xfree(tls, (unsafe.Pointer)(_az)) crt.Xfree(tls, unsafe.Pointer(_az))
} }
var Xsig crt.Xpthread_cond_t var Xsig crt.Xpthread_cond_t
@@ -392,30 +414,28 @@ func bool2int(b bool) int32 {
return 0 return 0
} }
func bug20530(interface{}) {} //TODO remove when https://github.com/golang/go/issues/20530 is fixed. func bug20530(interface{}) {} //TODO remove when https://github.com/golang/go/issues/20530 is fixed.
func i16(n int16) int16 { return n }
func i32(n int32) int32 { return n }
func i64(n int64) int64 { return n }
func i8(n int8) int8 { return n }
func init() { nzf32 *= -1; nzf64 *= -1 } func init() { nzf32 *= -1; nzf64 *= -1 }
func u16(n uint16) uint16 { return n }
func u32(n uint32) uint32 { return n }
func u64(n uint64) uint64 { return n }
func u8(n byte) byte { return n }
var inf = math.Inf(1) var inf = math.Inf(1)
var nzf32 float32 // -0.0 var nzf32 float32 // -0.0
var nzf64 float64 // -0.0 var nzf64 float64 // -0.0
func postInc0(p *int32, d int32) int32 { v := *p; *p += d; return v } func elem0(a **int8, index uintptr) **int8 {
func store1(p **int8, v *int8) *int8 { *p = v; return v } return (**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(a)) + 4*index))
func store0(p *int32, v int32) int32 { *p = v; return v } }
func elem2(a *int8, index uintptr) *int8 {
return (*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(a)) + 1*index))
}
func postInc1(p *int32, d int32) int32 { v := *p; *p += d; return v }
func store2(p **int8, v *int8) *int8 { *p = v; return v }
func store1(p *int32, v int32) int32 { *p = v; return v }
type TQueryResult struct { type TQueryResult struct {
X0 *int8 XzFile *int8
X1 int32 XnElem int32
X2 int32 XnAlloc int32
X3 **int8 XazElem **int8
} // t2 struct{*int8,int32,int32,**int8} } // t3 struct{zFile *int8,nElem int32,nAlloc int32,azElem **int8}
func str(n int) *int8 { return (*int8)(unsafe.Pointer(&strTab[n])) } func str(n int) *int8 { return (*int8)(unsafe.Pointer(&strTab[n])) }
func wstr(n int) *int32 { return (*int32)(unsafe.Pointer(&strTab[n])) } func wstr(n int) *int32 { return (*int32)(unsafe.Pointer(&strTab[n])) }
var strTab = []byte("-v\x00testdb-%d\x00%d.testdb-%d\x00%s-journal\x00%s: START\x0a\x00%s: can't open\x0a\x00CREATE TABLE t%d(a,b,c);\x00INSERT INTO t%d VALUES(%d,%d,%d);\x00SELECT count(*) FROM t%d\x00tX size\x00100\x00SELECT avg(b) FROM t%d\x00tX avg\x00101\x00DELETE FROM t%d WHERE a>50\x00tX avg2\x0051\x00SELECT b, c FROM t%d WHERE a=%d\x00%d\x00readback\x00DROP TABLE t%d;\x00%s: END\x0a\x00BUSY %s #%d\x0a\x00EXEC %s: %s\x0a\x00DONE %s: %s\x0a\x00%s: command failed: %s - %s\x0a\x00QUERY %s: %s\x0a\x00DONE %s %s\x0a\x00%s: query failed: %s - %s\x0a\x00%s: malloc failed\x0a\x00%s\x00\x00%s: %s: bad result in column %d: %s\x0a\x00") var strTab = []byte("-v\x00testdb-%d\x00%d.testdb-%d\x00%s-journal\x00%s: START\x0a\x00%s: can't open\x0a\x00CREATE TABLE t%d(a,b,c);\x00INSERT INTO t%d VALUES(%d,%d,%d);\x00SELECT count(*) FROM t%d\x00tX size\x00100\x00SELECT avg(b) FROM t%d\x00tX avg\x00101.0\x00DELETE FROM t%d WHERE a>50\x00tX avg2\x0051.0\x00SELECT b, c FROM t%d WHERE a=%d\x00%d\x00readback\x00DROP TABLE t%d;\x00%s: END\x0a\x00BUSY %s #%d\x0a\x00EXEC %s: %s\x0a\x00DONE %s: %s\x0a\x00%s: command failed: %s - %s\x0a\x00QUERY %s: %s\x0a\x00DONE %s %s\x0a\x00%s: query failed: %s - %s\x0a\x00%s: malloc failed\x0a\x00%s\x00\x00%s: %s: bad result in column %d: %s\x0a\x00")

View File

@@ -1,23 +1,23 @@
// Code generated by ccgo. DO NOT EDIT. // Code generated by ccgo. DO NOT EDIT.
// threadtest2.c // threadtest2
// /*
// 2004 January 13 // ** 2004 January 13
// // **
// The author disclaims copyright to this source code. In place of // ** The author disclaims copyright to this source code. In place of
// a legal notice, here is a blessing: // ** a legal notice, here is a blessing:
// // **
// May you do good and not evil. // ** May you do good and not evil.
// May you find forgiveness for yourself and forgive others. // ** May you find forgiveness for yourself and forgive others.
// May you share freely, never taking more than you give. // ** May you share freely, never taking more than you give.
// // **
// ************************************************************************* // *************************************************************************
// This file implements a simple standalone program used to test whether // ** This file implements a simple standalone program used to test whether
// or not the SQLite library is threadsafe. // ** or not the SQLite library is threadsafe.
// // **
// This file is NOT part of the standard SQLite library. It is used for // ** This file is NOT part of the standard SQLite library. It is used for
// testing only. // ** testing only.
// */
package main package main
import ( import (
@@ -55,84 +55,90 @@ var X__stdfiles [3]unsafe.Pointer
var Xstdout unsafe.Pointer var Xstdout unsafe.Pointer
func init() { func init() {
Xstdout = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 4) Xstdout = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 4)
} }
var Xstderr unsafe.Pointer var Xstderr unsafe.Pointer
func init() { func init() {
Xstderr = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 8) Xstderr = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
} }
// 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) { func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
var _i, _rc int32 var _i, _rc int32
var _1_zJournal *int8 var _1_zJournal *int8
var _db unsafe.Pointer var _db unsafe.Pointer
var _aThread [5]uint32 var _aThread [5]uint32
r0 = i32(0) r0 = int32(0)
if crt.Xstrcmp(tls, str(0), str(8)) != 0 { if crt.Xstrcmp(tls, str(0), str(8)) != 0 {
_1_zJournal = bin.Xsqlite3_mprintf(tls, str(17), unsafe.Pointer(str(0))) _1_zJournal = bin.Xsqlite3_mprintf(tls, str(17), unsafe.Pointer(str(0)))
crt.Xunlink(tls, str(0)) crt.Xunlink(tls, str(0))
crt.Xunlink(tls, _1_zJournal) 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))) bin.Xsqlite3_open(tls, str(0), (**bin.Xsqlite3)(unsafe.Pointer(&_db)))
if _db == nil { if _db == nil {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(28)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(28))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
_rc = bin.Xsqlite3_exec(tls, (*bin.Xsqlite3)(_db), str(59), nil, nil, nil) _rc = bin.Xsqlite3_exec(tls, (*bin.Xsqlite3)(_db), str(59), nil, nil, nil)
if _rc != 0 { if _rc != 0 {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(79), _rc) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(79), _rc)
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_db)) bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_db))
_i = i32(0) _i = int32(0)
_3: _3:
if uint32(_i) >= u32(5) { if uint32(_i) >= uint32(5) {
goto _6 goto _6
} }
crt.Xpthread_create(tls, (*uint32)(unsafe.Pointer(uintptr((unsafe.Pointer)(&_aThread))+4*uintptr(_i))), nil, Xworker, (unsafe.Pointer)(uintptr(_i))) crt.Xpthread_create(tls, elem0((*uint32)(unsafe.Pointer(&_aThread)), uintptr(_i)), nil, Xworker, crt.U2P(uintptr(_i)))
_i += 1 _i += 1
goto _3 goto _3
_6: _6:
_i = i32(0) _i = int32(0)
_7: _7:
if uint32(_i) >= u32(5) { if uint32(_i) >= uint32(5) {
goto _10 goto _10
} }
crt.Xpthread_join(tls, *(*uint32)(unsafe.Pointer(uintptr((unsafe.Pointer)(&_aThread)) + 4*uintptr(_i))), nil) crt.Xpthread_join(tls, *elem0((*uint32)(unsafe.Pointer(&_aThread)), uintptr(_i)), nil)
_i += 1 _i += 1
goto _7 goto _7
_10: _10:
if Xall_stop == 0 { if Xall_stop == 0 {
crt.Xprintf(tls, str(107)) crt.Xprintf(tls, str(107))
return i32(0) return int32(0)
} }
crt.Xprintf(tls, str(129)) crt.Xprintf(tls, str(129))
return i32(1) return int32(1)
_ = _aThread _ = _aThread
panic(0) 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) { func Xworker(tls *crt.TLS, _workerArg unsafe.Pointer) (r0 unsafe.Pointer) {
var _id, _rc, _cnt int32 var _id, _rc, _cnt int32
var _db unsafe.Pointer var _db unsafe.Pointer
_id = int32(uintptr(_workerArg)) _id = int32(crt.P2U(_workerArg))
_cnt = i32(0) _cnt = int32(0)
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(147), _id) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(147), _id)
_0: _0:
if Xall_stop != 0 || postInc0(&_cnt, int32(1)) >= i32(10000) { if Xall_stop != 0 || postInc1(&_cnt, 1) >= int32(10000) {
goto _1 goto _1
} }
if (_cnt % i32(100)) == i32(0) { if (_cnt % int32(100)) == int32(0) {
crt.Xprintf(tls, str(167), _id, _cnt) crt.Xprintf(tls, str(167), _id, _cnt)
} }
_3: _3:
if bin.Xsqlite3_open(tls, str(0), (**bin.Xsqlite3)(unsafe.Pointer(&_db))) != i32(0) { if bin.Xsqlite3_open(tls, str(0), (**bin.Xsqlite3)(unsafe.Pointer(&_db))) != int32(0) {
crt.Xsched_yield(tls) crt.Xsched_yield(tls)
goto _3 goto _3
} }
@@ -152,6 +158,11 @@ _1:
panic(0) panic(0)
} }
// C comment
// /*
// ** When this variable becomes non-zero, all threads stop
// ** what they are doing.
// */
var Xall_stop int32 var Xall_stop int32
func bool2int(b bool) int32 { func bool2int(b bool) int32 {
@@ -161,20 +172,15 @@ func bool2int(b bool) int32 {
return 0 return 0
} }
func bug20530(interface{}) {} //TODO remove when https://github.com/golang/go/issues/20530 is fixed. func bug20530(interface{}) {} //TODO remove when https://github.com/golang/go/issues/20530 is fixed.
func i16(n int16) int16 { return n }
func i32(n int32) int32 { return n }
func i64(n int64) int64 { return n }
func i8(n int8) int8 { return n }
func init() { nzf32 *= -1; nzf64 *= -1 } func init() { nzf32 *= -1; nzf64 *= -1 }
func u16(n uint16) uint16 { return n }
func u32(n uint32) uint32 { return n }
func u64(n uint64) uint64 { return n }
func u8(n byte) byte { return n }
var inf = math.Inf(1) var inf = math.Inf(1)
var nzf32 float32 // -0.0 var nzf32 float32 // -0.0
var nzf64 float64 // -0.0 var nzf64 float64 // -0.0
func postInc0(p *int32, d int32) int32 { v := *p; *p += d; return v } func elem0(a *uint32, index uintptr) *uint32 {
return (*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(a)) + 4*index))
}
func postInc1(p *int32, d int32) int32 { v := *p; *p += d; return v }
func str(n int) *int8 { return (*int8)(unsafe.Pointer(&strTab[n])) } func str(n int) *int8 { return (*int8)(unsafe.Pointer(&strTab[n])) }
func wstr(n int) *int32 { return (*int32)(unsafe.Pointer(&strTab[n])) } func wstr(n int) *int32 { return (*int32)(unsafe.Pointer(&strTab[n])) }

File diff suppressed because one or more lines are too long

View File

@@ -1,36 +1,36 @@
// Code generated by ccgo. DO NOT EDIT. // Code generated by ccgo. DO NOT EDIT.
// threadtest4.c // threadtest4
// /*
// 2014-12-11 // ** 2014-12-11
// // **
// The author disclaims copyright to this source code. In place of // ** The author disclaims copyright to this source code. In place of
// a legal notice, here is a blessing: // ** a legal notice, here is a blessing:
// // **
// May you do good and not evil. // ** May you do good and not evil.
// May you find forgiveness for yourself and forgive others. // ** May you find forgiveness for yourself and forgive others.
// May you share freely, never taking more than you give. // ** May you share freely, never taking more than you give.
// // **
// ************************************************************************* // *************************************************************************
// This file implements a simple standalone program used to stress the // ** This file implements a simple standalone program used to stress the
// SQLite library when accessing the same set of databases simultaneously // ** SQLite library when accessing the same set of databases simultaneously
// from multiple threads in shared-cache mode. // ** from multiple threads in shared-cache mode.
// // **
// This test program runs on unix-like systems only. It uses pthreads. // ** This test program runs on unix-like systems only. It uses pthreads.
// To compile: // ** To compile:
// // **
// gcc -g -Wall -I. threadtest4.c sqlite3.c -ldl -lpthread // ** gcc -g -Wall -I. threadtest4.c sqlite3.c -ldl -lpthread
// // **
// To run: // ** To run:
// // **
// ./a.out 10 // ** ./a.out 10
// // **
// The argument is the number of threads. There are also options, such // ** The argument is the number of threads. There are also options, such
// as -wal and -multithread and -serialized. // ** as -wal and -multithread and -serialized.
// // **
// Consider also compiling with clang instead of gcc and adding the // ** Consider also compiling with clang instead of gcc and adding the
// -fsanitize=thread option. // ** -fsanitize=thread option.
// */
package main package main
import ( import (
@@ -68,13 +68,13 @@ var X__stdfiles [3]unsafe.Pointer
var Xstdout unsafe.Pointer var Xstdout unsafe.Pointer
func init() { func init() {
Xstdout = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 4) Xstdout = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 4)
} }
var Xstderr unsafe.Pointer var Xstderr unsafe.Pointer
func init() { func init() {
Xstderr = (unsafe.Pointer)(uintptr(unsafe.Pointer(&X__stdfiles)) + 8) Xstderr = unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdfiles)) + 8)
} }
func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) { func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
@@ -85,104 +85,88 @@ func Xmain(tls *crt.TLS, _argc int32, _argv **int8) (r0 int32) {
var _wrMutex crt.Xpthread_mutex_t var _wrMutex crt.Xpthread_mutex_t
var _infoTop XWorkerInfo var _infoTop XWorkerInfo
var _aInfo, _p *XWorkerInfo var _aInfo, _p *XWorkerInfo
r0 = i32(0) r0 = int32(0)
_nWorker = i32(0) _nWorker = int32(0)
_wkrFlags = u32(0) _wkrFlags = uint32(0)
_nErr = i32(0) _nErr = int32(0)
_nTest = i32(0) _nTest = int32(0)
_db = nil _db = nil
bin.Xsqlite3_config(tls, i32(2)) bin.Xsqlite3_config(tls, int32(2))
_i = i32(1) _i = int32(1)
_0: _0:
if _i >= _argc { if _i >= _argc {
goto _3 goto _3
} }
_1_z = *(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 4*uintptr(_i))) _1_z = *elem0(_argv, uintptr(_i))
if int32(*(*int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_1_z)) + 1*uintptr(i32(0))))) != i32(45) { if int32(*elem1(_1_z, 0)) != int32(45) {
goto _4 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(*elem1(_1_z, uintptr(1))) == int32(45)) && (int32(*elem1(_1_z, uintptr(2))) != int32(0)) {
*(*uintptr)(unsafe.Pointer(&_1_z)) += uintptr(1) *(*uintptr)(unsafe.Pointer(&_1_z)) += uintptr(1)
} }
if crt.Xstrcmp(tls, _1_z, str(0)) == i32(0) { if crt.Xstrcmp(tls, _1_z, str(0)) == int32(0) {
bin.Xsqlite3_config(tls, i32(2)) bin.Xsqlite3_config(tls, int32(2))
{ _wkrFlags &= uint32(4294967294)
p := &_wkrFlags
*p = (*p) & uint32(i32(-2))
sink0(*p)
}
goto _14 goto _14
} }
if crt.Xstrcmp(tls, _1_z, str(13)) == i32(0) { if crt.Xstrcmp(tls, _1_z, str(13)) == int32(0) {
bin.Xsqlite3_config(tls, i32(3)) bin.Xsqlite3_config(tls, int32(3))
{ _wkrFlags |= uint32(1)
p := &_wkrFlags
*p = (*p) | uint32(i32(1))
sink0(*p)
}
goto _14 goto _14
} }
if crt.Xstrcmp(tls, _1_z, str(25)) == i32(0) { if crt.Xstrcmp(tls, _1_z, str(25)) == int32(0) {
{ _wkrFlags |= uint32(2)
p := &_wkrFlags
*p = (*p) | uint32(i32(2))
sink0(*p)
}
goto _14 goto _14
} }
if crt.Xstrcmp(tls, _1_z, str(30)) == i32(0) { if crt.Xstrcmp(tls, _1_z, str(30)) == int32(0) {
{ _wkrFlags |= uint32(4)
p := &_wkrFlags
*p = (*p) | uint32(i32(4))
sink0(*p)
}
goto _14 goto _14
} }
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(37), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 4*uintptr(_i))))) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(37), unsafe.Pointer(*elem0(_argv, uintptr(_i))))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
_14: _14:
goto _20 goto _20
_4: _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(*elem1(_1_z, 0)) < int32(49) || int32(*elem1(_1_z, 0)) > int32(57) || _nWorker != int32(0) {
goto _18 goto _18
} }
_nWorker = crt.Xatoi(tls, _1_z) _nWorker = crt.Xatoi(tls, _1_z)
if _nWorker < i32(2) { if _nWorker < int32(2) {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(70)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(70))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
goto _20 goto _20
_18: _18:
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(92), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 4*uintptr(_i))))) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(92), unsafe.Pointer(*elem0(_argv, uintptr(_i))))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
_20: _20:
_i += 1 _i += 1
goto _0 goto _0
_3: _3:
if _nWorker == i32(0) { if _nWorker == int32(0) {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(127), unsafe.Pointer(*(**int8)(unsafe.Pointer(uintptr((unsafe.Pointer)(_argv)) + 4*uintptr(i32(0)))))) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(127), unsafe.Pointer(*elem0(_argv, 0)))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
if bin.Xsqlite3_threadsafe(tls) == 0 { if bin.Xsqlite3_threadsafe(tls) == 0 {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(260)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(260))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
bin.Xsqlite3_initialize(tls) bin.Xsqlite3_initialize(tls)
bin.Xsqlite3_enable_shared_cache(tls, i32(1)) bin.Xsqlite3_enable_shared_cache(tls, int32(1))
crt.Xpthread_mutex_init(tls, &_wrMutex, nil) crt.Xpthread_mutex_init(tls, &_wrMutex, nil)
crt.Xunlink(tls, str(299)) crt.Xunlink(tls, str(299))
crt.Xunlink(tls, str(312)) crt.Xunlink(tls, str(312))
crt.Xunlink(tls, str(325)) crt.Xunlink(tls, str(325))
_rc = bin.Xsqlite3_open(tls, str(299), (**bin.Xsqlite3)(unsafe.Pointer(&_db))) _rc = bin.Xsqlite3_open(tls, str(299), (**bin.Xsqlite3)(unsafe.Pointer(&_db)))
if _rc != i32(0) { if _rc != int32(0) {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(338)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(338))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
crt.Xmemset(tls, (unsafe.Pointer)(&_infoTop), i32(0), u32(40)) crt.Xmemset(tls, unsafe.Pointer(&_infoTop), int32(0), uint32(40))
*(*unsafe.Pointer)(unsafe.Pointer(&(_infoTop.X4))) = _db _infoTop.Xdb = _db
*(*uint32)(unsafe.Pointer(&(_infoTop.X2))) = _wkrFlags _infoTop.XwkrFlags = _wkrFlags
_p = &_infoTop _p = &_infoTop
if (_wkrFlags & uint32(i32(2))) != 0 { if (_wkrFlags & uint32(2)) != 0 {
_run_sql(tls, _p, str(382)) _run_sql(tls, _p, str(382))
} }
_run_sql(tls, _p, str(406)) _run_sql(tls, _p, str(406))
@@ -197,212 +181,226 @@ _3:
_run_sql(tls, _p, str(743)) _run_sql(tls, _p, str(743))
_run_sql(tls, _p, str(805)) _run_sql(tls, _p, str(805))
_run_sql(tls, _p, str(841)) _run_sql(tls, _p, str(841))
_aInfo = (*XWorkerInfo)(_safe_malloc(tls, int32(u32(40)*uint32(_nWorker)))) _aInfo = (*XWorkerInfo)(_safe_malloc(tls, int32(uint32(40)*uint32(_nWorker))))
crt.Xmemset(tls, (unsafe.Pointer)(_aInfo), i32(0), u32(40)*uint32(_nWorker)) crt.Xmemset(tls, unsafe.Pointer(_aInfo), int32(0), uint32(40)*uint32(_nWorker))
_i = i32(0) _i = int32(0)
_25: _25:
if _i >= _nWorker { if _i >= _nWorker {
goto _28 goto _28
} }
*(*int32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X0))) = _i + i32(1) elem2(_aInfo, uintptr(_i)).Xtid = _i + int32(1)
*(*int32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X1))) = _nWorker elem2(_aInfo, uintptr(_i)).XnWorker = _nWorker
*(*uint32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X2))) = _wkrFlags elem2(_aInfo, uintptr(_i)).XwkrFlags = _wkrFlags
*(*unsafe.Pointer)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X3))) = _db elem2(_aInfo, uintptr(_i)).XmainDb = _db
*(**crt.Xpthread_mutex_t)(unsafe.Pointer((*unsafe.Pointer)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X9))))) = &_wrMutex *(**crt.Xpthread_mutex_t)(unsafe.Pointer(&(elem2(_aInfo, uintptr(_i)).XpWrMutex))) = &_wrMutex
_rc = crt.Xpthread_create(tls, (*uint32)(unsafe.Pointer(&((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X8))), nil, _worker_thread, (unsafe.Pointer)((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+40*uintptr(_i))))) _rc = crt.Xpthread_create(tls, &(elem2(_aInfo, uintptr(_i)).Xid), nil, _worker_thread, unsafe.Pointer(elem2(_aInfo, uintptr(_i))))
if _rc != i32(0) { if _rc != int32(0) {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(876), _i+i32(1)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(876), _i+int32(1))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
crt.Xsched_yield(tls) crt.Xsched_yield(tls)
_i += 1 _i += 1
goto _25 goto _25
_28: _28:
_i = i32(0) _i = int32(0)
_30: _30:
if _i >= _nWorker { if _i >= _nWorker {
goto _33 goto _33
} }
crt.Xpthread_join(tls, (*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+40*uintptr(_i))).X8, nil) crt.Xpthread_join(tls, elem2(_aInfo, uintptr(_i)).Xid, nil)
crt.Xprintf(tls, str(914), (*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+40*uintptr(_i))).X0, (*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+40*uintptr(_i))).X5, (*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+40*uintptr(_i))).X6) crt.Xprintf(tls, str(914), elem2(_aInfo, uintptr(_i)).Xtid, elem2(_aInfo, uintptr(_i)).XnErr, elem2(_aInfo, uintptr(_i)).XnTest)
if ((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X7) != nil { if (elem2(_aInfo, uintptr(_i)).XzMsg) != nil {
crt.Xprintf(tls, str(954), unsafe.Pointer((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo))+40*uintptr(_i))).X7)) crt.Xprintf(tls, str(954), unsafe.Pointer(elem2(_aInfo, uintptr(_i)).XzMsg))
goto _35 goto _35
} }
crt.Xprintf(tls, str(960)) crt.Xprintf(tls, str(960))
_35: _35:
{ _nErr += elem2(_aInfo, uintptr(_i)).XnErr
p := &_nErr _nTest += elem2(_aInfo, uintptr(_i)).XnTest
*p = (*p) + ((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X5)
sink1(*p)
}
{
p := &_nTest
*p = (*p) + ((*XWorkerInfo)(unsafe.Pointer(uintptr((unsafe.Pointer)(_aInfo)) + 40*uintptr(_i))).X6)
sink1(*p)
}
crt.Xfflush(tls, (*crt.XFILE)(Xstdout)) crt.Xfflush(tls, (*crt.XFILE)(Xstdout))
_i += 1 _i += 1
goto _30 goto _30
_33: _33:
bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_db)) 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) crt.Xprintf(tls, str(962), _nErr, _nTest)
return _nErr return _nErr
_ = _wrMutex
_ = _infoTop
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{}) { func _run_sql(tls *crt.TLS, _p *XWorkerInfo, _zFormat *int8, args ...interface{}) {
var _rc, _nRetry int32 var _rc, _i, _nRetry int32
var _zSql *int8 var _zSql *int8
var _pStmt unsafe.Pointer var _pStmt unsafe.Pointer
var _ap []interface{} var _ap []interface{}
_pStmt = nil _pStmt = nil
_nRetry = i32(0) _nRetry = int32(0)
_ap = args _ap = args
_zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap) _zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
_ap = nil _ap = nil
_check_oom(tls, (unsafe.Pointer)(_zSql)) _check_oom(tls, unsafe.Pointer(_zSql))
_rc = bin.Xsqlite3_prepare_v2(tls, (*bin.Xsqlite3)(_p.X4), _zSql, i32(-1), &_pStmt, nil) _i = int32(0)
if _rc != i32(0) { _0:
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(991), _rc, bin.Xsqlite3_extended_errcode(tls, (*bin.Xsqlite3)(_p.X4)), unsafe.Pointer(bin.Xsqlite3_errmsg(tls, (*bin.Xsqlite3)(_p.X4))), unsafe.Pointer(_zSql)) if _i >= int32(1000) {
crt.Xexit(tls, i32(1)) goto _3
}
_rc = bin.Xsqlite3_prepare_v2(tls, (*bin.Xsqlite3)(_p.Xdb), _zSql, int32(-1), &_pStmt, nil)
if _rc == int32(0) {
goto _3
}
_i += 1
goto _0
_3:
if _rc != int32(0) {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(991), _rc, bin.Xsqlite3_extended_errcode(tls, (*bin.Xsqlite3)(_p.Xdb)), unsafe.Pointer(bin.Xsqlite3_errmsg(tls, (*bin.Xsqlite3)(_p.Xdb))), unsafe.Pointer(_zSql))
crt.Xexit(tls, int32(1))
} }
_worker_trace(tls, _p, str(1036), unsafe.Pointer(_zSql)) _worker_trace(tls, _p, str(1036), unsafe.Pointer(_zSql))
_1: _6:
if store1(&_rc, bin.Xsqlite3_step(tls, _pStmt)) == i32(101) { if store3(&_rc, bin.Xsqlite3_step(tls, _pStmt)) == int32(101) {
goto _2 goto _7
} }
if (_rc&i32(255)) != i32(5) && (_rc&i32(255)) != i32(6) { if (_rc&int32(255)) != int32(5) && (_rc&int32(255)) != int32(6) {
goto _4 goto _9
} }
bin.Xsqlite3_reset(tls, _pStmt) bin.Xsqlite3_reset(tls, _pStmt)
_nRetry += 1 _nRetry += 1
if _nRetry < i32(10) { if _nRetry < int32(10) {
_worker_trace(tls, _p, str(1049), _nRetry, unsafe.Pointer(_zSql)) _worker_trace(tls, _p, str(1049), _nRetry, unsafe.Pointer(_zSql))
crt.Xsched_yield(tls) crt.Xsched_yield(tls)
goto _1 goto _6
} }
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1067), _p.X0, unsafe.Pointer(_zSql)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1067), _p.Xtid, unsafe.Pointer(_zSql))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
_4: _9:
if _rc != i32(100) { if _rc != int32(100) {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1109), _rc, bin.Xsqlite3_extended_errcode(tls, (*bin.Xsqlite3)(_p.X4)), unsafe.Pointer(bin.Xsqlite3_errmsg(tls, (*bin.Xsqlite3)(_p.X4))), unsafe.Pointer(_zSql)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1109), _rc, bin.Xsqlite3_extended_errcode(tls, (*bin.Xsqlite3)(_p.Xdb)), unsafe.Pointer(bin.Xsqlite3_errmsg(tls, (*bin.Xsqlite3)(_p.Xdb))), unsafe.Pointer(_zSql))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
goto _1 goto _6
_2: _7:
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql)) bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
bin.Xsqlite3_finalize(tls, _pStmt) 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) { func _check_oom(tls *crt.TLS, _x unsafe.Pointer) {
if _x == nil { if _x == nil {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1151)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1151))
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
} }
// 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{}) { func _worker_trace(tls *crt.TLS, _p *XWorkerInfo, _zFormat *int8, args ...interface{}) {
var _zMsg *int8 var _zMsg *int8
var _ap []interface{} var _ap []interface{}
if ((_p.X2) & uint32(i32(4))) == uint32(i32(0)) { if (_p.XwkrFlags & uint32(4)) == (0) {
return return
} }
_ap = args _ap = args
_zMsg = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap) _zMsg = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
_check_oom(tls, (unsafe.Pointer)(_zMsg)) _check_oom(tls, unsafe.Pointer(_zMsg))
_ap = nil _ap = nil
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1166), _p.X0, unsafe.Pointer(_zMsg)) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1166), _p.Xtid, 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 // C comment
// kill the process. // /*
// ** 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) { func _safe_malloc(tls *crt.TLS, _sz int32) (r0 unsafe.Pointer) {
var _x unsafe.Pointer var _x unsafe.Pointer
_x = bin.Xsqlite3_malloc(tls, func() int32 { _x = bin.Xsqlite3_malloc(tls, func() int32 {
if _sz > i32(0) { if _sz > int32(0) {
return _sz return _sz
} }
return i32(1) return int32(1)
}()) }())
_check_oom(tls, _x) _check_oom(tls, _x)
return _x 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) { func _worker_thread(tls *crt.TLS, _pArg unsafe.Pointer) (r0 unsafe.Pointer) {
var _iOuter, _i, _rc int32 var _iOuter, _i, _rc int32
var _pStmt unsafe.Pointer var _pStmt unsafe.Pointer
var _p *XWorkerInfo var _p *XWorkerInfo
_p = (*XWorkerInfo)(_pArg) _p = (*XWorkerInfo)(_pArg)
crt.Xprintf(tls, str(1183), _p.X0) crt.Xprintf(tls, str(1183), _p.Xtid)
crt.Xfflush(tls, (*crt.XFILE)(Xstdout)) crt.Xfflush(tls, (*crt.XFILE)(Xstdout))
_iOuter = i32(1) _iOuter = int32(1)
_0: _0:
if _iOuter > (_p.X1) { if _iOuter > _p.XnWorker {
goto _3 goto _3
} }
_worker_open_connection(tls, _p, _iOuter) _worker_open_connection(tls, _p, _iOuter)
_i = i32(0) _i = int32(0)
_4: _4:
if _i >= i32(4) { if _i >= int32(4) {
goto _7 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*int32(100))+int32(1), (_i+int32(1))*int32(100), ((_p.Xtid+_iOuter)%int32(3))+int32(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*int32(100))+int32(1), (_i+int32(1))*int32(100), (((_p.Xtid+_iOuter)+int32(1))%int32(3))+int32(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*int32(100))+int32(1), (_i+int32(1))*int32(100), (((_p.Xtid+_iOuter)+int32(2))%int32(3))+int32(1))
_i += 1 _i += 1
goto _4 goto _4
_7: _7:
_pStmt = _prep_sql(tls, _p.X4, str(1202), _p.X0) _pStmt = _prep_sql(tls, _p.Xdb, str(1202), _p.Xtid)
_worker_trace(tls, _p, str(1239), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt))) _worker_trace(tls, _p, str(1239), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt)))
_rc = bin.Xsqlite3_step(tls, _pStmt) _rc = bin.Xsqlite3_step(tls, _pStmt)
if _rc != i32(100) { if _rc != int32(100) {
_worker_error(tls, _p, str(1250), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt))) _worker_error(tls, _p, str(1250), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt)))
goto _10 goto _10
} }
if bin.Xsqlite3_column_int(tls, _pStmt, i32(0)) != i32(400) { if bin.Xsqlite3_column_int(tls, _pStmt, int32(0)) != int32(400) {
_worker_error(tls, _p, str(1269), bin.Xsqlite3_column_int(tls, _pStmt, i32(0))) _worker_error(tls, _p, str(1269), bin.Xsqlite3_column_int(tls, _pStmt, int32(0)))
} }
_10: _10:
bin.Xsqlite3_finalize(tls, _pStmt) bin.Xsqlite3_finalize(tls, _pStmt)
if (_p.X5) != 0 { if _p.XnErr != 0 {
goto _3 goto _3
} }
if ((_iOuter + (_p.X0)) % i32(3)) == i32(0) { if ((_iOuter + _p.Xtid) % int32(3)) == int32(0) {
bin.Xsqlite3_db_release_memory(tls, (*bin.Xsqlite3)(_p.X4)) bin.Xsqlite3_db_release_memory(tls, (*bin.Xsqlite3)(_p.Xdb))
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1 _p.XnTest += 1
} }
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
_run_sql(tls, _p, str(1286)) _run_sql(tls, _p, str(1286))
_run_sql(tls, _p, str(1293)) _run_sql(tls, _p, str(1293))
_run_sql(tls, _p, str(1325)) _run_sql(tls, _p, str(1325))
_run_sql(tls, _p, str(1357)) _run_sql(tls, _p, str(1357))
_run_sql(tls, _p, str(1389)) _run_sql(tls, _p, str(1389))
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1 _p.XnTest += 1
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
if _iOuter == (_p.X0) { if _iOuter == _p.Xtid {
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
_run_sql(tls, _p, str(1399)) _run_sql(tls, _p, str(1399))
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
} }
_pStmt = _prep_sql(tls, _p.X4, str(1406), _p.X0, _p.X0, _p.X0) _pStmt = _prep_sql(tls, _p.Xdb, str(1406), _p.Xtid, _p.Xtid, _p.Xtid)
_worker_trace(tls, _p, str(1239), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt))) _worker_trace(tls, _p, str(1239), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt)))
_i = i32(0) _i = int32(0)
_14: _14:
if _i >= (_p.X1) { if _i >= _p.XnWorker {
goto _17 goto _17
} }
_rc = bin.Xsqlite3_step(tls, _pStmt) _rc = bin.Xsqlite3_step(tls, _pStmt)
if _rc != i32(100) { if _rc != int32(100) {
_worker_error(tls, _p, str(1250), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt))) _worker_error(tls, _p, str(1250), unsafe.Pointer(bin.Xsqlite3_sql(tls, _pStmt)))
goto _17 goto _17
} }
@@ -411,58 +409,64 @@ _14:
goto _14 goto _14
_17: _17:
bin.Xsqlite3_finalize(tls, _pStmt) bin.Xsqlite3_finalize(tls, _pStmt)
if (_p.X5) != 0 { if _p.XnErr != 0 {
goto _3 goto _3
} }
_worker_delete_all_content(tls, _p, ((_p.X0)+_iOuter)%i32(2)) _worker_delete_all_content(tls, _p, (_p.Xtid+_iOuter)%int32(2))
_worker_close_connection(tls, _p) _worker_close_connection(tls, _p)
*(*unsafe.Pointer)(unsafe.Pointer(&(_p.X4))) = nil _p.Xdb = nil
_iOuter += 1 _iOuter += 1
goto _0 goto _0
_3: _3:
_worker_close_connection(tls, _p) _worker_close_connection(tls, _p)
crt.Xprintf(tls, str(1552), _p.X0) crt.Xprintf(tls, str(1552), _p.Xtid)
crt.Xfflush(tls, (*crt.XFILE)(Xstdout)) crt.Xfflush(tls, (*crt.XFILE)(Xstdout))
return nil return nil
} }
// Open the database connection for WorkerInfo. The order in which // C comment
// the files are opened is a function of the tid value. // /*
// ** 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) { func _worker_open_connection(tls *crt.TLS, _p *XWorkerInfo, _iCnt int32) {
var _x, _rc int32 var _x, _rc int32
var _zFile *int8 var _zFile *int8
_x = ((_p.X0) + _iCnt) % i32(6) _x = (_p.Xtid + _iCnt) % int32(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)))))) _zFile = bin.Xsqlite3_mprintf(tls, str(1572), int32(*elem4((*uint8)(unsafe.Pointer(elem5((*[3]uint8)(unsafe.Pointer(&_worker_open_connectionØ00aOrderØ001)), uintptr(_x)))), 0)))
_check_oom(tls, (unsafe.Pointer)(_zFile)) _check_oom(tls, unsafe.Pointer(_zFile))
_worker_trace(tls, _p, str(1586), 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(&_p.Xdb)), int32(131074), nil)
if _rc != i32(0) { if _rc != int32(0) {
crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1594), unsafe.Pointer(_zFile), _p.X0) crt.Xfprintf(tls, (*crt.XFILE)(Xstderr), str(1594), unsafe.Pointer(_zFile), _p.Xtid)
crt.Xexit(tls, i32(1)) crt.Xexit(tls, int32(1))
} }
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zFile)) bin.Xsqlite3_free(tls, unsafe.Pointer(_zFile))
_run_sql(tls, _p, str(1634)) _run_sql(tls, _p, str(1634))
bin.Xsqlite3_busy_timeout(tls, (*bin.Xsqlite3)(_p.X4), i32(10000)) bin.Xsqlite3_busy_timeout(tls, (*bin.Xsqlite3)(_p.Xdb), int32(10000))
_run_sql(tls, _p, str(1662)) _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(1686), int32(*elem4((*uint8)(unsafe.Pointer(elem5((*[3]uint8)(unsafe.Pointer(&_worker_open_connectionØ00aOrderØ001)), uintptr(_x)))), uintptr(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(1717), int32(*elem4((*uint8)(unsafe.Pointer(elem5((*[3]uint8)(unsafe.Pointer(&_worker_open_connectionØ00aOrderØ001)), uintptr(_x)))), uintptr(2))))
} }
var _worker_open_connectionØ00aOrderØ001 [6][3]uint8 var _worker_open_connectionØ00aOrderØ001 [6][3]uint8
func init() { 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)}} _worker_open_connectionØ00aOrderØ001 = [6][3]uint8{[3]uint8{uint8(1), uint8(2), uint8(3)}, [3]uint8{uint8(1), uint8(3), uint8(2)}, [3]uint8{uint8(2), uint8(1), uint8(3)}, [3]uint8{uint8(2), uint8(3), uint8(1)}, [3]uint8{uint8(3), uint8(1), uint8(2)}, [3]uint8{uint8(3), uint8(2), uint8(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) { func _worker_add_content(tls *crt.TLS, _p *XWorkerInfo, _mn int32, _mx int32, _iTab int32) {
var _zTabDef *int8 var _zTabDef *int8
switch _iTab { switch _iTab {
case i32(1): case int32(1):
goto _1 goto _1
case i32(2): case int32(2):
goto _2 goto _2
case i32(3): case int32(3):
goto _3 goto _3
default: default:
goto _4 goto _4
@@ -478,15 +482,18 @@ _3:
_zTabDef = str(1782) _zTabDef = str(1782)
goto _4 goto _4
_4: _4:
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
_run_sql(tls, _p, str(1799), _mn, _mx, unsafe.Pointer(_zTabDef), _p.X0) _run_sql(tls, _p, str(1799), _mn, _mx, unsafe.Pointer(_zTabDef), _p.Xtid)
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1 _p.XnTest += 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) { func _prep_sql(tls *crt.TLS, _db unsafe.Pointer, _zFormat *int8, args ...interface{}) (r0 unsafe.Pointer) {
var _rc int32 var _rc, _i int32
var _zSql *int8 var _zSql *int8
var _pStmt unsafe.Pointer var _pStmt unsafe.Pointer
var _ap []interface{} var _ap []interface{}
@@ -494,63 +501,83 @@ func _prep_sql(tls *crt.TLS, _db unsafe.Pointer, _zFormat *int8, args ...interfa
_ap = args _ap = args
_zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap) _zSql = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
_ap = nil _ap = nil
_check_oom(tls, (unsafe.Pointer)(_zSql)) _check_oom(tls, unsafe.Pointer(_zSql))
_rc = bin.Xsqlite3_prepare_v2(tls, (*bin.Xsqlite3)(_db), _zSql, i32(-1), &_pStmt, nil) _i = int32(0)
if _rc != i32(0) { _0:
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)) if _i >= int32(1000) {
crt.Xexit(tls, i32(1)) goto _3
} }
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_zSql)) _rc = bin.Xsqlite3_prepare_v2(tls, (*bin.Xsqlite3)(_db), _zSql, int32(-1), &_pStmt, nil)
if _rc == int32(0) {
goto _3
}
_i += 1
goto _0
_3:
if _rc != int32(0) {
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, int32(1))
}
bin.Xsqlite3_free(tls, unsafe.Pointer(_zSql))
return _pStmt 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{}) { func _worker_error(tls *crt.TLS, _p *XWorkerInfo, _zFormat *int8, args ...interface{}) {
var _ap []interface{} var _ap []interface{}
*(*int32)(unsafe.Pointer(&(_p.X5))) += 1 _p.XnErr += 1
bin.Xsqlite3_free(tls, (unsafe.Pointer)(_p.X7)) bin.Xsqlite3_free(tls, unsafe.Pointer(_p.XzMsg))
_ap = args _ap = args
*(**int8)(unsafe.Pointer(&(_p.X7))) = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap) _p.XzMsg = bin.Xsqlite3_vmprintf(tls, _zFormat, _ap)
_ap = nil _ap = nil
} }
// Delete all content in the three databases associated with a // C comment
// single thread. Make this happen all in a single transaction if // /*
// inTrans is true, or separately for each database if inTrans is // ** Delete all content in the three databases associated with a
// false. // ** 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) { func _worker_delete_all_content(tls *crt.TLS, _p *XWorkerInfo, _inTrans int32) {
if _inTrans != 0 { if _inTrans != 0 {
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
_run_sql(tls, _p, str(1947)) _run_sql(tls, _p, str(1947))
_run_sql(tls, _p, str(1953), _p.X0) _run_sql(tls, _p, str(1953), _p.Xtid)
_run_sql(tls, _p, str(1981), _p.X0) _run_sql(tls, _p, str(1981), _p.Xtid)
_run_sql(tls, _p, str(2009), _p.X0) _run_sql(tls, _p, str(2009), _p.Xtid)
_run_sql(tls, _p, str(2037)) _run_sql(tls, _p, str(2037))
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1 _p.XnTest += 1
goto _1 goto _1
} }
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
_run_sql(tls, _p, str(1953), _p.X0) _run_sql(tls, _p, str(1953), _p.Xtid)
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1 _p.XnTest += 1
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
_run_sql(tls, _p, str(1981), _p.X0) _run_sql(tls, _p, str(1981), _p.Xtid)
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1 _p.XnTest += 1
crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_lock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
_run_sql(tls, _p, str(2009), _p.X0) _run_sql(tls, _p, str(2009), _p.Xtid)
crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.X9)) crt.Xpthread_mutex_unlock(tls, (*crt.Xpthread_mutex_t)(_p.XpWrMutex))
*(*int32)(unsafe.Pointer(&(_p.X6))) += 1 _p.XnTest += 1
_1: _1:
} }
// Close the worker database connection // C comment
// /*
// ** Close the worker database connection
// */
func _worker_close_connection(tls *crt.TLS, _p *XWorkerInfo) { func _worker_close_connection(tls *crt.TLS, _p *XWorkerInfo) {
if (_p.X4) != nil { if _p.Xdb != nil {
_worker_trace(tls, _p, str(2044)) _worker_trace(tls, _p, str(2044))
bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_p.X4)) bin.Xsqlite3_close(tls, (*bin.Xsqlite3)(_p.Xdb))
*(*unsafe.Pointer)(unsafe.Pointer(&(_p.X4))) = nil _p.Xdb = nil
} }
} }
@@ -561,35 +588,40 @@ func bool2int(b bool) int32 {
return 0 return 0
} }
func bug20530(interface{}) {} //TODO remove when https://github.com/golang/go/issues/20530 is fixed. func bug20530(interface{}) {} //TODO remove when https://github.com/golang/go/issues/20530 is fixed.
func i16(n int16) int16 { return n }
func i32(n int32) int32 { return n }
func i64(n int64) int64 { return n }
func i8(n int8) int8 { return n }
func init() { nzf32 *= -1; nzf64 *= -1 } func init() { nzf32 *= -1; nzf64 *= -1 }
func u16(n uint16) uint16 { return n }
func u32(n uint32) uint32 { return n }
func u64(n uint64) uint64 { return n }
func u8(n byte) byte { return n }
var inf = math.Inf(1) var inf = math.Inf(1)
var nzf32 float32 // -0.0 var nzf32 float32 // -0.0
var nzf64 float64 // -0.0 var nzf64 float64 // -0.0
func sink1(int32) {} //TODO report GC bug func elem0(a **int8, index uintptr) **int8 {
func sink0(uint32) {} //TODO report GC bug return (**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(a)) + 4*index))
func store1(p *int32, v int32) int32 { *p = v; return v } }
func elem5(a *[3]uint8, index uintptr) *[3]uint8 {
return (*[3]uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(a)) + 3*index))
}
func elem1(a *int8, index uintptr) *int8 {
return (*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(a)) + 1*index))
}
func elem2(a *XWorkerInfo, index uintptr) *XWorkerInfo {
return (*XWorkerInfo)(unsafe.Pointer(uintptr(unsafe.Pointer(a)) + 40*index))
}
func elem4(a *uint8, index uintptr) *uint8 {
return (*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(a)) + 1*index))
}
func store3(p *int32, v int32) int32 { *p = v; return v }
type XWorkerInfo struct { type XWorkerInfo struct {
X0 int32 Xtid int32
X1 int32 XnWorker int32
X2 uint32 XwkrFlags uint32
X3 unsafe.Pointer XmainDb unsafe.Pointer
X4 unsafe.Pointer Xdb unsafe.Pointer
X5 int32 XnErr int32
X6 int32 XnTest int32
X7 *int8 XzMsg *int8
X8 uint32 Xid uint32
X9 unsafe.Pointer XpWrMutex unsafe.Pointer
} // t2 struct{int32,int32,uint32,*struct{},*struct{},int32,int32,*int8,uint32,*struct{}} } // t6 struct{tid int32,nWorker int32,wkrFlags uint32,mainDb *struct{},db *struct{},nErr int32,nTest int32,zMsg *int8,id uint32,pWrMutex *struct{}}
func str(n int) *int8 { return (*int8)(unsafe.Pointer(&strTab[n])) } func str(n int) *int8 { return (*int8)(unsafe.Pointer(&strTab[n])) }
func wstr(n int) *int32 { return (*int32)(unsafe.Pointer(&strTab[n])) } func wstr(n int) *int32 { return (*int32)(unsafe.Pointer(&strTab[n])) }