Blame libfreerdp/primitives/prim_sign.c

Packit Service fa4841
/* FreeRDP: A Remote Desktop Protocol Client
Packit Service fa4841
 * Sign operations.
Packit Service fa4841
 * vi:ts=4 sw=4:
Packit Service fa4841
 *
Packit Service fa4841
 * (c) Copyright 2012 Hewlett-Packard Development Company, L.P.
Packit Service fa4841
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
Packit Service fa4841
 * not use this file except in compliance with the License. You may obtain
Packit Service fa4841
 * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
Packit Service fa4841
 * Unless required by applicable law or agreed to in writing, software
Packit Service fa4841
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit Service fa4841
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
Packit Service fa4841
 * or implied. See the License for the specific language governing
Packit Service fa4841
 * permissions and limitations under the License.
Packit Service fa4841
 */
Packit Service fa4841
Packit Service fa4841
#ifdef HAVE_CONFIG_H
Packit Service fa4841
#include "config.h"
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#include <freerdp/types.h>
Packit Service fa4841
#include <freerdp/primitives.h>
Packit Service fa4841
Packit Service fa4841
#include "prim_internal.h"
Packit Service fa4841
Packit Service fa4841
/* ----------------------------------------------------------------------------
Packit Service fa4841
 * Set pDst to the sign-value of the 16-bit values in pSrc (-1, 0, or 1).
Packit Service fa4841
 */
Packit Service fa4841
static pstatus_t general_sign_16s(const INT16* pSrc, INT16* pDst, UINT32 len)
Packit Service fa4841
{
Packit Service fa4841
	while (len--)
Packit Service fa4841
	{
Packit Service fa4841
		INT16 src = *pSrc++;
Packit Service fa4841
		*pDst++ = (src < 0) ? (-1) : ((src > 0) ? 1 : 0);
Packit Service fa4841
	}
Packit Service fa4841
Packit Service fa4841
	return PRIMITIVES_SUCCESS;
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
/* ------------------------------------------------------------------------- */
Packit Service fa4841
void primitives_init_sign(primitives_t* prims)
Packit Service fa4841
{
Packit Service fa4841
	/* Start with the default. */
Packit Service fa4841
	prims->sign_16s = general_sign_16s;
Packit Service fa4841
}