Asterisk - The Open Source Telephony Project GIT-master-f36a736
Macros | Functions
astobj2_private.h File Reference

Common, private definitions for astobj2. More...

#include "asterisk/astobj2.h"
Include dependency graph for astobj2_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __is_ao2_object(user_data, file, line, func)
 
#define AO2_DEVMODE_STAT(stat)
 
#define is_ao2_object(user_data)    __is_ao2_object(user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 

Functions

enum ao2_lock_req __adjust_lock (void *user_data, enum ao2_lock_req lock_how, int keep_stronger)
 
int internal_is_ao2_object (void *user_data)
 
void log_bad_ao2 (void *user_data, const char *file, int line, const char *func)
 

Detailed Description

Common, private definitions for astobj2.

Author
Richard Mudgett rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file astobj2_private.h.

Macro Definition Documentation

◆ __is_ao2_object

#define __is_ao2_object (   user_data,
  file,
  line,
  func 
)

Definition at line 49 of file astobj2_private.h.

◆ AO2_DEVMODE_STAT

#define AO2_DEVMODE_STAT (   stat)

Definition at line 32 of file astobj2_private.h.

◆ is_ao2_object

#define is_ao2_object (   user_data)     __is_ao2_object(user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 61 of file astobj2_private.h.

Function Documentation

◆ __adjust_lock()

enum ao2_lock_req __adjust_lock ( void *  user_data,
enum ao2_lock_req  lock_how,
int  keep_stronger 
)

Definition at line 425 of file astobj2.c.

426{
427 struct astobj2 *obj = INTERNAL_OBJ(user_data);
428 struct astobj2_rwlock *obj_rwlock;
429 struct astobj2_lockobj *obj_lockobj;
430 enum ao2_lock_req orig_lock;
431
434 obj_rwlock = INTERNAL_OBJ_RWLOCK(user_data);
435 if (obj_rwlock->rwlock.num_lockers < 0) {
436 orig_lock = AO2_LOCK_REQ_WRLOCK;
437 } else {
438 orig_lock = AO2_LOCK_REQ_RDLOCK;
439 }
440 switch (lock_how) {
442 lock_how = AO2_LOCK_REQ_WRLOCK;
443 /* Fall through */
445 if (lock_how != orig_lock) {
446 /* Switch from read lock to write lock. */
449 }
450 break;
452 if (!keep_stronger && lock_how != orig_lock) {
453 /* Switch from write lock to read lock. */
456 }
457 break;
458 }
459 break;
461 obj_lockobj = INTERNAL_OBJ_LOCKOBJ(user_data);
462 orig_lock = __adjust_lock(obj_lockobj->lockobj.lock, lock_how, keep_stronger);
463 break;
464 default:
465 ast_log(LOG_ERROR, "Invalid lock option on ao2 object %p\n", user_data);
466 /* Fall through */
469 orig_lock = AO2_LOCK_REQ_MUTEX;
470 break;
471 }
472
473 return orig_lock;
474}
enum ao2_lock_req __adjust_lock(void *user_data, enum ao2_lock_req lock_how, int keep_stronger)
Definition: astobj2.c:425
#define INTERNAL_OBJ_LOCKOBJ(user_data)
Definition: astobj2.c:160
#define ast_log
Definition: astobj2.c:42
#define INTERNAL_OBJ_RWLOCK(user_data)
Definition: astobj2.c:157
#define INTERNAL_OBJ(user_data)
Definition: astobj2.c:163
#define ao2_rdlock(a)
Definition: astobj2.h:718
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition: astobj2.h:367
@ AO2_ALLOC_OPT_LOCK_OBJ
Definition: astobj2.h:376
@ AO2_ALLOC_OPT_LOCK_RWLOCK
Definition: astobj2.h:365
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
@ AO2_ALLOC_OPT_LOCK_MASK
Definition: astobj2.h:369
#define ao2_wrlock(a)
Definition: astobj2.h:719
ao2_lock_req
Which lock to request.
Definition: astobj2.h:700
@ AO2_LOCK_REQ_MUTEX
Definition: astobj2.h:702
@ AO2_LOCK_REQ_WRLOCK
Definition: astobj2.h:706
@ AO2_LOCK_REQ_RDLOCK
Definition: astobj2.h:704
#define ao2_unlock(a)
Definition: astobj2.h:729
#define LOG_ERROR
uint32_t options
The ao2 object option flags.
Definition: astobj2.c:70
struct ao2_lockobj_priv lockobj
Definition: astobj2.c:145
void * user_data[0]
Definition: astobj2.c:147
struct ao2_rwlock_priv rwlock
Definition: astobj2.c:134
struct __priv_data priv_data
Definition: astobj2.c:105
void * user_data[0]
Definition: astobj2.c:106

References __adjust_lock(), AO2_ALLOC_OPT_LOCK_MASK, AO2_ALLOC_OPT_LOCK_MUTEX, AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_ALLOC_OPT_LOCK_OBJ, AO2_ALLOC_OPT_LOCK_RWLOCK, AO2_LOCK_REQ_MUTEX, AO2_LOCK_REQ_RDLOCK, AO2_LOCK_REQ_WRLOCK, ao2_rdlock, ao2_unlock, ao2_wrlock, ast_log, INTERNAL_OBJ, INTERNAL_OBJ_LOCKOBJ, INTERNAL_OBJ_RWLOCK, ao2_lockobj_priv::lock, astobj2_lockobj::lockobj, LOG_ERROR, ao2_rwlock_priv::num_lockers, __priv_data::options, astobj2::priv_data, astobj2_rwlock::rwlock, astobj2::user_data, and astobj2_lockobj::user_data.

Referenced by __adjust_lock(), __ao2_iterator_next(), __ao2_link(), __ao2_weakproxy_find(), ao2_iterator_restart(), hash_ao2_node_destructor(), internal_ao2_traverse(), and rb_ao2_node_destructor().

◆ internal_is_ao2_object()

int internal_is_ao2_object ( void *  user_data)

Definition at line 193 of file astobj2.c.

194{
195 struct astobj2 *p;
196
197 if (!user_data) {
198 return 0;
199 }
200
202
203 return !p || IS_AO2_MAGIC_BAD(p) ? 0 : 1;
204}
#define IS_AO2_MAGIC_BAD(p)
Definition: astobj2.c:98

References INTERNAL_OBJ, IS_AO2_MAGIC_BAD, and astobj2::user_data.

◆ log_bad_ao2()

void log_bad_ao2 ( void *  user_data,
const char *  file,
int  line,
const char *  func 
)

Definition at line 206 of file astobj2.c.

207{
208 struct astobj2 *p;
209 char bad_magic[100];
210
211 if (!user_data) {
212 __ast_assert_failed(0, "user_data is NULL", file, line, func);
213 return;
214 }
215
217 snprintf(bad_magic, sizeof(bad_magic), "bad magic number 0x%x for object %p",
219 __ast_assert_failed(0, bad_magic, file, line, func);
220}
uint32_t magic
Definition: astobj2.c:93
void DO_CRASH_NORETURN __ast_assert_failed(int condition, const char *condition_str, const char *file, int line, const char *function)
Definition: utils.c:2816

References __ast_assert_failed(), make_ari_stubs::file, INTERNAL_OBJ, __priv_data::magic, astobj2::priv_data, and astobj2::user_data.