1 // posix.h -- Helper functions for POSIX-flavored OSs.
3 /* Copyright (C) 2000, 2002, 2003, 2006, 2010, 2012 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 #ifndef __JV_POSIX_H__
12 #define __JV_POSIX_H__
15 #include <sys/types.h>
17 #ifdef HAVE_SYS_TIME_H
21 #ifdef HAVE_SYS_SELECT_H
22 #include <sys/select.h>
25 #ifdef HAVE_SYS_SOCKET_H
26 #include <sys/socket.h>
35 /* The header file <sys/rw_lock.h> needs to be included before javaprims.h
36 on HP-UX 11 to avoid a compilation error. */
37 #ifdef HAVE_SYS_RW_LOCK_H
38 #include <sys/rw_lock.h>
42 #include <java/util/Properties.h>
44 // Prefix and suffix for shared libraries.
45 #define _Jv_platform_solib_prefix "lib"
46 #if defined(__APPLE__) && defined(__MACH__)
47 #define _Jv_platform_solib_suffix ".dylib"
48 #elif defined(HPUX) && defined(HP_PA)
49 #define _Jv_platform_solib_suffix ".sl"
51 #define _Jv_platform_solib_suffix ".so"
54 #if __MACH__ && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060)
55 # undef _Unwind_FindEnclosingFunction
56 # define _Unwind_FindEnclosingFunction(PC) _darwin10_Unwind_FindEnclosingFunction(PC)
59 // Some POSIX systems don't have O_SYNC and O_DYSNC so we define them here.
60 // Needed in java/io/natFileDescriptorPosix.cc.
61 #if !defined (O_SYNC) && defined (O_FSYNC)
62 #define O_SYNC O_FSYNC
64 #if !defined (O_DSYNC) && defined (O_FSYNC)
65 #define O_DSYNC O_FSYNC
67 // If O_DSYNC is still not defined, use O_SYNC (needed for newlib)
68 #if !defined (O_DSYNC)
69 #define O_DSYNC O_SYNC
72 // Name of the Process implementation.
74 #define _Jv_platform_process ::java::lang::EcosProcess
76 #define _Jv_platform_process ::java::lang::PosixProcess
79 // Separator for file name components.
80 #define _Jv_platform_file_separator ((jchar) '/')
81 // Separator for path components.
82 #define _Jv_platform_path_separator ((jchar) ':')
84 // List of names for `JNI_OnLoad'.
85 #define _Jv_platform_onload_names { "JNI_OnLoad", NULL }
87 // Type of libffi ABI used by JNICALL methods. NOTE: This must agree
88 // with the JNICALL definition in jni.h
89 #define _Jv_platform_ffi_abi FFI_DEFAULT_ABI
91 #ifndef DISABLE_JAVA_NET
92 #include <java/net/InetAddress.h>
95 extern int _Jv_select (int n
, fd_set
*, fd_set
*, fd_set
*, struct timeval
*);
96 extern jlong
_Jv_platform_gettimeofday ();
97 extern jlong
_Jv_platform_nanotime ();
98 extern void _Jv_platform_initialize (void);
99 extern void _Jv_platform_initProperties (java::util::Properties
*);
101 #ifdef JV_HASH_SYNCHRONIZATION
102 #ifndef HAVE_USLEEP_DECL
103 extern "C" int usleep (useconds_t useconds
);
104 #endif /* not HAVE_USLEEP_DECL */
107 _Jv_platform_usleep (unsigned long usecs
)
111 #endif /* JV_HASH_SYNCHRONIZATION */
113 #ifndef DISABLE_JAVA_NET
115 #ifndef HAVE_SOCKLEN_T
116 #define socklen_t int
120 _Jv_socket (int domain
, int type
, int protocol
)
122 return ::socket (domain
, type
, protocol
);
128 _Jv_connect (jint fd
, sockaddr
*ptr
, int len
)
130 return ::connect (fd
, ptr
, len
);
143 // Avoid macro definitions of bind from system headers, e.g. on
144 // Solaris 7 with _XOPEN_SOURCE. FIXME
146 _Jv_bind (int fd
, struct sockaddr
*addr
, int addrlen
)
148 return ::bind (fd
, addr
, addrlen
);
154 _Jv_listen (int fd
, int backlog
)
156 return ::listen (fd
, backlog
);
162 _Jv_write(int s
, void *buf
, int len
)
164 return ::write (s
, buf
, len
);
170 _Jv_read(int s
, void *buf
, int len
)
172 return ::read (s
, buf
, len
);
177 #endif /* DISABLE_JAVA_NET */
181 _Jv_pipe (int filedes
[2])
183 return ::pipe (filedes
);
186 // Forward declaration. See java-stack.h for definition.
189 // Given an address, determine the executable or shared object that defines
190 // it and the nearest named symbol.
191 extern int _Jv_platform_dladdr (void *addr
, _Jv_AddrInfo
*info
);
193 #endif /* __JV_POSIX_H__ */