00001 //--------------------------------------------------------------- 00002 // Go4 Release Package v2.10-5 (build 21005) 00003 // 03-Nov-2005 00004 //--------------------------------------------------------------- 00005 // The GSI Online Offline Object Oriented (Go4) Project 00006 // Experiment Data Processing at DVEE department, GSI 00007 //--------------------------------------------------------------- 00008 // 00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI 00010 // Planckstr. 1, 64291 Darmstadt, Germany 00011 //Contact: http://go4.gsi.de 00012 //---------------------------------------------------------------- 00013 //This software can be used under the license agreements as stated 00014 //in Go4License.txt file which is part of the distribution. 00015 //---------------------------------------------------------------- 00016 #include "typedefs.h" 00017 #define DEBUG 0 00018 /*2+F_SWAPLW****+******************************************************/ 00019 /* */ 00020 /*+ Module : F_SWAPLW */ 00021 /* */ 00022 /* */ 00023 /*--------------------------------------------------------------------*/ 00024 /*+ CALLING : sts = f_swaplw(pp_source, */ 00025 /* l_len, */ 00026 /* pp_dest) */ 00027 /* */ 00028 /*--------------------------------------------------------------------*/ 00029 /* */ 00030 /*+ PURPOSE : Long word byte swap. */ 00031 /* */ 00032 /*+ ARGUMENTS : */ 00033 /*+ pp_source : Pointer to source. */ 00034 /*+ l_dest : length (in long words) */ 00035 /*+ pp_dest : Pointer to destination or 0 if */ 00036 /* destination = source. */ 00037 /* */ 00038 /*+ FUNCTION : Long word byte swap. Works on the source field if */ 00039 /* pp_dest points to value 0 or swaps from the source */ 00040 /* to the destination field. */ 00041 /* (Should be replaced by a fast assembler routine) */ 00042 /* */ 00043 /*+ Return type : int (see s_errnum_def.h) */ 00044 /*+ Status codes: bit 0: success */ 00045 /* */ 00046 /*+ Initialize : - */ 00047 /*+ Include name: - */ 00048 /* */ 00049 /*3+Implementation************+****************************************/ 00050 /* */ 00051 /*+ File name : PC_PROC.C */ 00052 /*+ Version : 1.01 */ 00053 /*+ Author : R.S. Mayer */ 00054 /*+ Last Update : 27-Apr-1994 */ 00055 /*+ Object libr.: ? */ 00056 /*3+Updates*******+***********+****************************************/ 00057 /* */ 00058 /*+ Updates : Date Purpose */ 00059 /* */ 00060 /*3+Description***+***********+****************************************/ 00061 /*1- C Procedure ***********+******************************************/ 00062 #include <stdio.h> 00063 #include <stdlib.h> 00064 #include <string.h> 00065 #include <errno.h> 00066 00067 /* function prototypes */ 00068 00069 /* defines */ 00070 00071 int f_swaplw(int *pp_source, int l_len, int *pp_dest) 00072 00073 { 00074 unsigned char *p_source, *p_dest, *p_s, *p_d; 00075 unsigned int lu_save; 00076 00077 /* +++ action +++ */ 00078 p_source = (unsigned char *) pp_source; 00079 p_dest = (unsigned char *) pp_dest; 00080 00081 if (p_dest == NULL) 00082 { 00083 /* source == destination */ 00084 for (p_d = (unsigned char *) p_source, 00085 p_s = (unsigned char *) &lu_save; 00086 p_d < p_source + (l_len * 4); 00087 ) 00088 { 00089 lu_save = *( (int *) p_d); 00090 p_s += 4; /* increment source */ 00091 *(p_d++) = *(--p_s); 00092 *(p_d++) = *(--p_s); 00093 *(p_d++) = *(--p_s); 00094 *(p_d++) = *(--p_s); 00095 } 00096 } 00097 else 00098 { 00099 for (p_s = (unsigned char *) p_source, 00100 p_d = (unsigned char *) p_dest; 00101 p_s < p_source + (l_len * 4); 00102 p_s += 4) 00103 { 00104 p_s += 4; /* increment source */ 00105 *(p_d++) = *(--p_s); 00106 *(p_d++) = *(--p_s); 00107 *(p_d++) = *(--p_s); 00108 *(p_d++) = *(--p_s); 00109 } 00110 00111 } /* dest == 0 */ 00112 00113 return(0); 00114 } 00115 00116 00117 //----------------------------END OF GO4 SOURCE FILE ---------------------