kernel/eka/euser/us_exec.cpp
branchRCL_3
changeset 256 c1f20ce4abcf
parent 62 4a8fed1c0ef6
child 257 3e88ff8f41d5
equal deleted inserted replaced
249:a179b74831c9 256:c1f20ce4abcf
  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, system wide error if not
  2890 @return KErrNone if successful, KErrNotSupported if the DLL name matches the pattern
       
  2891 of a new-style locale library, system wide error otherwise
  2891 
  2892 
  2892 @see TExtendedLocale::SaveSystemSettings 
  2893 @see TExtendedLocale::SaveSystemSettings 
  2893 */
  2894 */
  2894 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLocaleDllName)
  2895 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLocaleDllName)
  2895 	{
  2896 	{
  2896 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  2897 #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 		}
  2897 	TLibraryFunction data[KNumLocaleExports];
  2902 	TLibraryFunction data[KNumLocaleExports];
  2898 	TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
  2903 	TInt r = DoLoadLocale(aLocaleDllName, &data[0]);
  2899 	if(r == KErrNone)
  2904 	if(r == KErrNone)
  2900 		{
  2905 		{
  2901 		iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
  2906 		iLocale.iExtraNegativeCurrencyFormatFlags=0x80000000;
  2991 with the locale information stored in the DLLs. The locale information is only
  2996 with the locale information stored in the DLLs. The locale information is only
  2992 stored in this TExtendedLocale. If you want to set the system wide settings with
  2997 stored in this TExtendedLocale. If you want to set the system wide settings with
  2993 the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
  2998 the locale information in the DLL, you can call TExtendedLocale::SaveSystemSettings
  2994 after calling this function.
  2999 after calling this function.
  2995 
  3000 
       
  3001 If the function fails then it will call LoadSystemSettings() to return its members
       
  3002 to a known, good state.
       
  3003 
  2996 @param aLanguageLocaleDllName The name of the language locale DLL to be loaded
  3004 @param aLanguageLocaleDllName The name of the language locale DLL to be loaded
  2997 @param aRegionLocaleDllName The name of the region locale DLL to be loaded
  3005 @param aRegionLocaleDllName The name of the region locale DLL to be loaded
  2998 @param aCollationLocaleDllName The name of the collation locale DLL to be loaded
  3006 @param aCollationLocaleDllName The name of the collation locale DLL to be loaded
  2999 
  3007 
  3000 @return KErrNone if successful, system wide error if not
  3008 @return KErrNone if successful, system wide error if not
  3004 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  3012 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
  3005 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLanguageLocaleDllName, 
  3013 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& aLanguageLocaleDllName, 
  3006 		const TDesC& aRegionLocaleDllName, 
  3014 		const TDesC& aRegionLocaleDllName, 
  3007 		const TDesC& aCollationLocaleDllName)
  3015 		const TDesC& aCollationLocaleDllName)
  3008 	{
  3016 	{
  3009 
       
  3010 	TInt err = LoadLocaleAspect(aLanguageLocaleDllName);
  3017 	TInt err = LoadLocaleAspect(aLanguageLocaleDllName);
       
  3018 
       
  3019 	if(err == KErrNone)
       
  3020 		err = LoadLocaleAspect(aRegionLocaleDllName);
       
  3021 
       
  3022 	if(err == KErrNone)
       
  3023 		err = LoadLocaleAspect(aCollationLocaleDllName);
       
  3024 
  3011 	if(err != KErrNone)
  3025 	if(err != KErrNone)
  3012 		return err;
  3026 		LoadSystemSettings();	
  3013 	
       
  3014 	err = LoadLocaleAspect(aRegionLocaleDllName);
       
  3015 	if(err != KErrNone)
       
  3016 		return err;
       
  3017 	
       
  3018 	err = LoadLocaleAspect(aCollationLocaleDllName);
       
  3019 	if(err != KErrNone)
       
  3020 		return err;	
       
  3021 
  3027 
  3022 	return err;	
  3028 	return err;	
  3023 	}
  3029 	}
  3024 #else
  3030 #else
  3025 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& /*aLanguageLocaleDllName*/, 
  3031 EXPORT_C TInt TExtendedLocale::LoadLocale(const TDesC& /*aLanguageLocaleDllName*/, 
  3766 free. If the mutex is already held by the current thread a count is maintained
  3772 free. If the mutex is already held by the current thread a count is maintained
  3767 of how many times the thread has acquired the mutex.
  3773 of how many times the thread has acquired the mutex.
  3768 */
  3774 */
  3769 EXPORT_C void RMutex::Wait()
  3775 EXPORT_C void RMutex::Wait()
  3770 	{
  3776 	{
  3771 
  3777 	Exec::MutexWait(iHandle, 0);
  3772 	Exec::MutexWait(iHandle);
  3778 	}
       
  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;
  3773 	}
  3830 	}
  3774 
  3831 
  3775 
  3832 
  3776 
  3833 
  3777 
  3834 
  4306 	}
  4363 	}
  4307 
  4364 
  4308 
  4365 
  4309 
  4366 
  4310 
  4367 
  4311 EXPORT_C void RSemaphore::Wait()
       
  4312 /**
  4368 /**
  4313 Waits for a signal on the semaphore.
  4369 Waits for a signal on the semaphore.
  4314 
  4370 
  4315 The function decrements the semaphore count by one and returns immediately 
  4371 The function decrements the semaphore count by one and returns immediately 
  4316 if it is zero or positive.
  4372 if it is zero or positive.
  4322 be waiting on a particular semaphore at a time. When there are multiple threads 
  4378 be waiting on a particular semaphore at a time. When there are multiple threads 
  4323 waiting on a semaphore, they are released in priority order.
  4379 waiting on a semaphore, they are released in priority order.
  4324 
  4380 
  4325 If the semaphore is deleted, all threads waiting on that semaphore are released.
  4381 If the semaphore is deleted, all threads waiting on that semaphore are released.
  4326 */
  4382 */
  4327 	{
  4383 EXPORT_C void RSemaphore::Wait()
  4328 
  4384 	{
  4329 	Exec::SemaphoreWait(iHandle, 0);
  4385 	Exec::SemaphoreWait(iHandle, 0);
  4330 	}
  4386 	}
  4331 
  4387 
  4332 
  4388 
  4333 
       
  4334 
       
  4335 EXPORT_C TInt RSemaphore::Wait(TInt aTimeout)
       
  4336 /**
  4389 /**
  4337 Waits for a signal on the semaphore, or a timeout.
  4390 Waits for a signal on the semaphore, or a timeout.
  4338 
  4391 
  4339 @param aTimeout The timeout value in micoseconds
  4392 @param aTimeout The timeout value in microseconds
  4340 
  4393 
  4341 @return KErrNone if the wait has completed normally.
  4394 @return KErrNone if the wait has completed normally.
  4342         KErrTimedOut if the timeout has expired.
  4395         KErrTimedOut if the timeout has expired.
  4343         KErrGeneral if the semaphore is being reset, i.e the semaphore
  4396         KErrGeneral if the semaphore is being reset, i.e the semaphore
  4344         is about to  be deleted.
  4397         is about to  be deleted.
  4345         KErrArgument if aTimeout is negative;
  4398         KErrArgument if aTimeout is negative;
  4346         otherwise one of the other system wide error codes.
  4399         otherwise one of the other system wide error codes.
  4347 */
  4400 */
  4348 	{
  4401 EXPORT_C TInt RSemaphore::Wait(TInt aTimeout)
  4349 
  4402 	{
  4350 	return Exec::SemaphoreWait(iHandle, aTimeout);
  4403 	if (aTimeout>=0)
  4351 	}
  4404 		return Exec::SemaphoreWait(iHandle, aTimeout);
  4352 
  4405 	return KErrArgument;
  4353 
  4406 	}
       
  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 	}
  4354 
  4421 
  4355 
  4422 
  4356 EXPORT_C void RSemaphore::Signal()
  4423 EXPORT_C void RSemaphore::Signal()
  4357 /**
  4424 /**
  4358 Signals the semaphore once.
  4425 Signals the semaphore once.
  4387 	Exec::SemaphoreSignalN(iHandle,aCount);
  4454 	Exec::SemaphoreSignalN(iHandle,aCount);
  4388 	}
  4455 	}
  4389 
  4456 
  4390 
  4457 
  4391 
  4458 
       
  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
  4392 
  4507 
  4393 EXPORT_C RCriticalSection::RCriticalSection()
  4508 EXPORT_C RCriticalSection::RCriticalSection()
  4394 	: iBlocked(1)
  4509 	: iBlocked(1)
  4395 /**
  4510 /**
  4396 Default constructor.
  4511 Default constructor.
  5325 	{
  5440 	{
  5326 
  5441 
  5327 	__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
  5442 	__ASSERT_ALWAYS(aInterval.Int()>=0,::Panic(ERTimerAfterTimeNegative));
  5328 	aStatus=KRequestPending;
  5443 	aStatus=KRequestPending;
  5329 	Exec::TimerHighRes(iHandle,aStatus,aInterval.Int());
  5444 	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());
  5330 	}
  5484 	}
  5331 
  5485 
  5332 
  5486 
  5333 
  5487 
  5334 
  5488