aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_obsolete.c
blob: 9c5a7c7ff9d96c093767eaa9aeda288f8221d758 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
 * %CopyrightBegin%
 * 
 * Copyright Ericsson AB 2004-2009. All Rights Reserved.
 * 
 * The contents of this file are subject to the Erlang Public License,
 * Version 1.1, (the "License"); you may not use this file except in
 * compliance with the License. You should have received a copy of the
 * Erlang Public License along with this software. If not, it can be
 * retrieved online at http://www.erlang.org/.
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 * 
 * %CopyrightEnd%
 */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include "sys.h"
#include "erl_driver.h"

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 *                                                                           *
 * ------------------------- OBSOLETE! DO NOT USE! ------------------------- *
 *                                                                           *
\*                                                                           */

/* cut from ../obsolete/driver.h (since it doesn't mix well with other
 * headers from the emulator).
 */
#ifdef __WIN32__
#ifdef CONST
#  undef CONST
#endif
#endif

#if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE)
#   define _USING_PROTOTYPES_ 1
#   define _ANSI_ARGS_(x)	x
#   define CONST const
#else
#   define _ANSI_ARGS_(x)	()
#   define CONST
#endif

typedef void* erl_mutex_t;
typedef void* erl_cond_t;
typedef void* erl_thread_t;

EXTERN erl_mutex_t erts_mutex_create _ANSI_ARGS_((void));
EXTERN int erts_mutex_destroy _ANSI_ARGS_((erl_mutex_t));
EXTERN int erts_mutex_lock _ANSI_ARGS_((erl_mutex_t));
EXTERN int erts_mutex_unlock _ANSI_ARGS_((erl_mutex_t));

EXTERN erl_cond_t erts_cond_create _ANSI_ARGS_((void));
EXTERN int erts_cond_destroy _ANSI_ARGS_((erl_cond_t));
EXTERN int erts_cond_signal _ANSI_ARGS_((erl_cond_t));
EXTERN int erts_cond_broadcast _ANSI_ARGS_((erl_cond_t));
EXTERN int erts_cond_wait _ANSI_ARGS_((erl_cond_t, erl_mutex_t));
EXTERN int erts_cond_timedwait _ANSI_ARGS_((erl_cond_t, erl_mutex_t, long));

EXTERN int erts_thread_create _ANSI_ARGS_((erl_thread_t*,
					 void* (*func)(void*),
					 void* arg,
					 int detached));
EXTERN erl_thread_t erts_thread_self _ANSI_ARGS_((void));
EXTERN void erts_thread_exit _ANSI_ARGS_((void*));
EXTERN int  erts_thread_join _ANSI_ARGS_((erl_thread_t, void**));
EXTERN int  erts_thread_kill _ANSI_ARGS_((erl_thread_t));

/*
 * These functions implement the thread interface in ../obsolete/driver.h.
 * Do *not* use this interface! Within the emulator, use the erl_threads.h,
 * erl_smp.h, or ethread.h interface. From a driver use the thread interface
 * in erl_driver.h.
 */

erl_mutex_t
erts_mutex_create(void)
{
    return (erl_mutex_t) erl_drv_mutex_create(NULL);
}

int
erts_mutex_destroy(erl_mutex_t mtx)
{
    erl_drv_mutex_destroy((ErlDrvMutex *) mtx);
    return 0;
}

int
erts_mutex_lock(erl_mutex_t mtx)
{
    erl_drv_mutex_lock((ErlDrvMutex *) mtx);
    return 0;
}

int
erts_mutex_unlock(erl_mutex_t mtx)
{
    erl_drv_mutex_unlock((ErlDrvMutex *) mtx);
    return 0;
}

erl_cond_t
erts_cond_create(void)
{
    return (erl_cond_t) erl_drv_cond_create(NULL);
}

int
erts_cond_destroy(erl_cond_t cnd)
{
    erl_drv_cond_destroy((ErlDrvCond *) cnd);
    return 0;
}


int
erts_cond_signal(erl_cond_t cnd)
{
    erl_drv_cond_signal((ErlDrvCond *) cnd);
    return 0;
}

int
erts_cond_broadcast(erl_cond_t cnd)
{
    erl_drv_cond_broadcast((ErlDrvCond *) cnd);
    return 0;
}


int
erts_cond_wait(erl_cond_t cnd, erl_mutex_t mtx)
{
    erl_drv_cond_wait((ErlDrvCond *) cnd, (ErlDrvMutex *) mtx);
    return 0;
}

int
erts_cond_timedwait(erl_cond_t cnd, erl_mutex_t mtx, long ms)
{
    return ENOTSUP;
}

int
erts_thread_create(erl_thread_t *tid,
		   void* (*func)(void*),
		   void* arg,
		   int detached)
{
    if (detached)
	return ENOTSUP;
    return erl_drv_thread_create(NULL, (ErlDrvTid *) tid, func, arg, NULL);
}

erl_thread_t
erts_thread_self(void)
{
    return (erl_thread_t) erl_drv_thread_self();
}

void
erts_thread_exit(void *res)
{
    erl_drv_thread_exit(res);
}

int
erts_thread_join(erl_thread_t tid, void **respp)
{
    return erl_drv_thread_join((ErlDrvTid) tid, respp);
}

int
erts_thread_kill(erl_thread_t tid)
{
    return ENOTSUP;
}