]> granicus.if.org Git - php/commitdiff
Imporoved PHP binary size and startup speed with GCC4 visibility control (Nuno)
authorDmitry Stogov <dmitry@php.net>
Wed, 30 Jan 2008 09:56:22 +0000 (09:56 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 30 Jan 2008 09:56:22 +0000 (09:56 +0000)
24 files changed:
TSRM/TSRM.h
TSRM/tsrm_virtual_cwd.h
Zend/acconfig.h
configure.in
ext/bz2/php_bz2.h
ext/dom/xml_common.h
ext/gd/php_gd.h
ext/hash/php_hash.h
ext/iconv/php_iconv.h
ext/libxml/php_libxml.h
ext/mbstring/mbstring.h
ext/mysqli/php_mysqli_structs.h
ext/pdo/php_pdo.h
ext/pgsql/php_pgsql.h
ext/skeleton/php_skeleton.h
ext/spl/php_spl.h
ext/unicode/php_unicode.h
ext/zip/lib/zip.h
main/SAPI.h
main/php.h
sapi/apache2filter/php_apache.h
sapi/apache2handler/php_apache.h
sapi/apache_hooks/mod_php5.h
sapi/pi3web/pi3web_sapi.h

index 4a73c3487bc04fd35357395ebd532ff9b9909904..9695a726ecfe7872bc4e544273903912ea175d7f 100644 (file)
 
 #ifdef TSRM_WIN32
 #      ifdef TSRM_EXPORTS
-#      define TSRM_API __declspec(dllexport)
+#              define TSRM_API __declspec(dllexport)
 #      else
-#      define TSRM_API __declspec(dllimport)
+#              define TSRM_API __declspec(dllimport)
 #      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define TSRM_API __attribute__ ((visibility("default")))
 #else
 #      define TSRM_API
 #endif
index 0fd21a668549e678ceedceefce39222f0dc7f0b6..7fb25658ba6d08bf8047235bf716b7514e37696b 100644 (file)
@@ -134,13 +134,15 @@ typedef unsigned short mode_t;
 #endif
 
 #ifdef TSRM_WIN32
-#       ifdef CWD_EXPORTS
-#       define CWD_API __declspec(dllexport)
-#       else
-#       define CWD_API __declspec(dllimport)
-#       endif
+#      ifdef CWD_EXPORTS
+#              define CWD_API __declspec(dllexport)
+#      else
+#              define CWD_API __declspec(dllimport)
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define CWD_API __attribute__ ((visibility("default")))
 #else
-#define CWD_API
+#      define CWD_API
 #endif
 
 #ifdef TSRM_WIN32
index 7fd5a07661b4ddc2a626c07a2c22349747b6e999..8e3176c0f11a0da70d5173971ecdcb1bde69b220 100644 (file)
 
 /* $Id$ */
 
-#define ZEND_API
-#define ZEND_DLEXPORT
+#if defined(__GNUC__) && __GNUC__ >= 4
+# define ZEND_API __attribute__ ((visibility("default")))
+# define ZEND_DLEXPORT __attribute__ ((visibility("default")))
+#else
+# define ZEND_API
+# define ZEND_DLEXPORT
+#endif
+
 #define ZEND_DLIMPORT
 
 @TOP@
index e9bd1edbc37c1a456c188cb162c8dc24d2b2a169..64d6f661962cf7fe15bcdc4f5fc4a19d053a8b70 100644 (file)
@@ -165,6 +165,14 @@ alpha*)
     ;;
 esac
 
+dnl activate some gcc specific optimizations for gcc >= 4
+if test "$GCC" = "yes"; then
+  GCC_MAJOR_VERSION=`$CC --version | $SED -n '1s/[[^0-9]]*\([[0-9]]\+\)\.[[0-9]]\+\..*/\1/;1p'`
+  if test $GCC_MAJOR_VERSION -ge 4; then
+    CFLAGS="$CFLAGS -fvisibility=hidden"
+  fi
+fi
+
 case $host_alias in
 *solaris*)
     CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
