163d1a8abSmrg /* Checking macros for unistd functions.
2*ec02198aSmrg    Copyright (C) 2005-2020 Free Software Foundation, Inc.
363d1a8abSmrg 
463d1a8abSmrg This file is part of GCC.
563d1a8abSmrg 
663d1a8abSmrg GCC is free software; you can redistribute it and/or modify it under
763d1a8abSmrg the terms of the GNU General Public License as published by the Free
863d1a8abSmrg Software Foundation; either version 3, or (at your option) any later
963d1a8abSmrg version.
1063d1a8abSmrg 
1163d1a8abSmrg In addition to the permissions in the GNU General Public License, the
1263d1a8abSmrg Free Software Foundation gives you unlimited permission to link the
1363d1a8abSmrg compiled version of this file into combinations with other programs,
1463d1a8abSmrg and to distribute those combinations without any restriction coming
1563d1a8abSmrg from the use of this file.  (The General Public License restrictions
1663d1a8abSmrg do apply in other respects; for example, they cover modification of
1763d1a8abSmrg the file, and distribution when not linked into a combine
1863d1a8abSmrg executable.)
1963d1a8abSmrg 
2063d1a8abSmrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
2163d1a8abSmrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
2263d1a8abSmrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2363d1a8abSmrg for more details.
2463d1a8abSmrg 
2563d1a8abSmrg Under Section 7 of GPL version 3, you are granted additional
2663d1a8abSmrg permissions described in the GCC Runtime Library Exception, version
2763d1a8abSmrg 3.1, as published by the Free Software Foundation.
2863d1a8abSmrg 
2963d1a8abSmrg You should have received a copy of the GNU General Public License and
3063d1a8abSmrg a copy of the GCC Runtime Library Exception along with this program;
3163d1a8abSmrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
3263d1a8abSmrg <http://www.gnu.org/licenses/>.  */
3363d1a8abSmrg 
3463d1a8abSmrg 
3563d1a8abSmrg #ifndef _SSP_UNISTD_H
3663d1a8abSmrg #define _SSP_UNISTD_H 1
3763d1a8abSmrg 
3863d1a8abSmrg #include <ssp.h>
3963d1a8abSmrg #include_next <unistd.h>
4063d1a8abSmrg 
4163d1a8abSmrg #if __SSP_FORTIFY_LEVEL > 0
4263d1a8abSmrg 
4363d1a8abSmrg #undef read
4463d1a8abSmrg #undef readlink
4563d1a8abSmrg #undef getcwd
4663d1a8abSmrg 
4763d1a8abSmrg extern ssize_t __SSP_REDIRECT (__read_alias, (int __fd, void *__buf,
4863d1a8abSmrg 					      size_t __nbytes), read);
4963d1a8abSmrg 
5063d1a8abSmrg extern inline __attribute__((__always_inline__)) ssize_t
read(int __fd,void * __buf,size_t __nbytes)5163d1a8abSmrg read (int __fd, void *__buf, size_t __nbytes)
5263d1a8abSmrg {
5363d1a8abSmrg   if (__ssp_bos0 (__buf) != (size_t) -1 && __nbytes > __ssp_bos0 (__buf))
5463d1a8abSmrg     __chk_fail ();
5563d1a8abSmrg   return __read_alias (__fd, __buf, __nbytes);
5663d1a8abSmrg }
5763d1a8abSmrg 
5863d1a8abSmrg extern int __SSP_REDIRECT (__readlink_alias,
5963d1a8abSmrg 			   (const char *__restrict__ __path,
6063d1a8abSmrg 			    char *__restrict__ __buf, size_t __len),
6163d1a8abSmrg 			   readlink);
6263d1a8abSmrg 
6363d1a8abSmrg extern inline __attribute__((__always_inline__)) int
readlink(const char * __restrict__ __path,char * __restrict__ __buf,size_t __len)6463d1a8abSmrg readlink (const char *__restrict__ __path, char *__restrict__ __buf,
6563d1a8abSmrg 	  size_t __len)
6663d1a8abSmrg {
6763d1a8abSmrg   if (__ssp_bos (__buf) != (size_t) -1 && __len > __ssp_bos (__buf))
6863d1a8abSmrg     __chk_fail ();
6963d1a8abSmrg   return __readlink_alias (__path, __buf, __len);
7063d1a8abSmrg }
7163d1a8abSmrg 
7263d1a8abSmrg extern char *__SSP_REDIRECT (__getcwd_alias,
7363d1a8abSmrg 			     (char *__buf, size_t __size), getcwd);
7463d1a8abSmrg 
7563d1a8abSmrg extern inline __attribute__((__always_inline__)) char *
getcwd(char * __buf,size_t __size)7663d1a8abSmrg getcwd (char *__buf, size_t __size)
7763d1a8abSmrg {
7863d1a8abSmrg   if (__ssp_bos (__buf) != (size_t) -1 && __size > __ssp_bos (__buf))
7963d1a8abSmrg     __chk_fail ();
8063d1a8abSmrg   return __getcwd_alias (__buf, __size);
8163d1a8abSmrg }
8263d1a8abSmrg 
8363d1a8abSmrg #endif /* __SSP_FORTIFY_LEVEL > 0 */
8463d1a8abSmrg #endif /* _SSP_UNISTD_H */
85