IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
unix.hxx
Go to the documentation of this file.
1
3
4#pragma once
5#include <ice/os/handle.hxx>
6
7#if ISP_UNIX
8
9#include <sys/time.h>
10#include <pthread.h>
11#include <semaphore.h>
12#include <unistd.h>
13#include <dlfcn.h>
14#include <stdlib.h>
15#include <malloc.h>
16#pragma clang diagnostic ignored "-Wunknown-attributes"
17
18template<>
20{
23 using PlatformHandleType = int;
24
27 static constexpr PlatformHandleType InvalidHandle = -1;
28
29 static bool is_valid(PlatformHandleType handle, void*) noexcept
30 {
31 return handle != InvalidHandle;
32 }
33
34 static bool close(PlatformHandleType handle, void*) noexcept
35 {
36 return ::close(handle) == 0;
37 }
38};
39
40template<>
42{
43 using PlatformHandleType = void*;
44
45 static constexpr PlatformHandleType InvalidHandle = nullptr;
46
47 static bool is_valid(PlatformHandleType handle, void*) noexcept
48 {
49 return handle != InvalidHandle;
50 }
51
52 static bool close(PlatformHandleType handle, void*) noexcept
53 {
54 return dlclose(handle) == 0;
55 }
56};
57
58// Can't use 'unix' since it's a define
59namespace ice::unix_
60{
61
62 using FileHandle = ice::os::Handle<ice::os::HandleType::File>;
63 using DynLibHandle = ice::os::Handle<ice::os::HandleType::DynLib>;
64
65} // namespace ice::unix
66
67#endif
@ File
Definition handle.hxx:14
@ DynLib
Definition handle.hxx:15
SPDX-License-Identifier: MIT.
Definition array.hxx:12
Definition handle.hxx:26