Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 49110 invoked by uid 500); 27 Nov 2001 02:48:24 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 49099 invoked from network); 27 Nov 2001 02:48:24 -0000 Date: 27 Nov 2001 02:31:55 -0000 Message-ID: <20011127023155.25720.qmail@icarus.apache.org> From: wrowe@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/include/arch/win32 misc.h X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N wrowe 01/11/26 18:31:55 Modified: misc/win32 misc.c misc/unix start.c include/arch/win32 misc.h Log: Introduce apr_os_level, an apr-private internal value for optimizing the resolution of os versions under Win32. Since so many APIs rely on this determination, this should improve the performance. Pre-determine the version within the apr_initialize() call. Revision Changes Path 1.5 +36 -32 apr/misc/win32/misc.c Index: misc.c =================================================================== RCS file: /home/cvs/apr/misc/win32/misc.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- misc.c 2001/02/16 04:15:57 1.4 +++ misc.c 2001/11/27 02:31:55 1.5 @@ -55,15 +55,15 @@ #include "apr_private.h" #include "misc.h" +apr_oslevel_e apr_os_level = APR_WIN_UNK; + apr_status_t apr_get_oslevel(apr_pool_t *cont, apr_oslevel_e *level) { static OSVERSIONINFO oslev; static unsigned int servpack = 0; - static BOOL first = TRUE; char *pservpack; - if (first) { - first = FALSE; + if (apr_os_level == APR_WIN_UNK) { oslev.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&oslev); if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) { @@ -72,43 +72,47 @@ ; if (*pservpack) servpack = atoi(pservpack); - } - } - if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) { - if (oslev.dwMajorVersion == 5) { - (*level) = APR_WIN_2000; } - else if (oslev.dwMajorVersion == 4) { - if (servpack >= 6) { - (*level) = APR_WIN_NT_4_SP6; - } - else if (servpack >= 4) { - (*level) = APR_WIN_NT_4_SP4; - } - else if (servpack >= 3) { - (*level) = APR_WIN_NT_4_SP3; + if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) { + if (oslev.dwMajorVersion == 5) { + (*level) = APR_WIN_2000; } - else if (servpack >= 2) { - (*level) = APR_WIN_NT_4_SP2; + else if (oslev.dwMajorVersion == 4) { + if (servpack >= 6) { + (*level) = APR_WIN_NT_4_SP6; + } + else if (servpack >= 4) { + (*level) = APR_WIN_NT_4_SP4; + } + else if (servpack >= 3) { + (*level) = APR_WIN_NT_4_SP3; + } + else if (servpack >= 2) { + (*level) = APR_WIN_NT_4_SP2; + } + else { + (*level) = APR_WIN_NT_4; + } } else { - (*level) = APR_WIN_NT_4; + (*level) = APR_WIN_NT; } - } - else { - (*level) = APR_WIN_NT; - } - return APR_SUCCESS; - } - else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { - if (oslev.dwMinorVersion == 0) { - (*level) = APR_WIN_95; return APR_SUCCESS; } - else if (oslev.dwMinorVersion > 0) { - (*level) = APR_WIN_98; - return APR_SUCCESS; + else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { + if (oslev.dwMinorVersion == 0) { + (*level) = APR_WIN_95; + return APR_SUCCESS; + } + else if (oslev.dwMinorVersion > 0) { + (*level) = APR_WIN_98; + return APR_SUCCESS; + } } + } + else { + *level = apr_os_level; + return APR_SUCCESS; } return APR_EEXIST; } 1.57 +9 -0 apr/misc/unix/start.c Index: start.c =================================================================== RCS file: /home/cvs/apr/misc/unix/start.c,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- start.c 2001/11/05 20:00:26 1.56 +++ start.c 2001/11/27 02:31:55 1.57 @@ -74,6 +74,9 @@ WSADATA wsaData; int err; #endif +#if defined WIN32 + apr_oslevel_e osver; +#endif if (initialized++) { return APR_SUCCESS; @@ -83,6 +86,12 @@ return APR_ENOPOOL; } +#ifdef WIN32 + /* Initialize apr_os_level global */ + if (apr_get_oslevel(global_apr_pool, &osver) != APR_SUCCESS) { + return APR_EEXIST; + } +#endif #if !defined(BEOS) && !defined(OS2) && !defined(WIN32) && !defined(NETWARE) apr_unix_setup_lock(); apr_proc_mutex_unix_setup_lock(); 1.33 +3 -1 apr/include/arch/win32/misc.h Index: misc.h =================================================================== RCS file: /home/cvs/apr/include/arch/win32/misc.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- misc.h 2001/11/21 17:48:38 1.32 +++ misc.h 2001/11/27 02:31:55 1.33 @@ -104,7 +104,8 @@ * export new kernel or winsock functions or behavior. */ typedef enum { - APR_WIN_95 = 0, + APR_WIN_UNK = 0, + APR_WIN_95 = 2, APR_WIN_98 = 4, APR_WIN_NT = 8, APR_WIN_NT_4 = 12, @@ -115,6 +116,7 @@ APR_WIN_2000 = 24 } apr_oslevel_e; +extern apr_oslevel_e apr_os_level; typedef enum { DLL_WINBASEAPI = 0, // kernel32 From WinBase.h