~ubuntu-branches/ubuntu/precise/xerces-c/precise-updates

« back to all changes in this revision

Viewing changes to src/xercesc/util/PlatformUtils.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jay Berkenbilt
  • Date: 2009-12-05 14:58:32 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091205145832-378dg3x72mdzfzup
Tags: 3.1.0~rc1-1
* New upstream release; public release candidate uploaded at request of
  upstream.
* Updated source format to '3.0 (quilt)'

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 */
17
17
 
18
18
/*
19
 
 * $Id: PlatformUtils.cpp 695427 2008-09-15 11:05:36Z borisk $
 
19
 * $Id: PlatformUtils.cpp 808881 2009-08-28 13:21:24Z amassari $
20
20
 *
21
21
 */
22
22
 
37
37
#if HAVE_SYS_TIMEB_H
38
38
#       include <sys/timeb.h>
39
39
#endif
 
40
#if HAVE_CPUID_H
 
41
#   include <cpuid.h>
 
42
#endif
40
43
 
41
44
#include <xercesc/util/Mutexes.hpp>
42
45
#include <xercesc/util/PlatformUtils.hpp>
50
53
#include <xercesc/util/XMLInitializer.hpp>
51
54
#include <xercesc/internal/MemoryManagerImpl.hpp>
52
55
 
 
56
#if XERCES_HAVE_INTRIN_H
 
57
#   include <intrin.h>
 
58
#endif
 
59
 
53
60
#include <xercesc/util/XMLFileMgr.hpp>
54
61
#if XERCES_USE_FILEMGR_POSIX
55
62
#       include <xercesc/util/FileManagers/PosixFileMgr.hpp>
147
154
XMLMutex*               XMLPlatformUtils::fgAtomicMutex = 0;
148
155
 
149
156
bool                    XMLPlatformUtils::fgXMLChBigEndian = true;
 
157
bool                    XMLPlatformUtils::fgSSE2ok = false;
150
158
 
151
159
// ---------------------------------------------------------------------------
152
160
//  XMLPlatformUtils: Init/term methods
215
223
    endianTest.ch = 1;
216
224
    fgXMLChBigEndian = (endianTest.ar[sizeof(XMLCh)-1] == 1);
217
225
 
 
226
    // Determine if we can use SSE2 functions
 
227
#if defined(XERCES_HAVE_CPUID_INTRINSIC)
 
228
    int CPUInfo[4]={0};
 
229
    __cpuid(CPUInfo, 1);
 
230
    if(CPUInfo[3] & (1UL << 26))
 
231
        fgSSE2ok = true;
 
232
    else
 
233
        fgSSE2ok = false;
 
234
#elif defined(XERCES_HAVE_GETCPUID)
 
235
    unsigned int eax, ebx, ecx, edx;
 
236
    if(!__get_cpuid (1, &eax, &ebx, &ecx, &edx) || (edx & (1UL << 26))==0)
 
237
        fgSSE2ok = false;
 
238
    else
 
239
        fgSSE2ok = true;
 
240
#elif defined(XERCES_HAVE_SSE2_INTRINSIC)
 
241
    // if we cannot find out at runtime, assume the define has it right
 
242
    fgSSE2ok = true;
 
243
#else
 
244
    fgSSE2ok = false;
 
245
#endif
218
246
 
219
247
    // Initialize the platform-specific mutex and file mgrs
220
248
    fgMutexMgr          = makeMutexMgr(fgMemoryManager);