Add SQLITE_STDCALL and SQLITE_CDECL macros on public function definitions.

FossilOrigin-Name: cae3239aa58b4f7016fc9dcac3966fe6ef833879
This commit is contained in:
mistachkin 2015-03-24 22:00:26 +00:00
commit d69e557940
7 changed files with 170 additions and 79 deletions

View File

@ -312,12 +312,12 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src
#
!IF $(USE_STDCALL)!=0
!IF "$(PLATFORM)"=="x86"
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
!ELSE
!IFNDEF PLATFORM
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
!ELSE
CORE_CCONV_OPTS =
SHELL_CCONV_OPTS =

View File

@ -1,9 +1,9 @@
C Fix\sa\scouple\scomment\stypos\sin\sa\stool\sscript.\s\sNo\schanges\sto\scode.
D 2015-03-24T21:34:53.280
C Add\sSQLITE_STDCALL\sand\sSQLITE_CDECL\smacros\son\spublic\sfunction\sdefinitions.
D 2015-03-24T22:00:26.504
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F Makefile.msc cd626b52ebeec0e2c0dd929243bdd25b0df19a71
F Makefile.msc 3481e2dd260968742c715542db178c2bdd5db99f
F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858
F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866
F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60
@ -232,7 +232,7 @@ F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
F src/select.c 72ffb62e2879956302140e9f6e6ae88aee36b0e5
F src/shell.c 3ae1e53878d2804fe77b8c8f1f6ca287a0e5d80e
F src/sqlite.h.in 2f9606a682af372415ce9d1f244183c5cc8385aa
F src/sqlite.h.in 278602140d49575e8708e643161f4263e428a02a
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
F src/sqliteInt.h bedf15914c09bfb5fe3ec4e3f211a4a6fc42cd33
@ -1212,9 +1212,9 @@ F tool/mkkeywordhash.c dfff09dbbfaf950e89af294f48f902181b144670
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
F tool/mkpragmatab.tcl 94f196c9961e0ca3513e29f57125a3197808be2d
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl f8a6223bebc9e3e9dc2700484c602f159b84c8aa
F tool/mksqlite3c.tcl 95ab31eda659e7ffb091e04bd83178f260d8edfd
F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12
F tool/mksqlite3c-noext.tcl 69bae8ce4aa52d2ff82d4a8a856bf283ec035b2e
F tool/mksqlite3c.tcl 52a3352f7aa15f1db851e45ac3a5e2173d6fe93c
F tool/mksqlite3h.tcl 44730d586c9031638cdd2eb443b801c0d2dbd9f8
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
F tool/mkvsix.tcl 52a4c613707ac34ae9c226e5ccc69cb948556105
F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091
@ -1246,7 +1246,8 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 436314b5728c9413f9ac2d837e1c19364f31be72
R 8395df004ed39c3d4f3903ab69f7e9ed
P 83421af67063825981f6051eb415944d90e9b2f6 e826cd7db6b3ab010533d81a759794c2470343d2
R 00893342a7c77a3a3db8feef49e96714
T +closed e826cd7db6b3ab010533d81a759794c2470343d2
U mistachkin
Z b92e1717d71c68278e3b78541d6aeae8
Z 1978375717c0fca1b1a377840034ad4e

View File

@ -1 +1 @@
83421af67063825981f6051eb415944d90e9b2f6
cae3239aa58b4f7016fc9dcac3966fe6ef833879

View File

