Edit report at http://bugs.php.net/bug.php?id=51183&edit=1

 ID:               51183
 Updated by:       srina...@php.net
 Reported by:      markus dot schiegl at lbbw dot de
 Summary:          ext/date/php_date.c fails to compile with Sun Studio
                   and PHP 5.2.13
 Status:           Assigned
 Type:             Bug
 Package:          Compile Failure
 Operating System: Solaris 10 (Sparc)
 PHP Version:      5.2.13
 Assigned To:      derick

 New Comment:

with sun studio 12 update, __inline is now recognized as synonymous for
inline. this patch makes this code compilable on all platforms

[sn123...@bflat]'php-5.3.2'>diff -u ext/date/php_date.c.ORIG
ext/date/php_date.c--- ext/date/php_date.c.ORIG    Mon May 31 08:38:45
2010

+++ ext/date/php_date.c Mon May 31 08:33:34 2010

@@ -36,7 +36,7 @@

 #elif defined(__GNUC__) && __GNUC__ < 3

 static __inline __int64_t php_date_llabs( __int64_t i ) { return i >= 0
? i : -i; }

 #else

-static __inline long long php_date_llabs( long long i ) { return i >= 0
? i : -i; }

+static inline long long php_date_llabs( long long i ) { return i >= 0 ?
i : -i; }

 #endif



(C99 standard does support inline keyword)



I can commit this bug, if no one has any objections to it.


Previous Comments:
------------------------------------------------------------------------
[2010-03-15 18:16:17] uklaus at hgb-leipzig dot de

for the records, 



Sun Studio 11 compiler on Solaris 10 Sparc: doesn't compile

Sun Studio 12 compiler on Solaris 10 Sparc: doesn't compile

Sun Studio 12 Update 1 compiler on Solaris 10 Sparc: compiles

------------------------------------------------------------------------
[2010-03-10 11:02:49] jose-marcio dot martins at mines-paristech dot fr

I submited this patch as it's simple and will work for every combination
of OS and compiler.



But the result is that php_date_llabs function isn't defined as inline.
This may be an important performance issue only if this function is
called very very frequently (I don't know if this hypothesis is true and
I don't believe).



The correct solution could be to redefine this with some other checks in
order to use the correct inline declaration syntax. Another solution, as
this is a really simple function is to declare it as a macro. Something
of the kind :



#define php_date_llabs(i)  ((long long) ((i) >= 0 ? (i) : -(i))

------------------------------------------------------------------------
[2010-03-08 20:26:07] rcshishe at cord dot edu

This also affects Solaris 10 x86 with Sun Studio compiler.

------------------------------------------------------------------------
[2010-03-05 11:42:12] markus dot schiegl at lbbw dot de

Jose Marcio, thanks for the patch. Compiles and works fine now!

------------------------------------------------------------------------
[2010-03-02 13:25:22] markus dot schiegl at lbbw dot de

Description:
------------
PHP 5.2.13 doesn't compile with Sun Studio compiler on Solaris 10 Sparc.
Configure works fine (as in 5.2.12), Make fails on ext/date/php_date.c
file with:



/bin/sh /opt/build/php/php-5.2.13/libtool --silent --preserve-dup-deps
--mode=compile cc -Iext/date/lib -Iext/date/
-I/opt/build/php/php-5.2.13/ext/d

ate/ -DPHP_ATOM_INC -I/opt/build/php/php-5.2.13/include
-I/opt/build/php/php-5.2.13/main -I/opt/build/php/php-5.2.13
-I/opt/build/php/php-5.2.13/ext/

date/lib -I/opt/build/php/ext/libxml2/include/libxml2 -I/usr/sfw/include
-I/opt/build/php/ext/curl/include -I/opt/build/php/ext/jpeg/include
-I/opt/b

uild/php/ext/freetype2/include
-I/opt/build/php/ext/freetype2/include/freetype2
-I/opt/build/php/ext/gettext/include -I/opt/build/php/ext/libiconv/in

clude -I/opt/build/php/php-5.2.13/ext/mbstring/oniguruma
-I/opt/build/php/php-5.2.13/ext/mbstring/libmbfl
-I/opt/build/php/php-5.2.13/ext/mbstring/li

bmbfl/mbfl -I/opt/build/php/ext/libmcrypt/include
-I/opt/build/php/ext/freetds/include -I/opt/build/php/ext/mysql/include
-I/opt/build/php/ext/instan

tclient/sdk/include -I/opt/build/php/ext/tidy/include
-I/opt/build/php/ext/xmlrpc-epi/include
-I/opt/build/php/ext/libxslt/include -I/opt/build/php/p

hp-5.2.13/TSRM -I/opt/build/php/php-5.2.13/Zend 
-I/opt/build/php/php/ext/libiconv/include
-I/opt/build/php/php/ext/gettext/include -D_POSIX_PTHREAD_

SEMANTICS  -I/opt/build/php/ext/libiconv/include -O -xs -xstrconst
-zlazyload -xmemalign=8s  -c
/opt/build/php/php-5.2.13/ext/date/php_date.c -o ext/

date/php_date.lo

"/opt/build/php/php-5.2.13/ext/date/php_date.c", line 38: warning: no
explicit type given

"/opt/build/php/php-5.2.13/ext/date/php_date.c", line 38: syntax error
before or at: long

cc: acomp failed for /opt/build/php/php-5.2.13/ext/date/php_date.c

*** Error code 1

make: Fatal error: Command failed for target `ext/date/php_date.lo'



A diff between 5.2.12 and 5.2.13 shows the culprit (php_date_llabs vs.
llabs and/or ifndef HAVE_LLABS, because of bug 50266 and bug 50930)



@@ -30,14 +30,12 @@

 #include "lib/timelib.h"

 #include <time.h>



-#ifndef HAVE_LLABS

-# ifdef PHP_WIN32

-static __inline __int64 llabs( __int64 i ) { return i >= 0? i: -i; }

-# elif defined(__GNUC__) && __GNUC__ < 3

-static __inline __int64_t llabs( __int64_t i ) { return i >= 0 ? i :
-i; }

-# elif defined(NETWARE) && defined(__MWERKS__)

-static __inline long long llabs( long long i ) { return i >= 0 ? i :
-i; }

-# endif

+#ifdef PHP_WIN32

+static __inline __int64 php_date_llabs( __int64 i ) { return i >= 0? i:
-i; }

+#elif defined(__GNUC__) && __GNUC__ < 3

+static __inline __int64_t php_date_llabs( __int64_t i ) { return i >= 0
? i : -i; }

+#else

+static __inline long long php_date_llabs( long long i ) { return i >= 0
? i : -i; }

 #endif



 /* {{{ arginfo */



Expected result:
----------------
successful compile

Actual result:
--------------
compile aborts with error


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51183&edit=1

Reply via email to