/* The transition from "non-FP supporting" to "FP supporting" must be done atomically to avoid confusing the floating point logic used by z_swap(), so this routine locks interrupts to ensure that a context switch does not occur. The locking isn't really needed when the routine is called by a cooperative thread (since context switching can't occur), but it is harmless.  */
void z_float_enable(struct k_thread *thread, unsigned int options)
/* The transition from "non-FP supporting" to "FP supporting" must be done atomically to avoid confusing the floating point logic used by z_swap(), so this routine locks interrupts to ensure that a context switch does not occur. The locking isn't really needed when the routine is called by a cooperative thread (since context switching can't occur), but it is harmless.  */
void z_float_enable(struct k_thread *thread, unsigned int options)
{
	unsigned int imask;
	struct k_thread *fp_owner;
	if (!thread) {
		return;
	}
	imask = irq_lock();
	thread->base.user_options |= (uint8_t)options;
	__asm__ volatile("clts\n\t");
	fp_owner = _kernel.current_fp;
	if (fp_owner != NULL) {
		if ((fp_owner->arch.flags & X86_THREAD_FLAG_ALL) != 0) {
			FpCtxSave(fp_owner);
		}
	}
	FpCtxInit(thread);
	if (thread == _current) {
		_kernel.current_fp = thread;
	} else {
		if ((_current->base.user_options & _FP_USER_MASK) == 0) {
			_kernel.current_fp = thread;
			z_FpAccessDisable();
		} else {
			FpCtxSave(thread);
		}
	}
	irq_unlock(imask);
}