Welcome! Log In Create A New Profile

Advanced

php-fpm Sparc support patch

Posted by Marcin Ochab 
All files from this thread

File Name File Size   Posted by Date  
php-5.2.10-fpm-0.5.11-sparc.diff.gz 199.3 KB open | download Marcin Ochab 06/30/2009 Read message
Emoticon1.gif 257 bytes open | download Matt Lewandowsky 07/01/2009 Read message
Emoticon2.gif 258 bytes open | download Matt Lewandowsky 07/01/2009 Read message
Marcin Ochab
php-fpm Sparc support patch
June 29, 2009 12:26PM
I was trying to get working php-fpm for php 5.2.8 on Solaris 9 Sparc
and I got error "unsupported processor. please write a patch and send
it to me".

I 've written a piece of code that works for me.
For universal use will be needed to add some IF directive at top to
find out if system have inttypes.h or stdint.h .

Please consider to add this to build because in new build for 5.2.10
there is still that problem.

Marcin Ochab

--- fpm_atomic.h Mon Jun 29 18:16:03 2009
+++ fpm_atomic.h.new Mon Jun 29 18:17:18 2009
@@ -5,7 +5,7 @@
#ifndef FPM_ATOMIC_H
#define FPM_ATOMIC_H 1

-#include <stdint.h>
+#include <inttypes.h>
#include <sched.h>

#if ( __i386__ || __i386 )
@@ -57,7 +57,47 @@
return res;
}

+#elif (__sparc__ || __sparc)
+#if (__arch64__ || __arch64)
+
+//Sparc support added by Marcin Ochab
+
+typedef uint64_t atomic_uint_t;
+typedef volatile atomic_uint_t atomic_t;
+
+
+static inline int atomic_cas_64(atomic_t *lock, atomic_uint_t old,
atomic_uint_t new)
+{
+ __asm__ __volatile__("casx [%2], %3, %0 " : "=&r"(new) :
"0"(new), "r"(lock), "r"(old): "memory");
+
+ return new;
+}
+
+static inline atomic_uint_t atomic_cmp_set(atomic_t *lock,
atomic_uint_t old, atomic_uint_t set)
+{
+ return (atomic_cas_64(lock, old, set)==old);
+}
+
+
+
#else
+
+typedef uint32_t atomic_uint_t;
+typedef volatile atomic_uint_t atomic_t;
+
+static inline int atomic_cas_32(atomic_t *lock, atomic_uint_t old,
atomic_uint_t new)
+{
+ __asm__ __volatile__("cas [%2], %3, %0 " : "=&r"(new) :
"0"(new), "r"(lock), "r"(old): "memory");
+
+ return new;
+}
+
+static inline atomic_uint_t atomic_cmp_set(atomic_t *lock,
atomic_uint_t old, atomic_uint_t set)
+{
+ return (atomic_cas_32(lock, old, set)==old);
+}
+
+#endif
+
+#else

#error unsupported processor. please write a patch and send it to me
Re: php-fpm Sparc support patch
June 29, 2009 04:09PM
If you can figure out how to get this into the patch itself I will be
more than happy to post a sparc patch in the downloads area.

On Mon, Jun 29, 2009 at 9:26 AM, Marcin Ochab<marcin.ochab@gmail.com> wrote:
>
> I was trying to get working php-fpm for php 5.2.8 on Solaris 9 Sparc
> and I got error "unsupported processor. please write a patch and send
> it to me".
>
> I 've written a piece of code that works for me.
> For universal use will be needed to add some IF directive at top to
> find out if system have inttypes.h or stdint.h .
>
> Please consider to add this to build because in new build for 5.2.10
> there is still that problem.
>
> Marcin Ochab
>
> --- fpm_atomic.h        Mon Jun 29 18:16:03 2009
> +++ fpm_atomic.h.new    Mon Jun 29 18:17:18 2009
> @@ -5,7 +5,7 @@
>  #ifndef FPM_ATOMIC_H
>  #define FPM_ATOMIC_H 1
>
> -#include <stdint.h>
> +#include <inttypes.h>
>  #include <sched.h>
>
>  #if ( __i386__ || __i386 )
> @@ -57,7 +57,47 @@
>        return res;
>  }
>
> +#elif (__sparc__ || __sparc)
> +#if (__arch64__ || __arch64)
> +
> +//Sparc support added by Marcin Ochab
> +
> +typedef uint64_t                    atomic_uint_t;
> +typedef volatile atomic_uint_t      atomic_t;
> +
> +
> +static inline int atomic_cas_64(atomic_t *lock, atomic_uint_t old,
> atomic_uint_t new)
> +{
> +        __asm__ __volatile__("casx [%2], %3, %0 " : "=&r"(new)  :
> "0"(new), "r"(lock), "r"(old): "memory");
> +
> +    return new;
> +}
> +
> +static inline atomic_uint_t atomic_cmp_set(atomic_t *lock,
> atomic_uint_t old, atomic_uint_t set)
> +{
> +       return (atomic_cas_64(lock, old, set)==old);
> +}
> +
> +
> +
>  #else
> +
> +typedef uint32_t                    atomic_uint_t;
> +typedef volatile atomic_uint_t      atomic_t;
> +
> +static inline int atomic_cas_32(atomic_t *lock, atomic_uint_t old,
> atomic_uint_t new)
> +{
> +        __asm__ __volatile__("cas [%2], %3, %0 " : "=&r"(new)  :
> "0"(new), "r"(lock), "r"(old): "memory");
> +
> +    return new;
> +}
> +
> +static inline atomic_uint_t atomic_cmp_set(atomic_t *lock,
> atomic_uint_t old, atomic_uint_t set)
> +{
> +       return (atomic_cas_32(lock, old, set)==old);
> +}
> +
> +#endif
> +
> +#else
>
>  #error unsupported processor. please write a patch and send it to me
>
>
Marcin Ochab
Re: php-fpm Sparc support patch
June 30, 2009 05:54PM
As You requested I have built complete php-fpm patch for php 5.2.10 based on
official version 0.5.11 that supports Sparc and Solaris 9. Except assembler
functions that I've sent you yesterday I've solved some issues on Solaris
with unsetenv(), setenv() , stdint.h . Now as I tested everything compiles
and work on Solaris 9 Sparc even in 64bit mode. I'm using it on site with
about 250 000 shows per day and for now have no problems. It should be
universal for all platforms now! :)

