Rombobjörn

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build_milter_api.gpr.in15
-rw-r--r--milter_api-start_wrapping.off.adb17
-rw-r--r--milter_api-start_wrapping.on.adb20
-rw-r--r--milter_api.adb6
-rw-r--r--test/test_milter.adb1
-rw-r--r--test/thread_wrapping.adb21
-rw-r--r--test/thread_wrapping.ads13
7 files changed, 57 insertions, 36 deletions
diff --git a/build_milter_api.gpr.in b/build_milter_api.gpr.in
index dfa8334..318b55e 100644
--- a/build_milter_api.gpr.in
+++ b/build_milter_api.gpr.in
@@ -13,9 +13,17 @@ library project Build_Milter_API is
Version := "1.2.1";
+ #if Wrap_Threads then
+ Wrap_Flag := "-w";
+ On_Or_Off := "on";
+ #else
+ Wrap_Flag := "";
+ On_Or_Off := "off";
+ #end if;
+
for Library_Name use "adamilter";
for Library_Kind use "dynamic";
- for Library_Version use "libadamilter.so." & Version;
+ for Library_Version use "libadamilter-" & Version & Wrap_Flag & ".so.0";
for Languages use ("Ada", "C");
for Library_Interface use ("Milter_API", "Berkeley_Exit_Codes");
for Object_Dir use Comfignat.Objdir;
@@ -23,6 +31,11 @@ library project Build_Milter_API is
for Library_Dir use Comfignat.Stage_Libdir;
for Library_ALI_Dir use Comfignat.Stage_Libdir & "/adamilter";
+ package Naming is
+ for body("Milter_API.Start_Wrapping") use
+ "milter_api-start_wrapping." & On_Or_Off & ".adb";
+ end Naming;
+
package Compiler is
for Default_Switches ("Ada") use ("-gnato");
end Compiler;
diff --git a/milter_api-start_wrapping.off.adb b/milter_api-start_wrapping.off.adb
new file mode 100644
index 0000000..c93b438
--- /dev/null
+++ b/milter_api-start_wrapping.off.adb
@@ -0,0 +1,17 @@
+-- Ada Milter API, a binding to Libmilter, the Sendmail mail filtering API
+-- Copyright 2013 B. Persson, Bjorn@Rombobeorn.se
+--
+-- This library is free software: you can redistribute it and/or modify it
+-- under the terms of the GNU General Public License version 3, as published
+-- by the Free Software Foundation.
+
+
+-- Thread wrapping is disabled when this file is used, so Start_Wrapping does
+-- nothing.
+
+
+separate(Milter_API)
+procedure Start_Wrapping is
+begin
+ null;
+end Start_Wrapping;
diff --git a/milter_api-start_wrapping.on.adb b/milter_api-start_wrapping.on.adb
new file mode 100644
index 0000000..7eb699c
--- /dev/null
+++ b/milter_api-start_wrapping.on.adb
@@ -0,0 +1,20 @@
+-- Ada Milter API, a binding to Libmilter, the Sendmail mail filtering API
+-- Copyright 2013 B. Persson, Bjorn@Rombobeorn.se
+--
+-- This library is free software: you can redistribute it and/or modify it
+-- under the terms of the GNU General Public License version 3, as published
+-- by the Free Software Foundation.
+
+
+-- Thread wrapping is enabled when this file is used, so Start_Wrapping calls
+-- start_wrapping_threads in libadamilter_thread_wrapper, which must be linked
+-- into the main executable.
+
+
+separate(Milter_API)
+procedure Start_Wrapping is
+ procedure start_wrapping_threads;
+ pragma import(C, start_wrapping_threads);
+begin
+ start_wrapping_threads;
+end Start_Wrapping;
diff --git a/milter_api.adb b/milter_api.adb
index f68b07a..f89a873 100644
--- a/milter_api.adb
+++ b/milter_api.adb
@@ -717,10 +717,16 @@ package body Milter_API is
Check_For_Error("smfi_opensocket", smfi_opensocket(I(Remove_Old_Socket)));
end Open_Socket;
+ procedure Start_Wrapping is separate;
+ -- If thread wrapping was enabled at compile time, then Start_Wrapping tells
+ -- the thread wrapper to start wrapping threads. Otherwise it does nothing.
+ pragma Inline_Always(Start_Wrapping);
+
procedure Main is
function smfi_main return int;
pragma import(C, smfi_main);
begin
+ Start_Wrapping;
Check_For_Error("smfi_main", smfi_main);
end Main;
diff --git a/test/test_milter.adb b/test/test_milter.adb
index 2cf2ed1..c903576 100644
--- a/test/test_milter.adb
+++ b/test/test_milter.adb
@@ -7,7 +7,6 @@
with Test_Milter_Package;
-with Thread_Wrapping;
with Ada.Command_Line;
with System_Log; use System_Log;
diff --git a/test/thread_wrapping.adb b/test/thread_wrapping.adb
deleted file mode 100644
index 75201e0..0000000
--- a/test/thread_wrapping.adb
+++ /dev/null
@@ -1,21 +0,0 @@
--- The Ada Milter API test milter
--- Copyright 2013 B. Persson, Bjorn@Rombobeorn.se
---
--- This program is free software: you can redistribute it and/or modify it
--- under the terms of the GNU General Public License version 3, as published
--- by the Free Software Foundation.
-
-
--- GNAT.Threads must be ready for use before wrapping of threads can begin.
-with GNAT.Threads;
-pragma Elaborate_All(GNAT.Threads);
-pragma Unreferenced(GNAT.Threads);
-
-package body Thread_Wrapping is
-
- procedure Start_Wrapping_Threads;
- pragma import(C, Start_Wrapping_Threads, "start_wrapping_threads");
-
-begin
- Start_Wrapping_Threads;
-end Thread_Wrapping;
diff --git a/test/thread_wrapping.ads b/test/thread_wrapping.ads
deleted file mode 100644
index a7e3487..0000000
--- a/test/thread_wrapping.ads
+++ /dev/null
@@ -1,13 +0,0 @@
--- The Ada Milter API test milter
--- Copyright 2013 B. Persson, Bjorn@Rombobeorn.se
---
--- This program is free software: you can redistribute it and/or modify it
--- under the terms of the GNU General Public License version 3, as published
--- by the Free Software Foundation.
-
-
-package Thread_Wrapping is
- pragma Elaborate_Body;
- -- Elaborating the spec and the body together isn't important, but without
- -- this pragma this package wouldn't be allowed to have a body.
-end Thread_Wrapping;