diff options
author | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-07-10 16:21:23 +0000 |
---|---|---|
committer | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-07-10 16:21:23 +0000 |
commit | bdb52491010a946a2b250fca2b5cd9a192fbc178 (patch) | |
tree | 126f1bd457593835c53d2882254ef8bf334a1684 | |
parent | 988bdd49e8bcf71900ed3a20a66e44a25532b9b3 (diff) | |
download | ATCD-bdb52491010a946a2b250fca2b5cd9a192fbc178.tar.gz |
fixed ACE_DIR semantics for pSOS
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-02a | 8 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-03a | 8 | ||||
-rw-r--r-- | ace/OS_Dirent.h | 13 | ||||
-rw-r--r-- | ace/OS_Dirent.inl | 76 |
5 files changed, 60 insertions, 53 deletions
diff --git a/ChangeLog b/ChangeLog index 1418c10cecb..89c4bd90e48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Jul 10 11:12:00 2001 Chris Gill <cdgill@cs.wustl.edu> + + * ace/OS_Dirent.{h, inl}: refactored XDIR, dirent usage for pSOS - + user is no longer responsible for buffer deallocation after each + readdir call, only for passing the pointer returned from opendir + into closedir when all done. ACE_DIR structure is now used + consistently for all pSOS dirent calls. + Tue Jul 10 06:06:07 2001 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu> * ace/Service_Repository.h: Updated the insert() comment to diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a index 1418c10cecb..89c4bd90e48 100644 --- a/ChangeLogs/ChangeLog-02a +++ b/ChangeLogs/ChangeLog-02a @@ -1,3 +1,11 @@ +Tue Jul 10 11:12:00 2001 Chris Gill <cdgill@cs.wustl.edu> + + * ace/OS_Dirent.{h, inl}: refactored XDIR, dirent usage for pSOS - + user is no longer responsible for buffer deallocation after each + readdir call, only for passing the pointer returned from opendir + into closedir when all done. ACE_DIR structure is now used + consistently for all pSOS dirent calls. + Tue Jul 10 06:06:07 2001 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu> * ace/Service_Repository.h: Updated the insert() comment to diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index 1418c10cecb..89c4bd90e48 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,11 @@ +Tue Jul 10 11:12:00 2001 Chris Gill <cdgill@cs.wustl.edu> + + * ace/OS_Dirent.{h, inl}: refactored XDIR, dirent usage for pSOS - + user is no longer responsible for buffer deallocation after each + readdir call, only for passing the pointer returned from opendir + into closedir when all done. ACE_DIR structure is now used + consistently for all pSOS dirent calls. + Tue Jul 10 06:06:07 2001 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu> * ace/Service_Repository.h: Updated the insert() comment to diff --git a/ace/OS_Dirent.h b/ace/OS_Dirent.h index c3315e7f642..bbac4ab4eff 100644 --- a/ace/OS_Dirent.h +++ b/ace/OS_Dirent.h @@ -63,9 +63,16 @@ struct ACE_DIR { int started_reading_; }; #elif defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) -// pHILE+ calls the DIR struct XDIR instead -# -typedef XDIR ACE_DIR; +// Create our own definition of the DIR struct, like what +// is available in the newer DIAB PPC header files +struct ACE_DIR +{ + /// The directory handle + XDIR xdir; + + /// The directory entry + struct dirent dirent; +}; #else typedef DIR ACE_DIR; # endif /* ACE_LACKS_STRUCT_DIR */ diff --git a/ace/OS_Dirent.inl b/ace/OS_Dirent.inl index 75980e33a7e..d6b0c4e7def 100644 --- a/ace/OS_Dirent.inl +++ b/ace/OS_Dirent.inl @@ -1,4 +1,4 @@ -// -*- C++ -*- +// -*- C++ -*- // $Id$ #if defined (ACE_HAS_PACE) @@ -11,17 +11,12 @@ ACE_OS_Dirent::opendir (const ACE_TCHAR *filename) return pace_opendir (filename); #elif defined (ACE_HAS_DIRENT) # if defined (ACE_PSOS) - - // The pointer to the <ACE_DIR> buffer must be passed to ACE_OS_Dirent::closedir - // in order to free it and avoid a memory leak. + // The pointer to the <ACE_DIR> buffer *must* be passed to + // ACE_OS_Dirent::closedir to free it and avoid a memory leak. ACE_DIR *dir; u_long result; ACE_NEW_RETURN (dir, ACE_DIR, 0); -# if defined (ACE_PSOS_DIAB_PPC) result = ::open_dir (ACE_const_cast (char *, filename), &(dir->xdir)); -# else - result = ::open_dir (ACE_const_cast (char *, filename), dir); -# endif /* defined ACE_PSOS_DIAB_PPC */ if (result == 0) return dir; else @@ -29,14 +24,14 @@ ACE_OS_Dirent::opendir (const ACE_TCHAR *filename) errno = result; return 0; } -# else /* ! defined (ACE_PSOS) */ +# else /* ! ACE_PSOS */ # if defined (ACE_WIN32) return ::ACE_OS_Dirent::opendir_emulation (filename); -# else /* ACE_WIN32 */ +# else /* ! ACE_WIN32 */ // VxWorks' ::opendir () is declared with a non-const argument. return ::opendir (ACE_const_cast (char *, filename)); # endif /* ACE_WIN32 */ -# endif /* ! defined (ACE_PSOS) */ +# endif /* ACE_PSOS */ #else ACE_UNUSED_ARG (filename); ACE_NOTSUP_RETURN (0); @@ -51,19 +46,12 @@ ACE_OS_Dirent::closedir (ACE_DIR *d) #elif defined (ACE_HAS_DIRENT) # if defined (ACE_PSOS) - u_long result; - -# if defined (ACE_PSOS_DIAB_PPC) - result = ::close_dir (&(d->xdir)); -# else - result = ::close_dir (d); -# endif /* defined ACE_PSOS_DIAB_PPC */ - + u_long result = ::close_dir (&(d->xdir)); delete d; if (result != 0) errno = result; -# else /* ! defined (ACE_PSOS) */ +# else /* ! ACE_PSOS */ # if defined (ACE_WIN32) ACE_OS_Dirent::closedir_emulation (d); @@ -73,7 +61,7 @@ ACE_OS_Dirent::closedir (ACE_DIR *d) ::closedir (d); # endif /* ACE_WIN32 */ -# endif /* !ACE_PSOS */ +# endif /* ACE_PSOS */ #else /* ACE_HAS_DIRENT */ ACE_UNUSED_ARG (d); #endif /* ACE_HAS_PACE */ @@ -86,35 +74,23 @@ ACE_OS_Dirent::readdir (ACE_DIR *d) return pace_readdir (d); #elif defined (ACE_HAS_DIRENT) # if defined (ACE_PSOS) - // The returned pointer to the dirent struct must be deleted by the - // caller to avoid a memory leak. - struct dirent *dir_ent; - u_long result; - - ACE_NEW_RETURN (dir_ent, - dirent, - 0); -#if defined (ACE_PSOS_DIAB_PPC) - result = ::read_dir (&(d->xdir), dir_ent); -#else - result = ::read_dir (d, dir_ent); -#endif /* defined ACE_PSOS_DIAB_PPC) */ + u_long result = ::read_dir (&(d->xdir), &(d->dirent)); if (0 == result) - return dir_ent; + return &(d->dirent); else { errno = result; return 0; } -# else /* ! defined (ACE_PSOS) */ +# else /* ! ACE_PSOS */ # if defined (ACE_WIN32) return ACE_OS_Dirent::readdir_emulation (d); # else /* defined (ACE_WIN32) */ return ::readdir (d); # endif /* defined (ACE_WIN32) */ -# endif /* ! defined (ACE_PSOS) */ +# endif /* ACE_PSOS */ #else ACE_UNUSED_ARG (d); ACE_NOTSUP_RETURN (0); @@ -125,7 +101,7 @@ ACE_INLINE int ACE_OS_Dirent::readdir_r (ACE_DIR *dirp, struct dirent *entry, struct dirent **result) -{ +{ #if defined (ACE_HAS_PACE) && !defined (ACE_WIN32) return pace_readdir_r (dirp, entry, result); # elif !defined (ACE_HAS_REENTRANT_FUNCTIONS) @@ -208,16 +184,16 @@ ACE_OS_Dirent::rewinddir (ACE_DIR *d) #endif /* ACE_HAS_DIRENT */ } -ACE_INLINE int -ACE_OS_Dirent::scandir (const ACE_TCHAR *dirname, - struct dirent **namelist[], - int (*selector)(const struct dirent *), - int (*comparator) (const struct dirent **f1, +ACE_INLINE int +ACE_OS_Dirent::scandir (const ACE_TCHAR *dirname, + struct dirent **namelist[], + int (*selector)(const struct dirent *), + int (*comparator) (const struct dirent **f1, const struct dirent **f2)) -{ -#if defined (ACE_HAS_SCANDIR) - return ::scandir (dirname, namelist, selector, comparator); -#else /* ! defined ( ACE_HAS_SCANDIR) */ - return ACE_OS_Dirent::scandir_emulation (dirname, namelist, selector, comparator); -#endif /* ACE_HAS_SCANDIR */ -} +{ +#if defined (ACE_HAS_SCANDIR) + return ::scandir (dirname, namelist, selector, comparator); +#else /* ! defined ( ACE_HAS_SCANDIR) */ + return ACE_OS_Dirent::scandir_emulation (dirname, namelist, selector, comparator); +#endif /* ACE_HAS_SCANDIR */ +} |