diff options
author | Benny Prijono <bennylp@teluu.com> | 2005-11-09 15:37:19 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2005-11-09 15:37:19 +0000 |
commit | 6e1024262b48b57b771331b8c19e988e43627bd7 (patch) | |
tree | a43fdaeb6d7b22cc7afab1633622bf55d39dfd67 /pjlib/src/pj/os_core_win32.c | |
parent | fb9e3b3a6649cc5cbe0c6747cb1918f3be71ba06 (diff) |
Rework pjlib++
git-svn-id: http://svn.pjsip.org/repos/pjproject/main@36 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/os_core_win32.c')
-rw-r--r-- | pjlib/src/pj/os_core_win32.c | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/pjlib/src/pj/os_core_win32.c b/pjlib/src/pj/os_core_win32.c index 68416c66..be770d56 100644 --- a/pjlib/src/pj/os_core_win32.c +++ b/pjlib/src/pj/os_core_win32.c @@ -512,32 +512,48 @@ PJ_DEF(pj_atomic_value_t) pj_atomic_get(pj_atomic_t *atomic_var) return atomic_var->value; } +/*
+ * pj_atomic_inc_and_get()
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_inc_and_get(pj_atomic_t *atomic_var)
+{
+ PJ_CHECK_STACK();
+
+#if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400
+ return InterlockedIncrement(&atomic_var->value);
+#else
+# error Fix Me
+#endif
+}
+
/* * pj_atomic_inc() */ PJ_DEF(void) pj_atomic_inc(pj_atomic_t *atomic_var) -{ - PJ_CHECK_STACK(); - -#if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400 - InterlockedIncrement(&atomic_var->value); -#else -# error Fix Me -#endif +{
+ pj_atomic_inc_and_get(atomic_var); } - +
+/*
+ * pj_atomic_dec_and_get()
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_dec_and_get(pj_atomic_t *atomic_var)
+{
+ PJ_CHECK_STACK();
+
+#if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400
+ return InterlockedDecrement(&atomic_var->value);
+#else
+# error Fix me
+#endif
+}
+
/* * pj_atomic_dec() */ PJ_DEF(void) pj_atomic_dec(pj_atomic_t *atomic_var) { - PJ_CHECK_STACK(); - -#if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400 - InterlockedDecrement(&atomic_var->value); -#else -# error Fix me -#endif + pj_atomic_dec_and_get(atomic_var); } /* @@ -546,10 +562,27 @@ PJ_DEF(void) pj_atomic_dec(pj_atomic_t *atomic_var) PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var, pj_atomic_value_t value ) { - InterlockedExchangeAdd( &atomic_var->value, value ); +#if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400
+ InterlockedExchangeAdd( &atomic_var->value, value );
+#else
+# error Fix me
+#endif +} +
+/*
+ * pj_atomic_add_and_get()
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var,
+ pj_atomic_value_t value)
+{
+#if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400
+ long oldValue = InterlockedExchangeAdd( &atomic_var->value, value);
+ return oldValue + value;
+#else
+# error Fix me
+#endif
} - /////////////////////////////////////////////////////////////////////////////// /* * pj_thread_local_alloc() |