patch-gcc_ada_s-osinte-openbsd_adb 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. $OpenBSD: patch-gcc_ada_s-osinte-openbsd_adb,v 1.1.1.1 2014/06/26 16:30:15 pascal Exp $
  2. --- gcc/ada/s-osinte-openbsd.adb.orig Mon Jun 17 16:05:29 2013
  3. +++ gcc/ada/s-osinte-openbsd.adb Mon Jun 17 17:12:06 2013
  4. @@ -0,0 +1,115 @@
  5. +------------------------------------------------------------------------------
  6. +-- --
  7. +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
  8. +-- --
  9. +-- S Y S T E M . O S _ I N T E R F A C E --
  10. +-- --
  11. +-- B o d y --
  12. +-- --
  13. +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. --
  14. +-- --
  15. +-- GNARL is free software; you can redistribute it and/or modify it under --
  16. +-- terms of the GNU General Public License as published by the Free Soft- --
  17. +-- ware Foundation; either version 3, or (at your option) any later ver- --
  18. +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
  19. +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
  20. +-- or FITNESS FOR A PARTICULAR PURPOSE. --
  21. +-- --
  22. +-- As a special exception under Section 7 of GPL version 3, you are granted --
  23. +-- additional permissions described in the GCC Runtime Library Exception, --
  24. +-- version 3.1, as published by the Free Software Foundation. --
  25. +-- --
  26. +-- You should have received a copy of the GNU General Public License and --
  27. +-- a copy of the GCC Runtime Library Exception along with this program; --
  28. +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
  29. +-- <http://www.gnu.org/licenses/>. --
  30. +-- --
  31. +-- GNARL was developed by the GNARL team at Florida State University. It is --
  32. +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
  33. +-- State University (http://www.gnat.com). --
  34. +-- --
  35. +------------------------------------------------------------------------------
  36. +
  37. +-- This is the OpenBSD THREADS version of this package
  38. +
  39. +with Interfaces.C; use Interfaces.C;
  40. +
  41. +package body System.OS_Interface is
  42. +
  43. + -----------
  44. + -- Errno --
  45. + -----------
  46. +
  47. + function Errno return int is
  48. + type int_ptr is access all int;
  49. +
  50. + function internal_errno return int_ptr;
  51. + pragma Import (C, internal_errno, "__errno");
  52. +
  53. + begin
  54. + return (internal_errno.all);
  55. + end Errno;
  56. +
  57. + --------------------
  58. + -- Get_Stack_Base --
  59. + --------------------
  60. +
  61. + function Get_Stack_Base (thread : pthread_t) return Address is
  62. + pragma Unreferenced (thread);
  63. + begin
  64. + return (0);
  65. + end Get_Stack_Base;
  66. +
  67. + ------------------
  68. + -- pthread_init --
  69. + ------------------
  70. +
  71. + procedure pthread_init is
  72. + begin
  73. + null;
  74. + end pthread_init;
  75. +
  76. + -----------------
  77. + -- To_Duration --
  78. + -----------------
  79. +
  80. + function To_Duration (TS : timespec) return Duration is
  81. + begin
  82. + return Duration (TS.ts_sec) + Duration (TS.ts_nsec) / 10#1#E9;
  83. + end To_Duration;
  84. +
  85. + ------------------------
  86. + -- To_Target_Priority --
  87. + ------------------------
  88. +
  89. + function To_Target_Priority
  90. + (Prio : System.Any_Priority) return Interfaces.C.int
  91. + is
  92. + begin
  93. + return Interfaces.C.int (Prio);
  94. + end To_Target_Priority;
  95. +
  96. + -----------------
  97. + -- To_Timespec --
  98. + -----------------
  99. +
  100. + function To_Timespec (D : Duration) return timespec is
  101. + S : time_t;
  102. + F : Duration;
  103. +
  104. + begin
  105. + S := time_t (Long_Long_Integer (D));
  106. + F := D - Duration (S);
  107. +
  108. + -- If F has negative value due to a round-up, adjust for positive F
  109. +
  110. + if F < 0.0 then
  111. + S := S - 1;
  112. + F := F + 1.0;
  113. + end if;
  114. +
  115. + return timespec'(ts_sec => S,
  116. + ts_nsec => long (Long_Long_Integer (F * 10#1#E9)));
  117. + end To_Timespec;
  118. +
  119. +end System.OS_Interface;