1  /*
       2   * This file was generated automatically by ExtUtils::ParseXS version 3.43 from the
       3   * contents of TestXS.xs. Do not edit this file, edit TestXS.xs instead.
       4   *
       5   *    ANY CHANGES MADE HERE WILL BE LOST!
       6   *
       7   */
       8  
       9  #line 1 "TestXS.xs"
      10  #include <config.h>
      11  
      12  #define PERL_NO_GET_CONTEXT
      13  #include "EXTERN.h"
      14  #include "perl.h"
      15  #include "XSUB.h"
      16  
      17  #include "ppport.h"
      18  
      19  
      20  
      21  #line 22 "TestXS.c"
      22  #ifndef PERL_UNUSED_VAR
      23  #  define PERL_UNUSED_VAR(var) if (0) var = var
      24  #endif
      25  
      26  #ifndef dVAR
      27  #  define dVAR		dNOOP
      28  #endif
      29  
      30  
      31  /* This stuff is not part of the API! You have been warned. */
      32  #ifndef PERL_VERSION_DECIMAL
      33  #  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
      34  #endif
      35  #ifndef PERL_DECIMAL_VERSION
      36  #  define PERL_DECIMAL_VERSION \
      37  	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
      38  #endif
      39  #ifndef PERL_VERSION_GE
      40  #  define PERL_VERSION_GE(r,v,s) \
      41  	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
      42  #endif
      43  #ifndef PERL_VERSION_LE
      44  #  define PERL_VERSION_LE(r,v,s) \
      45  	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
      46  #endif
      47  
      48  /* XS_INTERNAL is the explicit static-linkage variant of the default
      49   * XS macro.
      50   *
      51   * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
      52   * "STATIC", ie. it exports XSUB symbols. You probably don't want that
      53   * for anything but the BOOT XSUB.
      54   *
      55   * See XSUB.h in core!
      56   */
      57  
      58  
      59  /* TODO: This might be compatible further back than 5.10.0. */
      60  #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
      61  #  undef XS_EXTERNAL
      62  #  undef XS_INTERNAL
      63  #  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
      64  #    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
      65  #    define XS_INTERNAL(name) STATIC XSPROTO(name)
      66  #  endif
      67  #  if defined(__SYMBIAN32__)
      68  #    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
      69  #    define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
      70  #  endif
      71  #  ifndef XS_EXTERNAL
      72  #    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
      73  #      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
      74  #      define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
      75  #    else
      76  #      ifdef __cplusplus
      77  #        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
      78  #        define XS_INTERNAL(name) static XSPROTO(name)
      79  #      else
      80  #        define XS_EXTERNAL(name) XSPROTO(name)
      81  #        define XS_INTERNAL(name) STATIC XSPROTO(name)
      82  #      endif
      83  #    endif
      84  #  endif
      85  #endif
      86  
      87  /* perl >= 5.10.0 && perl <= 5.15.1 */
      88  
      89  
      90  /* The XS_EXTERNAL macro is used for functions that must not be static
      91   * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
      92   * macro defined, the best we can do is assume XS is the same.
      93   * Dito for XS_INTERNAL.
      94   */
      95  #ifndef XS_EXTERNAL
      96  #  define XS_EXTERNAL(name) XS(name)
      97  #endif
      98  #ifndef XS_INTERNAL
      99  #  define XS_INTERNAL(name) XS(name)
     100  #endif
     101  
     102  /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
     103   * internal macro that we're free to redefine for varying linkage due
     104   * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
     105   * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
     106   */
     107  
     108  #undef XS_EUPXS
     109  #if defined(PERL_EUPXS_ALWAYS_EXPORT)
     110  #  define XS_EUPXS(name) XS_EXTERNAL(name)
     111  #else
     112     /* default to internal */
     113  #  define XS_EUPXS(name) XS_INTERNAL(name)
     114  #endif
     115  
     116  #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
     117  #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
     118  
     119  /* prototype to pass -Wmissing-prototypes */
     120  STATIC void
     121  S_croak_xs_usage(const CV *const cv, const char *const params);
     122  
     123  STATIC void
     124  S_croak_xs_usage(const CV *const cv, const char *const params)
     125  {
     126      const GV *const gv = CvGV(cv);
     127  
     128      PERL_ARGS_ASSERT_CROAK_XS_USAGE;
     129  
     130      if (gv) {
     131          const char *const gvname = GvNAME(gv);
     132          const HV *const stash = GvSTASH(gv);
     133          const char *const hvname = stash ? HvNAME(stash) : NULL;
     134  
     135          if (hvname)
     136  	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
     137          else
     138  	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
     139      } else {
     140          /* Pants. I don't think that it should be possible to get here. */
     141  	Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
     142      }
     143  }
     144  #undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE
     145  
     146  #define croak_xs_usage        S_croak_xs_usage
     147  
     148  #endif
     149  
     150  /* NOTE: the prototype of newXSproto() is different in versions of perls,
     151   * so we define a portable version of newXSproto()
     152   */
     153  #ifdef newXS_flags
     154  #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
     155  #else
     156  #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
     157  #endif /* !defined(newXS_flags) */
     158  
     159  #if PERL_VERSION_LE(5, 21, 5)
     160  #  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
     161  #else
     162  #  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
     163  #endif
     164  
     165  #line 166 "TestXS.c"
     166  
     167  XS_EUPXS(XS_TestXS_init); /* prototype to pass -Wmissing-prototypes */
     168  XS_EUPXS(XS_TestXS_init)
     169  {
     170      dVAR; dXSARGS;
     171      if (items != 2)
     172         croak_xs_usage(cv,  "int, char *");
     173      {
     174  	int	RETVAL;
     175  	dXSTARG;
     176  #line 19 "TestXS.xs"
     177          puts ("message from XS module\n");
     178          RETVAL = 1;
     179  #line 180 "TestXS.c"
     180  	XSprePUSH; PUSHi((IV)RETVAL);
     181      }
     182      XSRETURN(1);
     183  }
     184  
     185  #ifdef __cplusplus
     186  extern "C"
     187  #endif
     188  XS_EXTERNAL(boot_TestXS); /* prototype to pass -Wmissing-prototypes */
     189  XS_EXTERNAL(boot_TestXS)
     190  {
     191  #if PERL_VERSION_LE(5, 21, 5)
     192      dVAR; dXSARGS;
     193  #else
     194      dVAR; dXSBOOTARGSXSAPIVERCHK;
     195  #endif
     196  #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
     197      char* file = __FILE__;
     198  #else
     199      const char* file = __FILE__;
     200  #endif
     201  
     202      PERL_UNUSED_VAR(file);
     203  
     204      PERL_UNUSED_VAR(cv); /* -W */
     205      PERL_UNUSED_VAR(items); /* -W */
     206  #if PERL_VERSION_LE(5, 21, 5)
     207      XS_VERSION_BOOTCHECK;
     208  #  ifdef XS_APIVERSION_BOOTCHECK
     209      XS_APIVERSION_BOOTCHECK;
     210  #  endif
     211  #endif
     212  
     213          (void)newXSproto_portable("TestXS::init", XS_TestXS_init, file, "$$");
     214  #if PERL_VERSION_LE(5, 21, 5)
     215  #  if PERL_VERSION_GE(5, 9, 0)
     216      if (PL_unitcheckav)
     217          call_list(PL_scopestack_ix, PL_unitcheckav);
     218  #  endif
     219      XSRETURN_YES;
     220  #else
     221      Perl_xs_boot_epilog(aTHX_ ax);
     222  #endif
     223  }
     224