]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgcc/config/gcn/crt0.c
1 /* Copyright (C) 2017-2022 Free Software Foundation, Inc.
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
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.
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.
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/>. */
22 typedef long long size_t;
24 /* Provide an entry point symbol to silence a linker warning. */
27 #ifdef USE_NEWLIB_INITFINI
29 extern void __libc_init_array (void) __attribute__((weak
));
30 extern void __libc_fini_array (void) __attribute__((weak
));
32 __attribute__((amdgpu_hsa_kernel ()))
38 __attribute__((amdgpu_hsa_kernel ()))
46 /* These magic symbols are provided by the linker. */
47 extern void (*__preinit_array_start
[]) (void) __attribute__((weak
));
48 extern void (*__preinit_array_end
[]) (void) __attribute__((weak
));
49 extern void (*__init_array_start
[]) (void) __attribute__((weak
));
50 extern void (*__init_array_end
[]) (void) __attribute__((weak
));
51 extern void (*__fini_array_start
[]) (void) __attribute__((weak
));
52 extern void (*__fini_array_end
[]) (void) __attribute__((weak
));
54 __attribute__((amdgpu_hsa_kernel ()))
57 /* Iterate over all the init routines. */
61 count
= __preinit_array_end
- __preinit_array_start
;
62 for (i
= 0; i
< count
; i
++)
63 __preinit_array_start
[i
] ();
65 count
= __init_array_end
- __init_array_start
;
66 for (i
= 0; i
< count
; i
++)
67 __init_array_start
[i
] ();
70 __attribute__((amdgpu_hsa_kernel ()))
76 count
= __fini_array_end
- __fini_array_start
;
77 for (i
= count
; i
> 0; i
--)
78 __fini_array_start
[i
-1] ();