@ -43,18 +43,20 @@ extern "C" {
/*
** Add the ability to override 'extern'
** Provide the ability to override linkage features of the interface.
*/
#ifndef SQLITE_EXTERN
# define SQLITE_EXTERN extern
#endif
/*
** Add the ability to override 'cdecl'
*/
#ifndef SQLITE_API
# define SQLITE_API
#endif
#ifndef SQLITE_CDECL
# define SQLITE_CDECL
#endif
#ifndef SQLITE_STDCALL
# define SQLITE_STDCALL
#endif
/*
** These no-op macros are used in front of interfaces to mark those

View File

@ -80,9 +80,6 @@ if {$addstatic} {
puts $out \
{#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
#ifndef SQLITE_API
# define SQLITE_API
#endif}
}
@ -106,6 +103,7 @@ foreach hdr {
pager.h
parse.h
pcache.h
pragma.h
sqlite3ext.h
sqlite3.h
sqliteicu.h
@ -113,12 +111,31 @@ foreach hdr {
sqliteLimit.h
vdbe.h
vdbeInt.h
vxworks.h
wal.h
whereInt.h
} {
set available_hdr($hdr) 1
}
set available_hdr(sqliteInt.h) 0
# These headers should be copied into the amalgamation without modifying any
# of their function declarations or definitions.
set varonly_hdr(sqlite3.h) 1
# These are the functions that accept a variable number of arguments. They
# always need to use the "cdecl" calling convention even when another calling
# convention (e.g. "stcall") is being used for the rest of the library.
set cdecllist {
sqlite3_config
sqlite3_db_config
sqlite3_log
sqlite3_mprintf
sqlite3_snprintf
sqlite3_test_control
sqlite3_vtab_config
}
# 78 stars used for comment formatting.
set s78 \
{*****************************************************************************}
@ -135,21 +152,21 @@ proc section_comment {text} {
# Read the source file named $filename and write it into the
# sqlite3.c output file. If any #include statements are seen,
# process them approprately.
# process them appropriately.
#
proc copy_file {filename} {
global seen_hdr available_hdr out addstatic linemacros
global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros
set ln 0
set tail [file tail $filename]
section_comment "Begin file $tail"
if {$linemacros} {puts $out "#line 1 \"$filename\""}
set in [open $filename r]
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
set declpattern {[a-zA-Z][a-zA-Z_0-9 ]+ \**(sqlite3[_a-zA-Z0-9]+)\(}
set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
if {[file extension $filename]==".h"} {
set declpattern " *$declpattern"
}
set declpattern ^$declpattern
set declpattern ^$declpattern\$
while {![eof $in]} {
set line [gets $in]
incr ln
@ -165,42 +182,67 @@ proc copy_file {filename} {
if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""}
}
} elseif {![info exists seen_hdr($hdr)]} {
set seen_hdr($hdr) 1
if {![regexp {/\*\s+amalgamator:\s+dontcache\s+\*/} $line]} {
set seen_hdr($hdr) 1
}
puts $out $line
} elseif {[regexp {/\*\s+amalgamator:\s+keep\s+\*/} $line]} {
# This include file must be kept because there was a "keep"
# directive inside of a line comment.
puts $out $line
} else {
puts $out "/* $line */"
# Comment out the entire line, replacing any nested comment
# begin/end markers with the harmless substring "**".
puts $out "/* [string map [list /* ** */ **] $line] */"
}
} elseif {[regexp {^#ifdef __cplusplus} $line]} {
puts $out "#if 0"
} elseif {!$linemacros && [regexp {^#line} $line]} {
# Skip #line directives.
} elseif {$addstatic && ![regexp {^(static|typedef)} $line]} {
regsub {^SQLITE_API } $line {} line
if {[regexp $declpattern $line all funcname]} {
# Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before
# functions if this header file does not need it.
if {![info exists varonly_hdr($tail)]
&& [regexp $declpattern $line all rettype funcname rest]} {
regsub {^SQLITE_API } $line {} line
# Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.
# so that linkage can be modified at compile-time.
if {[regexp {^sqlite3_} $funcname]} {
puts $out "SQLITE_API $line"
set line SQLITE_API
append line " " [string trim $rettype]
if {[string index $rettype end] ne "*"} {
append line " "
}
if {[lsearch -exact $cdecllist $funcname] >= 0} {
append line SQLITE_CDECL
} else {
append line SQLITE_STDCALL
}
append line " " $funcname $rest
puts $out $line
} else {
puts $out "SQLITE_PRIVATE $line"
}
} elseif {[regexp $varpattern $line all varname]} {
# Add the SQLITE_PRIVATE before variable declarations or
# definitions for internal use
if {![regexp {^sqlite3_} $varname]} {
regsub {^extern } $line {} line
puts $out "SQLITE_PRIVATE $line"
} else {
if {[regexp {const char sqlite3_version\[\];} $line]} {
set line {const char sqlite3_version[] = SQLITE_VERSION;}
# Add the SQLITE_PRIVATE before variable declarations or
# definitions for internal use
regsub {^SQLITE_API } $line {} line
if {![regexp {^sqlite3_} $varname]} {
regsub {^extern } $line {} line
puts $out "SQLITE_PRIVATE $line"
} else {
if {[regexp {const char sqlite3_version\[\];} $line]} {
set line {const char sqlite3_version[] = SQLITE_VERSION;}
}
regsub {^SQLITE_EXTERN } $line {} line
puts $out "SQLITE_API $line"
}
regsub {^SQLITE_EXTERN } $line {} line
puts $out "SQLITE_API $line"
}
} elseif {[regexp {^(SQLITE_EXTERN )?void \(\*sqlite3IoTrace\)} $line]} {
regsub {^SQLITE_API } $line {} line
regsub {^SQLITE_EXTERN } $line {} line
puts $out "SQLITE_PRIVATE $line"
puts $out $line
} elseif {[regexp {^void \(\*sqlite3Os} $line]} {
regsub {^SQLITE_API } $line {} line
puts $out "SQLITE_PRIVATE $line"
} else {
puts $out $line

View File

@ -80,9 +80,6 @@ if {$addstatic} {
puts $out \
{#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
#ifndef SQLITE_API
# define SQLITE_API
#endif}
}
@ -127,6 +124,23 @@ foreach hdr {
}
set available_hdr(sqliteInt.h) 0
# These headers should be copied into the amalgamation without modifying any
# of their function declarations or definitions.
set varonly_hdr(sqlite3.h) 1
# These are the functions that accept a variable number of arguments. They
# always need to use the "cdecl" calling convention even when another calling
# convention (e.g. "stcall") is being used for the rest of the library.
set cdecllist {
sqlite3_config
sqlite3_db_config
sqlite3_log
sqlite3_mprintf
sqlite3_snprintf
sqlite3_test_control
sqlite3_vtab_config
}
# 78 stars used for comment formatting.
set s78 \
{*****************************************************************************}
@ -146,18 +160,18 @@ proc section_comment {text} {
# process them appropriately.
#
proc copy_file {filename} {
global seen_hdr available_hdr out addstatic linemacros
global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros
set ln 0
set tail [file tail $filename]
section_comment "Begin file $tail"
if {$linemacros} {puts $out "#line 1 \"$filename\""}
set in [open $filename r]
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
set declpattern {[a-zA-Z][a-zA-Z_0-9 ]+ \**(sqlite3[_a-zA-Z0-9]+)\(}
set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
if {[file extension $filename]==".h"} {
set declpattern " *$declpattern"
}
set declpattern ^$declpattern
set declpattern ^$declpattern\$
while {![eof $in]} {
set line [gets $in]
incr ln
@ -191,32 +205,49 @@ proc copy_file {filename} {
} elseif {!$linemacros && [regexp {^#line} $line]} {
# Skip #line directives.
} elseif {$addstatic && ![regexp {^(static|typedef)} $line]} {
regsub {^SQLITE_API } $line {} line
if {[regexp $declpattern $line all funcname]} {
# Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before
# functions if this header file does not need it.
if {![info exists varonly_hdr($tail)]
&& [regexp $declpattern $line all rettype funcname rest]} {
regsub {^SQLITE_API } $line {} line
# Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.
# so that linkage can be modified at compile-time.
if {[regexp {^sqlite3_} $funcname]} {
puts $out "SQLITE_API $line"
set line SQLITE_API
append line " " [string trim $rettype]
if {[string index $rettype end] ne "*"} {
append line " "
}
if {[lsearch -exact $cdecllist $funcname] >= 0} {
append line SQLITE_CDECL
} else {
append line SQLITE_STDCALL
}
append line " " $funcname $rest
puts $out $line
} else {
puts $out "SQLITE_PRIVATE $line"
}
} elseif {[regexp $varpattern $line all varname]} {
# Add the SQLITE_PRIVATE before variable declarations or
# definitions for internal use
if {![regexp {^sqlite3_} $varname]} {
regsub {^extern } $line {} line
puts $out "SQLITE_PRIVATE $line"
} else {
if {[regexp {const char sqlite3_version\[\];} $line]} {
set line {const char sqlite3_version[] = SQLITE_VERSION;}
# Add the SQLITE_PRIVATE before variable declarations or
# definitions for internal use
regsub {^SQLITE_API } $line {} line
if {![regexp {^sqlite3_} $varname]} {
regsub {^extern } $line {} line
puts $out "SQLITE_PRIVATE $line"
} else {
if {[regexp {const char sqlite3_version\[\];} $line]} {
set line {const char sqlite3_version[] = SQLITE_VERSION;}
}
regsub {^SQLITE_EXTERN } $line {} line
puts $out "SQLITE_API $line"
}
regsub {^SQLITE_EXTERN } $line {} line
puts $out "SQLITE_API $line"
}
} elseif {[regexp {^(SQLITE_EXTERN )?void \(\*sqlite3IoTrace\)} $line]} {
regsub {^SQLITE_API } $line {} line
regsub {^SQLITE_EXTERN } $line {} line
puts $out $line
} elseif {[regexp {^void \(\*sqlite3Os} $line]} {
regsub {^SQLITE_API } $line {} line
puts $out "SQLITE_PRIVATE $line"
} else {
puts $out $line

View File

@ -63,7 +63,7 @@ close $in
# Set up patterns for recognizing API declarations.
#
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)}
set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \**sqlite3_[_a-zA-Z0-9]+\(}
set declpattern {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3_[_a-zA-Z0-9]+)(\(.*)$}
# Force the output to use unix line endings, even on Windows.
fconfigure stdout -translation lf
@ -73,6 +73,19 @@ set filelist [subst {
$TOP/ext/rtree/sqlite3rtree.h
}]
# These are the functions that accept a variable number of arguments. They
# always need to use the "cdecl" calling convention even when another calling
# convention (e.g. "stcall") is being used for the rest of the library.
set cdecllist {
sqlite3_config
sqlite3_db_config
sqlite3_log
sqlite3_mprintf
sqlite3_snprintf
sqlite3_test_control
sqlite3_vtab_config
}
# Process the source files.
#
foreach file $filelist {
@ -89,21 +102,23 @@ foreach file $filelist {
regsub -- --VERS-- $line $zVersion line
regsub -- --VERSION-NUMBER-- $line $nVersion line
regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line
if {[regexp {define SQLITE_EXTERN extern} $line]} {
puts $line
puts [gets $in]
puts ""
puts "#ifndef SQLITE_API"
puts "# define SQLITE_API"
puts "#endif"
set line ""
}
if {([regexp $varpattern $line] && ![regexp {^ *typedef} $line])
|| ([regexp $declpattern $line])
} {
if {[regexp $varpattern $line] && ![regexp {^ *typedef} $line]} {
set line "SQLITE_API $line"
} else {
if {[regexp $declpattern $line all rettype funcname rest]} {
set line SQLITE_API
append line " " [string trim $rettype]
if {[string index $rettype end] ne "*"} {
append line " "
}
if {[lsearch -exact $cdecllist $funcname] >= 0} {
append line SQLITE_CDECL
} else {
append line SQLITE_STDCALL
}
append line " " $funcname $rest
}
}
puts $line
}