Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Side by Side Diff: Source/core/platform/audio/DenormalDisabler.h

Issue 23672027: Rename OS(WINDOWS) to OS(WIN) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #define DenormalDisabler_h 26 #define DenormalDisabler_h
27 27
28 #include "wtf/MathExtras.h" 28 #include "wtf/MathExtras.h"
29 #include <float.h> 29 #include <float.h>
30 30
31 namespace WebCore { 31 namespace WebCore {
32 32
33 // Deal with denormals. They can very seriously impact performance on x86. 33 // Deal with denormals. They can very seriously impact performance on x86.
34 34
35 // Define HAVE_DENORMAL if we support flushing denormals to zero. 35 // Define HAVE_DENORMAL if we support flushing denormals to zero.
36 #if OS(WINDOWS) && COMPILER(MSVC) 36 #if OS(WIN) && COMPILER(MSVC)
37 #define HAVE_DENORMAL 37 #define HAVE_DENORMAL
38 #endif 38 #endif
39 39
40 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) 40 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
41 #define HAVE_DENORMAL 41 #define HAVE_DENORMAL
42 #endif 42 #endif
43 43
44 #ifdef HAVE_DENORMAL 44 #ifdef HAVE_DENORMAL
45 class DenormalDisabler { 45 class DenormalDisabler {
46 public: 46 public:
47 DenormalDisabler() 47 DenormalDisabler()
48 : m_savedCSR(0) 48 : m_savedCSR(0)
49 { 49 {
50 #if OS(WINDOWS) && COMPILER(MSVC) 50 #if OS(WIN) && COMPILER(MSVC)
51 // Save the current state, and set mode to flush denormals. 51 // Save the current state, and set mode to flush denormals.
52 // 52 //
53 // http://stackoverflow.com/questions/637175/possible-bug-in-controlfp-s -may-not-restore-control-word-correctly 53 // http://stackoverflow.com/questions/637175/possible-bug-in-controlfp-s -may-not-restore-control-word-correctly
54 _controlfp_s(&m_savedCSR, 0, 0); 54 _controlfp_s(&m_savedCSR, 0, 0);
55 unsigned int unused; 55 unsigned int unused;
56 _controlfp_s(&unused, _DN_FLUSH, _MCW_DN); 56 _controlfp_s(&unused, _DN_FLUSH, _MCW_DN);
57 #else 57 #else
58 m_savedCSR = getCSR(); 58 m_savedCSR = getCSR();
59 setCSR(m_savedCSR | 0x8040); 59 setCSR(m_savedCSR | 0x8040);
60 #endif 60 #endif
61 } 61 }
62 62
63 ~DenormalDisabler() 63 ~DenormalDisabler()
64 { 64 {
65 #if OS(WINDOWS) && COMPILER(MSVC) 65 #if OS(WIN) && COMPILER(MSVC)
66 unsigned int unused; 66 unsigned int unused;
67 _controlfp_s(&unused, m_savedCSR, _MCW_DN); 67 _controlfp_s(&unused, m_savedCSR, _MCW_DN);
68 #else 68 #else
69 setCSR(m_savedCSR); 69 setCSR(m_savedCSR);
70 #endif 70 #endif
71 } 71 }
72 72
73 // This is a nop if we can flush denormals to zero in hardware. 73 // This is a nop if we can flush denormals to zero in hardware.
74 static inline float flushDenormalFloatToZero(float f) 74 static inline float flushDenormalFloatToZero(float f)
75 { 75 {
76 #if OS(WINDOWS) && COMPILER(MSVC) && (!_M_IX86_FP) 76 #if OS(WIN) && COMPILER(MSVC) && (!_M_IX86_FP)
77 // For systems using x87 instead of sse, there's no hardware support 77 // For systems using x87 instead of sse, there's no hardware support
78 // to flush denormals automatically. Hence, we need to flush 78 // to flush denormals automatically. Hence, we need to flush
79 // denormals to zero manually. 79 // denormals to zero manually.
80 return (fabs(f) < FLT_MIN) ? 0.0f : f; 80 return (fabs(f) < FLT_MIN) ? 0.0f : f;
81 #else 81 #else
82 return f; 82 return f;
83 #endif 83 #endif
84 } 84 }
85 private: 85 private:
86 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) 86 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
(...skipping 28 matching lines...) Expand all
115 return (fabs(f) < FLT_MIN) ? 0.0f : f; 115 return (fabs(f) < FLT_MIN) ? 0.0f : f;
116 } 116 }
117 }; 117 };
118 118
119 #endif 119 #endif
120 120
121 } // WebCore 121 } // WebCore
122 122
123 #undef HAVE_DENORMAL 123 #undef HAVE_DENORMAL
124 #endif // DenormalDisabler_h 124 #endif // DenormalDisabler_h
OLDNEW
« no previous file with comments | « Source/core/platform/Pasteboard.cpp ('k') | Source/core/platform/chromium/ClipboardChromium.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698