FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
swaplw.c
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 /********************************************************************
9  * Copyright:
10  * GSI, Gesellschaft fuer Schwerionenforschung mbH
11  * Planckstr. 1
12  * D-64291 Darmstadt
13  * Germany
14  * created 6.12.1995 by Ralph S. Mayer
15  ****************************+***************************************
16  * makes 4byte swap
17  ****************************+***************************************
18  */
19 
20 long swaplw(pp_source, l_len, pp_dest) long *pp_source, *pp_dest;
21 long l_len;
22 {
23 
24  char unsigned *p_source, *p_dest, *p_s, *p_d;
25  // char c_modnam[] = "f_swaplw";
26  long unsigned lu_save;
27 
28  /* +++ action +++ */
29  p_source = (unsigned char *)pp_source;
30  p_dest = (unsigned char *)pp_dest;
31 
32  if (p_dest) {
33  /* source != destination */
34  for (p_s = (unsigned char *)p_source, p_d = (unsigned char *)p_dest; p_s < p_source + (l_len * 4); p_s += 4) {
35  p_s += 4; /* increment source */
36  *(p_d++) = *(--p_s);
37  *(p_d++) = *(--p_s);
38  *(p_d++) = *(--p_s);
39  *(p_d++) = *(--p_s);
40  }
41  } else {
42  /* source == destination */
43  for (p_d = (unsigned char *)p_source, p_s = (unsigned char *)&lu_save; p_d < p_source + (l_len * 4);) {
44  lu_save = *((long *)p_d);
45  p_s += 4; /* increment source */
46  *(p_d++) = *(--p_s);
47  *(p_d++) = *(--p_s);
48  *(p_d++) = *(--p_s);
49  *(p_d++) = *(--p_s);
50  }
51  }
52 
53  return (1);
54 
55 } /* swaplw */
long swaplw(int *, int, int)