Permalink
Browse files

Initial commit of the Ada FCP2 library, named AdaFN.

git-svn-id: file:///home/toad/git-migration/temprepository/trunk/apps/AdaFN@18796 67a373e5-eb02-0410-a15c-ee090a768436
  • Loading branch information...
0 parents commit 417bb2a673da682ee2a4207444fd986332c04911 mosteo committed Mar 27, 2008
Showing 530 changed files with 68,100 additions and 0 deletions.
No changes.
@@ -0,0 +1,7 @@
+The AdaFN library is licensed under GPLv3 license:
+
+http://www.gnu.org/licenses/gpl-3.0.html
+
+The "or later" option is explicitly rejected for AdaFN. Any remainding license notices in source files are to be discarded in favor of this manifest.
+
+Other licensing options (e.g. GPLv2/CC compatible licensing or commercial licensing) will be considered on request.
@@ -0,0 +1,30 @@
+.PHONY: all lib clean
+
+PARAMS=-XHungarian_Include_Base=No -XAgpl_Include_PngIO=No -XAgpl_Include_Boost=No -XAgpl_Include_Concorde=No
+
+PARAMSBIN=${PARAMS} -Padafn -XAdaFN_Link=Dependencies
+
+PARAMSLIB=${PARAMS} -Padafn -XAdaFN_Link=Static_Library
+
+all:
+ gprmake ${PARAMSBIN} adafn_getkey
+ gprmake ${PARAMSBIN} adafn_putfile
+ gprmake ${PARAMSBIN} adafn_putdir
+ gprmake ${PARAMSBIN} adafn_test
+
+lib:
+ # NOTE: you don't need to build the library. Just "with" the project file in your project and choose the appropriate linking type.
+ # This makefile is provided only as a way to check the build and build the utils
+ #
+ # gprmake builds the C and C++ files
+ #
+ gprmake ${PARAMSLIB}
+ #
+ # gnatmake builds all the Ada files and does the linking
+ # I think gprmake should do this too, since it does when a main procedure is specified. Bug?
+ #
+ gnatmake ${PARAMSLIB}
+
+clean:
+ gnatclean -r -q ${PARAMSBIN}
+ gnatclean -r -q ${PARAMSLIB}
16 README
@@ -0,0 +1,16 @@
+This is an Ada library implementing the FCP2 protocol for communication with a freenet node.
+
+This library is developed with GNAT and this instructions are specific for that compiler.
+
+Usage: with the adafn.gpr project file in your own project file.
+
+Alternatively: issue
+
+ make
+to build the example executables (tests folder).
+
+ make lib
+to build a statically linkable library.
+
+Tested works with gnat-gpl-2007
+Tested does not work with gnat-4.1/4.2 (Preelaborable_Initialization pragma still unimplemented in gnat).
106 adafn.gpr
@@ -0,0 +1,106 @@
+with "agpl/agpl";
+
+project AdaFN is
+
+ type Boolean is ("True", "False");
+ type Enabled_Disabled is ("Enabled", "Disabled");
+ type Yes_No is ("Yes", "No");
+
+ Lib_Name := "adafn";
+ Lib_Version := "20080324";
+
+ for Object_Dir use "obj";
+ for Source_Dirs use ();
+
+ for Languages use ("Ada");
+
+ type Build_Type is ("Debug", "Release", "No_Options", "Profile");
+ type Linking_Type is ("Dependencies", "Static_Library", "Dynamic_Library");
+
+ Build : Build_Type := external ("AdaFN_Build", "Debug");
+ Link : Linking_Type := External ("AdaFN_Link", "Dependencies");
+
+ case Link is
+ when "Dependencies" =>
+ null;
+ when "Static_Library" =>
+ for Library_Dir use "libstatic";
+ for Library_Name use Lib_Name;
+ for Library_Kind use "Static";
+ for Library_Version use Lib_Name & ".a." & Lib_Version;
+ when "Dynamic_Library" =>
+ for Library_Dir use "libdynamic";
+ for Library_Name use Lib_Name;
+ for Library_Kind use "Dynamic";
+ for Library_Version use Lib_Name & ".so." & Lib_Version;
+ end case;
+
+ Include_Core : Yes_No := external ("AdaFN_Include_Core", "Yes");
+ Include_Main : Yes_No := external ("AdaFN_Include_Main", "Yes");
+
+ case Include_Core is
+ when "Yes" => for Source_Dirs use ("src");
+ when "No" => null;
+ end case;
+
+ case Include_Main is
+ when "Yes" => for Source_Dirs use project'Source_Dirs & "src/main";
+ when "No" => null;
+ end case;
+
+ package Ide is
+ for Vcs_Kind use "Subversion";
+ end Ide;
+
+ package Compiler is
+ for Default_Switches ("C") use ("-g", "-Wall", "-O2");
+ for Default_Switches ("C++") use ("-g", "-Wall", "-O2");
+ for Default_Switches ("Ada") use ("-g", "-gnatf", "-gnat05", "-gnatwcfjklmopruvz", "-gnatyacehikn", "-gnatqQ");
+
+ case Build is
+ when "Profile" =>
+ for Default_Switches ("Ada") use Compiler'Default_Switches ("Ada") &
+ ("-O2", "-gnato", "-fstack-check", "-gnata", "-gnatpg");
+ when "Debug" =>
+ for Default_Switches ("Ada") use Compiler'Default_Switches ("Ada") &
+ ("-O2", "-gnato", "-fstack-check", "-gnata");
+ when "Release" =>
+ for Default_Switches ("Ada") use Compiler'Default_Switches ("Ada") & ("-O3", "-gnatn", "-gnatN");
+ for Default_Switches ("C") use Compiler'Default_Switches ("C") & ("-O3");
+ for Default_Switches ("C++") use Compiler'Default_Switches ("C") & ("-O3");
+ when "No_Options" =>
+ for Default_Switches ("Ada") use ("-gnat05");
+ -- Deliberately override default switches not to have any!
+ end case;
+ end Compiler;
+
+ package Binder is
+ for Default_Switches ("Ada") use ("-E", "-g");
+ end Binder;
+
+ package Linker is
+ for Default_Switches ("Ada") use ("-g", "-Wl,--gc-sections");
+ for Default_Switches ("C") use ("-g");
+ for Default_Switches ("C++") use ("-g");
+ end Linker;
+
+ package Builder is
+ for Default_Switches ("Ada") use ("-g");
+ end Builder;
+
+ package Pretty_Printer is
+ for Default_Switches ("Ada") use ("-A1", "-A2", "-A3", "-A4");
+ end Pretty_Printer;
+
+ package Naming is
+ for Specification_Suffix ("C") use ".h";
+ for Implementation_Suffix ("C") use ".c";
+ for Specification_Suffix ("C++") use ".hh";
+ for Implementation_Suffix ("C++") use ".cpp";
+ for Implementation_Suffix ("C++") use ".cc";
+ for Specification_Suffix ("Changelog") use "changelog";
+ for Specification_Suffix ("Project file") use ".gpr";
+ for Specification_Suffix ("Python") use ".py";
+ end Naming;
+
+end AdaFN;
@@ -0,0 +1,74 @@
+-- The Ada Structured Library - A set of container classes and general
+-- tools for use with Ada95.
+-- Copyright (C) 1998-1999 Corey Minyard (minyard@acm.org)
+--
+-- This library is free software; you can redistribute it and/or modify it
+-- under the terms of the GNU General Public License as published by the
+-- Free Software Foundation; either version 2 of the License, or (at your
+-- option) any later version.
+--
+-- This library is distributed in the hope that it will be useful, but
+-- WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along
+-- with this library; if not, write to the Free Software Foundation, Inc.,
+-- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+--
+-- As a special exception, if other files instantiate generics from this
+-- unit, or you link this unit with other files to produce an executable,
+-- this unit does not by itself cause the resulting executable to be
+-- covered by the GNU General Public License. This exception does not
+-- however invalidate any other reasons why the executable file might be
+-- covered by the GNU Public License.
+--
+
+package body Asl.Semaphore.Counting is
+
+ ------------------------------------------------------------------------
+ procedure Take (O : in out Object) is
+ begin
+ O.The_Mutex.Wait;
+ end Take;
+
+ ------------------------------------------------------------------------
+ procedure Give (O : in out Object) is
+ begin
+ O.The_Mutex.Release;
+ end Give;
+
+ ------------------------------------------------------------------------
+ procedure Try_To_Take (O : in out Object;
+ Success : out Boolean;
+ Timeout : in Duration := 0.0) is
+ begin
+ select
+ O.The_Mutex.Wait;
+ Success := True;
+ or
+ delay Timeout;
+ Success := False;
+ end select;
+ end Try_To_Take;
+
+
+ ------------------------------------------------------------------------
+ ------------------------------------------------------------------------
+ protected body Mutex is
+
+ ---------------------------------------------------------------------
+ entry Wait when (Count > 0) is
+ begin
+ Count := Count - 1;
+ end Wait;
+
+ ---------------------------------------------------------------------
+ procedure Release is
+ begin
+ Count := Count + 1;
+ end Release;
+
+ end Mutex;
+
+end Asl.Semaphore.Counting;
@@ -0,0 +1,65 @@
+-- The Ada Structured Library - A set of container classes and general
+-- tools for use with Ada95.
+-- Copyright (C) 1998-1999 Corey Minyard (minyard@acm.org)
+--
+-- This library is free software; you can redistribute it and/or modify it
+-- under the terms of the GNU General Public License as published by the
+-- Free Software Foundation; either version 2 of the License, or (at your
+-- option) any later version.
+--
+-- This library is distributed in the hope that it will be useful, but
+-- WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along
+-- with this library; if not, write to the Free Software Foundation, Inc.,
+-- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+--
+-- As a special exception, if other files instantiate generics from this
+-- unit, or you link this unit with other files to produce an executable,
+-- this unit does not by itself cause the resulting executable to be
+-- covered by the GNU General Public License. This exception does not
+-- however invalidate any other reasons why the executable file might be
+-- covered by the GNU Public License.
+--
+
+-- A standard counting semaphore. The initial count is specified when the
+-- semaphore is declared. The Take operation will block is the count is
+-- zero, otherwise Take will decremenet the count. Give will always
+-- increment the count.
+
+package Asl.Semaphore.Counting is
+
+ type Object (Initial_Count : Natural) is
+ new Asl.Semaphore.Object with private;
+ type Object_Ptr is access all Object;
+
+ -- Claim the semaphore. Will block until the semaphore is available.
+ procedure Take (O : in out Object);
+
+ -- Release the semaphore.
+ procedure Give (O : in out Object);
+
+ -- Try to take the semaphore, but return an error if not successful.
+ -- Returns True if the semaphore was claimed and False if not. This
+ -- will wait up to Timeout time for the semaphore to become available.
+ procedure Try_To_Take (O : in out Object;
+ Success : out Boolean;
+ Timeout : in Duration := 0.0);
+
+private
+
+ protected type Mutex (Initial_Count : Natural) is
+ entry Wait;
+ procedure Release;
+ private
+ Count : Natural := Initial_Count;
+ end Mutex;
+
+ type Object (Initial_Count : Natural) is
+ new Asl.Semaphore.Object with record
+ The_Mutex : Mutex(Initial_Count);
+ end record;
+
+end Asl.Semaphore.Counting;
@@ -0,0 +1,51 @@
+-- The Ada Structured Library - A set of container classes and general
+-- tools for use with Ada95.
+-- Copyright (C) 1998-1999 Corey Minyard (minyard@acm.org)
+--
+-- This library is free software; you can redistribute it and/or modify it
+-- under the terms of the GNU General Public License as published by the
+-- Free Software Foundation; either version 2 of the License, or (at your
+-- option) any later version.
+--
+-- This library is distributed in the hope that it will be useful, but
+-- WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along
+-- with this library; if not, write to the Free Software Foundation, Inc.,
+-- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+--
+-- As a special exception, if other files instantiate generics from this
+-- unit, or you link this unit with other files to produce an executable,
+-- this unit does not by itself cause the resulting executable to be
+-- covered by the GNU General Public License. This exception does not
+-- however invalidate any other reasons why the executable file might be
+-- covered by the GNU Public License.
+--
+
+package Asl.Semaphore is
+
+ type Object is abstract tagged limited private;
+ type Object_Class is access all Object'Class;
+
+ -- Claim the semaphore. Will block until the semaphore is available.
+ procedure Take (O : in out Object)
+ is abstract;
+
+ -- Release the semaphore.
+ procedure Give (O : in out Object)
+ is abstract;
+
+ -- Try to take the semaphore, but return an error if not successful.
+ -- Returns True if the semaphore was claimed and False if not.
+ procedure Try_To_Take (O : in out Object;
+ Success : out Boolean;
+ Timeout : in Duration := 0.0)
+ is abstract;
+
+private
+
+ type Object is abstract tagged limited null record;
+
+end Asl.Semaphore;
@@ -0,0 +1,29 @@
+-- The Ada Structured Library - A set of container classes and general
+-- tools for use with Ada95.
+-- Copyright (C) 1998-1999 Corey Minyard (minyard@acm.org)
+--
+-- This library is free software; you can redistribute it and/or modify it
+-- under the terms of the GNU General Public License as published by the
+-- Free Software Foundation; either version 2 of the License, or (at your
+-- option) any later version.
+--
+-- This library is distributed in the hope that it will be useful, but
+-- WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along
+-- with this library; if not, write to the Free Software Foundation, Inc.,
+-- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+--
+-- As a special exception, if other files instantiate generics from this
+-- unit, or you link this unit with other files to produce an executable,
+-- this unit does not by itself cause the resulting executable to be
+-- covered by the GNU General Public License. This exception does not
+-- however invalidate any other reasons why the executable file might be
+-- covered by the GNU Public License.
+--
+
+package Asl is
+ pragma Pure;
+end Asl;
Oops, something went wrong.

0 comments on commit 417bb2a

Please sign in to comment.