Blame libfreerdp/primitives/prim_sign.c

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