aboutsummaryrefslogtreecommitdiff
path: root/include/libc-misc.h
blob: e76a8097d8b5d6ca21002716dd351168fe936fe7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Miscellaneous definitions for both glibc build and test.
   Copyright (C) 2024-2025 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <https://www.gnu.org/licenses/>.  */

#ifndef _INCLUDE_MISC_H
#define _INCLUDE_MISC_H

#include <config.h>

/* Add the compiler optimization to inhibit loop transformation to library
   calls.  This is used to avoid recursive calls in memset and memmove
   default implementations in tests.  */
#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
# define inhibit_loop_to_libcall \
    __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
#else
# define inhibit_loop_to_libcall
#endif

#ifdef HAVE_TEST_CC_INHIBIT_LOOP_TO_LIBCALL
# define test_cc_inhibit_loop_to_libcall \
    __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
#else
# define test_cc_inhibit_loop_to_libcall
#endif

/* Used to disable stack protection in sensitive places, like ifunc
   resolvers and early static TLS init.  */
#ifdef __clang__
# define cc_inhibit_stack_protector \
    __attribute__((no_stack_protector))
#else
# define cc_inhibit_stack_protector \
   __attribute__ ((__optimize__ ("-fno-stack-protector")))
#endif

#if IS_IN (testsuite) || IS_IN (testsuite_internal)
# ifdef HAVE_TEST_CC_NO_STACK_PROTECTOR
#  define test_inhibit_stack_protector cc_inhibit_stack_protector
#  define inhibit_stack_protector cc_inhibit_stack_protector
# else
#  define test_inhibit_stack_protector
#  define inhibit_stack_protector
# endif
#else
# ifdef HAVE_CC_NO_STACK_PROTECTOR
#  define inhibit_stack_protector cc_inhibit_stack_protector
# else
#  define inhibit_stack_protector
# endif
#endif

#endif