void \
ovs_##TYPE##_##FUN##_at(const struct ovs_##TYPE *l_, \
const char *where) \
+ OVS_NO_THREAD_SAFETY_ANALYSIS \
{ \
struct ovs_##TYPE *l = CONST_CAST(struct ovs_##TYPE *, l_); \
int error = pthread_##TYPE##_##FUN(&l->lock); \
int \
ovs_##TYPE##_##FUN##_at(const struct ovs_##TYPE *l_, \
const char *where) \
+ OVS_NO_THREAD_SAFETY_ANALYSIS \
{ \
struct ovs_##TYPE *l = CONST_CAST(struct ovs_##TYPE *, l_); \
int error = pthread_##TYPE##_##FUN(&l->lock); \
#define UNLOCK_FUNCTION(TYPE, FUN) \
void \
ovs_##TYPE##_##FUN(const struct ovs_##TYPE *l_) \
+ OVS_NO_THREAD_SAFETY_ANALYSIS \
{ \
struct ovs_##TYPE *l = CONST_CAST(struct ovs_##TYPE *, l_); \
int error; \
{
return !must_not_fork;
}
+\f
+/* Returns the total number of cores on this system, or 0 if the number cannot
+ * be determined. */
+unsigned int
+count_cpu_cores(void)
+{
+ long int n_cores = sysconf(_SC_NPROCESSORS_ONLN);
+
+ return n_cores > 0 ? n_cores : 0;
+}
#endif