2009/6/29 Michael Shadle

>
> If you can figure out how to get this into the patch itself I will be
> more than happy to post a sparc patch in the downloads area.
>
> On Mon, Jun 29, 2009 at 9:26 AM, Marcin Ochab
> wrote:
> >
> > I was trying to get working php-fpm for php 5.2.8 on Solaris 9 Sparc
> > and I got error "unsupported processor. please write a patch and send
> > it to me".
> >
> > I 've written a piece of code that works for me.
> > For universal use will be needed to add some IF directive at top to
> > find out if system have inttypes.h or stdint.h .
> >
> > Please consider to add this to build because in new build for 5.2.10
> > there is still that problem.
> >
> > Marcin Ochab
> >
> > --- fpm_atomic.h Mon Jun 29 18:16:03 2009
> > +++ fpm_atomic.h.new Mon Jun 29 18:17:18 2009
> > @@ -5,7 +5,7 @@
> > #ifndef FPM_ATOMIC_H
> > #define FPM_ATOMIC_H 1
> >
> > -#include
> > +#include
> > #include
> >
> > #if ( __i386__ || __i386 )
> > @@ -57,7 +57,47 @@
> > return res;
> > }
> >
> > +#elif (__sparc__ || __sparc)
> > +#if (__arch64__ || __arch64)
> > +
> > +//Sparc support added by Marcin Ochab
> > +
> > +typedef uint64_t atomic_uint_t;
> > +typedef volatile atomic_uint_t atomic_t;
> > +
> > +
> > +static inline int atomic_cas_64(atomic_t *lock, atomic_uint_t old,
> > atomic_uint_t new)
> > +{
> > + __asm__ __volatile__("casx [%2], %3, %0 " : "=&r"(new) :
> > "0"(new), "r"(lock), "r"(old): "memory");
> > +
> > + return new;
> > +}
> > +
> > +static inline atomic_uint_t atomic_cmp_set(atomic_t *lock,
> > atomic_uint_t old, atomic_uint_t set)
> > +{
> > + return (atomic_cas_64(lock, old, set)==old);
> > +}
> > +
> > +
> > +
> > #else
> > +
> > +typedef uint32_t atomic_uint_t;
> > +typedef volatile atomic_uint_t atomic_t;
> > +
> > +static inline int atomic_cas_32(atomic_t *lock, atomic_uint_t old,
> > atomic_uint_t new)
> > +{
> > + __asm__ __volatile__("cas [%2], %3, %0 " : "=&r"(new) :
> > "0"(new), "r"(lock), "r"(old): "memory");
> > +
> > + return new;
> > +}
> > +
> > +static inline atomic_uint_t atomic_cmp_set(atomic_t *lock,
> > atomic_uint_t old, atomic_uint_t set)
> > +{
> > + return (atomic_cas_32(lock, old, set)==old);
> > +}
> > +
> > +#endif
> > +
> > +#else
> >
> > #error unsupported processor. please write a patch and send it to me
> >
> >
>
Attachments:
open | download - php-5.2.10-fpm-0.5.11-sparc.diff.gz (199.3 KB)
Matt Lewandowsky
Re: php-fpm Sparc support patch
June 30, 2009 08:00PM
From: Marcin Ochab
Date: 2009年6月30日 14:54
To: highload-php-en@googlegroups.com
Subject: Re: php-fpm Sparc support patch


