]> gcc.gnu.org Git - gcc.git/blame - libjava/include/posix.h
win32.cc (_Jv_platform_nanotime): New function.
[gcc.git] / libjava / include / posix.h
CommitLineData
f536cd95
TT
1// posix.h -- Helper functions for POSIX-flavored OSs.
2
e59a1e40 3/* Copyright (C) 2000, 2002, 2003, 2006 Free Software Foundation
f536cd95
TT
4
5 This file is part of libgcj.
6
7This software is copyrighted work licensed under the terms of the
8Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9details. */
10
60678e47
BM
11#ifndef __JV_POSIX_H__
12#define __JV_POSIX_H__
13
60a78ccf
RO
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
f536cd95
TT
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
c3e0633c
MK
30#ifdef HAVE_SYS_SOCKET_H
31#include <sys/socket.h>
32#endif
33
f536cd95
TT
34#ifdef HAVE_UNISTD_H
35#include <unistd.h>
36#endif
37
0c1fcb02
TT
38#include <fcntl.h>
39
8eeda6e0 40#include <gcj/cni.h>
455cd615 41#include <java/util/Properties.h>
8eeda6e0 42
78bb0444
TT
43// Prefix and suffix for shared libraries.
44#define _Jv_platform_solib_prefix "lib"
4148df12 45#if defined(__APPLE__) && defined(__MACH__)
dcde9775
AT
46#define _Jv_platform_solib_suffix ".dylib"
47#else
78bb0444 48#define _Jv_platform_solib_suffix ".so"
dcde9775 49#endif
78bb0444 50
49c72d22
LR
51// Some POSIX systems don't have O_SYNC and O_DYSNC so we define them here.
52// Needed in java/io/natFileDescriptorPosix.cc.
53#if !defined (O_SYNC) && defined (O_FSYNC)
54#define O_SYNC O_FSYNC
55#endif
56#if !defined (O_DSYNC) && defined (O_FSYNC)
57#define O_DSYNC O_FSYNC
58#endif
248e983e
MK
59// If O_DSYNC is still not defined, use O_SYNC (needed for newlib)
60#if !defined (O_DSYNC)
61#define O_DSYNC O_SYNC
62#endif
49c72d22 63
2b7f1f8f
TT
64// Separator for file name components.
65#define _Jv_platform_file_separator ((jchar) '/')
66// Separator for path components.
67#define _Jv_platform_path_separator ((jchar) ':')
68
69// List of names for `JNI_OnLoad'.
70#define _Jv_platform_onload_names { "JNI_OnLoad", NULL }
71
72// Type of libffi ABI used by JNICALL methods. NOTE: This must agree
73// with the JNICALL definition in jni.h
74#define _Jv_platform_ffi_abi FFI_DEFAULT_ABI
75
d1bf262d
MK
76#ifndef DISABLE_JAVA_NET
77#include <java/net/InetAddress.h>
78#endif
79
f536cd95 80extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
8eeda6e0 81extern jlong _Jv_platform_gettimeofday ();
e59a1e40 82extern jlong _Jv_platform_nanotime ();
73272ce6 83extern void _Jv_platform_initialize (void);
455cd615 84extern void _Jv_platform_initProperties (java::util::Properties*);
8eeda6e0 85
c6d58c66
MK
86inline void
87_Jv_platform_close_on_exec (jint fd)
88{
89 // Ignore errors.
90 ::fcntl (fd, F_SETFD, FD_CLOEXEC);
91}
92
a191802c
RO
93#undef fcntl
94
6ec62897 95#ifdef JV_HASH_SYNCHRONIZATION
6b3517ea
RO
96#ifndef HAVE_USLEEP_DECL
97extern "C" int usleep (useconds_t useconds);
98#endif /* not HAVE_USLEEP_DECL */
99
35a94bdc
TT
100inline void
101_Jv_platform_usleep (unsigned long usecs)
102{
103 usleep (usecs);
104}
6ec62897 105#endif /* JV_HASH_SYNCHRONIZATION */
35a94bdc 106
d1bf262d
MK
107#ifndef DISABLE_JAVA_NET
108
32e098dd
AT
109#ifndef HAVE_SOCKLEN_T
110#define socklen_t int
111#endif
112
c3e0633c
MK
113static inline int
114_Jv_socket (int domain, int type, int protocol)
115{
116 return ::socket (domain, type, protocol);
117}
118
a191802c
RO
119#undef socket
120
c3e0633c
MK
121inline int
122_Jv_connect (jint fd, sockaddr *ptr, int len)
123{
124 return ::connect (fd, ptr, len);
125}
126
a191802c
RO
127#undef connect
128
c3e0633c
MK
129inline int
130_Jv_close (jint fd)
131{
132 return ::close (fd);
133}
134
a191802c
RO
135#undef close
136
c3e0633c
MK
137// Avoid macro definitions of bind from system headers, e.g. on
138// Solaris 7 with _XOPEN_SOURCE. FIXME
139inline int
140_Jv_bind (int fd, struct sockaddr *addr, int addrlen)
141{
142 return ::bind (fd, addr, addrlen);
143}
144
a191802c
RO
145#undef bind
146
c3e0633c
MK
147// Same problem with accept on Tru64 UNIX with _POSIX_PII_SOCKET
148inline int
149_Jv_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
150{
151 return ::accept (fd, addr, addrlen);
152}
153
a191802c
RO
154#undef accept
155
c3e0633c
MK
156inline int
157_Jv_listen (int fd, int backlog)
158{
159 return ::listen (fd, backlog);
160}
161
a191802c
RO
162#undef listen
163
c3e0633c
MK
164inline int
165_Jv_write(int s, void *buf, int len)
166{
167 return ::write (s, buf, len);
168}
169
a191802c
RO
170#undef write
171
c3e0633c
MK
172inline int
173_Jv_read(int s, void *buf, int len)
174{
175 return ::read (s, buf, len);
176}
e59ff7e9 177
a191802c
RO
178#undef read
179
e59ff7e9
MK
180#endif /* DISABLE_JAVA_NET */
181
ef050c9e
ME
182// Wraps ::pipe
183static inline int
184_Jv_pipe (int filedes[2])
185{
186 return ::pipe (filedes);
187}
188
e59ff7e9 189#endif /* __JV_POSIX_H__ */
This page took 0.631237 seconds and 5 git commands to generate.