Coverage Report

Created: 2025-06-24 06:45

/src/binutils-gdb/gas/flonum-copy.c
Line
Count
Source (jump to first uncovered line)
1
/* flonum_copy.c - copy a flonum
2
   Copyright (C) 1987-2025 Free Software Foundation, Inc.
3
4
   This file is part of GAS, the GNU Assembler.
5
6
   GAS is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3, or (at your option)
9
   any later version.
10
11
   GAS is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
16
   You should have received a copy of the GNU General Public License
17
   along with GAS; see the file COPYING.  If not, write to the Free
18
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19
   02110-1301, USA.  */
20
21
#include "as.h"
22
23
void
24
flonum_copy (FLONUM_TYPE *in, FLONUM_TYPE *out)
25
7.11k
{
26
7.11k
  unsigned int in_length; /* 0 origin */
27
7.11k
  unsigned int out_length;  /* 0 origin */
28
29
7.11k
  out->sign = in->sign;
30
7.11k
  in_length = in->leader - in->low;
31
32
7.11k
  if (in->leader < in->low)
33
0
    {
34
0
      out->leader = out->low - 1; /* 0.0 case */
35
0
    }
36
7.11k
  else
37
7.11k
    {
38
7.11k
      out_length = out->high - out->low;
39
      /* Assume no GAPS in packing of littlenums.
40
   I.e. sizeof(array) == sizeof(element) * number_of_elements.  */
41
7.11k
      if (in_length <= out_length)
42
7.11k
  {
43
7.11k
    {
44
      /* For defensive programming, zero any high-order
45
         littlenums we don't need.  This is destroying evidence
46
         and wasting time, so why bother???  */
47
7.11k
      if (in_length < out_length)
48
127
        {
49
127
    memset ((char *) (out->low + in_length + 1), '\0',
50
127
      out_length - in_length);
51
127
        }
52
7.11k
    }
53
7.11k
    memcpy ((void *) (out->low), (void *) (in->low),
54
7.11k
      ((in_length + 1) * sizeof (LITTLENUM_TYPE)));
55
7.11k
    out->exponent = in->exponent;
56
7.11k
    out->leader = in->leader - in->low + out->low;
57
7.11k
  }
58
0
      else
59
0
  {
60
0
    int shorten;    /* 1-origin. Number of littlenums we drop.  */
61
62
0
    shorten = in_length - out_length;
63
    /* Assume out_length >= 0 ! */
64
0
    memcpy ((void *) (out->low), (void *) (in->low + shorten),
65
0
      ((out_length + 1) * sizeof (LITTLENUM_TYPE)));
66
0
    out->leader = out->high;
67
0
    out->exponent = in->exponent + shorten;
68
0
  }
69
7.11k
    }       /* if any significant bits */
70
7.11k
}