You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Randy Kobes <ra...@theoryx5.uwinnipeg.ca> on 2004/10/01 05:49:42 UTC

[mp2] modperl_cmd.c on Win32

Hi,
  On Win32, there's a problem in compiling modperl_cmd.c
under src/modules/perl/ with the current cvs about trying to
use a function with the wrong number of arguments (lines 311
and 317). I think this is due to how modperl_var_modify_t is
defined within mod_perl.h, specifically with the presence of
_stdcall within the definition of MP_FUNC_T in
modperl_common_util.h for Win32. This patch:
================================================================
Index: src/modules/perl/mod_perl.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v
retrieving revision 1.70
diff -u -r1.70 mod_perl.h
--- src/modules/perl/mod_perl.h	20 Sep 2004 18:14:47 -0000	1.70
+++ src/modules/perl/mod_perl.h	1 Oct 2004 03:14:50 -0000
@@ -130,10 +130,10 @@

 #define MgTypeExt(mg) (mg->mg_type == '~')

-typedef void MP_FUNC_T(modperl_var_modify_t) (apr_table_t *,
-                                              apr_table_t *,
-                                              const char *,
-                                              const char *);
+typedef void (*modperl_var_modify_t) (apr_table_t *,
+                                      apr_table_t *,
+                                      const char *,
+                                      const char *);

 /* we need to hook a few internal things before APR_HOOK_REALLY_FIRST */
 #define MODPERL_HOOK_REALLY_REALLY_FIRST (-20)
====================================================================
allows things to build and the tests run (I'm getting a
couple of failures, but I'll look at those separately).

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] modperl_cmd.c on Win32

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
[...]
>>Is it possible that the right place to fix that is in modperl_common_util.h:
>>
>>#ifdef WIN32
>>#   define MP_FUNC_T(name) (_stdcall *name)

> So perhaps, in analogy, we could have a
> 
>   #ifdef WIN32
>   #   define MP_DECLARE(name)         *name __stdcall
>   #   define MP_DECLARE_NONSTD(name)  *name
>   /* XXX: not all functions get inlined
>   * so its unclear what to and not to include in the .def files
>   */
>  #   undef MP_INLINE
>  #   define MP_INLINE
>  #else
>  #   define MP_DECLARE(name)         *name
>  #   define MP_DECLARE_NONSTD        *name
>  #endif
> 
> and then use MP_DECLARE/MP_DECLARE_NONSTD?

+1, but I'd rather keep our more intuitive name: will MP_FUNC_T and 
MP_FUNC_NONSTD_T do? If so go ahead and commit it. But don't forget the 
parentheses: (*name) and the arguments to the macro :)



-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] modperl_cmd.c on Win32

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Fri, 1 Oct 2004, Stas Bekman wrote:

