Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time64 #583

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/all-unix/filesys/emul_handler/emul_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <sys/types.h>

/* This prevents redefinition of struct timeval */
#define _AROS_TYPES_TIMEVAL_S_H_
#define NO_AROS_TIMEVAL

#include <aros/debug.h>

Expand Down
3 changes: 1 addition & 2 deletions arch/all-unix/filesys/emul_handler/emul_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>

#pragma pack()

/* This prevents redefinition of struct timeval */
#define _AROS_TYPES_TIMEVAL_S_H_
#define NO_AROS_TIMEVAL

#define DEBUG 0
#define DASYNC(x)
Expand Down
3 changes: 1 addition & 2 deletions arch/all-unix/filesys/emul_handler/emul_host_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
#pragma pack()

/* This prevents redefinition of struct timeval */
#define _AROS_TYPES_TIMEVAL_S_H_
#define NO_AROS_TIMEVAL

#include <aros/debug.h>
#include <aros/symbolsets.h>
#include <dos/dosasl.h>
#include <utility/date.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/hostlib.h>
#include <proto/oop.h>
Expand Down
20 changes: 18 additions & 2 deletions compiler/include/aros/types/timeval_s.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,40 @@

#include <aros/cpu.h>

/* Version of timeval structure that guarantees 32-bit sizes and can be used
then 32-bit is enough */
struct timeval32
{
unsigned AROS_32BIT_TYPE tv_secs;
unsigned AROS_32BIT_TYPE tv_micro;
};

/* Note: after moving to 64-bit time, "struct timeval" will always be 64-bit
for compability with POSIX-style structure. All new compiled code will be
using 64-bit wide fields for both AROS-style and POSIX-style functions */

/* The following structure is composed of two anonymous unions so that it
can be transparently used by both AROS-style programs and POSIX-style
ones. For binary compatibility reasons the fields in the unions MUST
have the same size, however they can have different signs (as it is
the case for microseconds). */

#ifndef NO_AROS_TIMEVAL

__extension__ struct timeval
{
union /* Seconds passed. */
{
unsigned AROS_32BIT_TYPE tv_secs; /* AROS field */
unsigned AROS_32BIT_TYPE tv_sec; /* POSIX field */
unsigned AROS_32BIT_TYPE tv_sec; /* POSIX field */
};
union /* Microseconds passed in the current second. */
{
unsigned AROS_32BIT_TYPE tv_micro; /* AROS field */
signed AROS_32BIT_TYPE tv_usec; /* POSIX field */
signed AROS_32BIT_TYPE tv_usec; /* POSIX field */
};
};

#endif /* !NO_AROS_TIMEVAL */

#endif /* ! _AROS_TYPES_TIMEVAL_S_H_ */
4 changes: 3 additions & 1 deletion compiler/include/devices/inputevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ struct InputEvent
} ie_dead;
} ie_position;

struct timeval ie_TimeStamp;
/* This is guaranteed to be increasing with time, but not guaranteed
to contain absolute time */
struct timeval32 ie_TimeStamp;
};
#define ie_X ie_position.ie_xy.ie_x
#define ie_Y ie_position.ie_xy.ie_y
Expand Down
3 changes: 2 additions & 1 deletion compiler/include/devices/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ struct EClockVal
ULONG ev_lo;
};

/* Request used with 32-bit commands */
struct timerequest
{
struct IORequest tr_node;
struct timeval tr_time;
struct timeval32 tr_time;
};

#endif /* DEVICES_TIMER_H */
6 changes: 3 additions & 3 deletions compiler/include/intuition/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ struct Preferences
UWORD BaudRate; /* Baud rate for the serial port */

/* Timing rates */
struct timeval KeyRptSpeed; /* Repeat speed for keyboard */
struct timeval KeyRptDelay; /* Delay before keys repeat */
struct timeval DoubleClick; /* Interval allowed between clicks */
struct timeval32 KeyRptSpeed; /* Repeat speed for keyboard */
struct timeval32 KeyRptDelay; /* Delay before keys repeat */
struct timeval32 DoubleClick; /* Interval allowed between clicks */

