]> rtime.felk.cvut.cz Git - orte.git/blob - orte/include/rtai/compat.h
OCERA SF CVS tree of ORTE framework updated to
[orte.git] / orte / include / rtai / compat.h
1 /*
2  *  $Id: compat.h,v 0.0.0.1             2004/11/14
3  *
4  *  AUTHOR: Jan Kiszka                  jan.kiszka@web.de
5  *
6  *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
7  *  --------------------------------------------------------------------
8  *
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.
13  *
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.
18  *
19  */
20
21 #ifndef _COMPAT_H
22 #define _COMPAT_H
23
24 #include <linux/if.h>
25 #include <linux/in.h>
26 #include <rtnet.h>
27 #include "rtai_posix.h.patched"
28 #include <defines.h>  //macro MALLOC
29
30
31
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
36 #define free        rt_free
37 #define bswap_16    swab16
38 #define bswap_32    swab32
39
40 typedef __u32 in_addr_t;
41
42 static inline in_addr_t inet_addr(const char *cp)
43 {
44     return rt_inet_aton(cp);
45 }
46
47
48 static char inet_ntoa_buf[16];
49
50 static inline char *inet_ntoa(struct in_addr in)
51 {
52     unsigned char *octet;
53
54     octet = (unsigned char *)&(in.s_addr);
55     sprintf(inet_ntoa_buf, "%u.%u.%u.%u", octet[0], octet[1], octet[2], octet[3]);
56
57     return inet_ntoa_buf;
58 }
59
60
61 #define CLOCK_REALTIME  0
62
63 static inline void clock_gettime(int dummy, struct timespec *time)
64 {
65     count2timespec(rt_get_time(), time);
66 }
67
68
69 static inline int atoi(const char* nptr)
70 {
71     return simple_strtol(nptr, (char **)NULL, 10);
72 }
73
74
75 static inline char *strdup(const char *s)
76 {
77     size_t len = strlen(s)+1;
78     char *new_s;
79
80     new_s = MALLOC(len);
81     if (new_s == NULL)
82         return NULL;
83
84     memcpy(new_s, s, len);
85     return new_s;
86 }
87
88
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
94
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
100
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
106
107 #define pthread_create              pthread_create_rt
108 #define pthread_join                pthread_join_rt
109 #define pthread_exit                pthread_exit_rt
110
111
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
121
122 #endif /* _COMPAT_H */