Skip to content

Commit ee03dc8

Browse files
cfriedtstephanosio
authored andcommitted
posix: sys/stat.h: format for coding style compliance
The original format of this file as imported from PicoLibC was not compatible with Zephyr's coding stytle. This change fixes compliance issues listed below: - whitespace formatting - block comment formatting - named parameters Introduction of new typedefs should be considered false-negatives as these are existing standard POSIX types. Signed-off-by: Chris Friedt <[email protected]>
1 parent 28726d6 commit ee03dc8

File tree

1 file changed

+157
-151
lines changed
  • include/zephyr/posix/sys

1 file changed

+157
-151
lines changed

include/zephyr/posix/sys/stat.h

+157-151
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
12
/*
2-
Copyright (c) 1982, 1986, 1993
3-
The Regents of the University of California. All rights reserved.
4-
5-
Redistribution and use in source and binary forms, with or without
6-
modification, are permitted provided that the following conditions
7-
are met:
8-
1. Redistributions of source code must retain the above copyright
9-
notice, this list of conditions and the following disclaimer.
10-
2. Redistributions in binary form must reproduce the above copyright
11-
notice, this list of conditions and the following disclaimer in the
12-
documentation and/or other materials provided with the distribution.
13-
3. Neither the name of the University nor the names of its contributors
14-
may be used to endorse or promote products derived from this software
15-
without specific prior written permission.
16-
17-
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20-
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23-
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26-
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27-
SUCH DAMAGE.
3+
* Copyright (c) 1982, 1986, 1993
4+
* The Regents of the University of California. All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
* 3. Neither the name of the University nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28+
* SUCH DAMAGE.
2829
*/
29-
#ifndef _SYS_STAT_H
30-
#define _SYS_STAT_H
30+
#ifndef ZEPHYR_POSIX_SYS_STAT_H_
31+
#define ZEPHYR_POSIX_SYS_STAT_H_
3132

