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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
//===- LinuxCommon.h - Common Declarations For Linux ------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// Copyright (C) 2004 eXtensible Systems, Inc. All Rights Reserved.
//
// This program is open source software; you can redistribute it and/or modify
// it under the terms of the University of Illinois Open Source License. See
// LICENSE.TXT (distributed with this software) for details.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
//
//===----------------------------------------------------------------------===//
/// @file lib/System/linux/Common.h
/// @author Reid Spencer <rspencer@x10sys.com> (original author)
/// @version \verbatim $Id$ \endverbatim
/// @date 2004/08/14
/// @since 1.4
/// @brief Provides common linux specific declarations and includes.
//===----------------------------------------------------------------------===//
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/param.h>
#include <pthread.h>
#define FATAL(arg) \
{ llvm::sys::panic(LLVM_CONTEXT, arg); }
#define RETURN_ERRNO \
return ErrorCode(LLVM_ERROR_CODE(OSDomain,errno))
#define RETURN_OSERROR(code) \
return ErrorCode(LLVM_ERROR_CODE(OSDomain,code))
#ifdef assert
#define ASSERT_ARG(expr) \
if ( ! (expr) ) {\
return ErrorCode(ERR_SYS_INVALID_ARG);\
}
#else
#define ASSERT_ARG(expr)
#endif
#define CHECK(var,call,args,msg) \
{ \
if ( -1 == ( var = ::call args )) { \
panic(LLVM_CONTEXT, msg); \
} \
}
#define RETURN_ON_ERROR(call,args) \
{ \
errno = 0; \
if ( 0 > ( call args ) ) { \
RETURN_ERRNO; \
} \
}
#define RETURN_ON_ERRORCODE(call,args) \
{ \
ErrorCode code = call args ; \
if ( ! code ) \
return code; \
}
#define PTHREAD_CALL( call, args, cleanup ) \
{ \
int errcode = ::call args ; \
if ( errcode != 0 ) { \
cleanup ; \
RETURN_ERRNO ; \
} \
}
#define CLEANUP_CALL( call, args, cleanup ) \
{ \
int result = call args ; \
if ( result != 0 ) { \
cleanup ; \
RETURN_ERRNO ; \
} \
}
// Define our realtime signals
#define SIG_LOOP_TERMINATE ( SIGRTMIN + 3 )
#define SIG_USER_EVENT_1 ( SIGRTMIN + 4 )
#define SIG_USER_EVENT_2 ( SIGRTMIN + 5 )
#define SIG_USER_EVENT_3 ( SIGRTMIN + 6 )
#define SIG_USER_EVENT_4 ( SIGRTMIN + 7 )
#define SIG_USER_EVENT_5 ( SIGRTMIN + 8 )
#define SIG_USER_EVENT_6 ( SIGRTMIN + 9 )
#define SIG_USER_EVENT_7 ( SIGRTMIN + 10 )
#define SIG_USER_EVENT_8 ( SIGRTMIN + 11 )
#define SIG_AIO_1 ( SIGRTMIN + 12 )
#define SIG_AIO_2 ( SIGRTMIN + 13 )
#define SIG_AIO_3 ( SIGRTMIN + 14 )
#define SIG_AIO_4 ( SIGRTMIN + 15 )
#define SIG_AIO_5 ( SIGRTMIN + 16 )
#define SIG_AIO_6 ( SIGRTMIN + 17 )
#define SIG_AIO_7 ( SIGRTMIN + 18 )
#define SIG_AIO_8 ( SIGRTMIN + 19 )
namespace llvm {
namespace sys {
#if 0
inline void
time_t2TimeValue( time_t t, TimeValue &tv )
{
TimeValue::Seconds_Type seconds = t;
seconds -= TimeValue::posix_zero_time.seconds();
tv.set( seconds, 0 );
}
inline void
TimeValue2timespec( const TimeValue& tv, struct timespec & ts )
{
uint64_t seconds;
uint64_t nanos;
tv.timespec_time( seconds, nanos );
ts.tv_sec = static_cast<time_t>(seconds);
ts.tv_nsec = static_cast<long int>(nanos);
}
inline void
timeval2TimeValue( struct timeval& tval, TimeValue& tv )
{
TimeValue::Seconds_Type seconds = tval.tv_sec;
seconds -= TimeValue::posix_zero_time.seconds();
tv.set( seconds, tval.tv_usec * XPS_NANOSECONDS_PER_MICROSECOND );
}
extern pid_t pid_; ///< This processes' process identification number
extern int pagesize_; ///< The virtual memory page size of this machine
extern long arg_max_; ///< The maximum size in bytes of arguments to exec()
extern long child_max_; ///< The maximum processes per user.
extern long clk_tck_; ///< The number of clock ticks per second on this machine
extern long stream_max_; ///< The maximum number of streams that can be opened
extern long tzname_max_; ///< The maximum length of a timezone name
extern long file_max_; ///< The maximum number of files that can be opened
extern long line_max_; ///< The maximum length of an I/O line
extern long job_control_; ///< Non-zero if POSIX job control enabled
extern long saved_ids_; ///< ?
extern long phys_pages_; ///< Total number of physical pages
extern long avphys_pages_; ///< Average number of free physical pages
#endif
}
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
|