1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** POSIX wrapper for THREADX */
17 /** */
18 /** */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 /* Include necessary system files. */
24
25 #include "tx_api.h" /* Threadx API */
26 #include "pthread.h" /* Posix API */
27 #include "px_int.h" /* Posix helper functions */
28
29
30 /**************************************************************************/
31 /* */
32 /* FUNCTION RELEASE */
33 /* */
34 /* pthread_attr_destroy PORTABLE C */
35 /* 6.1.7 */
36 /* AUTHOR */
37 /* */
38 /* William E. Lamie, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function destroys a pthread attributes object and allows the */
43 /* system to reclaim any resources associated with that pthread */
44 /* attributes object.This doesn't have an effect on any threads created*/
45 /* using this pthread attributes object. */
46 /* */
47 /* */
48 /* INPUT */
49 /* */
50 /* attr Address of the pthread attributes */
51 /* object to be destroyed. */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* 0 If successful */
56 /* Value In case of any error or the results */
57 /* of referencing the object after it */
58 /* has been destroyed. */
59 /* */
60 /* CALLS */
61 /* */
62 /* None */
63 /* */
64 /* CALLED BY */
65 /* */
66 /* Application Code */
67 /* */
68 /* RELEASE HISTORY */
69 /* */
70 /* DATE NAME DESCRIPTION */
71 /* */
72 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
73 /* */
74 /**************************************************************************/
pthread_attr_destroy(pthread_attr_t * attr)75 INT pthread_attr_destroy(pthread_attr_t *attr)
76 {
77
78 /* Clear the flag and make this pthread_attr structure free */
79 /* First check the attribute object is already destroyed? */
80 if (attr->inuse == TX_FALSE)
81 return(EINVAL);
82 else
83 {
84 /* No then destroy the attributes object */
85 attr->inuse = TX_FALSE;
86 return(OK);
87 }
88 }
89