summaryrefslogtreecommitdiff
path: root/pjlib/src/pj
diff options
context:
space:
mode:
Diffstat (limited to 'pjlib/src/pj')
-rw-r--r--pjlib/src/pj/guid_simple.c10
-rw-r--r--pjlib/src/pj/os_core_unix.c14
2 files changed, 20 insertions, 4 deletions
diff --git a/pjlib/src/pj/guid_simple.c b/pjlib/src/pj/guid_simple.c
index 83870299..728d87e5 100644
--- a/pjlib/src/pj/guid_simple.c
+++ b/pjlib/src/pj/guid_simple.c
@@ -67,10 +67,12 @@ PJ_DEF(pj_str_t*) pj_generate_unique_string(pj_str_t *str)
pj_assert(PJ_GUID_STRING_LENGTH % 2 == 0);
for (p=str->ptr, end=p+PJ_GUID_STRING_LENGTH; p<end; ) {
- /* Assumes rand() only has 16bit randomness */
- unsigned short val = pj_rand();
- *p++ = guid_chars[(val >> 8) & 63];
- *p++ = guid_chars[(val & 0xFF) & 63];
+ pj_uint32_t rand_val = pj_rand();
+ pj_uint32_t rand_idx = RAND_MAX;
+
+ for ( ; rand_idx>0 && p<end; rand_idx>>=8, rand_val>>=8, p++) {
+ *p = guid_chars[(rand_val & 0xFF) & 63];
+ }
}
str->slen = PJ_GUID_STRING_LENGTH;
diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c
index 00094cf3..c46fbf09 100644
--- a/pjlib/src/pj/os_core_unix.c
+++ b/pjlib/src/pj/os_core_unix.c
@@ -308,7 +308,14 @@ PJ_DEF(int) pj_thread_get_prio_min(pj_thread_t *thread)
if (rc != 0)
return -1;
+#if defined _POSIX_PRIORITY_SCHEDULING
return sched_get_priority_min(policy);
+#elif defined __OpenBSD__
+ return 0;
+#else
+ pj_assert("pj_thread_get_prio_min() not supported!");
+ return 0;
+#endif
}
@@ -325,7 +332,14 @@ PJ_DEF(int) pj_thread_get_prio_max(pj_thread_t *thread)
if (rc != 0)
return -1;
+#if defined _POSIX_PRIORITY_SCHEDULING
return sched_get_priority_max(policy);
+#elif defined __OpenBSD__
+ return 31;
+#else
+ pj_assert("pj_thread_get_prio_max() not supported!");
+ return 0;
+#endif
}