/* Intuition Mouse-Pointer data */
UWORD PointerMatrix[POINTERSIZE]; /* Definition of pointer sprite */
Expand Down
12 changes: 6 additions & 6 deletions compiler/include/prefs/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
#define ID_INPT MAKE_ID('I','N','P','T')

struct InputPrefs {
char ip_Keymap[16];
UWORD ip_PointerTicks;
struct timeval ip_DoubleClick;
struct timeval ip_KeyRptDelay;
struct timeval ip_KeyRptSpeed;
WORD ip_MouseAccel;
char ip_Keymap[16];
UWORD ip_PointerTicks;
struct timeval32 ip_DoubleClick;
struct timeval32 ip_KeyRptDelay;
struct timeval32 ip_KeyRptSpeed;
WORD ip_MouseAccel;

/* The following fields are compatible with AmigaOS v4 */
ULONG ip_ClassicKeyboard; /* Reserved */
Expand Down
6 changes: 4 additions & 2 deletions compiler/posixc/include/aros/posixc/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
#include <sys/select.h>

/* struct itimerval is used by the interval timers getitimer()/setitimer() */
/* NOTIMPL
struct itimerval
{
struct timeval it_interval; /* timer interval */
struct timeval it_value; /* current value */
struct timeval it_interval; // timer interval
struct timeval it_value; // current value
};
*/

/* Which interval timer */
#define ITIMER_REAL 0 /* Decrements in real time */
Expand Down
7 changes: 5 additions & 2 deletions compiler/pthread/pthread_cond_timedwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ int _pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const

if (abstime)
{
struct timeval tvabstime;
// prepare MsgPort
memset( &timermp, 0, sizeof( timermp ) );
timermp.mp_Node.ln_Type = NT_MSGPORT;
Expand Down Expand Up @@ -82,15 +83,17 @@ int _pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const
// prepare the device command and send it
timerio.tr_node.io_Command = TR_ADDREQUEST;
timerio.tr_node.io_Flags = 0;
TIMESPEC_TO_TIMEVAL(&timerio.tr_time, abstime);
TIMESPEC_TO_TIMEVAL(&tvabstime, abstime);
if (!relative)
{
struct timeval starttime;
// absolute time has to be converted to relative
// GetSysTime can't be used due to the timezone offset in abstime
gettimeofday(&starttime, NULL);
timersub(&timerio.tr_time, &starttime, &timerio.tr_time);
timersub(&tvabstime, &starttime, &tvabstime);
}
timerio.tr_time.tv_secs = tvabstime.tv_sec;
timerio.tr_time.tv_micro = tvabstime.tv_usec;
timermask = 1 << timermp.mp_SigBit;
sigs |= timermask;
SendIO((struct IORequest *)&timerio);
Expand Down
8 changes: 4 additions & 4 deletions developer/demos/simple_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ void wait_for_timer(struct timerequest *tr, struct timeval *tv )

tr->tr_node.io_Command = TR_ADDREQUEST; /* add a new timer request */

/* structure assignment */
tr->tr_time = *tv;
tr->tr_time.tv_secs = tv->tv_secs;
tr->tr_time.tv_micro = tv->tv_micro;

/* post request to the timer -- will go to sleep till done */
DoIO((struct IORequest *) tr );
Expand Down Expand Up @@ -239,8 +239,8 @@ if (tr == 0 )
tr->tr_node.io_Command = TR_GETSYSTIME;
DoIO((struct IORequest *) tr );

/* structure assignment */
*tv = tr->tr_time;
tv->tv_secs = tr->tr_time.tv_secs;
tv->tv_micro = tr->tr_time.tv_micro;

delete_timer( tr );
return( 0 );
Expand Down
4 changes: 2 additions & 2 deletions rom/devs/input/input_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ struct inputbase
struct MinList HandlerList;
struct InputEvent *EventQueueHead;
struct InputEvent *EventQueueTail;
struct timeval KeyRepeatThreshold;
struct timeval KeyRepeatInterval;
struct timeval32 KeyRepeatThreshold;
struct timeval32 KeyRepeatInterval;
ULONG ResetSig;
UWORD ActQualifier;
UBYTE Prev1DownCode;
Expand Down
33 changes: 23 additions & 10 deletions rom/devs/input/processevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@

#define SEND_KEYTIMER_REQUEST(timerio,time) \
timerio->tr_node.io_Command = TR_ADDREQUEST; \
timerio->tr_time = time; \
timerio->tr_time.tv_secs = time.tv_secs; \
timerio->tr_time.tv_micro = time.tv_micro; \
SendIO((struct IORequest *)timerio)

#define ABORT_KEYTIMER_REQUEST \
Expand Down Expand Up @@ -77,6 +78,14 @@ AROS_INTH1(ResetHandler, struct inputbase *, InputDevice)
AROS_INTFUNC_EXIT
}

