posix.h: Add suffix for darwin dynamic libraries.
[gcc.git] / libjava / include / posix.h
1 // posix.h -- Helper functions for POSIX-flavored OSs.
2
3 /* Copyright (C) 2000, 2002, 2003 Free Software Foundation
4
5 This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
10
11 #ifndef __JV_POSIX_H__
12 #define __JV_POSIX_H__
13
14 /* Required on Tru64 UNIX V4/V5 so <sys/socket.h> defines prototypes of
15 socket functions with socklen_t instead of size_t. This must be defined
16 early so <standards.h> defines the correct version of __PIIX. */
17 #define _POSIX_PII_SOCKET
18
19 #include <time.h>
20 #include <sys/types.h>
21
22 #ifdef HAVE_SYS_TIME_H
23 #include <sys/time.h>
24 #endif
25
26 #ifdef HAVE_SYS_SELECT_H
27 #include <sys/select.h>
28 #endif
29
30 #ifdef HAVE_SYS_SOCKET_H
31 #include <sys/socket.h>
32 #endif
33
34 #ifdef HAVE_UNISTD_H
35 #include <unistd.h>
36 #endif
37
38 #include <fcntl.h>
39
40 #include <gcj/cni.h>
41 #include <java/util/Properties.h>
42
43 // Prefix and suffix for shared libraries.
44 #define _Jv_platform_solib_prefix "lib"
45 #if defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
46 #define _Jv_platform_solib_suffix ".dylib"
47 #else
48 #define _Jv_platform_solib_suffix ".so"
49 #endif
50
51 // Separator for file name components.
52 #define _Jv_platform_file_separator ((jchar) '/')
53 // Separator for path components.
54 #define _Jv_platform_path_separator ((jchar) ':')
55
56 // List of names for `JNI_OnLoad'.
57 #define _Jv_platform_onload_names { "JNI_OnLoad", NULL }
58
59 // Type of libffi ABI used by JNICALL methods. NOTE: This must agree
60 // with the JNICALL definition in jni.h
61 #define _Jv_platform_ffi_abi FFI_DEFAULT_ABI
62
63 #ifndef DISABLE_JAVA_NET
64 #include <java/net/InetAddress.h>
65 #endif
66
67 extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
68 extern jlong _Jv_platform_gettimeofday ();
69 extern void _Jv_platform_initialize (void);
70 extern void _Jv_platform_initProperties (java::util::Properties*);
71
72 inline void
73 _Jv_platform_close_on_exec (jint fd)
74 {
75 // Ignore errors.
76 ::fcntl (fd, F_SETFD, FD_CLOEXEC);
77 }
78
79 #undef fcntl
80
81 #ifdef JV_HASH_SYNCHRONIZATION
82 inline void
83 _Jv_platform_usleep (unsigned long usecs)
84 {
85 usleep (usecs);
86 }
87 #endif /* JV_HASH_SYNCHRONIZATION */
88
89 #ifndef DISABLE_JAVA_NET
90
91 #ifndef HAVE_SOCKLEN_T
92 #define socklen_t int
93 #endif
94
95 static inline int
96 _Jv_socket (int domain, int type, int protocol)
97 {
98 return ::socket (domain, type, protocol);
99 }
100
101 #undef socket
102
103 inline int
104 _Jv_connect (jint fd, sockaddr *ptr, int len)
105 {
106 return ::connect (fd, ptr, len);
107 }
108
109 #undef connect
110
111 inline int
112 _Jv_close (jint fd)
113 {
114 return ::close (fd);
115 }
116
117 #undef close
118
119 // Avoid macro definitions of bind from system headers, e.g. on
120 // Solaris 7 with _XOPEN_SOURCE. FIXME
121 inline int
122 _Jv_bind (int fd, struct sockaddr *addr, int addrlen)
123 {
124 return ::bind (fd, addr, addrlen);
125 }
126
127 #undef bind
128
129 // Same problem with accept on Tru64 UNIX with _POSIX_PII_SOCKET
130 inline int
131 _Jv_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
132 {
133 return ::accept (fd, addr, addrlen);
134 }
135
136 #undef accept
137
138 inline int
139 _Jv_listen (int fd, int backlog)
140 {
141 return ::listen (fd, backlog);
142 }
143
144 #undef listen
145
146 inline int
147 _Jv_write(int s, void *buf, int len)
148 {
149 return ::write (s, buf, len);
150 }
151
152 #undef write
153
154 inline int
155 _Jv_read(int s, void *buf, int len)
156 {
157 return ::read (s, buf, len);
158 }
159
160 #undef read
161
162 #endif /* DISABLE_JAVA_NET */
163
164 #endif /* __JV_POSIX_H__ */