3 #ifndef SCM_NULL_THREADS_H
4 #define SCM_NULL_THREADS_H
6 /* Copyright (C) 2002 Free Software Foundation, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 /* The null-threads implementation. We provide the standard API, but
26 no new threads can be created.
29 #error temporarily broken, compile with threads enabled (default option)
31 /* We can't switch so don't bother trying.
33 #undef SCM_THREAD_SWITCHING_CODE
34 #define SCM_THREAD_SWITCHING_CODE
36 #define scm_t_thread int
38 /* The "(void)(...)" constructs in the expansions are there to ensure
39 that the side effects of the argument expressions take place.
42 #define scm_thread_create(th,proc,data) ((void)(proc), (void)(data), ENOTSUP)
43 #define scm_thread_join(th) do { (void)(th); abort(); } while(0)
44 #define scm_thread_detach(th) do { (void)(th); abort(); } while(0)
45 #define scm_thread_self() 0
47 #define scm_t_mutex int
49 #define scm_mutex_init(mx) do { (void)(mx); } while(0)
50 #define scm_mutex_destroy(mx) do { (void)(mx); } while(0)
51 #define scm_mutex_lock(mx) do { (void)(mx); } while(0)
52 #define scm_mutex_trylock(mx) ((void)(mx), 1)
53 #define scm_mutex_unlock(mx) do { (void)(mx); } while(0)
55 #define scm_t_cond int
57 #define scm_cond_init(cv) do { (void)(cv); } while(0)
58 #define scm_cond_destroy(cv) do { (void)(cv); } while(0)
59 #define scm_cond_wait(cv,mx) ((void)(cv), (void)(mx), ENOTSUP)
60 #define scm_cond_timedwait(cv,mx,at) ((void)(cv), (void)(mx), (void)(at), \
62 #define scm_cond_signal(cv) do { (void)(cv); } while(0)
63 #define scm_cond_broadcast(cv) do { (void)(cv); } while(0)
65 #define scm_thread_select select
67 typedef void **scm_t_key
;
69 #define scm_key_create(keyp) do { *(keyp) = malloc(sizeof(void*)); \
71 #define scm_key_delete(key) do { free(key); } while(0)
72 #define scm_key_setspecific(key, value) do { *(key) = (value); } while(0)
73 #define scm_key_getspecific(key) *(key)
77 /* These are the actual prototypes of the functions/macros defined
78 above. We list them here for reference. */
80 typedef int scm_t_thread
;
82 SCM_API
int scm_thread_create (scm_t_thread
*th
,
83 void (*proc
) (void *), void *data
);
84 SCM_API
void scm_thread_join (scm_t_thread th
);
85 SCM_API
void scm_thread_detach (scm_t_thread th
);
86 SCM_API scm_t_thread
scm_thread_self (void);
88 typedef int scm_t_mutex
;
90 SCM_API
void scm_mutex_init (scm_t_mutex
*mx
);
91 SCM_API
void scm_mutex_destroy (scm_t_mutex
*mx
);
92 SCM_API
void scm_mutex_lock (scm_t_mutex
*mx
);
93 SCM_API
int scm_mutex_trylock (scm_t_mutex
*mx
);
94 SCM_API
void scm_mutex_unlock (scm_t_mutex
*mx
);
96 typedef int scm_t_cond
;
98 SCM_API
void scm_cond_init (scm_t_cond
*cv
);
99 SCM_API
void scm_cond_destroy (scm_t_cond
*cv
);
100 SCM_API
void scm_cond_wait (scm_t_cond
*cv
, scm_t_mutex
*mx
);
101 SCM_API
int scm_cond_timedwait (scm_t_cond
*cv
, scm_t_mutex
*mx
,
102 scm_t_timespec
*abstime
);
103 SCM_API
void scm_cond_signal (scm_t_cond
*cv
);
104 SCM_API
void scm_cond_broadcast (scm_t_cond
*cv
);
106 typedef int scm_t_key
;
108 SCM_API
void scm_key_create (scm_t_key
*keyp
);
109 SCM_API
void scm_key_delete (scm_t_key key
);
110 SCM_API
void scm_key_setspecific (scm_t_key key
, const void *value
);
111 SCM_API
void *scm_key_getspecific (scm_t_key key
);
113 SCM_API
int scm_thread_select (int nfds
,
114 SELECT_TYPE
*readfds
,
115 SELECT_TYPE
*writefds
,
116 SELECT_TYPE
*exceptfds
,
117 struct timeval
*timeout
);
121 #endif /* SCM_NULL_THREADS_H */