ReactOS  0.4.13-dev-1149-g95dd1c6
xdr_float.c File Reference
#include <wintirpc.h>
#include "namespace.h"
#include <sys/types.h>
#include <stdio.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include "un-namespace.h"
Include dependency graph for xdr_float.c:

Go to the source code of this file.

Macros

#define IEEEFP
 

Functions

bool_t xdr_float (XDR *xdrs, float *fp)
 
bool_t xdr_double (XDR *xdrs, double *dp)
 

Macro Definition Documentation

◆ IEEEFP

#define IEEEFP

Definition at line 90 of file xdr_float.c.

Function Documentation

◆ xdr_double()

bool_t xdr_double ( XDR xdrs,
double dp 
)

Definition at line 197 of file xdr_float.c.

200 {
201 #ifdef IEEEFP
202  int32_t *i32p;
203  bool_t rv;
204 #else
205  int32_t *lp;
206  struct ieee_double id;
207  struct vax_double vd;
208  struct dbl_limits *lim;
209  int i;
210 #endif
211 
212  switch (xdrs->x_op) {
213 
214  case XDR_ENCODE:
215 #ifdef IEEEFP
216  i32p = (int32_t *)(void *)dp;
217 #if BYTE_ORDER == BIG_ENDIAN
218  rv = XDR_PUTINT32(xdrs, i32p);
219  if (!rv)
220  return (rv);
221  rv = XDR_PUTINT32(xdrs, i32p+1);
222 #else
223  rv = XDR_PUTINT32(xdrs, i32p+1);
224  if (!rv)
225  return (rv);
226  rv = XDR_PUTINT32(xdrs, i32p);
227 #endif
228  return (rv);
229 #else
230  vd = *((struct vax_double *)dp);
231  for (i = 0, lim = dbl_limits;
232  i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
233  i++, lim++) {
234  if ((vd.mantissa4 == lim->d.mantissa4) &&
235  (vd.mantissa3 == lim->d.mantissa3) &&
236  (vd.mantissa2 == lim->d.mantissa2) &&
237  (vd.mantissa1 == lim->d.mantissa1) &&
238  (vd.exp == lim->d.exp)) {
239  id = lim->ieee;
240  goto shipit;
241  }
242  }
243  id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
244  id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3);
245  id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) |
246  (vd.mantissa3 << 13) |
247  ((vd.mantissa4 >> 3) & MASK(13));
248  shipit:
249  id.sign = vd.sign;
250  lp = (int32_t *)&id;
251  return (XDR_PUTINT32(xdrs, lp++) && XDR_PUTINT32(xdrs, lp));
252 #endif
253 
254  case XDR_DECODE:
255 #ifdef IEEEFP
256  i32p = (int32_t *)(void *)dp;
257 #if BYTE_ORDER == BIG_ENDIAN
258  rv = XDR_GETINT32(xdrs, i32p);
259  if (!rv)
260  return (rv);
261  rv = XDR_GETINT32(xdrs, i32p+1);
262 #else
263  rv = XDR_GETINT32(xdrs, i32p+1);
264  if (!rv)
265  return (rv);
266  rv = XDR_GETINT32(xdrs, i32p);
267 #endif
268  return (rv);
269 #else
270  lp = (int32_t *)&id;
271  if (!XDR_GETINT32(xdrs, lp++) || !XDR_GETINT32(xdrs, lp))
272  return (FALSE);
273  for (i = 0, lim = dbl_limits;
274  i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
275  i++, lim++) {
276  if ((id.mantissa2 == lim->ieee.mantissa2) &&
277  (id.mantissa1 == lim->ieee.mantissa1) &&
278  (id.exp == lim->ieee.exp)) {
279  vd = lim->d;
280  goto doneit;
281  }
282  }
283  vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
284  vd.mantissa1 = (id.mantissa1 >> 13);
285  vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) |
286  (id.mantissa2 >> 29);
287  vd.mantissa3 = (id.mantissa2 >> 13);
288  vd.mantissa4 = (id.mantissa2 << 3);
289  doneit:
290  vd.sign = id.sign;
291  *dp = *((double *)&vd);
292  return (TRUE);
293 #endif
294 
295  case XDR_FREE:
296  return (TRUE);
297  }
298  /* NOTREACHED */
299  return (FALSE);
300 }
#define TRUE
Definition: types.h:120
#define XDR_PUTINT32(xdrs, int32p)
Definition: xdr.h:187
int32_t bool_t
Definition: types.h:101
ULONG MASK
Definition: afilter.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define XDR_GETINT32(xdrs, int32p)
Definition: xdr.h:186
enum xdr_op x_op
Definition: xdr.h:104
Definition: xdr.h:85
INT32 int32_t
Definition: types.h:71
DWORD exp
Definition: msg.c:15681
Definition: xdr.h:87
Definition: xdr.h:86
GLenum GLuint id
Definition: glext.h:5579

◆ xdr_float()

bool_t xdr_float ( XDR xdrs,
float *  fp 
)

Definition at line 95 of file xdr_float.c.

98 {
99 #ifndef IEEEFP
100  struct ieee_single is;
101  struct vax_single vs, *vsp;
102  struct sgl_limits *lim;
103  int i;
104 #endif
105  switch (xdrs->x_op) {
106 
107  case XDR_ENCODE:
108 #ifdef IEEEFP
109  return (XDR_PUTINT32(xdrs, (int32_t *)fp));
110 #else
111  vs = *((struct vax_single *)fp);
112  for (i = 0, lim = sgl_limits;
113  i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
114  i++, lim++) {
115  if ((vs.mantissa2 == lim->s.mantissa2) &&
116  (vs.exp == lim->s.exp) &&
117  (vs.mantissa1 == lim->s.mantissa1)) {
118  is = lim->ieee;
119  goto shipit;
120  }
121  }
122  is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
123  is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2;
124  shipit:
125  is.sign = vs.sign;
126  return (XDR_PUTINT32(xdrs, (int32_t *)&is));
127 #endif
128 
129  case XDR_DECODE:
130 #ifdef IEEEFP
131  return (XDR_GETINT32(xdrs, (int32_t *)fp));
132 #else
133  vsp = (struct vax_single *)fp;
134  if (!XDR_GETINT32(xdrs, (int32_t *)&is))
135  return (FALSE);
136  for (i = 0, lim = sgl_limits;
137  i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
138  i++, lim++) {
139  if ((is.exp == lim->ieee.exp) &&
140  (is.mantissa == lim->ieee.mantissa)) {
141  *vsp = lim->s;
142  goto doneit;
143  }
144  }
145  vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
146  vsp->mantissa2 = is.mantissa;
147  vsp->mantissa1 = (is.mantissa >> 16);
148  doneit:
149  vsp->sign = is.sign;
150  return (TRUE);
151 #endif
152 
153  case XDR_FREE:
154  return (TRUE);
155  }
156  /* NOTREACHED */
157  return (FALSE);
158 }
return
Definition: dirsup.c:529
#define TRUE
Definition: types.h:120
#define XDR_PUTINT32(xdrs, int32p)
Definition: xdr.h:187
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define XDR_GETINT32(xdrs, int32p)
Definition: xdr.h:186
enum xdr_op x_op
Definition: xdr.h:104
Definition: xdr.h:85
INT32 int32_t
Definition: types.h:71
Definition: xdr.h:87
Definition: xdr.h:86