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.
21 #include "defines.h" //macro MALLOC
23 /* This should become a bit more generic for all platforms... */
24 #define rtl_printf rt_printk
25 #define printf rt_printk /* catch some probably forgotten printf's */
26 #define malloc rt_malloc
29 typedef __u32 in_addr_t;
31 static inline in_addr_t inet_addr(const char *cp)
33 return rt_inet_aton(cp);
37 static char inet_ntoa_buf[16];
39 static inline char *inet_ntoa(struct in_addr in)
43 octet = (unsigned char *)&(in.s_addr);
44 sprintf(inet_ntoa_buf, "%u.%u.%u.%u", octet[0], octet[1], octet[2], octet[3]);
50 #define CLOCK_REALTIME 0
52 static inline void clock_gettime(int dummy, struct timespec *time)
54 count2timespec(rt_get_time(), time);
58 static inline int atoi(const char* nptr)
60 return simple_strtol(nptr, (char **)NULL, 10);
64 static inline char *strdup(const char *s)
66 size_t len = strlen(s)+1;
73 memcpy(new_s, s, len);
77 #define pthread_rwlock_init pthread_rwlock_init_rt
78 #define pthread_rwlock_rdlock pthread_rwlock_rdlock_rt
79 #define pthread_rwlock_wrlock pthread_rwlock_wrlock_rt
80 #define pthread_rwlock_unlock pthread_rwlock_unlock_rt
81 #define pthread_rwlock_destroy pthread_rwlock_destroy_rt
83 #define pthread_mutex_init pthread_mutex_init_rt
84 #define pthread_mutex_lock pthread_mutex_lock_rt
85 #define pthread_mutex_timedlock pthread_mutex_timedlock_rt
86 #define pthread_mutex_unlock pthread_mutex_unlock_rt
87 #define pthread_mutex_destroy pthread_mutex_destroy_rt
89 #define pthread_create pthread_create_rt
90 #define pthread_join pthread_join_rt
91 #define pthread_exit pthread_exit_rt
94 #define socket rt_socket
95 #define close rt_socket_close
96 #define setsockopt rt_socket_setsockopt
97 #define getsockopt(a, b, c, d, e) -1
98 #define ioctl rt_socket_ioctl
99 #define bind rt_socket_bind
100 #define getsockname rt_socket_getsockname
101 #define recvfrom rt_socket_recvfrom
102 #define sendto rt_socket_sendto