]> rtime.felk.cvut.cz Git - orte.git/blob - orte/include/rtai/compat.h
Update of ORTE. Configured to compile for Linux out of box.
[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 #include "defines.h"  //macro MALLOC
22
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
27 #define free        rt_free
28
29 typedef __u32 in_addr_t;
30
31 static inline in_addr_t inet_addr(const char *cp)
32 {
33     return rt_inet_aton(cp);
34 }
35
36
37 static char inet_ntoa_buf[16];
38
39 static inline char *inet_ntoa(struct in_addr in)
40 {
41     unsigned char *octet;
42
43     octet = (unsigned char *)&(in.s_addr);
44     sprintf(inet_ntoa_buf, "%u.%u.%u.%u", octet[0], octet[1], octet[2], octet[3]);
45
46     return inet_ntoa_buf;
47 }
48
49
50 #define CLOCK_REALTIME  0
51
52 static inline void clock_gettime(int dummy, struct timespec *time)
53 {
54     count2timespec(rt_get_time(), time);
55 }
56
57
58 static inline int atoi(const char* nptr)
59 {
60     return simple_strtol(nptr, (char **)NULL, 10);
61 }
62
63
64 static inline char *strdup(const char *s)
65 {
66     size_t len = strlen(s)+1;
67     char *new_s;
68
69     new_s = MALLOC(len);
70     if (new_s == NULL)
71         return NULL;
72
73     memcpy(new_s, s, len);
74     return new_s;
75 }
76
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
82
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
88
89 #define pthread_create              pthread_create_rt
90 #define pthread_join                pthread_join_rt
91 #define pthread_exit                pthread_exit_rt
92
93
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