source: vendor/gcc/current/libjava/include/posix.h

Last change on this file was 1391, checked in by bird, 21 years ago

GCC v3.3.3 sources.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.7 KB
Line 
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
7This software is copyrighted work licensed under the terms of the
8Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9details. */
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#define _Jv_platform_solib_suffix ".so"
46
47#ifndef DISABLE_JAVA_NET
48#include <java/net/InetAddress.h>
49#endif
50
51extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
52extern jlong _Jv_platform_gettimeofday ();
53extern void _Jv_platform_initialize (void);
54extern void _Jv_platform_initProperties (java::util::Properties*);
55
56inline void
57_Jv_platform_close_on_exec (jint fd)
58{
59 // Ignore errors.
60 ::fcntl (fd, F_SETFD, FD_CLOEXEC);
61}
62
63#undef fcntl
64
65#ifdef JV_HASH_SYNCHRONIZATION
66inline void
67_Jv_platform_usleep (unsigned long usecs)
68{
69 usleep (usecs);
70}
71#endif /* JV_HASH_SYNCHRONIZATION */
72
73#ifndef DISABLE_JAVA_NET
74
75#ifndef HAVE_SOCKLEN_T
76#define socklen_t int
77#endif
78
79static inline int
80_Jv_socket (int domain, int type, int protocol)
81{
82 return ::socket (domain, type, protocol);
83}
84
85#undef socket
86
87inline int
88_Jv_connect (jint fd, sockaddr *ptr, int len)
89{
90 return ::connect (fd, ptr, len);
91}
92
93#undef connect
94
95inline int
96_Jv_close (jint fd)
97{
98 return ::close (fd);
99}
100
101#undef close
102
103// Avoid macro definitions of bind from system headers, e.g. on
104// Solaris 7 with _XOPEN_SOURCE. FIXME
105inline int
106_Jv_bind (int fd, struct sockaddr *addr, int addrlen)
107{
108 return ::bind (fd, addr, addrlen);
109}
110
111#undef bind
112
113// Same problem with accept on Tru64 UNIX with _POSIX_PII_SOCKET
114inline int
115_Jv_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
116{
117 return ::accept (fd, addr, addrlen);
118}
119
120#undef accept
121
122inline int
123_Jv_listen (int fd, int backlog)
124{
125 return ::listen (fd, backlog);
126}
127
128#undef listen
129
130inline int
131_Jv_write(int s, void *buf, int len)
132{
133 return ::write (s, buf, len);
134}
135
136#undef write
137
138inline int
139_Jv_read(int s, void *buf, int len)
140{
141 return ::read (s, buf, len);
142}
143
144#undef read
145
146#endif /* DISABLE_JAVA_NET */
147
148#endif /* __JV_POSIX_H__ */
Note: See TracBrowser for help on using the repository browser.