Imported Upstream version 0.1.0+git20131207+e452e83
[deb_libhybris.git] / hybris / common / gingerbread / patches / gingerbread-bionic.patch
1 diff --git a/libc/bionic/__errno.c b/libc/bionic/__errno.c
2 index 8f33cce..34664c6 100644
3 --- a/libc/bionic/__errno.c
4 +++ b/libc/bionic/__errno.c
5 @@ -28,7 +28,4 @@
6 #include <errno.h>
7 #include <bionic_tls.h>
8
9 -volatile int* __errno( void )
10 -{
11 - return &((volatile int*)__get_tls())[TLS_SLOT_ERRNO];
12 -}
13 +
14 diff --git a/libc/bionic/__set_errno.c b/libc/bionic/__set_errno.c
15 index c72d4f7..529a4ef 100644
16 --- a/libc/bionic/__set_errno.c
17 +++ b/libc/bionic/__set_errno.c
18 @@ -28,13 +28,6 @@
19
20 #include <errno.h>
21
22 -
23 -int __set_errno(int n)
24 -{
25 - errno = n;
26 - return -1;
27 -}
28 -
29 /*
30 * this function is called from syscall stubs,
31 * (tail-called in the case of 0-4 arg versions)
32 diff --git a/libc/bionic/pthread-rwlocks.c b/libc/bionic/pthread-rwlocks.c
33 index ca3e95c..1494523 100644
34 --- a/libc/bionic/pthread-rwlocks.c
35 +++ b/libc/bionic/pthread-rwlocks.c
36 @@ -69,6 +69,8 @@ static int __get_thread_id(void)
37
38 int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
39 {
40 +
41 + abort();
42 if (!attr)
43 return EINVAL;
44
45 @@ -77,8 +79,9 @@ int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
46 }
47
48 int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
49 -{
50 - if (!attr)
51 +{
52 + abort();
53 + if (!attr)
54 return EINVAL;
55
56 *attr = -1;
57 @@ -87,6 +90,7 @@ int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
58
59 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared)
60 {
61 + abort();
62 if (!attr)
63 return EINVAL;
64
65 @@ -102,6 +106,8 @@ int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared)
66
67 int pthread_rwlockattr_getpshared(pthread_rwlockattr_t *attr, int *pshared)
68 {
69 + abort();
70 +
71 if (!attr || !pshared)
72 return EINVAL;
73
74 @@ -111,6 +117,7 @@ int pthread_rwlockattr_getpshared(pthread_rwlockattr_t *attr, int *pshared)
75
76 int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
77 {
78 + abort();
79 pthread_mutexattr_t* lock_attr = NULL;
80 pthread_condattr_t* cond_attr = NULL;
81 pthread_mutexattr_t lock_attr0;
82 @@ -150,6 +157,10 @@ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *at
83
84 int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
85 {
86 + abort();
87 +
88 +
89 +
90 int ret;
91
92 if (rwlock == NULL)
93 @@ -209,11 +220,14 @@ static void _pthread_rwlock_pulse(pthread_rwlock_t *rwlock)
94
95 int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
96 {
97 + abort();
98 return pthread_rwlock_timedrdlock(rwlock, NULL);
99 }
100
101 int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
102 {
103 + abort();
104 +
105 int ret = 0;
106
107 if (rwlock == NULL)
108 @@ -231,6 +245,7 @@ int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
109
110 int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout)
111 {
112 + abort();
113 int thread_id, ret = 0;
114
115 if (rwlock == NULL)
116 @@ -256,11 +271,14 @@ EXIT:
117
118 int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
119 {
120 + abort();
121 +
122 return pthread_rwlock_timedwrlock(rwlock, NULL);
123 }
124
125 int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
126 {
127 + abort();
128 int thread_id, ret = 0;
129
130 if (rwlock == NULL)
131 @@ -280,6 +298,7 @@ int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
132
133 int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout)
134 {
135 + abort();
136 int thread_id, ret = 0;
137
138 if (rwlock == NULL)
139 @@ -310,6 +329,8 @@ EXIT:
140
141 int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
142 {
143 + abort();
144 +
145 int ret = 0;
146
147 if (rwlock == NULL)
148 diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
149 index 6b01830..490c39f 100644
150 --- a/libc/bionic/pthread.c
151 +++ b/libc/bionic/pthread.c
152 @@ -177,7 +177,8 @@ __get_stack_base(int *p_stack_size)
153
154 void __init_tls(void** tls, void* thread)
155 {
156 - int nn;
157 + *((int *) 0) = -1;
158 +/* int nn;
159
160 ((pthread_internal_t*)thread)->tls = tls;
161
162 @@ -188,7 +189,7 @@ void __init_tls(void** tls, void* thread)
163 for (nn = TLS_SLOT_ERRNO; nn < BIONIC_TLS_SLOTS; nn++)
164 tls[nn] = 0;
165
166 - __set_tls( (void*)tls );
167 + __set_tls( (void*)tls ); */
168 }
169
170
171 @@ -1662,6 +1663,7 @@ static int tlsmap_alloc(tlsmap_t* m, tls_dtor_t dtor)
172
173 int pthread_key_create(pthread_key_t *key, void (*destructor_function)(void *))
174 {
175 + abort();
176 uint32_t err = ENOMEM;
177 tlsmap_t* map = tlsmap_lock();
178 int k = tlsmap_alloc(map, destructor_function);
179 @@ -1686,6 +1688,7 @@ int pthread_key_create(pthread_key_t *key, void (*destructor_function)(void *))
180 */
181 int pthread_key_delete(pthread_key_t key)
182 {
183 + abort();
184 uint32_t err;
185 pthread_internal_t* thr;
186 tlsmap_t* map;
187 @@ -1730,6 +1733,7 @@ err1:
188
189 int pthread_setspecific(pthread_key_t key, const void *ptr)
190 {
191 + abort();
192 int err = EINVAL;
193 tlsmap_t* map;
194
195 @@ -1747,6 +1751,7 @@ int pthread_setspecific(pthread_key_t key, const void *ptr)
196
197 void * pthread_getspecific(pthread_key_t key)
198 {
199 + abort();
200 if (!TLSMAP_VALIDATE_KEY(key)) {
201 return NULL;
202 }
203 @@ -1775,6 +1780,7 @@ void * pthread_getspecific(pthread_key_t key)
204 */
205 static void pthread_key_clean_all(void)
206 {
207 + abort();
208 tlsmap_t* map;
209 void** tls = (void**)__get_tls();
210 int rounds = PTHREAD_DESTRUCTOR_ITERATIONS;
211 @@ -1830,6 +1836,7 @@ extern int tkill(int tid, int sig);
212
213 int pthread_kill(pthread_t tid, int sig)
214 {
215 + abort();
216 int ret;
217 int old_errno = errno;
218 pthread_internal_t * thread = (pthread_internal_t *)tid;
219 @@ -1847,6 +1854,7 @@ extern int __rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
220
221 int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
222 {
223 + abort();
224 /* pthread_sigmask must return the error code, but the syscall
225 * will set errno instead and return 0/-1
226 */
227 @@ -1863,6 +1871,7 @@ int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
228
229 int pthread_getcpuclockid(pthread_t tid, clockid_t *clockid)
230 {
231 + abort();
232 const int CLOCK_IDTYPE_BITS = 3;
233 pthread_internal_t* thread = (pthread_internal_t*)tid;
234
235 @@ -1879,6 +1888,7 @@ int pthread_getcpuclockid(pthread_t tid, clockid_t *clockid)
236 */
237 int pthread_once( pthread_once_t* once_control, void (*init_routine)(void) )
238 {
239 + abort();
240 static pthread_mutex_t once_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
241
242 if (*once_control == PTHREAD_ONCE_INIT) {
243 @@ -1898,6 +1908,7 @@ int pthread_once( pthread_once_t* once_control, void (*init_routine)(void) )
244
245 int pthread_setname_np(pthread_t thid, const char *thname)
246 {
247 + abort();
248 size_t thname_len;
249 int saved_errno, ret;
250
251 diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h
252 index 94a81cd..81c5e16 100644
253 --- a/libc/private/bionic_tls.h
254 +++ b/libc/private/bionic_tls.h
255 @@ -55,17 +55,17 @@ __BEGIN_DECLS
256 /* Well known TLS slots */
257 #define TLS_SLOT_SELF 0
258 #define TLS_SLOT_THREAD_ID 1
259 -#define TLS_SLOT_ERRNO 2
260 +#define TLS_SLOT_ERRNO 4
261
262 -#define TLS_SLOT_OPENGL_API 3
263 -#define TLS_SLOT_OPENGL 4
264 +#define TLS_SLOT_OPENGL_API 5
265 +#define TLS_SLOT_OPENGL 6
266
267 /* this slot is only used to pass information from the dynamic linker to
268 * libc.so when the C library is loaded in to memory. The C runtime init
269 * function will then clear it. Since its use is extremely temporary,
270 * we reuse an existing location.
271 */
272 -#define TLS_SLOT_BIONIC_PREINIT (TLS_SLOT_ERRNO+1)
273 +#define TLS_SLOT_BIONIC_PREINIT 3
274
275 /* small technical note: it is not possible to call pthread_setspecific
276 * on keys that are <= TLS_SLOT_MAX_WELL_KNOWN, which is why it is set to
277 @@ -76,7 +76,7 @@ __BEGIN_DECLS
278 * pthread_key_create() to initialize them. on the other hand, there is
279 * no destructor associated to them (we might need to implement this later)
280 */
281 -#define TLS_SLOT_MAX_WELL_KNOWN TLS_SLOT_ERRNO
282 +#define TLS_SLOT_MAX_WELL_KNOWN 2
283
284 #define TLS_DEFAULT_ALLOC_MAP 0x0000001F
285
286 diff --git a/libdl/libdl.c b/libdl/libdl.c
287 index b36af16..ad6d4b4 100644
288 --- a/libdl/libdl.c
289 +++ b/libdl/libdl.c
290 @@ -24,6 +24,8 @@ void *dlsym(void *handle, const char *symbol) { return 0; }
291 int dladdr(void *addr, Dl_info *info) { return 0; }
292 int dlclose(void *handle) { return 0; }
293
294 +int *__errno() { return 0; };
295 +void __set_errno(int f) {};
296 #ifdef __arm__
297 void *dl_unwind_find_exidx(void *pc, int *pcount) { return 0; }
298 #elif defined(__i386__) || defined(__sh__)