void GetSysTime32(struct timeval32 *dest, struct Library *TimerBase)
{
struct timeval tv;
GetSysTime(&tv);
dest->tv_secs = tv.tv_secs;
dest->tv_micro = tv.tv_micro;
}

/**********************
** ForwardEvents() **
**********************/
Expand Down Expand Up @@ -281,7 +290,7 @@ void ProcessEvents(struct inputbase *InputDevice)
timer_ie.ie_position.ie_addr = 0;

/* Add a timestamp to the event */
GetSysTime(&(timer_ie.ie_TimeStamp));
GetSysTime32(&(timer_ie.ie_TimeStamp), TimerBase);

AddEQTail(&timer_ie, InputDevice);
ForwardQueuedEvents(InputDevice);
Expand Down Expand Up @@ -394,7 +403,7 @@ void ProcessEvents(struct inputbase *InputDevice)
}

/* Set the timestamp */
GetSysTime(&(ie->ie_TimeStamp));
GetSysTime32(&(ie->ie_TimeStamp), TimerBase);

/* and enqueue */
AddEQTail(ie, InputDevice);
Expand All @@ -414,7 +423,7 @@ void ProcessEvents(struct inputbase *InputDevice)

ie->ie_NextEvent = NULL;
/* Add a timestamp to the event */
GetSysTime(&(ie->ie_TimeStamp));
GetSysTime32(&(ie->ie_TimeStamp), TimerBase);

D(bug("id: %d\n", ie->ie_Class));

Expand All @@ -427,13 +436,17 @@ void ProcessEvents(struct inputbase *InputDevice)
} break;

case IND_SETTHRESH:
InputDevice->KeyRepeatThreshold =
((struct timerequest *)ioreq)->tr_time;
InputDevice->KeyRepeatThreshold.tv_secs =
((struct timerequest *)ioreq)->tr_time.tv_secs;
InputDevice->KeyRepeatThreshold.tv_micro =
((struct timerequest *)ioreq)->tr_time.tv_micro;
break;

case IND_SETPERIOD:
InputDevice->KeyRepeatInterval =
((struct timerequest *)ioreq)->tr_time;
InputDevice->KeyRepeatInterval.tv_secs =
((struct timerequest *)ioreq)->tr_time.tv_secs;
InputDevice->KeyRepeatInterval.tv_micro =
((struct timerequest *)ioreq)->tr_time.tv_micro;
break;

}
Expand All @@ -454,7 +467,7 @@ void ProcessEvents(struct inputbase *InputDevice)
ie = keyrepeatie;
ie.ie_NextEvent = NULL; /* !! */
ie.ie_Qualifier |= IEQUALIFIER_REPEAT;
GetSysTime(&ie.ie_TimeStamp);
GetSysTime32(&ie.ie_TimeStamp, TimerBase);

