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_mutexattr_destroy PORTABLE C */
35 /* 6.1.7 */
36 /* AUTHOR */
37 /* */
38 /* William E. Lamie, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function shall destroy a mutex attributes object; the object */
43 /* becomes,in effect,uninitialized.A destroyed attr attributes object */
44 /* can be reinitialized using pthread_mutexattr_init(); */
45 /* */
46 /* */
47 /* INPUT */
48 /* */
49 /* attr Address of the mutex attributes */
50 /* object to be destroyed. */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* 0 If successful */
55 /* Value In case of any error or the results */
56 /* of referencing the object after it */
57 /* has been destroyed. */
58 /* */
59 /* CALLS */
60 /* */
61 /* None */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* Application Code */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
72 /* */
73 /**************************************************************************/
pthread_mutexattr_destroy(pthread_mutexattr_t * attr)74 INT pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
75 {
76
77 /* Clear the flag and make this pthread_mutexattr structure free */
78 /* First check the attribute object is already destroyed? */
79 if (attr->in_use == TX_FALSE)
80 {
81 posix_errno = EINVAL;
82 posix_set_pthread_errno(EINVAL);
83 return(EINVAL);
84 }
85 else
86 {
87 /* No then destroy the attributes object */
88 attr->in_use = TX_FALSE;
89 return(OK);
90 }
91 }
92