summaryrefslogtreecommitdiffhomepage
path: root/src/libSystem
diff options
context:
space:
mode:
Diffstat (limited to 'src/libSystem')
-rw-r--r--src/libSystem/SystemKit/Err.h5
-rw-r--r--src/libSystem/SystemKit/Jail.h5
-rw-r--r--src/libSystem/SystemKit/Macros.h5
-rw-r--r--src/libSystem/SystemKit/Syscall.h5
-rw-r--r--src/libSystem/SystemKit/Verify.h10
-rw-r--r--src/libSystem/src/SystemCalls.cc4
6 files changed, 23 insertions, 11 deletions
diff --git a/src/libSystem/SystemKit/Err.h b/src/libSystem/SystemKit/Err.h
index ea36abde..7e8dbee4 100644
--- a/src/libSystem/SystemKit/Err.h
+++ b/src/libSystem/SystemKit/Err.h
@@ -4,7 +4,8 @@
======================================== */
-#pragma once
+#ifndef SYSTEMKIT_ERR_H
+#define SYSTEMKIT_ERR_H
#include <libSystem/SystemKit/Macros.h>
@@ -56,3 +57,5 @@ inline constexpr ErrRef kErrorUnimplemented = -1;
/// @brief The last error reported by the system to the process.
IMPORT_C ErrRef kLastError;
+
+#endif
diff --git a/src/libSystem/SystemKit/Jail.h b/src/libSystem/SystemKit/Jail.h
index f28968b4..acf392b4 100644
--- a/src/libSystem/SystemKit/Jail.h
+++ b/src/libSystem/SystemKit/Jail.h
@@ -4,7 +4,8 @@
======================================== */
-#pragma once
+#ifndef SYSTEMKIT_JAIL_H
+#define SYSTEMKIT_JAIL_H
#include <libSystem/SystemKit/System.h>
@@ -34,3 +35,5 @@ struct JAIL {
/// @brief Get the current jail
/// @return Pointer to the current jail structure, or NULL if not in a jail
IMPORT_C struct JAIL* JailGetCurrent(Void);
+
+#endif
diff --git a/src/libSystem/SystemKit/Macros.h b/src/libSystem/SystemKit/Macros.h
index b30db701..dab30384 100644
--- a/src/libSystem/SystemKit/Macros.h
+++ b/src/libSystem/SystemKit/Macros.h
@@ -7,7 +7,8 @@ Purpose: libsci Macros header.
======================================== */
-#pragma once
+#ifndef SYSTEMKIT_MACROS_H
+#define SYSTEMKIT_MACROS_H
/***********************************************************************************/
/// @file libSystem/Macros.h
@@ -124,3 +125,5 @@ typedef nullPtr NullPtr;
#define LIBSYS_UNUSED(X) ((void) X)
IMPORT_C void _rtl_assert(Bool expr, const Char* origin);
+
+#endif
diff --git a/src/libSystem/SystemKit/Syscall.h b/src/libSystem/SystemKit/Syscall.h
index 58d7d7f1..1d30782f 100644
--- a/src/libSystem/SystemKit/Syscall.h
+++ b/src/libSystem/SystemKit/Syscall.h
@@ -4,7 +4,8 @@
======================================== */
-#pragma once
+#ifndef SYSTEMKIT_SYSCALL_H
+#define SYSTEMKIT_SYSCALL_H
#include <libSystem/SystemKit/System.h>
#include <cstdarg>
@@ -19,3 +20,5 @@ IMPORT_C UInt64 libsys_hash_64(const Char* path);
#ifndef SYSCALL_HASH
#define SYSCALL_HASH(str) libsys_hash_64(str)
#endif // !SYSCALL_HASH
+
+#endif
diff --git a/src/libSystem/SystemKit/Verify.h b/src/libSystem/SystemKit/Verify.h
index c584ac82..0bdfd2ca 100644
--- a/src/libSystem/SystemKit/Verify.h
+++ b/src/libSystem/SystemKit/Verify.h
@@ -7,7 +7,8 @@
======================================== */
-#pragma once
+#ifndef SYSTEMKIT_VERIFY_H
+#define SYSTEMKIT_VERIFY_H
#include <libSystem/SystemKit/System.h>
@@ -15,14 +16,11 @@ namespace LibSystem::Verify {
/// @author 0xf00sec, and Amlal El Mahrouss
/// @brief safe cast operator.
template <class T, class R>
-inline R sys_safe_cast(const T* ptr) {
+inline R* sys_safe_cast(const T* ptr) {
::_rtl_assert(ptr, "safe cast failed!");
return static_cast<R*>(const_cast<T*>(ptr));
}
-template <class T, class R = Void>
-inline Void sys_safe_cast(const T* ptr) = delete;
-
template <class T, class U>
struct is_castable {
using return_type = U;
@@ -45,3 +43,5 @@ constexpr R* sys_constexpr_cast(T* ptr) {
return static_cast<R*>(ptr);
}
} // namespace LibSystem::Verify
+
+#endif
diff --git a/src/libSystem/src/SystemCalls.cc b/src/libSystem/src/SystemCalls.cc
index 95545cde..c9dc1c52 100644
--- a/src/libSystem/src/SystemCalls.cc
+++ b/src/libSystem/src/SystemCalls.cc
@@ -123,7 +123,7 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input UInt64 len, _Input UIn
IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) {
return static_cast<Ref>(libsys_syscall_arg_3(
- SYSCALL_HASH("IoOpenFile"), Verify::sys_safe_cast(path), Verify::sys_safe_cast(drv_letter)));
+ SYSCALL_HASH("IoOpenFile"), Verify::sys_safe_cast<Char, Void>(path), Verify::sys_safe_cast<Char, Void>(drv_letter)));
}
IMPORT_C Void IoCloseFile(_Input Ref desc) {
@@ -159,7 +159,7 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const Char* fmt, ...) {
// if truncated, `needed` >= kBufferSz; we still send truncated buffer
auto ret_ptr = libsys_syscall_arg_3(SYSCALL_HASH("PrintOut"), static_cast<VoidPtr>(desc),
- Verify::sys_safe_cast(buf));
+ Verify::sys_safe_cast<Char, Void>(buf));
if (!ret_ptr) return -kErrorInvalidData;