From: mistachkin Date: Tue, 24 Mar 2015 21:27:27 +0000 (+0000) Subject: Add SQLITE_STDCALL and SQLITE_CDECL macros on public function definitions. X-Git-Tag: version-3.8.9~35^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=59b9b02c1fa889a4f4e83f2a5597bf62baca4ccb;p=thirdparty%2Fsqlite.git Add SQLITE_STDCALL and SQLITE_CDECL macros on public function definitions. FossilOrigin-Name: 242f09d4d1c92ee9058857a5e780442f4b7bad55 --- diff --git a/Makefile.msc b/Makefile.msc index 249e3c284d..837fc003c0 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -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 = diff --git a/manifest b/manifest index 2022595ba2..8a9bcb9667 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Suppress\sa\scompiler\swarning\sthat\swas\sappearing\swith\sSQLITE_THREADSAFE=0. -D 2015-03-24T18:19:39.691 +C Add\sSQLITE_STDCALL\sand\sSQLITE_CDECL\smacros\son\spublic\sfunction\sdefinitions. +D 2015-03-24T21:27:27.369 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 82977ae32ba5f5a115d4434418087c9c1088f643 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d F src/sqliteInt.h bedf15914c09bfb5fe3ec4e3f211a4a6fc42cd33 @@ -1213,8 +1213,8 @@ F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl 94f196c9961e0ca3513e29f57125a3197808be2d F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 9ef48e1748dce7b844f67e2450ff9dfeb0fb4ab5 -F tool/mksqlite3c.tcl 95ab31eda659e7ffb091e04bd83178f260d8edfd -F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12 +F tool/mksqlite3c.tcl ab2cfb2191f1edaea0e72b6ad3bc3f71aa61a6b9 +F tool/mksqlite3h.tcl c02e391f595bf91528341ffaa53e5084d8b595ce F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl 52a4c613707ac34ae9c226e5ccc69cb948556105 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 @@ -1246,7 +1246,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cbeb9a1aed8ce3fb569a7717ad03c7c058b68de6 -R 1df40f85f677c47017b13b63b82a97b5 -U drh -Z 408df2ac27dc537c38335d50565b918f +P 436314b5728c9413f9ac2d837e1c19364f31be72 +R 887ef727abd3a9965cbccad906bf79e4 +T *branch * stdcall +T *sym-stdcall * +T -sym-trunk * +U mistachkin +Z cb11de2c68ebf434af7cc941e8219588 diff --git a/manifest.uuid b/manifest.uuid index b639b7d8cc..d35f197244 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -436314b5728c9413f9ac2d837e1c19364f31be72 \ No newline at end of file +242f09d4d1c92ee9058857a5e780442f4b7bad55 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8e2727f6ae..6d2cc146dc 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -49,13 +49,6 @@ extern "C" { # define SQLITE_EXTERN extern #endif -/* -** Add the ability to override 'cdecl' -*/ -#ifndef SQLITE_CDECL -# define SQLITE_CDECL -#endif - /* ** These no-op macros are used in front of interfaces to mark those ** interfaces as either deprecated or experimental. New applications diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index fd823385b3..b33eef8f1a 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -83,6 +83,12 @@ if {$addstatic} { #endif #ifndef SQLITE_API # define SQLITE_API +#endif +#ifndef SQLITE_CDECL +# define SQLITE_CDECL +#endif +#ifndef SQLITE_STDCALL +# define SQLITE_STDCALL #endif} } @@ -127,6 +133,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 +169,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 +214,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 diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl index a89b9f9beb..9ed74c3f4b 100644 --- a/tool/mksqlite3h.tcl +++ b/tool/mksqlite3h.tcl @@ -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 { @@ -97,13 +110,33 @@ foreach file $filelist { puts "#ifndef SQLITE_API" puts "# define SQLITE_API" puts "#endif" + puts "" + puts "#ifndef SQLITE_CDECL" + puts "# define SQLITE_CDECL" + puts "#endif" + puts "" + puts "#ifndef SQLITE_STDCALL" + puts "# define SQLITE_STDCALL" + 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 }