/src/FreeRDP/libfreerdp/primitives/prim_sign.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* FreeRDP: A Remote Desktop Protocol Client |
2 | | * Sign operations. |
3 | | * vi:ts=4 sw=4: |
4 | | * |
5 | | * (c) Copyright 2012 Hewlett-Packard Development Company, L.P. |
6 | | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
7 | | * not use this file except in compliance with the License. You may obtain |
8 | | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. |
9 | | * Unless required by applicable law or agreed to in writing, software |
10 | | * distributed under the License is distributed on an "AS IS" BASIS, |
11 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
12 | | * or implied. See the License for the specific language governing |
13 | | * permissions and limitations under the License. |
14 | | */ |
15 | | |
16 | | #include <freerdp/config.h> |
17 | | |
18 | | #include <freerdp/types.h> |
19 | | #include <freerdp/primitives.h> |
20 | | |
21 | | #include "prim_internal.h" |
22 | | #include "prim_sign.h" |
23 | | |
24 | | /* ---------------------------------------------------------------------------- |
25 | | * Set pDst to the sign-value of the 16-bit values in pSrc (-1, 0, or 1). |
26 | | */ |
27 | | static pstatus_t general_sign_16s(const INT16* WINPR_RESTRICT pSrc, INT16* WINPR_RESTRICT pDst, |
28 | | UINT32 len) |
29 | 0 | { |
30 | 0 | while (len--) |
31 | 0 | { |
32 | 0 | INT16 src = *pSrc++; |
33 | 0 | *pDst++ = WINPR_ASSERTING_INT_CAST(int16_t, (src < 0) ? (-1) : ((src > 0) ? 1 : 0)); |
34 | 0 | } |
35 | | |
36 | 0 | return PRIMITIVES_SUCCESS; |
37 | 0 | } |
38 | | |
39 | | /* ------------------------------------------------------------------------- */ |
40 | | void primitives_init_sign(primitives_t* WINPR_RESTRICT prims) |
41 | 0 | { |
42 | | /* Start with the default. */ |
43 | 0 | prims->sign_16s = general_sign_16s; |
44 | 0 | } |
45 | | |
46 | | void primitives_init_sign_opt(primitives_t* WINPR_RESTRICT prims) |
47 | 0 | { |
48 | 0 | primitives_init_sign(prims); |
49 | 0 | primitives_init_sign_ssse3(prims); |
50 | 0 | } |