[1046] | 1 | /* Checking macros for unistd functions.
|
---|
| 2 | Copyright (C) 2005, 2009 Free Software Foundation, Inc.
|
---|
| 3 |
|
---|
| 4 | This file is part of GCC.
|
---|
| 5 |
|
---|
| 6 | GCC is free software; you can redistribute it and/or modify it under
|
---|
| 7 | the terms of the GNU General Public License as published by the Free
|
---|
| 8 | Software Foundation; either version 3, or (at your option) any later
|
---|
| 9 | version.
|
---|
| 10 |
|
---|
| 11 | In addition to the permissions in the GNU General Public License, the
|
---|
| 12 | Free Software Foundation gives you unlimited permission to link the
|
---|
| 13 | compiled version of this file into combinations with other programs,
|
---|
| 14 | and to distribute those combinations without any restriction coming
|
---|
| 15 | from the use of this file. (The General Public License restrictions
|
---|
| 16 | do apply in other respects; for example, they cover modification of
|
---|
| 17 | the file, and distribution when not linked into a combine
|
---|
| 18 | executable.)
|
---|
| 19 |
|
---|
| 20 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
| 21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
| 22 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
---|
| 23 | for more details.
|
---|
| 24 |
|
---|
| 25 | Under Section 7 of GPL version 3, you are granted additional
|
---|
| 26 | permissions described in the GCC Runtime Library Exception, version
|
---|
| 27 | 3.1, as published by the Free Software Foundation.
|
---|
| 28 |
|
---|
| 29 | You should have received a copy of the GNU General Public License and
|
---|
| 30 | a copy of the GCC Runtime Library Exception along with this program;
|
---|
| 31 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
---|
| 32 | <http://www.gnu.org/licenses/>. */
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | #ifndef _SSP_UNISTD_H
|
---|
| 36 | #define _SSP_UNISTD_H 1
|
---|
| 37 |
|
---|
| 38 | #include <ssp.h>
|
---|
| 39 | #include_next <unistd.h>
|
---|
| 40 |
|
---|
| 41 | #if __SSP_FORTIFY_LEVEL > 0
|
---|
| 42 |
|
---|
| 43 | #undef read
|
---|
| 44 | #undef readlink
|
---|
| 45 | #undef getcwd
|
---|
| 46 |
|
---|
| 47 | extern ssize_t __SSP_REDIRECT (__read_alias, (int __fd, void *__buf,
|
---|
| 48 | size_t __nbytes), read);
|
---|
| 49 |
|
---|
| 50 | extern inline __attribute__((__always_inline__)) ssize_t
|
---|
| 51 | read (int __fd, void *__buf, size_t __nbytes)
|
---|
| 52 | {
|
---|
| 53 | if (__ssp_bos0 (__buf) != (size_t) -1 && __nbytes > __ssp_bos0 (__buf))
|
---|
| 54 | __chk_fail ();
|
---|
| 55 | return __read_alias (__fd, __buf, __nbytes);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | extern int __SSP_REDIRECT (__readlink_alias,
|
---|
| 59 | (const char *__restrict__ __path,
|
---|
| 60 | char *__restrict__ __buf, size_t __len),
|
---|
| 61 | readlink);
|
---|
| 62 |
|
---|
| 63 | extern inline __attribute__((__always_inline__)) int
|
---|
| 64 | readlink (const char *__restrict__ __path, char *__restrict__ __buf,
|
---|
| 65 | size_t __len)
|
---|
| 66 | {
|
---|
| 67 | if (__ssp_bos (__buf) != (size_t) -1 && __len > __ssp_bos (__buf))
|
---|
| 68 | __chk_fail ();
|
---|
| 69 | return __readlink_alias (__path, __buf, __len);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | extern char *__SSP_REDIRECT (__getcwd_alias,
|
---|
| 73 | (char *__buf, size_t __size), getcwd);
|
---|
| 74 |
|
---|
| 75 | extern inline __attribute__((__always_inline__)) char *
|
---|
| 76 | getcwd (char *__buf, size_t __size)
|
---|
| 77 | {
|
---|
| 78 | if (__ssp_bos (__buf) != (size_t) -1 && __size > __ssp_bos (__buf))
|
---|
| 79 | __chk_fail ();
|
---|
| 80 | return __getcwd_alias (__buf, __size);
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | #endif /* __SSP_FORTIFY_LEVEL > 0 */
|
---|
| 84 | #endif /* _SSP_UNISTD_H */
|
---|