summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ucode/types.h20
-rw-r--r--include/ucode/util.h28
2 files changed, 43 insertions, 5 deletions
diff --git a/include/ucode/types.h b/include/ucode/types.h
index bf8b9f2..85c3eb8 100644
--- a/include/ucode/types.h
+++ b/include/ucode/types.h
@@ -206,11 +206,6 @@ typedef struct {
uc_declare_vector(uc_resource_types_t, uc_resource_type_t *);
-
-/* Object iteration */
-
-extern uc_list_t uc_object_iterators;
-
typedef struct {
uc_list_t list;
struct lh_table *table;
@@ -270,6 +265,19 @@ uc_search_path_free(uc_search_path_t *search_path) {
}
+/* TLS data */
+
+typedef struct {
+ /* VM owning installed signal handlers */
+ uc_vm_t *signal_handler_vm;
+
+ /* Object iteration */
+ uc_list_t object_iterators;
+} uc_thread_context_t;
+
+__hidden uc_thread_context_t *uc_thread_context_get(void);
+
+
/* VM definitions */
typedef enum {
@@ -388,6 +396,7 @@ uc_value_t *ucv_array_push(uc_value_t *, uc_value_t *);
uc_value_t *ucv_array_shift(uc_value_t *);
uc_value_t *ucv_array_unshift(uc_value_t *, uc_value_t *);
void ucv_array_sort(uc_value_t *, int (*)(const void *, const void *));
+void ucv_array_sort_r(uc_value_t *, int (*)(uc_value_t *, uc_value_t *, void *), void *);
bool ucv_array_delete(uc_value_t *, size_t, size_t);
bool ucv_array_set(uc_value_t *, size_t, uc_value_t *);
size_t ucv_array_length(uc_value_t *);
@@ -396,6 +405,7 @@ uc_value_t *ucv_object_new(uc_vm_t *);
uc_value_t *ucv_object_get(uc_value_t *, const char *, bool *);
bool ucv_object_add(uc_value_t *, const char *, uc_value_t *);
void ucv_object_sort(uc_value_t *, int (*)(const void *, const void *));
+void ucv_object_sort_r(uc_value_t *, int (*)(const char *, uc_value_t *, const char *, uc_value_t *, void *), void *);
bool ucv_object_delete(uc_value_t *, const char *);
size_t ucv_object_length(uc_value_t *);
diff --git a/include/ucode/util.h b/include/ucode/util.h
index cc92e33..1360d28 100644
--- a/include/ucode/util.h
+++ b/include/ucode/util.h
@@ -267,4 +267,32 @@ uc_vector_extend_(char **base, size_t itemsize, size_t count, size_t add)
iter != NULL && iter >= (vec)->entries; \
iter--)
+#ifdef __APPLE__
+
+# define uc_vector_sort_cb(fn_, optype_, udtype_, ...) \
+ int fn_(void *ud, const void *k1, const void *k2) { \
+ optype_ v1 = *(optype_ *)k1; \
+ optype_ v2 = *(optype_ *)k2; \
+ udtype_ ctx = (udtype_)ud; \
+ __VA_ARGS__ \
+ }
+
+# define uc_vector_sort(v_, cmp_, ud_) \
+ qsort_r((v_)->entries, (v_)->count, sizeof((v_)->entries[0]), ud_, cmp_)
+
+#else
+
+# define uc_vector_sort_cb(fn_, optype_, udtype_, ...) \
+ int fn_(const void *k1, const void *k2, void *ud) { \
+ optype_ v1 = *(optype_ *)k1; \
+ optype_ v2 = *(optype_ *)k2; \
+ udtype_ ctx = (udtype_)ud; \
+ __VA_ARGS__ \
+ }
+
+# define uc_vector_sort(v_, cmp_, ud_) \
+ qsort_r((v_)->entries, (v_)->count, sizeof((v_)->entries[0]), cmp_, ud_)
+
+#endif
+
#endif /* UCODE_UTIL_H */