summaryrefslogtreecommitdiff
path: root/ace/os_include/sys/os_resource.h
blob: dd289b10a7a03dc7853af87e55b121f920affc5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// -*- C++ -*-

//=============================================================================
/**
 *  @file    os_resource.h
 *
 *  definitions for XSI resource operations
 *
 *  $Id$
 *
 *  @author Don Hinton <dhinton@dresystems.com>
 *  @author This code was originally in various places including ace/OS.h.
 */
//=============================================================================

#ifndef ACE_OS_INCLUDE_SYS_OS_RESOURCE_H
#define ACE_OS_INCLUDE_SYS_OS_RESOURCE_H

#include /**/ "ace/pre.h"

#include "ace/config-lite.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/os_include/sys/os_time.h"
#include "ace/os_include/sys/os_types.h"

#if !defined (ACE_LACKS_SYS_RESOURCE_H)
#  include /**/ <sys/resource.h>
#endif /* !ACE_LACKS_SYS_RESOURCE_H */

#if defined (ACE_HAS_SYSINFO)
#  include /**/ <sys/systeminfo.h>
#endif /* ACE_HAS_SYS_INFO */

#if defined (ACE_HAS_SYS_SYSCALL_H)
#  include /**/ <sys/syscall.h>
#endif /* ACE_HAS_SYS_SYSCALL_H */

// prusage_t is defined in <sys/procfs.h>
#if defined (ACE_HAS_PROC_FS)
#  include /**/ <sys/procfs.h>
#endif  /* ACE_HAS_PROC_FS */

// Place all additions (especially function declarations) within extern "C" {}
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

// There must be a better way to do this...
#if !defined (RLIMIT_NOFILE)
#  if defined (linux) || defined (AIX) || defined (SCO)
#    if defined (RLIMIT_OFILE)
#      define RLIMIT_NOFILE RLIMIT_OFILE
#    else
#      define RLIMIT_NOFILE 200
#    endif /* RLIMIT_OFILE */
#  endif /* defined (linux) || defined (AIX) || defined (SCO) */
#endif /* RLIMIT_NOFILE */

#if defined (ACE_WIN32)
#  define RUSAGE_SELF 1
   /// Fake the UNIX rusage structure.  Perhaps we can add more to this
   /// later on?
   struct rusage
   {
     FILETIME ru_utime;
     FILETIME ru_stime;
   };
#else /* !ACE_WIN32 */
#   if defined (m88k)
#     define RUSAGE_SELF 1
#   endif  /*  m88k */
#endif /* ACE_WIN32 */

#if defined (ACE_LACKS_RLIMIT_PROTOTYPE)
  int getrlimit (int resource, struct rlimit *rlp);
  int setrlimit (int resource, const struct rlimit *rlp);
#endif /* ACE_LACKS_RLIMIT_PROTOTYPE */

#if defined (ACE_HAS_PRUSAGE_T)
   typedef prusage_t ACE_Rusage;
#elif defined (ACE_HAS_GETRUSAGE)
   typedef rusage ACE_Rusage;
#else
   typedef int ACE_Rusage;
#endif /* ACE_HAS_PRUSAGE_T */

#if !defined (ACE_WIN32)
// These prototypes are chronically lacking from many versions of
// UNIX.
# if !defined (ACE_HAS_GETRUSAGE_PROTOTYPE)
  int getrusage (int who, struct rusage *rusage);
# endif /* ! ACE_HAS_GETRUSAGE_PROTO */

# if defined (ACE_LACKS_SYSCALL)
  int syscall (int, ACE_HANDLE, struct rusage *);
# endif /* ACE_LACKS_SYSCALL */
#endif /* !ACE_WIN32 */

#ifdef __cplusplus
}
#endif /* __cplusplus */

#include /**/ "ace/post.h"
#endif /* ACE_OS_INCLUDE_SYS_OS_RESOURCE_H */