From: Ivan Maidanski Date: Mon, 7 Jan 2013 14:26:01 +0000 (+0400) Subject: Generate ordered_loads/stores_only headers from templates X-Git-Tag: libatomic_ops-7_4_0~48^2~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=744b11d87f8b6c477b41787775f1fa568951061c;p=libatomic_ops Generate ordered_loads/stores_only headers from templates (code refactoring) * src/Makefile.am (EXTRA_DIST): Add ordered_loads_only.template, ordered_stores_only.template entries. * src/Makefile.am (BUILT_SOURCES): Add ordered_loads_only.h, ordered_stores_only.h entries (move from nobase_private_HEADERS). * src/Makefile.am (atomic_ops/sysdeps/loadstore/ordered_loads_only.h, atomic_ops/sysdeps/loadstore/ordered_stores_only.h): New rule (to generate header from the corresponding template). * src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h: Regenerate (from the corresponding template). * src/atomic_ops/sysdeps/loadstore/ordered_stores_only.h: Likewise. * src/atomic_ops/sysdeps/loadstore/ordered_loads_only.template: New template header (code copied from the corresponding header of "loadstore" folder and parameterized with XSIZE and XCTYPE). * src/atomic_ops/sysdeps/loadstore/ordered_stores_only.template: Likewise. --- diff --git a/src/Makefile.am b/src/Makefile.am index a733c65..eaa580c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,8 @@ EXTRA_DIST = Makefile.msft atomic_ops/sysdeps/README \ atomic_ops/generalize-small.template \ atomic_ops/sysdeps/loadstore/acquire_release_volatile.template \ atomic_ops/sysdeps/loadstore/atomic_load_store.template \ + atomic_ops/sysdeps/loadstore/ordered_loads_only.template \ + atomic_ops/sysdeps/loadstore/ordered_stores_only.template \ atomic_ops/sysdeps/sunc/sparc.S BUILT_SOURCES = atomic_ops/generalize-arithm.h \ @@ -28,6 +30,8 @@ BUILT_SOURCES = atomic_ops/generalize-arithm.h \ atomic_ops/sysdeps/loadstore/char_atomic_load_store.h \ atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h \ atomic_ops/sysdeps/loadstore/int_atomic_load_store.h \ + atomic_ops/sysdeps/loadstore/ordered_loads_only.h \ + atomic_ops/sysdeps/loadstore/ordered_stores_only.h \ atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h \ atomic_ops/sysdeps/loadstore/short_atomic_load_store.h @@ -75,8 +79,6 @@ nobase_private_HEADERS = atomic_ops/ao_version.h \ atomic_ops/sysdeps/icc/ia64.h \ \ atomic_ops/sysdeps/loadstore/double_atomic_load_store.h \ - atomic_ops/sysdeps/loadstore/ordered_loads_only.h \ - atomic_ops/sysdeps/loadstore/ordered_stores_only.h \ \ atomic_ops/sysdeps/msftc/arm.h \ atomic_ops/sysdeps/msftc/common32_defs.h \ @@ -99,6 +101,20 @@ atomic_ops/generalize-arithm.h: atomic_ops/generalize-arithm.template sed -e s:XSIZE:int:g -e s:XCTYPE:unsigned:g $? >> $@ sed -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? >> $@ +atomic_ops/sysdeps/loadstore/ordered_loads_only.h: \ + atomic_ops/sysdeps/loadstore/ordered_loads_only.template + sed -e s:XSIZE:char:g -e s:XCTYPE:unsigned/**/char:g $? > $@ + sed -e s:XSIZE:short:g -e s:XCTYPE:unsigned/**/short:g $? >> $@ + sed -e s:XSIZE:int:g -e s:XCTYPE:unsigned:g $? >> $@ + sed -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? >> $@ + +atomic_ops/sysdeps/loadstore/ordered_stores_only.h: \ + atomic_ops/sysdeps/loadstore/ordered_stores_only.template + sed -e s:XSIZE:char:g -e s:XCTYPE:unsigned/**/char:g $? > $@ + sed -e s:XSIZE:short:g -e s:XCTYPE:unsigned/**/short:g $? >> $@ + sed -e s:XSIZE:int:g -e s:XCTYPE:unsigned:g $? >> $@ + sed -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? >> $@ + atomic_ops/sysdeps/loadstore/acquire_release_volatile.h: \ atomic_ops/sysdeps/loadstore/acquire_release_volatile.template sed -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? > $@ diff --git a/src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h b/src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h index 48d1132..ae8baa9 100644 --- a/src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h +++ b/src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h @@ -21,10 +21,10 @@ */ #ifdef AO_HAVE_char_load - AO_INLINE unsigned char - AO_char_load_read(const volatile unsigned char *addr) + AO_INLINE unsigned/**/char + AO_char_load_read(const volatile unsigned/**/char *addr) { - unsigned char result = AO_char_load(addr); + unsigned/**/char result = AO_char_load(addr); AO_compiler_barrier(); return result; @@ -34,12 +34,33 @@ # define AO_char_load_acquire(addr) AO_char_load_read(addr) # define AO_HAVE_char_load_acquire #endif /* AO_HAVE_char_load */ +/* + * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #ifdef AO_HAVE_short_load - AO_INLINE unsigned short - AO_short_load_read(const volatile unsigned short *addr) + AO_INLINE unsigned/**/short + AO_short_load_read(const volatile unsigned/**/short *addr) { - unsigned short result = AO_short_load(addr); + unsigned/**/short result = AO_short_load(addr); AO_compiler_barrier(); return result; @@ -49,12 +70,33 @@ # define AO_short_load_acquire(addr) AO_short_load_read(addr) # define AO_HAVE_short_load_acquire #endif /* AO_HAVE_short_load */ +/* + * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #ifdef AO_HAVE_int_load - AO_INLINE unsigned int - AO_int_load_read(const volatile unsigned int *addr) + AO_INLINE unsigned + AO_int_load_read(const volatile unsigned *addr) { - unsigned int result = AO_int_load(addr); + unsigned result = AO_int_load(addr); AO_compiler_barrier(); return result; @@ -64,6 +106,27 @@ # define AO_int_load_acquire(addr) AO_int_load_read(addr) # define AO_HAVE_int_load_acquire #endif /* AO_HAVE_int_load */ +/* + * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #ifdef AO_HAVE_load AO_INLINE AO_t diff --git a/src/atomic_ops/sysdeps/loadstore/ordered_loads_only.template b/src/atomic_ops/sysdeps/loadstore/ordered_loads_only.template new file mode 100644 index 0000000..bc828ce --- /dev/null +++ b/src/atomic_ops/sysdeps/loadstore/ordered_loads_only.template @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifdef AO_HAVE_XSIZE_load + AO_INLINE XCTYPE + AO_XSIZE_load_read(const volatile XCTYPE *addr) + { + XCTYPE result = AO_XSIZE_load(addr); + + AO_compiler_barrier(); + return result; + } +# define AO_HAVE_XSIZE_load_read + +# define AO_XSIZE_load_acquire(addr) AO_XSIZE_load_read(addr) +# define AO_HAVE_XSIZE_load_acquire +#endif /* AO_HAVE_XSIZE_load */ diff --git a/src/atomic_ops/sysdeps/loadstore/ordered_stores_only.h b/src/atomic_ops/sysdeps/loadstore/ordered_stores_only.h index 3ec6055..1fe145b 100644 --- a/src/atomic_ops/sysdeps/loadstore/ordered_stores_only.h +++ b/src/atomic_ops/sysdeps/loadstore/ordered_stores_only.h @@ -22,7 +22,7 @@ #if defined(AO_HAVE_char_store) AO_INLINE void - AO_char_store_write(volatile unsigned char *addr, unsigned char val) + AO_char_store_write(volatile unsigned/**/char *addr, unsigned/**/char val) { AO_compiler_barrier(); AO_char_store(addr, val); @@ -32,10 +32,31 @@ # define AO_char_store_release(addr, val) AO_char_store_write(addr, val) # define AO_HAVE_char_store_release #endif /* AO_HAVE_char_store */ +/* + * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #if defined(AO_HAVE_short_store) AO_INLINE void - AO_short_store_write(volatile unsigned short *addr, unsigned short val) + AO_short_store_write(volatile unsigned/**/short *addr, unsigned/**/short val) { AO_compiler_barrier(); AO_short_store(addr, val); @@ -45,10 +66,31 @@ # define AO_short_store_release(addr, val) AO_short_store_write(addr, val) # define AO_HAVE_short_store_release #endif /* AO_HAVE_short_store */ +/* + * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #if defined(AO_HAVE_int_store) AO_INLINE void - AO_int_store_write(volatile unsigned int *addr, unsigned int val) + AO_int_store_write(volatile unsigned *addr, unsigned val) { AO_compiler_barrier(); AO_int_store(addr, val); @@ -58,6 +100,27 @@ # define AO_int_store_release(addr, val) AO_int_store_write(addr, val) # define AO_HAVE_int_store_release #endif /* AO_HAVE_int_store */ +/* + * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #if defined(AO_HAVE_store) AO_INLINE void diff --git a/src/atomic_ops/sysdeps/loadstore/ordered_stores_only.template b/src/atomic_ops/sysdeps/loadstore/ordered_stores_only.template new file mode 100644 index 0000000..0fa173c --- /dev/null +++ b/src/atomic_ops/sysdeps/loadstore/ordered_stores_only.template @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#if defined(AO_HAVE_XSIZE_store) + AO_INLINE void + AO_XSIZE_store_write(volatile XCTYPE *addr, XCTYPE val) + { + AO_compiler_barrier(); + AO_XSIZE_store(addr, val); + } +# define AO_HAVE_XSIZE_store_write + +# define AO_XSIZE_store_release(addr, val) AO_XSIZE_store_write(addr, val) +# define AO_HAVE_XSIZE_store_release +#endif /* AO_HAVE_XSIZE_store */