compiler.h: Add fopen_like and popen_like macro
and apply them to the related functions Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
e1f45857e3
commit
da9a2b9770
@ -236,11 +236,15 @@
|
||||
/* The allocation function annonations */
|
||||
|
||||
# if __GNUC__ >= 11
|
||||
# define fopen_like __attribute__((__malloc__(fclose, 1)))
|
||||
# define popen_like __attribute__((__malloc__(pclose, 1)))
|
||||
# define malloc_like __attribute__((__malloc__(__builtin_free, 1)))
|
||||
# define malloc_like1(a) __attribute__((__malloc__(__builtin_free, 1))) __attribute__((__alloc_size__(a)))
|
||||
# define malloc_like2(a, b) __attribute__((__malloc__(__builtin_free, 1))) __attribute__((__alloc_size__(a, b)))
|
||||
# define realloc_like(a) __attribute__((__alloc_size__(a)))
|
||||
# else
|
||||
# define fopen_like __attribute__((__malloc__))
|
||||
# define popen_like __attribute__((__malloc__))
|
||||
# define malloc_like __attribute__((__malloc__))
|
||||
# define malloc_like1(a) __attribute__((__malloc__)) __attribute__((__alloc_size__(a)))
|
||||
# define malloc_like2(a, b) __attribute__((__malloc__)) __attribute__((__alloc_size__(a, b)))
|
||||
@ -495,6 +499,8 @@
|
||||
# define used_code
|
||||
# define used_data
|
||||
|
||||
# define fopen_like
|
||||
# define popen_like
|
||||
# define malloc_like
|
||||
# define malloc_like1(a)
|
||||
# define malloc_like2(a, b)
|
||||
@ -631,6 +637,8 @@
|
||||
# define unused_data
|
||||
# define used_code
|
||||
# define used_data
|
||||
# define fopen_like
|
||||
# define popen_like
|
||||
# define malloc_like
|
||||
# define malloc_like1(a)
|
||||
# define malloc_like2(a, b)
|
||||
@ -737,6 +745,8 @@
|
||||
# define unused_data
|
||||
# define used_code
|
||||
# define used_data
|
||||
# define fopen_like
|
||||
# define popen_like
|
||||
# define malloc_like
|
||||
# define malloc_like1(a)
|
||||
# define malloc_like2(a, b)
|
||||
@ -822,6 +832,8 @@
|
||||
# define unused_data
|
||||
# define used_code
|
||||
# define used_data
|
||||
# define fopen_like
|
||||
# define popen_like
|
||||
# define malloc_like
|
||||
# define malloc_like1(a)
|
||||
# define malloc_like2(a, b)
|
||||
@ -882,6 +894,8 @@
|
||||
# define unused_data
|
||||
# define used_code
|
||||
# define used_data
|
||||
# define fopen_like
|
||||
# define popen_like
|
||||
# define malloc_like
|
||||
# define malloc_like1(a)
|
||||
# define malloc_like2(a, b)
|
||||
|
@ -143,7 +143,7 @@ int fileno(FAR FILE *stream);
|
||||
int fgetc(FAR FILE *stream);
|
||||
int fgetpos(FAR FILE *stream, FAR fpos_t *pos);
|
||||
FAR char *fgets(FAR char *s, int n, FAR FILE *stream);
|
||||
FAR FILE *fopen(FAR const char *path, FAR const char *type);
|
||||
FAR FILE *fopen(FAR const char *path, FAR const char *type) fopen_like;
|
||||
int fprintf(FAR FILE *stream, FAR const IPTR char *format, ...)
|
||||
printflike(2, 3);
|
||||
int fputc(int c, FAR FILE *stream);
|
||||
@ -220,14 +220,14 @@ int vsscanf(FAR const char *buf, FAR const IPTR char *fmt, va_list ap)
|
||||
* Part 1 (dprintf and vdprintf)
|
||||
*/
|
||||
|
||||
FAR FILE *fdopen(int fd, FAR const char *type);
|
||||
FAR FILE *fdopen(int fd, FAR const char *type) fopen_like;
|
||||
int dprintf(int fd, FAR const IPTR char *fmt, ...) printflike(2, 3);
|
||||
int vdprintf(int fd, FAR const IPTR char *fmt, va_list ap)
|
||||
printflike(2, 0);
|
||||
|
||||
/* Operations on paths */
|
||||
|
||||
FAR FILE *tmpfile(void);
|
||||
FAR FILE *tmpfile(void) fopen_like;
|
||||
FAR char *tmpnam(FAR char *s);
|
||||
FAR char *tempnam(FAR const char *dir, FAR const char *pfx) malloc_like;
|
||||
int remove(FAR const char *path);
|
||||
@ -237,8 +237,8 @@ int remove(FAR const char *path);
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL__
|
||||
FILE *popen(FAR const char *command, FAR const char *mode);
|
||||
int pclose(FILE *stream);
|
||||
FILE *popen(FAR const char *command, FAR const char *mode) popen_like;
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
|
Loading…
Reference in New Issue
Block a user