[Pcre-svn] [359] code/trunk: Add PCRE_CALL_CONVENTION for MS…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [359] code/trunk: Add PCRE_CALL_CONVENTION for MSVC users; add some missing PCRE_EXP_DEFNs.
Revision: 359
          http://vcs.pcre.org/viewvc?view=rev&revision=359
Author:   ph10
Date:     2008-07-09 17:20:19 +0100 (Wed, 09 Jul 2008)


Log Message:
-----------
Add PCRE_CALL_CONVENTION for MSVC users; add some missing PCRE_EXP_DEFNs.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/NON-UNIX-USE
    code/trunk/pcre_compile.c
    code/trunk/pcre_config.c
    code/trunk/pcre_dfa_exec.c
    code/trunk/pcre_exec.c
    code/trunk/pcre_fullinfo.c
    code/trunk/pcre_get.c
    code/trunk/pcre_info.c
    code/trunk/pcre_internal.h
    code/trunk/pcre_refcount.c
    code/trunk/pcre_study.c
    code/trunk/pcre_version.c
    code/trunk/pcreposix.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/ChangeLog    2008-07-09 16:20:19 UTC (rev 359)
@@ -34,6 +34,13 @@


 8.  Added comments about Mac OS X stack usage to the pcrestack man page and to 
     test 2 if it fails. 
+    
+9.  Added PCRE_CALL_CONVENTION just before the names of all exported functions,
+    and a #define of that name to empty if it is not externally set. This is to 
+    allow users of MSVC to set it if necessary.  
+    
+10. The PCRE_EXP_DEFN macro which precedes exported functions was missing from 
+    the convenience functions in the pcre_get.c source file.



Version 7.7 07-May-08

Modified: code/trunk/NON-UNIX-USE
===================================================================
--- code/trunk/NON-UNIX-USE    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/NON-UNIX-USE    2008-07-09 16:20:19 UTC (rev 359)
@@ -190,6 +190,17 @@
 __declspec(dllimport), with unwanted results.



+CALLING CONVENTIONS IN WINDOWS ENVIRONMENTS
+
+It is possible to compile programs to use different calling conventions using
+MSVC. Search the web for "calling conventions" for more information. To make it
+easier to change the calling convention for the exported functions in the
+PCRE library, the macro PCRE_CALL_CONVENTION is present in all the external
+definitions. It can be set externally when compiling (e.g. in CFLAGS). If it is
+not set, it defaults to empty; the default calling convention is then used
+(which is what is wanted most of the time).
+
+
COMMENTS ABOUT WIN32 BUILDS (see also "BUILDING PCRE WITH CMAKE" below)

There are two ways of building PCRE using the "configure, make, make install"
@@ -428,5 +439,5 @@
$!
=========================

-Last Updated: 25 January 2008
+Last Updated: 09 July 2008
****

Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_compile.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -5944,7 +5944,7 @@
                 with errorptr and erroroffset set
 */


-PCRE_EXP_DEFN pcre *
+PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
pcre_compile(const char *pattern, int options, const char **errorptr,
int *erroroffset, const unsigned char *tables)
{
@@ -5952,7 +5952,7 @@
}


-PCRE_EXP_DEFN pcre *
+PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
pcre_compile2(const char *pattern, int options, int *errorcodeptr,
const char **errorptr, int *erroroffset, const unsigned char *tables)
{

Modified: code/trunk/pcre_config.c
===================================================================
--- code/trunk/pcre_config.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_config.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -62,7 +62,7 @@
 Returns:           0 if data returned, negative on error
 */


-PCRE_EXP_DEFN int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_config(int what, void *where)
{
switch (what)

Modified: code/trunk/pcre_dfa_exec.c
===================================================================
--- code/trunk/pcre_dfa_exec.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_dfa_exec.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -2505,7 +2505,7 @@
                  < -1 => some kind of unexpected problem
 */


-PCRE_EXP_DEFN int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,
const char *subject, int length, int start_offset, int options, int *offsets,
int offsetcount, int *workspace, int wscount)

Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_exec.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -4384,7 +4384,7 @@
                  < -1 => some kind of unexpected problem
 */


-PCRE_EXP_DEFN int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
int offsetcount)

Modified: code/trunk/pcre_fullinfo.c
===================================================================
--- code/trunk/pcre_fullinfo.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_fullinfo.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -65,7 +65,7 @@
 Returns:           0 if data returned, negative on error
 */


