2 * $Id: compat.h,v 0.0.0.1 2004/11/14
4 * AUTHOR: Jan Kiszka jan.kiszka@web.de
6 * ORTE - OCERA Real-Time Ethernet http://www.ocera.org/
7 * --------------------------------------------------------------------
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
27 #include "rtai_posix.h.patched"
28 #include <defines.h> //macro MALLOC
32 /* This should become a bit more generic for all platforms... */
33 #define rtl_printf rt_printk
34 #define printf rt_printk /* catch some probably forgotten printf's */
35 #define malloc rt_malloc
37 #define bswap_16 swab16
38 #define bswap_32 swab32
40 typedef __u32 in_addr_t;
42 static inline in_addr_t inet_addr(const char *cp)
44 return rt_inet_aton(cp);
48 static char inet_ntoa_buf[16];
50 static inline char *inet_ntoa(struct in_addr in)
54 octet = (unsigned char *)&(in.s_addr);
55 sprintf(inet_ntoa_buf, "%u.%u.%u.%u", octet[0], octet[1], octet[2], octet[3]);
61 #define CLOCK_REALTIME 0
63 static inline void clock_gettime(int dummy, struct timespec *time)
65 count2timespec(rt_get_time(), time);
69 static inline int atoi(const char* nptr)
71 return simple_strtol(nptr, (char **)NULL, 10);
75 static inline char *strdup(const char *s)
77 size_t len = strlen(s)+1;
84 memcpy(new_s, s, len);
89 #define sem_init sem_init_rt
90 #define sem_destroy sem_destroy_rt
91 #define sem_timedwait sem_timedwait_rt
92 #define sem_post sem_post_rt
93 #define sem_getvalue sem_getvalue_rt
95 #define pthread_rwlock_init pthread_rwlock_init_rt
96 #define pthread_rwlock_rdlock pthread_rwlock_rdlock_rt
97 #define pthread_rwlock_wrlock pthread_rwlock_wrlock_rt
98 #define pthread_rwlock_unlock pthread_rwlock_unlock_rt
99 #define pthread_rwlock_destroy pthread_rwlock_destroy_rt
101 #define pthread_mutex_init pthread_mutex_init_rt
102 #define pthread_mutex_lock pthread_mutex_lock_rt
103 #define pthread_mutex_timedlock pthread_mutex_timedlock_rt
104 #define pthread_mutex_unlock pthread_mutex_unlock_rt
105 #define pthread_mutex_destroy pthread_mutex_destroy_rt
107 #define pthread_create pthread_create_rt
108 #define pthread_join pthread_join_rt
109 #define pthread_exit pthread_exit_rt
112 #define socket rt_socket
113 #define close rt_socket_close
114 #define setsockopt rt_socket_setsockopt
115 #define getsockopt(a, b, c, d, e) -1
116 #define ioctl rt_socket_ioctl
117 #define bind rt_socket_bind
118 #define getsockname rt_socket_getsockname
119 #define recvfrom rt_socket_recvfrom
120 #define sendto rt_socket_sendto
122 #endif /* _COMPAT_H */