AddEQTail(&ie, InputDevice);

Expand Down Expand Up @@ -533,7 +546,7 @@ void ProcessEvents(struct inputbase *InputDevice)
/* Gameport just returns the frame count since the last
report in ie_TimeStamp.tv_secs; we therefore must add
a real timestamp ourselves */
GetSysTime(&gpdie->ie_TimeStamp);
GetSysTime32(&gpdie->ie_TimeStamp, TimerBase);

/* Wheel events come in as IECLASS_NEWMOUSE, so fix ie_Class
and ie_Qualifier) */
Expand Down
3 changes: 2 additions & 1 deletion rom/filesys/SFS/FS/filesystemmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -4876,7 +4876,8 @@ static void diskchangenotify(ULONG class) {
ie.ie_Code=0;
ie.ie_Qualifier=IEQUALIFIER_MULTIBROADCAST;
ie.ie_EventAddress=0;
ie.ie_TimeStamp=tv;
ie.ie_TimeStamp.tv_secs=tv.tv_secs;
ie.ie_TimeStamp.tv_micro=tv.tv_micro;

inputreq->io_Command = IND_WRITEEVENT;
inputreq->io_Length = sizeof(struct InputEvent);
Expand Down
12 changes: 3 additions & 9 deletions rom/intuition/intuition_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@ CONST struct Preferences IntuitionDefaultPreferences =
0, // PrinterPort
5, // BaudRate

{
{ 0 },{ 40000 }
}
{ 0, 40000 }
, // timeval KeyRptSpeed

{
{ 0 },{ 500000 }
}
{ 0, 500000 }
, // timeval KeyRptDelay

{
{ 0 },{ 500000 }
}
{ 0, 500000 }
, // timeval DoubleClick

{
Expand Down
8 changes: 5 additions & 3 deletions rom/intuition/setprefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static void SetColors(UWORD *p, UBYTE first, UBYTE cnt, struct IntuitionBase *In
struct timerequest req =
{
{{{0}, 0}, 0},
{{0}}
{ 0, 0}
};

if (size > offsetof(struct Preferences, KeyRptDelay))
Expand All @@ -125,7 +125,8 @@ static void SetColors(UWORD *p, UBYTE first, UBYTE cnt, struct IntuitionBase *In
req.tr_node.io_Device = GetPrivIBase(IntuitionBase)->InputIO->io_Device;
req.tr_node.io_Unit = GetPrivIBase(IntuitionBase)->InputIO->io_Unit;
req.tr_node.io_Command = IND_SETTHRESH;
req.tr_time = GetPrivIBase(IntuitionBase)->ActivePreferences.KeyRptDelay;
req.tr_time.tv_secs = GetPrivIBase(IntuitionBase)->ActivePreferences.KeyRptDelay.tv_secs;
req.tr_time.tv_micro = GetPrivIBase(IntuitionBase)->ActivePreferences.KeyRptDelay.tv_micro;
DoIO(&req.tr_node);

#ifndef __MORPHOS__
Expand Down Expand Up @@ -156,7 +157,8 @@ static void SetColors(UWORD *p, UBYTE first, UBYTE cnt, struct IntuitionBase *In
req.tr_node.io_Device = GetPrivIBase(IntuitionBase)->InputIO->io_Device;
req.tr_node.io_Unit = GetPrivIBase(IntuitionBase)->InputIO->io_Unit;
req.tr_node.io_Command = IND_SETPERIOD;
req.tr_time = GetPrivIBase(IntuitionBase)->ActivePreferences.KeyRptSpeed;
req.tr_time.tv_secs = GetPrivIBase(IntuitionBase)->ActivePreferences.KeyRptSpeed.tv_secs;
req.tr_time.tv_micro = GetPrivIBase(IntuitionBase)->ActivePreferences.KeyRptSpeed.tv_micro;
DoIO(&req.tr_node);

#ifndef __MORPHOS__
Expand Down
Loading