1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- Added <sys/time.h> include to <sys/socket.h> due to latest "TimeVal" change

in the OS4 SDK. Otherwise "struct timeval" will not be defined at the time
  the <net/if.h> of the netincludes will be included by <proto/bsdsocket.h>.

- The strftime() hook function had the locale and character parameters
  switched, which made 'setlocale(LC_ALL,""); strftime(..);' unusable.
  Fixed.

- fchown() and chown() now accept owner and group ID values of -1, which
  indicate that the respective information should not be changed.

- The OS4 library build now includes the crtbegin.o and crtend.o object
  files in the libc.a library, which solves a problem with the thread-safe
  shared library support code.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15090 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2006-04-05 06:43:56 +00:00
parent 9c436ceaaa
commit 2e4de301cc
12 changed files with 282 additions and 123 deletions

View File

@ -1,5 +1,5 @@
#
# $Id: GNUmakefile.os4,v 1.93 2006-02-27 11:18:51 obarthel Exp $
# $Id: GNUmakefile.os4,v 1.94 2006-04-05 06:43:56 obarthel Exp $
#
# :ts=8
#
@ -147,10 +147,10 @@ WARNINGS = \
# -Wconversion -Wshadow
INCLUDES = -Iinclude -I. -I$(SDK_INCLUDE)
#OPTIONS = -D__THREAD_SAFE -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames -fno-common -std=gnu99
OPTIONS = -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames -fno-common -std=gnu99
OPTIONS = -D__THREAD_SAFE -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames -fno-common -std=gnu99
#OPTIONS = -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames -fno-common -std=gnu99
OPTIMIZE = -O3
DEBUG = -ggdb
#DEBUG = -ggdb
CFLAGS = $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(OPTIONS) $(CODE_TYPE) $(INCLUDES)
@ -159,6 +159,8 @@ CFLAGS = $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(OPTIONS) $(CODE_TYPE) $(INCLUDES)
# All objects files which make up libc.a
C_LIB = \
c.lib_rev.o \
crtbegin.o \
crtend.o \
ctype_isalnum.o \
ctype_isalpha.o \
ctype_isascii.o \

View File