index 5d453a545745a4d43b50d6dd1037fa94c2dcff76..9ef05568553f05488c0b6edc6d5bf6d42758759a 100644 (file)
@@ -34,15 +34,17 @@ extern zend_module_entry bz2_module_entry;
 #endif
 
 #ifdef PHP_WIN32
-# ifdef PHP_BZ2_EXPORTS
-#  define PHP_BZ2_API __declspec(dllexport)
-# elif defined(COMPILE_DL_BZ2)
-#  define PHP_BZ2_API __declspec(dllimport)
-# else
-#  define PHP_BZ2_API /* nothing special */
-# endif
+#      ifdef PHP_BZ2_EXPORTS
+#              define PHP_BZ2_API __declspec(dllexport)
+#      elif defined(COMPILE_DL_BZ2)
+#              define PHP_BZ2_API __declspec(dllimport)
+#      else
+#              define PHP_BZ2_API /* nothing special */
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHP_BZ2_API __attribute__ ((visibility("default")))
 #else
-# define PHP_BZ2_API
+#      define PHP_BZ2_API
 #endif
 
 PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
index 167ac84a7a269e4e1a2c1e97f40dcd97145899ec..05afde91dadf5015bc86dc4d36902fbf8add65b5 100644 (file)
@@ -35,14 +35,19 @@ typedef struct _dom_object {
 } dom_object;
 
 #ifdef PHP_WIN32
-#ifdef PHPAPI
-#undef PHPAPI
-#endif
-#ifdef DOM_EXPORTS
-#define PHPAPI __declspec(dllexport)
-#else
-#define PHPAPI __declspec(dllimport)
-#endif /* DOM_EXPORTS */
+#      ifdef PHPAPI
+#              undef PHPAPI
+#      endif
+#      ifdef DOM_EXPORTS
+#              define PHPAPI __declspec(dllexport)
+#      else
+#              define PHPAPI __declspec(dllimport)
+#      endif /* DOM_EXPORTS */
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      ifdef PHPAPI
+#              undef PHPAPI
+#      endif
+#      define PHPAPI __attribute__ ((visibility("default")))
 #endif /* PHP_WIN32 */
 
 #define PHP_DOM_EXPORT PHPAPI
index b495a0e268b357b725e157dcb90e4f36a05a70b6..7026f3961866837d80f86ae9a6ea7c49ba8751f5 100644 (file)
 #define PHP_GDIMG_TYPE_GD2PART 10
 
 #ifdef PHP_WIN32
-#define PHP_GD_API __declspec(dllexport)
+#      define PHP_GD_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHP_GD_API __attribute__ ((visibility("default")))
 #else
-#define PHP_GD_API
+#      define PHP_GD_API
 #endif
 
 PHPAPI extern const char php_sig_gif[3];
index ce361f59821f12702cab21cec17e976e5af34750..d0555dc2418edde724549012f47574a8804c7534 100644 (file)
@@ -104,9 +104,11 @@ extern zend_module_entry hash_module_entry;
 #define phpext_hash_ptr &hash_module_entry
 
 #ifdef PHP_WIN32
-#define PHP_HASH_API __declspec(dllexport)
+#      define PHP_HASH_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHP_HASH_API __attribute__ ((visibility("default")))
 #else
-#define PHP_HASH_API
+#      define PHP_HASH_API
 #endif
 
 #ifdef ZTS
index e48993d3627b366b40ca299a2fe4f3e25e6eb168..b1c2cfdd5c3f924b8398e5965207cbada25f304e 100644 (file)
 #define PHP_ICONV_H
 
 #ifdef PHP_WIN32
-#ifdef PHP_ICONV_EXPORTS
-#define PHP_ICONV_API __declspec(dllexport)
+#      ifdef PHP_ICONV_EXPORTS
+#              define PHP_ICONV_API __declspec(dllexport)
+#      else
+#              define PHP_ICONV_API __declspec(dllimport)
+#      endif 
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHP_ICONV_API __attribute__ ((visibility("default")))
 #else
