1 // Copyright 2023 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 #include "_cgo_export.h"
6
7 static void callDestructorCallback() {
8 GoDestructorCallback();
9 }
10
11 static void (*destructorFn)(void);
12
13 void registerDestructor() {
14 destructorFn = callDestructorCallback;
15 }
16
17 __attribute__((destructor))
18 static void destructor() {
19 if (destructorFn) {
20 destructorFn();
21 }
22 }
23
View as plain text