Initial commit
This commit is contained in:
commit
25b96c28cf
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
/Cargo.lock
|
3
AUTHORS
Normal file
3
AUTHORS
Normal file
|
@ -0,0 +1,3 @@
|
|||
This software was written by the following people:
|
||||
|
||||
Keegan McAllister <kmcallister@mozilla.com>
|
8
COPYRIGHT
Normal file
8
COPYRIGHT
Normal file
|
@ -0,0 +1,8 @@
|
|||
This project is copyright 2014, The syscall.rs Project Developers (given in
|
||||
the file AUTHORS).
|
||||
|
||||
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
|
||||
http://opensource.org/licenses/MIT>, at your option. All files in the project
|
||||
carrying such notice may not be copied, modified, or distributed except
|
||||
according to those terms.
|
5
Cargo.toml
Normal file
5
Cargo.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
[package]
|
||||
|
||||
name = "syscall"
|
||||
version = "0.0.1"
|
||||
authors = [ "The syscall.rs Project Developers" ]
|
201
LICENSE-APACHE
Normal file
201
LICENSE-APACHE
Normal file
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
25
LICENSE-MIT
Normal file
25
LICENSE-MIT
Normal file
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2014 The syscall.rs Project Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
7
README.md
Normal file
7
README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Raw system calls for Rust
|
||||
|
||||
This library allows Rust code to invoke system calls directly.
|
||||
|
||||
It currently only supports x86-64 Linux, but more platforms can be added.
|
||||
|
||||
We do not intend to provide wrapper functions like `read(2)` etc. because there are many subtly different ways to define them in Rust.
|
30
src/lib.rs
Normal file
30
src/lib.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2014 The syscall.rs Project Developers. See the
|
||||
// COPYRIGHT file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Raw system calls for Rust.
|
||||
|
||||
#![crate_name="syscall"]
|
||||
#![crate_type="lib"]
|
||||
|
||||
#![feature(macro_rules, asm, globs)]
|
||||
#![no_std]
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate std;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate native;
|
||||
|
||||
pub use platform::*;
|
||||
|
||||
pub mod macros;
|
||||
|
||||
#[cfg(target_os="linux", target_arch="x86_64")]
|
||||
#[path="platform/linux-x86_64/mod.rs"]
|
||||
pub mod platform;
|
49
src/macros.rs
Normal file
49
src/macros.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! syscall(
|
||||
($nr:ident)
|
||||
=> ( ::syscall::syscall0(
|
||||
::syscall::nr::$nr) );
|
||||
|
||||
($nr:ident, $a1:expr)
|
||||
=> ( ::syscall::syscall1(
|
||||
::syscall::nr::$nr,
|
||||
$a1 as uint) );
|
||||
|
||||
($nr:ident, $a1:expr, $a2:expr)
|
||||
=> ( ::syscall::syscall2(
|
||||
::syscall::nr::$nr,
|
||||
$a1 as uint, $a2 as uint) );
|
||||
|
||||
($nr:ident, $a1:expr, $a2:expr, $a3:expr)
|
||||
=> ( ::syscall::syscall3(
|
||||
::syscall::nr::$nr,
|
||||
$a1 as uint, $a2 as uint, $a3 as uint) );
|
||||
|
||||
($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr)
|
||||
=> ( ::syscall::syscall4(
|
||||
::syscall::nr::$nr,
|
||||
$a1 as uint, $a2 as uint, $a3 as uint,
|
||||
$a4 as uint) );
|
||||
|
||||
($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr)
|
||||
=> ( ::syscall::syscall5(
|
||||
::syscall::nr::$nr,
|
||||
$a1 as uint, $a2 as uint, $a3 as uint,
|
||||
$a4 as uint, $a5 as uint) );
|
||||
|
||||
($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr)
|
||||
=> ( ::syscall::syscall6(
|
||||
::syscall::nr::$nr,
|
||||
$a1 as uint, $a2 as uint, $a3 as uint,
|
||||
$a4 as uint, $a5 as uint, $a6 as uint) );
|
||||
)
|
88
src/platform/linux-x86_64/mod.rs
Normal file
88
src/platform/linux-x86_64/mod.rs
Normal file
|
@ -0,0 +1,88 @@
|
|||
// Copyright 2014 The syscall.rs Project Developers. See the
|
||||
// COPYRIGHT file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! This library was built for x86-64 Linux.
|
||||
|
||||
pub mod nr;
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn syscall0(n: uint) -> uint {
|
||||
let mut ret : uint;
|
||||
asm!("syscall" : "={rax}"(ret)
|
||||
: "{rax}"(n)
|
||||
: "rcx", "r11", "memory"
|
||||
: "volatile");
|
||||
ret
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn syscall1(n: uint, a1: uint) -> uint {
|
||||
let mut ret : uint;
|
||||
asm!("syscall" : "={rax}"(ret)
|
||||
: "{rax}"(n), "{rdi}"(a1)
|
||||
: "rcx", "r11", "memory"
|
||||
: "volatile");
|
||||
ret
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn syscall2(n: uint, a1: uint, a2: uint) -> uint {
|
||||
let mut ret : uint;
|
||||
asm!("syscall" : "={rax}"(ret)
|
||||
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2)
|
||||
: "rcx", "r11", "memory"
|
||||
: "volatile");
|
||||
ret
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn syscall3(n: uint, a1: uint, a2: uint, a3: uint) -> uint {
|
||||
let mut ret : uint;
|
||||
asm!("syscall" : "={rax}"(ret)
|
||||
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3)
|
||||
: "rcx", "r11", "memory"
|
||||
: "volatile");
|
||||
ret
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn syscall4(n: uint, a1: uint, a2: uint, a3: uint,
|
||||
a4: uint) -> uint {
|
||||
let mut ret : uint;
|
||||
asm!("syscall" : "={rax}"(ret)
|
||||
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
|
||||
"{r10}"(a4)
|
||||
: "rcx", "r11", "memory"
|
||||
: "volatile");
|
||||
ret
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn syscall5(n: uint, a1: uint, a2: uint, a3: uint,
|
||||
a4: uint, a5: uint) -> uint {
|
||||
let mut ret : uint;
|
||||
asm!("syscall" : "={rax}"(ret)
|
||||
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
|
||||
"{r10}"(a4), "{r8}"(a5)
|
||||
: "rcx", "r11", "memory"
|
||||
: "volatile");
|
||||
ret
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn syscall6(n: uint, a1: uint, a2: uint, a3: uint,
|
||||
a4: uint, a5: uint, a6: uint) -> uint {
|
||||
let mut ret : uint;
|
||||
asm!("syscall" : "={rax}"(ret)
|
||||
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
|
||||
"{r10}"(a4), "{r8}"(a5), "{r9}"(a6)
|
||||
: "rcx", "r11", "memory"
|
||||
: "volatile");
|
||||
ret
|
||||
}
|
327
src/platform/linux-x86_64/nr.rs
Normal file
327
src/platform/linux-x86_64/nr.rs
Normal file
|
@ -0,0 +1,327 @@
|
|||
// Copyright 2014 The syscall.rs Project Developers. See the
|
||||
// COPYRIGHT file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! System call numbers for x86-64 Linux.
|
||||
|
||||
pub static READ : uint = 0;
|
||||
pub static WRITE : uint = 1;
|
||||
pub static OPEN : uint = 2;
|
||||
pub static CLOSE : uint = 3;
|
||||
pub static STAT : uint = 4;
|
||||
pub static FSTAT : uint = 5;
|
||||
pub static LSTAT : uint = 6;
|
||||
pub static POLL : uint = 7;
|
||||
pub static LSEEK : uint = 8;
|
||||
pub static MMAP : uint = 9;
|
||||
pub static MPROTECT : uint = 10;
|
||||
pub static MUNMAP : uint = 11;
|
||||
pub static BRK : uint = 12;
|
||||
pub static RT_SIGACTION : uint = 13;
|
||||
pub static RT_SIGPROCMASK : uint = 14;
|
||||
pub static RT_SIGRETURN : uint = 15;
|
||||
pub static IOCTL : uint = 16;
|
||||
pub static PREAD64 : uint = 17;
|
||||
pub static PWRITE64 : uint = 18;
|
||||
pub static READV : uint = 19;
|
||||
pub static WRITEV : uint = 20;
|
||||
pub static ACCESS : uint = 21;
|
||||
pub static PIPE : uint = 22;
|
||||
pub static SELECT : uint = 23;
|
||||
pub static SCHED_YIELD : uint = 24;
|
||||
pub static MREMAP : uint = 25;
|
||||
pub static MSYNC : uint = 26;
|
||||
pub static MINCORE : uint = 27;
|
||||
pub static MADVISE : uint = 28;
|
||||
pub static SHMGET : uint = 29;
|
||||
pub static SHMAT : uint = 30;
|
||||
pub static SHMCTL : uint = 31;
|
||||
pub static DUP : uint = 32;
|
||||
pub static DUP2 : uint = 33;
|
||||
pub static PAUSE : uint = 34;
|
||||
pub static NANOSLEEP : uint = 35;
|
||||
pub static GETITIMER : uint = 36;
|
||||
pub static ALARM : uint = 37;
|
||||
pub static SETITIMER : uint = 38;
|
||||
pub static GETPID : uint = 39;
|
||||
pub static SENDFILE : uint = 40;
|
||||
pub static SOCKET : uint = 41;
|
||||
pub static CONNECT : uint = 42;
|
||||
pub static ACCEPT : uint = 43;
|
||||
pub static SENDTO : uint = 44;
|
||||
pub static RECVFROM : uint = 45;
|
||||
pub static SENDMSG : uint = 46;
|
||||
pub static RECVMSG : uint = 47;
|
||||
pub static SHUTDOWN : uint = 48;
|
||||
pub static BIND : uint = 49;
|
||||
pub static LISTEN : uint = 50;
|
||||
pub static GETSOCKNAME : uint = 51;
|
||||
pub static GETPEERNAME : uint = 52;
|
||||
pub static SOCKETPAIR : uint = 53;
|
||||
pub static SETSOCKOPT : uint = 54;
|
||||
pub static GETSOCKOPT : uint = 55;
|
||||
pub static CLONE : uint = 56;
|
||||
pub static FORK : uint = 57;
|
||||
pub static VFORK : uint = 58;
|
||||
pub static EXECVE : uint = 59;
|
||||
pub static EXIT : uint = 60;
|
||||
pub static WAIT4 : uint = 61;
|
||||
pub static KILL : uint = 62;
|
||||
pub static UNAME : uint = 63;
|
||||
pub static SEMGET : uint = 64;
|
||||
pub static SEMOP : uint = 65;
|
||||
pub static SEMCTL : uint = 66;
|
||||
pub static SHMDT : uint = 67;
|
||||
pub static MSGGET : uint = 68;
|
||||
pub static MSGSND : uint = 69;
|
||||
pub static MSGRCV : uint = 70;
|
||||
pub static MSGCTL : uint = 71;
|
||||
pub static FCNTL : uint = 72;
|
||||
pub static FLOCK : uint = 73;
|
||||
pub static FSYNC : uint = 74;
|
||||
pub static FDATASYNC : uint = 75;
|
||||
pub static TRUNCATE : uint = 76;
|
||||
pub static FTRUNCATE : uint = 77;
|
||||
pub static GETDENTS : uint = 78;
|
||||
pub static GETCWD : uint = 79;
|
||||
pub static CHDIR : uint = 80;
|
||||
pub static FCHDIR : uint = 81;
|
||||
pub static RENAME : uint = 82;
|
||||
pub static MKDIR : uint = 83;
|
||||
pub static RMDIR : uint = 84;
|
||||
pub static CREAT : uint = 85;
|
||||
pub static LINK : uint = 86;
|
||||
pub static UNLINK : uint = 87;
|
||||
pub static SYMLINK : uint = 88;
|
||||
pub static READLINK : uint = 89;
|
||||
pub static CHMOD : uint = 90;
|
||||
pub static FCHMOD : uint = 91;
|
||||
pub static CHOWN : uint = 92;
|
||||
pub static FCHOWN : uint = 93;
|
||||
pub static LCHOWN : uint = 94;
|
||||
pub static UMASK : uint = 95;
|
||||
pub static GETTIMEOFDAY : uint = 96;
|
||||
pub static GETRLIMIT : uint = 97;
|
||||
pub static GETRUSAGE : uint = 98;
|
||||
pub static SYSINFO : uint = 99;
|
||||
pub static TIMES : uint = 100;
|
||||
pub static PTRACE : uint = 101;
|
||||
pub static GETUID : uint = 102;
|
||||
pub static SYSLOG : uint = 103;
|
||||
pub static GETGID : uint = 104;
|
||||
pub static SETUID : uint = 105;
|
||||
pub static SETGID : uint = 106;
|
||||
pub static GETEUID : uint = 107;
|
||||
pub static GETEGID : uint = 108;
|
||||
pub static SETPGID : uint = 109;
|
||||
pub static GETPPID : uint = 110;
|
||||
pub static GETPGRP : uint = 111;
|
||||
pub static SETSID : uint = 112;
|
||||
pub static SETREUID : uint = 113;
|
||||
pub static SETREGID : uint = 114;
|
||||
pub static GETGROUPS : uint = 115;
|
||||
pub static SETGROUPS : uint = 116;
|
||||
pub static SETRESUID : uint = 117;
|
||||
pub static GETRESUID : uint = 118;
|
||||
pub static SETRESGID : uint = 119;
|
||||
pub static GETRESGID : uint = 120;
|
||||
pub static GETPGID : uint = 121;
|
||||
pub static SETFSUID : uint = 122;
|
||||
pub static SETFSGID : uint = 123;
|
||||
pub static GETSID : uint = 124;
|
||||
pub static CAPGET : uint = 125;
|
||||
pub static CAPSET : uint = 126;
|
||||
pub static RT_SIGPENDING : uint = 127;
|
||||
pub static RT_SIGTIMEDWAIT : uint = 128;
|
||||
pub static RT_SIGQUEUEINFO : uint = 129;
|
||||
pub static RT_SIGSUSPEND : uint = 130;
|
||||
pub static SIGALTSTACK : uint = 131;
|
||||
pub static UTIME : uint = 132;
|
||||
pub static MKNOD : uint = 133;
|
||||
pub static USELIB : uint = 134;
|
||||
pub static PERSONALITY : uint = 135;
|
||||
pub static USTAT : uint = 136;
|
||||
pub static STATFS : uint = 137;
|
||||
pub static FSTATFS : uint = 138;
|
||||
pub static SYSFS : uint = 139;
|
||||
pub static GETPRIORITY : uint = 140;
|
||||
pub static SETPRIORITY : uint = 141;
|
||||
pub static SCHED_SETPARAM : uint = 142;
|
||||
pub static SCHED_GETPARAM : uint = 143;
|
||||
pub static SCHED_SETSCHEDULER : uint = 144;
|
||||
pub static SCHED_GETSCHEDULER : uint = 145;
|
||||
pub static SCHED_GET_PRIORITY_MAX : uint = 146;
|
||||
pub static SCHED_GET_PRIORITY_MIN : uint = 147;
|
||||
pub static SCHED_RR_GET_INTERVAL : uint = 148;
|
||||
pub static MLOCK : uint = 149;
|
||||
pub static MUNLOCK : uint = 150;
|
||||
pub static MLOCKALL : uint = 151;
|
||||
pub static MUNLOCKALL : uint = 152;
|
||||
pub static VHANGUP : uint = 153;
|
||||
pub static MODIFY_LDT : uint = 154;
|
||||
pub static PIVOT_ROOT : uint = 155;
|
||||
pub static _SYSCTL : uint = 156;
|
||||
pub static PRCTL : uint = 157;
|
||||
pub static ARCH_PRCTL : uint = 158;
|
||||
pub static ADJTIMEX : uint = 159;
|
||||
pub static SETRLIMIT : uint = 160;
|
||||
pub static CHROOT : uint = 161;
|
||||
pub static SYNC : uint = 162;
|
||||
pub static ACCT : uint = 163;
|
||||
pub static SETTIMEOFDAY : uint = 164;
|
||||
pub static MOUNT : uint = 165;
|
||||
pub static UMOUNT2 : uint = 166;
|
||||
pub static SWAPON : uint = 167;
|
||||
pub static SWAPOFF : uint = 168;
|
||||
pub static REBOOT : uint = 169;
|
||||
pub static SETHOSTNAME : uint = 170;
|
||||
pub static SETDOMAINNAME : uint = 171;
|
||||
pub static IOPL : uint = 172;
|
||||
pub static IOPERM : uint = 173;
|
||||
pub static CREATE_MODULE : uint = 174;
|
||||
pub static INIT_MODULE : uint = 175;
|
||||
pub static DELETE_MODULE : uint = 176;
|
||||
pub static GET_KERNEL_SYMS : uint = 177;
|
||||
pub static QUERY_MODULE : uint = 178;
|
||||
pub static QUOTACTL : uint = 179;
|
||||
pub static NFSSERVCTL : uint = 180;
|
||||
pub static GETPMSG : uint = 181;
|
||||
pub static PUTPMSG : uint = 182;
|
||||
pub static AFS_SYSCALL : uint = 183;
|
||||
pub static TUXCALL : uint = 184;
|
||||
pub static SECURITY : uint = 185;
|
||||
pub static GETTID : uint = 186;
|
||||
pub static READAHEAD : uint = 187;
|
||||
pub static SETXATTR : uint = 188;
|
||||
pub static LSETXATTR : uint = 189;
|
||||
pub static FSETXATTR : uint = 190;
|
||||
pub static GETXATTR : uint = 191;
|
||||
pub static LGETXATTR : uint = 192;
|
||||
pub static FGETXATTR : uint = 193;
|
||||
pub static LISTXATTR : uint = 194;
|
||||
pub static LLISTXATTR : uint = 195;
|
||||
pub static FLISTXATTR : uint = 196;
|
||||
pub static REMOVEXATTR : uint = 197;
|
||||
pub static LREMOVEXATTR : uint = 198;
|
||||
pub static FREMOVEXATTR : uint = 199;
|
||||
pub static TKILL : uint = 200;
|
||||
pub static TIME : uint = 201;
|
||||
pub static FUTEX : uint = 202;
|
||||
pub static SCHED_SETAFFINITY : uint = 203;
|
||||
pub static SCHED_GETAFFINITY : uint = 204;
|
||||
pub static SET_THREAD_AREA : uint = 205;
|
||||
pub static IO_SETUP : uint = 206;
|
||||
pub static IO_DESTROY : uint = 207;
|
||||
pub static IO_GETEVENTS : uint = 208;
|
||||
pub static IO_SUBMIT : uint = 209;
|
||||
pub static IO_CANCEL : uint = 210;
|
||||
pub static GET_THREAD_AREA : uint = 211;
|
||||
pub static LOOKUP_DCOOKIE : uint = 212;
|
||||
pub static EPOLL_CREATE : uint = 213;
|
||||
pub static EPOLL_CTL_OLD : uint = 214;
|
||||
pub static EPOLL_WAIT_OLD : uint = 215;
|
||||
pub static REMAP_FILE_PAGES : uint = 216;
|
||||
pub static GETDENTS64 : uint = 217;
|
||||
pub static SET_TID_ADDRESS : uint = 218;
|
||||
pub static RESTART_SYSCALL : uint = 219;
|
||||
pub static SEMTIMEDOP : uint = 220;
|
||||
pub static FADVISE64 : uint = 221;
|
||||
pub static TIMER_CREATE : uint = 222;
|
||||
pub static TIMER_SETTIME : uint = 223;
|
||||
pub static TIMER_GETTIME : uint = 224;
|
||||
pub static TIMER_GETOVERRUN : uint = 225;
|
||||
pub static TIMER_DELETE : uint = 226;
|
||||
pub static CLOCK_SETTIME : uint = 227;
|
||||
pub static CLOCK_GETTIME : uint = 228;
|
||||
pub static CLOCK_GETRES : uint = 229;
|
||||
pub static CLOCK_NANOSLEEP : uint = 230;
|
||||
pub static EXIT_GROUP : uint = 231;
|
||||
pub static EPOLL_WAIT : uint = 232;
|
||||
pub static EPOLL_CTL : uint = 233;
|
||||
pub static TGKILL : uint = 234;
|
||||
pub static UTIMES : uint = 235;
|
||||
pub static VSERVER : uint = 236;
|
||||
pub static MBIND : uint = 237;
|
||||
pub static SET_MEMPOLICY : uint = 238;
|
||||
pub static GET_MEMPOLICY : uint = 239;
|
||||
pub static MQ_OPEN : uint = 240;
|
||||
pub static MQ_UNLINK : uint = 241;
|
||||
pub static MQ_TIMEDSEND : uint = 242;
|
||||
pub static MQ_TIMEDRECEIVE : uint = 243;
|
||||
pub static MQ_NOTIFY : uint = 244;
|
||||
pub static MQ_GETSETATTR : uint = 245;
|
||||
pub static KEXEC_LOAD : uint = 246;
|
||||
pub static WAITID : uint = 247;
|
||||
pub static ADD_KEY : uint = 248;
|
||||
pub static REQUEST_KEY : uint = 249;
|
||||
pub static KEYCTL : uint = 250;
|
||||
pub static IOPRIO_SET : uint = 251;
|
||||
pub static IOPRIO_GET : uint = 252;
|
||||
pub static INOTIFY_INIT : uint = 253;
|
||||
pub static INOTIFY_ADD_WATCH : uint = 254;
|
||||
pub static INOTIFY_RM_WATCH : uint = 255;
|
||||
pub static MIGRATE_PAGES : uint = 256;
|
||||
pub static OPENAT : uint = 257;
|
||||
pub static MKDIRAT : uint = 258;
|
||||
pub static MKNODAT : uint = 259;
|
||||
pub static FCHOWNAT : uint = 260;
|
||||
pub static FUTIMESAT : uint = 261;
|
||||
pub static NEWFSTATAT : uint = 262;
|
||||
pub static UNLINKAT : uint = 263;
|
||||
pub static RENAMEAT : uint = 264;
|
||||
pub static LINKAT : uint = 265;
|
||||
pub static SYMLINKAT : uint = 266;
|
||||
pub static READLINKAT : uint = 267;
|
||||
pub static FCHMODAT : uint = 268;
|
||||
pub static FACCESSAT : uint = 269;
|
||||
pub static PSELECT6 : uint = 270;
|
||||
pub static PPOLL : uint = 271;
|
||||
pub static UNSHARE : uint = 272;
|
||||
pub static SET_ROBUST_LIST : uint = 273;
|
||||
pub static GET_ROBUST_LIST : uint = 274;
|
||||
pub static SPLICE : uint = 275;
|
||||
pub static TEE : uint = 276;
|
||||
pub static SYNC_FILE_RANGE : uint = 277;
|
||||
pub static VMSPLICE : uint = 278;
|
||||
pub static MOVE_PAGES : uint = 279;
|
||||
pub static UTIMENSAT : uint = 280;
|
||||
pub static EPOLL_PWAIT : uint = 281;
|
||||
pub static SIGNALFD : uint = 282;
|
||||
pub static TIMERFD_CREATE : uint = 283;
|
||||
pub static EVENTFD : uint = 284;
|
||||
pub static FALLOCATE : uint = 285;
|
||||
pub static TIMERFD_SETTIME : uint = 286;
|
||||
pub static TIMERFD_GETTIME : uint = 287;
|
||||
pub static ACCEPT4 : uint = 288;
|
||||
pub static SIGNALFD4 : uint = 289;
|
||||
pub static EVENTFD2 : uint = 290;
|
||||
pub static EPOLL_CREATE1 : uint = 291;
|
||||
pub static DUP3 : uint = 292;
|
||||
pub static PIPE2 : uint = 293;
|
||||
pub static INOTIFY_INIT1 : uint = 294;
|
||||
pub static PREADV : uint = 295;
|
||||
pub static PWRITEV : uint = 296;
|
||||
pub static RT_TGSIGQUEUEINFO : uint = 297;
|
||||
pub static PERF_EVENT_OPEN : uint = 298;
|
||||
pub static RECVMMSG : uint = 299;
|
||||
pub static FANOTIFY_INIT : uint = 300;
|
||||
pub static FANOTIFY_MARK : uint = 301;
|
||||
pub static PRLIMIT64 : uint = 302;
|
||||
pub static NAME_TO_HANDLE_AT : uint = 303;
|
||||
pub static OPEN_BY_HANDLE_AT : uint = 304;
|
||||
pub static CLOCK_ADJTIME : uint = 305;
|
||||
pub static SYNCFS : uint = 306;
|
||||
pub static SENDMMSG : uint = 307;
|
||||
pub static SETNS : uint = 308;
|
||||
pub static GETCPU : uint = 309;
|
||||
pub static PROCESS_VM_READV : uint = 310;
|
||||
pub static PROCESS_VM_WRITEV : uint = 311;
|
||||
pub static KCMP : uint = 312;
|
||||
pub static FINIT_MODULE : uint = 313;
|
||||
pub static SCHED_SETATTR : uint = 314;
|
||||
pub static SCHED_GETATTR : uint = 315;
|
30
tests/test.rs
Normal file
30
tests/test.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2014 The syscall.rs Project Developers. See the
|
||||
// COPYRIGHT file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(phase)]
|
||||
|
||||
#[phase(plugin, link)]
|
||||
extern crate syscall;
|
||||
|
||||
// getpid() is POSIX but that doesn't guarantee it's a system call.
|
||||
#[cfg(target_os="linux")]
|
||||
#[test]
|
||||
fn getpid() {
|
||||
unsafe {
|
||||
assert!(0 < syscall::syscall0(syscall::nr::GETPID));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
#[test]
|
||||
fn getpid_macro() {
|
||||
unsafe {
|
||||
assert!(0 < syscall!(GETPID));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue