Re: IOLockSleepDeadline example in docu is wrong (won't compile)
Re: IOLockSleepDeadline example in docu is wrong (won't compile)
- Subject: Re: IOLockSleepDeadline example in docu is wrong (won't compile)
- From: Carlos Calderon <email@hidden>
- Date: Tue, 04 Sep 2007 09:36:41 -0700
Hi Markus,
Are you perchance trying to compile this sample code on a Leopard seed
build?
// carlos
On Sep 4, 2007, at 5:22 AM, Markus Hanauska wrote:
Hi everyone!
I'm trying to sleep within my KEXT. I found the following source
code sample on Appel's side:
http://developer.apple.com/documentation/Porting/Conceptual/PortingDrivers/other-iokit/chapter_3_section_4.html
Nice, but it does not work! I can't even compile it.
int nanoseconds_to_delay = 1000000; # 1 msec for an example
AbsoluteTime absinterval, deadline;
.
.
.
nanoseconds_to_absolutetime(nanoseconds_to_delay, &absinterval);
clock_absolutetime_interval_to_deadline(absinterval, &deadline);
IOLockSleepDeadline(lock, event, deadline, THREAD_UNINT);
nanoseconds_to_absolutetime and
clock_absolutetime_interval_to_deadline work with uint64_t and not
with AbsoluteTime.
extern void nanoseconds_to_absolutetime(
uint64_t nanoseconds,
uint64_t *result);
and
extern void clock_absolutetime_interval_to_deadline(
uint64_t abstime,
uint64_t *result);
But AbsoluteTime is defined as
typedef UnsignedWide AbsoluteTime;
And UnsignedWide is
#if defined(__BIG_ENDIAN__)
typedef struct UnsignedWide {
UInt32 hi;
UInt32 lo;
} UnsignedWide;
#elif defined(__LITTLE_ENDIAN__)
typedef struct UnsignedWide {
UInt32 lo;
UInt32 hi;
} UnsignedWide;
#else
#error Unknown endianess.
#endif
I can't cast a number to a struct. Publishing source code that is
supposed to not even compile is not only silly and confusing
programmers, it's outreight useless.
Seeing that the struct is endian safe, I assume I can do the
following:
AbsoluteTime deadlineTime;
memcpy(&deadlineTime, deadline, sizeof(deadline));
correct?
--
Best Regards,
Markus Hanauska
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@apple.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden