git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
blob f466215742f2452579e3110b798dbbef9c3f3585 2286 bytes (raw)
name: thread-utils.h 	 # note: path name is non-authoritative(*)

 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
 
#ifndef THREAD_COMPAT_H
#define THREAD_COMPAT_H

#ifndef NO_PTHREADS
#include <pthread.h>

#define HAVE_THREADS 1

#else

#define HAVE_THREADS 0

/*
 * macros instead of typedefs because pthread definitions may have
 * been pulled in by some system dependencies even though the user
 * wants to disable pthread.
 */
#define pthread_t int
#define pthread_mutex_t int
#define pthread_cond_t int
#define pthread_key_t git_pthread_key_t

#define pthread_mutex_init(mutex, attr) dummy_pthread_init(mutex)
#define pthread_mutex_lock(mutex)
#define pthread_mutex_unlock(mutex)
#define pthread_mutex_destroy(mutex)

#define pthread_cond_init(cond, attr) dummy_pthread_init(cond)
#define pthread_cond_wait(cond, mutex)
#define pthread_cond_signal(cond)
#define pthread_cond_broadcast(cond)
#define pthread_cond_destroy(cond)

#define pthread_key_create(key, destroy) git_pthread_key_create(key, destroy)
#define pthread_key_delete(key) git_pthread_key_delete(key)

#define pthread_create(thread, attr, fn, data) \
	dummy_pthread_create(thread, attr, fn, data)
#define pthread_join(thread, retval) \
	dummy_pthread_join(thread, retval)

#define pthread_setspecific(key, data) git_pthread_setspecific(key, data)
#define pthread_getspecific(key) git_pthread_getspecific(key)

typedef struct {
	void *data;
	/* extra indirection because setspecific is passed key by value */
	void **vdata;
} git_pthread_key_t;

static inline int git_pthread_key_create(git_pthread_key_t *key,
					 void (*destroy)(void *))
{
	key->data = NULL;
	key->vdata = &key->data;
	/* We don't use this; alternatively we could all via atexit(). */
	if (destroy)
		BUG("NO_PTHREADS does not support pthread key destructors");
	return 0;
}

static inline int git_pthread_key_delete(git_pthread_key_t key)
{
	/* noop */
	return 0;
}

static inline void git_pthread_setspecific(git_pthread_key_t key, void *data)
{
	*(key.vdata) = data;
}

static inline void *git_pthread_getspecific(git_pthread_key_t key)
{
	return key.data;
}

int dummy_pthread_create(pthread_t *pthread, const void *attr,
			 void *(*fn)(void *), void *data);
int dummy_pthread_join(pthread_t pthread, void **retval);

int dummy_pthread_init(void *);

#endif

int online_cpus(void);
int init_recursive_mutex(pthread_mutex_t*);


#endif /* THREAD_COMPAT_H */

debug log:

solving f466215742 ...
found f466215742 in https://public-inbox.org/git/20190523055108.GA20871@sigill.intra.peff.net/
found 4961487ed9 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100644 4961487ed914f4fea817df26904109bb05f2a2c5	thread-utils.h

applying [1/1] https://public-inbox.org/git/20190523055108.GA20871@sigill.intra.peff.net/
diff --git a/thread-utils.h b/thread-utils.h
index 4961487ed9..f466215742 100644

Checking patch thread-utils.h...
Applied patch thread-utils.h cleanly.

index at:
100644 f466215742f2452579e3110b798dbbef9c3f3585	thread-utils.h

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).