File: testsingle.adb

package info (click to toggle)
libspe2 2.2.80-95-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 940 kB
  • ctags: 1,214
  • sloc: ansic: 9,316; makefile: 551; ada: 448; sh: 24
file content (74 lines) | stat: -rw-r--r-- 1,667 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 -- 
 -- test functions: 
 --    spe_context_create 
 --    spe_image_open
 --    spe_program_load
 --    spe_context_run
 --    spe_context_destroy
 --    spe_image_close
 -- 
with System;
with Ada.Text_IO;
with Interfaces.C;
with libspe2;
with libspe2_types;

procedure testsingle is
  use System;
  use Ada.Text_IO;
  use Interfaces.C;
  use libspe2;
  use libspe2_types;

  ctx : spe_context_ptr_t;
  flags : unsigned := 0;
  gang : spe_gang_context_ptr_t;
  program : spe_program_handle_t;
  argp : addr_ptr := Null;
  envp : addr_ptr := Null;
  rc : Integer;

  spe_entry : unsigned := SPE_DEFAULT_ENTRY;
  spe_entry_ptr : unsigned_ptr := new unsigned'(spe_entry);
  stop_info_ptr : spe_stop_info_ptr := new spe_stop_info;

  filename : String (1 .. 5) := "hello";
  filename_c : char_array (1 .. 6);

begin
  filename_c := To_C (filename, True); 
  program := spe_image_open(filename_c);
  if program = NULL then
    Put_Line("spe_image_open failed!");
  end if;
 
  gang := Null;
  ctx := spe_context_create(flags, gang);
  if ctx = NULL then
    Put_Line("spe_context_create failed!");
  end if;

  rc := spe_program_load(ctx, program);
  if rc /= 0 then
    Put_Line("spe_program_load failed!");
  end if;

  rc := spe_context_run(ctx, spe_entry_ptr, 0, argp, envp, stop_info_ptr);
  Put_Line("exit_code: " & Integer'Image(stop_info_ptr.spe_exit_code));
  if rc /= 0 then
    Put_Line("spe_context_run failed!");
  end if;

  rc := spe_context_destroy (ctx); 
  if rc /= 0 then
    Put_Line("spe_context_destroy failed!");
  end if;
 
  rc := spe_image_close(program);
  if rc /= 0 then
    Put_Line("spe_image_close failed!");
  end if;

end testsingle;