kernel/eka/euser/us_exec.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
  2885 stored in this TExtendedLocale. If you want to set the system wide settings with
  2885 stored in this TExtendedLocale. If you want to set the system wide settings with
  2886 the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
  2886 the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
  2887 after calling this function.
  2887 after calling this function.
  2888 
  2888 
  2889 @param aLocaleDllName The name of the locale DLL to be loaded
  2889 @param aLocaleDllName The name of the locale DLL to be loaded
  2890 @return KErrNone if successful, KErrNotSupported if the DLL name matches the pattern
  2890 @return KErrNone if successful, system wide error if not
  2891 of a new-style locale library, system wide error otherwise
       
  2892 
  2891 
  2893 @see TExtendedLocale::SaveSystemSettings 
  2892 @see TExtendedLocale::SaveSystemSettings 
  2894 */
  2893 */
  2895 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLocaleDllName)
  2894 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLocaleDllName)
  2896 	{
  2895 	{
  2897 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  2896 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  2898 	if (aLocaleDllName.Find(KFindLan) != KErrNotFound || aLocaleDllName.Find(KFindReg) != KErrNotFound || aLocaleDllName.Find(KFindCol) != KErrNotFound)
       
  2899 		{
       
  2900 		return KErrNotSupported; // Only try to load old-style locale libraries
       
  2901 		}
       
  2902 	TLibraryFunction data[KNumLocaleExports];
  2897 	TLibraryFunction data[KNumLocaleExports];
  2903 	TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
  2898 	TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
  2904 	if(r == KErrNone)
  2899 	if(r == KErrNone)
  2905 		{
  2900 		{
  2906 		iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
  2901 		iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
  2996 with the locale information stored in the DLLs. The locale information is only
  2991 with the locale information stored in the DLLs. The locale information is only
  2997 stored in this TExtendedLocale. If you want to set the system wide settings with
  2992 stored in this TExtendedLocale. If you want to set the system wide settings with
  2998 the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
  2993 the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
  2999 after calling this function.
  2994 after calling this function.
  3000 
  2995 
  3001 If the function fails then it will call LoadSystemSettings() to return its members
       
  3002 to a known, good state.
       
  3003 
       
  3004 @param aLanguageLocaleDllName The name of the language locale DLL to be loaded
  2996 @param aLanguageLocaleDllName The name of the language locale DLL to be loaded
  3005 @param aRegionLocaleDllName The name of the region locale DLL to be loaded
  2997 @param aRegionLocaleDllName The name of the region locale DLL to be loaded
  3006 @param aCollationLocaleDllName The name of the collation locale DLL to be loaded
  2998 @param aCollationLocaleDllName The name of the collation locale DLL to be loaded
  3007 
  2999 
  3008 @return KErrNone if successful, system wide error if not
  3000 @return KErrNone if successful, system wide error if not
  3012 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  3004 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  3013 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLanguageLocaleDllName, 
  3005 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLanguageLocaleDllName, 
  3014 		const TDesC& aRegionLocaleDllName, 
  3006 		const TDesC& aRegionLocaleDllName, 
  3015 		const TDesC& aCollationLocaleDllName)
  3007 		const TDesC& aCollationLocaleDllName)
  3016 	{
  3008 	{
       
  3009 
  3017 	TInt err = LoadLocaleAspect(aLanguageLocaleDllName);
  3010 	TInt err = LoadLocaleAspect(aLanguageLocaleDllName);
  3018 
       
  3019 	if(err == KErrNone)
       
  3020 		err = LoadLocaleAspect(aRegionLocaleDllName);
       
  3021 
       
  3022 	if(err == KErrNone)
       
  3023 		err = LoadLocaleAspect(aCollationLocaleDllName);
       
  3024 
       
  3025 	if(err != KErrNone)
  3011 	if(err != KErrNone)
  3026 		LoadSystemSettings();	
  3012 		return err;
       
  3013 	
       
  3014 	err = LoadLocaleAspect(aRegionLocaleDllName);
       
  3015 	if(err != KErrNone)
       
  3016 		return err;
       
  3017 	
       
  3018 	err = LoadLocaleAspect(aCollationLocaleDllName);
       
  3019 	if(err != KErrNone)
       
  3020 		return err;	
  3027 
  3021 
  3028 	return err;	
  3022 	return err;	
  3029 	}
  3023 	}
  3030 #else
  3024 #else
  3031 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& /*aLanguageLocaleDllName*/, 
  3025 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& /*aLanguageLocaleDllName*/, 
  3772 free. If the mutex is already held by the current thread a count is maintained
  3766 free. If the mutex is already held by the current thread a count is maintained
  3773 of how many times the thread has acquired the mutex.
  3767 of how many times the thread has acquired the mutex.
  3774 */
  3768 */
  3775 EXPORT_C void RMutex::Wait()
  3769 EXPORT_C void RMutex::Wait()
  3776 	{
  3770 	{
  3777 	Exec::MutexWait(iHandle, 0);
  3771 
  3778 	}
  3772 	Exec::MutexWait(iHandle);
  3779 
       
  3780 
       
  3781 
       
  3782 
       
  3783 /**
       
  3784 Acquire the mutex if it is currently free, but don't wait for it.
       
  3785 
       
  3786 This function checks if the mutex is currently held. If not the mutex is marked
       
  3787 as held by the current thread and the call returns immediately indicating
       
  3788 success. If the mutex is held by another thread the call returns immediately
       
  3789 indicating failure. If the mutex is already held by the current thread a count
       
  3790 is maintained of how many times the thread has acquired the mutex.
       
  3791 
       
  3792 @return	KErrNone if the mutex was acquired
       
  3793 		KErrTimedOut if the mutex could not be acquired
       
  3794         KErrGeneral if the semaphore is being reset, i.e the semaphore
       
  3795         is about to  be deleted.
       
  3796 */
       
  3797 EXPORT_C TInt RMutex::Poll()
       
  3798 	{
       
  3799 	return Exec::MutexWait(iHandle, -1);
       
  3800 	}
       
  3801 
       
  3802 
       
  3803 
       
  3804 
       
  3805 /**
       
  3806 Acquire the mutex, if necessary waiting up to a specified maximum amount of time
       
  3807 for it to become free.
       
  3808 
       
  3809 This function checks if the mutex is currently held. If not the mutex is marked
       
  3810 as held by the current thread and the call returns immediately. If the mutex is
       
  3811 held by another thread the current thread will suspend until the mutex becomes
       
  3812 free or until the specified timeout period has elapsed. If the mutex is already
       
  3813 held by the current thread a count is maintained of how many times the thread
       
  3814 has acquired the mutex.
       
  3815 
       
  3816 @param aTimeout The timeout value in microseconds
       
  3817 
       
  3818 @return KErrNone if the mutex was acquired successfully.
       
  3819         KErrTimedOut if the timeout has expired.
       
  3820         KErrGeneral if the mutex is being reset, i.e the mutex
       
  3821         is about to  be deleted.
       
  3822         KErrArgument if aTimeout is negative;
       
  3823         otherwise one of the other system wide error codes.
       
  3824 */
       
  3825 EXPORT_C TInt RMutex::Wait(TInt aTimeout)
       
  3826 	{
       
  3827 	if (aTimeout>=0)
       
  3828 		return Exec::MutexWait(iHandle, aTimeout);
       
  3829 	return KErrArgument;
       
  3830 	}
  3773 	}
  3831 
  3774 
  3832 
  3775 
  3833 
  3776 
  3834 
  3777 
  4363 	}
  4306 	}
  4364 
  4307 
  4365 
  4308 
  4366 
  4309 
  4367 
  4310 
       
  4311 EXPORT_C void RSemaphore::Wait()
  4368 /**
  4312 /**
  4369 Waits for a signal on the semaphore.
  4313 Waits for a signal on the semaphore.
  4370 
  4314 
  4371 The function decrements the semaphore count by one and returns immediately 
  4315 The function decrements the semaphore count by one and returns immediately 
  4372 if it is zero or positive.
  4316 if it is zero or positive.
  4378 be waiting on a particular semaphore at a time. When there are multiple threads 
  4322 be waiting on a particular semaphore at a time. When there are multiple threads 
  4379 waiting on a semaphore, they are released in priority order.
  4323 waiting on a semaphore, they are released in priority order.
  4380 
  4324 
  4381 If the semaphore is deleted, all threads waiting on that semaphore are released.
  4325 If the semaphore is deleted, all threads waiting on that semaphore are released.
  4382 */
  4326 */
  4383 EXPORT_C void RSemaphore::Wait()
  4327 	{
  4384 	{
  4328 
  4385 	Exec::SemaphoreWait(iHandle, 0);
  4329 	Exec::SemaphoreWait(iHandle, 0);
  4386 	}
  4330 	}
  4387 
  4331 
  4388 
  4332 
       
  4333 
       
  4334 
       
  4335 EXPORT_C TInt RSemaphore::Wait(TInt aTimeout)
  4389 /**
  4336 /**
  4390 Waits for a signal on the semaphore, or a timeout.
  4337 Waits for a signal on the semaphore, or a timeout.
  4391 
  4338 
  4392 @param aTimeout The timeout value in microseconds
  4339 @param aTimeout The timeout value in micoseconds
  4393 
  4340 
  4394 @return KErrNone if the wait has completed normally.
  4341 @return KErrNone if the wait has completed normally.
  4395         KErrTimedOut if the timeout has expired.
  4342         KErrTimedOut if the timeout has expired.
  4396         KErrGeneral if the semaphore is being reset, i.e the semaphore
  4343         KErrGeneral if the semaphore is being reset, i.e the semaphore
  4397         is about to  be deleted.
  4344         is about to  be deleted.
  4398         KErrArgument if aTimeout is negative;
  4345         KErrArgument if aTimeout is negative;
  4399         otherwise one of the other system wide error codes.
  4346         otherwise one of the other system wide error codes.
  4400 */
  4347 */
  4401 EXPORT_C TInt RSemaphore::Wait(TInt aTimeout)
  4348 	{
  4402 	{
  4349 
  4403 	if (aTimeout>=0)
  4350 	return Exec::SemaphoreWait(iHandle, aTimeout);
  4404 		return Exec::SemaphoreWait(iHandle, aTimeout);
  4351 	}
  4405 	return KErrArgument;
  4352 
  4406 	}
  4353 
  4407 
       
  4408 
       
  4409 /**
       
  4410 Acquires the semaphore if that is possible without waiting.
       
  4411 
       
  4412 @return KErrNone if the semaphore was acquired successfully
       
  4413         KErrTimedOut if the semaphore could not be acquired
       
  4414         KErrGeneral if the semaphore is being reset, i.e the semaphore
       
  4415         is about to  be deleted.
       
  4416 */
       
  4417 EXPORT_C TInt RSemaphore::Poll()
       
  4418 	{
       
  4419 	return Exec::SemaphoreWait(iHandle, -1);
       
  4420 	}
       
  4421 
  4354 
  4422 
  4355 
  4423 EXPORT_C void RSemaphore::Signal()
  4356 EXPORT_C void RSemaphore::Signal()
  4424 /**
  4357 /**
  4425 Signals the semaphore once.
  4358 Signals the semaphore once.
  4454 	Exec::SemaphoreSignalN(iHandle,aCount);
  4387 	Exec::SemaphoreSignalN(iHandle,aCount);
  4455 	}
  4388 	}
  4456 
  4389 
  4457 
  4390 
  4458 
  4391 
  4459 #ifndef __CPU_ARM
       
  4460 /**
       
  4461 Acquire the lock, if necessary waiting up to a specified maximum amount of time
       
  4462 for it to become free.
       
  4463 
       
  4464 This function checks if the lock is currently held. If not the lock is marked
       
  4465 as held by the current thread and the call returns immediately. If the lock is
       
  4466 held by another thread the current thread will suspend until the lock becomes
       
  4467 free or until the specified timeout period has elapsed.
       
  4468 
       
  4469 @param aTimeout The timeout value in microseconds
       
  4470 
       
  4471 @return KErrNone if the lock was acquired successfully.
       
  4472         KErrTimedOut if the timeout has expired.
       
  4473         KErrGeneral if the lock is being reset, i.e the lock
       
  4474         is about to  be deleted.
       
  4475         KErrArgument if aTimeout is negative;
       
  4476         otherwise one of the other system wide error codes.
       
  4477 */
       
  4478 EXPORT_C TInt RFastLock::Wait(TInt aTimeout)
       
  4479 	{
       
  4480 	if (aTimeout<=0)
       
  4481 		return KErrArgument;
       
  4482 	TInt orig = __e32_atomic_add_acq32(&iCount, TUint32(-1));
       
  4483 	if (orig == 0)
       
  4484 		return KErrNone;
       
  4485 	FOREVER
       
  4486 		{
       
  4487 		TInt r = Exec::SemaphoreWait(iHandle, aTimeout);
       
  4488 		if (r != KErrTimedOut)	// got lock OK or lock deleted
       
  4489 			return r;
       
  4490 		// Before we can return KErrTimedOut we must increment iCount (since we
       
  4491 		// previously decremented it in anticipation of acquiring the lock.
       
  4492 		// However we must not increment iCount if it would become zero, since
       
  4493 		// the semaphore will have been signalled (to counterbalance the Wait()
       
  4494 		// which timed out and thus never happened). This would result in two
       
  4495 		// threads being able to acquire the lock simultaneously - one by
       
  4496 		// decrementing iCount from 0 to -1 without looking at the semaphore,
       
  4497 		// and the other by decrementing iCount from -1 to -2 and then absorbing
       
  4498 		// the spurious semaphore signal.
       
  4499 		orig = __e32_atomic_tas_ord32(&iCount, -1, 0, 1);	// don't release lock completely
       
  4500 		if (orig < -1)
       
  4501 			return KErrTimedOut;	// count corrected - don't need to touch semaphore
       
  4502 		// lock is actually free at this point, try again to claim it
       
  4503 		aTimeout = 1;
       
  4504 		}
       
  4505 	}
       
  4506 #endif
       
  4507 
  4392 
  4508 EXPORT_C RCriticalSection::RCriticalSection()
  4393 EXPORT_C RCriticalSection::RCriticalSection()
  4509 	: iBlocked(1)
  4394 	: iBlocked(1)
  4510 /**
  4395 /**
  4511 Default constructor.
  4396 Default constructor.
  5440 	{
  5325 	{
  5441 
  5326 
  5442 	__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
  5327 	__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
  5443 	aStatus=KRequestPending;
  5328 	aStatus=KRequestPending;
  5444 	Exec::TimerHighRes(iHandle,aStatus,aInterval.Int());
  5329 	Exec::TimerHighRes(iHandle,aStatus,aInterval.Int());
  5445 	}
       
  5446 
       
  5447 
       
  5448 
       
  5449 
       
  5450 /**
       
  5451 Requests an event at a specified time after the last expiry of the this
       
  5452 timer object, to a resolution of 1ms. If the last usage of this timer object
       
  5453 was not via either this function or RTimer::HighRes(), this call behaves the
       
  5454 same as RTimer::HighRes().
       
  5455 The "HighRes timer" counter stops during power-down (the same as "after timer"). 
       
  5456 
       
  5457 @param aStatus    On completion, contains the status of the request.
       
  5458                   This is KErrNone if the timer completed normally at the
       
  5459                   requested time, otherwise another of the
       
  5460                   system-wide error codes. In particular KErrArgument indicates
       
  5461 				  that the requested expiry time has already passed.
       
  5462 
       
  5463 @param aInterval  The time interval, in microseconds, after which an event
       
  5464                   is to occur, measured from the last expiry time (or intended
       
  5465 				  expiry time in the case where the timer was cancelled) of this
       
  5466 				  timer object.
       
  5467 				  Note that the interval is allowed to be negative. To see why
       
  5468 				  this might be useful consider the following sequence of timer
       
  5469 				  operations:
       
  5470 					1. Timer expires at time T
       
  5471 					2. AgainHighRes(1000000) - timer is queued for T + 1 sec
       
  5472 					3. Cancel() - timer is not queued but last scheduled expiry
       
  5473 									is still at T + 1 second
       
  5474 					4. AgainHighRes(-500000)
       
  5475 					5. Timer expires at time T + 0.5 second
       
  5476 
       
  5477 @panic KERN-EXEC 15, if this function is called while a request for a timer
       
  5478        event is still outstanding.
       
  5479 */
       
  5480 EXPORT_C void RTimer::AgainHighRes(TRequestStatus &aStatus,TTimeIntervalMicroSeconds32 aInterval)
       
  5481 	{
       
  5482 	aStatus=KRequestPending;
       
  5483 	Exec::TimerAgainHighRes(iHandle,aStatus,aInterval.Int());
       
  5484 	}
  5330 	}
  5485 
  5331 
  5486 
  5332 
  5487 
  5333 
  5488 
  5334