zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

libc-misc.h (2309B) - Raw


      1 /* Miscellaneous definitions for both glibc build and test.
      2    Copyright (C) 2024-2025 Free Software Foundation, Inc.
      3    This file is part of the GNU C Library.
      4 
      5    The GNU C Library is free software; you can redistribute it and/or
      6    modify it under the terms of the GNU Lesser General Public
      7    License as published by the Free Software Foundation; either
      8    version 2.1 of the License, or (at your option) any later version.
      9 
     10    The GNU C Library is distributed in the hope that it will be useful,
     11    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13    Lesser General Public License for more details.
     14 
     15    You should have received a copy of the GNU Lesser General Public
     16    License along with the GNU C Library; if not, see
     17    <https://www.gnu.org/licenses/>.  */
     18 
     19 #ifndef _INCLUDE_MISC_H
     20 #define _INCLUDE_MISC_H
     21 
     22 #include <config.h>
     23 
     24 /* Add the compiler optimization to inhibit loop transformation to library
     25    calls.  This is used to avoid recursive calls in memset and memmove
     26    default implementations in tests.  */
     27 #ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
     28 # define inhibit_loop_to_libcall \
     29     __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
     30 #else
     31 # define inhibit_loop_to_libcall
     32 #endif
     33 
     34 #ifdef HAVE_TEST_CC_INHIBIT_LOOP_TO_LIBCALL
     35 # define test_cc_inhibit_loop_to_libcall \
     36     __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
     37 #else
     38 # define test_cc_inhibit_loop_to_libcall
     39 #endif
     40 
     41 /* Used to disable stack protection in sensitive places, like ifunc
     42    resolvers and early static TLS init.  */
     43 #ifdef __clang__
     44 # define cc_inhibit_stack_protector \
     45     __attribute__((no_stack_protector))
     46 #else
     47 # define cc_inhibit_stack_protector \
     48    __attribute__ ((__optimize__ ("-fno-stack-protector")))
     49 #endif
     50 
     51 #if IS_IN (testsuite) || IS_IN (testsuite_internal)
     52 # ifdef HAVE_TEST_CC_NO_STACK_PROTECTOR
     53 #  define test_inhibit_stack_protector cc_inhibit_stack_protector
     54 #  define inhibit_stack_protector cc_inhibit_stack_protector
     55 # else
     56 #  define test_inhibit_stack_protector
     57 #  define inhibit_stack_protector
     58 # endif
     59 #else
     60 # ifdef HAVE_CC_NO_STACK_PROTECTOR
     61 #  define inhibit_stack_protector cc_inhibit_stack_protector
     62 # else
     63 #  define inhibit_stack_protector
     64 # endif
     65 #endif
     66 
     67 #endif