1
1
/* Provide a more complete sys/stat header file.
2
Copyright (C) 2005-2010 Free Software Foundation, Inc.
2
Copyright (C) 2005-2011 Free Software Foundation, Inc.
4
4
This program is free software; you can redistribute it and/or modify
5
5
it under the terms of the GNU General Public License as published by
54
57
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
55
58
headers that may declare mkdir(). */
56
59
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
60
# include <io.h> /* mingw32, mingw64 */
61
# include <direct.h> /* mingw64 */
298
297
#if @GNULIB_FCHMODAT@
299
298
# if !@HAVE_FCHMODAT@
300
extern int fchmodat (int fd, char const *file, mode_t mode, int flag)
301
_GL_ARG_NONNULL ((2));
299
_GL_FUNCDECL_SYS (fchmodat, int,
300
(int fd, char const *file, mode_t mode, int flag)
301
_GL_ARG_NONNULL ((2)));
303
_GL_CXXALIAS_SYS (fchmodat, int,
304
(int fd, char const *file, mode_t mode, int flag));
305
_GL_CXXALIASWARN (fchmodat);
303
306
#elif defined GNULIB_POSIXCHECK
305
308
# if HAVE_RAW_DECL_FCHMODAT
312
315
#if @REPLACE_FSTAT@
313
# define fstat rpl_fstat
314
extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2));
316
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
317
# define fstat rpl_fstat
319
_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
320
_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
322
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
324
_GL_CXXALIASWARN (fstat);
318
327
#if @GNULIB_FSTATAT@
319
328
# if @REPLACE_FSTATAT@
321
# define fstatat rpl_fstatat
323
# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@
324
extern int fstatat (int fd, char const *name, struct stat *st, int flags)
325
_GL_ARG_NONNULL ((2, 3));
329
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
331
# define fstatat rpl_fstatat
333
_GL_FUNCDECL_RPL (fstatat, int,
334
(int fd, char const *name, struct stat *st, int flags)
335
_GL_ARG_NONNULL ((2, 3)));
336
_GL_CXXALIAS_RPL (fstatat, int,
337
(int fd, char const *name, struct stat *st, int flags));
340
_GL_FUNCDECL_SYS (fstatat, int,
341
(int fd, char const *name, struct stat *st, int flags)
342
_GL_ARG_NONNULL ((2, 3)));
344
_GL_CXXALIAS_SYS (fstatat, int,
345
(int fd, char const *name, struct stat *st, int flags));
347
_GL_CXXALIASWARN (fstatat);
327
348
#elif defined GNULIB_POSIXCHECK
329
350
# if HAVE_RAW_DECL_FSTATAT
336
357
#if @GNULIB_FUTIMENS@
337
358
# if @REPLACE_FUTIMENS@
339
# define futimens rpl_futimens
341
# if !@HAVE_FUTIMENS@ || @REPLACE_FUTIMENS@
342
extern int futimens (int fd, struct timespec const times[2]);
359
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
361
# define futimens rpl_futimens
363
_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
364
_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
366
# if !@HAVE_FUTIMENS@
367
_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
369
_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
371
_GL_CXXALIASWARN (futimens);
344
372
#elif defined GNULIB_POSIXCHECK
346
374
# if HAVE_RAW_DECL_FUTIMENS
361
389
invocation of lchmod, but we know of no workarounds that are
362
390
reliable in general. You might try requesting support for lchmod
363
391
from your operating system supplier. */
364
# define lchmod chmod
392
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
393
# define lchmod chmod
395
/* Need to cast, because on mingw, the second parameter of chmod is
397
_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
398
(const char *filename, mode_t mode));
400
# if 0 /* assume already declared */
401
_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
402
_GL_ARG_NONNULL ((1)));
404
_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
366
# if 0 /* assume already declared */
367
extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1));
407
_GL_CXXALIASWARN (lchmod);
369
409
#elif defined GNULIB_POSIXCHECK
379
419
# if ! @HAVE_LSTAT@
380
420
/* mingw does not support symlinks, therefore it does not have lstat. But
381
421
without links, stat does just fine. */
422
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
425
_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
383
426
# elif @REPLACE_LSTAT@
385
# define lstat rpl_lstat
386
extern int rpl_lstat (const char *name, struct stat *buf)
387
_GL_ARG_NONNULL ((1, 2));
427
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
429
# define lstat rpl_lstat
431
_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
432
_GL_ARG_NONNULL ((1, 2)));
433
_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
435
_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
438
_GL_CXXALIASWARN (lstat);
389
440
#elif defined GNULIB_POSIXCHECK
398
449
#if @REPLACE_MKDIR@
400
# define mkdir rpl_mkdir
401
extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1));
450
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
452
# define mkdir rpl_mkdir
454
_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
455
_GL_ARG_NONNULL ((1)));
456
_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
403
458
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
404
459
Additionally, it declares _mkdir (and depending on compile flags, an
405
alias mkdir), only in the nonstandard <io.h>, which is included above. */
460
alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
461
which are included above. */
406
462
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
464
# if !GNULIB_defined_rpl_mkdir
408
465
static inline int
409
466
rpl_mkdir (char const *name, mode_t mode)
411
468
return _mkdir (name);
470
# define GNULIB_defined_rpl_mkdir 1
414
# define mkdir rpl_mkdir
473
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
474
# define mkdir rpl_mkdir
476
_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
478
_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
481
_GL_CXXALIASWARN (mkdir);
419
484
#if @GNULIB_MKDIRAT@
420
485
# if !@HAVE_MKDIRAT@
421
extern int mkdirat (int fd, char const *file, mode_t mode)
422
_GL_ARG_NONNULL ((2));
486
_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
487
_GL_ARG_NONNULL ((2)));
489
_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
490
_GL_CXXALIASWARN (mkdirat);
424
491
#elif defined GNULIB_POSIXCHECK
426
493
# if HAVE_RAW_DECL_MKDIRAT
433
500
#if @GNULIB_MKFIFO@
434
501
# if @REPLACE_MKFIFO@
436
# define mkfifo rpl_mkfifo
438
# if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@
439
extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1));
502
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
504
# define mkfifo rpl_mkfifo
506
_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
507
_GL_ARG_NONNULL ((1)));
508
_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
511
_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
512
_GL_ARG_NONNULL ((1)));
514
_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
516
_GL_CXXALIASWARN (mkfifo);
441
517
#elif defined GNULIB_POSIXCHECK
443
519
# if HAVE_RAW_DECL_MKFIFO
450
526
#if @GNULIB_MKFIFOAT@
451
527
# if !@HAVE_MKFIFOAT@
452
extern int mkfifoat (int fd, char const *file, mode_t mode)
453
_GL_ARG_NONNULL ((2));
528
_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
529
_GL_ARG_NONNULL ((2)));
531
_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
532
_GL_CXXALIASWARN (mkfifoat);
455
533
#elif defined GNULIB_POSIXCHECK
457
535
# if HAVE_RAW_DECL_MKFIFOAT
464
542
#if @GNULIB_MKNOD@
465
543
# if @REPLACE_MKNOD@
467
# define mknod rpl_mknod
469
# if !@HAVE_MKNOD@ || @REPLACE_MKNOD@
470
extern int mknod (char const *file, mode_t mode, dev_t dev)
471
_GL_ARG_NONNULL ((1));
544
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
546
# define mknod rpl_mknod
548
_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
549
_GL_ARG_NONNULL ((1)));
550
_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
553
_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
554
_GL_ARG_NONNULL ((1)));
556
/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
557
_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
559
_GL_CXXALIASWARN (mknod);
473
560
#elif defined GNULIB_POSIXCHECK
475
562
# if HAVE_RAW_DECL_MKNOD
482
569
#if @GNULIB_MKNODAT@
483
570
# if !@HAVE_MKNODAT@
484
extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev)
485
_GL_ARG_NONNULL ((2));
571
_GL_FUNCDECL_SYS (mknodat, int,
572
(int fd, char const *file, mode_t mode, dev_t dev)
573
_GL_ARG_NONNULL ((2)));
575
_GL_CXXALIAS_SYS (mknodat, int,
576
(int fd, char const *file, mode_t mode, dev_t dev));
577
_GL_CXXALIASWARN (mknodat);
487
578
#elif defined GNULIB_POSIXCHECK
489
580
# if HAVE_RAW_DECL_MKNODAT
508
599
# else /* !_LARGE_FILES */
509
600
# define stat(name, st) rpl_stat (name, st)
510
601
# endif /* !_LARGE_FILES */
511
extern int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
602
_GL_EXTERN_C int stat (const char *name, struct stat *buf)
603
_GL_ARG_NONNULL ((1, 2));
513
605
#elif defined GNULIB_POSIXCHECK
522
614
#if @GNULIB_UTIMENSAT@
523
615
# if @REPLACE_UTIMENSAT@
525
# define utimensat rpl_utimensat
527
# if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@
528
extern int utimensat (int fd, char const *name,
529
struct timespec const times[2], int flag)
530
_GL_ARG_NONNULL ((2));
616
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
618
# define utimensat rpl_utimensat
620
_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
621
struct timespec const times[2], int flag)
622
_GL_ARG_NONNULL ((2)));
623
_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
624
struct timespec const times[2], int flag));
626
# if !@HAVE_UTIMENSAT@
627
_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
628
struct timespec const times[2], int flag)
629
_GL_ARG_NONNULL ((2)));
631
_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
632
struct timespec const times[2], int flag));
634
_GL_CXXALIASWARN (utimensat);
532
635
#elif defined GNULIB_POSIXCHECK
533
636
# undef utimensat
534
637
# if HAVE_RAW_DECL_UTIMENSAT