From 9b69c73dfee35a3a107a48fa26baafa489112f31 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Thu, 11 Feb 2021 21:55:35 +0330 Subject: [PATCH] LibC: Stub out semaphore.h --- Userland/Libraries/LibC/CMakeLists.txt | 1 + Userland/Libraries/LibC/semaphore.cpp | 65 ++++++++++++++++++++++++++ Userland/Libraries/LibC/semaphore.h | 46 ++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 Userland/Libraries/LibC/semaphore.cpp create mode 100644 Userland/Libraries/LibC/semaphore.h diff --git a/Userland/Libraries/LibC/CMakeLists.txt b/Userland/Libraries/LibC/CMakeLists.txt index cab661dcb6..9905619d42 100644 --- a/Userland/Libraries/LibC/CMakeLists.txt +++ b/Userland/Libraries/LibC/CMakeLists.txt @@ -21,6 +21,7 @@ set(LIBC_SOURCES qsort.cpp scanf.cpp sched.cpp + semaphore.cpp serenity.cpp setjmp.S signal.cpp diff --git a/Userland/Libraries/LibC/semaphore.cpp b/Userland/Libraries/LibC/semaphore.cpp new file mode 100644 index 0000000000..165c14eddc --- /dev/null +++ b/Userland/Libraries/LibC/semaphore.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +int sem_close(sem_t*) +{ + ASSERT_NOT_REACHED(); +} +int sem_destroy(sem_t*) +{ + ASSERT_NOT_REACHED(); +} +int sem_getvalue(sem_t*, int*) +{ + ASSERT_NOT_REACHED(); +} +int sem_init(sem_t*, int, unsigned int) +{ + ASSERT_NOT_REACHED(); +} +sem_t* sem_open(const char*, int, ...) +{ + ASSERT_NOT_REACHED(); +} +int sem_post(sem_t*) +{ + ASSERT_NOT_REACHED(); +} +int sem_trywait(sem_t*) +{ + ASSERT_NOT_REACHED(); +} +int sem_unlink(const char*) +{ + ASSERT_NOT_REACHED(); +} +int sem_wait(sem_t*) +{ + ASSERT_NOT_REACHED(); +} diff --git a/Userland/Libraries/LibC/semaphore.h b/Userland/Libraries/LibC/semaphore.h new file mode 100644 index 0000000000..4d0444bef5 --- /dev/null +++ b/Userland/Libraries/LibC/semaphore.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include +#include + +__BEGIN_DECLS + +typedef int sem_t; + +int sem_close(sem_t*); +int sem_destroy(sem_t*); +int sem_getvalue(sem_t*, int*); +int sem_init(sem_t*, int, unsigned int); +sem_t* sem_open(const char*, int, ...); +int sem_post(sem_t*); +int sem_trywait(sem_t*); +int sem_unlink(const char*); +int sem_wait(sem_t*); + +__END_DECLS