util.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*************************************************************************
  2. * *
  3. * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
  4. * All rights reserved. Email: [email protected] Web: www.q12.org *
  5. * *
  6. * This library is free software; you can redistribute it and/or *
  7. * modify it under the terms of EITHER: *
  8. * (1) The GNU Lesser General Public License as published by the Free *
  9. * Software Foundation; either version 2.1 of the License, or (at *
  10. * your option) any later version. The text of the GNU Lesser *
  11. * General Public License is included with this library in the *
  12. * file LICENSE.TXT. *
  13. * (2) The BSD-style license that is included with this library in *
  14. * the file LICENSE-BSD.TXT. *
  15. * *
  16. * This library is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
  19. * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
  20. * *
  21. *************************************************************************/
  22. #ifndef _ODE_UTIL_H_
  23. #define _ODE_UTIL_H_
  24. #include "objects.h"
  25. /* the efficient alignment. most platforms align data structures to some
  26. * number of bytes, but this is not always the most efficient alignment.
  27. * for example, many x86 compilers align to 4 bytes, but on a pentium it
  28. * is important to align doubles to 8 byte boundaries (for speed), and
  29. * the 4 floats in a SIMD register to 16 byte boundaries. many other
  30. * platforms have similar behavior. setting a larger alignment can waste
  31. * a (very) small amount of memory. NOTE: this number must be a power of
  32. * two. this is set to 16 by default.
  33. */
  34. #ifndef EFFICIENT_ALIGNMENT
  35. #define EFFICIENT_ALIGNMENT 16
  36. #endif
  37. /* utility */
  38. /* round something up to be a multiple of the EFFICIENT_ALIGNMENT */
  39. #define dEFFICIENT_SIZE(x) ((((x)-1)|(EFFICIENT_ALIGNMENT-1))+1)
  40. /* alloca aligned to the EFFICIENT_ALIGNMENT. note that this can waste
  41. * up to 15 bytes per allocation, depending on what alloca() returns.
  42. */
  43. #define dALLOCA16(n) \
  44. ((char*)dEFFICIENT_SIZE(((size_t)(alloca((n)+(EFFICIENT_ALIGNMENT-1))))))
  45. void dInternalHandleAutoDisabling (dxWorld *world, dReal stepsize);
  46. void dxStepBody (dxBody *b, dReal h);
  47. typedef void (*dstepper_fn_t) (dxWorld *world, dxBody * const *body, int nb,
  48. dxJoint * const *_joint, int nj, dReal stepsize);
  49. void dxProcessIslands (dxWorld *world, dReal stepsize, dstepper_fn_t stepper);
  50. #endif