[AMDGPU][True16][CodeGen] true16 codegen pattern for v_med3_u/i16 (#121850)
[llvm-project.git] / libc / src / spawn / posix_spawn_file_actions_destroy.cpp
blob168118da249d1e05ded0ea5053df1a0b91d3013b
1 //===-- Implementation of posix_spawn_file_actions_destroy ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "posix_spawn_file_actions_destroy.h"
11 #include "file_actions.h"
13 #include "src/__support/CPP/new.h"
14 #include "src/__support/common.h"
15 #include "src/__support/macros/config.h"
16 #include "src/errno/libc_errno.h"
18 #include <spawn.h>
20 namespace LIBC_NAMESPACE_DECL {
22 LLVM_LIBC_FUNCTION(int, posix_spawn_file_actions_destroy,
23 (posix_spawn_file_actions_t * actions)) {
24 if (actions == nullptr)
25 return EINVAL;
26 if (actions->__front == nullptr)
27 return 0;
29 auto *act = reinterpret_cast<BaseSpawnFileAction *>(actions->__front);
30 actions->__front = nullptr;
31 actions->__back = nullptr;
32 if (act == nullptr)
33 return 0;
35 while (act != nullptr) {
36 auto *temp = act;
37 act = act->next;
38 switch (temp->type) {
39 case BaseSpawnFileAction::OPEN:
40 delete reinterpret_cast<SpawnFileOpenAction *>(temp);
41 break;
42 case BaseSpawnFileAction::CLOSE:
43 delete reinterpret_cast<SpawnFileCloseAction *>(temp);
44 break;
45 case BaseSpawnFileAction::DUP2:
46 delete reinterpret_cast<SpawnFileDup2Action *>(temp);
47 break;
51 return 0;
54 } // namespace LIBC_NAMESPACE_DECL