summaryrefslogtreecommitdiff
path: root/libc/src/pthread/pthread_atfork.cpp
blob: 7136bf35816cbff16f280932a9b78c087fe46fd7 (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
//===-- Linux implementation of the pthread_atfork function ---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "pthread_atfork.h"

#include "src/__support/common.h"
#include "src/__support/threads/fork_callbacks.h"

#include <errno.h>
#include <pthread.h> // For pthread_* type definitions.

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(int, pthread_atfork,
                   (__atfork_callback_t prepare, __atfork_callback_t parent,
                    __atfork_callback_t child)) {
  return register_atfork_callbacks(prepare, parent, child) ? 0 : ENOMEM;
}

} // namespace __llvm_libc