summaryrefslogtreecommitdiffhomepage
path: root/include/stc/carc.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-06-20 15:28:02 +0200
committerTyge Løvset <[email protected]>2023-06-20 15:28:02 +0200
commitde4f8fa86f141dfeab15f5576029910474f56fa1 (patch)
tree930f8ecb0a2765d4834aa34f6ac538096454816c /include/stc/carc.h
parentb617eded8cee98dd3ff9ac896328b172d37fcf91 (diff)
downloadSTC-modified-de4f8fa86f141dfeab15f5576029910474f56fa1.tar.gz
STC-modified-de4f8fa86f141dfeab15f5576029910474f56fa1.zip
Internal only:
Renamed _cx_memb() macro to _cx_MEMB() Renamed _cx_self macro to _cx_Self
Diffstat (limited to 'include/stc/carc.h')
-rw-r--r--include/stc/carc.h76
1 files changed, 38 insertions, 38 deletions
diff --git a/include/stc/carc.h b/include/stc/carc.h
index 749b1fc1..3b60fe78 100644
--- a/include/stc/carc.h
+++ b/include/stc/carc.h
@@ -91,119 +91,119 @@ typedef i_keyraw _cx_raw;
#define _i_atomic_dec_and_test(v) !(--*(v))
#endif
#ifndef i_is_forward
-_cx_deftypes(_c_carc_types, _cx_self, i_key);
+_cx_DEFTYPES(_c_carc_types, _cx_Self, i_key);
#endif
-struct _cx_memb(_rep_) { catomic_long counter; i_key value; };
+struct _cx_MEMB(_rep_) { catomic_long counter; i_key value; };
-STC_INLINE _cx_self _cx_memb(_init)(void)
- { return c_LITERAL(_cx_self){NULL, NULL}; }
+STC_INLINE _cx_Self _cx_MEMB(_init)(void)
+ { return c_LITERAL(_cx_Self){NULL, NULL}; }
-STC_INLINE long _cx_memb(_use_count)(const _cx_self* self)
+STC_INLINE long _cx_MEMB(_use_count)(const _cx_Self* self)
{ return self->use_count ? *self->use_count : 0; }
-STC_INLINE _cx_self _cx_memb(_from_ptr)(_cx_value* p) {
- _cx_self ptr = {p};
+STC_INLINE _cx_Self _cx_MEMB(_from_ptr)(_cx_value* p) {
+ _cx_Self ptr = {p};
if (p)
*(ptr.use_count = _i_alloc(catomic_long)) = 1;
return ptr;
}
// c++: std::make_shared<_cx_value>(val)
-STC_INLINE _cx_self _cx_memb(_make)(_cx_value val) {
- _cx_self ptr;
- struct _cx_memb(_rep_)* rep = _i_alloc(struct _cx_memb(_rep_));
+STC_INLINE _cx_Self _cx_MEMB(_make)(_cx_value val) {
+ _cx_Self ptr;
+ struct _cx_MEMB(_rep_)* rep = _i_alloc(struct _cx_MEMB(_rep_));
*(ptr.use_count = &rep->counter) = 1;
*(ptr.get = &rep->value) = val;
return ptr;
}
-STC_INLINE _cx_raw _cx_memb(_toraw)(const _cx_self* self)
+STC_INLINE _cx_raw _cx_MEMB(_toraw)(const _cx_Self* self)
{ return i_keyto(self->get); }
-STC_INLINE _cx_self _cx_memb(_move)(_cx_self* self) {
- _cx_self ptr = *self;
+STC_INLINE _cx_Self _cx_MEMB(_move)(_cx_Self* self) {
+ _cx_Self ptr = *self;
self->get = NULL, self->use_count = NULL;
return ptr;
}
-STC_INLINE void _cx_memb(_drop)(_cx_self* self) {
+STC_INLINE void _cx_MEMB(_drop)(_cx_Self* self) {
if (self->use_count && _i_atomic_dec_and_test(self->use_count)) {
i_keydrop(self->get);
- if ((char *)self->get != (char *)self->use_count + offsetof(struct _cx_memb(_rep_), value))
+ if ((char *)self->get != (char *)self->use_count + offsetof(struct _cx_MEMB(_rep_), value))
i_free(self->get);
i_free((long*)self->use_count);
}
}
-STC_INLINE void _cx_memb(_reset)(_cx_self* self) {
- _cx_memb(_drop)(self);
+STC_INLINE void _cx_MEMB(_reset)(_cx_Self* self) {
+ _cx_MEMB(_drop)(self);
self->use_count = NULL, self->get = NULL;
}
-STC_INLINE void _cx_memb(_reset_to)(_cx_self* self, _cx_value* p) {
- _cx_memb(_drop)(self);
- *self = _cx_memb(_from_ptr)(p);
+STC_INLINE void _cx_MEMB(_reset_to)(_cx_Self* self, _cx_value* p) {
+ _cx_MEMB(_drop)(self);
+ *self = _cx_MEMB(_from_ptr)(p);
}
#ifndef i_no_emplace
-STC_INLINE _cx_self _cx_memb(_from)(_cx_raw raw)
- { return _cx_memb(_make)(i_keyfrom(raw)); }
+STC_INLINE _cx_Self _cx_MEMB(_from)(_cx_raw raw)
+ { return _cx_MEMB(_make)(i_keyfrom(raw)); }
#else
-STC_INLINE _cx_self _cx_memb(_from)(_cx_value val)
- { return _cx_memb(_make)(val); }
+STC_INLINE _cx_Self _cx_MEMB(_from)(_cx_value val)
+ { return _cx_MEMB(_make)(val); }
#endif
// does not use i_keyclone, so OK to always define.
-STC_INLINE _cx_self _cx_memb(_clone)(_cx_self ptr) {
+STC_INLINE _cx_Self _cx_MEMB(_clone)(_cx_Self ptr) {
if (ptr.use_count)
_i_atomic_inc(ptr.use_count);
return ptr;
}
// take ownership of unowned
-STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self unowned) {
- _cx_memb(_drop)(self);
+STC_INLINE void _cx_MEMB(_take)(_cx_Self* self, _cx_Self unowned) {
+ _cx_MEMB(_drop)(self);
*self = unowned;
}
// share ownership with ptr
-STC_INLINE void _cx_memb(_assign)(_cx_self* self, _cx_self ptr) {
+STC_INLINE void _cx_MEMB(_assign)(_cx_Self* self, _cx_Self ptr) {
if (ptr.use_count)
_i_atomic_inc(ptr.use_count);
- _cx_memb(_drop)(self);
+ _cx_MEMB(_drop)(self);
*self = ptr;
}
#ifndef i_no_cmp
-STC_INLINE int _cx_memb(_raw_cmp)(const _cx_raw* rx, const _cx_raw* ry)
+STC_INLINE int _cx_MEMB(_raw_cmp)(const _cx_raw* rx, const _cx_raw* ry)
{ return i_cmp(rx, ry); }
-STC_INLINE int _cx_memb(_cmp)(const _cx_self* self, const _cx_self* other) {
+STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
_cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
return i_cmp((&rx), (&ry));
}
#endif
#ifdef _i_eq
-STC_INLINE bool _cx_memb(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry)
+STC_INLINE bool _cx_MEMB(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry)
{ return i_eq(rx, ry); }
-STC_INLINE bool _cx_memb(_eq)(const _cx_self* self, const _cx_self* other) {
+STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
_cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
return i_eq((&rx), (&ry));
}
#elif !defined i_no_cmp
-STC_INLINE bool _cx_memb(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry)
+STC_INLINE bool _cx_MEMB(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry)
{ return i_cmp(rx, ry) == 0; }
-STC_INLINE bool _cx_memb(_eq)(const _cx_self* self, const _cx_self* other)
- { return _cx_memb(_cmp)(self, other) == 0; }
+STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other)
+ { return _cx_MEMB(_cmp)(self, other) == 0; }
#endif
#ifndef i_no_hash
-STC_INLINE uint64_t _cx_memb(_raw_hash)(const _cx_raw* rx)
+STC_INLINE uint64_t _cx_MEMB(_raw_hash)(const _cx_raw* rx)
{ return i_hash(rx); }
-STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* self)
+STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
{ _cx_raw rx = i_keyto(self->get); return i_hash((&rx)); }
#endif