1 /*------------------------------------------------------------------------- 2 * 3 * plperl.h 4 * Common include file for PL/Perl files 5 * 6 * This should be included _AFTER_ postgres.h and system include files 7 * 8 * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group 9 * Portions Copyright (c) 1995, Regents of the University of California 10 * 11 * src/pl/plperl/plperl.h 12 */ 13 14 #ifndef PL_PERL_H 15 #define PL_PERL_H 16 17 /* stop perl headers from hijacking stdio and other stuff on Windows */ 18 #ifdef WIN32 19 #define WIN32IO_IS_STDIO 20 /* 21 * isnan is defined in both the perl and mingw headers. We don't use it, 22 * so this just clears up the compile warning. 23 */ 24 #ifdef isnan 25 #undef isnan 26 #endif 27 #endif /* WIN32 */ 28 29 /* 30 * Supply a value of PERL_UNUSED_DECL that will satisfy gcc - the one 31 * perl itself supplies doesn't seem to. 32 */ 33 #define PERL_UNUSED_DECL pg_attribute_unused() 34 35 /* 36 * Sometimes perl carefully scribbles on our *printf macros. 37 * So we undefine them here and redefine them after it's done its dirty deed. 38 */ 39 40 #ifdef USE_REPL_SNPRINTF 41 #undef snprintf 42 #undef vsnprintf 43 #endif 44 45 /* 46 * ActivePerl 5.18 and later are MinGW-built, and their headers use GCC's 47 * __inline__. Translate to something MSVC recognizes. 48 */ 49 #ifdef _MSC_VER 50 #define __inline__ inline 51 #endif 52 53 54 /* 55 * Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code 56 * can compile against MULTIPLICITY Perl builds without including XSUB.h. 57 */ 58 #define PERL_NO_GET_CONTEXT 59 #include "EXTERN.h" 60 #include "perl.h" 61 62 /* 63 * We want to include XSUB.h only within .xs files, because on some platforms 64 * it undesirably redefines a lot of libc functions. But it must appear 65 * before ppport.h, so use a #define flag to control inclusion here. 66 */ 67 #ifdef PG_NEED_PERL_XSUB_H 68 #include "XSUB.h" 69 #endif 70 71 /* put back our snprintf and vsnprintf */ 72 #ifdef USE_REPL_SNPRINTF 73 #ifdef snprintf 74 #undef snprintf 75 #endif 76 #ifdef vsnprintf 77 #undef vsnprintf 78 #endif 79 #ifdef __GNUC__ 80 #define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) 81 #define snprintf(...) pg_snprintf(__VA_ARGS__) 82 #else 83 #define vsnprintf pg_vsnprintf 84 #define snprintf pg_snprintf 85 #endif /* __GNUC__ */ 86 #endif /* USE_REPL_SNPRINTF */ 87 88 /* perl version and platform portability */ 89 #define NEED_eval_pv 90 #define NEED_newRV_noinc 91 #define NEED_sv_2pv_flags 92 #include "ppport.h" 93 94 /* perl may have a different width of "bool", don't buy it */ 95 #ifdef bool 96 #undef bool 97 #endif 98 99 /* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */ 100 #ifndef HeUTF8 101 #define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \ 102 SvUTF8(HeKEY_sv(he)) : \ 103 (U32)HeKUTF8(he)) 104 #endif 105 106 /* supply GvCV_set if it's missing - ppport.h doesn't supply it, unfortunately */ 107 #ifndef GvCV_set 108 #define GvCV_set(gv, cv) (GvCV(gv) = cv) 109 #endif 110 111 /* Perl 5.19.4 changed array indices from I32 to SSize_t */ 112 #if PERL_BCDVERSION >= 0x5019004 113 #define AV_SIZE_MAX SSize_t_MAX 114 #else 115 #define AV_SIZE_MAX I32_MAX 116 #endif 117 118 /* declare routines from plperl.c for access by .xs files */ 119 HV *plperl_spi_exec(char *, int); 120 void plperl_return_next(SV *); 121 SV *plperl_spi_query(char *); 122 SV *plperl_spi_fetchrow(char *); 123 SV *plperl_spi_prepare(char *, int, SV **); 124 HV *plperl_spi_exec_prepared(char *, HV *, int, SV **); 125 SV *plperl_spi_query_prepared(char *, int, SV **); 126 void plperl_spi_freeplan(char *); 127 void plperl_spi_cursor_close(char *); 128 char *plperl_sv_to_literal(SV *, char *); 129 void plperl_util_elog(int level, SV *msg); 130 131 #endif /* PL_PERL_H */ 132