浏览代码

LibC: Stub out semaphore.h

AnotherTest 4 年之前
父节点
当前提交
9b69c73dfe
共有 3 个文件被更改,包括 112 次插入0 次删除
  1. 1 0
      Userland/Libraries/LibC/CMakeLists.txt
  2. 65 0
      Userland/Libraries/LibC/semaphore.cpp
  3. 46 0
      Userland/Libraries/LibC/semaphore.h

+ 1 - 0
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

+ 65 - 0
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 <AK/Assertions.h>
+#include <semaphore.h>
+
+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();
+}

+ 46 - 0
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 <sys/cdefs.h>
+#include <sys/types.h>
+
+__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