| 1 |
/* |
| 2 |
Copyright (c) 2023, David Anderson All rights reserved. |
| 3 |
|
| 4 |
Redistribution and use in source and binary forms, with |
| 5 |
or without modification, are permitted provided that the |
| 6 |
following conditions are met: |
| 7 |
|
| 8 |
Redistributions of source code must retain the above |
| 9 |
copyright notice, this list of conditions and the following |
| 10 |
disclaimer. |
| 11 |
|
| 12 |
Redistributions in binary form must reproduce the above |
| 13 |
copyright notice, this list of conditions and the following |
| 14 |
disclaimer in the documentation and/or other materials |
| 15 |
provided with the distribution. |
| 16 |
|
| 17 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
| 18 |
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| 19 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 22 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 24 |
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 26 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 28 |
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 29 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 |
*/ |
| 31 |
|
| 32 |
/* Thanks to David Grayson/ |
| 33 |
codereview.stackexchange.com/questions/98791/ |
| 34 |
safe-multiplication-of-two-64-bit-signed-integers |
| 35 |
*/ |
| 36 |
|
| 37 |
int _dwarf_int64_mult(Dwarf_Signed x, Dwarf_Signed y, |
| 38 |
Dwarf_Signed * result, |
| 39 |
Dwarf_Debug dbg, Dwarf_Error*error); |
| 40 |
|
| 41 |
int _dwarf_uint64_mult(Dwarf_Unsigned x, Dwarf_Unsigned y, |
| 42 |
Dwarf_Unsigned * result, |
| 43 |
Dwarf_Debug dbg, Dwarf_Error *error); |
| 44 |
|
| 45 |
#if 0 |
| 46 |
/* See: |
| 47 |
https://stackoverflow.com/questions/ |
| 48 |
3944505/detecting-signed-overflow-in-c-c |
| 49 |
*/ |
| 50 |
int _dwarf_signed_add_check(Dwarf_Signed l, Dwarf_Signed r, |
| 51 |
Dwarf_Signed *sum, Dwarf_Debug dbg, |
| 52 |
Dwarf_Error *error); |
| 53 |
#endif /* 0 */ |