2 * $Id: compat.h,v 0.0.0.1 2004/11/14
4 * -------------------------------------------------------------------
6 * Open Real-Time Ethernet
8 * Copyright (C) 2001-2006
9 * Department of Control Engineering FEE CTU Prague, Czech Republic
10 * http://dce.felk.cvut.cz
11 * http://www.ocera.org
13 * Author: Petr Smolik petr@smoliku.cz
14 * Author - this code: Jan Kiszka jan.kiszka@web.de
16 * Project Responsible: Zdenek Hanzalek
17 * --------------------------------------------------------------------
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
37 #include "rtai_posix.h.patched"
38 #include <defines.h> //macro MALLOC
40 /* This should become a bit more generic for all platforms... */
41 #define rtl_printf rt_printk
42 #define printf rt_printk /* catch some probably forgotten printf's */
43 #define malloc rt_malloc
46 typedef __u32 in_addr_t;
48 static inline in_addr_t inet_addr(const char *cp)
50 return rt_inet_aton(cp);
54 static char inet_ntoa_buf[16];
56 static inline char *inet_ntoa(struct in_addr in)
60 octet = (unsigned char *)&(in.s_addr);
61 sprintf(inet_ntoa_buf, "%u.%u.%u.%u", octet[0], octet[1], octet[2], octet[3]);
67 #define CLOCK_REALTIME 0
69 static inline void clock_gettime(int dummy, struct timespec *time)
71 count2timespec(rt_get_time(), time);
75 static inline int atoi(const char* nptr)
77 return simple_strtol(nptr, (char **)NULL, 10);
81 #define sem_init sem_init_rt
82 #define sem_destroy sem_destroy_rt
83 #define sem_timedwait sem_timedwait_rt
84 #define sem_post sem_post_rt
85 #define sem_getvalue sem_getvalue_rt
87 #define pthread_rwlock_init pthread_rwlock_init_rt
88 #define pthread_rwlock_rdlock pthread_rwlock_rdlock_rt
89 #define pthread_rwlock_wrlock pthread_rwlock_wrlock_rt
90 #define pthread_rwlock_unlock pthread_rwlock_unlock_rt
91 #define pthread_rwlock_destroy pthread_rwlock_destroy_rt
93 #define pthread_mutex_init pthread_mutex_init_rt
94 #define pthread_mutex_lock pthread_mutex_lock_rt
95 #define pthread_mutex_timedlock pthread_mutex_timedlock_rt
96 #define pthread_mutex_unlock pthread_mutex_unlock_rt
97 #define pthread_mutex_destroy pthread_mutex_destroy_rt
99 #define pthread_create pthread_create_rt
100 #define pthread_join pthread_join_rt
101 #define pthread_exit pthread_exit_rt
103 #define pthread_cond_init pthread_cond_init_rt
104 #define pthread_cond_timedwait pthread_cond_timedwait_rt
105 #define pthread_cond_signal pthread_cond_signal_rt
106 #define pthread_cond_destroy pthread_cond_destroy_rt
108 #define socket socket_rt
109 #define setsockopt setsockopt_rt
110 #define getsockopt getsockopt_rt
111 #define ioctl ioctl_rt
113 #define getsockname getsockname_rt
114 #define recvfrom recvfrom_rt
115 #define sendto sendto_rt
117 static inline int close(int s)
121 while ((result = close_rt(s)) == -EAGAIN)
122 rt_sleep(nano2count(100000000));
126 #endif /* _COMPAT_H */