mailing list of musl libc
 help / color / mirror / code / Atom feed
e617796393ec57cb8c7359dada2b4e6a9921cdee blob 6132 bytes (raw)

  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
187
188
189
190
191
192
193
194
195
196
197
198
 
#ifndef _THREADS_H
#define _THREADS_H

/* This one is explicitly allowed to be included. */
#include <time.h>


#ifdef __cplusplus
extern "C" {
#endif

#define __NEED_cnd_t
#define __NEED_mtx_t
/* Until we come up with a better naming scheme, we need to expose
   some pthread types. */
#define __NEED_pthread_cond_t
#define __NEED_pthread_mutex_t
#define __NEED_pthread_once_t
#define __NEED_pthread_t
#define __NEED_pthread_key_t

#include <bits/alltypes.h>
#include <bits/errno.h>

typedef struct __mtx_on_heap __mtx_t;
void __mtx_unref(__mtx_t *) __attribute__((nonnull(1)));
__mtx_t* __mtx_getref(mtx_t *) __attribute__((nonnull(1)));

int __mtx_lock(__mtx_t *) __attribute__((nonnull(1)));
int __mtx_trylock(__mtx_t *) __attribute__((nonnull(1)));
int __mtx_unlock(__mtx_t *) __attribute__((nonnull(1)));
int __mtx_timedlock(__mtx_t *restrict, const struct timespec *restrict) __attribute__((nonnull(1)));

typedef struct __cnd_on_heap __cnd_t;
void __cnd_unref(__cnd_t *) __attribute__((nonnull(1)));
__cnd_t* __cnd_getref(cnd_t *, __mtx_t *, int *) __attribute__((nonnull(1,3)));

int __cnd_wait(__cnd_t *restrict, __mtx_t *restrict) __attribute__((nonnull(1,2)));

typedef pthread_t thrd_t;
typedef pthread_key_t tss_t;
typedef int (*thrd_start_t)(void*);
typedef void (*tss_dtor_t)(void*);

typedef struct once_flag once_flag;

/* Just have a copy of the definition for the moment. This has to be
   replaced by sharing that declaration in alltypes.h */
struct __once_cb {
	void (*__f)(void *);
	void *__x;
	struct __ptcb *__next;
};

struct once_flag {
  int __cntrl;
  int __waiters;
  struct __once_cb __cb;
};

#ifndef __THRD_EXPERIMENTAL
# define __THRD_EXPERIMENTAL 1
#endif

  /* The following list of 9 integer constants makes up for the binary
     compatibility of this C thread implementation. You must never
     link code against versions of the C library that do not agree
     upon these ABI parameters.

     Additionally this implementation assumes that the 5 types have
     the same size across C libraries and that these types can be
     initialized by the default initializer.

     The values for the 9 parameters are not fixed for now. Depending
     on the choices of other implementations and the evolution of the
     C standard they may still change. This should happen rarely, but
     you have to consider the C thread feature to be experimental
     until then, and be prepared to recompile your binary when linking
     against a different implementation or a new version.

     The macro __THRD_EXPERIMENTAL will be defined as long as we
     consider this ABI to be unstable. This comes with some link time
     checks and an overhead of some bytes. At your own risk you may
     switch this check off by defining __THRD_EXPERIMENTAL macro to
     0. */

#define __THRD_SUCCESS      0
#define __THRD_BUSY         EBUSY
#define __THRD_ERROR        EINVAL
#define __THRD_NOMEM        ENOMEM
#define __THRD_TIMEDOUT     ETIMEDOUT
#define __MTX_PLAIN         0
#define __MTX_RECURSIVE     1
#define __MTX_TIMED         2
#define TSS_DTOR_ITERATIONS 4

#define __THRD_CONCAT10_(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9)         \
_0 ## _ ## _1 ## _ ## _2 ## _ ## _3 ## _ ## _4 ## _ ## _5 ## _ ## _6 ## _ ## _7 ## _ ## _8 ## _ ## _9

#define __THRD_CONCAT10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
  __THRD_CONCAT10_(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9)


#define __THRD_ABI                              \
__THRD_CONCAT10(__thrd_abi,                     \
                __THRD_SUCCESS,                 \
                __THRD_BUSY,                    \
                __THRD_ERROR,                   \
                __THRD_NOMEM,                   \
                __THRD_TIMEDOUT,                \
                __MTX_PLAIN,                    \
                __MTX_RECURSIVE,                \
                __MTX_TIMED,                    \
                TSS_DTOR_ITERATIONS             \
                )

#define __THRD_SHFT(X, Y) (((X) << 3) ^ (Y))

enum {
  __thrd_abi =
  __THRD_SHFT(sizeof(cnd_t),
              __THRD_SHFT(sizeof(mtx_t),
                          __THRD_SHFT(sizeof(once_flag),
                                      __THRD_SHFT(sizeof(thrd_t),
                                                  sizeof(tss_t))))),
};

extern unsigned const __THRD_ABI;

#define __THRD_ABI_CHECK (1/(__THRD_ABI == __thrd_abi))

#if __THRD_EXPERIMENTAL
# define __THRD_ABI_MARK __attribute__((used)) static unsigned const*const __thrd_abi_mark = &__THRD_ABI
#else
# define __THRD_ABI_MARK typedef unsigned __thrd_abi_dummy_type
#endif

enum {
  thrd_success = __THRD_SUCCESS,
  thrd_busy = __THRD_BUSY,
  thrd_error = __THRD_ERROR,
  thrd_nomem = __THRD_NOMEM,
  thrd_timedout = __THRD_TIMEDOUT,
};

enum {
  mtx_plain = __MTX_PLAIN,
  mtx_recursive = __MTX_RECURSIVE,
  // all mutexes are timed, here. so this is a no-op
  mtx_timed = __MTX_TIMED,
};

#define ONCE_FLAG_INIT { ._cntrl = 0, }
#define thread_local _Thread_local

int thrd_create(thrd_t *, thrd_start_t, void *);
_Noreturn void thrd_exit(int);

int thrd_detach(thrd_t);
int thrd_join(thrd_t, int *);

int thrd_sleep(const struct timespec *, struct timespec *);
void thrd_yield(void);

thrd_t thrd_current(void);
int thrd_equal(thrd_t, thrd_t);
#define thrd_equal(A, B) ((A) == (B))

void call_once(once_flag *, void (*)(void));

int mtx_init(mtx_t *, int);
void mtx_destroy(mtx_t *);

int mtx_lock(mtx_t *);
int mtx_timedlock(mtx_t *restrict, const struct timespec *restrict);
int mtx_trylock(mtx_t *);
int mtx_unlock(mtx_t *);

int cnd_init(cnd_t *);
void cnd_destroy(cnd_t *);

int cnd_broadcast(cnd_t *);
int cnd_signal(cnd_t *);

int cnd_timedwait(cnd_t *restrict, mtx_t *restrict, const struct timespec *restrict);
int cnd_wait(cnd_t *, mtx_t *);

int tss_create(tss_t *, tss_dtor_t);
void tss_delete(tss_t key);

int tss_set(tss_t, void *);
void *tss_get(tss_t);

#ifdef __cplusplus
}
#endif

#endif
debug log:

solving 9486b8c ...
found 9486b8c in https://inbox.vuxu.org/musl/1408049748.4951.134.camel@eris.loria.fr/

applying [1/1] https://inbox.vuxu.org/musl/1408049748.4951.134.camel@eris.loria.fr/
diff --git a/include/threads.h b/include/threads.h\r
new file mode 100644\r
index 0000000..9486b8c\r

1:7: trailing whitespace.
#ifndef _THREADS_H\r
1:8: trailing whitespace.
#define _THREADS_H\r
1:9: trailing whitespace.
\r
1:10: trailing whitespace.
/* This one is explicitly allowed to be included. */\r
1:11: trailing whitespace.
#include <time.h>\r
Checking patch include/threads.h...
Applied patch include/threads.h cleanly.
warning: squelched 193 whitespace errors
warning: 198 lines add whitespace errors.

index at:
100644 e617796393ec57cb8c7359dada2b4e6a9921cdee	include/threads.h

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).