negdi2.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* More subroutines needed by GCC output code on some machines. */
  2. /* Compile this one with gcc. */
  3. /* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
  4. 2000, 2001 Free Software Foundation, Inc.
  5. This file is part of GNU CC.
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public Licence as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10. In addition to the permissions in the GNU General Public Licence, the
  11. Free Software Foundation gives you unlimited permission to link the
  12. compiled version of this file into combinations with other programs,
  13. and to distribute those combinations without any restriction coming
  14. from the use of this file. (The General Public Licence restrictions
  15. do apply in other respects; for example, they cover modification of
  16. the file, and distribution when not linked into a combine
  17. executable.)
  18. GNU CC is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. GNU General Public Licence for more details.
  22. You should have received a copy of the GNU General Public Licence
  23. along with GNU CC; see the file COPYING. If not, write to
  24. the Free Software Foundation, 59 Temple Place - Suite 330,
  25. Boston, MA 02111-1307, USA. */
  26. /* It is incorrect to include config.h here, because this file is being
  27. compiled for the target, and hence definitions concerning only the host
  28. do not apply. */
  29. #include <linux/types.h>
  30. union DWunion {
  31. s64 ll;
  32. struct {
  33. s32 low;
  34. s32 high;
  35. } s;
  36. };
  37. s64 __negdi2(s64 u)
  38. {
  39. union DWunion w;
  40. union DWunion uu;
  41. uu.ll = u;
  42. w.s.low = -uu.s.low;
  43. w.s.high = -uu.s.high - ((u32) w.s.low > 0);
  44. return w.ll;
  45. }