17372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh/* 27372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * Copyright (C) 2008 The Android Open Source Project 37372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * All rights reserved. 47372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * 57372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * Redistribution and use in source and binary forms, with or without 67372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * modification, are permitted provided that the following conditions 77372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * are met: 87372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * * Redistributions of source code must retain the above copyright 97372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * notice, this list of conditions and the following disclaimer. 107372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * * Redistributions in binary form must reproduce the above copyright 117372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * notice, this list of conditions and the following disclaimer in 127372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * the documentation and/or other materials provided with the 137372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * distribution. 147372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * 157372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 167372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 177372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 187372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 197372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 207372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 217372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 227372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 237372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 247372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 257372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 267372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * SUCH DAMAGE. 277372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh */ 287372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 297372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#ifndef _PTHREAD_H_ 307372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define _PTHREAD_H_ 317372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 327372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#include <time.h> 337372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#include <signal.h> 347372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#include <sched.h> 357372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#include <limits.h> 367372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#include <sys/types.h> 377372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 3814c2fbd9d075cf4214e83beb231f376bbc7604e1Andrew Hsieh#if defined(__LP64__) 391b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh #define __RESERVED_INITIALIZER , {0} 401b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#else 411b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh #define __RESERVED_INITIALIZER 421b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#endif 431b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh 447372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef struct { 457372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh int volatile value; 461b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#ifdef __LP64__ 471b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh char __reserved[36]; 481b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#endif 497372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh} pthread_mutex_t; 507372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 517372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define __PTHREAD_MUTEX_INIT_VALUE 0 527372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE 0x4000 537372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define __PTHREAD_ERRORCHECK_MUTEX_INIT_VALUE 0x8000 547372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 551b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#define PTHREAD_MUTEX_INITIALIZER {__PTHREAD_MUTEX_INIT_VALUE __RESERVED_INITIALIZER} 561b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {__PTHREAD_RECURSIVE_MUTEX_INIT_VALUE __RESERVED_INITIALIZER} 571b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER {__PTHREAD_ERRORCHECK_MUTEX_INIT_VALUE __RESERVED_INITIALIZER} 587372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 597372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehenum { 607372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh PTHREAD_MUTEX_NORMAL = 0, 617372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh PTHREAD_MUTEX_RECURSIVE = 1, 627372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh PTHREAD_MUTEX_ERRORCHECK = 2, 637372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 647372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh PTHREAD_MUTEX_ERRORCHECK_NP = PTHREAD_MUTEX_ERRORCHECK, 657372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh PTHREAD_MUTEX_RECURSIVE_NP = PTHREAD_MUTEX_RECURSIVE, 667372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 677372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL 687372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh}; 697372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 707372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef struct { 717372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh int volatile value; 721b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#ifdef __LP64__ 731b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh char __reserved[44]; 741b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#endif 757372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh} pthread_cond_t; 767372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 771b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#define PTHREAD_COND_INITIALIZER {0 __RESERVED_INITIALIZER} 787372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 797372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef struct { 807372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh uint32_t flags; 817372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh void* stack_base; 827372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh size_t stack_size; 837372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh size_t guard_size; 847372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh int32_t sched_policy; 857372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh int32_t sched_priority; 861b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#ifdef __LP64__ 871b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh char __reserved[16]; 881b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#endif 897372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh} pthread_attr_t; 907372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 917372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef long pthread_mutexattr_t; 927372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef long pthread_condattr_t; 937372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 941b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsiehtypedef long pthread_rwlockattr_t; 957372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 967372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef struct { 97244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh#if !defined(__LP64__) 98244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh pthread_mutex_t __unused_lock; 99244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh pthread_cond_t __unused_cond; 100244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh#endif 101244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh volatile int32_t state; // 0=unlock, -1=writer lock, +n=reader lock 102244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh volatile int32_t writer_thread_id; 103244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh volatile int32_t pending_readers; 104244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh volatile int32_t pending_writers; 105244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh int32_t attr; 106244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh#ifdef __LP64__ 107244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh char __reserved[36]; 108244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh#else 109244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh char __reserved[12]; 110244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh#endif 111244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh 1127372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh} pthread_rwlock_t; 1137372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 114244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh#ifdef __LP64__ 115244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh #define PTHREAD_RWLOCK_INITIALIZER { 0, 0, 0, 0, 0, { 0 } } 116244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh#else 117244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh #define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, 0, { 0 } } 118244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783Andrew Hsieh#endif 1197372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1207372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef int pthread_key_t; 1217372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef long pthread_t; 1227372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1237372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef volatile int pthread_once_t; 1247372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1251b1d56acc5281d0201fdbe8539012a2dbf09bc8fAndrew Hsieh#define PTHREAD_ONCE_INIT 0 1267372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 12714c2fbd9d075cf4214e83beb231f376bbc7604e1Andrew Hsieh#if defined(__LP64__) 12814c2fbd9d075cf4214e83beb231f376bbc7604e1Andrew Hsieh#define PTHREAD_STACK_MIN (4 * PAGE_SIZE) 12914c2fbd9d075cf4214e83beb231f376bbc7604e1Andrew Hsieh#else 1307372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define PTHREAD_STACK_MIN (2 * PAGE_SIZE) 13114c2fbd9d075cf4214e83beb231f376bbc7604e1Andrew Hsieh#endif 1327372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1337372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define PTHREAD_CREATE_DETACHED 0x00000001 1347372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define PTHREAD_CREATE_JOINABLE 0x00000000 1357372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1367372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define PTHREAD_PROCESS_PRIVATE 0 1377372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define PTHREAD_PROCESS_SHARED 1 1387372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1397372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define PTHREAD_SCOPE_SYSTEM 0 1407372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define PTHREAD_SCOPE_PROCESS 1 1417372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1427372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh__BEGIN_DECLS 1437372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1447372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_atfork(void (*)(void), void (*)(void), void(*)(void)); 1457372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1467372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_destroy(pthread_attr_t*) __nonnull((1)); 1477372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_getdetachstate(const pthread_attr_t*, int*) __nonnull((1, 2)); 1487372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_getguardsize(const pthread_attr_t*, size_t*) __nonnull((1, 2)); 1497372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_getschedparam(const pthread_attr_t*, struct sched_param*) __nonnull((1, 2)); 1507372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_getschedpolicy(const pthread_attr_t*, int*) __nonnull((1, 2)); 1517372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_getscope(const pthread_attr_t*, int*) __nonnull((1, 2)); 1527372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_getstack(const pthread_attr_t*, void**, size_t*) __nonnull((1, 2, 3)); 1537372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_getstacksize(const pthread_attr_t*, size_t*) __nonnull((1, 2)); 1547372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_init(pthread_attr_t*) __nonnull((1)); 1557372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_setdetachstate(pthread_attr_t*, int) __nonnull((1)); 1567372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_setguardsize(pthread_attr_t*, size_t) __nonnull((1)); 1577372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_setschedparam(pthread_attr_t*, const struct sched_param*) __nonnull((1, 2)); 1587372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_setschedpolicy(pthread_attr_t*, int) __nonnull((1)); 1597372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_setscope(pthread_attr_t*, int) __nonnull((1)); 1607372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_attr_setstack(pthread_attr_t*, void*, size_t) __nonnull((1)); 161b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsiehint pthread_attr_setstacksize(pthread_attr_t*, size_t stack_size) __nonnull((1)); 1627372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1637372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_condattr_destroy(pthread_condattr_t*) __nonnull((1)); 164b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsiehint pthread_condattr_getclock(const pthread_condattr_t*, clockid_t*) __nonnull((1, 2)); 1657372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_condattr_getpshared(const pthread_condattr_t*, int*) __nonnull((1, 2)); 1667372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_condattr_init(pthread_condattr_t*) __nonnull((1)); 167b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsiehint pthread_condattr_setclock(pthread_condattr_t*, clockid_t) __nonnull((1)); 1687372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_condattr_setpshared(pthread_condattr_t*, int) __nonnull((1)); 1697372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1707372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_cond_broadcast(pthread_cond_t*) __nonnull((1)); 1717372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_cond_destroy(pthread_cond_t*) __nonnull((1)); 1727372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_cond_init(pthread_cond_t*, const pthread_condattr_t*) __nonnull((1)); 1737372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_cond_signal(pthread_cond_t*) __nonnull((1)); 1747372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const struct timespec*) __nonnull((1, 2, 3)); 1757372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*) __nonnull((1, 2)); 1767372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1777372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_create(pthread_t*, pthread_attr_t const*, void *(*)(void*), void*) __nonnull((1, 3)); 1787372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_detach(pthread_t); 1797372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehvoid pthread_exit(void*) __noreturn; 1807372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1817372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_equal(pthread_t, pthread_t); 1827372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1837372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_getattr_np(pthread_t, pthread_attr_t*) __nonnull((2)); 1847372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1857372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_getcpuclockid(pthread_t, clockid_t*) __nonnull((2)); 1867372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1877372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_getschedparam(pthread_t, int*, struct sched_param*) __nonnull((2, 3)); 1887372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1897372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehvoid* pthread_getspecific(pthread_key_t); 1907372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 191239fbd351e885fa6844a674255b79d1d81c3682aAndrew Hsiehpid_t pthread_gettid_np(pthread_t); 192239fbd351e885fa6844a674255b79d1d81c3682aAndrew Hsieh 1937372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_join(pthread_t, void**); 1947372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1957372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_key_create(pthread_key_t*, void (*)(void*)) __nonnull((1)); 1967372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_key_delete(pthread_key_t); 1977372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 1987372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_kill(pthread_t, int); 1997372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2007372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutexattr_destroy(pthread_mutexattr_t*) __nonnull((1)); 2017372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutexattr_getpshared(const pthread_mutexattr_t*, int*) __nonnull((1, 2)); 2027372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutexattr_gettype(const pthread_mutexattr_t*, int*) __nonnull((1, 2)); 2037372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutexattr_init(pthread_mutexattr_t*) __nonnull((1)); 2047372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutexattr_setpshared(pthread_mutexattr_t*, int) __nonnull((1)); 2057372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutexattr_settype(pthread_mutexattr_t*, int) __nonnull((1)); 2067372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2077372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutex_destroy(pthread_mutex_t*) __nonnull((1)); 2087372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) __nonnull((1)); 2097372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutex_lock(pthread_mutex_t*) __nonnull((1)); 210b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsiehint pthread_mutex_timedlock(pthread_mutex_t*, const struct timespec*) __nonnull((1, 2)); 2117372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutex_trylock(pthread_mutex_t*) __nonnull((1)); 2127372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_mutex_unlock(pthread_mutex_t*) __nonnull((1)); 2137372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2147372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_once(pthread_once_t*, void (*)(void)) __nonnull((1, 2)); 2157372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2167372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlockattr_destroy(pthread_rwlockattr_t*) __nonnull((1)); 2177372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlockattr_getpshared(const pthread_rwlockattr_t*, int*) __nonnull((1, 2)); 2187372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlockattr_init(pthread_rwlockattr_t*) __nonnull((1)); 2197372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int) __nonnull((1)); 2207372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2217372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_destroy(pthread_rwlock_t*) __nonnull((1)); 2227372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_init(pthread_rwlock_t*, const pthread_rwlockattr_t*) __nonnull((1)); 2237372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_rdlock(pthread_rwlock_t*) __nonnull((1)); 2247372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_timedrdlock(pthread_rwlock_t*, const struct timespec*) __nonnull((1, 2)); 2257372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_timedwrlock(pthread_rwlock_t*, const struct timespec*) __nonnull((1, 2)); 2267372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_tryrdlock(pthread_rwlock_t*) __nonnull((1)); 2277372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_trywrlock(pthread_rwlock_t*) __nonnull((1)); 2287372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_unlock(pthread_rwlock_t *rwlock) __nonnull((1)); 2297372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_rwlock_wrlock(pthread_rwlock_t*) __nonnull((1)); 2307372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2311b55d7b281f282232ee58da5d09d3da5969ff11dAndrew Hsiehpthread_t pthread_self(void) __pure2; 2327372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2337372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_setname_np(pthread_t, const char*) __nonnull((2)); 2347372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2357372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_setschedparam(pthread_t, int, const struct sched_param*) __nonnull((3)); 2367372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2377372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_setspecific(pthread_key_t, const void*); 2387372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2397372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_sigmask(int, const sigset_t*, sigset_t*); 2407372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2417372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef void (*__pthread_cleanup_func_t)(void*); 2427372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2437372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehtypedef struct __pthread_cleanup_t { 2447372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh struct __pthread_cleanup_t* __cleanup_prev; 2457372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh __pthread_cleanup_func_t __cleanup_routine; 2467372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh void* __cleanup_arg; 2477372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh} __pthread_cleanup_t; 2487372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2497372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehextern void __pthread_cleanup_push(__pthread_cleanup_t* c, __pthread_cleanup_func_t, void*); 2507372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehextern void __pthread_cleanup_pop(__pthread_cleanup_t*, int); 2517372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2527372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh/* Believe or not, the definitions of pthread_cleanup_push and 2537372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * pthread_cleanup_pop below are correct. Posix states that these 2547372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * can be implemented as macros that might introduce opening and 2557372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * closing braces, and that using setjmp/longjmp/return/break/continue 2567372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh * between them results in undefined behavior. 2577372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh */ 2587372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define pthread_cleanup_push(routine, arg) \ 2597372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh do { \ 2607372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh __pthread_cleanup_t __cleanup; \ 2617372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh __pthread_cleanup_push( &__cleanup, (routine), (arg) ); \ 2627372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2637372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#define pthread_cleanup_pop(execute) \ 2647372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh __pthread_cleanup_pop( &__cleanup, (execute)); \ 2657372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh } while (0); \ 2667372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2677372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2687372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#if !defined(__LP64__) 2697372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 270b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsieh// Bionic additions that are deprecated even in the 32-bit ABI. 271b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsieh// 272b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsieh// TODO: Remove them once chromium_org / NFC have switched over. 2737372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_cond_timedwait_monotonic_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*); 2747372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsiehint pthread_cond_timedwait_monotonic(pthread_cond_t*, pthread_mutex_t*, const struct timespec*); 2757372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 276b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsiehint pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*) /* TODO: __attribute__((deprecated("use pthread_cond_timedwait instead")))*/; 277b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsieh#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE 1 /* TODO: stop defining this to push LP32 off this API sooner. */ 278b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsiehint pthread_cond_timeout_np(pthread_cond_t*, pthread_mutex_t*, unsigned) /* TODO: __attribute__((deprecated("use pthread_cond_timedwait instead")))*/; 2797372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 280b193073d2e5369d848d2135d5a2f642f3242cf0eAndrew Hsiehint pthread_mutex_lock_timeout_np(pthread_mutex_t*, unsigned) __attribute__((deprecated("use pthread_mutex_timedlock instead"))); 2817372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2827372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#endif /* !defined(__LP64__) */ 2837372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2847372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh__END_DECLS 2857372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh 2867372bd5a6d7d0cb636bdfdd27ca99b2d6abc0f2cAndrew Hsieh#endif /* _PTHREAD_H_ */ 287