-#define PHP_ICONV_API __declspec(dllimport)
-#endif 
-#else
-#define PHP_ICONV_API
+#      define PHP_ICONV_API
 #endif
 
 #ifdef PHP_ATOM_INC
index 8503d85b222c20a4ed9d63502a11bef81b41f785..17aa7c5cb5ff307d7c422fae6a6cfc7efb6cf6fb 100644 (file)
@@ -27,9 +27,11 @@ extern zend_module_entry libxml_module_entry;
 #define libxml_module_ptr &libxml_module_entry
 
 #ifdef PHP_WIN32
-#define PHP_LIBXML_API __declspec(dllexport)
+#      define PHP_LIBXML_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHP_LIBXML_API __attribute__ ((visibility("default")))
 #else
-#define PHP_LIBXML_API
+#      define PHP_LIBXML_API
 #endif
 
 #include "ext/standard/php_smart_str.h"
index 63afaf50942487887b29f0f9443e8065049e1a9c..1393559f8e9b4a8e414154130aa275b5475f8b3f 100644 (file)
 #endif
 
 #ifdef PHP_WIN32
-# undef MBSTRING_API
-# ifdef MBSTRING_EXPORTS
-#  define MBSTRING_API __declspec(dllexport)
-# elif defined(COMPILE_DL_MBSTRING)
-#  define MBSTRING_API __declspec(dllimport)
-# else
-#  define MBSTRING_API /* nothing special */
-# endif
+#      undef MBSTRING_API
+#      ifdef MBSTRING_EXPORTS
+#              define MBSTRING_API __declspec(dllexport)
+#      elif defined(COMPILE_DL_MBSTRING)
+#              define MBSTRING_API __declspec(dllimport)
+#      else
+#              define MBSTRING_API /* nothing special */
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      undef MBSTRING_API
+#      define MBSTRING_API __attribute__ ((visibility("default")))
 #else
-# undef MBSTRING_API
-# define MBSTRING_API /* nothing special */
+#      undef MBSTRING_API
+#      define MBSTRING_API /* nothing special */
 #endif
 
 
