Fri, 20 Dec 2019 14:29:41 +0100
adds proper cmake build targets
universe@114 | 1 | /** |
universe@114 | 2 | * @mainpage UAP Common Extensions |
universe@114 | 3 | * Library with common and useful functions, macros and data structures. |
universe@114 | 4 | * <p> |
universe@259 | 5 | * Latest available source:<br> |
universe@259 | 6 | * <a href="https://sourceforge.net/projects/ucx/files/"> |
universe@259 | 7 | * https://sourceforge.net/projects/ucx/files/</a> |
universe@259 | 8 | * </p> |
universe@259 | 9 | * |
universe@259 | 10 | * <p> |
universe@259 | 11 | * Repositories:<br> |
universe@263 | 12 | * <a href="https://sourceforge.net/p/ucx/code"> |
universe@263 | 13 | * https://sourceforge.net/p/ucx/code</a> |
universe@259 | 14 | * - or - |
universe@114 | 15 | * <a href="https://develop.uap-core.de/hg/ucx"> |
universe@114 | 16 | * https://develop.uap-core.de/hg/ucx</a> |
universe@114 | 17 | * </p> |
universe@114 | 18 | * |
universe@114 | 19 | * <h2>LICENCE</h2> |
universe@114 | 20 | * |
universe@259 | 21 | * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved. |
universe@114 | 22 | * |
universe@114 | 23 | * Redistribution and use in source and binary forms, with or without |
universe@114 | 24 | * modification, are permitted provided that the following conditions are met: |
universe@114 | 25 | * |
universe@114 | 26 | * 1. Redistributions of source code must retain the above copyright |
universe@114 | 27 | * notice, this list of conditions and the following disclaimer. |
universe@114 | 28 | * |
universe@114 | 29 | * 2. Redistributions in binary form must reproduce the above copyright |
universe@114 | 30 | * notice, this list of conditions and the following disclaimer in the |
universe@114 | 31 | * documentation and/or other materials provided with the distribution. |
universe@114 | 32 | * |
universe@114 | 33 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
universe@114 | 34 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
universe@114 | 35 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
universe@114 | 36 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
universe@114 | 37 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
universe@114 | 38 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
universe@114 | 39 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
universe@114 | 40 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
universe@114 | 41 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
universe@114 | 42 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
universe@114 | 43 | * POSSIBILITY OF SUCH DAMAGE. |
universe@114 | 44 | */ |
universe@114 | 45 | |
universe@251 | 46 | #include "ucx/ucx.h" |
olaf@270 | 47 | |
olaf@331 | 48 | int ucx_szmul_impl(size_t a, size_t b, size_t *result) { |
olaf@270 | 49 | if(a == 0 || b == 0) { |
olaf@270 | 50 | *result = 0; |
universe@273 | 51 | return 0; |
olaf@270 | 52 | } |
olaf@270 | 53 | size_t r = a * b; |
olaf@270 | 54 | if(r / b == a) { |
olaf@270 | 55 | *result = r; |
olaf@270 | 56 | return 0; |
olaf@270 | 57 | } else { |
olaf@270 | 58 | *result = 0; |
olaf@270 | 59 | return 1; |
olaf@270 | 60 | } |
olaf@270 | 61 | } |
universe@273 | 62 |