]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/config/gcn/crt0.c
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / gcn / crt0.c
CommitLineData
8d9254fc 1/* Copyright (C) 2017-2020 Free Software Foundation, Inc.
91d7b7fe
AS
2
3 This file is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 3, or (at your option) any
6 later version.
7
8 This file is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
12
13 Under Section 7 of GPL version 3, you are granted additional
14 permissions described in the GCC Runtime Library Exception, version
15 3.1, as published by the Free Software Foundation.
16
17 You should have received a copy of the GNU General Public License and
18 a copy of the GCC Runtime Library Exception along with this program;
19 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
20 <http://www.gnu.org/licenses/>. */
21
7039cebf
KCY
22typedef long long size_t;
23
91d7b7fe
AS
24/* Provide an entry point symbol to silence a linker warning. */
25void _start() {}
7039cebf
KCY
26
27#ifdef USE_NEWLIB_INITFINI
28
29extern void __libc_init_array (void) __attribute__((weak));
30extern void __libc_fini_array (void) __attribute__((weak));
31
32__attribute__((amdgpu_hsa_kernel ()))
33void _init_array()
34{
35 __libc_init_array ();
36}
37
38__attribute__((amdgpu_hsa_kernel ()))
39void _fini_array()
40{
41 __libc_fini_array ();
42}
43
44#endif
45
46/* These magic symbols are provided by the linker. */
47extern void (*__preinit_array_start []) (void) __attribute__((weak));
48extern void (*__preinit_array_end []) (void) __attribute__((weak));
49extern void (*__init_array_start []) (void) __attribute__((weak));
50extern void (*__init_array_end []) (void) __attribute__((weak));
51extern void (*__fini_array_start []) (void) __attribute__((weak));
52extern void (*__fini_array_end []) (void) __attribute__((weak));
53
54__attribute__((amdgpu_hsa_kernel ()))
55void _init_array()
56{
57 /* Iterate over all the init routines. */
58 size_t count;
59 size_t i;
60
61 count = __preinit_array_end - __preinit_array_start;
62 for (i = 0; i < count; i++)
63 __preinit_array_start[i] ();
64
65 count = __init_array_end - __init_array_start;
66 for (i = 0; i < count; i++)
67 __init_array_start[i] ();
68}
69
70__attribute__((amdgpu_hsa_kernel ()))
71void _fini_array()
72{
73 size_t count;
74 size_t i;
75
76 count = __fini_array_end - __fini_array_start;
77 for (i = count; i > 0; i--)
78 __fini_array_start[i-1] ();
79}