1408
|
1 /* safe-@l@stat.h -- EINTR-safe interface to @l@stat |
|
2 Copyright (C) 1994 Free Software Foundation, Inc. |
|
3 |
|
4 This program is free software; you can redistribute it and/or modify |
|
5 it under the terms of the GNU General Public License as published by |
|
6 the Free Software Foundation; either version 2, or (at your option) |
|
7 any later version. |
|
8 |
|
9 This program is distributed in the hope that it will be useful, |
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 GNU General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU General Public License |
|
15 along with this program; if not, write to the Free Software |
|
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
17 |
|
18 /* Written by Jim Meyering <meyering@comco.com>. */ |
|
19 |
|
20 #ifndef _safe_@l@stat_h_ |
|
21 #define _safe_@l@stat_h_ 1 |
|
22 |
|
23 /* NOTE: you must include the following headers (in the listed order) |
|
24 before this one: <sys/types.h>, <sys/stat.h>. */ |
|
25 |
|
26 #if !defined(S_ISLNK) && defined(S_IFLNK) @LSTAT_ONLY@ |
|
27 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) @LSTAT_ONLY@ |
|
28 #endif @LSTAT_ONLY@ |
|
29 @LSTAT_ONLY@ |
|
30 #ifndef S_ISLNK @LSTAT_ONLY@ |
|
31 #include "safe-stat.h" @LSTAT_ONLY@ |
|
32 #define SAFE_LSTAT SAFE_STAT @LSTAT_ONLY@ |
|
33 #define safe_lstat safe_stat @LSTAT_ONLY@ |
|
34 #else @LSTAT_ONLY@ |
|
35 @LSTAT_ONLY@ |
|
36 #include <errno.h> |
|
37 |
|
38 #ifndef errno |
|
39 extern int errno; |
|
40 #endif |
|
41 |
|
42 #ifndef __GNUC__ |
|
43 #define __inline /* empty */ |
|
44 #endif |
|
45 |
|
46 /* On some systems, @l@stat can return EINTR. */ |
|
47 |
|
48 #ifndef EINTR |
|
49 # define SAFE_@L@STAT(name, buf) @l@stat (name, buf) |
|
50 #else |
|
51 # ifndef __static |
|
52 # define __static static |
|
53 # endif |
|
54 # define SAFE_@L@STAT(name, buf) safe_@l@stat (name, buf) |
|
55 __static __inline int |
|
56 safe_@l@stat (name, buf) |
|
57 const char *name; |
|
58 struct stat *buf; |
|
59 { |
|
60 int ret; |
|
61 |
|
62 do |
|
63 ret = @l@stat (name, buf); |
|
64 while (ret < 0 && errno == EINTR); |
|
65 |
|
66 return ret; |
|
67 } |
|
68 #endif |
|
69 |
|
70 #endif /* S_ISLNK */ @LSTAT_ONLY@ |
|
71 #endif /* _safe_@l@stat_h_ */ |