Skip to content

Commit 96eb669

Browse files
committed
Fix link issue on Linux
1 parent e1ccb23 commit 96eb669

File tree

4 files changed

+72
-57
lines changed

4 files changed

+72
-57
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// Graph.cpp
3+
// OpenGraph_SPI
4+
5+
#include "Graph.hpp"
6+
#include "Subgraph.hpp"
7+
#include "OGGraphDescription.h"
8+
9+
#if !OG_TARGET_OS_WASI
10+
#include <dispatch/dispatch.h>
11+
#endif
12+
13+
#include <pthread.h>
14+
15+
pthread_key_t OG::Graph::_current_update_key;
16+
17+
OG::Graph::Graph() OG_NOEXCEPT {
18+
// TODO
19+
20+
// libdispatch is not supported on WASI
21+
// Tracked via https://github.com/swiftwasm/swift/issues/5565
22+
#if !OG_TARGET_OS_WASI
23+
static dispatch_once_t make_keys;
24+
dispatch_once_f(&make_keys, nullptr, [](void * _Nullable context){
25+
pthread_key_create(&_current_update_key, nullptr);
26+
OG::Subgraph::make_current_subgraph_key();
27+
});
28+
#endif
29+
30+
// TODO
31+
}
32+
33+
const void OG::Graph::value_mark_all() const OG_NOEXCEPT {
34+
// TODO
35+
}
36+
37+
void OG::Graph::all_start_profiling(uint32_t) OG_NOEXCEPT {
38+
// TODO
39+
}
40+
void OG::Graph::all_stop_profiling() OG_NOEXCEPT {
41+
// TODO
42+
}
43+
void OG::Graph::start_profiling(uint32_t) OG_NOEXCEPT {
44+
// TODO
45+
}
46+
void OG::Graph::stop_profiling() OG_NOEXCEPT {
47+
// TODO
48+
}
49+
50+
const bool OG::Graph::thread_is_updating() const OG_NOEXCEPT {
51+
void *current = pthread_getspecific(current_key());
52+
if (!current) {
53+
return false;
54+
}
55+
// TODO
56+
return false;
57+
}
58+
59+
const bool OG::Graph::is_context_updating(const OG::Graph::Context&) const OG_NOEXCEPT {
60+
// TODO
61+
return false;
62+
}

Sources/OpenGraph_SPI/Graph/Graph.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//
22
// Graph.hpp
3-
//
4-
//
5-
// Created by Kyle on 2024/1/18.
6-
//
3+
// OpenGraph_SPI
4+
75

86
#ifndef Graph_hpp
97
#define Graph_hpp
@@ -122,9 +120,11 @@ class Graph final {
122120
static void all_stop_profiling() OG_NOEXCEPT;
123121
void start_profiling(uint32_t) OG_NOEXCEPT;
124122
void stop_profiling() OG_NOEXCEPT;
125-
123+
124+
#if OG_OBJC_FOUNDATION
126125
static void write_to_file(const Graph * _Nullable, const char * _Nullable, uint8_t) OG_NOEXCEPT;
127-
126+
#endif
127+
128128
const bool thread_is_updating() const OG_NOEXCEPT;
129129
const bool is_context_updating(const OG::Graph::Context&) const OG_NOEXCEPT;
130130

Sources/OpenGraph_SPI/Graph/Graph.mm

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,12 @@
33
// OpenGraph_SPI
44

55
#include "Graph.hpp"
6-
#include "Subgraph.hpp"
76
#include "OGGraphDescription.h"
87

98
#if OG_OBJC_FOUNDATION
10-
#include <dispatch/dispatch.h>
11-
#include <pthread.h>
129
#include <Foundation/Foundation.h>
1310
#include <zlib.h>
1411

15-
pthread_key_t OG::Graph::_current_update_key;
16-
17-
OG::Graph::Graph() OG_NOEXCEPT {
18-
// TODO
19-
20-
// libdispatch is not supported on WASI
21-
// Tracked via https://github.com/swiftwasm/swift/issues/5565
22-
#if !OG_TARGET_OS_WASI
23-
static dispatch_once_t make_keys;
24-
dispatch_once_f(&make_keys, nullptr, [](void * _Nullable context){
25-
pthread_key_create(&_current_update_key, nullptr);
26-
OG::Subgraph::make_current_subgraph_key();
27-
});
28-
#endif
29-
30-
// TODO
31-
}
32-
33-
const void OG::Graph::value_mark_all() const OG_NOEXCEPT {
34-
// TODO
35-
}
36-
37-
void OG::Graph::all_start_profiling(uint32_t) OG_NOEXCEPT {
38-
// TODO
39-
}
40-
void OG::Graph::all_stop_profiling() OG_NOEXCEPT {
41-
// TODO
42-
}
43-
void OG::Graph::start_profiling(uint32_t) OG_NOEXCEPT {
44-
// TODO
45-
}
46-
void OG::Graph::stop_profiling() OG_NOEXCEPT {
47-
// TODO
48-
}
49-
5012
void OG::Graph::write_to_file(const Graph * _Nullable graph, const char * _Nullable name, uint8_t options) OG_NOEXCEPT {
5113
@autoreleasepool {
5214
NSDictionary <NSString *, id> *options_dict = @{
@@ -94,17 +56,4 @@
9456
}
9557
}
9658

97-
const bool OG::Graph::thread_is_updating() const OG_NOEXCEPT {
98-
void *current = pthread_getspecific(current_key());
99-
if (!current) {
100-
return false;
101-
}
102-
// TODO
103-
return false;
104-
}
105-
106-
const bool OG::Graph::is_context_updating(const OG::Graph::Context&) const OG_NOEXCEPT {
107-
// TODO
108-
return false;
109-
}
11059
#endif /* OG_OBJC_FOUNDATION */

Sources/OpenGraph_SPI/Graph/OGGraph.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ OGGraphRef OGGraphCreateShared(OGGraphRef storage) {
4242
}
4343

4444
void OGGraphArchiveJSON(char const * _Nullable name) {
45+
#if OG_OBJC_FOUNDATION
4546
OG::Graph::write_to_file(nullptr, name, 0);
47+
#endif
4648
}
4749

4850
void OGGraphArchiveJSON2(char const * _Nullable name, uint8_t options) {
51+
#if OG_OBJC_FOUNDATION
4952
OG::Graph::write_to_file(nullptr, name, options);
53+
#endif
5054
}
5155

5256
namespace {

0 commit comments

Comments
 (0)