aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2009-11-30 10:38:23 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2009-11-30 11:38:23 +0100
commitc84b434f46aabff791f59a45ec74c8b9a3cf32f2 (patch)
tree8b0a240aa8ed5792f527be14bd43e2be09bd2b77 /gcc
parente68c7b43067cf63f3783238073193ea2ab2fe525 (diff)
downloadgcc-c84b434f46aabff791f59a45ec74c8b9a3cf32f2.zip
gcc-c84b434f46aabff791f59a45ec74c8b9a3cf32f2.tar.gz
gcc-c84b434f46aabff791f59a45ec74c8b9a3cf32f2.tar.bz2
socket.c: Add more accessor functions for struct servent (need setters as well as getters).
2009-11-30 Bob Duff <duff@adacore.com> * socket.c: Add more accessor functions for struct servent (need setters as well as getters). * g-sothco.ads (Servent): Declare interfaces to C setter functions for struct servent. * g-sttsne-locking.adb (Copy_Service_Entry): Use setter functions for struct servent. From-SVN: r154777
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog9
-rw-r--r--gcc/ada/g-sothco.ads23
-rw-r--r--gcc/ada/g-sttsne-locking.adb30
-rw-r--r--gcc/ada/socket.c31
4 files changed, 81 insertions, 12 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index bde300e..ef5245b 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,12 @@
+2009-11-30 Bob Duff <duff@adacore.com>
+
+ * socket.c: Add more accessor functions for struct servent (need
+ setters as well as getters).
+ * g-sothco.ads (Servent): Declare interfaces to C setter functions for
+ struct servent.
+ * g-sttsne-locking.adb (Copy_Service_Entry): Use setter functions for
+ struct servent.
+
2009-11-30 Robert Dewar <dewar@adacore.com>
* s-stchop-vxworks.adb: Add comment.
diff --git a/gcc/ada/g-sothco.ads b/gcc/ada/g-sothco.ads
index ffa3e69..82003e2 100644
--- a/gcc/ada/g-sothco.ads
+++ b/gcc/ada/g-sothco.ads
@@ -225,13 +225,32 @@ package GNAT.Sockets.Thin_Common is
function Servent_S_Name
(E : Servent_Access) return C.Strings.chars_ptr;
+
function Servent_S_Aliases
(E : Servent_Access) return Chars_Ptr_Pointers.Pointer;
+
function Servent_S_Port
(E : Servent_Access) return C.int;
+
function Servent_S_Proto
(E : Servent_Access) return C.Strings.chars_ptr;
+ procedure Servent_Set_S_Name
+ (E : Servent_Access;
+ S_Name : C.Strings.chars_ptr);
+
+ procedure Servent_Set_S_Aliases
+ (E : Servent_Access;
+ S_Aliases : Chars_Ptr_Pointers.Pointer);
+
+ procedure Servent_Set_S_Port
+ (E : Servent_Access;
+ S_Port : C.int);
+
+ procedure Servent_Set_S_Proto
+ (E : Servent_Access;
+ S_Proto : C.Strings.chars_ptr);
+
------------------
-- Host entries --
------------------
@@ -347,4 +366,8 @@ private
pragma Import (C, Servent_S_Aliases, "__gnat_servent_s_aliases");
pragma Import (C, Servent_S_Port, "__gnat_servent_s_port");
pragma Import (C, Servent_S_Proto, "__gnat_servent_s_proto");
+ pragma Import (C, Servent_Set_S_Name, "__gnat_servent_set_s_name");
+ pragma Import (C, Servent_Set_S_Aliases, "__gnat_servent_set_s_aliases");
+ pragma Import (C, Servent_Set_S_Port, "__gnat_servent_set_s_port");
+ pragma Import (C, Servent_Set_S_Proto, "__gnat_servent_set_s_proto");
end GNAT.Sockets.Thin_Common;
diff --git a/gcc/ada/g-sttsne-locking.adb b/gcc/ada/g-sttsne-locking.adb
index 6225871..543281d 100644
--- a/gcc/ada/g-sttsne-locking.adb
+++ b/gcc/ada/g-sttsne-locking.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2007, AdaCore --
+-- Copyright (C) 2007-2009, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -206,14 +206,15 @@ package body GNAT.Sockets.Thin.Task_Safe_NetDB is
Source_Aliases : Chars_Ptr_Array
renames Chars_Ptr_Pointers.Value
- (Source_Servent.S_Aliases, Terminator => C.Strings.Null_Ptr);
+ (Servent_S_Aliases (Source_Servent),
+ Terminator => C.Strings.Null_Ptr);
-- Null-terminated list of aliases (last element of this array is
-- Null_Ptr).
begin
Result := -1;
- Names_Length := C.Strings.Strlen (Source_Servent.S_Name) + 1
- + C.Strings.Strlen (Source_Servent.S_Proto) + 1;
+ Names_Length := C.Strings.Strlen (Servent_S_Name (Source_Servent)) + 1 +
+ C.Strings.Strlen (Servent_S_Proto (Source_Servent)) + 1;
for J in Source_Aliases'Range loop
if Source_Aliases (J) /= C.Strings.Null_Ptr then
@@ -235,6 +236,8 @@ package body GNAT.Sockets.Thin.Task_Safe_NetDB is
Names_Index : size_t := Netdb_Data.Names'First;
-- Index of first available location in Netdb_Data.Names
+ Stored_Name : C.Strings.chars_ptr;
+
begin
if Netdb_Data'Size / 8 > Target_Buffer_Length then
return;
@@ -243,26 +246,29 @@ package body GNAT.Sockets.Thin.Task_Safe_NetDB is
-- Copy service name
Store_Name
- (C.Strings.Value (Source_Servent.S_Name),
+ (C.Strings.Value (Servent_S_Name (Source_Servent)),
Netdb_Data.Names, Names_Index,
- Target_Servent.S_Name);
+ Stored_Name);
+ Servent_Set_S_Name (Target_Servent, Stored_Name);
-- Copy aliases (null-terminated string pointer array)
- Target_Servent.S_Aliases :=
- Netdb_Data.Aliases_List
- (Netdb_Data.Aliases_List'First)'Unchecked_Access;
+ Servent_Set_S_Aliases
+ (Target_Servent,
+ Netdb_Data.Aliases_List
+ (Netdb_Data.Aliases_List'First)'Unchecked_Access);
-- Copy port number
- Target_Servent.S_Port := Source_Servent.S_Port;
+ Servent_Set_S_Port (Target_Servent, Servent_S_Port (Source_Servent));
-- Copy protocol name
Store_Name
- (C.Strings.Value (Source_Servent.S_Proto),
+ (C.Strings.Value (Servent_S_Proto (Source_Servent)),
Netdb_Data.Names, Names_Index,
- Target_Servent.S_Proto);
+ Stored_Name);
+ Servent_Set_S_Proto (Target_Servent, Stored_Name);
for J in Netdb_Data.Aliases_List'Range loop
if J = Netdb_Data.Aliases_List'Last then
diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c
index 0bc4b43..7675564 100644
--- a/gcc/ada/socket.c
+++ b/gcc/ada/socket.c
@@ -91,6 +91,10 @@ extern char * __gnat_servent_s_name (struct servent *);
extern char ** __gnat_servent_s_aliases (struct servent *);
extern int __gnat_servent_s_port (struct servent *);
extern char * __gnat_servent_s_proto (struct servent *);
+extern void __gnat_servent_set_s_name (struct servent *, char *);
+extern void __gnat_servent_set_s_aliases (struct servent *, char **);
+extern void __gnat_servent_set_s_port (struct servent *, int);
+extern void __gnat_servent_set_s_proto (struct servent *, char *);
#if defined (__vxworks) || defined (_WIN32)
extern int __gnat_inet_pton (int, const char *, void *);
#endif
@@ -535,6 +539,8 @@ __gnat_inet_pton (int af, const char *src, void *dst) {
* };
*/
+/* Getters */
+
char *
__gnat_servent_s_name (struct servent * s)
{
@@ -559,6 +565,31 @@ __gnat_servent_s_proto (struct servent * s)
return s->s_proto;
}
+/* Setters */
+
+void
+__gnat_servent_set_s_name (struct servent * s, char * s_name)
+{
+ s->s_name = s_name;
+}
+
+void
+__gnat_servent_set_s_aliases (struct servent * s, char ** s_aliases)
+{
+ s->s_aliases = s_aliases;
+}
+
+void
+__gnat_servent_set_s_port (struct servent * s, int s_port)
+{
+ s->s_port = s_port;
+}
+
+void
+__gnat_servent_set_s_proto (struct servent * s, char * s_proto)
+{
+ s->s_proto = s_proto;
+}
#else
# warning Sockets are not supported on this platform