[PHP] Avoid using zend_error_noreturn() as it doesn't work with all
builds of PHP (SF bug #3166423). Instead we now wrap it in a SWIG_FAIL() function which we annotate as "noreturn" for GCC to avoids warnings. This also reduces the size of the compiled wrapper (e.g. the stripped size is 6% for Xapian's PHP bindings). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13077 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4dfe131207
commit
d96db667f7
3 changed files with 25 additions and 25 deletions
|
|
@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 2.0.7 (in progress)
|
Version 2.0.7 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2012-05-12: olly
|
||||||
|
[PHP] Avoid using zend_error_noreturn() as it doesn't work with all
|
||||||
|
builds of PHP (SF bug #3166423). Instead we now wrap it in a
|
||||||
|
SWIG_FAIL() function which we annotate as "noreturn" for GCC to
|
||||||
|
avoids warnings. This also reduces the size of the compiled
|
||||||
|
wrapper (e.g. the stripped size is 6% for Xapian's PHP bindings).
|
||||||
|
|
||||||
2012-05-11: wsfulton
|
2012-05-11: wsfulton
|
||||||
[Java] SF patch #3522855 Fix unintended uninitialised memory access in OUTPUT typemaps.
|
[Java] SF patch #3522855 Fix unintended uninitialised memory access in OUTPUT typemaps.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ extern "C" {
|
||||||
#include "zend_exceptions.h"
|
#include "zend_exceptions.h"
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "ext/standard/php_string.h"
|
#include "ext/standard/php_string.h"
|
||||||
|
#include <stdlib.h> /* for abort(), used in generated code. */
|
||||||
|
|
||||||
#ifdef ZEND_RAW_FENTRY
|
#ifdef ZEND_RAW_FENTRY
|
||||||
/* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */
|
/* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */
|
||||||
|
|
|
||||||
|
|
@ -409,11 +409,19 @@ public:
|
||||||
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module);
|
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module);
|
||||||
Printf(s_header, "#endif\n\n");
|
Printf(s_header, "#endif\n\n");
|
||||||
|
|
||||||
Printf(s_header, "// Allow the user to workaround a PHP bug on some platforms/architectures by\n");
|
/* The following can't go in Lib/php/phprun.swg as it uses SWIG_ErrorMsg(), etc
|
||||||
Printf(s_header, "// compiling with -DSWIG_ZEND_ERROR_NORETURN=zend_error\n");
|
* which has to be dynamically generated as it depends on the module name.
|
||||||
Printf(s_header, "#ifndef SWIG_ZEND_ERROR_NORETURN\n");
|
*/
|
||||||
Printf(s_header, "# define SWIG_ZEND_ERROR_NORETURN zend_error_noreturn\n");
|
Append(s_header, "#ifdef __GNUC__\n");
|
||||||
Printf(s_header, "#endif\n\n");
|
Append(s_header, "static void SWIG_FAIL() __attribute__ ((__noreturn__));\n");
|
||||||
|
Append(s_header, "#endif\n\n");
|
||||||
|
Append(s_header, "static void SWIG_FAIL() {\n");
|
||||||
|
Append(s_header, " zend_error(SWIG_ErrorCode(), \"%s\", SWIG_ErrorMsg());\n");
|
||||||
|
// zend_error() should never return with the parameters we pass, but if it
|
||||||
|
// does, we really don't want to let SWIG_FAIL() return. This also avoids
|
||||||
|
// a warning about returning from a function marked as "__noreturn__".
|
||||||
|
Append(s_header, " abort();\n");
|
||||||
|
Append(s_header, "}\n\n");
|
||||||
|
|
||||||
Printf(s_header, "static void %s_init_globals(zend_%s_globals *globals ) {\n", module, module);
|
Printf(s_header, "static void %s_init_globals(zend_%s_globals *globals ) {\n", module, module);
|
||||||
Printf(s_header, " globals->error_msg = default_error_msg;\n");
|
Printf(s_header, " globals->error_msg = default_error_msg;\n");
|
||||||
|
|
@ -716,7 +724,7 @@ public:
|
||||||
|
|
||||||
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
|
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
|
||||||
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
|
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
|
||||||
Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n", NIL);
|
Printv(f->code, "SWIG_FAIL();\n", NIL);
|
||||||
|
|
||||||
Printv(f->code, "}\n", NIL);
|
Printv(f->code, "}\n", NIL);
|
||||||
Wrapper_print(f, s_wrappers);
|
Wrapper_print(f, s_wrappers);
|
||||||
|
|
@ -1000,11 +1008,7 @@ public:
|
||||||
/* Error handling code */
|
/* Error handling code */
|
||||||
Printf(f->code, "fail:\n");
|
Printf(f->code, "fail:\n");
|
||||||
Printv(f->code, cleanup, NIL);
|
Printv(f->code, cleanup, NIL);
|
||||||
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
|
Append(f->code, "SWIG_FAIL();\n");
|
||||||
* using zend_error() here shouldn't generate a warning, so just use that.
|
|
||||||
* At worst this may result in slightly less good code.
|
|
||||||
*/
|
|
||||||
Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
|
|
||||||
|
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
|
|
||||||
|
|
@ -2320,11 +2324,7 @@ done:
|
||||||
|
|
||||||
Append(f->code, "return;\n");
|
Append(f->code, "return;\n");
|
||||||
Append(f->code, "fail:\n");
|
Append(f->code, "fail:\n");
|
||||||
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
|
Append(f->code, "SWIG_FAIL();\n");
|
||||||
* using zend_error() here shouldn't generate a warning, so just use that.
|
|
||||||
* At worst this may result in slightly less good code.
|
|
||||||
*/
|
|
||||||
Append(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
|
|
||||||
Wrapper_print(f, s_wrappers);
|
Wrapper_print(f, s_wrappers);
|
||||||
|
|
@ -2715,15 +2715,7 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
Append(w->code, "fail:\n");
|
Append(w->code, "fail:\n");
|
||||||
if (!is_void) {
|
Append(w->code, "SWIG_FAIL();\n");
|
||||||
Append(w->code, "SWIG_ZEND_ERROR_NORETURN(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
|
||||||
} else {
|
|
||||||
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
|
|
||||||
* using zend_error() here shouldn't generate a warning, so just use that.
|
|
||||||
* At worst this may result in slightly less good code.
|
|
||||||
*/
|
|
||||||
Append(w->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
|
||||||
}
|
|
||||||
Append(w->code, "}\n");
|
Append(w->code, "}\n");
|
||||||
|
|
||||||
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue