From c8bd05f90915366b53d126445363ef4bab47c245 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Wed, 24 Sep 2008 16:10:00 +0200 Subject: [PATCH] Add more detail about wrapper functions Add a few more details about work generally done by wrapper functions. Note that syscall(2) performs the same steps. --- Changes | 4 ++++ man2/syscalls.2 | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 9ef113945..297006159 100644 --- a/Changes +++ b/Changes @@ -32,3 +32,7 @@ Global changes Changes to individual pages --------------------------- +syscalls.2 + mtk + Add a few more details about work generally done by wrapper + functions. Note that syscall(2) performs the same steps. diff --git a/man2/syscalls.2 b/man2/syscalls.2 index 49ff2c515..03b15c380 100644 --- a/man2/syscalls.2 +++ b/man2/syscalls.2 @@ -46,7 +46,22 @@ For example, glibc contains a function which invokes the underlying "truncate" system call. Often the glibc wrapper function is quite thin, doing little work -before invoking the system call. +other than copying arguments to the right registers +before invoking the system call, +and then setting +.I errno +appropriately after the system call has returned. +(These are the same steps that are performed by +.BR syscall (2), +which can be used to invoke system calls +for which no wrapper function is provided.) +Note: system calls indicate a failure by returning a negative error +number to the caller; +when this happens, +the wrapper function negates the returned error number +(to make it positive), copies it to +.IR errno , +and returns \-1 to the caller of the wrapper. Sometimes, however, the wrapper function does some extra work before invoking the system call.