rbb         99/10/14 10:39:09

  Modified:    src/lib/apr acconfig.h
               src/lib/apr/time/unix time.c
  Added:       src/lib/apr/inc apr_macro.h
  Log:
  Isolate the APR thread-safety macros.  This makes any macro available to
  ANY portion of APR.  It also makes these macros internal to APR only,
  because this header file is not exposed to programs which use APR.
  
  Revision  Changes    Path
  1.7       +0 -34     apache-2.0/src/lib/apr/acconfig.h
  
  Index: acconfig.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/acconfig.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- acconfig.h        1999/10/11 14:13:19     1.6
  +++ acconfig.h        1999/10/14 17:38:45     1.7
  @@ -66,40 +66,6 @@
   Sigfunc *signal(int signo, Sigfunc * func);
   #endif
   
  -#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
  -#define SAFETY_LOCK(func_name, cnt, name_str) \
  -    { \
  -    if (lock_##func_name == NULL) \
  -        if (ap_create_lock(&lock_##func_name, APR_MUTEX, APR_INTRAPROCESS, 
name_str, cnt) != APR_SUCCESS) \
  -            return APR_NOTTHREADSAFE; \
  -    if (ap_lock(lock_##func_name) != APR_SUCCESS) \
  -        return APR_NOTTHREADSAFE; \
  -    }
  -#else
  -#define SAFETY_LOCK(func_name, cnt)
  -#endif 
  -        
  -#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
  -#define SAFETY_UNLOCK(func_name) \
  -    if (ap_unlock(lock_##func_name) != APR_SUCCESS) { \
  -        return APR_NOTTHREADSAFE; \
  -    }
  -#else
  -#define SAFETY_UNLOCK(func_name, cnt)
  -#endif 
  -
  -#ifdef HAVE_GMTIME_R
  -#define GMTIME_R(x, y) gmtime_r(x, y)
  -#else
  -#define GMTIME_R(x, y) memcpy(y, gmtime(x), sizeof(y))
  -#endif
  -
  -#ifdef HAVE_LOCALTIME_R
  -#define LOCALTIME_R(x, y) localtime_r(x, y)
  -#else
  -#define LOCALTIME_R(x, y) memcpy(y, localtime(x), sizeof(y))
  -#endif
  -
   #if !defined(HAVE_STRCASECMP) && defined(HAVE_STRICMP)
   #define strcasecmp(s1,s2) stricmp(s1,s2)
   #endif
  
  
  
  1.1                  apache-2.0/src/lib/apr/inc/apr_macro.h
  
  Index: apr_macro.h
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group and was originally based
   * on public domain software written at the National Center for
   * Supercomputing Applications, University of Illinois, Urbana-Champaign.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #ifndef AP_MACROS_H
  #define AP_MACROS_H
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  #ifndef _POSIX_THREAD_SAFE_FUNCTIONS
  #define SAFETY_LOCK(func_name, name_str) \
      { \
      if (lock_##func_name == NULL) \
          if (ap_create_lock(&lock_##func_name, APR_MUTEX, APR_INTRAPROCESS, 
name_
  str, NULL) != APR_SUCCESS) \
              return APR_NOTTHREADSAFE; \
      if (ap_lock(lock_##func_name) != APR_SUCCESS) \
          return APR_NOTTHREADSAFE; \
      }
  #else
  #define SAFETY_LOCK(func_name, name_str)
  #endif
  
  #ifndef _POSIX_THREAD_SAFE_FUNCTIONS
  #define SAFETY_UNLOCK(func_name) \
      if (ap_unlock(lock_##func_name) != APR_SUCCESS) { \
          return APR_NOTTHREADSAFE; \
      }
  #else
  #define SAFETY_UNLOCK(func_name)
  #endif
  
  #ifdef HAVE_GMTIME_R
  #define GMTIME_R(x, y) gmtime_r(x, y)
  #else
  #define GMTIME_R(x, y) memcpy(y, gmtime(x), sizeof(y))
  #endif
  
  #ifdef HAVE_LOCALTIME_R
  #define LOCALTIME_R(x, y) localtime_r(x, y)
  #else
  #define LOCALTIME_R(x, y) memcpy(y, localtime(x), sizeof(y))
  #endif
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif        /* !AP_MACROS_H */
  
  
  
  1.7       +3 -2      apache-2.0/src/lib/apr/time/unix/time.c
  
  Index: time.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/time/unix/time.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- time.c    1999/10/11 17:52:27     1.6
  +++ time.c    1999/10/14 17:39:03     1.7
  @@ -58,6 +58,7 @@
   #include "apr_general.h"
   #include "apr_lib.h"
   #include "apr_portable.h"
  +#include "apr_macro.h"
   #include <time.h>
   #include <errno.h>
   #include <string.h>
  @@ -111,13 +112,13 @@
   {
       switch (type) {
       case APR_LOCALTIME: {
  -        SAFETY_LOCK(localtime, atime->cntxt, "localtimefile");
  +        SAFETY_LOCK(localtime, "localtimefile");
           LOCALTIME_R(&atime->currtime->tv_sec, atime->explodedtime);
           SAFETY_UNLOCK(localtime);
           break;
       }
       case APR_UTCTIME: {
  -        SAFETY_LOCK(gmtime, atime->cntxt, "gmtimefile");
  +        SAFETY_LOCK(gmtime, "gmtimefile");
           GMTIME_R(&atime->currtime->tv_sec, atime->explodedtime);
           SAFETY_UNLOCK(gmtime);
           break;
  
  
  

Reply via email to