@ -1,5 +1,5 @@
/*
* $Id: amiga_dotimer.c,v 1.7 2006-01-08 12:04:22 obarthel Exp $
* $Id: amiga_dotimer.c,v 1.8 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -55,6 +55,23 @@
/****************************************************************************/
/* A quick workaround for the timeval/timerequest->TimeVal/TimeRequest
change in the recent OS4 header files. */
#if defined(__NEW_TIMEVAL_DEFINITION_USED__)
#define timeval TimeVal
#define tv_secs Seconds
#define tv_micro Microseconds
#define timerequest TimeRequest
#define tr_node Request
#define tr_time Time
#endif /* __NEW_TIMEVAL_DEFINITION_USED__ */
/****************************************************************************/
LONG
DoTimer(struct timeval *tv,LONG unit,LONG command)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: amiga_timedelay.c,v 1.3 2006-01-08 12:04:22 obarthel Exp $
* $Id: amiga_timedelay.c,v 1.4 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -39,6 +39,19 @@
/****************************************************************************/
/* A quick workaround for the timeval/timerequest->TimeVal/TimeRequest
change in the recent OS4 header files. */
#if defined(__NEW_TIMEVAL_DEFINITION_USED__)
#define timeval TimeVal
#define tv_secs Seconds
#define tv_micro Microseconds
#endif /* __NEW_TIMEVAL_DEFINITION_USED__ */
/****************************************************************************/
LONG
TimeDelay(LONG unit,ULONG seconds,ULONG micros)
{

View File

@ -1,9 +1,18 @@
c.lib 1.200
- added <sys/time.h> include to sys/socket.h due to latest "TimeVal" change
- Added <sys/time.h> include to <sys/socket.h> due to latest "TimeVal" change
in the OS4 SDK. Otherwise "struct timeval" will not be defined at the time
the <net/if.h> of the netincludes will be included by <proto/bsdsocket.h>.
- The strftime() hook function had the locale and character parameters
switched, which made 'setlocale(LC_ALL,""); strftime(..);' unusable.
Fixed.
- fchown() and chown() now accept owner and group ID values of -1, which
indicate that the respective information should not be changed.
- The OS4 library build now includes the crtbegin.o and crtend.o object
files in the libc.a library, which solves a problem with the thread-safe
shared library support code.
c.lib 1.199 (6.3.2006)

View File

@ -1,5 +1,5 @@
/*
* $Id: sas_profile.c,v 1.6 2005-04-24 08:46:37 obarthel Exp $
* $Id: sas_profile.c,v 1.7 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -52,6 +52,19 @@ extern struct Library * SysBase;
/****************************************************************************/
/* A quick workaround for the timeval/timerequest->TimeVal/TimeRequest
change in the recent OS4 header files. */
#if defined(__NEW_TIMEVAL_DEFINITION_USED__)
#define timerequest TimeRequest
#define tr_node Request
#define tr_time Time
#endif /* __NEW_TIMEVAL_DEFINITION_USED__ */
/****************************************************************************/
struct SPROFMSG
{
struct Message message;

View File

@ -1,5 +1,5 @@
/*
* $Id: lib_user.c,v 1.6 2006-01-08 12:06:14 obarthel Exp $
* $Id: lib_user.c,v 1.7 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -100,7 +100,7 @@ UserLibOpen(struct UserData * ud)
{
BOOL result = FALSE;
/* For the AmigaOS4 build, invoke the clib2 shared library
/* For the thread safe build, invoke the clib2 shared library
initialization code. Note that this is not strictly
necessary. In fact, you should not need this functionality
if you stick to use Amiga operating system routines only
@ -109,15 +109,15 @@ UserLibOpen(struct UserData * ud)
Use this feature only if you are porting code to the Amiga
which cannot be easily converted to follow the AmigaOS
API definitions only. */
#if defined(__amigaos4__) && defined(__THREAD_SAFE)
#if defined(__THREAD_SAFE)
{
/* Note that the clib2 library initialization is
called exactly once, when the first client
opens this library. */
if(ud->ud_UseCount == 0 && !__lib_init(SysBase))
if(ud->ud_UseCount == 0 && !__lib_init(ud->ud_SysBase))
goto out;
}
#endif /* __amigaos4__ && __THREAD_SAFE */
#endif /* __THREAD_SAFE */
/* Remember that one more customer is using this data structure. */
ud->ud_UseCount++;
@ -140,7 +140,7 @@ UserLibClose(struct UserData * ud)
/* Remember that one less customer is using this data structure. */
ud->ud_UseCount--;
/* For the AmigaOS4 build, invoke the clib2 shared library
/* For the thread safe build, invoke the clib2 shared library
cleanup code. Note that this is not strictly
necessary. In fact, you should not need this functionality
if you stick to use Amiga operating system routines only
@ -149,7 +149,7 @@ UserLibClose(struct UserData * ud)
Use this feature only if you are porting code to the Amiga
which cannot be easily converted to follow the AmigaOS
API definitions only. */
#if defined(__amigaos4__) && defined(__THREAD_SAFE)
#if defined(__THREAD_SAFE)
{
/* Note that the clib2 library cleanup code is
called exactly once, when the last client
@ -157,7 +157,7 @@ UserLibClose(struct UserData * ud)
if(ud->ud_UseCount == 0)
__lib_exit();
}
#endif /* __amigaos4__ && __THREAD_SAFE */
#endif /* __THREAD_SAFE */
}
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: time_strftime.c,v 1.18 2006-01-08 12:04:27 obarthel Exp $
* $Id: time_strftime.c,v 1.19 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -59,8 +59,8 @@ struct format_hook_data
STATIC VOID
format_hook_function(
struct Hook * hook,
long c,
struct Locale * UNUSED unused_locale)
struct Locale * UNUSED unused_locale,
ULONG c)
{
struct format_hook_data * data = hook->h_Data;
@ -97,7 +97,7 @@ store_string_via_hook(const char * string,int len,struct Hook * hook)
len = strlen(string);
while(len-- > 0)
CallHookPkt(hook,(APTR)((ULONG)(*string++)),NULL);
CallHookPkt(hook,NULL,(APTR)((ULONG)(*string++)));
}
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_chown.c,v 1.9 2006-01-08 12:04:27 obarthel Exp $
* $Id: unistd_chown.c,v 1.10 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -54,6 +54,8 @@ chown(const char * path_name, uid_t owner, gid_t group)
struct name_translation_info path_name_nti;
#endif /* UNIX_PATH_SEMANTICS */
struct DevProc * dvp = NULL;
BPTR file_lock = ZERO;
BOOL owner_changed = TRUE;
LONG status;
int result = ERROR;
@ -80,14 +82,6 @@ chown(const char * path_name, uid_t owner, gid_t group)
}
#endif /* CHECK_FOR_NULL_POINTERS */
if(owner > 65535 || group > 65535)
{
SHOWMSG("invalid owner or group");
__set_errno(EINVAL);
goto out;
}
#if defined(UNIX_PATH_SEMANTICS)
{
if(__unix_path_semantics)
@ -112,6 +106,52 @@ chown(const char * path_name, uid_t owner, gid_t group)
}
#endif /* UNIX_PATH_SEMANTICS */
/* A value of -1 for either the owner or the group ID means
that what's currently being used should not be changed. */
if(owner == (uid_t)-1 || group == (gid_t)-1)
{
D_S(struct FileInfoBlock,fib);
PROFILE_OFF();
/* Try to find out which owner/group information
is currently in use. */
lock = Lock(path_name,SHARED_LOCK);
if(lock == ZERO || CANNOT Examine(file_lock,fib))
{
PROFILE_ON();
__set_errno(__translate_access_io_error_to_errno(IoErr()));
goto out;
}
UnLock(lock);
lock = ZERO;
PROFILE_ON();
/* Replace the information that should not be changed. */
if(owner == (uid_t)-1)
owner = fib->fib_OwnerUID;
if(group == (gid_t)-1)
group = fib->fib_OwnerGID;
/* Is anything different at all? */
if(owner == fib->fib_OwnerUID && group == fib->fib_OwnerGID)
owner_changed = FALSE;
}
if(owner > 65535 || group > 65535)
{
SHOWMSG("invalid owner or group");
__set_errno(EINVAL);
goto out;
}
if(owner_changed)
{
D(("changing owner of '%s'",path_name));
#if defined(__amigaos4__)
@ -165,13 +205,19 @@ chown(const char * path_name, uid_t owner, gid_t group)
__set_errno(__translate_io_error_to_errno(IoErr()));
goto out;
}
}
result = OK;
out:
PROFILE_OFF();
FreeDeviceProc(dvp);
if(file_lock != ZERO)
UnLock(file_lock);
PROFILE_ON();
RETURN(result);

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_fchown.c,v 1.12 2006-01-08 12:04:27 obarthel Exp $
* $Id: unistd_fchown.c,v 1.13 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -88,17 +88,6 @@ fchown(int file_descriptor, uid_t owner, gid_t group)
goto out;
}
if(owner > 65535 || group > 65535)
{
SHOWMSG("owner or group not OK");
SHOWVALUE(owner);
SHOWVALUE(group);
__set_errno(EINVAL);
goto out;
}
PROFILE_OFF();
success = (__safe_examine_file_handle(fd->fd_DefaultFile,fib) && (parent_dir = __safe_parent_of_file_handle(fd->fd_DefaultFile)) != ZERO);
PROFILE_ON();
@ -114,17 +103,43 @@ fchown(int file_descriptor, uid_t owner, gid_t group)
old_current_dir = CurrentDir(parent_dir);
current_dir_changed = TRUE;
/* A value of -1 for either the owner or the group ID means
that what's currently being used should not be changed. */
if(owner == (uid_t)-1)
owner = fib->fib_OwnerUID;
if(group == (gid_t)-1)
group = fib->fib_OwnerGID;
/* Check if the owner and group IDs are usable. This test
follows the comparison against -1 above just so that we
can be sure that we are not mistaking a -1 for a
large unsigned number. */
if(owner > 65535 || group > 65535)
{
SHOWMSG("owner or group not OK");
SHOWVALUE(owner);
SHOWVALUE(group);
__set_errno(EINVAL);
goto out;
}
/* Did anything change at all? */
if(group != fib->fib_OwnerUID || owner != fib->fib_OwnerUID)
{
PROFILE_OFF();
#if defined(__amigaos4__)
{
success = SetOwner(fib->fib_FileName,(LONG)((((ULONG)owner) << 16) | group));
success = SetOwner(fib->fib_FileName,(LONG)((((ULONG)owner) << 16) | (ULONG)group));
}
#else
{
if(((struct Library *)DOSBase)->lib_Version >= 39)
{
success = SetOwner(fib->fib_FileName,(LONG)((((ULONG)owner) << 16) | group));
success = SetOwner(fib->fib_FileName,(LONG)((((ULONG)owner) << 16) | (ULONG)group));
}
else
{
@ -148,7 +163,7 @@ fchown(int file_descriptor, uid_t owner, gid_t group)
new_name->name[0] = len;
memmove(&new_name->name[1],fib->fib_FileName,len);
success = DoPkt(dvp->dvp_Port,ACTION_SET_OWNER,dvp->dvp_Lock,MKBADDR(new_name),(LONG)((((ULONG)owner) << 16) | group),0,0);
success = DoPkt(dvp->dvp_Port,ACTION_SET_OWNER,dvp->dvp_Lock,MKBADDR(new_name),(LONG)((((ULONG)owner) << 16) | (ULONG)group),0,0);
error = IoErr();
FreeDeviceProc(dvp);
@ -168,6 +183,7 @@ fchown(int file_descriptor, uid_t owner, gid_t group)
__set_errno(__translate_io_error_to_errno(IoErr()));
goto out;
}
}
result = OK;

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_headers.h,v 1.9 2006-01-08 12:04:27 obarthel Exp $
* $Id: unistd_headers.h,v 1.10 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -65,12 +65,26 @@ extern struct MinList NOCOMMON __unlink_list;
/* Local timer I/O. */
extern struct MsgPort * NOCOMMON __timer_port;
extern struct timerequest * NOCOMMON __timer_request;
extern BOOL NOCOMMON __timer_busy;
extern struct Library * NOCOMMON __TimerBase;
/****************************************************************************/
/* A quick workaround for the timeval/timerequest->TimeVal/TimeRequest
change in the recent OS4 header files. */
#if defined(__NEW_TIMEVAL_DEFINITION_USED__)
extern struct TimeRequest * NOCOMMON __timer_request;
#else
extern struct timerequest * NOCOMMON __timer_request;
#endif /* __NEW_TIMEVAL_DEFINITION_USED__ */
/****************************************************************************/
#if defined(__amigaos4__)
extern struct TimerIFace * NOCOMMON __ITimer;
#endif /* __amigaos4__ */

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_time_delay.c,v 1.7 2006-01-08 12:04:27 obarthel Exp $
* $Id: unistd_time_delay.c,v 1.8 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -47,6 +47,23 @@
/****************************************************************************/
/* A quick workaround for the timeval/timerequest->TimeVal/TimeRequest
change in the recent OS4 header files. */
#if defined(__NEW_TIMEVAL_DEFINITION_USED__)
#define timeval TimeVal
#define tv_secs Seconds
#define tv_micro Microseconds
#define timerequest TimeRequest
#define tr_node Request
#define tr_time Time
#endif /* __NEW_TIMEVAL_DEFINITION_USED__ */
/****************************************************************************/
unsigned int
__time_delay(unsigned long seconds,unsigned long microseconds)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_timer.c,v 1.9 2006-01-08 12:04:27 obarthel Exp $
* $Id: unistd_timer.c,v 1.10 2006-04-05 06:43:56 obarthel Exp $
*
* :ts=4
*
@ -51,6 +51,18 @@
/****************************************************************************/
/* A quick workaround for the timeval/timerequest->TimeVal/TimeRequest
change in the recent OS4 header files. */
#if defined(__NEW_TIMEVAL_DEFINITION_USED__)
#define timerequest TimeRequest
#define tr_node Request
#endif /* __NEW_TIMEVAL_DEFINITION_USED__ */
/****************************************************************************/
/* Local timer I/O. */
struct MsgPort * NOCOMMON __timer_port;
struct timerequest * NOCOMMON __timer_request;