[svn-commits] fjoe: freebsd/trunk r8287 - in /freebsd/trunk: freebsd/dahdi/ include/dahdi/c...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Mar 8 13:35:28 CST 2010
Author: fjoe
Date: Mon Mar 8 13:35:25 2010
New Revision: 8287
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8287
Log:
More Linux compat schemes:
- More uXX fixed width integer types
- cpu_to_le32/le32_to_cpu()
- struct completion
- struct semaphore
- time_before()
Modified:
freebsd/trunk/freebsd/dahdi/bsd-compat.c
freebsd/trunk/include/dahdi/compat/bsd.h
freebsd/trunk/include/dahdi/compat/types.h
Modified: freebsd/trunk/freebsd/dahdi/bsd-compat.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/dahdi/bsd-compat.c?view=diff&rev=8287&r1=8286&r2=8287
==============================================================================
--- freebsd/trunk/freebsd/dahdi/bsd-compat.c (original)
+++ freebsd/trunk/freebsd/dahdi/bsd-compat.c Mon Mar 8 13:35:25 2010
@@ -135,6 +135,65 @@
}
void
+init_completion(struct completion *c)
+{
+ cv_init(&c->cv, "DAHDI completion cv");
+ mtx_init(&c->lock, "DAHDI completion lock", "condvar", MTX_DEF);
+}
+
+void
+destroy_completion(struct completion *c)
+{
+ cv_destroy(&c->cv);
+ mtx_destroy(&c->lock);
+}
+
+int
+wait_for_completion_timeout(struct completion *c, unsigned long timeout)
+{
+ int res;
+
+ mtx_lock(&c->lock);
+ res = cv_timedwait(&c->cv, &c->lock, timeout);
+ mtx_unlock(&c->lock);
+ if (res == 0)
+ return 1;
+
+ /* Signal timeout */
+ return 0;
+}
+
+void
+complete(struct completion *c)
+{
+ cv_signal(&c->cv);
+}
+
+void
+_sema_init(struct semaphore *s, int value)
+{
+ sema_init(&s->sema, value, "DAHDI semaphore");
+}
+
+void
+_sema_destroy(struct semaphore *s)
+{
+ sema_destroy(&s->sema);
+}
+
+void
+down_interruptible(struct semaphore *s)
+{
+ sema_wait(&s->sema);
+}
+
+void
+up(struct semaphore *s)
+{
+ sema_post(&s->sema);
+}
+
+void
rlprintf(int pps, const char *fmt, ...)
{
va_list ap;
Modified: freebsd/trunk/include/dahdi/compat/bsd.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/compat/bsd.h?view=diff&rev=8287&r1=8286&r2=8287
==============================================================================
--- freebsd/trunk/include/dahdi/compat/bsd.h (original)
+++ freebsd/trunk/include/dahdi/compat/bsd.h Mon Mar 8 13:35:25 2010
@@ -2,9 +2,12 @@
#define _DAHDI_COMPAT_BSD_H_
#include <sys/callout.h>
+#include <sys/condvar.h>
+#include <sys/endian.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
+#include <sys/sema.h>
#include <sys/sx.h>
#include <sys/taskqueue.h>
#include <machine/atomic.h>
@@ -15,6 +18,9 @@
#define LINUX_VERSION_CODE -1
#define KERNEL_VERSION(x, y, z) 0
+
+#define cpu_to_le32(x) htole32(x)
+#define le32_to_cpu(x) le32toh(x)
#define copy_from_user(to, from, n) (bcopy((from), (to), (n)), 0)
#define copy_to_user(to, from, n) (bcopy((from), (to), (n)), 0)
@@ -137,6 +143,26 @@
void del_timer(struct timer_list *t);
void del_timer_sync(struct timer_list *t);
+struct completion {
+ struct cv cv;
+ struct mtx lock;
+};
+
+#define INIT_COMPLETION(c)
+void init_completion(struct completion *c);
+void destroy_completion(struct completion *c);
+int wait_for_completion_timeout(struct completion *c, unsigned long timeout);
+void complete(struct completion *c);
+
+struct semaphore {
+ struct sema sema;
+};
+
+void _sema_init(struct semaphore *s, int value);
+void _sema_destroy(struct semaphore *s);
+void down_interruptible(struct semaphore *s);
+void up(struct semaphore *s);
+
void rlprintf(int pps, const char *fmt, ...)
__printflike(2, 3);
@@ -225,6 +251,7 @@
#define udelay(usec) DELAY(usec)
#define mdelay(msec) DELAY((msec) * 1000)
+
#if defined(msleep)
#undef msleep
#endif
@@ -232,6 +259,7 @@
#define time_after(a, b) ((a) > (b))
#define time_after_eq(a, b) ((a) >= (b))
+#define time_before(a, b) ((a) < (b))
#define try_module_get(m) (1)
#define module_put(m) ((void) (m))
Modified: freebsd/trunk/include/dahdi/compat/types.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/compat/types.h?view=diff&rev=8287&r1=8286&r2=8287
==============================================================================
--- freebsd/trunk/include/dahdi/compat/types.h (original)
+++ freebsd/trunk/include/dahdi/compat/types.h Mon Mar 8 13:35:25 2010
@@ -4,8 +4,15 @@
#include <sys/types.h>
typedef uint8_t __u8;
+typedef uint8_t u8;
+typedef uint16_t __u16;
+typedef uint16_t u16;
+
typedef int32_t __s32;
typedef uint32_t __u32;
typedef uint32_t u32;
+typedef int16_t __le16;
+typedef int32_t __le32;
+
#endif /* _DAHDI_COMPAT_TYPES_H_ */
More information about the svn-commits
mailing list