~ubuntu-branches/ubuntu/saucy/nwchem/saucy

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/armci/src/locks/semaphores.c

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2012-02-09 20:02:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120209200241-jgk03qfsphal4ug2
Tags: 6.1-1
* New upstream release.

[ Michael Banck ]
* debian/patches/02_makefile_flags.patch: Updated.
* debian/patches/02_makefile_flags.patch: Use internal blas and lapack code.
* debian/patches/02_makefile_flags.patch: Define GCC4 for LINUX and LINUX64
  (Closes: #632611 and LP: #791308).
* debian/control (Build-Depends): Added openssh-client.
* debian/rules (USE_SCALAPACK, SCALAPACK): Removed variables (Closes:
  #654658).
* debian/rules (LIBDIR, USE_MPIF4, ARMCI_NETWORK): New variables.
* debian/TODO: New file.
* debian/control (Build-Depends): Removed libblas-dev, liblapack-dev and
  libscalapack-mpi-dev.
* debian/patches/04_show_testsuite_diff_output.patch: New patch, shows the
  diff output for failed tests.
* debian/patches/series: Adjusted.
* debian/testsuite: Optionally run all tests if "all" is passed as option.
* debian/rules: Run debian/testsuite with "all" if DEB_BUILD_OPTIONS
  contains "checkall".

[ Daniel Leidert ]
* debian/control: Used wrap-and-sort. Added Vcs-Svn and Vcs-Browser fields.
  (Priority): Moved to extra according to policy section 2.5.
  (Standards-Version): Bumped to 3.9.2.
  (Description): Fixed a typo.
* debian/watch: Added.
* debian/patches/03_hurd-i386_define_path_max.patch: Added.
  - Define MAX_PATH if not defines to fix FTBFS on hurd.
* debian/patches/series: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if HAVE_CONFIG_H
 
2
#   include "config.h"
 
3
#endif
 
4
 
 
5
/* $Id: semaphores.c,v 1.12 2005-03-10 19:11:23 vinodtipparaju Exp $ */
 
6
#include "semaphores.h"
 
7
#if HAVE_STDIO_H
 
8
#   include <stdio.h>
 
9
#endif
 
10
#if HAVE_UNISTD_H
 
11
#   include <unistd.h>
 
12
#endif
 
13
 
 
14
int num_sem_alloc=0;
 
15
void perror();
 
16
#ifdef SUN
 
17
int  fprintf();
 
18
void fflush();
 
19
int semget(),semctl();
 
20
#endif
 
21
 
 
22
#include "armcip.h"
 
23
 
 
24
struct sembuf sops;
 
25
int semaphoreID;
 
26
 
 
27
int SemGet(num_sem)
 
28
    int num_sem;
 
29
{
 
30
  semaphoreID = semget(IPC_PRIVATE,num_sem, IPC_CREAT | 0600);
 
31
  if(semaphoreID<0){
 
32
    fprintf(stderr," Semaphore Allocation Failed \nsuggestions to fix the problem: \n");
 
33
    fprintf(stderr," 1. run ipcs and ipcrm -s commands to clean any semaphore ids\n");
 
34
    fprintf(stderr," 2. verify if constant SEMMSL defined in file semaphore.h is set correctly for your system\n");
 
35
    fprintf(stderr," 3. recompile semaphore.c\n");
 
36
       sleep(1);
 
37
       perror("Error message from failed semget:");
 
38
       armci_die(" exiting ...", num_sem);
 
39
    }
 
40
       
 
41
    num_sem_alloc = num_sem;
 
42
    return(semaphoreID);
 
43
}
 
44
 
 
45
void SemInit(id,value)
 
46
    int id,value;
 
47
{
 
48
  int i, semid, num_sem;
 
49
  union semun semctl_arg;
 
50
 
 
51
    semctl_arg.val = value;
 
52
 
 
53
    if(id == ALL_SEMS){ semid = 0; num_sem = num_sem_alloc;}
 
54
      else { semid = id; num_sem = 1;}
 
55
 
 
56
    for(i=0; i< num_sem; i++){ 
 
57
       if( semctl(semaphoreID, semid, SETVAL,semctl_arg )<0){ 
 
58
         perror((char*)0);
 
59
         armci_die("SemInit error",id);
 
60
       }
 
61
       semid++;
 
62
    }
 
63
}
 
64
 
 
65
 
 
66
/*  release semaphore(s) */
 
67
void SemDel()
 
68
{
 
69
    union semun dummy;
 
70
 
 
71
    /* this is only to avoid compiler whinning about the unitialized variable*/
 
72
    dummy.val=0; 
 
73
 
 
74
    (void) semctl(semaphoreID,0,IPC_RMID,dummy);
 
75
}
 
76
 
 
77
 
 
78
void Sem_CreateInitLocks(int num, lockset_t *id)
 
79
{
 
80
     *id = SemGet(num);
 
81
     SemInit(ALL_SEMS,1);
 
82
}
 
83
 
 
84
 
 
85
void Sem_InitLocks(int num, lockset_t id)
 
86
{
 
87
    semaphoreID = id;
 
88
    num_sem_alloc = num;
 
89
}
 
90
 
 
91
 
 
92
void Sem_DeleteLocks(lockset_t id)
 
93
{
 
94
    union semun dummy;
 
95
 
 
96
    /* this is only to avoid compiler whinning about the unitialized variable*/
 
97
    dummy.val=0; 
 
98
 
 
99
    (void) semctl(id,0,IPC_RMID,dummy);
 
100
}
 
101
 
 
102