-PCRE_EXP_DEFN int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,
void *where)
{

Modified: code/trunk/pcre_get.c
===================================================================
--- code/trunk/pcre_get.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_get.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -65,7 +65,7 @@
                 (PCRE_ERROR_NOSUBSTRING) if not found
 */


-int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
 pcre_get_stringnumber(const pcre *code, const char *stringname)
 {
 int rc;
@@ -114,7 +114,7 @@
                 (PCRE_ERROR_NOSUBSTRING) if not found
 */


-int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
 pcre_get_stringtable_entries(const pcre *code, const char *stringname,
   char **firstptr, char **lastptr)
 {
@@ -231,7 +231,7 @@
                    PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
 */


-int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
 pcre_copy_substring(const char *subject, int *ovector, int stringcount,
   int stringnumber, char *buffer, int size)
 {
@@ -276,7 +276,7 @@
                    PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
 */


-int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
 pcre_copy_named_substring(const pcre *code, const char *subject, int *ovector,
   int stringcount, const char *stringname, char *buffer, int size)
 {
@@ -308,7 +308,7 @@
                    PCRE_ERROR_NOMEMORY (-6) failed to get store
 */


-int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
 pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
   const char ***listptr)
 {
@@ -353,7 +353,7 @@
 Returns:    nothing
 */


-void
+PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
 pcre_free_substring_list(const char **pointer)
 {
 (pcre_free)((void *)pointer);
@@ -386,7 +386,7 @@
                    PCRE_ERROR_NOSUBSTRING (-7) substring not present
 */


-int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
 pcre_get_substring(const char *subject, int *ovector, int stringcount,
   int stringnumber, const char **stringptr)
 {
@@ -433,7 +433,7 @@
                    PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
 */


-int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
 pcre_get_named_substring(const pcre *code, const char *subject, int *ovector,
   int stringcount, const char *stringname, const char **stringptr)
 {
@@ -456,7 +456,7 @@
 Returns:    nothing
 */


-void
+PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
pcre_free_substring(const char *pointer)
{
(pcre_free)((void *)pointer);

Modified: code/trunk/pcre_info.c
===================================================================
--- code/trunk/pcre_info.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_info.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -72,7 +72,7 @@
                 or negative values on error
 */


-PCRE_EXP_DEFN int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_info(const pcre *argument_re, int *optptr, int *first_byte)
{
real_pcre internal_re;

Modified: code/trunk/pcre_internal.h
===================================================================
--- code/trunk/pcre_internal.h    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_internal.h    2008-07-09 16:20:19 UTC (rev 359)
@@ -132,6 +132,20 @@
 #  endif
 #endif


+/* When compiling with the MSVC compiler, it is sometimes necessary to include
+a "calling convention" before exported function names. (This is secondhand
+information; I know nothing about MSVC myself). For example, something like
+
+ void __cdecl function(....)
+
+might be needed. In order so make this easy, all the exported functions have
+PCRE_CALL_CONVENTION just before their names. It is rarely needed; if not
+set, we ensure here that it has no effect. */
+
+#ifndef PCRE_CALL_CONVENTION
+#define PCRE_CALL_CONVENTION
+#endif
+
/* We need to have types that specify unsigned 16-bit and 32-bit integers. We
cannot determine these outside the compilation (e.g. by running a program as
part of "configure") because PCRE is often cross-compiled for use on other

Modified: code/trunk/pcre_refcount.c
===================================================================
--- code/trunk/pcre_refcount.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_refcount.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -68,7 +68,7 @@
                 a negative error number
 */


-PCRE_EXP_DEFN int
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_refcount(pcre *argument_re, int adjust)
{
real_pcre *re = (real_pcre *)argument_re;

Modified: code/trunk/pcre_study.c
===================================================================
--- code/trunk/pcre_study.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_study.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -504,7 +504,7 @@
             NULL on error or if no optimization possible
 */


-PCRE_EXP_DEFN pcre_extra *
+PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION
pcre_study(const pcre *external_re, int options, const char **errorptr)
{
uschar start_bits[32];

Modified: code/trunk/pcre_version.c
===================================================================
--- code/trunk/pcre_version.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcre_version.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -79,7 +79,7 @@
 pre-processor time. This hack uses a standard trick for avoiding calling
 the STRING macro with an empty argument when doing the test. */


-PCRE_EXP_DEFN const char *
+PCRE_EXP_DEFN const char * PCRE_CALL_CONVENTION
pcre_version(void)
{
return (XSTRING(Z PCRE_PRERELEASE)[1] == 0)?

Modified: code/trunk/pcreposix.c
===================================================================
--- code/trunk/pcreposix.c    2008-07-09 11:03:07 UTC (rev 358)
+++ code/trunk/pcreposix.c    2008-07-09 16:20:19 UTC (rev 359)
@@ -160,7 +160,7 @@
 *          Translate error code to string        *
 *************************************************/


-PCREPOSIX_EXP_DEFN size_t
+PCREPOSIX_EXP_DEFN size_t PCRE_CALL_CONVENTION
 regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
 {
 const char *message, *addmessage;
@@ -195,7 +195,7 @@
 *           Free store held by a regex           *
 *************************************************/


-PCREPOSIX_EXP_DEFN void
+PCREPOSIX_EXP_DEFN void PCRE_CALL_CONVENTION
 regfree(regex_t *preg)
 {
 (pcre_free)(preg->re_pcre);
@@ -218,7 +218,7 @@
               various non-zero codes on failure
 */


-PCREPOSIX_EXP_DEFN int
+PCREPOSIX_EXP_DEFN int PCRE_CALL_CONVENTION
regcomp(regex_t *preg, const char *pattern, int cflags)
{
const char *errorptr;
@@ -260,7 +260,7 @@
be set. When this is the case, the nmatch and pmatch arguments are ignored, and
the only result is yes/no/error. */

-PCREPOSIX_EXP_DEFN int
+PCREPOSIX_EXP_DEFN int PCRE_CALL_CONVENTION
regexec(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags)
{