z_Windows_NT-586_util.c

Go to the documentation of this file.
00001 /*
00002  * z_Windows_NT-586_util.c -- platform specific routines.
00003  * $Revision: 42181 $
00004  * $Date: 2013-03-26 15:04:45 -0500 (Tue, 26 Mar 2013) $
00005  */
00006 
00007 /* <copyright>
00008     Copyright (c) 1997-2013 Intel Corporation.  All Rights Reserved.
00009 
00010     Redistribution and use in source and binary forms, with or without
00011     modification, are permitted provided that the following conditions
00012     are met:
00013 
00014       * Redistributions of source code must retain the above copyright
00015         notice, this list of conditions and the following disclaimer.
00016       * Redistributions in binary form must reproduce the above copyright
00017         notice, this list of conditions and the following disclaimer in the
00018         documentation and/or other materials provided with the distribution.
00019       * Neither the name of Intel Corporation nor the names of its
00020         contributors may be used to endorse or promote products derived
00021         from this software without specific prior written permission.
00022 
00023     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00027     HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00028     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 
00035 
00036 ------------------------------------------------------------------------
00037 
00038     Portions of this software are protected under the following patents:
00039         U.S. Patent 5,812,852
00040         U.S. Patent 6,792,599
00041         U.S. Patent 7,069,556
00042         U.S. Patent 7,328,433
00043         U.S. Patent 7,500,242
00044 
00045 </copyright> */
00046 
00047 #include "kmp.h"
00048 
00049 #if (KMP_ARCH_X86 || KMP_ARCH_X86_64)
00050 /* Only 32-bit "add-exchange" instruction on IA-32 architecture causes us to
00051  * use compare_and_store for these routines
00052  */
00053 
00054 kmp_int32
00055 __kmp_test_then_or32( volatile kmp_int32 *p, kmp_int32 d )
00056 {
00057     kmp_int32 old_value, new_value;
00058 
00059     old_value = TCR_4( *p );
00060     new_value = old_value | d;
00061 
00062     while ( ! __kmp_compare_and_store32 ( p, old_value, new_value ) )
00063     {
00064         KMP_CPU_PAUSE();
00065         old_value = TCR_4( *p );
00066         new_value = old_value | d;
00067     }
00068 
00069     return old_value;
00070 }
00071 
00072 kmp_int32
00073 __kmp_test_then_and32( volatile kmp_int32 *p, kmp_int32 d )
00074 {
00075     kmp_int32 old_value, new_value;
00076 
00077     old_value = TCR_4( *p );
00078     new_value = old_value & d;
00079 
00080     while ( ! __kmp_compare_and_store32 ( p, old_value, new_value ) )
00081     {
00082         KMP_CPU_PAUSE();
00083         old_value = TCR_4( *p );
00084         new_value = old_value & d;
00085     }
00086     return old_value;
00087 }
00088 
00089 #if KMP_ARCH_X86
00090 kmp_int64
00091 __kmp_test_then_add64( volatile kmp_int64 *p, kmp_int64 d )
00092 {
00093     kmp_int64 old_value, new_value;
00094 
00095     old_value = TCR_8( *p );
00096     new_value = old_value + d;
00097     while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
00098     {
00099         KMP_CPU_PAUSE();
00100         old_value = TCR_8( *p );
00101         new_value = old_value + d;
00102     }
00103 
00104     return old_value;
00105 }
00106 #endif /* KMP_ARCH_X86 */
00107 
00108 kmp_int64
00109 __kmp_test_then_or64( volatile kmp_int64 *p, kmp_int64 d )
00110 {
00111     kmp_int64 old_value, new_value;
00112 
00113     old_value = TCR_8( *p );
00114     new_value = old_value | d;
00115     while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
00116     {
00117         KMP_CPU_PAUSE();
00118         old_value = TCR_8( *p );
00119         new_value = old_value | d;
00120     }
00121 
00122     return old_value;
00123 }
00124 
00125 kmp_int64
00126 __kmp_test_then_and64( volatile kmp_int64 *p, kmp_int64 d )
00127 {
00128     kmp_int64 old_value, new_value;
00129 
00130     old_value = TCR_8( *p );
00131     new_value = old_value & d;
00132     while ( ! __kmp_compare_and_store64 ( p, old_value, new_value ) )
00133     {
00134         KMP_CPU_PAUSE();
00135         old_value = TCR_8( *p );
00136         new_value = old_value & d;
00137     }
00138 
00139     return old_value;
00140 }
00141 
00142 #endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */
00143 
00144 /* ------------------------------------------------------------------------ */
00145 /* ------------------------------------------------------------------------ */
00146 

Generated on 25 Aug 2013 for libomp_oss by  doxygen 1.6.1