index 65503f978a160871611dd9e4e4043d6f11e7e4b0..75e6436743d88581b5c85c6252d214358bb6952b 100644 (file)
@@ -157,7 +157,11 @@ typedef struct {
 #define L64(x) x##i64
 typedef __int64 my_longlong;
 #else
-#define PHP_MYSQLI_API
+# if defined(__GNUC__) && __GNUC__ >= 4
+#  define PHP_MYSQLI_API __attribute__ ((visibility("default")))
+# else
+#  define PHP_MYSQLI_API
+# endif
 #define MYSQLI_LLU_SPEC "%llu"
 #define MYSQLI_LL_SPEC "%lld"
 #define L64(x) x##LL
index fa83596e484e21e0d1c3c3aa01dc69d6e8c0e92a..b2e146894946e22b5517be6568f87f16581f988c 100755 (executable)
@@ -31,15 +31,17 @@ extern zend_module_entry pdo_module_entry;
 #define phpext_pdo_ptr &pdo_module_entry
 
 #ifdef PHP_WIN32
-# if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
-#  define PDO_API __declspec(dllexport)
-# elif defined(COMPILE_DL_PDO)
-#  define PDO_API __declspec(dllimport)
-# else
-#  define PDO_API /* nothing special */
-# endif
+#      if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
+#              define PDO_API __declspec(dllexport)
+#      elif defined(COMPILE_DL_PDO)
+#              define PDO_API __declspec(dllimport)
+#      else
+#              define PDO_API /* nothing special */
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PDO_API __attribute__ ((visibility("default")))
 #else
-# define PDO_API /* nothing special */
+#      define PDO_API /* nothing special */
 #endif
 
 #ifdef ZTS
index 0e384348685c12990430e2f82ee4c0ae58055831..96ce461b6fd1a38ec3f201e9809121b58532c6ad 100644 (file)
@@ -42,7 +42,11 @@ extern zend_module_entry pgsql_module_entry;
 #endif
 #else
 #include <libpq/libpq-fs.h>
-#define PHP_PGSQL_API /* nothing special */
+# if defined(__GNUC__) && __GNUC__ >= 4
+#  define PHP_PGSQL_API __attribute__ ((visibility("default")))
+# else
+#  define PHP_PGSQL_API
+# endif
 #endif
 
 #ifdef HAVE_PG_CONFIG_H
index 7508f4f97934f85c9316dfdd0d7e37c12d4371a4..495907bbd16ed2c19ef475bfa5152ed78968d945 100644 (file)
@@ -7,9 +7,11 @@ extern zend_module_entry extname_module_entry;
 #define phpext_extname_ptr &extname_module_entry
 
 #ifdef PHP_WIN32
-#define PHP_EXTNAME_API __declspec(dllexport)
+#      define PHP_EXTNAME_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHP_EXTNAME_API __attribute__ ((visibility("default")))
 #else
-#define PHP_EXTNAME_API
+#      define PHP_EXTNAME_API
 #endif
 
 #ifdef ZTS
index 1c202747ecc888e31c49f1acca05242a2137765e..a6ec050c272077bdb297f8d635785757f1d51cc6 100755 (executable)
@@ -32,15 +32,17 @@ extern zend_module_entry spl_module_entry;
 #define phpext_spl_ptr &spl_module_entry
 
 #ifdef PHP_WIN32
-# ifdef SPL_EXPORTS
-#  define SPL_API __declspec(dllexport)
-# elif defined(COMPILE_DL_SPL)
-#  define SPL_API __declspec(dllimport)
-# else
-#  define SPL_API /* nothing */
-# endif
+#      ifdef SPL_EXPORTS
+#              define SPL_API __declspec(dllexport)
+#      elif defined(COMPILE_DL_SPL)
+#              define SPL_API __declspec(dllimport)
+#      else
+#              define SPL_API /* nothing */
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define SPL_API __attribute__ ((visibility("default")))
 #else
-# define SPL_API
+#      define SPL_API
 #endif
 
 #if defined(PHP_WIN32) && !defined(COMPILE_DL_SPL)
index 3fe387fb6758ad70ded3a838bb47cbb45b81e377..22769c84432b8acf1d36a343e34a739e6736d313 100644 (file)
@@ -37,9 +37,11 @@ extern zend_module_entry unicode_module_entry;
 #define phpext_unicode_ptr &unicode_module_entry
 
 #ifdef PHP_WIN32
-#define PHP_UNICODE_API __declspec(dllexport)
+#      define PHP_UNICODE_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHP_UNICODE_API __attribute__ ((visibility("default")))
 #else
-#define PHP_UNICODE_API
+#      define PHP_UNICODE_API
 #endif
 
 PHP_MINIT_FUNCTION(unicode);
index 6af8451b56eba9ec6bc0552f05871e81337b1d18..953acfcfd9a1f3a49bf2f3a8660d93ee73a4f52b 100644 (file)
 /* #defines that rename all zip_ functions and structs */
 #include "zip_alias.h"
 #ifdef PHP_WIN32
-#include "zip_win32.h"
-# ifdef PHP_ZIP_EXPORTS
-#  define PHPZIPAPI __declspec(dllexport)
-# else
-#  define PHPZIPAPI
-# endif
+#      include "zip_win32.h"
+#      ifdef PHP_ZIP_EXPORTS
+#              define PHPZIPAPI __declspec(dllexport)
+#      else
+#              define PHPZIPAPI
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHPZIPAPI __attribute__ ((visibility("default")))
 #else
-#define PHPZIPAPI
+#      define PHPZIPAPI
 #endif
 BEGIN_EXTERN_C()
 #include <sys/types.h>
index d34c47248e08c52d939793eec39eb7791a67237f..b7e1366eb351eb0f3388bde286cdcf96051c25a7 100644 (file)
 
 #ifdef PHP_WIN32
 #      ifdef SAPI_EXPORTS
-#      define SAPI_API __declspec(dllexport) 
+#              define SAPI_API __declspec(dllexport) 
 #      else
-#      define SAPI_API __declspec(dllimport) 
+#              define SAPI_API __declspec(dllimport) 
 #      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define SAPI_API __attribute__ ((visibility("default")))
 #else
-#define SAPI_API
+#      define SAPI_API
 #endif
 
 #undef shutdown
index 4c83fead038144a2c510aa12daa8a67e2b735abe..d4f0199e55a2ffe3a96d9e3865981b1d25e6df75 100644 (file)
 #define PHP_DEBUG ZEND_DEBUG
 
 #ifdef PHP_WIN32
-#include "tsrm_win32.h"
-#include "win95nt.h"
+#      include "tsrm_win32.h"
+#      include "win95nt.h"
 #      ifdef PHP_EXPORTS
-#      define PHPAPI __declspec(dllexport)
+#              define PHPAPI __declspec(dllexport)
 #      else
-#      define PHPAPI __declspec(dllimport)
+#              define PHPAPI __declspec(dllimport)
 #      endif
-#define PHP_DIR_SEPARATOR '\\'
-#define PHP_EOL "\r\n"
+#      define PHP_DIR_SEPARATOR '\\'
+#      define PHP_EOL "\r\n"
 #else
-#define PHPAPI
+#      if defined(__GNUC__) && __GNUC__ >= 4
+#              define PHPAPI __attribute__ ((visibility("default")))
+#      else
+#              define PHPAPI
+#      endif
+
 #define THREAD_LS
 #define PHP_DIR_SEPARATOR '/'
 #if defined(__MacOSX__)
index 561d38f8ae8af347f5745c1ecf6f1248cf557228..0790f669138ae2da1872938a243bf4432970a4f9 100644 (file)
@@ -65,4 +65,10 @@ extern const command_rec php_dir_cmds[];
 
 #define APR_ARRAY_FOREACH_CLOSE() }}
 
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef AP_MODULE_DECLARE_DATA
+# define AP_MODULE_DECLARE_DATA PHPAPI
+#endif
+
 #endif /* PHP_APACHE_H */
index 6edc9e2b6998d3055b99549672fadacfd65a6336..cebd2d068053c1aa2310496f2007b7e0b01e49ec 100644 (file)
@@ -82,5 +82,10 @@ extern php_apache2_info_struct php_apache2_info;
 #define AP2(v) (php_apache2_info.v)
 #endif
 
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef AP_MODULE_DECLARE_DATA
+# define AP_MODULE_DECLARE_DATA PHPAPI
+#endif
 
 #endif /* PHP_APACHE_H */
index 0d61bf89822a388a7e76adc02210184cee3de2ce..1549dbf2636f9c37969ead07d46d18914354668f 100644 (file)
@@ -71,6 +71,13 @@ extern php_apache_info_struct php_apache_info;
 #define AP_LOGGING 10
 #define AP_CLEANUP 11
 
+
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef MODULE_VAR_EXPORT
+# define MODULE_VAR_EXPORT PHPAPI
+#endif
+
 #endif                                                 /* MOD_PHP5_H */
 
 /*
index 9300241d449200dc18b714d4a4c674347e774e5e..d229fec53faf33b6838943ca59ec6c600f12c168 100644 (file)
@@ -9,8 +9,12 @@
 #              define MODULE_API __declspec(dllimport) 
 #      endif
 #else
+#      if defined(__GNUC__) && __GNUC__ >= 4
+#              define MODULE_API __attribute__ ((visibility("default")))
+#      else
+#              define MODULE_API
+#      endif
 #      define far
-#      define MODULE_API
 
        typedef int BOOL;
        typedef void far *LPVOID;