|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
several patches for Solaris >= 10Hi.
Please find attached a series of patches for Solaris >= 10, based on 2.2.4 code. These patches will not work for Solaris < 10 (and apr's ./configure is patched to take that into account). Thank you. --Stefan -- Stefan Teleman KDE e.V. stefan.teleman@... [apr_atomic.c.diff] --- srclib/apr/atomic/unix/apr_atomic.c.orig 2006-08-03 07:05:27.000000000 -0400 +++ srclib/apr/atomic/unix/apr_atomic.c 2007-03-13 23:29:16.356121000 -0400 @@ -1,9 +1,9 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at +/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -22,19 +22,69 @@ #include <stdlib.h> -#if defined(__GNUC__) && defined(__STRICT_ANSI__) && !defined(USE_GENERIC_ATOMICS) +#if defined(SOLARIS2) && ((SOLARIS2 + 0) >= 10) +#include <atomic.h> +#if defined(USE_GENERIC_ATOMICS) +#undef USE_GENERIC_ATOMICS +#endif + +static volatile apr_uint32_t solaris_atomic_cas32(volatile apr_uint32_t *mem, + apr_uint32_t with, + apr_uint32_t cmp) +{ + volatile uint32_t prev; + prev = atomic_cas_32(mem, cmp, with); + return (apr_uint32_t) prev; +} + +static volatile apr_uint32_t solaris_atomic_add32(volatile apr_uint32_t *mem, + apr_uint32_t val) +{ + return (apr_uint32_t) atomic_add_32_nv(mem, (int32_t) val); +} + +static volatile apr_uint32_t solaris_atomic_sub32(volatile apr_uint32_t *mem, + apr_uint32_t val) +{ + volatile uint32_t result; + volatile int32_t sub = (int32_t) -val; + result = atomic_add_32_nv(mem, sub); + return (apr_uint32_t) result; +} + +static volatile int solaris_atomic_dec32(volatile apr_uint32_t *mem) +{ + volatile int32_t result; + result = (int32_t) atomic_dec_32_nv((volatile uint32_t *) mem); + result -= 1; + return (int) result; +} + +static volatile apr_uint32_t solaris_atomic_swap32(volatile apr_uint32_t *mem, apr_uint32_t val) +{ + volatile uint32_t result; + result = atomic_swap_32((uint32_t *) mem, (uint32_t *) val); + return (apr_uint32_t) result; +} + +#endif /* SOLARIS */ + +#if defined(__GNUC__) && defined(__STRICT_ANSI__) && !defined(USE_GENERIC_ATOMICS) && !defined(SOLARIS10) /* force use of generic atomics if building e.g. with -std=c89, which * doesn't allow inline asm */ #define USE_GENERIC_ATOMICS #endif -#if (defined(__i386__) || defined(__x86_64__)) \ - && defined(__GNUC__) && !defined(USE_GENERIC_ATOMICS) +#if (defined(__i386__) || defined(__i386) || defined (__amd64) || defined(__x86_64__) || defined (__sparc) || defined (__sparcv9)) \ + && !defined(USE_GENERIC_ATOMICS) && defined(SOLARIS2) APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with, apr_uint32_t cmp) { +#if defined(SOLARIS2) && ((SOLARIS2 + 0) >= 10) + return solaris_atomic_cas32(mem, with, cmp); +#else apr_uint32_t prev; asm volatile ("lock; cmpxchgl %1, %2" @@ -42,17 +92,23 @@ : "r" (with), "m" (*(mem)), "0"(cmp) : "memory", "cc"); return prev; +#endif } #define APR_OVERRIDE_ATOMIC_CAS32 static apr_uint32_t inline intel_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) { +#if defined(SOLARIS2) && ((SOLARIS2 + 0) >= 10) + return solaris_atomic_add32(mem, val); +#else + asm volatile ("lock; xaddl %0,%1" : "=r"(val), "=m"(*mem) /* outputs */ : "0"(val), "m"(*mem) /* inputs */ : "memory", "cc"); return val; +#endif } APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, @@ -64,15 +120,22 @@ APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) { +#if defined(SOLARIS2) && ((SOLARIS2 + 0) >= 10) + solaris_atomic_sub32(mem, val); +#else asm volatile ("lock; subl %1, %0" : : "m" (*(mem)), "r" (val) : "memory", "cc"); +#endif } #define APR_OVERRIDE_ATOMIC_SUB32 APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) { +#if defined(SOLARIS2) && ((SOLARIS2 + 0) >= 10) + return solaris_atomic_dec32(mem); +#else unsigned char prev; asm volatile ("lock; decl %1;\n\t" @@ -81,6 +144,7 @@ : "m" (*(mem)) : "memory", "cc"); return prev; +#endif } #define APR_OVERRIDE_ATOMIC_DEC32 @@ -98,6 +162,9 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val) { +#if defined(SOLARIS2) && ((SOLARIS2 + 0) >= 10) + return solaris_atomic_swap32(mem, val); +#else apr_uint32_t prev = val; asm volatile ("lock; xchgl %0, %1" @@ -105,12 +172,13 @@ : "m" (*(mem)), "0"(prev) : "memory"); return prev; +#endif } #define APR_OVERRIDE_ATOMIC_XCHG32 /*#define apr_atomic_init(pool) APR_SUCCESS*/ -#endif /* (__linux__ || __EMX__ || __FreeBSD__) && __i386__ */ +#endif /* (__linux__ || __EMX__ || __FreeBSD__ || __sun) */ #if (defined(__PPC__) || defined(__ppc__)) && defined(__GNUC__) \ && !defined(USE_GENERIC_ATOMICS) [apr_hints.m4.diff] --- srclib/apr/build/apr_hints.m4.orig Thu Aug 3 04:05:27 2006 +++ srclib/apr/build/apr_hints.m4 Tue Mar 20 16:31:54 2007 @@ -234,8 +234,13 @@ ;; *-solaris2*) PLATOSVERS=`echo $host | sed 's/^.*solaris2.//'` + if [ $PLATOSVERS -ge 10 ] ; then APR_ADDTO(CPPFLAGS, [-DSOLARIS2=$PLATOSVERS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT]) + APR_SETIFNULL(apr_lock_method, [USE_SYSVSEM_SERIALIZE]) + else + APR_ADDTO(CPPFLAGS, [-DSOLARIS2=$PLATOSVERS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT]) APR_SETIFNULL(apr_lock_method, [USE_FCNTL_SERIALIZE]) + endif ;; *-sunos4*) APR_ADDTO(CPPFLAGS, [-DSUNOS4]) [configure.apr.diff] --- srclib/apr/configure.orig Fri Jan 5 22:39:14 2007 +++ srclib/apr/configure Tue Mar 20 16:27:57 2007 @@ -4931,9 +4931,14 @@ if test -z "$apr_lock_method"; then + if [ $PLATOSVERS -ge 10 ] ; then + test "x$silent" != "xyes" && echo " setting apr_lock_method to \"USE_SYSVSEM_SERIALIZE\"" + apr_lock_method="USE_SYSVSEM_SERIALIZE" + else test "x$silent" != "xyes" && echo " setting apr_lock_method to \"USE_FCNTL_SERIALIZE\"" apr_lock_method="USE_FCNTL_SERIALIZE" fi + fi ;; *-sunos4*) [mpm_common.c.diff] --- server/mpm_common.c.orig 2006-09-15 09:19:25.000000000 -0400 +++ server/mpm_common.c 2007-03-13 23:30:40.194531000 -0400 @@ -1186,16 +1186,22 @@ apr_status_t ap_fatal_signal_setup(server_rec *s, apr_pool_t *in_pconf) { #ifndef NO_USE_SIGACTION - struct sigaction sa; + struct sigaction sa; sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + +#if defined(SA_RESTART) + sa.sa_flags |= SA_RESTART; +#endif +#if defined(SA_INTERRUPT) + sa.sa_flags |= SA_INTERRUPT; +#endif #if defined(SA_ONESHOT) - sa.sa_flags = SA_ONESHOT; + sa.sa_flags |= SA_ONESHOT; #elif defined(SA_RESETHAND) - sa.sa_flags = SA_RESETHAND; -#else - sa.sa_flags = 0; + sa.sa_flags |= SA_RESETHAND; #endif sa.sa_handler = sig_coredump; [signals.c.diff] --- srclib/apr/threadproc/unix/signals.c.orig 2006-08-03 07:05:27.000000000 -0400 +++ srclib/apr/threadproc/unix/signals.c 2007-03-13 23:29:47.826964000 -0400 @@ -73,7 +73,7 @@ */ APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func) { - struct sigaction act, oact; + struct sigaction act, oact; act.sa_handler = func; sigemptyset(&act.sa_mask); @@ -81,6 +81,9 @@ #ifdef SA_INTERRUPT /* SunOS */ act.sa_flags |= SA_INTERRUPT; #endif +#ifdef SA_RESTART + act.sa_flags |= SA_RESTART; +#endif #if defined(__osf__) && defined(__alpha) /* XXX jeff thinks this should be enabled whenever SA_NOCLDWAIT is defined */ [worker.c.diff] --- server/mpm/worker/worker.c.orig 2006-09-15 09:19:25.000000000 -0400 +++ server/mpm/worker/worker.c 2007-03-13 23:30:10.917395000 -0400 @@ -426,7 +426,7 @@ static void set_signals(void) { #ifndef NO_USE_SIGACTION - struct sigaction sa; + struct sigaction sa; #endif if (!one_process) { @@ -437,6 +437,14 @@ sigemptyset(&sa.sa_mask); sa.sa_flags = 0; +#ifdef SA_RESTART + sa.sa_flags |= SA_RESTART; +#endif + +#ifdef SA_INTERRUPT + sa.sa_flags |= SA_INTERRUPT; +#endif + sa.sa_handler = sig_term; if (sigaction(SIGTERM, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, |
|
|
Re: several patches for Solaris >= 10On Tue, Mar 20, 2007 at 07:53:16PM -0400, Stefan Teleman wrote:
> Please find attached a series of patches for Solaris >= 10, based on 2.2.4 > code. We already added the solaris atomic API support to trunk, pretty long ago at this point. http://svn.apache.org/repos/asf/apr/apr/trunk/atomic/unix/apr_atomic.c Are yours better? (quite possible) Also, why do you undefine the generics atomics defines? they exist for a reason! Your patch also seems to be a diff against a httpd source tree, and includes httpd-specific code. This is dev@apr, please use it only for APR code, and it's best to submit patches against trunk , *not* whatever httpd happens to ship :-) -- Colm MacCárthaigh Public Key: colm+pgp@... |
|
|
Re: several patches for Solaris >= 10On 3/20/07, Colm MacCarthaigh <colm@...> wrote:
> Also, why do you undefine the generics atomics defines? they exist > for a reason! On 3/20/07, Colm MacCarthaigh <colm@...> wrote: > Also, why do you undefine the generics atomics defines? they exist > for a reason! #if defined(SOLARIS2) && ((SOLARIS2 + 0) >= 10) #include <atomic.h> #if defined(USE_GENERIC_ATOMICS) #undef USE_GENERIC_ATOMICS #endif If i am in Solaris >= 10 and i have the Solaris atomics, do i want to still need the generic atomics ? > Your patch also seems to be a diff against a httpd source tree, and > includes httpd-specific code. This is dev@apr, please use it only for > APR code, and it's best to submit patches against trunk , *not* whatever > httpd happens to ship :-) yes it is against 2.2.4. when i sent the original patch for the atomics to httpd@, a couple months ago, i was told to send it to apr@, because "this was an apr patch". ;-) --Stefan -- Stefan Teleman KDE e.V. stefan.teleman@... |
|
|
Re: several patches for Solaris >= 10On Tue, Mar 20, 2007 at 09:32:32PM -0400, Stefan Teleman wrote:
> #if defined(SOLARIS2) && ((SOLARIS2 + 0) >= 10) > #include <atomic.h> > #if defined(USE_GENERIC_ATOMICS) > #undef USE_GENERIC_ATOMICS > #endif > > If i am in Solaris >= 10 and i have the Solaris atomics, do i want to > still need the generic atomics ? That's not how it's structured. It's either generic atomics OR a system/architecture specific implementation, there are valid reasons why people may prefer generic atomics at build time. But the reason is more our conventions; we should never over-ride a user-specifiable define. > >Your patch also seems to be a diff against a httpd source tree, and > >includes httpd-specific code. This is dev@apr, please use it only for > >APR code, and it's best to submit patches against trunk , *not* whatever > >httpd happens to ship :-) > > yes it is against 2.2.4. And is it any better than what we have in trunk? I see you're using the _nv calls, I'm not sure if they mean "nevada" or "non-volatile" though ;-) -- Colm MacCárthaigh Public Key: colm+pgp@... |
| Free embeddable forum powered by Nabble | Forum Help |