Serenity Operating System
at hosted 114 lines 4.7 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this 9 * list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#pragma once 28 29#include <sched.h> 30#include <stdint.h> 31#include <sys/cdefs.h> 32#include <sys/types.h> 33#include <time.h> 34 35__BEGIN_DECLS 36 37int pthread_create(pthread_t*, pthread_attr_t*, void* (*)(void*), void*); 38void pthread_exit(void*); 39int pthread_kill(pthread_t, int); 40void pthread_cleanup_push(void (*)(void*), void*); 41void pthread_cleanup_pop(int); 42int pthread_join(pthread_t, void**); 43int pthread_mutex_lock(pthread_mutex_t*); 44int pthread_mutex_trylock(pthread_mutex_t* mutex); 45int pthread_mutex_unlock(pthread_mutex_t*); 46int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*); 47int pthread_mutex_destroy(pthread_mutex_t*); 48 49int pthread_attr_init(pthread_attr_t*); 50int pthread_attr_destroy(pthread_attr_t*); 51 52#define PTHREAD_CREATE_JOINABLE 0 53#define PTHREAD_CREATE_DETACHED 1 54 55int pthread_attr_getdetachstate(const pthread_attr_t*, int*); 56int pthread_attr_setdetachstate(pthread_attr_t*, int); 57 58int pthread_attr_getguardsize(const pthread_attr_t*, size_t*); 59int pthread_attr_setguardsize(pthread_attr_t*, size_t); 60 61int pthread_attr_getschedparam(const pthread_attr_t*, struct sched_param*); 62int pthread_attr_setschedparam(pthread_attr_t*, const struct sched_param*); 63 64int pthread_attr_getstack(const pthread_attr_t*, void**, size_t*); 65int pthread_attr_setstack(pthread_attr_t* attr, void*, size_t); 66 67int pthread_attr_getstacksize(const pthread_attr_t*, size_t*); 68int pthread_attr_setstacksize(pthread_attr_t*, size_t); 69 70int pthread_once(pthread_once_t*, void (*)()); 71#define PTHREAD_ONCE_INIT 0 72void* pthread_getspecific(pthread_key_t key); 73int pthread_setspecific(pthread_key_t key, const void* value); 74 75int pthread_getschedparam(pthread_t thread, int* policy, struct sched_param* param); 76int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param* param); 77 78#define PTHREAD_MUTEX_NORMAL 0 79#define PTHREAD_MUTEX_RECURSIVE 1 80#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL 81#define PTHREAD_MUTEX_INITIALIZER { 0, 0, 0, PTHREAD_MUTEX_DEFAULT } 82#define PTHREAD_COND_INITIALIZER { 0, 0, CLOCK_MONOTONIC } 83 84int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)); 85int pthread_key_delete(pthread_key_t key); 86int pthread_cond_broadcast(pthread_cond_t*); 87int pthread_cond_init(pthread_cond_t*, const pthread_condattr_t*); 88int pthread_cond_signal(pthread_cond_t*); 89int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*); 90int pthread_condattr_init(pthread_condattr_t*); 91int pthread_condattr_setclock(pthread_condattr_t*, clockid_t); 92int pthread_condattr_destroy(pthread_condattr_t*); 93int pthread_cancel(pthread_t); 94int pthread_cond_destroy(pthread_cond_t*); 95int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const struct timespec*); 96 97void pthread_testcancel(void); 98 99int pthread_spin_destroy(pthread_spinlock_t*); 100int pthread_spin_init(pthread_spinlock_t*, int); 101int pthread_spin_lock(pthread_spinlock_t*); 102int pthread_spin_trylock(pthread_spinlock_t*); 103int pthread_spin_unlock(pthread_spinlock_t*); 104pthread_t pthread_self(void); 105int pthread_detach(pthread_t); 106int pthread_equal(pthread_t, pthread_t); 107int pthread_mutexattr_init(pthread_mutexattr_t*); 108int pthread_mutexattr_settype(pthread_mutexattr_t*, int); 109int pthread_mutexattr_destroy(pthread_mutexattr_t*); 110 111int pthread_setname_np(pthread_t, const char*); 112int pthread_getname_np(pthread_t, char*, size_t); 113 114__END_DECLS