> Randy Kobes wrote:
> > Hi,
> >   On Win32, there's a problem in compiling modperl_cmd.c
> > under src/modules/perl/ with the current cvs about trying to
> > use a function with the wrong number of arguments (lines 311
> > and 317). I think this is due to how modperl_var_modify_t is
> > defined within mod_perl.h, specifically with the presence of
> > _stdcall within the definition of MP_FUNC_T in
> > modperl_common_util.h for Win32. This patch:
> > ================================================================
> > Index: src/modules/perl/mod_perl.h
> > ===================================================================
> > RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v
> > retrieving revision 1.70
> > diff -u -r1.70 mod_perl.h
> > --- src/modules/perl/mod_perl.h	20 Sep 2004 18:14:47 -0000	1.70
> > +++ src/modules/perl/mod_perl.h	1 Oct 2004 03:14:50 -0000
> > @@ -130,10 +130,10 @@
> >
> >  #define MgTypeExt(mg) (mg->mg_type == '~')
> >
> > -typedef void MP_FUNC_T(modperl_var_modify_t) (apr_table_t *,
> > -                                              apr_table_t *,
> > -                                              const char *,
> > -                                              const char *);
> > +typedef void (*modperl_var_modify_t) (apr_table_t *,
> > +                                      apr_table_t *,
> > +                                      const char *,
> > +                                      const char *);
>
>
>
> >  /* we need to hook a few internal things before APR_HOOK_REALLY_FIRST */
> >  #define MODPERL_HOOK_REALLY_REALLY_FIRST (-20)
> > ====================================================================
> > allows things to build and the tests run (I'm getting a
> > couple of failures, but I'll look at those separately).
> >
>
> Is it possible that the right place to fix that is in modperl_common_util.h:
>
> #ifdef WIN32
> #   define MP_FUNC_T(name) (_stdcall *name)
> /* XXX: not all functions get inlined
>   * so its unclear what to and not to include in the .def files
>   */
> #   undef MP_INLINE
> #   define MP_INLINE
> #else
> #   define MP_FUNC_T(name)          (*name)
> #endif
>
> as you can see there already a special case for WIN32. And it was added
> there for some reason. Do you know why? May be it's because of this nature
> of that specific function that you've a problem with? Should it stay
> intact for other uses?

You're right that the
  #ifdef WIN32
  #   define MP_FUNC_T(name) (_stdcall *name)
  /* XXX: not all functions get inlined
    * so its unclear what to and not to include in the .def files
  */
 #   undef MP_INLINE
 #   define MP_INLINE

is needed elsewhere, specifically in modperl_filter.h:
   typedef ap_filter_t * MP_FUNC_T(modperl_filter_add_t) ...
where the _stcall is necessary. I think the situation
is analagous to what's described in ap_config.h:
===================================================================
#if !defined(WIN32)
/**
 * Apache Core dso functions are declared with AP_DECLARE(), so they may
 * use the most appropriate calling convention.  Hook functions and other
 * Core functions with variable arguments must use AP_DECLARE_NONSTD().
 * @code
 * AP_DECLARE(rettype) ap_func(args)
 * @endcode
 */
#define AP_DECLARE(type)            type

/**
 * Apache Core dso variable argument and hook functions are declared with
 * AP_DECLARE_NONSTD(), as they must use the C language calling convention.
 * @see AP_DECLARE
 * @code
 * AP_DECLARE_NONSTD(rettype) ap_func(args [...])
 * @endcode
 */
#define AP_DECLARE_NONSTD(type)     type

/**
 * Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA.
 * This assures the appropriate indirection is invoked at compile time.
 *
 * @note AP_DECLARE_DATA extern type apr_variable; syntax is required for
 * declarations within headers to properly import the variable.
 * @code
 * AP_DECLARE_DATA type apr_variable
 * @endcode
 */
#define AP_DECLARE_DATA

#elif defined(AP_DECLARE_STATIC)
#define AP_DECLARE(type)            type __stdcall
#define AP_DECLARE_NONSTD(type)     type
#define AP_DECLARE_DATA
#elif defined(AP_DECLARE_EXPORT)
#define AP_DECLARE(type)            __declspec(dllexport) type __stdcall
#define AP_DECLARE_NONSTD(type)     __declspec(dllexport) type
#define AP_DECLARE_DATA             __declspec(dllexport)
#else
#define AP_DECLARE(type)            __declspec(dllimport) type __stdcall
#define AP_DECLARE_NONSTD(type)     __declspec(dllimport) type
#define AP_DECLARE_DATA             __declspec(dllimport)
#endif

====================================================================

So perhaps, in analogy, we could have a

  #ifdef WIN32
  #   define MP_DECLARE(name)         *name __stdcall
  #   define MP_DECLARE_NONSTD(name)  *name
  /* XXX: not all functions get inlined
  * so its unclear what to and not to include in the .def files
  */
 #   undef MP_INLINE
 #   define MP_INLINE
 #else
 #   define MP_DECLARE(name)         *name
 #   define MP_DECLARE_NONSTD        *name
 #endif

and then use MP_DECLARE/MP_DECLARE_NONSTD?

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] modperl_cmd.c on Win32

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
> Hi,
>   On Win32, there's a problem in compiling modperl_cmd.c
> under src/modules/perl/ with the current cvs about trying to
> use a function with the wrong number of arguments (lines 311
> and 317). I think this is due to how modperl_var_modify_t is
> defined within mod_perl.h, specifically with the presence of
> _stdcall within the definition of MP_FUNC_T in
> modperl_common_util.h for Win32. This patch:
> ================================================================
> Index: src/modules/perl/mod_perl.h
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v
> retrieving revision 1.70
> diff -u -r1.70 mod_perl.h
> --- src/modules/perl/mod_perl.h	20 Sep 2004 18:14:47 -0000	1.70
> +++ src/modules/perl/mod_perl.h	1 Oct 2004 03:14:50 -0000
> @@ -130,10 +130,10 @@
> 
>  #define MgTypeExt(mg) (mg->mg_type == '~')
> 
> -typedef void MP_FUNC_T(modperl_var_modify_t) (apr_table_t *,
> -                                              apr_table_t *,
> -                                              const char *,
> -                                              const char *);
> +typedef void (*modperl_var_modify_t) (apr_table_t *,
> +                                      apr_table_t *,
> +                                      const char *,
> +                                      const char *);



>  /* we need to hook a few internal things before APR_HOOK_REALLY_FIRST */
>  #define MODPERL_HOOK_REALLY_REALLY_FIRST (-20)
> ====================================================================
> allows things to build and the tests run (I'm getting a
> couple of failures, but I'll look at those separately).
> 

Is it possible that the right place to fix that is in modperl_common_util.h:

#ifdef WIN32
#   define MP_FUNC_T(name) (_stdcall *name)
/* XXX: not all functions get inlined
  * so its unclear what to and not to include in the .def files
  */
#   undef MP_INLINE
#   define MP_INLINE
#else
#   define MP_FUNC_T(name)          (*name)
#endif

as you can see there already a special case for WIN32. And it was added 
there for some reason. Do you know why? May be it's because of this nature 
of that specific function that you've a problem with? Should it stay 
intact for other uses?

I suppose that this is the change that broke things for you:
http://cvs.apache.org/viewcvs.cgi/modperl-2.0/src/modules/perl/modperl_cmd.c?r1=1.65&r2=1.66&diff_format=h

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org