1 #ifndef __ALT_SEM_H__
2 #define __ALT_SEM_H__
3 
4 /******************************************************************************
5 *                                                                             *
6 * License Agreement                                                           *
7 *                                                                             *
8 * Copyright (c) 2004 Altera Corporation, San Jose, California, USA.           *
9 * All rights reserved.                                                        *
10 *                                                                             *
11 * Permission is hereby granted, free of charge, to any person obtaining a     *
12 * copy of this software and associated documentation files (the "Software"),  *
13 * to deal in the Software without restriction, including without limitation   *
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
15 * and/or sell copies of the Software, and to permit persons to whom the       *
16 * Software is furnished to do so, subject to the following conditions:        *
17 *                                                                             *
18 * The above copyright notice and this permission notice shall be included in  *
19 * all copies or substantial portions of the Software.                         *
20 *                                                                             *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
27 * DEALINGS IN THE SOFTWARE.                                                   *
28 *                                                                             *
29 *                                                                             *
30 * Altera does not recommend, suggest or require that this reference design    *
31 * file be used in conjunction or combination with any other product.          *
32 ******************************************************************************/
33 
34 /******************************************************************************
35 *                                                                             *
36 * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT.                       *
37 *                                                                             *
38 ******************************************************************************/
39 
40 /*
41  * This header provides macro definitions that can be used to create and use
42  * semaphores. These macros can be used in both a uC/OS-II based environment,
43  * and a single threaded HAL based environment.
44  *
45  * The motivation for these macros is to allow code to be developed which is
46  * thread safe under uC/OS-II, but incurs no additional overhead when used in a
47  * single threaded HAL environment.
48  *
49  * In the case of a single threaded HAL environment, they compile to
50  * "do nothing" directives, which ensures they do not contribute to the final
51  * executable.
52  *
53  * The following macros are available:
54  *
55  * ALT_SEM        - Create a semaphore instance.
56  * ALT_EXTERN_SEM - Create a reference to an external semaphore instance.
57  * ALT_STATIC_SEM - Create a static semaphore instance.
58  * ALT_SEM_CREATE - Initialise a semaphore.
59  * ALT_SEM_PEND   - Pend on a semaphore.
60  * ALT_SEM_POST   - Increment a semaphore.
61  *
62  * Input arguments and return codes are all consistant with the equivalent
63  * uC/OS-II function.
64  *
65  * It's important to be careful in the use of the macros: ALT_SEM,
66  * ALT_EXTERN_SEM, and ALT_STATIC_SEM. In these three cases the semi-colon is
67  * included in the macro definition; so, for example, you should use:
68  *
69  * ALT_SEM(mysem)
70  *
71  * not:
72  *
73  * ALT_SEM(mysem);
74  *
75  * The inclusion of the semi-colon has been necessary to ensure the macros can
76  * compile with no warnings when used in a single threaded HAL environment.
77  *
78  */
79 
80 #include "priv/alt_no_error.h"
81 
82 #define ALT_SEM(sem)
83 #define ALT_EXTERN_SEM(sem)
84 #define ALT_STATIC_SEM(sem)
85 
86 #define ALT_SEM_CREATE(sem, value) alt_no_error ()
87 #define ALT_SEM_PEND(sem, timeout) alt_no_error ()
88 #define ALT_SEM_POST(sem) alt_no_error ()
89 
90 #ifndef ALT_SINGLE_THREADED
91 #define ALT_SINGLE_THREADED
92 #endif
93 
94 #endif /* __ALT_SEM_H__ */
95