Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / gnu / usr.bin / as / flo-copy.c
1 /* flonum_copy.c - copy a flonum
2    Copyright (C) 1987, 1990, 1991, 1992 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 2, 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
18    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 /*
21  * $FreeBSD: src/gnu/usr.bin/as/flo-copy.c,v 1.5 1999/08/27 23:34:15 peter Exp $
22  * $DragonFly: src/gnu/usr.bin/as/Attic/flo-copy.c,v 1.2 2003/06/17 04:25:44 dillon Exp $
23  */
24 #include "as.h"
25
26 void
27     flonum_copy(in, out)
28 FLONUM_TYPE *in;
29 FLONUM_TYPE *out;
30 {
31         int in_length;  /* 0 origin */
32         int out_length; /* 0 origin */
33
34         out->sign = in->sign;
35         in_length = in->leader - in->low;
36
37         if (in_length < 0) {
38                 out->leader = out->low - 1; /* 0.0 case */
39         } else {
40                 out_length = out->high - out->low;
41                 /*
42                  * Assume no GAPS in packing of littlenums.
43                  * I.e. sizeof(array) == sizeof(element) * number_of_elements.
44                  */
45                 if (in_length <= out_length) {
46                         {
47                                 /*
48                                  * For defensive programming, zero any high-order littlenums we don't need.
49                                  * This is destroying evidence and wasting time, so why bother???
50                                  */
51                                 if (in_length < out_length) {
52 memset((char *)(out->low + in_length + 1), '\0', out_length - in_length);
53                                 }
54                         }
55                         memcpy((void *)(out->low), (void *)(in->low), (int)((in_length + 1) * sizeof(LITTLENUM_TYPE)));
56                         out->exponent = in->exponent;
57                         out->leader   = in->leader - in->low + out->low;
58                 } else {
59                         int     shorten;                /* 1-origin. Number of littlenums we drop. */
60
61                         shorten = in_length - out_length;
62                         /* Assume out_length >= 0 ! */
63                         memcpy((void *)( out->low), (void *)(in->low + shorten), (int)((out_length + 1) * sizeof(LITTLENUM_TYPE)));
64                         out->leader = out->high;
65                         out->exponent = in->exponent + shorten;
66                 }
67         } /* if any significant bits */
68 } /* flonum_copy() */
69
70 /* end of flonum_copy.c */