1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/lib/libast/features/dirent
Martijn Dekker f37098f177 Build fix for Linux i386
iffe feature test that add a -D_LARGEFILE64_SOURCE compiler flag to
detect the presence of 64-bit types like off64_t are very
incorrect; they always find the type even if the rest of the source
is not compiled with that flag, causing an inconsistent compilation
environment. This was the cause of mysterious failures to compile
some feature tests on Linux i386 -- it tried to use an off64_t type
that was wrongly detected.

A flag like -D_LARGEFILE64_SOURCE needs to be added to the compiler
flags consistently so it is used for compiling all files and tests.

src/lib/libast/features/dirent,
src/lib/libast/features/fs,
src/lib/libast/features/lib,
src/lib/libast/features/mmap,
src/cmd/ksh93/features/rlimits:
- Remove the -D_LARGEFILE64_SOURCE flag from all the tests that
  used it.
- Fix some preprocessor directives for compiling without
  _LARGEFILE64_SOURCE. We cannot rely on the result of the _lib_*64
  tests because those functions are still found in glibc even if
  _LARGEFILE64_SOURCE is not defined; we have to check for the
  existence of the type definitions before using them.

src/cmd/INIT/cc.linux.i386,
src/cmd/INIT/cc.linux.i386-icc:
- Add/update compiler wrappers to hardcode -D_LARGEFILE64_SOURCE
  in the flags for the default compiler. If it is overriden with
  $CC, then it needs to be added manually if desired.
2021-01-31 23:47:43 +00:00

275 lines
4.7 KiB
Text

set prototyped
set nodefine
lib stat64
typ off64_t
set define
lib opendir
hdr dirent,ndir
sys dir
nxt dirent
tst botch_d_ino_dirent64 note{ dirent64.d_ino vs. readdir64 mismatch }end compile{
#if !__arm__
)
#endif
#include <dirent.h>
int
main()
{
struct dirent64 ent;
char aha[5-((int)sizeof(ent.d_ino))];
return sizeof(aha);
}
}end
if ( ! _lib_opendir ) {
/*
* <dirent.h> for systems with no opendir()
*/
#ifndef _DIRENT_H
#define _DIRENT_H
typedef struct
{
int dd_fd; /* file descriptor */
#ifdef _DIR_PRIVATE_
_DIR_PRIVATE_
#endif
} DIR;
struct dirent
{
long d_fileno; /* entry serial number */
int d_reclen; /* entry length */
int d_namlen; /* entry name length */
char d_name[1]; /* entry name */
};
#ifndef _DIR_PRIVATE_
#ifdef rewinddir
#undef rewinddir
#define rewinddir(p) seekdir(p,0L)
#endif
extern DIR* opendir(const char*);
extern void closedir(DIR*);
extern struct dirent* readdir(DIR*);
extern void seekdir(DIR*, long);
extern long telldir(DIR*);
#endif
#endif
}
elif ( _nxt_dirent && _lib_stat64 && _typ_off64_t && _botch_d_ino_dirent64 ) pass{
cat <<!
/*
* <dirent.h> for [fl]stat64 and off64_t with sizeof(ino64_t)==4
*/
#ifndef _AST_STD_H
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
#else
#ifndef _DIR64_H
#define _DIR64_H
#include <ast_std.h>
#if _typ_off64_t
#undef off_t
#endif
#undef __ino64_t
#define __ino64_t int64_t
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
#undef __ino64_t
#define __ino64_t __ino64_t
#if _typ_off64_t
#define off_t off64_t
#endif
#if _lib_readdir64 && _typ_struct_dirent64
#ifndef dirent
#define dirent dirent64
#endif
#ifndef readdir
#define readdir readdir64
#endif
#endif
#endif
#endif
!
}end
elif ( _nxt_dirent && _lib_stat64 && _typ_off64_t ) pass{
cat <<!
/*
* <dirent.h> for [fl]stat64 and off64_t
*/
#ifndef _AST_STD_H
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
#else
#ifndef _DIR64_H
#define _DIR64_H
#include <ast_std.h>
#if _typ_off64_t
#undef off_t
#endif
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
#if _typ_off64_t
#define off_t off64_t
#endif
#if _lib_readdir64 && _typ_struct_dirent64
#ifndef dirent
#define dirent dirent64
#endif
#ifndef readdir
#define readdir readdir64
#endif
#endif
#endif
#endif
!
}end
elif ( _nxt_dirent && _hdr_dirent ) pass{
cat <<!
/*
* <dirent.h> for systems with ok <dirent.h>
*/
#ifndef _DIRENT_H
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
#ifndef _DIRENT_H
#define _DIRENT_H
#endif
#endif
!
}end
elif ( _hdr_ndir ) {
/*
* <dirent.h> for systems with opendir() and <ndir.h>
*/
#ifndef _DIRENT_H
#define _DIRENT_H
#if defined(__STDPP__directive) && defined(__STDPP__hide)
__STDPP__directive pragma pp:hide closedir opendir readdir seekdir telldir
#else
#define closedir ______closedir
#define opendir ______opendir
#define readdir ______readdir
#define seekdir ______seekdir
#define telldir ______telldir
#endif
#include <ndir.h>
#if defined(__STDPP__directive) && defined(__STDPP__hide)
__STDPP__directive pragma pp:nohide closedir opendir readdir seekdir telldir
#else
#undef closedir
#undef opendir
#undef readdir
#undef seekdir
#undef telldir
#endif
#ifndef dirent
#define dirent direct
#endif
#if !defined(d_fileno) && !defined(d_ino)
#define d_fileno d_ino
#endif
#ifdef rewinddir
#undef rewinddir
#define rewinddir(p) seekdir(p,0L)
#endif
extern DIR* opendir(const char*);
extern void closedir(DIR*);
extern struct dirent* readdir(DIR*);
extern void seekdir(DIR*, long);
extern long telldir(DIR*);
#endif
}
elif ( _sys_dir ) {
/*
* <dirent.h> for systems with opendir() and no <ndir.h>
*/
#ifndef _DIRENT_H
#define _DIRENT_H
#if defined(__STDPP__directive) && defined(__STDPP__hide)
__STDPP__directive pragma pp:hide closedir opendir readdir seekdir telldir
#else
#define closedir ______closedir
#define opendir ______opendir
#define readdir ______readdir
#define seekdir ______seekdir
#define telldir ______telldir
#endif
#include <sys/dir.h>
#if defined(__STDPP__directive) && defined(__STDPP__hide)
__STDPP__directive pragma pp:nohide closedir opendir readdir seekdir telldir
#else
#undef closedir
#undef opendir
#undef readdir
#undef seekdir
#undef telldir
#endif
#ifndef dirent
#define dirent direct
#endif
#if !defined(d_fileno) && !defined(d_ino)
#define d_fileno d_ino
#endif
#ifdef rewinddir
#undef rewinddir
#define rewinddir(p) seekdir(p,0L)
#endif
extern DIR* opendir(const char*);
extern void closedir(DIR*);
extern struct dirent* readdir(DIR*);
extern void seekdir(DIR*, long);
extern long telldir(DIR*);
#endif
}
endif