source: trunk/libs/newlib/src/newlib/libc/include/threads.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.0 KB
Line 
1/*-
2 * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef _THREADS_H_
28#define _THREADS_H_
29
30#include <machine/_threads.h>
31#include <time.h>
32
33typedef void (*tss_dtor_t)(void *);
34typedef int (*thrd_start_t)(void *);
35
36enum {
37        mtx_plain = 0x1,
38        mtx_recursive = 0x2,
39        mtx_timed = 0x4
40};
41
42enum {
43        thrd_busy = 1,
44        thrd_error = 2,
45        thrd_nomem = 3,
46        thrd_success = 4,
47        thrd_timedout = 5
48};
49
50#if !defined(__cplusplus) || __cplusplus < 201103L
51#define thread_local            _Thread_local
52#endif
53
54__BEGIN_DECLS
55void    call_once(once_flag *, void (*)(void));
56int     cnd_broadcast(cnd_t *);
57void    cnd_destroy(cnd_t *);
58int     cnd_init(cnd_t *);
59int     cnd_signal(cnd_t *);
60int     cnd_timedwait(cnd_t *__restrict, mtx_t *__restrict __mtx,
61    const struct timespec *__restrict)
62    __requires_exclusive(*__mtx);
63int     cnd_wait(cnd_t *, mtx_t *__mtx)
64    __requires_exclusive(*__mtx);
65void    mtx_destroy(mtx_t *__mtx)
66    __requires_unlocked(*__mtx);
67int     mtx_init(mtx_t *__mtx, int)
68    __requires_unlocked(*__mtx);
69int     mtx_lock(mtx_t *__mtx)
70    __locks_exclusive(*__mtx);
71int     mtx_timedlock(mtx_t *__restrict __mtx,
72    const struct timespec *__restrict)
73    __trylocks_exclusive(thrd_success, *__mtx);
74int     mtx_trylock(mtx_t *__mtx)
75    __trylocks_exclusive(thrd_success, *__mtx);
76int     mtx_unlock(mtx_t *__mtx)
77    __unlocks(*__mtx);
78int     thrd_create(thrd_t *, thrd_start_t, void *);
79thrd_t  thrd_current(void);
80int     thrd_detach(thrd_t);
81int     thrd_equal(thrd_t, thrd_t);
82_Noreturn void
83        thrd_exit(int);
84int     thrd_join(thrd_t, int *);
85int     thrd_sleep(const struct timespec *, struct timespec *);
86void    thrd_yield(void);
87int     tss_create(tss_t *, tss_dtor_t);
88void    tss_delete(tss_t);
89void *  tss_get(tss_t);
90int     tss_set(tss_t, void *);
91__END_DECLS
92
93#endif /* !_THREADS_H_ */
Note: See TracBrowser for help on using the repository browser.