3233
#ifdef __cplusplus
3334
extern "C" {
@@ -41,65 +42,66 @@ extern "C" {
4142
/* dj's stat defines _STAT_H_ */
4243
#ifndef _STAT_H_
4344

44-
/* It is intended that the layout of this structure not change when the
45-
sizes of any of the basic types change (short, int, long) [via a compile
46-
time option]. */
45+
/*
46+
* It is intended that the layout of this structure not change when the
47+
* sizes of any of the basic types change (short, int, long) [via a compile
48+
* time option].
49+
*/
4750

4851
#ifdef __CYGWIN__
4952
#include <cygwin/stat.h>
5053
#ifdef _LIBC
5154
#define stat64 stat
5255
#endif
5356
#else
54-
struct stat
55-
{
56-
dev_t st_dev;
57-
ino_t st_ino;
58-
mode_t st_mode;
59-
nlink_t st_nlink;
60-
uid_t st_uid;
61-
gid_t st_gid;
57+
struct stat {
58+
dev_t st_dev;
59+
ino_t st_ino;
60+
mode_t st_mode;
61+
nlink_t st_nlink;
62+
uid_t st_uid;
63+
gid_t st_gid;
6264
#if defined(__linux) && defined(__x86_64__)
63-
int __pad0;
65+
int __pad0;
6466
#endif
65-
dev_t st_rdev;
67+
dev_t st_rdev;
6668
#if defined(__linux) && !defined(__x86_64__)
67-
unsigned short int __pad2;
69+
unsigned short int __pad2;
6870
#endif
69-
off_t st_size;
71+
off_t st_size;
7072
#if defined(__linux)
71-
blksize_t st_blksize;
72-
blkcnt_t st_blocks;
73-
struct timespec st_atim;
74-
struct timespec st_mtim;
75-
struct timespec st_ctim;
76-
#define st_atime st_atim.tv_sec /* Backward compatibility */
73+
blksize_t st_blksize;
74+
blkcnt_t st_blocks;
75+
struct timespec st_atim;
76+
struct timespec st_mtim;
77+
struct timespec st_ctim;
78+
#define st_atime st_atim.tv_sec /* Backward compatibility */
7779
#define st_mtime st_mtim.tv_sec
7880
#define st_ctime st_ctim.tv_sec
7981
#if defined(__linux) && defined(__x86_64__)
80-
__uint64_t __glibc_reserved[3];
82+
__uint64_t __glibc_reserved[3];
8183
#endif
8284
#else
8385
#if defined(__rtems__)
84-
struct timespec st_atim;
85-
struct timespec st_mtim;
86-
struct timespec st_ctim;
87-
blksize_t st_blksize;
88-
blkcnt_t st_blocks;
86+
struct timespec st_atim;
87+
struct timespec st_mtim;
88+
struct timespec st_ctim;
89+
blksize_t st_blksize;
90+
blkcnt_t st_blocks;
8991
#else
90-
/* SysV/sco doesn't have the rest... But Solaris, eabi does. */
92+
/* SysV/sco doesn't have the rest... But Solaris, eabi does. */
9193
#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
92-
time_t st_atime;
93-
time_t st_mtime;
94-
time_t st_ctime;
94+
time_t st_atime;
95+
time_t st_mtime;
96+
time_t st_ctime;
9597
#else
96-
struct timespec st_atim;
97-
struct timespec st_mtim;
98-
struct timespec st_ctim;
99-
blksize_t st_blksize;
100-
blkcnt_t st_blocks;
98+
struct timespec st_atim;
99+
struct timespec st_mtim;
100+
struct timespec st_ctim;
101+
blksize_t st_blksize;
102+
blkcnt_t st_blocks;
101103
#if !defined(__rtems__)
102-
long st_spare4[2];
104+
long st_spare4[2];
103105
#endif
104106
#endif
105107
#endif
@@ -114,122 +116,126 @@ struct stat
114116

115117
#endif
116118

117-
#define _IFMT 0170000 /* type of file */
118-
#define _IFDIR 0040000 /* directory */
119-
#define _IFCHR 0020000 /* character special */
120-
#define _IFBLK 0060000 /* block special */
121-
#define _IFREG 0100000 /* regular */
122-
#define _IFLNK 0120000 /* symbolic link */
123-
#define _IFSOCK 0140000 /* socket */
124-
#define _IFIFO 0010000 /* fifo */
119+
#define _IFMT 0170000 /* type of file */
120+
#define _IFDIR 0040000 /* directory */
121+
#define _IFCHR 0020000 /* character special */
122+
#define _IFBLK 0060000 /* block special */
123+
#define _IFREG 0100000 /* regular */
124+
#define _IFLNK 0120000 /* symbolic link */
125+
#define _IFSOCK 0140000 /* socket */
126+
#define _IFIFO 0010000 /* fifo */
125127

126-
#define S_BLKSIZE 1024 /* size of a block */
128+
#define S_BLKSIZE 1024 /* size of a block */
127129

128-
#define S_ISUID 0004000 /* set user id on execution */
129-
#define S_ISGID 0002000 /* set group id on execution */
130-
#define S_ISVTX 0001000 /* save swapped text even after use */
130+
#define S_ISUID 0004000 /* set user id on execution */
131+
#define S_ISGID 0002000 /* set group id on execution */
132+
#define S_ISVTX 0001000 /* save swapped text even after use */
131133
#if __BSD_VISIBLE
132-
#define S_IREAD 0000400 /* read permission, owner */
133-
#define S_IWRITE 0000200 /* write permission, owner */
134-
#define S_IEXEC 0000100 /* execute/search permission, owner */
135-
#define S_ENFMT 0002000 /* enforcement-mode locking */
136-
#endif /* !_BSD_VISIBLE */
137-
138-
#define S_IFMT _IFMT
139-
#define S_IFDIR _IFDIR
140-
#define S_IFCHR _IFCHR
141-
#define S_IFBLK _IFBLK
142-
#define S_IFREG _IFREG
143-
#define S_IFLNK _IFLNK
144-
#define S_IFSOCK _IFSOCK
145-
#define S_IFIFO _IFIFO
134+
#define S_IREAD 0000400 /* read permission, owner */
135+
#define S_IWRITE 0000200 /* write permission, owner */
136+
#define S_IEXEC 0000100 /* execute/search permission, owner */
137+
#define S_ENFMT 0002000 /* enforcement-mode locking */
138+
#endif /* !_BSD_VISIBLE */
139+
140+
#define S_IFMT _IFMT
141+
#define S_IFDIR _IFDIR
142+
#define S_IFCHR _IFCHR
143+
#define S_IFBLK _IFBLK
144+
#define S_IFREG _IFREG
145+
#define S_IFLNK _IFLNK
146+
#define S_IFSOCK _IFSOCK
147+
#define S_IFIFO _IFIFO
146148

147149
#ifdef _WIN32
148-
/* The Windows header files define _S_ forms of these, so we do too
149-
for easier portability. */
150-
#define _S_IFMT _IFMT
151-
#define _S_IFDIR _IFDIR
152-
#define _S_IFCHR _IFCHR
153-
#define _S_IFIFO _IFIFO
154-
#define _S_IFREG _IFREG
155-
#define _S_IREAD 0000400
156-
#define _S_IWRITE 0000200
157-
#define _S_IEXEC 0000100
158-
#endif
159-
160-
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
161-
#define S_IRUSR 0000400 /* read permission, owner */
162-
#define S_IWUSR 0000200 /* write permission, owner */
163-
#define S_IXUSR 0000100/* execute/search permission, owner */
164-
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
165-
#define S_IRGRP 0000040 /* read permission, group */
166-
#define S_IWGRP 0000020 /* write permission, grougroup */
167-
#define S_IXGRP 0000010/* execute/search permission, group */
168-
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
169-
#define S_IROTH 0000004 /* read permission, other */
170-
#define S_IWOTH 0000002 /* write permission, other */
171-
#define S_IXOTH 0000001/* execute/search permission, other */
150+
/*
151+
* The Windows header files define _S_ forms of these, so we do too
152+
* for easier portability.
153+
*/
154+
#define _S_IFMT _IFMT
155+
#define _S_IFDIR _IFDIR
156+
#define _S_IFCHR _IFCHR
157+
#define _S_IFIFO _IFIFO
158+
#define _S_IFREG _IFREG
159+
#define _S_IREAD 0000400
160+
#define _S_IWRITE 0000200
161+
#define _S_IEXEC 0000100
162+
#endif
163+
164+
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
165+
#define S_IRUSR 0000400 /* read permission, owner */
166+
#define S_IWUSR 0000200 /* write permission, owner */
167+
#define S_IXUSR 0000100 /* execute/search permission, owner */
168+
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
169+
#define S_IRGRP 0000040 /* read permission, group */
170+
#define S_IWGRP 0000020 /* write permission, grougroup */
171+
#define S_IXGRP 0000010 /* execute/search permission, group */
172+
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
173+
#define S_IROTH 0000004 /* read permission, other */
174+
#define S_IWOTH 0000002 /* write permission, other */
175+
#define S_IXOTH 0000001 /* execute/search permission, other */
172176

173177
#if __BSD_VISIBLE
174-
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
175-
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
178+
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
179+
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
176180
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
177181
#endif
178182

179-
#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
180-
#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
181-
#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
182-
#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
183-
#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
184-
#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
185-
#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
183+
#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
184+
#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
185+
#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
186+
#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
187+
#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
188+
#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
189+
#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
186190

187191
#if defined(__CYGWIN__) || defined(__rtems__)
188192
/* Special tv_nsec values for futimens(2) and utimensat(2). */
189-
#define UTIME_NOW -2L
190-
#define UTIME_OMIT -1L
193+
#define UTIME_NOW -2L
194+
#define UTIME_OMIT -1L
191195
#endif
192196

193-
int chmod (const char *__path, mode_t __mode );
194-
int fchmod (int __fd, mode_t __mode);
195-
int fstat (int __fd, struct stat *__sbuf );
196-
int mkdir (const char *_path, mode_t __mode );
197-
int mkfifo (const char *__path, mode_t __mode );
198-
int stat (const char *__restrict __path, struct stat *__restrict __sbuf );
199-
mode_t umask (mode_t __mask );
197+
int chmod(const char *__path, mode_t __mode);
198+
int fchmod(int __fd, mode_t __mode);
199+
int fstat(int __fd, struct stat *__sbuf);
200+
int mkdir(const char *_path, mode_t __mode);
201+
int mkfifo(const char *__path, mode_t __mode);
202+
int stat(const char *__restrict __path, struct stat *__restrict __sbuf);
203+
mode_t umask(mode_t __mask);
200204

201-
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
202-
int lstat (const char *__restrict __path, struct stat *__restrict __buf );
203-
int mknod (const char *__path, mode_t __mode, dev_t __dev );
205+
#if defined(__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
206+
int lstat(const char *__restrict __path, struct stat *__restrict __buf);
207+
int mknod(const char *__path, mode_t __mode, dev_t __dev);
204208
#endif
205209

206210
#if __ATFILE_VISIBLE && !defined(__INSIDE_CYGWIN__)
207-
int fchmodat (int, const char *, mode_t, int);
208-
int fstatat (int, const char *__restrict , struct stat *__restrict, int);
209-
int mkdirat (int, const char *, mode_t);
210-
int mkfifoat (int, const char *, mode_t);
211-
int mknodat (int, const char *, mode_t, dev_t);
212-
int utimensat (int, const char *, const struct timespec [2], int);
211+
int fchmodat(int __fd, const char *__path, mode_t __mode, int __flag);
212+
int fstatat(int __fd, const char *__restrict __path, struct stat *__restrict __buf, int __flag);
213+
int mkdirat(int __fd, const char *__path, mode_t __mode);
214+
int mkfifoat(int __fd, const char *__path, mode_t __mode);
215+
int mknodat(int __fd, const char *__path, mode_t __mode, dev_t __dev);
216+
int utimensat(int __fd, const char *__path, const struct timespec __times[2], int __flag);
213217
#endif
214218
#if __POSIX_VISIBLE >= 200809 && !defined(__INSIDE_CYGWIN__)
215-
int futimens (int, const struct timespec [2]);
219+
int futimens(int __fd, const struct timespec __times[2]);
216220
#endif
217221

218-
/* Provide prototypes for most of the _<systemcall> names that are
219-
provided in newlib for some compilers. */
222+
/*
223+
* Provide prototypes for most of the _<systemcall> names that are
224+
* provided in newlib for some compilers.
225+
*/
220226
#ifdef _LIBC
221-
int _fstat (int __fd, struct stat *__sbuf );
222-
int _stat (const char *__restrict __path, struct stat *__restrict __sbuf );
223-
int _mkdir (const char *_path, mode_t __mode );
227+
int _fstat(int __fd, struct stat *__sbuf);
228+
int _stat(const char *__restrict __path, struct stat *__restrict __sbuf);
229+
int _mkdir(const char *_path, mode_t __mode);
224230
#ifdef __LARGE64_FILES
225231
struct stat64;
226-
int _stat64 (const char *__restrict __path, struct stat64 *__restrict __sbuf );
227-
int _fstat64 (int __fd, struct stat64 *__sbuf );
232+
int _stat64(const char *__restrict __path, struct stat64 *__restrict __sbuf);
233+
int _fstat64(int __fd, struct stat64 *__sbuf);
228234
#endif
229235
#endif
230236

231237
#endif /* !_STAT_H_ */
232238
#ifdef __cplusplus
233239
}
234240
#endif
235-
#endif /* _SYS_STAT_H */
241+
#endif /* ZEPHYR_POSIX_SYS_STAT_H_ */

0 commit comments

Comments
 (0)