As You requested I have built complete php-fpm patch for php 5.2.10 based on official version 0.5.11 that supports Sparc and Solaris 9. Except assembler functions that I've sent you yesterday I've solved some issues on Solaris with unsetenv(), setenv() , stdint.h . Now as I tested everything compiles and work on Solaris 9 Sparc even in 64bit mode. I'm using it on site with about 250 000 shows per day and for now have no problems. It should be universal for all platforms now! :)
I am somewhat curious as to the cause of the failure. I last built php-fpm against 5.2.6 for Solaris 10/SPARC. I don't recall anything out of the ordinary. I don't have time to poke at php-fpm for the next few days, likely, but do you know if it's a Solaris 9-specific issue or a SPARC-specific issue? Or, in the latter case, when it broke?

Thanks,

--Matt
Marcin Ochab
Re: php-fpm Sparc support patch
July 01, 2009 06:10AM
I don't know how could You build php-fpm 5.2.6 on SPARC if in
/sapi/cgi/fpm/fpm_atomic.h there was only i386 nad amd64 assembler code
before my patch!
You should get "unsupported processor. please write a patch and send
it to me".

The other isues were:
-broken switching between systems with inttypes.h or stdint.h - I added #if
HAVE_INTTYPES_H directives in few places

-if system doesn't have unsetenv() function it won't compile - I added
#ifndef HAVE_UNSETENV and my implementation of this function in
/sapi/cgi/fpm/fpm_env.c if wasn't in system

-in /sapi/cgi/fpm/fpm_env.c setenv() function wasn't working properly - on
my solaris 9 was adding some stupid data do ENV, I don't know if it was ok
or not on other systems. I've rewritten it in other way.

- when /libevent/libevent.a was compiling no proper /libevent/event-config.h
was generated. It was a problem when for example system doesn't have
stdint.h - I added this file in
/libevent/Makefile.in like this "libevent.a: event-config.h
$(libevent_a_OBJECTS) $(libevent_a_DEPENDENCIES)" and changed order in
/sapi/cgi/Makefile.frag to: "$(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS)
$(SAPI_EXTRA_DEPS) $(PHP_SAPI_OBJS)"


I don't know if on Solaris10 there is stdint.h. If it is probably only
assembler addition in /sapi/cgi/fpm/fpm_atomic.h were needed for this system
- but with my changes code is more universal.

2009/7/1 Matt Lewandowsky

> *From:* Marcin Ochab
> *Date:* 2009$BG/(B6$B7n(B30$BF|(B 14:54
> *To:* highload-php-en@googlegroups.com
> *Subject:* Re: php-fpm Sparc support patch
>
> As You requested I have built complete php-fpm patch for php 5.2.10 based
> on official version 0.5.11 that supports Sparc and Solaris 9. Except
> assembler functions that I've sent you yesterday I've solved some issues
> on Solaris with unsetenv(), setenv() , stdint.h . Now as I tested everything
> compiles and work on Solaris 9 Sparc even in 64bit mode. I'm using it on
> site with about 250 000 shows per day and for now have no problems. It
> should be universal for all platforms now! :)
>
> I am somewhat curious as to the cause of the failure. I last built
> php-fpm against 5.2.6 for Solaris 10/SPARC. I don't recall anything out of
> the ordinary. I don't have time to poke at php-fpm for the next few days,
> likely, but do you know if it's a Solaris 9-specific issue or a
> SPARC-specific issue? Or, in the latter case, when it broke?
>
> Thanks,
>
> --Matt
>
Matt Lewandowsky
Re: php-fpm Sparc support patch
July 01, 2009 06:35AM
From: Marcin Ochab
Date: 2009$BG/(B7$B7n(B1$BF|(B 3:10
To: highload-php-en@googlegroups.com
Subject: Re: php-fpm Sparc support patch


I don't know how could You build php-fpm 5.2.6 on SPARC if in /sapi/cgi/fpm/fpm_atomic.h there was only i386 nad amd64 assembler code before my patch!
You should get "unsupported processor. please write a patch and send
it to me".

[SNIPPED]

I don't know if on Solaris10 there is stdint.h. If it is probably only assembler addition in /sapi/cgi/fpm/fpm_atomic.h were needed for this system - but with my changes code is more universal.



Interesting... I don't know what I had to do to get it working; I don't see any patches in my dir aside from php-fpm... But it (obviously) has been some time since I last built it (Build Date Aug 3 2008 01:29:57), so perhaps I have forgotten something that I came across somewhere. I've been meaning to get a newer version built, so perhaps I'll give your new patch a try in the next few days!

And yes, there's stdint.h on Solaris 10 (and presumably OpenSolaris, but I'm not logged into an OpenSolaris machine right now).

Thanks for giving SPARC some love, though. It does well with tasks like this.

Warmest,

--Matt
Attachments:
open | download - Emoticon1.gif (257 bytes)
open | download - Emoticon2.gif (258 bytes)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 315
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready